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.

index.php 39KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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. \backend\assets\VuejsDistributionIndexAsset::register($this);
  32. $this->setTitle('Distributions') ;
  33. $this->setPageTitle('Distributions') ;
  34. ?>
  35. <div id="app-distribution-index" class="app-vuejs">
  36. <?php if(strlen($date)): ?>
  37. <span id="distribution-date"><?= $date; ?></span>
  38. <?php endif; ?>
  39. <div id="loading" v-if="showLoading">
  40. <img src="<?= Yii::$app->urlManagerBackend->getBaseUrl(); ?>/img/loader.gif" alt="Chargement ..." />
  41. </div>
  42. <div id="wrapper-app-distribution-index" :class="'wrapper-app-vuejs '+(loading ? '' : 'loaded')">
  43. <div class="col-md-4">
  44. <div id="calendar">
  45. <v-date-picker
  46. is-inline
  47. is-expanded
  48. v-model="date"
  49. popover-visibility="hidden"
  50. firstDayOfWeek="1"
  51. :mode="calendar.mode"
  52. :formats="calendar.formats"
  53. :theme-styles="calendar.themeStyles"
  54. :attributes="calendar.attrs"
  55. @dayclick='dayClicked'>
  56. ></v-date-picker>
  57. </div>
  58. <div class="clr"></div>
  59. </div>
  60. <div class="col-md-8">
  61. <div v-if="date">
  62. <div id="infos-top">
  63. <div class="col-md-12">
  64. <div class="info-box" id="info-box-distribution">
  65. <span :class="'info-box-icon '+(distribution.active ? 'bg-green' : 'bg-red')"><i :class="'fa '+(distribution.active ? 'fa-check' : 'fa-remove')"></i></span>
  66. <div class="info-box-content">
  67. <span class="info-box-text">
  68. <h4>Distribution du <strong>{{ dateFormat }}</strong></h4>
  69. <a @click="activeWeekDistribution" data-active="0" class="btn btn-default btn-active-week" v-if="oneDistributionWeekActive">Désactiver cette semaine</a>
  70. <a @click="activeWeekDistribution" data-active="1" class="btn btn-default btn-active-week" v-else>Activer cette semaine</a>
  71. <a @click="activeDistribution" data-active="0" class="btn btn-default" v-if="distribution.active">Désactiver ce jour</a>
  72. <a @click="activeDistribution" data-active="1" class="btn btn-default" v-else>Activer ce jour</a>
  73. </span>
  74. </div>
  75. </div>
  76. </div>
  77. <!-- produits -->
  78. <div class="col-md-6">
  79. <div class="info-box col-md-4">
  80. <span class="info-box-icon bg-yellow"><i class="fa fa-clone"></i></span>
  81. <div class="info-box-content">
  82. <span class="info-box-text">
  83. {{ countActiveProducts }} Produits<br /><br />
  84. <button class="btn btn-default" @click="showModalProducts = true">Configurer</button>
  85. </span>
  86. </div>
  87. </div>
  88. </div>
  89. <modal v-if="showModalProducts" id="modal-products" @close="showModalProducts = false">
  90. <h3 slot="header">Produits</h3>
  91. <div slot="body">
  92. <table class="table table-condensed table-bordered table-hover">
  93. <thead>
  94. <tr>
  95. <td>Actif</td>
  96. <td>Nom</td>
  97. <td class="quantity-ordered">Commandé</td>
  98. <td class="quantity-max">Maximum</td>
  99. </tr>
  100. </thead>
  101. <tbody>
  102. <tr v-for="product in products">
  103. <td>
  104. <button class="btn btn-success" v-if="product.productDistribution[0].active == 1"><span class="glyphicon glyphicon-ok"></span></button>
  105. <button class="btn btn-default" v-else data-active-product="1" :data-id-product="product.id" @click="productActiveClick"><span class="glyphicon glyphicon-ok"></span></button>
  106. <button class="btn btn-danger" v-if="product.productDistribution[0].active == 0"><span class="glyphicon glyphicon-remove"></span></button>
  107. <button class="btn btn-default" v-else data-active-product="0" :data-id-product="product.id" @click="productActiveClick"><span class="glyphicon glyphicon-remove"></span></button>
  108. </td>
  109. <td>{{ product.name }}</td>
  110. <td class="quantity-ordered">{{ product.quantity_ordered ? product.quantity_ordered + ' '+ ((product.unit == 'piece') ? ' p.' : ' '+(product.unit == 'g' || product.unit == 'kg') ? 'kg' : 'litre(s)') : '&empty;' }}</td>
  111. <td class="quantity-max">
  112. <div class="input-group">
  113. <input type="text" class="form-control quantity-max" placeholder="&infin;" :data-id-product="product.id" v-model="product.productDistribution[0].quantity_max" @keyup="productQuantityMaxChange" />
  114. <span class="input-group-addon">{{ (product.unit == 'piece') ? 'p.' : ' '+((product.unit == 'g' || product.unit == 'kg') ? 'kg' : 'litre(s)') }}</span>
  115. </div>
  116. </td>
  117. </tr>
  118. </tbody>
  119. </table>
  120. </div>
  121. <div slot="footer">
  122. <div class="actions-form">
  123. <button class="modal-default-button btn btn-default" @click="closeModalProducts">Fermer</button>
  124. </div>
  125. </div>
  126. </modal>
  127. <div class="col-md-6">
  128. <div class="info-box col-md-4">
  129. <span class="info-box-icon bg-yellow"><i class="fa fa-map-marker"></i></span>
  130. <div class="info-box-content">
  131. <span class="info-box-text">
  132. {{ countActivePointsSale }} Points de vente<br /><br />
  133. <button class="btn btn-default" @click="showModalPointsSale = true">Configurer</button>
  134. </span>
  135. </div>
  136. </div>
  137. </div>
  138. <modal v-if="showModalPointsSale" id="modal-points-sale" @close="showModalPointsSale = false">
  139. <h3 slot="header">Points de vente</h3>
  140. <div slot="body">
  141. <table class="table table-condensed table-bordered table-hover">
  142. <thead>
  143. <tr>
  144. <td>Actif</td>
  145. <td>Nom</td>
  146. </tr>
  147. </thead>
  148. <tbody>
  149. <tr v-for="pointSale in pointsSale">
  150. <td>
  151. <button class="btn btn-success" v-if="pointSale.pointSaleDistribution[0].delivery == 1"><span class="glyphicon glyphicon-ok"></span></button>
  152. <button class="btn btn-default" v-else data-delivery-point-sale="1" :data-id-point-sale="pointSale.id" @click="pointSaleActiveClick"><span class="glyphicon glyphicon-ok"></span></button>
  153. <button class="btn btn-danger" v-if="pointSale.pointSaleDistribution[0].delivery == 0"><span class="glyphicon glyphicon-remove"></span></button>
  154. <button class="btn btn-default" v-else data-delivery-point-sale="0" :data-id-point-sale="pointSale.id" @click="pointSaleActiveClick"><span class="glyphicon glyphicon-remove"></span></button>
  155. </td>
  156. <td>{{ pointSale.name }}</td>
  157. </tr>
  158. </tbody>
  159. </table>
  160. </div>
  161. </modal>
  162. <div class="col-md-6">
  163. <div id="summary-ca-weight" class="info-box col-md-4">
  164. <span class="info-box-icon bg-yellow"><i class="fa fa-euro"></i></span>
  165. <div class="info-box-content">
  166. <span class="info-box-text">CA</span>
  167. <span class="info-box-number">{{ distribution.revenues }} <span class="normal" v-if="distribution.potential_revenues != '0.00 €'">/ {{ distribution.potential_revenues }}</span></span>
  168. <span class="info-box-text">Poids</span>
  169. <span class="info-box-number">{{ distribution.weight }} kg <span class="normal" v-if="distribution.potential_weight > 0">/ {{ distribution.potential_weight }} kg</span></span>
  170. </div>
  171. </div>
  172. </div>
  173. <div class="col-md-6">
  174. <div class="info-box col-md-4">
  175. <span class="info-box-icon bg-yellow"><i class="fa fa-download"></i></span>
  176. <div class="info-box-content">
  177. <span class="info-box-text">
  178. {{ countOrders }} Commande<span v-if="countOrders > 1">s</span><br />
  179. <a href="#" class="btn btn-xs btn-default" disabled="disabled" v-if="countOrders == 0">Télécharger (PDF)</a>
  180. <a :href="distribution.url_report" class="btn btn-default">Télécharger (PDF)</a><br />
  181. <a href="#" class="btn btn-xs btn-default" disabled="disabled" v-if="countOrders == 0">Télécharger (CSV)</a>
  182. <a :href="distribution.url_report+'&type=csv'" class="btn btn-default">Télécharger (CSV)</a>
  183. </span>
  184. </div>
  185. </div>
  186. </div>
  187. </div>
  188. </div>
  189. <div class="callout callout-info" v-else>
  190. <h4><i class="fa fa-info"></i> Pour commencer</h4>
  191. <p>Veuillez choisir une date de distribution.</p>
  192. </div>
  193. </div>
  194. <div class="clr"></div>
  195. <div id="orders" class="panel panel-default" v-if="date">
  196. <div class="panel-heading">
  197. <h3 class="panel-title">Commandes <label class="label label-success" v-if="orders.length">{{ orders.length }}</label><label class="label label-danger" v-else>0</label></h3>
  198. </div>
  199. <div class="panel-body">
  200. <button id="btn-add-subscriptions" @click="addSubscriptions" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-plus"></span> Importer les abonnements</button>
  201. <button id="btn-add-order" @click="showModalFormOrderCreate = true" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-plus"></span> Ajouter une commande</button>
  202. <order-form
  203. v-if="showModalFormOrderCreate"
  204. :date="date"
  205. :order="orderCreate"
  206. :points-sale="pointsSale"
  207. :users="users"
  208. :products="products"
  209. @close="showModalFormOrderCreate = false"
  210. @ordercreatedupdated="orderCreatedUpdated"
  211. ></order-form>
  212. <div id="wrapper-nav-points-sale">
  213. <ul id="nav-points-sale">
  214. <li data-id-point-sale="0" data-id-point-sale="0" v-if="countActivePointsSale > 1" @click="pointSaleClick">
  215. <a class="btn btn-default btn-primary" v-if="idActivePointSale == 0">Tous <span class="label label-default">{{ orders.length }}</span> <span class="glyphicon glyphicon-triangle-bottom"></span></a>
  216. <a class="btn btn-default" v-else>Tous <span class="label label-default">{{ orders.length }}</span><span class="glyphicon glyphicon-triangle-bottom"></span></a>
  217. </li>
  218. <li v-for="pointSale in pointsSale" :data-id-point-sale="pointSale.id" v-if="pointSale.pointSaleDistribution[0].delivery == 1" @click="pointSaleClick">
  219. <a class="btn btn-default btn-primary" v-if="idActivePointSale == pointSale.id">{{ pointSale.name }} <span class="label label-default">{{ countOrdersByPointSale[pointSale.id] }}</span><span class="glyphicon glyphicon-triangle-bottom"></span></a>
  220. <a class="btn btn-default" v-else>{{ pointSale.name }} <span class="label label-default">{{ countOrdersByPointSale[pointSale.id] }}</span><span class="glyphicon glyphicon-triangle-bottom"></span></a>
  221. </li>
  222. </ul>
  223. <div class="clr"></div>
  224. </div>
  225. <table class="table table-condensed table-bordered table-hover" v-if="countOrdersByPointSale[idActivePointSale] > 0 || (idActivePointSale == 0 && orders.length > 0)">
  226. <tbody>
  227. <template v-for="(order, key, index) in orders" v-if="idActivePointSale == 0 || idActivePointSale == order.id_point_sale">
  228. <tr>
  229. <td>
  230. <label class="label label-success" v-if="order.origin == 'user'">client</label>
  231. <label class="label label-default" v-else-if="order.origin == 'auto'">auto</label>
  232. <label class="label label-warning" v-else>admin</label>
  233. </td>
  234. <td>
  235. <span class="label label-danger" v-if="order.date_delete"><span class="glyphicon glyphicon-trash"></span></span>
  236. <span class="label label-warning" v-if="order.date_update"><span class="glyphicon glyphicon-pencil"></span></span>
  237. <span class="label label-success" v-if="!order.date_update && !order.date_delete"><span class="glyphicon glyphicon-check"></span></span>
  238. </td>
  239. <td>
  240. <span v-if="order.user">{{ order.user.lastname+' '+order.user.name }}</span>
  241. <span v-else>{{ order.username }}</span>
  242. <span v-if="order.comment && order.comment.length > 0" class="glyphicon glyphicon-comment"></span>
  243. </td>
  244. <td v-if="idActivePointSale == 0">
  245. {{ order.pointSale.name }}
  246. </td>
  247. <td>{{ order.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}</td>
  248. <td class="column-state-payment">
  249. <div class="input-group">
  250. <span class="label label-success input-group-addon" v-if="order.amount_paid == order.amount">payé</span>
  251. <span class="label label-default input-group-addon" v-else-if="order.amount_paid == 0">non réglé</span>
  252. <span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span>
  253. <span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à payer</span>
  254. <span class="glyphicon glyphicon-time" title="Paiement automatique" v-if="order.auto_payment && producer.credit && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>
  255. </div>
  256. </td>
  257. <td class="column-payment" v-if="producer.credit">
  258. <div class="btn-group" v-if="order.user && !order.date_delete">
  259. <button class="btn btn-xs btn-default" v-if="order.amount_paid == order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="refund" :data-amount="order.amount">
  260. <span class="glyphicon glyphicon-euro"></span> Rembourser
  261. </button>
  262. <button class="btn btn-xs btn-default" v-else-if="order.amount_paid == 0" @click="orderPaymentClick" :data-id-order="order.id" data-type="payment" :data-amount="order.amount">
  263. <span class="glyphicon glyphicon-euro"></span> Payer
  264. </button>
  265. <button class="btn btn-xs btn-default" v-else-if="order.amount_paid < order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="payment" :data-amount="order.amount_remaining">
  266. <span class="glyphicon glyphicon-euro"></span> Payer
  267. </button>
  268. <button class="btn btn-xs btn-default" v-else-if="order.amount_paid > order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="refund" :data-amount="order.amount_surplus">
  269. <span class="glyphicon glyphicon-euro"></span> Rembourser
  270. </button>
  271. <button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  272. <span class="caret"></span>
  273. <span class="sr-only">Toggle Dropdown</span>
  274. </button>
  275. <ul class="dropdown-menu">
  276. <li><a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">Historique</a></li>
  277. </ul>
  278. </div>
  279. </td>
  280. <td class="column-actions">
  281. <span v-if="order.oneProductUnactivated" class="glyphicon glyphicon-warning-sign" title="Contient un produit non activé"></span>
  282. <button class="btn btn-default" :data-id-order="order.id" @click="orderViewClick"><span :class="'glyphicon ' + ((showViewProduct && idOrderView == order.id) ? 'glyphicon-eye-close' : 'glyphicon-eye-open')"></span></button>
  283. <button class="btn btn-default" :data-id-order="order.id" @click="updateOrderClick"><span class="glyphicon glyphicon-pencil"></span></button>
  284. <button class="btn btn-default" :data-id-order="order.id" @click="deleteOrderClick"><span class="glyphicon glyphicon-trash"></span></button>
  285. <a class="btn btn-default" :href="baseUrl+'/subscription/update?id='+order.id_subscription" v-if="order.id_subscription > 0"><span class="glyphicon glyphicon-repeat"></span></a>
  286. <a class="btn btn-default add-subscription" :href="baseUrl+'/subscription/create?idOrder='+order.id" v-else><span class="glyphicon glyphicon-plus"></span><span class="glyphicon glyphicon-repeat"></span></a>
  287. <order-form
  288. v-if="showModalFormOrderUpdate && idOrderUpdate == order.id"
  289. :date="date"
  290. :id-point-sale="idActivePointSale"
  291. :points-sale="pointsSale"
  292. :users="users"
  293. :products="products"
  294. :order="ordersUpdate[key]"
  295. @close="showModalFormOrderUpdate = false"
  296. @ordercreatedupdated="orderCreatedUpdated"
  297. ></order-form>
  298. <modal v-if="showModalPayment && idOrderPayment == order.id" class="modal-payment" @close="showModalPayment = false">
  299. <h3 slot="header">
  300. Commande du <strong>{{ dateFormat }}</strong> &gt;
  301. <strong><span v-if="order.user">{{ order.user.name +' '+order.user.lastname }}</span>
  302. <span v-else>{{ order.username }}</span></strong>
  303. </h3>
  304. <div slot="body">
  305. <div class="col-md-4">
  306. <div class="info-box">
  307. <span :class="'info-box-icon ' +((order.amount_paid == order.amount) ? 'bg-green' : 'bg-red')"><i class="fa fa-check"></i></span>
  308. <div class="info-box-content">
  309. <span class="info-box-text">Montant</span>
  310. <span class="info-box-number">{{ order.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}</span>
  311. <span class="info-box-text">
  312. Statut<br />
  313. <span class="label label-success" v-if="order.amount_paid == order.amount">payé</span>
  314. <span class="label label-default" v-else-if="order.amount_paid == 0">non réglé</span>
  315. <span class="label label-default" v-else-if="order.amount_paid > order.amount">surplus</span>
  316. <span class="label label-warning" v-else-if="order.amount_paid < order.amount">reste à payer</span>
  317. </span>
  318. </div>
  319. </div>
  320. <div class="info-box">
  321. <span :class="'info-box-icon ' +((order.user.credit > 0) ? 'bg-green' : 'bg-red')"><i class="fa fa-user"></i></span>
  322. <div class="info-box-content">
  323. <span class="info-box-text">Crédit utilisateur</span>
  324. <span class="info-box-number">{{ order.user.credit.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}</span>
  325. </div>
  326. </div>
  327. <button v-if="order.amount_paid == order.amount"
  328. class="btn btn-default"
  329. :data-amount="order.amount"
  330. data-type="refund"
  331. @click="orderPaymentClick" >
  332. <span class="glyphicon glyphicon-chevron-right"></span>
  333. Rembourser {{ order.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
  334. </button>
  335. <button v-else-if="order.amount_paid == 0"
  336. class="btn btn-default"
  337. :data-amount="order.amount"
  338. data-type="payment"
  339. @click="orderPaymentClick">
  340. <span class="glyphicon glyphicon-chevron-right"></span>
  341. Payer {{ order.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
  342. </button>
  343. <button v-else-if="order.amount_paid > order.amount"
  344. class="btn btn-default"
  345. :data-amount="order.amount_surplus"
  346. data-type="refund"
  347. @click="orderPaymentClick">
  348. <span class="glyphicon glyphicon-chevron-right"></span>
  349. Rembourser {{ order.amount_surplus.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
  350. </button>
  351. <button v-else-if="order.amount_paid < order.amount"
  352. class="btn btn-default"
  353. :data-amount="order.amount_remaining"
  354. data-type="payment"
  355. @click="orderPaymentClick">
  356. <span class="glyphicon glyphicon-chevron-right"></span>
  357. Payer le restant {{ order.amount_remaining.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
  358. </button>
  359. </div>
  360. <div class="col-md-8">
  361. <h4>Historique paiement</h4>
  362. <table class="table table-condensed table-bordered table-hover">
  363. <thead>
  364. <tr>
  365. <td>Date</td>
  366. <td>Utilisateur</td>
  367. <td>Action</td>
  368. <td>- Débit</td>
  369. <td>+ Crédit</td>
  370. </tr>
  371. </thead>
  372. <tbody>
  373. <tr v-for="creditHistory in order.creditHistory">
  374. <td>{{ creditHistory.date }}</td>
  375. <td>{{ creditHistory.user_action }}</td>
  376. <td v-html="creditHistory.wording"></td>
  377. <td v-html="creditHistory.debit"></td>
  378. <td v-html="creditHistory.credit"></td>
  379. </tr>
  380. </tbody>
  381. </table>
  382. </div>
  383. </div>
  384. </modal>
  385. </td>
  386. </tr>
  387. <tr class="view" v-if="showViewProduct && idOrderView == order.id">
  388. <td colspan="6">
  389. <strong><span class="glyphicon glyphicon-menu-right"></span> Produits</strong>
  390. <ul>
  391. <li v-for="product in products" v-if="order.productOrder[product.id].quantity > 0">
  392. {{ product.name }} : {{ order.productOrder[product.id].quantity }} {{ order.productOrder[product.id].unit == 'piece' ? ' pièce(s)' : ' '+order.productOrder[product.id].unit }} <span v-if="product.productDistribution[0].active == 0" class="glyphicon glyphicon-warning-sign" title="Ce produit n'est pas activé"></span>
  393. </li>
  394. </ul>
  395. <div v-if="order.comment && order.comment.length > 0" class="comment">
  396. <strong><span class="glyphicon glyphicon-menu-right"></span> Commentaire</strong><br />
  397. {{ order.comment }}
  398. </div>
  399. </td>
  400. </tr>
  401. </template>
  402. </tbody>
  403. </table>
  404. <div class="alert alert-warning" v-else>
  405. Aucune commande
  406. </div>
  407. </div>
  408. </div>
  409. </div>
  410. </div>
  411. <!-- template for the order-form component -->
  412. <script type="text/x-template" id="order-form-template">
  413. <modal class="modal-form-order" @close="$emit('close')">
  414. <h3 slot="header">Ajouter une commande</h3>
  415. <div slot="body">
  416. <div class="callout callout-warning" v-if="errors.length">
  417. <ul>
  418. <li v-for="error in errors">{{ error }}</li>
  419. </ul>
  420. </div>
  421. <div class="col-md-4">
  422. <div class="form-group">
  423. <label class="control-label" for="select-id-point-sale">Point de vente</label>
  424. <select class="form-control" id="select-id-point-sale" v-model="order.id_point_sale">
  425. <option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id">{{ pointSale.name }}</option>
  426. </select>
  427. </div>
  428. <div class="form-group">
  429. <label class="control-label" for="select-id-user">Utilisateur</label>
  430. <select class="form-control" v-model="order.id_user">
  431. <option v-for="user in users" :value="user.id_user">{{ user.lastname +' '+ user.name }}</option>
  432. </select>
  433. <input v-model="order.username" type="text" class="form-control" placeholder="Ou saisissez ici le nom de l'utilisateur" />
  434. </div>
  435. <div class="form-group">
  436. <label class="control-label" for="textarea-comment">Commentaire</label>
  437. <textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea>
  438. </div>
  439. </div>
  440. <div class="col-md-8">
  441. <label class="control-label">Produits</label>
  442. <table class="table table-condensed table-bordered table-hover table-products">
  443. <thead>
  444. <tr>
  445. <th></th>
  446. <th>Nom</th>
  447. <th>Quantité</th>
  448. <th>Reste</th>
  449. </tr>
  450. </thead>
  451. <tbody>
  452. <tr v-for="product in products" :class="(order.productOrder[product.id] > 0) ? 'product-ordered' : ''">
  453. <td>
  454. <span class="label label-success" v-if="product.productDistribution[0].active == 1">Actif</span>
  455. <span class="label label-danger" v-else>Inactif</span>
  456. </td>
  457. <td>{{ product.name }}</td>
  458. <td class="quantity">
  459. <div class="input-group">
  460. <span class="input-group-btn">
  461. <button class="btn btn-default btn-moins" type="button" @click="productQuantityClick(product.id, order.productOrder[product.id].unit == 'piece' ? -1 : -parseFloat(product.step))"><span class="glyphicon glyphicon-minus"></span></button>
  462. </span>
  463. <input type="text" v-model="order.productOrder[product.id].quantity" class="form-control" />
  464. <span class="input-group-addon">{{ order.productOrder[product.id].unit == 'piece' ? 'p.' : order.productOrder[product.id].unit }}</span>
  465. <span class="input-group-btn">
  466. <button class="btn btn-default btn-plus" type="button" @click="productQuantityClick(product.id, order.productOrder[product.id].unit == 'piece' ? 1 : parseFloat(product.step))"><span class="glyphicon glyphicon-plus"></span></button>
  467. </span>
  468. </div>
  469. </td>
  470. <td class="quantity-remaining infinite" v-if="product.quantity_remaining === null || order.productOrder[product.id].unit != product.unit">&infin;</td>
  471. <td class="quantity-remaining negative" v-else-if="product.quantity_remaining <= 0">{{ product.quantity_remaining }} {{ order.productOrder[product.id].unit == 'piece' ? ' p.' : ' '+(order.productOrder[product.id].unit == 'g' || order.productOrder[product.id].unit == 'kg') ? 'kg' : 'litre(s)' }}</td>
  472. <td class="quantity-remaining has-quantity" v-else>{{ product.quantity_remaining }} {{ order.productOrder[product.id].unit == 'piece' ? ' p.' : ' '+(order.productOrder[product.id].unit == 'g' || order.productOrder[product.id].unit == 'kg') ? 'kg' : 'litre(s)' }}</td>
  473. </tr>
  474. </tbody>
  475. </table>
  476. </div>
  477. </div>
  478. <div slot="footer">
  479. <div class="actions-form">
  480. <button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-if="!order.id && order.id_user" data-process-credit="1">Créer et payer</button>
  481. <button class="modal-default-button btn btn-primary" @click="submitFormUpdate" v-if="order.id && order.id_user" data-process-credit="1">Modifier et payer</button>
  482. <button class="modal-default-button btn btn-primary" @click="submitFormUpdate" v-if="order.id">Modifier</button>
  483. <button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-else>Créer</button>
  484. <button class="modal-default-button btn btn-default" @click="$emit('close')">Annuler</button>
  485. </div>
  486. </div>
  487. </modal>
  488. </script>
  489. <!-- template for the modal component -->
  490. <script type="text/x-template" id="modal-template">
  491. <transition name="modal">
  492. <div class="modal-mask">
  493. <div class="modal-wrapper">
  494. <div class="modal-container">
  495. <div class="modal-header">
  496. <slot name="header"></slot>
  497. </div>
  498. <div class="modal-body">
  499. <slot name="body"></slot>
  500. </div>
  501. <div class="modal-footer">
  502. <slot name="footer">
  503. <button class="modal-default-button btn btn-default" @click="$emit('close')">Fermer</button>
  504. </slot>
  505. </div>
  506. </div>
  507. </div>
  508. </div>
  509. </transition>
  510. </script>