Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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