Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

337 lines
22KB

  1. <?php
  2. /**
  3. Copyright distrib (2018)
  4. contact@opendistrib.net
  5. Ce logiciel est un programme informatique servant à aider les producteurs
  6. à distribuer leur production en circuits courts.
  7. Ce logiciel est régi par la licence CeCILL soumise au droit français et
  8. respectant les principes de diffusion des logiciels libres. Vous pouvez
  9. utiliser, modifier et/ou redistribuer ce programme sous les conditions
  10. de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
  11. sur le site "http://www.cecill.info".
  12. En contrepartie de l'accessibilité au code source et des droits de copie,
  13. de modification et de redistribution accordés par cette licence, il n'est
  14. offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
  15. seule une responsabilité restreinte pèse sur l'auteur du programme, le
  16. titulaire des droits patrimoniaux et les concédants successifs.
  17. A cet égard l'attention de l'utilisateur est attirée sur les risques
  18. associés au chargement, à l'utilisation, à la modification et/ou au
  19. développement et à la reproduction du logiciel par l'utilisateur étant
  20. donné sa spécificité de logiciel libre, qui peut le rendre complexe à
  21. manipuler et qui le réserve donc à des développeurs et des professionnels
  22. avertis possédant des connaissances informatiques approfondies. Les
  23. utilisateurs sont donc invités à charger et tester l'adéquation du
  24. logiciel à leurs besoins dans des conditions permettant d'assurer la
  25. sécurité de leurs systèmes et ou de leurs données et, plus généralement,
  26. à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
  27. Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
  28. pris connaissance de la licence CeCILL, et que vous en avez accepté les
  29. termes.
  30. */
  31. \producer\assets\VuejsOrderOrderAsset::register($this);
  32. $this->setTitle('Commander') ;
  33. ?>
  34. <div id="app-order-order" :class="{'loaded': !loadingInit}">
  35. <?php if(isset($order)): ?>
  36. <span id="order-distribution-date"><?= $order->distribution->date; ?></span>
  37. <?php endif; ?>
  38. <?php if(isset($date)): ?>
  39. <span id="distribution-date"><?= $date; ?></span>
  40. <?php endif; ?>
  41. <div v-if="loadingInit && distributions.length == 0" class="alert alert-warning">
  42. Aucune distribution n'est prévue chez ce producteur.
  43. </div>
  44. <div v-else>
  45. <div>
  46. <div id="steps">
  47. <ul>
  48. <li id="step-date" :class="'col-md-3 '+((step == 'date') ? 'active' : '')">
  49. <button @click="changeStep('date')" :class="'btn '+ (step == 'date' ? 'btn-primary' : 'btn-default')">
  50. <span class="button-content"><span class="glyphicon glyphicon-time"></span> Date</span></span>
  51. </button>
  52. <div class="info-step" v-if="dateFormat">
  53. {{ dateFormat }}
  54. </div>
  55. </li>
  56. <li id="step-point-sale" :class="'col-md-3 '+((step == 'point-sale') ? 'active ' : '')">
  57. <button @click="changeStep('point-sale')" :class="'btn '+ (step == 'point-sale' ? 'btn-primary' : 'btn-default')" :disabled="step == 'date'">
  58. <span class="button-content"><span class="glyphicon glyphicon-map-marker"></span> Points de vente</span>
  59. </button>
  60. <div class="info-step" v-if="pointSaleActive">
  61. {{ pointSaleActive.name }}
  62. </div>
  63. </li>
  64. <li id="step-products" :class="'col-md-3 '+((step == 'products') ? 'active ' : '')">
  65. <button @click="changeStep('products')" :class="'btn '+ (step == 'products' ? 'btn-primary' : 'btn-default')" :disabled="step == 'date' || step == 'point-sale'">
  66. <span class="button-content"><span class="glyphicon glyphicon-th-list"></span> Produits</span>
  67. </button>
  68. <div class="info-step" v-if="oneProductOrdered()">
  69. {{ countProductOrdered() }} produit{{ (countProductOrdered() > 1) ? 's' : '' }}
  70. </div>
  71. </li>
  72. <li id="step-payment" :class="'col-md-3 '+((step == 'payment') ? 'active' : '')">
  73. <button @click="changeStep('payment')" :class="'btn '+ (step == 'payment' ? 'btn-primary' : 'btn-default')" :disabled="step == 'date' || step == 'point-sale' || step == 'products'">
  74. <span class="button-content"><span class="glyphicon glyphicon-ok"></span> Confirmation</span>
  75. </button>
  76. </li>
  77. </ul>
  78. <div class="clr"></div>
  79. </div>
  80. <div class="content">
  81. <div v-if="errors.length" class="alert alert-danger">
  82. <ul>
  83. <li v-for="error in errors">
  84. {{ error }}
  85. </li>
  86. </ul>
  87. </div>
  88. <transition name="slide">
  89. <div id="content-step-date" v-if="step == 'date'">
  90. <div id="legend">
  91. <div><span id="distribution-date-color"></span> Prochains jours de distribution</div>
  92. <div><span id="order-date-color"></span> Vos commandes déjà enregistrées</div>
  93. </div>
  94. <div id="calendar">
  95. <v-calendar
  96. is-inline
  97. is-double-paned
  98. is-expanded
  99. v-model="date"
  100. mode="single"
  101. firstDayOfWeek="1"
  102. :formats="calendar.formats"
  103. :theme-styles="calendar.themeStyles"
  104. :attributes="calendar.attrs"
  105. :available-dates="calendar.availableDates"
  106. @dayclick='dayClick'>
  107. ></v-calendar>
  108. </div>
  109. </div>
  110. </transition>
  111. <transition name="slide">
  112. <div id="content-step-point-sale" v-if="step == 'point-sale'">
  113. <div v-if="loading">
  114. Chargement ...
  115. </div>
  116. <div v-else>
  117. <h3>Où souhaitez-vous récupérer votre commande ?</h3>
  118. <table id="points-sale" class="table table-bordered" v-if="pointsSale.length">
  119. <thead>
  120. <tr>
  121. <th>Nom</th>
  122. <th>Localité</th>
  123. <th></th>
  124. </tr>
  125. </thead>
  126. <tbody>
  127. <tr v-for="pointSale in orderedPointsSale" v-if="pointSale && pointSale.pointSaleDistribution.delivery" :class="(pointSaleActive && pointSale.id == pointSaleActive.id) ? 'selected' : ''">
  128. <td class="name">
  129. <span class="the-name">{{ pointSale.name }}</span>
  130. <div class="comment" v-if="pointSale.userPointSale">
  131. {{ pointSale.userPointSale.comment }}
  132. </div>
  133. </td>
  134. <td class="locality">{{ pointSale.locality }}</td>
  135. <td class="actions">
  136. <div :class="'form-group' + (pointSale.invalid_code ? ' has-error' : '')">
  137. <div class="input-group" v-if="pointSale.code.length > 0">
  138. <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
  139. <input v-model="pointsSaleCodes[pointSale.id]" type="password" placeholder="Code" class="form-control input-code" />
  140. </div>
  141. </div>
  142. <button class="btn btn-primary" @click="pointSaleClick" :data-code="pointSale.code.length > 0" :data-id-point-sale="pointSale.id">
  143. <span class="glyphicon glyphicon-map-marker"></span>
  144. Choisir
  145. </button>
  146. </td>
  147. </tr>
  148. </tbody>
  149. </table>
  150. <div class="alert alert-warning" v-else>
  151. Aucun point de vente disponible pour ce jour de distribution.
  152. </div>
  153. </div>
  154. </div>
  155. </transition>
  156. <transition name="slide">
  157. <div id="content-step-products" v-if="step == 'products'">
  158. <div v-if="products.length">
  159. <table id="products" class="table table-bordered" >
  160. <thead>
  161. <tr>
  162. <th>Photo</th>
  163. <th>Nom</th>
  164. <th>Prix unitaire</th>
  165. <th>Quantité</th>
  166. <th>Total</th>
  167. </tr>
  168. </thead>
  169. <tbody>
  170. <tr v-for="product in products" v-if="product.productDistribution[0].active == 1">
  171. <td class="photo">
  172. <img v-if="product.photo.length" class="photo-product" :src="'<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/uploads/'+product.photo" />
  173. </td>
  174. <td class="name">
  175. <span class="name">{{ product.name }}</span>
  176. <span class="other">
  177. <span v-if="product.description.length">/</span>
  178. <span class="description">{{ product.description }}</span>
  179. <span v-if="product.unit == 'piece' && product.weight">({{ product.weight }}g)</span>
  180. </span>
  181. <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)" class="label label-danger">
  182. Épuisé
  183. </span>
  184. <div class="recipe" v-if="product.recipe.length">{{ product.recipe }}</div>
  185. </td>
  186. <td class="price-unit">
  187. {{ formatPrice(product.price_with_tax) }}<br /><span class="unit">{{ product.wording_unit }}</span>
  188. </td>
  189. <td class="td-quantity">
  190. <div class="input-group">
  191. <span class="input-group-btn">
  192. <button class="btn btn-default btn-moins" type="button" @click="productQuantityClick(product, product.unit == 'piece' ? -1 : -parseFloat(product.step))" :disabled="product.quantity_form == 0"><span class="glyphicon glyphicon-minus"></span></button>
  193. </span>
  194. <input type="text" v-model="product.quantity_form" class="form-control quantity" readonly="readonly" />
  195. <span class="input-group-addon">{{ product.unit == 'piece' ? 'p.' : product.unit }}</span>
  196. <span class="input-group-btn">
  197. <button class="btn btn-default btn-plus" type="button" @click="productQuantityClick(product, product.unit == 'piece' ? 1 : parseFloat(product.step))" :disabled="product.quantity_form == product.quantity_remaining && product.quantity_max > 0"><span class="glyphicon glyphicon-plus"></span></button>
  198. </span>
  199. </div>
  200. </td>
  201. <td class="price-total">
  202. {{ formatPrice(product.price_with_tax * (product.quantity_form / product.coefficient_unit )) }}
  203. </td>
  204. </tr>
  205. <tr class="total">
  206. <td colspan="4"></td>
  207. <td class="price-total">{{ priceTotal(true) }}</td>
  208. </tr>
  209. </tbody>
  210. </table>
  211. <div class="block-actions">
  212. <button class="btn btn-primary" @click="changeStep('payment')">Valider</button>
  213. </div>
  214. </div>
  215. <div class="alert alert-warning" v-else>
  216. Aucun produit disponible
  217. </div>
  218. </div>
  219. </transition>
  220. <transition name="slide">
  221. <div id="content-step-payment" v-if="step == 'payment'">
  222. <div class="comment">
  223. <label for="order-comment">Commentaire</label>
  224. <textarea id="order-comment" v-model="comment" class="form-control"></textarea>
  225. </div>
  226. <template v-if="!checkCreditLimit(order) && pointSaleActive.credit_functioning == 'mandatory'">
  227. <div class="alert alert-danger">Vous devez recharger votre crédit ou supprimer des produits. Votre producteur n'autorise pas un crédit inférieur à <strong>{{ formatPrice(creditLimit) }}</strong>.</div>
  228. <div class="block-actions">
  229. <a class="btn btn-primary" href="<?= Yii::$app->urlManager->createUrl(['site/index']) ?>">Retour à l'accueil</a>
  230. </div>
  231. </template>
  232. <template v-else>
  233. <div class="credit">
  234. <div v-if="producer.credit == 1 && pointSaleActive.credit == 1 && (pointSaleActive.credit_functioning != 'user' || (pointSaleActive.credit_functioning == 'user' && user.credit_active))">
  235. <input type="checkbox" id="use-credit" v-model="useCredit" disabled="disabled" v-if="pointSaleActive.credit_functioning == 'mandatory' || (pointSaleActive.credit_functioning == 'user' && user.credit_active)" />
  236. <input type="checkbox" id="use-credit" v-model="useCredit" v-else /> <label for="use-credit">Utiliser mon Crédit ({{ formatPrice(user.credit) }})</label>
  237. <div class="info" v-if="useCredit">
  238. <template v-if="order == null || order.amount_paid == 0">
  239. <span v-if="checkCreditLimit(order)">{{ priceTotal(true) }} seront débités</span>
  240. <span v-else>
  241. {{ formatPrice(user.credit) }} seront débités. (Limite de crédit à {{ formatPrice(producer.credit_limit) }})<br />
  242. Restera {{ formatPrice(priceTotal() - credit) }} à régler.
  243. </span>
  244. </template>
  245. <template v-else-if="order != null && order.amount_paid > 0 && order.amount_paid < priceTotal()">
  246. <span v-if="checkCreditLimit(order)">{{ formatPrice(priceTotal() - order.amount_paid) }} seront débités</span>
  247. <span v-else>
  248. {{ formatPrice(user.credit) }} seront débités. (Limite de crédit à {{ formatPrice(producer.credit_limit) }})<br />
  249. Restera {{ formatPrice(priceTotal() - order.amount_paid - user.credit) }} à régler.
  250. </span>
  251. </template>
  252. <template v-else-if="order != null && order.amount_paid > priceTotal()">
  253. <span>{{ formatPrice(order.amount_paid - priceTotal()) }} seront remboursés</span>
  254. </template>
  255. </div>
  256. </div>
  257. <div v-else>
  258. <span class="glyphicon glyphicon-chevron-right"></span> La commande sera à régler sur place.
  259. </div>
  260. </div>
  261. <div class="block-actions">
  262. <button class="btn btn-primary" disabled="disabled" v-if="disableConfirmButton">Je confirme ma commande</button>
  263. <button class="btn btn-primary" v-else @click="confirmClick">Je confirme ma commande</button>
  264. </div>
  265. </template>
  266. </div>
  267. </transition>
  268. </div>
  269. </div>
  270. <div id="infos" v-if="producer != null && producer.order_infos != null && producer.order_infos.length">
  271. <div class="panel panel-default">
  272. <div class="panel-heading">
  273. Informations
  274. </div>
  275. <div class="panel-body">
  276. {{ producer.order_infos }}
  277. </div>
  278. </div>
  279. </div>
  280. <?php
  281. $producer = GlobalParam::getCurrentProducer() ;
  282. if($producer->hasSpecificDelays()): ?>
  283. <div id="specific-delays" class="panel panel-default">
  284. <div class="panel-heading">
  285. Délais de commande spécifiques
  286. </div>
  287. <div class="panel-body">
  288. <table class="table table-bordered">
  289. <thead>
  290. <tr>
  291. <th>Jour</th>
  292. <th>Délai</th>
  293. </tr>
  294. </thead>
  295. <?php foreach($producer->getSpecificDelays() as $day => $delay): ?>
  296. <tr>
  297. <td>
  298. <?php
  299. switch($day) {
  300. case 'monday': echo 'Lundi' ; break;
  301. case 'tuesday': echo 'Mardi' ; break;
  302. case 'wednesday': echo 'Mercredi' ; break;
  303. case 'thursday': echo 'Jeudi' ; break;
  304. case 'friday': echo 'Vendredi' ; break;
  305. case 'saturday': echo 'Samedi' ; break;
  306. case 'sunday': echo 'Dimanche' ; break;
  307. }
  308. ?>
  309. </td>
  310. <td>
  311. <span><?= $delay['order_delay'] ?> jour<?= ($delay['order_delay'] > 1) ? 's' : '' ?></span> à l'avance,
  312. avant <span><?= $delay['order_deadline'] ?>h</span>
  313. </td>
  314. </tr>
  315. <?php endforeach; ?>
  316. </table>
  317. </div>
  318. </div>
  319. <?php endif; ?>
  320. </div>
  321. </div>