Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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