| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- $banque = banque::getInitialCompte(core::getGet("add"));
- if($banque["import"] != "csv"){
- alert::recError("Vous ne pouvez pas importer de CSV sur ce compte.");
- echo '<script>window.location.replace("/compte-' . core::getGet("add") . '.html");</script>';
- exit();
- }
- ?>
- <link rel="stylesheet" href="css/dragAndDrop.css">
- <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
- <h2 class="bd-title" id="content">
- <span>Banque : Importer un fichier CSV</span>
- </h2>
- </header>
- <?php
- if(!empty($banque["compte"])){
- $compte = " - N°". $banque["compte"];
- } else {
- $compte = "";
- }
- echo core::filAriane(array(
- "current" => "Importer un CSV",
- "arbo" => array(
- "Comptes bancaires" => NULL,
- $banque["label"] . $compte => "/compte-". core::getGet("add") .".html",
- "Importer un CSV" => NULL)
- ));
- ?>
- <br />
- <?php if(empty($banque["compte"])){
- echo "<div class=\"alert alert-danger\" role=\"alert\">Aucun numéro de compte n'a été défini sur ce compte. Vous ne pouvez donc pas importer de fichier CSV. Il vous faut renseigner le numéro du compte dans l'espace d'administration pour poursuivre.</div>";
- }
- else { ?>
- <form action="/submit.php" method="post" enctype="multipart/form-data" onsubmit="loading()">
- <input type="hidden" name="from" value="compte-upload">
- <input type="hidden" name="add" value="<?php echo core::getGet("add") ?>">
- <input type="hidden" name="compte" value="<?php echo $banque["compte"] ?>">
- <div class="file-drop-area">
- <span class="choose-file-button">Choisissez votre fichier CSV</span>
- <span class="file-message">ou déposez le dans cette zone</span>
- <input id="compte-upload" class="import-excel" name="compte-upload" type="file" onchange="dargAndDrop()" accept=".csv" required>
- </div>
- <br />
- <?php button::confirm(
- array(
- "value" => "Charger le dernier CSV émanant du ".$banque["label"]." de Crédit Mutuel",
- "text" => "Vérifiez que le CSV correspond au bon compte. Le compte de destination est ".$banque["label"]." (N°".$banque["compte"].")"
- )
- ) ?>
- </form>
- <script>
- function dargAndDrop(){
- var fileInput = $("#compte-upload");
- var fileName = fileInput.val().split('\\').pop();
- var ext = fileName.split('.').pop().toLowerCase();
- var fileAttendu = "<?php echo banque::fileName($banque["compte"]) ?>";
-
- if(ext !== "csv"){
- $("#printToastErrorTxt").html("Seuls les fichiers CSV sont acceptés");
- $("#printToastError").toast('show');
- fileInput.val("");
- } else {
- if(fileName.includes(fileAttendu)){
- $(".file-message").text("Fichier prêt à être chargé : " + fileName);
- } else {
- $("#printToastErrorTxt").html("Le fichier "+ fileName +" ne semble pas être associé au bon compte.");
- $("#printToastError").toast('show');
- fileInput.val("");
- }
- }
- }
- </script>
- <?php
- }
- ?>
|