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

@@ -21,12 +21,14 @@ return array(
'Location set' => 'Coordonnées GPS présentes ?',
'Main' => 'Généralités',
'Message no location' => 'Ce point de retrait ne possède pas de coordonnées GPS : pour vos clients, il est conseillé de géolocaliser l\'adresse.',
'Message info minimum de commande' => 'Vous n\'avez pas atteint le minimum de commande de %minimum € sur ce point de retrait.',
'Minimum amount' => 'Minimum de commande',
'Module name' => 'Point de Retrait AuxBieauxLegumes',
'My places' => 'Point de retrait AuxBieauxLegumes',
'My withdrawal places' => 'Mes points de retrait AuxBieauxLegumes',
'Order number' => 'N° de commande',
'Place name' => 'Nom du point de retrait',
'Please select a delivery place' => 'Veuillez sélectionner un point de retrait',
'Recenter map' => 'Géolocaliser l\'adresse',
'Revert origin position' => 'Revenir à la position d\'origine',
'Schedule' => 'Horaires de retrait',

View File

@@ -40,6 +40,7 @@ class ScheduleLoop extends BaseLoop implements PropelSearchLoopInterface
->set("DAY_LABEL", PointRetrait::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))
;
$loopResult->addRow($loopResultRow);
}

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;
}
}

View File

@@ -21,9 +21,9 @@
</div>
<div class="row" id="select-pdr">
<div class="col-md-4">
<div class="col-md-5">
{form name="thelia.order.delivery"}
<div class="table-responsive" style="border: 1px solid gray">
<div class="table-responsive" style="border: 0px solid gray">
<table class="table table-condensed table-main">
{loop type="pdr_places" name="places-loop" active=true order="city"}
<tr class="ligne-pdr">
@@ -31,14 +31,21 @@
<div class="titre-pdr"><img src="{image file='assets/img/pin.png' source='PointRetrait'}" class="img-pin"><span class="pin-number">{$ID}</span>{$TITLE}</div>
<span class="adresse">{$ADDRESS1}</span><br>
<span class="adresse">{$ZIPCODE} {$CITY}</span><br>
{if {cart attr='total_taxed_price_without_discount'} < $MINIMUM_AMOUNT}
<div class="row">
<div class="alert alert-info" style="width:95%; margin:5px">{intl l="Message info minimum de commande" d="pointretrait" minimum=$MINIMUM_AMOUNT}</div>
</div>
{else}
<table class="table table-schedule">
{loop type="pdr_schedule" name="schedule-loop" place_id={$ID}}
{loop type="pdr_schedule" name="schedule-loop" place_id={$ID}}
<tr class="creneau">
<td style="padding:10px; text-align: center">{$DAY_LABEL} {format_date date=$BEGIN format="H\hi"} à {format_date date=$END format="H\hi"}</td>
<td style="padding:10px; text-align: center"><input type="radio" name="lps-choosen-day" value="{$ID}"{if {cart attr='total_taxed_price_without_discount'} < $minimum} disabled{/if} /></td>
<td style="padding:10px; text-align: center">{$DAY_LABEL} {$CALCULATED_DAY} {format_date date=$BEGIN format="H\hi"} à {format_date date=$END format="H\hi"}</td>
<td style="padding:10px; text-align: center"><input type="radio" name="pdr-choosen-day" value="{$ID}"{if {cart attr='total_taxed_price_without_discount'} < $MINIMUM_AMOUNT} disabled{/if} /></td>
</tr>
{/loop}
{/loop}
</table>
{/if}
<div class="price">
{if $PRICE > 0}
{format_number number=$PRICE}
@@ -53,7 +60,7 @@
</div>
{/form}
</div>
<div class="col-md-8">
<div class="col-md-7">
<input type="hidden" id="map-center-lat" value={{module_config module='PlanificationLivraison' key='map_center_latitude' locale='en_US'}|default:50.75075530537203} />
<input type="hidden" id="map-center-lon" value={{module_config module='PlanificationLivraison' key='map_center_longitude' locale='en_US'}|default:2.252608244005041} />
@@ -93,14 +100,6 @@
}
});
$("#form-cart-delivery").off('submit').submit(function(ev) {
if ($('[delivery-mode=pdr]').is(':checked')
&&
$('input[name=pdr-choosen-day]:checked').length === 0) {
alert("{intl l='Please select a withdrawal' d='pointretrait' js=1}");
ev.preventDefault();
}
});
function loadScript() {
var script = document.createElement('script');
@@ -121,9 +120,8 @@
var opt = {
center: new google.maps.LatLng($("#map-center-lat").val(), $("#map-center-lon").val()),
zoom: 12,
streetViewControl: false,
mapTypeControl: false,
disableDefaultUI: true,
streetViewControl: true,
mapTypeControl: true,
restriction: {
latLngBounds: LIMITES,
strictBounds: false,