avancées dans le bdc log

This commit is contained in:
Marion Muszynski 2016-04-05 18:15:35 +02:00
parent c6887b7b84
commit c35bcc893a
2 changed files with 45 additions and 21 deletions

View File

@ -83,10 +83,16 @@ class MakeStats {
return $records;
}
public static function getArrayLines($lines, $by_product_price = false)
public static function getArrayLines($lines, $by_product_price = false, $id_sale = 0)
{
$arrayTmp = array();
$g = 0;
if ($id_sale>0) {
$sale = new Sale((int) $id_sale);
$all_multi = $sale->getMultiForStats($ids_od, 2);
}
foreach($lines as $line)
{
@ -96,20 +102,21 @@ class MakeStats {
if(!isset($arrayTmp[$line['product_id']]))
$arrayTmp[$line['product_id']] = array();
$product_price = MakeStats::getProductPriceWithReduction($line);
if($by_product_price)
{
if(!isset($arrayTmp[$line['product_id']][$line['product_attribute_id']]))
$arrayTmp[$line['product_id']][$line['product_attribute_id']] = array();
if(!isset($arrayTmp[$line['product_id']][$line['product_attribute_id']][$product_price]))
$arrayTmp[$line['product_id']][$line['product_attribute_id']][$product_price] = array('line' => $line, 'total' => 0);
}
else
{
if(!isset($arrayTmp[$line['product_id']][$line['product_attribute_id']]))
$arrayTmp[$line['product_id']][$line['product_attribute_id']] = array('line' => $line, 'total' => 0);
}
$product_price = MakeStats::getProductPriceWithReduction($line);
if($by_product_price)
{
if(!isset($arrayTmp[$line['product_id']][$line['product_attribute_id']]))
$arrayTmp[$line['product_id']][$line['product_attribute_id']] = array();
if(!isset($arrayTmp[$line['product_id']][$line['product_attribute_id']][$product_price]))
$arrayTmp[$line['product_id']][$line['product_attribute_id']][$product_price] = array('line' => $line, 'total' => 0);
}
else
{
if(!isset($arrayTmp[$line['product_id']][$line['product_attribute_id']]))
$arrayTmp[$line['product_id']][$line['product_attribute_id']] = array('line' => $line, 'total' => 0);
}
if (isset($line['product_quantity'])) {
$quantity = $line['product_quantity'] - $line['product_quantity_reinjected'];
@ -118,14 +125,22 @@ class MakeStats {
}
$stock = (isset($line['attribute_quantity']))?$line['attribute_quantity']:$line['stock'];
if($by_product_price) {
if($by_product_price) {
$arrayTmp[$line['product_id']][$line['product_attribute_id']][$product_price]['total'] += $quantity;
$arrayTmp[$line['product_id']][$line['product_attribute_id']][$product_price]['stock'] = $stock;
} else {
$arrayTmp[$line['product_id']][$line['product_attribute_id']][$product_price]['stock'] = $stock;
} else {
$arrayTmp[$line['product_id']][$line['product_attribute_id']]['total'] += $quantity;
$arrayTmp[$line['product_id']][$line['product_attribute_id']]['stock'] = $stock;
$arrayTmp[$line['product_id']][$line['product_attribute_id']]['stock'] = $stock;
}
}
if(!isset($arrayTmp[$line['product_id']]['multi']) && in_array($line['id_order'], $all_multi)) {
$arrayTmp[$line['product_id']]['multi'] = $quantity;
} elseif (isset($arrayTmp[$line['product_id']]['multi']) && in_array($line['id_order'], $all_multi)) {
$arrayTmp[$line['product_id']]['multi'] += $quantity;
} else {
$arrayTmp[$line['product_id']]['multi'] = 0;
}
}
return $lines = $arrayTmp;
}

View File

@ -140,7 +140,7 @@ if(Tools::getValue('action') == 'getOrderForm' && ( ( $id_category = Tools::getV
$lines = array();
$array_product = array();
if($type == 1 || $type == 2 || $type == 3) {
if($type == 1 || $type == 2 || $type == 3 || $type == 4) {
$arrayProduct = array();
foreach($products as $product)
$array_product[$product['id_product']] = $arrayProduct[$product['id_product']] = new Product($product['id_product']);
@ -784,6 +784,7 @@ if(Tools::getValue('action') == 'getOrderForm' && ( ( $id_category = Tools::getV
{
foreach($lines_attributes as $values)
{
$id_product_attribute = $values['line']['product_attribute_id'];
$id_product = $values['line']['product_id'];
$current_product = $array_product[$id_product];
@ -808,6 +809,14 @@ if(Tools::getValue('action') == 'getOrderForm' && ( ( $id_category = Tools::getV
$activeSheet->setCellValue($letter_product_ht.$i, (float)$wholesale_price );
$activeSheet->getStyle($letter_product_ht.$i)->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR );
$activeSheet->setCellValue($letter_product_multi.$i, $values['line']['multi']);
$activeSheet->setCellValue($letter_product_M1_M2.$i, $values['line']['m1_m2']);
// colonnes vide
$activeSheet->setCellValue($letter_product_colisage.$i, '');
$activeSheet->setCellValue($letter_product_stock3btk.$i, '');
$activeSheet->setCellValue($letter_product_missing.$i, '');
$activeSheet->setCellValue($letter_product_total_qty.$i, '='.$letter_product_M1_M2.$i.'+'.$letter_product_multi.$i.'+'.$letter_product_colisage.$i.'-'.$letter_product_stock3btk.$i.'-'.$letter_product_missing.$i);
$activeSheet->getStyle($letter_product_total.$i)->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR );
@ -941,8 +950,8 @@ if(Tools::getValue('action') == 'getOrderForm' && ( ( $id_category = Tools::getV
$activeSheet->getColumnDimension($letter_product_attribute_name)->setWidth(20);
}
$activeSheet->getColumnDimension($letter_product_ht)->setWidth(13);
$activeSheet->getColumnDimension($letter_product_M1_M2)->setWidth(13);
$activeSheet->getColumnDimension($letter_product_multi)->setWidth(13);
$activeSheet->getColumnDimension($letter_product_M1_M2)->setWidth(13);
$activeSheet->getColumnDimension($letter_product_colisage)->setWidth(13);
$activeSheet->getColumnDimension($letter_product_stock3btk)->setWidth(13);
$activeSheet->getColumnDimension($letter_product_missing)->setWidth(13);