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.
116 righe
5.0 KiB
116 righe
5.0 KiB
<? |
|
if (isset($this)) { |
|
$submit = false; |
|
if ($this->partecipazioneAttiva()) { |
|
$submit = true; |
|
} |
|
$partecipante = $this->miaPartecipazione(); |
|
$formManager = new FormManager(); |
|
$formManager->stripEnte = true; |
|
$formManager->init($codice_form,$this->modulo."-".$_SESSION["ente"]->codice,$partecipante["codice"] ?? null); |
|
if (empty($formManager->getValues())) { |
|
$partecipantiTable = static::getOeTable(); |
|
$sources = []; |
|
$check = $this->db->prepare("SELECT codice, `timestamp` FROM {$partecipantiTable} WHERE codice_operatore = :operatore AND codice_elenco = :elenco ORDER BY codice DESC"); |
|
$check->bindValue(":operatore",$_SESSION["utente"]->oe["codice"]); |
|
if (empty($_GET["duplicateFrom"])) { |
|
$formTable = static::getFormTable(); |
|
$altriElenchi = $this->db->go("SELECT codice_elenco FROM {$formTable} WHERE codice_form = :form",[":form"=>$codice_form])->fetchAll(PDO::FETCH_COLUMN); |
|
if (!empty($altriElenchi)) { |
|
foreach($altriElenchi AS $altroElenco) { |
|
$check->bindValue(":elenco",$altroElenco); |
|
$check->execute(); |
|
if ($check->rowCount() > 0) { |
|
$altraPartecipazione = $check->fetch(PDO::FETCH_ASSOC); |
|
$existingForm = new FormManager(); |
|
$existingForm->init($codice_form,$this->modulo."-{$_SESSION["ente"]->codice}",$altraPartecipazione["codice"]); |
|
$values = $existingForm->getValues(); |
|
if (!empty($values)) { |
|
$altraPartecipazione["codice_elenco"] = $altroElenco; |
|
$sources[] = $altraPartecipazione; |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
} else { |
|
$altraPartecipazione = $_GET["duplicateFrom"]; |
|
$check->bindValue(":elenco",$_GET["duplicateElenco"]); |
|
$check->execute(); |
|
if ($check->rowCount() > 0) { |
|
$check = $check->fetch(PDO::FETCH_ASSOC); |
|
if ($check["codice"] == $altraPartecipazione) { |
|
$formManager->duplicateID = $altraPartecipazione; |
|
} |
|
} |
|
} |
|
} |
|
if ($submit) { |
|
if (!empty($sources)) { |
|
if (count($sources) > 1) { |
|
?> |
|
<div class="modal fade" id="selezionaElenco"> |
|
<div class="modal-dialog modal-dialog-centered" role="document"> |
|
<div class="modal-content rounded-0"> |
|
<div class="card card-body"> |
|
<? |
|
echo "<h2>" . __("Seleziona fonte") . "</h2>"; |
|
foreach($sources AS $source) { |
|
?> |
|
<a class="btn btn-info btn-block my-2" href="form.php?codice=<?= $this->info["codice"] ?>&codice_form=<?= $codice_form ?>&duplicateFrom=<?= $source["codice"]; ?>&duplicateElenco=<?= $source["codice_elenco"] ?>"> |
|
<?= __("Compilato il") . ": " . mysql2datetime($source["timestamp"]) ?> |
|
</a> |
|
<? |
|
} |
|
?> |
|
</div> |
|
</div><!-- /.modal-content --> |
|
</div><!-- /.modal-dialog --> |
|
</div><!-- /.modal --> |
|
<? } else { |
|
$source = $sources[0]; |
|
} ?> |
|
<div id="importAlert"> |
|
<? ob_start(); ?> |
|
<div class="mt-2 row"> |
|
<div class="col-12 col-lg-6"> |
|
<button class="btn btn-danger btn-block" onclick="$('#importAlert').slideUp();"> |
|
<?= __("Ignora") ?> |
|
</button> |
|
</div> |
|
<div class="col-12 col-lg-6"> |
|
<? |
|
if (count($sources) > 1) { |
|
?> |
|
<button class="btn btn-info btn-block" onclick="$('#selezionaElenco').modal();"> |
|
<?= __("Importa") ?> |
|
</button> |
|
<? |
|
} else { |
|
?> |
|
<a class="btn btn-info btn-block" href="form.php?codice=<?= $this->info["codice"] ?>&codice_form=<?= $codice_form ?>&duplicateFrom=<?= $source["codice"]; ?>&duplicateElenco=<?= $source["codice_elenco"] ?>"> |
|
<?= __("Importa") ?> |
|
</a> |
|
<? |
|
} |
|
?> |
|
</div> |
|
</div> |
|
<? $buttons = ob_get_clean() ?> |
|
<? alertManager::printInfoBox(__('Hai già compilato questo form in un\'altra sezione'),$buttons); ?> |
|
</div> |
|
<? |
|
} |
|
?> |
|
<form id="submit-form" action="form-save.php" rel="validate" method="post" target="_self"> |
|
<input type="hidden" name="token" value="<?= tokenGen() ?>"> |
|
<input type="hidden" name="codice" value="<?= $this->info["codice"] ?>"> |
|
<input type="hidden" name="codice_form" value="<?= $formManager->info["codice"] ?>"> |
|
<? } |
|
$formManager->printForm($submit,true); |
|
if ($submit) { ?> |
|
<button type="submit" class="btn btn-lg btn-block btn-success"><span class="fa fa-save"></span> <?= __("Salva") ?></button> |
|
</form> |
|
<? } |
|
} |
|
?>
|