public function getSettingsPage()
 {
     $configuration_obj = new DpdPolandConfiguration();
     $payment_modules = array();
     foreach (DpdPoland::getPaymentModules() as $payment_module) {
         $module = Module::getInstanceByName($payment_module['name']);
         if (!Validate::isLoadedObject($module)) {
             continue;
         }
         $payment_modules[] = array('displayName' => $module->displayName, 'name' => $payment_module['name']);
     }
     $this->context->smarty->assign(array('saveAction' => $this->module_instance->module_url, 'settings' => $configuration_obj, 'payer_numbers' => DpdPolandPayerNumber::getPayerNumbers(), 'payment_modules' => $payment_modules, 'zones' => Zone::getZones(), 'carrier_zones' => array('classic' => $this->getZonesForCarrier(DpdPolandConfiguration::CARRIER_CLASSIC_ID), 'standard' => $this->getZonesForCarrier(DpdPolandConfiguration::CARRIER_STANDARD_ID), 'standard_cod' => $this->getZonesForCarrier(DpdPolandConfiguration::CARRIER_STANDARD_COD_ID))));
     if (version_compare(_PS_VERSION_, '1.6', '>=')) {
         return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_ . 'admin/configuration_16.tpl');
     }
     return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_ . 'admin/configuration.tpl');
 }
Ejemplo n.º 2
0
 public function hookAdminOrder($params)
 {
     if (!$this->soapClientExists()) {
         return '';
     }
     $order = new Order((int) $params['id_order']);
     if (!DpdPolandConfiguration::checkRequiredConfiguration()) {
         $this->context->smarty->assign(array('displayBlock' => false, 'moduleSettingsLink' => $this->context->link->getAdminLink('AdminModules') . '&configure=' . $this->name . '&menu=configuration'));
     } else {
         $this->displayFlashMessagesIfIsset();
         // PDF error might be set as flash error
         $order = new Order((int) $params['id_order']);
         $package = DpdPolandPackage::getInstanceByIdOrder((int) $order->id);
         $parcels = DpdPolandParcel::getParcels($order, $package->id_package_ws);
         $products = DpdPolandParcelProduct::getShippedProducts($order, DpdPolandParcelProduct::getProductDetailsByParcels($parcels));
         $customer = new Customer((int) $order->id_customer);
         $settings = new DpdPolandConfiguration();
         if (version_compare(_PS_VERSION_, '1.5', '<')) {
             $this->addJS(_PS_JS_DIR_ . 'jquery/jquery.scrollTo-1.4.2-min.js');
             $this->addJS(_PS_JS_DIR_ . 'jquery/jquery-ui-1.8.10.custom.min.js');
             $this->addJS(_PS_JS_DIR_ . 'jquery/accordion/accordion.ui.js');
             $this->addJS(_PS_JS_DIR_ . 'jquery/jquery.autocomplete.js');
             $this->addJS(_DPDPOLAND_JS_URI_ . 'adminOrder.js');
             $this->addCSS(_DPDPOLAND_CSS_URI_ . 'adminOrder.css');
             $this->addCSS(_PS_CSS_DIR_ . 'jquery-ui-1.8.10.custom.css');
         } else {
             $this->context->controller->addJqueryUI(array('ui.core', 'ui.widget', 'ui.accordion'));
             $this->context->controller->addJqueryPlugin('scrollTo');
             $this->context->controller->addJS(_DPDPOLAND_JS_URI_ . 'adminOrder.js');
             $this->context->controller->addCSS(_DPDPOLAND_CSS_URI_ . 'adminOrder.css');
         }
         $selectedPayerNumber = $package->payerNumber ? $package->payerNumber : $settings->client_number;
         $selectedRecipientIdAddress = $package->id_address_delivery ? $package->id_address_delivery : $order->id_address_delivery;
         $id_currency_pl = Currency::getIdByIsoCode(_DPDPOLAND_CURRENCY_ISO_, (int) $this->context->shop->id);
         $currency_to = new Currency((int) $id_currency_pl);
         $currency_from = new Currency($order->id_currency);
         $id_method = $this->getMethodIdByCarrierId((int) $order->id_carrier);
         if ($id_method) {
             $payment_method_compatible = false;
             $is_cod_module = Configuration::get(DpdPolandConfiguration::COD_MODULE_PREFIX . $order->module);
             if ($id_method == _DPDPOLAND_STANDARD_COD_ID_ && $is_cod_module || $id_method == _DPDPOLAND_STANDARD_ID_ && !$is_cod_module || $id_method == _DPDPOLAND_CLASSIC_ID_ && !$is_cod_module) {
                 $payment_method_compatible = true;
             }
         } else {
             $payment_method_compatible = true;
         }
         if (!$payment_method_compatible) {
             $error_message = $this->l('Your payment method and Shipping method is not compatible.') . '<br />';
             $error_message .= ' ' . $this->l('If delivery address is not Poland, then COD payment method is not supported.') . '<br />';
             $error_message .= ' ' . $this->l('If delivery address is not Poland, then COD payment method is not supported.') . '<br />';
             $error_message .= ' ' . $this->l('If delivery address is Poland and payment method is COD please use shipping method DPD Domestic + COD.') . '<br />';
             $error_message .= ' ' . $this->l('If delivery address is Poland and no COD payment is used please select DPD Domestic shipping method.');
             $this->context->smarty->assign('compatibility_warning_message', $error_message);
         }
         if (!$this->validateAddressForPackageSession((int) $selectedRecipientIdAddress, (int) $id_method)) {
             $error_message = $this->l('Your develivery address is not compatible with the selected shipping method.') . ' ' . $this->l('DPD Poland Domestic is available only if develivery address is Poland.') . ' ' . $this->l('DPD Internationl shipping method is available only if delivery address is not Poland.');
             $this->context->smarty->assign('address_warning_message', $error_message);
         }
         $cookie = new Cookie(_DPDPOLAND_COOKIE_);
         $this->context->smarty->assign(array('displayBlock' => true, 'order' => $order, 'messages' => $this->html, 'package' => $package, 'selected_id_method' => self::getMethodIdByCarrierId($order->id_carrier), 'settings' => $settings, 'payerNumbers' => DpdPolandPayerNumber::getPayerNumbers(), 'selectedPayerNumber' => $selectedPayerNumber, 'products' => $products, 'parcels' => $parcels, 'senderAddress' => $this->getSenderAddress($settings, $package->id_address_sender), 'recipientAddresses' => $customer->getAddresses($this->context->language->id), 'selectedRecipientIdAddress' => $selectedRecipientIdAddress, 'recipientAddress' => $this->getRecipientAddress($selectedRecipientIdAddress), 'currency_from' => $currency_from, 'currency_to' => $currency_to, 'redirect_and_open' => $cookie->dpdpoland_package_id, 'printout_format' => $cookie->dpdpoland_printout_format));
         $this->setGlobalVariablesForAjax();
     }
     if (version_compare(_PS_VERSION_, '1.6', '<')) {
         return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_ . 'hook/adminOrder.tpl');
     }
     return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_ . 'hook/adminOrder_16.tpl');
 }