* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 9538 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ require_once(dirname(__FILE__).'/classes/MondialRelayClass.php'); require_once(dirname(__FILE__).'/classes/MRCreateTickets.php'); require_once(dirname(__FILE__).'/mondialrelay.php'); class AdminMondialRelay extends AdminTab { private $mondialrelay = NULL; public function __construct() { MondialRelay::initModuleAccess(); $this->table = 'mr_selected'; $this->className = 'MondialRelayClass'; parent::__construct(); } private function displayOrdersTable() { global $cookie; $mondialrelay = new MondialRelay(); $order_state = new OrderState((int)(Configuration::get('MONDIAL_RELAY_ORDER_STATE')), $cookie->id_lang); $mr_weight_coef = (int)(Configuration::get('MR_WEIGHT_COEF')); $html = ''; // Simulate a ticket generation $MRCreateTicket = new MRCreateTickets(array( 'orderIdList' => NULL, 'totalOrder' => NULL, 'weightList' => NULL)); $errorListTicket = $MRCreateTicket->checkPreValidation(); $titleType = array( 'error' => $this->l('Thanks to kindly correct the following errors on '). ' '. $this->l('the contact page').':'; } } $html .= '

'.$this->l('All orders which have the state').' "'.$order_state->name.'" '. $this->l('will be available for sticker creation'); $html .= '. ' . $this->l('Change configuration') . '

'; $orders = MondialRelay::getOrders(array()); if (empty($orders)) $html.= '

' . $this->l('No orders with this state.') . '

'; else { $html.= '
'; $html.= "\n"; $html.= ''; $html.= ''; $html.= ''; $html.= ''; $html.= ''; $html.= ''; $html.= ''; $html.= ''; $html.= ''; $html.= ''; $html.= ''; $html.= ''; $html.= ''; foreach ($orders as $order) { if ($order['weight'] == 0) { $result_weight = Db::getInstance()->getRow(' SELECT SUM(product_weight * product_quantity) as weight FROM '._DB_PREFIX_.'order_detail WHERE id_order = '.(int)($order['id_order'])); $order['weight'] = round($mr_weight_coef * $result_weight['weight']); } $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ' '; } $html .= '
'.$this->l('Order ID').''.$this->l('Customer').''.$this->l('Total price').''.$this->l('Total shipping').''.$this->l('Date').''.$this->l('Put a Weight (grams)').''.$this->l('MR Number').''.$this->l('MR Country').''.$this->l('Exp Number').''.$this->l('Detail').'
'.$order['id_order'].''.$order['customer'].''.Tools::displayPrice($order['total'], new Currency($order['id_currency'])) . ''.Tools::displayPrice($order['shipping'], new Currency($order['id_currency'])) . ''.Tools::displayDate($order['date'], $order['id_lang']).''.$order['MR_Selected_Num'].''.$order['MR_Selected_Pays'].''.$order['exp_number'].' '.$this->l('View').'
'; $html .= '
'; $html .= ''; } unset($mondialrelay); unset($order_state); return $html; } public function displayhistoriqueForm() { $mondialrelay = new MondialRelay(); $_html = ''; $query = "SELECT * FROM `" . _DB_PREFIX_ ."mr_historique` ORDER BY `id` DESC ;"; $query = Db::getInstance()->ExecuteS($query); $_html.= '
' . $this->l('History of labels creation') . '
'; foreach ($query AS $k => $row) { $_html.= ' '; } $_html .= '
' . $this->l('Order ID') . ' ' . $this->l('Exp num') . ' ' . $this->l('Print stick A4') . ' ' . $this->l('Print stick A5') . '
'.$row['order'].' '.$row['exp'].'
'; return $_html; } 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 .= ' '; $html .= $this->displayOrdersTable(); $html .= '

'; $html .= $this->displayhistoriqueForm(); echo $html; } } ?>