Parcourir la source

[Backend] Export grille : optimisation espace

refactoring
Guillaume il y a 3 ans
Parent
révision
8553397827
2 fichiers modifiés avec 39 ajouts et 23 suppressions
  1. +7
    -7
      backend/controllers/DistributionController.php
  2. +32
    -16
      backend/views/distribution/report-grid.php

+ 7
- 7
backend/controllers/DistributionController.php Voir le fichier

$pointSale->initOrders($ordersArray); $pointSale->initOrders($ordersArray);
} }


$ordersByPage = 12 ;
$ordersByPage = 22 ;
$nbPages = ceil(count($ordersArray) / $ordersByPage) ; $nbPages = ceil(count($ordersArray) / $ordersByPage) ;
$ordersArrayPaged = [] ; $ordersArrayPaged = [] ;




$index ++ ; $index ++ ;


if($index == $ordersByPage - 1) {
if($index == $ordersByPage) {
$index = 0 ; $index = 0 ;
$indexPage ++ ; $indexPage ++ ;
} }
padding: 0px ; padding: 0px ;
margin: 0px ; margin: 0px ;
border: solid 1px #e0e0e0 ; border: solid 1px #e0e0e0 ;
padding: 3px 8px ;
padding: 3px ;
vertical-align : top; vertical-align : top;
page-break-inside: avoid !important; page-break-inside: avoid !important;
} }


table tr th { table tr th {
font-size: 13px ;
font-size: 10px ;
} }
table tr td { table tr td {
font-size: 11px ;
font-size: 10px ;
} }
table thead tr { table thead tr {
.th-user, .th-user,
.td-nb-products { .td-nb-products {
width: 35px ;
/* width: 35px ; */
text-align: center ; text-align: center ;
} }

+ 32
- 16
backend/views/distribution/report-grid.php Voir le fichier



$html = '' ; $html = '' ;


foreach($pointsSaleArray as $pointSale) {
foreach($pointsSaleArray as $keyPointSale => $pointSale) {


if(isset($ordersArray[$pointSale->id]) && count($ordersArray[$pointSale->id]) > 0) { if(isset($ordersArray[$pointSale->id]) && count($ordersArray[$pointSale->id]) > 0) {
$html .= '<h1>'.$pointSale->name.'</h1>' ; $html .= '<h1>'.$pointSale->name.'</h1>' ;


$html .= '</tbody></table>'; $html .= '</tbody></table>';


$html .= '<pagebreak>';
$html .= ' <pagebreak>';
} }
} }
} }


echo($html) ;
$html = substr($html, 0, strlen($html) - 11) ;

echo $html ;


function line_product($product, $orders) { function line_product($product, $orders) {
$html = '' ; $html = '' ;


$html .= '<tr>' ;
$html .= '<td>'.$product->name.'</td>' ;
if(has_quantity($product, $orders)) {
$html .= '<tr>' ;
$html .= '<td>'.$product->name.'</td>' ;


foreach($orders as $order) {
$quantity = '' ;
foreach($order->productOrder as $productOrder) {
if($product->id == $productOrder->id_product) {
$unit = (Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($productOrder->unit, 'wording_short', true) ;
foreach($orders as $order) {
$quantity = '' ;
foreach($order->productOrder as $productOrder) {
if($product->id == $productOrder->id_product) {
$unit = (Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($productOrder->unit, 'wording_short', true) ;


$quantity .= $productOrder->quantity .$unit ;
if($productOrder->quantity > 1) {
$quantity = '<strong>'.$quantity.'</strong>' ;
$quantity .= $productOrder->quantity .$unit ;
if($productOrder->quantity > 1) {
$quantity = '<strong>'.$quantity.'</strong>' ;
}
} }
} }

$html .= '<td class="td-nb-products">'.$quantity.'</td>' ;
} }


$html .= '<td class="td-nb-products">'.$quantity.'</td>' ;
$html .= '</tr>' ;
} }


$html .= '</tr>' ;

return $html ; return $html ;
} }

function has_quantity($product, $orders) {
foreach($orders as $order) {
foreach($order->productOrder as $productOrder) {
if($product->id == $productOrder->id_product) {
return true ;
}
}
}

return false ;
}

Chargement…
Annuler
Enregistrer