Преглед на файлове

[Administration & site] Nombre maximum de producteurs

feature/souke
Guillaume Bourgeois преди 10 месеца
родител
ревизия
dc239df4d6
променени са 13 файла, в които са добавени 274 реда и са изтрити 187 реда
  1. +5
    -0
      common/logic/Producer/Producer/Module/ProducerModule.php
  2. +8
    -0
      common/logic/Producer/Producer/Repository/ProducerRepository.php
  3. +23
    -0
      common/logic/Producer/Producer/Service/ProducerManager.php
  4. +2
    -0
      common/logic/Setting/SettingDetails/Admin/AdminSettingDefinition.php
  5. +17
    -0
      common/logic/Setting/SettingDetails/Admin/General/MaximumNumberProducersAdminSetting.php
  6. +5
    -2
      frontend/controllers/SiteController.php
  7. +20
    -0
      frontend/views/site/_button_producer_signup.php
  8. +7
    -11
      frontend/views/site/index.php
  9. +4
    -6
      frontend/views/site/service.php
  10. +5
    -3
      frontend/views/site/signup.php
  11. +161
    -157
      frontend/web/css/screen.css
  12. +7
    -7
      frontend/web/sass/_responsive.scss
  13. +10
    -1
      frontend/web/sass/screen.scss

+ 5
- 0
common/logic/Producer/Producer/Module/ProducerModule.php Целия файл

@@ -60,6 +60,11 @@ class ProducerModule extends AbstractModule
return ProducerManager::getInstance();
}

public function getManager(): ProducerManager
{
return ProducerManager::getInstance();
}

public function getProducerPageSizer(): ProducerPageSizer
{
return ProducerPageSizer::getInstance();

+ 8
- 0
common/logic/Producer/Producer/Repository/ProducerRepository.php Целия файл

@@ -11,6 +11,7 @@ use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Service\ProducerSolver;
use common\logic\Producer\ProducerPriceRange\Repository\ProducerPriceRangeRepository;
use common\logic\Setting\AdminSettingBag;
use common\logic\User\User\Model\User;
use yii\helpers\Html;

@@ -369,6 +370,13 @@ class ProducerRepository extends AbstractRepository
return $count;
}

public function countCacheProducersActiveWithTurnover(): int
{
return \Yii::$app->cache->getOrSet('count_producers_active', function () {
return $this->countProducersActiveWithTurnover();
}, 60 * 60 * 24);
}

public function findProducers()
{
return $this->createQuery()->find();

+ 23
- 0
common/logic/Producer/Producer/Service/ProducerManager.php Целия файл

@@ -5,9 +5,20 @@ namespace common\logic\Producer\Producer\Service;
use common\logic\AbstractService;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\ManagerInterface;
use common\logic\Producer\Producer\Repository\ProducerRepository;
use common\logic\Setting\AdminSettingBag;

class ProducerManager extends AbstractService implements ManagerInterface
{
protected AdminSettingBag $adminSettingBag;
protected ProducerRepository $producerRepository;

public function loadDependencies(): void
{
$this->adminSettingBag = $this->loadService(AdminSettingBag::class);
$this->producerRepository = $this->loadService(ProducerRepository::class);
}

public function sendEmailNewProducer(Producer $producer): void
{
\Yii::$app->mailerService->sendAdmin(
@@ -18,4 +29,16 @@ class ProducerManager extends AbstractService implements ManagerInterface
]
);
}

public function isProducerSignupOpen(): bool
{
return $this->adminSettingBag->get('maximumNumberProducers')
> $this->producerRepository->countCacheProducersActiveWithTurnover();
}

public function getProducerSignupRemainingPlaces(): int
{
return max($this->adminSettingBag->get('maximumNumberProducers')
- $this->producerRepository->countCacheProducersActiveWithTurnover(), 0);
}
}

+ 2
- 0
common/logic/Setting/SettingDetails/Admin/AdminSettingDefinition.php Целия файл

@@ -6,6 +6,7 @@ use common\logic\Setting\SettingDefinition;
use common\logic\Setting\SettingDetails\Admin\General\AdministratorEmailAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\AdministratorPhoneNumberAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\ForumFlarumUrlAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\MaximumNumberProducersAdminSetting;

class AdminSettingDefinition extends SettingDefinition
{
@@ -19,6 +20,7 @@ class AdminSettingDefinition extends SettingDefinition
self::SUBSECTION_GENERAL => [
new AdministratorEmailAdminSetting(),
new AdministratorPhoneNumberAdminSetting(),
new MaximumNumberProducersAdminSetting(),
new ForumFlarumUrlAdminSetting(),
]
],

+ 17
- 0
common/logic/Setting/SettingDetails/Admin/General/MaximumNumberProducersAdminSetting.php Целия файл

@@ -0,0 +1,17 @@
<?php

namespace common\logic\Setting\SettingDetails\Admin\General;

use common\logic\Setting\SettingDetails\AbstractSettingDetail;

class MaximumNumberProducersAdminSetting extends AbstractSettingDetail
{
public function __construct()
{
$this
->setName('maximumNumberProducers')
->setLabel("Nombre maximum de producteurs")
->setTypeInteger()
->setFormTypeInput();
}
}

+ 5
- 2
frontend/controllers/SiteController.php Целия файл

@@ -133,7 +133,10 @@ class SiteController extends FrontendController
*/
public function actionIndex()
{
return $this->render('index');
return $this->render('index', [
'maximumNumberProducers' => $this->getSettingModule()->getAdminSettingBag()->get('maximumNumberProducers'),
'countProducersActive' => $this->getProducerModule()->getRepository()->countCacheProducersActiveWithTurnover()
]);
}

public function actionService()
@@ -183,7 +186,7 @@ class SiteController extends FrontendController
$userModule = $this->getUserModule();
$orderModule = $this->getOrderModule();

$countProducersActive = $producerModule->countProducersActiveWithTurnover();
$countProducersActive = $producerModule->getRepository()->countProducersActiveWithTurnover();
$timeSavedByProducersAverage = $producerModule->getTimeSavedByProducersAverage();
$countProducersWithOptionTimeSaved = $producerModule->countProducersWithTimeSaved();
$countPointSalesActive = $pointSaleModule->countPointSalesActiveLastThreeMonths();

+ 20
- 0
frontend/views/site/_button_producer_signup.php Целия файл

@@ -0,0 +1,20 @@
<?php
$producerModule = $this->getProducerModule();
$producerSignupRemainingPlaces = $producerModule->getManager()->getProducerSignupRemainingPlaces();

if (Yii::$app->user->isGuest): ?>
<?php if($producerModule->getManager()->isProducerSignupOpen()): ?>
<a class="btn btn-primary"
href="<?= \Yii::$app->urlManagerFrontend->createUrl(['site/signup']); ?>">
<span class="glyphicon glyphicon-user"></span> Je crée mon espace producteur
</a><br />
<strong><?= ($producerSignupRemainingPlaces); ?></strong>
place<?php if($producerSignupRemainingPlaces > 1): ?>s<?php endif; ?> restante<?php if($producerSignupRemainingPlaces > 1): ?>s<?php endif; ?>
<?php else: ?>
<div class="label label-warning label-producer-signup-closed">
La plateforme n'accueille pas de nouveaux producteurs pour le moment
</div>
<?php endif; ?>
<br />
<br />
<?php endif; ?>

+ 7
- 11
frontend/views/site/index.php Целия файл

@@ -41,6 +41,8 @@ use common\helpers\Url;
$this->setTitle('Un outil pour organiser des ventes en circuit court');
$this->setMeta('description', 'Simplifiez la distribution de vos produits en circuit court grâce à des outils web adaptés.');

$producerModule = $this->getProducerModule();

?>

<div class="row" id="row-users-producers">
@@ -58,25 +60,19 @@ $this->setMeta('description', 'Simplifiez la distribution de vos produits en cir
<div class="word-animate"><span class="functionality"></span></div>
</div>
<div class="links">
<?php if (Yii::$app->user->isGuest): ?>
<a class="btn btn-primary"
href="<?= \Yii::$app->urlManagerFrontend->createUrl(['site/signup']); ?>">
<span class="glyphicon glyphicon-user"></span> Je crée mon espace
</a>
<?php endif; ?>
<?= $this->render('_button_producer_signup'); ?>
<a class="btn btn-default"
href="<?= \Yii::$app->urlManagerFrontend->createUrl(['site/service']); ?>">
<span class="glyphicon glyphicon-plus-sign"></span> En savoir plus
</a>
<?php if (Yii::$app->user->isGuest): ?><br /><?php endif; ?>
<a class="btn btn-default" href="<?= \Yii::$app->parameterBag->get('appointmentUrl'); ?>" target="_blank">
<span class="glyphicon glyphicon-education"></span> Je demande une démo
</a>
<?php if (Yii::$app->user->isGuest): ?>
<a class="btn btn-default"
href="<?= \Yii::$app->urlManagerFrontend->createUrl(['site/producer', 'id' => 32]); ?>">
<span class="glyphicon glyphicon-check"></span> Je teste le logiciel
</a>
<a class="btn btn-default"
href="<?= \Yii::$app->urlManagerFrontend->createUrl(['site/producer', 'id' => 32]); ?>">
<span class="glyphicon glyphicon-check"></span> Je teste le logiciel
</a>
<?php endif; ?>
</div>
</div>

+ 4
- 6
frontend/views/site/service.php Целия файл

@@ -37,6 +37,8 @@

use yii\helpers\Html;

$producerModule = $this->getProducerModule();

$this->setTitle('Fonctionnalités, services & tarifs');
$this->setIcon('console');
//$this->setMeta('description', '');
@@ -156,21 +158,17 @@ $this->setIcon('console');
</div>
<div class="panel-body">
<p class="text-center">
<?= $this->render('_button_producer_signup'); ?>
<?php if (Yii::$app->user->isGuest): ?>
<a class="btn btn-default"
href="<?= $this->getUrlManagerFrontend()->createUrl(['site/signup']); ?>">
<span class="glyphicon glyphicon-user"></span> Je crée un espace producteur
</a>
<?php endif; ?>
<a class="btn btn-default"
href="<?= $this->getUrlManagerFrontend()->createUrl(['site/producer', 'id' => 32]); ?>">
<span class="glyphicon glyphicon-check"></span> Je teste le logiciel
</a>
<?php endif; ?>
<a class="btn btn-default" href="<?= \Yii::$app->parameterBag->get('appointmentUrl'); ?>"
target="_blank">
<span class="glyphicon glyphicon-education"></span> Je demande une démo
</a>
<br><br>
<a class="btn btn-default"
href="<?= $this->getUrlManagerFrontend()->createUrl(['site/about']); ?>">
<span class="glyphicon glyphicon-info-sign"></span> À propos

+ 5
- 3
frontend/views/site/signup.php Целия файл

@@ -69,9 +69,11 @@ $this->params['breadcrumbs'][] = $this->title;
<label class="btn btn-default <?php if($model->option_user_producer == 'user' || !$model->option_user_producer): ?>active<?php endif; ?>">
<input type="radio" name="SignupForm[option_user_producer]" value="user" id="option-user" autocomplete="off" <?php if($model->option_user_producer == 'user' || !$model->option_user_producer): ?>checked<?php endif; ?>> Je suis client
</label>
<label class="btn btn-default <?php if($model->option_user_producer == 'producer'): ?>active<?php endif; ?>">
<input type="radio" name="SignupForm[option_user_producer]" value="producer" id="option-producer" autocomplete="off" <?php if($model->option_user_producer == 'producer'): ?>checked<?php endif; ?>> Je suis producteur
</label>
<?php if($this->getProducerModule()->getManager()->isProducerSignupOpen()): ?>
<label class="btn btn-default <?php if($model->option_user_producer == 'producer'): ?>active<?php endif; ?>">
<input type="radio" name="SignupForm[option_user_producer]" value="producer" id="option-producer" autocomplete="off" <?php if($model->option_user_producer == 'producer'): ?>checked<?php endif; ?>> Je suis producteur
</label>
<?php endif; ?>
</div>

<div id="fields-producer">

+ 161
- 157
frontend/web/css/screen.css
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 7
- 7
frontend/web/sass/_responsive.scss Целия файл

@@ -35,13 +35,12 @@ termes.
*/

@media screen and (min-width: 768px) {
.equal, .equal > div[class*='col-'] {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
flex: 1 1 auto;
.home #row-users-producers {
.producer, .users {
.panel-body {
height: 260px;
}
}
}
}

@@ -150,6 +149,7 @@ termes.
}

.home {

#content #presentation-distrib h3 {
color: $courant;
}

+ 10
- 1
frontend/web/sass/screen.scss Целия файл

@@ -572,6 +572,10 @@ section#header-title {
}
}

.label-producer-signup-closed {
font-size: 14px;
}

#row-users-producers {
width: 100%;
text-align: center;
@@ -606,7 +610,6 @@ section#header-title {
right: 6px;
}
}

}
}

@@ -1034,6 +1037,12 @@ section#header-title {
}
}

#content .site-service {
#panel-go-further {
text-align: center;
}
}

#content #mentions {
padding-top: 20px;


Loading…
Отказ
Запис