$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php";
include_once($configPath);
$error = true;
if (!empty($_POST) && !empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice,$_POST["codice"]) && tokenVerify() && $_SESSION["utente"]->gerarchia <= 10) {
$_POST["codice_gestore"] = (!empty($_SESSION["ente"])) ? $_SESSION["ente"]->codice : 0;
if (empty($_POST["codice"])) {
$_POST["timestamp_creazione"] = date("d/m/Y H:i:s");
}
$salva = new salva();
$salva->debug = false;
$salva->nome_tabella = "b_documentale";
$salva->operazione = empty($_POST["codice"]) ? "INSERT" : "UPDATE";
$salva->oggetto = $_POST;
$codice = $salva->save();
if (!empty($codice)) {
$error = false;
if (isset($_POST["allegato"])) {
$errori_upload = array();
foreach($_POST["allegato"] as $allegato) {
if (filesManager::saveFile($allegato["filename"],$codice,"documentale",$allegato["nome"] ?? "","A",$allegato["classificazione"] ?? "") === false) {
$errori_upload[] = $allegato["filename"];
}
}
}
if (isset($_POST["allegato-multimedia"])) {
$errori_upload = array();
foreach($_POST["allegato-multimedia"] as $allegato) {
if (filesManager::saveFile($allegato["filename"],$codice,"documentale",$allegato["nome"] ?? "","A",$allegato["classificazione"] ?? "","M") === false) {
$errori_upload[] = $allegato["filename"];
}
}
}
if (!empty($errori_upload)) {
$errori = implode("
" . __("errore") . " upload: ", $errori_upload);
?>
swal({title:js_dict["success-msg"],html:"