Ver código fonte

Refactoring

refactoring
Guillaume Bourgeois 1 ano atrás
pai
commit
1771a994de
3 arquivos alterados com 114 adições e 126 exclusões
  1. +0
    -21
      backend/controllers/DistributionController.php
  2. +1
    -1
      backend/views/distribution/report-bourlingue.php
  3. +113
    -104
      backend/views/distribution/report-grid.php

+ 0
- 21
backend/controllers/DistributionController.php Ver arquivo

@@ -1124,27 +1124,6 @@ class DistributionController extends BackendController
// points de vente
foreach ($pointsSaleArray as $pointSale) {
if (count($pointSale->orders)) {
// listing commandes

/*foreach ($pointSale->orders as $order) {
$orderLine = [$order->getStrUser()];

foreach ($productsIndexArray as $idProduct => $indexProduct) {
$orderLine[$indexProduct] = '';
}

foreach ($order->productOrder as $productOrder) {
if (strlen($orderLine[$productsIndexArray[$productOrder->id_product]])) {
$orderLine[$productsIndexArray[$productOrder->id_product]] .= ' + ';
}
$orderLine[$productsIndexArray[$productOrder->id_product]] .= $productOrder->quantity;
if ($productOrder->product->unit != $productOrder->unit) {
$orderLine[$productsIndexArray[$productOrder->id_product]] .= Product::strUnit($productOrder->unit, 'wording_short', true);
}
}
$datas[] = $this->_lineOrderReportCSV($orderLine, $cpt - 1, true);
}*/

// total point de vente
$totalsPointSaleArray = $this->_totalReportCSV(
'> ' . $pointSale->name,

+ 1
- 1
backend/views/distribution/report-bourlingue.php Ver arquivo

@@ -79,7 +79,7 @@ foreach ($pointsSaleArray as $pointSale) {
$strUser = '';

// username
$strUser = $order->getStrUser() ;
$strUser = $orderManager->getOrderUsername($order) ;
if(strlen($order->comment_point_sale))
{

+ 113
- 104
backend/views/distribution/report-grid.php Ver arquivo

@@ -1,124 +1,133 @@
<?php

$html = '' ;

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

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

foreach ($ordersArray[$pointSale->id] as $indexPage => $orders) {

$html .= '<table class="">'
. '<thead>'
. '<tr>'
. '<th></th>';

foreach ($orders as $order) {
$html .= '<th class="th-user" text-rotate="90">'
. '<div class="user">' . $order->getStrUser() . '</div>'
//.'<div class="amount">'.number_format($order->amount_with_tax, 2) .' € </div>'
. '</th>';
}

$html .= '</tr>'
. '<thead>'
. '<tbody>';


foreach ($categoriesArray as $category) {
if ($category) {
$html .= '<tr><td class="category-name">' . $category->name . '</td><td colspan="' . (count($orders)) . '"></td></tr>';
}

foreach ($productsArray as $product) {
if (($category && $product->id_product_category == $category->id) || (!$category && !$product->id_product_category)) {
$html .= line_product($product, $orders);
}
}
}

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


$html .= '<table class="">'
. '<thead>'
. '<tr>'
. '<th>Client</th>'
. '<th>Contact</th>'
. '<th>Commentaire</th>'
. '<th>Montant</th>'
. '</thead>'
. '<tbody>';

foreach ($orders as $order) {
$html .= '<tr>';
$strUser = $order->getStrUser();
if ($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) {
$strUser .= '<br />' . $order->reference;
}

$html .= '<td>' . $strUser . '</td>';
$contactUser = '';
if ($order->user) {
$contactUser .= $order->user->phone . '<br />' . $order->user->email;
}
$html .= '<td>' . $contactUser . '</td>';
$html .= '<td>' . nl2br($order->comment) . '</td>';
$html .= '<td>' . number_format($order->amount_with_tax, 2) . ' € </td>';
$html .= '</tr>';
}

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

$html .= ' <pagebreak>';
use common\logic\Order\Order\Wrapper\OrderManager;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Product\Product\Wrapper\ProductManager;

$orderManager = OrderManager::getInstance();

$html = '';

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

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

foreach ($ordersArray[$pointSale->id] as $indexPage => $orders) {

$html .= '<table class="">'
. '<thead>'
. '<tr>'
. '<th></th>';

foreach ($orders as $order) {
$html .= '<th class="th-user" text-rotate="90">'
. '<div class="user">' . $orderManager->getOrderUsername($order) . '</div>'
//.'<div class="amount">'.number_format($order->amount_with_tax, 2) .' € </div>'
. '</th>';
}

$html .= '</tr>'
. '<thead>'
. '<tbody>';


foreach ($categoriesArray as $category) {
if ($category) {
$html .= '<tr><td class="category-name">' . $category->name . '</td><td colspan="' . (count($orders)) . '"></td></tr>';
}

foreach ($productsArray as $product) {
if (($category && $product->id_product_category == $category->id) || (!$category && !$product->id_product_category)) {
$html .= line_product($product, $orders);
}
}
}

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


$html .= '<table class="">'
. '<thead>'
. '<tr>'
. '<th>Client</th>'
. '<th>Contact</th>'
. '<th>Commentaire</th>'
. '<th>Montant</th>'
. '</thead>'
. '<tbody>';

foreach ($orders as $order) {
$html .= '<tr>';
$strUser = $orderManager->getOrderUsername($order);
if ($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) {
$strUser .= '<br />' . $order->reference;
}

$html .= '<td>' . $strUser . '</td>';
$contactUser = '';
if ($order->user) {
$contactUser .= $order->user->phone . '<br />' . $order->user->email;
}
$html .= '<td>' . $contactUser . '</td>';
$html .= '<td>' . nl2br($order->comment) . '</td>';
$html .= '<td>' . number_format($order->amount_with_tax, 2) . ' € </td>';
$html .= '</tr>';
}

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

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

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

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

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

if(has_quantity($product, $orders)) {
$html .= '<tr>' ;
$html .= '<td>'.$product->name.'</td>' ;
function line_product($product, $orders)
{
$productManager = ProductManager::getInstance();
$html = '';

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

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

$html .= '<td class="td-nb-products">'.$quantity.'</td>' ;
$quantity .= $productOrder->quantity . $unit;
if ($productOrder->quantity > 1) {
$quantity = '<strong>' . $quantity . '</strong>';
}
}
}

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

return $html ;
$html .= '</tr>';
}

return $html;
}

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

return false ;
return false;
}

Carregando…
Cancelar
Salvar