gestione gare pubbliche
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.
 
 
 
 
 

151 righe
5.5 KiB

<?php
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php";
include_once($configPath);
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice)) {
$procedure = getProcedure();
?>
<h3><?=__('Limiti per procedura')?></h3>
<input type="checkbox" checked id="no-limit" onChange="$('#limiti-table').slideToggle();">
<strong><?=__('Nessun limite')?></strong>
<div class="table-responsive py-3 collapse" id="limiti-table">
<table style="width:100%">
<thead>
<tr>
<th><?= __("Abilita") ?></th>
<th><?= __("Procedura") ?></th>
<th><?= __("Importo massimo") ?></th>
</tr>
</thead>
<tbody>
<?foreach ($procedure as $id => $procedura):?>
<tr>
<td width="10" class="text-center">
<input type="checkbox" onChange="if ($('#limiteProcedura<?= $id ?>:disabled').length > 0) { $('#limiteProcedura<?= $id ?>').removeAttr('disabled'); } else { $('#limiteProcedura<?= $id ?>').attr('disabled','disabled'); } ">
</td>
<td>
<?=$procedura["titolo"]?>
</td>
<td>
<input type="text" class="form-control text-right limit" id="limiteProcedura<?= $id ?>" disabled name="<?= $id ?>" value="" rel="N;0;0;N" title="<?= __("Limite") ?> - <?= $procedura["titolo"] ?>">
</td>
</tr>
<?endforeach?>
</tbody>
</table>
</div>
<div class="table-responsive">
<input id="assign-all" type="checkbox" class="mr-1"><span><?=__('Seleziona tutti')?></span>
<table style="width:100%" class="table table-striped table-hover" id="all-users">
<thead>
<tr>
<th><?=__("Utente")?></th>
<th><?=__("Ente")?></th>
</tr>
</thead>
</table>
</div>
<button class="btn btn-primary ml-auto" onclick="updateLimiti()">
<?=__('Salva limiti')?>
</button>
<script type="text/javascript">
window.selected = [];
window.userTable = $("#all-users").DataTable({
processing: true,
serverSide: true,
language: {
url: "/dictionary/datatables/<?=$_SESSION['language']?>.lang"
},
ajax: {
url: "/backend/utenti/limiti/table.php",
},
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, '<?= __("tutti") ?>']],
columns: [
{"orderable": false},
{"orderable": false},
],
drawCallback: function(){
//disattiva il seleziona tutti
if ($("#assign-all").is(':checked')) {
$("#assign-all").click();
}
//applica i listener alle checkbox
$(".checkbox-limit").on('click', function(){
var value = $(this).data('value');
if (window.selected.includes(value)) {
window.selected = window.selected.filter((v) => v != value);
} else {
window.selected.push(value);
}
})
//seleziona i checkbox salvati in memoria
window.selected.forEach((value) => {
$(`[data-value="${value}"]`).prop('checked', true);
})
}
})
$("#assign-all").on('change',function(){
if ($(this).is(":checked")) {
$(".checkbox-limit").each(function(){
if (!$(this).is(":checked")) {
$(this).click();
}
})
} else {
$(".checkbox-limit").each(function(){
if ($(this).is(":checked")) {
$(this).click();
}
})
}
})
function updateLimiti() {
var limiti = {};
//valida tutti gli input con la classe limit non disabilitati
$(".limit").each(function(){
if (!$(this).is(":disabled")) {
errors = valida($(this));
if (errors.length > 0) {
return
}
limiti[$(this).attr('name')] = $(this).val();
}
})
//se sono tutti validi:
//genera il json dei limiti:
limiti = JSON.stringify(limiti);
if ($("#no-limit").is(":checked")) {
//se è selezionato #no-limit limiti = ""
limiti = "";
}
//invia il json dei limiti di applicare e i codici relazione ai quali applicarlo
//ripulisci window.selected
$.ajax({
type: "POST",
url: "/backend/utenti/limiti/massive-save.php",
data: {
selected: window.selected,
limiti: limiti
},
beforeSend: function() {
$("#wait_div").show();
}
})
.fail(function(response){
swal(js_dict['error-retry']);
})
.done(function(response){
eval(response);
})
.always(function(){
$("#wait_div").slideUp('fast');
})
}
</script>
<?
}
?>