82 lines
2.5 KiB
PHP
82 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace PointRetrait\Hook;
|
|
|
|
use PointRetrait\PointRetrait;
|
|
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"],
|
|
[],
|
|
[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"
|
|
]);
|
|
}
|
|
}
|
|
|
|
/* 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
|
|
])
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|