From c3af0a66ba449e2074657de76e3a6c6f082eb188 Mon Sep 17 00:00:00 2001 From: TheCoreDev Date: Tue, 16 Feb 2021 17:09:17 +0100 Subject: [PATCH] =?UTF-8?q?LivraisonParSecteurs=20:=20partie=20back-office?= =?UTF-8?q?=20termin=C3=A9e=20!!!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LivraisonParSecteurs/Config/config.xml | 1 + .../LivraisonParSecteurs/Config/routing.xml | 24 ++- .../backOffice/CitiesController.php | 101 +++++++++++ .../backOffice/GeneralController.php | 71 ++++++++ .../Controller/backOffice/ListController.php | 34 ++++ .../ScheduleController.php} | 76 +------- .../Form/CitiesAddForm.php | 58 ++++++ .../LivraisonParSecteurs/Form/CitiesForm.php | 5 +- .../Form/ScheduleCreateForm.php | 5 +- .../LivraisonParSecteurs/I18n/fr_FR.php | 6 + .../Loop/AreaCitiesLoop.php | 21 ++- .../Loop/AreaScheduleLoop.php | 2 +- .../backOffice/default/deliveryarea-edit.html | 1 + .../backOffice/default/deliveryarea-list.html | 2 +- .../default/form/area-cities-add.html | 73 ++++++++ .../default/includes/area-cities.html | 168 +++++++++++------- .../default/includes/area-schedule.html | 6 +- .../backOffice/default/js/area-cities-js.html | 14 +- .../default/js/area-schedule-js.html | 3 +- .../default/modal/area-cities-modal.html | 34 ++++ .../backOffice/custom/assets/img/pin.svg | 16 ++ templates/backOffice/custom/template.xml | 44 +++++ 22 files changed, 603 insertions(+), 162 deletions(-) create mode 100644 local/modules/LivraisonParSecteurs/Controller/backOffice/CitiesController.php create mode 100644 local/modules/LivraisonParSecteurs/Controller/backOffice/GeneralController.php create mode 100644 local/modules/LivraisonParSecteurs/Controller/backOffice/ListController.php rename local/modules/LivraisonParSecteurs/Controller/{BackOfficeController.php => backOffice/ScheduleController.php} (66%) create mode 100644 local/modules/LivraisonParSecteurs/Form/CitiesAddForm.php create mode 100644 local/modules/LivraisonParSecteurs/templates/backOffice/default/form/area-cities-add.html create mode 100644 local/modules/LivraisonParSecteurs/templates/backOffice/default/modal/area-cities-modal.html create mode 100644 templates/backOffice/custom/assets/img/pin.svg create mode 100644 templates/backOffice/custom/template.xml diff --git a/local/modules/LivraisonParSecteurs/Config/config.xml b/local/modules/LivraisonParSecteurs/Config/config.xml index 8b9bf557..a75c9576 100644 --- a/local/modules/LivraisonParSecteurs/Config/config.xml +++ b/local/modules/LivraisonParSecteurs/Config/config.xml @@ -9,6 +9,7 @@
+ diff --git a/local/modules/LivraisonParSecteurs/Config/routing.xml b/local/modules/LivraisonParSecteurs/Config/routing.xml index e25dbb91..a703a5d2 100644 --- a/local/modules/LivraisonParSecteurs/Config/routing.xml +++ b/local/modules/LivraisonParSecteurs/Config/routing.xml @@ -5,30 +5,40 @@ xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - LivraisonParSecteurs\Controller\BackOfficeController::viewAction + LivraisonParSecteurs\Controller\backOffice\ListController::viewAction - LivraisonParSecteurs\Controller\BackOfficeController::toggleActive + LivraisonParSecteurs\Controller\backOffice\ListController::toggleActive \d+ - LivraisonParSecteurs\Controller\BackOfficeController::viewArea + LivraisonParSecteurs\Controller\backOffice\GeneralController::viewArea - LivraisonParSecteurs\Controller\BackOfficeController::editArea + LivraisonParSecteurs\Controller\backOffice\GeneralController::editArea + - LivraisonParSecteurs\Controller\BackOfficeController::deleteSchedule + LivraisonParSecteurs\Controller\backOffice\ScheduleController::deleteSchedule - LivraisonParSecteurs\Controller\BackOfficeController::updateSchedule + LivraisonParSecteurs\Controller\backOffice\ScheduleController::updateSchedule - LivraisonParSecteurs\Controller\BackOfficeController::createSchedule + LivraisonParSecteurs\Controller\backOffice\ScheduleController::createSchedule + + + LivraisonParSecteurs\Controller\backOffice\CitiesController::removeCity + + + LivraisonParSecteurs\Controller\backOffice\CitiesController::addCity + + + diff --git a/local/modules/LivraisonParSecteurs/Controller/backOffice/CitiesController.php b/local/modules/LivraisonParSecteurs/Controller/backOffice/CitiesController.php new file mode 100644 index 00000000..b2959c42 --- /dev/null +++ b/local/modules/LivraisonParSecteurs/Controller/backOffice/CitiesController.php @@ -0,0 +1,101 @@ +checkAuth(AdminResources::MODULE, LivraisonParSecteurs::getModuleCode(), AccessManager::UPDATE)) + return $response; + + $areaCity_id = $this->getRequest()->get('area-cities_id'); + $query = LpsAreaCityQuery::create()->findById($areaCity_id); + if ($query === null) + $error_msg = "City not found by Id in this area"; + else + { + $con = Propel::getConnection(); + $con->beginTransaction(); + $query->delete($con); + $con->commit(); + } + + if ($this->getRequest()->request->get("success_url") == null) { + return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/module/LivraisonParSecteurs")); + } else { + return new RedirectResponse(URL::getInstance()->absoluteUrl($this->getRequest()->request->get("success_url"))); + } + } + + + /* + * Add a new delivered city in an area + */ + public function addCity() + { + // Check current user authorization + if (null !== $response = $this->checkAuth(AdminResources::MODULE, LivraisonParSecteurs::getModuleCode(), AccessManager::UPDATE)) + return $response; + + $con = Propel::getConnection(); + $con->beginTransaction(); + + $error_msg = ""; + $addForm = $this->createForm("lps-area-cities-add", "form"); + try { + $form = $this->validateForm($addForm, "POST"); + $data = $form->getData(); + + $query = new LpsAreaCity(); + $query->fromArray($data, TableMap::TYPE_FIELDNAME); + $query->setIdArea($data['area_id']); + $query->save($con); + $con->commit(); + + } catch (FormValidationException $ex) { + $error_msg = $this->createStandardFormValidationErrorMessage($ex); + + if (false !== $error_msg) { + $this->setupFormErrorContext( + $this->getTranslator()->trans("City add"), + $error_msg, + $addForm, + $ex + ); + + return $this->generateErrorRedirect($addForm); + } + } + + if ($data['success_url'] == null) { + return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/module/LivraisonParSecteurs")); + } else { + return $this->generateSuccessRedirect($addForm); + } + + } + +} \ No newline at end of file diff --git a/local/modules/LivraisonParSecteurs/Controller/backOffice/GeneralController.php b/local/modules/LivraisonParSecteurs/Controller/backOffice/GeneralController.php new file mode 100644 index 00000000..57c1541f --- /dev/null +++ b/local/modules/LivraisonParSecteurs/Controller/backOffice/GeneralController.php @@ -0,0 +1,71 @@ +render("deliveryarea-list"); + } + + + public function viewArea() + { + $selectedArea = LpsAreaQuery::create()->findOneById($this->getRequest()->query->get("area_id")); + + return $this->render("deliveryarea-edit", array('module_code' => LivraisonParSecteurs::getModuleCode(), + 'area_id' => $selectedArea)); + } + + + public function editArea() + { + // Check current user authorization + if (null !== $response = $this->checkAuth(AdminResources::MODULE, LivraisonParSecteurs::getModuleCode(), AccessManager::VIEW)) + return $response; + + $con = Propel::getConnection(); + $con->beginTransaction(); + + $error_msg = ""; + $changeForm = $this->createForm("lps-area-general-update", "form"); + + try { + $form = $this->validateForm($changeForm, "POST"); + + $data = $form->getData(); + $area = LpsAreaQuery::create()->findOneById($data['area_id']); + if ($area === null) { + $error_msg = "Delivery area not found by Id"; + } + else { + $area->fromArray($data, TableMap::TYPE_FIELDNAME); + $area->save(); + $con->commit(); + } + } catch (FormValidationException $ex) { + $error_msg = $this->createStandardFormValidationErrorMessage($ex); + } + + if ($this->getRequest()->get('save_mode') == 'stay') + return $this->render("deliveryarea-edit"); + + return $this->render("deliveryarea-list"); + } + +} \ No newline at end of file diff --git a/local/modules/LivraisonParSecteurs/Controller/backOffice/ListController.php b/local/modules/LivraisonParSecteurs/Controller/backOffice/ListController.php new file mode 100644 index 00000000..69d5a098 --- /dev/null +++ b/local/modules/LivraisonParSecteurs/Controller/backOffice/ListController.php @@ -0,0 +1,34 @@ +render("deliveryarea-list"); + } + + + public function toggleActive($id) + { + // Check current user authorization + if (null !== $response = $this->checkAuth(AdminResources::MODULE, LivraisonParSecteurs::getModuleCode(), AccessManager::UPDATE)) + return $response; + + $deliveryarea = LpsAreaQuery::create()->findOneById($id); + $deliveryarea->setActive($deliveryarea->getActive() ? 0 : 1)->save(); + + return $this->render("deliveryarea-list"); + } +} \ No newline at end of file diff --git a/local/modules/LivraisonParSecteurs/Controller/BackOfficeController.php b/local/modules/LivraisonParSecteurs/Controller/backOffice/ScheduleController.php similarity index 66% rename from local/modules/LivraisonParSecteurs/Controller/BackOfficeController.php rename to local/modules/LivraisonParSecteurs/Controller/backOffice/ScheduleController.php index d787b6de..358d86bc 100644 --- a/local/modules/LivraisonParSecteurs/Controller/BackOfficeController.php +++ b/local/modules/LivraisonParSecteurs/Controller/backOffice/ScheduleController.php @@ -1,9 +1,8 @@ render("deliveryarea-list"); - } - - public function toggleActive($id) - { - // Check current user authorization - if (null !== $response = $this->checkAuth(AdminResources::MODULE, LivraisonParSecteurs::getModuleCode(), AccessManager::UPDATE)) - return $response; - - $deliveryarea = LpsAreaQuery::create()->findOneById($id); - $deliveryarea->setActive($deliveryarea->getActive() ? 0 : 1)->save(); - - return $this->render("deliveryarea-list"); - } - - public function updatePrice($params = []) - { - return $this->render("deliveryarea-list"); - } - - public function viewArea() - { - $selectedArea = LpsAreaQuery::create()->findOneById($this->getRequest()->query->get("area_id")); - - return $this->render("deliveryarea-edit", array('module_code' => LivraisonParSecteurs::getModuleCode(), - 'area_id' => $selectedArea)); - } - - public function editArea() - { - // Check current user authorization - if (null !== $response = $this->checkAuth(AdminResources::MODULE, LivraisonParSecteurs::getModuleCode(), AccessManager::VIEW)) - return $response; - - $con = Propel::getConnection(); - $con->beginTransaction(); - - $error_msg = ""; - $changeForm = $this->createForm("lps-area-general-update", "form"); - - try { - $form = $this->validateForm($changeForm, "POST"); - - $data = $form->getData(); - $area = LpsAreaQuery::create()->findOneById($data['area_id']); - if ($area === null) { - $error_msg = "Delivery area not found by Id"; - } - else { - $area->fromArray($data, TableMap::TYPE_FIELDNAME); - $area->save(); - $con->commit(); - } - } catch (FormValidationException $ex) { - $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } - - if ($this->getRequest()->get('save_mode') == 'stay') - return $this->render("deliveryarea-edit"); - - return $this->render("deliveryarea-list"); - } /* * Delete a day in an area's delivery schedule @@ -167,8 +102,8 @@ class BackOfficeController extends BaseAdminController /* - * Update a day in an area's delivery schedule - */ + * Add a new delivery day in an area + */ public function createSchedule() { // Check current user authorization @@ -210,7 +145,6 @@ class BackOfficeController extends BaseAdminController } else { return $this->generateSuccessRedirect($changeForm); } - } } \ No newline at end of file diff --git a/local/modules/LivraisonParSecteurs/Form/CitiesAddForm.php b/local/modules/LivraisonParSecteurs/Form/CitiesAddForm.php new file mode 100644 index 00000000..5de23882 --- /dev/null +++ b/local/modules/LivraisonParSecteurs/Form/CitiesAddForm.php @@ -0,0 +1,58 @@ +formBuilder + ->add("area_id","integer", [ + "label_attr" => ["for" => "attr-area-id"], + "required" => true, + "constraints" => [new Constraints\NotBlank()] + ]) + ->add("zipcode", "integer", [ + "label" => $this->translator->trans("Zipcode", [], LivraisonParSecteurs::MESSAGE_DOMAIN), + "label_attr" => ["for" => "attr-city-zipcode"], + "required" => true, + "constraints" => [new Constraints\NotBlank(), new Constraints\NotNull()], + ]) + ->add("title", "text", [ + "label" => $this->translator->trans("City", [], LivraisonParSecteurs::MESSAGE_DOMAIN), + "label_attr" => ["for" => "attr-city-title"], + "required" => true, + "constraints" => [new Constraints\NotBlank(), new Constraints\NotNull()], + "attr" => array() + ]) + ->add("latitude", "number", [ + "label" => $this->translator->trans("Latitude", [], LivraisonParSecteurs::MESSAGE_DOMAIN), + "label_attr" => ["for" => "attr-city-latitude"], + "required" => false + ]) + ->add("longitude", "number", [ + "label" => $this->translator->trans("Longitude", [], LivraisonParSecteurs::MESSAGE_DOMAIN), + "label_attr" => ["for" => "attr-city-longitude"], + "required" => false + ]); + } + + /** + * @inheritDoc + */ + public function getName() + { + return "lps-area-cities-add"; + } +} diff --git a/local/modules/LivraisonParSecteurs/Form/CitiesForm.php b/local/modules/LivraisonParSecteurs/Form/CitiesForm.php index d24d06a0..549ac2cb 100644 --- a/local/modules/LivraisonParSecteurs/Form/CitiesForm.php +++ b/local/modules/LivraisonParSecteurs/Form/CitiesForm.php @@ -23,14 +23,15 @@ class CitiesForm extends BaseForm "integer", [ "required" => true, - "constraints" => [new Constraints\NotBlank()] + "constraints" => [new Constraints\NotBlank()], + 'label' => $this->translator->trans('Area Id', [], LivraisonParSecteurs::DOMAIN_NAME) ]) ->add( 'zipcode', 'integer', [ 'constraints' => [new Constraints\NotBlank()], - 'label' => $this->translator->trans('Delivery price', [], LivraisonParSecteurs::DOMAIN_NAME) + 'label' => $this->translator->trans('Zipcode', [], LivraisonParSecteurs::DOMAIN_NAME) ]); } diff --git a/local/modules/LivraisonParSecteurs/Form/ScheduleCreateForm.php b/local/modules/LivraisonParSecteurs/Form/ScheduleCreateForm.php index 2828de2f..43a4d84e 100644 --- a/local/modules/LivraisonParSecteurs/Form/ScheduleCreateForm.php +++ b/local/modules/LivraisonParSecteurs/Form/ScheduleCreateForm.php @@ -35,11 +35,10 @@ class ScheduleCreateForm extends BaseForm ]) ->add("begin_time", "time", [ "label" => $this->translator->trans("Delivery beginning time", [], LivraisonParSecteurs::MESSAGE_DOMAIN), - "label_attr" => ["for" => "attr-area-schedule-begin"], + "label_attr" => ["for" => "attr-area-schedule-start"], "input" => "string", "widget" => "single_text", - "required" => true, - "constraints" => [new Constraints\NotBlank(), new Constraints\NotNull()], + "required" => true,"constraints" => [new Constraints\NotBlank(), new Constraints\NotNull()], "attr" => array() ]) ->add("end_time", "time", [ diff --git a/local/modules/LivraisonParSecteurs/I18n/fr_FR.php b/local/modules/LivraisonParSecteurs/I18n/fr_FR.php index fcc05b82..7267cb8a 100644 --- a/local/modules/LivraisonParSecteurs/I18n/fr_FR.php +++ b/local/modules/LivraisonParSecteurs/I18n/fr_FR.php @@ -2,11 +2,13 @@ return array( 'Active' => 'Actif', 'Actions' => 'Actions', + 'Add a new city' => 'Rajouter une commune', 'Add a new delivery day' => 'Ajouter un jour de livraison', 'Area name' => 'Nom du secteur', 'Cities' => 'Communes desservies', 'City' => 'Commune', 'Create a delivery day' => 'Créer un nouveau jour de livraison', + 'Delete a city from this area' => 'Supprimer une commune de livraison', 'Delete an entry of schedule' => 'Supprimer un jour de livraison', 'Delivered cities count' => 'Nb de communes desservies', 'Delivery beginning time' => 'Début de la tournée', @@ -14,14 +16,18 @@ return array( 'Delivery days' => 'Jours de livraison', 'Delivery ending time' => 'Fin de la tournée', 'Delivery price' => 'Frais de livraison', + 'Do you really want to remove this city ?' => 'Voulez-vous réellement retirer cette commune de ce secteur de livraison ?', 'Do you really want to delete this delivery day ?' => 'Voulez-vous réellement supprimer ce jour de livraison ?', 'Edit an area' => 'Modifier le secteur', + 'Format to respect' => 'Merci de respecter le format 50.255612 ou -3.121146 (le séparateur est un point et le nombre peut être négatif)', 'General' => 'Général', 'Home delivery cost' => 'Frais de livraison à domicile', 'Modify a delivery day' => 'Modifier un jour de livraison', 'My areas' => 'Mes secteurs de livraison', + 'Remove this city' => 'Retirer cette commune', 'Save' => 'Sauvegarder', 'Schedule' => 'Horaires de livraison', + 'There is no city delivered in this area' => 'Aucune commune desservie dans ce secteur', 'There is no schedule for this area' => 'Aucune livraison actuellement sur ce secteur', 'Title of config view' => 'Module LivraisonParSecteurs - Configuration', 'Zipcode' => 'Code postal', diff --git a/local/modules/LivraisonParSecteurs/Loop/AreaCitiesLoop.php b/local/modules/LivraisonParSecteurs/Loop/AreaCitiesLoop.php index c625faec..0711a09e 100644 --- a/local/modules/LivraisonParSecteurs/Loop/AreaCitiesLoop.php +++ b/local/modules/LivraisonParSecteurs/Loop/AreaCitiesLoop.php @@ -3,12 +3,15 @@ namespace LivraisonParSecteurs\Loop; use LivraisonParSecteurs\Model\LpsAreaCityQuery; +use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\PropelSearchLoopInterface; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Type\EnumListType; +use Thelia\Type\TypeCollection; /** * Class AreaCitiesLoop @@ -48,7 +51,9 @@ class AreaCitiesLoop extends BaseLoop implements PropelSearchLoopInterface protected function getArgDefinitions() { return new ArgumentCollection( - Argument::createIntListTypeArgument('area_id') + Argument::createIntListTypeArgument('area_id'), + Argument::createEnumListTypeArgument('order', + ['title', 'zipcode'], 'title') ); } @@ -58,11 +63,23 @@ class AreaCitiesLoop extends BaseLoop implements PropelSearchLoopInterface public function buildModelCriteria() { $query = LpsAreaCityQuery::create(); + if (null != $id = $this->getAreaId()) { $query->filterByIdArea($id); } - return $query->orderByZipcode(); + foreach ($this->getOrder() as $order) { + switch ($order) { + case 'title': + $query->orderByTitle(); + break; + case 'zipcode': + $query->orderByZipcode()->orderByTitle(); + break; + } + } + + return $query; } } diff --git a/local/modules/LivraisonParSecteurs/Loop/AreaScheduleLoop.php b/local/modules/LivraisonParSecteurs/Loop/AreaScheduleLoop.php index 2b1ef92c..5eb5db9a 100644 --- a/local/modules/LivraisonParSecteurs/Loop/AreaScheduleLoop.php +++ b/local/modules/LivraisonParSecteurs/Loop/AreaScheduleLoop.php @@ -64,6 +64,6 @@ class AreaScheduleLoop extends BaseLoop implements PropelSearchLoopInterface $query->filterByIdArea($id); } - return $query->orderByDay(); + return $query->orderByDay()->orderByBeginTime(); } } diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-edit.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-edit.html index 52725f38..153d6890 100644 --- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-edit.html +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-edit.html @@ -52,6 +52,7 @@ {include file="modal/area-schedule-modal.html"} +{include file="modal/area-cities-modal.html"} {/block} diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html index 5e1514fd..99601424 100644 --- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html @@ -49,7 +49,7 @@ {$PRICE} € - {$DELIVERY_DAYS} + {$DELIVERY_DAYS}{if $DELIVERY_DAYS eq ''}{intl l="There is no schedule for this area" d="livraisonparsecteurs"}{/if} {$COVERED_CITIES_NUMBER}
diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/form/area-cities-add.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/form/area-cities-add.html new file mode 100644 index 00000000..62fa06ce --- /dev/null +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/form/area-cities-add.html @@ -0,0 +1,73 @@ +{form name=$form_name} +{form_hidden_fields form=$form} + +{render_form_field form=$form field="success_url" value={url path="/admin/module/LivraisonParSecteurs/edit?area_id={$area_id}#cities"}} +{render_form_field form=$form field="error_url" value={url path="/admin/module/LivraisonParSecteurs/edit?area_id={$area_id}#cities"}} + +{form_field form=$form field="area_id"} + +{/form_field} + +
+
+ + {form_field form=$form field="zipcode"} +
+ + +
+ {form_error form=$form field="zipcode"}{$message}{/form_error} + {/form_field} + + {form_field form=$form field="title"} +
+ + +
+ {form_error form=$form field="title"}{$message}{/form_error} + {/form_field} + +
+
+ {form_field form=$form field="latitude"} +
+ + +
+ {form_error form=$form field="latitude"}{$message}{/form_error} + {/form_field} +
+
+ {form_field form=$form field="longitude"} +
+ + +
+ {form_error form=$form field="longitude"}{$message}{/form_error} + {/form_field} +
+
+
+
+ {intl l="Format to respect" d="livraisonparsecteurs"} +
+
+ +
+
+{/form} \ No newline at end of file diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-cities.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-cities.html index ec2064b2..dc930a33 100644 --- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-cities.html +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-cities.html @@ -23,91 +23,121 @@ } .city-remove { - height: 30x !important; + height: 30px !important; + } + + .pin { + height: 25px; + margin-left: 12px; + } + + .legende { + margin-top: 25px; + text-align: center; + font-style: italic; } {form name='lps-area-cities-update'} -
+
- {if $form_error} -
{$form_error_message}
- {/if} + {if $form_error} +
{$form_error_message}
+ {/if} -
-
+
+
- {loop name="area" type="lps_area" id="$area_id"} - - {form_hidden_fields form=$form} + {loop name="area" type="lps_area" id="$area_id"} + + {form_hidden_fields form=$form} - {form_field form=$form field="area_id"} - - {/form_field} + {form_field form=$form field="area_id"} + + {/form_field} -
-
- - - - - - - - - - {loop name="cities" type="lps_area_cities" area_id="$area_id"} - - - - - - {/loop} - -
{intl l="Zipcode" d="livraisonparsecteurs"}{intl l="City" d="livraisonparsecteurs"} -
- - - -
-
{$ZIPCODE}{$TITLE} -
- - - -
-
-
+
+
+ + + + + + + + + + {loop name="cities" type="lps_area_cities" area_id="$area_id" order="title"} + + + + + + {/loop} + {elseloop rel="cities"} + + + + {/elseloop} + +
{intl l="Zipcode" d="livraisonparsecteurs"}{intl l="City" d="livraisonparsecteurs"} +
+ {loop name="auth-delete" type="auth" role="ADMIN" resource="admin.lps.cities" access="CREATE" module="LivraisonParSecteurs"} + + + + {/loop} +
+
{$ZIPCODE}{$TITLE}{if $LATITUDE eq '' or $LONGITUDE eq ''}Pas de coordonnées{/if} +
+ {loop name="auth-delete" type="auth" role="ADMIN" resource="admin.lps.cities" access="DELETE" module="LivraisonParSecteurs"} + + + + {/loop} +
+
+
+ {intl l="There is no city delivered in this area" d="livraisonparsecteurs"} +
+
+
- - - - {loop name="cities-coordinates" type="lps_area_cities" area_id="$area_id"} - - - - - - {/loop} - - + + + + {loop name="cities-coordinates" type="lps_area_cities" area_id="$area_id"} + + + + + + {/loop} + + - - {/loop} -
+ -
- - + + {/loop} +
-
- -
+
+ + + +
+ + + +
NB : Les communes sans coordonnées GPS n'apparaitront pas sur la carte ci-dessus.
+
+
{/form} diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-schedule.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-schedule.html index 06ece97b..40a56314 100644 --- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-schedule.html +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-schedule.html @@ -6,7 +6,7 @@ {/if} {loop name="area" type="lps_area" id="$area_id"} -
+ {form_hidden_fields form=$form} {include @@ -57,7 +57,7 @@
{loop name="auth-edit" type="auth" role="ADMIN" resource="admin.lps.schedule" access="UPDATE" module="LivraisonParSecteurs"} - {/loop} {loop name="auth-delete" type="auth" role="ADMIN" resource="admin.lps.schedule" access="DELETE" module="LivraisonParSecteurs"} - diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/js/area-cities-js.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/js/area-cities-js.html index cc971214..b1171d18 100644 --- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/js/area-cities-js.html +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/js/area-cities-js.html @@ -5,7 +5,6 @@ (function($){ $('a[href="#cities"]').on("shown.bs.tab",function(){ - var opt = { center: new google.maps.LatLng($("#map-center-lat").val(), $("#map-center-lon").val()), zoom: 12, @@ -24,7 +23,6 @@ }); function displayPins() { - var arrays = []; $('#coordinates').eq(0).find('tr').each((r,row) => arrays.push($(row).find('td,th').map((c,cell) => $(cell).text()).toArray())) @@ -37,6 +35,18 @@ }); } + + // On sélectionne une commune à supprimer + $('a.cities-remove').click(function (ev) { + $('#attr-cities-id-remove').val($(this).data('id')); + }); + + // On ajoute une commune au secteur + $('a.city-add').click(function (ev) { + $("#attr-city-zipcode input, #attr-city-title input").prop('required', true); + $("#attr-city-latitude input, #attr-city-longitude input").prop('required', false); + }); + })(jQuery); \ No newline at end of file diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/js/area-schedule-js.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/js/area-schedule-js.html index 38316170..28916344 100644 --- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/js/area-schedule-js.html +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/js/area-schedule-js.html @@ -17,10 +17,11 @@ }); $('a.area-schedule-add').click(function (ev) { - $("#attr-area-schedule-begin input, #attr-area-schedule-end input").prop('required', false); + $("#attr-area-schedule-begin input, #attr-area-schedule-end input").prop('required', true); $("#attr-area-schedule-day").prop('required', true); }); + {$langcode = {lang attr="code"}|substr:0:2} $(document).ready(function () { $('.input-group.time').datetimepicker({ diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/modal/area-cities-modal.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/modal/area-cities-modal.html new file mode 100644 index 00000000..7724e931 --- /dev/null +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/modal/area-cities-modal.html @@ -0,0 +1,34 @@ +{* DELETE modal *} +{capture "cities_delete"} + {intl l="Do you really want to remove this city ?" d="livraisonparsecteurs"} + + + +{/capture} + +{include file="includes/generic-confirm-dialog.html" +dialog_id = "area-cities-remove" +dialog_title = {intl l="Delete a city from this area" d="livraisonparsecteurs"} +dialog_message = {$smarty.capture.cities_delete nofilter} +dialog_ok_label = {intl l="Delete"} +dialog_cancel_label = {intl l="Cancel"} +form_action = {token_url path='/admin/module/LivraisonParSecteurs/city/remove'} +} + + +{* CREATE Modal *} +{form name="lps-area-cities-add"} + {capture "cities_add"} + {include file="form/area-cities-add.html" form_name="lps-area-cities-add" area_id=$smarty.get.area_id} + {/capture} + + {include file="includes/generic-create-dialog.html" + dialog_id = "area-cities-add" + dialog_title = {intl l="Add a new city" d="livraisonparsecteurs"} + dialog_body = {$smarty.capture.cities_add nofilter} + dialog_ok_label = {intl l="Create"} + dialog_cancel_label = {intl l="Cancel"} + form_action = {url path="admin/module/LivraisonParSecteurs/city/add"} + form_enctype = {form_enctype form=$form} + } +{/form} diff --git a/templates/backOffice/custom/assets/img/pin.svg b/templates/backOffice/custom/assets/img/pin.svg new file mode 100644 index 00000000..35417c6c --- /dev/null +++ b/templates/backOffice/custom/assets/img/pin.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/templates/backOffice/custom/template.xml b/templates/backOffice/custom/template.xml new file mode 100644 index 00000000..40cad776 --- /dev/null +++ b/templates/backOffice/custom/template.xml @@ -0,0 +1,44 @@ + +