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.
99 righe
3.4 KiB
99 righe
3.4 KiB
<? |
|
$error = true; |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"public_html/"))."config.php"; |
|
include_once($configPath); |
|
$id_modulo = "partecipanti"; |
|
if (isset($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice,$_POST["codice_gara"],$id_modulo) && tokenVerify()) { |
|
$gara = gara::init($_POST["codice_gara"],$_POST["codice_round"]); |
|
if (!empty($gara) && $gara->setLotto($_POST["codice_lotto"])) { |
|
if (!$gara->checkLock($id_modulo)) { |
|
if (!empty($gara->lotto)) { |
|
$elements = jsonToArray("elements.json"); |
|
$uploaded = massiveHelper::getDataFromUpload($elements,$_POST["filechunk"]); |
|
if (!empty($uploaded)) { |
|
$error = false; |
|
if (!empty($uploaded["data"])) { |
|
$partecipanti = $uploaded["data"]; |
|
$cf = []; |
|
$raggruppamenti = []; |
|
$errors = []; |
|
foreach ($partecipanti AS $partecipante) { |
|
if (empty($partecipante["codice_fiscale_capogruppo"])) { |
|
$cf[] = $partecipante["codice_fiscale"]; |
|
} |
|
} |
|
foreach ($partecipanti AS $key => $partecipante) { |
|
if (!empty($partecipante["codice_fiscale_capogruppo"])) { |
|
if (in_array($partecipante["codice_fiscale_capogruppo"],$cf) === false) { |
|
$errors[] = $partecipante["codice_fiscale_capogruppo"] . " - " . __("Codice fiscale non presente tra i capogruppo"); |
|
} else { |
|
if (!empty($partecipante["ruolo"])) { |
|
$partecipante["codice_fiscale_impresa"] = $partecipante["codice_fiscale"]; |
|
$raggruppamenti[$partecipante["codice_fiscale_capogruppo"]][] = $partecipante; |
|
unset($partecipanti[$key]); |
|
} else { |
|
$errors[] = $partecipante["ragione_sociale"] . " - " . __("Ruolo nel raggruppamento non specificato"); |
|
} |
|
} |
|
} |
|
} |
|
if (empty($errors)) { |
|
$pdo->go("DELETE FROM r_partecipanti_gare WHERE codice_round = :round AND codice_lotto = :codice",[":round"=>$gara->round["codice"],":codice"=>$gara->lotto["codice"]]); |
|
foreach($partecipanti AS $partecipante) { |
|
if (!empty($raggruppamenti[$partecipante["codice_fiscale"]])) { |
|
$partecipante["raggruppamento"] = $raggruppamenti[$partecipante["codice_fiscale"]]; |
|
} |
|
if (!$gara->savePartecipante($partecipante)) { |
|
$errors[] = __("Errore nel salvataggio del partecipante") . ": " . $partecipante["ragione_sociale"]; |
|
} |
|
} |
|
} |
|
if (empty($errors)) { |
|
?> |
|
<script> |
|
swal({title:js_dict["success-msg"],type:"success"}).then(function(){ |
|
window.location.reload(); |
|
}); |
|
</script> |
|
<? |
|
} else { |
|
alertManager::printAlertBox(__("impossibile continuare")); |
|
?> |
|
<div class="table-responsive"> |
|
<table class="table table-striped"> |
|
<thead> |
|
<tr> |
|
<td><?= __("errore") ?></td> |
|
</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(); |
|
} |
|
?>
|
|
|