diff --git a/core/lib/Thelia/Controller/Admin/OrderController.php b/core/lib/Thelia/Controller/Admin/OrderController.php index c04e2c93e..97713a589 100644 --- a/core/lib/Thelia/Controller/Admin/OrderController.php +++ b/core/lib/Thelia/Controller/Admin/OrderController.php @@ -46,7 +46,11 @@ class OrderController extends BaseAdminController public function indexAction() { if (null !== $response = $this->checkAuth(AdminResources::ORDER, array(), AccessManager::VIEW)) return $response; - return $this->render("orders", array("display_order" => 20)); + + return $this->render("orders", array( + "display_order" => 20, + "orders_order" => $this->getListOrderFromSession("orders", "orders_order", "create-date-reverse") + )); } public function viewAction($order_id) diff --git a/core/lib/Thelia/Core/Template/Loop/Order.php b/core/lib/Thelia/Core/Template/Loop/Order.php index 3fb04d60c..c3e48dc8e 100644 --- a/core/lib/Thelia/Core/Template/Loop/Order.php +++ b/core/lib/Thelia/Core/Template/Loop/Order.php @@ -26,17 +26,20 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; - use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\PropelSearchLoopInterface; use Thelia\Core\Template\Element\SearchLoopInterface; -use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Model\Base\Customer; use Thelia\Model\CustomerQuery; +use Thelia\Model\Map\CustomerTableMap; +use Thelia\Model\Map\OrderAddressTableMap; use Thelia\Model\OrderAddressQuery; use Thelia\Model\OrderQuery; -use Thelia\Type\TypeCollection; use Thelia\Type; +use Thelia\Type\TypeCollection; + /** * * @package Thelia\Core\Template\Loop @@ -72,7 +75,14 @@ class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInt new Argument( 'order', new TypeCollection( - new Type\EnumListType(array('create-date', 'create-date-reverse')) + new Type\EnumListType(array( + 'id', 'id-reverse', + 'reference', 'reference-reverse', + 'create-date', 'create-date-reverse', + 'company', 'company-reverse', + 'customer-name', 'customer-name-reverse', + 'status', 'status-reverse' + )) ), 'create-date-reverse' ) @@ -165,12 +175,67 @@ class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInt foreach ($orderers as $orderer) { switch ($orderer) { + case 'id': + $search->orderById(Criteria::ASC); + break; + case 'id_reverse': + $search->orderById(Criteria::DESC); + break; + + case 'reference': + $search->orderByRef(Criteria::ASC); + break; + case 'reference_reverse': + $search->orderByRef(Criteria::DESC); + break; + case "create-date": $search->orderByCreatedAt(Criteria::ASC); break; case "create-date-reverse": $search->orderByCreatedAt(Criteria::DESC); break; + + case "status": + $search->orderByStatusId(Criteria::ASC); + break; + case "status": + $search->orderByStatusId(Criteria::DESC); + break; + + case 'company' : + $search + ->joinOrderAddressRelatedByDeliveryOrderAddressId() + ->withColumn(OrderAddressTableMap::COMPANY, 'company') + ->orderBy('company', Criteria::ASC) + ; + break; + case 'companyreverse' : + $search + ->joinOrderAddressRelatedByDeliveryOrderAddressId() + ->withColumn(OrderAddressTableMap::COMPANY, 'company') + ->orderBy('company', Criteria::DESC) + ; + break; + + case 'customer-name' : + $search + ->joinCustomer() + ->withColumn(CustomerTableMap::FIRSTNAME, 'firstname') + ->withColumn(CustomerTableMap::LASTNAME, 'lastname') + ->orderBy('lastname', Criteria::ASC) + ->orderBy('firstname', Criteria::ASC) + ; + break; + case 'customer-name-reverse' : + $search + ->joinCustomer() + ->withColumn(CustomerTableMap::FIRSTNAME, 'firstname') + ->withColumn(CustomerTableMap::LASTNAME, 'lastname') + ->orderBy('lastname', Criteria::DESC) + ->orderBy('firstname', Criteria::DESC) + ; + break; } } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php index d0f021ef5..f022cf0c5 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php @@ -28,6 +28,7 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Template\Smarty\Exception\SmartyPluginException; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Tools\DateTimeFormat; +use Thelia\Tools\MoneyFormat; use Thelia\Tools\NumberFormat; /** @@ -135,6 +136,40 @@ class Format extends AbstractSmartyPlugin $this->getParam($params, "thousands_sep", null) ); } + /** + * + * display a amount in expected format + * + * available parameters : + * number => int or float number + * decimals => how many decimals format expected + * dec_point => separator for the decimal point + * thousands_sep => thousands separator + * symbol => Currency symbol + * + * ex : {format_money number="1246.12" decimals="1" dec_point="," thousands_sep=" " symbol="€"} will output "1 246,1 €" + * + * @param $params + * @param null $template + * @throws \Thelia\Core\Template\Smarty\Exception\SmartyPluginException + * @return string the expected number formatted + */ + public function formatMoney($params, $template = null) + { + $number = $this->getParam($params, "number", false); + + if ($number === false || $number == '') { + return ""; + } + + return MoneyFormat::getInstance($this->request)->format( + $number, + $this->getParam($params, "decimals", null), + $this->getParam($params, "dec_point", null), + $this->getParam($params, "thousands_sep", null), + $this->getParam($params, "symbol", null) + ); + } /** * @return an array of SmartyPluginDescriptor @@ -143,7 +178,8 @@ class Format extends AbstractSmartyPlugin { return array( new SmartyPluginDescriptor("function", "format_date", $this, "formatDate"), - new SmartyPluginDescriptor("function", "format_number", $this, "formatNumber") - ); + new SmartyPluginDescriptor("function", "format_number", $this, "formatNumber"), + new SmartyPluginDescriptor("function", "format_money", $this, "formatMoney") + ); } } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php index 4c92ee85c..da98ce14d 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php @@ -82,8 +82,9 @@ class Module extends AbstractSmartyPlugin } } - if (! empty($content)) + if (! empty($content)) { return $template->fetch(sprintf("string:%s", $content)); + } return ""; } diff --git a/templates/backOffice/default/customer-edit.html b/templates/backOffice/default/customer-edit.html index d5b48f3d6..9747c935c 100644 --- a/templates/backOffice/default/customer-edit.html +++ b/templates/backOffice/default/customer-edit.html @@ -160,6 +160,7 @@

+ {ifloop rel="address"}
@@ -212,6 +213,13 @@
+ {/ifloop} + + {elseloop rel="address"} +
+ {intl l="This customer has not defined any delivery address"} +
+ {/elseloop} diff --git a/templates/backOffice/default/order-edit.html b/templates/backOffice/default/order-edit.html index fc7903e1c..12915da92 100644 --- a/templates/backOffice/default/order-edit.html +++ b/templates/backOffice/default/order-edit.html @@ -28,22 +28,30 @@ {loop type="order" name="the-order" id=$order_id customer="*"} {loop type="currency" name="order-currency" id=$CURRENCY} - {assign "orderCurrency" $SYMBOL} + {$orderCurrency=$SYMBOL} {/loop} {assign "orderStatusId" $STATUS} -
- {$REF} -
-
+
+
+ {intl l='Order %ref' ref=$REF} +
+ +
+ - +
+ +
+ +
+
@@ -59,16 +67,16 @@
- - - - - + + + + + @@ -95,11 +103,11 @@ {/ifloop} - - - - - + + + + + {/loop} @@ -107,17 +115,17 @@ - + - + - - + - + - +
- {intl l='Cart'} + {intl l='Cart - Prices in %currency' currency=$orderCurrency}
{intl l="Product"}{intl l="Unit. price"}{intl l="Tax"}{intl l="Unit taxed price"}{intl l="Quantity"}{intl l="Taxed total"}{intl l="Unit. price"}{intl l="Tax"}{intl l="Unit taxed price"}{intl l="Quantity"}{intl l="Taxed total"}
{$orderCurrency} {$realPrice}{$orderCurrency} {$realTax}{$orderCurrency} {$realTaxedPrice}{$QUANTITY}{$orderCurrency} {$realTaxedPrice * $QUANTITY}{format_money number=$realPrice symbol=$orderCurrency}{format_money number=$realTax symbol=$orderCurrency}{format_money number=$realTaxedPrice symbol=$orderCurrency}{$QUANTITY}{format_money number=$realTaxedPrice * $QUANTITY symbol=$orderCurrency}
{intl l="Total without discount"}{$orderCurrency} {$TOTAL_TAXED_AMOUNT-$POSTAGE}{format_money number=$TOTAL_TAXED_AMOUNT-$POSTAGE symbol=$orderCurrency}
{intl l="Discount"}{$orderCurrency} {$DISCOUNT}{format_money number=$DISCOUNT symbol=$orderCurrency}
{intl l="Coupon code"} + {loop type="order_coupon" name="couponcode" order=$ID} {$CODE}{if $LOOP_COUNT != $LOOP_TOTAL}, {/if} {/loop} @@ -129,17 +137,17 @@
{intl l="Total including discount"}{$orderCurrency} {$TOTAL_TAXED_AMOUNT-$POSTAGE}{format_money number=$TOTAL_TAXED_AMOUNT-$POSTAGE symbol=$orderCurrency}
{intl l="Postage"}{$orderCurrency} {$POSTAGE}{format_money number=$POSTAGE symbol=$orderCurrency}
{intl l="Total"}{$orderCurrency} {$TOTAL_TAXED_AMOUNT}{format_money number=$TOTAL_TAXED_AMOUNT symbol=$orderCurrency}
diff --git a/templates/backOffice/default/orders.html b/templates/backOffice/default/orders.html index 808bd8c8d..0cfd9c286 100644 --- a/templates/backOffice/default/orders.html +++ b/templates/backOffice/default/orders.html @@ -32,12 +32,57 @@ - {intl l="Order n°"} - {intl l="Date & Hour"} - {intl l="Company"} - {intl l="Name"} - {intl l="Amount"} - {intl l="Status"} + + {admin_sortable_header + current_order=$orders_order + order='reference' + reverse_order='reference-reverse' + path={url path='/admin/orders'} + request_parameter_name='orders_order' + label="{intl l='Order #'}" + } + + + {admin_sortable_header + current_order=$orders_order + order='create-date' + reverse_order='create-date-reverse' + path={url path='/admin/orders'} + request_parameter_name='orders_order' + label="{intl l='Date & Hour'}" + } + + + {admin_sortable_header + current_order=$orders_order + order='company' + reverse_order='company-reverse' + path={url path='/admin/orders'} + request_parameter_name='orders_order' + label="{intl l='Company'}" + } + + + {admin_sortable_header + current_order=$orders_order + order='customer-name' + reverse_order='customer-name-reverse' + path={url path='/admin/orders'} + request_parameter_name='orders_order' + label="{intl l='Cutomer Name'}" + } + + {intl l='Amount'} + + + {admin_sortable_header + current_order=$orders_order + order='status' + reverse_order='status-reverse' + path={url path='/admin/orders'} + request_parameter_name='orders_order' + label="{intl l='Status'}" + } {module_include location='orders_table_header'} @@ -47,7 +92,11 @@ - {loop type="order" name="order-list" customer="*" backend_context="1" page={$order_page} limit={#max_displayed_orders#} status=$status_filter|default:'*'} + {loop type="order" name="order-list" customer="*" order=$orders_order backend_context="1" page={$order_page} limit={#max_displayed_orders#} status=$status_filter|default:'*'} + + {loop type="currency" name="order-currency" id=$CURRENCY} + {$orderCurrency=$SYMBOL} + {/loop} {loop type="order_address" name="order-invoice-address" id=$INVOICE_ADDRESS} {assign "orderInvoiceFirstName" $FIRSTNAME} @@ -66,8 +115,8 @@ {format_date date=$CREATE_DATE} {$orderInvoiceCompany} {$orderInvoiceFirstName|ucwords} {$orderInvoiceLastName|upper} - {$TOTAL_TAXED_AMOUNT} - {$orderStatus} + {format_money number=$TOTAL_TAXED_AMOUNT symbol=$orderCurrency} + {$orderStatus} {module_include location='orders_table_row'} @@ -94,14 +143,14 @@
    {if $order_page != 1} -
  • «
  • +
  • «
  • {else}
  • «
  • {/if} {pageloop rel="order-list"} {if $PAGE != $CURRENT} -
  • {$PAGE}
  • +
  • {$PAGE}
  • {else}
  • {$PAGE}
  • @@ -110,7 +159,7 @@ {/pageloop} {if $PAGE == $LAST && $LAST != $CURRENT} -
  • »
  • +
  • »
  • {else}
  • »
  • {/if}