Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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