public function actionAjaxStatisticsHtml() | public function actionAjaxStatisticsHtml() | ||||
{ | { | ||||
return \Yii::$app->cache->getOrSet('dashboard_statistics12', function () { | |||||
return \Yii::$app->cache->getOrSet('dashboard_statistics14', function () { | |||||
$producerModule = $this->getProducerModule(); | $producerModule = $this->getProducerModule(); | ||||
$pointSaleModule = $this->getPointSaleModule(); | $pointSaleModule = $this->getPointSaleModule(); | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$averageOrdersPerDay = $orderModule->countGlobalUserOrdersAverageLastSevenDays(); | $averageOrdersPerDay = $orderModule->countGlobalUserOrdersAverageLastSevenDays(); | ||||
$turnoverLastThirtyDays = $orderModule->getRepository()->getTurnoverLastThirtyDays(); | $turnoverLastThirtyDays = $orderModule->getRepository()->getTurnoverLastThirtyDays(); | ||||
$resultMatomoApiVisitSummary = json_decode(file_get_contents(\Yii::$app->parameterBag->get('matomoApiVisitSummaryUrl'))); | $resultMatomoApiVisitSummary = json_decode(file_get_contents(\Yii::$app->parameterBag->get('matomoApiVisitSummaryUrl'))); | ||||
$numberVisitsDay = $resultMatomoApiVisitSummary->nb_uniq_visitors / 30; | |||||
$numberVisitsDay = intval($resultMatomoApiVisitSummary->nb_uniq_visitors / 30); | |||||
$amountBilledLastMonth = $producerModule->getRepository()->getAmountBilledLastMonth(); | $amountBilledLastMonth = $producerModule->getRepository()->getAmountBilledLastMonth(); | ||||
$amountToBillCurrentMonth = $producerModule->getRepository()->getAmountToBillCurrentMonth(); | $amountToBillCurrentMonth = $producerModule->getRepository()->getAmountToBillCurrentMonth(); | ||||
$amountProducerUnpaidInvoices = $producerModule->getDolibarrUtils()->getAmountProducerInvoicesUnpaid(); | $amountProducerUnpaidInvoices = $producerModule->getDolibarrUtils()->getAmountProducerInvoicesUnpaid(); |
?> | ?> | ||||
<div class="row"> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
Price::format($turnoverLastThirtyDays, 0), | |||||
'CA producteurs sur les 30 derniers jours', | |||||
'aqua', | |||||
'line-chart', | |||||
Yii::$app->urlManager->createUrl('stats-admin/turnover') | |||||
) ?> | |||||
</div> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
$averageOrdersPerDay, | |||||
'Commandes clients / jour sur les 7 derniers jours', | |||||
'aqua', | |||||
'shopping-cart', | |||||
Yii::$app->urlManager->createUrl('stats-admin/turnover') | |||||
) ?> | |||||
</div> | |||||
</div> | |||||
<div class="row"> | <div class="row"> | ||||
<div class="col-lg-6 col-xs-6"> | <div class="col-lg-6 col-xs-6"> | ||||
<?= AdminLTE::smallBox( | <?= AdminLTE::smallBox( | ||||
'map-marker' | 'map-marker' | ||||
) ?> | ) ?> | ||||
</div> | </div> | ||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
$averageOrdersPerDay, | |||||
'Commandes clients / jour sur les 7 derniers jours', | |||||
'aqua', | |||||
'shopping-cart', | |||||
Yii::$app->urlManager->createUrl('stats-admin/turnover') | |||||
) ?> | |||||
</div> | |||||
</div> | |||||
<div class="row"> | |||||
<div class="col-lg-6 col-xs-6"> | <div class="col-lg-6 col-xs-6"> | ||||
<?= AdminLTE::smallBox( | <?= AdminLTE::smallBox( | ||||
$numberVisitsDay, | $numberVisitsDay, | ||||
'eye' | 'eye' | ||||
) ?> | ) ?> | ||||
</div> | </div> | ||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
Price::format($turnoverLastThirtyDays, 0), | |||||
'CA total producteurs sur les 30 derniers jours', | |||||
'aqua', | |||||
'line-chart', | |||||
Yii::$app->urlManager->createUrl('stats-admin/turnover') | |||||
) ?> | |||||
</div> | |||||
</div> | </div> | ||||
<div class="row"> | <div class="row"> | ||||
<div class="col-lg-6 col-xs-6"> | <div class="col-lg-6 col-xs-6"> |
$invoicesArray = $this->getDolibarrProducerInvoices($producer); | $invoicesArray = $this->getDolibarrProducerInvoices($producer); | ||||
foreach($invoicesArray as $invoice) { | foreach($invoicesArray as $invoice) { | ||||
if($invoice['remaintopay'] > 0) { | |||||
if(isset($invoice['remaintopay']) && $invoice['remaintopay'] > 0) { | |||||
$unpaidInvoicesArray[] = $invoice; | $unpaidInvoicesArray[] = $invoice; | ||||
} | } | ||||
} | } | ||||
$unpaidInvoicesArray = $this->getDolibarrInvoicesUnpaid(); | $unpaidInvoicesArray = $this->getDolibarrInvoicesUnpaid(); | ||||
foreach($unpaidInvoicesArray as $unpaidInvoice) { | foreach($unpaidInvoicesArray as $unpaidInvoice) { | ||||
$amount += $unpaidInvoice['remaintopay']; | |||||
if(isset($unpaidInvoice['remaintopay'])) { | |||||
$amount += $unpaidInvoice['remaintopay']; | |||||
} | |||||
} | } | ||||
return $amount; | return $amount; |
public function actionAbout() | public function actionAbout() | ||||
{ | { | ||||
$aboutFewNumbers = Yii::$app->cache->getOrSet('about_few_numbers7', function () { | |||||
$aboutFewNumbers = Yii::$app->cache->getOrSet('about_few_numbers10', function () { | |||||
$producerModule = $this->getProducerModule(); | $producerModule = $this->getProducerModule(); | ||||
$pointSaleModule = $this->getPointSaleModule(); | $pointSaleModule = $this->getPointSaleModule(); | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$countPointSalesActive = $pointSaleModule->countPointSalesActiveLastThreeMonths(); | $countPointSalesActive = $pointSaleModule->countPointSalesActiveLastThreeMonths(); | ||||
$countUsersActive = $userModule->countUsersActiveLastThreeMonths(); | $countUsersActive = $userModule->countUsersActiveLastThreeMonths(); | ||||
$averageOrdersPerDay = $orderModule->countGlobalUserOrdersAverageLastSevenDays(); | $averageOrdersPerDay = $orderModule->countGlobalUserOrdersAverageLastSevenDays(); | ||||
$averageTurnover = $orderModule->getAverageTurnoverLastThreeMonths(); | |||||
// $averageTurnover = $orderModule->getAverageTurnoverLastThreeMonths(); | |||||
$turnoverLastThirtyDays = $orderModule->getRepository()->getTurnoverLastThirtyDays(); | |||||
$resultMatomoApiVisitSummary = json_decode(file_get_contents(Yii::$app->parameterBag->get('matomoApiVisitSummaryUrl'))); | $resultMatomoApiVisitSummary = json_decode(file_get_contents(Yii::$app->parameterBag->get('matomoApiVisitSummaryUrl'))); | ||||
$numberVisitsMonth = $resultMatomoApiVisitSummary->nb_uniq_visitors; | |||||
$numberVisitsByDay = intval($resultMatomoApiVisitSummary->nb_uniq_visitors / 30); | |||||
return $this->renderPartial('_about_few_numbers', [ | return $this->renderPartial('_about_few_numbers', [ | ||||
'countProducersActive' => $countProducersActive, | 'countProducersActive' => $countProducersActive, | ||||
'countPointSalesActive' => $countPointSalesActive, | 'countPointSalesActive' => $countPointSalesActive, | ||||
'countUsersActive' => $countUsersActive, | 'countUsersActive' => $countUsersActive, | ||||
'averageOrdersPerDay' => $averageOrdersPerDay, | 'averageOrdersPerDay' => $averageOrdersPerDay, | ||||
'averageTurnover' => $averageTurnover, | |||||
'numberVisitsMonth' => $numberVisitsMonth, | |||||
//'averageTurnover' => $averageTurnover, | |||||
'turnoverLastThirtyDays' => $turnoverLastThirtyDays, | |||||
'numberVisitsByDay' => $numberVisitsByDay, | |||||
'timeSavedByProducersAverage' => $timeSavedByProducersAverage, | 'timeSavedByProducersAverage' => $timeSavedByProducersAverage, | ||||
'countProducersWithOptionTimeSaved' => $countProducersWithOptionTimeSaved | 'countProducersWithOptionTimeSaved' => $countProducersWithOptionTimeSaved | ||||
]); | ]); |
<?= few_numbers_item(few_numbers_format_number($averageOrdersPerDay), 'Commandes clients / jour', 'en moyenne sur les 7 derniers jours'); ?> | <?= few_numbers_item(few_numbers_format_number($averageOrdersPerDay), 'Commandes clients / jour', 'en moyenne sur les 7 derniers jours'); ?> | ||||
</div> | </div> | ||||
<div class="row"> | <div class="row"> | ||||
<?= few_numbers_item(few_numbers_format_number($averageTurnover).' €', 'CA producteurs / mois', 'moyenne sur les 3 derniers mois'); ?> | |||||
<?= few_numbers_item(few_numbers_format_number($numberVisitsMonth), 'Visiteurs', 'le mois dernier'); ?> | |||||
<?= few_numbers_item(few_numbers_format_number($numberVisitsByDay), 'Visiteurs / jour', 'en moyenne sur les 30 derniers jours'); ?> | |||||
<?= few_numbers_item(few_numbers_format_number($turnoverLastThirtyDays).' €', 'CA total producteurs', 'sur les 30 derniers jours'); ?> | |||||
</div> | </div> | ||||
<?php if($countProducersWithOptionTimeSaved): ?> | <?php if($countProducersWithOptionTimeSaved): ?> | ||||
<div class="row"> | |||||
<!--<div class="row"> | |||||
<?= few_numbers_item($timeSavedByProducersAverage.' h', 'Heures gagnées par semaine', 'moyenne sur '.$countProducersWithOptionTimeSaved.' producteur'.(($countProducersWithOptionTimeSaved) ? 's' : '')); ?> | <?= few_numbers_item($timeSavedByProducersAverage.' h', 'Heures gagnées par semaine', 'moyenne sur '.$countProducersWithOptionTimeSaved.' producteur'.(($countProducersWithOptionTimeSaved) ? 's' : '')); ?> | ||||
</div> | |||||
</div>--> | |||||
<?php endif; ?> | <?php endif; ?> | ||||
</div> | </div> | ||||
</div> | </div> |