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.

index.php 42KB

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