From 8ebec9fb3eb916e44a9fc02437ebfffc32adee08 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Tue, 21 Jun 2016 17:18:24 +0200 Subject: [PATCH] addind admin pending orders --- adm/pdf.php | 10 ++ modules/logistics/AdminLogisticsPending.php | 170 ++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 modules/logistics/AdminLogisticsPending.php diff --git a/adm/pdf.php b/adm/pdf.php index a57f3a51..f4896559 100755 --- a/adm/pdf.php +++ b/adm/pdf.php @@ -50,6 +50,7 @@ $functionArray = array( 'privatesalesM2Bis' => 'generateInvoicesPDFPrivateM2Bis', 'privatesalesM3' => 'generateInvoicesPDFPrivateM3', 'privatesalesAll' => 'generateInvoicesPDFPrivateSalesAll', + 'pendingorders' => 'generatePendingOrdersInvoice', ); foreach ($functionArray as $var => $function) @@ -289,3 +290,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); + } +} diff --git a/modules/logistics/AdminLogisticsPending.php b/modules/logistics/AdminLogisticsPending.php new file mode 100644 index 00000000..2f1cd6af --- /dev/null +++ b/modules/logistics/AdminLogisticsPending.php @@ -0,0 +1,170 @@ +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 ''; + + echo ''; + + echo '

'.$this->l('Commandes en attente').'

'; + echo '
+ + + + + + + + + + + + '; + foreach ($sales_info as $key => $sale) { + echo ' + + + + + + + + + + '; + } + echo ' +
'.$this->l('Sale ID').''.$this->l('Title').''.$this->l('Date start').''.$this->l('Nb orders').''.$this->l('Check all').''.$this->l('See orders').'
'.$sale['id_sale'].''.$sale['title'].''.$sale['date_start'].''.count($sale['orders']).''.$this->l('+').'
+

+
'; + } + + 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 "
";var_dump($sales, $orders);echo "
";die(); + } + } +} \ No newline at end of file