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.

order.php 49KB

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