From c51923cc1b7f47f121795320987e36995a209ef8 Mon Sep 17 00:00:00 2001 From: TheCoreDev Date: Thu, 11 Nov 2021 14:50:21 +0100 Subject: [PATCH] Correction d'un bogue sur prise en compte de la LivraisonForfaitaire dans OrderCreation --- .../AdminOrderCreation/AdminOrderCreation.php | 68 -- local/modules/AdminOrderCreation/CHANGELOG.md | 7 - .../AdminOrderCreation/Config/config.xml | 21 - .../AdminOrderCreation/Config/module.xml | 28 - .../AdminOrderCreation/Config/routing.xml | 18 - .../AdminOrderCreation/Config/schema.xml | 30 - .../Controller/OrderController.php | 803 ------------------ .../Form/OrderCreateForm.php | 213 ----- .../Hook/Back/OrderEditHook.php | 22 - .../Hook/Back/OrderHook.php | 35 - .../I18n/backOffice/default/fr_FR.php | 61 -- .../modules/AdminOrderCreation/I18n/en_US.php | 4 - .../modules/AdminOrderCreation/I18n/fr_FR.php | 4 - local/modules/AdminOrderCreation/LICENSE | 21 - .../AdminOrderCreation/Model/Order.php | 63 -- local/modules/AdminOrderCreation/Readme.md | 24 - .../modules/AdminOrderCreation/Util/Calc.php | 39 - .../Util/CriteriaSearchTrait.php | 54 -- .../modules/AdminOrderCreation/composer.json | 13 - .../ajax/order-create-modal-success.html | 5 - .../ajax/order-create-modal.html | 592 ------------- .../admin-order-creation/assets/js/script.js | 465 ---------- .../hook/orders.edit.js.html | 17 - .../admin-order-creation/hook/orders.js.html | 56 -- .../hook/orders.table-header.html | 3 - .../include/product-line.html | 152 ---- .../Admin/OrderCreationAdminController.php | 3 +- .../backOffice/default/customer-edit-js.html | 4 +- .../default/forms/create-order-form.html | 3 +- 29 files changed, 6 insertions(+), 2822 deletions(-) delete mode 100644 local/modules/AdminOrderCreation/AdminOrderCreation.php delete mode 100644 local/modules/AdminOrderCreation/CHANGELOG.md delete mode 100644 local/modules/AdminOrderCreation/Config/config.xml delete mode 100644 local/modules/AdminOrderCreation/Config/module.xml delete mode 100644 local/modules/AdminOrderCreation/Config/routing.xml delete mode 100644 local/modules/AdminOrderCreation/Config/schema.xml delete mode 100644 local/modules/AdminOrderCreation/Controller/OrderController.php delete mode 100644 local/modules/AdminOrderCreation/Form/OrderCreateForm.php delete mode 100644 local/modules/AdminOrderCreation/Hook/Back/OrderEditHook.php delete mode 100644 local/modules/AdminOrderCreation/Hook/Back/OrderHook.php delete mode 100644 local/modules/AdminOrderCreation/I18n/backOffice/default/fr_FR.php delete mode 100644 local/modules/AdminOrderCreation/I18n/en_US.php delete mode 100644 local/modules/AdminOrderCreation/I18n/fr_FR.php delete mode 100644 local/modules/AdminOrderCreation/LICENSE delete mode 100644 local/modules/AdminOrderCreation/Model/Order.php delete mode 100644 local/modules/AdminOrderCreation/Readme.md delete mode 100644 local/modules/AdminOrderCreation/Util/Calc.php delete mode 100644 local/modules/AdminOrderCreation/Util/CriteriaSearchTrait.php delete mode 100644 local/modules/AdminOrderCreation/composer.json delete mode 100644 local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/ajax/order-create-modal-success.html delete mode 100644 local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/ajax/order-create-modal.html delete mode 100644 local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/assets/js/script.js delete mode 100644 local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.edit.js.html delete mode 100644 local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.js.html delete mode 100644 local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.table-header.html delete mode 100644 local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/include/product-line.html diff --git a/local/modules/AdminOrderCreation/AdminOrderCreation.php b/local/modules/AdminOrderCreation/AdminOrderCreation.php deleted file mode 100644 index 5aa5f8dcc..000000000 --- a/local/modules/AdminOrderCreation/AdminOrderCreation.php +++ /dev/null @@ -1,68 +0,0 @@ - - - - - -
- - - - - - - - - - - - - diff --git a/local/modules/AdminOrderCreation/Config/module.xml b/local/modules/AdminOrderCreation/Config/module.xml deleted file mode 100644 index 92ce01bce..000000000 --- a/local/modules/AdminOrderCreation/Config/module.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - AdminOrderCreation\AdminOrderCreation - - Module for generate an order from the back office - - - Module pour générer des commandes depuis le back office - - - en_US - fr_FR - - 1.3.4 - - - Gilles Bourgeat - gilles.bourgeat@gmail.com - - - classic - 2.3.0 - beta - 0 - 0 - diff --git a/local/modules/AdminOrderCreation/Config/routing.xml b/local/modules/AdminOrderCreation/Config/routing.xml deleted file mode 100644 index d82805c26..000000000 --- a/local/modules/AdminOrderCreation/Config/routing.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - AdminOrderCreation:Order:ajaxModalCreate - - - - AdminOrderCreation:Order:ajaxSearchCustomer - - - - AdminOrderCreation:Order:ajaxSearchProduct - - diff --git a/local/modules/AdminOrderCreation/Config/schema.xml b/local/modules/AdminOrderCreation/Config/schema.xml deleted file mode 100644 index 3b9818e79..000000000 --- a/local/modules/AdminOrderCreation/Config/schema.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - diff --git a/local/modules/AdminOrderCreation/Controller/OrderController.php b/local/modules/AdminOrderCreation/Controller/OrderController.php deleted file mode 100644 index b0e776618..000000000 --- a/local/modules/AdminOrderCreation/Controller/OrderController.php +++ /dev/null @@ -1,803 +0,0 @@ -checkAuth(AdminResources::ORDER, [], AccessManager::CREATE)) { - return $response; - } - - $order = new Order(); - - $order->setLang($this->getLang()); - - $order->setDispatcher($this->getDispatcher()); - - $form = $this->createForm('admin-order-creation.create', 'form', [], ['csrf_protection' => false]); - - $formValidate = $this->validateForm($form, 'post'); - - $this->performOrder($order, $formValidate); - - $this->getParserContext()->addForm($form); - - $errorMessage = []; - foreach ($formValidate->getErrors() as $error) { - $errorMessage[] = $error->getMessage(); - } - - if (count($errorMessage)) { - $form->setErrorMessage(implode('
', $errorMessage)); - } - - if (!$form->hasError() && 'create' === $formValidate->get('action')->getData()) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::DATABASE_NAME); - - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - - try { - $cart = new Cart(); - - $cart->save(); - - $order->setCartId($cart->getId()); - - // on passe par le statut par défault - $order->setOrderStatus( - OrderStatusQuery::create()->findOneById(1) - ); - - $order->save(); - - $this->performCreditNote($order, $formValidate); - - $orderStatusId = $formValidate->get('status_id')->getData(); - - if ((int) $orderStatusId >= 2) { - if ((int) AdminOrderCreation::getConfigValue(AdminOrderCreation::CONFIG_KEY_INVOICE_REF_TYPE) === 0) { - // pour retirer les stocks et générer la référence facture - $order->setOrderStatus( - OrderStatusQuery::create()->findOneById(2) - ); - - $this->getDispatcher()->dispatch( - TheliaEvents::ORDER_UPDATE_STATUS, - (new OrderEvent($order))->setStatus(2) - ); - - $order->save(); - } else { // dans le cas d'une facturation à par - $order->setInvoiceRef((int) AdminOrderCreation::getConfigValue(AdminOrderCreation::CONFIG_KEY_INVOICE_REF_INCREMENT)); - - AdminOrderCreation::setConfigValue( - AdminOrderCreation::CONFIG_KEY_INVOICE_REF_INCREMENT, - (int) AdminOrderCreation::getConfigValue(AdminOrderCreation::CONFIG_KEY_INVOICE_REF_INCREMENT) + 1 - ); - - $order->setOrderStatus( - OrderStatusQuery::create()->findOneById(2) - ); - $order->save(); - } - } - - if ((int) $orderStatusId > 2) { - $order->setOrderStatus( - OrderStatusQuery::create()->findOneById((int) $orderStatusId) - ); - $this->getDispatcher()->dispatch( - TheliaEvents::ORDER_UPDATE_STATUS, - (new OrderEvent($order))->setStatus((int) $orderStatusId) - ); - } - - $order->save(); - - $con->commit(); - } catch (\Exception $e) { - $con->rollBack(); - throw $e; - } - } - - if ($order->getId()) { - return $this->render('admin-order-creation/ajax/order-create-modal-success', [ - 'order' => $order - ]); - } else { - return $this->render('admin-order-creation/ajax/order-create-modal', [ - 'order' => $order, - 'hasCreditNoteModule' => $this->hasCreditNoteModule(), - 'configNewCreditNoteStatusId' => AdminOrderCreation::getConfigValue(AdminOrderCreation::CONFIG_KEY_DEFAULT_NEW_CREDIT_NOTE_STATUS_ID), - 'configNewCreditNoteTypeId' => AdminOrderCreation::getConfigValue(AdminOrderCreation::CONFIG_KEY_DEFAULT_NEW_CREDIT_NOTE_TYPE_ID), - 'configPayedOrderMinimumStatusId' => AdminOrderCreation::getConfigValue(AdminOrderCreation::CONFIG_KEY_PAYED_ORDER_MINIMUM_STATUS_ID) - ]); - } - } - - /** - * @param Request $request - * @return JsonResponse - * @throws \Propel\Runtime\Exception\PropelException - */ - public function ajaxSearchCustomerAction(Request $request) - { - if (null !== $response = $this->checkAuth(AdminResources::ORDER, [], AccessManager::CREATE)) { - return $response; - } - - $customerQuery = CustomerQuery::create() - ->innerJoinAddress() - ->groupById() - ->limit(20); - - $this->whereConcatRegex($customerQuery, [ - 'customer.REF', - 'customer.FIRSTNAME', - 'customer.LASTNAME', - 'customer.EMAIL', - 'address.COMPANY', - 'address.PHONE' - ], $request->get('q')); - - $customerQuery - ->withColumn(AddressTableMap::COMPANY, 'COMPANY') - ->withColumn(AddressTableMap::ADDRESS1, 'ADDRESS') - ->withColumn(AddressTableMap::CITY, 'CITY') - ->withColumn(AddressTableMap::ZIPCODE, 'ZIPCODE') - ->withColumn(AddressTableMap::PHONE, 'PHONE'); - - $customers = $customerQuery->find(); - - $json = [ - 'incomplete_results' => count($customers) ? false : true, - 'items' => [] - ]; - - /** @var Customer $customer */ - foreach ($customers as $customer) { - $json['items'][] = [ - 'id' => $customer->getId(), - 'company' => $customer->getVirtualColumn('COMPANY'), - 'firstname' => $customer->getFirstname(), - 'lastname' => $customer->getLastname(), - 'ref' => $customer->getRef(), - 'address' => $this->formatAddress($customer) - ]; - } - - return new JsonResponse($json); - } - - /** - * @param Request $request - * @return JsonResponse - * @throws \Propel\Runtime\Exception\PropelException - */ - public function ajaxSearchProductAction(Request $request) - { - if (null !== $response = $this->checkAuth(AdminResources::ORDER, [], AccessManager::CREATE)) { - return $response; - } - - $productQuery = ProductQuery::create(); - - $productQuery->useI18nQuery( - $this->getRequest()->getSession()->getAdminEditionLang()->getLocale() - ); - - $productQuery - ->withColumn(ProductI18nTableMap::TITLE, 'TITLE'); - - $this->whereConcatRegex($productQuery, array( - 'product.REF', - 'product_i18n.TITLE' - ), $request->get('q')); - - $productQuery->setLimit(10); - - $products = $productQuery->find(); - - $json = [ - 'incomplete_results' => count($products) ? false : true, - 'items' => [] - ]; - - /** @var Product $product */ - foreach ($products as $product) { - $json['items'][] = [ - 'id' => $product->getId(), - 'ref' => $product->getRef(), - 'title' => $product->getVirtualColumn('TITLE') - ]; - } - - return new JsonResponse($json); - } - - protected function hasCreditNoteModule() - { - return class_exists('\CreditNote\CreditNote'); - } - - protected function performOrder(Order $order, Form $formValidate) - { - $this - ->performCurrency($order, $formValidate) - ->performOrderStatus($order, $formValidate) - ->performCustomer($order, $formValidate) - ->performInvoiceAddress($order, $formValidate) - ->performDeliveryAddress($order, $formValidate) - ->performDeliveryAddress($order, $formValidate) - ->performProducts($order, $formValidate) - ->performShipping($order, $formValidate) - ->performGlobalReduction($order, $formValidate) - ->performPaymentModule($order, $formValidate) - ->performDeliveryModule($order, $formValidate) - ; - - return $this; - } - - protected function performPaymentModule(Order $order, Form $form) - { - $paymentModuleId = (int) $form->get('payment_module_id')->getData(); - - $order->setPaymentModuleId($paymentModuleId); - - return $this; - } - - protected function performDeliveryModule(Order $order, Form $form) - { - $deliveryModuleId = (int) $form->get('delivery_module_id')->getData(); - - $order->setDeliveryModuleId($deliveryModuleId); - - return $this; - } - - protected function performShipping(Order $order, Form $form) - { - $price = (float) $form->get('shipping_price_with_tax')->getData(); - - $priceWithTax = (float) $form->get('shipping_price_with_tax')->getData(); - - $order->setPostage($priceWithTax); - $order->setPostageTax($priceWithTax - $price); - - return $this; - } - - protected function performGlobalReduction(Order $order, Form $form) - { - $reduction = (float) $form->get('reduction')->getData(); - - $reductionType = (int) $form->get('reduction_type')->getData(); - - $total = $order->getTotalAmountWithTax(false); - - $afterDiscount = Calc::reduction( - $reduction, - $reductionType, - $total, - 1 - ); - - $order->setDiscount(-($afterDiscount - $total)); - - return $this; - } - - protected function performCurrency(Order $order, Form $form) - { - /** @var int $currencyId */ - $currencyId = $form->get('currency_id')->getData(); - - if (empty($currencyId) || null === $currency = CurrencyQuery::create()->findPk($currencyId)) { - $currency = CurrencyQuery::create()->findOneByByDefault(true); - } - - $order->setCurrency($currency); - $order->setCurrencyRate($currency->getRate()); - - return $this; - } - - protected function getCountry(Form $form) - { - /** @var int $countryId */ - $countryId = $form->get('country_id')->getData(); - - if (!empty($countryId) && $country = CountryQuery::create()->findPk($countryId)) { - return $country; - } - - return CountryQuery::create()->filterByByDefault(true)->findOne(); - } - - protected function performOrderStatus(Order $order, Form $form) - { - if (null !== $statusId = $form->get('status_id')->getData()) { - $order->setOrderStatus( - OrderStatusQuery::create()->findOneById((int) $statusId) - ); - } else { - $order->setOrderStatus( - OrderStatusQuery::create()->findOneById(1) - ); - } - - return $this; - } - - protected function performCustomer(Order $order, Form $form) - { - if (null !== $customerId = $form->get('customer_id')->getData()) { - $order->setCustomer( - CustomerQuery::create()->findOneById((int) $customerId) - ); - } - - if (null === $customerId && 'create' === $form->get('action')->getData()) { - $form->addError( - new FormError('Please select a customer') - ); - } - - return $this; - } - - protected function performCreditNote(Order $order, Form $form) - { - if (!$this->hasCreditNoteModule()) { - return $this; - } - - $action = $form->get('action')->getData(); - - $creditNoteId = $form->get('credit_note_id')->getData(); - - $creditNoteStatusId = $form->get('credit_note_status_id')->getData(); - - $creditNoteTypeId = $form->get('credit_note_type_id')->getData(); - - if ($creditNoteId && $action === 'create') { - /** @var CreditNote $creditNote */ - $creditNote = CreditNoteQuery::create() - ->filterById($creditNoteId) - ->useCreditNoteStatusQuery() - ->filterByUsed(false) - ->filterByInvoiced(true) - ->endUse() - ->findOne(); - - if (null === $creditNote) { - $form->addError( - new FormError('Please select a valid credit note') - ); - } - - $orderCreditNote = (new OrderCreditNote()) - ->setOrderId($order->getId()) - ->setCreditNoteId($creditNote->getId()); - - if (round($order->getTotalAmountWithTax() - $creditNote->getTotalPriceWithTax(), 2) > 0) { // cas crédit note plus petit - $orderCreditNote->setAmountPrice($creditNote->getTotalPriceWithTax()); - } elseif (round($order->getTotalAmountWithTax() - $creditNote->getTotalPriceWithTax(), 2) < 0) { // cas crédit note plus grand - $orderCreditNote->setAmountPrice($order->getTotalAmountWithTax()); - - // copy address - $lastInvoiceAddress = $creditNote->getCreditNoteAddress(); - $invoiceAddress = (new CreditNoteAddress()) - ->setFirstname($lastInvoiceAddress->getFirstname()) - ->setLastname($lastInvoiceAddress->getLastname()) - ->setCity($lastInvoiceAddress->getCity()) - ->setZipcode($lastInvoiceAddress->getZipcode()) - ->setAddress1($lastInvoiceAddress->getAddress1()) - ->setAddress2($lastInvoiceAddress->getAddress2()) - ->setAddress3($lastInvoiceAddress->getAddress3()) - ->setCustomerTitleId($lastInvoiceAddress->getCustomerTitleId()) - ->setCountryId($lastInvoiceAddress->getCountryId()); - - $invoiceAddress->save(); - - $crediNoteDetail = (new CreditNoteDetail()) - ->setTitle('Remboursement différence') - ->setTaxRuleId(null) - ->setPriceWithTax(-($order->getTotalAmountWithTax() - $creditNote->getTotalPriceWithTax())) - ->setPrice(-($order->getTotalAmountWithTax() - $creditNote->getTotalPriceWithTax())) - ->setType('other'); - - $newCreditNote = (new CreditNote()) - ->setCurrency($creditNote->getCurrency()) - ->setTypeId($creditNoteTypeId) - ->setStatusId($creditNoteStatusId) - ->setCreditNoteAddress($invoiceAddress) - ->addCreditNoteDetail($crediNoteDetail) - ->setTotalPrice(-($order->getTotalAmountWithTax() - $creditNote->getTotalPriceWithTax())) - ->setTotalPriceWithTax(-($order->getTotalAmountWithTax() - $creditNote->getTotalPriceWithTax())) - ->setCustomerId($creditNote->getCustomer()->getId()) - ->setParentId($creditNote->getId()) - ->setOrderId($order->getId()); - - $newCreditNote->setDispatcher($this->getDispatcher()); - - $newCreditNote->save(); - } else { // cas crédit note égale - $orderCreditNote->setAmountPrice($creditNote->getTotalPriceWithTax()); - } - - $orderCreditNote->save(); - - $newStatus = CreditNoteStatusQuery::findNextCreditNoteUsedStatus($creditNote->getCreditNoteStatus()); - - $creditNote->setCreditNoteStatus($newStatus); - $creditNote->save(); - } - } - - protected function performInvoiceAddress(Order $order, Form $form) - { - $action = $form->get('action')->getData(); - - $invoiceAddressId = $form->get('invoice_address_id')->getData(); - - if ($invoiceAddressId) { - $address = AddressQuery::create()->findOneById((int) $invoiceAddressId); - - $orderAddress = (new OrderAddress()) - ->setCustomerTitle($address->getCustomerTitle()) - ->setAddress1($address->getAddress1()) - ->setAddress2($address->getAddress2()) - ->setAddress3($address->getAddress3()) - ->setFirstname($address->getFirstname()) - ->setLastname($address->getLastname()) - ->setCity($address->getCity()) - ->setZipcode($address->getZipcode()) - ->setCompany($address->getCompany()) - ->setCountry($address->getCountry()); - } else { - $invoiceAddressTitle = $form->get('invoice_address_title')->getData(); - $invoiceAddressFirstname = $form->get('invoice_address_firstname')->getData(); - $invoiceAddressLastname = $form->get('invoice_address_lastname')->getData(); - $invoiceAddressCompany = $form->get('invoice_address_company')->getData(); - $invoiceAddressAddress1 = $form->get('invoice_address_address1')->getData(); - $invoiceAddressAddress2 = $form->get('invoice_address_address2')->getData(); - $invoiceAddressZipcode = $form->get('invoice_address_zipcode')->getData(); - $invoiceAddressCity = $form->get('invoice_address_city')->getData(); - $invoiceAddressCountryId = $form->get('invoice_address_country_id')->getData(); - - $orderAddress = (new OrderAddress()) - ->setCustomerTitleId($invoiceAddressTitle) - ->setAddress1($invoiceAddressAddress1) - ->setAddress2($invoiceAddressAddress2) - ->setFirstname($invoiceAddressFirstname) - ->setLastname($invoiceAddressLastname) - ->setCity($invoiceAddressCity) - ->setZipcode($invoiceAddressZipcode) - ->setCompany($invoiceAddressCompany) - ->setCountry( - CountryQuery::create()->findOneById($invoiceAddressCountryId) - ); - } - - if (empty($orderAddress->getLastname()) && 'create' === $form->get('action')->getData()) { - $form->addError( - new FormError('Please select a invoice address') - ); - } - - if ($action === 'create') { - $orderAddress->save(); - - $order->setInvoiceOrderAddressId($orderAddress->getId()); - } - - return $this; - } - - protected function performDeliveryAddress(Order $order, Form $form) - { - $action = $form->get('action')->getData(); - - $deliveryAddressId = $form->get('delivery_address_id')->getData(); - - if ($deliveryAddressId) { - $address = AddressQuery::create()->findOneById((int) $deliveryAddressId); - - $orderAddress = (new OrderAddress()) - ->setCustomerTitle($address->getCustomerTitle()) - ->setAddress1($address->getAddress1()) - ->setAddress2($address->getAddress2()) - ->setAddress3($address->getAddress3()) - ->setFirstname($address->getFirstname()) - ->setLastname($address->getLastname()) - ->setCity($address->getCity()) - ->setZipcode($address->getZipcode()) - ->setCompany($address->getCompany()) - ->setCountry($address->getCountry()); - } else { - $deliveryAddressTitle = $form->get('delivery_address_title')->getData(); - $deliveryAddressFirstname = $form->get('delivery_address_firstname')->getData(); - $deliveryAddressLastname = $form->get('delivery_address_lastname')->getData(); - $deliveryAddressCompany = $form->get('delivery_address_company')->getData(); - $deliveryAddressAddress1 = $form->get('delivery_address_address1')->getData(); - $deliveryAddressAddress2 = $form->get('delivery_address_address2')->getData(); - $deliveryAddressZipcode = $form->get('delivery_address_zipcode')->getData(); - $deliveryAddressCity = $form->get('delivery_address_city')->getData(); - $deliveryAddressCountryId = $form->get('delivery_address_country_id')->getData(); - - $orderAddress = (new OrderAddress()) - ->setCustomerTitleId($deliveryAddressTitle) - ->setAddress1($deliveryAddressAddress1) - ->setAddress2($deliveryAddressAddress2) - ->setFirstname($deliveryAddressFirstname) - ->setLastname($deliveryAddressLastname) - ->setCity($deliveryAddressCity) - ->setZipcode($deliveryAddressZipcode) - ->setCompany($deliveryAddressCompany) - ->setCountry( - CountryQuery::create()->findOneById($deliveryAddressCountryId) - ); - } - - if (empty($orderAddress->getLastname()) && 'create' === $form->get('action')->getData()) { - $form->addError( - new FormError('Please select a delivery address') - ); - } - - if ($action === 'create') { - $orderAddress->save(); - - $order->setDeliveryOrderAddressId($orderAddress->getId()); - } - - return $this; - } - - protected function getLang() - { - return $this->getSession()->getAdminEditionLang(); - } - - protected function performProducts(Order $order, Form $form) - { - $country = $this->getCountry($form); - - $productIds = $form->get('product_id')->getData(); - $quantities = $form->get('product_quantity')->getData(); - $productSaleElementIds = $form->get('product_sale_element_id')->getData(); - $productPriceWithoutTax = $form->get('product_price_without_tax')->getData(); - $refreshPrice = $form->get('refresh_price')->getData(); - - $currency = $this->getCurrency($form); - - foreach ($productIds as $key => $id) { - if (!isset($quantities[$key])) { - $quantities[$key] = 1; - } - - $product = ProductQuery::create()->findOneById($id); - - /** @var ProductI18n $productI18n */ - $productI18n = I18n::forceI18nRetrieving( - $order->getLang()->getLocale(), - 'Product', - $product->getId() - ); - - $productSaleElementsLoop = new ProductSaleElements($this->container); - - if (isset($productSaleElementIds[$key])) { - if (null !== ProductSaleElementsQuery::create() - ->filterByProductId($product->getId()) - ->filterById($productSaleElementIds[$key]) - ->findOne()) { - $productSaleElementsLoop->initializeArgs([ - 'name' => 'product_sale_elements', - 'type' => 'product_sale_elements', - 'id' => $productSaleElementIds[$key], - 'currency' => $currency->getId() - ]); - } else { - $productSaleElementsLoop->initializeArgs([ - 'name' => 'product_sale_elements', - 'type' => 'product_sale_elements', - 'product' => $product->getId(), - 'currency' => $currency->getId() - ]); - } - } else { - $productSaleElementsLoop->initializeArgs([ - 'name' => 'product_sale_elements', - 'type' => 'product_sale_elements', - 'product' => $product->getId(), - 'currency' => $currency->getId() - ]); - } - - $pagination = null; - $results = $productSaleElementsLoop->exec($pagination); - - /** @var \Thelia\Model\ProductSaleElements $productSaleElement */ - $productSaleElement = $results->getResultDataCollection()[0]; - - /** @var TaxRuleI18n $taxRuleI18n */ - $taxRuleI18n = I18n::forceI18nRetrieving( - $order->getLang()->getLocale(), - 'TaxRule', - $product->getTaxRuleId() - ); - - if (isset($refreshPrice[$key]) && (int) $refreshPrice[$key]) { - $price = $productSaleElement->getVirtualColumn('price_PRICE'); - $promoPrice = $productSaleElement->getVirtualColumn('price_PROMO_PRICE'); - } else { - $price = isset($productPriceWithoutTax[$key]) ? (float) $productPriceWithoutTax[$key] : $productSaleElement->getVirtualColumn('price_PRICE'); - $promoPrice = isset($productPriceWithoutTax[$key]) ? (float) $productPriceWithoutTax[$key] : $productSaleElement->getVirtualColumn('price_PROMO_PRICE'); - } - - $taxDetail = $product->getTaxRule()->getTaxDetail( - $product, - $country, - $price, - $promoPrice, - $order->getLang()->getLocale() - ); - - $orderProduct = (new OrderProduct()) - ->setProductRef($product->getRef()) - ->setProductSaleElementsRef($productSaleElement->getRef()) - ->setProductSaleElementsId($productSaleElement->getId()) - ->setTitle($productI18n->getTitle()) - ->setChapo($productI18n->getChapo()) - ->setDescription($productI18n->getDescription()) - ->setPostscriptum($productI18n->getPostscriptum()) - ->setVirtual($product->getVirtual()) - ->setQuantity($quantities[$key]) - ->setWasNew($productSaleElement->getNewness()) - ->setWeight($productSaleElement->getWeight()) - ->setTaxRuleTitle($taxRuleI18n->getTitle()) - ->setTaxRuleDescription($taxRuleI18n->getDescription()) - ->setEanCode($productSaleElement->getEanCode()) - ->setDispatcher($this->getDispatcher()) - ->setPrice($price) - ->setPromoPrice($promoPrice) - ->setWasInPromo($productSaleElement->getPromo()) - ; - - /** @var OrderProductTax $tax */ - foreach ($taxDetail as $tax) { - $orderProduct->addOrderProductTax($tax); - } - - foreach ($productSaleElement->getAttributeCombinations() as $attributeCombination) { - /** @var \Thelia\Model\Attribute $attribute */ - $attribute = I18n::forceI18nRetrieving( - $this->getSession()->getLang()->getLocale(), - 'Attribute', - $attributeCombination->getAttributeId() - ); - - /** @var \Thelia\Model\AttributeAv $attributeAv */ - $attributeAv = I18n::forceI18nRetrieving( - $this->getSession()->getLang()->getLocale(), - 'AttributeAv', - $attributeCombination->getAttributeAvId() - ); - - $orderProduct->addOrderProductAttributeCombination( - (new OrderProductAttributeCombination()) - ->setOrderProductId($orderProduct->getId()) - ->setAttributeTitle($attribute->getTitle()) - ->setAttributeChapo($attribute->getChapo()) - ->setAttributeDescription($attribute->getDescription()) - ->setAttributePostscriptum($attribute->getPostscriptum()) - ->setAttributeAvTitle($attributeAv->getTitle()) - ->setAttributeAvChapo($attributeAv->getChapo()) - ->setAttributeAvDescription($attributeAv->getDescription()) - ->setAttributeAvPostscriptum($attributeAv->getPostscriptum()) - ); - } - - $order->addOrderProduct($orderProduct); - } - - - if (!count($order->getOrderProducts()) && 'create' === $form->get('action')->getData()) { - $form->addError( - new FormError('Please select a product') - ); - } - - return $this; - } - - protected function getCurrency(Form $form) - { - $currencyId = $form->get('currency_id')->getData(); - if (null !== $currencyId) { - $currency = CurrencyQuery::create()->findPk($currencyId); - if (null === $currency) { - throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop'); - } - } else { - $currency = $this->getRequest()->getSession()->getCurrency(); - } - - return $currency; - } - - /** - * @param ActiveRecordInterface $model - * @return string - * @throws \Propel\Runtime\Exception\PropelException - */ - protected function formatAddress(ActiveRecordInterface $model) - { - /** @var Order|Customer $model */ - return implode(' ', [$model->getVirtualColumn('ADDRESS'), $model->getVirtualColumn('ZIPCODE'), $model->getVirtualColumn('CITY')]); - } -} diff --git a/local/modules/AdminOrderCreation/Form/OrderCreateForm.php b/local/modules/AdminOrderCreation/Form/OrderCreateForm.php deleted file mode 100644 index 17a2f3eb9..000000000 --- a/local/modules/AdminOrderCreation/Form/OrderCreateForm.php +++ /dev/null @@ -1,213 +0,0 @@ - - */ -class OrderCreateForm extends BaseForm -{ - /** - * @return string the name of you form. This name must be unique - */ - public function getName() - { - return 'admin-order-creation-create'; - } - - /** - * - * in this function you add all the fields you need for your Form. - * Form this you have to call add method on $this->formBuilder attribute : - * - */ - protected function buildForm() - { - $this->formBuilder - ->add('currency_id', IntegerType::class, array( - 'required' => false - )) - ->add('country_id', IntegerType::class, array( - 'required' => false - )); - - $this->formBuilder - ->add('action', ChoiceType::class, array( - 'required' => true, - 'choices' => array( - 'open' => 'open', - 'refresh' => 'refresh', - 'create' => 'create', - ), - )) - ->add('status_id', IntegerType::class, array( - 'required' => false - )) - ->add('customer_id', IntegerType::class, array( - 'required' => false - )) - ->add('invoice_address_id', IntegerType::class, array( - 'required' => false - )) - ->add('delivery_address_id', IntegerType::class, array( - 'required' => false - )) - ; - - $this->formBuilder - ->add('invoice_address_id', IntegerType::class, array( - 'required' => false - )) - ->add('invoice_address_title', TextType::class, array( - 'required' => false - )) - ->add('invoice_address_firstname', TextType::class, array( - 'required' => false - )) - ->add('invoice_address_lastname', TextType::class, array( - 'required' => false - )) - ->add('invoice_address_company', TextType::class, array( - 'required' => false - )) - ->add('invoice_address_address1', TextType::class, array( - 'required' => false - )) - ->add('invoice_address_address2', TextType::class, array( - 'required' => false - )) - ->add('invoice_address_zipcode', TextType::class, array( - 'required' => false - )) - ->add('invoice_address_city', TextType::class, array( - 'required' => false - )) - ->add('invoice_address_country_id', IntegerType::class, array( - 'required' => false - )) - ; - - $this->formBuilder - ->add('delivery_address_id', IntegerType::class, array( - 'required' => false - )) - ->add('delivery_address_title', TextType::class, array( - 'required' => false - )) - ->add('delivery_address_firstname', TextType::class, array( - 'required' => false - )) - ->add('delivery_address_lastname', TextType::class, array( - 'required' => false - )) - ->add('delivery_address_company', TextType::class, array( - 'required' => false - )) - ->add('delivery_address_address1', TextType::class, array( - 'required' => false - )) - ->add('delivery_address_address2', TextType::class, array( - 'required' => false - )) - ->add('delivery_address_zipcode', TextType::class, array( - 'required' => false - )) - ->add('delivery_address_city', TextType::class, array( - 'required' => false - )) - ->add('delivery_address_country_id', IntegerType::class, array( - 'required' => false - )) - ; - - $this->formBuilder - ->add('product_id', 'collection', array( - 'required' => false, - 'allow_add' => true, - 'allow_delete' => true - )) - ->add('product_sale_element_id', 'collection', array( - 'required' => false, - 'allow_add' => true, - 'allow_delete' => true - )) - ->add('product_quantity', 'collection', array( - 'required' => false, - 'allow_add' => true, - 'allow_delete' => true - )) - ->add('product_price_with_tax', 'collection', array( - 'required' => false, - 'allow_add' => true, - 'allow_delete' => true - )) - ->add('product_price_without_tax', 'collection', array( - 'required' => false, - 'allow_add' => true, - 'allow_delete' => true - )) - ->add('refresh_price', 'collection', array( - 'required' => false, - 'allow_add' => true, - 'allow_delete' => true - )) - ; - - $this->formBuilder - ->add('reduction', TextType::class, array( - 'required' => false, - 'empty_data' => 0 - )) - ->add('reduction_type', NumberType::class, array( - 'required' => false - )); - - $this->formBuilder - ->add('shipping_price', TextType::class, array( - 'required' => false, - 'empty_data' => 0 - )) - ->add('shipping_tax_rule_id', IntegerType::class, array( - 'required' => false - )) - ->add('shipping_price_with_tax', TextType::class, array( - 'required' => false, - 'empty_data' => 0 - )); - - $this->formBuilder - ->add('payment_module_id', IntegerType::class, array( - 'required' => false - )) - ->add('delivery_module_id', IntegerType::class, array( - 'required' => false - )) - ; - - $this->formBuilder - ->add('credit_note_id', IntegerType::class, array( - 'required' => false - )) - ->add('credit_note_type_id', IntegerType::class, array( - 'required' => false - )) - ->add('credit_note_status_id', IntegerType::class, array( - 'required' => false - )) - ; - } -} diff --git a/local/modules/AdminOrderCreation/Hook/Back/OrderEditHook.php b/local/modules/AdminOrderCreation/Hook/Back/OrderEditHook.php deleted file mode 100644 index 3a944b122..000000000 --- a/local/modules/AdminOrderCreation/Hook/Back/OrderEditHook.php +++ /dev/null @@ -1,22 +0,0 @@ -add($this->render( - 'admin-order-creation/hook/orders.edit.js.html', - $event->getArguments() - )); - } -} diff --git a/local/modules/AdminOrderCreation/Hook/Back/OrderHook.php b/local/modules/AdminOrderCreation/Hook/Back/OrderHook.php deleted file mode 100644 index f0df2cc10..000000000 --- a/local/modules/AdminOrderCreation/Hook/Back/OrderHook.php +++ /dev/null @@ -1,35 +0,0 @@ -add($this->render( - 'admin-order-creation/hook/orders.table-header.html', - $event->getArguments() - )); - } - - public function onOrderJs(HookRenderEvent $event) - { - $event->add($this->render( - 'admin-order-creation/hook/orders.js.html', - array_merge($event->getArguments() + [ - - ]) - )); - } -} diff --git a/local/modules/AdminOrderCreation/I18n/backOffice/default/fr_FR.php b/local/modules/AdminOrderCreation/I18n/backOffice/default/fr_FR.php deleted file mode 100644 index d6036ef50..000000000 --- a/local/modules/AdminOrderCreation/I18n/backOffice/default/fr_FR.php +++ /dev/null @@ -1,61 +0,0 @@ - 'Un nouvel avoir d\'un montant de %amount TTC sera créer pour le client.', - 'Add product' => 'Ajouter un produit', - 'Address :' => 'Adresse :', - 'Address complement :' => 'Complément d\'adresse :', - 'An error has occurred !!!' => 'Une erreur est survenue', - 'Cancel' => 'Annuler', - 'City :' => 'Ville :', - 'Close' => 'Fermer', - 'Company :' => 'Société :', - 'Country :' => 'Pays :', - 'Create' => 'Créer', - 'Create new order' => 'Créer une nouvelle commande', - 'Create order' => 'Créer une commande', - 'Credit note :' => 'Avoir :', - 'Customer :' => 'Client :', - 'Default product sale element' => 'Déclinaison par défaut', - 'Delete' => 'Supprimer', - 'Delivery address' => 'Adresse de livraison', - 'Delivery module :' => 'Module de livraison :', - 'Firstname :' => 'Prénom :', - 'Global amount' => 'Montant global', - 'Global reduction' => 'Réduction global', - 'Invoice address' => 'Adresse de facturation', - 'Lastname :' => 'Nom :', - 'Message content :' => 'Message :', - 'Message status :' => 'Statut :', - 'Order Informations :' => 'Informations de la commande', - 'Other' => 'Autre', - 'Payment module :' => 'Module de paiement :', - 'Percentage' => 'Pourcentage', - 'Please wait, loading' => 'Veillez patienter, chargement ...', - 'Price' => 'Prix', - 'Price with tax :' => 'Prix TTC :', - 'Price without tax :' => 'Prix HT :', - 'Product' => 'Produit', - 'Product sale element' => 'Déclinaison', - 'Products' => 'Produits', - 'Quantity' => 'Quantité', - 'Search...' => 'Rechercher ...', - 'Shipping' => 'Frais de livraison', - 'Status :' => 'Statut :', - 'Status of new credit note :' => 'Statut du nouvel avoir :', - 'Total tax :' => 'Total taxe :', - 'Tax rule :' => 'Règle de taxe :', - 'This command uses the credit note ref %ref for the amount of %amount with tax.' => 'Cette commande utilise l\'avoir %ref avec un montant de %amount TTC.', - 'This order use the country : %country' => 'Cette commande utilise le pays : %country', - 'This order use the currency : %currency' => 'Cette commande utilise le devise : %currency', - 'Title :' => 'Titre :', - 'Total with tax :' => 'Total TTC :', - 'Total without tax :' => 'Total HT :', - 'Type :' => 'Type :', - 'Type of new credit note :' => 'Type du nouvel avoir :', - 'Unit price with tax' => 'Prix unitaire TTC', - 'Use Credit Note :' => 'Utiliser un avoir :', - 'Value :' => 'Value :', - 'Your customer will have to pay the difference of %amount with tax' => 'Votre client devra payer la différence d\'un montant de %amount TTC', - 'Zipcode :' => 'Code postal :', -); diff --git a/local/modules/AdminOrderCreation/I18n/en_US.php b/local/modules/AdminOrderCreation/I18n/en_US.php deleted file mode 100644 index 0b4fa142b..000000000 --- a/local/modules/AdminOrderCreation/I18n/en_US.php +++ /dev/null @@ -1,4 +0,0 @@ - 'The displayed english string', -); diff --git a/local/modules/AdminOrderCreation/I18n/fr_FR.php b/local/modules/AdminOrderCreation/I18n/fr_FR.php deleted file mode 100644 index 370862450..000000000 --- a/local/modules/AdminOrderCreation/I18n/fr_FR.php +++ /dev/null @@ -1,4 +0,0 @@ - 'La traduction française de la chaine', -); diff --git a/local/modules/AdminOrderCreation/LICENSE b/local/modules/AdminOrderCreation/LICENSE deleted file mode 100644 index 16e6d881e..000000000 --- a/local/modules/AdminOrderCreation/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019 thelia-modules - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/local/modules/AdminOrderCreation/Model/Order.php b/local/modules/AdminOrderCreation/Model/Order.php deleted file mode 100644 index fa22a4150..000000000 --- a/local/modules/AdminOrderCreation/Model/Order.php +++ /dev/null @@ -1,63 +0,0 @@ -getOrderProducts() as $orderProduct) { - if ($orderProduct->getWasInPromo()) { - $total += $orderProduct->getPromoPrice() * $orderProduct->getQuantity(); - } else { - $total += $orderProduct->getPrice() * $orderProduct->getQuantity(); - } - - foreach ($orderProduct->getOrderProductTaxes() as $orderProductTax) { - if ($orderProduct->getWasInPromo()) { - $total += $orderProductTax->getPromoAmount() * $orderProduct->getQuantity(); - } else { - $total += $orderProductTax->getAmount() * $orderProduct->getQuantity(); - } - } - } - - $total += $this->getPostage(); - - - if ($withDiscount) { - $total -= $this->getDiscount(); - } - - return $total; - } - - public function getTotalAmountWithoutTax($withDiscount = true) - { - $total = 0; - - foreach ($this->getOrderProducts() as $orderProduct) { - if ($orderProduct->getWasInPromo()) { - $total += $orderProduct->getPromoPrice() * $orderProduct->getQuantity(); - } else { - $total += $orderProduct->getPrice() * $orderProduct->getQuantity(); - } - } - - $total += $this->getPostage() - $this->getPostageTax(); - - if ($withDiscount) { - $total -= $this->getDiscount(); - } - - return $total; - } -} \ No newline at end of file diff --git a/local/modules/AdminOrderCreation/Readme.md b/local/modules/AdminOrderCreation/Readme.md deleted file mode 100644 index a4c9a24c4..000000000 --- a/local/modules/AdminOrderCreation/Readme.md +++ /dev/null @@ -1,24 +0,0 @@ -# Admin Order Creation - -Author: Gilles Bourgeat - -A module to create orders from the Thelia back-office. - -## Compatibility - -Thelia >= 2.3 - -## Installation - -### Manually - -* Copy the module into ```/local/modules/``` directory and be sure that the name of the module is ```AdminOrderCreation```. -* Activate it in your thelia administration panel - -### Composer - -Add it in your main thelia composer.json file - -``` -composer require thelia/admin-order-creation ~1.3.3 -``` diff --git a/local/modules/AdminOrderCreation/Util/Calc.php b/local/modules/AdminOrderCreation/Util/Calc.php deleted file mode 100644 index d326c5a77..000000000 --- a/local/modules/AdminOrderCreation/Util/Calc.php +++ /dev/null @@ -1,39 +0,0 @@ - 100) { - throw new \Exception('Invalid arg reduction'); - } - - return (($price / 100) * (100 - $value)); - } elseif ($type === 2) { - if ($value < 0 || $value > $price * $quantity) { - throw new \Exception('Invalid arg reduction'); - } - - return ($price * $quantity - $value) / $quantity; - } elseif ($type === 3) { - if ($value < 0 || $value > $price) { - throw new \Exception('Invalid arg reduction'); - } - - return ($price - $value); - } - } -} diff --git a/local/modules/AdminOrderCreation/Util/CriteriaSearchTrait.php b/local/modules/AdminOrderCreation/Util/CriteriaSearchTrait.php deleted file mode 100644 index a67e719c3..000000000 --- a/local/modules/AdminOrderCreation/Util/CriteriaSearchTrait.php +++ /dev/null @@ -1,54 +0,0 @@ - 2 && preg_match('/^[a-z0-9]+$/i', $v)) { - $words[] = $v; - } - } - - if (!count($words)) { - return null; - } - - $regex = array(); - $regex[] = '.*' . implode('.+', $words) . '.*'; - if (count($words) > 1) { - $regex[] = '.*' . implode('.+', array_reverse($words)) . '.*'; - } - - return implode('|', $regex); - } - - /** - * @param ModelCriteria $query - * @param array $columns - * @param string $q - */ - public function whereConcatRegex(ModelCriteria $query, array $columns, $q) - { - $query->where("CONCAT_WS(' ', " . implode(',', $columns). ") REGEXP ?", self::getRegex($q), \PDO::PARAM_STR); - } -} diff --git a/local/modules/AdminOrderCreation/composer.json b/local/modules/AdminOrderCreation/composer.json deleted file mode 100644 index 56b7a4c7c..000000000 --- a/local/modules/AdminOrderCreation/composer.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "thelia/admin-order-creation", - "description": "A module to create orders from the Thelia back-office.", - "license": "MIT", - "type": "thelia-module", - "require": { - "thelia/installer": "~1.1", - "thelia/credit-note-module": "~2.3.0" - }, - "extra": { - "installer-name": "AdminOrderCreation" - } -} diff --git a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/ajax/order-create-modal-success.html b/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/ajax/order-create-modal-success.html deleted file mode 100644 index c3d41eea1..000000000 --- a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/ajax/order-create-modal-success.html +++ /dev/null @@ -1,5 +0,0 @@ -{check_auth role="ADMIN" resource="order" access="create"} - - \ No newline at end of file diff --git a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/ajax/order-create-modal.html b/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/ajax/order-create-modal.html deleted file mode 100644 index 958916f40..000000000 --- a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/ajax/order-create-modal.html +++ /dev/null @@ -1,592 +0,0 @@ -{form name="admin-order-creation.create"} - - - {form_field field='action'} - - {/form_field} - - {if $form_error}
{$form_error_message nofilter}
{/if} - -
-
-
- {$currency_id = 0} - {form_field field='currency_id'} - {capture name="currency"} - - {/capture} - {intl l="This order use the currency : %currency" d="adminordercreation.bo.default" currency=$smarty.capture.currency} - {/form_field} -
-
- -
-
- {$country_id = 0} - {form_field field='country_id'} - {capture name="country"} - - {/capture} - {intl l="This order use the country : %country" d="adminordercreation.bo.default" country=$smarty.capture.country} - {/form_field} -
-
- - {* status select *} -
-
- - {$ignoreStatus = false} - {form_field field='credit_note_id'} - {if $data} - {$ignoreStatus = true} - {/if} - {/form_field} - - {form_field field='status_id'} - - {/form_field} -
-
- - {* customer select *} -
-
- - {form_field field='customer_id'} - - {/form_field} -
-
- - {* delivery module *} -
-
- - {form_field field='delivery_module_id'} - - {/form_field} -
-
- - {* payment module *} -
-
- - {form_field field='payment_module_id'} - - {/form_field} -
-
- - {* address invoice *} -
-
-
{intl l="Invoice address" d="adminordercreation.bo.default"}
-
- - {$other = false} -
- {form_field field='invoice_address_id'} - {if !$data} - {$other = true} - {/if} - - {/form_field} -
- -
- {form_field field='invoice_address_title'} -
- - -
- {/form_field} - {form_field field='invoice_address_firstname'} -
- - -
- {/form_field} - {form_field field='invoice_address_lastname'} -
- - -
- {/form_field} - {form_field field='invoice_address_address1'} -
- - -
- {/form_field} - {form_field field='invoice_address_address2'} -
- - -
- {/form_field} - {form_field field='invoice_address_city'} -
- - -
- {/form_field} - {form_field field='invoice_address_zipcode'} -
- - -
- {/form_field} - {form_field field='invoice_address_country_id'} -
- - -
- {/form_field} - {form_field field='invoice_address_company'} -
- - -
- {/form_field} -
- -
-
-
- - {* delivery invoice *} -
-
-
{intl l="Delivery address" d="adminordercreation.bo.default"}
-
- - {$other = false} -
- {form_field field='delivery_address_id'} - {if !$data} - {$other = true} - {/if} - - {/form_field} -
- -
- {form_field field='delivery_address_title'} -
- - -
- {/form_field} - {form_field field='delivery_address_firstname'} -
- - -
- {/form_field} - {form_field field='delivery_address_lastname'} -
- - -
- {/form_field} - {form_field field='delivery_address_address1'} -
- - -
- {/form_field} - {form_field field='delivery_address_address2'} -
- - -
- {/form_field} - {form_field field='delivery_address_city'} -
- - -
- {/form_field} - {form_field field='delivery_address_zipcode'} -
- - -
- {/form_field} - {form_field field='delivery_address_country_id'} -
- - -
- {/form_field} - {form_field field='delivery_address_company'} -
- - -
- {/form_field} -
-
-
-
- - {* Product *} -
-
-
{intl l="Products" d="adminordercreation.bo.default"}
-
- {$count = 0} - {form_field field='product_id'} - {foreach from=$data item=item key=key} - {if $key > $count} - {$count = $key} - {/if} - {/foreach} - {/form_field} - - - - - - - - - - - - - {form_field field='product_id'} - {foreach from=$order->getOrderProducts() item=orderProduct key=key} - {include file="admin-order-creation/include/product-line.html" orderProduct=$orderProduct} - {/foreach} - {/form_field} - -
- {intl l="Product" d="adminordercreation.bo.default"} / {intl l="Product sale element" d="adminordercreation.bo.default"} - - {intl l="Unit price with tax" d="adminordercreation.bo.default"} - - {intl l="Quantity" d="adminordercreation.bo.default"} - - {intl l="Price" d="adminordercreation.bo.default"} - - -
- -
-
-
- - {* Shipping *} -
-
-
{intl l="Shipping" d="adminordercreation.bo.default"}
-
-
-
- {form_field field='shipping_price'} -
- - -
- {/form_field} -
- -
- {form_field field='shipping_tax_rule_id'} -
- - -
- {/form_field} -
- -
- {form_field field='shipping_price_with_tax'} -
- - -
- {/form_field} -
-
-
-
-
- - {* Global reduction *} -
-
-
{intl l="Global reduction" d="adminordercreation.bo.default"}
-
-
-
-
- {form_field field='reduction_type'} -
- - -
- {/form_field} -
-
-
- {form_field field='reduction'} -
- - -
- {/form_field} -
-
-
-
-
- - {if $hasCreditNoteModule} -
-
-
{intl l="Use Credit Note :" d="adminordercreation.bo.default"}
-
-
- {* customer select *} -
-
- - {$credit_note_id = null} - {form_field field='credit_note_id'} - - {/form_field} -
-
-
- {if $credit_note_id} - {loop type="credit-note" name="credit-note" backend_context=true id=$credit_note_id} -
- {intl l="This command uses the credit note ref %ref for the amount of %amount with tax." d="adminordercreation.bo.default" - ref=$REF - amount={format_money number=$TOTAL_PRICE_WITH_TAX currency_id=$CURRENCY_ID} - } -
- {$diffAmount = ($order->getTotalAmountWithTax() - $TOTAL_PRICE_WITH_TAX)|round:2} - {if $diffAmount == 0} - - {elseif $diffAmount > 0} -
- {intl l="Your customer will have to pay the difference of %amount with tax" d="adminordercreation.bo.default" - amount={format_money number={$order->getTotalAmountWithTax() - $TOTAL_PRICE_WITH_TAX} currency_id=$CURRENCY_ID} - } -
- {else} -
- {intl l="A new credit note of %amount with tax will be issued for this customer." d="adminordercreation.bo.default" - amount={format_money number=-{$order->getTotalAmountWithTax() - $TOTAL_PRICE_WITH_TAX} currency_id=$CURRENCY_ID} - } -
-
-
-
- - {form_field field='credit_note_status_id'} - {if !$data} - {$data = $configNewCreditNoteStatusId} - {/if} - - {/form_field} -
-
-
-
- - {form_field field='credit_note_type_id'} - {if !$data} - {$data = $configNewCreditNoteTypeId} - {/if} - - {/form_field} -
-
-
- {/if} - {/loop} - {/if} -
-
- -
-
-
- {/if} - -
-
-
{intl l="Order Informations :" d="adminordercreation.bo.default"}
-
-
-
-

- {intl l="Total without tax :" d="adminordercreation.bo.default"} - {format_money number=$order->getTotalAmountWithoutTax() currency_id=$order->getCurrency()->getId()} HT - -

-
-
-

- {intl l="Total tax :" d="adminordercreation.bo.default"} - {format_money number={$order->getTotalAmountWithTax()-$order->getTotalAmountWithoutTax()} currency_id=$order->getCurrency()->getId()} - -

-
-
-

- {intl l="Total with tax :" d="adminordercreation.bo.default"} - {format_money number=$order->getTotalAmountWithTax() currency_id=$order->getCurrency()->getId()} TTC - -

-
-
-
-
-
- - - - -
- -{/form} \ No newline at end of file diff --git a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/assets/js/script.js b/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/assets/js/script.js deleted file mode 100644 index 5f67d817e..000000000 --- a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/assets/js/script.js +++ /dev/null @@ -1,465 +0,0 @@ -(function(){ - var $modal = $('#modal-order-creation'); - var currentRequest; - - // fix bug bootstrap 3 and select2 - $.fn.modal.Constructor.prototype.enforceFocus = function() {}; - - var timer = null; - function refreshWithTimer($form, event) { - if (timer !== null) { - clearTimeout(timer); - timer = null; - } - timer = setTimeout(function($form){ - $modal.loadAjax(event, getFormData($form, { - 'admin-order-creation-create[action]': 'refresh' - })); - }, 700, $form); - } - - function initSelect($target, allowClear){ - - if (typeof allowClear === "undefined") { - allowClear = false; - } - return $target.select2({ - allowClear: allowClear, - templateResult: function(data){ - if (!data.id) return data.text; - var prefix = data.element.dataset.color ? ' ' : ''; - prefix += (data.element.dataset.ref ? ' ' + data.element.dataset.ref + '' : ''); - return $(prefix + ' ' + data.text + ''); - }, - templateSelection: function(data){ - if (!data.id) return data.text; - var prefix = data.element.dataset.color ? ' ' : ''; - prefix += (data.element.dataset.ref ? ' ' + data.element.dataset.ref + '' : ''); - return $(prefix + ' ' + data.text + ''); - } - }); - } - - function getFormData($form, data){ - var formData = $form.serializeArray(); - - for (var i in formData) { - for (var e in data) { - if (formData[i].name === e) { - formData[i].value = data[e]; - delete data[e]; - } - } - } - - for (var e in data) { - formData.push({ - name: i, - value: data[i] - } - ); - } - - return formData - } - - function initAjaxSelectCustomer($target){ - return $target.select2({ - ajax: { - url: $target.data('url'), - dataType: 'json', - delay: 250, - data: function (params){ - return { - q: params.term, - customerId: $target.data('customer-id') - }; - }, - processResults: function (data){ - return {results: data.items}; - }, - error: function(jqXHR, textStatus){ - if (jqXHR.statusText === 'abort') return; - $target.select2('destroy'); - $modal.displayError(jqXHR, textStatus); - }, - cache: false - }, - minimumInputLength: 3, - placeholder: $target.data('placeholder'), - templateResult: function(data){ - if (data.loading) return data.text; - - var markup = "
"; - markup += data.ref + ' : (' + data.firstname + ' ' + data.lastname + ')' + '
' + data.address + ''; - markup += "
"; - - return $(markup); - }, - templateSelection: function(data){ - if (data.text) { - return data.text; - } - - return data.ref + ' : (' + data.firstname + ' ' + data.lastname + ')'; - } - }); - } - - function initAjaxSelectProduct($target){ - return $target.select2({ - ajax: { - url: $target.data('url'), - dataType: 'json', - delay: 250, - data: function (params){ - return { - q: params.term - }; - }, - processResults: function (data){ - return {results: data.items}; - }, - error: function(jqXHR, textStatus){ - if (jqXHR.statusText === 'abort') return; - $target.select2('destroy'); - $modal.displayError(jqXHR, textStatus); - }, - cache: false - }, - minimumInputLength: 3, - placeholder: $target.data('placeholder'), - templateResult: function(data){ - if (data.loading) return data.text; - - var markup = "
"; - markup += data.ref + ' : ' + data.title; - markup += "
"; - - return $(markup); - }, - templateSelection: function(data){ - if (data.text) { - return data.text; - } - - return data.ref + ' : ' + data.title; - } - }); - } - - /****** Modal methods ******/ - $modal.loaderOff = function(){ - $modal.find('.modal-loader').addClass('hidden'); - $modal.find('.modal-body').removeClass('hidden'); - }; - - $modal.loaderOn = function(){ - $modal.find('.modal-loader').removeClass('hidden'); - $modal.find('.modal-body').addClass('hidden'); - }; - - $modal.reset = function(){ - $modal.hideError(); - $modal.loaderOn(); - }; - - $modal.hideError = function(){ - $modal.find('.modal-error').addClass('hidden').find('iframe').contents().find('html').empty(); - }; - - $modal.displayError = function(jqXHR, textStatus){ - if (jqXHR.statusText === 'abort') return; - $modal.loaderOff(); - $modal.find('.modal-body').addClass('hidden'); - var $error = $modal.find('.modal-error').removeClass('hidden'); - $error.find('.textStatus').html(textStatus); - $error.find('iframe').contents().find('html').html(jqXHR.responseText); - }; - - $modal.modalReady = function(){ - var $form = $modal.find('.modal-body form'); - - var $selectStatus = initSelect($form.find('.js-select-status')); - var $selectCustomer = initAjaxSelectCustomer($form.find('.js-select-customer')); - var $selectProduct = initAjaxSelectProduct($form.find('.js-select-product')); - var $selectProductSaleElement = initSelect($form.find('.js-select-product-sale-element')); - var $selectInvoiceAddress = initSelect($form.find('.js-select-invoice-address')); - var $selectDeliveryAddress = initSelect($form.find('.js-select-delivery-address')); - var $selectCreditNote = initSelect($form.find('.js-select-credit-note'), true); - var $selectCreditNoteStatus = initSelect($form.find('.js-select-credit-note-status')); - var $selectCreditNoteType = initSelect($form.find('.js-select-credit-note-type')); - - $form.on('submit', function(event){ - event.preventDefault(); - - $modal.loadAjax(event, getFormData($form, { - 'admin-order-creation-create[action]': 'create' - })); - }); - - $selectStatus.on('select2:select', function(event){ - $modal.loadAjax(event, getFormData($form, { - 'admin-order-creation-create[action]': 'refresh' - })); - }); - - $selectCustomer.on('select2:select', function(event){ - $modal.loadAjax(event, getFormData($form, { - 'admin-order-creation-create[customer_id]': event.params.data.id, - 'admin-order-creation-create[action]': 'refresh' - })); - }); - - $selectInvoiceAddress.on('select2:select', function(event){ - $modal.loadAjax(event, getFormData($form, { - 'admin-order-creation-create[action]': 'refresh' - })); - }); - - $selectDeliveryAddress.on('select2:select', function(event){ - $modal.loadAjax(event, getFormData($form, { - 'admin-order-creation-create[action]': 'refresh' - })); - }); - - $selectProduct.on('select2:select', function(event){ - $(event.target).parents('tr').find('.js-refresh-price').val('1'); - - $modal.loadAjax(event, getFormData($form, { - 'admin-order-creation-create[action]': 'refresh' - })); - }); - - $selectProductSaleElement.on('select2:select', function(event){ - $(event.target).parents('tr').find('.js-refresh-price').val('1'); - - $modal.loadAjax(event, getFormData($form, { - 'admin-order-creation-create[action]': 'refresh' - })); - }); - - $selectCreditNote.on('select2:select', function(event){ - $modal.loadAjax(event, getFormData($form, { - 'admin-order-creation-create[action]': 'refresh' - })); - }); - - $form.on('change', '.js-field-currency', function(event){ - $modal.loadAjax(event, getFormData($form, { - 'credit-note-create[action]': 'refresh' - })); - }); - - $form.on('change', '.js-action-refresh', function(event){ - if ($(this).val().length) { - refreshWithTimer($form, event); - } - }); - - var currentProductRequestTax; - $form.on('change', '.js-product-price-with-tax, .js-product-price-without-tax', function(event){ - if (currentProductRequestTax) currentProductRequestTax.abort(); - - var $th = $(this), $thr = $(this).parents('tr'); - - var val = parseFloat($(this).val()); - - if (!val) { - val = 0; - } - - currentProductRequestTax = $.ajax({ - url: $(this).data('url'), - dataType: 'json', - data: { - price: val, - tax_rule: this.dataset.taxRuleId - } - }); - - // ajax success - currentProductRequestTax.done(function(data){ - if ($th.hasClass('js-product-price-without-tax')) { - $thr.find('.js-product-price-with-tax').val(data.result); - } else { - $thr.find('.js-product-price-without-tax').val(data.result); - } - - refreshWithTimer($form, event); - }); - - // ajax error - currentProductRequestTax.fail(function(jqXHR, textStatus){ - if (jqXHR.statusText === 'abort') return; - $modal.displayError(jqXHR, textStatus); - }); - }); - - - /***** Product line *****/ - var $tableProductLine = $form.find('.js-table-product-line'); - var templateProductLine = $('#template-order-creation-product-line').html(); - - $tableProductLine.on('click', '.js-action-add', function(event){ - event.preventDefault(); - $(this).data('key', parseInt($(this).data('key')) + 1); - - var templateProductLineKey = templateProductLine.replace(/\[\]/g, '[' + $(this).data('key') + ']'); - $tableProductLine.find('tbody').append(templateProductLineKey); - - var $selectProduct = initAjaxSelectProduct($form.find('.js-table-product-line tbody .js-select-product').last()); - - $selectProduct.on('select2:select', function(event){ - $modal.loadAjax(event, getFormData($form, { - 'admin-order-creation-create[action]': 'refresh' - })); - }); - - /*if ($tableProductLine.find('tbody tr').not('.js-no-free-amount').length) { - $tableProductLine.find('.js-no-free-amount').addClass('hidden'); - } else { - $tableProductLine.find('.js-no-free-amount').removeClass('hidden'); - }*/ - }); - - $tableProductLine.on('click', '.js-action-delete', function(event){ - event.preventDefault(); - $(this).parents('tr').remove(); - - $modal.loadAjax(event, getFormData($form, { - 'admin-order-creation-create[action]': 'refresh' - })); - }); - - var $shippingArea = $form.find('.js-shipping-area'); - - var currentRequestTax; - $shippingArea.on('change', '.js-field-amount-without-tax, .js-field-amount-with-tax', function(event){ - if (currentRequestTax) currentRequestTax.abort(); - - var $th = $(this), $thr = $shippingArea; - - var val = parseFloat($(this).val()); - - if (!val) { - val = 0; - } - - currentRequestTax = $.ajax({ - url: $(this).data('url'), - dataType: 'json', - data: { - price: val, - tax_rule: parseInt($thr.find('.js-field-tax-rule').val()) - } - }); - - // ajax success - currentRequestTax.done(function(data){ - if ($th.hasClass('js-field-amount-without-tax')) { - $thr.find('.js-field-amount-with-tax').val(data.result); - } else { - $thr.find('.js-field-amount-without-tax').val(data.result); - } - - refreshWithTimer($form, event); - }); - - // ajax error - currentRequestTax.fail(function(jqXHR, textStatus){ - if (jqXHR.statusText === 'abort') return; - $modal.displayError(jqXHR, textStatus); - }); - }); - - $shippingArea.on('change', '.js-field-tax-rule', function(event){ - if (currentRequestTax) currentRequestTax.abort(); - - var $th = $(this), $thr = $shippingArea; - - var val = parseFloat($thr.find('.js-field-amount-with-tax').val()); - - if (!val) { - val = 0; - } - - currentRequestTax = $.ajax({ - url: $(this).data('url'), - dataType: 'json', - data: { - price: val, - tax_rule: parseInt($thr.find('.js-field-tax-rule').val()) - } - }); - - // ajax success - currentRequestTax.done(function(data){ - if ($th.hasClass('js-field-amount-without-tax')) { - $thr.find('.js-field-amount-with-tax').val(data.result); - } else { - $thr.find('.js-field-amount-without-tax').val(data.result); - } - - refreshWithTimer($form, event); - }); - - // ajax error - currentRequestTax.fail(function(jqXHR, textStatus){ - if (jqXHR.statusText === 'abort') return; - $modal.displayError(jqXHR, textStatus); - }); - }); - - - - }; - - $modal.loadAjax = function(event, data){ - if (typeof data === 'undefined') { - data = {}; - } - - // kill last ajax request if not if it's not finished - if (currentRequest) currentRequest.abort(); - - // to avoid a display bug with select2 - setTimeout(function(data){ - // ajax start - currentRequest = $.ajax({ - url: $modal.data('ajaxUrl'), - data: data, - method: 'POST' - }); - - // ajax success - currentRequest.done(function(data, textStatus, xhr){ - $modal.loaderOff(); - $modal.find('.modal-body').html(data); - $modal.modalReady(); - }); - - // ajax error - currentRequest.fail(function(jqXHR, textStatus){ - $modal.displayError(jqXHR, textStatus); - }); - }, 100, data); - }; - - $('body').on('click', '#btn-create-order', function(event){ - $modal.modal('show'); - var customerId = $(this).data('customerId'); - var creditNoteId = $(this).data('creditNoteId'); - - $modal.loadAjax(event, { - 'admin-order-creation-create[action]': 'open', - 'admin-order-creation-create[customer_id]': customerId, - 'admin-order-creation-create[credit_note_id]': creditNoteId - }); - }); - - $modal.on('hidden.bs.modal', function(){ - $modal.reset(); - }); - -}()); \ No newline at end of file diff --git a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.edit.js.html b/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.edit.js.html deleted file mode 100644 index ee37f7f3f..000000000 --- a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.edit.js.html +++ /dev/null @@ -1,17 +0,0 @@ - - \ No newline at end of file diff --git a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.js.html b/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.js.html deleted file mode 100644 index 571c53c00..000000000 --- a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.js.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - - -{javascripts file='admin-order-creation/assets/js/script.js' source="AdminOrderCreation"} - -{/javascripts} - \ No newline at end of file diff --git a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.table-header.html b/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.table-header.html deleted file mode 100644 index 70a3027a4..000000000 --- a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/hook/orders.table-header.html +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/include/product-line.html b/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/include/product-line.html deleted file mode 100644 index 0fd5b3dba..000000000 --- a/local/modules/AdminOrderCreation/templates/backOffice/default/admin-order-creation/include/product-line.html +++ /dev/null @@ -1,152 +0,0 @@ - - - {form_field field='product_id' value_key=$key} - {if $orderProduct} - {loop type="product_sale_elements" order="id" name="product-sale-element-price-$key" id=$orderProduct->getProductSaleElementsId() currency=$currency_id backend_context=true} - {$product_id = $PRODUCT_ID} - {/loop} - {/if} - {$taxRuleId = null} -
- -
- {/form_field} - {form_field field='product_sale_element_id' value_key=$key} -
- {if $product_id} - {$attributeCombinations = []} - {$PSE_first = null} - {loop type="product_sale_elements" order="id" name="product-sale-element-$key" product=$product_id currency=$currency_id backend_context=true} - {$PSE_id = $ID} - {if !$PSE_first} - {$PSE_first = $ID} - {/if} - {loop type="attribute_combination" name="attribute-combination-$key" product_sale_elements=$ID backend_context=true} - {$attributeCombinations[$PSE_id][] = $ATTRIBUTE_TITLE|cat:' : '|cat:$ATTRIBUTE_AVAILABILITY_TITLE} - {/loop} - {/loop} - - {if $attributeCombinations|count} - - {else} - {intl l="Default product sale element" d="adminordercreation.bo.default"} - - {loop type="product_sale_elements" order="id" name="product-sale-element-$key" product=$product_id limit=1 currency=$currency_id backend_context=true} - {$productSaleEmenetIdSelected = $ID} - - {/loop} - {/if} - {/if} -
- {/form_field} - - - {if $product_id} - {if $productSaleEmenetIdSelected} - - {loop type="product_sale_elements" order="id" name="product-sale-element-price-$key" id=$productSaleEmenetIdSelected currency=$currency_id backend_context=true} - {form_field field='refresh_price' value_key=$key} - - {/form_field} - - {if $orderProduct->getWasInPromo()} - {$priceWithoutTax = $orderProduct->getPromoPrice()} - {else} - {$priceWithoutTax = $orderProduct->getPrice()} - {/if} - - {$taxes = 0} - {foreach from=$orderProduct->getOrderProductTaxes() item=orderProductTax} - {if $orderProduct->getWasInPromo()} - {$taxes = $taxes + $orderProductTax->getPromoAmount()} - {else} - {$taxes = $taxes + $orderProductTax->getAmount()} - {/if} - {/foreach} - - {form_field field='product_price_without_tax' value_key=$key} -
-
- -
HT
-
-
- {/form_field} - - {form_field field='product_price_with_tax' value_key=$key} -
-
- -
TTC
-
-
- {/form_field} - {/loop} - {/if} - {/if} - - - {form_field field='product_quantity' value_key=$key} -
- {if $product_id} - {loop type="product_sale_elements" order="id" name="product-sale-element-quanaity-$key" id=$productSaleEmenetIdSelected currency=$currency_id backend_context=true} - - {/loop} - {/if} -
- {/form_field} - - - {if $productSaleEmenetIdSelected} - {loop type="product_sale_elements" order="id" name="product-sale-element-price-$key" id=$productSaleEmenetIdSelected currency=$currency_id backend_context=true} -
-
- -
HT
-
-
- -
-
- -
TTC
-
-
- {/loop} - {/if} - - - - - \ No newline at end of file diff --git a/local/modules/OrderCreation/Controller/Admin/OrderCreationAdminController.php b/local/modules/OrderCreation/Controller/Admin/OrderCreationAdminController.php index c2d8e7ffe..f58dc4c91 100644 --- a/local/modules/OrderCreation/Controller/Admin/OrderCreationAdminController.php +++ b/local/modules/OrderCreation/Controller/Admin/OrderCreationAdminController.php @@ -157,11 +157,12 @@ class OrderCreationAdminController extends BaseAdminController $event->setRedirect(0); } + $deliveryModuleId = $formValidate->get(OrderCreationCreateForm::FIELD_NAME_DELIVERY_MODULE_ID)->getData(); $event ->setContainer($this->getContainer()) ->setCustomerId($formValidate->get(OrderCreationCreateForm::FIELD_NAME_CUSTOMER_ID)->getData()) ->setDeliveryAddressId($formValidate->get(OrderCreationCreateForm::FIELD_NAME_DELIVERY_ADDRESS_ID)->getData()) - ->setDeliveryModuleId($formValidate->get(OrderCreationCreateForm::FIELD_NAME_DELIVERY_MODULE_ID)->getData()) + ->setDeliveryModuleId($deliveryModuleId) ->setInvoiceAddressId($formValidate->get(OrderCreationCreateForm::FIELD_NAME_INVOICE_ADDRESS_ID)->getData()) ->setPaymentModuleId($formValidate->get(OrderCreationCreateForm::FIELD_NAME_PAYMENT_MODULE_ID)->getData()) ->setProductSaleElementIds($formValidate->get(OrderCreationCreateForm::FIELD_NAME_PRODUCT_SALE_ELEMENT_ID)->getData()) diff --git a/local/modules/OrderCreation/templates/backOffice/default/customer-edit-js.html b/local/modules/OrderCreation/templates/backOffice/default/customer-edit-js.html index 91c71e5b0..7fe8e2c60 100644 --- a/local/modules/OrderCreation/templates/backOffice/default/customer-edit-js.html +++ b/local/modules/OrderCreation/templates/backOffice/default/customer-edit-js.html @@ -150,7 +150,7 @@ $listDelivery.removeClass('loading'); $listDelivery.html(response); - $('#list-delivery input.delivery-method').each(function () { + $('#list-delivery input.js-change-delivery-method').each(function () { if ($(this).is(':checked')) { $('#delivery-module').val($(this).val()); } @@ -185,7 +185,7 @@ } }); - $listDelivery.on('change', '.delivery-method', function () { + $listDelivery.on('change', '.js-change-delivery-method', function () { $('#delivery-module').val($(this).val()); }); diff --git a/local/modules/OrderCreation/templates/backOffice/default/forms/create-order-form.html b/local/modules/OrderCreation/templates/backOffice/default/forms/create-order-form.html index 4c96d6d3b..76b409dfc 100644 --- a/local/modules/OrderCreation/templates/backOffice/default/forms/create-order-form.html +++ b/local/modules/OrderCreation/templates/backOffice/default/forms/create-order-form.html @@ -103,6 +103,7 @@
+ {custom_render_form_field field='delivery-module'}
@@ -125,7 +126,7 @@
-
+
{render_form_field field='redirects_payment'}