From 0bbab6b568d0f7559226e71b5fdd1ee60b17a4a9 Mon Sep 17 00:00:00 2001 From: TheCoreDev Date: Fri, 5 Mar 2021 19:00:53 +0100 Subject: [PATCH] PointRetrait : On avance pas mal sur le frontOffice --- .../LivraisonParSecteurs/Config/module.xml | 3 - .../LivraisonParSecteurs.php | 16 +-- .../Loop/selectedDeliveryDate.php | 66 ---------- .../default/includes/area-cities.html | 2 +- .../default/scheduled-deliveries.html | 20 +-- .../Controller/Configuration.php | 10 +- .../Form/Configuration.php | 58 ++++++++- .../PlanificationLivraison/I18n/fr_FR.php | 8 ++ .../PlanificationLivraison.php | 19 ++- .../default}/assets/img/drapeau-orange.png | Bin .../default}/assets/img/drapeau-rouge.png | Bin .../default}/assets/img/drapeau-vert.png | Bin .../default/module_configuration.html | 9 +- local/modules/PointRetrait/Config/config.xml | 1 + local/modules/PointRetrait/Config/module.xml | 3 - .../modules/PointRetrait/Loop/GeneralLoop.php | 18 ++- .../backOffice/default/includes/main.html | 2 +- .../default/scheduled-withdrawals.html | 20 +-- .../frontOffice/default/assets/css/styles.css | 65 ++++++++++ .../default/order-delivery-extra.html | 114 +++++++++++++----- 20 files changed, 276 insertions(+), 158 deletions(-) delete mode 100644 local/modules/LivraisonParSecteurs/Loop/selectedDeliveryDate.php rename {templates/backOffice/custom => local/modules/PlanificationLivraison/templates/backOffice/default}/assets/img/drapeau-orange.png (100%) rename {templates/backOffice/custom => local/modules/PlanificationLivraison/templates/backOffice/default}/assets/img/drapeau-rouge.png (100%) rename {templates/backOffice/custom => local/modules/PlanificationLivraison/templates/backOffice/default}/assets/img/drapeau-vert.png (100%) create mode 100644 local/modules/PointRetrait/templates/frontOffice/default/assets/css/styles.css diff --git a/local/modules/LivraisonParSecteurs/Config/module.xml b/local/modules/LivraisonParSecteurs/Config/module.xml index 25207301..5978655d 100644 --- a/local/modules/LivraisonParSecteurs/Config/module.xml +++ b/local/modules/LivraisonParSecteurs/Config/module.xml @@ -25,7 +25,4 @@ alpha 0 0 - - PlanificationLivraison - diff --git a/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php b/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php index d6914c33..50bce3f2 100644 --- a/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php +++ b/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php @@ -5,6 +5,7 @@ namespace LivraisonParSecteurs; use DateInterval; use LivraisonParSecteurs\Model\LpsAreaCityQuery; use LivraisonParSecteurs\Model\LpsAreaQuery; +use PlanificationLivraison\PlanificationLivraison; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Propel; use Thelia\Core\Translation\Translator; @@ -12,6 +13,8 @@ use Thelia\Install\Database; use Thelia\Model\AddressQuery; use Thelia\Model\ConfigQuery; use Thelia\Model\Country; +use Thelia\Model\ModuleConfigI18nQuery; +use Thelia\Model\ModuleConfigQuery; use Thelia\Model\OrderPostage; use Thelia\Module\AbstractDeliveryModule; use Thelia\Module\Exception\DeliveryException; @@ -22,14 +25,12 @@ class LivraisonParSecteurs extends AbstractDeliveryModule /** @var string */ const DOMAIN_NAME = 'livraisonparsecteurs'; const MESSAGE_DOMAIN = 'livraisonparsecteurs'; - const VARIABLE_MINIMUM_DELAY = 'minimum_delay_before_order'; const LPS_AREA_SCHEDULE_ID = 'lps_area_schedule_id'; const LPS_CHOSEN_ADDRESS = 'lps_chosen_delivery_address'; const LPS_DELIVERY_DATE = 'lps_delivery_date'; const LPS_DELIVERY_BEGIN_TIME = 'lps_begin_time'; const LPS_DELIVERY_END_TIME = 'lps_end_time'; const FORMAT_DATES = 'd/m/Y'; - const FORMAT_HEURES = 'H:i'; const FORMAT_DATE_COMPLETE = 'Y-m-d H:i:s'; const SECTEUR_ACTIF = 1; @@ -71,15 +72,7 @@ class LivraisonParSecteurs extends AbstractDeliveryModule // Condition 2 : le secteur doit être actif à date. if ($area->getActive() === self::SECTEUR_ACTIF) - { - // Condition 3 : le panier doit avoir atteint le minimum de commande pour ce secteur. -/* - $montantPanier = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getTaxedAmount($country); - $montantMinimum = $area->getMinimumAmount(); - if ($montantPanier >= $montantMinimum) -*/ $isValid = true; - } } } return $isValid; @@ -136,7 +129,8 @@ class LivraisonParSecteurs extends AbstractDeliveryModule static public function calculateRelativeDate($baseDay) { - $minimumDelayBeforeOrder = ConfigQuery::read(LivraisonParSecteurs::VARIABLE_MINIMUM_DELAY); + $minimumDelayBeforeOrder = PlanificationLivraison::getConfigValue(PlanificationLivraison::CONFIG_PREPARATION_DELAY, 0, "en_US"); + $date = new \DateTime(); $date->add(new DateInterval('P'. $minimumDelayBeforeOrder . 'D')); diff --git a/local/modules/LivraisonParSecteurs/Loop/selectedDeliveryDate.php b/local/modules/LivraisonParSecteurs/Loop/selectedDeliveryDate.php deleted file mode 100644 index 37413314..00000000 --- a/local/modules/LivraisonParSecteurs/Loop/selectedDeliveryDate.php +++ /dev/null @@ -1,66 +0,0 @@ -getOrderId()) - { - - if (null !== $order = OrderQuery::create()->findPk($orderId)) - { - return MondialRelayPickupAddressQuery::create() - ->filterByOrderAddressId($order->getDeliveryOrderAddressId()); - } - } - - return null; - } - - public function parseResults(LoopResult $loopResult) - { - foreach ($loopResult->getResultDataCollection() as $item) { - $loopResultRow = new LoopResultRow($item); - $loopResultRow - ->set("ID", $relayData['id']) - ->set("LATITUDE", $relayData['latitude']) - ->set("LONGITUDE", $relayData['longitude']) - ->set("ZIPCODE", $relayData['zipcode']) - ->set("CITY", $relayData['city']) - ->set("COUNTRY", $relayData['country']) - ->set("NAME", $relayData['name']) - ->set("ADDRESS", $relayData['address']) - ->set("DISTANCE", $relayData['distance']) - ->set("OPENINGS", $relayData['openings']) - ; - - $loopResult->addRow($loopResultRow); - } - - return $loopResult; - } -} 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 17e320cb..48978e19 100644 --- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-cities.html +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/includes/area-cities.html @@ -132,7 +132,7 @@
- +
NB : Les communes sans coordonnées GPS n'apparaitront pas sur la carte ci-dessus.
diff --git a/local/modules/LivraisonParSecteurs/templates/backOffice/default/scheduled-deliveries.html b/local/modules/LivraisonParSecteurs/templates/backOffice/default/scheduled-deliveries.html index 38d5fd6e..c8b3141c 100644 --- a/local/modules/LivraisonParSecteurs/templates/backOffice/default/scheduled-deliveries.html +++ b/local/modules/LivraisonParSecteurs/templates/backOffice/default/scheduled-deliveries.html @@ -28,17 +28,17 @@ {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/drapeau-vert.png'}"} - {assign var=alt value='Drapeau vert'} - {/if} - {if $DELTA <= 4} - {assign var=path value="{image file='assets/img/drapeau-orange.png'}"} - {assign var=alt value='Drapeau orange'} - {/if} - {if $DELTA <= 1} - {assign var=path value="{image file='assets/img/drapeau-rouge.png'}"} + {if $DELTA <= {module_config module="PlanificationLivraison" key='delay_red_alert' locale="en_US"}} + {assign var=path value="{image file='assets/img/drapeau-rouge.png' source='PlanificationLivraison'}"} {assign var=alt value='Drapeau rouge'} + {else} + {if $DELTA <= {module_config module="PlanificationLivraison" key='delay_orange_alert' locale="en_US"}} + {assign var=path value="{image file='assets/img/drapeau-orange.png' source='PlanificationLivraison'}"} + {assign var=alt value='Drapeau orange'} + {else} + {assign var=path value="{image file='assets/img/drapeau-vert.png' source='PlanificationLivraison'}"} + {assign var=alt value='Drapeau vert'} + {/if} {/if} {assign var=title value="{$DELTA} jour(s) de délai"} diff --git a/local/modules/PlanificationLivraison/Controller/Configuration.php b/local/modules/PlanificationLivraison/Controller/Configuration.php index 16544fb1..de35a1eb 100755 --- a/local/modules/PlanificationLivraison/Controller/Configuration.php +++ b/local/modules/PlanificationLivraison/Controller/Configuration.php @@ -33,10 +33,12 @@ class Configuration extends BaseAdminController $validateForm = $this->validateForm($form); $data = $validateForm->getData(); - PlanificationLivraison::setConfigValue( - PlanificationLivraison::CONFIG_VALUE_NAME, - $data["google_api_key"] - ); + PlanificationLivraison::setConfigValue(PlanificationLivraison::CONFIG_API_KEY, $data["google_api_key"]); + PlanificationLivraison::setConfigValue(PlanificationLivraison::CONFIG_MAP_CENTER_LAT, $data["map_center_lat"]); + PlanificationLivraison::setConfigValue(PlanificationLivraison::CONFIG_MAP_CENTER_LNG, $data["map_center_lng"]); + PlanificationLivraison::setConfigValue(PlanificationLivraison::CONFIG_RED_ALERT, $data["delay_red_alert"]); + PlanificationLivraison::setConfigValue(PlanificationLivraison::CONFIG_ORANGE_ALERT, $data["delay_orange_alert"]); + PlanificationLivraison::setConfigValue(PlanificationLivraison::CONFIG_PREPARATION_DELAY, $data["orders_preparation_delay"]); return $this->redirectToConfigurationPage(); diff --git a/local/modules/PlanificationLivraison/Form/Configuration.php b/local/modules/PlanificationLivraison/Form/Configuration.php index f10ebb22..bf4f82dc 100644 --- a/local/modules/PlanificationLivraison/Form/Configuration.php +++ b/local/modules/PlanificationLivraison/Form/Configuration.php @@ -16,12 +16,62 @@ class Configuration extends BaseForm { $this->formBuilder ->add( - "google_api_key", - "text", + "google_api_key","text", array( - "label" => "GoogleMap API key", + "label" => $this->translator->trans("GoogleMap API key", [], PlanificationLivraison::DOMAIN_NAME), "label_attr" => [ - "for" => "google_api_key" + "for" => "attr-google-api-key" + ], + "required" => true + )) + ->add( + "map_center_lat","text", + array( + "label" => $this->translator->trans("Map Center latitude", [], PlanificationLivraison::DOMAIN_NAME), + "label_attr" => [ + "for" => "attr-map-center-lat", + "help" => "Format 99.99999999 ou -99.9999999" + ], + "required" => true + )) + ->add( + "map_center_lng","text", + array( + "label" => $this->translator->trans("Map Center longitude", [], PlanificationLivraison::DOMAIN_NAME), + "label_attr" => [ + "for" => "attr-map-center-lng", + "help" => "Format 99.99999999 ou -99.9999999" + + ], + "required" => true + )) + ->add( + "delay_red_alert","number", + array( + "label" => $this->translator->trans("Red alert delay", [], PlanificationLivraison::DOMAIN_NAME), + "label_attr" => [ + "for" => "attr-map-center-lat", + "help" => $this->translator->trans("Help for red alert", [], PlanificationLivraison::DOMAIN_NAME) + ], + "required" => true + )) + ->add( + "delay_orange_alert","number", + array( + "label" => $this->translator->trans("Orange alert delay", [], PlanificationLivraison::DOMAIN_NAME), + "label_attr" => [ + "for" => "attr-delay_orange_alert", + "help" => $this->translator->trans("Help for orange alert", [], PlanificationLivraison::DOMAIN_NAME) + ], + "required" => true + )) + ->add( + "orders_preparation_delay","number", + array( + "label" => $this->translator->trans("Number of days needed for preparation", [], PlanificationLivraison::DOMAIN_NAME), + "label_attr" => [ + "for" => "attr-orders-preparation-delay", + "help" => $this->translator->trans("Help for preparation delay", [], PlanificationLivraison::DOMAIN_NAME) ], "required" => true ) diff --git a/local/modules/PlanificationLivraison/I18n/fr_FR.php b/local/modules/PlanificationLivraison/I18n/fr_FR.php index b6adb853..fd1e977d 100644 --- a/local/modules/PlanificationLivraison/I18n/fr_FR.php +++ b/local/modules/PlanificationLivraison/I18n/fr_FR.php @@ -1,5 +1,13 @@ 'Clé API GoogleMap', + 'Map Center latitude' => 'Latitude du centre de la carte', + 'Map Center longitude' => 'Longitude du centre de la carte', + 'Red alert delay' => 'Nombre de jours du seuil CRITIQUE', + 'Orange alert delay' => 'Nombre de jours du seuil URGENT', + 'Number of days needed for preparation' => 'Nombre de jours nécessaires pour préparation des commandes', + 'Help for red alert' => 'Si le délai entre la date du jour et la date de livraison/retrait prévue est inférieur à ce nombre de jours, la commande apparaitra comme CRITIQUE dans votre tableau de bord', + 'Help for orange alert' => 'Si le délai entre la date du jour et la date de livraison/retrait prévue est inférieur à ce nombre de jours, la commande apparaitra comme URGENTE dans votre tableau de bord', + 'Help for preparation delay' => 'Délai incompressible entre la commande client et la possibilité de livraison/retrait (achats des produits, préparation, ...)', 'Save' => 'Enregistrer', ); diff --git a/local/modules/PlanificationLivraison/PlanificationLivraison.php b/local/modules/PlanificationLivraison/PlanificationLivraison.php index e4e4fb7c..eedb4d30 100644 --- a/local/modules/PlanificationLivraison/PlanificationLivraison.php +++ b/local/modules/PlanificationLivraison/PlanificationLivraison.php @@ -1,14 +1,4 @@ {$form_error_message}{/if} - {render_form_field field="google_api_key" value={module_config module="PlanificationLivraison" key='planiflivraison_googlemap_api_key' locale="en_US"}} + {render_form_field field="google_api_key" value={module_config module="PlanificationLivraison" key='googlemap_api_key' locale="en_US"}} + {render_form_field field="map_center_lat" value={module_config module="PlanificationLivraison" key='map_center_latitude' locale="en_US"}} + {render_form_field field="map_center_lng" value={module_config module="PlanificationLivraison" key='map_center_longitude' locale="en_US"}} + + {render_form_field field="orders_preparation_delay" value={module_config module="PlanificationLivraison" key='orders_preparation_delay' locale="en_US"}} + + {render_form_field field="delay_red_alert" value={module_config module="PlanificationLivraison" key='delay_red_alert' locale="en_US"}} + {render_form_field field="delay_orange_alert" value={module_config module="PlanificationLivraison" key='delay_orange_alert' locale="en_US"}}