Quelques corrections + init du module ClickAndCollect
This commit is contained in:
82
local/modules/ClickAndCollect/Hook/AdminHook.php
Normal file
82
local/modules/ClickAndCollect/Hook/AdminHook.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace ClickAndCollect\Hook;
|
||||
|
||||
use ClickAndCollect\ClickAndCollect;
|
||||
use Thelia\Core\Event\Hook\HookRenderBlockEvent;
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
|
||||
/**
|
||||
* Class AdminHook
|
||||
*/
|
||||
class AdminHook extends BaseHook
|
||||
{
|
||||
protected $securityContext;
|
||||
|
||||
public function __construct(SecurityContext $securityContext)
|
||||
{
|
||||
$this->securityContext = $securityContext;
|
||||
}
|
||||
|
||||
|
||||
public function onMainTopMenuTools(HookRenderEvent $event)
|
||||
{
|
||||
$isGranted = $this->securityContext->isGranted(
|
||||
["ADMIN"],
|
||||
[],
|
||||
[ClickAndCollect::getModuleCode()],
|
||||
[AccessManager::VIEW]
|
||||
);
|
||||
|
||||
if ($isGranted) {
|
||||
$event->add($this->render("menu-hook.html", $event->getArguments()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Pour afficher la liste des retraits en Click and Collect, dans la page d'accueil backOffice */
|
||||
public function displayScheduledWithdrawals(HookRenderBlockEvent $event)
|
||||
{
|
||||
$content = trim($this->render("scheduled-clickandcollect.html"));
|
||||
if (!empty($content)) {
|
||||
$event->add([
|
||||
"id" => "block-scheduled-clickandcollect",
|
||||
"title" => $this->trans("Scheduled click and collect", [], ClickAndCollect::DOMAIN_NAME),
|
||||
"content" => $content,
|
||||
"class" => "col-md-6"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Pour intégrer la date de retrait possible dans différents formulaires (email, backOffice, ...) */
|
||||
public function displayDeliveryDate(HookRenderEvent $event)
|
||||
{
|
||||
|
||||
$moduleId = $event->getArgument('module');
|
||||
$orderId = $event->getArgument('order_id');
|
||||
|
||||
if ((null !== $orderId) && ($moduleId == ClickAndCollect::getModuleId()))
|
||||
{
|
||||
$sessionData = $this->getSession()->get('cncData');
|
||||
$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
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
local/modules/ClickAndCollect/Hook/CssHook.php
Normal file
17
local/modules/ClickAndCollect/Hook/CssHook.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace ClickAndCollect\Hook;
|
||||
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
|
||||
/**
|
||||
* Class CssHook
|
||||
*/
|
||||
class CssHook extends BaseHook
|
||||
{
|
||||
public function onAddCss(HookRenderEvent $event)
|
||||
{
|
||||
$event->add($this->addCSS('assets/css/styles.css'));
|
||||
}
|
||||
}
|
||||
82
local/modules/ClickAndCollect/Hook/EmailHook.php
Normal file
82
local/modules/ClickAndCollect/Hook/EmailHook.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace ClickAndCollect\Hook;
|
||||
|
||||
use ClickAndCollect\ClickAndCollect;
|
||||
use PointRetrait\Model\PdrPlacesQuery;
|
||||
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 == ClickAndCollect::getModuleId()))
|
||||
{
|
||||
$sessionData = $this->getSession()->get('cncData');
|
||||
$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("ClickAndCollect : 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 == ClickAndCollect::getModuleId()))
|
||||
{
|
||||
$sessionData = $this->getSession()->get('cncData');
|
||||
$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("ClickAndCollect : Impossible de récupérer les données de session SessionData");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
56
local/modules/ClickAndCollect/Hook/FrontHook.php
Normal file
56
local/modules/ClickAndCollect/Hook/FrontHook.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace ClickAndCollect\Hook;
|
||||
|
||||
use ClickAndCollect\ClickAndCollect;
|
||||
use PointRetrait\PointRetrait;
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
|
||||
class FrontHook extends BaseHook
|
||||
{
|
||||
|
||||
public function onOrderDeliveryExtra(HookRenderEvent $event)
|
||||
{
|
||||
$event->add(
|
||||
$this->render(
|
||||
'order-delivery-extra.html',
|
||||
[
|
||||
'module_id' => ClickAndCollect::getModuleId()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function displayWithdrawalDate(HookRenderEvent $event)
|
||||
{
|
||||
$order = $this->getSession()->getOrder();
|
||||
if ((null !== $order) && $order->getDeliveryModuleId() == PointRetrait::getModuleId())
|
||||
{
|
||||
$sessionData = $this->getSession()->get('cncData');
|
||||
$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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user