Blame view

api/client/liste.php 621 Bytes
acc8777f   Geoffrey PREUD'HOMME   api/utilisateur/l...
1
2
3
4
5
6
7
  <?php
  
  require_once("../commun.php");
  
  verifierDroit(2);
  
  $requete = $db->prepare("SELECT idCarte, solde, decouvert FROM Clients");
0b7b1139   Geoffrey PREUD'HOMME   erreur_bdd_prepare
8
9
10
  if (!$requete) {
      retour("erreur_bdd_preparee", ["message" => $db->error]);
  }
acc8777f   Geoffrey PREUD'HOMME   api/utilisateur/l...
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  if (!$requete->execute()) {
      retour("erreur_bdd", ["message" => $requete->error]);
  }
  $requete->bind_result($idCarte, $solde, $decouvert);
  $clients = [];
  while ($requete->fetch()) {
      $client = ["idCarte" => $idCarte, "solde" => $solde];
      if ($droit >= 3) {
          $client["decouvert"] = !!$decouvert;
      }
      $clients[] = $client;
  }
  $requete->close();
  
  
  retour("ok", ["clients" => $clients]);
  
  ?>