<?php
    $jsonTarget = "/json.php?jsonData=parametre-access";
    if(debug::isFile("debug")){
        debug::log(debug::getBadge($jsonTarget, "OUVRIR LE JSON : ".$jsonTarget), "JSON chargé en arrière plan");
    } 
?>
<header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
    <h2 class="bd-title" id="content">
        <span>Administration : Groupes & Droits</span>
    </h2>
</header>
<?php
echo core::filAriane(array(
    "current" => "Groupes & Droits",
    "arbo" => array(
        "Administration" => NULL,
        "Groupes & Droits" => "/parametre-teams.html"
    )
));
?>

<div>
    <table  id="table" 
            class="table-striped table-hover table-sm" 
            data-toggle="table" 
            data-flat="true" 
            data-url="<?php echo $jsonTarget ?>">
        <thead>
            <tr>
                <th data-sortable="true" data-field="access">Accès</th>
                <th data-sortable="true" data-field="Administrateur" data-formatter="checkFormatter" data-width="180">Administrateur</th>
                <th data-sortable="true" data-field="Membre du Bureau du CSE" data-formatter="checkFormatter" data-width="180">Bureau du CSE</th>
                <th data-sortable="true" data-field="Elu du CSE" data-formatter="checkFormatter" data-width="180">Elu du CSE</th>
                <th data-sortable="true" data-field="Comptable" data-formatter="checkFormatter" data-width="180">Comptable</th>
                <th data-sortable="true" data-field="Modérateur du CMS" data-formatter="checkFormatter" data-width="180">Modérateur du CMS</th>
                <th data-sortable="true" data-field="Assistance sociale" data-formatter="checkFormatter" data-width="180">Assistance sociale</th>
            </tr>
        </thead>
    </table>
</div>

<script>
    function checkFormatter(value) { 
        if(value === 1){ var color = "#d4edda;"; var txt = "Autorisé"; }
        else if(value === 2){ var color = "#ffeeba;"; var txt = "Partiellement"; }
        else { var color = "#f8d7da"; var txt = "-"; }
        return '<div with:100% height:20px style="background-color:'+color+'; text-align:center;">' + txt + '</div>'
    }
</script>