From acaa4a969e329eea4bb0a1847a43b57a15a7a0eb Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 17 Sep 2013 16:38:16 +0200 Subject: [PATCH 001/113] empty cart or delivery exception --- .../lib/Thelia/Config/Resources/routing/front.xml | 4 ++-- .../Thelia/Controller/Front/OrderController.php | 4 ++-- .../Thelia/Core/EventListener/ViewListener.php | 15 +++++++++++++++ .../Core/HttpFoundation/Session/Session.php | 3 +++ core/lib/Thelia/Core/Routing/RewritingRouter.php | 2 +- .../Core/Template/Smarty/Plugins/Security.php | 13 ++++++++++++- core/lib/Thelia/Exception/OrderException.php | 15 ++++++++++++++- templates/default/order_invoice.html | 14 ++++++++++---- 8 files changed, 59 insertions(+), 11 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index 7705c81cc..e702a1938 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -112,12 +112,12 @@ cart - + Thelia\Controller\Front\OrderController::deliver order_delivery - + Thelia\Controller\Front\DefaultController::noAction order_delivery diff --git a/core/lib/Thelia/Controller/Front/OrderController.php b/core/lib/Thelia/Controller/Front/OrderController.php index f34715894..393f71ebd 100755 --- a/core/lib/Thelia/Controller/Front/OrderController.php +++ b/core/lib/Thelia/Controller/Front/OrderController.php @@ -69,9 +69,9 @@ class OrderController extends BaseFrontController /* check that the delivery module fetch the delivery address area */ if(AreaDeliveryModuleQuery::create() ->filterByAreaId($deliveryAddress->getCountry()->getAreaId()) - ->filterByDeliveryModuleId() + ->filterByDeliveryModuleId($deliveryModuleId) ->count() == 0) { - throw new \Exception("PUKE"); + throw new \Exception("Delivery module cannot be use with selected delivery address"); } diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php index c723c2112..9de281dbe 100755 --- a/core/lib/Thelia/Core/EventListener/ViewListener.php +++ b/core/lib/Thelia/Core/EventListener/ViewListener.php @@ -28,8 +28,10 @@ use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Router; use Thelia\Core\Template\Exception\ResourceNotFoundException; use Thelia\Core\Template\ParserInterface; +use Thelia\Exception\OrderException; use Thelia\Tools\Redirect; use Thelia\Tools\URL; use Thelia\Core\Security\Exception\AuthenticationException; @@ -87,6 +89,19 @@ class ViewListener implements EventSubscriberInterface // Redirect to the login template Redirect::exec($this->container->get('thelia.url.manager')->viewUrl($ex->getLoginTemplate())); + } catch (OrderException $e) { + switch($e->getCode()) { + case OrderException::CART_EMPTY: + // Redirect to the cart template + Redirect::exec($this->container->get('router.chainRequest')->generate($e->cartRoute, $e->arguments, Router::ABSOLUTE_URL)); + break; + case OrderException::UNDEFINED_DELIVERY: + // Redirect to the delivery choice template + Redirect::exec($this->container->get('router.chainRequest')->generate($e->orderDeliveryRoute, $e->arguments, Router::ABSOLUTE_URL)); + break; + } + + throw $e; } } diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index 5edd007b3..8a0952ff4 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -218,6 +218,9 @@ class Session extends BaseSession return $this; } + /** + * @return Order + */ public function getOrder() { return $this->get("thelia.order"); diff --git a/core/lib/Thelia/Core/Routing/RewritingRouter.php b/core/lib/Thelia/Core/Routing/RewritingRouter.php index 2b663a979..9b736a614 100644 --- a/core/lib/Thelia/Core/Routing/RewritingRouter.php +++ b/core/lib/Thelia/Core/Routing/RewritingRouter.php @@ -128,7 +128,7 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface */ public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) { - // TODO: Implement generate() method. + throw new RouteNotFoundException(); } /** diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php index 71b9c3f81..abe84a292 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php @@ -78,7 +78,17 @@ class Security extends AbstractSmartyPlugin { $cart = $this->request->getSession()->getCart(); if($cart===null || $cart->countCartItems() == 0) { - throw new OrderException('Cart must not be empty', OrderException::CART_EMPTY); + throw new OrderException('Cart must not be empty', OrderException::CART_EMPTY, array('empty' => 1)); + } + + return ""; + } + + public function checkValidDeliveryFunction($params, &$smarty) + { + $order = $this->request->getSession()->getOrder(); + if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId()) { + throw new OrderException('Delivery must be defined', OrderException::UNDEFINED_DELIVERY, array('missing' => 1)); } return ""; @@ -94,6 +104,7 @@ class Security extends AbstractSmartyPlugin return array( new SmartyPluginDescriptor('function', 'check_auth', $this, 'checkAuthFunction'), new SmartyPluginDescriptor('function', 'check_cart_not_empty', $this, 'checkCartNotEmptyFunction'), + new SmartyPluginDescriptor('function', 'check_valid_delivery', $this, 'checkValidDeliveryFunction'), ); } } diff --git a/core/lib/Thelia/Exception/OrderException.php b/core/lib/Thelia/Exception/OrderException.php index d276f8b59..70fd21c01 100755 --- a/core/lib/Thelia/Exception/OrderException.php +++ b/core/lib/Thelia/Exception/OrderException.php @@ -25,12 +25,25 @@ namespace Thelia\Exception; class OrderException extends \RuntimeException { + /** + * @var string The cart template name + */ + public $cartRoute = "cart.view"; + public $orderDeliveryRoute = "order.delivery"; + + public $arguments = array(); + const UNKNOWN_EXCEPTION = 0; const CART_EMPTY = 100; - public function __construct($message, $code = null, $previous = null) + const UNDEFINED_DELIVERY = 200; + + public function __construct($message, $code = null, $arguments = array(), $previous = null) { + if(is_array($arguments)) { + $this->arguments = $arguments; + } if ($code === null) { $code = self::UNKNOWN_EXCEPTION; } diff --git a/templates/default/order_invoice.html b/templates/default/order_invoice.html index f1a6e4205..ba9b7b677 100644 --- a/templates/default/order_invoice.html +++ b/templates/default/order_invoice.html @@ -1,5 +1,11 @@ {extends file="layout.tpl"} +{block name="no-return-functions"} + {check_auth context="front" roles="CUSTOMER" login_tpl="login"} + {check_cart_not_empty} + {check_valid_delivery} +{/block} + {block name="breadcrumb"} - - + {include file="includes/menu.html"}

Find a product

@@ -135,13 +49,21 @@
Type
-
-
+
+ +
+
+
-
@@ -150,13 +72,21 @@
Price
- $value) { ?>
-
+
+ +
+
+
-
@@ -165,13 +95,21 @@
Size
- $value) { ?>
-
+
+ +
+
+
-
diff --git a/templates/default/includes/menu.html b/templates/default/includes/menu.html new file mode 100644 index 000000000..083c74ef2 --- /dev/null +++ b/templates/default/includes/menu.html @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/templates/default/includes/single-product.html b/templates/default/includes/single-product.html new file mode 100644 index 000000000..40b9d326b --- /dev/null +++ b/templates/default/includes/single-product.html @@ -0,0 +1,60 @@ +
+ + {loop name="brand.feature" type="feature" product=$ID title="brand"} + {loop name="brand.value" type="feature_value" feature=$ID product=$product_id} + + {/loop} + {/loop} + {loop name="brand.feature" type="feature" product=$ID title="isbn"} + {loop name="brand.value" type="feature_value" feature=$ID product=$product_id} + + {/loop} + {/loop} + + + +
+

{$TITLE}

+ +
+

{$DESCRIPTION}

+
+
+ +
+
+ + + + + + {if $IS_PROMO } + {loop name="productSaleElements_promo" type="product_sale_elements" product=$ID limit="1" order="min_price"} + {assign var="default_product_sale_elements" value=$ID} + {intl l="Special Price:"} {format_number number=$TAXED_PROMO_PRICE} {currency attr="symbol"} + {intl l="Regular Price:"} {format_number number=$TAXED_PRICE} {currency attr="symbol"} + {/loop} + {else} + {format_number number=$BEST_TAXED_PRICE} {currency attr="symbol"} + {/if} + +
+
+ +
+
+
\ No newline at end of file diff --git a/templates/default/index.html b/templates/default/index.html index ca6fbbf7c..674892ce9 100644 --- a/templates/default/index.html +++ b/templates/default/index.html @@ -80,8 +80,7 @@ preorder : http://schema.org/PreOrder online_only : http://schema.org/OnlineOnly --> - {currency attr="symbol"} {format_number number="{$BEST_TAXED_PRICE}"} - + {format_number number="{$BEST_TAXED_PRICE}"} {currency attr="symbol"} From 16de9bbcc92930779503a9a8c18e4439e2fc37f6 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 20 Sep 2013 09:19:12 +0200 Subject: [PATCH 091/113] allow displaying how much product wanted in category page --- .../Template/Smarty/Plugins/UrlGenerator.php | 3 ++- templates/default/assets/js/script.js | 27 +++---------------- templates/default/category.html | 6 ++--- .../default/includes/category-toolbar.html | 14 +++++----- 4 files changed, 15 insertions(+), 35 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php index aa96a0014..f1249697a 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php @@ -186,7 +186,8 @@ class UrlGenerator extends AbstractSmartyPlugin protected function getCurrentUrl() { - return URL::getInstance()->retrieveCurrent($this->request)->toString(); + //return URL::getInstance()->retrieveCurrent($this->request)->toString(); + return $this->request->getUri(); } protected function getReturnToUrl() diff --git a/templates/default/assets/js/script.js b/templates/default/assets/js/script.js index 18581ed1e..2bbba577f 100644 --- a/templates/default/assets/js/script.js +++ b/templates/default/assets/js/script.js @@ -126,31 +126,10 @@ }).filter(':has(:checked)').addClass('active'); }); + $('#limit-top').change(function(e){ + window.location = $(this).val() + }); - // Styliser le message Confirm par Bootstrap sur un formulaire - /* - $('body').on('click', '[data-confirm]', function(){ - var $this = $(this); - bootbox.confirm($(this).attr('data-confirm'), - function(result){ - if(result) { - // Si lien - if($this.attr('href')){ - window.location.href = $this.attr('href'); - }else{ - // Si on doit soumettre un formulaire - var $form = $this.closest("form"); - if($form.size() > 0){ - $form.submit(); - } - } - } - } - ); - - return false; - }); - */ }); })(jQuery); diff --git a/templates/default/category.html b/templates/default/category.html index aa6f95c08..5c1516f45 100644 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -20,13 +20,13 @@ {block name="main-content"}
- + {$limit={$smarty.get.limit|default:8}}
- {include file="includes/category-toolbar.html" toolbar="top"} + {include file="includes/category-toolbar.html" toolbar="top" limit=$limit}
    - {loop type="product" name="product_list" category={category attr="id"}} + {loop type="product" name="product_list" category={category attr="id"} limit=$limit}
  • {include file="includes/single-product.html" product_id=$ID} diff --git a/templates/default/includes/category-toolbar.html b/templates/default/includes/category-toolbar.html index 98ce01434..8268d6393 100644 --- a/templates/default/includes/category-toolbar.html +++ b/templates/default/includes/category-toolbar.html @@ -5,11 +5,11 @@ per page @@ -30,8 +30,8 @@ {intl l="View as"}: - - + + From 5abae4db7dd117d37b35634d6511bb06b352f8dd Mon Sep 17 00:00:00 2001 From: mespeche Date: Fri, 20 Sep 2013 09:35:56 +0200 Subject: [PATCH 092/113] Setting profile update --- core/lib/Thelia/Config/Resources/config.xml | 2 + .../Thelia/Form/ProfileModificationForm.php | 91 +++++++++++++++++++ templates/admin/default/profile-edit.html | 80 ++++++++++++++++ 3 files changed, 173 insertions(+) create mode 100644 core/lib/Thelia/Form/ProfileModificationForm.php diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 43e48f6e4..8f5a78b59 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -102,6 +102,8 @@
    + + diff --git a/core/lib/Thelia/Form/ProfileModificationForm.php b/core/lib/Thelia/Form/ProfileModificationForm.php new file mode 100644 index 000000000..94ce1fba9 --- /dev/null +++ b/core/lib/Thelia/Form/ProfileModificationForm.php @@ -0,0 +1,91 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Thelia\Core\Translation\Translator; +use Thelia\Model\ConfigQuery; + +/** + * Class ProfileModification + * @package Thelia\Form + * @author Manuel Raynaud + */ +class ProfileModificationForm extends BaseForm +{ + + + protected function buildForm() + { + + $this->formBuilder + ->add("firstname", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("First Name"), + "label_attr" => array( + "for" => "firstname" + ) + )) + ->add("lastname", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Last Name"), + "label_attr" => array( + "for" => "lastname" + ) + )) + ->add("password", "password", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) + ), + "label" => Translator::getInstance()->trans("Password"), + "label_attr" => array( + "for" => "password" + ) + )) + ->add("password_confirm", "password", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))), + new Constraints\Callback(array("methods" => array( + array($this, "verifyPasswordField") + ))) + ), + "label" => "Password confirmation", + "label_attr" => array( + "for" => "password_confirmation" + ) + )) + ; + } + + public function getName() + { + return "thelia_profile_modification"; + } +} diff --git a/templates/admin/default/profile-edit.html b/templates/admin/default/profile-edit.html index e69de29bb..19b6c4c2d 100644 --- a/templates/admin/default/profile-edit.html +++ b/templates/admin/default/profile-edit.html @@ -0,0 +1,80 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Edit profile'}{/block} + +{block name="check-permissions"}admin.profile.edit{/block} + +{block name="main-content"} +
    + +
    + + + +
    +
    + +
    + {intl l="Edit profile $NAME"} +
    + +
    + {form name="thelia.admin.profile.modification"} + + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {if $form_error}
    {$form_error_message}
    {/if} + + {form_field form=$form field='firstname'} +
    + + +
    + {/form_field} + + {form_field form=$form field='lastname'} +
    + + +
    + {/form_field} + + {form_field form=$form field='password'} +
    + + +
    + {/form_field} + + {form_field form=$form field='password_confirm'} +
    + + +
    + {/form_field} + +
    + +
    + + {/form} +
    + +
    + +
    + +
    +
    +{/block} \ No newline at end of file From f7d2c09c6d883a60ccc3e281e0adb611141c375e Mon Sep 17 00:00:00 2001 From: franck Date: Fri, 20 Sep 2013 09:38:48 +0200 Subject: [PATCH 093/113] Added producr attributes routes --- core/lib/Thelia/Config/Resources/config.xml | 2 +- core/lib/Thelia/Config/Resources/routing/admin.xml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 43e48f6e4..495cf2ac3 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -18,7 +18,7 @@ - + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 284103798..5c07d48c2 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -178,6 +178,12 @@ Thelia\Controller\Admin\ProductController::updateAccessoryPositionAction + + + + Thelia\Controller\Admin\ProductController::updateAttributesAndFeaturesAction + + From cb5f6d4c7027bfe9bc9382e584671c9428587318 Mon Sep 17 00:00:00 2001 From: franck Date: Fri, 20 Sep 2013 09:57:30 +0200 Subject: [PATCH 094/113] Fixed translations --- templates/admin/default/home.html | 156 +++++++++++++++--------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/templates/admin/default/home.html b/templates/admin/default/home.html index ea1bd3392..3371a1d9f 100755 --- a/templates/admin/default/home.html +++ b/templates/admin/default/home.html @@ -21,8 +21,8 @@
    - - + + @@ -34,7 +34,7 @@
    -
    +
    @@ -47,7 +47,7 @@
    -
    {intl l="Informations site"}
    +
    {intl l="Shop Informations"}
    @@ -56,7 +56,7 @@ - + @@ -64,11 +64,11 @@ - + - + @@ -76,11 +76,11 @@ - + - + @@ -112,32 +112,32 @@
    1
    {intl l="Sections"}{intl l="Categories"} 8
    43
    {intl l="Products online"}{intl l="Online products"} 43
    {intl l="Products offline"}{intl l="Offline products"} 0
    1
    {intl l="Orders pending"}{intl l="Pending orders"} 1
    {intl l="Orders treatment"}{intl l="In process orderst"} 0
    - - - - + + + + + + + + - - - - - + - + - + - + - + @@ -148,34 +148,34 @@
    {intl l="C. A. TTC"}2000.00 €
    {intl l="Overall sales"}2500.00 €
    {intl l="Sales excluding shipping"}2000.00 €
    {intl l="C. A. TTC hors frais de port"}2500.00 €
    {intl l="C. A. TTC précédent"}{intl l="Yesterday sales"} 1700.00 €
    {intl l="Commandes en instance"}{intl l="Waiting orders"} 4
    {intl l="Commandes en traitement"}{intl l="In process orders"} 52
    {intl l="Commandes annulées"}{intl l="Canceled orders"} 3
    {intl l="Panier moyen TTC"}{intl l="Average cart"} 25.00 €
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {intl l="C. A. TTC"}2000.00 €
    {intl l="C. A. TTC hors frais de port"}2500.00 €
    {intl l="C. A. TTC précédent"}1700.00 €
    {intl l="Commandes en instance"}4
    {intl l="Commandes en traitement"}52
    {intl l="Commandes annulées"}3
    {intl l="Panier moyen TTC"}25.00 €
    {intl l="Overall sales"}2500.00 €
    {intl l="Sales excluding shipping"}2000.00 €
    {intl l="Previous month sales"}1700.00 €
    {intl l="Waiting orders"}4
    {intl l="In process orders"}52
    {intl l="Canceled orders"}3
    {intl l="Average cart"}25.00 €
    @@ -184,34 +184,34 @@
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {intl l="C. A. TTC"}2000.00 €
    {intl l="C. A. TTC hors frais de port"}2500.00 €
    {intl l="C. A. TTC précédent"}1700.00 €
    {intl l="Commandes en instance"}4
    {intl l="Commandes en traitement"}52
    {intl l="Commandes annulées"}3
    {intl l="Panier moyen TTC"}25.00 €
    {intl l="Overall sales"}2500.00 €
    {intl l="Sales excluding shipping"}2000.00 €
    {intl l="Previous year sales"}1700.00 €
    {intl l="Waiting orders"}4
    {intl l="In process orders"}52
    {intl l="Canceled orders"}3
    {intl l="Average cart"}25.00 €
    From b933a96c8eb7ca42db745ccadce2b48924e45278 Mon Sep 17 00:00:00 2001 From: mespeche Date: Fri, 20 Sep 2013 10:39:02 +0200 Subject: [PATCH 095/113] Vertical align middle tables --- .../default/assets/less/thelia/tables.less | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/templates/admin/default/assets/less/thelia/tables.less b/templates/admin/default/assets/less/thelia/tables.less index 8a4baa897..e542786ec 100755 --- a/templates/admin/default/assets/less/thelia/tables.less +++ b/templates/admin/default/assets/less/thelia/tables.less @@ -1,3 +1,22 @@ +// Baseline styles + +.table { + + // Cells + thead, + tbody, + tfoot { + > tr { + > th, + > td { + vertical-align: middle; + } + } + } + +} + + tfoot{ .pagination{ From 265da6a57ebbeda60c579c81a612ac331f5bb329 Mon Sep 17 00:00:00 2001 From: mespeche Date: Fri, 20 Sep 2013 12:00:39 +0200 Subject: [PATCH 096/113] Add default language & editing language default field --- .../Thelia/Form/ProfileModificationForm.php | 28 +++++++++ templates/admin/default/profile-edit.html | 62 ++++++++++++++++--- 2 files changed, 82 insertions(+), 8 deletions(-) diff --git a/core/lib/Thelia/Form/ProfileModificationForm.php b/core/lib/Thelia/Form/ProfileModificationForm.php index 94ce1fba9..e3119cfee 100644 --- a/core/lib/Thelia/Form/ProfileModificationForm.php +++ b/core/lib/Thelia/Form/ProfileModificationForm.php @@ -58,6 +58,34 @@ class ProfileModificationForm extends BaseForm "for" => "lastname" ) )) + ->add("default_language", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Default language"), + "label_attr" => array( + "for" => "default_language" + ) + )) + ->add("editing_language_default", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans("Editing language default"), + "label_attr" => array( + "for" => "editing_language_default" + ) + )) + ->add("old_password", "password", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) + ), + "label" => Translator::getInstance()->trans("Old password"), + "label_attr" => array( + "for" => "old_password" + ) + )) ->add("password", "password", array( "constraints" => array( new Constraints\NotBlank(), diff --git a/templates/admin/default/profile-edit.html b/templates/admin/default/profile-edit.html index 19b6c4c2d..e882dc40d 100644 --- a/templates/admin/default/profile-edit.html +++ b/templates/admin/default/profile-edit.html @@ -47,20 +47,55 @@
    {/form_field} - {form_field form=$form field='password'} + {form_field form=$form field='default_language'}
    - -
    - {/form_field} - {form_field form=$form field='password_confirm'} -
    - - +
    {/form_field} + {form_field form=$form field='editing_language_default'} +
    + + + +
    + {/form_field} + +
    +
    {intl l="Change password"}
    + + {form_field form=$form field='old_password'} +
    + + +
    + {/form_field} + + {form_field form=$form field='password'} +
    + + +
    + {/form_field} + + {form_field form=$form field='password_confirm'} +
    + + +
    + {/form_field} +
    +
    +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-select/bootstrap-select.js'} + + {/javascripts} + {javascripts file='assets/js/main.js'} + + {/javascripts} + {/block} \ No newline at end of file From bb40086e2ae1b4d85d68bfba6ecec5996ce8a066 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 20 Sep 2013 13:59:51 +0200 Subject: [PATCH 097/113] allow to order products on category page --- templates/default/assets/js/script.js | 4 + templates/default/category.html | 89 ++----------------- .../default/includes/categories-filters.html | 77 ++++++++++++++++ .../default/includes/category-toolbar.html | 63 ++++++++----- .../default/includes/single-product.html | 13 ++- templates/default/index.html | 57 +----------- 6 files changed, 136 insertions(+), 167 deletions(-) create mode 100644 templates/default/includes/categories-filters.html diff --git a/templates/default/assets/js/script.js b/templates/default/assets/js/script.js index 2bbba577f..d115d2c5d 100644 --- a/templates/default/assets/js/script.js +++ b/templates/default/assets/js/script.js @@ -130,6 +130,10 @@ window.location = $(this).val() }); + $('#sortby-top').change(function(e){ + window.location = $(this).val() + }); + }); })(jQuery); diff --git a/templates/default/category.html b/templates/default/category.html index 5c1516f45..99db32948 100644 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -21,16 +21,15 @@ {block name="main-content"}
    {$limit={$smarty.get.limit|default:8}} + {$product_page={$smarty.get.page|default:1}} + {$product_order={$smarty.get.order|default:'alpha'}}
    - {include file="includes/category-toolbar.html" toolbar="top" limit=$limit} + {include file="includes/category-toolbar.html" toolbar="top" limit=$limit order=$product_order}
      - {loop type="product" name="product_list" category={category attr="id"} limit=$limit} - -
    • - {include file="includes/single-product.html" product_id=$ID} -
    • + {loop type="product" name="product_list" category={category attr="id"} limit=$limit page=$product_page order=$product_order} + {include file="includes/single-product.html" product_id=$ID hasBtn=true hasDescription=true width="218" height="146"} {/loop}
    @@ -42,83 +41,7 @@ {include file="includes/menu.html"} -
    -

    Find a product

    -
    -
    -
    - Type -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    - -
    -
    - Price -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    - -
    -
    - Size -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    - -
    - -
    -
    -
    + {include file="includes/categories-filters.html"} diff --git a/templates/default/includes/categories-filters.html b/templates/default/includes/categories-filters.html new file mode 100644 index 000000000..6a9425a66 --- /dev/null +++ b/templates/default/includes/categories-filters.html @@ -0,0 +1,77 @@ +
    +

    Find a product

    +
    +
    +
    + Type +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    + Price +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    + Size +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    \ No newline at end of file diff --git a/templates/default/includes/category-toolbar.html b/templates/default/includes/category-toolbar.html index 8268d6393..99583a02d 100644 --- a/templates/default/includes/category-toolbar.html +++ b/templates/default/includes/category-toolbar.html @@ -1,30 +1,30 @@ -
    \ No newline at end of file +
+ \ No newline at end of file diff --git a/templates/default/index.html b/templates/default/index.html index 674892ce9..390f06965 100644 --- a/templates/default/index.html +++ b/templates/default/index.html @@ -100,62 +100,7 @@
    {loop name="product_promo" type="product" limit="5" promo="yes"} -
  • -
    - - {$product_id=$ID} - {loop name="brand.feature" type="feature" product="{$ID}" title="brand"} - {loop name="brand.value" type="feature_value" feature="{$ID}" product="$product_id"} - - {/loop} - {/loop} - {loop name="brand.feature" type="feature" product=$ID title="isbn"} - {loop name="brand.value" type="feature_value" feature=$ID product=$product_id} - - {/loop} - {/loop} - - - -
    -

    {$CHAPO}

    -
    - -
    -
    - {loop type="category" name="category_tag" id=$DEFAULT_CATEGORY} - - {/loop} - - - - - {loop name="productSaleElements_promo" type="product_sale_elements" product="{$ID}" limit="1"} - {intl l="Special Price:"} {format_number number="{$TAXED_PROMO_PRICE}"} {currency attr="symbol"} - {intl l="Regular Price:"} {format_number number="{$TAXED_PRICE}"} {currency attr="symbol"} - {/loop} -
    -
    -
    -
  • + {include file="includes/single-product.html" product_id=$ID hasBtn=false hasDescription=false width="218" height="146"} {/loop}
From 1649e4d76b5e120e80ad90579c46d4381375c5c2 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 20 Sep 2013 14:26:36 +0200 Subject: [PATCH 098/113] fix query in Thelia\Model\Folder::countAllContents --- core/lib/Thelia/Model/Folder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Model/Folder.php b/core/lib/Thelia/Model/Folder.php index 8cbe00ce0..128c5932a 100755 --- a/core/lib/Thelia/Model/Folder.php +++ b/core/lib/Thelia/Model/Folder.php @@ -44,8 +44,8 @@ class Folder extends BaseFolder foreach($children as $child) { - $contentsCount += ProductQuery::create() - ->filterByCategory($child) + $contentsCount += ContentQuery::create() + ->filterByFolder($child) ->count(); } From 2cf71f99a90c3dae389fd486fcdf997f49f9749a Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 20 Sep 2013 14:38:11 +0200 Subject: [PATCH 099/113] change some informations in layou --- templates/default/layout.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/default/layout.tpl b/templates/default/layout.tpl index 7834bc706..37cbad224 100644 --- a/templates/default/layout.tpl +++ b/templates/default/layout.tpl @@ -314,10 +314,10 @@ URL: http://www.thelia.net
  • - +33 09 08 07 06 05 + +33 04 44 05 31 00
  • - +
  • From 854149930259ab6fcea3d253f03152233d8f5a33 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 20 Sep 2013 16:25:46 +0200 Subject: [PATCH 100/113] order process --- core/lib/Thelia/Action/Order.php | 89 ++++-------- core/lib/Thelia/Config/Resources/config.xml | 1 + .../Thelia/Config/Resources/routing/front.xml | 6 +- .../Controller/Front/OrderController.php | 33 +++++ core/lib/Thelia/Core/Event/OrderEvent.php | 17 +++ core/lib/Thelia/Core/Template/Loop/Cart.php | 10 +- core/lib/Thelia/Core/Template/Loop/Module.php | 137 ++++++++++++++++++ core/lib/Thelia/Core/Template/Loop/Order.php | 91 +++++++++++- core/lib/Thelia/Exception/OrderException.php | 3 - .../Thelia/Exception/TaxEngineException.php | 1 + .../Exception/TheliaProcessException.php | 54 +++++++ core/lib/Thelia/Model/Order.php | 26 +++- core/lib/Thelia/Model/OrderQuery.php | 39 ++++- core/lib/Thelia/Model/TaxRule.php | 20 ++- core/lib/Thelia/Model/TaxRuleQuery.php | 10 +- core/lib/Thelia/Module/BaseModule.php | 23 +++ core/lib/Thelia/TaxEngine/Calculator.php | 54 ++++++- .../TaxEngine/OrderProductTaxCollection.php | 126 ++++++++++++++++ .../Thelia/Tests/TaxEngine/CalculatorTest.php | 2 +- core/lib/Thelia/Tools/I18n.php | 37 +++++ install/insert.sql | 4 +- local/modules/Cheque/Cheque.php | 9 ++ local/modules/FakeCB/FakeCB.php | 9 ++ .../{order_payment.html => order_placed.html} | 12 +- 24 files changed, 718 insertions(+), 95 deletions(-) create mode 100755 core/lib/Thelia/Core/Template/Loop/Module.php create mode 100755 core/lib/Thelia/Exception/TheliaProcessException.php create mode 100755 core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php rename templates/default/{order_payment.html => order_placed.html} (85%) diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index 17d8327c0..3b1ceb5da 100755 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -24,20 +24,14 @@ namespace Thelia\Action; use Propel\Runtime\ActiveQuery\ModelCriteria; -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\OrderEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Exception\OrderException; -use Thelia\Model\AttributeAvI18n; -use Thelia\Model\AttributeAvI18nQuery; -use Thelia\Model\AttributeI18n; -use Thelia\Model\AttributeI18nQuery; +use Thelia\Exception\TheliaProcessException; use Thelia\Model\AddressQuery; use Thelia\Model\OrderProductAttributeCombination; -use Thelia\Model\ProductI18nQuery; -use Thelia\Model\Lang; use Thelia\Model\ModuleQuery; use Thelia\Model\OrderProduct; use Thelia\Model\OrderStatus; @@ -45,7 +39,7 @@ use Thelia\Model\Map\OrderTableMap; use Thelia\Model\OrderAddress; use Thelia\Model\OrderStatusQuery; use Thelia\Model\ConfigQuery; -use Thelia\Model\ProductI18n; +use Thelia\Tools\I18n; /** * @@ -125,6 +119,7 @@ class Order extends BaseAction implements EventSubscriberInterface $currency = $this->getSession()->getCurrency(); $lang = $this->getSession()->getLang(); $deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress); + $taxCountry = $deliveryAddress->getCountry(); $invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress); $cart = $this->getSession()->getCart(); $cartItems = $cart->getCartItems(); @@ -182,23 +177,30 @@ class Order extends BaseAction implements EventSubscriberInterface foreach($cartItems as $cartItem) { $product = $cartItem->getProduct(); - /* get customer translation */ - $productI18n = $this->getI18n(ProductI18nQuery::create(), new ProductI18n(), $product->getId()); + /* get translation */ + $productI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Product', $product->getId()); $pse = $cartItem->getProductSaleElements(); /* check still in stock */ if($cartItem->getQuantity() > $pse->getQuantity()) { - $e = new OrderException("Not enough stock", OrderException::NOT_ENOUGH_STOCK); - $e->cartItem = $cartItem; - throw $e; + throw new TheliaProcessException("Not enough stock", TheliaProcessException::CART_ITEM_NOT_ENOUGH_STOCK, $cartItem); } /* decrease stock */ $pse->setQuantity( $pse->getQuantity() - $cartItem->getQuantity() ); - $pse->save(); + $pse->save($con); + + /* get tax */ + $taxRuleI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'TaxRule', $product->getTaxRuleId()); + + $taxDetail = $product->getTaxRule()->getTaxDetail( + $taxCountry, + $cartItem->getPromo() == 1 ? $cartItem->getPromoPrice() : $cartItem->getPrice(), + $this->getSession()->getLang()->getLocale() + ); $orderProduct = new OrderProduct(); $orderProduct @@ -215,14 +217,22 @@ class Order extends BaseAction implements EventSubscriberInterface ->setWasNew($pse->getNewness()) ->setWasInPromo($cartItem->getPromo()) ->setWeight($pse->getWeight()) + ->setTaxRuleTitle($taxRuleI18n->getTitle()) + ->setTaxRuleDescription($taxRuleI18n->getDescription()) ; $orderProduct->setDispatcher($this->getDispatcher()); - $orderProduct->save(); + $orderProduct->save($con); + + /* fulfill order_product_tax */ + foreach($taxDetail as $tax) { + $tax->setOrderProductId($orderProduct->getId()); + $tax->save($con); + } /* fulfill order_attribute_combination and decrease stock */ foreach($pse->getAttributeCombinations() as $attributeCombination) { - $attribute = $this->getI18n(AttributeI18nQuery::create(), new AttributeI18n(), $attributeCombination->getAttributeId()); - $attributeAv = $this->getI18n(AttributeAvI18nQuery::create(), new AttributeAvI18n(), $attributeCombination->getAttributeAvId()); + $attribute = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Attribute', $attributeCombination->getAttributeId()); + $attributeAv = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'AttributeAv', $attributeCombination->getAttributeAvId()); $orderAttributeCombination = new OrderProductAttributeCombination(); $orderAttributeCombination @@ -237,7 +247,7 @@ class Order extends BaseAction implements EventSubscriberInterface ->setAttributeAvPostscriptum($attributeAv->getPostscriptum()) ; - $orderAttributeCombination->save(); + $orderAttributeCombination->save($con); } } @@ -248,12 +258,13 @@ class Order extends BaseAction implements EventSubscriberInterface $this->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder)); /* clear session */ + /* but memorize placed order */ $sessionOrder = new \Thelia\Model\Order(); $event->setOrder($sessionOrder); + $event->setPlacedOrder($placedOrder); $this->getSession()->setOrder($sessionOrder); - /* empty cart */ - $this->getSession()->getCart()->clear(); + /* empty cart @todo */ /* call pay method */ $paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace()); @@ -349,42 +360,4 @@ class Order extends BaseAction implements EventSubscriberInterface return $request->getSession(); } - - /** - * @param ModelCriteria $query - * @param ActiveRecordInterface $object - * @param $id - * @param array $needed = array('Title') - * - * @return ProductI18n - */ - protected function getI18n(ModelCriteria $query, ActiveRecordInterface $object, $id, $needed = array('Title')) - { - $i18n = $query - ->filterById($id) - ->filterByLocale( - $this->getSession()->getLang()->getLocale() - )->findOne(); - /* or default translation */ - if(null === $i18n) { - $i18n = $query - ->filterById($id) - ->filterByLocale( - Lang::getDefaultLanguage()->getLocale() - )->findOne(); - } - if(null === $i18n) { // @todo something else ? - $i18n = $object; - foreach($needed as $need) { - $method = sprintf('get%s', $need); - if(method_exists($i18n, $method)) { - $i18n->$method('DEFAULT ' . strtoupper($need)); - } else { - // @todo throw sg ? - } - } - } - - return $i18n; - } } diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 43e48f6e4..329ed609d 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -21,6 +21,7 @@ + diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index f254a817e..5b26a6ed6 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -137,7 +137,11 @@ Thelia\Controller\Front\OrderController::pay - order_payment + + + + Thelia\Controller\Front\OrderController::orderPlaced + order_placed diff --git a/core/lib/Thelia/Controller/Front/OrderController.php b/core/lib/Thelia/Controller/Front/OrderController.php index 4dd678a82..1f2c716ae 100755 --- a/core/lib/Thelia/Controller/Front/OrderController.php +++ b/core/lib/Thelia/Controller/Front/OrderController.php @@ -23,6 +23,7 @@ namespace Thelia\Controller\Front; use Propel\Runtime\Exception\PropelException; +use Thelia\Exception\TheliaProcessException; use Thelia\Form\Exception\FormValidationException; use Thelia\Core\Event\OrderEvent; use Thelia\Core\Event\TheliaEvents; @@ -32,9 +33,11 @@ use Thelia\Form\OrderPayment; use Thelia\Log\Tlog; use Thelia\Model\AddressQuery; use Thelia\Model\AreaDeliveryModuleQuery; +use Thelia\Model\Base\OrderQuery; use Thelia\Model\CountryQuery; use Thelia\Model\ModuleQuery; use Thelia\Model\Order; +use Thelia\Tools\URL; /** * Class OrderController @@ -187,6 +190,36 @@ class OrderController extends BaseFrontController $orderEvent = $this->getOrderEvent(); $this->getDispatcher()->dispatch(TheliaEvents::ORDER_PAY, $orderEvent); + + $placedOrder = $orderEvent->getPlacedOrder(); + + if(null !== $placedOrder && null !== $placedOrder->getId()) { + /* order has been placed */ + $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId())))); + } else { + /* order has not been placed */ + $this->redirectToRoute("cart.view"); + } + } + + public function orderPlaced($order_id) + { + /* check if the placed order matched the customer */ + $placedOrder = OrderQuery::create()->findPk( + $this->getRequest()->attributes->get('order_id') + ); + + if(null === $placedOrder) { + throw new TheliaProcessException("No placed order", TheliaProcessException::NO_PLACED_ORDER, $placedOrder); + } + + $customer = $this->getSecurityContext()->getCustomerUser(); + + if(null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) { + throw new TheliaProcessException("Received placed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder); + } + + $this->getParserContext()->set("placed_order_id", $placedOrder->getId()); } protected function getOrderEvent() diff --git a/core/lib/Thelia/Core/Event/OrderEvent.php b/core/lib/Thelia/Core/Event/OrderEvent.php index a156b753f..7089141bb 100755 --- a/core/lib/Thelia/Core/Event/OrderEvent.php +++ b/core/lib/Thelia/Core/Event/OrderEvent.php @@ -28,6 +28,7 @@ use Thelia\Model\Order; class OrderEvent extends ActionEvent { protected $order = null; + protected $placedOrder = null; protected $invoiceAddress = null; protected $deliveryAddress = null; protected $deliveryModule = null; @@ -51,6 +52,14 @@ class OrderEvent extends ActionEvent $this->order = $order; } + /** + * @param Order $order + */ + public function setPlacedOrder(Order $order) + { + $this->placedOrder = $order; + } + /** * @param $address */ @@ -107,6 +116,14 @@ class OrderEvent extends ActionEvent return $this->order; } + /** + * @return null|Order + */ + public function getPlacedOrder() + { + return $this->placedOrder; + } + /** * @return null|int */ diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index 16c108135..5c08b2896 100755 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -81,6 +81,8 @@ class Cart extends BaseLoop return $result; } + $taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic; + foreach ($cartItems as $cartItem) { $product = $cartItem->getProduct(); $productSaleElement = $cartItem->getProductSaleElements(); @@ -97,12 +99,8 @@ class Cart extends BaseLoop ->set("STOCK", $productSaleElement->getQuantity()) ->set("PRICE", $cartItem->getPrice()) ->set("PROMO_PRICE", $cartItem->getPromoPrice()) - ->set("TAXED_PRICE", $cartItem->getTaxedPrice( - CountryQuery::create()->findOneById(64) // @TODO : make it magic - )) - ->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice( - CountryQuery::create()->findOneById(64) // @TODO : make it magic - )) + ->set("TAXED_PRICE", $cartItem->getTaxedPrice($taxCountry)) + ->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice($taxCountry)) ->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0); $result->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Module.php b/core/lib/Thelia/Core/Template/Loop/Module.php new file mode 100755 index 000000000..1c4f91b4d --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Module.php @@ -0,0 +1,137 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +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\ModuleQuery; + +use Thelia\Module\BaseModule; +use Thelia\Type; + +/** + * + * Module loop + * + * + * Class Module + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Module extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + new Argument( + 'module_type', + new Type\TypeCollection( + new Type\EnumListType(array( + BaseModule::CLASSIC_MODULE_TYPE, + BaseModule::DELIVERY_MODULE_TYPE, + BaseModule::PAYMENT_MODULE_TYPE, + )) + ) + ), + Argument::createIntListTypeArgument('exclude'), + Argument::createBooleanOrBothTypeArgument('active', Type\BooleanOrBothType::ANY) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = ModuleQuery::create(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $moduleType = $this->getModule_type(); + + if (null !== $moduleType) { + $search->filterByType($moduleType, Criteria::IN); + } + + $exclude = $this->getExclude(); + + if (!is_null($exclude)) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $active = $this->getActive(); + + if($active !== Type\BooleanOrBothType::ANY) { + $search->filterByActivate($active ? 1 : 0, Criteria::EQUAL); + } + + $search->orderByPosition(); + + /* perform search */ + $modules = $this->search($search, $pagination); + + $loopResult = new LoopResult($modules); + + foreach ($modules as $module) { + $loopResultRow = new LoopResultRow($loopResult, $module, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow->set("ID", $module->getId()) + ->set("IS_TRANSLATED",$module->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE",$locale) + ->set("TITLE",$module->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $module->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $module->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $module->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("CODE", $module->getCode()) + ->set("TYPE", $module->getType()) + ->set("ACTIVE", $module->getActivate()) + ->set("CLASS", $module->getFullNamespace()) + ->set("POSITION", $module->getPosition()); + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/Order.php b/core/lib/Thelia/Core/Template/Loop/Order.php index fd11d8d4c..41d49c4f8 100755 --- a/core/lib/Thelia/Core/Template/Loop/Order.php +++ b/core/lib/Thelia/Core/Template/Loop/Order.php @@ -23,12 +23,16 @@ 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\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; - +use Thelia\Model\OrderQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; /** * * @package Thelia\Core\Template\Loop @@ -37,19 +41,94 @@ use Thelia\Core\Template\Loop\Argument\Argument; */ class Order extends BaseLoop { + public $countable = true; + public $timestampable = true; + public $versionable = false; + public function getArgDefinitions() { - return new ArgumentCollection(); + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + new Argument( + 'customer', + new TypeCollection( + new Type\IntType(), + new Type\EnumType(array('current')) + ), + 'current' + ), + Argument::createIntListTypeArgument('status') + ); } /** + * @param $pagination * - * - * @return \Thelia\Core\Template\Element\LoopResult + * @return LoopResult */ public function exec(&$pagination) { - // TODO : a coder ! - return new LoopResult(); + $search = OrderQuery::create(); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $customer = $this->getCustomer(); + + 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); + } + + $status = $this->getStatus(); + + if (null !== $status) { + $search->filterByStatusId($status, Criteria::IN); + } + + $orders = $this->search($search, $pagination); + + $loopResult = new LoopResult($orders); + + foreach ($orders as $order) { + $tax = 0; + $amount = $order->getTotalAmount($tax); + $loopResultRow = new LoopResultRow($loopResult, $order, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow + ->set("ID", $order->getId()) + ->set("REF", $order->getRef()) + ->set("CUSTOMER", $order->getCustomerId()) + ->set("DELIVERY_ADDRESS", $order->getDeliveryOrderAddressId()) + ->set("INVOICE_ADDRESS", $order->getInvoiceOrderAddressId()) + ->set("INVOICE_DATE", $order->getInvoiceDate()) + ->set("CURRENCY", $order->getCurrencyId()) + ->set("CURRENCY_RATE", $order->getCurrencyRate()) + ->set("TRANSACTION_REF", $order->getTransactionRef()) + ->set("DELIVERY_REF", $order->getDeliveryRef()) + ->set("INVOICE_REF", $order->getInvoiceRef()) + ->set("POSTAGE", $order->getPostage()) + ->set("PAYMENT_MODULE", $order->getPaymentModuleId()) + ->set("DELIVERY_MODULE", $order->getDeliveryModuleId()) + ->set("STATUS", $order->getStatusId()) + ->set("LANG", $order->getLangId()) + ->set("POSTAGE", $order->getPostage()) + ->set("TOTAL_TAX", $tax) + ->set("TOTAL_AMOUNT", $amount - $tax) + ->set("TOTAL_TAXED_AMOUNT", $amount) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; } } diff --git a/core/lib/Thelia/Exception/OrderException.php b/core/lib/Thelia/Exception/OrderException.php index 68eb36474..70fd21c01 100755 --- a/core/lib/Thelia/Exception/OrderException.php +++ b/core/lib/Thelia/Exception/OrderException.php @@ -30,7 +30,6 @@ class OrderException extends \RuntimeException */ public $cartRoute = "cart.view"; public $orderDeliveryRoute = "order.delivery"; - public $cartItem = null; public $arguments = array(); @@ -40,8 +39,6 @@ class OrderException extends \RuntimeException const UNDEFINED_DELIVERY = 200; - const NOT_ENOUGH_STOCK = 300; - public function __construct($message, $code = null, $arguments = array(), $previous = null) { if(is_array($arguments)) { diff --git a/core/lib/Thelia/Exception/TaxEngineException.php b/core/lib/Thelia/Exception/TaxEngineException.php index 93f5b8237..86f8952b9 100755 --- a/core/lib/Thelia/Exception/TaxEngineException.php +++ b/core/lib/Thelia/Exception/TaxEngineException.php @@ -39,6 +39,7 @@ class TaxEngineException extends \RuntimeException const UNDEFINED_TAX_RULES_COLLECTION = 503; const UNDEFINED_REQUIREMENTS = 504; const UNDEFINED_REQUIREMENT_VALUE = 505; + const UNDEFINED_TAX_RULE = 506; const BAD_AMOUNT_FORMAT = 601; diff --git a/core/lib/Thelia/Exception/TheliaProcessException.php b/core/lib/Thelia/Exception/TheliaProcessException.php new file mode 100755 index 000000000..f61224dea --- /dev/null +++ b/core/lib/Thelia/Exception/TheliaProcessException.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Exception; + +/** + * these exception are non fatal exception, due to thelia process exception + * or customer random navigation + * + * they redirect the customer who trig them to a specific error page // @todo + * + * Class TheliaProcessException + * @package Thelia\Exception + */ +class TheliaProcessException extends \RuntimeException +{ + public $data = null; + + const UNKNOWN_EXCEPTION = 0; + + const CART_ITEM_NOT_ENOUGH_STOCK = 100; + const NO_PLACED_ORDER = 101; + const PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER = 102; + + public function __construct($message, $code = null, $data = null, $previous = null) + { + $this->data = $data; + + if ($code === null) { + $code = self::UNKNOWN_EXCEPTION; + } + parent::__construct($message, $code, $previous); + } +} diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index f730c8853..5249a1366 100755 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -2,11 +2,15 @@ namespace Thelia\Model; +use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Propel; use Thelia\Core\Event\OrderEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Order as BaseOrder; +use Thelia\Model\Base\OrderProductTaxQuery; +use Thelia\Model\Map\OrderProductTaxTableMap; +use Thelia\Model\OrderProductQuery; use Thelia\Model\Map\OrderTableMap; use \PDO; @@ -38,13 +42,27 @@ class Order extends BaseOrder /** * calculate the total amount * - * @TODO create body method + * @param int $tax * - * @return int + * @return int|string|Base\double */ - public function getTotalAmount() + public function getTotalAmount(&$tax = 0) { - return 2; + $amount = 0; + $tax = 0; + + /* browse all products */ + $orderProductIds = array(); + foreach($this->getOrderProducts() as $orderProduct) { + $taxAmount = OrderProductTaxQuery::create() + ->withColumn('SUM(' . OrderProductTaxTableMap::AMOUNT . ')', 'total_tax') + ->filterByOrderProductId($orderProduct->getId(), Criteria::EQUAL) + ->findOne(); + $amount += ($orderProduct->getWasInPromo() == 1 ? $orderProduct->getPromoPrice() : $orderProduct->getPrice()) * $orderProduct->getQuantity(); + $tax += round($taxAmount->getVirtualColumn('total_tax'), 2) * $orderProduct->getQuantity(); + } + + return $amount + $tax + $this->getPostage(); // @todo : manage discount } /** diff --git a/core/lib/Thelia/Model/OrderQuery.php b/core/lib/Thelia/Model/OrderQuery.php index 13cb1cbf1..8d5e4c085 100755 --- a/core/lib/Thelia/Model/OrderQuery.php +++ b/core/lib/Thelia/Model/OrderQuery.php @@ -2,8 +2,11 @@ namespace Thelia\Model; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Propel; use Thelia\Model\Base\OrderQuery as BaseOrderQuery; - +use \PDO; +use Thelia\Model\Map\OrderTableMap; /** * Skeleton subclass for performing query and update operations on the 'order' table. @@ -15,6 +18,38 @@ use Thelia\Model\Base\OrderQuery as BaseOrderQuery; * long as it does not already exist in the output directory. * */ -class OrderQuery extends BaseOrderQuery { +class OrderQuery extends BaseOrderQuery +{ + /** + * PROPEL SHOULD FIX IT + * + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return Order A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, REF, CUSTOMER_ID, INVOICE_ORDER_ADDRESS_ID, DELIVERY_ORDER_ADDRESS_ID, INVOICE_DATE, CURRENCY_ID, CURRENCY_RATE, TRANSACTION_REF, DELIVERY_REF, INVOICE_REF, POSTAGE, PAYMENT_MODULE_ID, DELIVERY_MODULE_ID, STATUS_ID, LANG_ID, CREATED_AT, UPDATED_AT FROM `order` WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (\Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new Order(); + $obj->hydrate($row); + OrderTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + return $obj; + } } // OrderQuery diff --git a/core/lib/Thelia/Model/TaxRule.php b/core/lib/Thelia/Model/TaxRule.php index 36f80a044..024fd8923 100755 --- a/core/lib/Thelia/Model/TaxRule.php +++ b/core/lib/Thelia/Model/TaxRule.php @@ -3,7 +3,25 @@ namespace Thelia\Model; use Thelia\Model\Base\TaxRule as BaseTaxRule; +use Thelia\TaxEngine\Calculator; +use Thelia\TaxEngine\OrderProductTaxCollection; -class TaxRule extends BaseTaxRule { +class TaxRule extends BaseTaxRule +{ + /** + * @param Country $country + * @param $untaxedAmount + * @param null $askedLocale + * + * @return OrderProductTaxCollection + */ + public function getTaxDetail(Country $country, $untaxedAmount, $askedLocale = null) + { + $taxCalculator = new Calculator(); + $taxCollection = new OrderProductTaxCollection(); + $taxCalculator->loadTaxRule($this, $country)->getTaxedPrice($untaxedAmount, $taxCollection, $askedLocale); + + return $taxCollection; + } } diff --git a/core/lib/Thelia/Model/TaxRuleQuery.php b/core/lib/Thelia/Model/TaxRuleQuery.php index d5ce47546..572500003 100755 --- a/core/lib/Thelia/Model/TaxRuleQuery.php +++ b/core/lib/Thelia/Model/TaxRuleQuery.php @@ -21,13 +21,19 @@ class TaxRuleQuery extends BaseTaxRuleQuery { const ALIAS_FOR_TAX_RULE_COUNTRY_POSITION = 'taxRuleCountryPosition'; - public function getTaxCalculatorCollection(Product $product, Country $country) + /** + * @param TaxRule $taxRule + * @param Country $country + * + * @return array|mixed|\Propel\Runtime\Collection\ObjectCollection + */ + public function getTaxCalculatorCollection(TaxRule $taxRule, Country $country) { $search = TaxQuery::create() ->filterByTaxRuleCountry( TaxRuleCountryQuery::create() ->filterByCountry($country, Criteria::EQUAL) - ->filterByTaxRuleId($product->getTaxRuleId()) + ->filterByTaxRuleId($taxRule->getId()) ->orderByPosition() ->find() ) diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index f559c1fd5..8efc76e6e 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -25,7 +25,9 @@ namespace Thelia\Module; use Symfony\Component\DependencyInjection\ContainerAware; +use Thelia\Model\ModuleI18nQuery; use Thelia\Model\Map\ModuleImageTableMap; +use Thelia\Model\ModuleI18n; use Thelia\Tools\Image; use Thelia\Exception\ModuleException; use Thelia\Model\Module; @@ -76,6 +78,27 @@ abstract class BaseModule extends ContainerAware return $this->container; } + public function setTitle(Module $module, $titles) + { + if(is_array($titles)) { + foreach($titles as $locale => $title) { + $moduleI18n = ModuleI18nQuery::create()->filterById($module->getId())->filterByLocale($locale)->findOne(); + if(null === $moduleI18n) { + $moduleI18n = new ModuleI18n(); + $moduleI18n + ->setId($module->getId()) + ->setLocale($locale) + ->setTitle($title) + ; + $moduleI18n->save(); + } else { + $moduleI18n->setTitle($title); + $moduleI18n->save(); + } + } + } + } + public function deployImageFolder(Module $module, $folderPath) { try { diff --git a/core/lib/Thelia/TaxEngine/Calculator.php b/core/lib/Thelia/TaxEngine/Calculator.php index b5a2f995e..8039dec39 100755 --- a/core/lib/Thelia/TaxEngine/Calculator.php +++ b/core/lib/Thelia/TaxEngine/Calculator.php @@ -24,8 +24,11 @@ namespace Thelia\TaxEngine; use Thelia\Exception\TaxEngineException; use Thelia\Model\Country; +use Thelia\Model\OrderProductTax; use Thelia\Model\Product; +use Thelia\Model\TaxRule; use Thelia\Model\TaxRuleQuery; +use Thelia\Tools\I18n; /** * Class Calculator @@ -68,14 +71,34 @@ class Calculator $this->product = $product; $this->country = $country; - $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product, $country); + $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product->getTaxRule(), $country); return $this; } - public function getTaxAmountFromUntaxedPrice($untaxedPrice) + public function loadTaxRule(TaxRule $taxRule, Country $country) { - return $this->getTaxedPrice($untaxedPrice) - $untaxedPrice; + $this->product = null; + $this->country = null; + $this->taxRulesCollection = null; + + if($taxRule->getId() === null) { + throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE); + } + if($country->getId() === null) { + throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY); + } + + $this->country = $country; + + $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country); + + return $this; + } + + public function getTaxAmountFromUntaxedPrice($untaxedPrice, &$taxCollection = null) + { + return $this->getTaxedPrice($untaxedPrice, $taxCollection) - $untaxedPrice; } public function getTaxAmountFromTaxedPrice($taxedPrice) @@ -83,7 +106,15 @@ class Calculator return $taxedPrice - $this->getUntaxedPrice($taxedPrice); } - public function getTaxedPrice($untaxedPrice) + /** + * @param $untaxedPrice + * @param null $taxCollection returns OrderProductTaxCollection + * @param null $askedLocale + * + * @return int + * @throws \Thelia\Exception\TaxEngineException + */ + public function getTaxedPrice($untaxedPrice, &$taxCollection = null, $askedLocale = null) { if(null === $this->taxRulesCollection) { throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxAmount', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION); @@ -97,6 +128,9 @@ class Calculator $currentPosition = 1; $currentTax = 0; + if(null !== $taxCollection) { + $taxCollection = new OrderProductTaxCollection(); + } foreach($this->taxRulesCollection as $taxRule) { $position = (int)$taxRule->getTaxRuleCountryPosition(); @@ -109,7 +143,17 @@ class Calculator $currentPosition = $position; } - $currentTax += $taxType->calculate($taxedPrice); + $taxAmount = round($taxType->calculate($taxedPrice), 2); + $currentTax += $taxAmount; + + if(null !== $taxCollection) { + $taxI18n = I18n::forceI18nRetrieving($askedLocale, 'Tax', $taxRule->getId()); + $orderProductTax = new OrderProductTax(); + $orderProductTax->setTitle($taxI18n->getTitle()); + $orderProductTax->setDescription($taxI18n->getDescription()); + $orderProductTax->setAmount($taxAmount); + $taxCollection->addTax($orderProductTax); + } } $taxedPrice += $currentTax; diff --git a/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php b/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php new file mode 100755 index 000000000..5c4ac2022 --- /dev/null +++ b/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php @@ -0,0 +1,126 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\TaxEngine; + +use Thelia\Model\OrderProductTax; + +/** + * + * @author Etienne Roudeix + * + */ +class OrderProductTaxCollection implements \Iterator +{ + private $position; + protected $taxes = array(); + + public function __construct() + { + foreach (func_get_args() as $tax) { + $this->addTax($tax); + } + } + + public function isEmpty() + { + return count($this->taxes) == 0; + } + + /** + * @param OrderProductTax $tax + * + * @return OrderProductTaxCollection + */ + public function addTax(OrderProductTax $tax) + { + $this->taxes[] = $tax; + + return $this; + } + + public function getCount() + { + return count($this->taxes); + } + + /** + * (PHP 5 >= 5.0.0)
    + * Return the current element + * @link http://php.net/manual/en/iterator.current.php + * @return OrderProductTax + */ + public function current() + { + return $this->taxes[$this->position]; + } + + /** + * (PHP 5 >= 5.0.0)
    + * Move forward to next element + * @link http://php.net/manual/en/iterator.next.php + * @return void Any returned value is ignored. + */ + public function next() + { + $this->position++; + } + + /** + * (PHP 5 >= 5.0.0)
    + * Return the key of the current element + * @link http://php.net/manual/en/iterator.key.php + * @return mixed scalar on success, or null on failure. + */ + public function key() + { + return $this->position; + } + + /** + * (PHP 5 >= 5.0.0)
    + * Checks if current position is valid + * @link http://php.net/manual/en/iterator.valid.php + * @return boolean The return value will be casted to boolean and then evaluated. + * Returns true on success or false on failure. + */ + public function valid() + { + return isset($this->taxes[$this->position]); + } + + /** + * (PHP 5 >= 5.0.0)
    + * Rewind the Iterator to the first element + * @link http://php.net/manual/en/iterator.rewind.php + * @return void Any returned value is ignored. + */ + public function rewind() + { + $this->position = 0; + } + + public function getKey($key) + { + return isset($this->taxes[$key]) ? $this->taxes[$key] : null; + } +} diff --git a/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php b/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php index 502b14c7e..f8c6ec6c0 100755 --- a/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php +++ b/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php @@ -86,7 +86,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase $taxRuleQuery = $this->getMock('\Thelia\Model\TaxRuleQuery', array('getTaxCalculatorCollection')); $taxRuleQuery->expects($this->once()) ->method('getTaxCalculatorCollection') - ->with($productQuery, $countryQuery) + ->with($productQuery->getTaxRule(), $countryQuery) ->will($this->returnValue('foo')); $rewritingUrlQuery = $this->getProperty('taxRuleQuery'); diff --git a/core/lib/Thelia/Tools/I18n.php b/core/lib/Thelia/Tools/I18n.php index 1f3ff57dd..aeb79ca84 100644 --- a/core/lib/Thelia/Tools/I18n.php +++ b/core/lib/Thelia/Tools/I18n.php @@ -23,6 +23,8 @@ namespace Thelia\Tools; +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Thelia\Model\Lang; /** @@ -54,4 +56,39 @@ class I18n return \DateTime::createFromFormat($currentDateFormat, $date); } + + public static function forceI18nRetrieving($askedLocale, $modelName, $id, $needed = array('Title')) + { + $i18nQueryClass = sprintf("\\Thelia\\Model\\%sI18nQuery", $modelName); + $i18nClass = sprintf("\\Thelia\\Model\\%sI18n", $modelName); + + /* get customer language translation */ + $i18n = $i18nQueryClass::create() + ->filterById($id) + ->filterByLocale( + $askedLocale + )->findOne(); + /* or default translation */ + if(null === $i18n) { + $i18n = $i18nQueryClass::create() + ->filterById($id) + ->filterByLocale( + Lang::getDefaultLanguage()->getLocale() + )->findOne(); + } + if(null === $i18n) { // @todo something else ? + $i18n = new $i18nClass();; + $i18n->setId($id); + foreach($needed as $need) { + $method = sprintf('set%s', $need); + if(method_exists($i18n, $method)) { + $i18n->$method('DEFAULT ' . strtoupper($need)); + } else { + // @todo throw sg ? + } + } + } + + return $i18n; + } } diff --git a/install/insert.sql b/install/insert.sql index aa7573d12..df252d366 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -1153,7 +1153,7 @@ INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `created_at`, `upda INSERT INTO `tax_i18n` (`id`, `locale`, `title`) VALUES (1, 'fr_FR', 'TVA française à 19.6%'), - (1, 'en_UK', 'french 19.6% tax'); + (1, 'en_US', 'french 19.6% tax'); INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`) VALUES @@ -1162,7 +1162,7 @@ INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`) INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`) VALUES (1, 'fr_FR', 'TVA française à 19.6%'), - (1, 'en_UK', 'french 19.6% tax'); + (1, 'en_US', 'french 19.6% tax'); INSERT INTO `tax_rule_country` (`tax_rule_id`, `country_id`, `tax_id`, `position`, `created_at`, `updated_at`) VALUES diff --git a/local/modules/Cheque/Cheque.php b/local/modules/Cheque/Cheque.php index f4438db4e..4516c84f3 100755 --- a/local/modules/Cheque/Cheque.php +++ b/local/modules/Cheque/Cheque.php @@ -71,6 +71,15 @@ class Cheque extends BaseModule implements PaymentModuleInterface if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) { $this->deployImageFolder($module, sprintf('%s/images', __DIR__)); } + + /* set module title */ + $this->setTitle( + $module, + array( + "en_US" => "Cheque", + "fr_FR" => "Cheque", + ) + ); } public function destroy() diff --git a/local/modules/FakeCB/FakeCB.php b/local/modules/FakeCB/FakeCB.php index 7b304420c..329bbac41 100755 --- a/local/modules/FakeCB/FakeCB.php +++ b/local/modules/FakeCB/FakeCB.php @@ -71,6 +71,15 @@ class FakeCB extends BaseModule implements PaymentModuleInterface if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) { $this->deployImageFolder($module, sprintf('%s/images', __DIR__)); } + + /* set module title */ + $this->setTitle( + $module, + array( + "en_US" => "Credit Card", + "fr_FR" => "Credit Card", + ) + ); } public function destroy() diff --git a/templates/default/order_payment.html b/templates/default/order_placed.html similarity index 85% rename from templates/default/order_payment.html rename to templates/default/order_placed.html index 884230258..c4a26af67 100644 --- a/templates/default/order_payment.html +++ b/templates/default/order_placed.html @@ -24,9 +24,11 @@ 4 Secure payment
    + {loop type="order" name="placed-order" id=$placed_order_id} +
    -

    You chose to pay by : Cheque

    +

    You chose to pay by : {loop name="payment-module" type="module" id=$PAYMENT_MODULE}{$TITLE}{/loop}

    Thank you for the trust you place in us.

    @@ -35,15 +37,17 @@
    Order number :
    -
    PRO123456788978979
    +
    {$REF}
    Date :
    -
    02/12/2013
    +
    {format_date date=$CREATE_DATE output="date"}
    Total :
    -
    $216.25
    +
    {loop type="currency" name="order-currency" id=$CURRENCY}{$SYMBOL}{/loop} {$TOTAL_TAXED_AMOUNT}
    + {/loop} + Go home From 61191b9d326407f50a18b9152cd28608286df81c Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 20 Sep 2013 16:31:19 +0200 Subject: [PATCH 101/113] fixes order integration --- local/modules/FakeCB/FakeCB.php | 2 +- templates/default/order_placed.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/local/modules/FakeCB/FakeCB.php b/local/modules/FakeCB/FakeCB.php index 329bbac41..ca682fab3 100755 --- a/local/modules/FakeCB/FakeCB.php +++ b/local/modules/FakeCB/FakeCB.php @@ -77,7 +77,7 @@ class FakeCB extends BaseModule implements PaymentModuleInterface $module, array( "en_US" => "Credit Card", - "fr_FR" => "Credit Card", + "fr_FR" => "Carte de crédit", ) ); } diff --git a/templates/default/order_placed.html b/templates/default/order_placed.html index c4a26af67..281800bb5 100644 --- a/templates/default/order_placed.html +++ b/templates/default/order_placed.html @@ -32,7 +32,7 @@

    Thank you for the trust you place in us.

    -

    A summary of your order email has been sent to the following address: email@toto.com

    +

    A summary of your order email has been sent to the following address: {customer attr="email"}

    Your order will be confirmed by us upon receipt of your payment.

    From 1a962d701d6bc1a4c3d56bb744a95af743d00136 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 20 Sep 2013 16:31:25 +0200 Subject: [PATCH 102/113] translate some missing string --- templates/default/includes/category-toolbar.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/default/includes/category-toolbar.html b/templates/default/includes/category-toolbar.html index 99583a02d..b3a6c7daa 100644 --- a/templates/default/includes/category-toolbar.html +++ b/templates/default/includes/category-toolbar.html @@ -1,10 +1,10 @@