Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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