You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 9 месеци
пре 10 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 8 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 8 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 8 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 8 месеци
пре 9 месеци
пре 8 месеци
пре 9 месеци
пре 9 месеци
пре 8 месеци
пре 9 месеци
пре 8 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
пре 9 месеци
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. use common\helpers\GlobalParam;
  3. use domain\Producer\Producer\Producer;
  4. use domain\Producer\Producer\ProducerModule;
  5. use domain\User\User\UserModule;
  6. use common\helpers\Environment;
  7. use yii\bootstrap5\Nav;
  8. use yii\helpers\Html;
  9. $userModule = UserModule::getInstance();
  10. $producerModule = ProducerModule::getInstance();
  11. $userCurrent = GlobalParam::getCurrentUser();
  12. $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent);
  13. $producer = null;
  14. if ($isUserCurrentGrantedAsProducer && $userCurrent->id_producer) {
  15. $producer = $producerModule->getRepository()->findOneProducerById($userCurrent->id_producer);
  16. }
  17. ?>
  18. <div class="container container-nav-user-top">
  19. <?php if($context == 'producer'): ?>
  20. <?= Environment::badgeBeta(); ?>
  21. <?php endif; ?>
  22. <div class="nav-user-top">
  23. <nav class="navbar navbar-expand-lg">
  24. <div class="container-fluid">
  25. <?php
  26. $producersArray = Producer::find()
  27. ->joinWith(['userProducer user_producer'])
  28. ->where([
  29. 'user_producer.id_user' => GlobalParam::getCurrentUserId(),
  30. 'user_producer.bookmark' => 1,
  31. ])
  32. ->all();
  33. $itemsProducersArray = [];
  34. if (count($producersArray)) {
  35. /*$itemsProducersArray[] = [
  36. 'label' => 'Mes favoris',
  37. ];*/
  38. foreach ($producersArray as $producerItem) {
  39. $itemsProducersArray[] = [
  40. 'label' => Html::encode($producerItem->name),
  41. 'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producerItem->slug]),
  42. ];
  43. }
  44. } else {
  45. $itemsProducersArray[] = [
  46. 'label' => 'Aucun producteur dans votre liste.',
  47. ];
  48. }
  49. $itemsProducersArray[] = '<hr class="dropdown-divider">';
  50. $itemsProducersArray[] = [
  51. 'label' => '<i class="bi bi-search"></i> Rechercher un producteur',
  52. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/index'])
  53. ];
  54. // Items du menu
  55. $itemHome = [
  56. 'label' => '<i class="bi bi-house-door"></i> <span class="link-text">Accueil</span>',
  57. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/index']),
  58. 'linkOptions' => ['class' => '']
  59. ];
  60. $itemAdministration = [
  61. 'label' => '<i class="bi bi-gear"></i> <span class="link-text">Administration</span>',
  62. 'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']),
  63. 'visible' => $isUserCurrentGrantedAsProducer,
  64. 'linkOptions' => ['class' => '']
  65. ];
  66. $itemProducerSpace = [
  67. 'label' => '<i class="bi bi-shop"></i> <span class="link-text">Ma boutique</span>',
  68. 'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']),
  69. 'visible' => $isUserCurrentGrantedAsProducer,
  70. 'linkOptions' => ['class' => '']
  71. ];
  72. $itemProducers = [
  73. 'label' => '<i class="bi bi-bookmark-heart"></i> <span class="link-text">Producteurs</span>',
  74. 'url' => '#',
  75. 'items' => $itemsProducersArray,
  76. 'options' => ['class' => 'nav-item-producers'],
  77. 'linkOptions' => ['class' => ''],
  78. 'visible' => !Yii::$app->user->isGuest
  79. ];
  80. $itemsUserArray = [];
  81. if ($context == 'producer') {
  82. $itemsUserArray = [
  83. /*[
  84. 'label' => '<span class="glyphicon glyphicon-home"></span> Retour à l\'accueil',
  85. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/index']),
  86. ]*/
  87. ];
  88. }
  89. $itemsUserArray[] = [
  90. 'label' => '<i class="bi bi-person"></i> Mon profil',
  91. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['user/update']),
  92. ];
  93. $itemsUserArray[] = [
  94. 'label' => '<i class="bi bi-box-arrow-left"></i> Déconnexion',
  95. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/logout']),
  96. ];
  97. $itemUser = [
  98. 'label' => '<i class="bi bi-person"></i> <span class="link-text">' .
  99. ((!Yii::$app->user->isGuest) ? Html::encode(Yii::$app->user->identity->name . ' ' . Yii::$app->user->identity->lastname) : '') .
  100. '</span>',
  101. 'options' => ['id' => 'label1', 'class' => 'nav-item-user'],
  102. 'url' => '#',
  103. 'linkOptions' => ['class' => ''],
  104. 'items' => $itemsUserArray,
  105. 'visible' => !Yii::$app->user->isGuest
  106. ];
  107. $itemConnexion = [
  108. 'label' => '<i class="bi bi-box-arrow-in-right"></i> Connexion',
  109. 'url' => ($context == 'producer')
  110. ? $this->getUrlManagerFrontend()->createAbsoluteUrl([
  111. 'site/producer',
  112. 'id' => $this->context->getProducerCurrent()->id,
  113. 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $this->context->getProducerCurrent()->slug])
  114. ])
  115. : $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/login']),
  116. 'linkOptions' => ['class' => ''],
  117. 'visible' => \Yii::$app->user->isGuest,
  118. 'active' => $this->getControllerAction() == 'site/login'
  119. ];
  120. $itemSignup = [
  121. 'label' => '<i class="bi bi-person-plus"></i> Inscription',
  122. 'url' => ($context == 'producer')
  123. ? $this->getUrlManagerFrontend()->createAbsoluteUrl([
  124. 'site/producer',
  125. 'id' => $this->context->getProducerCurrent()->id,
  126. 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $this->context->getProducerCurrent()->slug])
  127. ])
  128. : $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/signup']),
  129. 'linkOptions' => ['class' => ''],
  130. 'visible' => \Yii::$app->user->isGuest,
  131. 'active' => $this->getControllerAction() == 'site/signup'
  132. ];
  133. if ($context == 'frontend') {
  134. $itemsMenu = [
  135. $itemAdministration,
  136. $itemProducerSpace,
  137. $itemProducers,
  138. $itemUser,
  139. $itemConnexion,
  140. $itemSignup
  141. ];
  142. } elseif ($context == 'producer') {
  143. $itemsMenu = [
  144. $itemHome,
  145. $itemAdministration,
  146. $itemProducers,
  147. $itemUser,
  148. $itemConnexion,
  149. $itemSignup
  150. ];
  151. }
  152. echo Nav::widget([
  153. 'encodeLabels' => false,
  154. 'options' => ['class' => 'nav nav-pills navbar-nav navbar-right'],
  155. 'items' => $itemsMenu
  156. ]);
  157. ?>
  158. </div>
  159. </nav>
  160. </div>
  161. </div>