cms.compte-upload.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <link rel="stylesheet" href="css/dragAndDrop.css">
  2. <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
  3. <h2 class="bd-title" id="content">
  4. <span>Banque : Importer un fichier CSV</span>
  5. </h2>
  6. </header>
  7. <?php
  8. $banque = banque::getInitialCompte(core::getGet("add"));
  9. echo core::filAriane(array(
  10. "current" => "Importer un CSV",
  11. "arbo" => array(
  12. "Comptes bancaires" => NULL,
  13. $banque["label"] . " - N°".$banque["compte"] => "/compte-". core::getGet("add") .".html",
  14. "Importer un CSV" => NULL)
  15. ));
  16. ?>
  17. <br />
  18. <form action="/submit.php" method="post" enctype="multipart/form-data" onsubmit="loading()">
  19. <input type="hidden" name="from" value="compte-upload">
  20. <input type="hidden" name="add" value="<?php echo core::getGet("add") ?>">
  21. <input type="hidden" name="compte" value="<?php echo $banque["compte"] ?>">
  22. <div class="file-drop-area">
  23. <span class="choose-file-button">Choisissez votre fichier CSV</span>
  24. <span class="file-message">ou déposez le dans cette zone</span>
  25. <input id="compte-upload" class="import-excel" name="compte-upload" type="file" onchange="dargAndDrop()" accept=".csv" required>
  26. </div>
  27. <br />
  28. <?php button::confirm(
  29. array(
  30. "value" => "Charger le dernier CSV émanant du ".$banque["label"]." de Crédit Mutuel",
  31. "text" => "Vérifiez que le CSV correspond au bon compte. Le compte de destination est ".$banque["label"]." (N°".$banque["compte"].")"
  32. )
  33. ) ?>
  34. </form>
  35. <script>
  36. function dargAndDrop(){
  37. var fileName = $("#compte-upload").val().split('\\').pop();
  38. var ext = fileName.split('.').pop();
  39. var fileAttendu = "<?php echo banque::fileName($banque["compte"]) ?>";
  40. if(ext!=="csv"){
  41. $("#printToastErrorTxt").html("Seuls les fichiers CSV sont acceptés");
  42. $("#printToastError").toast('show');
  43. $('#attachement-document').val("");
  44. } else {
  45. if(fileName.includes(fileAttendu)){
  46. $(".file-message").text("Fichier prêt à être chargé : " + fileName);
  47. } else {
  48. $("#printToastErrorTxt").html("Le fichier "+ fileName +" ne semble pas être associé au bon compte.");
  49. $("#printToastError").toast('show');
  50. $('#attachement-document').val("");
  51. }
  52. }
  53. }
  54. </script>