Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
3 лет назад
5 лет назад
5 лет назад
2 лет назад
5 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  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. <?php if($orderUpdate):
  37. $orderUpdateDistributionTimestamp = strtotime($orderUpdate->distribution->date);
  38. ?>
  39. <script>
  40. window.vueValues = {
  41. date: new Date(<?= date('Y', $orderUpdateDistributionTimestamp) ?>, <?= date('m', $orderUpdateDistributionTimestamp) - 1 ?>, <?= date('d', $orderUpdateDistributionTimestamp) ?>),
  42. dateFormat: '<?= date('d/m/Y', $orderUpdateDistributionTimestamp) ?>',
  43. showModalFormOrderUpdate: true,
  44. idOrderUpdate: <?= $orderUpdate->id ?>
  45. };
  46. </script>
  47. <?php endif; ?>
  48. <div id="app-distribution-index" class="app-vuejs">
  49. <?php if(strlen($date)): ?>
  50. <span id="distribution-date"><?= $date; ?></span>
  51. <?php endif; ?>
  52. <div id="loading" v-if="showLoading">
  53. <img src="<?= Yii::$app->urlManagerBackend->getBaseUrl(); ?>/img/loader.gif" alt="Chargement ..." />
  54. </div>
  55. <div id="wrapper-app-distribution-index" :class="'wrapper-app-vuejs '+(loading ? '' : 'loaded')">
  56. <div class="col-md-4">
  57. <div id="calendar">
  58. <v-date-picker
  59. is-inline
  60. is-expanded
  61. v-model="date"
  62. popover-visibility="hidden"
  63. firstDayOfWeek="1"
  64. :mode="calendar.mode"
  65. :formats="calendar.formats"
  66. :theme-styles="calendar.themeStyles"
  67. :attributes="calendar.attrs"
  68. @dayclick='dayClicked'>
  69. ></v-date-picker>
  70. </div>
  71. <div class="clr"></div>
  72. </div>
  73. <div class="col-md-8">
  74. <div v-if="date">
  75. <div id="infos-top">
  76. <div class="col-md-12">
  77. <div class="info-box" id="info-box-distribution">
  78. <span :class="'info-box-icon '+(distribution.active ? 'bg-green' : 'bg-red')"><i :class="'fa '+(distribution.active ? 'fa-check' : 'fa-remove')"></i></span>
  79. <div class="info-box-content">
  80. <span class="info-box-text">
  81. <h4>Distribution du <strong>{{ dateFormat }}</strong></h4>
  82. <a @click="activeWeekDistribution" data-active="0" class="btn btn-default btn-active-week" v-if="oneDistributionWeekActive">Désactiver cette semaine</a>
  83. <a @click="activeWeekDistribution" data-active="1" class="btn btn-default btn-active-week" v-else>Activer cette semaine</a>
  84. <a @click="activeDistribution" data-active="0" class="btn btn-default" v-if="distribution.active">Désactiver ce jour</a>
  85. <a @click="activeDistribution" data-active="1" class="btn btn-default" v-else>Activer ce jour</a>
  86. </span>
  87. </div>
  88. </div>
  89. </div>
  90. <!-- produits -->
  91. <div class="col-md-6">
  92. <div class="info-box col-md-4">
  93. <span class="info-box-icon bg-yellow"><i class="fa fa-clone"></i></span>
  94. <div class="info-box-content">
  95. <span class="info-box-text">
  96. {{ countActiveProducts }} Produits<br /><br />
  97. <button class="btn btn-default" @click="showModalProducts = true">Configurer</button>
  98. </span>
  99. </div>
  100. </div>
  101. </div>
  102. <modal v-if="showModalProducts" id="modal-products" @close="showModalProducts = false">
  103. <h3 slot="header">Produits</h3>
  104. <div slot="body">
  105. <table class="table table-condensed table-bordered table-hover">
  106. <thead>
  107. <tr>
  108. <td>Actif</td>
  109. <td>Nom</td>
  110. <td class="quantity-ordered">Commandé</td>
  111. <td class="quantity-max">Maximum</td>
  112. </tr>
  113. </thead>
  114. <tbody>
  115. <tr v-for="product in products">
  116. <td>
  117. <button class="btn btn-success" v-if="product.productDistribution[0].active == 1"><span class="glyphicon glyphicon-ok"></span></button>
  118. <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>
  119. <button class="btn btn-danger" v-if="product.productDistribution[0].active == 0"><span class="glyphicon glyphicon-remove"></span></button>
  120. <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>
  121. </td>
  122. <td>{{ product.name }}</td>
  123. <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>
  124. <td class="quantity-max">
  125. <div class="input-group">
  126. <input type="text" class="form-control quantity-max" placeholder="&infin;" :data-id-product="product.id" v-model="product.productDistribution[0].quantity_max" @keyup="productQuantityMaxChange" />
  127. <span class="input-group-addon">{{ (product.unit == 'piece') ? 'p.' : ' '+((product.unit == 'g' || product.unit == 'kg') ? 'kg' : 'litre(s)') }}</span>
  128. </div>
  129. </td>
  130. </tr>
  131. </tbody>
  132. </table>
  133. </div>
  134. <div slot="footer">
  135. <div class="actions-form">
  136. <button class="modal-default-button btn btn-default" @click="closeModalProducts">Fermer</button>
  137. </div>
  138. </div>
  139. </modal>
  140. <div class="col-md-6">
  141. <div class="info-box col-md-4">
  142. <span class="info-box-icon bg-yellow"><i class="fa fa-map-marker"></i></span>
  143. <div class="info-box-content">
  144. <span class="info-box-text">
  145. {{ countActivePointsSale }} Points de vente<br /><br />
  146. <button class="btn btn-default" @click="showModalPointsSale = true">Configurer</button>
  147. </span>
  148. </div>
  149. </div>
  150. </div>
  151. <modal v-if="showModalPointsSale" id="modal-points-sale" @close="showModalPointsSale = false">
  152. <h3 slot="header">Points de vente</h3>
  153. <div slot="body">
  154. <table class="table table-condensed table-bordered table-hover">
  155. <thead>
  156. <tr>
  157. <td>Actif</td>
  158. <td>Nom</td>
  159. </tr>
  160. </thead>
  161. <tbody>
  162. <tr v-for="pointSale in pointsSale" v-if="pointSale.status == 1">
  163. <td>
  164. <button class="btn btn-success" v-if="pointSale.pointSaleDistribution[0].delivery == 1"><span class="glyphicon glyphicon-ok"></span></button>
  165. <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>
  166. <button class="btn btn-danger" v-if="pointSale.pointSaleDistribution[0].delivery == 0"><span class="glyphicon glyphicon-remove"></span></button>
  167. <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>
  168. </td>
  169. <td>{{ pointSale.name }}</td>
  170. </tr>
  171. </tbody>
  172. </table>
  173. </div>
  174. </modal>
  175. <div class="col-md-6">
  176. <div id="summary-ca-weight" class="info-box col-md-4">
  177. <span class="info-box-icon bg-yellow"><i class="fa fa-euro"></i></span>
  178. <div class="info-box-content">
  179. <span class="info-box-text">CA (TTC)</span>
  180. <span class="info-box-number">{{ distribution.revenues }} <span class="normal" v-if="distribution.potential_revenues != '0,00 €'">/ {{ distribution.potential_revenues }}</span></span>
  181. <span class="info-box-text">Poids</span>
  182. <span class="info-box-number">{{ distribution.weight }} kg <span class="normal" v-if="distribution.potential_weight > 0">/ {{ distribution.potential_weight }} kg</span></span>
  183. </div>
  184. </div>
  185. </div>
  186. <div class="col-md-6">
  187. <div class="info-box col-md-4">
  188. <span class="info-box-icon bg-yellow"><i class="fa fa-download"></i></span>
  189. <div class="info-box-content">
  190. <span class="info-box-text">
  191. {{ countOrders }} Commande<span v-if="countOrders > 1">s</span><br />
  192. <a :href="distribution.url_report" class="btn btn-xs btn-default" v-if="countOrders > 0">Liste (PDF)</a>
  193. <a :href="distribution.url_report+'&type=csv'" class="btn btn-xs btn-default" v-if="countOrders > 0">Tableau (CSV)</a>
  194. <br v-if="producer && producer.option_display_export_grid && countOrders > 0" />
  195. <a :href="distribution.url_report_grid" class="btn btn-xs btn-default" v-if="producer && producer.option_display_export_grid && countOrders > 0">Grille (PDF)</a>
  196. </span>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <div class="callout callout-info" v-else>
  203. <h4><i class="fa fa-info"></i> Pour commencer</h4>
  204. <p>Veuillez choisir une date de distribution.</p>
  205. </div>
  206. </div>
  207. <div class="clr"></div>
  208. <div id="orders" class="panel panel-default" v-if="date">
  209. <div class="panel-heading">
  210. <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>
  211. <div class="buttons">
  212. </div>
  213. </div>
  214. <div class="panel-body">
  215. <order-form
  216. v-if="showModalFormOrderCreate"
  217. :date="date"
  218. :order="orderCreate"
  219. :points-sale="pointsSale"
  220. :id-active-point-sale="idActivePointSale"
  221. :means-payment="meansPayment"
  222. :users="users"
  223. :products="products"
  224. :producer="producer"
  225. :loading-update-product-order="loadingUpdateProductOrder"
  226. @close="showModalFormOrderCreate = false"
  227. @ordercreatedupdated="orderCreatedUpdated"
  228. @updateproductorderprices="updateProductOrderPrices"
  229. ></order-form>
  230. <div id="wrapper-nav-points-sale">
  231. <ul id="nav-points-sale">
  232. <li data-id-point-sale="0" data-id-point-sale="0" v-if="countActivePointsSale > 1" @click="pointSaleClick">
  233. <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>
  234. <a class="btn btn-default" v-else>Tous <span class="label label-default">{{ orders.length }}</span><span class="glyphicon glyphicon-triangle-bottom"></span></a>
  235. </li>
  236. <li v-for="pointSale in pointsSale" :data-id-point-sale="pointSale.id" v-if="pointSale.pointSaleDistribution[0].delivery == 1" @click="pointSaleClick">
  237. <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>
  238. <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>
  239. </li>
  240. </ul>
  241. <div class="clr"></div>
  242. </div>
  243. <div id="buttons-top-orders">
  244. <div class="right">
  245. <div class="dropdown">
  246. <button class="btn btn-default btn-xs dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
  247. <span class="glyphicon glyphicon-file"></span> Documents
  248. <span class="caret"></span>
  249. </button>
  250. <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
  251. <li><a v-if="idActivePointSale > 0" @click="generateDeliveryNote" href="javascript:void(0);" >Générer un bon de livraison pour ce point de vente</a></li>
  252. <li><a @click="generateDeliveryNoteEachUser" href="javascript:void(0);">Générer un bon de livraison pour chaque client</a></li>
  253. <li><a @click="validateDeliveryNotes" href="javascript:void(0);">Valider les bons de livraisons</a></li>
  254. </ul>
  255. </div>
  256. <button id="btn-add-subscriptions" @click="addSubscriptions" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-plus"></span> Importer les abonnements</button>
  257. <template v-if="producer && producer.tiller == true">
  258. <button v-if="tillerIsSynchro" id="btn-tiller" class="btn btn-success btn-xs" disabled><span class="glyphicon glyphicon-refresh"></span> Synchronisé avec Tiller</button>
  259. <button v-else id="btn-tiller" class="btn btn-xs btn-default" @click="synchroTiller"><span class="glyphicon glyphicon-refresh"></span> Synchroniser avec Tiller</button>
  260. </template>
  261. <button v-if="producer && producer.credit" id="btn-pay-orders" class="btn btn-default btn-xs" @click="payOrders"><span class="glyphicon glyphicon-euro"></span> Payer les commandes</button>
  262. <button id="btn-add-order" @click="openModalFormOrderCreate" class="btn btn-xs btn-primary"><span class="glyphicon glyphicon-plus"></span> Ajouter une commande</button>
  263. </div>
  264. <div class="left">
  265. <a v-if="false && deliveryNoteExist(idActivePointSale)" :href="UrlManager.getBaseUrl()+'delivery-note/update?id='+deliveryNotes[idActivePointSale].id" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-file"></span> Bon de livraison</a>
  266. </div>
  267. <div class="clr"></div>
  268. </div>
  269. <div class="alert alert-danger" v-if="missingSubscriptions && missingSubscriptions.length > 0">
  270. {{ missingSubscriptions.length }} abonnement<template v-if="missingSubscriptions.length > 1">s</template> manquant<template v-if="missingSubscriptions.length > 1">s</template> :
  271. <ul>
  272. <li v-for="subscription in missingSubscriptions">{{ subscription.username }}</li>
  273. </ul>
  274. </div>
  275. <div class="alert alert-danger" v-if="distribution && !distribution.active && orders && orders.length > 0">
  276. Attention, ce jour de distribution n'est pas activé et vous avez quand même des commandes enregistrées.
  277. </div>
  278. <div v-if="idActivePointSale > 0 && (totalActivePointSale() > 0 || weightActivePointSale() > 0)" class="point-sale-totals">
  279. <span class="title">Totaux</span>
  280. CA TTC : <strong>{{ totalActivePointSale() }} €</strong> / Poids : <strong>{{ weightActivePointSale() }} kg</strong>
  281. </div>
  282. <table class="table table-condensed table-bordered table-hover" v-if="countOrdersByPointSale[idActivePointSale] > 0 || (idActivePointSale == 0 && orders.length > 0)">
  283. <thead>
  284. <tr>
  285. <th class="column-checkbox" v-if="idActivePointSale > 0">
  286. <input type="checkbox" v-model="checkboxSelectAllOrders" @change="selectAllOrdersEvent" />
  287. </th>
  288. <th class="column-origin">Origine</th>
  289. <th class="column-state">État</th>
  290. <th class="column-user">Utilisateur</th>
  291. <th class="column-point-sale" v-if="idActivePointSale == 0">Point de vente</th>
  292. <th class="column-amount">Montant</th>
  293. <th class="column-state-payment">Paiement</th>
  294. <th class="column-payment"></th>
  295. <th class="column-tiller" v-if="producer && producer.tiller">Tiller</th>
  296. <th class="column-actions"></th>
  297. <th class="column-delivery-note"></th>
  298. </tr>
  299. </thead>
  300. <tbody>
  301. <template v-for="(order, key, index) in orders" v-if="idActivePointSale == 0 || idActivePointSale == order.id_point_sale">
  302. <tr>
  303. <td class="column-checkbox" v-if="idActivePointSale > 0">
  304. <input type="checkbox" v-model="order.selected" />
  305. </td>
  306. <td class="column-origin">
  307. <label class="label label-success" v-if="order.origin == 'user'">client</label>
  308. <label class="label label-default" v-else-if="order.origin == 'auto'">auto</label>
  309. <label class="label label-warning" v-else>admin</label>
  310. </td>
  311. <td class="column-state">
  312. <span class="label label-danger" v-if="order.date_delete"><span class="glyphicon glyphicon-trash"></span></span>
  313. <span class="label label-warning" v-if="order.date_update"><span class="glyphicon glyphicon-pencil"></span></span>
  314. <span class="label label-success" v-if="!order.date_update && !order.date_delete"><span class="glyphicon glyphicon-check"></span></span>
  315. </td>
  316. <td class="column-user">
  317. <span v-if="order.user">
  318. <template v-if="order.user.name_legal_person && order.user.name_legal_person.length">
  319. {{ order.user.name_legal_person }}
  320. </template>
  321. <template v-else>
  322. {{ order.user.lastname+' '+order.user.name }}
  323. </template>
  324. </span>
  325. <span v-else>{{ order.username }}</span>
  326. <span v-if="order.comment && order.comment.length > 0" class="glyphicon glyphicon-comment"></span>
  327. <span v-if="order.delivery_home && order.delivery_address && order.delivery_address.length > 0" class="glyphicon glyphicon-home"></span>
  328. </td>
  329. <td class="column-point-sale" v-if="idActivePointSale == 0">
  330. <template v-if="order.pointSale">
  331. {{ order.pointSale.name }}
  332. </template>
  333. </td>
  334. <td class="column-amount">
  335. {{ order.amount.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}
  336. </td>
  337. <td class="column-state-payment">
  338. <div class="input-group">
  339. <span class="label label-success input-group-addon" v-if="order.amount_paid == order.amount">payé</span>
  340. <span class="label label-default input-group-addon" v-else-if="order.amount_paid == 0">non réglé</span>
  341. <span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span>
  342. <span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à payer</span>
  343. <span class="glyphicon glyphicon-time" title="Paiement automatique" v-if="order.auto_payment && producer && producer.credit && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>
  344. </div>
  345. </td>
  346. <td class="column-payment" v-if="producer && producer.credit">
  347. <div class="btn-group" v-if="order.user && !order.date_delete">
  348. <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">
  349. <span class="glyphicon glyphicon-euro"></span> Rembourser
  350. </button>
  351. <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">
  352. <span class="glyphicon glyphicon-euro"></span> Payer
  353. </button>
  354. <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">
  355. <span class="glyphicon glyphicon-euro"></span> Payer
  356. </button>
  357. <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">
  358. <span class="glyphicon glyphicon-euro"></span> Rembourser
  359. </button>
  360. <button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  361. <span class="caret"></span>
  362. <span class="sr-only">Toggle Dropdown</span>
  363. </button>
  364. <ul class="dropdown-menu">
  365. <li><a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">Historique</a></li>
  366. </ul>
  367. </div>
  368. </td>
  369. <td v-if="producer && producer.tiller" class="tiller column-tiller">
  370. <input v-if="order.tiller_synchronization == true" type="checkbox" checked="checked" :id="'checkbox-tiller-synchronization-'+order.id" :data-id-order="order.id" @change="changeSynchroTiller" />
  371. <input v-else type="checkbox" :id="'checkbox-tiller-synchronization-'+order.id" :data-id-order="order.id" @change="changeSynchroTiller" />
  372. <label :for="'checkbox-tiller-synchronization-'+order.id">Tiller</label>
  373. </td>
  374. <td class="column-actions">
  375. <span v-if="order.oneProductUnactivated" class="glyphicon glyphicon-warning-sign" title="Contient un produit non activé"></span>
  376. <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  377. Action <span class="caret"></span>
  378. </button>
  379. <ul class="dropdown-menu">
  380. <li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="orderViewClick"><span :class="'glyphicon ' + ((showViewProduct && idOrderView == order.id) ? 'glyphicon-eye-close' : 'glyphicon-eye-open')"></span> Voir</a></li>
  381. <li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="updateOrderClick"><span class="glyphicon glyphicon-pencil"></span> Modifier</a></li>
  382. <li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="deleteOrderClick"><span class="glyphicon glyphicon-trash"></span> Supprimer</a></li>
  383. <li v-if="order.id_subscription > 0"><a class="" :href="baseUrl+'/subscription/update?id='+order.id_subscription"><span class="glyphicon glyphicon-repeat"></span> Modifier l'abonnement associé</a></li>
  384. <li v-else><a class="add-subscription" :href="baseUrl+'/subscription/create?idOrder='+order.id"><span class="glyphicon glyphicon-plus"></span><span class="glyphicon glyphicon-repeat"></span>Créer un abonnement sur cette base</a></li>
  385. </ul>
  386. <order-form
  387. v-if="showModalFormOrderUpdate && idOrderUpdate == order.id"
  388. :date="date"
  389. :date-format="dateFormat"
  390. :points-sale="pointsSale"
  391. :id-active-point-sale="idActivePointSale"
  392. :means-payment="meansPayment"
  393. :users="users"
  394. :products="products"
  395. :order="ordersUpdate[key]"
  396. :producer="producer"
  397. :loading-update-product-order="loadingUpdateProductOrder"
  398. @close="showModalFormOrderUpdate = false"
  399. @ordercreatedupdated="orderCreatedUpdated"
  400. @updateproductorderprices="updateProductOrderPrices"
  401. @updateinvoiceprices="updateInvoicePrices"
  402. ></order-form>
  403. <modal v-if="showModalPayment && idOrderPayment == order.id" class="modal-payment" @close="showModalPayment = false">
  404. <h3 slot="header">
  405. Commande du <strong>{{ dateFormat }}</strong> &gt;
  406. <strong><span v-if="order.user">{{ order.user.name +' '+order.user.lastname }}</span>
  407. <span v-else>{{ order.username }}</span></strong>
  408. </h3>
  409. <div slot="body">
  410. <div class="col-md-4">
  411. <div class="info-box">
  412. <span :class="'info-box-icon ' +((order.amount_paid == order.amount) ? 'bg-green' : 'bg-red')"><i class="fa fa-check"></i></span>
  413. <div class="info-box-content">
  414. <span class="info-box-text">Montant</span>
  415. <span class="info-box-number">{{ order.amount.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}</span>
  416. <span class="info-box-text">
  417. Statut<br />
  418. <span class="label label-success" v-if="order.amount_paid == order.amount">payé</span>
  419. <span class="label label-default" v-else-if="order.amount_paid == 0">non réglé</span>
  420. <span class="label label-default" v-else-if="order.amount_paid > order.amount">surplus</span>
  421. <span class="label label-warning" v-else-if="order.amount_paid < order.amount">reste à payer</span>
  422. </span>
  423. </div>
  424. </div>
  425. <div class="info-box">
  426. <span :class="'info-box-icon ' +((order.user.credit > 0) ? 'bg-green' : 'bg-red')"><i class="fa fa-user"></i></span>
  427. <div class="info-box-content">
  428. <span class="info-box-text">Crédit utilisateur</span>
  429. <span class="info-box-number">{{ order.user.credit.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}</span>
  430. </div>
  431. </div>
  432. <button v-if="order.amount_paid == order.amount"
  433. class="btn btn-default"
  434. :data-amount="order.amount"
  435. data-type="refund"
  436. @click="orderPaymentClick" >
  437. <span class="glyphicon glyphicon-chevron-right"></span>
  438. Rembourser {{ order.amount.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
  439. </button>
  440. <button v-else-if="order.amount_paid == 0"
  441. class="btn btn-default"
  442. :data-amount="order.amount"
  443. data-type="payment"
  444. @click="orderPaymentClick">
  445. <span class="glyphicon glyphicon-chevron-right"></span>
  446. Payer {{ order.amount.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
  447. </button>
  448. <button v-else-if="order.amount_paid > order.amount"
  449. class="btn btn-default"
  450. :data-amount="order.amount_surplus"
  451. data-type="refund"
  452. @click="orderPaymentClick">
  453. <span class="glyphicon glyphicon-chevron-right"></span>
  454. Rembourser {{ order.amount_surplus.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
  455. </button>
  456. <button v-else-if="order.amount_paid < order.amount"
  457. class="btn btn-default"
  458. :data-amount="order.amount_remaining"
  459. data-type="payment"
  460. @click="orderPaymentClick">
  461. <span class="glyphicon glyphicon-chevron-right"></span>
  462. Payer le restant {{ order.amount_remaining.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
  463. </button>
  464. </div>
  465. <div class="col-md-8">
  466. <h4>Historique paiement</h4>
  467. <table class="table table-condensed table-bordered table-hover">
  468. <thead>
  469. <tr>
  470. <td>Date</td>
  471. <td>Utilisateur</td>
  472. <td>Action</td>
  473. <td>Origine action</td>
  474. <td>- Débit</td>
  475. <td>+ Crédit</td>
  476. </tr>
  477. </thead>
  478. <tbody>
  479. <tr v-for="creditHistory in order.creditHistory">
  480. <td>{{ creditHistory.date }}</td>
  481. <td>{{ creditHistory.user }}</td>
  482. <td v-html="creditHistory.wording"></td>
  483. <td>{{ creditHistory.user_action }}</td>
  484. <td v-html="creditHistory.debit"></td>
  485. <td v-html="creditHistory.credit"></td>
  486. </tr>
  487. </tbody>
  488. </table>
  489. </div>
  490. </div>
  491. </modal>
  492. </td>
  493. <td class="column-delivery-note">
  494. <a v-if="order.id_delivery_note" class="btn btn-default btn-xs" :href="UrlManager.getBaseUrl()+'delivery-note/update?id='+order.id_delivery_note">
  495. <span class="glyphicon glyphicon-file"></span> BL #{{ order.id_delivery_note }}
  496. </a>
  497. </td>
  498. </tr>
  499. <tr class="view" v-if="showViewProduct && idOrderView == order.id">
  500. <td colspan="6">
  501. <strong><span class="glyphicon glyphicon-menu-right"></span> Produits</strong>
  502. <ul>
  503. <li v-for="product in products" v-if="order.productOrder[product.id].quantity > 0">
  504. {{ 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>
  505. </li>
  506. </ul>
  507. <div v-if="order.comment && order.comment.length > 0" class="comment">
  508. <strong><span class="glyphicon glyphicon-menu-right"></span> Commentaire</strong><br />
  509. {{ order.comment }}
  510. </div>
  511. <div v-if="order.delivery_home && order.delivery_address && order.delivery_address.length > 0" class="delivery">
  512. <strong><span class="glyphicon glyphicon-menu-right"></span> Livraison à domicile</strong><br />
  513. {{ order.delivery_address }}
  514. </div>
  515. </td>
  516. </tr>
  517. </template>
  518. <!--<tr v-if="idActivePointSale > 0">
  519. <td colspan="4"><strong>Total (TTC)</strong></td>
  520. <td><strong>{{ totalActivePointSale() }}</strong></td>
  521. <td colspan="3"></td>
  522. </tr>-->
  523. </tbody>
  524. </table>
  525. <div class="alert alert-warning" v-else>
  526. Aucune commande
  527. </div>
  528. </div>
  529. </div>
  530. </div>
  531. </div>
  532. <!-- template for the order-form component -->
  533. <script type="text/x-template" id="order-form-template">
  534. <modal class="modal-form-order" @close="$emit('close')">
  535. <h3 v-if="order.id" slot="header">
  536. <template v-if="order.id">Modifier</template>
  537. <template v-else>Ajouter</template>
  538. une commande - {{ dateFormat }}
  539. </h3>
  540. <div slot="body">
  541. <div class="callout callout-warning" v-if="errors.length">
  542. <ul>
  543. <li v-for="error in errors">{{ error }}</li>
  544. </ul>
  545. </div>
  546. <div class="col-md-4">
  547. <div class="form-group">
  548. <a v-if="producer && 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>
  549. <label class="control-label" for="select-id-user">
  550. Utilisateur
  551. </label>
  552. <select class="form-control select2-order-form" v-model="order.id_user" @change="userChange">
  553. <option value="0">--</option>
  554. <option v-for="user in users" :value="user.id_user">
  555. <template v-if="user.name_legal_person && user.name_legal_person.length">
  556. Personne morale / {{ user.name_legal_person }}
  557. </template>
  558. <template v-else>
  559. {{ user.lastname +' '+ user.name }}
  560. </template>
  561. </option>
  562. </select>
  563. <input v-model="order.username" type="text" class="form-control" placeholder="Ou saisissez ici le nom de l'utilisateur" />
  564. </div>
  565. <div class="form-group">
  566. <label class="control-label" for="select-id-point-sale">Point de vente</label>
  567. <select class="form-control" id="select-id-point-sale" v-model="order.id_point_sale" @change="pointSaleChange">
  568. <option value="0">--</option>
  569. <option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id"">{{ pointSale.name }}</option>
  570. </select>
  571. </div>
  572. <div class="form-group">
  573. <label class="control-label" for="select-mean-payment">Moyen de paiement</label>
  574. <select class="form-control" id="select-mean-payment" v-model="order.mean_payment">
  575. <option value="0">--</option>
  576. <option v-for="(wordingMeanPayment, keyMeanPayment) in meansPayment" :value="keyMeanPayment">{{ wordingMeanPayment }}</option>
  577. </select>
  578. </div>
  579. <div class="form-group">
  580. <label class="control-label" for="textarea-comment">Commentaire</label>
  581. <textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea>
  582. </div>
  583. </div>
  584. <div class="col-md-8">
  585. <label class="control-label">Produits</label>
  586. <table class="table table-condensed table-bordered table-hover table-products">
  587. <thead>
  588. <tr>
  589. <th></th>
  590. <th>Nom</th>
  591. <th>Prix unitaire</th>
  592. <th>Quantité</th>
  593. <th>Reste</th>
  594. </tr>
  595. </thead>
  596. <tbody>
  597. <tr v-for="product in products" :class="(order.productOrder[product.id].quantity > 0) ? 'product-ordered' : ''">
  598. <td>
  599. <span class="label label-success" v-if="loadingUpdateProductOrder || order.productOrder[product.id].active">Actif</span>
  600. <span class="label label-danger" v-else>Inactif</span>
  601. </td>
  602. <td>{{ product.name }}</td>
  603. <td class="price">
  604. <div v-show="vatMode == 'all'" class="input-group">
  605. <input type="text" v-model="order.productOrder[product.id].price" class="form-control input-sm" @change="productPriceChange" :data-with-tax="false" :data-id-product="product.id" />
  606. <span class="input-group-addon" id="basic-addon2">€ HT&nbsp;&nbsp;</span>
  607. </div>
  608. <div class="input-group">
  609. <input type="text" v-model="order.productOrder[product.id].price_with_tax" class="form-control input-sm" @change="productPriceChange" :data-with-tax="true" :data-id-product="product.id" />
  610. <span class="input-group-addon" id="basic-addon2">€ TTC</span>
  611. </div>
  612. <div v-if="(order.id_invoice || order.id_delivery_note || order.id_quotation) && order.productOrder[product.id].quantity > 0">
  613. <span class="label label-default">
  614. Facturé
  615. <template v-if="order.productOrder[product.id].invoice_price != null">{{ order.productOrder[product.id].invoice_price }}</template>
  616. <template v-else>{{ order.productOrder[product.id].price }}</template>
  617. € HT
  618. </span>
  619. </div>
  620. </td>
  621. <td class="quantity">
  622. <div class="input-group">
  623. <span class="input-group-btn">
  624. <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>
  625. </span>
  626. <input type="text" v-model="order.productOrder[product.id].quantity" class="form-control input-quantity" />
  627. <span class="input-group-addon">{{ order.productOrder[product.id].unit == 'piece' ? 'p.' : order.productOrder[product.id].unit }}</span>
  628. <span class="input-group-btn">
  629. <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>
  630. </span>
  631. </div>
  632. </td>
  633. <td class="quantity-remaining infinite" v-if="product.quantity_remaining === null || order.productOrder[product.id].unit != product.unit">&infin;</td>
  634. <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>
  635. <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>
  636. </tr>
  637. </tbody>
  638. </table>
  639. </div>
  640. </div>
  641. <div slot="footer">
  642. <div class="actions-form">
  643. <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>
  644. <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>
  645. <button class="modal-default-button btn btn-primary" @click="submitFormUpdate" v-if="order.id">Modifier</button>
  646. <button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-if="!order.id">Créer</button>
  647. <button class="modal-default-button btn btn-danger" @click="$emit('close')">Fermer</button>
  648. <div class="right">
  649. <button class="modal-default-button btn btn-info btn-update-prices" @click="updateProductOrderPrices(true)">Recharger les prix</button>
  650. <button v-if="order.id" class="modal-default-button btn btn-info btn-update-prices" @click="updateInvoicePrices(true)">
  651. Réinitialiser les prix facturés
  652. </button>
  653. <button class="modal-default-button btn btn-info btn-display-prices-without-tax" @click="toggleVatMode()">
  654. <template v-if="vatMode == 'all'">Cacher</template>
  655. <template v-else>Afficher</template>
  656. les prix HT
  657. </button>
  658. </div>
  659. </div>
  660. </div>
  661. </modal>
  662. </script>
  663. <!-- template for the modal component -->
  664. <script type="text/x-template" id="modal-template">
  665. <transition name="modal">
  666. <div class="modal-mask">
  667. <div class="modal-wrapper">
  668. <div class="modal-container">
  669. <div class="modal-header">
  670. <slot name="header"></slot>
  671. </div>
  672. <div class="modal-body">
  673. <slot name="body"></slot>
  674. </div>
  675. <div class="modal-footer">
  676. <slot name="footer">
  677. <button class="modal-default-button btn btn-default" @click="$emit('close')">Fermer</button>
  678. </slot>
  679. </div>
  680. </div>
  681. </div>
  682. </div>
  683. </transition>
  684. </script>