Browse Source

Ajout de banque

stany.ferer 1 year ago
parent
commit
6f3abe59dd

+ 3 - 0
conf.inc.php

@@ -37,6 +37,9 @@ define("DB_T_LOTTERY", "lottery");
 define("DB_T_LOTTERY_INSCRITS", "lottery_salaries");
 define("DB_T_HISTORIQUE", "historique");
 define("DB_T_HISTORIQUE_REF", "historiqueRef");
+define("DB_T_BANQUE_COMPTES", "banque_comptes");
+define("DB_T_BANQUE_LIGNES", "banque_lignes");
+define("DB_T_BANQUE_CSV", "banque_csv");
 
 define("DEFAUT_PAGE", "rh-liste-salaries");
 define("DEFAUT_PAGE_SOCIAL", "sociale-check-salarie");

+ 221 - 0
core/class/banque.class.php

@@ -0,0 +1,221 @@
+<?php
+
+class banque
+{
+
+    public static function getInitial(int $_id)
+    {
+        $tmp = self::getInitialCompte($_id );
+        $return = array(
+            "num" => 0,
+            "id" => 0,
+            "date" => $tmp["solde_date"],
+            "label" => "SOLDE CREDITEUR AU " . core::convertDate($tmp["solde_date"], FALSE),
+            "debit" => 0,
+            "credit" => 0,
+            "solde" => $tmp["solde"],
+        );
+        return $return;
+    }
+
+    public static function getInitialCompte(int $_id)
+    {
+        db::query("SELECT "
+            . "* "
+            . "FROM " . DB_T_BANQUE_COMPTES . " "
+            . "WHERE " . DB_T_BANQUE_COMPTES . ".id = :id");
+            db::bind(':id', $_id);
+            return db::single();
+    }
+    
+    public static function getLignes(int $_id)
+    {
+        db::query("SELECT "
+            . "ROW_NUMBER() OVER (ORDER BY id) num, "
+            . "" . DB_T_BANQUE_LIGNES . ".id, "
+            . "" . DB_T_BANQUE_LIGNES . ".date, "
+            . "" . DB_T_BANQUE_LIGNES . ".label, "
+            . "" . DB_T_BANQUE_LIGNES . ".debit, "
+            . "" . DB_T_BANQUE_LIGNES . ".credit, "
+            . "" . DB_T_BANQUE_LIGNES . ".solde "
+            . "FROM " . DB_T_BANQUE_LIGNES . " "
+            . "WHERE " . DB_T_BANQUE_LIGNES . ".id_compte = :id_compte");
+            db::bind(':id_compte', $_id);
+            return db::resultset();
+    }
+
+    public static function getEtatCompte(int $_id)
+    {
+        db::query("SELECT "
+            . "" . DB_T_BANQUE_LIGNES . ".solde, "
+            . "" . DB_T_BANQUE_LIGNES . ".date "
+            . "FROM " . DB_T_BANQUE_LIGNES . " "
+            . "WHERE " . DB_T_BANQUE_LIGNES . ".id_compte = :id_compte "
+            . "ORDER BY " . DB_T_BANQUE_LIGNES . ".id DESC");
+            db::bind(':id_compte', $_id);
+            return db::single();
+    }
+
+    public static function getHistoriqueCSV()
+    {
+        db::query("SELECT "
+            . "" . DB_T_FILES . ".id, "
+            . "" . DB_T_FILES . ".name, "
+            . "" . DB_T_FILES . ".size, "
+            . "" . DB_T_FILES . ".creer, "
+            . "CONCAT (" . DB_T_USER . ".prenom, ' ', " . DB_T_USER . ".nom) AS 'user' "
+            . "FROM " . DB_T_FILES . " "
+            . "INNER JOIN " . DB_T_USER . " ON " . DB_T_FILES . ".id_user = " . DB_T_USER . ".id "
+            . "INNER JOIN " . DB_T_BANQUE_CSV . " ON " . DB_T_BANQUE_CSV . ".md5 = " . DB_T_FILES . ".id");
+        return db::resultset();
+    }
+
+    public static function addMd5CSV(string $_md5, int $_id_compte)
+    {
+        db::query("INSERT INTO " . DB_T_BANQUE_CSV . " (md5, id_compte) VALUES (:md5, :id_compte)");
+        db::bind(':md5', $_md5);
+        db::bind(':id_compte', $_id_compte);
+
+        try {
+            db::execute();
+            return TRUE;
+        } catch (Exception $ex) {
+            return FALSE;
+        }
+    }
+
+    public static function findMd5(string $_md5)
+    {
+        db::query("SELECT "
+            . "id "
+            . "FROM " . DB_T_BANQUE_LIGNES . " "
+            . "WHERE " . DB_T_BANQUE_LIGNES . ".md5 = :md5");
+            db::bind(':md5', $_md5);
+            if(empty(db::single()["id"])){
+                return FALSE;
+            } else {
+                return TRUE;
+            }
+
+            return db::single()["id"];
+    }
+
+    public static function recordLigne(array $_array, int $_id){
+        if(self::findMd5($_array["md5"]) == FALSE){
+            
+            db::query("INSERT INTO " . DB_T_BANQUE_LIGNES . " (id_compte, date, label, debit, credit, solde, md5) VALUES (:id_compte, :date, :label, :debit, :credit, :solde, :md5)");
+            db::bind(':id_compte', $_id);
+            db::bind(':date', $_array["date"]);
+            db::bind(':label', $_array["label"]);
+            db::bind(':debit', $_array["debit"]);
+            db::bind(':credit', $_array["credit"]);
+            db::bind(':solde', $_array["solde"]);
+            db::bind(':md5', $_array["md5"]);
+
+            try {
+                db::execute();
+                return TRUE;
+            } catch (Exception $ex) {
+                return FALSE;
+            }
+        }
+
+        return FALSE;
+    }
+
+    public static function recordLignes(array $_array, int $_id){
+        $z = 0;
+        foreach ($_array as $values) {
+            if(self::recordLigne($values, $_id) == TRUE){
+                $z++;
+            }
+        }
+        return $z;
+    }
+
+    public static function readCompte(array $_temp) {
+        $data = [];
+
+        if (!file_exists($_temp['tmp_name']) || !is_readable($_temp['tmp_name'])) {
+            return false;
+        }
+
+        if (($handle = fopen($_temp['tmp_name'], 'r')) !== false) {
+            $header = NULL;
+            $a = -1;
+            while (($row = fgetcsv($handle, 1000, ";")) !== false) {
+                $a++;
+
+                $convertedRow = array_map(function ($field) {
+                    return mb_convert_encoding($field, 'UTF-8', 'ISO-8859-1');
+                }, $row);
+
+                if ($header == NULL) {
+                    $header = TRUE;
+                    if(
+                        $convertedRow[0] != "Date" OR 
+                        $convertedRow[1] != "Date de valeur" OR
+                        $convertedRow[2] != "Débit" OR
+                        $convertedRow[3] != "Crédit" OR
+                        $convertedRow[4] != "Libellé" OR
+                        $convertedRow[5] != "Solde"
+                        ){
+                            ($convertedRow[0] != "Date") ? alert::recError("La 1er colonne doit se nommer Date") : "";
+                            ($convertedRow[1] != "Date de valeur") ? alert::recError("La 2em colonne doit se nommer Date de valeur") : "";
+                            ($convertedRow[2] != "Débit") ? alert::recError("La 3em colonne doit se nommer Débit") : "";
+                            ($convertedRow[3] != "Crédit") ? alert::recError("La 4em colonne doit se nommer Crédit") : "";
+                            ($convertedRow[4] != "Libellé") ? alert::recError("La 5em colonne doit se nommer Libellé") : "";
+                            ($convertedRow[5] != "Solde") ? alert::recError("La 6em colonne doit se nommer Solde") : "";
+                            alert::recError("Le fichier " . $_temp['name'] . " n'est pas un CSV de la banque Crédit Mutuel.");
+                            return FALSE;
+                        }
+
+                } else {
+                    $data[$a]["date"] = self::convertToMySqlDate($convertedRow[0]);
+                    $data[$a]["label"] = $convertedRow[4];
+                    $data[$a]["debit"] = self::transformerChaineEnNombre($convertedRow[2]);
+                    $data[$a]["credit"] = self::transformerChaineEnNombre($convertedRow[3]);
+                    $data[$a]["solde"] = self::transformerChaineEnNombre($convertedRow[5], TRUE);
+                    $data[$a]["md5"] = md5($data[$a]["date"].$data[$a]["debit"].$data[$a]["credit"].$data[$a]["solde"]);
+                }
+            }
+            fclose($handle);
+        }
+
+        return $data;
+    }
+
+    public static function transformerChaineEnNombre(string $_chaine, bool $_negatif = FALSE) {
+        // Supprimer les tirets "-"
+        if($_negatif == 0) {
+            $chaine = str_replace('-', '', $_chaine);
+        } else {
+            $chaine = $_chaine;
+        }
+    
+        // Remplacer les virgules par des points
+        $chaine = str_replace(',', '.', $chaine);
+    
+        // Convertir en nombre à virgule flottante (float)
+        $nombre = (float) $chaine;
+    
+        return $nombre;
+    }
+
+    public static function convertToMySqlDate($date) {
+        // Crée un objet DateTime à partir de la date au format dd/mm/yyyy
+        $dateTime = DateTime::createFromFormat('d/m/Y', $date);
+        
+        // Vérifie si la date est valide
+        if ($dateTime === false) {
+            return false; // Retourne false si la date n'est pas valide
+        }
+        
+        // Retourne la date au format MySQL (yyyy-mm-dd)
+        return $dateTime->format('Y-m-d');
+    }
+
+    public static function getEuro(float $_decimal){
+        return number_format($_decimal, 2, ',', '.') . " €";
+    }
+}

+ 45 - 0
core/class/button.class.php

@@ -0,0 +1,45 @@
+<?php
+
+class button
+{
+    public static function confirm(array $_array = NULL)
+    {
+        $config = array(
+            "value" => "Valider",
+            "title" => "Confirmation",
+            "text" => "Vous êtes certain de vouloir poursuivre ?",
+            "confirm" => "Continuer",
+            "cancel" => "Annuler",
+            "type" => "submit",
+            "class" => "btn btn-primary btn-lg",
+            "style" => "width: 100%"
+        );
+
+        if($_array != NULL){
+            (!empty($_array["value"])) ? $config["value"] = $_array["value"] : NULL;
+            (!empty($_array["text"])) ? $config["text"] = $_array["text"] : NULL;
+            (!empty($_array["title"])) ? $config["title"] = $_array["title"] : NULL;
+            (!empty($_array["confirm"])) ? $config["confirm"] = $_array["confirm"] : NULL;
+            (!empty($_array["cancel"])) ? $config["cancel"] = $_array["cancel"] : NULL;
+            (!empty($_array["type"])) ? $config["type"] = $_array["type"] : NULL;
+            (!empty($_array["class"])) ? $config["class"] = $_array["class"] : NULL;
+            (!empty($_array["style"])) ? $config["style"] = $_array["style"] : NULL;
+            (!empty($_array["id"])) ? $config["id"] = $_array["id"] : NULL;
+        }
+        
+        $print = "<input ";
+        $print .= 'class="' . $config["class"] .'" ';
+        $print .= 'style="' . $config["style"] .'" ';
+        $print .= 'type="' . $config["type"] .'" ';
+        $print .= 'value="' . $config["value"] .'" ';
+        $print .= 'data-confirm="' . $config["text"] .'" ';
+        $print .= 'data-confirm-title="' . $config["title"] .'" ';
+        $print .= 'data-confirm-button-confirm="' . $config["confirm"] .'" ';
+        $print .= 'data-confirm-button-cancel="' . $config["cancel"] .'" ';
+        if(!empty($_array["id"])) { $print .= 'id="' . $config["id"] .'" '; }
+        $print .= ">";
+
+        echo $print;
+    }
+
+}

+ 4 - 4
core/class/core.class.php

@@ -102,7 +102,7 @@ class core
     public static function convertDate(string $_datetime, bool $_hour = TRUE)
     {
         $pieces = explode(" ", $_datetime);
-        $pieces3 = explode(":", $pieces[1]);
+        if($_hour == TRUE) { $pieces3 = explode(":", $pieces[1]); }
         $pieces2 = explode("-", $pieces[0]);
         if($_hour == TRUE){
             return $pieces2[2] . "/" . $pieces2[1] . "/" . $pieces2[0] . " à " . $pieces3[0] . ":" . $pieces3[1];
@@ -183,11 +183,11 @@ class core
             </li>';
     }
 
-    public static function elementMenuH6(string $_titre, string $_style = NULL)
+    public static function elementMenuH6(string $_titre, string $_style = NULL, string $_collapse = NULL)
     {
-        ($_style != NULL) ? $_style = ' style="' . $_style . '"' : NULL;
+        ($_style != NULL) ? $_style = $_style : NULL;
         echo '<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
-                    <span' . $_style . '>' . $_titre . '</span>
+                    <a style="text-decoration: none; ' . $_style . '" href="#'.$_collapse.'" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle text-dark">' . $_titre . '</a>
                 </h6>';
     }
 

+ 7 - 0
core/class/csv.class.php

@@ -0,0 +1,7 @@
+<?php
+
+class csv
+{
+
+    
+}

+ 32 - 2
core/class/get.class.php

@@ -18,7 +18,7 @@ class get
         } elseif (core::ifGet("p")) {
             $page = core::getGet("p");
         } else {
-            if (session::accessUserByType(1) OR session::accessUserByType(4)) { // Admin
+            if (session::accessUserByType(1) or session::accessUserByType(4)) { // Admin
                 $page = DEFAUT_PAGE;
             } elseif (session::accessUserByType(3)) { // Assistance sociale
                 $page = DEFAUT_PAGE_SOCIAL;
@@ -107,9 +107,39 @@ class get
         return (isset($data["dateData"])) ? $data["dateData"] : NULL;
     }
 
+    public static function splitIdPage($_page = NULL)
+    {
+        $return = array(
+            "page" => NULL,
+            "id" => NULL,
+        );
+
+        $split = explode("-", $_page);
+        foreach ($split as $val) {
+            if (is_numeric($val)) {
+                $return["id"] = $val;
+            } else {
+                $return["page"] .= $val . "-";
+            }
+        }
+
+        $return["page"] = substr($return["page"], 0, -1);
+        return $return;
+    }
+
     public static function currentPage($_page = NULL)
     {
-        if (core::getGet("p") == $_page) {
+        if($_page != NULL){
+            $page = self::splitIdPage($_page);
+        } else {
+            $page = NULL;
+        }
+
+        if (core::getGet("id") == $page["id"] AND core::getGet("p") == $page["page"]) {
+            return " active";
+        } elseif (core::getGet("p") == $_page) {
+            return " active";
+        } elseif (core::getGet("p") == $_page) {
             return " active";
         } elseif (!core::ifGet("p") and (($_SESSION["user"]["idType"] == 1 and $_page == DEFAUT_PAGE) or ($_SESSION["user"]["idType"] == 3 and $_page == DEFAUT_PAGE_SOCIAL))) {
             return " active";

+ 38 - 0
core/class/json.class.php

@@ -32,6 +32,21 @@ class json extends db
                 case "lotterys":
                     return self::create_lotterys();
                     break;
+                case "banque-lignes-1":
+                    return self::create_banque_lignes(1);
+                    break;
+                case "banque-lignes-2":
+                    return self::create_banque_lignes(2);
+                    break;
+                case "banque-lignes-3":
+                    return self::create_banque_lignes(3);
+                    break;
+                case "banque-lignes-4":
+                    return self::create_banque_lignes(4);
+                    break;
+                case "banque-csv":
+                    return self::create_banque_csv();
+                    break;
             }
         } else {
             return 0;
@@ -137,6 +152,29 @@ class json extends db
         }
     }
 
+    private static function create_banque_csv()
+    {
+        $row = banque::getHistoriqueCSV();
+        if (file_put_contents(DIR_DATAS_JSON . "banque-csv.json", json_encode($row))) {
+            return 1;
+        } else {
+            return 0;
+        }
+    }
+
+    private static function create_banque_lignes(int $_id)
+    {
+        $row = array(banque::getInitial($_id));
+        $row2 = banque::getLignes($_id, $row[0]["solde"]);
+        $return = array_merge($row, $row2);
+
+        if (file_put_contents(DIR_DATAS_JSON . "banque-lignes-" . $_id . ".json", json_encode($return))) {
+            return 1;
+        } else {
+            return 0;
+        }
+    }
+
     public static function delete(string $_target)
     {
         if (is_file(DIR_DATAS_JSON . "/" . $_target . ".json")) {

+ 15 - 2
core/class/salaries.class.php

@@ -101,6 +101,20 @@ class salaries
         return db::single();
     }
 
+    public static function deleteExcelJsonForSFTP(int $_id)
+    {
+        db::query("UPDATE " . DB_T_EXCEL . " SET "
+            . "createForSFTP = NULL "
+            . "WHERE id = :id");
+        db::bind(':id', $_id);
+        try {
+            db::execute();
+            return TRUE;
+        } catch (Exception $e) {
+            return FALSE;
+        }
+    }
+
     public static function getExcelJsonTransferForSFTP(string $_md5)
     {
         // Récupération des données de l'excel au format Json
@@ -688,7 +702,6 @@ class salaries
     {
         $lastExcel = self::lastExcelForSFTP();
         $forSFTP = self::getExcelJsonForSFTP($lastExcel);
-        $finalSalarie = NULL;
         $csv = "OD_" . date("d-m-Y") . ".csv";
 
         $tmpSFTP = fopen(SFTP_LOCAL . $csv, "w");
@@ -697,7 +710,7 @@ class salaries
         foreach (json_decode($forSFTP["forSFTP"], TRUE) as $salarie) {
 
             $tmpSalarie = NULL;
-
+// TODO Extract
             if (isset($salarie["loginId"]) and $salarie["loginId"] != "" and isset($salarie["jourSortie"])) {
                 $tmpSalarie["loginId"] = $salarie["loginId"];
                 $tmpSalarie["jourSortie"] = $salarie["jourSortie"];

+ 0 - 1
core/json/cms.historique.php

@@ -2,7 +2,6 @@
 
 $row = historique::getAll();
 if (!empty($row)) {
-    $row[0]["log"] = nl2br($row[0]["log"]);
     echo json_encode($row);
     exit();
 } else {

+ 100 - 0
core/submit/cms.compte-upload.php

@@ -0,0 +1,100 @@
+<?php
+
+if (core::ifPost("from") AND core::getPost("from") == "compte-upload") {
+
+    if (isset($_FILES[core::getPost("from")]['error']) AND $_FILES[core::getPost("from")]['error'] > 0) {
+
+        switch ($_FILES[core::getPost("from")]['error']) {
+            case 1: // UPLOAD_ERR_INI_SIZE
+                alert::recError("Le fichier dépasse la limite autorisée par le serveur (fichier php.ini) !");
+                break;
+            case 2: // UPLOAD_ERR_FORM_SIZE
+                alert::recError("Le fichier dépasse la limite autorisée dans le formulaire HTML !");
+                break;
+            case 3: // UPLOAD_ERR_PARTIAL
+                alert::recError("L'envoi du fichier a été interrompu pendant le transfert !");
+                break;
+            case 4: // UPLOAD_ERR_NO_FILE
+                alert::recError("Vous n'avez pas chargé de fichier");
+                break;
+        }
+    } elseif ($_FILES[core::getPost("from")]['type'] != "text/csv") {
+        alert::recError("Seuls les fichiers CSV sont acceptés (".$_FILES[core::getPost("from")]['type'].")");
+        header("Location: /p=compte-upload&add=".core::getPost("add"));
+        exit();
+    } else {
+
+        if (file_exists($_FILES[core::getPost("from")]['tmp_name'])) {
+            $csvValue = banque::readCompte($_FILES[core::getPost("from")]);
+
+            if($csvValue == FALSE){
+                historique::recRef("/compte-".core::getPost("add").".html");
+                historique::add(array(
+                    "idType" => historique::getIdRef("ERROR"),
+                    "idUser" => session::getId(),
+                    "idPage" => historique::getIdRef("/compte-".core::getPost("add").".html"),
+                    "log" => "Erreur lors du chargement du fichier : " . $_FILES[core::getPost("from")]['name']
+                ));
+                historique::recordAlert("ERROR");
+                header("Location: /compte-".core::getPost("add").".html");
+                exit();
+            }
+
+            $data["md5File"] = file::record($_FILES[core::getPost("from")]);
+            if($data["md5File"] == FALSE){
+                alert::recError("Ce CSV " . $_FILES[core::getPost("from")]['name'] . " a déjà été importé.");
+                header("Location: /compte-historique-csv.html");
+                exit();
+            }
+
+            // Backup
+            (backup::create()) ? alert::recSuccess("Backup des données OK") : alert::recError("Backup des données KO");
+            banque::addMd5CSV($data["md5File"], core::getPost("add"));
+
+            // Création du CSV
+            json::create("banque-csv");
+            json::create("banque-lignes-".core::getPost("add"));
+
+            $nbLignes = banque::recordLignes($csvValue, core::getPost("add"));
+
+            if($nbLignes == 0){
+                $log = "Aucune ligne n'a été extraite du fichier : " . $_FILES[core::getPost("from")]['name'];
+            } elseif($nbLignes == 1){
+                $log = "Une seule ligne n'a été extraite du fichier : " . $_FILES[core::getPost("from")]['name'];
+            } else {
+                $log = $nbLignes . " lignes n'ont été extraites du fichier : " . $_FILES[core::getPost("from")]['name'];
+            }
+
+            historique::recRef("/compte-".core::getPost("add").".html");
+            historique::add(array(
+                "idType" => historique::getIdRef("ACTION"),
+                "idUser" => session::getId(),
+                "idPage" => historique::getIdRef("/compte-".core::getPost("add").".html"),
+                "log" => $log
+            ));
+            historique::recordAlert("SUCCESS");
+
+            alert::recSuccess($log);
+
+            header("Location: /compte-".core::getPost("add").".html");
+            exit();
+        } else {
+            historique::recRef("/compte-".core::getPost("add").".html");
+            historique::add(array(
+                "idType" => historique::getIdRef("ERROR"),
+                "idUser" => session::getId(),
+                "idPage" => historique::getIdRef("/compte-".core::getPost("add").".html"),
+                "log" => "Erreur lors du chargement du fichier : " . $_FILES[core::getPost("from")]['name']
+            ));
+            historique::recordAlert("ERROR");
+            alert::recError("Erreur lors du chargement du fichier : " . $_FILES[core::getPost("from")]['name']);
+        }
+    }
+
+    header("Location: /compte-".core::getPost("add").".html");
+    exit();
+} else {
+    header('HTTP/1.0 401 Unauthorized');
+    exit();
+}
+

+ 1 - 1
core/submit/cms.sftp-delete-file-local.php

@@ -1,7 +1,7 @@
 <?php
 
 if(core::ifPost("from")){
-    if (unlink(SFTP_LOCAL.core::getPost("file"))) { 
+    if (unlink(SFTP_LOCAL.core::getPost("file")) AND salaries::deleteExcelJsonForSFTP(salaries::lastExcel())) { 
 
         historique::recRef("/proweb-export-csv.html");
         historique::add(array(

+ 2 - 1
core/views/_cms.head.php

@@ -21,7 +21,8 @@
         <script src="libs/feather-icons/feather.min.js" type="text/javascript"></script>
         <script src="libs/js/modernizr.min.js" type="text/javascript"></script>
         <script src="libs/js/Chart.min.js" type="text/javascript"></script>
-        
+        <script src="libs/js/powerbuttons.min.js"></script>
+
         <style>
 
             .bd-placeholder-img {

+ 62 - 8
core/views/_cms.menu.php

@@ -1,9 +1,13 @@
 <nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
     <div class="position-sticky pt-2">
-        <ul class="nav flex-column">
+        <ul class="nav flex-column" id="accordion">         
+
             <?php  
+                $temp_accordion = array("rh-liste-salaries", "rh-historique-excel", "rh-upload-excel", "rh-import-to-temp", "stats");
+                (in_array(core::getGet("p"), $temp_accordion) OR core::ifGet("p") == FALSE) ? $_show = "show" : $_show = NULL;
                 (session::access(array(1, 4))) ? 
-                    core::elementMenuH6("Salariés") : NULL;
+                    core::elementMenuH6("Salariés", NULL, "col-salaries") : NULL;
+                echo '<ul class="collapse '. $_show .' list-unstyled" id="col-salaries" data-parent="#accordion">';
                 (session::access(array(1, 4))) ? 
                     core::elementMenu("rh-liste-salaries", "/", "RH : Liste des salariés", "users") : NULL;
                 (session::access(array(1, 4))) ? 
@@ -12,39 +16,89 @@
                     core::elementMenu("rh-import-to-temp", "/rh-import-to-temp.html", "RH : Reprise du traitement", "file-text") : NULL;
                 (session::access(array(1, 4))) ? 
                     core::elementMenu("stats", "/stats.html", "RH : Stats salariés", "pie-chart") : NULL;
-                
+                echo '</ul>';
+
+                $temp_accordion = array("proweb-salaries", "proweb-historique-excel", "proweb-export-csv", "proweb-salaries-upload");
+                (in_array(core::getGet("p"), $temp_accordion)) ? $_show = "show" : $_show = NULL;
                 (session::access(array(1, 4))) ? 
-                    core::elementMenuH6("ProWeb") : NULL;
+                    core::elementMenuH6("ProWeb", NULL, "col-proweb") : NULL;
+                echo '<ul class="collapse '. $_show .' list-unstyled" id="col-proweb" data-parent="#accordion">';
                 (session::access(array(1, 4))) ? 
                     core::elementMenu("proweb-salaries", "/proweb-salaries.html", "Proweb : Liste des salariés", "archive") : NULL;
                 (session::access(array(1, 4))) ? 
                     core::elementMenu("proweb-historique-excel", "/proweb-historique-excel.html", "Proweb : Historique des Excels", "file-text") : NULL;
                 (session::access(array(1, 4))) ? 
                 core::elementMenu("proweb-export-csv", "/proweb-export-csv.html", "Proweb : Transfert des données", "send") : NULL;
+                echo '</ul>';
+
+                $temp_accordion = array("compte", "compte-historique-csv", "compte-upload");
+                (in_array(core::getGet("p"), $temp_accordion)) ? $_show = "show" : $_show = NULL;
+                (session::access(array(1, 4))) ? 
+                    core::elementMenuH6("Comptes bancaires", NULL, "col-banque") : NULL;
+                echo '<ul class="collapse '. $_show .' list-unstyled" id="col-banque" data-parent="#accordion">';
+                (session::access(array(1, 4))) ? 
+                    core::elementMenu("compte-1", "/compte-1.html", "Banque : Compte Courant ASC", "shopping-bag") : NULL;
+                (session::access(array(1, 4))) ? 
+                    core::elementMenu("compte-2", "/compte-2.html", "Banque : Compte Courant AEP", "shopping-bag") : NULL;
+                (session::access(array(1, 4))) ? 
+                    core::elementMenu("compte-3", "/compte-3.html", "Banque : Livret OBNL TRIPLEX", "shopping-bag") : NULL;
+                (session::access(array(1, 4))) ? 
+                    core::elementMenu("compte-4", "/compte-4.html", "Banque : Épargne financière", "shopping-bag") : NULL;
+                (session::access(array(1, 4))) ? 
+                    core::elementMenu("compte-historique-csv", "/compte-historique-csv.html", "Banque : Historique des CSV", "file-text") : NULL;
+                echo '</ul>';
                 
+                $temp_accordion = array("sociale-check-salarie");
+                (in_array(core::getGet("p"), $temp_accordion)) ? $_show = "show" : $_show = NULL;
                 (session::access(array(1, 3, 4))) ? 
-                    core::elementMenuH6("Accès services sociaux") : NULL;
+                    core::elementMenuH6("Accès services sociaux", NULL, "col-sociaux") : NULL;
+                echo '<ul class="collapse '. $_show .' list-unstyled" id="col-sociaux" data-parent="#accordion">';
                 (session::access(array(1, 3, 4))) ?
                     core::elementMenu("sociale-check-salarie", "/sociale-check-salarie.html", "Validation d'un compte salarié", "check-square") : NULL;
+                echo '</ul>';
 
+                $temp_accordion = array("evenements", "evenement", "lotterys", "lottery");
+                (in_array(core::getGet("p"), $temp_accordion)) ? $_show = "show" : $_show = NULL;
                 (session::access(array(1, 4))) ? 
-                    core::elementMenuH6("Evènements") : NULL;
+                    core::elementMenuH6("Evènements", NULL, "col-events") : NULL;
+                echo '<ul class="collapse '. $_show .' list-unstyled" id="col-events" data-parent="#accordion">';
                 (session::access(array(1, 4))) ? 
                     core::elementMenu("evenements", "/evenements.html", "Listes des évènements", "calendar") : NULL;
                 (session::access(array(1, 4))) ? 
                     core::elementMenu("lotterys", "/lotterys.html", "Listes des tirages au sort", "zap") : NULL;
+                echo '</ul>';
                 
+                $temp_accordion = array();
+                (in_array(core::getGet("p"), $temp_accordion)) ? $_show = "show" : $_show = NULL;
                 (session::access(array(1, 4))) ? 
-                    core::elementMenuH6("Pratiques") : NULL;
+                    core::elementMenuH6("Pratiques", NULL, "col-practice") : NULL;
+                echo '<ul class="collapse '. $_show .' list-unstyled" id="col-practice" data-parent="#accordion">';
                 (session::access(array(1, 4))) ?
                     core::elementMenuLink("https://corporatedirectory.capgemini.com/MyDirectory/portals/std/index-portal.jsp", "Corporate Directory", "link") : NULL;
+                (session::access(array(1, 4))) ?
+                    core::elementMenuLink("https://www.cse-invent.com", "Site du CSE", "link") : NULL;
+                (session::access(array(1, 4))) ?
+                    core::elementMenuLink("https://" . DOMAIN_EVENTS, "Emargement Salariés", "link") : NULL;
+                (session::access(array(1, 4))) ?
+                    core::elementMenuLink("https://" . DOMAIN_CONTROL, "Emargement Contrôleur", "link") : NULL;
+                (session::access(array(1, 4))) ?
+                    core::elementMenuLink("https://wiki.cse-invent.com", "Wiki CSE", "link") : NULL;
+                (session::access(array(1, 4))) ?
+                    core::elementMenuLink("https://contact.cse-invent.com", "Contact CSE", "link") : NULL;
+                (session::access(array(1, 4))) ?
+                    core::elementMenuLink("https://sender.cse-invent.com", "SendPortal CSE", "link") : NULL;
+                echo '</ul>';
 
+                $temp_accordion = array("parametres", "historique");
+                (in_array(core::getGet("p"), $temp_accordion)) ? $_show = "show" : $_show = NULL;
                 (session::access(array(1))) ? 
-                    core::elementMenuH6("Administration") : NULL;
+                    core::elementMenuH6("Administration", NULL, "col-admin") : NULL;
+                echo '<ul class="collapse '. $_show .' list-unstyled" id="col-admin" data-parent="#accordion">';
                 (session::access(array(1))) ? 
                     core::elementMenu("parametres", "/parametres.html", "IT : Paramètres", "tool") : NULL;
                 (session::access(array(1))) ? 
                     core::elementMenu("historique", "/historique.html", "IT : Historique", "activity") : NULL;
+                echo '</ul>';
             ?>
         </ul>
     </div>

+ 0 - 10
core/views/_cms.nav.php

@@ -33,16 +33,6 @@
                     <a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown"><?php echo session::getName() ?></a>
                     <div class="dropdown-menu dropdown-menu-end">
                         <a href="/user.html" class="dropdown-item">Mon profil</a>
-                        <?php if(session::access(array(1, 4))) { ?>
-                            <div class="dropdown-divider"></div>
-                            <a href="https://www.cse-invent.com" target="_blank" class="dropdown-item">Site du CSE</a>
-                            <a href="https://www.cse-invent.com/gestion/" target="_blank" class="dropdown-item">Console Proweb</a>
-                            <a href="<?php echo "https://" . DOMAIN_EVENTS ?>" target="_blank" class="dropdown-item">Emargement Salariés</a>
-                            <a href="<?php echo "https://" . DOMAIN_CONTROL ?>" target="_blank" class="dropdown-item">Emargement Contrôleur</a>
-                            <a href="https://wiki.cse-invent.com/" target="_blank" class="dropdown-item">Wiki CSE</a>
-                            <a href="https://contact.cse-invent.com/" target="_blank" class="dropdown-item">Contact CSE</a>
-                            <a href="https://sender.cse-invent.com/" target="_blank" class="dropdown-item">SendPortal CSE</a>
-                        <?php } ?>
                         <div class="dropdown-divider"></div>
                         <a href="/submit.php?from=logout" class="dropdown-item">Se déconnecter</a>
                     </div>

+ 39 - 0
core/views/pages/cms.compte-historique-csv.php

@@ -0,0 +1,39 @@
+<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 : Historique des CSV</span>
+    </h2>
+</header>
+<?php   
+        echo core::filAriane(array(
+            "current" => "Historique des CSV", 
+            "arbo" => array( 
+                "Banque" => NULL,
+                "Historique des CSV" => "/compte-historique-csv.html")
+        )); 
+?>
+<div>
+    <table
+        id="table"
+        class="table-striped table-hover table-sm" 
+        data-page-size="25"
+        data-toggle="table"
+        data-show-columns="true"
+        data-search="true"
+        data-buttons-align="left"
+        data-pagination="true"
+        data-filter-control="true"
+        data-flat="true"
+        data-sort-name="cree"
+        data-sort-order="desc"
+        data-url="/json.php?file=banque-csv">
+        <thead>
+            <tr>
+                <th data-sortable="true" data-field="creer" data-filter-control="input" data-width="160">Charger le</th>
+                <th data-sortable="true" data-field="name" data-filter-control="input">Fichier</th>
+                <th data-sortable="true" data-field="size" data-width-unit="Ko" data-width="40">Poids</th>
+                <th data-sortable="true" data-field="id" data-filter-control="input" data-width="60">Md5</th>
+                <th data-sortable="true" data-field="user" data-filter-control="select" data-width="180">Chargé par</th>
+            </tr>
+        </thead>
+    </table> 
+</div>

+ 42 - 0
core/views/pages/cms.compte-upload.php

@@ -0,0 +1,42 @@
+<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   
+        $banque = banque::getInitialCompte(core::getGet("add"));
+
+        echo core::filAriane(array(
+            "current" => "Importer un CSV", 
+            "arbo" => array( 
+                "Comptes bancaires" => NULL,
+                $banque["label"] => "/compte-". core::getGet("add") .".html",
+                "Importer un CSV" => NULL)
+        )); 
+?>
+<br />
+<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") ?>">
+    <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()">
+    </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 fileName = $("#compte-upload").val().split('\\').pop();
+        $(".file-message").text($(".file-message").text().replace("ou déposez le dans cette zone", "Fichier prêt à être chargé : "+fileName));
+    }
+</script>

+ 75 - 0
core/views/pages/cms.compte.php

@@ -0,0 +1,75 @@
+<header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
+<h2 class="bd-title" id="content">
+    <span>Etat des comptes</span>
+    <a href="/?p=compte-upload&add=<?php echo core::getGet("id") ?>" style="position: absolute; right: 0; margin: 38px 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="plus-square"></span> Charger un CSV</button></a>
+</h2>
+</header>
+<?php   
+        $banque = banque::getInitialCompte(core::getGet("id"));
+        $etatCompte = banque::getEtatCompte(core::getGet("id"));
+
+        echo core::filAriane(array(
+            "current" => $banque["label"] . " (" . banque::getEuro($etatCompte["solde"]) . " au " . core::convertDate($etatCompte["date"], FALSE). ")", 
+            "arbo" => array( 
+                "Comptes bancaires" => NULL,
+                $banque["label"] . " (" . banque::getEuro($etatCompte["solde"]) . " au " . core::convertDate($etatCompte["date"], FALSE) . ")" => "/compte-". core::getGet("id") .".html")
+        )); 
+
+        //json::create("banque-lignes-".core::getGet("id"));
+?>
+
+<div>
+    <table
+        id="table"
+        class="table-striped table-hover table-sm" 
+        data-toggle="table"
+        data-page-size="25"
+        data-pagination="true"
+        data-show-footer="true"
+        data-search="true"
+        data-buttons-align="left"
+        data-filter-control="true"
+        data-flat="true"
+        data-sort-name="num"
+        data-sort-order="desc"
+        data-url="/json.php?file=banque-lignes-<?php echo core::getGet("id") ?>">
+        <thead>
+            <tr>
+                <th data-sortable="true" data-field="num" data-width="20">#</th>
+                <th data-sortable="true" data-field="date" data-filter-control="input" data-width="160">Date</th>
+                <th data-sortable="true" data-field="label" data-filter-control="input">Label</th>
+                <th data-sortable="true" data-formatter="dataFormatter" data-field="debit" data-filter-control="input" data-width="150" data-footer-formatter="debitFormatter">Débit</th>
+                <th data-sortable="true" data-formatter="dataFormatter" data-field="credit" data-filter-control="input" data-width="150" data-footer-formatter="creditFormatter">Crédit</th>
+                <th data-sortable="true" data-formatter="dataFormatter" data-field="solde" data-filter-control="input" data-width="150">Solde</th>
+            </tr>
+        </thead>
+    </table> 
+</div>
+
+<script>
+    let euro = Intl.NumberFormat('de-DE', {
+        style: 'currency',
+        currency: 'EUR',
+    });
+
+    function dataFormatter(value) { 
+        return euro.format(value);
+    }
+
+    function debitFormatter(data) {
+        var total = 0;
+        data.forEach(function (row) {
+            total += parseFloat(row.debit);
+        });
+        return parseFloat(total) === 0 ? euro.format(0.00) : euro.format(total.toFixed(2));
+    }
+
+    function creditFormatter(data) {
+        var total = 0;
+        data.forEach(function (row) {
+            total += parseFloat(row.credit);
+        });
+        return parseFloat(total) === 0 ? euro.format(0.00) : euro.format(total.toFixed(2));
+    }
+
+</script>

+ 1 - 1
core/views/pages/cms.evenements.php

@@ -5,7 +5,7 @@
 <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
 <h2 class="bd-title" id="content">
     <span>Listes des évènements</span>
-    <a href="/?p=evenement&add=1" style="position: absolute; right: 0; margin: 0 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="plus-square"></span> Ajouter un évènement</button></a>
+    <a href="/?p=evenement&add=1" style="position: absolute; right: 0; margin: 38px 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="plus-square"></span> Ajouter un évènement</button></a>
 </h2>
 </header>
 <?php   

+ 1 - 1
core/views/pages/cms.lotterys.php

@@ -5,7 +5,7 @@
 <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
 <h2 class="bd-title" id="content">
     <span>Listes des tirages au sort</span>
-    <a href="/?p=lottery&add=1" style="position: absolute; right: 0; margin: 0 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="plus-square"></span> Ajouter un tirage au sort</button></a>
+    <a href="/?p=lottery&add=1" style="position: absolute; right: 0; margin: 38px 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="plus-square"></span> Ajouter un tirage au sort</button></a>
 </h2>
 </header>
 <?php   

+ 1 - 1
core/views/pages/cms.proweb-historique-excel.php

@@ -1,7 +1,7 @@
 <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
     <h2 class="bd-title" id="content">
         <span>Proweb : Historique des Excels</span>
-        <a href="proweb-salaries-upload.html" style="position: absolute; right: 0; margin: 0 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="file-plus"></span> Importer un fichier Excel</button></a>
+        <a href="proweb-salaries-upload.html" style="position: absolute; right: 0; margin: 38px 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="file-plus"></span> Importer un fichier Excel</button></a>
         <a href="https://www.cse-invent.com/gestion/beneficiaire/od/export-etat/124/excel?type=EtatListe_od" target="_blank" style="position: absolute; right: 0; margin: 0 250px 0 0;"><button type="submit" class="btn btn-outline-secondary btn-sm"><span data-feather="link"></span> Exporter tous les salariés depuis Proweb</button></a>
     </h2>
 </header>

+ 1 - 1
core/views/pages/cms.proweb-salaries.php

@@ -5,7 +5,7 @@ $date = ($dateData != NULL) ? " (au " . core::convertDate($dateData, FALSE) . ")
 <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
     <h2 class="bd-title" id="content">
         <span>Proweb : Liste des salariés<?php echo $date ?></span>
-        <a href="proweb-salaries-upload.html" style="position: absolute; right: 0; margin: 0 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="file-plus"></span> Importer un fichier Excel</button></a>
+        <a href="proweb-salaries-upload.html" style="position: absolute; right: 0; margin: 38px 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="file-plus"></span> Importer un fichier Excel</button></a>
         <a href="https://www.cse-invent.com/gestion/beneficiaire/od/export-etat/124/excel?type=EtatListe_od" target="_blank" style="position: absolute; right: 0; margin: 0 250px 0 0;"><button type="submit" class="btn btn-outline-secondary btn-sm"><span data-feather="link"></span> Exporter tous les salariés depuis Proweb</button></a>
     </h2>
 </header>

+ 1 - 1
core/views/pages/cms.rh-historique-excel.php

@@ -6,7 +6,7 @@
 <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
     <h2 class="bd-title" id="content">
         <span>RH : Historique des Excels</span>
-        <a href="/rh-upload-excel.html" style="position: absolute; right: 0; margin: 0 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="file-plus"></span> Importer un fichier Excel</button></a>
+        <a href="/rh-upload-excel.html" style="position: absolute; right: 0; margin: 38px 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="file-plus"></span> Importer un fichier Excel</button></a>
     </h2>
 </header>
 <?php   

+ 1 - 1
core/views/pages/cms.rh-liste-salaries.php

@@ -5,7 +5,7 @@
 <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
     <h2 class="bd-title" id="content">
         <span>RH : Liste des salariés<?php echo $date ?></span>
-        <a href="/rh-upload-excel.html" style="position: absolute; right: 0; margin: 0 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="file-plus"></span> Importer un fichier Excel</button></a>
+        <a href="/rh-upload-excel.html" style="position: absolute; right: 0; margin: 38px 40px 0 0;"><button type="submit" class="btn btn-outline-success btn-sm"><span data-feather="file-plus"></span> Importer un fichier Excel</button></a>
     </h2>
 </header>
 <?php   

+ 1 - 1
core/views/pages/cms.sociale-check-salarie.php

@@ -73,6 +73,6 @@
             $("#tab-fiche-rechercher").hide();
             $("#tab-fiche-aide").show();
         });
-       
+        
     })
 </script>

File diff suppressed because it is too large
+ 1 - 0
public-cms/libs/js/powerbuttons.min.js


Some files were not shown because too many files changed in this diff