private function init() { if (Tools::isSubmit('printManifest')) { if ($shipment_ids = Tools::getValue('ShipmentsBox')) { $manifest = new DpdGroupManifest(); $manifest->shipments = $shipment_ids; if ($pdf_content = $manifest->printManifest()) { foreach ($shipment_ids as $id_shipment) { $shipment = new DpdGroupShipment(); $shipment->getAndSaveTrackingInfo((int) $id_shipment); } ob_end_clean(); header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="manifest_' . time() . '.pdf"'); echo $pdf_content; exit; } else { $this->module_instance->outputHTML($this->module_instance->displayError(reset(DpdGroupManifest::$errors))); } } else { $this->module_instance->outputHTML($this->module_instance->displayError($this->l('No selected shipments'))); } } if (Tools::isSubmit('printLabels')) { if ($shipment_ids = Tools::getValue('ShipmentsBox')) { $shipment = new DpdGroupShipment(); if ($pdf_content = $shipment->getLabelsPdf($shipment_ids)) { ob_end_clean(); header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="shipment_labels_' . time() . '.pdf"'); echo $pdf_content; } else { $this->module_instance->outputHTML($this->module_instance->displayError(reset(DpdGroupManifest::$errors))); } } else { $this->module_instance->outputHTML($this->module_instance->displayError($this->l('Select at least one shipment'))); } } if (Tools::isSubmit('changeOrderStatus')) { if ($shipment_ids = Tools::getValue('ShipmentsBox')) { foreach ($shipment_ids as $id_shipment) { $id_order = DpdGroupShipment::getOrderIdByShipmentId((int) $id_shipment); if (!self::changeOrderStatusToShipped($id_order)) { self::$errors[] = sprintf($this->l('Can not continue: shipment #%d order status could not be updated'), $id_shipment); break; } } if (self::$errors) { $this->module_instance->outputHTML($this->module_instance->displayError(reset(self::$errors))); } else { DpdGroup::addFlashMessage($this->l('Selected orders statuses were successfully updated')); Tools::redirectAdmin($this->module_instance->module_url . '&menu=shipment_list'); } } else { $this->module_instance->outputHTML($this->module_instance->displayError($this->l('Select at least one shipment'))); } } }
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'); }
* that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to telco.csee@geopost.pl so we can send you a copy immediately. * * @author JSC INVERTUS www.invertus.lt <*****@*****.**> * @copyright 2015 DPD Polska sp. z o.o. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of DPD Polska sp. z o.o. */ include_once dirname(__FILE__) . '/../../config/config.inc.php'; include_once dirname(__FILE__) . '/../../init.php'; $module_instance = Module::getInstanceByName('dpdgroup'); if (Tools::getValue('token') != sha1(_COOKIE_KEY_ . $module_instance->name)) { exit; } if (Tools::isSubmit('printLabels')) { $shipment = new DpdGroupShipment((int) Tools::getValue('id_order')); $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 { echo reset(DpdGroupShipment::$errors); exit; } }