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 18145ce07..8aab78130 100644 --- a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl @@ -197,85 +197,122 @@ {if $orders AND count($orders)} {assign var=count_ok value=count($orders_ok)} {assign var=count_ko value=count($orders_ko)} -

-
-
- - {l s='Valid orders:'} - {$count_ok} - {l s='for a total amount of %s' sprintf=$total_ok} -
-
- - {l s='Invalid orders:'} - {$count_ko} + {if $count_ok || $count_ko} + -
- - {if $count_ok} - - - - - - - - - - - - - - {foreach $orders_ok AS $key => $order} - - - - - - - - - - {/foreach} - -
{l s='ID'}{l s='Date'}{l s='Payment'}{l s='Status'}{l s='Products'}{l s='Total spent'}
{$order['id_order']}{dateFormat date=$order['date_add'] full=0}{$order['payment']}{$order['order_state']}{$order['nb_products']}{$order['total_paid_real']} - - {l s='View'} - -
{/if} - {if $count_ko} - - - - - - - - - - - - - {foreach $orders_ko AS $key => $order} - - - - - - - - - {/foreach} - -
{l s='ID'}{l s='Date'}{l s='Payment'}{l s='Status'}{l s='Products'}{l s='Total spent'}
{$order['id_order']}{dateFormat date=$order['date_add'] full=0}{$order['payment']}{$order['order_state']}{$order['nb_products']}{$order['total_paid_real']}
- {/if} {else} -

- {l s='%1$s %2$s has not placed any orders yet' sprintf=[$customer->firstname, $customer->lastname]} -

+

+ {l s='%1$s %2$s has not placed any orders yet' sprintf=[$customer->firstname, $customer->lastname]} +

{/if}
@@ -289,7 +326,6 @@ {l s='ID'} {l s='Date'} - {l s='Carrier'} {l s='Total'} @@ -302,7 +338,6 @@ {dateFormat date=$cart['date_upd'] full=0} - {$cart['name']} {$cart['total_price']} {/foreach} @@ -315,33 +350,95 @@ {/if}
{if $products AND count($products)} -
-
- {l s='Purchased products'} {count($products)} +
+
+ {l s='Room types and services'} {count($products)} +
+
- - - - - - - - - - {foreach $products AS $key => $product} - - - - - - {/foreach} - -
{l s='Date'}{l s='Name'}{l s='Quantity'}
{dateFormat date=$product['date_add'] full=0} - - {$product['product_name']} - - {$product['product_quantity']}
-
{/if} {if count($interested)}
@@ -454,7 +551,7 @@ - + diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index e8c21dfc3..053ca5a45 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -584,7 +584,7 @@
  {$customer->date_add|date_format:"%d %b, %Y"} ({l s='Member since'})
  {$customerStats['nb_orders']|intval} ({l s='Total valid order placed'})
-
  {displayPrice price=Tools::ps_round(Tools::convertPrice($customerStats['total_orders'], $currency), 2) currency=$currency->id} ({l s='Total spent since registration'})
+
  {displayPrice price=Tools::ps_round(Tools::convertPrice($customerStats['total_spent'], $currency), 2) currency=$currency->id} ({l s='Total spent since registration'})
{if Configuration::get('PS_B2B_ENABLE')}
{$customer->siret} ({l s='Siret'})
{$customer->ape|date_format:"%d %b, %Y"} ({l s='APE'})
@@ -1026,7 +1026,7 @@ {if $can_edit} - + {/if} diff --git a/classes/Customer.php b/classes/Customer.php index 7367dcf24..28b06864a 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -589,7 +589,8 @@ class CustomerCore extends ObjectModel public function getStats() { $result = Db::getInstance()->getRow(' - SELECT COUNT(`id_order`) AS nb_orders, SUM(`total_paid` / o.`conversion_rate`) AS total_orders + SELECT COUNT(`id_order`) AS nb_orders, SUM(`total_paid` / o.`conversion_rate`) AS total_orders, + SUM(o.`total_paid_real` / o.`conversion_rate`) AS total_spent FROM `'._DB_PREFIX_.'orders` o WHERE o.`id_customer` = '.(int)$this->id.' AND o.valid = 1'); @@ -736,7 +737,7 @@ class CustomerCore extends ObjectModel return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order - WHERE o.valid = 1 AND o.`id_customer` = '.(int)$this->id); + WHERE od.`product_auto_add`= 0 AND o.valid = 1 AND o.`id_customer` = '.(int)$this->id); } public static function getDefaultGroupId($id_customer) diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index f0995a219..413e55a28 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -838,6 +838,7 @@ class AdminCustomersControllerCore extends AdminController } $total_ok = 0; + $total_ko = 0; $orders_ok = array(); $orders_ko = array(); foreach ($orders as $order) { @@ -850,10 +851,21 @@ class AdminCustomersControllerCore extends AdminController $total_ok += $order['total_paid_real_not_formated']/$order['conversion_rate']; } else { $orders_ko[] = $order; + $total_ko += $order['total_paid'] / $order['conversion_rate']; } } - $products = $customer->getBoughtProducts(); + $purchasedServices = array(); + $purchasedRoomTypes = array(); + if ($products = $customer->getBoughtProducts()) { + foreach ($products as $product) { + if ($product['is_booking_product']) { + $purchasedRoomTypes[] = $product; + } else { + $purchasedServices[] = $product; + } + } + } $carts = Cart::getCustomerCarts($customer->id); $total_carts = count($carts); @@ -876,6 +888,7 @@ class AdminCustomersControllerCore extends AdminController FROM '._DB_PREFIX_.'cart_product cp JOIN '._DB_PREFIX_.'cart c ON (c.id_cart = cp.id_cart) 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 NOT EXISTS ( SELECT 1 @@ -948,8 +961,11 @@ class AdminCustomersControllerCore extends AdminController 'orders_ok' => $orders_ok, 'orders_ko' => $orders_ko, 'total_ok' => Tools::displayPrice($total_ok, $this->context->currency->id), + 'total_ko' => Tools::displayPrice($total_ko, $this->context->currency->id), // Products 'products' => $products, + 'purchasedRoomTypes' => $purchasedRoomTypes, + 'purchasedServices' => $purchasedServices, // Addresses 'addresses' => $customer->getAddresses($this->default_form_language), // Discounts diff --git a/js/admin/orders.js b/js/admin/orders.js index ba031000d..455ca27b1 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -30,6 +30,12 @@ $(document).ready(function() { // Init all events init(); + $(document).on('click', '.delete-voucher', function(e) { + if (!confirm(txt_confirm)) { + e.preventDefault(); + } + }); + $('img.js-disabled-action').css({"opacity":0.5}); });