/** * Get orders details to create Tickets * * @static * @param array $orderIdList * @param int $filterEntries * @param int $weight_coefficient * @return array */ public static function getOrders($orderIdList = array(), $filterEntries = MondialRelay::NO_FILTER, $weight_coefficient = 0) { $account_shop = MondialRelay::getAccountDetail(); $id_order_state = $account_shop['MR_ORDER_STATE']; $sql = MondialRelay::getBaseOrdersSQLQuery($id_order_state, $weight_coefficient); if (count($orderIdList)) { $sql .= ' AND o.id_order IN ('; foreach ($orderIdList as $id_order) { $sql .= (int) $id_order . ', '; } $sql = rtrim($sql, ', ') . ')'; } switch ($filterEntries) { case MondialRelay::WITHOUT_HOME_DELIVERY: $sql .= 'AND mr.mr_ModeLiv != "LD1" AND mr.mr_ModeLiv != "LDS"'; break; } $sql .= ' GROUP BY o.`id_order` ORDER BY o.`date_add` ASC'; return Db::getInstance()->executeS($sql); }
public function renderList() { $this->toolbar_title = $this->l('Order Management'); $statuses_array = array(); $statuses = ErpOrderState::getOrderStates((int) $this->context->language->id); foreach ($statuses as $status) { $statuses_array[$status['id_order_state']] = $status['name']; } require_once _PS_MODULE_DIR_ . 'erpillicopresta/models/ErpFeature.php'; $this->context->smarty->assign(array('token_mr' => ModuleCore::isEnabled('mondialrelay') ? MondialRelay::getToken('back') : 'false', 'token_expeditor' => ModuleCore::isEnabled('expeditor') ? Tools::getAdminToken('AdminExpeditor' . (int) Tab::getIdFromClassName('AdminExpeditor') . (int) $this->context->employee->id) : 'false', 'id_employee' => (int) $this->context->employee->id, 'order_statuses' => $statuses_array, 'controller_status' => $this->controller_status, 'erp_feature' => ErpFeature::getFeaturesWithToken($this->context->language->iso_code), 'template_path' => $this->template_path, 'expeditor_status' => Configuration::get('EXPEDITOR_STATE_EXP'), '_module_dir_' => _MODULE_DIR_)); $this->tpl_list_vars['has_bulk_actions'] = 'true'; // handle may contain error messages $handle = Tools::getValue('handle'); switch (trim($handle)) { case '': break; case 'false': $this->confirmations[] = $this->l('All orders have been updated') . '<br/>'; break; default: if (!empty($handle)) { // $handle = str_replace('u00e9', 'é', $handle); // $handle = str_replace('u00ea', 'ê', $handle); $handle = Tools::replaceAccentedChars($handle); // We take note about orders with error: no valid carrier (split on order number #) $orderWithoutShipping = strstr($handle, '#') != false ? true : false; $errors = explode('<br/>', str_replace('#', '<br/>', $handle)); foreach ($errors as $key => $error) { if (!empty($error)) { if (!$orderWithoutShipping) { $message = $error; } else { $message = $error; } $this->errors[] = Tools::displayError($message); } } } break; } if (Tools::getValue('linkPDF') != '' && Tools::getValue('newState') != '') { // if state need invoice generation if (ErpOrderState::invoiceAvailable(Tools::getValue('newState'))) { $pdf_link = new Link(); $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateInvoicesPDF3&id_orders=' . Tools::getValue('linkPDF'); $this->confirmations[] = ' <a target="_blank" href="' . $pdf_link . '" alt="invoices">' . $this->l('Download all invoices') . '<br/></a>'; } // if state need delivery slip generation if (ErpOrderState::deliverySlipAvailable(Tools::getValue('newState'))) { $pdf_link = new Link(); $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateDeliverySlipsPDF2&id_orders=' . Tools::getValue('linkPDF'); $this->confirmations[] = ' <a target="_blank" href="' . $pdf_link . '" alt="delivery">' . $this->l('Download all delivery slip') . '<br/></a>'; } } if (Tools::getValue('linkPDFPrint') != '') { if ($this->controller_status == STATUS1 && count(explode(',', Tools::getValue('linkPDFPrint'))) > ERP_ORDERFR) { $this->informations[] = sprintf($this->l('You are using the free version of 1-Click ERP which limits the possible number of documents to print to %d orders'), ERP_ORDERFR); } else { $invoices = ''; $delivery = ''; foreach (explode(',', Tools::getValue('linkPDFPrint')) as $id_order) { if (ErpOrderState::invoiceAvailable(ErpOrder::getIdStateByIdOrder($id_order))) { $invoices .= $id_order . ','; } if (ErpOrderState::deliverySlipAvailable(ErpOrder::getIdStateByIdOrder($id_order))) { $delivery .= $id_order . ','; } } if ($invoices != '') { $pdf_link = new Link(); $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateInvoicesPDF3&id_orders=' . Tools::substr($invoices, 0, -1); $this->confirmations[] = ' <a target="_blank" href="' . $pdf_link . '" alt="invoices">' . $this->l('Download all invoices') . '</br></a>'; } if ($delivery != '') { $pdf_link = new Link(); $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateDeliverySlipsPDF2&id_orders=' . Tools::substr($delivery, 0, -1); $this->confirmations[] = ' <a target="_blank" href="' . $pdf_link . '" alt="delivery">' . $this->l('Download all delivery slip') . '</br></a>'; } if ($invoices == '' && $delivery == '') { $this->errors[] = $this->l('The selected orders have no invoice or delivery !') . '<br/>'; } } } if (Tools::getValue('etiquettesMR') != '') { // Downlad all pdf and zip then delete and display link to zip file $etiquettesMR = explode(' ', Tools::getValue('etiquettesMR')); unset($etiquettesMR[count($etiquettesMR) - 1]); $zipPath = '../modules/erpillicopresta/export/mondialrelay.zip'; $zip = new ZipArchive(); if ($zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) { throw new Exception($this->l('Impossible to create the zip archive containing the shipping labels to Mondial Relay carrier !') . '<br/>'); } foreach ($etiquettesMR as $key => $i) { $zip->addFromString('mondialrelay_' . $key . '.pdf', Tools::file_get_contents($i)); } $zip->close(); //Display link to dl zip file $this->confirmations[] = ' <a target="_blank" href="' . $zipPath . '" alt="zip_file">' . $this->l('Download zip archive which contents all labels for Mondial Relay shipment') . '<br/></a>'; if (Tools::getValue('deliveryNumbersMR') != '') { // Get all tracking numbers $numbers = explode(" ", Tools::getValue('deliveryNumbersMR')); unset($numbers[count($numbers) - 1]); foreach ($numbers as $number) { $tabNumber = explode("-", $number); $order_carrier = new OrderCarrier(ErpOrder::getIdCarrierbyIdOrder((int) $tabNumber[1])); $order = new ErpOrder((int) $tabNumber[1]); // Update carrier $order->shipping_number = $tabNumber[0]; $order->update(); // Update order_carrier $order_carrier->tracking_number = pSQL($tabNumber[0]); $order_carrier->update(); } } } if (Tools::getValue('expeditorCSV') != '') { // CSV file creation $csvPath = '../modules/erpillicopresta/export/expeditor_inet.csv'; $fileCSV = fopen($csvPath, 'w'); // Fill in file fwrite($fileCSV, str_replace(',', '', Tools::getValue('expeditorCSV'))); //Close fclose($fileCSV); // link creation $this->confirmations[] = ' <a target="_blank" href="' . $csvPath . '" alt="csv_file">' . $this->l('Download export file (CSV) for ExpeditorInet') . '</br></a>'; } if (Tools::getValue('idOthers') != '') { //BEGIN Initialisations for TNT if (Module::isEnabled('tntcarrier')) { $TNTCheck = false; require_once _PS_MODULE_DIR_ . '/tntcarrier/classes/PackageTnt.php'; if (class_exists('ZipArchive', false) && ($tnt_zip = new ZipArchive())) { // Protection du ZIP $dateday = new DateTime(); $uniqid_file = uniqid('file_'); $token = md5($dateday->getTimestamp() . $uniqid_file); // Put all tnt pdf into a zip $tnt_zip_path = 'erpillicopresta/export/tnt_' . date('Y-m-d_His') . '_' . $uniqid_file . $token . '.zip'; if ($tnt_zip->open(_PS_MODULE_DIR_ . $tnt_zip_path, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) { $this->errors[] = Tools::displayError($this->l('Failed to create a ZIP archive containing the shipping labels to TNT carrier !') . '<br/>'); } else { // one or several id orders $id_others_order_array = strpos(Tools::getValue('idOthers'), ',') !== false ? explode(',', Tools::getValue('idOthers')) : (int) Tools::getValue('idOthers'); // Browse all orders not in ExpeditorInet nor MondialRelay foreach ((array) $id_others_order_array as $i => $id_order) { // BEGIN Commande TNT $id_order = (int) $id_order; if (ErpOrder::isTntOrder($id_order)) { // status change $currOrder = new ErpOrder($id_order); $currOrder->setCurrentState(4, $this->context->employee->id); // Start to check that weight order is valid if not tnt crash ! //echo($data['poid'] * 1000);die; // Get tracking number : dedicated class created for this action // Execution of the hook generating the tracking number at an order opening ... So ctrl c / ctrl v to execute here /*$erp_tntCarrier = new ErpTntCarrier(); $generate = $erp_tntCarrier->generateShipping($id_order);*/ $generateShipping = Hook::exec('adminOrder', array('id_order' => $id_order)); $tnt = new PackageTnt($id_order); $tntNumber = $tnt->getShippingNumber(); if (count($tntNumber) == 0) { $this->errors[] = Tools::displayError($this->l('Failed to get shipping number from TNT services : you have to fit the weight of the order.')); continue; } $tntNumber = $tntNumber[0]['shipping_number']; // Update order $order_carrier = new OrderCarrier(ErpOrder::getIdCarrierbyIdOrder((int) $id_order)); $order = new ErpOrder((int) $id_order); $order->shipping_number = $tntNumber; $order->update(); $order_carrier->tracking_number = pSQL($tntNumber); $order_carrier->update(); // Add pdf to zip $tnt_zip->addFile(_PS_MODULE_DIR_ . '/tntcarrier/pdf/' . $tntNumber . '.pdf', $tntNumber . '.pdf'); $TNTCheck = true; } // END Order TNT // SPLICE idOther if (is_array($id_others_order_array)) { unset($id_others_order_array[$i]); } else { unset($id_others_order_array); } } //Display dl zip link $tnt_zip->close(); if ($TNTCheck) { $this->confirmations[] = ' <a target="_blank" href="' . _MODULE_DIR_ . $tnt_zip_path . '" alt="zip_file">' . $this->l('Download zip archive which contents all labels for TNT shipment') . '<br/></a>'; } } } else { $this->errors[] = Tools::displayError($this->l('Class ZipArchive does not exist !') . '<br/>'); } //END Initialisations for TNT } // Display for order not processed : idothers if (isset($id_others_order_array)) { if (count($id_others_order_array) == 1) { //var_dump($id_others_order_array);die(); if (is_array($id_others_order_array)) { $id_others_order_array = $id_others_order_array[1]; } $this->errors[] = Tools::displayError($this->l('The following order has not been processed : order #') . $id_others_order_array . '. ' . $this->l('Please make sure that the carrier is either TNT, ExpeditorInet, or MondialRelay and that the order fits the carrier requirements.')); } elseif (count($id_others_order_array) > 1) { $this->errors[] = Tools::displayError($this->l('The following orders have not been processed : orders #') . implode(", ", $id_others_order_array) . '. ' . $this->l('Please make sure that the carrier is either TNT, ExpeditorInet, or MondialRelay and that the orders fit the carrier requirements.')); } } } return parent::renderList(); }
} require_once realpath(dirname(__FILE__) . '/../../config/config.inc.php'); if (_PS_VERSION_ < '1.5' || !defined('_PS_ADMIN_DIR_')) { require_once realpath(dirname(__FILE__) . '/../../init.php'); } /** Backward compatibility */ require dirname(__FILE__) . '/backward_compatibility/backward.php'; require dirname(__FILE__) . '/mondialrelay.php'; require dirname(__FILE__) . '/classes/MRCreateTickets.php'; require dirname(__FILE__) . '/classes/MRGetTickets.php'; require dirname(__FILE__) . '/classes/MRGetRelayPoint.php'; require dirname(__FILE__) . '/classes/MRRelayDetail.php'; require dirname(__FILE__) . '/classes/MRManagement.php'; MondialRelay::initModuleAccess(); // Access page List liable to the generated token $accessPageList = array(MondialRelay::getToken('front') => $front_office_method, MondialRelay::getToken('back') => $back_office_method); $params = array(); $result = array(); // If the method name associated to the token received doesn't match with // the list, then we kill the request if (!isset($accessPageList[$token]) || !in_array($method, $accessPageList[$token])) { exit; } // Method name allow to instanciate his object to properly call the // implemented interface method and do his job switch ($method) { case 'MRCreateTickets': $params['orderIdList'] = Tools::getValue('order_id_list'); $params['totalOrder'] = Tools::getValue('numSelected'); $params['weightList'] = Tools::getValue('weight_list'); break;
* * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <*****@*****.**> * @copyright 2007-2013 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include_once '../../config/config.inc.php'; include_once 'mondialrelay.php'; if (Tools::getValue('secure_key') != Configuration::get('MONDIAL_RELAY_SECURE_KEY')) { exit; } $account_shop = MondialRelay::getAccountDetail(); $expeditions = Db::getInstance()->executeS(' SELECT ms.`exp_number`, ms.`id_cart`, o.`id_order` FROM `' . _DB_PREFIX_ . 'mr_selected` ms LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON (o.`id_cart` = ms.`id_cart`) WHERE `exp_number` != 0'); if (empty($expeditions)) { exit; } $params = array('Enseigne' => $account_shop['MR_ENSEIGNE_WEBSERVICE'], 'Langue' => 'FR'); require_once dirname(__FILE__) . '/lib/nusoap/nusoap.php'; $client_mr = new nusoap_client("http://www.mondialrelay.fr/webservice/Web_Services.asmx?WSDL", true); $client_mr->soap_defencoding = 'UTF-8'; $client_mr->decode_utf8 = false; foreach ($expeditions as $expedition) { if ($expedition['id_order'] == NULL) {
public function __construct($params) { $this->_params = $params; parent::__construct(); }
public function display() { $post_action = count($_POST) ? $this->postProcess() : NULL; $this->displaySettings($post_action); if (MondialRelay::isAccountSet() && (int) $this->mondialrelay->account_shop['MR_ORDER_STATE']) { $this->displayOrdersTable(); $this->displayhistoriqueForm(); } }
$params['id_cart'] = $cart->id; $params['id_customer'] = $cookie->id_customer; $params['id_mr_method'] = Tools::getValue('id_mr_method'); $params['relayPointInfo'] = Tools::getValue('relayPointInfo'); break; default: } // Try to instanciate the method object name and call the necessaries method try { if (class_exists($method, false)) { $obj = new $method($params); // Verify that the class implement correctly the interface // Else use a Management class to do some ajax stuff if ($obj instanceof IMondialRelayWSMethod) { $obj->init(); $obj->send(); $result = $obj->getResult(); } unset($obj); } elseif (($management = new MRManagement($params)) && method_exists($management, $method)) { $result = $management->{$method}(); } else { throw new Exception('Method Class : ' . $method . ' can\'t be found'); } unset($management); } catch (Exception $e) { echo MondialRelay::jsonEncode(array('other' => array('error' => array($e->getMessage())))); exit(-1); } echo MondialRelay::jsonEncode($result); exit(0);
if (!defined('_PS_ADMIN_DIR_')) { require_once realpath(dirname(__FILE__) . '/../../config/config.inc.php'); require_once realpath(dirname(__FILE__) . '/../../init.php'); require_once dirname(__FILE__) . '/mondialrelay.php'; } $mondialrelay = isset($this) ? $this : new Mondialrelay(); require_once dirname(__FILE__) . '/classes/MRCreateTickets.php'; require_once dirname(__FILE__) . '/classes/MRGetTickets.php'; require_once dirname(__FILE__) . '/classes/MRGetRelayPoint.php'; require_once dirname(__FILE__) . '/classes/MRRelayDetail.php'; require_once dirname(__FILE__) . '/classes/MRManagement.php'; // Can't use Tools at this time... Need to know if _PS_ADMIN_DIR_ has to be defined $method = Tools::getValue('method'); $token = Tools::getValue('mrtoken'); // Access page List liable to the generated token $accessPageList = array(MondialRelay::getToken('front') => array('MRGetRelayPoint', 'addSelectedCarrierToDB'), MondialRelay::getToken('back') => array('MRGetTickets', 'MRCreateTickets', 'MRDeleteHistory', 'uninstallDetail', 'DeleteHistory')); $params = array(); $result = array(); // If the method name associated to the token received doesn't match with // the list, then we kill the request if (!isset($accessPageList[$token]) || !in_array($method, $accessPageList[$token])) { exit; } // Method name allow to instanciate his object to properly call the // implemented interface method and do his job switch ($method) { case 'MRCreateTickets': $params['orderIdList'] = Tools::getValue('order_id_list'); $params['totalOrder'] = Tools::getValue('numSelected'); $params['weightList'] = Tools::getValue('weight_list'); break;
<?php require_once dirname(__FILE__) . '/../../config/config.inc.php'; require_once dirname(__FILE__) . '/../../init.php'; require_once dirname(__FILE__) . '/mondialrelay.php'; MondialRelay::initModuleAccess(); echo '<script type="text/javascript" src="' . MondialRelay::$moduleURL . 'jquery-1.4.4.min.js"></script>'; ?> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> <script type="text/javascript"> var geocoder; var map; var infowindow = new google.maps.InfoWindow(); var markers = []; var json_addresses = null; function google_map_init() { geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 11, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map"), myOptions); geocoder.geocode( {'address': "<?php echo $_GET['address']; ?>
public static function initModuleAccess() { self::$modulePath = _PS_MODULE_DIR_ . 'mondialrelay/'; self::$MRFrontToken = sha1('mr' . _COOKIE_KEY_ . 'Front'); self::$MRBackToken = sha1('mr' . _COOKIE_KEY_ . 'Back'); $protocol = Configuration::get('PS_SSL_ENABLED') || !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' ? 'https://' : 'http://'; $endURL = __PS_BASE_URI__ . 'modules/mondialrelay/'; if (method_exists('Tools', 'getShopDomainSsl')) { self::$moduleURL = $protocol . Tools::getShopDomainSsl() . $endURL; } else { self::$moduleURL = $protocol . $_SERVER['HTTP_HOST'] . $endURL; } }
public function display() { $html = ''; // Allow to override the older jquery to use a new one :) // Added for the 1.3 compatibility to keep using the recent code if (_PS_VERSION_ < '1.4') { $html .= MondialRelay::getjQueryCompatibility(); } $html .= ' <script type="text/javascript" language="javascript"> var _PS_MR_MODULE_DIR_ = "' . MondialRelay::$moduleURL . '"; </script>'; $html .= $this->displayOrdersTable(); $html .= '<br/><br/>'; $html .= $this->displayhistoriqueForm(); echo $html; }
public function displayhistoriqueForm() { include_once dirname(__FILE__) . '/mondialrelay.php'; $mondialrelay = new MondialRelay(); $_html = ''; $query = "SELECT * FROM `" . _DB_PREFIX_ . "mr_historique` ORDER BY `id` DESC ;"; $query = Db::getInstance()->ExecuteS($query); $_html .= '<fieldset>'; $_html .= '<legend>' . $mondialrelay->getL('History of sticks creation') . '</legend>'; $_html .= '<div style="overflow-x: auto;overflow-y: scroller; height: 300px; padding-top: 0.6em;" >'; $_html .= '<form method="post" action="' . $_SERVER['REQUEST_URI'] . '">'; $_html .= '<table class=table><tbody><tr><th>' . $mondialrelay->getL('Selected') . '<br><a href="javascript:void(0);" onclick="checked_all_h();">' . $mondialrelay->getL('All') . '</a> | <a href="javascript:void(0);" onclick="un_checked_all_h();">' . $mondialrelay->getL('None') . '</a></th><th>' . $mondialrelay->getL('Orders ID') . '</th><th>' . $mondialrelay->getL('Exps num') . '</th><th>' . $mondialrelay->getL('Print stick A4') . '</th><th>' . $mondialrelay->getL('Print stick A5') . '</th></tr>'; foreach ($query as $k => $row) { $_html .= '<tr> <td><input type="hidden" name="history[' . $row['id'] . '][id]" id="history_id_' . $row['id'] . '" value="' . $row['id'] . '" /> <input type="checkbox" mask_mr_h=1 name=history[' . $row['id'] . '][selected] id="history_selected_' . $row['id'] . '" value="1" /></td> <td>' . str_replace(';', ', ', $row['order']) . '</td><td>' . str_replace(';', ', ', $row['exp']) . '</td><td><a href="' . $row['url_a4'] . '" target="a4">' . $mondialrelay->getL('Print stick A4') . '</a></td><td><a href="' . $row['url_a5'] . '" target="a5">' . $mondialrelay->getL('Print stick A5') . '</a></td></tr>'; } $_html .= '</tbody></table>'; $_html .= '<input type="submit" name="delete_h" id="delete_h" value="' . $mondialrelay->getL('Delete selected history') . '" class="button" />'; $_html .= '</form></div>'; $_html .= '</fieldset>'; return $_html; }