Merge branch 'ticket-simplemulti_logistic' into develop
This commit is contained in:
commit
56c4006da3
10
adm/pdf.php
10
adm/pdf.php
@ -51,6 +51,7 @@ $functionArray = array(
|
||||
'privatesalesM2Plus' => 'generateInvoicesPDFPrivateM2Plus',
|
||||
'privatesalesM3' => 'generateInvoicesPDFPrivateM3',
|
||||
'privatesalesAll' => 'generateInvoicesPDFPrivateSalesAll',
|
||||
'pendingorders' => 'generatePendingOrdersInvoice',
|
||||
);
|
||||
|
||||
foreach ($functionArray as $var => $function)
|
||||
@ -317,3 +318,12 @@ function generateDeliverySlipsPDF()
|
||||
if (is_array($slips))
|
||||
PDF::multipleDelivery($slips);
|
||||
}
|
||||
|
||||
function generatePendingOrdersInvoice()
|
||||
{
|
||||
$orders = Tools::getValue('orders');
|
||||
$id_orders = explode(',', $orders);
|
||||
if (is_array($id_orders)) {
|
||||
PDF::multipleInvoices($id_orders);
|
||||
}
|
||||
}
|
||||
|
@ -326,7 +326,31 @@ class AdminLogistics extends AdminTab {
|
||||
}
|
||||
} elseif(Tools::isSubmit('submitMod') && ($id_order = (int) Tools::getValue('id_order')) && (int) $cookie->profile == 1) {
|
||||
$product_ids = Tools::getValue('product_ids');
|
||||
echo "<pre>";var_dump($id_order,$product_ids);echo "</pre>";die();
|
||||
foreach ($product_ids as $id) {
|
||||
$id_sale = Db::getInstance()->getValue('
|
||||
SELECT `id_sale`
|
||||
FROM `'._DB_PREFIX_.'product_ps_cache`
|
||||
WHERE `id_product` = '.(int) $id
|
||||
);
|
||||
if (!$id_sale) {
|
||||
$id_sale = 0;
|
||||
}
|
||||
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT IGNORE INTO `'._DB_PREFIX_.'logistics_pending`
|
||||
VALUES ('.(int) $id_order.','.(int) $id.','.(int) $id_sale.')
|
||||
');
|
||||
|
||||
|
||||
}
|
||||
// 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 />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,7 +599,7 @@ class AdminLogistics extends AdminTab {
|
||||
<td class="right" style="display: none;">\' + (loaded.products[i].product_supplier_reference? loaded.products[i].product_supplier_reference: \'\') + \'</td>\
|
||||
<td class="center"><span style="opacity: .4">\' + loaded.products[i].product_quantity + \' / \' + (loaded.products[i].product_quantity_refunded > 0? loaded.products[i].product_quantity_refunded: loaded.products[i].product_quantity_return) + \' / \' + loaded.products[i].product_quantity_sent + \'</span></td>\
|
||||
<td class=" center toship\' + (loaded.products[i].product_quantity - loaded.products[i].product_quantity_return - loaded.products[i].product_quantity_sent == 0? \' red\': \'\') + \'"><strong>\' + Math.max($.inArray(loaded.products[i].product_id, locked_products) != -1? \'0\': (loaded.products[i].product_quantity - (loaded.products[i].product_quantity_refunded > 0? loaded.products[i].product_quantity_refunded: loaded.products[i].product_quantity_return) - loaded.products[i].product_quantity_sent), 0) + \'</strong></td>\
|
||||
<td class="center"><input type="checkbox" name="product_ids[]" value="\' + loaded.products[i].product_id + \'" /></td>
|
||||
<td class="center"><input type="checkbox" name="product_ids[]" value="\' + loaded.products[i].product_id + \'" \' + (loaded.products[i].is_pending>0? \'checked disabled\':\'\') + \'/></td>\
|
||||
<td class="shipped">\';
|
||||
|
||||
if (loaded.products[i].id_shipping != 2
|
||||
@ -595,7 +619,8 @@ class AdminLogistics extends AdminTab {
|
||||
</tbody>\
|
||||
<tfoot>\
|
||||
<tr>\
|
||||
<td colspan="7" style="text-align: center;"><input type="submit" class="button" name="submitMod" value="'.$this->l('MOD').'"/></td>\
|
||||
<td colspan="5"></td>\
|
||||
<td style="text-align: center;"><input type="submit" class="button" name="submitMod" value="'.$this->l('MOD').'"/></td>\
|
||||
<td></td>\
|
||||
</tr>\
|
||||
</tfoot>\
|
||||
|
170
modules/logistics/AdminLogisticsPending.php
Normal file
170
modules/logistics/AdminLogisticsPending.php
Normal file
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
if(!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
include _PS_ROOT_DIR_.'/modules/privatesales/Sale.php';
|
||||
|
||||
|
||||
class AdminLogisticsPending extends AdminTab {
|
||||
public $_html = '';
|
||||
|
||||
public function display() {
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
$sales_info = array();
|
||||
$link = new Link(2);
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'logistics_pending`
|
||||
ORDER BY `id_sale`
|
||||
') as $row) {
|
||||
if(!isset($sales_info[(int)$row['id_sale']])) {
|
||||
$s = new Sale((int)$row['id_sale']);
|
||||
$sales_info[(int)$row['id_sale']] = array(
|
||||
'id_sale' => (int)$row['id_sale'],
|
||||
'title' => $s->title[(int)$cookie->id_lang],
|
||||
'date_start' => $s->date_start,
|
||||
'orders' => array()
|
||||
);
|
||||
}
|
||||
if (!isset($sales_info[(int)$row['id_sale']]['orders'][(int)$row['id_order']] )){
|
||||
$order_infos = Db::getInstance()->getRow('
|
||||
SELECT CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, o.`payment`, o.`total_paid`
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`)
|
||||
WHERE o.`id_order` = '.(int)$row['id_order']
|
||||
);
|
||||
$sales_info[(int)$row['id_sale']]['orders'][(int)$row['id_order']] = array(
|
||||
'id_order' => (int)$row['id_order'],
|
||||
'customer' => $order_infos['customer'],
|
||||
'payment' => $order_infos['payment'],
|
||||
'total_paid' => $order_infos['total_paid'],
|
||||
'products' => array()
|
||||
);
|
||||
}
|
||||
$p = Db::getInstance()->getRow('
|
||||
SELECT od.`product_id`,od.`product_attribute_id`, od.`product_name`, od.`product_reference`
|
||||
FROM `'._DB_PREFIX_.'order_detail` od
|
||||
WHERE od.`id_order` = '.(int)$row['id_order'].'
|
||||
AND od.`product_id` = '.(int)(int)$row['id_product']
|
||||
);
|
||||
|
||||
$p['id_image'] = 0;
|
||||
if((int) $p['product_attribute_id'] != 0) {
|
||||
$img = Db::getInstance()->getRow('
|
||||
SELECT `id_image`
|
||||
FROM `'._DB_PREFIX_.'product_attribute_image`
|
||||
WHERE `id_product_attribute` = '.(int) $p['product_attribute_id'].'
|
||||
');
|
||||
|
||||
$p['id_image'] = $img['id_image'];
|
||||
}
|
||||
if($p['id_image'] == 0) {
|
||||
$img = Db::getInstance()->getRow('
|
||||
SELECT `id_image`
|
||||
FROM `'._DB_PREFIX_.'image`
|
||||
WHERE `cover` = 1
|
||||
AND `id_product` = '.(int) $p['product_id'].'
|
||||
');
|
||||
|
||||
$p['id_image'] = $img['id_image'];
|
||||
}
|
||||
$p['image'] = $link->getImageLink('image', $p['product_id'].'-'.$p['id_image'], 'home');
|
||||
|
||||
$sales_info[(int)$row['id_sale']]['orders'][(int)$row['id_order']]['products'][] = $p;
|
||||
}
|
||||
echo '<style>
|
||||
.table tr th{
|
||||
background: #F4E6C9 url(../adm/themes/origins_lite/news-bg.gif) repeat-x top left;
|
||||
padding: 4px 6px;
|
||||
}
|
||||
|
||||
</style>';
|
||||
|
||||
echo '<script>
|
||||
function check_all(element)
|
||||
{
|
||||
$(\'#\'+element+\' input\').each(function(){
|
||||
if ($(\'#all_\'+element).is(\':checked\')) {
|
||||
$(this).attr(\'checked\',\'checked\');
|
||||
} else {
|
||||
$(this).attr(\'checked\',\'\');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</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>';
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
//echo "<pre>";var_dump($sales, $orders);echo "</pre>";die();
|
||||
}
|
||||
}
|
||||
}
|
@ -249,6 +249,12 @@ if(($id_order = (int) Tools::getValue('id_order'))
|
||||
WHERE `id_product` = '.(int) $p['product_id'].'
|
||||
');
|
||||
|
||||
$p['is_pending'] = Db::getInstance()->getValue('
|
||||
SELECT COUNT(id_product)
|
||||
FROM `'._DB_PREFIX_.'logistics_pending`
|
||||
WHERE `id_product` = '.(int) $p['product_id'].' AND id_order = '.(int)$id_order
|
||||
);
|
||||
|
||||
if(!isset($sales_carriers[(int) $p['id_sale']])) {
|
||||
$sales_carriers[(int) $p['id_sale']] = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
|
Loading…
Reference in New Issue
Block a user