public function getDHLRates($id_zone, $is_cart, $cart, $product_weight, $dest_zip, $dest_state, $dest_country, $currency, $product, $id_product_attribute, $qty, $dest_city) { $rates = array(); if (file_exists(dirname(__FILE__) . '/../../dhl/classes/RateAvailableServices.php')) { include_once dirname(__FILE__) . '/../../dhl/dhl.php'; include_once dirname(__FILE__) . '/../../dhl/classes/RateAvailableServices.php'; $dhl = new DHL(); if ($dhl->active) { // Get handling cost (once) $handling = Configuration::get('PS_SHIPPING_HANDLING'); $carriers = $dhl->getCarriers($id_zone, $cart, $is_cart, $product); $dhl_rate = new DHLRate(); foreach ($carriers as $carrier) { $amount = $dhl_rate->getRate($carrier['id_carrier'], $carrier['id_zone'], $is_cart != '' ? $cart->getTotalWeight() : max($product_weight, 0.001), $dest_zip, "", $dest_country, $dest_city, $is_cart != '' ? 0 : $product->getPrice(true, $id_product_attribute, 6, NULL, false, true, $qty), $is_cart != '' ? 0 : $product->id, $is_cart != '' ? 0 : $id_product_attribute, $qty); // Add product spercific cost + handling fee if ($amount > 0) { $amount += $this->getExtraShippingCost($carrier, $handling, $is_cart != '' ? $cart->getProducts() : array(), $product, $qty); } // Apply shipping tax if needed if (!Tax::excludeTaxeOption()) { $carrierTax = Tax::getCarrierTaxRate($carrier['id_carrier']); } if (isset($carrierTax) && $amount !== false) { $amount *= 1 + $carrierTax / 100; } $amount = $amount === false ? -1 : Tools::convertPrice($amount, $currency); if ($amount > 0) { $rates[$carrier['name']] = array(Tools::displayPrice($amount, $currency, false), $carrier['id_carrier']); } elseif ($amount !== false && $amount == 0) { $rates[$carrier['name']] = array($dhl->l('Free!'), $carrier['id_carrier']); } } } } return $rates; }
unset($pack); } else { $pack_dim = isset($data['pack']) ? $data['pack'] : array(); } //previously generated labels $types = $dhl->getLabelTypes(); $prev_lab_html = ''; foreach ($types as $type) { $files = glob('labels/' . $id_order . '/*.' . $type); if (is_array($files) and sizeof($files) > 0) { $prev_lab_html .= strtoupper($type) . ': '; foreach ($files as $file) { $number = array(); preg_match('/.*_(.+)\\.' . $type . '/', $file, $number); $number = $number[1]; $prev_lab_html .= '<a target="_index" style="text-decoration:underline;" href="' . _MODULE_DIR_ . $dhl->name . '/' . $file . '">' . $dhl->l('Label #', 'ajaxLabelSettings') . $number . '</a>, '; } $prev_lab_html = substr($prev_lab_html, 0, strlen($prev_lab_html) - 2); $prev_lab_html .= '<br>'; } } $html = ' <link type="text/css" rel="stylesheet" href="' . _MODULE_DIR_ . $dhl->name . '/css/tooltipster.css" /> <script type="text/javascript" src="' . _MODULE_DIR_ . $dhl->name . '/js/jquery.tooltipster.min.js"></script> <fieldset style="padding:8px; font-weight:normal; margin:5px 0 10px 0; font-size:13px;"> <legend>' . $dhl->l('Addresses', 'ajaxLabelSettings') . '</legend> <div style="float:left;width: 48%;margin: 0 4% 0 0"> <h3>' . $dhl->l('Shipper', 'ajaxLabelSettings') . '</h3>
if (substr(_PS_VERSION_, 0, 3) == '1.5' && Tools::getValue('id_employee')) { $context = Context::getContext(); $context->cookie->id_employee = Tools::getValue('id_employee'); $context->employee = new Employee(Tools::getValue('id_employee')); } include_once dirname(__FILE__) . '/dhl.php'; include_once dirname(__FILE__) . '/classes/LabelPrinting.php'; $dhl = new DHL(); $LabelPrinting = new LabelPrinting(); if (Tools::getValue('dhl_random') != $dhl->_dhl_random) { exit; } if (Tools::isSubmit('shippingLabel') and Tools::isSubmit('id_order')) { $label = $LabelPrinting->getShippingLabel(Tools::getValue('id_order')); $ajax = Tools::getValue('ajax'); $tryagain = $ajax == 1 ? $dhl->l('Please change incorrect settings and try again.', 'display_label') : $dhl->l('Please close this tab and change incorrect settings at previous page.', 'display_label'); $html = ''; $tempLabels = array(); if (isset($label['errors']) && is_array($label['errors']) && count($label['errors'])) { $html .= '<p style="color: red;margin: 20px 0 0 0;border: 1px solid;padding: 5px;"><span style="font-weight:bold;">' . $dhl->l('There is ', 'display_label') . count($label['errors']) . $dhl->l(' error(s)', 'display_label') . '</span><br /><br />'; foreach ($label['errors'] as $error) { $html .= ($error['HelpContext'] ? '[#' . $error['HelpContext'] . '] ' : '- ') . $error['Description'] . '<br />'; } $html .= '<br />' . $tryagain . '</p>'; } elseif ($label[0] == 0) { $html .= '<p style="color: red;margin: 20px 0 0 0;border: 1px solid;padding: 5px;"><span style="font-weight:bold;">' . $dhl->l('Error', 'display_label') . ':</span> ' . $label[1] . '<br /><br />' . $tryagain . '</p>'; } elseif ($label[0] == 1) { //create folder for labels of this order $folder = 'labels/' . Tools::getValue('id_order'); if (!file_exists($folder)) { mkdir($folder);
} } else { $sorted = $dhl->_dhl_boxes; } } } if (!is_array($sorted)) { $sorted = array(); } Configuration::updateValue('DHL_BOXES', serialize($sorted)); if (sizeof($sorted) > 0) { $html = ' <table width="100%"> <tr height="31"> <td align="left" width="35%"> ' . $dhl->l('Name', 'manage_boxes') . ' <span class="info_tooltip" title=" ' . $dhl->l('After adding a name or changing box dimensions, click') . ' <img src=\'' . _MODULE_DIR_ . 'dhl/img/update.gif\' /> ' . $dhl->l('to save') . '. <br /><br /> ' . $dhl->l('Box name is optional, it is only used for internal organization') . ' "></span> </td> <td align="left">' . $dhl->l('Width') . ' </td> <td align="left">' . $dhl->l('Height') . ' </td> <td align="left">' . $dhl->l('Depth') . ' </td> <td align="left"><span title="' . $dhl->l('Max Weight') . '">' . $dhl->l('Max W') . '</span> </td> ' . ($exceptions ? '<td align="left">' . $dhl->l('Exceptions') . ' </td>' : '') . ' <td align="left" width="20"> </td>