diff --git a/api/client/payer.php b/api/client/payer.php
index bb8948a..aa4b70b 100644
--- a/api/client/payer.php
+++ b/api/client/payer.php
@@ -65,6 +65,6 @@ $requete->close();
$idTransaction = transaction(TRANSACTION_PAIEMENT, $_POST["idCarte"], $montant, $quantite);
-retour("ok", ["idTransaction" => $idTransaction, "soldeAncien" => $soldeAncien, "soldeNouveau" => $soldeNouveau]);
+retour("ok", ["idTransaction" => $idTransaction, "montant" => $montant, "soldeAncien" => $soldeAncien, "soldeNouveau" => $soldeNouveau]);
?>
diff --git a/index.html b/index.html
index 8a3996d..617787e 100644
--- a/index.html
+++ b/index.html
@@ -118,7 +118,7 @@
-
+
@@ -134,12 +134,12 @@
-
+
@@ -172,7 +172,7 @@
-
+
diff --git a/js/init.js b/js/init.js
index fbc1bda..8630daa 100644
--- a/js/init.js
+++ b/js/init.js
@@ -56,7 +56,6 @@ var app = new Vue({
},
// Fonctionnement
connecter: function() {
- console.log(57)
var that = this;
this.apiBrute("utilisateur/connexion", {login: this.login , mdp: this.mdp} , function(retour, donnees) {
that.mdp = ''
@@ -70,10 +69,6 @@ var app = new Vue({
that.page = 'operations'
break;
- case "identifiants_invalides":
- that.toast("Identifiants invalides")
- break;
-
default:
that.erreur(retour, donnees);
break;
@@ -89,8 +84,18 @@ var app = new Vue({
that.toast("Client " + that.idCarte + " crée avec un solde de " + that.solde + " €")
break;
- case "solde_negatif":
- that.toast("Solde négatif")
+ default:
+ that.erreur(retour, donnees);
+ break;
+ }
+ });
+ },
+ recharger: function() {
+ var that = this
+ this.api("client/recharger", {idCarte: this.idCarte, montant: this.credit}, function(retour, donnees) {
+ switch(retour) {
+ case "ok":
+ that.toast("Client " + that.idCarte + " rechargé : " + donnees.soldeAncien + " + " + that.credit + " → " + donnees.soldeNouveau + " €")
break;
default:
@@ -98,7 +103,41 @@ var app = new Vue({
break;
}
});
- }
+ },
+ payer: function(quantite) {
+ var that = this
+ var options = {idCarte: this.idCarte}
+ if (typeof(quantite) == 'number') {
+ options.quantite = quantite
+ } else {
+ options.montant = that.prix
+ }
+ this.api("client/payer", options, function(retour, donnees) {
+ switch(retour) {
+ case "ok":
+ that.toast("Client " + that.idCarte + " débité : " + donnees.soldeAncien + " - " + donnees.montant + " → " + donnees.soldeNouveau + " €")
+ break;
+
+ default:
+ that.erreur(retour, donnees);
+ break;
+ }
+ });
+ },
+ vidanger: function() {
+ var that = this
+ this.api("client/vidange", {idCarte: this.idCarte}, function(retour, donnees) {
+ switch(retour) {
+ case "ok":
+ that.toast("Client " + that.idCarte + " vidé : " + donnees.soldeAncien + " → 0 €")
+ break;
+
+ default:
+ that.erreur(retour, donnees);
+ break;
+ }
+ });
+ },
},
computed: {
timer: function() {
--
libgit2 0.21.2