示例#1
0
 public function hookAdminOrder($params)
 {
     $shipment = new DpdGroupShipment((int) $params['id_order']);
     if (Tools::isSubmit('printLabels')) {
         $pdf_file_contents = $shipment->getLabelsPdf();
         if ($pdf_file_contents) {
             ob_end_clean();
             header('Content-type: application/pdf');
             header('Content-Disposition: attachment; filename="shipment_labels_' . (int) Tools::getValue('id_order') . '.pdf"');
             echo $pdf_file_contents;
         } else {
             $this->addFlashError(reset(DpdGroupShipment::$errors));
             Tools::redirectAdmin(self::getAdminOrderLink() . '&id_order=' . (int) $params['id_order']);
         }
     }
     $this->displayFlashMessagesIfIsset();
     $order = new Order((int) $params['id_order']);
     $customer = new Customer($order->id_customer);
     $products = $shipment->getParcelsSetUp($order->getProductsDetail());
     if ($shipment->parcels) {
         DpdGroupParcel::addParcelDataToProducts($products, $order->id);
     }
     $id_method = self::getMethodIdByCarrierId($order->id_carrier);
     DpdGroupWS::$parcel_weight_warning_message = false;
     $price = $shipment->calculatePriceForOrder((int) $id_method, $order->id_address_delivery, $products);
     $carrier = new Carrier((int) $order->id_carrier, $order->id_lang);
     $ws_shipping_price = $price !== false ? $price : '---';
     $total_shipping = version_compare(_PS_VERSION_, '1.5', '>=') ? $order->total_shipping_tax_incl : $order->total_shipping;
     $this->context->smarty->assign(array('order' => $order, 'module_link' => $this->getModuleLink('AdminModules'), 'settings' => new DpdGroupConfiguration(), 'total_weight' => DpdGroupShipment::convertWeight($order->getTotalWeight()), 'shipment' => $shipment, 'selected_shipping_method_id' => $id_method, 'ws_shippingPrice' => $price !== false ? $price : '---', 'products' => $products, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'carrier_url' => $carrier->url, 'order_link' => self::getAdminOrderLink() . '&id_order=' . (int) Tools::getValue('id_order'), 'errors' => $this->getErrorMessagesForOrderPage(), 'warnings' => $this->getWarningMessagesForOrderPage($shipment->id_shipment, $id_method, $ws_shipping_price, $total_shipping), 'force_enable_button' => DpdGroupWS::$parcel_weight_warning_message, 'display_product_weight_warning' => $this->orderProductsWithoutWeight($products)));
     if (!$this->ps_14) {
         $this->context->controller->addJS(_DPDGROUP_JS_URI_ . 'jquery.bpopup.min.js');
         $this->context->controller->addJS(_DPDGROUP_JS_URI_ . 'adminOrder.js');
         $css_filename = $this->bootstrap ? 'adminOrder_16' : 'adminOrder';
         $this->context->controller->addCSS(_DPDGROUP_CSS_URI_ . $css_filename . '.css');
     }
     $this->setGlobalVariablesForAjax();
     $template_filename = $this->bootstrap ? 'adminOrder_16' : 'adminOrder';
     return $this->context->smarty->fetch(_DPDGROUP_TPL_DIR_ . 'hook/' . $template_filename . '.tpl');
 }
示例#2
0
 protected function getError($result)
 {
     if (is_object($result)) {
         $result = $this->objectToArray($result);
     }
     $transaction_id = isset($result['transactionId']) ? '; ' . $this->l('Transaction Id:') . ' ' . $result['transactionId'] : '';
     $error_text = '';
     $error_code = '';
     if (isset($result['detail']['EShopException']['error']['text'])) {
         $error_text = $result['detail']['EShopException']['error']['text'];
         if (isset($result['detail']['EShopException']['error']['code'])) {
             $error_code = $result['detail']['EShopException']['error']['code'];
         }
     } elseif (isset($result['priceList']['error']['text'])) {
         $error_text = $result['priceList']['error']['text'];
         if (isset($result['priceList']['error']['code'])) {
             $error_code = $result['priceList']['error']['code'];
         }
     } elseif (isset($result['resultList']['error']['text'])) {
         $error_text = $result['resultList']['error']['text'];
         if (isset($result['resultList']['error']['code'])) {
             $error_code = $result['resultList']['error']['code'];
         }
     } elseif (isset($result['error']['text'])) {
         $error_text = $result['error']['text'];
         if (isset($result['error']['code'])) {
             $error_code = $result['error']['code'];
         }
     } elseif (isset($result['prestashop_message'])) {
         self::$errors[] = $result['prestashop_message'] . $transaction_id;
     }
     $message = $this->getTranslatableMessage($error_code);
     if ($error_code == self::ID_WEIGHT_ERROR_MESSAGE) {
         self::$parcel_weight_warning_message = true;
         self::$notices[] = $error_text . $transaction_id;
         if ($message) {
             self::$notices[] = $message;
         }
     } else {
         if ($error_text) {
             self::$errors[] = $error_text . $transaction_id;
         }
         if ($message) {
             self::$errors[] = $message;
         }
     }
 }
示例#3
0
$filename = 'dpdgroup.ajax';
if (Tools::getValue('token') != sha1(_COOKIE_KEY_ . $module_instance->name) || !$module_instance instanceof DpdGroup) {
    exit;
}
if (Tools::isSubmit('testConnectivity')) {
    require_once _DPDGROUP_CONTROLLERS_DIR_ . 'Configuration.controller.php';
    $configuration_controller = new DpdGroupConfigurationController();
    if ((int) Tools::getValue('other_country')) {
        $error_message = $configuration_controller->testConnection((int) Tools::getValue('production_mode'), Tools::getValue('production_ws_url'), Tools::getValue('test_ws_url'));
    } else {
        $error_message = $configuration_controller->validateCountryConfiguration(Tools::getValue('ws_country'));
    }
    die($error_message ? $error_message : true);
}
if (Tools::isSubmit('calculatePrice')) {
    DpdGroupWS::$parcel_weight_warning_message = false;
    $id_order = (int) Tools::getValue('id_order');
    $shipment = new DpdGroupShipment((int) $id_order);
    $price = $shipment->calculatePriceForOrder((int) Tools::getValue('method_id'), (int) Tools::getValue('id_address'));
    $errors = array();
    if (DpdGroupShipment::$errors) {
        $errors = DpdGroupShipment::$errors;
    }
    $price = $price !== false ? $price : '---';
    $notices = DpdGroupShipment::$notices;
    $order = new Order((int) $id_order);
    $total_shipping = version_compare(_PS_VERSION_, '1.5', '>=') ? $order->total_shipping_tax_incl : $order->total_shipping;
    if (DpdGroupShipment::$errors) {
        $errors = array_merge($errors, DpdGroupShipment::$errors);
    }
    if (!$shipment->id_shipment && !(int) Tools::getValue('method_id')) {