Commit d0fe5751c237c762d7c08bf5b01419f5796f9c12
1 parent
7ee50aa3
Liste des transactions
Showing
3 changed files
with
102 additions
and
16 deletions
Show diff stats
index.html
... | ... | @@ -56,6 +56,7 @@ |
56 | 56 | <div class="left" v-else> |
57 | 57 | <a class="breadcrumb">10⁵</a> |
58 | 58 | <a class="breadcrumb" v-if="page == 'operations'">Opérations</a> |
59 | + <a class="breadcrumb" v-if="page == 'gestion'">Gestion</a> | |
59 | 60 | </div> |
60 | 61 | <ul class="right hide-on-med-and-down"> |
61 | 62 | <li v-if="connecte"> |
... | ... | @@ -63,6 +64,16 @@ |
63 | 64 | <i class="material-icons">perm_identity</i> {{ login }} (<i class="material-icons">timer</i> {{ timer }}) |
64 | 65 | </a> |
65 | 66 | </li> |
67 | + <li v-if="connecte && page == 'operations'"> | |
68 | + <a @click="page = 'gestion'"> | |
69 | + <i class="material-icons">settings</i> Gestion | |
70 | + </a> | |
71 | + </li> | |
72 | + <li v-if="connecte && page == 'gestion'"> | |
73 | + <a @click="page = 'operations'"> | |
74 | + <i class="material-icons">play_arrow</i> Opérations | |
75 | + </a> | |
76 | + </li> | |
66 | 77 | </ul> |
67 | 78 | <ul class="tabs" v-show="page == 'operations'"> |
68 | 79 | <li class="tab col s3"><a href="#creation">Création</a></li> |
... | ... | @@ -70,6 +81,12 @@ |
70 | 81 | <li class="tab col s3"><a class="active" href="#paiement">Paiement</a></li> |
71 | 82 | <li class="tab col s3"><a href="#vidange">Vidange</a></li> |
72 | 83 | </ul> |
84 | + <ul class="tabs" v-show="page == 'gestion'"> | |
85 | + <li class="tab col s3"><a href="#clients">Clients</a></li> | |
86 | + <li class="tab col s3"><a href="#transactions">Transactions</a></li> | |
87 | + <li class="tab col s3"><a href="#utilisateurs">Utilisateurs</a></li> | |
88 | + <li class="tab col s3"><a href="#statistiques">Statistiques</a></li> | |
89 | + </ul> | |
73 | 90 | <ul class="side-nav"> |
74 | 91 | <li><a>TODO</a></li> |
75 | 92 | </ul> |
... | ... | @@ -93,8 +110,8 @@ |
93 | 110 | <label for="mdp">Mot de passe</label> |
94 | 111 | </div> |
95 | 112 | <button :disabled="!login || !mdp">Se connecter</button> |
113 | + </form> | |
96 | 114 | </div> |
97 | - </form> | |
98 | 115 | </div> |
99 | 116 | <div v-if="PEUT_NFC"> |
100 | 117 | <h5>Avec votre carte étudiant</h5> |
... | ... | @@ -102,7 +119,7 @@ |
102 | 119 | </div> |
103 | 120 | |
104 | 121 | <div class="container" v-show="page == 'operations'"> |
105 | - <div class="row center"> | |
122 | + <div class="row"> | |
106 | 123 | <div id="creation"> |
107 | 124 | <h4>Créer un nouveau client</h4> |
108 | 125 | <form @submit="creer"> |
... | ... | @@ -175,6 +192,63 @@ |
175 | 192 | </div> |
176 | 193 | </div> |
177 | 194 | </div> |
195 | + | |
196 | + <div class="container" v-show="page == 'gestion'"> | |
197 | + <div class="row"> | |
198 | + <div id="clients"> | |
199 | + <h4>Liste des clients</h4> | |
200 | + </div> | |
201 | + <div id="transactions"> | |
202 | + <h4>Liste des transactions</h4> | |
203 | + <button @click="actuTransactions">Rafraîchir</button> | |
204 | + <ul class="collapsible popout" data-collapsible="accordion"> | |
205 | + <li v-for="transaction in transactions"> | |
206 | + <div class="collapsible-header" :class="{'red': !transaction.valide}"> | |
207 | + <span v-if="transaction.type == 1"> | |
208 | + <i class="material-icons">trending_flat</i> {{ transaction.client }} : {{ transaction.montant }} € | |
209 | + </span> | |
210 | + <span v-if="transaction.type == 2"> | |
211 | + <i class="material-icons">trending_up</i> {{ transaction.client }} : + {{ transaction.montant }} € | |
212 | + </span> | |
213 | + <span v-if="transaction.type == 3"> | |
214 | + <i class="material-icons">trending_down</i> {{ transaction.client }} : - {{ transaction.montant }} € | |
215 | + <span v-if="transaction.quantite != 0">({{ transaction.quantite }} consommation<span v-if="transaction.quantite >= 2">s</span>)</span> | |
216 | + </span> | |
217 | + <span v-if="transaction.type == 4"> | |
218 | + <i class="material-icons">delete</i> {{ transaction.client }} : - {{ transaction.montant }} € | |
219 | + </span> | |
220 | + </div> | |
221 | + <div class="collapsible-body"> | |
222 | + <ul> | |
223 | + <li> | |
224 | + <strong>Type :</strong> | |
225 | + <span v-if="transaction.type == 1">Création</span> | |
226 | + <span v-if="transaction.type == 2">Rechargement</span> | |
227 | + <span v-if="transaction.type == 3">Date</span> | |
228 | + <span v-if="transaction.type == 4">Vidange</span> | |
229 | + </li> | |
230 | + <li> | |
231 | + <strong>Date :</strong> {{ transaction.date }} | |
232 | + </li> | |
233 | + <li> | |
234 | + <strong>Utilisateur :</strong> {{ transaction.utilisateur }} | |
235 | + </li> | |
236 | + </ul> | |
237 | + <button @click="annuler(transaction.id)" :disabled="!transaction.valide">Annuler</button> | |
238 | + </div> | |
239 | + </li> | |
240 | + </ul> | |
241 | + </div> | |
242 | + <div id="utilisateurs"> | |
243 | + <h4>Liste des utilisateurs</h4> | |
244 | + </div> | |
245 | + <div id="statistiques"> | |
246 | + <h4>Statistiques</h4> | |
247 | + </div> | |
248 | + </div> | |
249 | + </div> | |
250 | + | |
251 | + | |
178 | 252 | </div> |
179 | 253 | |
180 | 254 | <footer class="page-footer"> | ... | ... |
js/init.js
... | ... | @@ -33,6 +33,7 @@ var app = new Vue({ |
33 | 33 | // Session |
34 | 34 | connecte: false, |
35 | 35 | date: 1, |
36 | + transactions: [], | |
36 | 37 | }, |
37 | 38 | methods: { |
38 | 39 | // API |
... | ... | @@ -45,6 +46,22 @@ var app = new Vue({ |
45 | 46 | donnees['jeton'] = this.jeton |
46 | 47 | this.apiBrute(chemin, donnees, cb) |
47 | 48 | }, |
49 | + actuTransactions: function() { | |
50 | + var that = this | |
51 | + this.api("transactions", {}, function(retour, donnees) { | |
52 | + switch(retour) { | |
53 | + case "ok": | |
54 | + console.log(donnees.transactions[0].type, TRANSACTION_CREATION) | |
55 | + that.transactions = donnees.transactions | |
56 | + break; | |
57 | + | |
58 | + default: | |
59 | + that.erreur(retour, donnees); | |
60 | + break; | |
61 | + } | |
62 | + }) | |
63 | + | |
64 | + }, | |
48 | 65 | // Affichage |
49 | 66 | toast: function(texte) { |
50 | 67 | Materialize.toast(texte, 4000); |
... | ... | @@ -54,7 +71,7 @@ var app = new Vue({ |
54 | 71 | this.erreurMessage = donnees['message'] |
55 | 72 | $("#modalErreur").openModal(); |
56 | 73 | }, |
57 | - annuler(id) { | |
74 | + annuler: function(id) { | |
58 | 75 | var that = this |
59 | 76 | this.api("annuler", {idTransaction: id}, function(retour, donnees) { |
60 | 77 | switch(retour) { |
... | ... | @@ -68,7 +85,7 @@ var app = new Vue({ |
68 | 85 | } |
69 | 86 | }); |
70 | 87 | }, |
71 | - transaction(id, texte) { | |
88 | + transaction: function(id, texte) { | |
72 | 89 | var that = this |
73 | 90 | var interieur = $('<span>').text(texte + ' ').append($('<a>').text('Annuler').one('click', function() { |
74 | 91 | that.annuler(id) |
... | ... | @@ -170,20 +187,12 @@ var app = new Vue({ |
170 | 187 | }, |
171 | 188 | }) |
172 | 189 | |
190 | +Vue.filter('date', function(timestamp) { | |
191 | + return Date(timestamp).toLocaleString(); | |
192 | +}) | |
193 | + | |
173 | 194 | setInterval(function actualiserDate() { |
174 | 195 | app.$data.date = Math.floor(Date.now()/1000) |
175 | 196 | }, 1000); |
176 | 197 | |
177 | 198 | |
178 | -// Placeholder | |
179 | -function vendu() { | |
180 | - var interieur = $("<span>").text("Vendu 1 bière à KAE1EET2YI (15,30 € → 13,50 €) ").append( | |
181 | - $("<a>").attr("href", "#!").text("Annuler") | |
182 | - ); | |
183 | - Materialize.toast(interieur, 4000); | |
184 | -} | |
185 | - | |
186 | -function soldeInsuffisant() { | |
187 | - $("#soldeInsuffisant").openModal(); | |
188 | -} | |
189 | - | ... | ... |