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.

преди 6 години
преди 4 години
преди 4 години
преди 4 години
преди 6 години
преди 1 година
преди 6 години
преди 4 години
преди 6 години
преди 8 месеца
преди 8 месеца
преди 6 години
преди 6 години
преди 4 години
преди 4 години
преди 4 години
преди 8 месеца
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 8 месеца
преди 4 години
преди 4 години
преди 4 години
преди 6 години
преди 8 месеца
преди 6 години
преди 6 години
преди 4 години
преди 4 години
преди 4 години
преди 6 години
преди 8 месеца
преди 6 години
преди 4 години
преди 6 години
преди 8 месеца
преди 4 години
преди 4 години
преди 8 месеца
преди 8 месеца
преди 8 месеца
преди 4 години
преди 8 месеца
преди 8 месеца
преди 6 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <?php
  2. /**
  3. * Copyright Souke (2018)
  4. *
  5. * contact@souke.fr
  6. *
  7. * Ce logiciel est un programme informatique servant à aider les producteurs
  8. * à distribuer leur production en circuits courts.
  9. *
  10. * Ce logiciel est régi par la licence CeCILL soumise au droit français et
  11. * respectant les principes de diffusion des logiciels libres. Vous pouvez
  12. * utiliser, modifier et/ou redistribuer ce programme sous les conditions
  13. * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
  14. * sur le site "http://www.cecill.info".
  15. *
  16. * En contrepartie de l'accessibilité au code source et des droits de copie,
  17. * de modification et de redistribution accordés par cette licence, il n'est
  18. * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
  19. * seule une responsabilité restreinte pèse sur l'auteur du programme, le
  20. * titulaire des droits patrimoniaux et les concédants successifs.
  21. *
  22. * A cet égard l'attention de l'utilisateur est attirée sur les risques
  23. * associés au chargement, à l'utilisation, à la modification et/ou au
  24. * développement et à la reproduction du logiciel par l'utilisateur étant
  25. * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
  26. * manipuler et qui le réserve donc à des développeurs et des professionnels
  27. * avertis possédant des connaissances informatiques approfondies. Les
  28. * utilisateurs sont donc invités à charger et tester l'adéquation du
  29. * logiciel à leurs besoins dans des conditions permettant d'assurer la
  30. * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
  31. * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
  32. *
  33. * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
  34. * pris connaissance de la licence CeCILL, et que vous en avez accepté les
  35. * termes.
  36. */
  37. use common\helpers\GlobalParam;
  38. use common\helpers\Image;
  39. use common\helpers\Price;
  40. use domain\Distribution\Distribution\Distribution;
  41. use domain\Producer\Producer\Producer;
  42. use domain\Producer\Producer\ProducerModule;
  43. use domain\User\User\UserModule;
  44. use common\helpers\Environment;
  45. use yii\helpers\Html;
  46. $userModule = UserModule::getInstance();
  47. $producerModule = ProducerModule::getInstance();
  48. $producer = GlobalParam::getCurrentProducer();
  49. $userCurrent = GlobalParam::getCurrentUser();
  50. ?>
  51. <header class="main-header">
  52. <?php $beta = Environment::badgeBeta(); ?>
  53. <?= Html::a('<span class="logo-mini"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-souke.svg" /></span><span class="logo-lg"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-souke.svg" />'.$beta.'</span>'.$beta, Yii::$app->homeUrl, ['class' => 'logo']) ?>
  54. <?php /*Html::a(
  55. 'Opendistrib',
  56. $userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)
  57. ? Yii::$app->urlManager->createUrl('dashboard-admin/index')
  58. : Yii::$app->homeUrl,
  59. ['class' => 'logo']
  60. );*/ ?>
  61. <nav class="navbar navbar-static-top" role="navigation">
  62. <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
  63. <span class="sr-only">Toggle navigation</span>
  64. </a>
  65. <span class="producer-panel<?php if(!$producer->logo || !Image::isPhotoExist($producer->logo)): ?> without-logo<?php endif; ?>">
  66. <?php if($producer->logo && Image::isPhotoExist($producer->logo)): ?>
  67. <span class="logo">
  68. <img class="img-logo"
  69. src="<?= Yii::$app->urlManagerProducer->getHostInfo() . '/' . Yii::$app->urlManagerProducer->baseUrl; ?>/uploads/<?= $producer->logo; ?>"
  70. alt="Logo <?= Html::encode($producer->name) ?>" />
  71. </span>
  72. <?php endif; ?>
  73. <div class="title">
  74. <?php if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?>
  75. <a href="<?= Yii::$app->urlManager->createUrl(['producer-admin/update', 'id' => $producer->id]) ?>">
  76. <?php endif; ?>
  77. <?= Html::encode($producer->name) ?>
  78. <?php if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?>
  79. </a>
  80. <?php endif; ?>
  81. <?php if ($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?>
  82. <span class="producer-id">#<?= $producer->id ?></span>
  83. <?php endif; ?>
  84. <?php if (!$producer->active): ?>
  85. <span class="label label-danger">Hors-ligne</span>
  86. <?php endif; ?>
  87. </div>
  88. </span>
  89. <div class="navbar-custom-menu">
  90. <?php
  91. $usersArray = $userModule->queryUsersBy(['id_producer' => GlobalParam::getCurrentProducerId()])
  92. ->andWhere('CAST(FROM_UNIXTIME(user.created_at) AS date) > \'' . date("Y-m-d", strtotime("-7 days")) . '\'')
  93. ->orderBy('created_at DESC')
  94. ->all();
  95. ?>
  96. <ul class="nav navbar-nav">
  97. <?php if ($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?>
  98. <li class="dropdown producer-menu">
  99. <a href="#" class="dropdown-toggle" data-toggle="dropdown">
  100. <i class="bi bi-bookmarks"></i>
  101. <span class="hidden-xs hidden-sm">Producteurs</span>
  102. <i class="fa fa-caret-down"></i>
  103. </a>
  104. <ul class="dropdown-menu">
  105. <li>
  106. <input type="text" class="search-producer form-control" placeholder="Rechercher" />
  107. </li>
  108. <li class="li-alert-no-results">
  109. <div class="alert alert-warning">Aucun producteur trouvé</div>
  110. </li>
  111. <?php $producersArray = Producer::find()->orderBy('name ASC')->all(); ?>
  112. <?php foreach ($producersArray as $producer): ?>
  113. <?php if ($producer->active == 1 && $producer->is_new): ?>
  114. <li class="producer">
  115. <a href="<?= Yii::$app->urlManagerBackend->createUrl(['site/switch-producer', 'id' => $producer->id]); ?>">
  116. <label class="label label-info">Nouveau</label>
  117. <?= Html::encode($producer->name) ?>
  118. <span class="producer-id">#<?= $producer->id ?></span>
  119. </a>
  120. </li>
  121. <?php endif; ?>
  122. <?php endforeach; ?>
  123. <?php foreach ($producersArray as $producer): ?>
  124. <?php if ($producer->active == 1 && !$producer->is_new): ?>
  125. <li class="producer">
  126. <a href="<?= Yii::$app->urlManagerBackend->createUrl(['site/switch-producer', 'id' => $producer->id]); ?>">
  127. <?php if($producer->is_new): ?> <label class="label label-info">Nouveau</label> <?php endif; ?>
  128. <?= Html::encode($producer->name) ?>
  129. <span class="producer-id">#<?= $producer->id ?></span>
  130. </a>
  131. </li>
  132. <?php endif; ?>
  133. <?php endforeach; ?>
  134. <?php foreach ($producersArray as $producer): ?>
  135. <?php if ($producer->active != 1): ?>
  136. <li class="producer">
  137. <a href="<?= Yii::$app->urlManagerBackend->createUrl(['site/switch-producer', 'id' => $producer->id]); ?>">
  138. <label class="label label-danger">Hors-ligne</label>
  139. <?= Html::encode($producer->name) ?>
  140. <span class="producer-id">#<?= $producer->id ?></span>
  141. </a>
  142. </li>
  143. <?php endif; ?>
  144. <?php endforeach; ?>
  145. </ul>
  146. </li>
  147. <?php endif; ?>
  148. <?php
  149. $pastDistributionsArray = Distribution::find()
  150. ->where(['<', 'distribution.date', date('Y-m-d')])
  151. ->andWhere([
  152. 'distribution.id_producer' => GlobalParam::getCurrentProducerId(),
  153. 'distribution.active' => 1
  154. ])
  155. ->orderBy('date DESC')
  156. ->limit(3)
  157. ->all();
  158. $pastDistributionsArray = array_reverse($pastDistributionsArray);
  159. $incomingDistributionsArray = Distribution::find()
  160. ->where(['>=', 'distribution.date', date('Y-m-d')])
  161. ->andWhere([
  162. 'distribution.id_producer' => GlobalParam::getCurrentProducerId(),
  163. 'distribution.active' => 1
  164. ])
  165. ->orderBy('date ASC')
  166. ->limit(20)
  167. ->all();
  168. ?>
  169. <li class="dropdown distributions-menu notifications-menu">
  170. <a href="#" class="dropdown-toggle" data-toggle="dropdown">
  171. <i class="bi bi-calendar"></i>
  172. <i class="fa fa-caret-down"></i>
  173. </a>
  174. <ul class="dropdown-menu">
  175. <?php if (count($pastDistributionsArray)): ?>
  176. <li class="header">3 dernières distributions :</li>
  177. <li>
  178. <ul class="menu">
  179. <?php foreach ($pastDistributionsArray as $distribution): ?>
  180. <li>
  181. <a href="<?= Yii::$app->urlManagerBackend->createUrl(['distribution/index', 'date' => $distribution->date]); ?>">
  182. <h5><?= strftime('%A %d %B', strtotime($distribution->date)) ?></h5>
  183. </a>
  184. </li>
  185. <?php endforeach; ?>
  186. </ul>
  187. </li>
  188. <?php endif; ?>
  189. <?php if (count($incomingDistributionsArray)): ?>
  190. <li class="header">Prochaines distributions :</li>
  191. <li>
  192. <ul class="menu">
  193. <?php foreach ($incomingDistributionsArray as $distribution): ?>
  194. <li>
  195. <a href="<?= Yii::$app->urlManagerBackend->createUrl(['distribution/index', 'date' => $distribution->date]); ?>">
  196. <h5><?= strftime('%A %d %B', strtotime($distribution->date)) ?></h5>
  197. </a>
  198. </li>
  199. <?php endforeach; ?>
  200. </ul>
  201. </li>
  202. <?php else: ?>
  203. <li class="header">
  204. Aucune distribution prévue.<br/>
  205. <a class="btn btn-default"
  206. href="<?= Yii::$app->urlManagerBackend->createUrl(['distribution/index']); ?>">Gérer
  207. mes distributions</a>
  208. </li>
  209. <?php endif; ?>
  210. </ul>
  211. </li>
  212. <li class="dropdown users-menu notifications-menu">
  213. <a href="#" class="dropdown-toggle" data-toggle="dropdown">
  214. <i class="bi bi-person-plus"></i>
  215. <?php if (count($usersArray)): ?><span
  216. class="label label-success"><?= count($usersArray) ?></span>
  217. <?php else: ?><span class="label label-warning">0</span><?php endif; ?>
  218. <i class="fa fa-caret-down"></i>
  219. </a>
  220. <ul class="dropdown-menu">
  221. <?php if (count($usersArray)): ?>
  222. <li class="header">Inscriptions des 7 derniers jours</li>
  223. <li>
  224. <ul class="menu">
  225. <?php foreach ($usersArray as $user): ?>
  226. <li>
  227. <a href="<?= Yii::$app->urlManagerBackend->createUrl(['user/update', 'id' => $user['user_id']]); ?>">
  228. <h5><?= Html::encode((isset($user['name_legal_person']) && strlen($user['name_legal_person'])) ? $user['name_legal_person'] : $user['name'] . ' ' . $user['lastname']); ?>
  229. <small>
  230. <i class="fa fa-clock-o"></i> <?= date('d/m/Y à H:i', $user['created_at']); ?>
  231. </small>
  232. </h5>
  233. </a>
  234. </li>
  235. <?php endforeach; ?>
  236. </ul>
  237. </li>
  238. <?php else: ?>
  239. <li class="header">Aucun nouvel inscrit ces 7 derniers jours.</li>
  240. <?php endif; ?>
  241. </ul>
  242. </li>
  243. <?php
  244. $usersNegativeCreditArray = $userModule->findUsersWithNegativeCredit();
  245. ?>
  246. <li class="dropdown users-negative-credit-menu notifications-menu">
  247. <a href="#" class="dropdown-toggle" data-toggle="dropdown">
  248. <i class="bi bi-currency-euro"></i>
  249. <?php if (count($usersNegativeCreditArray)): ?><span
  250. class="label label-warning"><?= count($usersNegativeCreditArray) ?></span>
  251. <?php else: ?><span class="label label-success">0</span><?php endif; ?>
  252. <i class="fa fa-caret-down"></i>
  253. </a>
  254. <ul class="dropdown-menu">
  255. <?php if (count($usersNegativeCreditArray)): ?>
  256. <li class="header"><a href="<?= Yii::$app->urlManager->createUrl(['credit/index']); ?>">Utilisateurs avec une cagnotte en négatif</a></li>
  257. <li>
  258. <ul class="menu">
  259. <?php foreach ($usersNegativeCreditArray as $user): ?>
  260. <li>
  261. <a href="<?= Yii::$app->urlManagerBackend->createUrl(['user/credit', 'id' => $user['user_id']]); ?>">
  262. <h5><?= $userModule->getUsernameFromArray($user); ?>
  263. <small>
  264. <i class="fa fa-euro"></i> <?= Price::format($user['credit']); ?>
  265. </small>
  266. </h5>
  267. </a>
  268. </li>
  269. <?php endforeach; ?>
  270. </ul>
  271. </li>
  272. <?php else: ?>
  273. <li class="header">Aucun de vos utilisateurs n'a de cagnotte en négatif.</li>
  274. <?php endif; ?>
  275. </ul>
  276. </li>
  277. <li>
  278. <a href="<?= Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index']); ?>">
  279. <i class="bi bi-house-door"></i>
  280. <span class="hidden-xs hidden-sm">Accueil</span>
  281. </a>
  282. </li>
  283. <?php if ($userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent)): ?>
  284. <li>
  285. <a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => GlobalParam::getCurrentProducer()->slug]); ?>">
  286. <i class="bi bi-shop"></i>
  287. <span class="hidden-xs hidden-sm">Ma boutique</span>
  288. </a>
  289. </li>
  290. <?php endif; ?>
  291. <li class="dropdown user user-menu">
  292. <a href="#" class="dropdown-toggle" data-toggle="dropdown">
  293. <i class="bi bi-person"></i>
  294. <span class="hidden-xs hidden-sm"><?= Html::encode(GlobalParam::getCurrentUser()->name . ' ' . substr(GlobalParam::getCurrentUser()->lastname, 0, 1) .'.'); ?></span>
  295. <i class="fa fa-caret-down"></i>
  296. </a>
  297. <ul class="dropdown-menu">
  298. <!--<li><a href="<?= Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index']); ?>">
  299. <i class="bi bi-house-door"></i> Accueil</a></li>-->
  300. <li><a href="<?= Yii::$app->urlManagerFrontend->createAbsoluteUrl(['user/update']); ?>">
  301. <i class="bi bi-person"></i> Mon profil</a></li>
  302. <li><a href="<?= Yii::$app->urlManagerBackend->createUrl(['site/logout']); ?>">
  303. <i class="bi bi-box-arrow-left"></i> Déconnexion</a></li>
  304. </ul>
  305. </li>
  306. <li class="link-control-sidebar">
  307. <a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
  308. </li>
  309. </ul>
  310. </div>
  311. </nav>
  312. </header>