namespace backend\controllers; | namespace backend\controllers; | ||||
use backend\models\MailForm; | |||||
use common\helpers\GlobalParam; | |||||
use common\logic\PointSale\PointSale\Model\PointSale; | |||||
use kartik\mpdf\Pdf; | use kartik\mpdf\Pdf; | ||||
use yii\filters\AccessControl; | use yii\filters\AccessControl; | ||||
use yii\filters\VerbFilter; | use yii\filters\VerbFilter; | ||||
]; | ]; | ||||
} | } | ||||
/** | |||||
* Affiche la page d'accueil de la section avec un aperçu du mode d'emploi | |||||
* à imprimer. | |||||
*/ | |||||
public function actionIndex() | |||||
public function actionEmail( | |||||
$idPointSale = 0, | |||||
$sectionSubscribers = 0, | |||||
$sectionInactiveUsers = 0, | |||||
$usersPointSaleLink = 0, | |||||
$usersPointSaleHasOrder = 0, | |||||
$idDistribution = 0) | |||||
{ | |||||
$producerCurrent = $this->getProducerCurrent(); | |||||
$userModule = $this->getUserModule(); | |||||
$distributionModule = $this->getDistributionModule(); | |||||
$mailForm = new MailForm(); | |||||
if ($idPointSale && !$usersPointSaleLink && !$usersPointSaleHasOrder) { | |||||
$usersPointSaleLink = 1; | |||||
} | |||||
if ($idDistribution && !$usersPointSaleLink && !$usersPointSaleHasOrder) { | |||||
$usersPointSaleLink = 1; | |||||
} | |||||
if($idDistribution) { | |||||
$users = []; | |||||
$distribution = $distributionModule->getRepository()->findOneDistributionById($idDistribution); | |||||
if($distribution) { | |||||
$mailForm->id_distribution = $idDistribution; | |||||
foreach($distribution->pointSaleDistribution as $pointSaleDistribution) { | |||||
if($pointSaleDistribution->delivery) { | |||||
$usersPointSaleArray = $userModule->getRepository()->queryUsersBy([ | |||||
'id_producer' => $producerCurrent->id, | |||||
'id_point_sale' => $pointSaleDistribution->id_point_sale, | |||||
'users_point_sale_link' => $usersPointSaleLink, | |||||
'users_point_sale_has_order' => $usersPointSaleHasOrder, | |||||
'newsletter' => true | |||||
])->all(); | |||||
foreach($usersPointSaleArray as $user) { | |||||
$users[$user['id']] = $user; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
else { | |||||
$users = $userModule->queryUsersBy([ | |||||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||||
'id_point_sale' => $idPointSale, | |||||
'users_point_sale_link' => $usersPointSaleLink, | |||||
'users_point_sale_has_order' => $usersPointSaleHasOrder, | |||||
'subscribers' => $sectionSubscribers, | |||||
'inactive' => $sectionInactiveUsers, | |||||
'newsletter' => true | |||||
])->all(); | |||||
} | |||||
$usersArray = []; | |||||
foreach ($users as $key => $user) { | |||||
if (isset($user['email']) && strlen($user['email']) > 0) { | |||||
$usersArray[] = $user['email']; | |||||
} else { | |||||
unset($users[$key]); | |||||
} | |||||
} | |||||
$pointsSaleArray = PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId(), 'status' => 1])->all(); | |||||
$pointSale = null; | |||||
if ($idPointSale) { | |||||
$pointSale = PointSale::findOne(['id' => $idPointSale]); | |||||
} | |||||
if ($mailForm->load(\Yii::$app->request->post()) && $mailForm->validate()) { | |||||
$responseSendMail = $mailForm->sendEmail($users); | |||||
if ($responseSendMail->success()) { | |||||
$this->setFlash('success', 'Votre email a bien été envoyé.'); | |||||
} else { | |||||
$bodyResponseSendMail = $responseSendMail->getBody(); | |||||
$emailsErrorArray = []; | |||||
if (isset($bodyResponseSendMail['Messages'])) { | |||||
foreach ($bodyResponseSendMail['Messages'] as $message) { | |||||
if ($message['Status'] != 'success') { | |||||
$emailsErrorArray[] = $message['Errors'][0]['ErrorMessage']; | |||||
} | |||||
} | |||||
} | |||||
$messageError = 'Un problème est survenu lors de l\'envoi de votre email.'; | |||||
if (count($emailsErrorArray) > 0) { | |||||
$messageError .= '<br />Problème détecté : ' . implode(',', $emailsErrorArray); | |||||
} | |||||
$this->setFlash('error', $messageError); | |||||
} | |||||
return $this->redirect(['mail', 'idPointSale' => $idPointSale]); | |||||
} | |||||
$incomingDistributionsArray = $distributionModule->findDistributionsIncoming(); | |||||
$incomingDistributionsDatesArray = ['0' => '--']; | |||||
foreach ($incomingDistributionsArray as $distribution) { | |||||
$incomingDistributionsDatesArray[$distribution->id] = strftime('%A %d %B %Y', strtotime($distribution->date)); | |||||
} | |||||
return $this->render('email', [ | |||||
'usersArray' => $usersArray, | |||||
'pointsSaleArray' => $pointsSaleArray, | |||||
'pointSale' => $pointSale, | |||||
'mailForm' => $mailForm, | |||||
'idPointSaleActive' => $idPointSale, | |||||
'idDistributionActive' => $idDistribution, | |||||
'incomingDistributionsArray' => $incomingDistributionsArray, | |||||
'incomingDistributionsDatesArray' => $incomingDistributionsDatesArray, | |||||
'sectionSubscribers' => $sectionSubscribers, | |||||
'sectionInactiveUsers' => $sectionInactiveUsers, | |||||
'usersPointSaleLink' => $usersPointSaleLink, | |||||
'usersPointSaleHasOrder' => $usersPointSaleHasOrder, | |||||
]); | |||||
} | |||||
public function actionPaper() | |||||
{ | { | ||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
$pointsSaleArray = $this->getPointSaleModule()->findPointSales(); | |||||
return $this->render('index', [ | |||||
return $this->render('paper', [ | |||||
'producer' => $producer, | 'producer' => $producer, | ||||
'pointsSaleArray' => $pointsSaleArray, | |||||
]); | ]); | ||||
} | } | ||||
// return the pdf output as per the destination setting | // return the pdf output as per the destination setting | ||||
return $pdf->render(); | return $pdf->render(); | ||||
} | } | ||||
} | } |
} | } | ||||
} | } | ||||
/** | |||||
* Affiche la liste des emails des utilisateurs liés à un point de vente donné. | |||||
*/ | |||||
public function actionMail( | |||||
$idPointSale = 0, | |||||
$sectionSubscribers = 0, | |||||
$sectionInactiveUsers = 0, | |||||
$usersPointSaleLink = 0, | |||||
$usersPointSaleHasOrder = 0) | |||||
{ | |||||
$userModule = $this->getUserModule(); | |||||
$distributionModule = $this->getDistributionModule(); | |||||
if ($idPointSale && !$usersPointSaleLink && !$usersPointSaleHasOrder) { | |||||
$usersPointSaleLink = 1; | |||||
} | |||||
$users = $userModule->queryUsersBy([ | |||||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||||
'id_point_sale' => $idPointSale, | |||||
'users_point_sale_link' => $usersPointSaleLink, | |||||
'users_point_sale_has_order' => $usersPointSaleHasOrder, | |||||
'subscribers' => $sectionSubscribers, | |||||
'inactive' => $sectionInactiveUsers, | |||||
'newsletter' => true | |||||
])->all(); | |||||
$usersArray = []; | |||||
foreach ($users as $key => $user) { | |||||
if (isset($user['email']) && strlen($user['email']) > 0) { | |||||
$usersArray[] = $user['email']; | |||||
} else { | |||||
unset($users[$key]); | |||||
} | |||||
} | |||||
$pointsSaleArray = PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId(), 'status' => 1])->all(); | |||||
$pointSale = null; | |||||
if ($idPointSale) { | |||||
$pointSale = PointSale::findOne(['id' => $idPointSale]); | |||||
} | |||||
$mailForm = new MailForm(); | |||||
if ($mailForm->load(\Yii::$app->request->post()) && $mailForm->validate()) { | |||||
$responseSendMail = $mailForm->sendEmail($users); | |||||
if ($responseSendMail->success()) { | |||||
$this->setFlash('success', 'Votre email a bien été envoyé.'); | |||||
} else { | |||||
$bodyResponseSendMail = $responseSendMail->getBody(); | |||||
$emailsErrorArray = []; | |||||
if (isset($bodyResponseSendMail['Messages'])) { | |||||
foreach ($bodyResponseSendMail['Messages'] as $message) { | |||||
if ($message['Status'] != 'success') { | |||||
$emailsErrorArray[] = $message['Errors'][0]['ErrorMessage']; | |||||
} | |||||
} | |||||
} | |||||
$messageError = 'Un problème est survenu lors de l\'envoi de votre email.'; | |||||
if (count($emailsErrorArray) > 0) { | |||||
$messageError .= '<br />Problème détecté : ' . implode(',', $emailsErrorArray); | |||||
} | |||||
$this->setFlash('error', $messageError); | |||||
} | |||||
return $this->redirect(['mail', 'idPointSale' => $idPointSale]); | |||||
} | |||||
$incomingDistributions = $distributionModule->findDistributionsIncoming(); | |||||
$incomingDistributionsArray = ['0' => '--']; | |||||
foreach ($incomingDistributions as $distribution) { | |||||
$incomingDistributionsArray[$distribution->id] = strftime('%A %d %B %Y', strtotime($distribution->date)); | |||||
} | |||||
return $this->render('emails', [ | |||||
'usersArray' => $usersArray, | |||||
'pointsSaleArray' => $pointsSaleArray, | |||||
'pointSale' => $pointSale, | |||||
'mailForm' => $mailForm, | |||||
'idPointSaleActive' => $idPointSale, | |||||
'incomingDistributionsArray' => $incomingDistributionsArray, | |||||
'sectionSubscribers' => $sectionSubscribers, | |||||
'sectionInactiveUsers' => $sectionInactiveUsers, | |||||
'usersPointSaleLink' => $usersPointSaleLink, | |||||
'usersPointSaleHasOrder' => $usersPointSaleHasOrder, | |||||
]); | |||||
} | |||||
public function actionSwitchIdentity(int $id) | public function actionSwitchIdentity(int $id) | ||||
{ | { | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); |
<?= | <?= | ||||
$this->render('_menu',[ | |||||
$this->render('@backend/views/user/_menu.php',[ | |||||
'section' => 'email', | |||||
'idPointSaleActive' => $idPointSaleActive, | 'idPointSaleActive' => $idPointSaleActive, | ||||
'sectionInactiveUsers' => isset($sectionInactiveUsers) ? $sectionInactiveUsers : null, | 'sectionInactiveUsers' => isset($sectionInactiveUsers) ? $sectionInactiveUsers : null, | ||||
'sectionSubscribers' => isset($sectionSubscribers) ? $sectionSubscribers: null, | 'sectionSubscribers' => isset($sectionSubscribers) ? $sectionSubscribers: null, | ||||
'pointsSaleArray' => $pointsSaleArray, | 'pointsSaleArray' => $pointsSaleArray, | ||||
'section' => 'mail' | |||||
'idDistributionActive' => $idDistributionActive, | |||||
'incomingDistributionsArray' => $incomingDistributionsArray, | |||||
'incomingDistributionsDatesArray' => $incomingDistributionsDatesArray, | |||||
]) ; | ]) ; | ||||
?> | ?> | ||||
<div class="col-md-6"> | <div class="col-md-6"> | ||||
<div class="panel panel-default"> | <div class="panel panel-default"> | ||||
<div class="panel-heading"> | <div class="panel-heading"> | ||||
<h3 class="panel-title">Envoyer un message</h3> | |||||
<h3 class="panel-title">Envoyer un email</h3> | |||||
</div> | </div> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<?php $form = ActiveForm::begin(); ?> | <?php $form = ActiveForm::begin(); ?> | ||||
<?= $form->field($mailForm, 'id_distribution')->dropDownList($incomingDistributionsArray) | |||||
<?= $form->field($mailForm, 'id_distribution')->dropDownList($incomingDistributionsDatesArray) | |||||
->hint("Sélectionnez une distribution pour ajouter automatiquement au message un lien vers la prise de commande de cette distribution"); ?> | ->hint("Sélectionnez une distribution pour ajouter automatiquement au message un lien vers la prise de commande de cette distribution"); ?> | ||||
<?= $form->field($mailForm, 'integrate_product_list')->checkbox() ; ?> | <?= $form->field($mailForm, 'integrate_product_list')->checkbox() ; ?> | ||||
<?= $form->field($mailForm, 'subject')->textInput() ; ?> | <?= $form->field($mailForm, 'subject')->textInput() ; ?> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<?php if($idPointSaleActive): ?> | <?php if($idPointSaleActive): ?> | ||||
<a class="btn btn-xs <?php if($usersPointSaleLink): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/mail','idPointSale' => $idPointSaleActive, 'usersPointSaleLink' => 1]); ?>">Liés au point de vente</a> | |||||
<a class="btn btn-xs <?php if($usersPointSaleHasOrder): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/mail','idPointSale' => $idPointSaleActive, 'usersPointSaleHasOrder' => 1]); ?>">Déjà commandés dans ce point de vente</a> | |||||
<a class="btn btn-xs <?php if($usersPointSaleLink): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['communicate/email','idPointSale' => $idPointSaleActive, 'idDistribution' => $idDistributionActive, 'usersPointSaleLink' => 1]); ?>">Liés au point de vente</a> | |||||
<a class="btn btn-xs <?php if($usersPointSaleHasOrder): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['communicate/email','idPointSale' => $idPointSaleActive, 'idDistribution' => $idDistributionActive, 'usersPointSaleHasOrder' => 1]); ?>">Déjà commandés dans ce point de vente</a> | |||||
<br /><br /> | <br /><br /> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?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 yii\helpers\Html ; | |||||
$this->setTitle('Communiquer') ; | |||||
$this->addBreadcrumb('Communiquer') ; | |||||
?> | |||||
<div class="col-md-6"> | |||||
<div id="email" class="panel panel-default" v-if="date"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Envoyer un email</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<p>Choisissez à quels utilisateurs vous souhaitez envoyer un email :</p> | |||||
<div> | |||||
<?= Html::a('<span class="glyphicon glyphicon-th-list"></span> Tous',['user/mail', 'idPointSale' => 0], ['class' => 'btn btn-default btn-point-sale']); ?> | |||||
<?= Html::a('<span class="glyphicon glyphicon-repeat"></span> Abonnés',['user/mail', 'sectionSubscribers' => 1], ['class' => 'btn btn-default btn-point-sale']); ?> | |||||
<?= Html::a('<span class="glyphicon glyphicon-time"></span> Inactifs',['user/mail', 'sectionInactiveUsers' => 1], ['class' => 'btn btn-default btn-point-sale']); ?> | |||||
<?php foreach($pointsSaleArray as $pointSale): ?> | |||||
<?= Html::a('<span class="glyphicon glyphicon-map-marker"></span> '.Html::encode($pointSale->name), ['user/mail', 'idPointSale' => $pointSale->id], ['class' => 'btn btn-default btn-point-sale']); ?> | |||||
<?php endforeach; ?> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-md-6"> | |||||
<div id="paper" class="panel panel-default" v-if="date"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Communiquer par papier</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<p>Imprimez ce petit encart pour indiquer à vos clients l'adresse internet leur permettant de passer leurs commandes.</p> | |||||
<?php echo $this->render('instructions', ['producer' => $producer]) ; ?> | |||||
<p><?php echo Html::a('<span class="glyphicon glyphicon-download-alt"></span> Télécharger', ['communicate/instructions'], ['class'=>'btn btn-primary']) ?></p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<?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 yii\helpers\Html ; | |||||
$this->setTitle('Communiquer par papier') ; | |||||
$this->addBreadcrumb('Communiquer') ; | |||||
?> | |||||
<div id="paper" class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Encart à imprimer</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<p>Imprimez cet encart pour indiquer à vos clients l'adresse internet leur permettant de passer leurs commandes.</p> | |||||
<?php echo $this->render('instructions', ['producer' => $producer]) ; ?> | |||||
<p><?php echo Html::a('<span class="glyphicon glyphicon-download-alt"></span> Télécharger', ['communicate/instructions'], ['class'=>'btn btn-primary']) ?></p> | |||||
</div> | |||||
</div> | |||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
$newVersionOpendistribLabel = ''; | $newVersionOpendistribLabel = ''; | ||||
if ($producer && !$producerModule->isUpToDateWithOpendistribVersion($producer)) { | if ($producer && !$producerModule->isUpToDateWithOpendistribVersion($producer)) { | ||||
$newVersionOpendistribLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.GlobalParam::getOpendistribVersion().'</small></span>'; | |||||
$newVersionOpendistribLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">' . GlobalParam::getOpendistribVersion() . '</small></span>'; | |||||
} | } | ||||
$countTicketsProducerUnreadLabel = ''; | $countTicketsProducerUnreadLabel = ''; | ||||
$countTicketsProducerUnread = $ticketModule->countTicketsUnreadByUser($this->getUserCurrent()); | $countTicketsProducerUnread = $ticketModule->countTicketsUnreadByUser($this->getUserCurrent()); | ||||
if($countTicketsProducerUnread && !$isUserCurrentGrantedAsAdministrator) { | |||||
$countTicketsProducerUnreadLabel = '<small class="label pull-right bg-blue">'.$countTicketsProducerUnread.'</small>'; | |||||
if ($countTicketsProducerUnread && !$isUserCurrentGrantedAsAdministrator) { | |||||
$countTicketsProducerUnreadLabel = '<small class="label pull-right bg-blue">' . $countTicketsProducerUnread . '</small>'; | |||||
} | } | ||||
$developerOnlineLabel = ''; | $developerOnlineLabel = ''; | ||||
if($adminSettingBag->get('supportOnline')) { | |||||
if ($adminSettingBag->get('supportOnline')) { | |||||
$developerOnlineLabel = '<small class="label pull-right bg-green"><i class="fa fa-phone"></i></small>'; | $developerOnlineLabel = '<small class="label pull-right bg-green"><i class="fa fa-phone"></i></small>'; | ||||
} | } | ||||
$countTicketsLabel = ''; | $countTicketsLabel = ''; | ||||
$countTicketsAdminUnread = $ticketModule->getRepository()->countTicketsAdminUnreadByUser($this->getUserCurrent()); | $countTicketsAdminUnread = $ticketModule->getRepository()->countTicketsAdminUnreadByUser($this->getUserCurrent()); | ||||
if($countTicketsAdminUnread && $isUserCurrentGrantedAsAdministrator) { | |||||
$countTicketsLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsAdminUnread.'</small></span>'; | |||||
} | |||||
else { | |||||
if ($countTicketsAdminUnread && $isUserCurrentGrantedAsAdministrator) { | |||||
$countTicketsLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">' . $countTicketsAdminUnread . '</small></span>'; | |||||
} else { | |||||
$countTicketsAdminOpen = $ticketModule->getRepository()->countTicketsAdminStatusOpen(); | $countTicketsAdminOpen = $ticketModule->getRepository()->countTicketsAdminStatusOpen(); | ||||
$countTicketsLabel = '<span class="pull-right-container"><small class="label pull-right bg-blue">'.$countTicketsAdminOpen.'</small></span>'; | |||||
$countTicketsLabel = '<span class="pull-right-container"><small class="label pull-right bg-blue">' . $countTicketsAdminOpen . '</small></span>'; | |||||
} | } | ||||
$sumUserProducerCredits = $userProducerModule->sumUserProducerCredits(); | $sumUserProducerCredits = $userProducerModule->sumUserProducerCredits(); | ||||
$countUsersWithStatusProducerOnline = $userModule->getRepository()->countUsersStatusProducerOnline(); | $countUsersWithStatusProducerOnline = $userModule->getRepository()->countUsersStatusProducerOnline(); | ||||
$countUsersWithStatusProducerOnlineLabel = ''; | $countUsersWithStatusProducerOnlineLabel = ''; | ||||
if($countUsersWithStatusProducerOnline) { | |||||
$countUsersWithStatusProducerOnlineLabel = '<small class="label pull-right bg-red">'.$countUsersWithStatusProducerOnline.'</small>'; | |||||
if ($countUsersWithStatusProducerOnline) { | |||||
$countUsersWithStatusProducerOnlineLabel = '<small class="label pull-right bg-red">' . $countUsersWithStatusProducerOnline . '</small>'; | |||||
} | } | ||||
$countUsersWithStatusUserOnline = $userModule->getRepository()->countUsersStatusUserOnline(); | $countUsersWithStatusUserOnline = $userModule->getRepository()->countUsersStatusUserOnline(); | ||||
$countUsersWithStatusUserOnlineLabel = ''; | $countUsersWithStatusUserOnlineLabel = ''; | ||||
if($countUsersWithStatusUserOnline) { | |||||
$countUsersWithStatusUserOnlineLabel = '<small class="label pull-right bg-blue">'.$countUsersWithStatusUserOnline.'</small>'; | |||||
if ($countUsersWithStatusUserOnline) { | |||||
$countUsersWithStatusUserOnlineLabel = '<small class="label pull-right bg-blue">' . $countUsersWithStatusUserOnline . '</small>'; | |||||
} | } | ||||
$countUsersOnlineLabel = ''; | $countUsersOnlineLabel = ''; | ||||
if($countUsersWithStatusProducerOnline || $countUsersWithStatusUserOnline) { | |||||
if ($countUsersWithStatusProducerOnline || $countUsersWithStatusUserOnline) { | |||||
$countUsersOnlineLabel = '<span class="pull-right-container">'; | $countUsersOnlineLabel = '<span class="pull-right-container">'; | ||||
if($countUsersWithStatusUserOnline) { | |||||
if ($countUsersWithStatusUserOnline) { | |||||
$countUsersOnlineLabel .= $countUsersWithStatusUserOnlineLabel; | $countUsersOnlineLabel .= $countUsersWithStatusUserOnlineLabel; | ||||
} | } | ||||
if($countUsersWithStatusProducerOnline) { | |||||
if ($countUsersWithStatusProducerOnline) { | |||||
$countUsersOnlineLabel .= $countUsersWithStatusProducerOnlineLabel; | $countUsersOnlineLabel .= $countUsersWithStatusProducerOnlineLabel; | ||||
} | } | ||||
$countUsersOnlineLabel .= '</span>'; | $countUsersOnlineLabel .= '</span>'; | ||||
], | ], | ||||
], | ], | ||||
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'subscription'], | ['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' => 'Communiquer', | |||||
'icon' => 'bullhorn', | |||||
'url' => ['/communicate/email'], | |||||
'visible' => $isUserCurrentGrantedAsProducer, | |||||
'items' => [ | |||||
['label' => 'Email', 'icon' => 'paper-plane', 'url' => ['/communicate/email'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
['label' => 'Papier', 'icon' => 'print', 'url' => ['/communicate/paper'], 'visible' => $isUserCurrentGrantedAsProducer], | |||||
] | |||||
], | |||||
[ | [ | ||||
'label' => 'Documents', | 'label' => 'Documents', | ||||
'icon' => 'clone', | 'icon' => 'clone', | ||||
'url' => ['/stats-admin/matomo'], | 'url' => ['/stats-admin/matomo'], | ||||
'visible' => $isUserCurrentGrantedAsAdministrator, | 'visible' => $isUserCurrentGrantedAsAdministrator, | ||||
'items' => [ | 'items' => [ | ||||
['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' => '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' => 'Paramètres', 'icon' => 'cog', 'url' => ['/setting-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator && $featureChecker->isEnabled(Feature::ALIAS_SETTINGS)], | ['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/setting-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator && $featureChecker->isEnabled(Feature::ALIAS_SETTINGS)], |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
if($section == 'email') { | |||||
$route = 'communicate/email'; | |||||
} | |||||
else { | |||||
$route = 'user/index'; | |||||
} | |||||
?> | ?> | ||||
<div id="menu-users"> | |||||
<div id="nav-points-sale"> | |||||
<a class="btn <?php if(!$idPointSaleActive && !$sectionInactiveUsers && !$sectionSubscribers): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/'.$section]); ?>"> | |||||
<span class="glyphicon glyphicon-th-list"></span> Tous <span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
</a> | |||||
<?php if(isset($sectionSubscribers) && !is_null($sectionSubscribers)): ?> | |||||
<a class="btn <?php if($sectionSubscribers): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/'.$section,'sectionSubscribers' => 1]); ?>"> | |||||
<span class="glyphicon glyphicon-repeat"></span> | |||||
Abonnés | |||||
<span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
</a> | |||||
<?php endif; ?> | |||||
<?php if(isset($sectionInactiveUsers) && !is_null($sectionInactiveUsers)): ?> | |||||
<a class="btn <?php if($sectionInactiveUsers): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/'.$section,'sectionInactiveUsers' => 1]); ?>"> | |||||
<span class="glyphicon glyphicon-time"></span> | |||||
Inactifs | |||||
<span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
</a> | |||||
<?php endif; ?> | |||||
<?php foreach($pointsSaleArray as $pointSale): ?> | |||||
<a class="btn <?php if($idPointSaleActive == $pointSale->id): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/'.$section,'idPointSale' => $pointSale->id]); ?>"> | |||||
<span class="glyphicon glyphicon-map-marker"></span> | |||||
<?= Html::encode($pointSale->name) ?> | |||||
<span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
</a> | |||||
<?php endforeach; ?> | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Filtre</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<div id="menu-users"> | |||||
<div id="nav-points-sale"> | |||||
<h4>Général</h4> | |||||
<div> | |||||
<a class="btn btn-xs <?php if(!$idPointSaleActive && !$idDistributionActive && !$sectionInactiveUsers && !$sectionSubscribers): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl([$route]); ?>"> | |||||
<span class="glyphicon glyphicon-th-list"></span> Tous | |||||
</a> | |||||
<?php if(isset($sectionSubscribers) && !is_null($sectionSubscribers)): ?> | |||||
<a class="btn btn-xs <?php if($sectionSubscribers): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl([$route,'sectionSubscribers' => 1]); ?>"> | |||||
<span class="glyphicon glyphicon-repeat"></span> | |||||
Abonnés | |||||
</a> | |||||
<?php endif; ?> | |||||
<?php if(isset($sectionInactiveUsers) && !is_null($sectionInactiveUsers)): ?> | |||||
<a class="btn btn-xs <?php if($sectionInactiveUsers): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl([$route,'sectionInactiveUsers' => 1]); ?>"> | |||||
<span class="glyphicon glyphicon-time"></span> | |||||
Inactifs | |||||
</a> | |||||
<?php endif; ?> | |||||
</div> | |||||
<?php if(count($pointsSaleArray) > 0): ?> | |||||
<h4>Points de vente</h4> | |||||
<div> | |||||
<?php foreach($pointsSaleArray as $pointSale): ?> | |||||
<a class="btn btn-xs <?php if($idPointSaleActive == $pointSale->id): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl([$route,'idPointSale' => $pointSale->id]); ?>"> | |||||
<span class="glyphicon glyphicon-map-marker"></span> | |||||
<?= Html::encode($pointSale->name) ?> | |||||
</a> | |||||
<?php endforeach; ?> | |||||
</div> | |||||
<?php endif; ?> | |||||
<?php if($section == 'email' && count($incomingDistributionsArray) > 0): ?> | |||||
<h4>Distributions</h4> | |||||
<div> | |||||
<?php foreach($incomingDistributionsArray as $distribution): ?> | |||||
<a class="btn btn-xs <?php if($idDistributionActive == $distribution->id): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl([$route,'idDistribution' => $distribution->id]); ?>"> | |||||
<span class="glyphicon glyphicon-calendar"></span> | |||||
<?= Html::encode($incomingDistributionsDatesArray[$distribution->id]) ?> | |||||
</a> | |||||
<?php endforeach; ?> | |||||
</div> | |||||
<?php endif; ?> | |||||
</div> | |||||
</div> | |||||
</div> | </div> | ||||
</div> | |||||
</div> |
$this->render('_menu', [ | $this->render('_menu', [ | ||||
'idPointSaleActive' => $idPointSaleActive, | 'idPointSaleActive' => $idPointSaleActive, | ||||
'idDistributionActive' => 0, | |||||
'sectionInactiveUsers' => $sectionInactiveUsers, | 'sectionInactiveUsers' => $sectionInactiveUsers, | ||||
'sectionSubscribers' => $sectionSubscribers, | 'sectionSubscribers' => $sectionSubscribers, | ||||
'pointsSaleArray' => $pointsSaleArray, | 'pointsSaleArray' => $pointsSaleArray, |