Swal({ text: "", type: "error", showCancelButton: false, confirmButtonColor: '#d33', confirmButtonText: js_dict.conferma, closeOnConfirm: true }).then(() => { window.location.reload(); }); permission($radice) && tokenVerify() && $_SESSION["utente"]->unlockSupporto()) { if (! empty(eFormsManager::get($_POST["guue"] ?? null, "TED_ESENDERS.FORM_SECTION.F03_2014.NUMBER_OF_AWARD_CONTRACT")) && eFormsManager::get($_POST["guue"] ?? null, "TED_ESENDERS.FORM_SECTION.F03_2014.NUMBER_OF_AWARD_CONTRACT") > 10000) { onSaveError("Il numero di aggiudicazioni inserite è superiore al massimo consentito"); return; } // Buffered output when responding with JSON to prevent notices from interfering if(!empty($_POST["action"]) && $_POST["action"] == "autosave") { ob_start(); } $ted = new TedEsender($_POST["form"], (int) $_POST["codice"], $settings, "{$_cdir}/config/xml"); $ted->setMode("save"); $ted->debug = DEVELOP_ENV; if (!empty($ted->info["modulo"]) && !empty($ted->info["codice_elemento"])) { if (!$_SESSION["utente"]->permission($ted->info["modulo"],$ted->info["codice_elemento"])) { header('HTTP/1.0 403 Forbidden'); die(); } } // Assegnamo un titolo provvisorio per evitare errori di autosalvataggio if(empty($_POST["titolo"])) { $_POST["titolo"] = uniqid(__guue("Pubblicazione")); } if (($ted->info["stato"] ?? "") === "TRASMESSO" || ($ted->info["stato"] ?? "") === "PUBBLICATO") { onSaveError("Questo form non può essere modificato"); return; } $result = $ted->save($_POST); if($result["concurrence_lock"] ?? false) { $message = "Questo form sta venendo modificato da un altro utente. Il blocco scade tra {$result['concurrence_lock']['delta']} secondi."; if(($_POST["action"] ?? "") === "autosave") { header('Content-Type: application/json'); die(json_encode(["errors" => $message])); } else { onSaveError($message); } return; } if(! empty($result["codice"])) { $query = []; $query["codice"] = $result["codice"]; $query["form"] = $result["form"]; switch($_POST["action"]) { case 'autosave': header('Content-Type: application/json'); if($result["first_save"] ?? false) { $query["section"] = $_GET["section"]; $query["subsection_index"] = $_GET["subsection_index"]; $query = http_build_query($query); $url = "/backend/guue/edit.php?{$query}"; die(json_encode(["redirect" => $url])); } $current_section = $_POST["current_section"]; $sections_index = array_flip(array_column($ted->sections, "name")); $section_index = $sections_index[$current_section]; $current_subsection_index = $_POST["current_subsection_index"]; $section = $ted->sections[$section_index]; $formStructure = $ted->createFormStructure($section, $current_subsection_index, false); // Fetch errors $errors = ob_get_clean(); if(!empty($errors) /*&& $ted->advanced_debug*/) { $formStructure["errors"] = $errors; } die(json_encode($formStructure)); break; case 'save-and-remain': if(!($result["first_save"] ?? false)) { die("window.location.reload()"); } break; case 'verify': if($ted->completed()) { $ted->noticeValidation(); } die("window.location.reload()"); break; default: $query["section"] = $_POST["next_section"]; $query["subsection_index"] = $_POST["next_subsection_index"]; break; } $query = http_build_query($query); $url = "/backend/guue/edit.php?{$query}"; die("window.location.href=\"{$url}\""); exit; } } header('HTTP/1.0 403 Forbidden'); die(); ?>