From 8e77e4b5303c1cdaa00ff81f3285acfdb87518ed Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 9 Sep 2013 11:07:51 +0200 Subject: [PATCH] create admin customer view and add output info in customer loop --- .../Thelia/Core/Template/Loop/Customer.php | 15 +++ core/lib/Thelia/Model/Order.php | 11 ++ templates/admin/default/customers.html | 108 ++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 templates/admin/default/customers.html diff --git a/core/lib/Thelia/Core/Template/Loop/Customer.php b/core/lib/Thelia/Core/Template/Loop/Customer.php index 1a4b84105..cbf9e4fda 100755 --- a/core/lib/Thelia/Core/Template/Loop/Customer.php +++ b/core/lib/Thelia/Core/Template/Loop/Customer.php @@ -64,6 +64,7 @@ class Customer extends BaseLoop ) ), Argument::createBooleanTypeArgument('reseller'), + Argument::createBooleanTypeArgument('last_order'), Argument::createIntTypeArgument('sponsor') ); } @@ -130,6 +131,20 @@ class Customer extends BaseLoop $loopResultRow->set("SPONSOR", $customer->getSponsor()); $loopResultRow->set("DISCOUNT", $customer->getDiscount()); + $lastOrderDate = ""; + $lastOrderAmount = ""; + + if ($this->getLastOrder()) { + $order = $customer->getOrders()->getFirst(); + if ($order) { + $lastOrderDate = $order->getCreatedAt(); + $lastOrderAmount = $order->getTotalAmount(); + } + } + + $loopResultRow->set("LASTORDER_DATE", $lastOrderDate); + $loopResultRow->set("LASTORDER_AMOUNT", $lastOrderAmount); + $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index 91582750a..ccdd152b5 100755 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -6,4 +6,15 @@ use Thelia\Model\Base\Order as BaseOrder; class Order extends BaseOrder { + /** + * calculate the total amount + * + * @TODO create body method + * + * @return int + */ + public function getTotalAmount() + { + return 0; + } } diff --git a/templates/admin/default/customers.html b/templates/admin/default/customers.html new file mode 100644 index 000000000..0e68677dd --- /dev/null +++ b/templates/admin/default/customers.html @@ -0,0 +1,108 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Customer'}{/block} + +{block name="check-permissions"}admin.customer.view{/block} + +{block name="main-content"} +
+
+ + + {module_include location='customer_top'} + +
+
+
+ + + + {ifloop rel="customer_list"} + + + + + + + {module_include location='category_list_header'} + + + + + + + + + + + + + {loop name="customer_list" type="customer" visible="*" last_order="1" backend_context="1"} + + + + + + + + {module_include location='customer_list_row'} + + + + + + + + {/loop} + + {/ifloop} +
+ {intl l="Customers list"} + + {module_include location='customer_list_caption'} + + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.customers.create"} + + + + {/loop} +
+ {intl l="customer ref"} + + {intl l="company"} + + {intl l="firstname & lastname"} + + {intl l="last order"} + {intl l='order amount'}{intl l='Actions'}
{#REF} + {#COMPANY} + + {#FIRSTNAME} {#LASTNAME} + + {format_date date=#LASTORDER_DATE} + + {format_number number=#LASTORDER_AMOUNT} + +
+ + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.customer.edit"} + + {/loop} + {loop type="auth" name="can_send_mail" roles="ADMIN" permissions="admin.customer.sendMail"} + + {/loop} + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.customer.delete"} + + {/loop} +
+
+
+
+
+ + + {module_include location='customer_bottom'} +
+
+ +{/block} \ No newline at end of file