|
|
@@ -0,0 +1,148 @@
|
|
|
+<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 : Insérer une ligne dans l'épargne financière</span>
|
|
|
+ </h2>
|
|
|
+</header>
|
|
|
+<?php
|
|
|
+ $banque = banque::getInitialCompte(4); // ID du compte épargne
|
|
|
+
|
|
|
+ echo core::filAriane(array(
|
|
|
+ "current" => "Importer un CSV",
|
|
|
+ "arbo" => array(
|
|
|
+ "Comptes bancaires" => NULL,
|
|
|
+ $banque["label"] => "/compte-4.html",
|
|
|
+ "Insérer une ligne" => NULL)
|
|
|
+ ));
|
|
|
+
|
|
|
+ $lastLigne = banque::lastArrayRecord(4); // ID du compte épargne
|
|
|
+ if($lastLigne["debit"] == "0.00" AND $lastLigne["credit"] == "0.00"){
|
|
|
+ $montant = "0.00";
|
|
|
+ $type = "Intial";
|
|
|
+ } elseif($lastLigne["debit"] == "0.00"){
|
|
|
+ $montant = $lastLigne["credit"];
|
|
|
+ $type = "Crédit";
|
|
|
+ } else {
|
|
|
+ $montant = $lastLigne["debit"];
|
|
|
+ $type = "Débit";
|
|
|
+ }
|
|
|
+?>
|
|
|
+<br />
|
|
|
+<form action="/submit.php" method="post" onsubmit="loading()">
|
|
|
+ <input type="hidden" name="from" value="compte-insert">
|
|
|
+ <input type="hidden" name="compte" value="<?php echo $banque["compte"] ?>">
|
|
|
+
|
|
|
+ <table>
|
|
|
+ <tr>
|
|
|
+ <td>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>Date</label>
|
|
|
+ <input type="date" min="<?php echo $lastLigne["date"] ?>" max="<?php echo date("Y-m-d") ?>" class="form-control" value="" name="date" placeholder="" required>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td width="40%">
|
|
|
+ <div class="form-group">
|
|
|
+ <label>Label</label>
|
|
|
+ <input type="text" class="form-control" value="" name="label" placeholder="" required>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>Montant</label>
|
|
|
+ <input type="number" class="form-control" value="" name="montant" placeholder="" required>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>Type de la ligne</label>
|
|
|
+ <select name="type" class="form-select" name="type" required>
|
|
|
+ <option value=""></option>
|
|
|
+ <option value="1"<?php if(isset($ligne["type"]) AND $ligne["type"] == 1){ echo " selected"; } ?>>Crédit</option>
|
|
|
+ <option value="2"<?php if(isset($ligne["type"]) AND $ligne["type"] == 2){ echo " selected"; } ?>>Débit</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>Solde</label>
|
|
|
+ <input type="text" class="form-control" value="" name="solde" placeholder="" readonly>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <div class="form-group">
|
|
|
+ <label></label>
|
|
|
+ <?php button::confirm(
|
|
|
+ array(
|
|
|
+ "value" => "Insérer",
|
|
|
+ "text" => "Vous allez insérer une ligne dans le compte ".$banque["label"].".<br />Assurez-vous que les informations sont correctes avant de valider.",
|
|
|
+ "class" => "btn btn-primary",
|
|
|
+ )
|
|
|
+ ) ?>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <td>
|
|
|
+ <div class="form-group">
|
|
|
+ <input type="text" class="form-control" value="<?php echo core::convertDate($lastLigne["date"], FALSE) ?>" disabled>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <div class="form-group">
|
|
|
+ <input type="text" class="form-control" value="<?php echo $lastLigne["label"] ?>" disabled>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <div class="form-group">
|
|
|
+ <input type="text" class="form-control" value="<?php echo $montant ?>" disabled>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <div class="form-group">
|
|
|
+ <input type="text" class="form-control" value="<?php echo $type ?>" disabled>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <div class="form-group">
|
|
|
+ <input type="text" class="form-control" value="<?php echo $lastLigne["solde"] ?>" disabled>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td><span style="color:grey">Dernière ligne</span></td>
|
|
|
+ </tr>
|
|
|
+ </table>
|
|
|
+</form>
|
|
|
+
|
|
|
+
|
|
|
+<script>
|
|
|
+document.addEventListener("DOMContentLoaded", function () {
|
|
|
+ const montantInput = document.querySelector('input[name="montant"]');
|
|
|
+ const typeSelect = document.querySelector('select[name="type"]');
|
|
|
+ const soldeInput = document.querySelector('input[name="solde"]');
|
|
|
+
|
|
|
+ // Valeur initiale du solde (à adapter dynamiquement si besoin)
|
|
|
+ let soldePrecedent = parseFloat("<?php echo $lastLigne['solde'] ?? 0; ?>");
|
|
|
+
|
|
|
+ function updateSolde() {
|
|
|
+ const montant = parseFloat(montantInput.value);
|
|
|
+ const type = typeSelect.value;
|
|
|
+
|
|
|
+ if (!isNaN(montant) && type) {
|
|
|
+ let nouveauSolde = soldePrecedent;
|
|
|
+
|
|
|
+ if (type === "1") { // Crédit
|
|
|
+ nouveauSolde += montant;
|
|
|
+ } else if (type === "2") { // Débit
|
|
|
+ nouveauSolde -= montant;
|
|
|
+ }
|
|
|
+
|
|
|
+ soldeInput.value = nouveauSolde.toFixed(2);
|
|
|
+ } else {
|
|
|
+ soldeInput.value = soldePrecedent.toFixed(2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ montantInput.addEventListener("input", updateSolde);
|
|
|
+ typeSelect.addEventListener("change", updateSolde);
|
|
|
+});
|
|
|
+</script>
|