Inital commit

This commit is contained in:
2020-11-19 15:36:28 +01:00
parent 71f32f83d3
commit 66ce4ee218
18077 changed files with 2166122 additions and 35184 deletions

View File

@@ -0,0 +1,33 @@
<?php
/**
* Created by PhpStorm.
* User: audreymartel
* Date: 27/07/2018
* Time: 15:51
*/
namespace OrderCreation\Form;
use OrderCreation\OrderCreation;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Thelia\Form\BaseForm;
class ConfigurationForm extends BaseForm
{
protected function buildForm()
{
$this->formBuilder
->add(
'order_creation_delivery_module_id',
TextType::class,
[
'label' => $this->translator->trans("Delivery module use to create order in back office", [], OrderCreation::MESSAGE_DOMAIN),
'label_attr' => array(
'help' => $this->translator->trans('Leave blank to select delivery module on each order', [], OrderCreation::MESSAGE_DOMAIN)
),
'data' => OrderCreation::getConfigValue('order_creation_delivery_module_id'),
'constraints' => [],
]
);
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* Created by PhpStorm.
* User: audreymartel
* Date: 27/07/2018
* Time: 15:51
*/
namespace OrderCreation\Form;
use OrderCreation\OrderCreation;
use OrderCreation\OrderCreationConfiguration;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Thelia\Form\BaseForm;
use Thelia\Model\Module;
use Thelia\Model\ModuleQuery;
class ConfigurationRedirectsPayementForm extends BaseForm
{
protected function buildForm()
{
$this->formBuilder
->add(
'order_creation_redirects_payment',
ChoiceType::class,
[
'label' => $this->translator->trans(
"Select all redirectable payment modules",
[],
OrderCreation::MESSAGE_DOMAIN
),
'expanded' => true,
'multiple' => true,
'choices' => $this->getPaymentModuleList(),
'data' => $this->getSelectedModule(),
]
);
}
private function getPaymentModuleList()
{
$modules = ModuleQuery::create()
->filterByType(3)
->filterByActivate(1)
->find();
if (0 != count($modules->getData())) {
$tabChoices = [];
/** @var Module $module */
foreach ($modules->getData() as $module) {
$tabChoices[$module->getId()] = $module->getCode();
}
return $tabChoices;
} else {
return [];
}
}
private function getSelectedModule()
{
$listModules = OrderCreationConfiguration::getlistPaymentModule();
return json_decode($listModules);
}
}

View File

@@ -0,0 +1,197 @@
<?php
/**
* Created by PhpStorm.
* User: gbarral
* Date: 28/08/2014
* Time: 11:02
*/
namespace OrderCreation\Form;
use OrderCreation\OrderCreation;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Validator\Constraints\GreaterThan;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Form\BaseForm;
use Thelia\Model\Sale;
class OrderCreationCreateForm extends BaseForm
{
const FIELD_NAME_CUSTOMER_ID = 'customer_id';
const FIELD_NAME_DELIVERY_ADDRESS_ID = 'delivery_address_id';
const FIELD_NAME_INVOICE_ADDRESS_ID = 'invoice_address_id';
const FIELD_NAME_DELIVERY_MODULE_ID = 'delivery-module';
const FIELD_NAME_PAYMENT_MODULE_ID = 'payment_module_id';
const FIELD_NAME_PRODUCT_SALE_ELEMENT_ID = 'product_sale_element_id';
const FIELD_NAME_QUANTITY = 'quantity';
const FIELD_DISCOUNT_TYPE = 'discount_type';
const FIELD_DISCOUNT_PRICE = 'discount_price';
const FIELD_CHECK_REDIRECTS_PAYMENT = 'redirects_payment';
protected function buildForm()
{
$this->formBuilder
->add(
self::FIELD_NAME_CUSTOMER_ID,
IntegerType::class,
[
'constraints' => [
new NotBlank()
],
'label' => $this->translator->trans("Customer", [], OrderCreation::MESSAGE_DOMAIN),
'label_attr' => [
'for' => self::FIELD_NAME_CUSTOMER_ID . '_form'
]
]
)
->add(
self::FIELD_NAME_DELIVERY_ADDRESS_ID,
IntegerType::class,
[
'constraints' => [
new NotBlank()
],
'label' => $this->translator->trans("Delivery address", [], OrderCreation::MESSAGE_DOMAIN),
'label_attr' => [
'for' => self::FIELD_NAME_DELIVERY_ADDRESS_ID . '_form'
]
]
)
->add(
self::FIELD_NAME_INVOICE_ADDRESS_ID,
IntegerType::class,
[
'constraints' => [
new NotBlank()
],
'label' => $this->translator->trans("Invoice address", [], OrderCreation::MESSAGE_DOMAIN),
'label_attr' => [
'for' => self::FIELD_NAME_INVOICE_ADDRESS_ID . '_form'
]
]
)
->add(
self::FIELD_NAME_DELIVERY_MODULE_ID,
IntegerType::class,
[
'constraints' => [
new NotBlank()
],
'label' => $this->translator->trans("Transport solution", [], OrderCreation::MESSAGE_DOMAIN),
'label_attr' => [
'for' => self::FIELD_NAME_DELIVERY_MODULE_ID . '_form'
]
]
)
->add(
self::FIELD_NAME_PAYMENT_MODULE_ID,
IntegerType::class,
[
'constraints' => [
new NotBlank()
],
'label' => $this->translator->trans("Payment solution", [], OrderCreation::MESSAGE_DOMAIN),
'label_attr' => [
'for' => self::FIELD_NAME_PAYMENT_MODULE_ID . '_form'
]
]
)
->add(
self::FIELD_NAME_PRODUCT_SALE_ELEMENT_ID,
CollectionType::class,
[
'type' => 'number',
'label' => $this->translator->trans('Product', [], OrderCreation::MESSAGE_DOMAIN),
'label_attr' => [
'for' => self::FIELD_NAME_PRODUCT_SALE_ELEMENT_ID . '_form'
],
'allow_add' => true,
'allow_delete' => true,
]
)
->add(
self::FIELD_NAME_QUANTITY,
CollectionType::class,
[
'type' => 'number',
'label' => $this->translator->trans('Quantity', [], OrderCreation::MESSAGE_DOMAIN),
'label_attr' => [
'for' => self::FIELD_NAME_QUANTITY . '_form'
],
'allow_add' => true,
'allow_delete' => true,
'options' => [
'constraints' => [
new NotBlank(),
new GreaterThan(
['value' => 0]
)
]
]
]
)
->add(
self::FIELD_DISCOUNT_TYPE,
ChoiceType::class,
[
'constraints' => [ new NotBlank() ],
'choices' => [
Sale::OFFSET_TYPE_AMOUNT => $this->translator->trans('Constant amount', [], 'core'),
Sale::OFFSET_TYPE_PERCENTAGE => $this->translator->trans('Percentage', [], 'core'),
],
'required' => true,
'label' => $this->translator->trans('Discount type', [], OrderCreation::MESSAGE_DOMAIN),
'label_attr' => [
'for' => self::FIELD_DISCOUNT_TYPE,
'help' => $this->translator->trans('Select the discount type that will be applied to the order price', [], OrderCreation::MESSAGE_DOMAIN),
],
'attr' => []
]
)
->add(
self::FIELD_DISCOUNT_PRICE,
NumberType::class,
[
'required' => false,
'constraints' => [],
'label' => $this->translator->trans('Discount value', [], OrderCreation::MESSAGE_DOMAIN),
'attr' => [
'placeholder' => $this->translator->trans('Discount included taxes', [], OrderCreation::MESSAGE_DOMAIN)
],
'label_attr' => [
'for' => self::FIELD_DISCOUNT_PRICE,
'help' => $this->translator->trans('You can define here a specific discount, as a percentage or a constant amount, depending on the selected discount type.', [], OrderCreation::MESSAGE_DOMAIN),
],
]
)
->add(
self::FIELD_CHECK_REDIRECTS_PAYMENT,
"checkbox",
[
"label" => $this->translator->trans('Go to payment page after order creation', [], OrderCreation::MESSAGE_DOMAIN),
'label_attr' => [
'for' => self::FIELD_CHECK_REDIRECTS_PAYMENT,
'help' => $this->translator->trans('Check this box if you want to pay the order with the selected payment module ', [], OrderCreation::MESSAGE_DOMAIN),
],
"required" => false,
"value" => false,
]
)
;
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
//This name MUST be the same that the form OrderDelivery (because of ajax delivery module return)
return "thelia_order_delivery";
}
}