On peaufine la page d'affichage des achats à faire
This commit is contained in:
@@ -6,6 +6,7 @@ use DateInterval;
|
|||||||
use DateTime;
|
use DateTime;
|
||||||
use Exception;
|
use Exception;
|
||||||
use PlanificationLivraison\Form\ProductsListForm;
|
use PlanificationLivraison\Form\ProductsListForm;
|
||||||
|
use PlanificationLivraison\Model\OrderDeliveryScheduleQuery;
|
||||||
use PlanificationLivraison\PlanificationLivraison;
|
use PlanificationLivraison\PlanificationLivraison;
|
||||||
use Propel\Runtime\Exception\PropelException;
|
use Propel\Runtime\Exception\PropelException;
|
||||||
use Propel\Runtime\Propel;
|
use Propel\Runtime\Propel;
|
||||||
@@ -24,6 +25,7 @@ class ProductsList extends BaseAdminController
|
|||||||
public function viewAction(Request $request)
|
public function viewAction(Request $request)
|
||||||
{
|
{
|
||||||
$productsList = [];
|
$productsList = [];
|
||||||
|
$myOrders = [];
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$error = "";
|
$error = "";
|
||||||
$startDate = new DateTime();
|
$startDate = new DateTime();
|
||||||
@@ -41,29 +43,67 @@ class ProductsList extends BaseAdminController
|
|||||||
|
|
||||||
if (null !== $startDate && null !== $endDate) {
|
if (null !== $startDate && null !== $endDate) {
|
||||||
|
|
||||||
$sql = "select op.product_sale_elements_ref as `name`, aa.title as `packaging`, sum(op.quantity) as `quantity` " .
|
$sqlMyOrders = "select ods.order_id from order_delivery_schedule ods " .
|
||||||
|
"where ods.due_delivery_time_start >= '" . $startDate->format(PlanificationLivraison::FORMAT_DATE_COMPLETE) . "' " .
|
||||||
|
" and ods.due_delivery_time_start <= '" . $endDate->format(PlanificationLivraison::FORMAT_DATE_COMPLETE) . "' ".
|
||||||
|
" and ods.order_id not in (select o.id from `order` o where o.status_id = (select os.id from order_status os where os.code='canceled'))";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stmt = $con->prepare($sqlMyOrders);
|
||||||
|
$stmt->execute();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||||
|
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sqlMyOrders), 0, $e);
|
||||||
|
}
|
||||||
|
$myOrders = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
|
||||||
|
// Récupération de la liste des produits commandés, regroupés par type de produit pour obtenir la quantité totale
|
||||||
|
$sqlProducts = "select op.product_sale_elements_id as `id`, op.product_sale_elements_ref as `name`, aa.title as `packaging`, sum(op.quantity) as `quantity`, '' as `repartition` " .
|
||||||
"from order_product op, product_sale_elements ps, attribute_combination ac, attribute_av_i18n aa " .
|
"from order_product op, product_sale_elements ps, attribute_combination ac, attribute_av_i18n aa " .
|
||||||
"where ps.id = op.product_sale_elements_id" .
|
"where ps.id = op.product_sale_elements_id" .
|
||||||
" and ac.product_sale_elements_id = ps.id" .
|
" and ac.product_sale_elements_id = ps.id" .
|
||||||
" and aa.id = ac.attribute_av_id" .
|
" and aa.id = ac.attribute_av_id" .
|
||||||
" and op.order_id in (" .
|
" and op.order_id in (" . implode(',', $myOrders) . ")" .
|
||||||
" select ods.order_id from order_delivery_schedule ods " .
|
|
||||||
" where ods.due_delivery_time_start >= '" . $startDate->format(PlanificationLivraison::FORMAT_DATE_COMPLETE) . "'" .
|
|
||||||
" and ods.due_delivery_time_start <= '" . $endDate->format(PlanificationLivraison::FORMAT_DATE_COMPLETE) . "'" .
|
|
||||||
" ) " .
|
|
||||||
" and op.order_id not in (select o.id from `order` o " .
|
|
||||||
" where o.status_id = (select os.id from order_status os where os.code='canceled')) " .
|
|
||||||
"group by op.product_sale_elements_id " .
|
"group by op.product_sale_elements_id " .
|
||||||
"order by op.product_ref, op.product_sale_elements_id";
|
"order by op.product_ref, op.product_sale_elements_id";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt = $con->prepare($sql);
|
$stmt = $con->prepare($sqlProducts);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sqlProducts), 0, $e);
|
||||||
}
|
}
|
||||||
$productsList = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
$productsList = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
// Récupération de la répartition des commande,s pour chaque produit
|
||||||
|
$sqlRepartition = "select op.product_sale_elements_id as `id`, sum(op.quantity) as `quantity`, DATE_FORMAT(ods.due_delivery_time_start, '%d/%m/%Y') as `day` " .
|
||||||
|
"from order_delivery_schedule ods, order_product op " .
|
||||||
|
"where ods.order_id in (" . implode(',', $myOrders) . ") " .
|
||||||
|
" and ods.order_id = op.order_id " .
|
||||||
|
"group by op.product_sale_elements_id, DATE_FORMAT(ods.due_delivery_time_start, '%d %m %y') " .
|
||||||
|
"order by op.product_sale_elements_id, ods.due_delivery_time_start";
|
||||||
|
try {
|
||||||
|
$stmt = $con->prepare($sqlRepartition);
|
||||||
|
$stmt->execute();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||||
|
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sqlRepartition), 0, $e);
|
||||||
|
}
|
||||||
|
$repartition = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($productsList as $key => $produit) {
|
||||||
|
$texte = "";
|
||||||
|
foreach ($repartition as $item) {
|
||||||
|
if ($item['id'] === $produit['id']) {
|
||||||
|
$texte .= $item['quantity'] . " unité(s) pour le " . $item['day'] . "<br>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$productsList[$key]['repartition'] = $texte;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$error = $e->getMessage();
|
$error = $e->getMessage();
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ class BackHook extends BaseHook
|
|||||||
|
|
||||||
$customCSS = $this->addCSS('assets/css/custom.css');
|
$customCSS = $this->addCSS('assets/css/custom.css');
|
||||||
$event->add($customCSS);
|
$event->add($customCSS);
|
||||||
|
|
||||||
|
$printCSS = $this->addCSS('assets/css/print.css');
|
||||||
|
$event->add($printCSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,18 @@ return array(
|
|||||||
'Number of days needed for preparation' => 'Nombre de jours nécessaires pour préparation des commandes',
|
'Number of days needed for preparation' => 'Nombre de jours nécessaires pour préparation des commandes',
|
||||||
'Number of days' => 'Nombre de jours',
|
'Number of days' => 'Nombre de jours',
|
||||||
'Number of days - help' => 'A partir d\'aujourd\'hui 0h00',
|
'Number of days - help' => 'A partir d\'aujourd\'hui 0h00',
|
||||||
'Number of days to consider' => 'Afficher les commandes à livrer ou déposer sur la période',
|
'Period to consider' => 'Commandes à livrer ou déposer sur la période',
|
||||||
'Red alert delay' => 'Nombre de jours du seuil CRITIQUE',
|
'Red alert delay' => 'Nombre de jours du seuil CRITIQUE',
|
||||||
'Orange alert delay' => 'Nombre de jours du seuil URGENT',
|
'Orange alert delay' => 'Nombre de jours du seuil URGENT',
|
||||||
'Orders for the next x days' => 'Liste des produits à livrer ou à déposer du <b>%start_date</b> au <b>%end_date</b> inclus',
|
'Orders for the next x days' => 'Produits à fournir pour la période du <b>%start_date</b> au <b>%end_date</b> inclus',
|
||||||
'Packaging' => 'Conditionnement',
|
'Packaging' => 'Conditionnement',
|
||||||
'Product' => 'Produit',
|
'Product' => 'Produit',
|
||||||
'Products to buy' => 'Liste des prochains achats à effectuer',
|
'Products to buy' => 'Liste des prochains achats à effectuer',
|
||||||
|
'Products to buy - short' => 'Liste des prochains achats',
|
||||||
|
'Repartition' => 'Répartition',
|
||||||
'Quantity' => 'Quantité',
|
'Quantity' => 'Quantité',
|
||||||
'Save' => 'Enregistrer',
|
'Save' => 'Enregistrer',
|
||||||
'Search' => 'Rechercher',
|
'Search products' => 'Rechercher les produits',
|
||||||
'Warning withdrawal date' => 'Vous pourrez récupérer votre commande à compter du %date.',
|
'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',
|
'Warning withdrawal date complete' => 'N\'oubliez pas de venir retirer votre commande le %date entre %heure_debut et %heure_fin',
|
||||||
'Monday' => 'Lundi',
|
'Monday' => 'Lundi',
|
||||||
|
|||||||
@@ -8,3 +8,11 @@
|
|||||||
h4 > b {
|
h4 > b {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i.icone-imprimante {
|
||||||
|
font-size: 26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#print-products-list {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
@media print {
|
||||||
|
|
||||||
|
#entete-recherche {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#titre {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
{$admin_current_location = 'module'}
|
{$admin_current_location = 'module'}
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
{block name="page-title"}{intl l='Products to buy' d='planificationlivraison'}{/block}
|
{block name="page-title"}<span id="titre">{intl l='Products to buy' d='planificationlivraison'}</span>{/block}
|
||||||
|
|
||||||
{block name="check-resource"}admin.module{/block}
|
{block name="check-resource"}admin.module{/block}
|
||||||
{block name="check-access"}view{/block}
|
{block name="check-access"}view{/block}
|
||||||
@@ -19,9 +19,9 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="general-block-decorator">
|
<div class="general-block-decorator" id="entete-recherche">
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<h4>{intl l="Number of days to consider" d="planificationlivraison"}</h4>
|
<h4>{intl l="Period to consider" d="planificationlivraison"}</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -34,18 +34,24 @@
|
|||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
{form_field form=$form field="date-picker-start"}
|
{form_field form=$form field="date-picker-start"}
|
||||||
<span class="input-group-addon">{intl l="From" d="planificationlivraison"}</span>
|
<span class="input-group-addon">{intl l="From" d="planificationlivraison"}</span>
|
||||||
<input type="text" id="{$label_attr.for}" class="form-control" name="{$name}" value="{$startDate}"/>
|
<input type="text" id="{$label_attr.for}" class="form-control" name="{$name}" value="{$startDate}" />
|
||||||
{form_error form=$form field="date-picker-start"}{$message}{/form_error}
|
{form_error form=$form field="date-picker-start"}{$message}{/form_error}
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field="date-picker-end"}
|
{form_field form=$form field="date-picker-end"}
|
||||||
<span class="input-group-addon">{intl l="To" d="planificationlivraison"}</span>
|
<span class="input-group-addon">{intl l="To" d="planificationlivraison"}</span>
|
||||||
<input type="text" id="{$label_attr.for}" class="form-control" name="{$name}" value="{$endDate}"/>
|
<input type="text" id="{$label_attr.for}" class="form-control" name="{$name}" value="{$endDate}" />
|
||||||
{form_error form=$form field="date-picker-end"}{$message}{/form_error}
|
{form_error form=$form field="date-picker-end"}{$message}{/form_error}
|
||||||
{/form_field}
|
{/form_field}
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="form-submit-button btn btn-info" >{intl l="Search" d="planificationlivraison"}</button>
|
<button type="submit" class="form-submit-button btn btn-info" >{intl l="Search products" d="planificationlivraison"}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div id="impression">
|
||||||
|
<span class="glyphicon glyphicon-print"></span>
|
||||||
|
<p class="texte">{intl l="Print the list" d="planificationlivraison"}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -62,6 +68,7 @@
|
|||||||
<th>{intl l="Product" d="planificationlivraison"}</th>
|
<th>{intl l="Product" d="planificationlivraison"}</th>
|
||||||
<th>{intl l="Packaging" d="planificationlivraison"}</th>
|
<th>{intl l="Packaging" d="planificationlivraison"}</th>
|
||||||
<th>{intl l="Quantity" d="planificationlivraison"}</th>
|
<th>{intl l="Quantity" d="planificationlivraison"}</th>
|
||||||
|
<th>{intl l="Repartition" d="planificationlivraison"}</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{foreach from=$productsList item=product}
|
{foreach from=$productsList item=product}
|
||||||
@@ -69,6 +76,7 @@
|
|||||||
<td>{$product.name}</td>
|
<td>{$product.name}</td>
|
||||||
<td>{$product.packaging}</td>
|
<td>{$product.packaging}</td>
|
||||||
<td>{$product.quantity}</td>
|
<td>{$product.quantity}</td>
|
||||||
|
<td>{$product.repartition nofilter}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -78,19 +86,15 @@
|
|||||||
</div>
|
</div>
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
<script>
|
|
||||||
if (typeof jQuery == 'undefined') {
|
|
||||||
{javascripts file='assets/js/libs/jquery.js'}
|
|
||||||
document.write(unescape("%3Cscript src='{$asset_url}' %3E%3C/script%3E"));
|
|
||||||
{/javascripts}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{block name="javascript-initialization"}
|
{block name="javascript-initialization"}
|
||||||
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
var startDate = new Date();
|
||||||
|
var endDate = new Date();
|
||||||
|
endDate.setDate(startDate.getDate() + 1);
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$('#date-picker-start').datepicker({
|
$('#date-picker-start').datepicker({
|
||||||
@@ -115,8 +119,8 @@
|
|||||||
endDate = e.date;
|
endDate = e.date;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#date-picker-start').datepicker('update', startDate);
|
// $('#date-picker-start').datepicker('update', startDate);
|
||||||
$('#date-picker-end').datepicker('update', endDate);
|
// $('#date-picker-end').datepicker('update', endDate);
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
<li class="{if $admin_current_location == 'planificationlivraison'}active{/if}" id="planificationlivraison">
|
<li class="{if $admin_current_location == 'planificationlivraison'}active{/if}" id="planificationlivraison">
|
||||||
<a title="{intl l='Products to buy' d='planificationlivraison'}" href="{url path='/admin/module/PlanificationLivraison/products'}" ><span class="glyphicon glyphicon-shopping-cart"></span> {intl l='Products to buy' d='planificationlivraison'}</a>
|
<a title="{intl l='Products to buy - short' d='planificationlivraison'}" href="{url path='/admin/module/PlanificationLivraison/products'}" ><span class="glyphicon glyphicon-shopping-cart"></span> {intl l='Products to buy - short' d='planificationlivraison'}</a>
|
||||||
</li>
|
</li>
|
||||||
Reference in New Issue
Block a user