Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

375 lines
19KB

  1. <?php
  2. /**
  3. * Copyright La boîte à pain (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 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\bootstrap5\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 a.producer-name,
  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. #footer-producer a {
  90. color: <?= $mainColor ?>
  91. }
  92. #header nav#main-nav ul a.active,
  93. #header nav#main-nav ul li a:hover,
  94. #header nav#main-nav ul li a span.label-success,
  95. #main .btn-primary,
  96. .order-order #main #app-order-order #steps ul li .btn.btn-primary,
  97. ul.pagination li.active a, ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active,
  98. .order-order #main #app-order-order table#products tr.total .price-total span,
  99. .subscription-create .subscription-form .products tr.total .price-total span,
  100. .subscription-update .subscription-form .products tr.total .price-total span {
  101. background-color: <?= $mainColor ?>;
  102. }
  103. #main .badge.bg-primary {
  104. background-color: <?= $mainColor ?> !important;
  105. }
  106. #header nav#main-nav {
  107. border-top: solid 5px <?= $mainColor ?>;
  108. }
  109. #main form .form-control:focus {
  110. box-shadow: 0px 0px 0px 1px <?= $mainColor ?>;
  111. border: solid 1px <?= $mainColor ?>;
  112. }
  113. .order-order #main #app-order-order #steps ul li .btn.btn-primary::after {
  114. border-left: 17px solid <?= $mainColor ?>;
  115. }
  116. #header nav#main-nav ul li a span.label.label-success {
  117. border: solid 1px <?= $mainColor ?>;
  118. }
  119. .order-order #main #app-order-order table#products tr.category-open td.category-name,
  120. .order-order #main #app-order-order table#products tr.category-closed td.category-name:hover{
  121. border-left-color: <?= $mainColor ?>;
  122. }
  123. </style>
  124. </head>
  125. <body class="<?= \Yii::$app->controller->id . '-' . \Yii::$app->controller->action->id ?>">
  126. <?php $this->beginBody() ?>
  127. <?= $this->render('@common/views/nav_user_top', [
  128. 'context' => 'producer'
  129. ]); ?>
  130. <div id="main" class="container">
  131. <?php $hasLogo = strlen($producer->logo) && Image::isPhotoExist($producer->logo); ?>
  132. <div id="header" class="<?= $hasLogo ? 'with-logo' : 'without-logo'; ?>">
  133. <?php if (strlen($producer->photo) || strlen($producer->logo)): ?>
  134. <div id="banner" style="background-color: <?= $mainColor ?>;<?php if(strlen($producer->photo)): ?>background-image:url(<?= \Yii::$app->urlManager->baseUrl; ?>/uploads/<?= urlencode($producer->photo); ?>);<?php endif; ?>">
  135. </div>
  136. <?php endif; ?>
  137. <?php if ($hasLogo): ?>
  138. <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; ?>>
  139. <a href="<?= \Yii::$app->urlManager->createUrl(['site/index']) ?>">
  140. <img class="img-logo"
  141. src="<?= \Yii::$app->urlManager->baseUrl; ?>/uploads/<?= $producer->logo; ?>"
  142. alt="Logo <?= Html::encode($producer->name) ?>"/>
  143. </a>
  144. </div>
  145. <?php endif; ?>
  146. <div id="title">
  147. <h1>
  148. <a class="producer-name" href="<?= Yii::$app->urlManager->createUrl(['site/index']); ?>">
  149. <?= Html::encode($producer->name); ?>
  150. </a>
  151. <?php if (!Yii::$app->user->isGuest): ?>
  152. <?php if ($userProducer && $userProducer->bookmark): ?>
  153. <a class="bookmark"
  154. href="<?= \Yii::$app->urlManagerProducer->createUrl(['site/bookmarks', 'action' => 'delete']); ?>"
  155. data-bs-toggle="tooltip" data-bs-placement="top" title="Supprimer de ma liste de producteurs">
  156. <i class="bi bi-bookmark-heart-fill"></i>
  157. </a>
  158. <?php else: ?>
  159. <a class="bookmark"
  160. href="<?= \Yii::$app->urlManagerProducer->createUrl(['site/bookmarks', 'action' => 'add']); ?>"
  161. data-bs-toggle="tooltip" data-bs-placement="top"
  162. title="Ajouter à ma liste de producteurs">
  163. <i class="bi bi-bookmark-heart"></i>
  164. </a>
  165. <?php endif; ?>
  166. <?php endif; ?>
  167. </h1>
  168. <h2>
  169. <?= Html::encode($producer->type) ?>
  170. <span class="location">
  171. <i class="bi bi-geo-alt-fill"></i>
  172. <?= Html::encode($producer->postcode); ?> <?= Html::encode($producer->city); ?>
  173. </span>
  174. </h2>
  175. </div>
  176. <nav id="main-nav">
  177. <?php
  178. $credit = '';
  179. if (isset($userProducer) && $userProducer) {
  180. $labelType = $userProducer->credit > 0 ? 'success' : 'danger';
  181. $credit = ' <span class="label label-' . $labelType . '">' . number_format($userProducer->credit, 2, ',', ' ') . ' €</span>';
  182. }
  183. $countSubcriptions = 0;
  184. if ($userCurrent) {
  185. $countSubcriptions = $this->getSubscriptionModule()->countSubscriptionsByUser(
  186. $userCurrent
  187. );
  188. }
  189. $labelSubscription = $countSubcriptions > 0 ? 'success' : 'default';
  190. $countOrders = Order::find()
  191. ->joinWith(['distribution'])
  192. ->where([
  193. 'id_user' => GlobalParam::getCurrentUserId(),
  194. 'distribution.id_producer' => GlobalParam::getCurrentProducerId()
  195. ])
  196. ->params([':date_today' => date('Y-m-d')])
  197. ->andWhere('distribution.date >= :date_today')
  198. ->count();
  199. $labelOrders = $countOrders > 0 ? 'success' : 'default';
  200. $isUserSubscribedNewsletter = $userModule->isUserSubscribedNewsletter($userCurrent);
  201. $isHome = in_array($this->getControllerAction(), ['site/index', 'site/products', 'site/points-sale']);
  202. echo Nav::widget([
  203. 'encodeLabels' => false,
  204. 'options' => ['class' => ''],
  205. 'items' => [
  206. [
  207. 'url' => $this->getUrlManagerProducer()->createUrl(['site/index']),
  208. 'label' => '<i class="bi bi-house-door"></i> <span class="hide-desktop"> Accueil</span>',
  209. 'active' => $isHome,
  210. ],
  211. [
  212. 'label' => '<i class="bi bi-pencil-square"></i> Commander',
  213. 'url' => $this->getUrlManagerProducer()->createUrl(['order/order']),
  214. 'visible' => $producer->option_allow_order_guest || !Yii::$app->user->isGuest,
  215. 'active' => in_array($this->getControllerAction(), ['order/order', 'order/confirm']),
  216. ],
  217. [
  218. 'label' => '<i class="bi bi-pencil-square"></i> Commander',
  219. '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])]),
  220. 'visible' => !$producer->option_allow_order_guest && \Yii::$app->user->isGuest,
  221. 'active' => in_array($this->getControllerAction(), ['order/order', 'order/confirm']),
  222. ],
  223. [
  224. 'label' => '<i class="bi bi-folder2-open"></i> Mes commandes <span class="label label-' . $labelOrders . '">' . $countOrders . '</span>',
  225. 'url' => $this->getUrlManagerProducer()->createUrl(['order/history']),
  226. 'visible' => !Yii::$app->user->isGuest,
  227. 'active' => $this->getControllerAction() == 'order/history',
  228. ],
  229. [
  230. 'label' => '<i class="bi bi-arrow-repeat"></i> Abonnements <span class="label label-' . $labelSubscription . '">' . $countSubcriptions . '</span>',
  231. 'url' => $this->getUrlManagerProducer()->createUrl(['subscription/index']),
  232. 'visible' => !Yii::$app->user->isGuest && $producer->user_manage_subscription,
  233. 'active' => in_array($this->getControllerAction(), ['subscription/index', 'subscription/form']),
  234. ],
  235. [
  236. 'label' => '<i class="bi bi-piggy-bank"></i> Cagnotte' . $credit,
  237. 'url' => $this->getUrlManagerProducer()->createUrl(['credit/history']),
  238. 'visible' => !Yii::$app->user->isGuest && $producer->credit,
  239. 'active' => $this->getControllerAction() == 'credit/history',
  240. ],
  241. [
  242. 'label' => '<i class="bi bi-megaphone"></i> Infolettre <span class="label label-' . ($isUserSubscribedNewsletter ? 'success' : 'danger') . '">' . ($isUserSubscribedNewsletter ? 'Oui' : 'Non') . '</span>',
  243. 'url' => $this->getUrlManagerProducer()->createUrl(['newsletter/index']),
  244. 'visible' => !Yii::$app->user->isGuest,
  245. 'active' => $this->getControllerAction() == 'newsletter/index',
  246. ],
  247. [
  248. 'label' => '<i class="bi bi-envelope"></i> Contact',
  249. 'url' => $this->getUrlManagerProducer()->createUrl(['site/contact']),
  250. 'active' => $this->getControllerAction() == 'site/contact',
  251. 'visible' => $featureModule->getChecker()->isEnabled(Feature::ALIAS_CONTACT)
  252. ],
  253. ],
  254. ]);
  255. $submenuItems = null;
  256. if($isHome) {
  257. $submenuItems = [
  258. [
  259. 'url' => $this->getUrlManagerProducer()->createUrl(['site/index']),
  260. 'label' => 'Présentation',
  261. 'active' => $this->getControllerAction() == 'site/index',
  262. ],
  263. [
  264. 'url' => $this->getUrlManagerProducer()->createUrl(['site/products']),
  265. 'label' => 'Produits <span class="label label-default">'.$productModule->getRepository()->countProducts(true).'</span>',
  266. 'active' => $this->getControllerAction() == 'site/products',
  267. ],
  268. [
  269. 'url' => $this->getUrlManagerProducer()->createUrl(['site/points-sale']),
  270. 'label' => 'Points de vente <span class="label label-default">'.$pointSaleModule->getRepository()->countPointSalesPublic().'</span>',
  271. 'active' => $this->getControllerAction() == 'site/points-sale',
  272. ],
  273. ];
  274. }
  275. if($submenuItems) {
  276. echo Nav::widget([
  277. 'encodeLabels' => false,
  278. 'options' => ['class' => 'submenu'],
  279. 'items' => $submenuItems
  280. ]);
  281. }
  282. ?>
  283. </nav>
  284. <div id="infos-producer">
  285. <?php if (!$this->getProducerModule()->hasSpecificDelays($producer) && $producer->order_deadline && $producer->order_delay): ?>
  286. <span data-toggle="tooltip" data-placement="bottom" title="Heure limite de commande">
  287. <span class="glyphicon glyphicon-time"></span> Commande avant
  288. <strong><?php echo Html::encode($producer->order_deadline) ?> h</strong></span>,
  289. <span data-toggle="tooltip" data-placement="bottom"
  290. title="Exemple : commande le lundi pour le
  291. <?php if ($producer->order_delay == 1): ?>mardi<?php elseif ($producer->order_delay == 2): ?>mercredi
  292. <?php elseif ($producer->order_delay == 3): ?>jeudi<?php elseif ($producer->order_delay == 4): ?>vendredi
  293. <?php elseif ($producer->order_delay == 5): ?>samedi<?php elseif ($producer->order_delay == 6): ?>dimanche
  294. <?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>
  295. <?php endif; ?>
  296. <div class="clr"></div>
  297. </div>
  298. </div>
  299. <section id="content">
  300. <?php if (strlen($this->getTitle())): ?>
  301. <h2 id="page-title">
  302. <?= $this->getTitle(); ?>
  303. <?php
  304. if ($this->buttons && count($this->buttons)): ?>
  305. <span id="buttons">
  306. <?php foreach ($this->buttons as $button) {
  307. echo '<a href="' . \Yii::$app->urlManagerProducer->createUrl($button['url']) . '" class="' . $button['class'] . '">' . $button['label'] . '</a>';
  308. }
  309. ?>
  310. </span>
  311. <?php endif; ?>
  312. </h2>
  313. <?php endif; ?>
  314. <?php if (Yii::$app->session->hasFlash('error')): ?>
  315. <div class="alert alert-danger" role="alert">
  316. <?= \Yii::$app->session->getFlash('error') ?>
  317. </div>
  318. <?php endif; ?>
  319. <?php if (Yii::$app->session->hasFlash('success')): ?>
  320. <div class="alert alert-success" role="alert">
  321. <?= \Yii::$app->session->getFlash('success') ?>
  322. </div>
  323. <?php endif; ?>
  324. <?= $content ?>
  325. </section>
  326. </div>
  327. <?php if (strlen($producer->mentions) || strlen($producer->gcs)): ?>
  328. <div id="footer-producer">
  329. <?php if (strlen($producer->mentions)): ?>
  330. <a href="<?php echo \Yii::$app->urlManager->createUrl(['site/mentions']); ?>">Mentions légales</a>
  331. <?php endif; ?>
  332. <?php if (strlen($producer->mentions) && strlen($producer->gcs)): ?> | <?php endif; ?>
  333. <?php if (strlen($producer->gcs)): ?>
  334. <a href="<?php echo \Yii::$app->urlManager->createUrl(['site/gcs']); ?>">Conditions générales de vente</a>
  335. <?php endif; ?>
  336. </div>
  337. <?php endif; ?>
  338. <footer id="footer" class="container">
  339. <div class="content">
  340. <a href="<?php echo \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index']); ?>">Souke</a> &bull;
  341. <a href="<?php echo \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/mentions']); ?>">Mentions légales</a> &bull;
  342. <a href="<?php echo \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/cgv']); ?>">CGS</a>
  343. </div>
  344. </footer>
  345. <script type="text/javascript" src="https://cdn.polyfill.io/v3/polyfill.min.js?features=Intl.~locale.fr"></script>
  346. <?php $this->endBody() ?>
  347. </body>
  348. </html>
  349. <?php $this->endPage() ?>