ClickAndCollect : module finalisé
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
<tr>
|
||||
<td style="text-align: center"><a href="/admin/order/update/{$ORDER_ID}" target="_blank" title="Client : {$CUSTOMER}">{$ORDER_ID}</a></td>
|
||||
<td>
|
||||
{format_date date=$START_DATE format="d/m/Y"} entre {format_date date=$START_DATE format="H\hi"} et {format_date date=$END_DATE format="H\hi"}
|
||||
{format_date date=$START_DATE format="d/m/Y"}
|
||||
</td>
|
||||
<td><img src={$path} alt="{$alt}" title="{$title}" style="margin-right: 10px; width:25px">{$DELTA} jour(s)</td>
|
||||
<td>{$PLACE}</td>
|
||||
|
||||
@@ -41,14 +41,14 @@
|
||||
{else}
|
||||
<table class="table table-schedule">
|
||||
{assign var="nextDate" value=""}
|
||||
{loop type="pdr_schedule" name="schedule-loop" place_id={$ID}}
|
||||
{loop type="pdr_schedule" name="schedule-loop" place_id={$ID} click_and_collect=1}
|
||||
<tr class="creneau">
|
||||
<td>{$DAY_LABEL}</td>
|
||||
<td>{format_date date=$BEGIN format="H\hi"}</td>
|
||||
<td>{format_date date=$END format="H\hi"}</td>
|
||||
</tr>
|
||||
{if $nextDate eq ''}
|
||||
{assign var="nextDate" value="$DAY_LABEL $CALCULATED_DAY"}
|
||||
{assign var="nextDate" value="$CALCULATED_DAY"}
|
||||
{/if}
|
||||
{/loop}
|
||||
</table>
|
||||
@@ -127,7 +127,8 @@
|
||||
}
|
||||
};
|
||||
|
||||
DataCnc.map = new google.maps.Map(document.getElementById('cnc_map'), opt);
|
||||
if (document.getElementById('cnc_map'))
|
||||
DataCnc.map = new google.maps.Map(document.getElementById('cnc_map'), opt);
|
||||
|
||||
displayPinsCnc();
|
||||
}
|
||||
|
||||
@@ -54,12 +54,12 @@ class LivraisonParSecteurs extends AbstractDeliveryModule
|
||||
$zipcode = AddressQuery::create()->filterById($currentAddressId)->findOne($con)->getZipcode();
|
||||
|
||||
// Condition 1 : le client doit être situé dans un secteur couvert par la livraison à domicile.
|
||||
if (null !== $areaId = LpsAreaCityQuery::create()->filterByZipcode($zipcode)->findOne($con))
|
||||
if (null !== $areaId = LpsAreaCityQuery::create()->filterByZipcode($zipcode)->findOne($con)->getIdArea())
|
||||
{
|
||||
$area = LpsAreaQuery::create()->findOneById($areaId);
|
||||
|
||||
// Condition 2 : le secteur doit être actif à date.
|
||||
if ($area->getActive() === self::SECTEUR_ACTIF)
|
||||
if (null !== $area && $area->getActive() === self::SECTEUR_ACTIF)
|
||||
$isValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
<div class="scheduled-deliveries-list">
|
||||
<table class="table table-striped" id="deliveries-table">
|
||||
<thead>
|
||||
<th> </th>
|
||||
<th>{intl l="Order number" d="livraisonparsecteurs"}</th>
|
||||
<th>{intl l="Scheduled date" d="livraisonparsecteurs"}</th>
|
||||
<th>{intl l="Delivery delay" d="livraisonparsecteurs"}</th>
|
||||
@@ -43,12 +42,11 @@
|
||||
{assign var=title value="{$DELTA} jour(s) de délai"}
|
||||
|
||||
<tr>
|
||||
<td><img src={$path} alt="{$alt}" title="{$title}" style="margin-left: 30px; width:25px"></td>
|
||||
<td><a href="/admin/order/update/{$ORDER_ID}" target="_blank" title="Client : {$CUSTOMER}">{$ORDER_ID}</a></td>
|
||||
<td>
|
||||
{format_date date=$START_DATE format="d/m/Y"} entre {format_date date=$START_DATE format="H\hi"} et {format_date date=$END_DATE format="H\hi"}
|
||||
</td>
|
||||
<td>{$DELTA} jour(s)</td>
|
||||
<td><img src={$path} alt="{$alt}" title="{$title}" style="margin-right:15px; width:25px">{$DELTA} jour(s)</td>
|
||||
<td>{$CITY}</td>
|
||||
<td>{$AREA}</td>
|
||||
</tr>
|
||||
|
||||
@@ -98,6 +98,13 @@
|
||||
alert("Veuillez choisir un point de retrait.");
|
||||
ev.preventDefault();
|
||||
}
|
||||
|
||||
if ($('[delivery-mode=cnc]').is(':checked')
|
||||
&&
|
||||
$('input[name=cnc-choosen-day]:checked').length === 0) {
|
||||
alert("Veuillez choisir un point Click and Collect.");
|
||||
ev.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -103,12 +103,11 @@ class DeliveryListener extends BaseAction implements EventSubscriberInterface
|
||||
$sessionData->setPlaceId($placeId);
|
||||
|
||||
// On sauvegarde la date de disponibilité, pour affichage ultérieur.
|
||||
$now = new DateTime();
|
||||
$today = $now->format('w');
|
||||
$chosenDate = PlanificationLivraison::calculateRelativeDate($today);
|
||||
$completeDay = PlanificationLivraison::getDayLabel($today);
|
||||
$chosenDate = PlanificationLivraison::calculateRelativeDate(null, $placeId);
|
||||
$completeDay = PlanificationLivraison::getDayLabel(($chosenDate->format('w') - 1) % 6);
|
||||
$completeDay .= " " . $chosenDate->format(PlanificationLivraison::FORMAT_DATES);
|
||||
$sessionData->setDeliveryDate($completeDay);
|
||||
$sessionData->setDeliveryFullDate($chosenDate->format(PlanificationLivraison::FORMAT_DATE_COMPLETE));
|
||||
|
||||
$session->set('cncData', $sessionData);
|
||||
}
|
||||
@@ -169,12 +168,20 @@ class DeliveryListener extends BaseAction implements EventSubscriberInterface
|
||||
$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'));
|
||||
$query->setDueDeliveryTimeEnd($endDate);
|
||||
|
||||
if ($deliveryModuleId == ClickAndCollect::getModuleId()) {
|
||||
$completeDate = $sessionData->getDeliveryFullDate();
|
||||
$query->setDueDeliveryTimeStart($completeDate);
|
||||
$query->setDueDeliveryTimeEnd($completeDate);
|
||||
}
|
||||
else {
|
||||
$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'));
|
||||
$query->setDueDeliveryTimeEnd($endDate);
|
||||
}
|
||||
|
||||
$query->save($con);
|
||||
$con->commit();
|
||||
|
||||
@@ -10,7 +10,8 @@ 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',
|
||||
'Warning withdrawal date' => 'Vous pourrez récupérer votre commande à compter du %date.',
|
||||
'Warning withdrawal date complete' => 'N\'oubliez pas de venir retirer votre commande le %date entre %heure_debut et %heure_fin',
|
||||
'Monday' => 'Lundi',
|
||||
'Tuesday' => 'Mardi',
|
||||
'Wednesday' => 'Mercredi',
|
||||
|
||||
@@ -117,10 +117,10 @@ class ScheduledDeliveriesLoop extends BaseLoop implements PropelSearchLoopInterf
|
||||
$deliveries->filterByDeliveryAddressId(null, Criteria::NOT_EQUAL);
|
||||
break;
|
||||
case self::RETRAIT:
|
||||
$deliveries->filterByDeliveryPlaceId(null, Criteria::NOT_EQUAL)->filterByDeliveryPlaceId($clickAndCollectPlaces, Criteria::NOT_IN);
|
||||
$deliveries->filterByDeliveryPlaceId($clickAndCollectPlaces, Criteria::IN);
|
||||
break;
|
||||
case self::CLICK_AND_COLLECT:
|
||||
$deliveries->filterByDeliveryPlaceId(null, Criteria::NOT_EQUAL)->filterByDeliveryPlaceId($clickAndCollectPlaces, Criteria::IN);
|
||||
$deliveries->filterByDeliveryPlaceId($clickAndCollectPlaces, Criteria::NOT_IN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -8,11 +8,29 @@ class SessionData
|
||||
{
|
||||
protected $scheduleId = null;
|
||||
protected $deliveryDate = null;
|
||||
protected $deliveryFullDate = null;
|
||||
protected $deliveryStartTime = null;
|
||||
protected $deliveryEndTime = null;
|
||||
protected $deliveryAddressId = null;
|
||||
protected $placeId = null;
|
||||
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getDeliveryFullDate()
|
||||
{
|
||||
return $this->deliveryFullDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $deliveryFullDate
|
||||
*/
|
||||
public function setDeliveryFullDate($deliveryFullDate)
|
||||
{
|
||||
$this->deliveryFullDate = $deliveryFullDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace PlanificationLivraison;
|
||||
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use PointRetrait\Model\PdrScheduleQuery;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Install\Database;
|
||||
@@ -13,7 +15,17 @@ class PlanificationLivraison extends BaseModule
|
||||
/** @var string */
|
||||
const DOMAIN_NAME = 'planificationlivraison';
|
||||
const FORMAT_DATES = 'd/m/Y';
|
||||
const FORMAT_DATE_AVEC_JOUR = 'w d/m/Y';
|
||||
const FORMAT_DATE_COMPLETE = 'Y-m-d H:i:s';
|
||||
const DAYS_OF_WEEK = [
|
||||
0 => 'monday',
|
||||
1 => 'tuesday',
|
||||
2 => 'wednesday',
|
||||
3 => 'thursday',
|
||||
4 => 'friday',
|
||||
5 => 'saturday',
|
||||
6 => 'sunday'
|
||||
];
|
||||
|
||||
const CONFIG_API_KEY = 'googlemap_api_key';
|
||||
const CONFIG_MAP_CENTER_LAT = 'map_center_latitude';
|
||||
@@ -32,36 +44,53 @@ class PlanificationLivraison extends BaseModule
|
||||
$database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
|
||||
}
|
||||
|
||||
static public function calculateRelativeDate($baseDay)
|
||||
|
||||
static public function calculateRelativeDate($baseDay, $placeId = null)
|
||||
{
|
||||
$minimumDelayBeforeOrder = PlanificationLivraison::getConfigValue(PlanificationLivraison::CONFIG_PREPARATION_DELAY, 0, "en_US");
|
||||
|
||||
$date = new \DateTime();
|
||||
$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;
|
||||
if (null !== $baseDay) { // Cas où l'on a choisi une date
|
||||
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;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
// Cas du Click and Collect où l'on doit prendre la première date dispo
|
||||
if (null !== $placeId) {
|
||||
|
||||
$allPossibleDaysOfWeek = PdrScheduleQuery::create()->filterByIdPlace($placeId)->orderByDay()->find()->getData();
|
||||
$allPossibleDays = [];
|
||||
foreach ($allPossibleDaysOfWeek as $theDay) {
|
||||
$dow = self::DAYS_OF_WEEK[$theDay->getDay()];
|
||||
array_push($allPossibleDays, date(self::FORMAT_DATE_COMPLETE, strtotime("next $dow", $date->getTimestamp())));
|
||||
}
|
||||
$nextPossibleDay = new DateTime(min($allPossibleDays));
|
||||
}
|
||||
}
|
||||
|
||||
return $nextPossibleDay;
|
||||
|
||||
@@ -20,7 +20,7 @@ return array(
|
||||
'Free' => 'Gratuit',
|
||||
'Location set' => 'Coordonnées GPS présentes ?',
|
||||
'Main' => 'Généralités',
|
||||
'Message explicatif' => 'Il est possible de récupérer votre commande directement auprès de nous, lors d\'une de nos tournées.',
|
||||
'Message explicatif' => 'Il est possible de récupérer votre commande directement auprès de nous, lors de notre prochaine tournée.',
|
||||
'Message no location' => 'Ce point de retrait ne possède pas de coordonnées GPS : pour vos clients, il est conseillé de géolocaliser son 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',
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace PointRetrait\Loop;
|
||||
|
||||
use PlanificationLivraison\PlanificationLivraison;
|
||||
use PointRetrait\Model\PdrScheduleQuery;
|
||||
use PointRetrait\PointRetrait;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -31,8 +30,20 @@ class ScheduleLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$theDate = '';
|
||||
|
||||
foreach ($loopResult->getResultDataCollection() as $pdr_schedule) {
|
||||
|
||||
if (null === $this->getClickAndCollect()) {
|
||||
$theDate = PlanificationLivraison::calculateRelativeDate($pdr_schedule->getDay(), null);
|
||||
}
|
||||
else {
|
||||
$newDate = PlanificationLivraison::calculateRelativeDate(null, $this->getPlaceId());
|
||||
if ($theDate == '' || $newDate < $theDate)
|
||||
$theDate = $newDate;
|
||||
}
|
||||
|
||||
|
||||
$loopResultRow = new LoopResultRow($pdr_schedule);
|
||||
$loopResultRow
|
||||
->set("ID", $pdr_schedule->getId())
|
||||
@@ -41,7 +52,7 @@ class ScheduleLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
->set("DAY_LABEL", PlanificationLivraison::getDayLabel($pdr_schedule->getDay()))
|
||||
->set("BEGIN", $pdr_schedule->getBeginTime())
|
||||
->set("END", $pdr_schedule->getEndTime())
|
||||
->set("CALCULATED_DAY", PlanificationLivraison::calculateRelativeDate($pdr_schedule->getDay())->format(PlanificationLivraison::FORMAT_DATES))
|
||||
->set("CALCULATED_DAY", PlanificationLivraison::getDayLabel(($theDate->format('w') - 1) % 6) . ' ' . $theDate->format(PlanificationLivraison::FORMAT_DATES))
|
||||
;
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
@@ -56,7 +67,8 @@ class ScheduleLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('place_id')
|
||||
Argument::createIntListTypeArgument('place_id'),
|
||||
Argument::createBooleanTypeArgument('click_and_collect', null)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<table class="table table-schedule">
|
||||
{loop type="pdr_schedule" name="schedule-loop" place_id={$ID}}
|
||||
<tr class="creneau">
|
||||
<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">{$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}
|
||||
@@ -82,7 +82,6 @@
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
// Masquer par défaut les options du mode PDR
|
||||
@@ -102,17 +101,17 @@
|
||||
var script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = "https://maps.googleapis.com/maps/api/js?callback=initMaps" +
|
||||
"&key={module_config module='PlanificationLivraison' key='googlemap_api_key' locale='en_US'}";
|
||||
"&key={module_config module='PlanificationLivraison' key='googlemap_api_key' locale='en_US'}";
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
|
||||
function initMaps() {
|
||||
initMap();
|
||||
initMapCnc();
|
||||
if (typeof initMapPdr === "function") initMapPdr();
|
||||
if (typeof initMapCnc === "function") initMapCnc();
|
||||
}
|
||||
|
||||
function initMap() {
|
||||
function initMapPdr() {
|
||||
const LIMITES = {
|
||||
north: 50.85043724044059,
|
||||
east: 2.6869845409159923,
|
||||
@@ -131,12 +130,13 @@
|
||||
}
|
||||
};
|
||||
|
||||
Data.map = new google.maps.Map(document.getElementById('pdr_map'), opt);
|
||||
if (document.getElementById('pdr_map'))
|
||||
Data.map = new google.maps.Map(document.getElementById('pdr_map'), opt);
|
||||
|
||||
displayPins();
|
||||
displayPinsPdr();
|
||||
}
|
||||
|
||||
function displayPins() {
|
||||
function displayPinsPdr() {
|
||||
var arrays = [];
|
||||
$('#coordinates').eq(0).find('tr').each((r,row) => arrays.push($(row).find('td,th').map((c,cell) => $(cell).text()).toArray()))
|
||||
|
||||
@@ -167,4 +167,4 @@
|
||||
initMaps();
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
Reference in New Issue
Block a user