foreach ($versionsArray as $version) { | foreach ($versionsArray as $version) { | ||||
$versionsRenderArray[$version] = [ | $versionsRenderArray[$version] = [ | ||||
'version' => $version, | 'version' => $version, | ||||
'content' => $this->renderFile('@common/versions/' . $version . '.php') | |||||
'content' => $this->renderFile('@common/versions/' . $version . '.php', [ | |||||
'userCurrent' => $this->getUserCurrent() | |||||
]) | |||||
]; | ]; | ||||
} | } | ||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
$producerManager = ProducerManager::getInstance(); | $producerManager = ProducerManager::getInstance(); | ||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
$userCurrent = GlobalParam::getCurrentUser(); | |||||
?> | ?> | ||||
<header class="main-header"> | <header class="main-header"> | ||||
<!-- <?= Html::a('<span class="logo-mini"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span><span class="logo-lg"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span>', Yii::$app->homeUrl, ['class' => 'logo']) ?>--> | <!-- <?= Html::a('<span class="logo-mini"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span><span class="logo-lg"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span>', Yii::$app->homeUrl, ['class' => 'logo']) ?>--> | ||||
<?= Html::a('Opendistrib', Yii::$app->homeUrl, ['class' => 'logo']); ?> | <?= Html::a('Opendistrib', Yii::$app->homeUrl, ['class' => 'logo']); ?> | ||||
<nav class="navbar navbar-static-top" role="navigation"> | <nav class="navbar navbar-static-top" role="navigation"> | ||||
<ul class="nav navbar-nav"> | <ul class="nav navbar-nav"> | ||||
<?php if ($userModule->isCurrentAdmin()): ?> | |||||
<?php if ($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?> | |||||
<li class="dropdown producer-menu"> | <li class="dropdown producer-menu"> | ||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> | <a href="#" class="dropdown-toggle" data-toggle="dropdown"> | ||||
<span class="glyphicon glyphicon-grain"></span> | <span class="glyphicon glyphicon-grain"></span> | ||||
</ul> | </ul> | ||||
</li> | </li> | ||||
<?php if ($userModule->isCurrentProducer() || $userModule->isCurrentAdmin()): ?> | |||||
<?php if ($userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent)): ?> | |||||
<li> | <li> | ||||
<a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => GlobalParam::getCurrentProducer()->slug]); ?>"> | <a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => GlobalParam::getCurrentProducer()->slug]); ?>"> | ||||
<span class="glyphicon glyphicon-eye-open"></span> | <span class="glyphicon glyphicon-eye-open"></span> |
*/ | */ | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\helpers\Opendistrib; | |||||
use yii\helpers\Html; | |||||
use common\logic\Ticket\Ticket\Wrapper\TicketManager; | |||||
use common\logic\User\User\Wrapper\UserModule; | |||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$userModule = $this->getUserModule(); | |||||
$userModule = UserModule::getInstance(); | |||||
$userProducerManager = $this->getUserProducerManager(); | $userProducerManager = $this->getUserProducerManager(); | ||||
$ticketManager = $this->getTicketManager(); | $ticketManager = $this->getTicketManager(); | ||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
$userCurrent = GlobalParam::getCurrentUser(); | |||||
$isUserCurrentGrantedAsAdministrator = $userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent); | |||||
$isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent); | |||||
?> | ?> | ||||
$countTicketsProducerUnreadLabel = ''; | $countTicketsProducerUnreadLabel = ''; | ||||
$countTicketsProducerUnread = $ticketManager->countTicketsUnreadByUser($this->getUserCurrent()); | $countTicketsProducerUnread = $ticketManager->countTicketsUnreadByUser($this->getUserCurrent()); | ||||
if($countTicketsProducerUnread && !$userModule->isCurrentAdmin()) { | |||||
if($countTicketsProducerUnread && !$isUserCurrentGrantedAsAdministrator) { | |||||
$countTicketsProducerUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsProducerUnread.'</small></span>'; | $countTicketsProducerUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsProducerUnread.'</small></span>'; | ||||
} | } | ||||
$countTicketsAdminUnreadLabel = ''; | $countTicketsAdminUnreadLabel = ''; | ||||
$countTicketsAdminUnread = $ticketManager->countTicketsAdminUnreadByUser($this->getUserCurrent()); | $countTicketsAdminUnread = $ticketManager->countTicketsAdminUnreadByUser($this->getUserCurrent()); | ||||
if($countTicketsAdminUnread && $userModule->isCurrentAdmin()) { | |||||
if($countTicketsAdminUnread && $isUserCurrentGrantedAsAdministrator) { | |||||
$countTicketsAdminUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsAdminUnread.'</small></span>'; | $countTicketsAdminUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsAdminUnread.'</small></span>'; | ||||
} | } | ||||
[ | [ | ||||
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'], | 'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'], | ||||
'items' => [ | 'items' => [ | ||||
['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
[ | [ | ||||
'label' => 'Support', | 'label' => 'Support', | ||||
'icon' => 'comments', | 'icon' => 'comments', | ||||
'url' => ['support/index'], | 'url' => ['support/index'], | ||||
'visible' => $userModule->isCurrentProducer(), | |||||
'visible' => $isUserCurrentGrantedAsProducer, | |||||
'template' => '<a href="{url}">{icon} {label}' . $countTicketsProducerUnreadLabel . '</a>' | 'template' => '<a href="{url}">{icon} {label}' . $countTicketsProducerUnreadLabel . '</a>' | ||||
], | ], | ||||
['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
[ | [ | ||||
'label' => 'Produits', | 'label' => 'Produits', | ||||
'icon' => 'clone', | 'icon' => 'clone', | ||||
'url' => ['/product/index'], | 'url' => ['/product/index'], | ||||
'visible' => $userModule->isCurrentProducer(), | |||||
'visible' => $isUserCurrentGrantedAsProducer, | |||||
'active' => Yii::$app->controller->id == 'product', | 'active' => Yii::$app->controller->id == 'product', | ||||
'items' => [ | 'items' => [ | ||||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Import prix', 'icon' => 'upload', 'url' => ['/product/price-import'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => 'Import prix', 'icon' => 'upload', 'url' => ['/product/price-import'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
] | ] | ||||
], | ], | ||||
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => $userModule->isCurrentProducer(), 'active' => Yii::$app->controller->id == 'point-sale'], | |||||
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'point-sale'], | |||||
[ | [ | ||||
'label' => 'Utilisateurs', | 'label' => 'Utilisateurs', | ||||
'icon' => 'users', | 'icon' => 'users', | ||||
'url' => ['/user/index'], | 'url' => ['/user/index'], | ||||
'items' => [ | 'items' => [ | ||||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
[ | [ | ||||
'label' => 'Crédit', | 'label' => 'Crédit', | ||||
'icon' => 'euro', | 'icon' => 'euro', | ||||
'url' => ['/credit/index'], | 'url' => ['/credit/index'], | ||||
'template' => '<a href="{url}">{icon} {label}' . $sumUserProducerCreditsLabel . '</a>', | 'template' => '<a href="{url}">{icon} {label}' . $sumUserProducerCreditsLabel . '</a>', | ||||
'visible' => $userModule->isCurrentProducer() && $producerManager->getConfig('credit') | |||||
'visible' => $isUserCurrentGrantedAsProducer && $producerManager->getConfig('credit') | |||||
], | ], | ||||
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
], | ], | ||||
], | ], | ||||
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $userModule->isCurrentProducer(), 'active' => Yii::$app->controller->id == 'subscription'], | |||||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'subscription'], | |||||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
[ | [ | ||||
'label' => 'Documents', | 'label' => 'Documents', | ||||
'icon' => 'clone', | 'icon' => 'clone', | ||||
'url' => ['/delivery-note/index'], | 'url' => ['/delivery-note/index'], | ||||
'items' => [ | 'items' => [ | ||||
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
], | ], | ||||
], | ], | ||||
[ | [ | ||||
'icon' => 'line-chart', | 'icon' => 'line-chart', | ||||
'url' => ['/stats/index'], | 'url' => ['/stats/index'], | ||||
'items' => [ | 'items' => [ | ||||
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
], | ], | ||||
], | ], | ||||
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => "Opendistrib", 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => "Opendistrib", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
[ | [ | ||||
'label' => 'Développement', | 'label' => 'Développement', | ||||
'icon' => 'code', | 'icon' => 'code', | ||||
'url' => ['/development/index'], | 'url' => ['/development/index'], | ||||
'visible' => $userModule->isCurrentProducer(), | |||||
'visible' => $isUserCurrentGrantedAsProducer, | |||||
'active' => Yii::$app->controller->id == 'development', | 'active' => Yii::$app->controller->id == 'development', | ||||
'template' => '<a href="{url}">{icon} {label}' . $newVersionOpendistribLabel . '</a>' | 'template' => '<a href="{url}">{icon} {label}' . $newVersionOpendistribLabel . '</a>' | ||||
], | ], | ||||
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $userModule->isCurrentProducer()], | |||||
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
[ | [ | ||||
'label' => 'Tickets', | 'label' => 'Tickets', | ||||
'icon' => 'comments', | 'icon' => 'comments', | ||||
'url' => ['support-admin/index'], | 'url' => ['support-admin/index'], | ||||
'visible' => $userModule->isCurrentAdmin(), | |||||
'visible' => $isUserCurrentGrantedAsAdministrator, | |||||
'template' => '<a href="{url}">{icon} {label}' . $countTicketsAdminUnreadLabel . '</a>' | 'template' => '<a href="{url}">{icon} {label}' . $countTicketsAdminUnreadLabel . '</a>' | ||||
], | ], | ||||
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
[ | [ | ||||
'label' => 'Statistiques', | 'label' => 'Statistiques', | ||||
'icon' => 'line-chart', | 'icon' => 'line-chart', | ||||
'url' => ['/stats-admin/matomo'], | 'url' => ['/stats-admin/matomo'], | ||||
'visible' => $userModule->isCurrentAdmin(), | |||||
'visible' => $isUserCurrentGrantedAsAdministrator, | |||||
'items' => [ | 'items' => [ | ||||
['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Commandes clients', 'icon' => 'calendar', 'url' => ['/stats-admin/customer-orders'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
['label' => 'Commandes clients', 'icon' => 'calendar', 'url' => ['/stats-admin/customer-orders'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
], | ], | ||||
], | ], | ||||
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $userModule->isCurrentAdmin()], | |||||
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
//['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentAdmin()], | |||||
//['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $userModule->isCurrentAdmin()], | |||||
//['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $userModule->isCurrentAdmin()], | |||||
//['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
//['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
//['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userModule->isCurrentConnected()], | ['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userModule->isCurrentConnected()], | ||||
], | ], | ||||
] | ] |
* termes. | * termes. | ||||
*/ | */ | ||||
use common\helpers\GlobalParam; | |||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | use common\logic\Producer\Producer\Wrapper\ProducerManager; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
$producerManager = ProducerManager::getInstance(); | $producerManager = ProducerManager::getInstance(); | ||||
$userCurrent = GlobalParam::getCurrentUser(); | |||||
$this->setTitle('Utilisateurs'); | $this->setTitle('Utilisateurs'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
'class' => 'btn btn-default btn-confirm-delete' | 'class' => 'btn btn-default btn-confirm-delete' | ||||
]); | ]); | ||||
}, | }, | ||||
'switch' => function($url, $model) use ($userModule) { | |||||
if($userModule->isCurrentAdmin()) { | |||||
'switch' => function($url, $model) use ($userModule, $userCurrent) { | |||||
if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)) { | |||||
return Html::a('<span class="glyphicon glyphicon-user"></span>', | return Html::a('<span class="glyphicon glyphicon-user"></span>', | ||||
Yii::$app->urlManager->createUrl(['user/switch-identity', 'id' => $model->id]), | Yii::$app->urlManager->createUrl(['user/switch-identity', 'id' => $model->id]), | ||||
[ | [ |
trigger_error("Le clonage n'est pas autorisé.", E_USER_ERROR); | trigger_error("Le clonage n'est pas autorisé.", E_USER_ERROR); | ||||
}*/ | }*/ | ||||
/** | |||||
* @return $this | |||||
*/ | |||||
final public static function getInstance(): self | final public static function getInstance(): self | ||||
{ | { | ||||
$c = get_called_class(); | $c = get_called_class(); |
interface ModuleInterface | interface ModuleInterface | ||||
{ | { | ||||
public function getContainerFqcn(): string; | public function getContainerFqcn(): string; | ||||
public function getServices(): ContainerInterface; | |||||
} | } |
return !\Yii::$app->user->isGuest; | return !\Yii::$app->user->isGuest; | ||||
} | } | ||||
/** | |||||
* Retourne si l'utilisateur courant est un producteur ou non. | |||||
* | |||||
*/ | |||||
public function isCurrentProducer(): bool | |||||
{ | |||||
$user = $this->getCurrent(); | |||||
if ($user) { | |||||
return $this->isProducer($user); | |||||
} | |||||
return false; | |||||
} | |||||
/** | |||||
* Retourne si l'utilisateur courant est un admin ou non. | |||||
* | |||||
*/ | |||||
public function isCurrentAdmin(): bool | |||||
{ | |||||
$user = $this->getCurrent(); | |||||
if ($user) { | |||||
return $this->isAdmin($user); | |||||
} | |||||
return false; | |||||
} | |||||
/** | /** | ||||
* Retourne l'ID de l'utilisateur courant connecté. | * Retourne l'ID de l'utilisateur courant connecté. | ||||
* | * |
{ | { | ||||
return NewsletterManager::getInstance(); | return NewsletterManager::getInstance(); | ||||
} | } | ||||
public function getAuthorizationChecker(): AuthorizationChecker | |||||
{ | |||||
return AuthorizationChecker::getInstance(); | |||||
} | |||||
} | } |
return UserContainer::class; | return UserContainer::class; | ||||
} | } | ||||
public function getServices(): UserContainer | |||||
{ | |||||
return $this->container; | |||||
} | |||||
public function getAuthorizationChecker(): AuthorizationChecker | public function getAuthorizationChecker(): AuthorizationChecker | ||||
{ | { | ||||
return AuthorizationChecker::getInstance(); | return AuthorizationChecker::getInstance(); |
"[Backend] Facture > créer : tri des utilisateurs par ordre alphabétique", | "[Backend] Facture > créer : tri des utilisateurs par ordre alphabétique", | ||||
"Correctif connexion personnes morales" | "Correctif connexion personnes morales" | ||||
] | ] | ||||
] | |||||
], | |||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Administration] Abonnements : suppression des commandes après la date de fin lors de l'arrêt d'un abonnement", | "[Administration] Abonnements : suppression des commandes après la date de fin lors de l'arrêt d'un abonnement", | ||||
"[Administration] Distributions > calendrier : amélioration chargement automatique des distributions (affichage pastilles vertes)" | "[Administration] Distributions > calendrier : amélioration chargement automatique des distributions (affichage pastilles vertes)" | ||||
] | ] | ||||
] | |||||
], | |||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Administration] Développement : mise en avant des nouvelles versions et des informations de contact" | "[Administration] Développement : mise en avant des nouvelles versions et des informations de contact" | ||||
], | ], | ||||
[] | [] | ||||
] | |||||
], | |||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Administration] Abonnements : comportement paiement automatique (déduit, oui, non)" | "[Administration] Abonnements : comportement paiement automatique (déduit, oui, non)" | ||||
], | ], | ||||
[] | [] | ||||
] | |||||
], | |||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Administration] Documents > listes : optimisation chargement", | "[Administration] Documents > listes : optimisation chargement", | ||||
"[Espace producteur] Commander : ajustement ordre des points de vente" | "[Espace producteur] Commander : ajustement ordre des points de vente" | ||||
] | ] | ||||
] | |||||
], | |||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Administration] Correctif problème upload images webp" | "[Administration] Correctif problème upload images webp" | ||||
] | ] | ||||
], | ], | ||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
], | ], | ||||
[] | [] | ||||
], | ], | ||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Administration] Export vers le logiciel Evoliz : ajout de la TVA + code classification vente" | "[Administration] Export vers le logiciel Evoliz : ajout de la TVA + code classification vente" | ||||
], | ], | ||||
[] | [] | ||||
] | |||||
], | |||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
[ | [ | ||||
"Logiciel de caisse Tiller : synchronisation des commandes partiellement payées" | "Logiciel de caisse Tiller : synchronisation des commandes partiellement payées" | ||||
] | ] | ||||
] | |||||
], | |||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Espace producteur] Produits : mise en évidence des noms de produit", | "[Espace producteur] Produits : mise en évidence des noms de produit", | ||||
"[Site] Profil utilisateur : permettre édition adresse email" | "[Site] Profil utilisateur : permettre édition adresse email" | ||||
], | ], | ||||
] | |||||
], | |||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Espace producteur] Abonnements : correctif disponibilité produits par point de vente", | "[Espace producteur] Abonnements : correctif disponibilité produits par point de vente", | ||||
"Abonnements > ajout/modification : prise en compte des contraintes de délai et d'heure limite de commande dans la génération des commandes des distributions à venir" | "Abonnements > ajout/modification : prise en compte des contraintes de délai et d'heure limite de commande dans la génération des commandes des distributions à venir" | ||||
] | ] | ||||
] | |||||
], | |||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
'[Administration] Distributions > Produits : possibilité de définir une quantité maximum à 0', | '[Administration] Distributions > Produits : possibilité de définir une quantité maximum à 0', | ||||
'[Technique] Réécriture requêtes bases de données' | '[Technique] Réécriture requêtes bases de données' | ||||
] | ] | ||||
] | |||||
], | |||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
'[Site & espace producteur] Barre de navigation en haut du site' | '[Site & espace producteur] Barre de navigation en haut du site' | ||||
], | ], | ||||
[] | [] | ||||
] | |||||
], | |||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Administration et espace producteur] Produits : optimisation de l'affichage des images" | "[Administration et espace producteur] Produits : optimisation de l'affichage des images" | ||||
] | ] | ||||
], | ], | ||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Technique] ParameterBag : service dédié à la récupération des paramètres système" | "[Technique] ParameterBag : service dédié à la récupération des paramètres système" | ||||
] | ] | ||||
], | ], | ||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Administration] Tickets admin : flag pour savoir si un ticket a été lu par le producteur" | "[Administration] Tickets admin : flag pour savoir si un ticket a été lu par le producteur" | ||||
] | ] | ||||
], | ], | ||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
"[Technique] Mise en place Twig" | "[Technique] Mise en place Twig" | ||||
] | ] | ||||
], | ], | ||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
[], | [], | ||||
[] | [] | ||||
], | ], | ||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
[], | [], | ||||
[] | [] | ||||
], | ], | ||||
$userCurrent | |||||
); | ); | ||||
?> | ?> |
<?php | <?php | ||||
use common\logic\User\User\Model\User; | |||||
use common\logic\User\User\Wrapper\UserModule; | use common\logic\User\User\Wrapper\UserModule; | ||||
function version(string $date, array $featuresMaintenanceArray, array $featuresMaintenanceAdminArray = []) { | |||||
function version(string $date, array $featuresMaintenanceArray, array $featuresMaintenanceAdminArray = [], User $userCurrent) { | |||||
release_date($date); | release_date($date); | ||||
features($featuresMaintenanceArray[0] ?? [], $featuresMaintenanceAdminArray[0] ?? []); | |||||
maintenance($featuresMaintenanceArray[1] ?? [], $featuresMaintenanceAdminArray[1] ?? []); | |||||
features($featuresMaintenanceArray[0] ?? [], $featuresMaintenanceAdminArray[0] ?? [], $userCurrent); | |||||
maintenance($featuresMaintenanceArray[1] ?? [], $featuresMaintenanceAdminArray[1] ?? [], $userCurrent); | |||||
} | } | ||||
function release_date(string $date) { | function release_date(string $date) { | ||||
echo $html; | echo $html; | ||||
} | } | ||||
function features(array $featuresArray, array $featuresAdminArray) { | |||||
function features(array $featuresArray, array $featuresAdminArray, User $userCurrent) { | |||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
if(count($featuresArray) > 0 || count($featuresAdminArray) > 0) { | if(count($featuresArray) > 0 || count($featuresAdminArray) > 0) { | ||||
$html = '<div class="block block-features">'; | $html = '<div class="block block-features">'; | ||||
foreach($featuresArray as $feature) { | foreach($featuresArray as $feature) { | ||||
$html .= '<li>'.$feature.'</li>'; | $html .= '<li>'.$feature.'</li>'; | ||||
} | } | ||||
if($userModule->isCurrentAdmin()) { | |||||
if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)) { | |||||
foreach($featuresAdminArray as $feature) { | foreach($featuresAdminArray as $feature) { | ||||
$html .= '<li class="admin">'.$feature.'</li>'; | $html .= '<li class="admin">'.$feature.'</li>'; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
function maintenance(array $maintenanceArray, array $maintenanceAdminArray) { | |||||
function maintenance(array $maintenanceArray, array $maintenanceAdminArray, User $userCurrent) { | |||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
if(count($maintenanceArray) > 0 || count($maintenanceAdminArray) > 0) { | if(count($maintenanceArray) > 0 || count($maintenanceAdminArray) > 0) { | ||||
$html = '<div class="block block-maintenance">'; | $html = '<div class="block block-maintenance">'; | ||||
foreach($maintenanceArray as $maintenance) { | foreach($maintenanceArray as $maintenance) { | ||||
$html .= '<li>'.$maintenance.'</li>'; | $html .= '<li>'.$maintenance.'</li>'; | ||||
} | } | ||||
if($userModule->isCurrentAdmin()) { | |||||
if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)) { | |||||
foreach ($maintenanceAdminArray as $maintenance) { | foreach ($maintenanceAdminArray as $maintenance) { | ||||
$html .= '<li class="admin">' . $maintenance . '</li>'; | $html .= '<li class="admin">' . $maintenance . '</li>'; | ||||
} | } |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
$userCurrent = GlobalParam::getCurrentUser(); | |||||
$isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent); | |||||
$producer = null; | $producer = null; | ||||
if ($userModule->isCurrentProducer()) { | |||||
if ($isUserCurrentGrantedAsProducer) { | |||||
$producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]); | $producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]); | ||||
} | } | ||||
$itemAdministration = [ | $itemAdministration = [ | ||||
'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>', | 'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>', | ||||
'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']), | 'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']), | ||||
'visible' => $userModule->isCurrentProducer(), | |||||
'visible' => $isUserCurrentGrantedAsProducer, | |||||
'linkOptions' => ['class' => 'btn btn-default navbar-btn'] | 'linkOptions' => ['class' => 'btn btn-default navbar-btn'] | ||||
]; | ]; | ||||
$itemProducerSpace = [ | $itemProducerSpace = [ | ||||
'label' => '<span class="glyphicon glyphicon-eye-open"></span> <span class="link-text">Mon espace producteur</span>', | 'label' => '<span class="glyphicon glyphicon-eye-open"></span> <span class="link-text">Mon espace producteur</span>', | ||||
'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']), | 'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']), | ||||
'visible' => $userModule->isCurrentProducer(), | |||||
'visible' => $isUserCurrentGrantedAsProducer, | |||||
'linkOptions' => ['class' => 'btn btn-default navbar-btn'] | 'linkOptions' => ['class' => 'btn btn-default navbar-btn'] | ||||
]; | ]; | ||||
$itemProducers = [ | $itemProducers = [ |
* termes. | * termes. | ||||
*/ | */ | ||||
use common\helpers\GlobalParam; | |||||
use common\logic\User\User\Wrapper\UserModule; | use common\logic\User\User\Wrapper\UserModule; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\bootstrap\Nav; | use yii\bootstrap\Nav; | ||||
\frontend\assets\AppAsset::register($this); | \frontend\assets\AppAsset::register($this); | ||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
$userCurrent = GlobalParam::getCurrentUser(); | |||||
$isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent); | |||||
$isHome = (Yii::$app->controller->id == 'site' && \Yii::$app->controller->action->id == 'index'); | $isHome = (Yii::$app->controller->id == 'site' && \Yii::$app->controller->action->id == 'index'); | ||||
$producer = null; | $producer = null; | ||||
if ($userModule->isCurrentProducer()) { | |||||
if ($isUserCurrentGrantedAsProducer) { | |||||
$producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]); | $producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]); | ||||
} | } | ||||
*/ | */ | ||||
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use common\logic\Producer\Producer\Model\Producer; | |||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | use common\logic\Producer\Producer\Wrapper\ProducerManager; | ||||
use common\logic\User\User\Wrapper\UserModule; | use common\logic\User\User\Wrapper\UserModule; | ||||
use common\logic\User\UserProducer\Model\UserProducer; | use common\logic\User\UserProducer\Model\UserProducer; | ||||
$userCurrent = GlobalParam::getCurrentUser(); | $userCurrent = GlobalParam::getCurrentUser(); | ||||
$producerManager = ProducerManager::getInstance(); | $producerManager = ProducerManager::getInstance(); | ||||
$producerUser = null; | $producerUser = null; | ||||
if($userModule->isCurrentProducer()) { | |||||
if($userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent)) { | |||||
$producerUser = $producerManager->findOneProducerById($userCurrent->id_producer); | $producerUser = $producerManager->findOneProducerById($userCurrent->id_producer); | ||||
} | } | ||||
$producer = $this->context->getProducerCurrent(); | $producer = $this->context->getProducerCurrent(); |