Commit 9868802a3c92776217d9eb3a82e54effba4c569e
1 parent
d0fe5751
Liste des clients
Showing
2 changed files
with
59 additions
and
5 deletions
Show diff stats
index.html
... | ... | @@ -133,6 +133,17 @@ |
133 | 133 | <input type="number" name="solde" v-model="solde"> |
134 | 134 | <label for="solde">Solde initial (€)</label> |
135 | 135 | </div> |
136 | + <div class="input-field" v-if="droit >= 3"> | |
137 | + <strong>Découvert autorisé</strong> | |
138 | + <div class="switch"> | |
139 | + <label> | |
140 | + Non | |
141 | + <input v-model="decouvert" type="checkbox"> | |
142 | + <span class="lever"></span> | |
143 | + Oui | |
144 | + </label> | |
145 | + </div> | |
146 | + </div> | |
136 | 147 | <button type="submit" :disabled="!solde || (!PEUT_NFC && !idCarte)">Créer</button> |
137 | 148 | </form> |
138 | 149 | </div> |
... | ... | @@ -197,12 +208,37 @@ |
197 | 208 | <div class="row"> |
198 | 209 | <div id="clients"> |
199 | 210 | <h4>Liste des clients</h4> |
211 | + <button @click="actuClients">Rafraîchir</button> | |
212 | + <ul class="collapsible popout" data-collapsible="accordion"> | |
213 | + <li v-for="client in clients"> | |
214 | + <div class="collapsible-header"> | |
215 | + <i class="material-icons">perm_identity</i> {{ client.idCarte }} : {{ client.solde }} € | |
216 | + </div> | |
217 | + <div class="collapsible-body"> | |
218 | + <ul> | |
219 | + <li v-if="droit >= 3"> | |
220 | + <strong>Découvert autorisé</strong> | |
221 | + <div class="switch"> | |
222 | + <label> | |
223 | + Non | |
224 | + <input v-model="client.decouvert" type="checkbox"> | |
225 | + <span class="lever"></span> | |
226 | + Oui | |
227 | + </label> | |
228 | + </div> | |
229 | + </li> | |
230 | + </ul> | |
231 | + <h5>Transactions</h5> | |
232 | + <p>TODO</p> | |
233 | + </div> | |
234 | + </li> | |
235 | + </ul> | |
200 | 236 | </div> |
201 | 237 | <div id="transactions"> |
202 | 238 | <h4>Liste des transactions</h4> |
203 | 239 | <button @click="actuTransactions">Rafraîchir</button> |
204 | 240 | <ul class="collapsible popout" data-collapsible="accordion"> |
205 | - <li v-for="transaction in transactions"> | |
241 | + <li v-for="transaction in transactions | orderBy 'date' -1"> | |
206 | 242 | <div class="collapsible-header" :class="{'red': !transaction.valide}"> |
207 | 243 | <span v-if="transaction.type == 1"> |
208 | 244 | <i class="material-icons">trending_flat</i> {{ transaction.client }} : {{ transaction.montant }} € |
... | ... | @@ -228,7 +264,7 @@ |
228 | 264 | <span v-if="transaction.type == 4">Vidange</span> |
229 | 265 | </li> |
230 | 266 | <li> |
231 | - <strong>Date :</strong> {{ transaction.date }} | |
267 | + <strong>Date :</strong> <span v-text="transaction.date | date"></span> | |
232 | 268 | </li> |
233 | 269 | <li> |
234 | 270 | <strong>Utilisateur :</strong> {{ transaction.utilisateur }} | ... | ... |
js/init.js
... | ... | @@ -31,8 +31,13 @@ var app = new Vue({ |
31 | 31 | erreurTitre: '', |
32 | 32 | erreurMessage: '', |
33 | 33 | // Session |
34 | + login: '', | |
35 | + droit: '', | |
36 | + jeton: '', | |
34 | 37 | connecte: false, |
35 | 38 | date: 1, |
39 | + // Données | |
40 | + clients: [], | |
36 | 41 | transactions: [], |
37 | 42 | }, |
38 | 43 | methods: { |
... | ... | @@ -46,12 +51,25 @@ var app = new Vue({ |
46 | 51 | donnees['jeton'] = this.jeton |
47 | 52 | this.apiBrute(chemin, donnees, cb) |
48 | 53 | }, |
54 | + actuClients: function() { | |
55 | + var that = this | |
56 | + this.api("client/liste", {}, function(retour, donnees) { | |
57 | + switch(retour) { | |
58 | + case "ok": | |
59 | + that.clients = donnees.clients | |
60 | + break; | |
61 | + | |
62 | + default: | |
63 | + that.erreur(retour, donnees); | |
64 | + break; | |
65 | + } | |
66 | + }) | |
67 | + }, | |
49 | 68 | actuTransactions: function() { |
50 | 69 | var that = this |
51 | 70 | this.api("transactions", {}, function(retour, donnees) { |
52 | 71 | switch(retour) { |
53 | 72 | case "ok": |
54 | - console.log(donnees.transactions[0].type, TRANSACTION_CREATION) | |
55 | 73 | that.transactions = donnees.transactions |
56 | 74 | break; |
57 | 75 | |
... | ... | @@ -60,8 +78,8 @@ var app = new Vue({ |
60 | 78 | break; |
61 | 79 | } |
62 | 80 | }) |
63 | - | |
64 | 81 | }, |
82 | + | |
65 | 83 | // Affichage |
66 | 84 | toast: function(texte) { |
67 | 85 | Materialize.toast(texte, 4000); |
... | ... | @@ -116,7 +134,7 @@ var app = new Vue({ |
116 | 134 | }, |
117 | 135 | creer: function() { |
118 | 136 | var that = this |
119 | - this.api("client/ajouter", {idCarte: this.idCarte, solde: this.solde}, function(retour, donnees) { | |
137 | + this.api("client/ajouter", {idCarte: this.idCarte, solde: this.solde, decouvert: this.decouvert}, function(retour, donnees) { | |
120 | 138 | switch(retour) { |
121 | 139 | case "ok": |
122 | 140 | that.transaction(donnees.idTransaction, "Client " + that.idCarte + " crée avec un solde de " + that.solde + " €") | ... | ... |