浏览代码

[Administration] Support admin : producteurs en ligne

feature/souke
Guillaume Bourgeois 9 个月前
父节点
当前提交
7220e1eb95
共有 13 个文件被更改,包括 231 次插入65 次删除
  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 查看文件

@@ -78,6 +78,15 @@ class ProducerAdminController extends BackendController
];
}

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

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

/**
* Liste les producteurs.
*

+ 14
- 3
backend/views/layouts/left.php 查看文件

@@ -86,6 +86,12 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran
$sumUserProducerCreditsLabel = '';
//$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(
@@ -176,7 +182,14 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran
],
['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',
'url' => ['support-admin/index'],
'visible' => $isUserCurrentGrantedAsAdministrator,
@@ -207,7 +220,5 @@ $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGran
],
]
) ?>

</section>

</aside>

+ 85
- 0
backend/views/producer-admin/online.php 查看文件

@@ -0,0 +1,85 @@
<?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 查看文件

@@ -36,6 +36,7 @@
* termes.
*/

use common\helpers\Image;
use common\logic\Ticket\Ticket\Model\Ticket;
use common\logic\Ticket\Ticket\Module\TicketModule;
use yii\helpers\Html;
@@ -45,6 +46,7 @@ use yii\grid\GridView;
* @var $this common\components\ViewBackend
*/

$userModule = $this->getUserModule();
$ticketModule = TicketModule::getInstance();
$adminSettingBag = $this->getSettingModule()->getAdminSettingBag();
$userCurrent = $this->getUserCurrent();
@@ -56,67 +58,69 @@ $supportDeveloperOnline = $adminSettingBag->get('supportDeveloperOnline');
?>

<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">
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; ?>
</span>
<span class="info-box-text">
<span class="info-box-text">
<br/>
<strong><?= $adminSettingBag->get('administratorPhoneNumber'); ?></strong>
</span>
</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/>
<?= Html::a('Prendre rendez-vous', Yii::$app->parameterBag->get('appointmentUrl'), ['class' => 'btn btn-sm btn-default', 'target' => '_blank']); ?>
</span>
</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>
<?php if($adminSettingBag->get('forumFlarumUrl')): ?>
<div class="col-md-6 col-left">
<div class="col-md-6 col-right">
<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">
<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>
<?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; ?>

<div class="nav-tabs-custom ticket-list">
@@ -157,11 +161,10 @@ function ticketList($context, $searchTicket, $dataProviderTicket, $userCurrent)
'format' => 'raw',
'value' => function ($ticket) use ($ticketModule, $userCurrent) {

if($ticketModule->isTicketUnread($ticket, $userCurrent)) {
if ($ticketModule->isTicketUnread($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]);
}

@@ -205,7 +208,7 @@ function ticketList($context, $searchTicket, $dataProviderTicket, $userCurrent)
'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'view' => function ($url, $ticket) {
'view' => function ($url, $ticket) {
$url = ['view', 'id' => $ticket->id];
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [
'title' => 'Voir le ticket', 'class' => 'btn btn-default'
@@ -235,7 +238,7 @@ function ticketList($context, $searchTicket, $dataProviderTicket, $userCurrent)
}
];

if($context == 'producer') {
if ($context == 'producer') {
$columns = [
$columnCreatedAt,
$columnSubject,
@@ -243,8 +246,7 @@ function ticketList($context, $searchTicket, $dataProviderTicket, $userCurrent)
$columnMessages,
$columnButtonActions
];
}
elseif($context == 'admin') {
} elseif ($context == 'admin') {
$columns = [
$columnCreatedAt,
$columnProducer,

+ 17
- 6
backend/web/css/screen.css 查看文件

@@ -2916,32 +2916,32 @@ termes.
padding-left: 25px;
}

/* line 4, ../sass/support/_index.scss */
/* line 3, ../sass/support/_index.scss */
.support-index .col-left {
padding-left: 0px;
}
/* line 7, ../sass/support/_index.scss */
/* line 6, ../sass/support/_index.scss */
.support-index .col-right {
padding-right: 0px;
}
/* line 13, ../sass/support/_index.scss */
/* line 12, ../sass/support/_index.scss */
.support-index .ticket-list .nav-tabs .label {
position: relative;
top: -2px;
left: 2px;
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 {
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-last-message,
.support-index .ticket-list .table .td-messages {
width: 100px;
}
/* line 31, ../sass/support/_index.scss */
/* line 30, ../sass/support/_index.scss */
.support-index .ticket-list .table .td-producer {
width: 200px;
}
@@ -2966,6 +2966,17 @@ termes.
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 */
.feature-admin-index table th.only-for-selected-producers,
.feature-admin-index table td.only-for-selected-producers {

+ 12
- 0
backend/web/sass/producer-admin/_online.scss 查看文件

@@ -0,0 +1,12 @@

.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 查看文件

@@ -1530,6 +1530,7 @@ a.btn, button.btn {
@import "support/_index.scss";
@import "support/_view.scss";
@import "producer-admin/_index.scss";
@import "producer-admin/_online.scss";
@import "feature-admin/_index.scss";
@import "setting/_form.scss";
@import "_responsive.scss" ;

+ 0
- 1
backend/web/sass/support/_index.scss 查看文件

@@ -1,6 +1,5 @@

.support-index {

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

+ 10
- 3
common/logic/Producer/Producer/Service/ProducerManager.php 查看文件

@@ -30,15 +30,22 @@ class ProducerManager extends AbstractService implements ManagerInterface
);
}

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

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
{
return max($this->adminSettingBag->get('maximumNumberProducers')
return max($this->getMaximumNumberProducers()
- $this->producerRepository->countCacheProducersActiveWithTurnover(), 0);
}
}

+ 6
- 0
common/logic/User/User/Model/User.php 查看文件

@@ -39,6 +39,7 @@
namespace common\logic\User\User\Model;

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\UserUserGroup\Model\UserUserGroup;
use yii\base\NotSupportedException;
@@ -246,6 +247,11 @@ class User extends ActiveRecordCommon implements IdentityInterface
* Relations
*/

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

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

+ 13
- 0
common/logic/User/User/Repository/UserRepository.php 查看文件

@@ -267,4 +267,17 @@ class UserRepository extends AbstractRepository
$userProducer = $this->userProducerRepository->findOneUserProducer($user);
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 查看文件

@@ -50,4 +50,12 @@ class UserRepositoryQuery extends AbstractRepositoryQuery
{
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 查看文件

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

if (Yii::$app->user->isGuest): ?>
<?php if($producerModule->getManager()->isProducerSignupOpen()): ?>
<?php if($producerManager->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 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: ?>
<div class="label label-warning label-producer-signup-closed">
La plateforme n'accueille pas de nouveaux producteurs pour le moment

正在加载...
取消
保存