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.
193 righe
10 KiB
193 righe
10 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
if (!empty($_SESSION["utente"]) && ($_SESSION["utente"]->permission($radice) || (!empty($_POST["modulo"]) && $_SESSION["utente"]->permission($_POST["modulo"])))) { |
|
if (isset($_POST["draw"])) { |
|
$filters = []; |
|
if (!empty($_POST["filters"])) { |
|
parse_str(str_replace("&","&",$_POST["filters"]), $filters); |
|
} |
|
$timing = [[date("Y-m-d H:i:s.u"),"Start"]]; |
|
$oeManager = new oeManager; |
|
$oeManager->countInviti = true; |
|
$oeManager->setFilters($filters); |
|
if (!empty($_POST["search"]["value"])) { |
|
$oeManager->generalFilter = $_POST["search"]["value"]; |
|
} |
|
$timing[] = [date("Y-m-d H:i:s.u"),"Init filters"]; |
|
$premialita = (settingsManager::getValue("premialitaOEVR-positivo") == "S"); |
|
$soglia = settingsManager::getValue("premialitaOEVR-soglia"); |
|
$timing[] = [date("Y-m-d H:i:s.u"),"Init settings"]; |
|
if (isset($_SESSION["exportoperatoriSettings"][$_POST["token"]]) && |
|
$_SESSION["exportoperatoriSearch"][$_POST["token"]] == $oeManager->generalFilter && |
|
json_encode($_SESSION["exportoperatoriSettings"][$_POST["token"]]) === json_encode($filters)) { |
|
$timing[] = [date("Y-m-d H:i:s.u"),"Get from search session"]; |
|
if (isset($_SESSION["exportoperatori"][$_POST["token"]])) { |
|
$operatori = $_SESSION["exportoperatori"][$_POST["token"]]; |
|
$relazioni = array_column($operatori,"codice"); |
|
$timing[] = [date("Y-m-d H:i:s.u"),"Get from clean session"]; |
|
} else { |
|
$relazioni = json_decode(gzuncompress($_SESSION["exportoperatoriRelazioni"][$_POST["token"]]),true); |
|
$timing[] = [date("Y-m-d H:i:s.u"),"Get from compressed session"]; |
|
} |
|
} else { |
|
$relazioni = $oeManager->getOERelations($_SESSION["ente"]->codice,$filters["logicOperator"] ?? "OR"); |
|
$timing[] = [date("Y-m-d H:i:s.u"),"New query"]; |
|
} |
|
|
|
|
|
$return = array(); |
|
$return["draw"] = (int)$_POST["draw"]; |
|
$return["recordsTotal"] = (int)0; |
|
$return["recordsFiltered"] = (int)0; |
|
$bind = []; |
|
if (!empty($relazioni)) { |
|
$oeAlbi = []; |
|
$timing[] = [date("Y-m-d H:i:s.u"),"Begin elaboration"]; |
|
if ($pdo->go("SHOW TABLES LIKE 'r_partecipanti_albo'")->rowCount() > 0) { |
|
$oeAlbi = $pdo->go("SELECT r_partecipanti_albo.codice_operatore FROM r_partecipanti_albo JOIN b_bandi_albo ON r_partecipanti_albo.codice_elenco = b_bandi_albo.codice |
|
WHERE conferma = 'S' AND ammesso = 'S' AND b_bandi_albo.tipologia <> 'I'")->fetchAll(PDO::FETCH_COLUMN); |
|
if (!empty($oeAlbi)) { |
|
$oeAlbi = array_unique($oeAlbi); |
|
} else { |
|
$oeAlbi = []; |
|
} |
|
} |
|
$timing[] = [date("Y-m-d H:i:s.u"),"OE List transacted"]; |
|
$return["recordsTotal"] = (int)count($relazioni); |
|
if (empty($operatori)) { |
|
$operatori = oeManager::getOE(array_keys($relazioni)); |
|
$timing[] = [date("Y-m-d H:i:s.u"),"Begin adding OE Info"]; |
|
if (!empty($operatori)) { |
|
foreach($operatori AS $index => $oe) { |
|
$oe["timestamp_iscrizione"] = $relazioni[$index]["timestamp"]; |
|
$oe["feedback"] = $relazioni[$index]["feedback"]; |
|
$oe["id_interno"] = $relazioni[$index]["id_interno"]; |
|
$oe["inviti"] = $relazioni[$index]["inviti"] ?? "n.a."; |
|
$oe["invitiSolari"] = $relazioni[$index]["invitiSolari"] ?? "n.a."; |
|
$oe["albi"] = (in_array($oe["codice"],$oeAlbi)); |
|
$operatori[$index] = $oe; |
|
} |
|
} |
|
$timing[] = [date("Y-m-d H:i:s.u"),"End adding OE Info"]; |
|
} |
|
if (!empty($operatori)) { |
|
$order = "ragione_sociale"; |
|
switch($_POST["order"][0]["column"]) { |
|
case "0": $order = "codice"; break; |
|
case "2": $order = "codice_fiscale_impresa"; break; |
|
case "3": $order = "partita_iva"; break; |
|
case "4": $order = "ragione_sociale"; break; |
|
case "6": $order = "timestamp_iscrizione"; break; |
|
case "7": $order = "inviti"; break; |
|
case "8": $order = "invitiSolari"; break; |
|
case "9": $order = "albi"; break; |
|
case "10": $order = "feedback"; break; |
|
} |
|
if ($_POST["order"][0]["dir"] == "desc") { |
|
usort($operatori, function($a, $b) { |
|
global $order; |
|
return $b[$order] > $a[$order]; |
|
}); |
|
} else { |
|
usort($operatori, function($a, $b) { |
|
global $order; |
|
return $a[$order] > $b[$order]; |
|
}); |
|
} |
|
$timing[] = [date("Y-m-d H:i:s.u"),"Data sorted"]; |
|
$return["recordsFiltered"] = count($operatori); |
|
$_SESSION["exportoperatoriSearch"][$_POST["token"]] = $oeManager->generalFilter; |
|
$_SESSION["exportoperatoriSettings"][$_POST["token"]] = $filters; |
|
if (count($operatori) < 5000) { |
|
$_SESSION["exportoperatori"][$_POST["token"]] = $operatori; |
|
} else { |
|
$_SESSION["exportoperatoriRelazioni"][$_POST["token"]] = gzcompress(json_encode($relazioni)); |
|
} |
|
$timing[] = [date("Y-m-d H:i:s.u"),"Session stored"]; |
|
session_write_close(); |
|
$operatori = array_slice($operatori,(int)$_POST["start"],(int)$_POST["length"]); |
|
$timing[] = [date("Y-m-d H:i:s.u"),"Data sliced"]; |
|
$punteggioMassimo = settingsManager::getValue("punteggioMassimoVR"); |
|
$acceptedCallbacks = ["invitaOperatore"]; |
|
if (!empty($operatori)) { |
|
$return["data"] = array(); |
|
$timing[] = [date("Y-m-d H:i:s.u"),"Begin - OE Checks verify"]; |
|
$verificaArt80 = $oeManager->checkVerificaOE(array_column($operatori, "codice_fiscale_impresa")); |
|
$timing[] = [date("Y-m-d H:i:s.u"),"End - OE Checks verify"]; |
|
foreach($operatori AS $operatore) { |
|
$row = array(); |
|
$row[0] = $operatore["codice"]; |
|
$row[1] = '<div class="mx-1 status_flag bg-white border border-secondary progress-bar-striped"></div>'; |
|
if(! empty($verificaArt80[$operatore["codice_fiscale_impresa"]])) { |
|
$row[1] = '<div class="mx-1 status_flag progress-bar-striped" style="background-color: '.$verificaArt80[$operatore["codice_fiscale_impresa"]]["color"].' !important"></div>'; |
|
} |
|
$row[2] = $operatore["codice_fiscale_impresa"]; |
|
$row[3] = $operatore["partita_iva"]; |
|
$row[4] = "<strong>{$operatore["ragione_sociale"]}</strong>" . (($operatore["attivo"] == "S") ? "" : "<br><small class='badge badge-danger'>".__("Utenza non attiva")."</small>") ; |
|
$row[5] = ($operatore["tipo"] == "IMP") ? __("Impresa") : __("Professionista"); |
|
$row[6] = mysql2datetime($operatore["timestamp_iscrizione"]); |
|
$row[7] = $operatore["inviti"] ?? "n.a."; |
|
$row[8] = $operatore["invitiSolari"] ?? "n.a."; |
|
$row[9] = ($operatore["albi"] == 1) ? "<span class='fa fa-check text-success'></span>" : ""; |
|
if (!empty($operatore["feedback"])) { |
|
$color = make_color($operatore["feedback"]/$punteggioMassimo,0,1); |
|
ob_start(); |
|
?> |
|
<span class="fa fa-star" style="color:<?= $color ?>"></span><br> |
|
<strong><?= number_format($operatore["feedback"],2) ?></strong> |
|
<? |
|
if ($premialita && $operatore["feedback"] >= $soglia) { |
|
$checkPremialita = vendorRating::getPremialita($operatore["codice"],null); |
|
if (!empty($checkPremialita)) { |
|
?> |
|
<br><small class="badge badge-info"><?= __("Premialità assegnata") ?></small> |
|
<? |
|
} |
|
} |
|
$row[10] = ob_get_clean(); |
|
} else { |
|
$row[10] = ""; |
|
} |
|
$row[11] = "<button class=\"btn btn-sm btn-info\" onClick=\"showCompany({$operatore["codice"]})\" title=\"".__("Visualizza")."\"><span class=\"fa fa-search\"></span></button>"; |
|
if (empty($_POST["callBackAction"])) { |
|
$row[12] = "<button class=\"btn btn-block btn-sm btn-primary\" onClick=\"showModalWithURL('/backend/comunicazioni/form.php?sezione=albo&codice_elemento=-1&destinatari={$operatore["codice"]}')\" title=\"".__("Comunicazione")."\"><span class=\"fa fa-paper-plane\"></span></button>"; |
|
} else { |
|
if (in_array($_POST["callBackAction"],$acceptedCallbacks,true)!==false) { |
|
$selected = false; |
|
if (isset($_POST["callBackSelected"])) { |
|
$callBackSelected = json_decode($_POST["callBackSelected"],true); |
|
if (!empty($callBackSelected) && (in_array($operatore["codice"],$callBackSelected) !== false)) { |
|
$selected = true; |
|
} |
|
} |
|
$callBackbuttons = "<button class=\"m-0 btn btn-block btn-sm btn-".((!$selected) ? "success" : "info")."\" id=\"callback-button-oe-{$operatore["codice"]}\" onClick=\"{$_POST["callBackAction"]}('{$operatore["codice"]}')\"> |
|
<span class=\"callback-label-oe-{$operatore["codice"]} ".(($selected) ? "collapse" : "")."\"><span class=\"fa fa-check\"></span> " . __("Seleziona") . "</span> |
|
<span class=\"callback-label-oe-{$operatore["codice"]} ".((!$selected) ? "collapse" : "")."\"><span class=\"fa fa-times\"></span> " . __("Deseleziona") . "</span> |
|
</button>"; |
|
$row[12] = $callBackbuttons; |
|
} else { |
|
$row[12] = "n/a"; |
|
} |
|
} |
|
|
|
$return["data"][] = $row; |
|
} |
|
$timing[] = [date("Y-m-d H:i:s.u"),"End data preparation"]; |
|
} else { |
|
$return["data"] = array(); |
|
} |
|
} else { |
|
$return["data"] = array(); |
|
} |
|
} else { |
|
$return["data"] = array(); |
|
} |
|
$return["timing"] = $timing; |
|
unset($oeManager); |
|
unset($relazioni); |
|
unset($operatori); |
|
echo json_encode($return); |
|
} |
|
} |
|
?>
|
|
|