diff --git a/local/modules/LivraisonParSecteurs/Config/config.xml b/local/modules/LivraisonParSecteurs/Config/config.xml index 3a5fac10..d30eb69a 100644 --- a/local/modules/LivraisonParSecteurs/Config/config.xml +++ b/local/modules/LivraisonParSecteurs/Config/config.xml @@ -21,7 +21,6 @@ - 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 new file mode 100644 index 00000000..10b2e284 --- /dev/null +++ b/local/modules/LivraisonParSecteurs/Config/thelia.sql @@ -0,0 +1,72 @@ + +# 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; + +-- --------------------------------------------------------------------- +-- lps_area +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `lps_area`; + +CREATE TABLE `lps_area` +( + `id` INTEGER NOT NULL, + `title` VARCHAR(50) NOT NULL, + `active` TINYINT DEFAULT 1 NOT NULL, + `price` FLOAT DEFAULT 0 NOT NULL, + `minimum_amount` FLOAT DEFAULT 15 NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`) +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- lps_area_city +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `lps_area_city`; + +CREATE TABLE `lps_area_city` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `id_area` INTEGER NOT NULL, + `zipcode` VARCHAR(10) NOT NULL, + `title` VARCHAR(50) NOT NULL, + `latitude` DOUBLE, + `longitude` DOUBLE, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `fi_area_area_city` (`id_area`), + CONSTRAINT `fk_area_area_city` + FOREIGN KEY (`id_area`) + REFERENCES `lps_area` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- lps_area_schedule +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `lps_area_schedule`; + +CREATE TABLE `lps_area_schedule` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `id_area` INTEGER NOT NULL, + `day` INTEGER NOT NULL, + `begin_time` TIME NOT NULL, + `end_time` TIME NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `fi_area_area_schedule` (`id_area`), + CONSTRAINT `fk_area_area_schedule` + FOREIGN KEY (`id_area`) + REFERENCES `lps_area` (`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/Form/GeneralForm.php b/local/modules/LivraisonParSecteurs/Form/GeneralForm.php index f20e5120..dee9ce62 100644 --- a/local/modules/LivraisonParSecteurs/Form/GeneralForm.php +++ b/local/modules/LivraisonParSecteurs/Form/GeneralForm.php @@ -26,6 +26,15 @@ class GeneralForm extends BaseForm "required" => true, "constraints" => [new Constraints\NotBlank()] ]) + ->add( + "title", + "text", + [ + "required" => true, + "constraints" => [new Constraints\NotBlank(), new Constraints\NotNull()], + "label" => $this->translator->trans('Area name', [], LivraisonParSecteurs::DOMAIN_NAME), + "label_attr" => ['for' => 'title'] + ]) ->add( "price", "number", diff --git a/local/modules/LivraisonParSecteurs/Hook/AdminHook.php b/local/modules/LivraisonParSecteurs/Hook/AdminHook.php index 3bf96997..a18aa6a9 100644 --- a/local/modules/LivraisonParSecteurs/Hook/AdminHook.php +++ b/local/modules/LivraisonParSecteurs/Hook/AdminHook.php @@ -87,7 +87,7 @@ class AdminHook extends BaseHook "id" => "block-scheduled-deliveries", "title" => $this->trans("Scheduled deliveries", [], LivraisonParSecteurs::DOMAIN_NAME), "content" => $content, - "class" => "col-md-8" + "class" => "col-md-6" ]); } } diff --git a/local/modules/LivraisonParSecteurs/I18n/fr_FR.php b/local/modules/LivraisonParSecteurs/I18n/fr_FR.php index b08c3bd5..02b2397d 100644 --- a/local/modules/LivraisonParSecteurs/I18n/fr_FR.php +++ b/local/modules/LivraisonParSecteurs/I18n/fr_FR.php @@ -26,7 +26,7 @@ return array( 'General' => 'Général', 'Home delivery cost' => 'Frais de livraison à domicile', 'Message info minimum de commande' => 'Un panier d\'un montant minimum de %montant € est nécessaire pour pouvoir bénéficier de la livraison à domicile.', - 'Minimum amount' => 'Montant minimum de commande', + 'Minimum amount' => 'Minimum de commande', 'Modify a delivery day' => 'Modifier un jour de livraison', 'Module name' => 'Livraison à domicile', 'My areas' => 'Mes secteurs de livraison', @@ -42,12 +42,12 @@ return array( 'There is no order to deliver' => 'Aucune commande à livrer à domicile', 'There is no schedule for this area' => 'Aucune livraison actuellement sur ce secteur', 'Title of config view' => 'Livraison à domicile - Configuration', - 'Zipcode' => 'Code postal', - 'Monday' => 'Lundi', + 'Zipcode' => 'Code postal', 'Monday' => 'Lundi', 'Tuesday' => 'Mardi', 'Wednesday' => 'Mercredi', 'Thursday' => 'Jeudi', 'Friday' => 'Vendredi', 'Saturday' => 'Samedi', 'Sunday' => 'Dimanche', + ); diff --git a/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php b/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php index 580f4510..4de5ef0f 100644 --- a/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php +++ b/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php @@ -7,7 +7,6 @@ use LivraisonParSecteurs\Model\LpsAreaCityQuery; use LivraisonParSecteurs\Model\LpsAreaQuery; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Propel; -use Symfony\Component\Form\FormError; use Thelia\Core\Translation\Translator; use Thelia\Install\Database; use Thelia\Model\AddressQuery; @@ -82,7 +81,6 @@ class LivraisonParSecteurs extends AbstractDeliveryModule } } } -$isValid = true; return $isValid; } diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html index dbc6423f..69750c3f 100644 --- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/deliveryarea-list.html @@ -1,4 +1,4 @@ -{extends file="admin-layout.tpl"} +mais{extends file="admin-layout.tpl"} {block name="no-return-functions"} {$admin_current_location = 'module'} 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 5469b428..682daf55 100644 --- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-general.html +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-general.html @@ -1,4 +1,10 @@ {form name='lps-area-general-update'} + + +
{if $form_error} @@ -24,6 +30,18 @@
+ {form_field form=$form field="title"} +
+ +   +
+ {form_error form=$form field="title"}{$message}{/form_error} + {/form_field} +
+ +
{form_field form=$form field="active"}
-
+
{form_field form=$form field="price"}
-  € +  €
{form_error form=$form field="price"}{$message}{/form_error} {/form_field} @@ -62,14 +80,12 @@ {if $required}*{/if} -  € +  €
{form_error form=$form field="minimum_amount"}{$message}{/form_error} {/form_field}
-
 
-
{/loop} diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/scheduled-deliveries.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/scheduled-deliveries.html index 1b4af8b0..1ea9d47e 100644 --- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/scheduled-deliveries.html +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/scheduled-deliveries.html @@ -16,7 +16,6 @@ -{loop type="auth" name="can_view" role="ADMIN" module="HookAdminHome" access="VIEW"}
@@ -28,7 +27,7 @@ - {loop name="deliveries-loop" type="scheduled_deliveries" order="date"} + {loop name="deliveries-loop" type="scheduled_deliveries" domicile_ou_retrait="domicile" only_future="true" order="date"} {if $DELTA <= 7} {assign var=path value="{image file='/assets/img/flag-green.png'}"} {assign var=alt value='Drapeau vert'} @@ -84,4 +83,3 @@ Total :  {$nbCommandes}  commande(s) -{/loop} \ No newline at end of file diff --git a/local/modules/PlanificationLivraison/Config/schema.xml b/local/modules/PlanificationLivraison/Config/schema.xml index 3ee198dc..c9f13b24 100644 --- a/local/modules/PlanificationLivraison/Config/schema.xml +++ b/local/modules/PlanificationLivraison/Config/schema.xml @@ -1,9 +1,10 @@
{intl l="Area" d="livraisonparsecteurs"}
- + - + + @@ -15,6 +16,9 @@ + + + @@ -22,5 +26,6 @@
+ diff --git a/local/modules/PlanificationLivraison/Config/thelia.sql b/local/modules/PlanificationLivraison/Config/thelia.sql index 5305b9a9..13abe44e 100644 --- a/local/modules/PlanificationLivraison/Config/thelia.sql +++ b/local/modules/PlanificationLivraison/Config/thelia.sql @@ -13,13 +13,15 @@ CREATE TABLE `order_delivery_schedule` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `order_id` INTEGER, - `delivery_address_id` INTEGER NOT NULL, + `delivery_address_id` INTEGER, + `delivery_place_id` INTEGER, `schedule_id` INTEGER NOT NULL, `due_delivery_time_start` DATETIME NOT NULL, `due_delivery_time_end` DATETIME NOT NULL, PRIMARY KEY (`id`), INDEX `fi_order_delivery_schedule_order_id` (`order_id`), INDEX `fi_order_delivery_address_id` (`delivery_address_id`), + INDEX `fi_order_delivery_place_id` (`delivery_place_id`), INDEX `fi_order_delivery_schedule_id` (`schedule_id`), CONSTRAINT `fk_order_delivery_schedule_order_id` FOREIGN KEY (`order_id`) @@ -27,6 +29,9 @@ CREATE TABLE `order_delivery_schedule` CONSTRAINT `fk_order_delivery_address_id` FOREIGN KEY (`delivery_address_id`) REFERENCES `order_address` (`id`), + CONSTRAINT `fk_order_delivery_place_id` + FOREIGN KEY (`delivery_place_id`) + REFERENCES `pdr_places` (`id`), CONSTRAINT `fk_order_delivery_schedule_id` FOREIGN KEY (`schedule_id`) REFERENCES `lps_area_schedule` (`id`) diff --git a/local/modules/PlanificationLivraison/Loop/ScheduledDeliveriesLoop.php b/local/modules/PlanificationLivraison/Loop/ScheduledDeliveriesLoop.php index e6e87030..61afb467 100644 --- a/local/modules/PlanificationLivraison/Loop/ScheduledDeliveriesLoop.php +++ b/local/modules/PlanificationLivraison/Loop/ScheduledDeliveriesLoop.php @@ -4,6 +4,7 @@ namespace PlanificationLivraison\Loop; use DateTime; use PlanificationLivraison\Model\OrderDeliveryScheduleQuery; +use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; @@ -17,9 +18,12 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; */ class ScheduledDeliveriesLoop extends BaseLoop implements PropelSearchLoopInterface { - public $countable = true; + const DOMICILE = "domicile"; + const RETRAIT = "retrait"; + public $countable = true; + /** * @param LoopResult $loopResult * @@ -35,22 +39,30 @@ class ScheduledDeliveriesLoop extends BaseLoop implements PropelSearchLoopInterf $loopResultRow ->set("ORDER_ID", $deliveries->getOrderId()) + ->set("ADDRESS_ID", $deliveries->getDeliveryAddressId()) + ->set("PLACE_ID", $deliveries->getDeliveryPlaceId()) + ->set("SCHEDULE_ID", $deliveries->getScheduleId()) ->set("START_DATE", $deliveries->getDueDeliveryTimeStart()) ->set("END_DATE", $deliveries->getDueDeliveryTimeEnd()) ->set("DELTA", $delta->days) - ->set("SCHEDULE_ID", $deliveries->getScheduleId()) ; $loopResult->addRow($loopResultRow); } return $loopResult; } + /** * @inheritdoc */ protected function getArgDefinitions() { return new ArgumentCollection( + Argument::createEnumListTypeArgument('domicile_ou_retrait', [ + self::DOMICILE, + self::RETRAIT + ], self::DOMICILE), + Argument::createBooleanTypeArgument('only_future', true), Argument::createEnumListTypeArgument('order', [ 'date', 'date-reverse' @@ -64,9 +76,35 @@ class ScheduledDeliveriesLoop extends BaseLoop implements PropelSearchLoopInterf public function buildModelCriteria() { $deliveries = OrderDeliveryScheduleQuery::create(); - $deliveries->filterByDueDeliveryTimeStart(array('min' => time()))->find(); - return $deliveries->orderByDueDeliveryTimeStart(); + foreach ($this->getDomicileOuRetrait() as $parametre) { + switch ($parametre) { + case self::DOMICILE: + $deliveries->filterByDeliveryAddressId(null, Criteria::NOT_EQUAL); + break; + case self::RETRAIT: + $deliveries->filterByDeliveryPlaceId(null, Criteria::NOT_EQUAL); + break; + } + } + + if ($this->getOnlyFuture()) + $deliveries->filterByDueDeliveryTimeStart(array('min' => time()))->find(); + else + $deliveries->filterByDueDeliveryTimeStart(array('max' => time()))->find(); + + foreach ($this->getOrder() as $parametre) { + switch ($parametre) { + case 'date': + $deliveries->orderByDueDeliveryTimeStart(Criteria::ASC); + break; + case 'date-reverse': + $deliveries->orderByDueDeliveryTimeStart(Criteria::DESC); + break; + } + } + + return $deliveries; } } diff --git a/local/modules/PointRetrait/Config/config.xml b/local/modules/PointRetrait/Config/config.xml index 68790e42..d85852cb 100644 --- a/local/modules/PointRetrait/Config/config.xml +++ b/local/modules/PointRetrait/Config/config.xml @@ -4,31 +4,21 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd"> + + + + + + + + - + + - +
- - - - - diff --git a/local/modules/PointRetrait/Config/routing.xml b/local/modules/PointRetrait/Config/routing.xml index 5e018bc2..f50d2344 100644 --- a/local/modules/PointRetrait/Config/routing.xml +++ b/local/modules/PointRetrait/Config/routing.xml @@ -4,28 +4,17 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - diff --git a/local/modules/PointRetrait/Config/schema.xml b/local/modules/PointRetrait/Config/schema.xml index 822ac883..49fc907b 100644 --- a/local/modules/PointRetrait/Config/schema.xml +++ b/local/modules/PointRetrait/Config/schema.xml @@ -2,24 +2,34 @@ - + + + + + + + + + + + + +
+ +
diff --git a/local/modules/PointRetrait/Config/sqldb.map b/local/modules/PointRetrait/Config/sqldb.map new file mode 100644 index 00000000..63a93baa --- /dev/null +++ b/local/modules/PointRetrait/Config/sqldb.map @@ -0,0 +1,2 @@ +# Sqlfile -> Database map +thelia.sql=thelia diff --git a/local/modules/PointRetrait/Config/thelia.sql b/local/modules/PointRetrait/Config/thelia.sql new file mode 100644 index 00000000..a00460f3 --- /dev/null +++ b/local/modules/PointRetrait/Config/thelia.sql @@ -0,0 +1,51 @@ + +# 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; + +-- --------------------------------------------------------------------- +-- pdr_places +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `pdr_places`; + +CREATE TABLE `pdr_places` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `title` VARCHAR(50) NOT NULL, + `active` TINYINT DEFAULT 1 NOT NULL, + `price` FLOAT DEFAULT 0 NOT NULL, + `minimum_amount` FLOAT DEFAULT 0 NOT NULL, + `latitude` DOUBLE, + `longitude` DOUBLE, + `address1` VARCHAR(255) NOT NULL, + `address2` VARCHAR(255), + `address3` VARCHAR(255), + `zipcode` VARCHAR(10) NOT NULL, + `city` VARCHAR(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- pdr_schedule +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `pdr_schedule`; + +CREATE TABLE `pdr_schedule` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `id_place` INTEGER NOT NULL, + `day` INTEGER NOT NULL, + `begin_time` TIME NOT NULL, + `end_time` TIME NOT NULL, + PRIMARY KEY (`id`), + INDEX `fi_places_schedule` (`id_place`), + CONSTRAINT `fk_places_schedule` + FOREIGN KEY (`id_place`) + REFERENCES `pdr_places` (`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/PointRetrait/Form/MainForm.php b/local/modules/PointRetrait/Form/MainForm.php new file mode 100644 index 00000000..b2d46307 --- /dev/null +++ b/local/modules/PointRetrait/Form/MainForm.php @@ -0,0 +1,86 @@ +formBuilder + ->add( + "place_id", + "integer", + [ + "required" => true, + "constraints" => [new Constraints\NotBlank()] + ]) + ->add( + "title", + "text", + [ + "required" => true, + "constraints" => [new Constraints\NotBlank(), new Constraints\NotNull()], + "label" => $this->translator->trans('Place', [], PointRetrait::DOMAIN_NAME), + "label_attr" => ['for' => 'title'] + ]) + ->add( + "price", + "number", + [ + "required" => true, + "constraints" => [new GreaterThanOrEqual(["value" => 0])], + "label" => $this->translator->trans('Withdrawal price', [], PointRetrait::DOMAIN_NAME), + "label_attr" => ['for' => 'price'] + ]) + ->add( + "minimum_amount", + "number", + [ + "required" => true, + "constraints" => [new GreaterThanOrEqual(["value" => 0])], + "label" => $this->translator->trans('Minimum amount', [], PointRetrait::DOMAIN_NAME), + "label_attr" => ['for' => 'minimum_amount'] + ]) + ->add("latitude", "number", [ + "label" => $this->translator->trans("Latitude", [], PointRetrait::MESSAGE_DOMAIN), + "label_attr" => ["for" => "latitude"], + "required" => false + ]) + ->add("longitude", "number", [ + "label" => $this->translator->trans("Longitude", [], PointRetrait::MESSAGE_DOMAIN), + "label_attr" => ["for" => "longitude"], + "required" => false + ]) + ->add( + "active", + "number", + [ + "required" => true, + "constraints" => [new Constraints\NotBlank()], + "label" => $this->translator->trans('Active', [], PointRetrait::DOMAIN_NAME), + "label_attr" => ['for' => 'active'] + ] + ); + } + + /** + * @inheritDoc + */ + public function getName() + { + return "pdr-place-main-update"; + } +} diff --git a/local/modules/PointRetrait/Hook/AdminHook.php b/local/modules/PointRetrait/Hook/AdminHook.php new file mode 100644 index 00000000..4d887883 --- /dev/null +++ b/local/modules/PointRetrait/Hook/AdminHook.php @@ -0,0 +1,54 @@ +securityContext = $securityContext; + } + + + public function onMainTopMenuTools(HookRenderEvent $event) + { + $isGranted = $this->securityContext->isGranted( + ["ADMIN"], + [], + [PointRetrait::getModuleCode()], + [AccessManager::VIEW] + ); + + if ($isGranted) { + $event->add($this->render("menu-hook.html", $event->getArguments())); + } + } + + + /* Pour afficher la liste des retraits en Point Retrait prévus dans la page d'accueil backOffice */ + public function displayScheduledWithdrawals(HookRenderBlockEvent $event) + { + $content = trim($this->render("scheduled-withdrawals.html")); + if (!empty($content)) { + $event->add([ + "id" => "block-scheduled-withdrawals", + "title" => $this->trans("Scheduled withdrawals", [], PointRetrait::DOMAIN_NAME), + "content" => $content, + "class" => "col-md-6" + ]); + } + } + +} diff --git a/local/modules/PointRetrait/I18n/fr_FR.php b/local/modules/PointRetrait/I18n/fr_FR.php index 37086245..50ffe383 100644 --- a/local/modules/PointRetrait/I18n/fr_FR.php +++ b/local/modules/PointRetrait/I18n/fr_FR.php @@ -1,4 +1,29 @@ 'La traduction française de la chaine', -); + 'Active' => 'Actif', + 'Delivery delay' => 'Délai avant retrait', + 'Edit a place' => 'Modifier un lieu de retrait', + 'Location set' => 'Coordonnées GPS présentes ?', + 'Main' => 'Généralités', + 'Minimum amount' => 'Minimum de commande', + 'Module name' => 'Point de Retrait AuxBieauxLegumes', + 'My places' => 'Point de retrait AuxBieauxLegumes', + 'My withdrawal places' => 'Mes points de retrait AuxBieauxLegumes', + 'Order number' => 'N° de commande', + 'Place' => 'Lieu de retrait', + 'Schedule' => 'Horaires de retrait', + 'Scheduled date' => 'Date de retrait prévue', + 'Scheduled withdrawals' => 'Commandes à retirer en Point Retrait', + 'Title of config view' => 'Point retrait AuxBieauxLegumes - Configuration', + 'There is no order to withdraw' => 'Aucune commande à retirer en Point Retrait', + 'Withdrawal days' => 'Jours de retrait', + 'Withdrawal price' => 'Coût du retrait', + 'Monday' => 'Lundi', + 'Tuesday' => 'Mardi', + 'Wednesday' => 'Mercredi', + 'Thursday' => 'Jeudi', + 'Friday' => 'Vendredi', + 'Saturday' => 'Samedi', + 'Sunday' => 'Dimanche', + '' => '', + ); diff --git a/local/modules/PointRetrait/Loop/GeneralLoop.php b/local/modules/PointRetrait/Loop/GeneralLoop.php new file mode 100644 index 00000000..a1606010 --- /dev/null +++ b/local/modules/PointRetrait/Loop/GeneralLoop.php @@ -0,0 +1,89 @@ +getResultDataCollection() as $places) { + + $loopResultRow = new LoopResultRow($places); + + $schedule = PdrScheduleQuery::create()->findById($places->getId()); + $deliveryDays = ""; + foreach ($schedule as $day) { + $deliveryDays .= PointRetrait::getDayLabel($day->getDay()) . ', '; + } + $deliveryDays = substr($deliveryDays, 0, strlen($deliveryDays)-2); + + + $loopResultRow + ->set("ID", $places->getId()) + ->set("TITLE", $places->getTitle()) + ->set("ACTIVE", $places->getActive()) + ->set("PRICE", $places->getPrice()) + ->set("MINIMUM_AMOUNT", $places->getMinimumAmount()) + ->set("DELIVERY_DAYS", $deliveryDays) + ->set("LATITUDE", $places->getLatitude()) + ->set("LONGITUDE", $places->getLongitude()) + ; + $loopResult->addRow($loopResultRow); + } + return $loopResult; + } + + /** + * @inheritdoc + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('active') + ); + } + + /** + * @inheritdoc + */ + public function buildModelCriteria() + { + $places = PdrPlacesQuery::create(); + + /* Filtrage éventuel */ + if (null != $id = $this->getId()) { + $places->filterById($id); + } + if (null != $active = $this->getActive()) { + $places->filterByActive($active); + } + + return $places->orderByTitle(); + } + +} diff --git a/local/modules/PointRetrait/Loop/ScheduleLoop.php b/local/modules/PointRetrait/Loop/ScheduleLoop.php new file mode 100644 index 00000000..58654db1 --- /dev/null +++ b/local/modules/PointRetrait/Loop/ScheduleLoop.php @@ -0,0 +1,78 @@ +getResultDataCollection() as $pdr_schedule) { + + $loopResultRow = new LoopResultRow($pdr_schedule); + $loopResultRow + ->set("ID", $pdr_schedule->getId()) + ->set("PLACE_ID", $pdr_schedule->getIdArea()) + ->set("DAY", $pdr_schedule->getDay()) + ->set("DAY_LABEL", PointRetrait::getDayLabel($pdr_schedule->getDay())) + ->set("BEGIN", $pdr_schedule->getBeginTime()) + ->set("END", $pdr_schedule->getEndTime()) + ; + $loopResult->addRow($loopResultRow); + } + return $loopResult; + } + + + /** + * @inheritdoc + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('place_id') + ); + } + + + /** + * @inheritdoc + */ + public function buildModelCriteria() + { + $places = PdrScheduleQuery::create(); + if (null != $id = $this->getId()) { + $places->filterById($id); + } + if (null != $id = $this->getPlaceId()) { + $places->filterByIdPlace($id); + } + + return $places->orderByDay()->orderByBeginTime(); + } + +} diff --git a/local/modules/PointRetrait/Model/PdrPlaces.php b/local/modules/PointRetrait/Model/PdrPlaces.php new file mode 100644 index 00000000..5e89b70a --- /dev/null +++ b/local/modules/PointRetrait/Model/PdrPlaces.php @@ -0,0 +1,20 @@ +getWrappedConnection()); + $database->insertSql(null, array(__DIR__ . '/Config/thelia.sql')); + } + + + /** + * This method is called by the Delivery loop, to check if the current module has to be displayed to the customer. + * Override it to implements your delivery rules/ + * + * If you return true, the delivery method will de displayed to the customer + * If you return false, the delivery method will not be displayed + * + * @param Country $country the country to deliver to. + * + * @return boolean + */ + public function isValidDelivery(Country $country) + { + return true; + } + + + /** + * Calculate and return delivery price in the shop's default currency + * + * @param Country $country the country to deliver to. + * + * @return OrderPostage|float the delivery price + * @throws DeliveryException if the postage price cannot be calculated. + */ + public function getPostage(Country $country) + { + if (! $this->isValidDelivery($country)) { + throw new DeliveryException( + Translator::getInstance()->trans("This module cannot be used on the current cart.") + ); + } + + $price = 0; + $con = Propel::getConnection(); +// $currentAddressId = $this->getRequest()->getSession()->getOrder()->getChoosenDeliveryAddress(); +// if (!empty($currentAddressId)) { +// $zipcode = AddressQuery::create()->filterById($currentAddressId)->findOne($con)->getZipcode(); +// $areaId = LpsAreaCityQuery::create()->findOneByZipcode($zipcode)->getIdArea(); +// $price = LpsAreaQuery::create()->findOneById($areaId)->getPrice(); +// } + + return $price; + } + + + static public function getDayLabel($int) + { + $translator = Translator::getInstance(); + + $days = [ + $translator->trans("Monday", [], PointRetrait::MESSAGE_DOMAIN), + $translator->trans("Tuesday", [], PointRetrait::MESSAGE_DOMAIN), + $translator->trans("Wednesday", [], PointRetrait::MESSAGE_DOMAIN), + $translator->trans("Thursday", [], PointRetrait::MESSAGE_DOMAIN), + $translator->trans("Friday", [], PointRetrait::MESSAGE_DOMAIN), + $translator->trans("Saturday", [], PointRetrait::MESSAGE_DOMAIN), + $translator->trans("Sunday", [], PointRetrait::MESSAGE_DOMAIN) + ]; + + if ($int === null) + return $days; + else + return $days[$int]; + } + } diff --git a/local/modules/PointRetrait/templates/backOffice/default/includes/main.html b/local/modules/PointRetrait/templates/backOffice/default/includes/main.html new file mode 100644 index 00000000..ffe3e97c --- /dev/null +++ b/local/modules/PointRetrait/templates/backOffice/default/includes/main.html @@ -0,0 +1,151 @@ + + +{form name='pdr-place-main-update'} +
+ + {if $form_error} +
{$form_error_message}
+ {/if} + + {loop name="places" type="pdr_places" id="$place_id"} + + {form_hidden_fields form=$form} + + {include + file = "includes/inner-form-toolbar.html" + hide_flags = true + hide_submit_buttons = false + page_url = "{url path='/admin/module/PointRetrait/edit' place_id=$place_id}" + close_url = "{url path='/admin/module/PointRetrait'}" + current_tab = "main" + } + + {form_field form=$form field="place_id"} + + {/form_field} + +
+ +
+
+ {form_field form=$form field="title"} +
+ +   +
+ {form_error form=$form field="title"}{$message}{/form_error} + {/form_field} +
+ +
+ {form_field form=$form field="active"} +
+ + +
+ +
+ +
+ {/form_field} +
+ +
+ {form_field form=$form field="price"} +
+ + +  € +
+ {form_error form=$form field="price"}{$message}{/form_error} + {/form_field} +
+ +
+ {form_field form=$form field="minimum_amount"} +
+ + +  € +
+ {form_error form=$form field="minimum_amount"}{$message}{/form_error} + {/form_field} +
+ +
+ {form_field form=$form field="latitude"} + + {/form_field} + {form_field form=$form field="longitude"} + + {/form_field} +
+ +
+ +
+
+ +
+
+
+ +
+ + {/loop} +
+{/form} diff --git a/local/modules/PointRetrait/templates/backOffice/default/js/main-js.html b/local/modules/PointRetrait/templates/backOffice/default/js/main-js.html new file mode 100644 index 00000000..d260a2e9 --- /dev/null +++ b/local/modules/PointRetrait/templates/backOffice/default/js/main-js.html @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/local/modules/PointRetrait/templates/backOffice/default/menu-hook.html b/local/modules/PointRetrait/templates/backOffice/default/menu-hook.html new file mode 100644 index 00000000..5fe31b79 --- /dev/null +++ b/local/modules/PointRetrait/templates/backOffice/default/menu-hook.html @@ -0,0 +1,3 @@ +
  • + {intl l='Module name' d='pointretrait'} +
  • \ No newline at end of file diff --git a/local/modules/PointRetrait/templates/backOffice/default/place-edit.html b/local/modules/PointRetrait/templates/backOffice/default/place-edit.html new file mode 100644 index 00000000..49075d7a --- /dev/null +++ b/local/modules/PointRetrait/templates/backOffice/default/place-edit.html @@ -0,0 +1,79 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='My places' d="pointretrait"}{/block} + +{block name="check-access"}update{/block} +{block name="check-module"}PointRetrait{/block} + +{block name="after-bootstrap-css"} + +{/block} + +{block name="main-content"} +
    + {assign "place_id" $smarty.get.place_id} + +
    +
    + {intl l="Edit a place" d="pointretrait"} : {loop name="places" type="pdr_places" id={$place_id}}{$TITLE}{/loop} +
    + + + +
    + {loop name="auth-general-tab" type="auth" role="ADMIN" resource="admin" access="VIEW" module="PointRetrait"} +
    + {include file="includes/main.html"} +
    + {/loop} + {loop name="auth-schedule-tab" type="auth" role="ADMIN" resource="admin.schedule" access="VIEW" module="PointRetrait"} +
    +{* + {include file="includes/schedule.html"} + *} +
    + {/loop} +
    +
    +
    + +{* +{include file="modal/schedule-modal.html"} +*} + +{/block} + +{block name="javascript-initialization"} +{javascripts file='assets/js/moment-with-locales.min.js'} + +{/javascripts} +{javascripts file='assets/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js'} + +{/javascripts} +{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + +{/javascripts} +{include file="js/main-js.html"} +{* +{include file="js/schedule-js.html"} +*} +{/block} diff --git a/local/modules/PointRetrait/templates/backOffice/default/places-list.html b/local/modules/PointRetrait/templates/backOffice/default/places-list.html new file mode 100644 index 00000000..83ac09f3 --- /dev/null +++ b/local/modules/PointRetrait/templates/backOffice/default/places-list.html @@ -0,0 +1,94 @@ +mais{extends file="admin-layout.tpl"} + +{block name="no-return-functions"} + {$admin_current_location = 'module'} +{/block} + +{block name="page-title"}{intl l='Title of config view' d='pointretrait'}{/block} + +{block name="check-resource"}admin.module{/block} +{block name="check-access"}view{/block} +{block name="check-module"}PointRetrait{/block} + +{block name="main-content"} +
    + + {if $general_error} +
    + {$general_error} +
    + {/if} + +
    +
    + + + + + + + + + + + + + + + + + {loop name="places" type="pdr_places"} + + + + + + + + + + {/loop} + + +
    + {intl l='My withdrawal places' d='pointretrait'} +
    {intl l="Place" d='pointretrait'}{intl l="Active" d='pointretrait'}{intl l="Withdrawal price" d='pointretrait'}{intl l="Minimum amount" d='pointretrait'}{intl l="Withdrawal days" d='pointretrait'}{intl l="Location set" d='pointretrait'} 
    {$TITLE} +
    + +
    +
    {$PRICE} €{$MINIMUM_AMOUNT} €{$DELIVERY_DAYS}{if $DELIVERY_DAYS eq ''}{intl l="There is no schedule for this place" d='pointretrait'}{/if}{if $LATITUDE != ''}Oui{else}Non{/if} + +
    +
    +
    +
    +{/block} + +{block name="javascript-initialization"} +{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + +{/javascripts} +{/block} diff --git a/local/modules/PointRetrait/templates/backOffice/default/scheduled-withdrawals.html b/local/modules/PointRetrait/templates/backOffice/default/scheduled-withdrawals.html new file mode 100644 index 00000000..ff2be328 --- /dev/null +++ b/local/modules/PointRetrait/templates/backOffice/default/scheduled-withdrawals.html @@ -0,0 +1,75 @@ + + + +
    + + + + + + + + + + {loop name="deliveries-loop" type="scheduled_deliveries" domicile_ou_retrait="retrait" only_future="true" order="date"} + {if $DELTA <= 7} + {assign var=path value="{image file='/assets/img/flag-green.png'}"} + {assign var=alt value='Drapeau vert'} + {/if} + {if $DELTA <= 4} + {assign var=path value="{image file='/assets/img/flag-orange.png'}"} + {assign var=alt value='Drapeau orange'} + {/if} + {if $DELTA <= 1} + {assign var=path value="{image file='/assets/img/flag-red.png'}"} + {assign var=alt value='Drapeau rouge'} + {/if} + {assign var=title value="{$DELTA} jour(s) de délai"} + + {loop name="order-loop" type="order" id={$ORDER_ID} customer="*"} + {loop type="customer" name="customer-loop" current="false" id=$CUSTOMER} + {assign var=client value="$FIRSTNAME $LASTNAME"} + {/loop} + {/loop} + + + + + + + + + {if $LOOP_COUNT == $LOOP_TOTAL}{assign var=nbCommandes value=$LOOP_TOTAL}{/if} + + {/loop} + {elseloop rel="deliveries-loop"} + + + + {/elseloop} + +
     {intl l="Order number" d="pointretrait"}{intl l="Scheduled date" d="pointretrait"}{intl l="Delivery delay" d="pointretrait"}{intl l="Place" d="pointretrait"}
    {$alt}{$ORDER_ID} + {format_date date=$START_DATE format="d/m/Y"} entre {format_date date=$START_DATE format="H\hi"} et {format_date date=$END_DATE format="H\hi"} + {$DELTA} jour(s)Point de retrait
    +
    + {intl l="There is no order to withdraw" d="pointretrait"} +
    +
    + Total :  {$nbCommandes}  commande(s) + +
    \ No newline at end of file