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.
94 righe
3.2 KiB
94 righe
3.2 KiB
<? |
|
$error = true; |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"public_html/"))."config.php"; |
|
include_once($configPath); |
|
if (isset($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice) && tokenVerify()) { |
|
$elements = jsonToArray("lotti.json"); |
|
$uploaded = massiveHelper::getDataFromUpload($elements,$_POST["filechunk"]); |
|
if (!empty($uploaded)) { |
|
$error = false; |
|
if (!empty($uploaded["data"])) { |
|
$error = false; |
|
$anni = []; |
|
$foundCig = []; |
|
$errors = []; |
|
foreach($uploaded["data"] AS $lotto) { |
|
if (!empty(trim($lotto["cig"])) && str_replace("0","",$lotto) != "") { |
|
if (in_array($lotto["cig"],$foundCig) === false) { |
|
|
|
if (!is_numeric($lotto["annoRiferimento"]) || strlen($lotto["annoRiferimento"]) != 4) $errors[] = $lotto["cig"] . " - " . __("Anno di riferimento non valido"); |
|
if (strlen($lotto["cig"]) != 10) $errors[] = $lotto["cig"] . " - " . __("Non valido"); |
|
if (!empty($lotto["inizioContratto"])) { |
|
$test_arr = explode('/', $lotto["inizioContratto"]); |
|
if (count($test_arr) == 3) { |
|
if (!checkdate($test_arr[1], $test_arr[0], $test_arr[2])) { |
|
$errors[] = $lotto["cig"] . " - " . $lotto["inizioContratto"] . " - " . __("Data inizio contratto non valida"); |
|
} |
|
} else { |
|
$errors[] = $lotto["cig"] . " - " . $lotto["inizioContratto"] . " - " . __("Data inizio contratto non valida"); |
|
} |
|
} |
|
if (!empty($lotto["fineContratto"])) { |
|
$test_arr = explode('/', $lotto["fineContratto"]); |
|
if (count($test_arr) == 3) { |
|
if (!checkdate($test_arr[1], $test_arr[0], $test_arr[2])) { |
|
$errors[] = $lotto["cig"] . " - " . $lotto["fineContratto"] . " - " . __("Data fine contratto non valida"); |
|
} |
|
} else { |
|
$errors[] = $lotto["cig"] . " - " . $lotto["fineContratto"] . " - " . __("Data fine contratto non valida"); |
|
} |
|
} |
|
if (!isset($anni[$lotto["annoRiferimento"]])) $anni[$lotto["annoRiferimento"]] = []; |
|
$anni[$lotto["annoRiferimento"]][] = $lotto; |
|
$foundCig[] = $lotto["cig"]; |
|
} else { |
|
$errors[] = $lotto["cig"] . " - " . __("Duplicato"); |
|
} |
|
} |
|
} |
|
if (empty($errors)) { |
|
$_SESSION["importAnac"][$_POST["operationID"]]["lotti"] = $anni; |
|
alertManager::printSuccessBox(__("Caricamento effettuato con successo")) |
|
?> |
|
<script> |
|
$('#checkLotti').val("S"); |
|
</script> |
|
<? |
|
} else { |
|
alertManager::printAlertBox(__("Impossibile continuare")); |
|
?> |
|
<div class="table-responsive"> |
|
<table class="table table-striped"> |
|
<thead> |
|
<tr> |
|
<th><?= __("errore") ?></th> |
|
</tr> |
|
</thead> |
|
<tbody> |
|
<? |
|
foreach($errors AS $errore) { |
|
?> |
|
<tr> |
|
<td><strong><?= $errore ?></strong></td> |
|
</tr> |
|
<? |
|
} |
|
?> |
|
</tbody> |
|
</table> |
|
</div> |
|
<? |
|
} |
|
} else { |
|
alertManager::printAlertBox(__("impossibile continuare")); |
|
if (!empty($uploaded["errors"])) { |
|
massiveHelper::printErrors($uploaded["errors"]); |
|
} |
|
} |
|
} |
|
} |
|
if ($error) { |
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
} |
|
?>
|
|
|