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'); }
} 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')) { $notices[] = $module_instance->l('Client did not selected DPD shipment, but you can use this shipment method.', $filename); } if ($price > 0 && $price > $total_shipping) {