indication of order carrier in order list

This commit is contained in:
Marion Muszynski 2017-08-25 10:44:59 +02:00
parent 8a6c7712b1
commit b46e35c500
2 changed files with 45 additions and 19 deletions

View File

@ -37,6 +37,7 @@ class AdminOrders extends AdminTab
$this->colorOnBackground = true;
$this->_select = '
a.id_order AS id_pdf,
a.id_carrier,
CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
osl.`name` AS `osname`,
os.`color`,
@ -73,13 +74,26 @@ class AdminOrders extends AdminTab
foreach ($states AS $state)
$statesArray[$state['id_order_state']] = $state['name'];
$carriers = Db::getInstance()->ExecuteS('
SELECT c.`id_carrier`, IF(c.`name` = "0", "'.Configuration::get('PS_SHOP_NAME').'", c.`name`) AS `name`'.($this->cursale !== NULL? ', (
SELECT IFNULL(p.`id_sale`, NULL) FROM `'._DB_PREFIX_.'privatesale_carrier` p WHERE c.`id_carrier` = p.`id_carrier` AND p.`id_sale` = '.$this->cursale->id.'
) AS `id_sale`': '').'
FROM `'._DB_PREFIX_.'carrier` c
WHERE c.`deleted` != 1 AND c.active =1
');
$carriersArray = array();
foreach ($carriers as $row) {
$carriersArray[(int)$row['id_carrier']] = $row['name'];
}
$this->fieldsDisplay = array(
'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false),
'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true),
'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 100, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true),
'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'price' => true, 'currency' => true),
'payment' => array('title' => $this->l('Payment'), 'width' => 100),
'payment' => array('title' => $this->l('Payment'), 'width' => 80),
'osname' => array('title' => $this->l('Status'), 'widthColumn' => 230, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
'id_carrier' => array('title' => $this->l('Carrier'), 'align' => 'center', 'width' => 80, 'callback' => 'printCarrier', 'orderby' => false, 'type' => 'select', 'select' => $carriersArray, 'filter_key' => 'a!id_carrier', 'filter_type' => 'int'),
'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
//'mixed' => array('title' => $this->l('Mixed'), 'callback' => 'printMixedSale', 'orderby' => false, 'search' => false),
'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false),

View File

@ -11,42 +11,54 @@ class Order extends OrderCore {
') == 1? 'S': 'M';
}
public function printCountry($value, $params)
public function printCountry($value, $params)
{
return '<img src="/img/flags/'.(int) $value.'.png" alt="" />';
}
public function printCarrier($value, $params)
{
$laposte_carriers = unserialize(Configuration::get('LAPOSTEWS_CARRIERS', serialize(array())));
$mondialrelay_carriers = unserialize(Configuration::get('MONDIALRELAYWS_CARRIERS', serialize(array())));
$carriers_drop = explode(',',Configuration::get('ANT_CARRIER_DROP'));
if(in_array($value,$mondialrelay_carriers)){
return '<img width="18px" src="/img/carriers/logo_mr.png" alt="" />';
}elseif(in_array($value,$laposte_carriers) || in_array($value,$carriers_drop)){
return '<img width="18px" src="/img/carriers/logo_socol.png" alt="" />';
}
}
public static function getTotalbyDate($date_start, $date_end, $state = 0){
if($state == 0){
if($date_start == $date_end){
return Db::getInstance()->getValue('
SELECT SUM(`total_paid`)
SELECT SUM(`total_paid`)
FROM `ps_orders` o
WHERE `date_add` LIKE "'.$date_start.'%"
');
}else{
return Db::getInstance()->getValue('
SELECT SUM(`total_paid`)
SELECT SUM(`total_paid`)
FROM `ps_orders` o
WHERE `date_add` BETWEEN "'.$date_start.' 00:00:00" AND "'.$date_end.' 23:59:59"
');
');
}
}else{
if($date_start == $date_end){
return Db::getInstance()->getValue('
SELECT SUM(`total_paid`)
SELECT SUM(`total_paid`)
FROM `ps_orders` o
WHERE `date_add` LIKE "'.$date_start.'%"
AND (SELECT id_order_state FROM ps_order_history hi WHERE o.id_order = hi.id_order ORDER BY id_order_history DESC LIMIT 1) = '.$state.'
');
}else{
}else{
return Db::getInstance()->getValue('
SELECT SUM(`total_paid`)
SELECT SUM(`total_paid`)
FROM `ps_orders` o
WHERE `date_add` BETWEEN "'.$date_start.' 00:00:00" AND "'.$date_end.' 23:59:59"
AND (SELECT id_order_state FROM ps_order_history hi WHERE o.id_order = hi.id_order ORDER BY id_order_history DESC LIMIT 1) = '.$state.'
');
');
}
}
}
@ -59,17 +71,17 @@ class Order extends OrderCore {
$ids_order_detail = array_column($products, 'id_order_detail');
$send_infos = Order::getIfSended($ids_order_detail);
foreach ($products AS $row)
{
if( $send_infos[$row['id_order_detail']]
if( $send_infos[$row['id_order_detail']]
== ($row['product_quantity'] - ($row['product_quantity_return'] + $row['product_quantity_refunded']) )
) {
$row['sended'] = 1;
} else {
$row['sended'] = 0;
}
// Change qty if selected
if ($selectedQty)
{
@ -104,28 +116,28 @@ class Order extends OrderCore {
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT *
FROM `'._DB_PREFIX_.'order_detail` od
WHERE od.`id_order` = '.(int)($this->id));
WHERE od.`id_order` = '.(int)($this->id));
}
}
public static function getIfSended($ids) {
$data = array();
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT
SELECT
d.`id_order_detail`,
IF(
IF(
(SELECT COUNT(p.`id_order_detail`)
FROM `'._DB_PREFIX_.'lapostews` p
FROM `'._DB_PREFIX_.'lapostews` p
WHERE d.`id_order_detail` = p.`id_order_detail`),
(SELECT SUM(p.`quantity`)
FROM `'._DB_PREFIX_.'lapostews` p
FROM `'._DB_PREFIX_.'lapostews` p
WHERE d.`id_order_detail` = p.`id_order_detail`),
0
) as `total_send`
FROM `'._DB_PREFIX_.'order_detail` d
WHERE d.`id_order_detail` IN ('.implode(',', $ids).')
') as $key => $info) {
$data[$info['id_order_detail']] = $info['total_send'];
$data[$info['id_order_detail']] = $info['total_send'];
}
return $data;
}