private function displayOrdersTable() { $order_state = new OrderState((int) Configuration::get('MONDIAL_RELAY_ORDER_STATE'), $this->context->language->id); $orders = MondialRelay::getOrders(array(), MondialRelay::NO_FILTER, $this->mondialrelay->account_shop['MR_WEIGHT_COEFFICIENT']); // Simulate a ticket generation $MRCreateTicket = new MRCreateTickets(array('orderIdList' => NULL, 'totalOrder' => NULL, 'weightList' => NULL)); foreach ($orders as &$order) { $order['display_total_price'] = Tools::displayPrice($order['total'], new Currency($order['id_currency'])); $order['display_shipping_price'] = Tools::displayPrice($order['shipping'], new Currency($order['id_currency'])); $order['display_date'] = Tools::displayDate($order['date'], $order['id_lang']); } $this->context->smarty->assign(array('MR_token_admin_module' => Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $this->context->employee->id), 'MR_token_admin_contact' => Tools::getAdminToken('AdminContact' . (int) Tab::getIdFromClassName('AdminContact') . (int) $this->context->employee->id), 'MR_token_admin_orders' => Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $this->context->employee->id), 'MR_order_state_name' => $order_state->name, 'MR_orders' => $orders, 'MR_PS_IMG_DIR_' => _PS_IMG_DIR_, 'MR_errors_type' => $MRCreateTicket->checkPreValidation())); unset($order_state); echo $this->context->smarty->fetch(dirname(__FILE__) . '/tpl/admintab/generate_tickets.tpl'); }
private function displayOrdersTable() { $order_state = new OrderState((int) Configuration::get('MONDIAL_RELAY_ORDER_STATE'), $this->context->language->id); $orders = MondialRelay::getOrders(array(), MondialRelay::NO_FILTER, $this->mondialrelay->account_shop['MR_WEIGHT_COEFFICIENT']); // Simulate a ticket generation $MRCreateTicket = new MRCreateTickets(array('orderIdList' => null, 'totalOrder' => null, 'weightList' => null), $this->mondialrelay); if (is_array($orders) && count($orders)) { foreach ($orders as &$order) { $order['display_total_price'] = Tools::displayPrice($order['total'], new Currency($order['id_currency'])); $order['display_shipping_price'] = Tools::displayPrice($order['shipping'], new Currency($order['id_currency'])); if (version_compare(_PS_VERSION_, '1.5.5', '<')) { $order['display_date'] = Tools::displayDate($order['date'], $this->context->language->id); } else { $order['display_date'] = Tools::displayDate($order['date']); } $order['weight'] = !empty($order['mr_weight']) && $order['mr_weight'] > 0 ? $order['mr_weight'] : $order['order_weight']; } } $controller = _PS_VERSION_ < '1.5' ? 'AdminContact' : 'AdminStores'; $this->context->smarty->assign(array('MR_token_admin_module' => Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $this->context->employee->id), 'MR_token_admin_contact' => array('controller_name' => $controller, 'token' => Tools::getAdminToken($controller . (int) Tab::getIdFromClassName($controller) . (int) $this->context->employee->id)), 'MR_token_admin_orders' => Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $this->context->employee->id), 'MR_order_state_name' => $order_state->name, 'MR_orders' => $orders, 'MR_PS_IMG_DIR_' => _PS_IMG_DIR_, 'MR_errors_type' => $MRCreateTicket->checkPreValidation())); unset($order_state); echo $this->mondialrelay->fetchTemplate('/views/templates/admin/', 'generate_tickets'); }
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(); if (count($errorListTicket)) { $html .= '<div class="error">' . $this->l('Thanks to kindly correct the following errors on ') . '<a href="index.php?tab=AdminContact&token=' . Tools::getAdminToken('AdminContact' . (int) Tab::getIdFromClassName('AdminContact') . (int) $cookie->id_employee) . '" style="color:#f00;"> ' . $this->l('the contact page') . '</a>:<ul>'; foreach ($errorListTicket as $type => $error) { $html .= '<li>' . $type . ': ' . $error . '</li>'; } $html .= '</ul></div>'; } $html .= '<p>' . $this->l('All orders which have the state') . ' "<b>' . $order_state->name . '</b>" ' . $this->l('will be available for sticker creation'); $html .= '. <a href="index.php?tab=AdminModules&configure=mondialrelay&token=' . Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $cookie->id_employee) . '" class="green">' . $this->l('Change configuration') . '</a></p> <div class="PS_MRErrorList error" id="otherErrors"> <img src="' . _PS_IMG_ . 'admin/error2.png" alt="" /> <span></span> </div>'; $orders = MondialRelay::getOrders(array()); if (empty($orders)) { $html .= '<h3 style="color:red;">' . $this->l('No orders with this state.') . '</h3>'; } else { $html .= '<form method="post" action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '">'; $html .= "\n<table class=\"table\" id='orders'>"; $html .= '<tr>'; $html .= '<th><input type="checkbox" id="toggleStatusOrderList" /></th>'; $html .= '<th>' . $this->l('Order ID') . '</th>'; $html .= '<th>' . $this->l('Customer') . '</th>'; $html .= '<th>' . $this->l('Total price') . '</th>'; $html .= '<th>' . $this->l('Total shipping') . '</th>'; $html .= '<th>' . $this->l('Date') . '</th>'; $html .= '<th>' . $this->l('Put a Weight (grams)') . '</th>'; $html .= '<th>' . $this->l('MR Number') . '</th>'; $html .= '<th>' . $this->l('MR Country') . '</th>'; $html .= '<th>' . $this->l('Exp Number') . '</th>'; $html .= '<th>' . $this->l('Detail') . '</th>'; $html .= '</tr>'; 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 .= '<tr id="PS_MRLineOrderInformation-' . $order['id_order'] . '">'; $html .= '<td><input type="checkbox" class="order_id_list" name="order_id_list[]" id="order_id_list" value="' . $order['id_order'] . '" /></td>'; $html .= '<td>' . $order['id_order'] . '</td>'; $html .= '<td>' . $order['customer'] . '</td>'; $html .= '<td>' . Tools::displayPrice($order['total'], new Currency($order['id_currency'])) . '</td>'; $html .= '<td>' . Tools::displayPrice($order['shipping'], new Currency($order['id_currency'])) . '</td>'; $html .= '<td>' . Tools::displayDate($order['date'], $order['id_lang']) . '</td>'; $html .= '<td><input type="text" name="weight_' . $order['id_order'] . '" id="weight_' . $order['id_order'] . '" size="7" value="' . $order['weight'] . '" /></td>'; $html .= '<td>' . $order['MR_Selected_Num'] . '</td>'; $html .= '<td>' . $order['MR_Selected_Pays'] . '</td>'; $html .= '<td>' . $order['exp_number'] . '</td>'; $html .= ' <td class="center"> <a href="index.php?tab=AdminOrders&id_order=' . $order['id_order'] . '&vieworder&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee) . '"> <img border="0" title="' . $this->l('View') . '" alt="' . $this->l('View') . '" src="' . _PS_IMG_ . 'admin/details.gif"/></a> </td> </tr> <tr class="PS_MRErrorList error" id="errorCreatingTicket_' . $order['id_order'] . '" style="display:none;"> <td colspan="11" style="background:url(' . _PS_IMG_ . 'admin/error2.png) 10px 10px no-repeat;"> <span></span> </td> </tr> <tr class="PS_MRSuccessList" id="successCreatingTicket_' . $order['id_order'] . '" style="display:none;"> <td>' . $order['id_order'] . '</td> <td colspan="10" style="background:url(' . _PS_IMG_ . 'admin/ok2.png) 10px 5px no-repeat #DFFAD3;"> ' . $this->l('Operation successful') . ' <span></span> </td> </tr>'; } $html .= ' </table>'; $html .= ' <div class="submit_button"> <div class="PS_MRSubmitButton" id="PS_MRSubmitButtonGenerateTicket"> <input type="button" name="generate" id="generate" value="' . $this->l('Generate') . '" class="button" /> </div> <div class="PS_MRLoader" id="PS_MRSubmitGenerateLoader"><img src="' . MondialRelay::$moduleURL . 'images/getTickets.gif"</div> </div>'; $html .= '</form>'; } unset($mondialrelay); unset($order_state); return $html; }