146 lines
4.7 KiB
PHP
146 lines
4.7 KiB
PHP
<?php
|
|
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
|
|
|
|
|
|
class AdminLogisticsFind extends AdminTab {
|
|
public $_html = '';
|
|
|
|
public function ajaxProcess() {
|
|
global $cookie;
|
|
|
|
if(!$cookie->isLoggedBack()) {
|
|
exit;
|
|
}
|
|
|
|
header('Content-Type: text/json');
|
|
|
|
$shipping_number = Tools::getValue('shipping_number');
|
|
if(!$shipping_number) {
|
|
echo json_encode(array());
|
|
exit;
|
|
}
|
|
|
|
echo json_encode(array(
|
|
Db::getInstance()->ExecuteS('
|
|
SELECT l.`date_add` AS `parcel_date`, d.`id_order`, d.`product_name`, l.`quantity`, o.`date_add`, c.`firstname`, c.`lastname`, c.`id_customer`
|
|
FROM `'._DB_PREFIX_.'lapostews` l
|
|
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
|
|
ON l.`id_order_detail` = d.`id_order_detail`
|
|
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
|
ON o.`id_order` = d.`id_order`
|
|
LEFT JOIN `'._DB_PREFIX_.'customer` c
|
|
ON o.`id_customer` = c.`id_customer`
|
|
WHERE l.`shipping_number` = "'.pSQL($shipping_number).'"
|
|
'),
|
|
/*Db::getInstance()->ExecuteS('
|
|
SELECT l.`date_add` AS `parcel_date`, d.`id_order`, d.`product_name`, l.`quantity`, o.`date_add`, c.`firstname`, c.`lastname`, c.`id_customer`
|
|
FROM `'._DB_PREFIX_.'exapaqws` l
|
|
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
|
|
ON l.`id_order_detail` = d.`id_order_detail`
|
|
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
|
ON o.`id_order` = d.`id_order`
|
|
LEFT JOIN `'._DB_PREFIX_.'customer` c
|
|
ON o.`id_customer` = c.`id_customer`
|
|
WHERE l.`shipping_number` = "'.pSQL($shipping_number).'"
|
|
'),
|
|
Db::getInstance()->ExecuteS('
|
|
SELECT l.`date_add` AS `parcel_date`, o.`id_order`, o.`date_add`, c.`firstname`, c.`lastname`, c.`id_customer`
|
|
FROM `'._DB_PREFIX_.'supplyweb_parcel` l
|
|
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
|
ON o.`id_order` = l.`id_order`
|
|
LEFT JOIN `'._DB_PREFIX_.'customer` c
|
|
ON o.`id_customer` = c.`id_customer`
|
|
WHERE l.`shipping_number` = "'.pSQL($shipping_number).'"
|
|
'),*/
|
|
Db::getInstance()->ExecuteS('
|
|
SELECT l.`date_add` AS `parcel_date`, o.`id_order`, o.`date_add`, c.`firstname`, c.`lastname`, c.`id_customer`
|
|
FROM `'._DB_PREFIX_.'shipping_history` l
|
|
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
|
ON o.`id_order` = l.`id_order`
|
|
LEFT JOIN `'._DB_PREFIX_.'customer` c
|
|
ON o.`id_customer` = c.`id_customer`
|
|
WHERE l.`shipping_number` = "'.pSQL($shipping_number).'"
|
|
'),
|
|
));
|
|
exit;
|
|
}
|
|
|
|
public function display() {
|
|
global $cookie;
|
|
|
|
$this->_html = '<h2>'.$this->l('Parcel lookup').'</h2>
|
|
<script type="text/javascript">
|
|
<!--
|
|
$(document).ready(function() {
|
|
var sn_timeout = null;
|
|
var sn_req = null;
|
|
|
|
$("#shipping_number").focus();
|
|
|
|
$("#shipping_number").keyup(function() {
|
|
$("#results").hide();
|
|
$("#results tbody").html("");
|
|
clearTimeout(sn_timeout);
|
|
sn_timeout = setTimeout(function() {
|
|
try {
|
|
sn_req.abort();
|
|
} catch(e) {}
|
|
|
|
sn_req = $.getJSON("'.str_replace('/index.php', '/ajax-tab.php', $_SERVER['REQUEST_URI']).'&shipping_number=" + $("#shipping_number").val(), function(result) {
|
|
if(result) {
|
|
var types = [
|
|
"La Poste",
|
|
"Exapaq",
|
|
"SupplyWeb",
|
|
"--"
|
|
];
|
|
for(var x=0; x < 4; x++) {
|
|
for(var i=0; i < result[x].length; i++) {
|
|
$("#results tbody").append($("<tr><td>" + result[x][i].parcel_date + "</td><td><a href=\'/adm/index.php?tab=AdminOrders&id_order=" + result[x][i].id_order + "&vieworder&token='.Tools::getAdminTokenLite('AdminOrders').'\'>" + result[x][i].id_order + "</a></td><td>" + result[x][i].date_add + "</td><td><a href=\'/adm/index.php?tab=AdminCustomers&id_customer=" + result[x][i].id_customer + "&viewcustomer&token='.Tools::getAdminTokenLite('AdminCustomers').'\'>" + result[x][i].id_customer + "</a></td><td>" + result[x][i].firstname + " " + result[x][i].lastname + "</td><td>" + types[x] + "</td><td>" + (x < 2? result[x][i].quantity + " x " + result[x][i].product_name: "") + "</td></tr>"));
|
|
}
|
|
}
|
|
$("#results").show();
|
|
}
|
|
});
|
|
}, 100);
|
|
});
|
|
});
|
|
-->
|
|
</script>
|
|
<style type="text/css">
|
|
#main .table {
|
|
width: 100%;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
#main fieldset {
|
|
text-align: center;
|
|
}
|
|
|
|
#main #shipping_number {
|
|
width: 200px;
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
|
|
<fieldset>
|
|
<input type="text" id="shipping_number" autocomplete="off" value="" placeholder="'.$this->l('Enter a shipping number here').'" />
|
|
</fieldset>
|
|
|
|
<table id="results" style="display: none;" class="std table">
|
|
<thead><tr>
|
|
<th>'.$this->l('Parcel Date').'</th>
|
|
<th>'.$this->l('Order ID').'</th>
|
|
<th>'.$this->l('Order Date').'</th>
|
|
<th>'.$this->l('Customer ID').'</th>
|
|
<th>'.$this->l('Customer').'</th>
|
|
<th>'.$this->l('Type').'</th>
|
|
<th>'.$this->l('Details').'</th>
|
|
</tr></thead><tbody></tbody>
|
|
</table>
|
|
';
|
|
|
|
echo $this->_html;
|
|
}
|
|
}
|