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'}
- |