+
diff --git a/local/modules/LivraisonParSecteurs/Config/schema.xml b/local/modules/LivraisonParSecteurs/Config/schema.xml
index 74de6ce7..e6ae0b13 100644
--- a/local/modules/LivraisonParSecteurs/Config/schema.xml
+++ b/local/modules/LivraisonParSecteurs/Config/schema.xml
@@ -7,7 +7,7 @@
-
+
diff --git a/local/modules/LivraisonParSecteurs/Config/thelia.sql b/local/modules/LivraisonParSecteurs/Config/thelia.sql
index bb583ab7..0405e3e5 100644
--- a/local/modules/LivraisonParSecteurs/Config/thelia.sql
+++ b/local/modules/LivraisonParSecteurs/Config/thelia.sql
@@ -14,7 +14,7 @@ CREATE TABLE `lps_area`
`id` INTEGER NOT NULL,
`title` VARCHAR(50) NOT NULL,
`active` TINYINT DEFAULT 1 NOT NULL,
- `price` INTEGER DEFAULT 0 NOT NULL,
+ `price` FLOAT DEFAULT 0 NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
diff --git a/local/modules/LivraisonParSecteurs/Controller/BackOfficeController.php b/local/modules/LivraisonParSecteurs/Controller/BackOfficeController.php
index ee9279b3..2de766f8 100644
--- a/local/modules/LivraisonParSecteurs/Controller/BackOfficeController.php
+++ b/local/modules/LivraisonParSecteurs/Controller/BackOfficeController.php
@@ -4,9 +4,12 @@ namespace LivraisonParSecteurs\Controller;
use LivraisonParSecteurs\LivraisonParSecteurs;
use LivraisonParSecteurs\Model\LpsAreaQuery;
+use Propel\Runtime\Map\TableMap;
+use Propel\Runtime\Propel;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources;
+use Thelia\Form\Exception\FormValidationException;
/**
* Class BackOfficeController
@@ -39,13 +42,40 @@ class BackOfficeController extends BaseAdminController
public function viewArea()
{
$selectedArea = LpsAreaQuery::create()->findOneById($this->getRequest()->query->get("area_id"));
- return $this->render("deliveryarea-edit", array('module_code' => 'DeliveryRound',
+
+ return $this->render("deliveryarea-edit", array('module_code' => LivraisonParSecteurs::getModuleCode(),
'area_id' => $selectedArea));
}
public function editArea()
{
- $selectedArea = LpsAreaQuery::create()->findOneById($id);
- return $this->render("deliveryarea-edit");
+ // 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);
+ }
+
+ return $this->render("deliveryarea-edit", Array($error_msg));
}
}
\ No newline at end of file
diff --git a/local/modules/LivraisonParSecteurs/Form/CitiesForm.php b/local/modules/LivraisonParSecteurs/Form/CitiesForm.php
new file mode 100644
index 00000000..a0eaa3ea
--- /dev/null
+++ b/local/modules/LivraisonParSecteurs/Form/CitiesForm.php
@@ -0,0 +1,40 @@
+formBuilder
+ ->add(
+ 'price',
+ 'number',
+ [
+ 'constraints' => [new Constraints\NotBlank()],
+ 'required' => true,
+ 'label' => $this->translator->trans('Delivery price', [], LivraisonParSecteurs::DOMAIN_NAME),
+ 'label_attr' => ['for' => 'price'],
+ 'attr' => array()
+ ]);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getName()
+ {
+ return "lps-area-cities.update";
+ }
+}
diff --git a/local/modules/LivraisonParSecteurs/Form/ConfigForm.php b/local/modules/LivraisonParSecteurs/Form/ConfigForm.php
deleted file mode 100644
index e30c53ca..00000000
--- a/local/modules/LivraisonParSecteurs/Form/ConfigForm.php
+++ /dev/null
@@ -1,40 +0,0 @@
-formBuilder
- ->add(
- 'price',
- 'number',
- [
- 'constraints' => [new Constraints\NotBlank()],
- 'required' => true,
- 'label' => $this->translator->trans('Price', [], LivraisonParSecteurs::DOMAIN_NAME),
- 'label_attr' => ['for' => 'price'],
- 'attr' => array()
- ])
- ->add(
- 'active',
- 'number',
- [
- 'required' => true,
- 'label' => $this->translator->trans('Active', [], LivraisonParSecteurs::DOMAIN_NAME),
- 'label_attr' => ['for' => 'active'],
- 'attr' => array()
- ]
- );
- }
-}
diff --git a/local/modules/LivraisonParSecteurs/Form/GeneralForm.php b/local/modules/LivraisonParSecteurs/Form/GeneralForm.php
new file mode 100644
index 00000000..eef6a5ba
--- /dev/null
+++ b/local/modules/LivraisonParSecteurs/Form/GeneralForm.php
@@ -0,0 +1,57 @@
+formBuilder
+ ->add(
+ "area_id",
+ "integer",
+ [
+ "required" => true,
+ "constraints" => [new Constraints\NotBlank()]
+ ])
+ ->add(
+ "price",
+ "number",
+ [
+ "required" => true,
+ "constraints" => [new GreaterThanOrEqual(["value" => 0])],
+ "label" => $this->translator->trans('Delivery price', [], LivraisonParSecteurs::DOMAIN_NAME),
+ "label_attr" => ['for' => 'price']
+ ])
+ ->add(
+ "active",
+ "number",
+ [
+ "required" => true,
+ "constraints" => [new Constraints\NotBlank()],
+ "label" => $this->translator->trans('Active', [], LivraisonParSecteurs::DOMAIN_NAME),
+ "label_attr" => ['for' => 'active']
+ ]
+ );
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getName()
+ {
+ return "lps-area-general-update";
+ }
+}
diff --git a/local/modules/LivraisonParSecteurs/Form/ScheduleForm.php b/local/modules/LivraisonParSecteurs/Form/ScheduleForm.php
new file mode 100644
index 00000000..7b5189e6
--- /dev/null
+++ b/local/modules/LivraisonParSecteurs/Form/ScheduleForm.php
@@ -0,0 +1,40 @@
+formBuilder
+ ->add(
+ 'price',
+ 'number',
+ [
+ 'constraints' => [new Constraints\NotBlank()],
+ 'required' => true,
+ 'label' => $this->translator->trans('Delivery price', [], LivraisonParSecteurs::DOMAIN_NAME),
+ 'label_attr' => ['for' => 'price'],
+ 'attr' => array()
+ ]);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getName()
+ {
+ return "lps-area-schedule.update";
+ }
+}
diff --git a/local/modules/LivraisonParSecteurs/I18n/fr_FR.php b/local/modules/LivraisonParSecteurs/I18n/fr_FR.php
index 5d405cc9..1fb4f419 100644
--- a/local/modules/LivraisonParSecteurs/I18n/fr_FR.php
+++ b/local/modules/LivraisonParSecteurs/I18n/fr_FR.php
@@ -5,7 +5,7 @@ return array(
'Area name' => 'Nom du secteur',
'Cities' => 'Communes couvertes',
'Delivery days' => 'Jours de livraison',
- 'Delivery price' => 'Prix de la livraison',
+ 'Delivery price' => 'Frais de livraison',
'Edit an area' => 'Modifier le secteur',
'General' => 'Général',
'Home delivery cost' => 'Frais de livraison à domicile',
diff --git a/local/modules/LivraisonParSecteurs/Model/LpsArea.php b/local/modules/LivraisonParSecteurs/Model/LpsArea.php
deleted file mode 100644
index 85a202f5..00000000
--- a/local/modules/LivraisonParSecteurs/Model/LpsArea.php
+++ /dev/null
@@ -1,20 +0,0 @@
-
{assign "area_id" $smarty.get.area_id}
- {if $form_error}
- {$form_error_message}
- {/if}
-
-
- {include
- file = "includes/inner-form-toolbar.html"
- hide_submit_buttons = false
- pageUrl = "{url path='/admin/module/LivraisonParSecteurs/edit' area_id=$area_id}"
- closeUrl = "{url path='/admin/module/LivraisonParSecteurs'}"
- current_tab = "general"
- }
-
-
{intl l='Edit an area' d='livraisonparsecteurs'} : {loop name="area" type="lps_area" id={$area_id}}{$TITLE}{/loop}
@@ -60,11 +46,19 @@
{/hookblock}
+
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
+
{/javascripts}
{/block}
diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html
index 171975e0..aacf38b2 100644
--- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html
+++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html
@@ -32,7 +32,7 @@
{intl l="Active" d='livraisonparsecteurs'} |
{intl l="Delivery price" d='livraisonparsecteurs'} |
{intl l="Delivery days" d='livraisonparsecteurs'} |
- {intl l="Actions" d='livraisonparsecteurs'} |
+ |
@@ -49,12 +49,12 @@
{$PRICE} € |
{$DELIVERY_DAYS} |
-
-
-
+
+
diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-general.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-general.html
index affdff19..d5459d2b 100644
--- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-general.html
+++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-general.html
@@ -1,49 +1,60 @@
-
-
-
+{form name='lps-area-general-update'}
+ | |