<?php
    $checkMaintenance = debug::isFile("maintenance");
    $checkDebug = debug::isFile("debug");
?>
<table class="table table-bordered">
<tbody>
    <tr>
        <td scope="row">
                <h4>Activation Modes</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>
            
                <h4>Refresh des données</h4>
                <div class="element-parametres">
                    <a href="/submit.php?from=parametres-json-refresh" onclick="return confirm('Etes-vous certain de vouloir réinitialiser les JSON ?')"><button type="button" class="btn btn-warning">Réinitialisation des JSON</button></a>
                </div>
        </td>
        <?php if (session::getType() == 1 AND (ENVIRONNEMENT != "PROD")) { ?>
        <td>
            <h4>Outils de débug</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-danger">Nettoyer les données</button></a>
            </div>
            <div class="element-parametres">
                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalPHPInfo">Voir le 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>
        </td>
        <?php } ?>
    </tr>
    </tbody>
</table>

<script>
    $(document).ready(function() {
        $('#modalPHPInfo').on('show.bs.modal', function() {
            $(this).find('.modal-body').css({
                width: 'auto', //probably not needed
                height: 'auto', //probably not needed 
                'max-height': '100%'
            });
        });

        $('#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=parametres-debug&target=debug&actif=" + $("#checkDebug").prop('checked');
        });
    });
</script>
