From 46007271638d9fe87fc3991999655bbcaeb31d4d Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 24 Sep 2013 12:10:22 +0200 Subject: [PATCH] order admin --- .../Thelia/Core/Template/Loop/Customer.php | 15 - .../Core/Template/Loop/OrderAddress.php | 92 +-- .../Thelia/Core/Template/Loop/OrderStatus.php | 64 +- templates/admin/default/admin-layout.tpl | 32 +- templates/admin/default/customers.html | 20 +- templates/admin/default/order-edit.html | 629 +++++++++--------- templates/admin/default/orders.html | 39 +- 7 files changed, 456 insertions(+), 435 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Customer.php b/core/lib/Thelia/Core/Template/Loop/Customer.php index e0ce92c76..e811606c0 100755 --- a/core/lib/Thelia/Core/Template/Loop/Customer.php +++ b/core/lib/Thelia/Core/Template/Loop/Customer.php @@ -63,7 +63,6 @@ class Customer extends BaseLoop ) ), Argument::createBooleanTypeArgument('reseller'), - Argument::createBooleanTypeArgument('last_order'), Argument::createIntTypeArgument('sponsor') ); } @@ -130,20 +129,6 @@ 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/Core/Template/Loop/OrderAddress.php b/core/lib/Thelia/Core/Template/Loop/OrderAddress.php index cb0cbd5b5..ac2a7344b 100755 --- a/core/lib/Thelia/Core/Template/Loop/OrderAddress.php +++ b/core/lib/Thelia/Core/Template/Loop/OrderAddress.php @@ -32,6 +32,7 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\AddressQuery; +use Thelia\Model\OrderAddressQuery; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -54,29 +55,7 @@ class OrderAddress extends BaseLoop protected function getArgDefinitions() { return new ArgumentCollection( - new Argument( - 'id', - new TypeCollection( - new Type\IntListType(), - new Type\EnumType(array('*', 'any')) - ) - ), - new Argument( - 'customer', - new TypeCollection( - new Type\IntType(), - new Type\EnumType(array('current')) - ), - 'current' - ), - Argument::createBooleanOrBothTypeArgument('default'), - new Argument( - 'exclude', - new TypeCollection( - new Type\IntListType(), - new Type\EnumType(array('none')) - ) - ) + Argument::createIntTypeArgument('id', null, true) ); } @@ -91,60 +70,27 @@ class OrderAddress extends BaseLoop $id = $this->getId(); - if (null !== $id && !in_array($id, array('*', 'any'))) { - $search->filterById($id, Criteria::IN); - } + $search->filterById($id, Criteria::IN); - $customer = $this->getCustomer(); + $orderAddresses = $this->search($search, $pagination); - if ($customer === 'current') { - $currentCustomer = $this->securityContext->getCustomerUser(); - if ($currentCustomer === null) { - return new LoopResult(); - } else { - $search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL); - } - } else { - $search->filterByCustomerId($customer, Criteria::EQUAL); - } + $loopResult = new LoopResult($orderAddresses); - $default = $this->getDefault(); - - if ($default === true) { - $search->filterByIsDefault(1, Criteria::EQUAL); - } else if($default === false) { - $search->filterByIsDefault(0, Criteria::EQUAL); - } - - $exclude = $this->getExclude(); - - if (null !== $exclude && 'none' !== $exclude) { - $search->filterById($exclude, Criteria::NOT_IN); - } - - $addresses = $this->search($search, $pagination); - - $loopResult = new LoopResult($addresses); - - foreach ($addresses as $address) { - $loopResultRow = new LoopResultRow($loopResult, $address, $this->versionable, $this->timestampable, $this->countable); + foreach ($orderAddresses as $orderAddress) { + $loopResultRow = new LoopResultRow($loopResult, $orderAddress, $this->versionable, $this->timestampable, $this->countable); $loopResultRow - ->set("ID", $address->getId()) - ->set("LABEL", $address->getLabel()) - ->set("CUSTOMER", $address->getCustomerId()) - ->set("TITLE", $address->getTitleId()) - ->set("COMPANY", $address->getCompany()) - ->set("FIRSTNAME", $address->getFirstname()) - ->set("LASTNAME", $address->getLastname()) - ->set("ADDRESS1", $address->getAddress1()) - ->set("ADDRESS2", $address->getAddress2()) - ->set("ADDRESS3", $address->getAddress3()) - ->set("ZIPCODE", $address->getZipcode()) - ->set("CITY", $address->getCity()) - ->set("COUNTRY", $address->getCountryId()) - ->set("PHONE", $address->getPhone()) - ->set("CELLPHONE", $address->getCellphone()) - ->set("DEFAULT", $address->getIsDefault()) + ->set("ID", $orderAddress->getId()) + ->set("TITLE", $orderAddress->getCustomerTitleId()) + ->set("COMPANY", $orderAddress->getCompany()) + ->set("FIRSTNAME", $orderAddress->getFirstname()) + ->set("LASTNAME", $orderAddress->getLastname()) + ->set("ADDRESS1", $orderAddress->getAddress1()) + ->set("ADDRESS2", $orderAddress->getAddress2()) + ->set("ADDRESS3", $orderAddress->getAddress3()) + ->set("ZIPCODE", $orderAddress->getZipcode()) + ->set("CITY", $orderAddress->getCity()) + ->set("COUNTRY", $orderAddress->getCountryId()) + ->set("PHONE", $orderAddress->getPhone()) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/OrderStatus.php b/core/lib/Thelia/Core/Template/Loop/OrderStatus.php index 7f0e97c4f..0f0d144c4 100755 --- a/core/lib/Thelia/Core/Template/Loop/OrderStatus.php +++ b/core/lib/Thelia/Core/Template/Loop/OrderStatus.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -23,33 +23,77 @@ namespace Thelia\Core\Template\Loop; -use Thelia\Core\Template\Element\BaseLoop; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\OrderStatusQuery; + /** * - * @package Thelia\Core\Template\Loop + * OrderStatus loop * - * @author Franck Allimant + * + * Class OrderStatus + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix */ -class OrderStatus extends BaseLoop +class OrderStatus extends BaseI18nLoop { - public function getArgDefinitions() + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() { - return new ArgumentCollection(); + return new ArgumentCollection( + Argument::createIntListTypeArgument('id') + ); } /** - * + * @param $pagination * * @return \Thelia\Core\Template\Element\LoopResult */ public function exec(&$pagination) { - // TODO : a coder ! - return new LoopResult(); + $search = OrderStatusQuery::create(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + /* perform search */ + $orderStatusList = $this->search($search, $pagination); + + $loopResult = new LoopResult($orderStatusList); + + foreach ($orderStatusList as $orderStatus) { + $loopResultRow = new LoopResultRow($loopResult, $orderStatus, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow->set("ID", $orderStatus->getId()) + ->set("IS_TRANSLATED",$orderStatus->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE",$locale) + ->set("CODE", $orderStatus->getCode()) + ->set("TITLE", $orderStatus->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $orderStatus->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $orderStatus->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $orderStatus->getVirtualColumn('i18n_POSTSCRIPTUM')) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; } } diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index 553466def..c8fe855b7 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -111,26 +111,26 @@ {/loop} {loop name="menu-auth-order" type="auth" roles="ADMIN" permissions="admin.orders.view"} - {/loop} {loop name="menu-auth-catalog" type="auth" roles="ADMIN" permissions="admin.catalog.view"} diff --git a/templates/admin/default/customers.html b/templates/admin/default/customers.html index 9d74835d7..cfa332ae4 100644 --- a/templates/admin/default/customers.html +++ b/templates/admin/default/customers.html @@ -64,9 +64,21 @@ - {loop name="customer_list" type="customer" current="false" visible="*" last_order="1" backend_context="1" page={$customer_page} limit={$display_customer}} + {loop name="customer_list" type="customer" current="false" visible="*" backend_context="1" page={$customer_page} limit={$display_customer}} + {assign "lastOrderDate" ''} + {assign "lastOrderAmount" ''} + {assign "lastOrderCurrency" ''} + + {loop type="order" name="last-order" customer=$ID order="create-date-reverse" limit="1"} + {assign "lastOrderDate" "{format_date date=$CREATE_DATE}"} + {assign "lastOrderAmount" "{format_number number=$TOTAL_TAXED_AMOUNT}"} + {loop type="currency" name="order-currency" id=$CURRENCY} + {assign "lastOrderCurrency" $SYMBOL} + {/loop} + {/loop} + - {$REF} + {$REF} {$COMPANY} @@ -79,11 +91,11 @@ {module_include location='customer_list_row'} - {format_date date=$LASTORDER_DATE} + {$lastOrderDate} - {format_number number=$LASTORDER_AMOUNT} + {$lastOrderCurrency} {$lastOrderAmount}
diff --git a/templates/admin/default/order-edit.html b/templates/admin/default/order-edit.html index 793414afb..7e27370e5 100644 --- a/templates/admin/default/order-edit.html +++ b/templates/admin/default/order-edit.html @@ -11,331 +11,340 @@
- - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- {intl l='Information about order 01201303540354'} -
{intl l="Designation"}{intl l="Price"}{intl l="Quantity"}{intl l="Total"}
T-Shirt F T120.00 €360.00 €
T-Shirt F T120.00 €360.00 €
T-Shirt F T120.00 €360.00 €
Total180.00 €
-
-
+ {ifloop rel='the-order'} -
-
- - - - - - - - - - + {loop type="order" name="the-order" id=$order_id customer="*"} - - - - - - - - -
- {intl l='Information about the bill'} -
{intl l="Bill n°"}{intl l="Compagny"}{intl l="Firstname & Lastname"}{intl l="Date & Hour"}
0001TheliaDupont Jean11/01/2013 14:11:00
-
-
+ {loop type="currency" name="order-currency" id=$CURRENCY} + {assign "orderCurrency" $SYMBOL} + {/loop} -
-

- {intl l='Information about the carriage'} - - {intl l='Download pdf bill'} - -

+ -
-
{intl l="Mode of transportation"}
-
Colissimo
-
-
-
{intl l="Description"}
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ut, error, necessitatibus ipsam dolores ad quisquam provident sed repudiandae ullam quasi quae perferendis numquam voluptates doloribus laborum possimus dicta similique in?
-
-
+
+
+
+ + + + + + + + + + -
-
-
+ {intl l='Cart'} +
{intl l="Product"}{intl l="Price"}{intl l="Quantity"}{intl l="Total"}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- {intl l='Information about the settlement'} -
{intl l="Type of payment"}Unknown
{intl l="Transaction reference"}141100
{intl l="Total order before discount"}60 €
{intl l="Discount"}10%
{intl l="Coupon code"}
{intl l="Total with discount"}50 €
{intl l="Freight"}6 €
{intl l="Total"}56 €
-
-
+ + + T-Shirt F T1 + 20.00 € + 3 + 60.00 € + + + T-Shirt F T1 + 20.00 € + 3 + 60.00 € + + + T-Shirt F T1 + 20.00 € + 3 + 60.00 € + + + + + Total + 180.00 € + + + +
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- {intl l='Billing address'} - - - -
{intl l="Title"}Mr
{intl l="Compagny"}Thelia
{intl l="Firstname"}Espeche
{intl l="Lastname"}Michaël
{intl l="Street address"}5, rue Rochon
{intl l="Additional address"}Lorem ipsum dolor sit amet
{intl l="Additional address"}Lorem ipsum dolor sit
{intl l="Zip code"}63000
{intl l="City"}Clermont-Fd
{intl l="Country"}France
{intl l="Phone"}01 02 03 04 05
-
-
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {intl l='Payment information'} +
{intl l="Payment module"}{loop name="payment-module" type="module" id=$PAYMENT_MODULE}{$TITLE}{/loop}
{intl l="Transaction reference"}{$TRANSACTION_REF}
{intl l="Total without discount"}@TODO
{intl l="Discount"}@TODO
{intl l="Coupon code"}@TODO
{intl l="Total including discount"}{$orderCurrency} {$TOTAL_TAXED_AMOUNT-$POSTAGE}
{intl l="Postage"}{$orderCurrency} {$POSTAGE}
{intl l="Total"}{$orderCurrency} {$TOTAL_TAXED_AMOUNT}
+
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- {intl l='Delivery address'} - - - -
{intl l="Title"}Mr
{intl l="Compagny"}Thelia
{intl l="Firstname"}Espeche
{intl l="Lastname"}Michaël
{intl l="Street address"}5, rue Rochon
{intl l="Additional address"}Lorem ipsum dolor sit amet
{intl l="Additional address"}Lorem ipsum dolor sit
{intl l="Zip code"}63000
{intl l="City"}Clermont-Fd
{intl l="Country"}France
{intl l="Phone"}01 02 03 04 05
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
- {intl l='Further information'} -
-
-
-
- -
-
-
-
-
-
-
- -
- -
-
-
{intl l='Bill'} {intl l='Download bill to pdf'}
{intl l='Delivery'} {intl l='Download delivery to pdf'}
-
-
+
-
+
+ +

+ {intl l='Delivery module'} +

+ + {loop name="payment-module" type="module" id=$DELIVERY_MODULE} + +
+
{intl l="Name"}
+
{$TITLE}
+
+
+
{intl l="Description"}
+
{$DESCRIPTION}
+
+ + {/loop} + +
+
+ + + + + + + + + + + + + {loop type="order_address" name="order-invoice-address" id=$INVOICE_ADDRESS} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/loop} + +
+ {intl l='Invoice informations'} + +
{intl l="Invoice reference"}{$INVOICE_REF}
{intl l="Invoice date"}{format_date date=$INVOICE_DATE output="date"}
{intl l="Title"}{loop type="title" name="order-invoice-address-title" id=$TITLE}{$LONG}{/loop}
{intl l="Compagny"}{$COMPANY}
{intl l="Firstname"}{$FIRSTNAME}
{intl l="Lastname"}{$LASTNAME}
{intl l="Street address"}{$ADDRESS1}
{intl l="Additional address"}{$ADDRESS2}
{intl l="Additional address"}{$ADDRESS3}
{intl l="Zip code"}{$ZIPCODE}
{intl l="City"}{$CITY}
{intl l="Country"}{loop type="country" name="order-invoice-address-country" id=$COUNTRY}{$TITLE}{/loop}
{intl l="Phone"}{$PHONE}
+
+
+ +
+
+ + + + {loop type="order_address" name="order-delivery-address" id=$DELIVERY_ADDRESS} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/loop} + +
+ {intl l='Delivery address'} + +
{intl l="Title"}{loop type="title" name="order-delivery-address-title" id=$TITLE}{$LONG}{/loop}
{intl l="Compagny"}{$COMPANY}
{intl l="Firstname"}{$FIRSTNAME}
{intl l="Lastname"}{$LASTNAME}
{intl l="Street address"}{$ADDRESS1}
{intl l="Additional address"}{$ADDRESS2}
{intl l="Additional address"}{$ADDRESS3}
{intl l="Zip code"}{$ZIPCODE}
{intl l="City"}{$CITY}
{intl l="Country"}{loop type="country" name="order-delivery-address-country" id=$COUNTRY}{$TITLE}{/loop}
{intl l="Phone"}{$PHONE}
+
+
+ + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ {intl l='Further information'} +
+
+
+
+ +
+
+
+
+
+
+
+ +
+ +
+
+
{intl l='Bill'} {intl l='Download bill to pdf'}
{intl l='Delivery'} {intl l='Download delivery to pdf'}
+
+
+ +
+ {/loop} + + {/ifloop} + {elseloop rel="the-order"} + + DOES NOT EXISTS + + {/elseloop}
diff --git a/templates/admin/default/orders.html b/templates/admin/default/orders.html index 2cb8517ea..c0b420275 100644 --- a/templates/admin/default/orders.html +++ b/templates/admin/default/orders.html @@ -45,22 +45,47 @@ + {loop type="order" name="order-list" customer="*"} - {loop type="customer" name="order-customer"} + {loop type="order_address" name="order-invoice-address" id=$INVOICE_ADDRESS} + {assign "orderInvoiceFirstName" $FIRSTNAME} + {assign "orderInvoiceLastName" $LASTNAME} + {assign "orderInvoiceCompany" $COMPANY} {/loop} - {loop type="order_address" name="order-invoice-address"} + {loop type="order-status" name="order-status" id=$STATUS} + {assign "orderStatus" $TITLE} + {if $CODE == 'not_paid'} + {assign "orderStatusLabel" "warning"} + {else} + {if $CODE == 'paid'} + {assign "orderStatusLabel" "success"} + {else} + {if $CODE == 'processing'} + {assign "orderStatusLabel" "Primary"} + {else} + {if $CODE == 'sent'} + {assign "orderStatusLabel" "info"} + {else} + {if $CODE == 'canceled'} + {assign "orderStatusLabel" "danger"} + {else} + {/if} + {/if} + {/if} + {/if} + {/if} {/loop} - {$REF} + 01230450123045 {format_date date=$CREATE_DATE} - Thelia - Dupont - 251 € - Paid + {$orderInvoiceCompany} + {$orderInvoiceFirstName|ucwords} {$orderInvoiceLastName|upper} + {$TOTAL_TAXED_AMOUNT} + {$orderStatus} {module_include location='orders_table_row'}