Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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