diff --git a/local/modules/LivraisonParSecteurs/Config/routing.xml b/local/modules/LivraisonParSecteurs/Config/routing.xml
new file mode 100644
index 00000000..3a963761
--- /dev/null
+++ b/local/modules/LivraisonParSecteurs/Config/routing.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ LivraisonParSecteurs\Controller\BackOfficeController::viewAction
+
+
+ LivraisonParSecteurs\Controller\BackOfficeController::updatePrice
+
+
+ LivraisonParSecteurs\Controller\BackOfficeController::toggleActive
+ \d+
+
+
+
diff --git a/local/modules/LivraisonParSecteurs/Config/sqldb.map b/local/modules/LivraisonParSecteurs/Config/sqldb.map
new file mode 100644
index 00000000..63a93baa
--- /dev/null
+++ b/local/modules/LivraisonParSecteurs/Config/sqldb.map
@@ -0,0 +1,2 @@
+# Sqlfile -> Database map
+thelia.sql=thelia
diff --git a/local/modules/LivraisonParSecteurs/Config/thelia.sql b/local/modules/LivraisonParSecteurs/Config/thelia.sql
index 8d9099c7..408d83c5 100644
--- a/local/modules/LivraisonParSecteurs/Config/thelia.sql
+++ b/local/modules/LivraisonParSecteurs/Config/thelia.sql
@@ -1,70 +1,48 @@
+
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
--- secteur
+-- lps_secteur
-- ---------------------------------------------------------------------
+
DROP TABLE IF EXISTS `lps_secteur`;
CREATE TABLE `lps_secteur`
(
- `id` INTEGER NOT NULL AUTO_INCREMENT,
- `nom` VARCHAR(50) NOT NULL
+ `id` INTEGER NOT NULL,
+ `nom` VARCHAR(50) NOT NULL,
+ `active` TINYINT DEFAULT 1 NOT NULL,
+ `created_at` DATETIME,
+ `updated_at` DATETIME,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
+INSERT INTO `lps_secteur`(`id`,`nom`) VALUES (1, 'Capso'), (2, 'Pays de Lumbres'), (3, 'Haut des Flanders'), (4, 'Flandres intérieur');
+
-- ---------------------------------------------------------------------
--- secteur_commune
+-- lps_secteur_commune
-- ---------------------------------------------------------------------
+
DROP TABLE IF EXISTS `lps_secteur_commune`;
CREATE TABLE `lps_secteur_commune`
(
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
`id_secteur` INTEGER NOT NULL,
- `zipcode` VARCHAR(10) NOT NULL
- PRIMARY KEY (`id_secteur`,`zipcode`)
- CONSTRAINT `fk_id_secteur`
+ `zipcode` VARCHAR(10) NOT NULL,
+ `created_at` DATETIME,
+ `updated_at` DATETIME,
+ PRIMARY KEY (`id`),
+ INDEX `fi_secteur_commune_secteur` (`id_secteur`),
+ CONSTRAINT `fk_secteur_commune_secteur`
FOREIGN KEY (`id_secteur`)
REFERENCES `lps_secteur` (`id`)
- ON UPDATE RESTRICT
- ON DELETE CASCADE,
- CONSTRAINT `fk_zipcode`
- FOREIGN KEY (`zipcode`)
- REFERENCES `address` (`zipcode`)
- ON UPDATE RESTRICT
ON DELETE CASCADE
) ENGINE=InnoDB;
--- ---------------------------------------------------------------------
--- secteur_horaires
--- ---------------------------------------------------------------------
-DROP TABLE IF EXISTS `lps_secteur_horaires`;
-
-CREATE TABLE `lps_secteur_horaires`
-(
- `id_secteur` INTEGER NOT NULL,
- `jour` TINYINT NOT NULL,
- `heure_debut` TIME NOT NULL,
- `heure_fin` TIME NOT NULL
- PRIMARY KEY (`id_secteur`,`jour`)
-) ENGINE=InnoDB;
-
-
-
-
--- ---------------------------------------------------------------------
--- Insertion des données
--- ---------------------------------------------------------------------
-INSERT INTO `secteur`(`id`,`nom`) VALUES
- (1, 'Capso'),
- (2, 'Pays de Lumbres'),
- (3, 'Haut des Flanders'),
- (4, 'Flandres intérieur')
-);
-
-
-INSERT INTO `secteur_commune`(`id_secteur`,`zipcode`) VALUES
+INSERT INTO `lps_secteur_commune`(`id_secteur`,`zipcode`) VALUES
(1,'62120'),
(1,'62129'),
(1,'62219'),
@@ -72,7 +50,9 @@ INSERT INTO `secteur_commune`(`id_secteur`,`zipcode`) VALUES
(1,'62510'),
(1,'62570'),
(1,'62575'),
-(1,'62910'),
+(1,'62910');
+
+INSERT INTO `lps_secteur_commune`(`id_secteur`,`zipcode`) VALUES
(2,'62010'),
(2,'62024'),
(2,'62088'),
@@ -91,9 +71,30 @@ INSERT INTO `secteur_commune`(`id_secteur`,`zipcode`) VALUES
(2,'62882'),
(2,'62897'),
(2,'62898'),
-(2,'62905')
-);
+(2,'62905');
+-- ---------------------------------------------------------------------
+-- lps_secteur_horaires
+-- ---------------------------------------------------------------------
+
+DROP TABLE IF EXISTS `lps_secteur_horaires`;
+
+CREATE TABLE `lps_secteur_horaires`
+(
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `id_secteur` INTEGER NOT NULL,
+ `jour` INTEGER NOT NULL,
+ `heure_debut` TIME NOT NULL,
+ `heure_fin` TIME NOT NULL,
+ `created_at` DATETIME,
+ `updated_at` DATETIME,
+ PRIMARY KEY (`id`),
+ INDEX `fi_secteur_horaires_secteur` (`id_secteur`),
+ CONSTRAINT `fk_secteur_horaires_secteur`
+ FOREIGN KEY (`id_secteur`)
+ REFERENCES `lps_secteur` (`id`)
+ ON DELETE CASCADE
+) ENGINE=InnoDB;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
diff --git a/local/modules/LivraisonParSecteurs/Controller/BackOfficeController.php b/local/modules/LivraisonParSecteurs/Controller/BackOfficeController.php
new file mode 100644
index 00000000..1a81e686
--- /dev/null
+++ b/local/modules/LivraisonParSecteurs/Controller/BackOfficeController.php
@@ -0,0 +1,28 @@
+render("secteurs");
+ }
+
+ public function toggleActive($params = [])
+ {
+ return $this->render("secteurs");
+ }
+
+ public function updatePrice($params = [])
+ {
+ return $this->render("secteurs");
+ }
+
+}
\ No newline at end of file
diff --git a/local/modules/LivraisonParSecteurs/Form/ConfigForm.php b/local/modules/LivraisonParSecteurs/Form/ConfigForm.php
new file mode 100644
index 00000000..03c32387
--- /dev/null
+++ b/local/modules/LivraisonParSecteurs/Form/ConfigForm.php
@@ -0,0 +1,30 @@
+formBuilder
+ ->add(
+ 'price',
+ 'number',
+ [
+ 'constraints' => [new Constraints\NotBlank()],
+ 'required' => true,
+ 'label' => $this->translator->trans('Price', [], LivraisonParSecteurs::DOMAIN_NAME),
+ 'label_attr' => ['for' => 'price'],
+ 'data' => LivraisonParSecteurs::getConfigValue('price', 0)
+ ]
+ );
+ }
+}
diff --git a/local/modules/LivraisonParSecteurs/Hook/AdminHook.php b/local/modules/LivraisonParSecteurs/Hook/AdminHook.php
new file mode 100644
index 00000000..1276dca0
--- /dev/null
+++ b/local/modules/LivraisonParSecteurs/Hook/AdminHook.php
@@ -0,0 +1,42 @@
+securityContext = $securityContext;
+ }
+
+ public function onModuleConfig(HookRenderEvent $event)
+ {
+ $isGranted = $this->securityContext->isGranted(
+ ["ADMIN"],
+ [],
+ [LivraisonParSecteurs::getModuleCode()],
+ [AccessManager::VIEW]
+ );
+
+ if ($isGranted) {
+ $event->add($this->render("secteurs.html", $event->getArguments()));
+ }
+ }
+
+ public function onModuleConfigJs(HookRenderEvent $event)
+ {
+ $event->add($this->render('script/livraisonparsecteurs-js.html'));
+ }
+
+}
diff --git a/local/modules/LivraisonParSecteurs/Loop/AreaLoop.php b/local/modules/LivraisonParSecteurs/Loop/AreaLoop.php
new file mode 100644
index 00000000..83001b31
--- /dev/null
+++ b/local/modules/LivraisonParSecteurs/Loop/AreaLoop.php
@@ -0,0 +1,66 @@
+getResultDataCollection() as $lps_area) {
+
+ $loopResultRow = new LoopResultRow($lps_area);
+ $loopResultRow
+ ->set("ID", $lps_area->getId())
+ ->set("NAME", $lps_area->getNom())
+ ->set("ACTIVE", $lps_area->getActive())
+ ->set("DELIVERY_DAYS", "Lundi....")
+ ;
+ $loopResult->addRow($loopResultRow);
+ }
+ return $loopResult;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function getArgDefinitions()
+ {
+ return new ArgumentCollection(
+ Argument::createIntListTypeArgument('id'),
+ Argument::createIntListTypeArgument('active')
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function buildModelCriteria()
+ {
+ $query = LpsSecteurQuery::create();
+
+ return $query->orderByNom();
+ }
+
+}
diff --git a/local/modules/LivraisonParSecteurs/Model/LpsSecteur.php b/local/modules/LivraisonParSecteurs/Model/LpsSecteur.php
new file mode 100644
index 00000000..9362e851
--- /dev/null
+++ b/local/modules/LivraisonParSecteurs/Model/LpsSecteur.php
@@ -0,0 +1,20 @@
+
+
+ {if $general_error}
+
+ {$general_error}
+
+ {/if}
+
+
+
+ {intl l="Home delivery cost" d='livraisonparsecteurs'}
+
+
+ {form name='livraisonparsecteurs.config_form'}
+
+ {/form}
+
+
+
+
+{/block}
+
+{block name="javascript-initialization"}
+{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
+
+
+{/javascripts}
+{/block}