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.
118 righe
4.6 KiB
118 righe
4.6 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
if (isset($_SESSION["ente"])) { |
|
|
|
function validateRequest($params) { |
|
if (!empty($params->token) && $params->token == $_SESSION["ente"]->getInfo()["advancedToken"]) { |
|
return true; |
|
} |
|
} |
|
|
|
function updateLiquidato($params) { |
|
if (validateRequest($params)) { |
|
$json = []; |
|
global $pdo; |
|
$json = ["success"=>false, "error" => true, "error_code" => 403, "message" => ["Unauthorized"]]; |
|
if (!empty($params->lotti)) { |
|
$lotti = $params->lotti; |
|
if (isset($lotti->liquidato)) { |
|
$lotti = [$lotti]; |
|
} |
|
$errori = []; |
|
$search = "SELECT b_simog_lotti.codice FROM b_simog_lotti WHERE "; |
|
$search_cig = $search . " cig = :search "; |
|
$search_codice = $search . " codice = :search "; |
|
$search_cig = $pdo->prepare($search_cig); |
|
$search_codice = $pdo->prepare($search_codice); |
|
$updateRecords = []; |
|
if (!empty($lotti)) { |
|
foreach($lotti AS $lotto) { |
|
$searchValue = ""; |
|
$search = ""; |
|
if (!empty($lotto->cig)) { |
|
$cig = true; |
|
$searchValue = $lotto->cig; |
|
$search = $search_cig; |
|
} else if (!empty($lotto->codice)) { |
|
$cig = false; |
|
$searchValue = $lotto->codice; |
|
$search = $search_codice; |
|
} |
|
if (!empty($searchValue)) { |
|
if (isset($lotto->liquidato)) { |
|
if (is_numeric($lotto->liquidato)) { |
|
$search->bindValue(":search",$searchValue); |
|
$search->execute(); |
|
if ($search->rowCount() > 0) { |
|
while ($record = $search->fetch(PDO::FETCH_ASSOC)) { |
|
$record["liquidato"] = $lotto->liquidato; |
|
$record["cig"] = $cig; |
|
$record["riferimento"] = $searchValue; |
|
$updateRecords[] = $record; |
|
} |
|
} else { |
|
$errori[] = (($cig) ? "CIG " : "#") . $searchValue . ": sconosciuto"; |
|
} |
|
} else { |
|
$errori[] = (($cig) ? "CIG " : "#") . $searchValue . ": Importo di liquidazione non numerico"; |
|
} |
|
} else { |
|
$errori[] = (($cig) ? "CIG " : "#") . $searchValue . ": Nessun importo di liquidazione indicato"; |
|
} |
|
} else { |
|
$break = true; |
|
$json["error_code"] = 400; |
|
$json["message"] = ["Verificare gli identificativi del lotto"]; |
|
break; |
|
} |
|
} |
|
if (!isset($break)) { |
|
if (empty($errori)) { |
|
$json["error_code"] = 200; |
|
$sqlUpdate = "UPDATE b_simog_lotti SET 190liquidazioni = :liquidato WHERE codice = :codice "; |
|
$update = $pdo->prepare($sqlUpdate); |
|
foreach($updateRecords AS $record) { |
|
$update->bindValue(":codice",$record["codice"]); |
|
$update->bindValue(":liquidato",$record["liquidato"]); |
|
$update->execute(); |
|
if ($update->rowCount() > 0) { |
|
$sqlLog = $sqlUpdate; |
|
$sqlLog = str_replace(":liquidato",$record["liquidato"],$sqlLog); |
|
$sqlLog = str_replace(":codice",$record["codice"],$sqlLog); |
|
scriviLog("b_lotti_simog",$sqlLog,"UPDATE",-1); |
|
$json["success"] = true; |
|
} else { |
|
$json["error_code"] = 201; |
|
$errori[] = (($record["cig"]) ? "CIG " : "#") . $record["riferimento"] . ": Nessun aggiornamento"; |
|
} |
|
} |
|
} |
|
if (!empty($errori)) { |
|
$json["message"] = $errori; |
|
} else { |
|
$json["error"] = false; |
|
$json["error_code"] = 0; |
|
$json["message"] = []; |
|
} |
|
} |
|
} else { |
|
$json["error_code"] = 400; |
|
$json["message"] = ["Nessun lotto indicato"]; |
|
} |
|
} else { |
|
$json["error_code"] = 400; |
|
$json["message"] = ["Nessun lotto indicato"]; |
|
} |
|
return json_encode($json,JSON_HEX_TAG | JSON_UNESCAPED_SLASHES); |
|
} |
|
return json_encode(["error"=>"Errore richiesta"]); |
|
} |
|
$base = file_get_contents("base.wsdl"); |
|
$base = str_replace("https://www.stazioneappalti.it",$_SESSION["config"]["link_sito"],$base); |
|
$base = 'data://text/plain;base64,'.base64_encode($base); |
|
$server = new SoapServer($base,array('cache_wsdl'=>WSDL_CACHE_NONE)); |
|
$server->addFunction("updateLiquidato"); |
|
$server->handle(); |
|
} |
|
?>
|