Browse Source

Maj refonte parametres

stany.ferer 2 years ago
parent
commit
ad86f392ac

+ 36 - 0
core/class/core.class.php

@@ -201,4 +201,40 @@ class core
     public static function checkboxSelecter(bool $_val){
         echo ($_val == TRUE) ? "checked" : "";
     }
+
+    public static function resetDatas()
+    {
+        db::query("TRUNCATE " . DB_T_TEMP_SALARIES);
+        db::execute();
+        json::delete("tmp_salaries");
+
+        db::query("TRUNCATE " . DB_T_SALARIES);
+        db::execute();
+        json::delete("salaries");
+
+        db::query("TRUNCATE " . DB_T_FILES);
+        db::execute();
+        file::cleanAllFiles(DIR_DATAS_FILES);
+
+        db::query("TRUNCATE " . DB_T_EXCEL);
+        db::execute();
+        json::delete("excel");
+
+        db::query("TRUNCATE " . DB_T_SALARIES_PROWEB);
+        db::execute();
+        json::delete("salaries-proweb");
+
+        db::query("TRUNCATE " . DB_T_EVENTS_INSCRITS);
+        db::execute();
+
+        db::query("TRUNCATE " . DB_T_EVENTS);
+        db::execute();
+
+        json::delete("events");
+
+        db::query("TRUNCATE " . DB_T_EXCEL_PROWEB);
+        db::execute();
+        json::delete("excel-proweb");
+        file::cleanAllFiles(SFTP_LOCAL);
+    }
 }

+ 21 - 0
core/class/file.class.php

@@ -55,6 +55,8 @@ class file
         }
     }
 
+
+
     public static function cleanFilesByOrder(string $_path, int $_nbFiles = 5)
     {
         $return = TRUE;
@@ -85,6 +87,25 @@ class file
         return $return;
     }
 
+    public static function cleanAllFiles(string $_path)
+    {
+        $return = TRUE;
+        $dir = new DirectoryIterator($_path);
+        $blackList = array(
+            ".",
+            "..",
+            "index.html",
+            "index.php"
+        );
+    
+        foreach ($dir as $fileinfo) {
+            if (!in_array($fileinfo->getFilename(), $blackList)) {
+                $return = (unlink($_path.$fileinfo->getFilename())) ? TRUE : FALSE;
+            }
+        }
+        return $return;
+    }
+
     public static function cleanFilesByTime(string $_path, int $_limitTime = 24*3600) // 24*3600 pour une journée
     {
         if ($handle = opendir($_path)) {

+ 2 - 2
core/controllers/cms.index.php

@@ -2,9 +2,9 @@
 
 if(session::isConnect()){
     require_once DIR_PHP_LAYOUTS . "cms.session.php";
-    require_once DIR_PHP_VIEWS . "_cms.head.php"; 
+    if (core::ifGet("blank") == FALSE) { require_once DIR_PHP_VIEWS . "_cms.head.php"; }
     get::page();
-    require_once DIR_PHP_VIEWS . "_cms.foot.php";
+    if (core::ifGet("blank") == FALSE) { require_once DIR_PHP_VIEWS . "_cms.foot.php"; }
 } else {
     get::page("login");
 }

+ 0 - 0
core/json/cms.host-restore.php → core/json/cms.parametres-restore.php


+ 0 - 26
core/submit/cms.dev-reset-to-mysql.php

@@ -1,26 +0,0 @@
-<?php
-
-
-
-db::query("TRUNCATE " . DB_T_TEMP_SALARIES);
-db::execute();
-json::delete("tmp_salaries");
-
-db::query("TRUNCATE " . DB_T_SALARIES);
-db::execute();
-json::delete("salaries");
-
-db::query("TRUNCATE ". DB_T_EXCEL);
-db::execute();
-json::delete("excel");
-
-db::query("TRUNCATE ". DB_T_SALARIES_PROWEB);
-db::execute();
-json::delete("salaries-proweb");
-
-db::query("TRUNCATE ". DB_T_EXCEL_PROWEB);
-db::execute();
-json::delete("excel-proweb");
-
-header("Location: /rh-historique-excel.html");
-exit();

+ 1 - 1
core/submit/cms.host-add-backup.php → core/submit/cms.parametres-add-backup.php

@@ -3,7 +3,7 @@
 if (core::ifGet("from")) {
     backup::create();
     file::cleanFilesByOrder(DIR_BACKUP, BACKUP_LIMIT);
-    header("Location: /host-restore.html");
+    header("Location: /parametres.html");
     exit();
 
 } else {

+ 1 - 1
core/submit/cms.dev-debug-activation.php → core/submit/cms.parametres-debug-activation.php

@@ -11,5 +11,5 @@ if(core::ifGet("actif")){
     }
 }
 
-header("Location: /host-parametres.html");
+header("Location: /parametres.html");
 exit();

+ 0 - 0
core/submit/cms.host-download-backup-zip.php → core/submit/cms.parametres-download-backup-zip.php


+ 1 - 1
core/submit/cms.dev-maintenance-activation.php → core/submit/cms.parametres-maintenance-activation.php

@@ -11,5 +11,5 @@ if(core::ifGet("actif")){
     }
 }
 
-header("Location: /host-parametres.html");
+header("Location: /parametres.html");
 exit();

+ 9 - 0
core/submit/cms.parametres-reset-datas.php

@@ -0,0 +1,9 @@
+<?php
+
+if((ENVIRONNEMENT == "DEV" OR ENVIRONNEMENT == "PREPROD")) {
+    core::resetDatas();
+    alert::recSuccess("Le nettoyage des données a bien été réalisé");
+    header("Location: /parametres.html");
+    exit();
+}
+

+ 1 - 1
core/submit/cms.host-restore-backup-zip.php → core/submit/cms.parametres-restore-backup-zip.php

@@ -2,7 +2,7 @@
 
 if (core::ifPost("from")) {
     backup::restore(DIR_BACKUP . core::getPost("file"));
-    header("Location: /host-restore.html");
+    header("Location: /parametres.html");
     exit();
 
 } else {

+ 2 - 10
core/views/_cms.menu.php

@@ -36,18 +36,10 @@
                 }
 
                 if(session::accessUserByType(1)){ 
-                    core::elementMenuH6("Maintenance");
-                    core::elementMenu("host-restore", "/host-restore.html", "IT : Restauration des données", "tool");
-                    core::elementMenu("host-parametres", "/host-parametres.html", "IT : Paramètres", "tool"); 
+                    core::elementMenuH6("Administration");
+                    core::elementMenu("parametres", "/parametres.html", "IT : Paramètres", "tool"); 
                 }
                 
-                if(session::accessUserByType(1) AND session::getId() == 1 AND (ENVIRONNEMENT == "DEV" OR ENVIRONNEMENT == "PREPROD")){ 
-                    core::elementMenuH6("Développement", "color:red");
-                    core::elementMenuLink("/submit.php?from=dev-reset-to-mysql", "Nettoyer les données", "tool", "color:red", "_top");
-                    core::elementMenu("debug-info", "/dev-debug-info.html", "Informations de debug", "tool", "color:red");
-                }    
-                    
-                
             ?>
         </ul>
     </div>

+ 2 - 2
core/views/_cms.nav.php

@@ -12,13 +12,13 @@
     }
 
     if(core::isMaintenance()){
-        $titleMaintenance = "<a href=\"/host-parametres.html\"><span class=\"badge\" style=\"background-color:red; margin-left:5px;\">SITE EN MODE MAINTENANCE</span></a>";
+        $titleMaintenance = "<a href=\"/parametres.html\"><span class=\"badge\" style=\"background-color:red; margin-left:5px;\">SITE EN MODE MAINTENANCE</span></a>";
     } else {
         $titleMaintenance = "";
     }
 
     if(core::isDebug()){
-        $titleDebug = "<a href=\"/host-parametres.html\"><span class=\"badge\" style=\"background-color:red; margin-left:5px;\">MODE DEBUG</span></a>";
+        $titleDebug = "<a href=\"/parametres.html\"><span class=\"badge\" style=\"background-color:red; margin-left:5px;\">MODE DEBUG</span></a>";
     } else {
         $titleDebug = "";
     }

+ 0 - 41
core/views/pages/cms.host-parametres.php

@@ -1,41 +0,0 @@
-<?php
-$checkMaintenance = core::isMaintenance();
-$checkDebug = core::isDebug();
-?>
-
-<header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
-    <h2 class="bd-title" id="content">
-        <span>Paramètres</span>
-    </h2>
-</header>
-<?php
-echo core::filAriane(array(
-    "current" => "Paramètres",
-    "arbo" => array(
-        "Maintenance" => NULL,
-        "Paramètres" => "/host-parametres.html"
-    )
-));
-?>
-
-<h4>Général</h4>
-<div class="form-check form-switch">
-    <input class="form-check-input" type="checkbox" role="switch" id="checkMaintenance" <?php core::checkboxSelecter($checkMaintenance) ?>>
-    <label class="form-check-label" for="checkMaintenance">Site en mode maintenance (les salariés ne pourront plus faire d'action sur le site)</label>
-</div>
-<div class="form-check form-switch">
-    <input class="form-check-input" type="checkbox" role="switch" id="checkDebug" <?php core::checkboxSelecter($checkDebug) ?>>
-    <label class="form-check-label" for="checkDebug">Afficher les erreurs (débug)</label>
-</div>
-
-<script>
-    $(document).ready(function() {
-        $('#checkMaintenance').on('change', function() {
-            window.location.href = "/submit.php?from=dev-maintenance-activation&actif=" + $("#checkMaintenance").prop('checked');
-        });
-
-        $('#checkDebug').on('change', function() {
-            window.location.href = "/submit.php?from=dev-debug-activation&actif=" + $("#checkDebug").prop('checked');
-        });
-    });
-</script>

+ 0 - 50
core/views/pages/cms.host-restore.php

@@ -1,50 +0,0 @@
-<header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
-<h2 class="bd-title" id="content">
-    <span>Restauration des données</span>
-    <a href="/submit.php?from=host-add-backup" 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> Créer un nouveau backup</button></a>
-</h2>
-</header>
-<?php   
-        echo core::filAriane(array(
-            "current" => "Restauration des données", 
-            "arbo" => array( 
-                "Maintenance" => NULL,
-                "Restauration des données" => "/host-restore.html")
-        )); 
-?>
-<div>
-    <table 
-        id="table" 
-        class="table-striped table-hover table-sm" 
-        data-toggle="table" 
-        data-sort-name="date" 
-        data-sort-order="desc" 
-        data-url="/json.php?jsonData=host-restore">
-        <thead>
-            <tr>
-                <th data-formatter="downloadFile" data-sortable="true" data-field="file" data-filter-control="input" data-align="left">Nom</th>
-                <th data-sortable="true" data-field="size" data-filter-control="input" data-width="100">Taille</th>
-                <th data-sortable="true" data-field="date" data-filter-control="input" data-width="170">Date de création</th>
-                <th data-formatter="restoreBackup" data-width="130"></th>
-            </tr>
-        </thead>
-    </table>
-</div>
-
-<script>
-    function downloadFile(value, row) {
-        return '<form method="post" action="/submit.php">\n\
-        <input type="hidden" name="from" value="host-download-backup-zip">\n\
-        <input type="hidden" name="file" value="' + row.file + '">\n\
-        <button type="submit" style="border:none; background:none;" title="Télécharger le fichier : ' + row.file + '">' + row.file + '</button>\n\
-        </form>';
-    }
-
-    function restoreBackup(value, row) {
-        return '<form method="post" action="/submit.php">\n\
-        <input type="hidden" name="from" value="host-restore-backup-zip">\n\
-        <input type="hidden" name="file" value="' + row.file + '">\n\
-        <button type="submit" onclick="return confirm(\'Etes-vous certain de vouloir restaurer cette version (données et fichiers) ?\')" class="btn btn-outline-danger btn-sm">Restaurer</button>\n\
-        </form>';
-    }
-</script>

+ 0 - 0
core/views/pages/cms.dev-debug-info.php → core/views/pages/cms.parametres-debug-info.php


+ 91 - 0
core/views/pages/cms.parametres-general.php

@@ -0,0 +1,91 @@
+<?php
+$checkMaintenance = core::isMaintenance();
+$checkDebug = core::isDebug();
+?>
+
+<h4>Général</h4>
+<div class="element-parametres form-check form-switch">
+    <input class="form-check-input" type="checkbox" role="switch" id="checkMaintenance" <?php core::checkboxSelecter($checkMaintenance) ?>>
+    <label class="form-check-label" for="checkMaintenance">Site en mode maintenance (les salariés ne pourront plus faire d'action sur le site)</label>
+</div>
+<div class="element-parametres form-check form-switch">
+    <input class="form-check-input" type="checkbox" role="switch" id="checkDebug" <?php core::checkboxSelecter($checkDebug) ?>>
+    <label class="form-check-label" for="checkDebug">Afficher les erreurs (débug)</label>
+</div>
+
+<?php if (session::accessUserByType(1) and session::getId() == 1 and (ENVIRONNEMENT == "DEV" or ENVIRONNEMENT == "PREPROD")) { ?>
+
+    <h4>Développement</h4>
+    <div class="element-parametres">
+        <a href="/submit.php?from=parametres-reset-datas" onclick="return confirm('Etes-vous certain de vouloir supprimer les données ?')"><button type="button" class="btn btn-warning">Nettoyer les données</button></a>
+    </div>
+    <div class="element-parametres">
+        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalPHPInfo">PHP Infos</button>
+    </div>
+
+    <div class="modal fade" id="modalPHPInfo" tabindex="-1" role="dialog" aria-hidden="true">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title" id="exampleModalLabel">PHP Info</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">&times;</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <iframe width="970" height="800" src="/parametres-debug-info.vue"></iframe>
+                </div>
+            </div>
+        </div>
+    </div>
+
+<?php } ?>
+
+<script>
+    $(document).ready(function() {
+        $('#checkMaintenance').on('change', function() {
+            window.location.href = "/submit.php?from=parametres-maintenance-activation&actif=" + $("#checkMaintenance").prop('checked');
+        });
+
+        $('#checkDebug').on('change', function() {
+            window.location.href = "/submit.php?from=dev-debug-activation&actif=" + $("#checkDebug").prop('checked');
+        });
+
+        $('#modalPHPInfo').on('show.bs.modal', function() {
+            $(this).find('.modal-body').css({
+                width: 'auto', //probably not needed
+                height: 'auto', //probably not needed 
+                'max-height': '100%'
+            });
+        });
+    });
+</script>
+
+<style>
+    h4 {
+        margin-top: 15px;
+    }
+
+    .element-parametres {
+        margin-top: 5px;
+    }
+
+    .modal-body {
+        position: relative;
+        overflow-y: auto;
+        max-height: 400px;
+        padding: 15px;
+    }
+
+    .modal-dialog{
+        width: 1005px !important;
+    }
+
+    .modal {
+        --bs-modal-width: none;
+    }
+
+    .autoModal.modal .modal-body {
+        max-height: 100%;
+    }
+</style>

+ 46 - 0
core/views/pages/cms.parametres-restore.php

@@ -0,0 +1,46 @@
+
+<div style="margin-top:60px;">
+
+    <a href="/submit.php?from=parametres-add-backup" style="position:absolute; right:25px; margin-top:-55px;">
+        <button type="submit" class="btn btn-outline-success btn-sm">
+        <span data-feather="plus-square"></span> Créer un nouveau backup</button>
+    </a>
+
+    <div>
+        <table 
+            id="table" 
+            class="table-striped table-hover table-sm" 
+            data-toggle="table" 
+            data-sort-name="date" 
+            data-sort-order="desc" 
+            data-url="/json.php?jsonData=parametres-restore">
+            <thead>
+                <tr>
+                    <th data-formatter="downloadFile" data-sortable="true" data-field="file" data-filter-control="input" data-align="left">Nom</th>
+                    <th data-sortable="true" data-field="size" data-filter-control="input" data-width="100">Taille</th>
+                    <th data-sortable="true" data-field="date" data-filter-control="input" data-width="170">Date de création</th>
+                    <th data-formatter="restoreBackup" data-width="130"></th>
+                </tr>
+            </thead>
+        </table>
+    </div>
+
+</div>
+
+<script>
+    function downloadFile(value, row) {
+        return '<form method="post" action="/submit.php">\n\
+        <input type="hidden" name="from" value="parametres-download-backup-zip">\n\
+        <input type="hidden" name="file" value="' + row.file + '">\n\
+        <button type="submit" style="border:none; background:none;" title="Télécharger le fichier : ' + row.file + '">' + row.file + '</button>\n\
+        </form>';
+    }
+
+    function restoreBackup(value, row) {
+        return '<form method="post" action="/submit.php">\n\
+        <input type="hidden" name="from" value="parametres-restore-backup-zip">\n\
+        <input type="hidden" name="file" value="' + row.file + '">\n\
+        <button type="submit" onclick="return confirm(\'Etes-vous certain de vouloir restaurer cette version (données et fichiers) ?\')" class="btn btn-outline-danger btn-sm">Restaurer</button>\n\
+        </form>';
+    }
+</script>

+ 0 - 7
core/views/pages/cms.users.php → core/views/pages/cms.parametres-users.php

@@ -2,13 +2,6 @@
     json::create("users");
 ?>
 
-<header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
-<h2 class="bd-title" id="content">
-    <span>Liste des utilisateurs</span>
-    <a href="/add-user.html" 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 utilisateur</button></a>
-</h2>
-</header>
-
 <div>
     <table
         id="table"

+ 81 - 0
core/views/pages/cms.parametres.php

@@ -0,0 +1,81 @@
+<?php
+$checkMaintenance = core::isMaintenance();
+$checkDebug = core::isDebug();
+?>
+
+<header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
+    <h2 class="bd-title" id="content">
+        <span>Paramètres</span>
+    </h2>
+</header>
+<?php
+echo core::filAriane(array(
+    "current" => "Paramètres",
+    "arbo" => array(
+        "Administration" => NULL,
+        "Paramètres" => "/arametres.html"
+    )
+));
+?>
+
+
+<br />
+    <ul class="nav nav-tabs" id="event-fiche" role="tablist">
+        <li class="nav-item">
+            <a class="nav-link active" data-toggle="tab" id="general-tab" role="tab" aria-selected="true">Général</a>
+        </li>
+        <li class="nav-item">
+            <a class="nav-link" data-toggle="tab" id="users-tab" role="tab" aria-selected="">Utilisateurs</a>
+        </li>
+        <li class="nav-item">
+            <a class="nav-link" data-toggle="tab" id="backup-tab" role="tab" aria-selected="">Backup et restauration</a>
+        </li> 
+        <li class="nav-item">
+            <a class="nav-link" data-toggle="tab" id="links-tab" role="tab" aria-selected="">Liens utiles</a>
+        </li>
+    </ul>
+<br />
+
+<div class="tab-content">
+    <div id="tab-general"> 
+        <?php get::page("parametres-general") ?> 
+    </div>
+    <div id="tab-users" style="display: none;">
+        <?php get::page("parametres-users") ?>
+    </div>
+    <div id="tab-backup" style="display: none;">
+        <?php get::page("parametres-restore") ?>
+    </div>
+    <div id="tab-links" style="display: none;">
+        
+    </div> 
+</div>
+
+<script>
+    $(document).ready(function(){
+        $("#general-tab").click(function() {
+            $("#tab-general").show();
+            $("#tab-users").hide();
+            $("#tab-backup").hide();
+            $("#tab-links").hide();
+        }); 
+        $("#users-tab").click(function() {
+            $("#tab-general").hide();
+            $("#tab-users").show();
+            $("#tab-backup").hide();
+            $("#tab-links").hide();
+        });  
+        $("#backup-tab").click(function() {
+            $("#tab-general").hide();
+            $("#tab-users").hide();
+            $("#tab-backup").show();
+            $("#tab-links").hide();
+        });
+        $("#links-tab").click(function() {
+            $("#tab-general").hide();
+            $("#tab-users").hide();
+            $("#tab-backup").hide();
+            $("#tab-links").show();
+        });
+    })
+</script>

+ 1 - 0
public-cms/.htaccess

@@ -4,4 +4,5 @@ RewriteEngine On
 RewriteRule ^index\.html$ /index.php 
 RewriteRule ^add\-([a-z]+)\.html$ index.php?p=$1&add=1 [L,NC,QSA,NS]
 RewriteRule ^([\-a-z]+)\.html$ index.php?p=$1 [L,NC,QSA,NS]
+RewriteRule ^([\-a-z]+)\.vue$ index.php?p=$1&blank=1 [L,NC,QSA,NS]
 RewriteRule ^([a-z]+)\-([0-9]*)\.html$ index.php?p=$1&id=$2 [L,NC,QSA,NS]