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

6 роки тому
3 роки тому
2 роки тому
3 роки тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <?php
  2. /**
  3. * Copyright La boîte à pain (2018)
  4. *
  5. * contact@opendistrib.net
  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 yii\bootstrap\Nav;
  38. use common\helpers\GlobalParam;
  39. use common\logic\User\UserProducer\UserProducer;
  40. use yii\helpers\Html;
  41. use common\logic\Order\Order\Order;
  42. \common\assets\CommonAsset::register($this);
  43. \producer\assets\AppAsset::register($this);
  44. $producer = $this->context->getProducer();
  45. if (!Yii::$app->user->isGuest) {
  46. $userProducer = UserProducer::findOne(['id_user' => GlobalParam::getCurrentUserId(), 'id_producer' => $producer->id]);
  47. }
  48. ?>
  49. <?php $this->beginPage() ?>
  50. <!DOCTYPE html>
  51. <html lang="fr-FR">
  52. <head>
  53. <title><?= Html::encode($producer->name); ?> | <?= $this->getPageTitle(); ?></title>
  54. <meta charset="utf-8">
  55. <meta name="viewport" content="width=device-width, initial-scale=1">
  56. <meta name="base-url" content="<?= \Yii::$app->urlManager->baseUrl; ?>">
  57. <meta name="slug-producer" content="<?= $producer->slug; ?>">
  58. <?= Html::csrfMetaTags() ?>
  59. <link rel="icon" type="image/png"
  60. href="<?php echo \Yii::$app->urlManager->getBaseUrl(); ?>/img/favicon-distrib.png"/>
  61. <?php $this->head() ?>
  62. </head>
  63. <body class="<?= \Yii::$app->controller->id . '-' . \Yii::$app->controller->action->id ?>">
  64. <?php $this->beginBody() ?>
  65. <div id="header-bap">
  66. <?php
  67. echo Nav::widget([
  68. 'encodeLabels' => false,
  69. 'items' => [
  70. [
  71. 'label' => '<span class="glyphicon glyphicon-menu-hamburger"></span>',
  72. 'options' => ['id' => 'label1'],
  73. 'url' => '#',
  74. 'items' => [
  75. [
  76. 'label' => '<span class="glyphicon glyphicon-chevron-left"></span> Retour à l\'accueil',
  77. 'url' => \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index']),
  78. 'visible' => \Yii::$app->user->isGuest
  79. ],
  80. [
  81. 'label' => '<span class="glyphicon glyphicon-user"></span> Inscription',
  82. 'url' => \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/signup']),
  83. 'visible' => \Yii::$app->user->isGuest
  84. ],
  85. [
  86. 'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion',
  87. 'url' => \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/login', 'return_url' => \Yii::$app->urlManager->createAbsoluteUrl(['site/index'])]),
  88. 'visible' => \Yii::$app->user->isGuest
  89. ],
  90. ],
  91. 'visible' => \Yii::$app->user->isGuest
  92. ],
  93. [
  94. 'label' => '<span class="glyphicon glyphicon-menu-hamburger"></span>',
  95. 'options' => ['id' => 'label1'],
  96. 'url' => '#',
  97. 'items' => [
  98. [
  99. 'label' => '<span class="glyphicon glyphicon-chevron-left"></span> Retour à l\'accueil',
  100. 'url' => \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index']),
  101. ],
  102. [
  103. 'label' => '<span class="glyphicon glyphicon-user"></span> Profil',
  104. 'url' => \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['user/update']),
  105. ],
  106. [
  107. 'label' => '<span class="glyphicon glyphicon-off"></span> Déconnexion<br /><small>' . (!Yii::$app->user->isGuest ? Html::encode(Yii::$app->user->identity->name . ' ' . strtoupper(substr(Yii::$app->user->identity->lastname, 0, 1))) : '') . '.</small>',
  108. 'url' => \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/logout']),
  109. ]
  110. ],
  111. 'visible' => !Yii::$app->user->isGuest
  112. ],
  113. ],
  114. 'options' => ['id' => 'nav-bap'],
  115. ]);
  116. ?>
  117. </div>
  118. <div class="container">
  119. <div id="left" class="col-md-3">
  120. <div class="fixed">
  121. <?php if (strlen($producer->logo)): ?>
  122. <div id="logo"<?php if (!is_null($producer->background_color_logo) && strlen($producer->background_color_logo)): ?> style="background-color:<?= Html::encode($producer->background_color_logo); ?>"<?php endif; ?>>
  123. <a href="<?= \Yii::$app->urlManager->createUrl(['site/index']) ?>">
  124. <img class="img-logo"
  125. src="<?= \Yii::$app->urlManager->baseUrl; ?>/uploads/<?= $producer->logo; ?>"
  126. alt="Logo <?= Html::encode($producer->name) ?>"/>
  127. </a>
  128. </div>
  129. <?php endif; ?>
  130. <h1><?= Html::encode($producer->name); ?></h1>
  131. <h2><?= Html::encode($producer->type) ?> à <?= Html::encode($producer->city); ?>
  132. (<?= Html::encode($producer->postcode); ?>)</h2>
  133. <nav id="main-nav">
  134. <?php
  135. $credit = '';
  136. if (isset($userProducer) && $userProducer) {
  137. $labelType = $userProducer->credit > 0 ? 'success' : 'danger';
  138. $credit = ' <span class="label label-' . $labelType . '">' . number_format($userProducer->credit, 2) . ' €</span>';
  139. }
  140. $countSubcriptions = $this->getSubscriptionManager()->countSubscriptionsByUser(
  141. GlobalParam::getCurrentUser(),
  142. GlobalParam::getCurrentProducer()
  143. );
  144. $labelSubscription = $countSubcriptions > 0 ? 'success' : 'default';
  145. $countOrders = Order::find()
  146. ->joinWith(['distribution'])
  147. ->where([
  148. 'id_user' => GlobalParam::getCurrentUserId(),
  149. 'distribution.id_producer' => GlobalParam::getCurrentProducerId()
  150. ])
  151. ->params([':date_today' => date('Y-m-d')])
  152. ->andWhere('distribution.date >= :date_today')
  153. ->count();
  154. $labelOrders = $countOrders > 0 ? 'success' : 'default';
  155. echo Nav::widget([
  156. 'encodeLabels' => false,
  157. 'options' => ['class' => 'nav'],
  158. 'items' => [
  159. [
  160. 'label' => '<span class="glyphicon glyphicon-th-large"></span> Accueil',
  161. 'url' => $this->getUrlManagerProducer()->createUrl(['site/index']),
  162. 'active' => $this->getControllerAction() == 'site/index',
  163. ],
  164. [
  165. 'label' => '<span class="glyphicon glyphicon-plus"></span> Commander',
  166. 'url' => $this->getUrlManagerProducer()->createUrl(['order/order']),
  167. 'visible' => $producer->option_allow_order_guest || !Yii::$app->user->isGuest,
  168. 'active' => $this->getControllerAction() == 'order/order',
  169. ],
  170. [
  171. 'label' => '<span class="glyphicon glyphicon-plus"></span> Commander',
  172. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducer()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducer()->slug])]),
  173. 'visible' => !$producer->option_allow_order_guest && \Yii::$app->user->isGuest,
  174. 'active' => $this->getControllerAction() == 'order/order',
  175. ],
  176. [
  177. 'label' => '<span class="glyphicon glyphicon-folder-open"></span> Mes commandes <span class="label label-' . $labelOrders . '">' . $countOrders . '</span>',
  178. 'url' => $this->getUrlManagerProducer()->createUrl(['order/history']),
  179. 'visible' => !Yii::$app->user->isGuest,
  180. 'active' => $this->getControllerAction() == 'order/history',
  181. ],
  182. [
  183. 'label' => '<span class="glyphicon glyphicon-repeat"></span> Abonnements <span class="label label-' . $labelSubscription . '">' . $countSubcriptions . '</span>',
  184. 'url' => $this->getUrlManagerProducer()->createUrl(['subscription/index']),
  185. 'visible' => !Yii::$app->user->isGuest && $producer->user_manage_subscription,
  186. 'active' => $this->getControllerAction() == 'subscription/index',
  187. ],
  188. [
  189. 'label' => '<span class="glyphicon glyphicon-euro"></span> Crédit' . $credit,
  190. 'url' => $this->getUrlManagerProducer()->createUrl(['credit/history']),
  191. 'visible' => !Yii::$app->user->isGuest && $producer->credit,
  192. 'active' => $this->getControllerAction() == 'credit/history',
  193. ],
  194. [
  195. 'label' => '<span class="glyphicon glyphicon-envelope"></span> Contact',
  196. 'url' => $this->getUrlManagerProducer()->createUrl(['site/contact']),
  197. 'active' => $this->getControllerAction() == 'site/contact',
  198. ],
  199. [
  200. 'label' => '<span class="glyphicon glyphicon-cog"></span> Administration',
  201. 'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['site/index']),
  202. 'visible' => isset(Yii::$app->user->identity) && $this->getUserManager()->isProducer(\Yii::$app->user->identity),
  203. 'options' => ['id' => 'btn-administration']
  204. ],
  205. ],
  206. ]);
  207. ?>
  208. </nav>
  209. </div>
  210. </div>
  211. <div id="main" class="col-md-9">
  212. <?php if (strlen($producer->photo)): ?>
  213. <div id="img-big">
  214. <img class="img-photo" src="<?= \Yii::$app->urlManager->baseUrl; ?>/uploads/<?= $producer->photo; ?>"
  215. alt="Photo <?= Html::encode($producer->name) ?>"/>
  216. </div>
  217. <?php endif; ?>
  218. <div id="infos-producer">
  219. <?php if(!$this->getProducerManager()->hasSpecificDelays($producer) && $producer->order_deadline && $producer->order_delay): ?>
  220. <span data-toggle="tooltip" data-placement="bottom" title="Heure limite de commande">
  221. <span class="glyphicon glyphicon-time"></span> Commande avant
  222. <strong><?php echo Html::encode($producer->order_deadline) ?> h</strong></span>,
  223. <span data-toggle="tooltip" data-placement="bottom"
  224. title="Exemple : commande le lundi pour le
  225. <?php if ($producer->order_delay == 1): ?>mardi<?php elseif ($producer->order_delay == 2): ?>mercredi
  226. <?php elseif ($producer->order_delay == 3): ?>jeudi<?php elseif ($producer->order_delay == 4): ?>vendredi
  227. <?php elseif ($producer->order_delay == 5): ?>samedi<?php elseif ($producer->order_delay == 6): ?>dimanche
  228. <?php elseif ($producer->order_delay == 7): ?>lundi d'après<?php endif; ?>"><strong><?= Html::encode($producer->order_delay) ?> jour<?php if ($producer->order_delay > 1): ?>s<?php endif; ?></strong> à l'avance</span>
  229. <?php endif; ?>
  230. <?php if (!Yii::$app->user->isGuest): ?>
  231. <span class="favorite">
  232. <?php if ($userProducer && $userProducer->bookmark): ?>
  233. <span class="glyphicon glyphicon-star"></span> <a
  234. href="<?= \Yii::$app->urlManagerProducer->createUrl(['site/bookmarks', 'action' => 'delete']); ?>"
  235. data-toggle="tooltip" data-placement="bottom" title="Supprimer de mes favoris">Favoris</a>
  236. <?php else: ?>
  237. <span class="glyphicon glyphicon glyphicon-star-empty"></span> <a
  238. href="<?= \Yii::$app->urlManagerProducer->createUrl(['site/bookmarks', 'action' => 'add']); ?>"
  239. data-toggle="tooltip" data-placement="bottom"
  240. title="Ajouter à mes favoris">Favoris</a>
  241. <?php endif; ?>
  242. </span>
  243. <?php endif; ?>
  244. <div class="clr"></div>
  245. </div>
  246. <?php if (strlen($this->getTitle())): ?>
  247. <h2 id="page-title">
  248. <?= $this->getTitle(); ?>
  249. <?php
  250. if ($this->buttons && count($this->buttons)): ?>
  251. <span id="buttons">
  252. <?php foreach ($this->buttons as $button) {
  253. echo '<a href="' . \Yii::$app->urlManagerProducer->createUrl($button['url']) . '" class="' . $button['class'] . '">' . $button['label'] . '</a>';
  254. }
  255. ?>
  256. </span>
  257. <?php endif; ?>
  258. </h2>
  259. <?php endif; ?>
  260. <section id="content">
  261. <?php if (Yii::$app->session->hasFlash('error')): ?>
  262. <div class="alert alert-danger" role="alert">
  263. <?= \Yii::$app->session->getFlash('error') ?>
  264. </div>
  265. <?php endif; ?>
  266. <?php if (Yii::$app->session->hasFlash('success')): ?>
  267. <div class="alert alert-success" role="alert">
  268. <?= \Yii::$app->session->getFlash('success') ?>
  269. </div>
  270. <?php endif; ?>
  271. <?= $content ?>
  272. </section>
  273. <?php if (strlen($producer->mentions) || strlen($producer->gcs)): ?>
  274. <section id="footer-producer">
  275. <?= Html::encode($producer->name) ?> :
  276. <?php if (strlen($producer->mentions)): ?>
  277. <a href="<?php echo \Yii::$app->urlManager->createUrl(['site/mentions']); ?>">Mentions
  278. légales</a>
  279. <?php endif; ?>
  280. <?php if (strlen($producer->mentions) && strlen($producer->gcs)): ?>
  281. &bull;
  282. <?php endif; ?>
  283. <?php if (strlen($producer->gcs)): ?>
  284. <a href="<?php echo \Yii::$app->urlManager->createUrl(['site/gcs']); ?>">Conditions générales
  285. de vente</a>
  286. <?php endif; ?>
  287. </section>
  288. <?php endif; ?>
  289. </div>
  290. </div>
  291. <footer id="footer" class="container">
  292. <div class="content">
  293. <a href="<?php echo \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index']); ?>">distrib</a> &bull;
  294. <a href="<?php echo \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/mentions']); ?>">Mentions
  295. légales</a> &bull;
  296. <a href="<?php echo \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/cgv']); ?>">CGS</a> &bull;
  297. <a id="code-source" href="https://forge.laclic.fr/Laclic/Opendistrib">Code source</a>
  298. </div>
  299. </footer>
  300. <script type="text/javascript" src="https://cdn.polyfill.io/v3/polyfill.min.js?features=Intl.~locale.fr"></script>
  301. <?php $this->endBody() ?>
  302. </body>
  303. </html>
  304. <?php $this->endPage() ?>