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.
138 righe
5.7 KiB
138 righe
5.7 KiB
<? |
|
$error = true; |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"public_html/"))."config.php"; |
|
include_once($configPath); |
|
if (isset($_SESSION["utente"]) && $_SESSION["utente"]->permission("simog")) { |
|
$printScript = false; |
|
if (isset($_POST["cig"])) { |
|
$_GET = $_POST; |
|
} else { |
|
$printScript = true; |
|
} |
|
if (empty($_GET["cig"]) || empty($_GET["anno"]) || empty($_GET["codice_ente"])) { |
|
$enti = $_SESSION["utente"]->getEntiBeneficiari(false); |
|
if ($enti !== false) { |
|
$error = false; |
|
?> |
|
<form action="/backend/anac/import.php" method="post" rel="validate"> |
|
<input id="token" type="hidden" name="token" value="<?= tokenGen() ?>"> |
|
<div class="row"> |
|
<div class="col-12 col-lg-6"> |
|
<div class="form-group"> |
|
<label for="cig"><?= __("CIG") ?>*</label> |
|
<input class="form-control input-lg text-center" name="cig" id="cig" rel="S;10;10;A" title="<?= __("CIG") ?>"> |
|
</div> |
|
</div> |
|
<div class="col-12 col-lg-6"> |
|
<div class="form-group"> |
|
<label for="anno"><?= __("Anno di riferimento") ?></label> |
|
<input class="form-control input-lg text-center" name="anno" id="anno" rel="S;4;4;A" title="<?= __("Anno di riferimento") ?>"> |
|
</div> |
|
</div> |
|
</div> |
|
<div class="form-group"> |
|
<label for="codice_ente"><?= __("Beneficiario") ?>* </label> |
|
<select name="codice_ente" class="form-control" title="<?= __("beneficiario") ?>" rel="S;0;0;N" id="codice_ente"> |
|
<option value="">Seleziona...</option> |
|
<? |
|
foreach($enti AS $ente) { |
|
?> |
|
<option value="<?= $ente["codice"] ?>"><?= $ente["denominazione"] ?></option> |
|
<? |
|
} |
|
?> |
|
</select> |
|
</div> |
|
<button type="submit" class="btn btn-block btn-primary"><span class="fa fa-download"></span> <?= __("Importa") ?></button> |
|
</form> |
|
<? |
|
} |
|
} else { |
|
if (tokenVerify($_GET["token"])) { |
|
if ($printScript) { echo "<script>"; } |
|
include($beRoot."/anac/ws/simog.class.php"); |
|
$error = false; |
|
$bind = [":gestore"=>$_SESSION["ente"]->codice,":cig"=>$_GET["cig"]]; |
|
$check = $pdo->go("SELECT b_simog_lotti.codice FROM b_simog_lotti JOIN b_simog ON b_simog_lotti.codice_simog = b_simog.codice WHERE codice_gestore = :gestore AND cig = :cig",$bind); |
|
if ($check->rowCount() === 0) { |
|
if (empty($_SESSION["simog"]["collaborazione"])) { |
|
?> |
|
modalURL = []; |
|
<? $action = base64_encode("/backend/anac/import.php?".http_build_query($_GET)); ?> |
|
showModalWithURL('/backend/anac/ws/views/login.php?action=<?= $action ?>'); |
|
<? |
|
} else { |
|
$simog = new simog(); |
|
$simog->index = $_SESSION["simog"]["collaborazione"]["index"]; |
|
$simog->ticket = $_SESSION["simog"]["ticket"]; |
|
$return = $simog->sendData("consultaComunicazione",["cig"=>$_GET["cig"]]); |
|
$found = false; |
|
$smart = false; |
|
if (!empty($return->comunicazione)) { |
|
$found = true; |
|
$smart = true; |
|
$return = $return->comunicazione; |
|
} else { |
|
$return = $simog->sendData("consultaGara",["CIG"=>$_GET["cig"],"schede"=>anac::getVersion()]); |
|
if (!empty($return->return->GaraXML)) { |
|
$found = true; |
|
$return = $return->return; |
|
$id_gara = $return->GaraXML->DatiGara->Gara->ID_GARA ?? ""; |
|
if (!empty($id_gara)) { |
|
$error = false; |
|
$bind = [":gestore"=>$_SESSION["ente"]->codice,":id_gara"=>$id_gara]; |
|
$check = $pdo->go("SELECT b_simog.codice FROM b_simog WHERE codice_gestore = :gestore AND id_gara = :id_gara",$bind); |
|
if ($check->rowCount() > 0) { |
|
$idInit = $check->fetch(PDO::FETCH_ASSOC)["codice"]; |
|
} |
|
} |
|
} |
|
} |
|
if ($found) { |
|
if (isset($idInit)) { |
|
$anac = anac::init($idInit); |
|
} else { |
|
$anac = new anac(); |
|
} |
|
if (!empty($anac)) { |
|
$esito = $anac->createFromSIMOG($return,$_GET["anno"],$_GET["codice_ente"],$smart); |
|
if (!empty($esito["codice"])) { |
|
?> |
|
swal({title:js_dict["success-msg"],type:"success"}).then(function(){ window.location.href="/backend/anac/panel.php?codice=<?= $esito["codice"] ?>";}); |
|
<? |
|
} else { |
|
$msg = ""; |
|
if (!empty($esito["errori"])) { |
|
if (is_array($esito["errori"])) { |
|
$msg = implode("<br>",$esito["errori"]); |
|
} else{ |
|
$msg = $esito["errori"]; |
|
} |
|
} |
|
?> |
|
swal({title:js_dict.error,html:<?= (!empty($msg)) ? "\"{$msg}\"" : "js_dict[\"error-generic\"]" ?>,type:"error"}); |
|
<? |
|
} |
|
} else { |
|
$error = true; |
|
} |
|
} else { |
|
?> |
|
swal({title:js_dict.error,html:"CIG <?= __("non trovato") ?>",type:"error"}); |
|
<? |
|
} |
|
} |
|
} else { |
|
?> |
|
swal({title:js_dict.error,html:"CIG <?= __("già esistente") ?>",type:"error"}); |
|
<? |
|
} |
|
if ($printScript) { echo "</script>"; } |
|
} |
|
} |
|
} |
|
if ($error) { |
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
} |
|
?>
|
|
|