From 123280f4d4ffbae5417332e804ad748345c5530e Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Tue, 15 Apr 2014 20:11:33 +0200 Subject: [PATCH] Cleaned the mess of Shipping zones, which is Shipping configuration... --- .../Thelia/Config/Resources/routing/admin.xml | 4 +- .../Admin/ShippingZoneController.php | 10 ++-- core/lib/Thelia/Core/Template/Loop/Area.php | 11 ++++- .../Form/ShippingZone/ShippingZoneAddArea.php | 2 +- templates/backOffice/default/I18n/fr_FR.php | 12 +++-- .../backOffice/default/configuration.html | 4 +- .../default/shipping-zones-edit.html | 48 +++++++++++++------ .../backOffice/default/shipping-zones.html | 40 +++++++++++++--- 8 files changed, 96 insertions(+), 35 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index d9951780e..ccf7a5234 100644 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -771,9 +771,9 @@ Thelia\Controller\Admin\ShippingZoneController::indexAction - + Thelia\Controller\Admin\ShippingZoneController::updateAction - \d+ + \d+ diff --git a/core/lib/Thelia/Controller/Admin/ShippingZoneController.php b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php index 82b630398..c8b497e14 100644 --- a/core/lib/Thelia/Controller/Admin/ShippingZoneController.php +++ b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php @@ -46,11 +46,11 @@ class ShippingZoneController extends BaseAdminController return $this->render("shipping-zones", array("display_shipping_zone" => 20)); } - public function updateAction($shipping_zones_id) + public function updateAction($delivery_module_id) { if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE, array(), AccessManager::VIEW)) return $response; return $this->render("shipping-zones-edit", array( - "shipping_zones_id" => $shipping_zones_id + "delivery_module_id" => $delivery_module_id )); } @@ -133,13 +133,13 @@ class ShippingZoneController extends BaseAdminController protected function renderEditionTemplate() { return $this->render("shipping-zones-edit", array( - "shipping_zones_id" => $this->getShippingZoneId() + "delivery_module_id" => $this->getDeliveryModuleId() )); } - protected function getShippingZoneId() + protected function getDeliveryModuleId() { - return $this->getRequest()->get('shipping_zone_id', 0); + return $this->getRequest()->get('delivery_module_id', 0); } } diff --git a/core/lib/Thelia/Core/Template/Loop/Area.php b/core/lib/Thelia/Core/Template/Loop/Area.php index 6ac3b1518..510fa03f2 100644 --- a/core/lib/Thelia/Core/Template/Loop/Area.php +++ b/core/lib/Thelia/Core/Template/Loop/Area.php @@ -77,7 +77,8 @@ class Area extends BaseLoop implements PropelSearchLoopInterface return new ArgumentCollection( Argument::createIntListTypeArgument('id'), Argument::createIntTypeArgument('with_zone'), - Argument::createIntTypeArgument('without_zone') + Argument::createIntTypeArgument('without_zone'), + Argument::createBooleanOrBothTypeArgument('unassigned') ); } @@ -106,6 +107,14 @@ class Area extends BaseLoop implements PropelSearchLoopInterface ->where('`without_zone`.delivery_module_id '.Criteria::ISNULL); } + $notAssigned = $this->getUnassigned(); + + if ($notAssigned) { + $search + ->joinAreaDeliveryModule('unassigned', Criteria::LEFT_JOIN) + ->where('`unassigned`.delivery_module_id ' . Criteria::ISNULL); + } + return $search; } diff --git a/core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php b/core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php index ea31b696b..8930c9cb2 100644 --- a/core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php +++ b/core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php @@ -65,7 +65,7 @@ class ShippingZoneAddArea extends BaseForm new GreaterThan(array('value' => 0)) ), 'label_attr' => array('for' => 'shipping_area'), - 'label' => Translator::getInstance()->trans('Area') + 'label' => Translator::getInstance()->trans('Available shipping zones') )) ->add('shipping_zone_id', 'integer', array( 'constraints' => array( diff --git a/templates/backOffice/default/I18n/fr_FR.php b/templates/backOffice/default/I18n/fr_FR.php index 71c60ece5..d1c829970 100755 --- a/templates/backOffice/default/I18n/fr_FR.php +++ b/templates/backOffice/default/I18n/fr_FR.php @@ -9,6 +9,7 @@ return array( 'Cannot translate all fields. According to your PHP configuration, forms cannot contains more than %current_max_input_vars input fields, but at least %required_max_input_vars are required. Please change the value of max_input_vars in your PHP configuration of change the translation file by hand.' => 'Limitation système bloquante ! Votre configuration PHP limite le nombre de champs d\'une forme HTML à %current_max_input_vars champs. Au moins %required_max_input_vars champs sont nécessaires pour effectuer les traductions. Merci de modifier en conséquence la variable max_input_vars de votre configuration PHP. Vous pouvez aussi modifier les fichiers de traduction à la main.', 'Congratulations, all text is now translated !' => 'Félicitations, tous les textes ont été traduits !', 'Did not found any text to translate. It\'s probably normal. If not, please be sure to use Smarty\'s "intl" function in templates, or the Translator::trans() method in PHP files.' => 'Aucun texte à traduire. C\'est probablement normal. Si ce n\'est pas le cas vérifiez que vous utilisez bien la fonction Smarty "intl" ou bien le translator Translator::trans dans un fichier php', + 'Warning, some of your shipping zones are not attached to any delivery module:' => 'Attention, les zones de livraison suivantes ne sont associées à aucun module:', 'A content could be attached to more than one folder. Select here the additional folders for this content.' => 'Un contenu peut être rattaché à plusieurs dossiers. Sélectionnez ici les dossiers dans lesquels ce contenu apparaîtra', 'A product could be attached to more than one category. Select here the additional categories for this product.' => 'Un produit peut être associé à plusieurs rubriques. Sélectionner les rubrique pour lesquels le produit sera associé', 'A short description, used when a summary or an introduction is required' => 'Une courte description, utilisée lorsqu\'un résumé ou une introduction est requise', @@ -374,13 +375,13 @@ return array( 'Edit product' => 'Modifier le produit', 'Edit product %title' => 'Modifier le produit %title', 'Edit shipping configuration %title' => 'Modifier la configuration de livraison %title', - 'Edit shipping zone %title' => 'Modifier la zone de livraison %title', 'Edit tax rule taxes' => 'Modifier les taxes de la règle de taxe', 'Edit template "%name"' => 'Modifier le template "%name"', 'Edit this address' => 'Editer cette adresse', 'Edit this category' => 'Editer cette rubrique', 'Edit this content' => 'Modifier ce contenu', 'Edit this customer' => 'Modifier ce client', + 'Edit this delivery zone' => 'Modifier cette zone de livraison', 'Edit this folder' => 'Modifier ce dossier', 'Edit this module' => 'Modifier ce module', 'Edit this order' => 'Editer cette commande', @@ -401,7 +402,7 @@ return array( 'Editing profile' => 'Modification du profil', 'Editing profile \'%name\'' => 'Edition du profil \'%name\' ', 'Editing shipping configuration "%name"' => 'En cours de modification de la configuration de livraison "%name"', - 'Editing shipping zone "%name"' => 'En cours de modification de la zone de livraison "%name"', + 'Editing shipping configuration for module "%name"' => 'Configuration des zones de livraison du module "%title" ', 'Editing tax' => 'En cours de modification de la taxe', 'Editing tax rule' => 'En cours de modification de la règle de taxe', 'Editing template "%name"' => 'Modification du template "%name"', @@ -738,7 +739,10 @@ return array( 'Set as default tax rule' => 'Configurer en tant que règle par défaut', 'Shipping configuration' => 'Configuration du transport', 'Shipping configuration name' => 'Nom de la configuration de livraison', - 'Shipping zones' => 'Zones de livraison', + 'Shipping configuration of delivery module "%title"' => 'Configuration des zones de livraison du module "%title" ', + 'Shipping zone' => 'Zone de livraison', + 'Shipping zones for this module' => 'Zones de livraison associées à ce module', + 'Shipping zones management' => 'Zones de livraison', 'Shop' => 'Boutique', 'Shop Informations' => 'Informations sur la boutique', 'Short conclusion' => 'Courte conclusion', @@ -819,6 +823,7 @@ return array( 'Thelia support forum' => 'Forum de Thelia', 'Thelia system variables' => 'Variables Thelia', 'Thelia, the open source e-commerce solution' => 'Thelia, la solution e-commerce libre', + 'There are no shipping zones attached to this module.' => 'Ce module de transport n\'est associé à aucune zone de livraison', 'There is currently no active module here.' => 'Il n\'y a aucun module actif ici', 'There is no documents attached to this %type.' => 'Il n\'y a aucun document lié à ce %type.', 'There is no images attached to this %type.' => 'Il n\'y a pas d\'image liée à ce %type.', @@ -919,7 +924,6 @@ return array( 'You don\'t need to use commas or other punctuations.' => 'Vous n\'avez pas besoin d\'utiliser de virgules ou d\'autres signes de ponctuation', 'Your current IP address is %ip' => 'Votre adresse IP est %ip', 'Zip code' => 'Code postal', - 'Zones' => 'Zones', 'activate' => 'activer', 'activate %title module' => 'Activez le module %title', 'activation' => 'Activation', diff --git a/templates/backOffice/default/configuration.html b/templates/backOffice/default/configuration.html index 4e57584ca..e4d51dda8 100644 --- a/templates/backOffice/default/configuration.html +++ b/templates/backOffice/default/configuration.html @@ -89,14 +89,14 @@ {loop type="auth" name="pcc2" role="ADMIN" resource="admin.configuration.shipping-zone" access="VIEW"} - {intl l='Shipping zones'} + {intl l='Shipping configuration'} {/loop} {loop type="auth" name="pcc3" role="ADMIN" resource="admin.configuration.shipping-configuration" access="VIEW"} - {intl l='Shipping configuration'} + {intl l='Shipping zones management'} {/loop} diff --git a/templates/backOffice/default/shipping-zones-edit.html b/templates/backOffice/default/shipping-zones-edit.html index 6d76bc5eb..5f07b9089 100644 --- a/templates/backOffice/default/shipping-zones-edit.html +++ b/templates/backOffice/default/shipping-zones-edit.html @@ -10,21 +10,31 @@
+ {loop type="module" id="$delivery_module_id" active="*" name="module.name" backend_context="1"} +
- -
- {intl l='Edit shipping zone %title' title=$TITLE} + +
+
+
+ {intl l='Shipping configuration of delivery module "%title"' title=$TITLE} +
+ +
+
{form name="thelia.shopping_zone_area"} @@ -32,18 +42,18 @@ {form_hidden_fields form=$form} {form_field form=$form field='success_url'} - {* the url the user is redirected to on login success *} + {* the url the user is redirected to on login success *} {/form_field} {form_field form=$form field='shipping_zone_id'} - + {/form_field} {form_field form=$form field='area_id'}
@@ -61,21 +71,30 @@ - - + + - {loop type="area" name="area.module.associated" with_zone=$shipping_zones_id} + {loop type="area" name="area.module.associated" with_zone=$delivery_module_id} - {/loop} + {elseloop rel="area.module.associated"} + + + + {/elseloop}
{intl l="Zones"}{intl l="Actions"}{intl l="Shipping zone"}{intl l="Actions"}
{$NAME} +
+
+ {intl l="There are no shipping zones attached to this module."} +
+
@@ -86,6 +105,7 @@
+ {/loop}
@@ -96,11 +116,11 @@ {form_hidden_fields form=$form} {form_field form=$form field='success_url'} - {* the url the user is redirected to on login success *} + {* the url the user is redirected to on login success *} {/form_field} {form_field form=$form field='shipping_zone_id'} - + {/form_field} {form_field form=$form field='area_id'} diff --git a/templates/backOffice/default/shipping-zones.html b/templates/backOffice/default/shipping-zones.html index 26f860770..1f7f3f689 100644 --- a/templates/backOffice/default/shipping-zones.html +++ b/templates/backOffice/default/shipping-zones.html @@ -13,7 +13,7 @@ {module_include location='shipping_zones_top'} @@ -21,18 +21,33 @@
+ +
+
+
+ {intl l='Warning, some of your shipping zones are not attached to any delivery module:'} + {loop name="area-not-attached" type="area" unassigned=true} + {$NAME}{if $LOOP_COUNT < $LOOP_TOTAL},{else}.{/if} + {/loop} +
+
+
+
+ + - - + + + {module_include location='shipping_zones_table_header'} - + @@ -40,10 +55,23 @@ {loop type="module" module_type="2" active="*" name="delivery.list" backend_context="1"} + {module_include location='shipping_zones_table_row'} -
- {intl l='Thelia Shipping zones'} + {intl l='Shipping configuration'}
{intl l="Name"}
{intl l="Delivery module"}{intl l="Shipping zones for this module"}{intl l="Actions"}{intl l="Actions"}
{$TITLE} + {loop name="area.module.associated" type="area" with_zone=$ID backend_context="1"} + {$countries = ''} + {loop name="country-area" type="country" area=$ID backend_context="1"} + {$countries = "$countries, $TITLE"} + {/loop} + {$countries = ltrim($countries, ', ')} + {$NAME}{if $LOOP_COUNT < $LOOP_TOTAL},{/if} + {/loop} + {elseloop rel="area.module.associated"} + {intl l="There are no shipping zones attached to this module."} + {/elseloop} + +
{loop type="auth" name="can_change" role="ADMIN" resource="admin.configuration.shipping-zone" access="UPDATE"}