diff --git a/local/modules/PlanificationLivraison/Controller/ProductsList.php b/local/modules/PlanificationLivraison/Controller/ProductsList.php index eec9a302..07e844c9 100755 --- a/local/modules/PlanificationLivraison/Controller/ProductsList.php +++ b/local/modules/PlanificationLivraison/Controller/ProductsList.php @@ -6,6 +6,7 @@ use DateInterval; use DateTime; use Exception; use PlanificationLivraison\Form\ProductsListForm; +use PlanificationLivraison\Model\OrderDeliveryScheduleQuery; use PlanificationLivraison\PlanificationLivraison; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Propel; @@ -24,6 +25,7 @@ class ProductsList extends BaseAdminController public function viewAction(Request $request) { $productsList = []; + $myOrders = []; $con = Propel::getConnection(); $error = ""; $startDate = new DateTime(); @@ -41,29 +43,67 @@ class ProductsList extends BaseAdminController 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 " . "where ps.id = op.product_sale_elements_id" . " and ac.product_sale_elements_id = ps.id" . " and aa.id = ac.attribute_av_id" . - " and op.order_id in (" . - " 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')) " . + " and op.order_id in (" . implode(',', $myOrders) . ")" . "group by op.product_sale_elements_id " . "order by op.product_ref, op.product_sale_elements_id"; try { - $stmt = $con->prepare($sql); + $stmt = $con->prepare($sqlProducts); $stmt->execute(); } catch (Exception $e) { 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); + + // 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'] . "
"; + } + } + $productsList[$key]['repartition'] = $texte; + } + } } catch (\Exception $e) { $error = $e->getMessage(); diff --git a/local/modules/PlanificationLivraison/Hook/BackHook.php b/local/modules/PlanificationLivraison/Hook/BackHook.php index f1222ba3..49686efb 100644 --- a/local/modules/PlanificationLivraison/Hook/BackHook.php +++ b/local/modules/PlanificationLivraison/Hook/BackHook.php @@ -59,6 +59,9 @@ class BackHook extends BaseHook $customCSS = $this->addCSS('assets/css/custom.css'); $event->add($customCSS); + + $printCSS = $this->addCSS('assets/css/print.css'); + $event->add($printCSS); } } diff --git a/local/modules/PlanificationLivraison/I18n/fr_FR.php b/local/modules/PlanificationLivraison/I18n/fr_FR.php index 9ac23717..dfbc3d02 100644 --- a/local/modules/PlanificationLivraison/I18n/fr_FR.php +++ b/local/modules/PlanificationLivraison/I18n/fr_FR.php @@ -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' => 'Nombre de jours', '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', 'Orange alert delay' => 'Nombre de jours du seuil URGENT', - 'Orders for the next x days' => 'Liste des produits à livrer ou à déposer du %start_date au %end_date inclus', + 'Orders for the next x days' => 'Produits à fournir pour la période du %start_date au %end_date inclus', 'Packaging' => 'Conditionnement', 'Product' => 'Produit', 'Products to buy' => 'Liste des prochains achats à effectuer', + 'Products to buy - short' => 'Liste des prochains achats', + 'Repartition' => 'Répartition', 'Quantity' => 'Quantité', '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 complete' => 'N\'oubliez pas de venir retirer votre commande le %date entre %heure_debut et %heure_fin', 'Monday' => 'Lundi', diff --git a/local/modules/PlanificationLivraison/templates/backOffice/default/assets/css/custom.css b/local/modules/PlanificationLivraison/templates/backOffice/default/assets/css/custom.css index d1a27bb0..edd72966 100644 --- a/local/modules/PlanificationLivraison/templates/backOffice/default/assets/css/custom.css +++ b/local/modules/PlanificationLivraison/templates/backOffice/default/assets/css/custom.css @@ -7,4 +7,12 @@ h4 > b { color: red; +} + +i.icone-imprimante { + font-size: 26px; +} + +#print-products-list { + font-size: 18px; } \ No newline at end of file diff --git a/local/modules/PlanificationLivraison/templates/backOffice/default/assets/css/print.css b/local/modules/PlanificationLivraison/templates/backOffice/default/assets/css/print.css new file mode 100644 index 00000000..5fae2b7c --- /dev/null +++ b/local/modules/PlanificationLivraison/templates/backOffice/default/assets/css/print.css @@ -0,0 +1,13 @@ +@media print { + + #entete-recherche { + display: none; + } + #titre { + display: none; + } + footer { + display: none; + } + +} diff --git a/local/modules/PlanificationLivraison/templates/backOffice/default/liste-achats.html b/local/modules/PlanificationLivraison/templates/backOffice/default/liste-achats.html index 981a7c68..aa556ec2 100644 --- a/local/modules/PlanificationLivraison/templates/backOffice/default/liste-achats.html +++ b/local/modules/PlanificationLivraison/templates/backOffice/default/liste-achats.html @@ -4,7 +4,7 @@ {$admin_current_location = 'module'} {/block} -{block name="page-title"}{intl l='Products to buy' d='planificationlivraison'}{/block} +{block name="page-title"}{intl l='Products to buy' d='planificationlivraison'}{/block} {block name="check-resource"}admin.module{/block} {block name="check-access"}view{/block} @@ -19,9 +19,9 @@ {/if} -
+
-

{intl l="Number of days to consider" d="planificationlivraison"}

+

{intl l="Period to consider" d="planificationlivraison"}

@@ -34,18 +34,24 @@
{form_field form=$form field="date-picker-start"} {intl l="From" d="planificationlivraison"} - + {form_error form=$form field="date-picker-start"}{$message}{/form_error} {/form_field} {form_field form=$form field="date-picker-end"} {intl l="To" d="planificationlivraison"} - + {form_error form=$form field="date-picker-end"}{$message}{/form_error} {/form_field}
- + +
+
+
+
+ +

{intl l="Print the list" d="planificationlivraison"}

@@ -62,6 +68,7 @@ {intl l="Product" d="planificationlivraison"} {intl l="Packaging" d="planificationlivraison"} {intl l="Quantity" d="planificationlivraison"} + {intl l="Repartition" d="planificationlivraison"} {foreach from=$productsList item=product} @@ -69,6 +76,7 @@ {$product.name} {$product.packaging} {$product.quantity} + {$product.repartition nofilter} {/foreach} @@ -78,19 +86,15 @@
{/block} - - {block name="javascript-initialization"} diff --git a/local/modules/PlanificationLivraison/templates/backOffice/default/menu-hook.html b/local/modules/PlanificationLivraison/templates/backOffice/default/menu-hook.html index e091e5d4..020ce8d2 100644 --- a/local/modules/PlanificationLivraison/templates/backOffice/default/menu-hook.html +++ b/local/modules/PlanificationLivraison/templates/backOffice/default/menu-hook.html @@ -1,3 +1,3 @@
  • - {intl l='Products to buy' d='planificationlivraison'} + {intl l='Products to buy - short' d='planificationlivraison'}
  • \ No newline at end of file