<?php
    $checkLogSuccess = core::getConfig("LOG_SUCCESS");
    $checkLogWarning = core::getConfig("LOG_WARNING");
    $checkLogError = core::getConfig("LOG_ERROR");
?>

<h4>Historique</h4>
<div class="element-parametres form-check form-switch">
    <input class="form-check-input" type="checkbox" role="switch" id="checkLogSuccess" <?php core::checkboxSelecter($checkLogSuccess) ?>>
    <label class="form-check-label" for="checkLogSuccess">Historiser les actions réalisées avec succès</label>
</div>

<div class="element-parametres form-check form-switch">
    <input class="form-check-input" type="checkbox" role="switch" id="checkLogWarning" <?php core::checkboxSelecter($checkLogWarning) ?>>
    <label class="form-check-label" for="checkLogWarning">Historiser les actions réalisées avec warning</label>
</div>

<div class="element-parametres form-check form-switch">
    <input class="form-check-input" type="checkbox" role="switch" id="checkLogError" <?php core::checkboxSelecter($checkLogError) ?>>
    <label class="form-check-label" for="checkLogError">Historiser les actions en erreur</label>
</div>

<script>
    $(document).ready(function() {
        $('#checkLogSuccess').on('change', function() {
            window.location.href = "/submit.php?from=parametres-config&name=LOG_SUCCESS&value=" + $("#checkLogSuccess").prop('checked');
        });

        $('#checkLogWarning').on('change', function() {
            window.location.href = "/submit.php?from=parametres-config&name=LOG_WARNING&value=" + $("#checkLogWarning").prop('checked');
        });

        $('#checkLogError').on('change', function() {
            window.location.href = "/submit.php?from=parametres-config&name=LOG_ERROR&value=" + $("#checkLogError").prop('checked');
        });
    });
</script>

<h4>Espaces disques</h4>
<?php 
    $infosDB = core::getSizeDataBase();
    $unGo = 1073741824;

    $totalSpaceRoot = disk_total_space(DOCUMENT_ROOT);
    $freeSpaceRoot = disk_free_space(DOCUMENT_ROOT);
    $actualSpaceRoot = $totalSpaceRoot - disk_free_space(DOCUMENT_ROOT);

    $totalSpaceData = disk_total_space(DOCUMENT_DATAS);
    $freeSpaceData = disk_free_space(DOCUMENT_DATAS);
    $actualSpaceData = $totalSpaceData - disk_free_space(DOCUMENT_DATAS);

    core::progressBarWarning($actualSpaceRoot, $totalSpaceRoot, "Espace ROOT", "bi-pc-display-horizontal");
    core::progressBarWarning($actualSpaceData, $totalSpaceData, "Espace DATAS", "bi-pc-display-horizontal");
    core::progressBarWarning(core::convertBytes(floatval($infosDB["moDB"]), "Mo", "o", TRUE), $unGo, "Base de donnée Mysql", "bi bi-database-fill");
    core::progressBarWarning(file::sizeFolder(DIR_BACKUP), $freeSpaceData, "Dossier Backups", "bi bi-folder");
    core::progressBarWarning(file::sizeFolder(DOCUMENT_DATAS), $freeSpaceData, "Dossier Documents", "bi bi-folder");
    core::progressBarWarning(file::sizeFolder(DIR_DATAS_JSONDATA), $freeSpaceRoot, "Dossier Json", "bi bi-folder");
    core::progressBarWarning(file::sizeFolder(SFTP_LOCAL), $freeSpaceRoot, "Dossier SFTP", "bi bi-folder");
?>
