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.

783 rindas
58KB

  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" target="_blank" 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. <template v-if="!order.date_delete">
  374. <a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">
  375. <order-state-payment :order="order" :producer="producer"></order-state-payment>
  376. </a>
  377. <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>
  378. </template>
  379. </td>
  380. <td class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.credit == 1)">
  381. <template v-if="order.isCreditContext">
  382. <a :href="baseUrl+'/user/credit?id='+order.id_user" :class="order.user.credit >= 0 ? 'positive' : 'negative'">
  383. {{ order.user.credit.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+'&nbsp;€' }}
  384. </a>
  385. </template>
  386. </td>
  387. <td class="column-actions">
  388. <span v-if="false && order.oneProductUnactivated" class="glyphicon glyphicon-warning-sign" title="Contient un produit non activé"></span>
  389. <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>
  390. <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>
  391. <div class="wrapper-button-dropdown">
  392. <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  393. € <span class="caret"></span>
  394. </button>
  395. <ul class="dropdown-menu">
  396. <template v-if="!order.isPaidViaInvoice">
  397. <li v-if="order.isCreditContext">
  398. <a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="credit">
  399. <span class="glyphicon glyphicon-piggy-bank"></span> {{ getLabelPaymentRefund(order, 'Débiter', 'Recréditer', 'le crédit') }}
  400. </a>
  401. </li>
  402. <template v-if="(!order.isCreditFunctioningMandatory && !order.isCreditFunctioningUser) || !order.id_user">
  403. <li>
  404. <a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="money">
  405. <span class="glyphicon glyphicon-euro"></span> {{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'en espèce') }}
  406. </a>
  407. </li>
  408. <li>
  409. <a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="cheque">
  410. <span class="glyphicon glyphicon-euro"></span> {{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'par chèque') }}
  411. </a>
  412. </li>
  413. <li>
  414. <a href="javascript:void(0);" @click="orderPaymentClick" :data-id-order="order.id" :data-type="getTypePayment(order)" data-mean-payment="transfer">
  415. <span class="glyphicon glyphicon-euro"></span> {{ getLabelPaymentRefund(order, 'Payer', 'Rembourser', 'par virement') }}
  416. </a>
  417. </li>
  418. </template>
  419. </template>
  420. <li>
  421. <a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">
  422. <span class="glyphicon glyphicon-th-list"></span> Historique
  423. </a>
  424. </li>
  425. </ul>
  426. </div>
  427. <div class="wrapper-button-dropdown">
  428. <button type="button" :class="'btn btn-xs dropdown-toggle ' + (countDocuments(order) ? 'btn-success' : 'btn-default')" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  429. <span class="glyphicon glyphicon-file"></span> <template v-if="countDocuments(order)">{{ countDocuments(order) }}</template> <span class="caret"></span>
  430. </button>
  431. <ul class="dropdown-menu">
  432. <li v-if="!order.id_delivery_note">
  433. <a href="javascript:void(0);" class="" :data-id-order="order.id" @click="generateDeliveryNote">
  434. <span class="glyphicon glyphicon-plus"></span> Générer un bon de livraison
  435. </a>
  436. </li>
  437. <li v-if="order.id_quotation">
  438. <a :href="UrlManager.getBaseUrl()+'quotation/update?id='+order.id_quotation">
  439. <span class="glyphicon glyphicon-file"></span> Devis
  440. </a>
  441. </li>
  442. <li v-if="order.id_delivery_note">
  443. <a :href="UrlManager.getBaseUrl()+'delivery-note/update?id='+order.id_delivery_note">
  444. <span class="glyphicon glyphicon-file"></span> Bon de livraison
  445. </a>
  446. </li>
  447. <li v-if="order.id_invoice">
  448. <a :href="UrlManager.getBaseUrl()+'invoice/update?id='+order.id_invoice">
  449. <span class="glyphicon glyphicon-file"></span> Facture
  450. </a>
  451. </li>
  452. </ul>
  453. </div>
  454. <div class="wrapper-button-dropdown">
  455. <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  456. <span class="caret"></span>
  457. </button>
  458. <ul class="dropdown-menu">
  459. <li><a href="javascript:void(0);" class="" :data-id-order="order.id" @click="deleteOrderClick"><span class="glyphicon glyphicon-trash"></span> Supprimer</a></li>
  460. <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>
  461. <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>
  462. </ul>
  463. </div>
  464. <order-form
  465. v-if="showModalFormOrderUpdate && idOrderUpdate == order.id"
  466. create="0"
  467. :date="date"
  468. :date-format="dateFormat"
  469. :points-sale="pointsSale"
  470. :id-active-point-sale="idActivePointSale"
  471. :means-payment="meansPayment"
  472. :users="users"
  473. :products="products"
  474. :order="ordersUpdate[key]"
  475. :orders="ordersUpdate"
  476. :producer="producer"
  477. :loading-update-product-order="loadingUpdateProductOrder"
  478. :units="units"
  479. @close="closeModalOrderForm(false)"
  480. @ordercreatedupdated="orderCreatedUpdated"
  481. @updateproductorderprices="updateProductOrderPrices"
  482. @updateinvoiceprices="updateInvoicePrices"
  483. ></order-form>
  484. <modal v-if="showModalPayment && idOrderPayment == order.id" class="modal-payment" @close="showModalPayment = false">
  485. <h3 slot="header">
  486. Commande du <strong>{{ dateFormat }}</strong> &gt;
  487. <strong><span v-if="order.user">{{ order.user.name +' '+order.user.lastname }}</span>
  488. <span v-else>{{ order.username }}</span></strong>
  489. </h3>
  490. <div slot="body">
  491. <div class="row">
  492. <div class="col-md-6">
  493. <div class="info-box">
  494. <span :class="'info-box-icon ' +((order.isPaid) ? 'bg-green' : 'bg-red')"><i class="fa fa-check"></i></span>
  495. <div class="info-box-content">
  496. <span class="info-box-text">Montant</span>
  497. <span class="info-box-number">
  498. {{ order.amount.toFixed(2)+' €' }}
  499. </span>
  500. </div>
  501. </div>
  502. </div>
  503. <div class="col-md-6" v-if="order.isCreditContext">
  504. <div class="info-box">
  505. <span :class="'info-box-icon ' +((order.user.credit > 0) ? 'bg-green' : 'bg-red')"><i class="fa fa-user"></i></span>
  506. <div class="info-box-content">
  507. <span class="info-box-text">Crédit utilisateur</span>
  508. <span class="info-box-number">
  509. {{ order.user.credit.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}
  510. </span>
  511. </div>
  512. </div>
  513. </div>
  514. </div>
  515. <div class="row">
  516. <div class="col-md-12">
  517. <h4>Historique paiements</h4>
  518. <table class="table table-condensed table-bordered table-hover" v-if="order.paymentsArray && order.paymentsArray.length > 0">
  519. <thead>
  520. <tr>
  521. <td>Date</td>
  522. <td>Origine action</td>
  523. <td>Type</td>
  524. <td>Moyen</td>
  525. <td>Montant</td>
  526. </tr>
  527. </thead>
  528. <tbody>
  529. <tr v-for="payment in order.paymentsArray">
  530. <td>{{ payment.date }}</td>
  531. <td>{{ payment.user_action }}</td>
  532. <td>{{ payment.wording_type }}</td>
  533. <td>{{ payment.wording_mean_payment }}</td>
  534. <td v-html="payment.amount"></td>
  535. </tr>
  536. </tbody>
  537. </table>
  538. <div class="alert alert-info" v-else>
  539. Aucun paiement rattaché à commande.
  540. </div>
  541. <div class="alert alert-success" v-if="order.isPaidViaInvoice">
  542. La commande est payée via la <a :href="UrlManager.getBaseUrl()+'invoice/update?id='+order.id_invoice">facture</a> à laquelle elle est rattachée.
  543. </div>
  544. </div>
  545. </div>
  546. </div>
  547. </modal>
  548. </td>
  549. <td v-if="producer && producer.tiller" class="tiller column-tiller">
  550. <input v-if="order.tiller_synchronization == true" type="checkbox" checked="checked" :id="'checkbox-tiller-synchronization-'+order.id" :data-id-order="order.id" @change="changeSynchroTiller" />
  551. <input v-else type="checkbox" :id="'checkbox-tiller-synchronization-'+order.id" :data-id-order="order.id" @change="changeSynchroTiller" />
  552. <label :for="'checkbox-tiller-synchronization-'+order.id">Tiller</label>
  553. </td>
  554. </tr>
  555. <tr class="view" v-if="showViewProduct && idOrderView == order.id">
  556. <td colspan="6">
  557. <strong><span class="glyphicon glyphicon-menu-right"></span> Produits</strong>
  558. <ul>
  559. <li v-for="product in products" v-if="getProductDistribution(product) && order.productOrder[product.id].quantity > 0">
  560. {{ 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>
  561. </li>
  562. </ul>
  563. <div v-if="order.comment && order.comment.length > 0" class="comment">
  564. <strong><span class="glyphicon glyphicon-menu-right"></span> Commentaire</strong><br />
  565. {{ order.comment }}
  566. </div>
  567. <div v-if="order.delivery_home && order.delivery_address && order.delivery_address.length > 0" class="delivery">
  568. <strong><span class="glyphicon glyphicon-menu-right"></span> Livraison à domicile</strong><br />
  569. {{ order.delivery_address }}
  570. </div>
  571. </td>
  572. </tr>
  573. </template>
  574. </tbody>
  575. </table>
  576. <div class="alert alert-warning" v-else>
  577. Aucune commande
  578. </div>
  579. </div>
  580. </div>
  581. </div>
  582. </div>
  583. <script type="text/x-template" id="order-state-payment">
  584. <span v-html="order.paymentLabelShort"></span>
  585. </script>
  586. <!-- template for the order-form component -->
  587. <script type="text/x-template" id="order-form-template">
  588. <modal class="modal-form-order" @close="$emit('close')">
  589. <h3 v-if="order.id" slot="header">
  590. <template v-if="order.id">Modifier</template>
  591. <template v-else>Ajouter</template>
  592. une commande - {{ dateFormat }}
  593. </h3>
  594. <div slot="body">
  595. <div class="callout callout-warning" v-if="errors.length">
  596. <ul>
  597. <li v-for="error in errors">{{ error }}</li>
  598. </ul>
  599. </div>
  600. <div class="col-md-4">
  601. <div class="form-group">
  602. <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>
  603. <label class="control-label" for="select-id-user">
  604. Utilisateur
  605. </label>
  606. <select class="form-control select2-order-form" v-model="order.id_user" @change="userChange">
  607. <option value="0">--</option>
  608. <option v-for="user in users" :value="user.id_user">
  609. <template v-if="user.name_legal_person && user.name_legal_person.length">
  610. {{ user.name_legal_person }} (personne morale)
  611. </template>
  612. <template v-else>
  613. {{ user.lastname +' '+ user.name }}
  614. </template>
  615. </option>
  616. </select>
  617. <input v-model="order.username" type="text" class="form-control" placeholder="Ou saisissez ici le nom de l'utilisateur" />
  618. </div>
  619. <div class="form-group">
  620. <label class="control-label" for="select-id-point-sale">Point de vente</label>
  621. <select class="form-control" id="select-id-point-sale" v-model="order.id_point_sale" @change="pointSaleChange">
  622. <option value="0">--</option>
  623. <option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id"">{{ pointSale.name }}</option>
  624. </select>
  625. </div>
  626. <div class="form-group">
  627. <label class="control-label" for="textarea-comment">Commentaire</label>
  628. <textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea>
  629. </div>
  630. <div class="form-group" v-if="isPointSaleCreditFunctioningOptional(order.id_point_sale)">
  631. <input type="checkbox" id="debit-credit" v-model="order.debitCredit" />
  632. <label class="control-label" for="debit-credit">Débiter le crédit</label>
  633. </div>
  634. </div>
  635. <div class="col-md-8">
  636. <label class="control-label">Produits</label>
  637. <table class="table table-condensed table-bordered table-hover table-products">
  638. <thead>
  639. <tr>
  640. <th></th>
  641. <th>Nom</th>
  642. <th>Prix unitaire</th>
  643. <th>Quantité</th>
  644. <th>Reste</th>
  645. </tr>
  646. </thead>
  647. <tbody>
  648. <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' : ''">
  649. <td>
  650. <span class="label label-success" v-if="loadingUpdateProductOrder || order.productOrder[product.id].active">Actif</span>
  651. <span class="label label-danger" v-else>Inactif</span>
  652. </td>
  653. <td>
  654. {{ product.name }}
  655. </td>
  656. <td class="price">
  657. <div v-show="vatMode == 'all'" class="input-group">
  658. <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" />
  659. <span class="input-group-addon" id="basic-addon2">€ HT&nbsp;&nbsp;</span>
  660. </div>
  661. <div class="input-group">
  662. <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" />
  663. <span class="input-group-addon" id="basic-addon2">€ TTC</span>
  664. </div>
  665. <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">
  666. <span class="label-invoice-price">Prix facturé</span><br />
  667. <div class="input-group">
  668. <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" />
  669. <input v-else type="text" v-model="order.productOrder[product.id].invoice_price" class="form-control input-sm" :data-id-product="product.id" />
  670. <span class="input-group-addon" id="basic-addon2">€ HT</span>
  671. </div>
  672. </div>
  673. </td>
  674. <td class="quantity">
  675. <div class="input-group">
  676. <span class="input-group-btn">
  677. <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>
  678. </span>
  679. <input type="text" v-model="order.productOrder[product.id].quantity" class="form-control input-quantity" />
  680. <span class="input-group-addon">{{ order.productOrder[product.id].unit == 'piece' ? 'p.' : order.productOrder[product.id].unit }}</span>
  681. <span class="input-group-btn">
  682. <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>
  683. </span>
  684. </div>
  685. </td>
  686. <td class="quantity-remaining infinite" v-if="product.quantity_remaining === null || order.productOrder[product.id].unit != product.unit">&infin;</td>
  687. <td class="quantity-remaining negative" v-else-if="getProductQuantityRemaining(product) <= 0">
  688. {{ getProductQuantityRemaining(product) }} {{ order.productOrder[product.id].unit == 'piece' ? ' p.' : ' '+(order.productOrder[product.id].unit == 'g' || order.productOrder[product.id].unit == 'kg') ? 'kg' : 'litre(s)' }}
  689. <span class="glyphicon glyphicon-alert" v-if="getProductQuantityRemaining(product) < 0"></span>
  690. </td>
  691. <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>
  692. </tr>
  693. </tbody>
  694. </table>
  695. </div>
  696. </div>
  697. <div slot="footer">
  698. <div class="actions-form">
  699. <button class="modal-default-button btn btn-danger" @click="$emit('close')">Fermer</button>
  700. <button class="modal-default-button btn btn-primary" @click="submitFormUpdate" v-if="order.id">Modifier</button>
  701. <button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-if="!order.id">Créer</button>
  702. <div class="right">
  703. <button class="modal-default-button btn btn-info btn-update-prices" @click="updateProductOrderPrices(true)">Recharger les prix</button>
  704. <button v-if="order.id" class="modal-default-button btn btn-info btn-update-prices" @click="updateInvoicePrices(true)">
  705. Réinitialiser les prix facturés
  706. </button>
  707. <button class="modal-default-button btn btn-info btn-display-prices-without-tax" @click="toggleVatMode()">
  708. <template v-if="vatMode == 'all'">Cacher</template>
  709. <template v-else>Afficher</template>
  710. les prix HT
  711. </button>
  712. </div>
  713. </div>
  714. </div>
  715. </modal>
  716. </script>
  717. <!-- template for the modal component -->
  718. <script type="text/x-template" id="modal-template">
  719. <transition name="modal">
  720. <div class="modal-mask">
  721. <div class="modal-wrapper">
  722. <div class="modal-container">
  723. <div class="modal-header">
  724. <slot name="header"></slot>
  725. </div>
  726. <div class="modal-body">
  727. <slot name="body"></slot>
  728. </div>
  729. <div class="modal-footer">
  730. <slot name="footer">
  731. <button class="modal-default-button btn btn-default" @click="$emit('close')">Fermer</button>
  732. </slot>
  733. </div>
  734. </div>
  735. </div>
  736. </div>
  737. </transition>
  738. </script>