fix statistiques
This commit is contained in:
parent
b60bb6e0b2
commit
65d13d70f9
@ -3153,7 +3153,7 @@ class Bdd
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function getClientFactureStatisticPerMonth($clientId, array $produitList)
|
||||
private function getClientFactureStatisticPerMonthSave($clientId, array $produitList)
|
||||
{
|
||||
$currentYear = date('Y');
|
||||
$monthLists = range(1, 12);
|
||||
@ -3209,6 +3209,58 @@ class Bdd
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getClientFactureStatisticPerMonth($clientId, array $produitList)
|
||||
{
|
||||
$currentYear = date('Y');
|
||||
$monthLists = range(1, 12);
|
||||
$data = [] ;
|
||||
foreach($monthLists as $monthValue) {
|
||||
if(!isset($data[$monthValue])) {
|
||||
$data[$monthValue] = [];
|
||||
}
|
||||
$sql = "SELECT
|
||||
devis.id as devis_id,
|
||||
devis.id_client as devis_client_id,
|
||||
devis.date as devis_date,
|
||||
devis.mentions as devis_mention
|
||||
FROM ".$this->tableprefix."devis as devis
|
||||
WHERE YEAR(devis.date) = ? AND
|
||||
MONTH(devis.date) = ? AND
|
||||
devis.id_client = ? AND
|
||||
(devis.mentions = ? OR devis.mentions = ?)
|
||||
ORDER BY devis.date ASC;";
|
||||
$factureList = $this->execSQLNoJsonReturn(
|
||||
$sql,
|
||||
[$currentYear,$monthValue,$clientId,DevisMentionConstant::FACTURED,DevisMentionConstant::FACTURED_FORMATTED]
|
||||
);
|
||||
|
||||
$factureDevisIds = [];
|
||||
foreach($factureList as $facture) {
|
||||
$factureDevisIds[] = $facture['devis_id'];
|
||||
}
|
||||
|
||||
$defuntCount = count($factureList);
|
||||
$produitsPrice = 0;
|
||||
$statisticForeachProductPerMonth = [];
|
||||
foreach($produitList as $produit) {
|
||||
if(!isset($statisticForeachProductPerMonth[$produit['id']])) {
|
||||
$statisticForeachProductPerMonth[$produit['id']] = 0;
|
||||
}
|
||||
$productTotalCount = $this->getDevisProductsQuantityByDevisListAndProductId($factureDevisIds, $produit['id']);
|
||||
$totalWithoutVat = $productTotalCount * $produit["prix_unitaire"];
|
||||
$statisticForeachProductPerMonth[$produit['id']] += $productTotalCount;
|
||||
$produitsPrice += $totalWithoutVat;
|
||||
}
|
||||
$data[$monthValue] = [
|
||||
"defunt_count" => $defuntCount,
|
||||
"total_price" => $produitsPrice,
|
||||
"year" => $currentYear,
|
||||
"products" => $statisticForeachProductPerMonth
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getExportClientStatData(array $clientIds)
|
||||
{
|
||||
$data = [];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user