Browse Source

[Administration] Support admin : producteurs en ligne

feature/souke
Guillaume Bourgeois 9 months ago
parent
commit
7220e1eb95
13 changed files with 231 additions and 65 deletions
  1. +9
    -0
      backend/controllers/ProducerAdminController.php
  2. +14
    -3
      backend/views/layouts/left.php
  3. +85
    -0
      backend/views/producer-admin/online.php
  4. +49
    -47
      backend/views/support/index.php
  5. +17
    -6
      backend/web/css/screen.css
  6. +12
    -0
      backend/web/sass/producer-admin/_online.scss
  7. +1
    -0
      backend/web/sass/screen.scss
  8. +0
    -1
      backend/web/sass/support/_index.scss
  9. +10
    -3
      common/logic/Producer/Producer/Service/ProducerManager.php
  10. +6
    -0
      common/logic/User/User/Model/User.php
  11. +13
    -0
      common/logic/User/User/Repository/UserRepository.php
  12. +8
    -0
      common/logic/User/User/Repository/UserRepositoryQuery.php
  13. +7
    -5
      frontend/views/site/_button_producer_signup.php

+ 9
- 0
backend/controllers/ProducerAdminController.php View File

]; ];
} }


public function actionOnline()
{
$usersWithStatusProducerOnlineArray = $this->getUserModule()->getRepository()->findUsersStatusProducerOnline();

return $this->render('@backend/views/producer-admin/online', [
'usersWithStatusProducerOnlineArray' => $usersWithStatusProducerOnlineArray,
]);
}

/** /**
* Liste les producteurs. * Liste les producteurs.
* *

+ 14
- 3
backend/views/layouts/left.php View File

$sumUserProducerCreditsLabel = ''; $sumUserProducerCreditsLabel = '';
//$sumUserProducerCreditsLabel = '<span class="pull-right-container"><small class="label pull-right '.($sumUserProducerCredits >= 0 ? 'bg-green' : 'bg-red') .'">'.number_format($sumUserProducerCredits, 2).' €</small></span>'; //$sumUserProducerCreditsLabel = '<span class="pull-right-container"><small class="label pull-right '.($sumUserProducerCredits >= 0 ? 'bg-green' : 'bg-red') .'">'.number_format($sumUserProducerCredits, 2).' €</small></span>';


$countUsersWithStatusProducerOnline = $userModule->getRepository()->countUsersStatusProducerOnline();
$countUsersWithStatusProducerOnlineLabel = '';
if($countUsersWithStatusProducerOnline) {
$countUsersWithStatusProducerOnlineLabel = '<span class="pull-right-container"><small class="label pull-right bg-blue">'.$countUsersWithStatusProducerOnline.'</small></span>';
}

?> ?>


<?= dmstr\widgets\Menu::widget( <?= dmstr\widgets\Menu::widget(
], ],
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator], ['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
[ [
'label' => 'Tickets',
'label' => 'En ligne',
'icon' => 'wifi',
'url' => ['producer-admin/online'],
'visible' => $isUserCurrentGrantedAsAdministrator,
'template' => '<a href="{url}">{icon} {label}' . $countUsersWithStatusProducerOnlineLabel . '</a>'
],
[
'label' => 'Support',
'icon' => 'comments', 'icon' => 'comments',
'url' => ['support-admin/index'], 'url' => ['support-admin/index'],
'visible' => $isUserCurrentGrantedAsAdministrator, 'visible' => $isUserCurrentGrantedAsAdministrator,
], ],
] ]
) ?> ) ?>

</section> </section>

</aside> </aside>

+ 85
- 0
backend/views/producer-admin/online.php View File

<?php

/**
* Copyright distrib (2018)
*
* contact@opendistrib.net
*
* Ce logiciel est un programme informatique servant à aider les producteurs
* à distribuer leur production en circuits courts.
*
* Ce logiciel est régi par la licence CeCILL soumise au droit français et
* respectant les principes de diffusion des logiciels libres. Vous pouvez
* utiliser, modifier et/ou redistribuer ce programme sous les conditions
* de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
* sur le site "http://www.cecill.info".
*
* En contrepartie de l'accessibilité au code source et des droits de copie,
* de modification et de redistribution accordés par cette licence, il n'est
* offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
* seule une responsabilité restreinte pèse sur l'auteur du programme, le
* titulaire des droits patrimoniaux et les concédants successifs.
*
* A cet égard l'attention de l'utilisateur est attirée sur les risques
* associés au chargement, à l'utilisation, à la modification et/ou au
* développement et à la reproduction du logiciel par l'utilisateur étant
* donné sa spécificité de logiciel libre, qui peut le rendre complexe à
* manipuler et qui le réserve donc à des développeurs et des professionnels
* avertis possédant des connaissances informatiques approfondies. Les
* utilisateurs sont donc invités à charger et tester l'adéquation du
* logiciel à leurs besoins dans des conditions permettant d'assurer la
* sécurité de leurs systèmes et ou de leurs données et, plus généralement,
* à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
*
* Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
* pris connaissance de la licence CeCILL, et que vous en avez accepté les
* termes.
*/

use common\helpers\Image;
use yii\helpers\Html;
use yii\grid\GridView;
use common\logic\User\User\Model\User;
use common\logic\Producer\Producer\Model\Producer;
use common\helpers\Price;

$producerModule = $this->getProducerModule();
$userModule = $this->getUserModule();
$this->setTitle('Producteurs en ligne');
$this->addBreadcrumb($this->getTitle());

?>
<div class="producer-admin-online">
<?php if($usersWithStatusProducerOnlineArray && count($usersWithStatusProducerOnlineArray) > 0): ?>
<?php foreach ($usersWithStatusProducerOnlineArray as $userWithStatusProducerOnline): ?>
<?php $producer = $userWithStatusProducerOnline->producer; ?>
<div class="col-md-3">
<div class="box box-primary">
<div class="box-body box-profile">
<?php if ($producer->logo && Image::isPhotoExist($producer->logo)): ?>
<img class="profile-user-img img-responsive img-circle"
src="<?= Yii::$app->urlManagerProducer->getHostInfo() . '/' . Yii::$app->urlManagerProducer->baseUrl; ?>/uploads/<?= $producer->logo; ?>"
alt="Logo <?= Html::encode($producer->name) ?>">
<?php endif; ?>

<h3 class="profile-username text-center">
<?= $producer->name; ?>
</h3>
<p class="text-muted text-center">
<?= $userModule->getSolver()->getUsername($userWithStatusProducerOnline); ?><br/>
</p>
<!--<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<b>Téléphone</b> <a class="pull-right">06 00 00 00 00</a>
</li>
</ul>
<a href="#" class="btn btn-primary btn-block"><b>Bouton</b></a>-->
</div>
</div>
</div>
<?php endforeach; ?>
<div class="clr"></div>
<?php else: ?>
<div class="alert alert-info">Aucun producteur en ligne actuellement.</div>
<?php endif; ?>
</div>

+ 49
- 47
backend/views/support/index.php View File

* termes. * termes.
*/ */


use common\helpers\Image;
use common\logic\Ticket\Ticket\Model\Ticket; use common\logic\Ticket\Ticket\Model\Ticket;
use common\logic\Ticket\Ticket\Module\TicketModule; use common\logic\Ticket\Ticket\Module\TicketModule;
use yii\helpers\Html; use yii\helpers\Html;
* @var $this common\components\ViewBackend * @var $this common\components\ViewBackend
*/ */


$userModule = $this->getUserModule();
$ticketModule = TicketModule::getInstance(); $ticketModule = TicketModule::getInstance();
$adminSettingBag = $this->getSettingModule()->getAdminSettingBag(); $adminSettingBag = $this->getSettingModule()->getAdminSettingBag();
$userCurrent = $this->getUserCurrent(); $userCurrent = $this->getUserCurrent();
?> ?>


<div class="support-index"> <div class="support-index">
<?php if($context == 'producer'): ?>
<?php if ($context == 'producer'): ?>


<div class="callout callout-info">
<p><i class="icon fa fa-info-circle"></i> Pour toutes vos questions, remarques, suggestions et remontées de bugs.</p>
</div>
<div>
<div class="col-md-6 col-left">
<div class="info-box">
<span class="info-box-icon <?php if($supportDeveloperOnline): ?>bg-green<?php else: ?>bg-yellow<?php endif; ?>"><i class="fa fa-phone"></i></span>
<div class="info-box-content">
<div class="callout callout-info">
<p><i class="icon fa fa-info-circle"></i> Pour toutes vos questions, remarques, suggestions et remontées de
bugs.</p>
</div>
<div>
<div class="col-md-6 col-left">
<div class="info-box">
<span class="info-box-icon <?php if ($supportDeveloperOnline): ?>bg-green<?php else: ?>bg-yellow<?php endif; ?>"><i
class="fa fa-phone"></i></span>
<div class="info-box-content">
<span class="info-box-text"> <span class="info-box-text">
Me contacter directement Me contacter directement
<?php if($supportDeveloperOnline): ?>
<br /><span class="label label-success">Disponible</span>
<?php if ($supportDeveloperOnline): ?>
<br/><span class="label label-success">Disponible</span>
<?php endif; ?> <?php endif; ?>
</span> </span>
<span class="info-box-text">
<span class="info-box-text">
<br/> <br/>
<strong><?= $adminSettingBag->get('administratorPhoneNumber'); ?></strong> <strong><?= $adminSettingBag->get('administratorPhoneNumber'); ?></strong>
</span> </span>
</div>
</div> </div>
</div> </div>
</div>
<div class="col-md-6 col-right">
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-calendar"></i></span>
<div class="info-box-content">
<div class="col-md-6 col-right">
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-calendar"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br/> <span class="info-box-text"><br/>
<?= Html::a('Prendre rendez-vous', Yii::$app->parameterBag->get('appointmentUrl'), ['class' => 'btn btn-sm btn-default', 'target' => '_blank']); ?> <?= Html::a('Prendre rendez-vous', Yii::$app->parameterBag->get('appointmentUrl'), ['class' => 'btn btn-sm btn-default', 'target' => '_blank']); ?>
</span> </span>
</div>
</div> </div>
</div> </div>
</div>
<div class="col-md-6 col-left">
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-comments"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br/><?= Html::a('Ouvrir un ticket', ['support/create'], ['class' => 'btn btn-sm btn-default']); ?></span>
</div>
</div>
</div>
<div class="col-md-6 col-right">
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-envelope"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br/><?= Html::a("M'envoyer un email", 'mailto:'.$adminSettingBag->get('administratorEmail'), ['class' => 'btn btn-sm btn-default']); ?></span>
<div class="col-md-6 col-left">
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-comments"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br/><?= Html::a('Ouvrir un ticket', ['support/create'], ['class' => 'btn btn-sm btn-default']); ?></span>
</div>
</div> </div>
</div> </div>
</div>
<?php if($adminSettingBag->get('forumFlarumUrl')): ?>
<div class="col-md-6 col-left">
<div class="col-md-6 col-right">
<div class="info-box"> <div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-users"></i></span>
<span class="info-box-icon bg-yellow"><i class="fa fa-envelope"></i></span>
<div class="info-box-content"> <div class="info-box-content">
<span class="info-box-text"><br/><?= Html::a("Ouvrir une discussion sur le forum", $adminSettingBag->get('forumFlarumUrl'), ['class' => 'btn btn-sm btn-default', 'target' => '_blank']); ?></span>
<span class="info-box-text"><br/><?= Html::a("M'envoyer un email", 'mailto:' . $adminSettingBag->get('administratorEmail'), ['class' => 'btn btn-sm btn-default']); ?></span>
</div> </div>
</div> </div>
</div> </div>
<?php endif; ?>
</div>
<div class="clr"></div>
<?php if ($adminSettingBag->get('forumFlarumUrl')): ?>
<div class="col-md-6 col-left">
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-users"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br/><?= Html::a("Ouvrir une discussion sur le forum", $adminSettingBag->get('forumFlarumUrl'), ['class' => 'btn btn-sm btn-default', 'target' => '_blank']); ?></span>
</div>
</div>
</div>
<?php endif; ?>
</div>
<div class="clr"></div>
<?php endif; ?> <?php endif; ?>


<div class="nav-tabs-custom ticket-list"> <div class="nav-tabs-custom ticket-list">
'format' => 'raw', 'format' => 'raw',
'value' => function ($ticket) use ($ticketModule, $userCurrent) { 'value' => function ($ticket) use ($ticketModule, $userCurrent) {


if($ticketModule->isTicketUnread($ticket, $userCurrent)) {
if ($ticketModule->isTicketUnread($ticket, $userCurrent)) {
$firstTicketMessageUnread = $ticketModule->getFirstTicketMessageUnread($ticket, $userCurrent); $firstTicketMessageUnread = $ticketModule->getFirstTicketMessageUnread($ticket, $userCurrent);
$link = '<strong>'.Html::a($ticket->subject, ['view', 'id' => $ticket->id, '#' => $firstTicketMessageUnread->id]).'</strong>';
}
else {
$link = '<strong>' . Html::a($ticket->subject, ['view', 'id' => $ticket->id, '#' => $firstTicketMessageUnread->id]) . '</strong>';
} else {
$link = Html::a($ticket->subject, ['view', 'id' => $ticket->id]); $link = Html::a($ticket->subject, ['view', 'id' => $ticket->id]);
} }


'headerOptions' => ['class' => 'column-actions'], 'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'], 'contentOptions' => ['class' => 'column-actions'],
'buttons' => [ 'buttons' => [
'view' => function ($url, $ticket) {
'view' => function ($url, $ticket) {
$url = ['view', 'id' => $ticket->id]; $url = ['view', 'id' => $ticket->id];
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [ return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [
'title' => 'Voir le ticket', 'class' => 'btn btn-default' 'title' => 'Voir le ticket', 'class' => 'btn btn-default'
} }
]; ];


if($context == 'producer') {
if ($context == 'producer') {
$columns = [ $columns = [
$columnCreatedAt, $columnCreatedAt,
$columnSubject, $columnSubject,
$columnMessages, $columnMessages,
$columnButtonActions $columnButtonActions
]; ];
}
elseif($context == 'admin') {
} elseif ($context == 'admin') {
$columns = [ $columns = [
$columnCreatedAt, $columnCreatedAt,
$columnProducer, $columnProducer,

+ 17
- 6
backend/web/css/screen.css View File

padding-left: 25px; padding-left: 25px;
} }


/* line 4, ../sass/support/_index.scss */
/* line 3, ../sass/support/_index.scss */
.support-index .col-left { .support-index .col-left {
padding-left: 0px; padding-left: 0px;
} }
/* line 7, ../sass/support/_index.scss */
/* line 6, ../sass/support/_index.scss */
.support-index .col-right { .support-index .col-right {
padding-right: 0px; padding-right: 0px;
} }
/* line 13, ../sass/support/_index.scss */
/* line 12, ../sass/support/_index.scss */
.support-index .ticket-list .nav-tabs .label { .support-index .ticket-list .nav-tabs .label {
position: relative; position: relative;
top: -2px; top: -2px;
left: 2px; left: 2px;
padding: 0.3em 0.6em 0.2em 0.6em; padding: 0.3em 0.6em 0.2em 0.6em;
} }
/* line 22, ../sass/support/_index.scss */
/* line 21, ../sass/support/_index.scss */
.support-index .ticket-list .table .filters { .support-index .ticket-list .table .filters {
display: none; display: none;
} }
/* line 26, ../sass/support/_index.scss */
/* line 25, ../sass/support/_index.scss */
.support-index .ticket-list .table .td-created-at, .support-index .ticket-list .table .td-created-at,
.support-index .ticket-list .table .td-last-message, .support-index .ticket-list .table .td-last-message,
.support-index .ticket-list .table .td-messages { .support-index .ticket-list .table .td-messages {
width: 100px; width: 100px;
} }
/* line 31, ../sass/support/_index.scss */
/* line 30, ../sass/support/_index.scss */
.support-index .ticket-list .table .td-producer { .support-index .ticket-list .table .td-producer {
width: 200px; width: 200px;
} }
margin-top: 5px; margin-top: 5px;
} }


/* line 3, ../sass/producer-admin/_online.scss */
.producer-admin-online .box {
height: 250px;
}
/* line 6, ../sass/producer-admin/_online.scss */
.producer-admin-online .box .profile-username {
font-family: 'Source Sans Pro',sans-serif;
font-weight: normal;
font-size: 18px;
}

/* line 4, ../sass/feature-admin/_index.scss */ /* line 4, ../sass/feature-admin/_index.scss */
.feature-admin-index table th.only-for-selected-producers, .feature-admin-index table th.only-for-selected-producers,
.feature-admin-index table td.only-for-selected-producers { .feature-admin-index table td.only-for-selected-producers {

+ 12
- 0
backend/web/sass/producer-admin/_online.scss View File


.producer-admin-online {
.box {
height: 250px;

.profile-username {
font-family: 'Source Sans Pro',sans-serif;
font-weight: normal;
font-size: 18px;
}
}
}

+ 1
- 0
backend/web/sass/screen.scss View File

@import "support/_index.scss"; @import "support/_index.scss";
@import "support/_view.scss"; @import "support/_view.scss";
@import "producer-admin/_index.scss"; @import "producer-admin/_index.scss";
@import "producer-admin/_online.scss";
@import "feature-admin/_index.scss"; @import "feature-admin/_index.scss";
@import "setting/_form.scss"; @import "setting/_form.scss";
@import "_responsive.scss" ; @import "_responsive.scss" ;

+ 0
- 1
backend/web/sass/support/_index.scss View File



.support-index { .support-index {

.col-left { .col-left {
padding-left: 0px; padding-left: 0px;
} }

+ 10
- 3
common/logic/Producer/Producer/Service/ProducerManager.php View File

); );
} }


public function getMaximumNumberProducers(): ?int
{
return $this->adminSettingBag->get('maximumNumberProducers');
}

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

return !$maximumNumberProducers
|| $maximumNumberProducers > $this->producerRepository->countCacheProducersActiveWithTurnover();
} }


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

+ 6
- 0
common/logic/User/User/Model/User.php View File

namespace common\logic\User\User\Model; namespace common\logic\User\User\Model;


use common\logic\Order\Order\Model\Order; use common\logic\Order\Order\Model\Order;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\User\UserProducer\Model\UserProducer; use common\logic\User\UserProducer\Model\UserProducer;
use common\logic\User\UserUserGroup\Model\UserUserGroup; use common\logic\User\UserUserGroup\Model\UserUserGroup;
use yii\base\NotSupportedException; use yii\base\NotSupportedException;
* Relations * Relations
*/ */


public function getProducer()
{
return $this->hasOne(Producer::class, ['id' => 'id_producer']);
}

public function getUserProducer() public function getUserProducer()
{ {
return $this->hasMany(UserProducer::class, ['id_user' => 'id']); return $this->hasMany(UserProducer::class, ['id_user' => 'id']);

+ 13
- 0
common/logic/User/User/Repository/UserRepository.php View File

$userProducer = $this->userProducerRepository->findOneUserProducer($user); $userProducer = $this->userProducerRepository->findOneUserProducer($user);
return $userProducer ? $userProducer->active : false; return $userProducer ? $userProducer->active : false;
} }

public function findUsersStatusProducerOnline(): array
{
return $this->createDefaultQuery()
->isStatusProducer()
->filterByDateLastConnectionLessThanFewMinutes()
->find();
}

public function countUsersStatusProducerOnline(): int
{
return count($this->findUsersStatusProducerOnline());
}
} }

+ 8
- 0
common/logic/User/User/Repository/UserRepositoryQuery.php View File

{ {
return $this->filterByStatus(User::STATUS_PRODUCER); return $this->filterByStatus(User::STATUS_PRODUCER);
} }

public function filterByDateLastConnectionLessThanFewMinutes(): self
{
$date = new \DateTime('-5 minutes');
$this->andWhere('user.date_last_connection >= :date')
->addParams(['date' => $date->format('Y-m-d H:i:s')]);
return $this;
}
} }

+ 7
- 5
frontend/views/site/_button_producer_signup.php View File

<?php <?php
$producerModule = $this->getProducerModule();
$producerSignupRemainingPlaces = $producerModule->getManager()->getProducerSignupRemainingPlaces();
$producerManager = $this->getProducerModule()->getManager();
$producerSignupRemainingPlaces = $producerManager->getProducerSignupRemainingPlaces();


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

Loading…
Cancel
Save