Ejemplo n.º 1
0
 public function renderView()
 {
     global $cookie;
     if (Module::isInstalled('agilemultipleseller') && !intval(Tools::getValue('id_product')) and $this->is_seller and AgileSellerManager::limited_by_membership($cookie->id_employee)) {
         $this->errors[] = Tools::displayError('You have not purchased membership yet or you have registered products more than limit allowed by your membership.');
         return;
     }
     return parent::renderView();
 }
Ejemplo n.º 2
0
 public function postProcess()
 {
     if (Module::isInstalled('aplazame') && Module::isEnabled('aplazame')) {
         if (Tools::isSubmit('id_order') && Tools::getValue('id_order') > 0) {
             $order = new Order(Tools::getValue('id_order'));
             if (Validate::isLoadedObject($order)) {
                 if (Tools::isSubmit('partialRefund') && isset($order)) {
                     if ($this->tabAccess['edit'] == '1') {
                         if (is_array($_POST['partialRefundProduct'])) {
                             $amount = 0;
                             $order_detail_list = array();
                             foreach ($_POST['partialRefundProduct'] as $id_order_detail => $amount_detail) {
                                 $order_detail_list[$id_order_detail] = array('quantity' => (int) $_POST['partialRefundProductQuantity'][$id_order_detail], 'id_order_detail' => (int) $id_order_detail);
                                 $order_detail = new OrderDetail((int) $id_order_detail);
                                 if (empty($amount_detail)) {
                                     $order_detail_list[$id_order_detail]['unit_price'] = $order_detail->unit_price_tax_excl;
                                     $order_detail_list[$id_order_detail]['amount'] = $order_detail->unit_price_tax_incl * $order_detail_list[$id_order_detail]['quantity'];
                                 } else {
                                     $order_detail_list[$id_order_detail]['unit_price'] = (double) str_replace(',', '.', $amount_detail / $order_detail_list[$id_order_detail]['quantity']);
                                     $order_detail_list[$id_order_detail]['amount'] = (double) str_replace(',', '.', $amount_detail);
                                 }
                                 $amount += $order_detail_list[$id_order_detail]['amount'];
                             }
                             $choosen = false;
                             $voucher = 0;
                             if ((int) Tools::getValue('refund_voucher_off') == 1) {
                                 $amount -= $voucher = (double) Tools::getValue('order_discount_price');
                             } elseif ((int) Tools::getValue('refund_voucher_off') == 2) {
                                 $choosen = true;
                                 $amount = $voucher = (double) Tools::getValue('refund_voucher_choose');
                             }
                             $shipping_cost_amount = (double) str_replace(',', '.', Tools::getValue('partialRefundShippingCost')) ? (double) str_replace(',', '.', Tools::getValue('partialRefundShippingCost')) : false;
                             if ($shipping_cost_amount > 0) {
                                 $amount += $shipping_cost_amount;
                             }
                             if ($amount > 0) {
                                 if (!Tools::isSubmit('generateDiscountRefund') && $order->module == 'aplazame') {
                                     $aplazame = ModuleCore::getInstanceByName('aplazame');
                                     $aplazame->refundAmount($order, $amount);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     parent::postProcess();
 }
 public function renderList()
 {
     if (Tools::isSubmit('viewReturns')) {
         $id_order = Tools::getValue('id_order', 0);
         if ($id_order) {
             $module = new Yamodule();
             $params = array('order' => new Order($id_order));
             $this->content .= $module->displayReturnsContentTabs($params);
             $this->content .= $module->displayReturnsContent($params);
         } else {
             $this->errors[] = $this->l('There is no order number!');
         }
     } else {
         return parent::renderList();
     }
 }
Ejemplo n.º 4
0
 public function setMedia()
 {
     parent::setMedia();
     $js_files = array('js/admin/orders.js');
     PSM::amendJS($this->context->controller->js_files, $js_files);
 }
 /**
  * Override for Prestashop 16
  */
 private function initToolbar16()
 {
     if ($this->display == 'view') {
         /** @var Order $order */
         $order = $this->loadObject();
         $customer = $this->context->customer;
         if (!Validate::isLoadedObject($order)) {
             Tools::redirectAdmin($this->context->link->getAdminLink('AdminOrders'));
         }
         $this->toolbar_title[] = sprintf($this->l('Order %1$s from %2$s %3$s'), $order->reference, $customer->firstname, $customer->lastname);
         $this->addMetaTitle($this->toolbar_title[count($this->toolbar_title) - 1]);
         if ($order->hasBeenShipped()) {
             $type = $this->l('Return products');
         } elseif ($order->hasBeenPaid()) {
             $type = $this->l('Standard refund');
         } else {
             $type = $this->l('Cancel products');
         }
         if (!$order->hasBeenShipped() && !$this->lite_display) {
             $this->toolbar_btn['new'] = array('short' => 'Create', 'href' => '#', 'desc' => $this->l('Add a product'), 'class' => 'add_product');
         }
         if (Configuration::get('PS_ORDER_RETURN') && !$this->lite_display) {
             $this->toolbar_btn['standard_refund'] = array('short' => 'Create', 'href' => '', 'desc' => $type, 'class' => 'process-icon-standardRefund');
         }
         if ($order->hasInvoice() && !$this->lite_display) {
             $this->toolbar_btn['partial_refund'] = array('short' => 'Create', 'href' => '', 'desc' => $this->l('Partial refund'), 'class' => 'process-icon-partialRefund');
         }
     }
     if (class_exists('DynamicParcelDistribution')) {
         if (DynamicParcelDistribution::isEnabled('dynamicparceldistribution') && Configuration::get(DynamicParcelDistribution::CONST_PREFIX . 'ALLOW_COURIER_PICKUP')) {
             $this->toolbar_btn['call_carrier'] = array('short' => 'Create', 'href' => '#', 'desc' => $this->l('Call DPD Carrier'), 'class' => 'process-icon-callCarrier', 'js' => 'showCarrierWindow()');
         }
     }
     $res = parent::initToolbar();
     if (Context::getContext()->shop->getContext() != Shop::CONTEXT_SHOP && isset($this->toolbar_btn['new']) && Shop::isFeatureActive()) {
         unset($this->toolbar_btn['new']);
     }
     return $res;
 }