No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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 yii\bootstrap\Nav;
  38. use yii\bootstrap\NavBar;
  39. use yii\widgets\Breadcrumbs;
  40. use common\widgets\Alert;
  41. use common\helpers\Url;
  42. use common\models\Producer;
  43. use common\models\User;
  44. use common\helpers\GlobalParam;
  45. \common\assets\CommonAsset::register($this);
  46. \producer\assets\AppAsset::register($this);
  47. $producer = $this->context->getProducer();
  48. if (!Yii::$app->user->isGuest) {
  49. $userProducer = UserProducer::findOne(['id_user' => User::getCurrentId(), 'id_producer' => $producer->id]);
  50. }
  51. ?>
  52. <?php $this->beginPage() ?>
  53. <!DOCTYPE html>
  54. <html lang="fr-FR">
  55. <head>
  56. <title><?= Html::encode($producer->name); ?> | <?= $this->getPageTitle(); ?></title>
  57. <meta charset="utf-8">
  58. <meta name="viewport" content="width=device-width, initial-scale=1">
  59. <meta name="base-url" content="<?= Yii::$app->urlManager->baseUrl; ?>">
  60. <meta name="slug-producer" content="<?= $producer->slug; ?>">
  61. <?= Html::csrfMetaTags() ?>
  62. <link rel="icon" type="image/png"
  63. href="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/favicon-distrib.png"/>
  64. <?php $this->head() ?>
  65. </head>
  66. <body class="<?= Yii::$app->controller->id . '-' . Yii::$app->controller->action->id ?>">
  67. <?php $this->beginBody() ?>
  68. <div id="header-bap">
  69. <?php
  70. echo Nav::widget([
  71. 'encodeLabels' => false,
  72. 'items' => [
  73. [
  74. 'label' => '<span class="glyphicon glyphicon-menu-hamburger"></span>',
  75. 'options' => ['id' => 'label1'],
  76. 'url' => '#',
  77. 'items' => [
  78. [
  79. 'label' => '<span class="glyphicon glyphicon-chevron-left"></span> Retour à l\'accueil',
  80. 'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index']),
  81. 'visible' => Yii::$app->user->isGuest
  82. ],
  83. [
  84. 'label' => '<span class="glyphicon glyphicon-user"></span> Inscription',
  85. 'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/signup']),
  86. 'visible' => Yii::$app->user->isGuest
  87. ],
  88. [
  89. 'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion',
  90. 'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/login', 'return_url' => Yii::$app->urlManager->createAbsoluteUrl(['site/index'])]),
  91. 'visible' => Yii::$app->user->isGuest
  92. ],
  93. ],
  94. 'visible' => Yii::$app->user->isGuest
  95. ],
  96. [
  97. 'label' => '<span class="glyphicon glyphicon-menu-hamburger"></span>',
  98. 'options' => ['id' => 'label1'],
  99. 'url' => '#',
  100. 'items' => [
  101. [
  102. 'label' => '<span class="glyphicon glyphicon-chevron-left"></span> Retour à l\'accueil',
  103. 'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index']),
  104. ],
  105. [
  106. 'label' => '<span class="glyphicon glyphicon-user"></span> Profil',
  107. 'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['user/update']),
  108. ],
  109. [
  110. 'label' => '<span class="glyphicon glyphicon-off"></span> Déconnexion<br /><small>' . (!Yii::$app->user->isGuest ? Html::encode(Yii::$app->user->identity->name . ' ' . strtoupper(substr(Yii::$app->user->identity->lastname, 0, 1))) : '') . '.</small>',
  111. 'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/logout']),
  112. ]
  113. ],
  114. 'visible' => !Yii::$app->user->isGuest
  115. ],
  116. ],
  117. 'options' => ['id' => 'nav-bap'],
  118. ]);
  119. ?>
  120. </div>
  121. <div class="container">
  122. <div id="left" class="col-md-3">
  123. <div class="fixed">
  124. <?php if (strlen($producer->logo)): ?>
  125. <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; ?>>
  126. <a href="<?= Yii::$app->urlManager->createUrl(['site/index']) ?>">
  127. <img class="img-logo"
  128. src="<?= Yii::$app->urlManager->baseUrl; ?>/uploads/<?= $producer->logo; ?>"
  129. alt="Logo <?= Html::encode($producer->name) ?>"/>
  130. </a>
  131. </div>
  132. <?php endif; ?>
  133. <h1><?= Html::encode($producer->name); ?></h1>
  134. <h2><?= Html::encode($producer->type) ?> à <?= Html::encode($producer->city); ?>
  135. (<?= Html::encode($producer->postcode); ?>)</h2>
  136. <nav id="main-nav">
  137. <?php
  138. $credit = '';
  139. if (isset($userProducer) && $userProducer) {
  140. $labelType = $userProducer->credit > 0 ? 'success' : 'danger';
  141. $credit = ' <span class="label label-' . $labelType . '">' . number_format($userProducer->credit, 2) . ' €</span>';
  142. }
  143. $countSubcriptions = Subscription::find()
  144. ->where([
  145. 'subscription.id_user' => User::getCurrentId(),
  146. 'subscription.id_producer' => GlobalParam::getCurrentProducerId(),
  147. ])->count();
  148. $labelSubscription = $countSubcriptions > 0 ? 'success' : 'default';
  149. $countOrders = Order::find()
  150. ->joinWith(['distribution'])
  151. ->where([
  152. 'id_user' => User::getCurrentId(),
  153. 'distribution.id_producer' => GlobalParam::getCurrentProducerId()
  154. ])
  155. ->params([':date_today' => date('Y-m-d')])
  156. ->andWhere('distribution.date >= :date_today')
  157. ->count();
  158. $labelOrders = $countOrders > 0 ? 'success' : 'default';
  159. echo Nav::widget([
  160. 'encodeLabels' => false,
  161. 'options' => ['class' => 'nav'],
  162. 'items' => [
  163. [
  164. 'label' => '<span class="glyphicon glyphicon-th-large"></span> Accueil',
  165. 'url' => Yii::$app->urlManager->createUrl(['site/index']),
  166. 'active' => $this->getControllerAction() == 'site/index',
  167. ],
  168. [
  169. 'label' => '<span class="glyphicon glyphicon-plus"></span> Commander',
  170. 'url' => Yii::$app->urlManager->createUrl(['order/order']),
  171. 'visible' => $producer->option_allow_order_guest || !Yii::$app->user->isGuest,
  172. 'active' => $this->getControllerAction() == 'order/order',
  173. ],
  174. [
  175. 'label' => '<span class="glyphicon glyphicon-plus"></span> Commander',
  176. 'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducer()->id, 'return_url' => Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducer()->slug])]),
  177. 'visible' => !$producer->option_allow_order_guest && Yii::$app->user->isGuest,
  178. 'active' => $this->getControllerAction() == 'order/order',
  179. ],
  180. [
  181. 'label' => '<span class="glyphicon glyphicon-folder-open"></span> Mes commandes <span class="label label-' . $labelOrders . '">' . $countOrders . '</span>',
  182. 'url' => Yii::$app->urlManager->createUrl(['order/history']),
  183. 'visible' => !Yii::$app->user->isGuest,
  184. 'active' => $this->getControllerAction() == 'order/history',
  185. ],
  186. [
  187. 'label' => '<span class="glyphicon glyphicon-repeat"></span> Abonnements <span class="label label-' . $labelSubscription . '">' . $countSubcriptions . '</span>',
  188. 'url' => Yii::$app->urlManager->createUrl(['subscription/index']),
  189. 'visible' => !Yii::$app->user->isGuest && $producer->user_manage_subscription,
  190. 'active' => $this->getControllerAction() == 'subscription/index',
  191. ],
  192. [
  193. 'label' => '<span class="glyphicon glyphicon-euro"></span> Crédit' . $credit,
  194. 'url' => Yii::$app->urlManager->createUrl(['credit/history']),
  195. 'visible' => !Yii::$app->user->isGuest && $producer->credit,
  196. 'active' => $this->getControllerAction() == 'credit/history',
  197. ],
  198. /*[
  199. 'label' => '<span class="glyphicon glyphicon-envelope"></span> Contact',
  200. 'url' => Yii::$app->urlManager->createUrl(['site/contact']),
  201. 'active' => $this->getControllerAction() == 'site/contact',
  202. ],*/
  203. [
  204. 'label' => '<span class="glyphicon glyphicon-cog"></span> Administration',
  205. 'url' => Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']),
  206. 'visible' => isset(Yii::$app->user->identity) && Yii::$app->user->identity->isProducer(),
  207. 'options' => ['id' => 'btn-administration']
  208. ],
  209. ],
  210. ]);
  211. ?>
  212. </nav>
  213. </div>
  214. </div>
  215. <div id="main" class="col-md-9">
  216. <?php if (strlen($producer->photo)): ?>
  217. <div id="img-big">
  218. <img class="img-photo" src="<?= Yii::$app->urlManager->baseUrl; ?>/uploads/<?= $producer->photo; ?>"
  219. alt="Photo <?= Html::encode($producer->name) ?>"/>
  220. </div>
  221. <?php endif; ?>
  222. <div id="infos-producer">
  223. <?php if(!$producer->hasSpecificDelays() && $producer->order_deadline && $producer->order_delay): ?>
  224. <span data-toggle="tooltip" data-placement="bottom" title="Heure limite de commande">
  225. <span class="glyphicon glyphicon-time"></span> Commande avant
  226. <strong><?php echo Html::encode($producer->order_deadline) ?> h</strong></span>,
  227. <span data-toggle="tooltip" data-placement="bottom"
  228. title="Exemple : commande le lundi pour le
  229. <?php if ($producer->order_delay == 1): ?>mardi<?php elseif ($producer->order_delay == 2): ?>mercredi
  230. <?php elseif ($producer->order_delay == 3): ?>jeudi<?php elseif ($producer->order_delay == 4): ?>vendredi
  231. <?php elseif ($producer->order_delay == 5): ?>samedi<?php elseif ($producer->order_delay == 6): ?>dimanche
  232. <?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>
  233. <?php endif; ?>
  234. <?php if (!Yii::$app->user->isGuest): ?>
  235. <span class="favorite">
  236. <?php if ($userProducer && $userProducer->bookmark): ?>
  237. <span class="glyphicon glyphicon-star"></span> <a
  238. href="<?= Yii::$app->urlManagerProducer->createUrl(['site/bookmarks', 'action' => 'delete']); ?>"
  239. data-toggle="tooltip" data-placement="bottom" title="Supprimer de mes favoris">Favoris</a>
  240. <?php else: ?>
  241. <span class="glyphicon glyphicon glyphicon-star-empty"></span> <a
  242. href="<?= Yii::$app->urlManagerProducer->createUrl(['site/bookmarks', 'action' => 'add']); ?>"
  243. data-toggle="tooltip" data-placement="bottom"
  244. title="Ajouter à mes favoris">Favoris</a>
  245. <?php endif; ?>
  246. </span>
  247. <?php endif; ?>
  248. <div class="clr"></div>
  249. </div>
  250. <?php if (strlen($this->getTitle())): ?>
  251. <h2 id="page-title">
  252. <?= $this->getTitle(); ?>
  253. <?php
  254. if (count($this->buttons)): ?>
  255. <span id="buttons">
  256. <?php foreach ($this->buttons as $button) {
  257. echo '<a href="' . Yii::$app->urlManagerProducer->createUrl($button['url']) . '" class="' . $button['class'] . '">' . $button['label'] . '</a>';
  258. }
  259. ?>
  260. </span>
  261. <?php endif; ?>
  262. </h2>
  263. <?php endif; ?>
  264. <section id="content">
  265. <?php if (Yii::$app->session->hasFlash('error')): ?>
  266. <div class="alert alert-danger" role="alert">
  267. <?= Yii::$app->session->getFlash('error') ?>
  268. </div>
  269. <?php endif; ?>
  270. <?php if (Yii::$app->session->hasFlash('success')): ?>
  271. <div class="alert alert-success" role="alert">
  272. <?= Yii::$app->session->getFlash('success') ?>
  273. </div>
  274. <?php endif; ?>
  275. <?= $content ?>
  276. </section>
  277. <?php if (strlen($producer->mentions) || strlen($producer->gcs)): ?>
  278. <section id="footer-producer">
  279. <?= Html::encode($producer->name) ?> :
  280. <?php if (strlen($producer->mentions)): ?>
  281. <a href="<?php echo Yii::$app->urlManager->createUrl(['site/mentions']); ?>">Mentions
  282. légales</a>
  283. <?php endif; ?>
  284. <?php if (strlen($producer->mentions) && strlen($producer->gcs)): ?>
  285. &bull;
  286. <?php endif; ?>
  287. <?php if (strlen($producer->gcs)): ?>
  288. <a href="<?php echo Yii::$app->urlManager->createUrl(['site/gcs']); ?>">Conditions générales
  289. de vente</a>
  290. <?php endif; ?>
  291. </section>
  292. <?php endif; ?>
  293. </div>
  294. </div>
  295. <footer id="footer" class="container">
  296. <div class="content">
  297. <a href="<?php echo Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index']); ?>">distrib</a> &bull;
  298. <a href="<?php echo Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/mentions']); ?>">Mentions
  299. légales</a> &bull;
  300. <a href="<?php echo Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/cgv']); ?>">CGS</a> &bull;
  301. <a id="code-source" href="https://framagit.org/guillaume-bourgeois/distrib">Code source <img
  302. src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-framagit.png"
  303. alt="Hébergé par Framasoft"/> <img
  304. src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-gitlab.png"
  305. alt="Propulsé par Gitlab"/></a> &bull;
  306. <a id="social-mastodon" href="https://mastodon.social/@opendistrib">Mastodon <img
  307. src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-mastodon.png" alt="Mastodon"/></a>
  308. &bull;
  309. <a id="social-diaspora" href="https://framasphere.org/people/db12d640c64c0137f1d52a0000053625">Diaspora <img
  310. src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-diaspora.png" alt="Diaspora"/></a>
  311. </div>
  312. </footer>
  313. <script type="text/javascript" src="https://cdn.polyfill.io/v3/polyfill.min.js?features=Intl.~locale.fr"></script>
  314. <?php $this->endBody() ?>
  315. <?= $this->render('@common/views/_analytics.php'); ?>
  316. </body>
  317. </html>
  318. <?php $this->endPage() ?>