LivraisonParSecteurs : modif du stockage en session des données nécessaires

This commit is contained in:
2021-03-09 10:41:58 +01:00
parent 9643b76aed
commit c97324ff5f
15 changed files with 250 additions and 59 deletions

View File

@@ -2,6 +2,9 @@
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;
@@ -11,6 +14,8 @@ use Thelia\Model\Country;
use Thelia\Model\OrderPostage;
use Thelia\Module\AbstractDeliveryModule;
use Thelia\Module\Exception\DeliveryException;
use DateInterval;
class PointRetrait extends AbstractDeliveryModule
@@ -19,6 +24,13 @@ 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';
/**
@@ -65,12 +77,9 @@ class PointRetrait extends AbstractDeliveryModule
}
$price = 0;
$con = Propel::getConnection();
$currentAddressId = $this->getRequest()->getSession()->getOrder()->getChoosenDeliveryAddress();
if (!empty($currentAddressId)) {
$zipcode = AddressQuery::create()->filterById($currentAddressId)->findOne($con)->getZipcode();
// $areaId = LpsAreaCityQuery::create()->findOneByZipcode($zipcode)->getIdArea();
// $price = LpsAreaQuery::create()->findOneById($areaId)->getPrice();
if (null !== $chosenPlace = $this->getRequest()->get(('pdr-choosen-day'))) {
$placeId = PdrScheduleQuery::create()->findOneById($chosenPlace)->getIdPlace();
$price = PdrPlacesQuery::create()->findOneById($placeId)->getPrice();
}
return $price;
@@ -97,4 +106,39 @@ class PointRetrait extends AbstractDeliveryModule
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;
}
}