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.

368 lines
18KB

  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\helpers\GlobalParam;
  38. use common\helpers\Image;
  39. use domain\Feature\Feature\Feature;
  40. use domain\Feature\Feature\FeatureModule;
  41. use domain\Order\Order\Order;
  42. use domain\PointSale\PointSale\PointSaleModule;
  43. use domain\Producer\Producer\ProducerModule;
  44. use domain\Product\Product\ProductModule;
  45. use domain\User\User\UserModule;
  46. use domain\User\UserProducer\UserProducer;
  47. use yii\bootstrap\Nav;
  48. use yii\helpers\Html;
  49. \common\assets\CommonAsset::register($this);
  50. \producer\assets\AppAsset::register($this);
  51. $userModule = UserModule::getInstance();
  52. $userCurrent = GlobalParam::getCurrentUser();
  53. $producerModule = ProducerModule::getInstance();
  54. $featureModule = FeatureModule::getInstance();
  55. $productModule = ProductModule::getInstance();
  56. $pointSaleModule = PointSaleModule::getInstance();
  57. $producerUser = null;
  58. if ($userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent)) {
  59. $producerUser = $producerModule->findOneProducerById($userCurrent->id_producer);
  60. }
  61. $producer = $this->context->getProducerCurrent();
  62. if (!Yii::$app->user->isGuest) {
  63. $userProducer = UserProducer::findOne(['id_user' => GlobalParam::getCurrentUserId(), 'id_producer' => $producer->id]);
  64. }
  65. $mainColor = $producer->option_main_color ?: '#ee6f42' ;
  66. ?>
  67. <?php $this->beginPage() ?>
  68. <!DOCTYPE html>
  69. <html lang="fr-FR">
  70. <head>
  71. <title><?= Html::encode($producer->name); ?> | <?= $this->getPageTitle(); ?></title>
  72. <meta charset="utf-8">
  73. <meta name="viewport" content="width=device-width, initial-scale=1">
  74. <meta name="base-url" content="<?= \Yii::$app->urlManager->baseUrl; ?>">
  75. <meta name="slug-producer" content="<?= $producer->slug; ?>">
  76. <?= Html::csrfMetaTags() ?>
  77. <link rel="icon" type="image/png"
  78. href="<?php echo \Yii::$app->urlManager->getBaseUrl(); ?>/img/favicon-souke-1.png"/>
  79. <?php $this->head() ?>
  80. <?= $this->render('@common/views/matomo.php') ?>
  81. <style>
  82. #header #title h1,
  83. #header #title h2 .location .bi,
  84. #content a,
  85. .credit-history #credit-user,
  86. .credit-history #content .table span.payment-positive,
  87. .order-order #main #app-order-order #steps ul li .info-step,
  88. .block-date .month {
  89. color: <?= $mainColor ?>
  90. }
  91. #header nav#main-nav ul li.active a,
  92. #header nav#main-nav ul li a:hover,
  93. #header nav#main-nav ul li a span.label-success,
  94. #main .btn-primary,
  95. .order-order #main #app-order-order #steps ul li .btn.btn-primary,
  96. ul.pagination li.active a, ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
  97. background-color: <?= $mainColor ?>;
  98. }
  99. #header nav#main-nav {
  100. border-top: solid 5px <?= $mainColor ?>;
  101. }
  102. #main form .form-control:focus {
  103. box-shadow: 0px 0px 0px 1px <?= $mainColor ?>;
  104. border: solid 1px <?= $mainColor ?>;
  105. }
  106. .order-order #main #app-order-order #steps ul li .btn.btn-primary::after {
  107. border-left: 17px solid <?= $mainColor ?>;
  108. }
  109. #header nav#main-nav ul li a span.label.label-success {
  110. border: solid 1px <?= $mainColor ?>;
  111. }
  112. </style>
  113. </head>
  114. <body class="<?= \Yii::$app->controller->id . '-' . \Yii::$app->controller->action->id ?>">
  115. <?php $this->beginBody() ?>
  116. <?= $this->render('@common/views/nav_user_top', [
  117. 'context' => 'producer'
  118. ]); ?>
  119. <div id="main" class="container">
  120. <div id="header">
  121. <?php if (strlen($producer->photo) || strlen($producer->logo)): ?>
  122. <div id="banner" style="background-color: <?= $mainColor ?>;<?php if(strlen($producer->photo)): ?>background-image:url(<?= \Yii::$app->urlManager->baseUrl; ?>/uploads/<?= $producer->photo; ?>);<?php endif; ?>">
  123. </div>
  124. <?php endif; ?>
  125. <?php if (strlen($producer->logo) && Image::isPhotoExist($producer->logo)): ?>
  126. <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; ?>>
  127. <a href="<?= \Yii::$app->urlManager->createUrl(['site/index']) ?>">
  128. <img class="img-logo"
  129. src="<?= \Yii::$app->urlManager->baseUrl; ?>/uploads/<?= $producer->logo; ?>"
  130. alt="Logo <?= Html::encode($producer->name) ?>"/>
  131. </a>
  132. </div>
  133. <?php endif; ?>
  134. <div id="title">
  135. <h1>
  136. <?= Html::encode($producer->name); ?>
  137. <?php if (!Yii::$app->user->isGuest): ?>
  138. <?php if ($userProducer && $userProducer->bookmark): ?>
  139. <a class="bookmark"
  140. href="<?= \Yii::$app->urlManagerProducer->createUrl(['site/bookmarks', 'action' => 'delete']); ?>"
  141. data-bs-toggle="tooltip" data-bs-placement="top" title="Supprimer de ma liste de producteurs">
  142. <i class="bi bi-bookmark-heart-fill"></i>
  143. </a>
  144. <?php else: ?>
  145. <a class="bookmark"
  146. href="<?= \Yii::$app->urlManagerProducer->createUrl(['site/bookmarks', 'action' => 'add']); ?>"
  147. data-bs-toggle="tooltip" data-bs-placement="top"
  148. title="Ajouter à ma liste de producteurs">
  149. <i class="bi bi-bookmark-heart"></i>
  150. </a>
  151. <?php endif; ?>
  152. <?php endif; ?>
  153. </h1>
  154. <h2>
  155. <?= Html::encode($producer->type) ?>
  156. <span class="location">
  157. <i class="bi bi-geo-alt-fill"></i>
  158. <?= Html::encode($producer->postcode); ?> <?= Html::encode($producer->city); ?>
  159. </span>
  160. </h2>
  161. </div>
  162. <nav id="main-nav">
  163. <?php
  164. $credit = '';
  165. if (isset($userProducer) && $userProducer) {
  166. $labelType = $userProducer->credit > 0 ? 'success' : 'danger';
  167. $credit = ' <span class="label label-' . $labelType . '">' . number_format($userProducer->credit, 2) . ' €</span>';
  168. }
  169. $countSubcriptions = 0;
  170. if ($userCurrent) {
  171. $countSubcriptions = $this->getSubscriptionModule()->countSubscriptionsByUser(
  172. $userCurrent
  173. );
  174. }
  175. $labelSubscription = $countSubcriptions > 0 ? 'success' : 'default';
  176. $countOrders = Order::find()
  177. ->joinWith(['distribution'])
  178. ->where([
  179. 'id_user' => GlobalParam::getCurrentUserId(),
  180. 'distribution.id_producer' => GlobalParam::getCurrentProducerId()
  181. ])
  182. ->params([':date_today' => date('Y-m-d')])
  183. ->andWhere('distribution.date >= :date_today')
  184. ->count();
  185. $labelOrders = $countOrders > 0 ? 'success' : 'default';
  186. $isUserSubscribedNewsletter = $userModule->isUserSubscribedNewsletter($userCurrent);
  187. $isHome = in_array($this->getControllerAction(), ['site/index', 'site/products', 'site/points-sale']);
  188. echo Nav::widget([
  189. 'encodeLabels' => false,
  190. 'options' => ['class' => ''],
  191. 'items' => [
  192. [
  193. 'url' => $this->getUrlManagerProducer()->createUrl(['site/index']),
  194. 'label' => '<i class="bi bi-house-door"></i>',
  195. 'active' => $isHome,
  196. ],
  197. [
  198. 'label' => '<i class="bi bi-pencil-square"></i> Commander',
  199. 'url' => $this->getUrlManagerProducer()->createUrl(['order/order']),
  200. 'visible' => $producer->option_allow_order_guest || !Yii::$app->user->isGuest,
  201. 'active' => in_array($this->getControllerAction(), ['order/order', 'order/confirm']),
  202. ],
  203. [
  204. 'label' => '<i class="bi bi-pencil-square"></i> Commander',
  205. '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])]),
  206. 'visible' => !$producer->option_allow_order_guest && \Yii::$app->user->isGuest,
  207. 'active' => in_array($this->getControllerAction(), ['order/order', 'order/confirm']),
  208. ],
  209. [
  210. 'label' => '<i class="bi bi-folder2-open"></i> Mes commandes <span class="label label-' . $labelOrders . '">' . $countOrders . '</span>',
  211. 'url' => $this->getUrlManagerProducer()->createUrl(['order/history']),
  212. 'visible' => !Yii::$app->user->isGuest,
  213. 'active' => $this->getControllerAction() == 'order/history',
  214. ],
  215. [
  216. 'label' => '<i class="bi bi-arrow-repeat"></i> Abonnements <span class="label label-' . $labelSubscription . '">' . $countSubcriptions . '</span>',
  217. 'url' => $this->getUrlManagerProducer()->createUrl(['subscription/index']),
  218. 'visible' => !Yii::$app->user->isGuest && $producer->user_manage_subscription,
  219. 'active' => in_array($this->getControllerAction(), ['subscription/index', 'subscription/form']),
  220. ],
  221. [
  222. 'label' => '<i class="bi bi-piggy-bank"></i> Cagnotte' . $credit,
  223. 'url' => $this->getUrlManagerProducer()->createUrl(['credit/history']),
  224. 'visible' => !Yii::$app->user->isGuest && $producer->credit,
  225. 'active' => $this->getControllerAction() == 'credit/history',
  226. ],
  227. [
  228. 'label' => '<i class="bi bi-megaphone"></i> Infolettre <span class="label label-' . ($isUserSubscribedNewsletter ? 'success' : 'danger') . '">' . ($isUserSubscribedNewsletter ? 'Oui' : 'Non') . '</span>',
  229. 'url' => $this->getUrlManagerProducer()->createUrl(['newsletter/index']),
  230. 'visible' => !Yii::$app->user->isGuest,
  231. 'active' => $this->getControllerAction() == 'newsletter/index',
  232. ],
  233. [
  234. 'label' => '<i class="bi bi-envelope"></i> Contact',
  235. 'url' => $this->getUrlManagerProducer()->createUrl(['site/contact']),
  236. 'active' => $this->getControllerAction() == 'site/contact',
  237. 'visible' => $featureModule->getChecker()->isEnabled(Feature::ALIAS_CONTACT)
  238. ],
  239. ],
  240. ]);
  241. $submenuItems = null;
  242. if($isHome) {
  243. $submenuItems = [
  244. [
  245. 'url' => $this->getUrlManagerProducer()->createUrl(['site/index']),
  246. 'label' => 'Présentation',
  247. 'active' => $this->getControllerAction() == 'site/index',
  248. ],
  249. [
  250. 'url' => $this->getUrlManagerProducer()->createUrl(['site/products']),
  251. 'label' => 'Produits <span class="label label-default">'.$productModule->getRepository()->countProducts(true).'</span>',
  252. 'active' => $this->getControllerAction() == 'site/products',
  253. ],
  254. [
  255. 'url' => $this->getUrlManagerProducer()->createUrl(['site/points-sale']),
  256. 'label' => 'Points de vente <span class="label label-default">'.$pointSaleModule->getRepository()->countPointSalesPublic().'</span>',
  257. 'active' => $this->getControllerAction() == 'site/points-sale',
  258. ],
  259. ];
  260. }
  261. if($submenuItems) {
  262. echo Nav::widget([
  263. 'encodeLabels' => false,
  264. 'options' => ['class' => 'submenu'],
  265. 'items' => $submenuItems
  266. ]);
  267. }
  268. ?>
  269. </nav>
  270. <div id="infos-producer">
  271. <?php if (!$this->getProducerModule()->hasSpecificDelays($producer) && $producer->order_deadline && $producer->order_delay): ?>
  272. <span data-toggle="tooltip" data-placement="bottom" title="Heure limite de commande">
  273. <span class="glyphicon glyphicon-time"></span> Commande avant
  274. <strong><?php echo Html::encode($producer->order_deadline) ?> h</strong></span>,
  275. <span data-toggle="tooltip" data-placement="bottom"
  276. title="Exemple : commande le lundi pour le
  277. <?php if ($producer->order_delay == 1): ?>mardi<?php elseif ($producer->order_delay == 2): ?>mercredi
  278. <?php elseif ($producer->order_delay == 3): ?>jeudi<?php elseif ($producer->order_delay == 4): ?>vendredi
  279. <?php elseif ($producer->order_delay == 5): ?>samedi<?php elseif ($producer->order_delay == 6): ?>dimanche
  280. <?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>
  281. <?php endif; ?>
  282. <div class="clr"></div>
  283. </div>
  284. </div>
  285. <section id="content">
  286. <?php if (strlen($this->getTitle())): ?>
  287. <h2 id="page-title">
  288. <?= $this->getTitle(); ?>
  289. <?php
  290. if ($this->buttons && count($this->buttons)): ?>
  291. <span id="buttons">
  292. <?php foreach ($this->buttons as $button) {
  293. echo '<a href="' . \Yii::$app->urlManagerProducer->createUrl($button['url']) . '" class="' . $button['class'] . '">' . $button['label'] . '</a>';
  294. }
  295. ?>
  296. </span>
  297. <?php endif; ?>
  298. </h2>
  299. <?php endif; ?>
  300. <?php if (Yii::$app->session->hasFlash('error')): ?>
  301. <div class="alert alert-danger" role="alert">
  302. <?= \Yii::$app->session->getFlash('error') ?>
  303. </div>
  304. <?php endif; ?>
  305. <?php if (Yii::$app->session->hasFlash('success')): ?>
  306. <div class="alert alert-success" role="alert">
  307. <?= \Yii::$app->session->getFlash('success') ?>
  308. </div>
  309. <?php endif; ?>
  310. <?= $content ?>
  311. </section>
  312. <?php if (strlen($producer->mentions) || strlen($producer->gcs)): ?>
  313. <section id="footer-producer">
  314. <?= Html::encode($producer->name) ?> :
  315. <?php if (strlen($producer->mentions)): ?>
  316. <a href="<?php echo \Yii::$app->urlManager->createUrl(['site/mentions']); ?>">Mentions
  317. légales</a>
  318. <?php endif; ?>
  319. <?php if (strlen($producer->mentions) && strlen($producer->gcs)): ?>
  320. &bull;
  321. <?php endif; ?>
  322. <?php if (strlen($producer->gcs)): ?>
  323. <a href="<?php echo \Yii::$app->urlManager->createUrl(['site/gcs']); ?>">Conditions générales
  324. de vente</a>
  325. <?php endif; ?>
  326. </section>
  327. <?php endif; ?>
  328. </div>
  329. <footer id="footer" class="container">
  330. <div class="content">
  331. <a href="<?php echo \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index']); ?>">Opendistrib</a>
  332. &bull;
  333. <a href="<?php echo \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/mentions']); ?>">Mentions
  334. légales</a> &bull;
  335. <a href="<?php echo \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/cgv']); ?>">CGS</a>
  336. </div>
  337. </footer>
  338. <script type="text/javascript" src="https://cdn.polyfill.io/v3/polyfill.min.js?features=Intl.~locale.fr"></script>
  339. <?php $this->endBody() ?>
  340. </body>
  341. </html>
  342. <?php $this->endPage() ?>