if (count($pointSale->orders)) { | if (count($pointSale->orders)) { | ||||
// listing commandes | // listing commandes | ||||
$datas[] = ['> ' . $pointSale->name]; | $datas[] = ['> ' . $pointSale->name]; | ||||
foreach ($pointSale->orders as $order) { | |||||
/*foreach ($pointSale->orders as $order) { | |||||
$orderLine = [$order->getStrUser()]; | $orderLine = [$order->getStrUser()]; | ||||
foreach ($productsIndexArray as $idProduct => $indexProduct) { | foreach ($productsIndexArray as $idProduct => $indexProduct) { | ||||
} | } | ||||
} | } | ||||
$datas[] = $this->_lineOrderReportCSV($orderLine, $cpt - 1, true); | $datas[] = $this->_lineOrderReportCSV($orderLine, $cpt - 1, true); | ||||
} | |||||
}*/ | |||||
// total point de vente | // total point de vente | ||||
$totalsPointSaleArray = $this->_totalReportCSV( | $totalsPointSaleArray = $this->_totalReportCSV( | ||||
$productsIndexArray | $productsIndexArray | ||||
); | ); | ||||
$datas[] = $this->_lineOrderReportCSV($totalsPointSaleArray, $cpt - 1, true); | $datas[] = $this->_lineOrderReportCSV($totalsPointSaleArray, $cpt - 1, true); | ||||
$datas[] = []; | |||||
} | } | ||||
} | } | ||||
// distributions | // distributions | ||||
$firstDistribution = Distribution::searchOne([], [ | $firstDistribution = Distribution::searchOne([], [ | ||||
'orderby' => 'id ASC' | |||||
'orderby' => 'date ASC' | |||||
]) ; | ]) ; | ||||
$lastDistribution = Distribution::searchOne([], [ | $lastDistribution = Distribution::searchOne([], [ | ||||
'orderby' => 'id DESC' | |||||
'orderby' => 'date DESC' | |||||
]) ; | ]) ; | ||||
$firstYear = date('Y',strtotime($firstDistribution->date)) ; | $firstYear = date('Y',strtotime($firstDistribution->date)) ; |
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
$add = false; | $add = false; | ||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
if ($product->id == $productOrder->id_product) { | |||||
if($product->id == $productOrder->id_product) { | |||||
$unit = (Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '.Product::strUnit($productOrder->unit, 'wording_short', true) ; | $unit = (Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '.Product::strUnit($productOrder->unit, 'wording_short', true) ; | ||||
$strProducts .= $product->name . ' (' .$productOrder->quantity .$unit.')<br />'; | $strProducts .= $product->name . ' (' .$productOrder->quantity .$unit.')<br />'; | ||||
$add = true; | $add = true; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$html .= '<td>'.substr($strProducts, 0, strlen($strProducts) - 6).'</td>'; | $html .= '<td>'.substr($strProducts, 0, strlen($strProducts) - 6).'</td>'; | ||||
if($isBig) { | if($isBig) { | ||||
if($pointSale->credit) { | if($pointSale->credit) { | ||||
$credit = '' ; | $credit = '' ; | ||||
if(isset($order->user) && isset($order->user->userProducer)) { | |||||
$credit = number_format($order->user->userProducer[0]->credit,2).' €' ; | |||||
if(isset($order->user) && $order->user->id) { | |||||
$userProducer = UserProducer::searchOne([ | |||||
'id_user' => $order->user->id | |||||
]); | |||||
if($userProducer) { | |||||
$credit = number_format($userProducer->credit,2).' €' ; | |||||
} | |||||
} | } | ||||
$html .= '<td>'.$credit.'</td>' ; | $html .= '<td>'.$credit.'</td>' ; | ||||
} | } | ||||
$query->andFilterWhere(['like', 'phone', $params['phone']]); | $query->andFilterWhere(['like', 'phone', $params['phone']]); | ||||
} | } | ||||
$query->orderBy('user.lastname ASC, user.name ASC'); | |||||
$query->orderBy('user.type DESC, user.lastname ASC, user.name ASC'); | |||||
return $query; | return $query; | ||||
} | } |