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.
102 righe
3.4 KiB
102 righe
3.4 KiB
<? |
|
$configPath = substr(__DIR__, 0, strpos(__DIR__, "/public_html")) . "/config.php"; |
|
include_once($configPath); |
|
define('_ELENCHI_API', 1); |
|
require_once(__DIR__ . "/inc/init.php"); |
|
|
|
$return = []; |
|
$return["draw"] = (int)$_POST["draw"]; |
|
$return["recordsTotal"] = (int)0; |
|
$return["recordsFiltered"] = (int)0; |
|
|
|
|
|
|
|
if (!empty($_SESSION["utente"]) && ($_SESSION["utente"]->permission($radice) || (!empty($_POST["modulo"]) && $_SESSION["utente"]->permission($_POST["modulo"])))) { |
|
if (isset($_POST["draw"])) { |
|
|
|
if (!empty($endpoint)) { |
|
$body = []; |
|
|
|
// Alleghiamo l'ordine |
|
if (isset($_POST["order"])) { |
|
$orderKey = null; |
|
switch ($_POST["order"][0]["column"]) { |
|
case "1": |
|
$orderKey = "codice_fiscale_impresa"; |
|
break; |
|
case "2": |
|
$orderKey = "ragione_sociale"; |
|
break; |
|
case "3": |
|
$orderKey = "pec"; |
|
break; |
|
} |
|
$orderDir = $_POST["order"][0]["dir"] ?? "asc"; |
|
if ($orderKey) |
|
$body["order"] = ["dir" => $orderDir, "column" => $orderKey]; |
|
} |
|
// Alleghiamo il limit |
|
if (isset($_POST["start"]) && isset($_POST["length"])) { |
|
$body["limit"] = ["start" => $_POST["start"], "limit" => $_POST["length"]]; |
|
} |
|
// Alleghiamo i filtri |
|
if (!empty($_POST["filters"])) { |
|
parse_str(str_replace("&","&",$_POST["filters"]), $body["filters"]); |
|
} |
|
// Alleghiamo la ricerca se presente |
|
if (!empty($_POST["search"]["value"])) { |
|
$body["filters"]["search"] = $_POST["search"]["value"]; |
|
} |
|
|
|
// Appendiamo un body se serve |
|
if (!empty($body)) { |
|
$body = json_encode($body); |
|
} else { |
|
$body = ""; |
|
} |
|
$data = json_decode(tuttogare_api_call("{$endpoint["endpoint"]}/getPartecipantiAlbo?codice={$key}", $endpoint["token"], "POST", $body), true) ?? []; |
|
if (isset($data["data"])) { |
|
$data["recordsFiltered"] = $data["recordsTotal"]; |
|
$data["draw"] = $_POST["draw"]; |
|
|
|
if ($modulo_riferimento === "gare") { |
|
// Otteniamo tutti gli invitati |
|
$invitati = $gara->getDestinatari(); |
|
// Otteniamo quelli formato OE |
|
$invitati_oe = array_filter($invitati, "is_numeric"); |
|
// Filtriamo quelli formato PEC |
|
$invitati_pec = array_diff($invitati, $invitati_oe); |
|
// Convertiamo gli OE in PEC se ci sono |
|
$invitati_oe = empty($invitati_oe) ? [] : oeManager::getOE($invitati_oe); |
|
// Se abbiamo un valore di ritorno, prendiamo solo la pec dagli oe |
|
$invitati_oe = empty($invitati_oe) ? [] : array_column($invitati_oe, "pec"); |
|
// Riuniamo tutto |
|
$invitati = array_merge($invitati_pec, $invitati_oe); |
|
|
|
foreach ($data["data"] as &$entry) { |
|
|
|
if (in_array(strtolower($entry[3]), $invitati)) { |
|
$entry[] = <<<HTM |
|
<div class="badge badge-success badge-sm"> |
|
<i class="fa fa-check"></i> |
|
Invitato |
|
</div> |
|
HTM; |
|
} else { |
|
$entry[] = <<<HTM |
|
<button class="btn btn-primary btn-sm" onclick="invitaRemoto(`{$entry[1]}`,`{$entry[2]}`,`{$entry[3]}`)"> |
|
<i class="fa fa-paper-plane"></i> |
|
Invita |
|
</button> |
|
HTM; |
|
} |
|
} |
|
} |
|
$return = $data; |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
echo (json_encode($return, JSON_PRETTY_PRINT));
|
|
|