Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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