LivraisonParSecteur : Rajout de la gestion du minimum de commande
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
INSERT INTO `lps_area`(`id`,`title`) VALUES
|
||||
(1, 'Capso'),
|
||||
(2, 'Pays de Lumbres'),
|
||||
(3, 'Haut des Flandres'),
|
||||
(4, 'Flandres intérieur');
|
||||
INSERT INTO `lps_area`(`id`,`title`,`minimum_amount`) VALUES
|
||||
(1, 'Capso', 15.0),
|
||||
(2, 'Pays de Lumbres', 15.0),
|
||||
(3, 'Haut des Flandres', 15.0),
|
||||
(4, 'Flandres intérieur', 15.0);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<column name="title" required="true" size="50" type="VARCHAR" />
|
||||
<column name="active" required="true" type="TINYINT" defaultValue="1" />
|
||||
<column name="price" required="true" type="FLOAT" defaultValue="0" />
|
||||
<column name="minimum_amount" required="true" type="FLOAT" defaultValue="15" />
|
||||
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Sqlfile -> Database map
|
||||
thelia.sql=thelia
|
||||
@@ -1,71 +0,0 @@
|
||||
|
||||
# This is a fix for InnoDB in MySQL >= 4.1.x
|
||||
# It "suspends judgement" for fkey relationships until are tables are set.
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- lps_area
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `lps_area`;
|
||||
|
||||
CREATE TABLE `lps_area`
|
||||
(
|
||||
`id` INTEGER NOT NULL,
|
||||
`title` VARCHAR(50) NOT NULL,
|
||||
`active` TINYINT DEFAULT 1 NOT NULL,
|
||||
`price` FLOAT DEFAULT 0 NOT NULL,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- lps_area_city
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `lps_area_city`;
|
||||
|
||||
CREATE TABLE `lps_area_city`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`id_area` INTEGER NOT NULL,
|
||||
`zipcode` VARCHAR(10) NOT NULL,
|
||||
`title` VARCHAR(50) NOT NULL,
|
||||
`latitude` DOUBLE,
|
||||
`longitude` DOUBLE,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `fi_area_area_city` (`id_area`),
|
||||
CONSTRAINT `fk_area_area_city`
|
||||
FOREIGN KEY (`id_area`)
|
||||
REFERENCES `lps_area` (`id`)
|
||||
ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- lps_area_schedule
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `lps_area_schedule`;
|
||||
|
||||
CREATE TABLE `lps_area_schedule`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`id_area` INTEGER NOT NULL,
|
||||
`day` INTEGER NOT NULL,
|
||||
`begin_time` TIME NOT NULL,
|
||||
`end_time` TIME NOT NULL,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `fi_area_area_schedule` (`id_area`),
|
||||
CONSTRAINT `fk_area_area_schedule`
|
||||
FOREIGN KEY (`id_area`)
|
||||
REFERENCES `lps_area` (`id`)
|
||||
ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
# This restores the fkey checks, after having unset them earlier
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -35,6 +35,15 @@ class GeneralForm extends BaseForm
|
||||
"label" => $this->translator->trans('Delivery price', [], LivraisonParSecteurs::DOMAIN_NAME),
|
||||
"label_attr" => ['for' => 'price']
|
||||
])
|
||||
->add(
|
||||
"minimum_amount",
|
||||
"number",
|
||||
[
|
||||
"required" => true,
|
||||
"constraints" => [new GreaterThanOrEqual(["value" => 0])],
|
||||
"label" => $this->translator->trans('Minimum amount', [], LivraisonParSecteurs::DOMAIN_NAME),
|
||||
"label_attr" => ['for' => 'minimum_amount']
|
||||
])
|
||||
->add(
|
||||
"active",
|
||||
"number",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace LivraisonParSecteurs\Hook;
|
||||
|
||||
use LivraisonParSecteurs\LivraisonParSecteurs;
|
||||
use Thelia\Core\Event\Hook\HookRenderBlockEvent;
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
@@ -34,6 +35,7 @@ class AdminHook extends BaseHook
|
||||
}
|
||||
}
|
||||
|
||||
/* Pour intégrer la date prévue de livraison dans différents formulaires (email, backOffice, ...) */
|
||||
public function displayDeliveryDate(HookRenderEvent $event)
|
||||
{
|
||||
|
||||
@@ -60,4 +62,18 @@ class AdminHook extends BaseHook
|
||||
}
|
||||
}
|
||||
|
||||
/* Pour afficher la liste des livraisons à effectuer dans la page d'accueil backOffice */
|
||||
public function displayScheduledDeliveries(HookRenderBlockEvent $event)
|
||||
{
|
||||
$content = trim($this->render("scheduled-deliveries.html"));
|
||||
if (!empty($content)) {
|
||||
$event->add([
|
||||
"id" => "block-scheduled-deliveries",
|
||||
"title" => $this->trans("Scheduled deliveries", [], LivraisonParSecteurs::DOMAIN_NAME),
|
||||
"content" => $content,
|
||||
"class" => "col-md-8"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@ return array(
|
||||
'Actions' => 'Actions',
|
||||
'Add a new city' => 'Rajouter une commune',
|
||||
'Add a new delivery day' => 'Ajouter un jour de livraison',
|
||||
'Area' => 'Secteur',
|
||||
'Area name' => 'Nom du secteur',
|
||||
'Choose this day' => 'Choisissez ce jour',
|
||||
'Choose this day' => 'Je choisis ce créneau',
|
||||
'Cities' => 'Communes desservies',
|
||||
'City' => 'Commune',
|
||||
'Create a delivery day' => 'Créer un nouveau jour de livraison',
|
||||
@@ -23,16 +24,21 @@ return array(
|
||||
'Format to respect' => 'Merci de respecter le format 50.255612 ou -3.121146 (le séparateur est un point et le nombre peut être négatif)',
|
||||
'General' => 'Général',
|
||||
'Home delivery cost' => 'Frais de livraison à domicile',
|
||||
'Message info minimum de commande' => 'La livraison à domicile est soumise à un montant minimum de commande sur votre secteur : il est possible que vous n\'ayez pas atteint ce minimum.',
|
||||
'Minimum amount' => 'Montant minimum de commande',
|
||||
'Modify a delivery day' => 'Modifier un jour de livraison',
|
||||
'Module name' => 'Livraison à domicile',
|
||||
'My areas' => 'Mes secteurs de livraison',
|
||||
'Next delivery day' => 'Prochain jour de livraison',
|
||||
'Order number' => 'Commande n°',
|
||||
'Please select a delivery day' => 'Veuillez choisir un jour de livraison',
|
||||
'Remove this city' => 'Retirer cette commune',
|
||||
'Save' => 'Sauvegarder',
|
||||
'Schedule' => 'Horaires de livraison',
|
||||
'Scheduled date' => 'Livraison prévue le',
|
||||
'Scheduled deliveries' => 'Livraisons à domicile planifiées',
|
||||
'There is no city delivered in this area' => 'Aucune commune desservie dans ce secteur',
|
||||
'There is no order to deliver' => 'Aucune commande à livrer à domicile',
|
||||
'There is no schedule for this area' => 'Aucune livraison actuellement sur ce secteur',
|
||||
'Title of config view' => 'Module LivraisonParSecteurs - Confiwguration',
|
||||
'Zipcode' => 'Code postal',
|
||||
|
||||
@@ -7,6 +7,7 @@ use LivraisonParSecteurs\Model\LpsAreaCityQuery;
|
||||
use LivraisonParSecteurs\Model\LpsAreaQuery;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Propel;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Install\Database;
|
||||
use Thelia\Model\AddressQuery;
|
||||
@@ -28,6 +29,10 @@ class LivraisonParSecteurs extends AbstractDeliveryModule
|
||||
const LPS_DELIVERY_DATE = 'lps_delivery_date';
|
||||
const LPS_DELIVERY_BEGIN_TIME = 'lps_begin_time';
|
||||
const LPS_DELIVERY_END_TIME = 'lps_end_time';
|
||||
const FORMAT_DATES = 'd/m/Y';
|
||||
const FORMAT_HEURES = 'H:i';
|
||||
const FORMAT_DATE_COMPLETE = 'Y-m-d H:i:s';
|
||||
|
||||
|
||||
/**
|
||||
* @param ConnectionInterface|null $con
|
||||
@@ -59,8 +64,17 @@ class LivraisonParSecteurs extends AbstractDeliveryModule
|
||||
if (!empty($currentAddressId)) {
|
||||
$zipcode = AddressQuery::create()->filterById($currentAddressId)->findOne($con)->getZipcode();
|
||||
|
||||
if (null !== LpsAreaCityQuery::create()->filterByZipcode($zipcode)->findOne($con))
|
||||
$isValid = true;
|
||||
// Condition 1 : le client doit être situé dans un secteur couvert par la livraison à domicile.
|
||||
if (null !== $areaId = LpsAreaCityQuery::create()->filterByZipcode($zipcode)->findOne($con))
|
||||
{
|
||||
|
||||
// Condition 2 : il doit avoir atteint le minimum de commande.
|
||||
$montantPanier = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getTaxedAmount($country);
|
||||
$montantMinimum = LpsAreaQuery::create()->findOneById($areaId)->getMinimumAmount();
|
||||
|
||||
if ($montantPanier >= $montantMinimum)
|
||||
$isValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $isValid;
|
||||
|
||||
@@ -48,6 +48,7 @@ class AreaLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
->set("TITLE", $lps_area->getTitle())
|
||||
->set("ACTIVE", $lps_area->getActive())
|
||||
->set("PRICE", $lps_area->getPrice())
|
||||
->set("MINIMUM_AMOUNT", $lps_area->getMinimumAmount())
|
||||
->set("DELIVERY_DAYS", $deliveryDays)
|
||||
->set("COVERED_CITIES_NUMBER", $citiesCount)
|
||||
;
|
||||
|
||||
@@ -34,11 +34,12 @@ class AreaScheduleLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
$loopResultRow = new LoopResultRow($lps_area_schedule);
|
||||
$loopResultRow
|
||||
->set("ID", $lps_area_schedule->getId())
|
||||
->set("AREA_ID", $lps_area_schedule->getIdArea())
|
||||
->set("DAY", $lps_area_schedule->getDay())
|
||||
->set("DAY_LABEL", LivraisonParSecteurs::getDayLabel($lps_area_schedule->getDay()))
|
||||
->set("BEGIN", $lps_area_schedule->getBeginTime())
|
||||
->set("END", $lps_area_schedule->getEndTime())
|
||||
->set("CALCULATED_DAY", LivraisonParSecteurs::calculateRelativeDate($lps_area_schedule->getDay())->format("d/m"))
|
||||
->set("CALCULATED_DAY", LivraisonParSecteurs::calculateRelativeDate($lps_area_schedule->getDay())->format(LivraisonParSecteurs::FORMAT_DATES))
|
||||
;
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
@@ -51,6 +52,7 @@ class AreaScheduleLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('area_id')
|
||||
);
|
||||
}
|
||||
@@ -61,6 +63,9 @@ class AreaScheduleLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$area = LpsAreaScheduleQuery::create();
|
||||
if (null != $id = $this->getId()) {
|
||||
$area->filterById($id);
|
||||
}
|
||||
if (null != $id = $this->getAreaId()) {
|
||||
$area->filterByIdArea($id);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<tr style="background-color:#1A712C; color:white">
|
||||
<th>{intl l="Scheduled date" d="livraisonparsecteurs"}</th>
|
||||
<td>{$day} entre {format_date date=$begin_time format="H:i"} et {format_date date=$end_time format="H:i"}</td>
|
||||
<td>{$day} entre {format_date date=$begin_time format="H\hi"} et {format_date date=$end_time format="H\hi"}</td>
|
||||
</tr>
|
||||
|
||||
<tr><td> </td></tr>
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<th>{intl l="Area name" d='livraisonparsecteurs'}</th>
|
||||
<th class="col-md-1">{intl l="Active" d='livraisonparsecteurs'}</th>
|
||||
<th>{intl l="Delivery price" d='livraisonparsecteurs'}</th>
|
||||
<th>{intl l="Minimum amount" d='livraisonparsecteurs'}</th>
|
||||
<th>{intl l="Delivery days" d='livraisonparsecteurs'}</th>
|
||||
<th>{intl l="Delivered cities count" d='livraisonparsecteurs'}</th>
|
||||
<th class="col-md-1"> </th>
|
||||
@@ -38,7 +39,7 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{loop name="areas" type="lps_area" backend_context="yes"}
|
||||
{loop name="areas" type="lps_area"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/module/LivraisonParSecteurs/edit' area_id=$ID}">{$TITLE}</a></td>
|
||||
<td>
|
||||
@@ -49,6 +50,7 @@
|
||||
</div>
|
||||
</td>
|
||||
<td>{$PRICE} €</td>
|
||||
<td>{$MINIMUM_AMOUNT} €</td>
|
||||
<td>{$DELIVERY_DAYS}{if $DELIVERY_DAYS eq ''}<i>{intl l="There is no schedule for this area" d="livraisonparsecteurs"}</i>{/if}</td>
|
||||
<td>{$COVERED_CITIES_NUMBER}</td>
|
||||
<td class="actions">
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
{form_error form=$form field="begin_time"}{$message}{/form_error}
|
||||
<div class='input-group time' id="{$label_attr.for}">
|
||||
<input type='text' class="form-control" name="{$name}" value="{$BEGIN|default:"9:00"}"/>
|
||||
<input type='text' class="form-control" name="{$name}" value="{$BEGIN|default:"14:00"}"/>
|
||||
<span class="input-group-addon">
|
||||
<span class="glyphicon glyphicon-time"></span>
|
||||
</span>
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
{form_error form=$form field="end_time"}{$message}{/form_error}
|
||||
<div class='input-group time' id="{$label_attr.for}">
|
||||
<input type='text' class="form-control" name="{$name}" value="{$END|default:"12:00"}"/>
|
||||
<input type='text' class="form-control" name="{$name}" value="{$END|default:"16:00"}"/>
|
||||
<span class="input-group-addon">
|
||||
<span class="glyphicon glyphicon-time"></span>
|
||||
</span>
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
{/form_field}
|
||||
|
||||
<div class="row form-inline">
|
||||
<div class="col-md-3"> </div>
|
||||
<div class="col-md-3">
|
||||
{form_field form=$form field="active"}
|
||||
<div class="form-group">
|
||||
@@ -54,7 +53,23 @@
|
||||
{form_error form=$form field="price"}{$message}{/form_error}
|
||||
{/form_field}
|
||||
</div>
|
||||
<div class="col-md-3"> </div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{form_field form=$form field="minimum_amount"}
|
||||
<div class="form-group form-inline">
|
||||
<label class="control-label" for="{$label_attr.for}">
|
||||
{intl l=$label d='livraisonparsecteurs'}
|
||||
{if $required}<span class="required">*</span>{/if}
|
||||
</label>
|
||||
|
||||
<input type="text" id="{$label_attr.for}" class="form-control" name="{$name}" value="{$MINIMUM_AMOUNT}" {if $required}required{/if} /> €
|
||||
</div>
|
||||
{form_error form=$form field="minimum_amount"}{$message}{/form_error}
|
||||
{/form_field}
|
||||
</div>
|
||||
|
||||
<div class="col-md-2"> </div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
{/loop}
|
||||
|
||||
@@ -51,8 +51,8 @@
|
||||
{loop name="area-schedule" type="lps_area_schedule" area_id=$area_id}
|
||||
<tr>
|
||||
<td>{$DAY_LABEL}</td>
|
||||
<td>{format_date date=$BEGIN format="H:i"}</td>
|
||||
<td>{format_date date=$END format="H:i"}</td>
|
||||
<td>{format_date date=$BEGIN format="H\hi"}</td>
|
||||
<td>{format_date date=$END format="H\hi"}</td>
|
||||
{* Actions *}
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
@@ -60,8 +60,9 @@
|
||||
<a class="btn btn-info btn-responsive area-schedule-update-default"
|
||||
title="{intl l='Modify this delivery day' d='livraisonparsecteurs'}"
|
||||
data-target="#area-schedule-update" data-toggle="modal" data-id="{$ID}"
|
||||
data-day="{$DAY}" data-begin="{format_date date=$BEGIN format="H:i"}"
|
||||
data-end="{format_date date=$END format="H:i"}">
|
||||
data-day="{$DAY}"
|
||||
data-begin="{format_date date=$BEGIN format='H:i'}"
|
||||
data-end="{format_date date=$END format='H:i'}">
|
||||
<i class="glyphicon glyphicon-edit"></i>
|
||||
</a>
|
||||
{/loop}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<style>
|
||||
#block-scheduled-deliveries > div.scheduled-deliveries-list > table > thead > tr > th,
|
||||
#block-scheduled-deliveries > div.scheduled-deliveries-list > table > tbody > tr > td {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.nb-commandes {
|
||||
font-size: 14px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
.nb-commandes b {
|
||||
color: orange;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
{loop type="auth" name="can_view" role="ADMIN" module="HookAdminHome" access="VIEW"}
|
||||
<div class="scheduled-deliveries-list">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<th>{intl l="Order number" d="livraisonparsecteurs"}</th>
|
||||
<th>{intl l="Scheduled date" d="livraisonparsecteurs"}</th>
|
||||
<th>{intl l="City" d="livraisonparsecteurs"}</th>
|
||||
<th>{intl l="Area" d="livraisonparsecteurs"}</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{loop name="deliveries-loop" type="scheduled_deliveries" order="date"}
|
||||
{if $DELTA <= 7}
|
||||
{assign var=path value="{image file='/assets/img/flag-green.png'}"}
|
||||
{assign var=alt value='Drapeau vert'}
|
||||
{/if}
|
||||
{if $DELTA <= 4}
|
||||
{assign var=path value="{image file='/assets/img/flag-orange.png'}"}
|
||||
{assign var=alt value='Drapeau orange'}
|
||||
{/if}
|
||||
{if $DELTA <= 1}
|
||||
{assign var=path value="{image file='/assets/img/flag-red.png'}"}
|
||||
{assign var=alt value='Drapeau rouge'}
|
||||
{/if}
|
||||
{assign var=title value="{$DELTA} jour(s) de délai"}
|
||||
|
||||
{loop name="order-loop" type="order" id={$ORDER_ID} customer="*"}
|
||||
{loop type="customer" name="customer-loop" current="false" id=$CUSTOMER}
|
||||
{assign var=client value="$FIRSTNAME $LASTNAME"}
|
||||
{/loop}
|
||||
{loop type="order_address" name="address-loop" id=$DELIVERY_ADDRESS}
|
||||
{assign var=commune value=$CITY}
|
||||
{/loop}
|
||||
{/loop}
|
||||
|
||||
<tr>
|
||||
<td><a href="/admin/order/update/{$ORDER_ID}" target="_blank" title="Client : {$client}">{$ORDER_ID}</a></td>
|
||||
<td>
|
||||
{format_date date=$START_DATE format="d/m"} entre {format_date date=$START_DATE format="H:i"} et {format_date date=$END_DATE format="H:i"}, soit dans <strong>{$DELTA}</strong> jour(s)
|
||||
<img src={$path} alt="{$alt}" title="{$title}" style="margin-left: 30px; width:25px">
|
||||
</td>
|
||||
<td>{$commune}</td>
|
||||
<td>{loop name="area-schedule-loop" type="lps_area_schedule" id={$SCHEDULE_ID}}
|
||||
{loop name="area-loop" type="lps_area" id={$AREA_ID}}
|
||||
{$TITLE}
|
||||
{/loop}
|
||||
{/loop}
|
||||
</td>
|
||||
</tr>
|
||||
{if $LOOP_COUNT == $LOOP_TOTAL}{assign var=nbCommandes value=$LOOP_TOTAL}{/if}
|
||||
|
||||
{/loop}
|
||||
{elseloop rel="deliveries-loop"}
|
||||
<tr>
|
||||
<td colspan="1000">
|
||||
<div class="alert alert-info">
|
||||
{intl l="There is no order to deliver" d="livraisonparsecteurs"}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/elseloop}
|
||||
</tbody>
|
||||
</table>
|
||||
<span class="nb-commandes">Total : <b>{$nbCommandes}</b> commande(s)</span>
|
||||
|
||||
</div>
|
||||
{/loop}
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="panel panel-default col-sm-6">
|
||||
<div class="panel-heading"><strong>{intl l="Scheduled date" d="livraisonparsecteurs"}</strong></div>
|
||||
<div class="panel-body">
|
||||
<span>{$day} entre {format_date date=$begin_time format="H:i"} et {format_date date=$end_time format="H:i"}</span>
|
||||
<span>{$day} entre {format_date date=$begin_time format="H\hi"} et {format_date date=$end_time format="H\hi"}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<div class="panel-heading">{intl l="Scheduled date" d="livraisonparsecteurs"}</div>
|
||||
<div class="panel-body">
|
||||
<span>{$day} entre {format_date date=$begin_time format="H:i"} et {format_date date=$end_time format="H:i"}</span>
|
||||
<span>{$day} entre {format_date date=$begin_time format="H\hi"} et {format_date date=$end_time format="H\hi"}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
{loop type="lps_area_schedule" name="area-schedule" area_id={$area_id}}
|
||||
<tr>
|
||||
<td style="padding:10px; text-align: center">{$DAY_LABEL} {$CALCULATED_DAY}</td>
|
||||
<td style="padding:10px; text-align: center">{format_date date=$BEGIN format="H:i"} à {format_date date=$END format="H:i"}</td>
|
||||
<td style="padding:10px; text-align: center">{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}" /></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
@@ -11,4 +11,8 @@
|
||||
</service>
|
||||
</services>
|
||||
|
||||
<loops>
|
||||
<loop name="scheduled_deliveries" class="PlanificationLivraison\Loop\ScheduledDeliveriesLoop"/>
|
||||
</loops>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -59,7 +59,7 @@ class DeliveryListener extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
// On sauvegarde la date de livraison choisie avec les heures, pour affichage ultérieur.
|
||||
$completeDay = LivraisonParSecteurs::getDayLabel($schedule->getDay());
|
||||
$completeDay .= " " . $chosenDate->format("d/m");
|
||||
$completeDay .= " " . $chosenDate->format(LivraisonParSecteurs::FORMAT_DATES);
|
||||
$session->set(LivraisonParSecteurs::LPS_DELIVERY_DATE, $completeDay);
|
||||
$session->set(LivraisonParSecteurs::LPS_DELIVERY_BEGIN_TIME, $schedule->getBeginTime());
|
||||
$session->set(LivraisonParSecteurs::LPS_DELIVERY_END_TIME, $schedule->getEndTime());
|
||||
@@ -94,7 +94,7 @@ class DeliveryListener extends BaseAction implements EventSubscriberInterface
|
||||
$schedule = LpsAreaScheduleQuery::create()->findOneById($scheduleId);
|
||||
$chosenDate = LivraisonParSecteurs::calculateRelativeDate($schedule->getDay());
|
||||
|
||||
$format = 'Y-m-d H:i:s';
|
||||
$format = LivraisonParSecteurs::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'));
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace PlanificationLivraison\Loop;
|
||||
|
||||
use DateTime;
|
||||
use PlanificationLivraison\Model\OrderDeliveryScheduleQuery;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
/**
|
||||
* Class ScheduledDeliveriesLoop
|
||||
* @package PlanificationLivraison\Loop
|
||||
*/
|
||||
class ScheduledDeliveriesLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $countable = true;
|
||||
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $deliveries) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($deliveries);
|
||||
|
||||
$delta = date_diff($deliveries->getDueDeliveryTimeStart(), new DateTime("now"));
|
||||
|
||||
$loopResultRow
|
||||
->set("ORDER_ID", $deliveries->getOrderId())
|
||||
->set("START_DATE", $deliveries->getDueDeliveryTimeStart())
|
||||
->set("END_DATE", $deliveries->getDueDeliveryTimeEnd())
|
||||
->set("DELTA", $delta->days)
|
||||
->set("SCHEDULE_ID", $deliveries->getScheduleId())
|
||||
;
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createEnumListTypeArgument('order', [
|
||||
'date',
|
||||
'date-reverse'
|
||||
], 'date')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$deliveries = OrderDeliveryScheduleQuery::create();
|
||||
$deliveries->filterByDueDeliveryTimeStart(array('min' => time()))->find();
|
||||
|
||||
return $deliveries->orderByDueDeliveryTimeStart();
|
||||
}
|
||||
|
||||
}
|
||||
BIN
templates/backOffice/custom/assets/img/flag-green.png
Normal file
BIN
templates/backOffice/custom/assets/img/flag-green.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
templates/backOffice/custom/assets/img/flag-orange.png
Normal file
BIN
templates/backOffice/custom/assets/img/flag-orange.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
templates/backOffice/custom/assets/img/flag-red.png
Normal file
BIN
templates/backOffice/custom/assets/img/flag-red.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -120,11 +120,11 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/form_field}
|
||||
|
||||
{form_field field='delivery-module'}
|
||||
<div class="alert alert-danger">{intl l="Message info minimum de commande" d="livraisonparsecteurs" }</div>
|
||||
|
||||
{form_field field='delivery-module'}
|
||||
<div id="delivery-method" class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{intl l="Choose your delivery method"}
|
||||
@@ -134,7 +134,6 @@
|
||||
</div>
|
||||
<div class="panel-body" id="delivery-module-list-block"></div>
|
||||
</div>
|
||||
|
||||
{/form_field}
|
||||
|
||||
{hook name="order-delivery.form-bottom"}
|
||||
|
||||
Reference in New Issue
Block a user