選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

order.php 49KB

5年前
5年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. <?php
  2. /**
  3. * Copyright Souke (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 domain\Distribution\Distribution\DistributionModule;
  39. use domain\Distribution\PointSaleDistribution\PointSaleDistribution;
  40. use domain\Producer\Producer\Producer;
  41. use domain\Producer\Producer\ProducerModule;
  42. use yii\helpers\Html;
  43. \producer\assets\VuejsOrderOrderAsset::register($this);
  44. $distributionModule =DistributionModule::getInstance();
  45. $producerModule = ProducerModule::getInstance();
  46. $producer = $this->context->getProducerCurrent();
  47. $this->setTitle('Commander');
  48. $this->setMeta('description', $producerModule->getSeoGenerator()->generateMetaDescriptionOrder());
  49. ?>
  50. <script>
  51. var appInitValues = {
  52. urlLogin: '<?= \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducerCurrent()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducerCurrent()->slug])]) ?>',
  53. producerOptionOrderEntryPoint: '<?= $producer->option_order_entry_point ?>',
  54. <?php if (isset($order)): ?>pointSaleActiveId: <?= $order->id_point_sale ?><?php endif; ?>
  55. };
  56. </script>
  57. <div id="app-order-order" :class="{'loaded': !loadingInit}">
  58. <?php if (isset($order)): ?>
  59. <span id="order-distribution-date"><?= $order->distribution->date; ?></span>
  60. <?php endif; ?>
  61. <?php if (isset($date)): ?>
  62. <span id="distribution-date"><?= $date; ?></span>
  63. <?php endif; ?>
  64. <div v-if="loadingInit">
  65. <div class="text-center">
  66. <div class="spinner-border" role="status">
  67. <span class="visually-hidden">Chargement ...</span>
  68. </div>
  69. </div>
  70. </div>
  71. <div class="wrapper">
  72. <div v-if="!loadingInit && !pointSaleActive && distributions.length == 0" class="alert alert-warning">
  73. Aucune distribution à venir chez ce producteur.
  74. </div>
  75. <div v-else>
  76. <div id="steps">
  77. <ul class="row g-0">
  78. <?php if ($producer->option_order_entry_point == Producer::ORDER_ENTRY_POINT_DATE): ?>
  79. <step-date
  80. first="true"
  81. :step="step"
  82. :point-sale-active="pointSaleActive"
  83. :date-format="dateFormat"
  84. :change-step="changeStep"
  85. :producer="producer"
  86. ></step-date>
  87. <step-point-sale
  88. :step="step"
  89. :point-sale-active="pointSaleActive"
  90. :change-step="changeStep"
  91. :producer="producer"
  92. ></step-point-sale>
  93. <?php else: ?>
  94. <step-point-sale
  95. first="true"
  96. :step="step"
  97. :point-sale-active="pointSaleActive"
  98. :change-step="changeStep"
  99. :producer="producer"
  100. ></step-point-sale>
  101. <step-date
  102. :step="step"
  103. :point-sale-active="pointSaleActive"
  104. :date-format="dateFormat"
  105. :change-step="changeStep"
  106. :producer="producer"
  107. ></step-date>
  108. <?php endif; ?>
  109. <li id="step-products" :class="'col-md-4 '+((step == 'products') ? 'active ' : '')">
  110. <button @click="changeStep('products')"
  111. :class="'btn '+ (step == 'products' ? 'btn-primary' : 'btn-secondary')"
  112. :disabled="step == 'date' || step == 'point-sale'">
  113. <span class="button-content"><span
  114. class="glyphicon glyphicon-th-list"></span> Produits</span>
  115. </button>
  116. <div class="info-step" v-if="oneProductOrdered()">
  117. {{ countProductOrdered() }} produit{{ (countProductOrdered() > 1) ? 's' : '' }}
  118. </div>
  119. </li>
  120. </ul>
  121. <div class="clr"></div>
  122. </div>
  123. <div class="content">
  124. <div v-if="order && date" class="alert alert-warning alert-edit-order">
  125. <div class="glyphicon glyphicon-pencil"></div>
  126. Attention, vous êtes en train de modifier votre commande du <strong>{{ dateFormat }}</strong>.
  127. </div>
  128. <div v-if="errors && errors.length" class="alert alert-danger">
  129. <ul>
  130. <li v-for="error in errors">
  131. <div v-html="error"></div>
  132. </li>
  133. </ul>
  134. </div>
  135. <div v-else-if="loading && step != 'payment'">
  136. <div class="text-center">
  137. <div class="spinner-border" role="status">
  138. <span class="visually-hidden">Chargement ...</span>
  139. </div>
  140. </div>
  141. </div>
  142. <transition name="slide">
  143. <div id="content-step-date" v-if="step == 'date'">
  144. <div v-if="!loading && pointSaleActive && distributions.length == 0" class="alert alert-warning">
  145. Aucune distribution à venir sur ce point de vente.
  146. </div>
  147. <div v-else-if="!loading">
  148. <?php if ($producer->behavior_order_select_distribution == Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST): ?>
  149. <div style="display:none ;">
  150. <?php endif; ?>
  151. <div id="legend">
  152. <div><span id="distribution-date-color"></span> Prochains jours de distribution</div>
  153. <div><span id="order-date-color"></span> Vos commandes déjà enregistrées</div>
  154. <div><span id="leave-period-date-color"></span> Congés</div>
  155. </div>
  156. <div id="calendar">
  157. <v-calendar
  158. is-inline
  159. is-expanded
  160. v-model="date"
  161. mode="single"
  162. color="green"
  163. :columns="calendar.columns"
  164. :masks="calendar.masks"
  165. :theme-styles="calendar.themeStyles"
  166. :attributes="calendar.attrs"
  167. :available-dates="calendar.availableDates"
  168. @dayclick='dayClick'
  169. ></v-calendar>
  170. </div>
  171. <?php if ($producer->behavior_order_select_distribution == Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST): ?>
  172. </div>
  173. <?php endif; ?>
  174. <?php if ($producer->behavior_order_select_distribution == Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST): ?>
  175. <div id="distributions-list">
  176. <?php $incomingDistributions = $distributionModule->findDistributionsIncoming(); ?>
  177. <?php foreach ($incomingDistributions as $distribution): ?>
  178. <?php
  179. $pointSaleDistributions = PointSaleDistribution::searchAll([
  180. 'id_distribution' => $distribution->id,
  181. 'delivery' => 1
  182. ], []);
  183. ?>
  184. <div class="card card-default">
  185. <div class="card-body">
  186. <button class="btn btn-primary" @click="dayClickList"
  187. data-distribution-date="<?= $distribution->date . ' 00:00:00' ?>">
  188. Sélectionner cette distribution
  189. </button>
  190. <span class="date"><?= ucfirst(strftime('%A %d %B', strtotime($distribution->date))); ?></span>
  191. <?php
  192. if ($pointSaleDistributions && count($pointSaleDistributions) > 0) {
  193. echo '<div class="point-sales">';
  194. foreach ($pointSaleDistributions as $pointSaleDistribution) {
  195. if ($pointSaleDistribution->pointSale->status == 1) {
  196. echo $pointSaleDistribution->pointSale->name . '';
  197. if (strlen($pointSaleDistribution->pointSale->locality)) {
  198. echo ' (' . $pointSaleDistribution->pointSale->locality . ')';
  199. }
  200. echo '<br />';
  201. }
  202. }
  203. echo '</div>';
  204. }
  205. ?>
  206. </div>
  207. </div>
  208. <?php endforeach; ?>
  209. </div>
  210. <?php endif; ?>
  211. </div>
  212. </div>
  213. </transition>
  214. <transition name="slide">
  215. <div id="content-step-point-sale" v-if="step == 'point-sale'">
  216. <div v-if="!loading">
  217. <h3>Où souhaitez-vous récupérer votre commande ?</h3>
  218. <table id="points-sale" class="table table-striped" v-if="pointsSale.length">
  219. <thead>
  220. <tr>
  221. <th><?= $producerModule->getPointSaleWording($producer); ?></th>
  222. <th class="column-locality">Localité</th>
  223. <th></th>
  224. </tr>
  225. </thead>
  226. <tbody>
  227. <tr v-for="pointSale in orderedPointsSale"
  228. v-if="pointSale && (producer.option_order_entry_point == 'point-sale' || (producer.option_order_entry_point == 'date' && pointSale.pointSaleDistribution.delivery))"
  229. :class="(pointSaleActive && pointSale.id == pointSaleActive.id) ? 'selected' : ''">
  230. <td class="name">
  231. <span class="the-name">{{ pointSale.name }}</span>
  232. <div class="comment" v-if="pointSale.userPointSale">
  233. {{ pointSale.userPointSale.comment }}
  234. </div>
  235. <div class="locality">{{ pointSale.locality }}</div>
  236. <div class="comment" v-if="pointSale.infos && pointSale.infos.length > 0"
  237. v-html="pointSale.infos"></div>
  238. <div class="minimum-order-amount" v-if="pointSale.minimum_order_amount">
  239. Montant minimum de commande : {{ formatPrice(pointSale.minimum_order_amount) }}
  240. </div>
  241. <div class="shared-point-sale-producers" v-if="pointSale.producers_sharing_point_sale_as_string">
  242. Autres producteurs présents : <span v-html="pointSale.producers_sharing_point_sale_as_string"></span>
  243. </div>
  244. </td>
  245. <td class="column-locality">{{ pointSale.locality }}</td>
  246. <td class="actions">
  247. <template
  248. v-if="(order == null || order.id_point_sale != pointSale.id) && pointSale.maximum_number_orders && pointSale.count_orders && pointSale.count_orders >= pointSale.maximum_number_orders">
  249. <span class="label label-default">
  250. <template v-if="pointSale.is_bread_box">
  251. Déjà réservée
  252. </template>
  253. <template v-else>
  254. Maximum de commande atteint
  255. </template>
  256. </span>
  257. </template>
  258. <template v-else>
  259. <div :class="'form-group' + (pointSale.invalid_code ? ' has-error' : '')">
  260. <form>
  261. <div class="input-group"
  262. v-if="pointSale.code && pointSale.code.length > 0">
  263. <span class="input-group-text">
  264. <i class="bi bi-lock"></i>
  265. </span>
  266. <input v-model="pointsSaleCodes[pointSale.id]" type="password"
  267. placeholder="Code" class="form-control input-code" />
  268. </div>
  269. </form>
  270. </div>
  271. <div v-if="!user && producer.credit == 1 && pointSale.payment_method_credit == 1">
  272. <a :href="urlLogin" class="btn btn-secondary">
  273. <i class="bi bi-box-arrow-in-right"></i>
  274. Connexion obligatoire
  275. </a>
  276. </div>
  277. <div v-else>
  278. <button class="btn btn-primary" @click="pointSaleClick"
  279. :data-code="pointSale.code && pointSale.code.length > 0"
  280. :data-id-point-sale="pointSale.id">
  281. <i class="bi bi-geo-alt"></i>
  282. Choisir
  283. </button>
  284. </div>
  285. </template>
  286. </td>
  287. </tr>
  288. </tbody>
  289. </table>
  290. <div class="alert alert-warning" v-else>
  291. Aucun point de vente disponible pour ce jour de distribution.
  292. </div>
  293. </div>
  294. </div>
  295. </transition>
  296. <transition name="slide">
  297. <div id="content-step-products" v-if="step == 'products'">
  298. <div v-if="!loading">
  299. <div v-if="products.length">
  300. <table id="products" class="table table-bordered">
  301. <thead>
  302. <tr>
  303. <th class="photo">Photo</th>
  304. <th class="name">Nom</th>
  305. <th class="price">Prix unitaire</th>
  306. <th class="quantity">Quantité</th>
  307. <th class="total">Total</th>
  308. </tr>
  309. </thead>
  310. <tbody>
  311. <template v-for="category in categories">
  312. <tr v-if="category.id && countProductsByCategory(category)" :id="'category'+category.id" :class="(categoryCurrent && categoryCurrent.id == category.id) ? 'category-open' : 'category-closed'">
  313. <td class="category-name" colspan="5" @click="setCategoryCurrent(category)">
  314. <!--<span v-if="categoryCurrent && categoryCurrent.id == category.id"
  315. class="bi bi-caret-down-fill"></span>
  316. <span v-else class="bi bi-caret-right-fill"></span>-->
  317. {{ category.name }}
  318. <span class="badge bg-secondary">{{ countProductsByCategory(category) }}<!-- produit<template
  319. v-if="countProductsByCategory(category) > 1">s</template>--></span>
  320. <span v-if="countSelectedProductsByCategory(category) > 0"
  321. class="badge badge-count-selected-products bg-primary">{{ countSelectedProductsByCategory(category) }}<!-- produit<template
  322. v-if="countSelectedProductsByCategory(category) > 1">s</template>--><span> sélectionné<template
  323. v-if="countSelectedProductsByCategory(category) > 1">s</template></span></span>
  324. </td>
  325. </tr>
  326. <template v-if="(categoryCurrent && categoryCurrent.id == category.id) || category.id == null">
  327. <tr v-for="product in products"
  328. v-if="product.id_product_category == category.id && isProductAvailable(product)" class="product-open">
  329. <td class="photo">
  330. <a class="product-photo" :href="product.photo_big" :title="product.name">
  331. <img v-if="product.photo.length" class="photo-product" :src="product.photo"/>
  332. </a>
  333. </td>
  334. <td class="name product-name-description-block">
  335. <span class="name">{{ product.name }}</span>
  336. <span class="other">
  337. <span v-if="product.weight">({{ product.weight }}&nbsp;g)</span>
  338. </span>
  339. <div>
  340. <span v-if="product.quantity_max > 0 && ((product.quantity_form / product.coefficient_unit == product.quantity_remaining) || ((product.quantity_remaining * product.coefficient_unit) - product.quantity_form) < product.step)"
  341. class="badge bg-danger">Épuisé</span>
  342. </div>
  343. <div class="description" v-if="product.description.length">
  344. {{ product.description }}
  345. </div>
  346. <div class="description-long" v-if="product.recipe.length">
  347. <a href="javascript:void(0);" class="show-more-link">En savoir
  348. plus</a>
  349. <div class="content">
  350. {{ product.recipe }}
  351. </div>
  352. </div>
  353. </td>
  354. <td class="price-unit">
  355. <template v-if="productHasPrice(product)">
  356. <div>
  357. {{ formatPrice(getBestProductPrice(product.id,
  358. product.quantity_form)) }}<br/>
  359. <span class="price-infos">{{ product.wording_unit }}</span>
  360. <template v-if="product.unit == 'piece' && product.weight">
  361. <br />
  362. <span class="price-infos">
  363. {{ formatPrice(product.price_unit_ref) }} / kg
  364. </span>
  365. </template>
  366. </div>
  367. <div v-if="productHasPriceWithFromQuantity(product)"
  368. class="alert alert-info decreasing-prices">
  369. <ul>
  370. <li v-for="price in product.prices"
  371. v-if="price.from_quantity > 0">
  372. <strong>{{ formatPrice(price.price_with_tax)
  373. }}</strong><br/>à partir de {{
  374. price.from_quantity }} {{ product.wording_unit_ref
  375. }}
  376. </li>
  377. </ul>
  378. </div>
  379. </template>
  380. </td>
  381. <td class="td-quantity">
  382. <template v-if="productHasPrice(product)">
  383. <div class="input-group">
  384. <span class="input-group-btn">
  385. <button class="btn btn-secondary btn-moins"
  386. type="button"
  387. @click="productQuantityClick(product, product.unit == 'piece' ? -1 : -parseFloat(product.step))"
  388. :disabled="product.quantity_form == 0">
  389. <i class="bi bi-dash-lg"></i></button>
  390. </span>
  391. <input type="text" v-model="product.quantity_form"
  392. class="form-control quantity" readonly="readonly"/>
  393. <span class="input-group-text">{{ product.unit == 'piece' ? 'p.' : product.unit }}</span>
  394. <span class="input-group-btn">
  395. <button class="btn btn-secondary btn-plus"
  396. type="button"
  397. @click="productQuantityClick(product, product.unit == 'piece' ? 1 : parseFloat(product.step))"
  398. :disabled="product.quantity_form == product.quantity_remaining && product.quantity_max > 0">
  399. <i class="bi bi-plus-lg"></i></button>
  400. </span>
  401. </div>
  402. </template>
  403. </td>
  404. <td class="price-total">
  405. <template
  406. v-if="productHasPrice(product) && product.quantity_form > 0">
  407. {{ formatPrice(getBestProductPrice(product.id,
  408. product.quantity_form) * (product.quantity_form /
  409. product.coefficient_unit )) }}
  410. </template>
  411. </td>
  412. </tr>
  413. </template>
  414. </template>
  415. <tr class="total">
  416. <td class="summary" colspan="4">
  417. <template v-if="priceTotal() > 0">
  418. <h3>Résumé</h3>
  419. <ul>
  420. <li v-for="product in products" v-if="product.quantity_form > 0">
  421. <span class="quantity">{{ product.quantity_form }} {{ product.unit == 'piece' ? 'p.' : product.unit }}</span>
  422. <span class="name">{{ product.name }}</span>
  423. <!--<span class="other">
  424. <span v-if="product.description.length">/</span>
  425. <span class="description">{{ product.description }}</span>-->
  426. <span class="other">
  427. <span v-if="product.weight">({{ product.weight }}&nbsp;g)</span>
  428. </span>
  429. </li>
  430. </ul>
  431. </template>
  432. </td>
  433. <td class="price-total">
  434. <span>{{ priceTotal(true) }}</span>
  435. </td>
  436. </tr>
  437. </tbody>
  438. </table>
  439. <div id="content-step-payment">
  440. <div>
  441. <div class="card delivery" v-if="pointSaleActive.is_home_delivery">
  442. <div class="card-body">
  443. <h5 class="card-title">
  444. <label for="order-comment">
  445. <i class="bi bi-truck"></i>
  446. Adresse de livraison
  447. </label>
  448. </h5>
  449. <div class="card-text">
  450. <form>
  451. <textarea id="deliver-address" v-model="deliveryAddress" class="form-control" required="required"></textarea>
  452. </form>
  453. </div>
  454. </div>
  455. </div>
  456. <div class="card comment">
  457. <div class="card-body">
  458. <h5 class="card-title">
  459. <label for="order-comment">
  460. <i class="bi bi-chat-left"></i>
  461. Commentaire
  462. </label>
  463. </h5>
  464. <div class="card-text">
  465. <form>
  466. <textarea id="order-comment" v-model="comment" class="form-control"></textarea>
  467. </form>
  468. </div>
  469. </div>
  470. </div>
  471. <div id="payment-methods" class="card" v-if="pointSaleActive.payment_method_onsite || pointSaleActive.payment_method_credit || pointSaleActive.payment_method_online">
  472. <div class="card-body">
  473. <h5 class="card-title">
  474. <i class="bi bi-currency-euro"></i>
  475. Paiement
  476. </h5>
  477. <div class="card-text">
  478. <div class="row">
  479. <div class="col-md-4" v-if="isPaymentMethodOnsiteActive()">
  480. <input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="onsite" id="payment-method-onsite" autocomplete="off">
  481. <label class="btn btn-outline-success" for="payment-method-onsite">
  482. <i class="bi bi-wallet2"></i>
  483. Sur place
  484. </label>
  485. </div>
  486. <div class="col-md-4" v-if="isPaymentMethodCreditActive()">
  487. <template v-if="errorCreditMandatoryAndLimit()">
  488. <div class="alert alert-danger">
  489. <i class="bi bi-piggy-bank"></i>
  490. Vous devez
  491. <template v-if="producer.online_payment == 1">
  492. <a href="<?= \Yii::$app->urlManager->createUrl(['credit/add']) ?>">
  493. recharger votre cagnotte</a>
  494. </template>
  495. <template v-else>recharger votre cagnotte</template>
  496. auprès de votre producteur ou supprimer des produits.</span>
  497. Votre producteur n'autorise pas une cagnotte avec un montant inférieur
  498. à {{ formatPrice(producer.credit_limit) }}.<br />
  499. Montant de votre cagnotte : {{ formatPrice(user.credit) }}<br />
  500. Montant de votre commande : {{ priceTotal(true) }}
  501. </div>
  502. </template>
  503. <template v-else>
  504. <input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="credit" id="payment-method-credit" autocomplete="off">
  505. <label class="btn btn-outline-success" for="payment-method-credit">
  506. <i class="bi bi-piggy-bank"></i>
  507. Cagnotte
  508. </label>
  509. <div class="infos">
  510. Montant de ma cagnotte : {{ formatPrice(user.credit) }}<br />
  511. <template v-if="paymentMethod == 'credit'">
  512. <template v-if="order == null || order.amount_paid == 0">
  513. <span v-if="checkCreditLimit(order)">{{ priceTotal(true) }} seront débités</span>
  514. <span v-else>
  515. {{ formatPrice(user.credit) }} seront débités. (Limite de cagnotte à {{ formatPrice(producer.credit_limit) }})<br/>
  516. Restera {{ formatPrice(priceTotal() - user.credit) }} à régler.
  517. </span>
  518. </template>
  519. <template v-else-if="order != null && order.amount_paid > 0 && order.amount_paid < priceTotal()">
  520. <span v-if="checkCreditLimit(order)">{{ formatPrice(priceTotal() - order.amount_paid) }} seront débités</span>
  521. <span v-else>
  522. {{ formatPrice(user.credit) }} seront débités. (Limite de cagnotte à {{ formatPrice(producer.credit_limit) }})<br/>
  523. Restera {{ formatPrice(priceTotal() - order.amount_paid - user.credit) }} à régler.
  524. </span>
  525. </template>
  526. <template v-else-if="order != null && order.amount_paid > priceTotal()">
  527. <span>{{ formatPrice(order.amount_paid - priceTotal()) }} seront remboursés</span>
  528. </template>
  529. </template>
  530. </div>
  531. </template>
  532. </div>
  533. <div class="col-md-4" v-if="isPaymentMethodCreditActiveFunctioningUser(false)">
  534. <input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="credit" id="payment-method-credit" autocomplete="off" disabled>
  535. <label class="btn btn-outline-success" for="payment-method-credit">
  536. <i class="bi bi-piggy-bank"></i>
  537. Cagnotte
  538. </label>
  539. <div class="infos">
  540. Sur demande, vous pouvez payer vos commandes via votre
  541. cagnotte sur ce point de vente. N'hésitez pas à en
  542. parler à votre producteur.
  543. </div>
  544. </div>
  545. <div class="col-md-4" v-if="isPaymentMethodOnlineActive()">
  546. <input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="online" id="payment-method-online" autocomplete="off">
  547. <label class="btn btn-outline-success" for="payment-method-online">
  548. <i class="bi bi-credit-card"></i>
  549. Carte bancaire
  550. </label>
  551. <div class="infos">
  552. Paiement sécurisé via la plateforme Stripe.
  553. </div>
  554. </div>
  555. </div>
  556. </div>
  557. </div>
  558. </div>
  559. <template>
  560. <div id="signup-guest" class="card" v-if="!user && producer.option_allow_order_guest">
  561. <div class="card-body">
  562. <h5 class="card-title">
  563. <i class="bi bi-person"></i>
  564. Informations personnelles
  565. </h5>
  566. <div class="card-text">
  567. <form action="#">
  568. <div class="form-group field-signupguest-email required">
  569. <label class="control-label" for="signupguest-email">Email</label>
  570. <input type="email" id="signupguest-email" class="form-control"
  571. name="SignupForm[email]">
  572. <p class="help-block help-block-error"></p>
  573. </div>
  574. <div class="form-group field-signupguest-firstname required">
  575. <label class="control-label" for="signupguest-firstname">Prénom</label>
  576. <input type="text" id="signupguest-firstname" class="form-control"
  577. name="SignupForm[firstname]">
  578. <p class="help-block help-block-error"></p>
  579. </div>
  580. <div class="form-group field-signupguest-lastname required">
  581. <label class="control-label" for="signupguest-lastname">Nom</label>
  582. <input type="text" id="signupguest-lastname" class="form-control"
  583. name="SignupForm[lastname]">
  584. <p class="help-block help-block-error"></p>
  585. </div>
  586. <div class="form-group field-signupguest-phone required">
  587. <label class="control-label" for="signupguest-phone">Téléphone</label>
  588. <input type="text" id="signupguest-phone" class="form-control"
  589. name="SignupForm[phone]">
  590. <p class="help-block help-block-error"></p>
  591. </div>
  592. </form>
  593. </div>
  594. </div>
  595. </div>
  596. <div class="block-actions">
  597. <button class="btn btn-primary" disabled="disabled" v-if="disableConfirmButton || errorCreditMandatoryAndLimit() || !oneProductOrdered()">
  598. <span v-if="disableConfirmButton" class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
  599. Je confirme ma commande
  600. </button>
  601. <button class="btn btn-primary" v-else @click="confirmClick">
  602. Je confirme ma commande
  603. </button>
  604. </div>
  605. </template>
  606. </div>
  607. </div>
  608. </div>
  609. <div class="alert alert-warning" v-else>
  610. Aucun produit disponible
  611. </div>
  612. </div>
  613. </div>
  614. </transition>
  615. <transition name="slide">
  616. </transition>
  617. </div>
  618. </div>
  619. <!--<div v-if="producer != null && producer.online_payment && producer.option_online_payment_type == 'credit'"
  620. id="credit-online-payment">
  621. <div class="panel panel-default">
  622. <div class="panel-heading">
  623. <i class="glyphicon glyphicon-euro"></i> Paiement en ligne
  624. <a href="<?= \Yii::$app->urlManager->createUrl(['credit/add']) ?>" class="btn btn-sm btn-secondary"><i
  625. class="glyphicon glyphicon-credit-card"></i> Créditer mon compte</a>
  626. </div>
  627. <div class="panel-body">
  628. Vous utilisez le crédit pour régler vos commandes ? Simplifiez les paiements avec votre producteur
  629. en créditant votre compte par carte bancaire.
  630. </div>
  631. </div>
  632. </div>-->
  633. <?= $this->render('_block_infos'); ?>
  634. </div>
  635. </div>
  636. <script type="text/x-template" id="template-step-date">
  637. <li id="step-date" :class="'col-md-4'+((step == 'date') ? ' active' : '')+(first ? ' first' : '')">
  638. <button @click="changeStep('date')" :class="'btn '+ (step == 'date' ? 'btn-primary' : 'btn-secondary')"
  639. :disabled="producer && producer.option_order_entry_point == 'point-sale' && !pointSaleActive">
  640. <span class="button-content"><span class="glyphicon glyphicon-time"></span> Date</span></span>
  641. </button>
  642. <div class="info-step" v-if="dateFormat">
  643. {{ dateFormat }}
  644. </div>
  645. </li>
  646. </script>
  647. <script type="text/x-template" id="template-step-point-sale">
  648. <li id="step-point-sale" :class="'col-md-4'+((step == 'point-sale') ? ' active ' : '')+(first ? ' first' : '')">
  649. <button @click="changeStep('point-sale')"
  650. :class="'btn '+ (step == 'point-sale' ? 'btn-primary' : 'btn-secondary')"
  651. :disabled="producer && (producer.option_order_entry_point == 'date' && step == 'date')">
  652. <span class="button-content"><span
  653. class="glyphicon glyphicon-map-marker"></span> <?= $producerModule->getPointSaleWording($producer); ?></span>
  654. </button>
  655. <div class="info-step" v-if="pointSaleActive">
  656. {{ pointSaleActive.name }}
  657. </div>
  658. </li>
  659. </script>