Commit f06ddf22bf5e5e937227fb23a988b16da4e47698
1 parent
cb35789c
api/utilisateur/fiche
Showing
1 changed file
with
45 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +require_once("../commun.php"); | ||
4 | + | ||
5 | +verifierJeton(donne("jeton")); | ||
6 | + | ||
7 | +if (!donne("login")) { | ||
8 | + retour("requete_malformee"); | ||
9 | +} | ||
10 | + | ||
11 | +if ($login != donne("login")) { | ||
12 | + verifierDroit(3); | ||
13 | +} | ||
14 | + | ||
15 | +// Informations sur l'utilisateur | ||
16 | +$requete = $db->prepare("SELECT idCarte, droit FROM Utilisateurs WHERE login=?"); | ||
17 | +$requete->bind_param("s", $_POST["login"]); | ||
18 | +if (!$requete->execute()) { | ||
19 | + retour("erreur_bdd", ["message" => $requete->error]); | ||
20 | +} | ||
21 | +$requete->bind_result($idCarte, $droit); | ||
22 | +if (!$requete->fetch()) { | ||
23 | + retour("utilisateur_inconnu"); | ||
24 | +} | ||
25 | +$requete->close(); | ||
26 | + | ||
27 | +// Transactions de l'utilisateur | ||
28 | +$requete = $db->prepare("SELECT id, type, client, UNIX_TIMESTAMP(date), montant, quantite, valide FROM Transactions WHERE utilisateur=?"); | ||
29 | +$requete->bind_param("s", $_POST["login"]); | ||
30 | +if (!$requete->execute()) { | ||
31 | + retour("erreur_bdd", ["message" => $requete->error]); | ||
32 | +} | ||
33 | +$requete->bind_result($id, $type, $client, $date, $montant, $quantite, $valide); | ||
34 | +$transactions = []; | ||
35 | +while($requete->fetch()) { | ||
36 | + $transaction = ["id" => $id, "type" => $type, "client" => $client, "date" => $date, "montant" => $montant, "quantite" => $quantite, "utilisateur" => $_POST["login"], "valide" => $valide]; | ||
37 | + $transactions[] = $transaction; | ||
38 | + | ||
39 | +} | ||
40 | +$requete->close(); | ||
41 | + | ||
42 | + | ||
43 | +retour("ok", ["login" => $_POST["login"], "idCarte" => $idCarte, "droit" => $droit, "transactions" => $transactions]); | ||
44 | + | ||
45 | +?> |