public function display()
    {
        global $cookie;
        $emc = new Envoimoinscher();
        echo '<h2>' . $emc->lang('List of orders to export') . '</h2>';
        if (Tools::isSubmit('submitExport')) {
            $orderToExport = array();
            $idsOrdersToExport = Tools::getValue('ordersBox');
            if (!empty($idsOrdersToExport)) {
                foreach ($idsOrdersToExport as $id) {
                    $orderToExport[] = self::getOrderDetails((int) $id);
                }
                echo '<form action="http://www.envoimoinscher.com/index.html" method="POST">
						<input type="hidden" name="url_renvoi" value="' . Tools::getProtocol() . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $_SERVER['REQUEST_URI'] . '">
						<input type="hidden" name="login" value="' . htmlspecialchars(Configuration::get('EMC_LOGIN'), ENT_COMPAT, 'UTF-8') . '">
						<input type="hidden" name="tracking" value="prestashop_module_v1">';
                self::inputMaker($orderToExport);
                echo '</form>
					<script type="text/javascript">
					$(document).ready(function() {
						$("form").submit();
						});
					</script>';
            } else {
                echo '<div class="alert error">
					   <img src="' . _PS_IMG_ . 'admin/forbbiden.gif" alt="nok" />
					   ' . $emc->lang('No order to export') . '</div>
					   <p><a class="button" href="' . Tools::getProtocol() . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $_SERVER['REQUEST_URI'] . '">Retour</a></p>';
            }
        } else {
            if (Configuration::get('EMC_ORDER_STATE') and Configuration::get('EMC_CARRIER') and Configuration::get('EMC_FIRST_NAME') and Configuration::get('EMC_LAST_NAME') and Configuration::get('EMC_ADDRESS') and Configuration::get('EMC_ZIP_CODE') and Configuration::get('EMC_CITY') and Configuration::get('EMC_COUNTRY') and Configuration::get('EMC_PHONE') and Configuration::get('EMC_EMAIL') and Configuration::get('EMC_LOGIN')) {
                echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="POST">';
                $orders = self::getOrders();
                self::displayOrders($orders);
                echo '<p><input type="submit" value="' . $emc->lang('Send') . '" name="submitExport" class="button" style="margin:10px 0px 0px 25px;"></p>
						</form>';
            } else {
                echo '<h2 style="color:red">' . $emc->lang('Please configure this module in order') . '</h2>';
            }
        }
        echo '<br><p><a href="index.php?tab=AdminModules&configure=envoimoinscher&token=' . Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $cookie->id_employee) . '" class="button">
			 ' . $emc->lang('Change configuration') . '</a></p>';
    }
Exemplo n.º 2
0
    private function displayOrders($orders)
    {
        global $cookie;
        $emc = new Envoimoinscher();
        echo '<table cellspacing="0" cellpadding="0" class="table" align="center" style="margin:10px 0px 0px 25px;">
					<tr>
						<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'ordersBox[]\', this.checked)" /></th>
						<th>' . $emc->lang('ID') . '</th>
						<th>' . $emc->lang('Name') . '</th>
						<th>' . $emc->lang('Total Cost') . '</th>
						<th>' . $emc->lang('Total shipment') . '</th>
						<th>' . $emc->lang('Date') . '</th>
						<th>' . $emc->lang('Packaging') . '</th>
						<th>' . $emc->lang('Nature of contents') . '</th>
						<th>' . $emc->lang('Detail') . '</th>		
					</tr>';
        if (!empty($orders)) {
            foreach ($orders as $order) {
                $customer = new Customer((int) $order['id_customer']);
                echo '<tr>
							  <td align="center">
								<input type="checkbox" name="ordersBox[]" class="ordersBox" value="' . (int) $order['id_order'] . '" />
							  </td>
							  <td align="center">' . (int) $order['id_order'] . '</td>
							  <td>' . htmlentities($customer->lastname, ENT_COMPAT, 'UTF-8') . ' ' . htmlentities($customer->firstname, ENT_COMPAT, 'UTF-8') . '</td>
							  <td align="center">' . Tools::displayPrice($order['total'], new Currency((int) $order['id_currency'])) . '</td>
							  <td align="center">' . Tools::displayPrice($order['shipping'], new Currency((int) $order['id_currency'])) . '</td>
							  <td align="center">' . Tools::displayDate($order['date'], (int) $order['id_lang']) . '</td>
							  <td align="center">
							  	<select name="packaging_' . $order['id_order'] . '">';
                foreach ($this->packaging as $package => $value) {
                    echo '<option ' . (Configuration::get('EMC_PACKAGING_DEFAULT') == $value ? ' selected="selected" ' : '') . ' value="' . htmlentities($value, ENT_COMPAT, 'UTF-8') . '">
										' . htmlentities($package, ENT_COMPAT, 'UTF-8') . '</option>';
                }
                echo '</select>
							  </td>
							  <td>' . envoimoinscher::selectNature(Configuration::get('EMC_CONTENT'), (int) $order['id_order']) . '</td>
							  <td align="center"><a href="index.php?tab=AdminOrders&id_order=' . (int) $order['id_order'] . '&vieworder&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee) . '">
					<img border="0" title="' . $emc->lang('View') . '" alt="' . $emc->lang('View') . '" src="' . _PS_IMG_ . 'admin/details.gif"/></a></td>
						  </tr>';
            }
        } else {
            echo '<tr><td colspan="4" align="center">' . $emc->lang('No order to export') . '</td></tr>';
        }
        echo '</table>';
    }