Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
242 righe
9.0 KiB
242 righe
9.0 KiB
<? |
|
$configPath = substr(__DIR__, 0, strpos(__DIR__, "/public_html")) . "/config.php"; |
|
include_once($configPath); |
|
if (!empty($_SESSION["utente"]) && isset($_GET["codice"]) && ($_SESSION["utente"]->permission($radice))) { |
|
$codice = purify($_GET["codice"]); |
|
$re = Modulo::getModuli(["all_utente" => false])[$codice]; |
|
if (!empty($re) && $re["gerarchia"] >= $_SESSION["utente"]->gerarchia) { |
|
$show = true; |
|
if ($re["ente"] && !$re["all_ente"] && isset($_SESSION["ente"])) { |
|
$sql = "SELECT * FROM r_moduli_ente WHERE id_modulo = :codice AND cod_ente = :cod_ente "; |
|
$check_ente = $pdo->go($sql, [":codice" => $codice, ":cod_ente" => $_SESSION["ente"]->codice]); |
|
if ($check_ente->rowCount() == 0) { |
|
$show = false; |
|
} |
|
} |
|
if ($show) { |
|
?> |
|
<h3 style="margin:0" class="card card-body bg-light mb-2"> |
|
<div> |
|
<span class="<?= $re["icon"] ?>"></span> <?= $re["titolo"] ?> |
|
</div> |
|
<small><?= $re["descrizione"] ?></small> |
|
</h3> |
|
<ul class="nav nav-tabs" id="myTab" role="tablist"> |
|
<li class="nav-item" role="presentation"> |
|
<button class="nav-link active" id="permissed-tab" data-toggle="tab" data-target="#permissed" type="button" role="tab" aria-controls="permissed" aria-selected="true"><?= __('Utenti con accesso al permesso') ?></button> |
|
</li> |
|
<li class="nav-item" role="presentation"> |
|
<button class="nav-link" id="unpermissed-tab" data-toggle="tab" data-target="#unpermissed" type="button" role="tab" aria-controls="unpermissed" aria-selected="false"><?= __('Utenti senza accesso al permesso') ?></button> |
|
</li> |
|
</ul> |
|
<!--TABLE PERMISSED--> |
|
<div class="tab-content" id="myTabContent"> |
|
<div class="tab-pane fade show active" id="permissed" role="tabpanel" aria-labelledby="permissed-tab"> |
|
<div class="d-flex justify-content-around my-3"> |
|
<div> |
|
<input class="ml-2" type="checkbox" id="remove-all"> |
|
<span><?=__('Seleziona tutti')?></span> |
|
</div> |
|
<button onclick="rimuoviMassivamente()" class="ml-auto btn btn-primary"><?=__('Rimuovi massivamente')?></button> |
|
</div> |
|
<div class="table-responsive"> |
|
<table id="permissed-table" width="100%" class="table table-striped table-hover"> |
|
<thead> |
|
<tr> |
|
<th><?=__('Utente')?></th> |
|
<th><?=__('Ente')?></th> |
|
<th><?=__('Timestamp')?></th> |
|
<th></th> |
|
</tr> |
|
</thead> |
|
</table> |
|
</div> |
|
</div> |
|
<script type="text/javascript"> |
|
window.permissed = []; |
|
window.permissedTable = $("#permissed-table").DataTable({ |
|
processing: true, |
|
serverSide: true, |
|
language: { |
|
url: "/dictionary/datatables/<?= $_SESSION["language"] ?>.lang" |
|
}, |
|
ajax: { |
|
url: "/backend/utenti/permessi/table-assigned.php", |
|
data: function (d) { |
|
d.codice = "<?=$codice?>" |
|
} |
|
}, |
|
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, '<?= __("tutti") ?>']], |
|
columns: [ |
|
{"orderable": false}, |
|
{"orderable": false}, |
|
{"orderable": false}, |
|
{"orderable": false} |
|
], |
|
drawCallback: function(){ |
|
//applica i listener alle checkbox |
|
$(".relation_checkbox_permissed").on('click', function(){ |
|
var value = $(this).data('value'); |
|
if (window.permissed.includes(value)) { |
|
window.permissed = window.permissed.filter((v) => v != value); |
|
} else { |
|
window.permissed.push(value); |
|
} |
|
}) |
|
//disattiva il seleziona tutti |
|
if ($("#remove-all").is(':checked')) { |
|
$("#remove-all").click(); |
|
} |
|
//applica i valori impostati in precedenza |
|
window.permissed.forEach((value) => { |
|
$(`[data-value=${value}]`).prop('checked', true) |
|
}) |
|
} |
|
}) |
|
|
|
function rimuoviMassivamente() { |
|
$.ajax({ |
|
url: '/backend/utenti/permessi/massive-delete.php', |
|
type: 'POST', |
|
dataType: 'text', |
|
data: { |
|
token: '<?=tokenGen()?>', |
|
permissions : window.permissed |
|
} |
|
}) |
|
.done(function(script){ |
|
if ($("#remove-all").is(':checked')) { |
|
$("#remove-all").click(); |
|
} |
|
window.permissed = []; |
|
eval(script) |
|
}) |
|
.fail(function(){ |
|
swal(js_dict["error-retry"]); |
|
}) |
|
} |
|
|
|
$("#remove-all").on('change', function(){ |
|
if ($(this).is(':checked')) { |
|
$(".relation_checkbox_permissed").each(function(){ |
|
if (!$(this).is(":checked")) { |
|
$(this).click(); |
|
} |
|
}) |
|
} else { |
|
$(".relation_checkbox_permissed").each(function(){ |
|
if ($(this).is(":checked")) { |
|
$(this).click(); |
|
} |
|
}) |
|
} |
|
}) |
|
</script> |
|
<!--/TABLE PERMISSED--> |
|
<!--/TABLE UNPERMISSED--> |
|
<div class="tab-pane fade" id="unpermissed" role="tabpanel" aria-labelledby="unpermissed-tab"> |
|
<div class="d-flex justify-content-around my-3"> |
|
<div> |
|
<input class="ml-2" type="checkbox" id="assign-all"> |
|
<span><?=__('Seleziona tutti')?></span> |
|
</div> |
|
<button onclick="assegnaMassivamente()" class="ml-auto btn btn-primary"><?=__('Assegna massivamente')?></button> |
|
</div> |
|
<div class="table-responsive"> |
|
<table id="unpermissed-table" width="100%" class="table table-striped table-hover"> |
|
<thead> |
|
<tr> |
|
<th><?=__('Utente')?></th> |
|
<th><?=__('Ente')?></th> |
|
<th><?=__('Timestamp')?></th> |
|
<th></th> |
|
</tr> |
|
</thead> |
|
</table> |
|
</div> |
|
</div> |
|
</div> |
|
<script type="text/javascript"> |
|
window.unpermissed = []; |
|
window.unpermissedTable = $("#unpermissed-table").DataTable({ |
|
processing: true, |
|
serverSide: true, |
|
language: { |
|
url: "/dictionary/datatables/<?= $_SESSION["language"] ?>.lang" |
|
}, |
|
ajax: { |
|
url: "/backend/utenti/permessi/table-unassigned.php", |
|
data: function (d) { |
|
d.codice = "<?=$codice?>" |
|
} |
|
}, |
|
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, '<?= __("tutti") ?>']], |
|
columns: [ |
|
{"orderable": false}, |
|
{"orderable": false}, |
|
{"orderable": false}, |
|
{"orderable": false} |
|
], |
|
drawCallback: function(){ |
|
//applica i listener alle checkbox |
|
$(".relation_checkbox_unpermissed").on('click', function(){ |
|
var value = $(this).data('value'); |
|
if (window.unpermissed.includes(value)) { |
|
window.unpermissed = window.unpermissed.filter((v) => v != value); |
|
} else { |
|
window.unpermissed.push(value); |
|
} |
|
}) |
|
if ($("#assign-all").is(':checked')) { |
|
$("#assign-all").click(); |
|
} |
|
//applica i valori impostati in precedenza |
|
window.unpermissed.forEach((value) => { |
|
$(`[data-value="${value}"]`).prop('checked', true) |
|
}) |
|
} |
|
}) |
|
|
|
function assegnaMassivamente() { |
|
$.ajax({ |
|
url: '/backend/utenti/permessi/massive-assign.php', |
|
type: 'POST', |
|
dataType: 'text', |
|
data: { |
|
token: '<?=tokenGen()?>', |
|
permissions : window.unpermissed |
|
} |
|
}) |
|
.done(function(script){ |
|
if ($("#assign-all").is(':checked')) { |
|
$("#assign-all").click(); |
|
} |
|
window.unpermissed = []; |
|
eval(script) |
|
}) |
|
.fail(function(){ |
|
swal(js_dict["error-retry"]); |
|
}) |
|
} |
|
$("#assign-all").on('change', function(){ |
|
if ($(this).is(':checked')) { |
|
$(".relation_checkbox_unpermissed").each(function(){ |
|
if (!$(this).is(":checked")) { |
|
$(this).click(); |
|
} |
|
}) |
|
} else { |
|
$(".relation_checkbox_unpermissed").each(function(){ |
|
if ($(this).is(":checked")) { |
|
$(this).click(); |
|
} |
|
}) |
|
} |
|
}) |
|
</script> |
|
<!--/TABLE UNPERMISSED--> |
|
<? |
|
} |
|
} |
|
} |
|
?>
|