瀏覽代碼

[backend] Export CSV : ajout d'une ligne total en nombre de pièces

dev
Guillaume 3 年之前
父節點
當前提交
a58155b097
共有 3 個文件被更改,包括 58 次插入8 次删除
  1. +48
    -2
      backend/controllers/DistributionController.php
  2. +3
    -1
      backend/controllers/OrderController.php
  3. +7
    -5
      backend/web/js/backend.js

+ 48
- 2
backend/controllers/DistributionController.php 查看文件

@@ -580,25 +580,43 @@ class DistributionController extends BackendController

// total point de vente
$totalsPointSaleArray = $this->_totalReportCSV(
'Total',
' Total (unité)',
$pointSale->orders,
$productsArray,
$productsIndexArray
);
$datas[] = $this->_lineOrderReportCSV($totalsPointSaleArray, $cpt);

$totalsGlobalPiecesArray = $this->_totalReportPiecesCSV(
' Total (pièces)',
$ordersArray,
$productsArray,
$productsIndexArray
);
$datas[] = $this->_lineOrderReportCSV($totalsGlobalPiecesArray, $cpt);

$datas[] = [];
}
}

// global
$totalsGlobalArray = $this->_totalReportCSV(
'> Totaux',
'> Totaux (unité)',
$ordersArray,
$productsArray,
$productsIndexArray
);
$datas[] = $this->_lineOrderReportCSV($totalsGlobalArray, $cpt);

// global (pièces)
$totalsGlobalPiecesArray = $this->_totalReportPiecesCSV(
'> Totaux (pièces)',
$ordersArray,
$productsArray,
$productsIndexArray
);
$datas[] = $this->_lineOrderReportCSV($totalsGlobalPiecesArray, $cpt);

CSV::downloadSendHeaders('Commandes_' . $date . '.csv');
echo CSV::array2csv($datas);
die();
@@ -765,6 +783,34 @@ class DistributionController extends BackendController
return $totalsPointSaleArray;
}

public function _totalReportPiecesCSV($label, $ordersArray, $productsArray, $productsIndexArray)
{
$totalsPointSaleArray = [$label];

foreach ($productsArray as $product) {
$quantity = 0 ;
foreach (Product::$unitsArray as $unit => $dataUnit) {
$quantityProduct = Order::getProductQuantity($product->id, $ordersArray, false, $unit);

if($unit == 'piece') {
$quantity += $quantityProduct ;
}
else {
if($product->weight > 0) {
$quantity += ($quantityProduct * $dataUnit['coefficient']) / $product->weight ;
}
}
}

if($quantity) {
$index = $productsIndexArray[$product->id];
$totalsPointSaleArray[$index] = $quantity;
}
}

return $totalsPointSaleArray;
}

public function _lineOrderReportCSV($orderLine, $cptMax, $showTotal = false)
{
$line = [];

+ 3
- 1
backend/controllers/OrderController.php 查看文件

@@ -880,7 +880,9 @@ class OrderController extends BackendController
$order->processCredit();
}

$order->setTillerSynchronization() ;
if($order) {
$order->setTillerSynchronization() ;
}

// lien utilisateur / point de vente
if ($idUser && $pointSale) {

+ 7
- 5
backend/web/js/backend.js 查看文件

@@ -87,9 +87,11 @@ function opendistrib_products_event_price_with_tax() {
if(typeof taxRateSelected == 'undefined') {
taxRateSelected = 0 ;
}
$('#product-price-with-tax').val(getPriceWithTax($('#product-price').val(), taxRateSelected));
//formattage des prix
$('#product-price').val(parseFloat($('#product-price').val()).toFixed(3));
if($('#product-price').val()) {
$('#product-price-with-tax').val(getPriceWithTax($('#product-price').val(), taxRateSelected));
//formattage des prix
$('#product-price').val(parseFloat($('#product-price').val()).toFixed(3));
}
}
function opendistrib_products_event_price(){
taxRateSelected = $('#product-id_tax_rate').find('option:selected').data('tax-rate-value');
@@ -104,11 +106,11 @@ function opendistrib_products_event_unit(change) {
var unit = $('#product-unit').val() ;
if(unit == 'piece') {
$('.field-product-step').hide() ;
$('.field-product-weight').show() ;
$('.field-product-weight label').html('Poids (g)') ;
}
else {
$('.field-product-step').show() ;
$('.field-product-weight').hide() ;
$('.field-product-weight label').html('Poids ('+$('#product-unit').val()+')') ;
}
var label_price_ttc = $('.field-product-price .control-label.with-tax') ;

Loading…
取消
儲存