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.

413 lines
21KB

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