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.
79 righe
3.1 KiB
79 righe
3.1 KiB
<? |
|
$error = true; |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice) && $_SESSION["utente"]->gerarchia <= 10 && tokenVerify()) { |
|
$reportManager = new reportManager(); |
|
$reportDisponibili = $reportManager->getReportDisponibili(true); |
|
$settings = $reportDisponibili[$_POST["modulo"]] ?? null; |
|
if (!empty($settings)) { |
|
$graphType = reportManager::graphTypes()[$_POST["type"]] ?? null; |
|
if (!empty($graphType)) { |
|
if (count($_POST["group_keys"]) <= $graphType["maxGroups"]) { |
|
$groupKeys = array_filter($_POST["group_keys"]); |
|
if (empty($groupKeys)) { |
|
$groupKeys = null; |
|
} |
|
$continua = true; |
|
if (!empty($_POST["codice"])) { |
|
$continua = false; |
|
$report = reportManager::getSelfManagedReport($_POST["codice"]); |
|
if (!isset($_SESSION["ente"]) || $_SESSION["ente"]->codice == $report["codice_gestore"]) { |
|
$continua = true; |
|
} |
|
} else { |
|
$report = []; |
|
} |
|
if ($continua) { |
|
$report["codice_gestore"] = $_SESSION["ente"]->codice ?? 0; |
|
$columns = []; |
|
if (!empty($_POST["columns"])) { |
|
if ($graphType["serieMultiple"] || count($_POST["columns"]) === 1) { |
|
foreach($_POST["columns"] AS $column) { |
|
$column = explode("#",$column); |
|
if (count($column) === 2) { |
|
$field = $settings["fields"][$column[0]] ?? null; |
|
if (!empty($field) && in_array($column[1],$field["operazioni"]) !== 0) { |
|
$columns[] = ["name"=>$column[0],"operazione"=>$column[1]]; |
|
} |
|
} |
|
} |
|
} |
|
if (!empty($columns)) { |
|
$report["titolo"] = $_POST["titolo"]; |
|
$report["descrizione"] = $_POST["descrizione"]; |
|
$report["modulo"] = $_POST["modulo"]; |
|
$report["settings"] = json_encode(["type"=>$_POST["type"],"group_keys"=>$groupKeys,"columns"=>$columns]); |
|
|
|
$salva = new salva(); |
|
$salva->debug = false; |
|
|
|
$salva->nome_tabella = "b_report_personalizzati"; |
|
$salva->operazione = (empty($_POST["codice"])) ? "INSERT" : "UPDATE"; |
|
$salva->oggetto = $report; |
|
if ($salva->save()) { |
|
$error = false; |
|
?> |
|
swal({title:js_dict["success-msg"],type:"success"}).then(function() { |
|
window.location.reload(); |
|
}); |
|
<? |
|
} |
|
} else { |
|
$error = false; |
|
?> |
|
swal({title:js_dict.error,html:"<?= __("Errore configurazione serie") ?>",type:"error"}); |
|
<? |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
if ($error) { |
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
} |
|
?>
|