Merge branch 'ticket-simplemulti_logistic' into develop
This commit is contained in:
commit
f41acac7ad
@ -340,16 +340,28 @@ class AdminLogistics extends AdminTab {
|
||||
INSERT IGNORE INTO `'._DB_PREFIX_.'logistics_pending`
|
||||
VALUES ('.(int) $id_order.','.(int) $id.','.(int) $id_sale.')
|
||||
');
|
||||
|
||||
|
||||
}
|
||||
|
||||
$id_order_state = Db::getInstance()->getRow('
|
||||
SELECT `id_order_state`
|
||||
FROM `'._DB_PREFIX_.'order_history`
|
||||
WHERE `id_order`= '.(int) $id_order.'
|
||||
ORDER BY `id_order_history` DESC
|
||||
');
|
||||
|
||||
// commande en attente
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int)$id_order;
|
||||
$history->id_employee = (int)($cookie->id_employee);
|
||||
$history->changeIdOrderState(19, (int)($id_order));
|
||||
if ($history->add()) {
|
||||
$this->_html .= '<p class="conf">'.$this->l('Order status changed').'</p><br />';
|
||||
if ((int)$id_order_state['id_order_state'] != 19) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int)$id_order;
|
||||
$history->id_employee = (int)($cookie->id_employee);
|
||||
$history->changeIdOrderState(19, (int)($id_order));
|
||||
if ($history->add()) {
|
||||
$this->_html .= '<p class="conf">'.$this->l('Order status changed').'</p><br />';
|
||||
} else {
|
||||
$this->_html .= '<p class="error">'.$this->l('Error occured').'</p><br />';
|
||||
}
|
||||
} else {
|
||||
$this->_html .= '<p class="conf">'.$this->l('Order in pending').'</p><br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,30 @@ class AdminLogisticsPending extends AdminTab {
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
$sales_info = array();
|
||||
$distinct_orders = array();
|
||||
$link = new Link(2);
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'logistics_pending`
|
||||
ORDER BY `id_sale`
|
||||
SELECT lp.*, oh.`id_order_state`
|
||||
FROM `'._DB_PREFIX_.'logistics_pending` lp
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = lp.`id_order`)
|
||||
WHERE oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = lp.`id_order` GROUP BY moh.`id_order`)
|
||||
ORDER BY lp.`id_sale`
|
||||
') as $row) {
|
||||
|
||||
// If order status is not in pending, order is deleted from logistic_pending table
|
||||
if ((int)$row['id_order_state'] != 19) {
|
||||
Db::getInstance()->ExecuteS('
|
||||
DELETE FROM `'._DB_PREFIX_.'logistics_pending`
|
||||
WHERE `id_order` = '.(int)$row['id_order']
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// count of orders
|
||||
if (!in_array((int)$row['id_order'], $distinct_orders)) {
|
||||
$distinct_orders[] = (int)$row['id_order'];
|
||||
}
|
||||
|
||||
if(!isset($sales_info[(int)$row['id_sale']])) {
|
||||
$s = new Sale((int)$row['id_sale']);
|
||||
$sales_info[(int)$row['id_sale']] = array(
|
||||
@ -40,7 +58,8 @@ class AdminLogisticsPending extends AdminTab {
|
||||
'customer' => $order_infos['customer'],
|
||||
'payment' => $order_infos['payment'],
|
||||
'total_paid' => $order_infos['total_paid'],
|
||||
'products' => array()
|
||||
'products' => array(),
|
||||
'id_state' => (int)$row['id_order_state']
|
||||
);
|
||||
}
|
||||
$p = Db::getInstance()->getRow('
|
||||
@ -79,6 +98,10 @@ class AdminLogisticsPending extends AdminTab {
|
||||
background: #F4E6C9 url(../adm/themes/origins_lite/news-bg.gif) repeat-x top left;
|
||||
padding: 4px 6px;
|
||||
}
|
||||
.table tr td.product_name {
|
||||
box-sizing: border-box;
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
</style>';
|
||||
|
||||
@ -96,75 +119,79 @@ class AdminLogisticsPending extends AdminTab {
|
||||
}
|
||||
</script>';
|
||||
|
||||
echo '<h2>'.$this->l('Commandes en attente').'</h2>';
|
||||
echo '<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
|
||||
<table class="table" style="margin-top:30px; width: 100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.$this->l('Sale ID').'</th>
|
||||
<th>'.$this->l('Title').'</th>
|
||||
<th>'.$this->l('Date start').'</th>
|
||||
<th align="center">'.$this->l('Nb orders').'</th>
|
||||
<th align="center">'.$this->l('Check all').'</th>
|
||||
<th align="center">'.$this->l('See orders').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($sales_info as $key => $sale) {
|
||||
echo '<tr style="background-color: #fff;">
|
||||
<td>'.$sale['id_sale'].'</td>
|
||||
<td>'.$sale['title'].'</td>
|
||||
<td>'.$sale['date_start'].'</td>
|
||||
<td align="center">'.count($sale['orders']).'</td>
|
||||
<td align="center"><input type="checkbox" name="sales[]" id="all_sale_'.(int)$sale['id_sale'].'" value="'.(int)$sale['id_sale'].'" onclick="check_all(\'sale_'.(int)$sale['id_sale'].'\');"/></td>
|
||||
<td align="center" style="cursor:pointer;font-size: 20px;" onclick="$(\'#sale_'.(int)$sale['id_sale'].'\').slideToggle();">'.$this->l('+').'</td>
|
||||
</tr>
|
||||
<tr id="sale_'.(int)$sale['id_sale'].'" style="display:none;">
|
||||
<td colspan="6" style="padding: 0;">
|
||||
<table class="table" style="width: 100%; border:none;" cellpadding="0" cellspacing="0">';
|
||||
foreach ($sale['orders'] as $k => $order) {
|
||||
echo '<tr style="background-color: lightblue;">
|
||||
<td>'.$order['id_order'].'</td>
|
||||
<td>'.$order['customer'].'</td>
|
||||
<td>'.$order['total_paid'].'</td>
|
||||
<td>'.$order['payment'].'</td>
|
||||
<td><input type="checkbox" name="orders[]" value="'.(int)$order['id_order'].'"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5" style="padding: 0;">
|
||||
<table class="table" style="width: 100%" id="order_'.(int)$sale['id_order'].'">';
|
||||
foreach ($order['products'] as $ke => $product) {
|
||||
echo '<tr style="background-color: #fff;font-size: 12px;">
|
||||
<td align="center" style="width:150px;"><img src="'.$product['image'].'" alt="" width="100" height="auto" /></td>
|
||||
<td class="alt_row">'.$product['product_name'].'</td>
|
||||
<td class="alt_row">'.$product['product_reference'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</tbody>
|
||||
</table>
|
||||
<p style="width:100%;text-align:right;"><input class="button" type="submit" name="submitPrint" value="'.$this->l('Print').'"></p>
|
||||
</form>';
|
||||
echo '<h2>'.$this->l('Commandes en attente').' '.(!empty($distinct_orders)?'('.count($distinct_orders).')':'').'</h2>';
|
||||
if (!empty($sales_info)) {
|
||||
echo '<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
|
||||
<table class="table" style="margin-top:30px; width: 100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.$this->l('Sale ID').'</th>
|
||||
<th>'.$this->l('Title').'</th>
|
||||
<th>'.$this->l('Date start').'</th>
|
||||
<th align="center">'.$this->l('Nb orders').'</th>
|
||||
<th align="center">'.$this->l('Check all').'</th>
|
||||
<th align="center">'.$this->l('See orders').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($sales_info as $key => $sale) {
|
||||
echo '<tr style="background-color: #fff;">
|
||||
<td>'.$sale['id_sale'].'</td>
|
||||
<td>'.$sale['title'].'</td>
|
||||
<td>'.$sale['date_start'].'</td>
|
||||
<td align="center">'.count($sale['orders']).'</td>
|
||||
<td align="center"><input type="checkbox" name="sales[]" id="all_sale_'.(int)$sale['id_sale'].'" value="'.(int)$sale['id_sale'].'" onclick="check_all(\'sale_'.(int)$sale['id_sale'].'\');"/></td>
|
||||
<td align="center" style="cursor:pointer;font-size: 20px;" onclick="$(\'#sale_'.(int)$sale['id_sale'].'\').slideToggle();">'.$this->l('+').'</td>
|
||||
</tr>
|
||||
<tr id="sale_'.(int)$sale['id_sale'].'" style="display:none;">
|
||||
<td colspan="6" style="padding: 0;">
|
||||
<table class="table" style="width: 100%; border:none;" cellpadding="0" cellspacing="0">';
|
||||
foreach ($sale['orders'] as $k => $order) {
|
||||
echo '<tr style="background-color: lightblue;">
|
||||
<td><a target="_blank" href="'.__PS_BASE_URI__.'adm/index.php?tab=AdminOrders&id_order='.$order['id_order'].'&vieworder&token='.Tools::getAdminTokenLite('AdminOrders').'">'.$order['id_order'].'</a></td>
|
||||
<td>'.$order['customer'].'</td>
|
||||
<td>'.$order['total_paid'].'</td>
|
||||
<td>'.$order['payment'].'</td>
|
||||
<td><input type="checkbox" name="orders[]" value="'.(int)$order['id_order'].'"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5" style="padding: 0;">
|
||||
<table class="table" style="width: 100%" id="order_'.(int)$sale['id_order'].'">';
|
||||
foreach ($order['products'] as $ke => $product) {
|
||||
echo '<tr style="background-color: #fff;font-size: 12px;">
|
||||
<td align="center" style="width:150px;"><img src="'.$product['image'].'" alt="" width="100" height="auto" /></td>
|
||||
<td class="alt_row product_name"><span>'.$product['product_name'].'</span></td>
|
||||
<td class="alt_row" align="center">'.($product['product_reference']?$product['product_reference']:'-').'</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</tbody>
|
||||
</table>
|
||||
<p style="width:100%;text-align:right;"><input class="button" type="submit" name="submitPrint" value="'.$this->l('Print').'"></p>
|
||||
</form>';
|
||||
} else {
|
||||
echo '<p>'.$this->l('Aucune Commandes en attente').'</p>';
|
||||
}
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
if(Tools::isSubmit('submitPrint')) {
|
||||
$sales = Tools::getValue('sales');
|
||||
$orders = Tools::getValue('orders');
|
||||
if (!empty($orders)) {
|
||||
$orders = array_unique($orders);
|
||||
Tools::redirectAdmin('pdf.php?pendingorders&orders='.implode(',', $orders) .'&token='.$this->token);
|
||||
} else {
|
||||
$this->_errors[] = $this->l('No selected orders for these sales');
|
||||
}
|
||||
//echo "<pre>";var_dump($sales, $orders);echo "</pre>";die();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user