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();
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2020-10-16 21:35:19 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6 col-md-offset-3">
|
|
|
|
<div class="input-group">
|
2021-02-25 11:22:06 +01:00
|
|
|
<input type="text" class="form-control" placeholder="'.tr('Ricerca rapida').'" id="ricerca_impostazioni" value="'.$ricerca.'"/>
|
2020-10-16 21:35:19 +02:00
|
|
|
<div class="input-group-btn">
|
|
|
|
<button class="btn btn-primary" type="button">
|
|
|
|
<span class="fa fa-search"></span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-10-16 21:35:19 +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>
|
|
|
|
</div>
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-10-16 21:35:19 +02:00
|
|
|
<br><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 -->
|
|
|
|
<div class="box box-primary collapsed-box" title="'.$gruppo['nome'].'">
|
|
|
|
<div class="box-header clickable" id="impostazioni-'.$key.'">
|
2020-10-30 11:39:11 +01:00
|
|
|
<div class="box-title">'.tr('_SEZIONE_', [
|
2020-10-16 21:35:19 +02:00
|
|
|
'_SEZIONE_' => $gruppo['nome'],
|
|
|
|
]).'</div>
|
|
|
|
<div class="box-tools pull-right">
|
|
|
|
<div class="badge">'.$gruppo['numero'].'</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="box-body""></div>
|
|
|
|
</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>
|
|
|
|
globals.impostazioni = {
|
|
|
|
errors: {},
|
|
|
|
};
|
|
|
|
|
|
|
|
$("[id^=impostazioni]").click(function() {
|
|
|
|
caricaSezione(this);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#ricerca_impostazioni").change(function (){
|
|
|
|
let ricerca = $(this).val();
|
|
|
|
$(".box").removeClass("hidden");
|
|
|
|
|
|
|
|
if (ricerca) {
|
|
|
|
$.get("'.$structure->fileurl('actions.php').'?id_module='.$id_module.'&op=ricerca&search=" + ricerca, function(data) {
|
|
|
|
$(".box").addClass("hidden");
|
|
|
|
|
|
|
|
let sezioni = JSON.parse(data);
|
|
|
|
for(const sezione of sezioni){
|
|
|
|
$(`.box[title="` + sezione + `"]`).removeClass("hidden");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
function caricaSezione(header) {
|
|
|
|
let box = $(header).closest(".box");
|
|
|
|
box.toggleClass("collapsed-box");
|
|
|
|
|
|
|
|
// Controllo sul caricamento già effettuato
|
|
|
|
let container = box.find(".box-body");
|
|
|
|
if (container.html()){
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Caricamento della sezione di impostazioni
|
|
|
|
let sezione = box.attr("title");
|
|
|
|
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,
|
|
|
|
type: "GET",
|
|
|
|
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>';
|
|
|
|
}
|