From d5bd7198cd0fd8b7322c255a0e4122a21aab8820 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Mon, 6 May 2024 09:34:53 +0530 Subject: [PATCH] Added amount paid from all orders in the total amount paid in the view of admin customer --- .../controllers/customer_threads/helpers/view/view.tpl | 8 ++++---- .../controllers/customers/helpers/view/view.tpl | 2 +- classes/order/Order.php | 3 ++- controllers/admin/AdminCustomerThreadsController.php | 8 +++++++- controllers/admin/AdminCustomersController.php | 10 ++++++++-- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/admin/themes/default/template/controllers/customer_threads/helpers/view/view.tpl b/admin/themes/default/template/controllers/customer_threads/helpers/view/view.tpl index 31b65cf8a..2d4a2409f 100644 --- a/admin/themes/default/template/controllers/customer_threads/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/customer_threads/helpers/view/view.tpl @@ -33,7 +33,7 @@ {if isset($next_thread) && $next_thread} {$next_thread.name} - + {/if}
@@ -71,7 +71,7 @@

{if $count_ok} - {l s='[1]%1$d[/1] order(s) validated for a total amount of [2]%2$s[/2]' sprintf=[$count_ok, $total_ok] tags=['', '']} + {l s='[1]%1$d[/1] order(s) validated, total amount paid [2]%2$s[/2]' sprintf=[$count_ok, $total_ok] tags=['', '']} {else} {l s="No orders validated for the moment"} {/if} @@ -115,7 +115,7 @@
{l s="Choose a template"} - --> + --> @@ -159,7 +159,7 @@ }); timer = setInterval("markAsRead()", 3000); }); - + function markAsRead() { $.ajax({ diff --git a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl index 9553067df..a83c3b67b 100644 --- a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl @@ -252,7 +252,7 @@ {/if} {if $count_ko} - +
diff --git a/classes/order/Order.php b/classes/order/Order.php index a4e7a5e6b..cb692afe1 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -962,7 +962,8 @@ class OrderCore extends ObjectModel } $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT o.*, (SELECT SUM(od.`product_quantity`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = o.`id_order`) nb_products + SELECT o.*, (SELECT SUM(od.`product_quantity`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = o.`id_order`) nb_products, + (SELECT MAX(hbd.`date_to`) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_order` = o.`id_order`) order_last_date FROM `'._DB_PREFIX_.'orders` o WHERE o.`id_customer` = '.(int)$id_customer. Shop::addSqlRestriction(Shop::SHARE_ORDER).' diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php index c7a52fc5e..13a69f79c 100644 --- a/controllers/admin/AdminCustomerThreadsController.php +++ b/controllers/admin/AdminCustomerThreadsController.php @@ -656,10 +656,16 @@ class AdminCustomerThreadsControllerCore extends AdminController $total_ok = 0; $orders_ok = array(); foreach ($orders as $key => $order) { - if ($order['valid']) { + if ($order['valid'] + || strtotime($order['order_last_date']) >= strtotime(date('Y-m-d')) + ) { $orders_ok[] = $order; + } + + if ($order['total_paid_real']) { $total_ok += $order['total_paid_real']/$order['conversion_rate']; } + $orders[$key]['date_add'] = Tools::displayDate($order['date_add']); $orders[$key]['total_paid_real'] = Tools::displayPrice($order['total_paid_real'], new Currency((int)$order['id_currency'])); } diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index a70d9dc1a..4141325ea 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -829,9 +829,14 @@ class AdminCustomersControllerCore extends AdminController $order['order_state'] = $this->l('There is no status defined for this order.'); } - if ($order['valid']) { - $orders_ok[] = $order; + if ($order['total_paid_real_not_formated']) { $total_ok += $order['total_paid_real_not_formated']/$order['conversion_rate']; + } + + if ($order['valid'] + || strtotime($order['order_last_date']) >= strtotime(date('Y-m-d')) + ) { + $orders_ok[] = $order; } else { $orders_ko[] = $order; } @@ -862,6 +867,7 @@ class AdminCustomersControllerCore extends AdminController JOIN '._DB_PREFIX_.'product p ON (cp.id_product = p.id_product) AND p.booking_product=1 WHERE c.id_customer = '.(int)$customer->id.' + AND p.booking_product = 1 AND NOT EXISTS ( SELECT 1 FROM '._DB_PREFIX_.'orders o
{l s='ID'}