Browse Source

[Frontend] Page "À propos"

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
255abc0f04
3 changed files with 43 additions and 7 deletions
  1. +27
    -0
      common/logic/Producer/Producer/Repository/ProducerRepository.php
  2. +13
    -1
      frontend/controllers/SiteController.php
  3. +3
    -6
      frontend/views/site/about.php

+ 27
- 0
common/logic/Producer/Producer/Repository/ProducerRepository.php View File

@@ -150,6 +150,19 @@ class ProducerRepository extends AbstractRepository
}
}

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)
{
$turnover = $this->getTurnover($producer, $month);
@@ -268,6 +281,20 @@ class ProducerRepository extends AbstractRepository
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()
{
return $this->createQuery()->find();

+ 13
- 1
frontend/controllers/SiteController.php View File

@@ -40,6 +40,7 @@ namespace frontend\controllers;

use common\helpers\GlobalParam;
use frontend\forms\ProducerCodeForm;
use GuzzleHttp\Client;
use Yii;
use frontend\forms\PasswordResetRequestForm;
use frontend\forms\ResetPasswordForm;
@@ -173,7 +174,18 @@ class SiteController extends FrontendController

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
]);
}

/**

+ 3
- 6
frontend/views/site/about.php View File

@@ -63,16 +63,13 @@ $this->setTitle('À propos');
<h2>Résumé en quelques chiffres</h2>
</div>
<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('250', 'Points de vente'); ?>
<?= few_numbers_item('150', 'Commandes clients / jour'); ?>
<?= 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>

Loading…
Cancel
Save