} | } | ||||
} | } | ||||
public function getTurnoverByNumberMonths(Producer $producer, $numberMonths = 1) | |||||
{ | |||||
$totalTurnover = 0; | |||||
for($i = 1; $i <= $numberMonths; $i++) { | |||||
$timeMonth = strtotime('-' . $i . ' month'); | |||||
$month = date('Y-m', $timeMonth); | |||||
$totalTurnover += $this->getTurnover($producer, $month); | |||||
} | |||||
return $totalTurnover; | |||||
} | |||||
public function getAmountToBeBilledByMonth(Producer $producer, $month, bool $format = false) | public function getAmountToBeBilledByMonth(Producer $producer, $month, bool $format = false) | ||||
{ | { | ||||
$turnover = $this->getTurnover($producer, $month); | $turnover = $this->getTurnover($producer, $month); | ||||
return $this->queryProducersActive()->find(); | return $this->queryProducersActive()->find(); | ||||
} | } | ||||
public function countProducersActiveWithTurnover(): int | |||||
{ | |||||
$count = 0; | |||||
$producersArray = $this->findProducersActive(); | |||||
foreach($producersArray as $producer) { | |||||
if($this->getTurnoverByNumberMonths($producer, 3)) { | |||||
$count ++; | |||||
} | |||||
} | |||||
return $count; | |||||
} | |||||
public function findProducers() | public function findProducers() | ||||
{ | { | ||||
return $this->createQuery()->find(); | return $this->createQuery()->find(); |
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use frontend\forms\ProducerCodeForm; | use frontend\forms\ProducerCodeForm; | ||||
use GuzzleHttp\Client; | |||||
use Yii; | use Yii; | ||||
use frontend\forms\PasswordResetRequestForm; | use frontend\forms\PasswordResetRequestForm; | ||||
use frontend\forms\ResetPasswordForm; | use frontend\forms\ResetPasswordForm; | ||||
public function actionAbout() | public function actionAbout() | ||||
{ | { | ||||
return $this->render('about'); | |||||
$producerManager = $this->getProducerManager(); | |||||
$countProducersActive = $producerManager->countProducersActiveWithTurnover(); | |||||
$resultMatomoApiVisitSummary = json_decode(file_get_contents(Yii::$app->params['matomoApiVisitSummaryUrl'])); | |||||
$numberVisitsMonth = $resultMatomoApiVisitSummary->nb_uniq_visitors; | |||||
return $this->render('about', [ | |||||
'countProducersActive' => $countProducersActive, | |||||
'numberVisitsMonth' => $numberVisitsMonth | |||||
]); | |||||
} | } | ||||
/** | /** |
<h2>Résumé en quelques chiffres</h2> | <h2>Résumé en quelques chiffres</h2> | ||||
</div> | </div> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<?= few_numbers_item('35', 'Producteurs actifs'); ?> | |||||
<?= few_numbers_item($countProducersActive, 'Producteurs actifs'); ?> | |||||
<?= few_numbers_item('3000', 'Clients réguliers'); ?> | <?= few_numbers_item('3000', 'Clients réguliers'); ?> | ||||
<?= few_numbers_item('250', 'Points de vente'); ?> | <?= few_numbers_item('250', 'Points de vente'); ?> | ||||
<?= few_numbers_item('150', 'Commandes clients / jour'); ?> | <?= few_numbers_item('150', 'Commandes clients / jour'); ?> | ||||
<?= few_numbers_item('150 000 €', 'Moyenne CA / mois'); ?> | <?= few_numbers_item('150 000 €', 'Moyenne CA / mois'); ?> | ||||
<?= few_numbers_item('10 000', 'Visiteurs / mois'); ?> | |||||
<!-- https://statistiques.laclic.fr/?module=API&method=VisitsSummary.get&idSite=8&period=month&date=today&format=JSON&token_auth=35f48cd260340b4b20f67190faa27c5c --> | |||||
<?= few_numbers_item('4', 'Heures gagnées / semaine'); ?> | |||||
<?= few_numbers_item($numberVisitsMonth, 'Visiteurs le mois dernier'); ?> | |||||
<?php //few_numbers_item('4', 'Heures gagnées / semaine'); ?> | |||||
</div> | </div> | ||||
</div> | </div> |