From d05184bf053a8fb12c3dbbf8f78ac6b66eab3e87 Mon Sep 17 00:00:00 2001 From: TheCoreDev Date: Mon, 22 Feb 2021 17:09:05 +0100 Subject: [PATCH] LivraisonParSecteurs : rajout de quelques infos dans le template front --- .../LivraisonParSecteurs/Config/config.xml | 1 + .../LivraisonParSecteurs/Hook/FrontHook.php | 23 + .../LivraisonParSecteurs.php | 9 +- .../Loop/selectedDeliveryDate.php | 66 +++ .../frontOffice/default/delivery-address.html | 29 ++ .../default/order-delivery-extra.html | 2 - .../EventListeners/DeliveryListener.php | 81 ++- .../frontOffice/custom/order-invoice.html | 463 ++++++++++++++++++ .../frontOffice/default/order-invoice.html | 2 +- 9 files changed, 648 insertions(+), 28 deletions(-) create mode 100644 local/modules/LivraisonParSecteurs/Loop/selectedDeliveryDate.php create mode 100644 local/modules/LivraisonParSecteurs/templates/frontOffice/default/delivery-address.html create mode 100644 templates/frontOffice/custom/order-invoice.html diff --git a/local/modules/LivraisonParSecteurs/Config/config.xml b/local/modules/LivraisonParSecteurs/Config/config.xml index 8e5d45f6..816f76df 100644 --- a/local/modules/LivraisonParSecteurs/Config/config.xml +++ b/local/modules/LivraisonParSecteurs/Config/config.xml @@ -25,6 +25,7 @@ + diff --git a/local/modules/LivraisonParSecteurs/Hook/FrontHook.php b/local/modules/LivraisonParSecteurs/Hook/FrontHook.php index 6acb8f15..c55ad7f9 100644 --- a/local/modules/LivraisonParSecteurs/Hook/FrontHook.php +++ b/local/modules/LivraisonParSecteurs/Hook/FrontHook.php @@ -41,6 +41,29 @@ class FrontHook extends BaseHook ); } + + public function displayDeliveryDate(HookRenderEvent $event) + { + if ((null !== $order = $this->getSession()->getOrder()) && $order->getDeliveryModuleId() == LivraisonParSecteurs::getModuleId()) + { + $selectedDay = $this->getSession()->get(LivraisonParSecteurs::LPS_DELIVERY_DATE); + $beginTime = $this->getSession()->get(LivraisonParSecteurs::LPS_DELIVERY_BEGIN_TIME); + $endTime = $this->getSession()->get(LivraisonParSecteurs::LPS_DELIVERY_END_TIME); + + if ( (null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime) ) + { + $event->add( + $this->render( + 'delivery-address.html', [ + 'day' => $selectedDay, + 'begin_time' => $beginTime, + 'end_time' => $endTime + ]) + ); + } + } + } + } diff --git a/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php b/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php index 3fd0b33d..2a4ca59f 100644 --- a/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php +++ b/local/modules/LivraisonParSecteurs/LivraisonParSecteurs.php @@ -21,9 +21,13 @@ class LivraisonParSecteurs extends AbstractDeliveryModule { /** @var string */ const DOMAIN_NAME = 'livraisonparsecteurs'; - const MESSAGE_DOMAIN = "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'; /** * @param ConnectionInterface|null $con @@ -117,6 +121,7 @@ class LivraisonParSecteurs extends AbstractDeliveryModule $date = new \DateTime(); $date->add(new DateInterval('P'. $minimumDelayBeforeOrder . 'D')); + $nextPossibleDay = ''; switch ($baseDay) { case 0 : $nextPossibleDay = $date->modify('next monday'); diff --git a/local/modules/LivraisonParSecteurs/Loop/selectedDeliveryDate.php b/local/modules/LivraisonParSecteurs/Loop/selectedDeliveryDate.php new file mode 100644 index 00000000..37413314 --- /dev/null +++ b/local/modules/LivraisonParSecteurs/Loop/selectedDeliveryDate.php @@ -0,0 +1,66 @@ +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/frontOffice/default/delivery-address.html b/local/modules/LivraisonParSecteurs/templates/frontOffice/default/delivery-address.html new file mode 100644 index 00000000..1685cce3 --- /dev/null +++ b/local/modules/LivraisonParSecteurs/templates/frontOffice/default/delivery-address.html @@ -0,0 +1,29 @@ +{strip} + +
+ {loop type="address" name="delivery-address" id={order attr="delivery_address"}} +
{intl l="Delivery address"}
+
+ {loop type="title" name="customer.title.info" id=$TITLE}{$SHORT}{/loop} {$LASTNAME|upper} {$FIRSTNAME|ucwords} + {$COMPANY} +
+ {$ADDRESS1}
+ {if $ADDRESS2 != ""} + {$ADDRESS2}
+ {/if} + {if $ADDRESS3 != ""} + {$ADDRESS3}
+ {/if} + {$ZIPCODE} + {$CITY} +
+
+ {/loop} + +
{intl l="Delivery day" d="livraisonparsecteurs"}
+
+ {$day} entre {format_date date=$begin_time format="H:i"} et {format_date date=$end_time format="H:i"} +
+
+ +{/strip} diff --git a/local/modules/LivraisonParSecteurs/templates/frontOffice/default/order-delivery-extra.html b/local/modules/LivraisonParSecteurs/templates/frontOffice/default/order-delivery-extra.html index baecfaea..65def0f0 100644 --- a/local/modules/LivraisonParSecteurs/templates/frontOffice/default/order-delivery-extra.html +++ b/local/modules/LivraisonParSecteurs/templates/frontOffice/default/order-delivery-extra.html @@ -1,8 +1,6 @@ +{hook name="order-invoice.javascript-initialization"} +{/block} + +{block name="stylesheet"} +{hook name="order-invoice.stylesheet"} +{/block} + +{block name="after-javascript-include"} +{hook name="order-invoice.after-javascript-include"} +{/block} + diff --git a/templates/frontOffice/default/order-invoice.html b/templates/frontOffice/default/order-invoice.html index 37347137..5c9428d8 100644 --- a/templates/frontOffice/default/order-invoice.html +++ b/templates/frontOffice/default/order-invoice.html @@ -270,7 +270,7 @@
{ifhook rel="order-invoice.delivery-address"} {* delivery module can customize the delivery address *} - {hook name="order-invoice.delivery-address" module={order attr="delivery_module"}} + {hook name="order-invoice.delivery-address" module="{order attr="delivery_module"}"} {/ifhook} {elsehook rel="order-invoice.delivery-address"}