PlanificationLivraison : on avance sur les templates d'email
This commit is contained in:
@@ -20,20 +20,24 @@
|
||||
</loops>
|
||||
|
||||
<hooks>
|
||||
|
||||
<hook id="lps.admin.hook" class="LivraisonParSecteurs\Hook\AdminHook">
|
||||
<tag name="hook.event_listener" event="main.in-top-menu-items" type="back" method="onMainTopMenuTools" />
|
||||
<tag name="hook.event_listener" event="order-edit.bill-delivery-address" type="back" method="displayDeliveryDate" />
|
||||
<tag name="hook.event_listener" event="home.block" type="back" method="displayScheduledDeliveries" />
|
||||
<argument type="service" id="thelia.securityContext"/>
|
||||
</hook>
|
||||
|
||||
<hook id="lps.front.hookmanager" class="LivraisonParSecteurs\Hook\FrontHook">
|
||||
<tag name="hook.event_listener" event="order-delivery.extra" type="front" method="onOrderDeliveryExtra" />
|
||||
<tag name="hook.event_listener" event="order-invoice.delivery-address" type="front" method="displayDeliveryDate" />
|
||||
</hook>
|
||||
|
||||
<hook id="lps.email.hookmanager" class="LivraisonParSecteurs\Hook\EmailHook">
|
||||
<tag name="hook.event_listener" event="email-html.order-confirmation.delivery-address" type="email" method="displayDeliveryDateWithinEmail" />
|
||||
<tag name="hook.event_listener" event="email-html.order-notification.delivery-address" type="email" method="displayDeliveryDateWithinEmail" />
|
||||
</hook>
|
||||
|
||||
</hooks>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace LivraisonParSecteurs\Form;
|
||||
|
||||
use LivraisonParSecteurs\LivraisonParSecteurs;
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
|
||||
@@ -25,7 +26,7 @@ class ScheduleCreateForm extends BaseForm
|
||||
"constraints" => [new Constraints\NotBlank()]
|
||||
])
|
||||
->add("day", "choice", [
|
||||
"choices" => LivraisonParSecteurs::getDayLabel(null),
|
||||
"choices" => PlanificationLivraison::getDayLabel(null),
|
||||
"label" => $this->translator->trans("Delivery day", [], LivraisonParSecteurs::MESSAGE_DOMAIN),
|
||||
"label_attr" => ["for" => "attr-area-schedule-day"],
|
||||
"required" => true,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace LivraisonParSecteurs\Form;
|
||||
|
||||
use LivraisonParSecteurs\LivraisonParSecteurs;
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
|
||||
@@ -31,7 +32,7 @@ class ScheduleUpdateForm extends BaseForm
|
||||
"constraints" => [new Constraints\NotBlank()]
|
||||
])
|
||||
->add("day", "choice", [
|
||||
"choices" => LivraisonParSecteurs::getDayLabel(null),
|
||||
"choices" => PlanificationLivraison::getDayLabel(null),
|
||||
"label" => $this->translator->trans("Delivery day", [], LivraisonParSecteurs::MESSAGE_DOMAIN),
|
||||
"label_attr" => ["for" => "attr-area-schedule-day"],
|
||||
"required" => true,
|
||||
|
||||
@@ -36,21 +36,6 @@ class AdminHook extends BaseHook
|
||||
}
|
||||
|
||||
|
||||
// public function onModuleConfig(HookRenderEvent $event)
|
||||
// {
|
||||
// $isGranted = $this->securityContext->isGranted(
|
||||
// ["ADMIN"],
|
||||
// [],
|
||||
// [LivraisonParSecteurs::getModuleCode()],
|
||||
// [AccessManager::VIEW]
|
||||
// );
|
||||
//
|
||||
// if ($isGranted) {
|
||||
// $event->add($this->render("deliveryarea-list.html", $event->getArguments()));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/* Pour intégrer la date prévue de livraison dans différents formulaires (email, backOffice, ...) */
|
||||
public function displayDeliveryDate(HookRenderEvent $event)
|
||||
{
|
||||
@@ -60,9 +45,10 @@ class AdminHook extends BaseHook
|
||||
|
||||
if ((null !== $orderId) && ($moduleId == 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);
|
||||
$lpsData = $this->getSession()->get('lpsData');
|
||||
$selectedDay = $lpsData->getDeliveryDate();
|
||||
$beginTime = $lpsData->getDeliveryStartTime();
|
||||
$endTime = $lpsData->getDeliveryEndTime();
|
||||
|
||||
if ( (null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime) )
|
||||
{
|
||||
|
||||
@@ -48,10 +48,10 @@ class FrontHook extends BaseHook
|
||||
$order = $this->getSession()->getOrder();
|
||||
if ((null !== $order) && $order->getDeliveryModuleId() == LivraisonParSecteurs::getModuleId())
|
||||
{
|
||||
$lpsData = $this->getSession()->get('lpsData');
|
||||
$selectedDay = $lpsData->getDeliveryDate();
|
||||
$beginTime = $lpsData->getDeliveryStartTime();
|
||||
$endTime = $lpsData->getDeliveryEndTime();
|
||||
$sessionData = $this->getSession()->get('lpsData');
|
||||
$selectedDay = $sessionData->getDeliveryDate();
|
||||
$beginTime = $sessionData->getDeliveryStartTime();
|
||||
$endTime = $sessionData->getDeliveryEndTime();
|
||||
|
||||
if ( (null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime) )
|
||||
{
|
||||
@@ -65,7 +65,7 @@ class FrontHook extends BaseHook
|
||||
);
|
||||
}
|
||||
else
|
||||
throw new TheliaProcessException("LivraisonParSecteurs : Impossible de récupérer les données de session LpsData : " . $event->getMessage());
|
||||
throw new TheliaProcessException("LivraisonParSecteurs : Impossible de récupérer les données de session LpsData");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,11 +46,4 @@ return array(
|
||||
'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',
|
||||
'Tuesday' => 'Mardi',
|
||||
'Wednesday' => 'Mercredi',
|
||||
'Thursday' => 'Jeudi',
|
||||
'Friday' => 'Vendredi',
|
||||
'Saturday' => 'Samedi',
|
||||
'Sunday' => 'Dimanche',
|
||||
|
||||
);
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
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;
|
||||
@@ -22,13 +20,6 @@ class LivraisonParSecteurs extends AbstractDeliveryModule
|
||||
/** @var string */
|
||||
const DOMAIN_NAME = 'livraisonparsecteurs';
|
||||
const MESSAGE_DOMAIN = 'livraisonparsecteurs';
|
||||
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_DATE_COMPLETE = 'Y-m-d H:i:s';
|
||||
const SECTEUR_ACTIF = 1;
|
||||
|
||||
|
||||
@@ -104,58 +95,4 @@ class LivraisonParSecteurs extends AbstractDeliveryModule
|
||||
return $price;
|
||||
}
|
||||
|
||||
static public function getDayLabel($int)
|
||||
{
|
||||
$translator = Translator::getInstance();
|
||||
|
||||
$days = [
|
||||
$translator->trans("Monday", [], LivraisonParSecteurs::MESSAGE_DOMAIN),
|
||||
$translator->trans("Tuesday", [], LivraisonParSecteurs::MESSAGE_DOMAIN),
|
||||
$translator->trans("Wednesday", [], LivraisonParSecteurs::MESSAGE_DOMAIN),
|
||||
$translator->trans("Thursday", [], LivraisonParSecteurs::MESSAGE_DOMAIN),
|
||||
$translator->trans("Friday", [], LivraisonParSecteurs::MESSAGE_DOMAIN),
|
||||
$translator->trans("Saturday", [], LivraisonParSecteurs::MESSAGE_DOMAIN),
|
||||
$translator->trans("Sunday", [], LivraisonParSecteurs::MESSAGE_DOMAIN)
|
||||
];
|
||||
|
||||
if ($int === null)
|
||||
return $days;
|
||||
else
|
||||
return $days[$int];
|
||||
}
|
||||
|
||||
static public function calculateRelativeDate($baseDay)
|
||||
{
|
||||
$minimumDelayBeforeOrder = PlanificationLivraison::getConfigValue(PlanificationLivraison::CONFIG_PREPARATION_DELAY, 0, "en_US");
|
||||
|
||||
$date = new \DateTime();
|
||||
$date->add(new DateInterval('P'. $minimumDelayBeforeOrder . 'D'));
|
||||
|
||||
$nextPossibleDay = '';
|
||||
switch ($baseDay) {
|
||||
case 0 :
|
||||
$nextPossibleDay = $date->modify('next monday');
|
||||
break;
|
||||
case 1 :
|
||||
$nextPossibleDay = $date->modify('next tuesday');
|
||||
break;
|
||||
case 2 :
|
||||
$nextPossibleDay = $date->modify('next wednesday');
|
||||
break;
|
||||
case 3 :
|
||||
$nextPossibleDay = $date->modify('next thursday');
|
||||
break;
|
||||
case 4 :
|
||||
$nextPossibleDay = $date->modify('next friday');
|
||||
break;
|
||||
case 5 :
|
||||
$nextPossibleDay = $date->modify('next saturday');
|
||||
break;
|
||||
case 6 :
|
||||
$nextPossibleDay = $date->modify('next sunday');
|
||||
break;
|
||||
}
|
||||
|
||||
return $nextPossibleDay;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace LivraisonParSecteurs\Loop;
|
||||
use LivraisonParSecteurs\LivraisonParSecteurs;
|
||||
use LivraisonParSecteurs\Model\LpsAreaCityQuery;
|
||||
use LivraisonParSecteurs\Model\LpsAreaScheduleQuery;
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -37,7 +38,7 @@ class AreaLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
$schedule = LpsAreaScheduleQuery::create()->findByIdArea($lps_area->getId());
|
||||
$deliveryDays = "";
|
||||
foreach ($schedule as $day) {
|
||||
$deliveryDays .= LivraisonParSecteurs::getDayLabel($day->getDay()) . ', ';
|
||||
$deliveryDays .= PlanificationLivraison::getDayLabel($day->getDay()) . ', ';
|
||||
}
|
||||
$deliveryDays = substr($deliveryDays, 0, strlen($deliveryDays)-2);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace LivraisonParSecteurs\Loop;
|
||||
|
||||
use LivraisonParSecteurs\LivraisonParSecteurs;
|
||||
use LivraisonParSecteurs\Model\LpsAreaScheduleQuery;
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -36,10 +37,10 @@ class AreaScheduleLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
->set("ID", $lps_area_schedule->getId())
|
||||
->set("AREA_ID", $lps_area_schedule->getIdArea())
|
||||
->set("DAY", $lps_area_schedule->getDay())
|
||||
->set("DAY_LABEL", LivraisonParSecteurs::getDayLabel($lps_area_schedule->getDay()))
|
||||
->set("DAY_LABEL", PlanificationLivraison::getDayLabel($lps_area_schedule->getDay()))
|
||||
->set("BEGIN", $lps_area_schedule->getBeginTime())
|
||||
->set("END", $lps_area_schedule->getEndTime())
|
||||
->set("CALCULATED_DAY", LivraisonParSecteurs::calculateRelativeDate($lps_area_schedule->getDay())->format(LivraisonParSecteurs::FORMAT_DATES))
|
||||
->set("CALCULATED_DAY", PlanificationLivraison::calculateRelativeDate($lps_area_schedule->getDay())->format(PlanificationLivraison::FORMAT_DATES))
|
||||
;
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<tr><td> </td></tr>
|
||||
|
||||
<tr style="background-color:#1A712C; color:white">
|
||||
<th>{intl l="Scheduled date" d="livraisonparsecteurs"}</th>-->
|
||||
<td>{$day} entre {format_date date=$begin_time format="H\hi"} et {format_date date=$end_time format="H\hi"}</td>-->
|
||||
<th>{intl l="Scheduled date" d="livraisonparsecteurs"}</th>
|
||||
<td>{$day} entre {format_date date=$begin_time format="H\hi"} et {format_date date=$end_time format="H\hi"}</td>
|
||||
</tr>
|
||||
|
||||
<tr><td> </td></tr>
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
<form name="planiflivraison.configuration" class="PlanificationLivraison\Form\Configuration" />
|
||||
</forms>
|
||||
|
||||
|
||||
<loops>
|
||||
<loop name="scheduled_deliveries" class="PlanificationLivraison\Loop\ScheduledDeliveriesLoop"/>
|
||||
</loops>
|
||||
@@ -24,6 +23,9 @@
|
||||
<hook id="planiflivraison.back.hook" class="PlanificationLivraison\Hook\BackHook">
|
||||
<tag name="hook.event_listener" event="module.configuration" type="back" method="onModuleConfiguration" />
|
||||
</hook>
|
||||
<hook id="css.back.hook">
|
||||
<tag name="hook.event_listener" event="main.head-css" type="back" templates="css:assets/css/custom.css" />
|
||||
</hook>
|
||||
</hooks>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
<foreign-key foreignTable="pdr_places" name="fk_order_delivery_place_id">
|
||||
<reference foreign="id" local="delivery_place_id" />
|
||||
</foreign-key>
|
||||
<foreign-key foreignTable="lps_area_schedule" name="fk_order_delivery_schedule_id">
|
||||
<reference foreign="id" local="schedule_id" />
|
||||
</foreign-key>
|
||||
|
||||
</table>
|
||||
<external-schema filename="local/config/schema.xml" referenceOnly="true" />
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Sqlfile -> Database map
|
||||
thelia.sql=thelia
|
||||
@@ -1,41 +0,0 @@
|
||||
|
||||
# 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;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- order_delivery_schedule
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `order_delivery_schedule`;
|
||||
|
||||
CREATE TABLE `order_delivery_schedule`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`order_id` INTEGER,
|
||||
`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`)
|
||||
REFERENCES `order` (`id`),
|
||||
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`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
# This restores the fkey checks, after having unset them earlier
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -6,6 +6,7 @@ use DateTime;
|
||||
use LivraisonParSecteurs\LivraisonParSecteurs;
|
||||
use LivraisonParSecteurs\Model\LpsAreaScheduleQuery;
|
||||
use PlanificationLivraison\Model\OrderDeliverySchedule;
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use PointRetrait\Model\PdrScheduleQuery;
|
||||
use PointRetrait\PointRetrait;
|
||||
use Propel\Runtime\Propel;
|
||||
@@ -56,40 +57,41 @@ class DeliveryListener extends BaseAction implements EventSubscriberInterface
|
||||
if ($module == LivraisonParSecteurs::getModuleId()) {
|
||||
if (null !== $scheduleId = $request->get('lps-choosen-day', null)) {
|
||||
|
||||
$lpsData = new SessionData();
|
||||
$lpsData->setDeliveryAddressId($session->getOrder()->getChoosenDeliveryAddress());
|
||||
$lpsData->setAreaScheduleId($scheduleId);
|
||||
$sessionData = new SessionData();
|
||||
$sessionData->setDeliveryAddressId($session->getOrder()->getChoosenDeliveryAddress());
|
||||
$sessionData->setScheduleId($scheduleId);
|
||||
|
||||
// On sauvegarde la date de livraison choisie avec les heures, pour affichage ultérieur.
|
||||
$schedule = LpsAreaScheduleQuery::create()->findOneById($scheduleId);
|
||||
$chosenDate = LivraisonParSecteurs::calculateRelativeDate($schedule->getDay());
|
||||
$completeDay = LivraisonParSecteurs::getDayLabel($schedule->getDay());
|
||||
$completeDay .= " " . $chosenDate->format(LivraisonParSecteurs::FORMAT_DATES);
|
||||
$chosenDate = PlanificationLivraison::calculateRelativeDate($schedule->getDay());
|
||||
$completeDay = PlanificationLivraison::getDayLabel($schedule->getDay());
|
||||
$completeDay .= " " . $chosenDate->format(PlanificationLivraison::FORMAT_DATES);
|
||||
|
||||
$lpsData->setDeliveryDate($completeDay);
|
||||
$lpsData->setDeliveryStartTime($schedule->getBeginTime());
|
||||
$lpsData->setDeliveryEndTime($schedule->getEndTime());
|
||||
$sessionData->setDeliveryDate($completeDay);
|
||||
$sessionData->setDeliveryStartTime($schedule->getBeginTime());
|
||||
$sessionData->setDeliveryEndTime($schedule->getEndTime());
|
||||
|
||||
$session->set('lpsData', $lpsData);
|
||||
$session->set('lpsData', $sessionData);
|
||||
}
|
||||
}
|
||||
|
||||
if ($module == PointRetrait::getModuleId()) {
|
||||
if (null !== $scheduleId = $request->get('pdr-choosen-day', null)) {
|
||||
$schedule =PdrScheduleQuery::create()->findOneById($scheduleId);
|
||||
$placeId = $schedule->getIdPlace();
|
||||
|
||||
$session->set(PointRetrait::PDR_PLACE_SCHEDULE_ID, $scheduleId);
|
||||
$session->set(PointRetrait::PDR_CHOSEN_PLACE, $placeId);
|
||||
|
||||
$chosenDate = PointRetrait::calculateRelativeDate($schedule->getDay());
|
||||
$sessionData = new SessionData();
|
||||
$sessionData->setScheduleId($scheduleId);
|
||||
$schedule = PdrScheduleQuery::create()->findOneById($scheduleId);
|
||||
$sessionData->setPlaceId($schedule->getIdPlace());
|
||||
|
||||
// On sauvegarde la date de livraison choisie avec les heures, pour affichage ultérieur.
|
||||
$completeDay = PointRetrait::getDayLabel($schedule->getDay());
|
||||
$completeDay .= " " . $chosenDate->format(PointRetrait::FORMAT_DATES);
|
||||
$session->set(PointRetrait::PDR_DELIVERY_DATE, $completeDay);
|
||||
$session->set(PointRetrait::PDR_DELIVERY_BEGIN_TIME, $schedule->getBeginTime());
|
||||
$session->set(PointRetrait::PDR_DELIVERY_END_TIME, $schedule->getEndTime());
|
||||
$chosenDate = PlanificationLivraison::calculateRelativeDate($schedule->getDay());
|
||||
$completeDay = PlanificationLivraison::getDayLabel($schedule->getDay());
|
||||
$completeDay .= " " . $chosenDate->format(PlanificationLivraison::FORMAT_DATES);
|
||||
$sessionData->setDeliveryDate($completeDay);
|
||||
$sessionData->setDeliveryStartTime($schedule->getBeginTime());
|
||||
$sessionData->setDeliveryEndTime($schedule->getEndTime());
|
||||
|
||||
$session->set('pdrData', $sessionData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,28 +109,41 @@ class DeliveryListener extends BaseAction implements EventSubscriberInterface
|
||||
$order = $event->getOrder();
|
||||
$deliveryModuleId = $order->getDeliveryModuleId();
|
||||
|
||||
if ($deliveryModuleId == LivraisonParSecteurs::getModuleId()) {
|
||||
if ($deliveryModuleId == LivraisonParSecteurs::getModuleId()
|
||||
|| $deliveryModuleId == PointRetrait::getModuleId())
|
||||
{
|
||||
if ($deliveryModuleId == LivraisonParSecteurs::getModuleId())
|
||||
$sessionData = $session->get('lpsData');
|
||||
else
|
||||
$sessionData = $session->get('pdrData');
|
||||
|
||||
$lpsData = new SessionData();
|
||||
$lpsData = $session->get('lpsData');
|
||||
if ($lpsData === null)
|
||||
throw new TheliaProcessException("PlanificationLivraison : Données de session LpsData vides : " . $event->getMessage());
|
||||
|
||||
$scheduleId = $lpsData->getAreaScheduleId();
|
||||
$orderId = $order->getId();
|
||||
if ($sessionData === null)
|
||||
throw new TheliaProcessException("PlanificationLivraison : Données de session vides : " . $event->getMessage());
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$con->beginTransaction();
|
||||
$query = new OrderDeliverySchedule();
|
||||
try {
|
||||
$query->setOrderId($orderId);
|
||||
$scheduleId = $sessionData->getScheduleId();
|
||||
|
||||
$query->setOrderId($order->getId());
|
||||
$query->setScheduleId($scheduleId);
|
||||
$query->setDeliveryAddressId($lpsData->getDeliveryAddressId());
|
||||
|
||||
$schedule = LpsAreaScheduleQuery::create()->findOneById($scheduleId);
|
||||
$chosenDate = LivraisonParSecteurs::calculateRelativeDate($schedule->getDay());
|
||||
if ($deliveryModuleId == LivraisonParSecteurs::getModuleId()) {
|
||||
$query->setDeliveryAddressId($sessionData->getDeliveryAddressId());
|
||||
$query->setDeliveryPlaceId(null);
|
||||
|
||||
$format = LivraisonParSecteurs::FORMAT_DATE_COMPLETE;
|
||||
$schedule = LpsAreaScheduleQuery::create()->findOneById($scheduleId);
|
||||
}
|
||||
else {
|
||||
$query->setDeliveryPlaceId($sessionData->getPlaceId());
|
||||
$query->setDeliveryAddressId(null);
|
||||
|
||||
$schedule = PdrScheduleQuery::create()->findOneById($scheduleId);
|
||||
}
|
||||
|
||||
$chosenDate = PlanificationLivraison::calculateRelativeDate($schedule->getDay());
|
||||
$format = PlanificationLivraison::FORMAT_DATE_COMPLETE;
|
||||
$startDate = DateTime::createFromFormat($format, $chosenDate->format('Y-m-d ') . $schedule->getBeginTime()->format('H:i:s'));
|
||||
$query->setDueDeliveryTimeStart($startDate);
|
||||
$endDate = DateTime::createFromFormat($format, $chosenDate->format('Y-m-d ') . $schedule->getEndTime()->format('H:i:s'));
|
||||
@@ -148,7 +163,7 @@ class DeliveryListener extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
return [
|
||||
TheliaEvents::ORDER_SET_DELIVERY_MODULE => ['recordCurrentDeliveryAddress', 64],
|
||||
TheliaEvents::ORDER_BEFORE_PAYMENT => ['updateCurrentDeliveryAddress', 64]
|
||||
TheliaEvents::ORDER_AFTER_CREATE => ['updateCurrentDeliveryAddress', 64]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,4 +10,12 @@ return array(
|
||||
'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',
|
||||
'Warning withdrawal date' => 'N\'oubliez pas de venir retirer votre commande le %date entre %heure_debut et %heure_fin',
|
||||
'Monday' => 'Lundi',
|
||||
'Tuesday' => 'Mardi',
|
||||
'Wednesday' => 'Mercredi',
|
||||
'Thursday' => 'Jeudi',
|
||||
'Friday' => 'Vendredi',
|
||||
'Saturday' => 'Samedi',
|
||||
'Sunday' => 'Dimanche',
|
||||
);
|
||||
|
||||
@@ -58,6 +58,7 @@ class ScheduledDeliveriesLoop extends BaseLoop implements PropelSearchLoopInterf
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('order_id'),
|
||||
Argument::createEnumListTypeArgument('domicile_ou_retrait', [
|
||||
self::DOMICILE,
|
||||
self::RETRAIT
|
||||
@@ -77,6 +78,12 @@ class ScheduledDeliveriesLoop extends BaseLoop implements PropelSearchLoopInterf
|
||||
{
|
||||
$deliveries = OrderDeliveryScheduleQuery::create();
|
||||
|
||||
|
||||
if (null !== $this->getOrderId()) {
|
||||
return $deliveries->filterByOrderId($this->getOrderId());
|
||||
}
|
||||
|
||||
|
||||
foreach ($this->getDomicileOuRetrait() as $parametre) {
|
||||
switch ($parametre) {
|
||||
case self::DOMICILE:
|
||||
|
||||
@@ -6,11 +6,44 @@ namespace PlanificationLivraison\Model;
|
||||
|
||||
class SessionData
|
||||
{
|
||||
protected $deliveryAddressId = null;
|
||||
protected $areaScheduleId = null;
|
||||
protected $scheduleId = null;
|
||||
protected $deliveryDate = null;
|
||||
protected $deliveryStartTime = null;
|
||||
protected $deliveryEndTime = null;
|
||||
protected $deliveryAddressId = null;
|
||||
protected $placeId = null;
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getScheduleId()
|
||||
{
|
||||
return $this->scheduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $scheduleId
|
||||
*/
|
||||
public function setScheduleId($scheduleId)
|
||||
{
|
||||
$this->scheduleId = $scheduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getPlaceId()
|
||||
{
|
||||
return $this->placeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $placeId
|
||||
*/
|
||||
public function setPlaceId($placeId)
|
||||
{
|
||||
$this->placeId = $placeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
@@ -28,22 +61,6 @@ class SessionData
|
||||
$this->deliveryAddressId = $deliveryAddressId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getAreaScheduleId()
|
||||
{
|
||||
return $this->areaScheduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $areaScheduleId
|
||||
*/
|
||||
public function setAreaScheduleId($areaScheduleId)
|
||||
{
|
||||
$this->areaScheduleId = $areaScheduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace PlanificationLivraison;
|
||||
|
||||
use DateInterval;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Install\Database;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
@@ -18,6 +20,10 @@ class PlanificationLivraison extends BaseModule
|
||||
const CONFIG_ORANGE_ALERT = 'delay_orange_alert';
|
||||
const CONFIG_PREPARATION_DELAY = 'orders_preparation_delay';
|
||||
|
||||
const FORMAT_DATES = 'd/m/Y';
|
||||
const FORMAT_DATE_COMPLETE = 'Y-m-d H:i:s';
|
||||
|
||||
|
||||
/**
|
||||
* @param ConnectionInterface|null $con
|
||||
*/
|
||||
@@ -27,4 +33,60 @@ class PlanificationLivraison extends BaseModule
|
||||
$database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
|
||||
}
|
||||
|
||||
static public function calculateRelativeDate($baseDay)
|
||||
{
|
||||
$minimumDelayBeforeOrder = PlanificationLivraison::getConfigValue(PlanificationLivraison::CONFIG_PREPARATION_DELAY, 0, "en_US");
|
||||
|
||||
$date = new \DateTime();
|
||||
$date->add(new DateInterval('P'. $minimumDelayBeforeOrder . 'D'));
|
||||
|
||||
$nextPossibleDay = '';
|
||||
switch ($baseDay) {
|
||||
case 0 :
|
||||
$nextPossibleDay = $date->modify('next monday');
|
||||
break;
|
||||
case 1 :
|
||||
$nextPossibleDay = $date->modify('next tuesday');
|
||||
break;
|
||||
case 2 :
|
||||
$nextPossibleDay = $date->modify('next wednesday');
|
||||
break;
|
||||
case 3 :
|
||||
$nextPossibleDay = $date->modify('next thursday');
|
||||
break;
|
||||
case 4 :
|
||||
$nextPossibleDay = $date->modify('next friday');
|
||||
break;
|
||||
case 5 :
|
||||
$nextPossibleDay = $date->modify('next saturday');
|
||||
break;
|
||||
case 6 :
|
||||
$nextPossibleDay = $date->modify('next sunday');
|
||||
break;
|
||||
}
|
||||
|
||||
return $nextPossibleDay;
|
||||
}
|
||||
|
||||
|
||||
static public function getDayLabel($int)
|
||||
{
|
||||
$translator = Translator::getInstance();
|
||||
|
||||
$days = [
|
||||
$translator->trans("Monday", [], PlanificationLivraison::DOMAIN_NAME),
|
||||
$translator->trans("Tuesday", [], PlanificationLivraison::DOMAIN_NAME),
|
||||
$translator->trans("Wednesday", [], PlanificationLivraison::DOMAIN_NAME),
|
||||
$translator->trans("Thursday", [], PlanificationLivraison::DOMAIN_NAME),
|
||||
$translator->trans("Friday", [], PlanificationLivraison::DOMAIN_NAME),
|
||||
$translator->trans("Saturday", [], PlanificationLivraison::DOMAIN_NAME),
|
||||
$translator->trans("Sunday", [], PlanificationLivraison::DOMAIN_NAME)
|
||||
];
|
||||
|
||||
if ($int === null)
|
||||
return $days;
|
||||
else
|
||||
return $days[$int];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
.mode-livraison {
|
||||
font-weight: 900;
|
||||
color: red;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
@@ -14,11 +14,18 @@
|
||||
<hook id="pdr.admin.hook" class="PointRetrait\Hook\AdminHook">
|
||||
<tag name="hook.event_listener" event="home.block" type="back" method="displayScheduledWithdrawals" />
|
||||
<tag name="hook.event_listener" event="main.in-top-menu-items" type="back" method="onMainTopMenuTools" />
|
||||
<tag name="hook.event_listener" event="order-edit.bill-delivery-address" type="back" method="displayDeliveryDate" />
|
||||
<argument type="service" id="thelia.securityContext"/>
|
||||
</hook>
|
||||
|
||||
<hook id="pdr.front.hook" class="PointRetrait\Hook\FrontHook">
|
||||
<tag name="hook.event_listener" event="order-delivery.extra" type="front" method="onOrderDeliveryExtra" />
|
||||
<tag name="hook.event_listener" event="order-invoice.delivery-address" type="front" method="displayWithdrawalDate" />
|
||||
</hook>
|
||||
|
||||
<hook id="pdr.email.hookmanager" class="PointRetrait\Hook\EmailHook">
|
||||
<tag name="hook.event_listener" event="email-html.order-confirmation.delivery-address" type="email" method="displayDeliveryDateWithinEmail" />
|
||||
<tag name="hook.event_listener" event="email-html.order-notification.before-products" type="email" method="displayCompleteInformationWithinEmail" />
|
||||
</hook>
|
||||
|
||||
</hooks>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace PointRetrait\Form;
|
||||
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use PointRetrait\PointRetrait;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
@@ -25,7 +26,7 @@ class CreateScheduleForm extends BaseForm
|
||||
"constraints" => [new Constraints\NotBlank()]
|
||||
])
|
||||
->add("day", "choice", [
|
||||
"choices" => PointRetrait::getDayLabel(null),
|
||||
"choices" => PlanificationLivraison::getDayLabel(null),
|
||||
"label" => $this->translator->trans("Withdrawal day", [], PointRetrait::MESSAGE_DOMAIN),
|
||||
"label_attr" => ["for" => "attr-place-schedule-day"],
|
||||
"required" => true,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace PointRetrait\Form;
|
||||
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use PointRetrait\PointRetrait;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
@@ -31,7 +32,7 @@ class UpdateScheduleForm extends BaseForm
|
||||
"constraints" => [new Constraints\NotBlank()]
|
||||
])
|
||||
->add("day", "choice", [
|
||||
"choices" => PointRetrait::getDayLabel(null),
|
||||
"choices" => PlanificationLivraison::getDayLabel(null),
|
||||
"label" => $this->translator->trans("Withdrawal day", [], PointRetrait::MESSAGE_DOMAIN),
|
||||
"label_attr" => ["for" => "attr-place-schedule-day"],
|
||||
"required" => true,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace PointRetrait\Form;
|
||||
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use PointRetrait\PointRetrait;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
@@ -25,7 +26,7 @@ class ViewScheduleForm extends BaseForm
|
||||
"constraints" => [new Constraints\NotBlank()]
|
||||
])
|
||||
->add("day", "choice", [
|
||||
"choices" => PointRetrait::getDayLabel(null),
|
||||
"choices" => PlanificationLivraison::getDayLabel(null),
|
||||
"label" => $this->translator->trans("Delivery day", [], PointRetrait::MESSAGE_DOMAIN),
|
||||
"label_attr" => ["for" => "attr-place-schedule-day"],
|
||||
"required" => true,
|
||||
|
||||
@@ -51,4 +51,31 @@ class AdminHook extends BaseHook
|
||||
}
|
||||
}
|
||||
|
||||
/* Pour intégrer la date prévue de retrait dans différents formulaires (email, backOffice, ...) */
|
||||
public function displayDeliveryDate(HookRenderEvent $event)
|
||||
{
|
||||
|
||||
$moduleId = $event->getArgument('module');
|
||||
$orderId = $event->getArgument('order_id');
|
||||
|
||||
if ((null !== $orderId) && ($moduleId == PointRetrait::getModuleId()))
|
||||
{
|
||||
$sessionData = $this->getSession()->get('pdrData');
|
||||
$selectedDay = $sessionData->getDeliveryDate();
|
||||
$beginTime = $sessionData->getDeliveryStartTime();
|
||||
$endTime = $sessionData->getDeliveryEndTime();
|
||||
|
||||
if ( (null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime) )
|
||||
{
|
||||
$event->add(
|
||||
$this->render(
|
||||
'delivery-address.html', [
|
||||
'day' => $selectedDay,
|
||||
'begin_time' => $beginTime,
|
||||
'end_time' => $endTime
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
83
local/modules/PointRetrait/Hook/EmailHook.php
Normal file
83
local/modules/PointRetrait/Hook/EmailHook.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace PointRetrait\Hook;
|
||||
|
||||
use PlanificationLivraison\Model\SessionData;
|
||||
use PointRetrait\Model\PdrPlacesQuery;
|
||||
use PointRetrait\PointRetrait;
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
use Thelia\Model\OrderQuery;
|
||||
|
||||
|
||||
class EmailHook extends BaseHook
|
||||
{
|
||||
public function displayDeliveryDateWithinEmail(HookRenderEvent $event)
|
||||
{
|
||||
|
||||
$moduleId = $event->getArgument('module');
|
||||
$orderId = $event->getArgument('order');
|
||||
|
||||
if ((null !== $orderId) && ($moduleId == PointRetrait::getModuleId()))
|
||||
{
|
||||
$sessionData = $this->getSession()->get('pdrData');
|
||||
$selectedDay = $sessionData->getDeliveryDate();
|
||||
$beginTime = $sessionData->getDeliveryStartTime();
|
||||
$endTime = $sessionData->getDeliveryEndTime();
|
||||
|
||||
if ( (null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime) )
|
||||
{
|
||||
$event->add(
|
||||
$this->render(
|
||||
'delivery-address.html', [
|
||||
'day' => $selectedDay,
|
||||
'begin_time' => $beginTime,
|
||||
'end_time' => $endTime
|
||||
])
|
||||
);
|
||||
}
|
||||
else
|
||||
throw new TheliaProcessException("PointRetrait : Impossible de récupérer les données de session SessionData");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function displayCompleteInformationWithinEmail(HookRenderEvent $event)
|
||||
{
|
||||
|
||||
$orderId = $event->getArgument('order');
|
||||
$moduleId = OrderQuery::create()->findOneById($orderId)->getDeliveryModuleId();
|
||||
|
||||
if ((null !== $orderId) && ($moduleId == PointRetrait::getModuleId()))
|
||||
{
|
||||
$sessionData = $this->getSession()->get('pdrData');
|
||||
$selectedDay = $sessionData->getDeliveryDate();
|
||||
$beginTime = $sessionData->getDeliveryStartTime();
|
||||
$endTime = $sessionData->getDeliveryEndTime();
|
||||
|
||||
if ( (null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime) )
|
||||
{
|
||||
$place = PdrPlacesQuery::create()->findOneById($sessionData->getPlaceId());
|
||||
|
||||
$event->add(
|
||||
$this->render(
|
||||
'delivery-address-full.html', [
|
||||
'day' => $selectedDay,
|
||||
'begin_time' => $beginTime,
|
||||
'end_time' => $endTime,
|
||||
'placeName' => $place->getTitle(),
|
||||
'address1' => $place->getAddress1() . ' ' . $place->getAddress2(),
|
||||
'zipcode' => $place->getZipcode(),
|
||||
'city' => $place->getCity()
|
||||
])
|
||||
);
|
||||
}
|
||||
else
|
||||
throw new TheliaProcessException("PointRetrait : Impossible de récupérer les données de session SessionData");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace PointRetrait\Hook;
|
||||
|
||||
use PlanificationLivraison\Model\SessionData;
|
||||
use PointRetrait\PointRetrait;
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
|
||||
class FrontHook extends BaseHook
|
||||
{
|
||||
@@ -21,6 +23,34 @@ class FrontHook extends BaseHook
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function displayWithdrawalDate(HookRenderEvent $event)
|
||||
{
|
||||
$order = $this->getSession()->getOrder();
|
||||
if ((null !== $order) && $order->getDeliveryModuleId() == PointRetrait::getModuleId())
|
||||
{
|
||||
$sessionData = $this->getSession()->get('pdrData');
|
||||
$selectedDay = $sessionData->getDeliveryDate();
|
||||
$beginTime = $sessionData->getDeliveryStartTime();
|
||||
$endTime = $sessionData->getDeliveryEndTime();
|
||||
|
||||
if ( (null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime) )
|
||||
{
|
||||
$event->add(
|
||||
$this->render(
|
||||
'delivery-address.html', [
|
||||
'day' => $selectedDay,
|
||||
'begin_time' => $beginTime,
|
||||
'end_time' => $endTime,
|
||||
'place_id' => $sessionData->getPlaceId()
|
||||
])
|
||||
);
|
||||
}
|
||||
else
|
||||
throw new TheliaProcessException("PointRetrait : Impossible de récupérer les données de session sessionData : ");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ return array(
|
||||
'Module name' => 'Point de Retrait AuxBieauxLegumes',
|
||||
'My places' => 'Point de retrait AuxBieauxLegumes',
|
||||
'My withdrawal places' => 'Mes points de retrait AuxBieauxLegumes',
|
||||
'Order to withdraw' => 'Commande à retirer au point retrait suivant',
|
||||
'Order number' => 'N° de commande',
|
||||
'Place name' => 'Nom du point de retrait',
|
||||
'Please select a delivery place' => 'Veuillez sélectionner un point de retrait',
|
||||
@@ -37,18 +38,13 @@ return array(
|
||||
'Title of config view' => 'Point retrait AuxBieauxLegumes - Configuration',
|
||||
'There is no order to withdraw' => 'Aucune commande à retirer en Point Retrait',
|
||||
'There is no schedule for this place' => 'Aucun créneau de retrait sur ce point de retrait',
|
||||
'When to get your order' => 'Quand pouvez-vous retirer votre commande ?',
|
||||
'Where to get your order' => 'Où pouvez-vous la récupérer ?',
|
||||
'Withdrawal beginning time' => 'Début du retrait',
|
||||
'Withdrawal day' => 'Jour de retrait',
|
||||
'Withdrawal days' => 'Jours de retrait',
|
||||
'Withdrawal ending time' => 'Fin du retrait',
|
||||
'Withdrawal price' => 'Coût du retrait',
|
||||
'Zipcode' => 'Code postal',
|
||||
'Monday' => 'Lundi',
|
||||
'Tuesday' => 'Mardi',
|
||||
'Wednesday' => 'Mercredi',
|
||||
'Thursday' => 'Jeudi',
|
||||
'Friday' => 'Vendredi',
|
||||
'Saturday' => 'Samedi',
|
||||
'Sunday' => 'Dimanche',
|
||||
'' => '',
|
||||
);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace PointRetrait\Loop;
|
||||
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use PointRetrait\Model\PdrPlacesQuery;
|
||||
use PointRetrait\Model\PdrScheduleQuery;
|
||||
use PointRetrait\PointRetrait;
|
||||
@@ -39,7 +40,7 @@ class GeneralLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
->orderByDay();
|
||||
$deliveryDays = "";
|
||||
foreach ($schedule as $day) {
|
||||
$deliveryDays .= PointRetrait::getDayLabel($day->getDay()) . ', ';
|
||||
$deliveryDays .= PlanificationLivraison::getDayLabel($day->getDay()) . ', ';
|
||||
}
|
||||
$deliveryDays = substr($deliveryDays, 0, strlen($deliveryDays)-2);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace PointRetrait\Loop;
|
||||
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use PointRetrait\Model\PdrScheduleQuery;
|
||||
use PointRetrait\PointRetrait;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
@@ -37,10 +38,10 @@ class ScheduleLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
->set("ID", $pdr_schedule->getId())
|
||||
->set("PLACE_ID", $pdr_schedule->getIdPlace())
|
||||
->set("DAY", $pdr_schedule->getDay())
|
||||
->set("DAY_LABEL", PointRetrait::getDayLabel($pdr_schedule->getDay()))
|
||||
->set("DAY_LABEL", PlanificationLivraison::getDayLabel($pdr_schedule->getDay()))
|
||||
->set("BEGIN", $pdr_schedule->getBeginTime())
|
||||
->set("END", $pdr_schedule->getEndTime())
|
||||
->set("CALCULATED_DAY", PointRetrait::calculateRelativeDate($pdr_schedule->getDay())->format(PointRetrait::FORMAT_DATES))
|
||||
->set("CALCULATED_DAY", PlanificationLivraison::calculateRelativeDate($pdr_schedule->getDay())->format(PlanificationLivraison::FORMAT_DATES))
|
||||
;
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
@@ -2,19 +2,15 @@
|
||||
|
||||
namespace PointRetrait;
|
||||
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use PointRetrait\Model\PdrPlacesQuery;
|
||||
use PointRetrait\Model\PdrScheduleQuery;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Install\Database;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\Country;
|
||||
use Thelia\Model\OrderPostage;
|
||||
use Thelia\Module\AbstractDeliveryModule;
|
||||
use Thelia\Module\Exception\DeliveryException;
|
||||
use DateInterval;
|
||||
|
||||
|
||||
|
||||
@@ -24,13 +20,6 @@ class PointRetrait extends AbstractDeliveryModule
|
||||
const DOMAIN_NAME = 'pointretrait';
|
||||
const MESSAGE_DOMAIN = 'pointretrait';
|
||||
const MODULE_URL = '/admin/module/PointRetrait';
|
||||
const FORMAT_DATES = 'd/m/Y';
|
||||
const PDR_PLACE_SCHEDULE_ID = 'pdr_place_schedule_id';
|
||||
const PDR_CHOSEN_PLACE = 'pdr_chosen_place';
|
||||
const PDR_DELIVERY_DATE = 'pdr_delivery_date';
|
||||
const PDR_DELIVERY_BEGIN_TIME = 'pdr_begin_time';
|
||||
const PDR_DELIVERY_END_TIME = 'pdr_end_time';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -86,59 +75,4 @@ class PointRetrait extends AbstractDeliveryModule
|
||||
}
|
||||
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
static public function calculateRelativeDate($baseDay)
|
||||
{
|
||||
$minimumDelayBeforeOrder = PlanificationLivraison::getConfigValue(PlanificationLivraison::CONFIG_PREPARATION_DELAY, 0, "en_US");
|
||||
|
||||
$date = new \DateTime();
|
||||
$date->add(new DateInterval('P'. $minimumDelayBeforeOrder . 'D'));
|
||||
|
||||
$nextPossibleDay = '';
|
||||
switch ($baseDay) {
|
||||
case 0 :
|
||||
$nextPossibleDay = $date->modify('next monday');
|
||||
break;
|
||||
case 1 :
|
||||
$nextPossibleDay = $date->modify('next tuesday');
|
||||
break;
|
||||
case 2 :
|
||||
$nextPossibleDay = $date->modify('next wednesday');
|
||||
break;
|
||||
case 3 :
|
||||
$nextPossibleDay = $date->modify('next thursday');
|
||||
break;
|
||||
case 4 :
|
||||
$nextPossibleDay = $date->modify('next friday');
|
||||
break;
|
||||
case 5 :
|
||||
$nextPossibleDay = $date->modify('next saturday');
|
||||
break;
|
||||
case 6 :
|
||||
$nextPossibleDay = $date->modify('next sunday');
|
||||
break;
|
||||
}
|
||||
|
||||
return $nextPossibleDay;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,4 +63,9 @@
|
||||
.pin-pdr {
|
||||
height: 25px;
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
.titre {
|
||||
font-weight: 900;
|
||||
color: red;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<tr><td> </td></tr>
|
||||
|
||||
<tr style="background-color:#1A712C; color:white">
|
||||
<th>{intl l="Scheduled date" d="pointretrait"}</th>
|
||||
<td>{$day} entre {format_date date=$begin_time format="H\hi"} et {format_date date=$end_time format="H\hi"}</td>
|
||||
</tr>
|
||||
|
||||
<tr><td> </td></tr>
|
||||
@@ -0,0 +1,18 @@
|
||||
<div class="panel panel-default col-md-12">
|
||||
<div class="panel-heading"><strong>{intl l="Scheduled date" d="pointretrait"}</strong></div>
|
||||
<div class="panel-body">
|
||||
<span>{$day} entre {format_date date=$begin_time format="H\hi"} et {format_date date=$end_time format="H\hi"}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default col-md-12">
|
||||
<div class="panel-heading"><strong>{intl l="Place name" d="pointretrait"}</strong></div>
|
||||
<div class="panel-body">
|
||||
<span>{format_address organization="{$placeName}"
|
||||
address_line1="{$address1}"
|
||||
postal_code="{$zipcode}"
|
||||
locality="{$city}"
|
||||
locale=$locale}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,6 @@
|
||||
<div class="panel panel-default col-sm-6">
|
||||
<div class="panel-heading">{intl l="Scheduled date" d="pointretrait"}</div>
|
||||
<div class="panel-body">
|
||||
<span>{$day} entre {format_date date=$begin_time format="H\hi"} et {format_date date=$end_time format="H\hi"}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,24 @@
|
||||
{strip}
|
||||
|
||||
<div class="panel panel-default col-sm-6">
|
||||
{loop type="pdr_places" name="place-loop" id={$place_id}}
|
||||
<div class="panel-heading">{intl l="Order to withdraw" d="pointretrait"}</div>
|
||||
<div class="panel-body">
|
||||
<span class="org"><strong>{$TITLE}</strong></span>
|
||||
<address class="adr">
|
||||
<span class="street-address">{$ADDRESS1}</span><br>
|
||||
{if $ADDRESS2 != ""}
|
||||
<span class="street-address">{$ADDRESS2}</span><br>
|
||||
{/if}
|
||||
<span class="locality">{$ZIPCODE} {$CITY}</span>
|
||||
</address>
|
||||
</div>
|
||||
{/loop}
|
||||
|
||||
<div class="panel-heading">{intl l="Scheduled date" d="pointretrait"}</div>
|
||||
<div class="panel-body">
|
||||
<span>{$day} entre {format_date date=$begin_time format="H\hi"} et {format_date date=$end_time format="H\hi"}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/strip}
|
||||
Reference in New Issue
Block a user