2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-10-16 21:35:19 +02:00
|
|
|
use Models\Setting;
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
2021-02-25 11:22:06 +01:00
|
|
|
$ricerca = get('search');
|
2020-10-16 21:35:19 +02:00
|
|
|
$gruppi = Setting::selectRaw('sezione AS nome, COUNT(id) AS numero')
|
|
|
|
->groupBy(['sezione'])
|
|
|
|
->orderBy('sezione')
|
|
|
|
->get();
|
|
|
|
|
2024-05-21 16:26:19 +02:00
|
|
|
echo '
|
2024-05-21 12:02:40 +02:00
|
|
|
<div class="container">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6 offset-md-3">
|
|
|
|
<div class="input-group">
|
|
|
|
<input type="text" class="form-control input-lg text-center" id="ricerca_impostazioni" placeholder="'.tr('Cerca').'...">
|
|
|
|
<div class="input-group-append">
|
|
|
|
<button class="btn btn-primary" type="button" id="search">
|
|
|
|
<span class="fa fa-search"></span>
|
|
|
|
</button>
|
|
|
|
</div>
|
2020-10-16 21:35:19 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-05-21 12:02:40 +02:00
|
|
|
<div class="col-md-3">
|
|
|
|
<button class="btn btn-warning hidden" type="button" id="riprova_salvataggi" onclick="riprovaSalvataggio()">
|
|
|
|
<span class="fa fa-save"></span> '.tr('Riprova salvataggi falliti').'
|
|
|
|
</button>
|
|
|
|
</div>
|
2020-10-16 21:35:19 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2024-05-21 12:02:40 +02:00
|
|
|
<hr>';
|
2018-02-22 11:07:52 +01:00
|
|
|
|
2020-10-16 21:35:19 +02:00
|
|
|
foreach ($gruppi as $key => $gruppo) {
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2020-10-16 21:35:19 +02:00
|
|
|
<!-- Impostazioni della singola sezione -->
|
2024-05-21 12:02:40 +02:00
|
|
|
<div class="card card-primary collapsed-card" title="'.$gruppo->nome.'">
|
|
|
|
<div class="card-header clickable" title="'.$gruppo->nome.'" id="impostazioni-'.$key.'">
|
2024-05-16 18:02:50 +02:00
|
|
|
<div class="card-title">'.tr('_SEZIONE_', [
|
2024-05-21 12:02:40 +02:00
|
|
|
'_SEZIONE_' => $gruppo->nome,
|
2024-03-22 15:52:24 +01:00
|
|
|
]).'</div>
|
2024-05-16 18:02:50 +02:00
|
|
|
<div class="card-tools pull-right">
|
2024-05-21 12:02:40 +02:00
|
|
|
<div class="badge">'.$gruppo->numero.'</div>
|
2020-10-16 21:35:19 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-05-20 17:23:52 +02:00
|
|
|
<div class="card-body row"></div>
|
2020-10-16 21:35:19 +02:00
|
|
|
</div>';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
2018-02-22 11:07:52 +01:00
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2020-10-16 21:35:19 +02:00
|
|
|
<script>
|
2024-05-21 12:02:40 +02:00
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
$("#ricerca_impostazioni").keyup(function(key) {
|
|
|
|
if (key.which == 13) {
|
|
|
|
$("#search").click();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-10-16 21:35:19 +02:00
|
|
|
globals.impostazioni = {
|
|
|
|
errors: {},
|
2021-08-06 11:21:23 +02:00
|
|
|
numero_ricerche: 0,
|
2020-10-16 21:35:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
$("[id^=impostazioni]").click(function() {
|
|
|
|
caricaSezione(this);
|
|
|
|
});
|
|
|
|
|
2024-05-21 12:02:40 +02:00
|
|
|
$("#search").on("click", function(){
|
|
|
|
const ricerca = $("#ricerca_impostazioni").val();
|
2021-08-06 11:21:23 +02:00
|
|
|
const icon = $(this).parent().find("span");
|
2024-05-17 12:11:00 +02:00
|
|
|
$(".card").removeClass("hidden");
|
2020-10-16 21:35:19 +02:00
|
|
|
|
2021-08-06 11:21:23 +02:00
|
|
|
// Segnalazione ricerca in corso
|
|
|
|
globals.impostazioni.numero_ricerche = globals.impostazioni.numero_ricerche + 1;
|
|
|
|
// Impostazione icona di caricamento
|
|
|
|
icon
|
|
|
|
.addClass("fa-spinner fa-spin")
|
|
|
|
.removeClass("fa-search")
|
|
|
|
|
2020-10-16 21:35:19 +02:00
|
|
|
if (ricerca) {
|
|
|
|
$.get("'.$structure->fileurl('actions.php').'?id_module='.$id_module.'&op=ricerca&search=" + ricerca, function(data) {
|
2021-08-06 11:21:23 +02:00
|
|
|
// Segnalazione ricerca completata
|
|
|
|
globals.impostazioni.numero_ricerche = globals.impostazioni.numero_ricerche - 1;
|
|
|
|
|
|
|
|
// Impostazione icona di ricerca
|
|
|
|
if (globals.impostazioni.numero_ricerche === 0){
|
|
|
|
icon
|
|
|
|
.removeClass("fa-spinner fa-spin")
|
|
|
|
.addClass("fa-search")
|
|
|
|
}
|
|
|
|
|
2024-05-21 12:02:40 +02:00
|
|
|
$(".card-header").addClass("hidden");
|
2020-10-16 21:35:19 +02:00
|
|
|
|
|
|
|
let sezioni = JSON.parse(data);
|
|
|
|
for(const sezione of sezioni){
|
2024-05-21 12:02:40 +02:00
|
|
|
$(`.card-header[title="` + sezione + `"]`).removeClass("hidden")
|
|
|
|
let card = $(`.card-header[title="` + sezione + `"]`).removeClass("hidden")
|
|
|
|
caricaSezione(card);
|
2020-10-16 21:35:19 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
function caricaSezione(header) {
|
2024-05-17 12:11:00 +02:00
|
|
|
let card = $(header).closest(".card");
|
|
|
|
card.toggleClass("collapsed-card");
|
2020-10-16 21:35:19 +02:00
|
|
|
|
|
|
|
// Controllo sul caricamento già effettuato
|
2024-05-17 12:11:00 +02:00
|
|
|
let container = card.find(".card-body");
|
2020-10-16 21:35:19 +02:00
|
|
|
if (container.html()){
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Caricamento della sezione di impostazioni
|
2024-05-17 12:11:00 +02:00
|
|
|
let sezione = card.attr("title");
|
2020-10-16 21:35:19 +02:00
|
|
|
localLoading(container, true);
|
|
|
|
return $.get("'.$structure->fileurl('sezione.php').'?id_module='.$id_module.'&sezione=" + sezione, function(data) {
|
|
|
|
container.html(data);
|
|
|
|
localLoading(container, false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function salvaImpostazione(id, valore){
|
|
|
|
$.ajax({
|
|
|
|
url: globals.rootdir + "/actions.php",
|
|
|
|
cache: false,
|
2021-03-02 15:01:11 +01:00
|
|
|
type: "POST",
|
2020-10-16 21:35:19 +02:00
|
|
|
dataType: "JSON",
|
|
|
|
data: {
|
|
|
|
op: "salva",
|
|
|
|
id_module: globals.id_module,
|
|
|
|
id: id,
|
|
|
|
valore: valore,
|
|
|
|
},
|
|
|
|
success: function(data) {
|
|
|
|
renderMessages();
|
|
|
|
|
|
|
|
if(!data.result) {
|
|
|
|
globals.impostazioni.errors[id] = valore;
|
|
|
|
$("#riprova_salvataggi").removeClass("hidden");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: function(data) {
|
|
|
|
swal("'.tr('Errore').'", "'.tr('Errore durante il salvataggio dei dati').'", "error");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function riprovaSalvataggio() {
|
|
|
|
const impostazioni = JSON.parse(JSON.stringify(globals.impostazioni.errors));;
|
|
|
|
globals.impostazioni.errors = {};
|
|
|
|
|
|
|
|
$("#riprova_salvataggi").addClass("hidden");
|
|
|
|
for ([id, valore] of Object.entries(impostazioni)) {
|
|
|
|
salvaImpostazione(id, valore);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>';
|
2021-02-25 11:22:06 +01:00
|
|
|
|
2021-02-26 11:04:06 +01:00
|
|
|
if (!empty($ricerca)) {
|
2021-02-25 11:22:06 +01:00
|
|
|
echo '
|
|
|
|
<script>$("#ricerca_impostazioni").change();</script>';
|
|
|
|
}
|