Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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