cms.clients.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
  2. <h2 class="bd-title" id="content">
  3. <span>Administration : Clients</span>
  4. </h2>
  5. </header>
  6. <?php
  7. echo core::filAriane(array(
  8. "current" => "Clients",
  9. "arbo" => array(
  10. "Administration" => NULL,
  11. "Clients" => "/clients.html"
  12. )
  13. ));
  14. $allClients = clients::getAll();
  15. ?>
  16. <table class="table">
  17. <thead>
  18. <tr>
  19. <th scope="col">#</th>
  20. <th scope="col">Clients</th>
  21. <th scope="col"></th>
  22. </tr>
  23. <tr>
  24. <form method="post" action="/submit.php">
  25. <th scope="row"><input type="hidden" name="from" value="client-add"></th>
  26. <td><input type="text" name="client" class="form-control form-control-sm" value=""></td>
  27. <td><button type="submit" class="btn btn-success btn-sm">Ajouter</button></td>
  28. </form>
  29. </tr>
  30. </thead>
  31. <tbody>
  32. <?php
  33. foreach ($allClients as $value) {
  34. echo " <tr>
  35. <th scope=\"row\">" . $value["id"] . "</th>
  36. <td><input type=\"text\" class=\"form-control form-control-sm\" id=\"clients-".$value["id"]."\" value=\"" . $value["label"] . "\"></td>
  37. <td><button type=\"button\" class=\"btn btn-primary btn-sm\" onclick=\"majClients(".$value["id"].");\">Modifier</button></td>
  38. </tr>";
  39. }
  40. ?>
  41. </tbody>
  42. </table>
  43. <script>
  44. function majClients(id){
  45. $.ajax({
  46. url: '/submit.php',
  47. type: 'POST',
  48. data: {
  49. from: "client-change",
  50. id: id,
  51. value: $('#clients-'+id).val()
  52. },
  53. success: function(response) {
  54. $("#printToastSuccessTxt").html("Le client vient d'être mis à jour");
  55. $("#printToastSuccess").toast('show');
  56. },
  57. error: function(xhr, status, error) {
  58. $("#printToastErrorTxt").html("Le client n'a pas été mis à jour");
  59. $("#printToastError").toast('show');
  60. }
  61. });
  62. }
  63. </script>