gestione gare pubbliche
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
4.3 KiB

<?php
$error = true;
$configPath = substr(__DIR__,0,strpos(__DIR__,"public_html/"))."config.php";
include_once($configPath);
if (isset($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice) && $_SESSION["utente"]->isSupportoOrRoot() && !empty($_SESSION["ente"]) && tokenVerify()) {
$elements = jsonToArray("utenti.json");
$uploaded = massiveHelper::getDataFromUpload($elements,$_POST["filechunk"]);
if (!empty($uploaded)) {
$error = false;
if (!empty($uploaded["data"])) {
$error = false;
$emails = $pdo->go("SELECT email FROM b_utenti")->fetchAll(PDO::FETCH_COLUMN, 0);
$enti = array_keys($_SESSION["ente"]->entiBeneficiari());
$utenti = [];
$errors = [];
foreach ($uploaded["data"] as $utente) {
if (in_array($utente["email"],$emails)) {
$errors[] = "{$utente["email"]} - " . __('Email già utilizzata');
}
$emails[] = $utente["email"];
if (!in_array($utente["collaborazione"], $enti)) {
$errors[] = "{$utente["collaborazione"]} -" . __('Collaborazione assente');
}
$utenti[] = $utente;
}
if (empty($errors)) {
foreach ($utenti as $utente) {
//crea il nuovo utente
$salva = new salva();
$salva->debug = false;
$salva->nome_tabella = "b_utenti";
$salva->operazione = "INSERT";
$salva->oggetto = [
"email" => $utente["email"],
"attivo" => substr($utente["attivo"], 0, 1),
"ruolo" => "USR",
"nome" => $utente["nome"],
"cognome" => $utente["cognome"],
"cf" => $utente["codice_fiscale"],
"password" => password_hash(md5(randomPassword(32)), PASSWORD_BCRYPT)
];
$codice_utente = $salva->save();
if (!empty($codice_utente)) {
//crea la collaborazione
$salva = new salva();
$salva->debug = false;
$salva->nome_tabella = "r_collaborazioni";
$salva->operazione = "INSERT";
$salva->oggetto = [
"gruppo" => $utente["collaborazione_ruolo"],
"codice_utente" => $codice_utente,
"codice_ente" => $utente["collaborazione"],
"attivo" => substr($utente["collaborazione_attivo"],0,1),
"readOnly" => substr($utente["collaborazione_sola_lettura"],0,1),
"utente_modifica" => 0
];
$salva->save();
}
}
alertManager::printSuccessBox(__("Caricamento effettuato con successo"));
} 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"]);
}
die();
}
}
if ($error) {
header('HTTP/1.0 403 Forbidden');
die();
}
}
?>