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.

810 rindas
61KB

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