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,6 +133,17 @@ | ||
133 | <input type="number" name="solde" v-model="solde"> | 133 | <input type="number" name="solde" v-model="solde"> |
134 | <label for="solde">Solde initial (€)</label> | 134 | <label for="solde">Solde initial (€)</label> |
135 | </div> | 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 | <button type="submit" :disabled="!solde || (!PEUT_NFC && !idCarte)">Créer</button> | 147 | <button type="submit" :disabled="!solde || (!PEUT_NFC && !idCarte)">Créer</button> |
137 | </form> | 148 | </form> |
138 | </div> | 149 | </div> |
@@ -197,12 +208,37 @@ | @@ -197,12 +208,37 @@ | ||
197 | <div class="row"> | 208 | <div class="row"> |
198 | <div id="clients"> | 209 | <div id="clients"> |
199 | <h4>Liste des clients</h4> | 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 | </div> | 236 | </div> |
201 | <div id="transactions"> | 237 | <div id="transactions"> |
202 | <h4>Liste des transactions</h4> | 238 | <h4>Liste des transactions</h4> |
203 | <button @click="actuTransactions">Rafraîchir</button> | 239 | <button @click="actuTransactions">Rafraîchir</button> |
204 | <ul class="collapsible popout" data-collapsible="accordion"> | 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 | <div class="collapsible-header" :class="{'red': !transaction.valide}"> | 242 | <div class="collapsible-header" :class="{'red': !transaction.valide}"> |
207 | <span v-if="transaction.type == 1"> | 243 | <span v-if="transaction.type == 1"> |
208 | <i class="material-icons">trending_flat</i> {{ transaction.client }} : {{ transaction.montant }} € | 244 | <i class="material-icons">trending_flat</i> {{ transaction.client }} : {{ transaction.montant }} € |
@@ -228,7 +264,7 @@ | @@ -228,7 +264,7 @@ | ||
228 | <span v-if="transaction.type == 4">Vidange</span> | 264 | <span v-if="transaction.type == 4">Vidange</span> |
229 | </li> | 265 | </li> |
230 | <li> | 266 | <li> |
231 | - <strong>Date :</strong> {{ transaction.date }} | 267 | + <strong>Date :</strong> <span v-text="transaction.date | date"></span> |
232 | </li> | 268 | </li> |
233 | <li> | 269 | <li> |
234 | <strong>Utilisateur :</strong> {{ transaction.utilisateur }} | 270 | <strong>Utilisateur :</strong> {{ transaction.utilisateur }} |
js/init.js
@@ -31,8 +31,13 @@ var app = new Vue({ | @@ -31,8 +31,13 @@ var app = new Vue({ | ||
31 | erreurTitre: '', | 31 | erreurTitre: '', |
32 | erreurMessage: '', | 32 | erreurMessage: '', |
33 | // Session | 33 | // Session |
34 | + login: '', | ||
35 | + droit: '', | ||
36 | + jeton: '', | ||
34 | connecte: false, | 37 | connecte: false, |
35 | date: 1, | 38 | date: 1, |
39 | + // Données | ||
40 | + clients: [], | ||
36 | transactions: [], | 41 | transactions: [], |
37 | }, | 42 | }, |
38 | methods: { | 43 | methods: { |
@@ -46,12 +51,25 @@ var app = new Vue({ | @@ -46,12 +51,25 @@ var app = new Vue({ | ||
46 | donnees['jeton'] = this.jeton | 51 | donnees['jeton'] = this.jeton |
47 | this.apiBrute(chemin, donnees, cb) | 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 | actuTransactions: function() { | 68 | actuTransactions: function() { |
50 | var that = this | 69 | var that = this |
51 | this.api("transactions", {}, function(retour, donnees) { | 70 | this.api("transactions", {}, function(retour, donnees) { |
52 | switch(retour) { | 71 | switch(retour) { |
53 | case "ok": | 72 | case "ok": |
54 | - console.log(donnees.transactions[0].type, TRANSACTION_CREATION) | ||
55 | that.transactions = donnees.transactions | 73 | that.transactions = donnees.transactions |
56 | break; | 74 | break; |
57 | 75 | ||
@@ -60,8 +78,8 @@ var app = new Vue({ | @@ -60,8 +78,8 @@ var app = new Vue({ | ||
60 | break; | 78 | break; |
61 | } | 79 | } |
62 | }) | 80 | }) |
63 | - | ||
64 | }, | 81 | }, |
82 | + | ||
65 | // Affichage | 83 | // Affichage |
66 | toast: function(texte) { | 84 | toast: function(texte) { |
67 | Materialize.toast(texte, 4000); | 85 | Materialize.toast(texte, 4000); |
@@ -116,7 +134,7 @@ var app = new Vue({ | @@ -116,7 +134,7 @@ var app = new Vue({ | ||
116 | }, | 134 | }, |
117 | creer: function() { | 135 | creer: function() { |
118 | var that = this | 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 | switch(retour) { | 138 | switch(retour) { |
121 | case "ok": | 139 | case "ok": |
122 | that.transaction(donnees.idTransaction, "Client " + that.idCarte + " crée avec un solde de " + that.solde + " €") | 140 | that.transaction(donnees.idTransaction, "Client " + that.idCarte + " crée avec un solde de " + that.solde + " €") |