Commit 1dc9797dde3ddc34d1fef988b863a677eb12d3b3
1 parent
dac984ec
Reste des transactions
Showing
3 changed files
with
54 additions
and
15 deletions
Show diff stats
api/client/payer.php
... | ... | @@ -65,6 +65,6 @@ $requete->close(); |
65 | 65 | $idTransaction = transaction(TRANSACTION_PAIEMENT, $_POST["idCarte"], $montant, $quantite); |
66 | 66 | |
67 | 67 | |
68 | -retour("ok", ["idTransaction" => $idTransaction, "soldeAncien" => $soldeAncien, "soldeNouveau" => $soldeNouveau]); | |
68 | +retour("ok", ["idTransaction" => $idTransaction, "montant" => $montant, "soldeAncien" => $soldeAncien, "soldeNouveau" => $soldeNouveau]); | |
69 | 69 | |
70 | 70 | ?> | ... | ... |
index.html
... | ... | @@ -118,7 +118,7 @@ |
118 | 118 | <input type="number" name="solde" v-model="solde"> |
119 | 119 | <label for="solde">Solde initial (€)</label> |
120 | 120 | </div> |
121 | - <button :disabled="!solde || (!PEUT_NFC && !idCarte)">Créer</button> | |
121 | + <button type="submit" :disabled="!solde || (!PEUT_NFC && !idCarte)">Créer</button> | |
122 | 122 | </form> |
123 | 123 | </div> |
124 | 124 | <div id="rechargement"> |
... | ... | @@ -134,12 +134,12 @@ |
134 | 134 | <input type="number" name="credit" v-model="credit"> |
135 | 135 | <label for="credit">Crédit (€)</label> |
136 | 136 | </div> |
137 | - <button :disabled="!credit || (!PEUT_NFC && !idCarte)">Créer</button> | |
137 | + <button type="submit" :disabled="!credit || (!PEUT_NFC && !idCarte)">Recharger</button> | |
138 | 138 | </form> |
139 | 139 | </div> |
140 | 140 | <div id="paiement"> |
141 | 141 | <h4>Vendre à un client</h4> |
142 | - <form @submit="payer"> | |
142 | + <form> | |
143 | 143 | <div class="input-field" v-if="!PEUT_NFC"> |
144 | 144 | <i class="material-icons prefix">credit_card</i> |
145 | 145 | <input type="text" name="idCarte" length="8" v-model="idCarte"> |
... | ... | @@ -150,7 +150,7 @@ |
150 | 150 | </div> |
151 | 151 | <div id="grilleBieres"> |
152 | 152 | <div> |
153 | - <div v-for="i in [1, 2, 3, 4, 5, 6]"><button :disabled="!PEUT_NFC && !idCarte">{{ i }}</button></div> | |
153 | + <div v-for="i in [1, 2, 3, 4, 5, 6]"><button type="button" @click="payer(i)" :disabled="prix || (!PEUT_NFC && !idCarte)">{{ i }}</button></div> | |
154 | 154 | </div> |
155 | 155 | </div> |
156 | 156 | <div class="row"> |
... | ... | @@ -161,7 +161,7 @@ |
161 | 161 | <input type="number" name="prix" v-model="prix"> |
162 | 162 | <label for="prix">Prix (€)</label> |
163 | 163 | </div> |
164 | - <button :disabled="!prix || (!PEUT_NFC && !idCarte)">Payer</button> | |
164 | + <button type="submit" @click="payer" :disabled="!prix || (!PEUT_NFC && !idCarte)">Payer</button> | |
165 | 165 | </form> |
166 | 166 | </div> |
167 | 167 | <div id="vidange"> |
... | ... | @@ -172,7 +172,7 @@ |
172 | 172 | <input type="text" name="idCarte" length="8" v-model="idCarte"> |
173 | 173 | <label for="idCarte">Identifiant de la carte</label> |
174 | 174 | </div> |
175 | - <button :disabled="!PEUT_NFC && !idCarte">Vider</button> | |
175 | + <button type="submit" :disabled="!PEUT_NFC && !idCarte">Vider</button> | |
176 | 176 | </form> |
177 | 177 | </div> |
178 | 178 | </div> | ... | ... |
js/init.js
... | ... | @@ -56,7 +56,6 @@ var app = new Vue({ |
56 | 56 | }, |
57 | 57 | // Fonctionnement |
58 | 58 | connecter: function() { |
59 | - console.log(57) | |
60 | 59 | var that = this; |
61 | 60 | this.apiBrute("utilisateur/connexion", {login: this.login , mdp: this.mdp} , function(retour, donnees) { |
62 | 61 | that.mdp = '' |
... | ... | @@ -70,10 +69,6 @@ var app = new Vue({ |
70 | 69 | that.page = 'operations' |
71 | 70 | break; |
72 | 71 | |
73 | - case "identifiants_invalides": | |
74 | - that.toast("Identifiants invalides") | |
75 | - break; | |
76 | - | |
77 | 72 | default: |
78 | 73 | that.erreur(retour, donnees); |
79 | 74 | break; |
... | ... | @@ -89,8 +84,18 @@ var app = new Vue({ |
89 | 84 | that.toast("Client " + that.idCarte + " crée avec un solde de " + that.solde + " €") |
90 | 85 | break; |
91 | 86 | |
92 | - case "solde_negatif": | |
93 | - that.toast("Solde négatif") | |
87 | + default: | |
88 | + that.erreur(retour, donnees); | |
89 | + break; | |
90 | + } | |
91 | + }); | |
92 | + }, | |
93 | + recharger: function() { | |
94 | + var that = this | |
95 | + this.api("client/recharger", {idCarte: this.idCarte, montant: this.credit}, function(retour, donnees) { | |
96 | + switch(retour) { | |
97 | + case "ok": | |
98 | + that.toast("Client " + that.idCarte + " rechargé : " + donnees.soldeAncien + " + " + that.credit + " → " + donnees.soldeNouveau + " €") | |
94 | 99 | break; |
95 | 100 | |
96 | 101 | default: |
... | ... | @@ -98,7 +103,41 @@ var app = new Vue({ |
98 | 103 | break; |
99 | 104 | } |
100 | 105 | }); |
101 | - } | |
106 | + }, | |
107 | + payer: function(quantite) { | |
108 | + var that = this | |
109 | + var options = {idCarte: this.idCarte} | |
110 | + if (typeof(quantite) == 'number') { | |
111 | + options.quantite = quantite | |
112 | + } else { | |
113 | + options.montant = that.prix | |
114 | + } | |
115 | + this.api("client/payer", options, function(retour, donnees) { | |
116 | + switch(retour) { | |
117 | + case "ok": | |
118 | + that.toast("Client " + that.idCarte + " débité : " + donnees.soldeAncien + " - " + donnees.montant + " → " + donnees.soldeNouveau + " €") | |
119 | + break; | |
120 | + | |
121 | + default: | |
122 | + that.erreur(retour, donnees); | |
123 | + break; | |
124 | + } | |
125 | + }); | |
126 | + }, | |
127 | + vidanger: function() { | |
128 | + var that = this | |
129 | + this.api("client/vidange", {idCarte: this.idCarte}, function(retour, donnees) { | |
130 | + switch(retour) { | |
131 | + case "ok": | |
132 | + that.toast("Client " + that.idCarte + " vidé : " + donnees.soldeAncien + " → 0 €") | |
133 | + break; | |
134 | + | |
135 | + default: | |
136 | + that.erreur(retour, donnees); | |
137 | + break; | |
138 | + } | |
139 | + }); | |
140 | + }, | |
102 | 141 | }, |
103 | 142 | computed: { |
104 | 143 | timer: function() { | ... | ... |