diff --git a/admin-dev/themes/default/css/admin.css b/admin-dev/themes/default/css/admin.css index 8acbc91e6..3f548a1eb 100644 --- a/admin-dev/themes/default/css/admin.css +++ b/admin-dev/themes/default/css/admin.css @@ -499,3 +499,31 @@ ul.listForm li {padding-bottom:3px;} .selected-line {background:#fff1b5;} #changedFiles ul{list-style-type: square; padding-left: 40px;} + +.tooltip { position: relative; } +.tooltip .tooltip_content { + z-index: 100; + text-align: left; + display: none; + white-space: nowrap; + position: absolute; + padding: 5px 5px; + background: black; + color: white; + box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.5); + margin-top: 5px; +} +.tooltip .tooltip_label { cursor: pointer; } +.tooltip .title { text-align: center; padding-bottom: 5px; display: block; font-weight: bold } +.tooltip:hover .tooltip_content { display: block; } +.tooltip_button { + border: 1px solid silver; + border-radius: 3px; + padding: 0 3px; + background: -moz-linear-gradient(top, #ddd, #aaa); + background: -o-linear-gradient(top, #ddd, #aaa); + background: -webkit-linear-gradient(top, #ddd, #aaa); + background: linear-gradient(top, #ddd, #aaa); + color: #666 +} + diff --git a/admin-dev/themes/default/template/controllers/orders/_product_line.tpl b/admin-dev/themes/default/template/controllers/orders/_product_line.tpl index 056fe566a..910450511 100755 --- a/admin-dev/themes/default/template/controllers/orders/_product_line.tpl +++ b/admin-dev/themes/default/template/controllers/orders/_product_line.tpl @@ -57,8 +57,38 @@ {/if} - {if ($order->hasBeenPaid())}{$product['product_quantity_refunded']}{/if} - {if ($order->hasBeenDelivered())}{$product['product_quantity_return']}{/if} + {if ($order->hasBeenPaid())} + + {$product['product_quantity_refunded']} + {if count($product['refund_history'])} + + + +
+ {l s='Refund history'} + {foreach $product['refund_history'] as $refund} + {l s='%1s - %2s' sprintf=[{dateFormat date=$refund.date_add}, {displayPrice price=$refund.amount_tax_incl}]}
+ {/foreach} +
+
+ {/if} + + {/if} + {if $order->hasBeenDelivered() || $order->hasProductReturned()} + + {$product['product_quantity_return']} + {if count($product['return_history'])} + + + +
+ {l s='Return history'} + {foreach $product['return_history'] as $return} + {l s='%1s - %2s - %3s' sprintf=[{dateFormat date=$return.date_add}, $return.product_quantity, $return.state]}
+ {/foreach} +
+
+ {/if} + + {/if} {$product['current_stock']} {displayPrice price=(Tools::ps_round($product_price, 2) * ($product['product_quantity'] - $product['customizationQuantityTotal'])) currency=$currency->id} diff --git a/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl index 3559ec774..1ebf0a2d7 100755 --- a/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -590,7 +590,7 @@ {l s='Unit Price'} * {l s='Qty'} {if ($order->hasBeenPaid())}{l s='Refunded'}{/if} - {if ($order->hasBeenDelivered())}{l s='Returned'}{/if} + {if ($order->hasBeenDelivered() || $order->hasProductReturned())}{l s='Returned'}{/if} {l s='Available quantity'} {l s='Total'} *   diff --git a/classes/order/Order.php b/classes/order/Order.php index 25b951a08..fdb50dc53 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -755,6 +755,21 @@ class OrderCore extends ObjectModel { return count($this->getHistory((int)($this->id_lang), false, false, OrderState::FLAG_DELIVERY)); } + + /** + * Has products returned by the merchant or by the customer? + */ + public function hasProductReturned() + { + return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' + SELECT IFNULL(SUM(ord.product_quantity), SUM(product_quantity_return)) + FROM `'._DB_PREFIX_.'orders` o + INNER JOIN `'._DB_PREFIX_.'order_detail` od + ON od.id_order = o.id_order + LEFT JOIN `'._DB_PREFIX_.'order_return_detail` ord + ON ord.id_order_detail = od.id_order_detail + WHERE o.id_order = '.(int)$this->id); + } public function hasBeenPaid() { diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 833b2beeb..d781f2c5a 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -199,5 +199,22 @@ class OrderReturnCore extends ObjectModel { return Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'order_return_detail` WHERE `id_order_detail` = '.(int)($id_order_detail).' AND `id_order_return` = '.(int)($id_order_return).' AND `id_customization` = '.(int)($id_customization)); } + + /** + * + * Get return details for one product line + * @param $id_order_detail + */ + public static function getProductReturnDetail($id_order_detail) + { + return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' + SELECT product_quantity, date_add, orsl.name as state + FROM `'._DB_PREFIX_.'order_return_detail` ord + LEFT JOIN `'._DB_PREFIX_.'order_return` o + ON o.id_order_return = ord.id_order_return + LEFT JOIN `'._DB_PREFIX_.'order_return_state_lang` orsl + ON orsl.id_order_return_state = o.state AND orsl.id_lang = '.(int)Context::getContext()->language->id.' + WHERE ord.`id_order_detail` = '.(int)$id_order_detail); + } } diff --git a/classes/order/OrderSlip.php b/classes/order/OrderSlip.php index 320164a7e..2438b038e 100644 --- a/classes/order/OrderSlip.php +++ b/classes/order/OrderSlip.php @@ -99,7 +99,7 @@ class OrderSlipCore extends ObjectModel ORDER BY `date_add` DESC'); } - public static function getOrdersSlipDetail($id_order_slip = true, $id_order_detail = false) + public static function getOrdersSlipDetail($id_order_slip = false, $id_order_detail = false) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS( ($id_order_detail ? 'SELECT SUM(`product_quantity`) AS `total`' : 'SELECT *'). @@ -141,7 +141,12 @@ class OrderSlipCore extends ObjectModel } return $order->getProducts($resTab); } - + + /** + * + * Get resume of all refund for one product line + * @param $id_order_detail + */ public static function getProductSlipResume($id_order_detail) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' @@ -149,6 +154,21 @@ class OrderSlipCore extends ObjectModel FROM `'._DB_PREFIX_.'order_slip_detail` WHERE `id_order_detail` = '.(int)$id_order_detail); } + + /** + * + * Get refund details for one product line + * @param $id_order_detail + */ + public static function getProductSlipDetail($id_order_detail) + { + return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' + SELECT product_quantity, amount_tax_excl, amount_tax_incl, date_add + FROM `'._DB_PREFIX_.'order_slip_detail` osd + LEFT JOIN `'._DB_PREFIX_.'order_slip` os + ON os.id_order_slip = osd.id_order_slip + WHERE osd.`id_order_detail` = '.(int)$id_order_detail); + } public function getProducts() { diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index a1c854112..113f188e2 100755 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1251,6 +1251,8 @@ class AdminOrdersControllerCore extends AdminController $product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity']; $product['amount_refundable'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl']; $product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl']); + $product['refund_history'] = OrderSlip::getProductSlipDetail($product['id_order_detail']); + $product['return_history'] = OrderReturn::getProductReturnDetail($product['id_order_detail']); // if the current stock requires a warning if ($product['current_stock'] == 0 && $display_out_of_stock_warning)