$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php";
include_once($configPath);
$id_modulo = "open";
$cmd_info = concorso::getInfoModulo($id_modulo);
$error = true;
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice,$_GET["codice"],$id_modulo) && $_SESSION["utente"]->permission($cmd_info["modulo_riferimento"]) && !empty($_GET["codice_lotto"])) {
$codice_round = $_GET["codice_round"] ?? NULL;
$concorso = concorso::init($_GET["codice"],$codice_round);
if (!empty($concorso) && $concorso->setLotto($_GET["codice_lotto"])) {
$record = $concorso->info;
$round = $concorso->round;
$lotto = $concorso->lotto;
$lock = $concorso->checkLock($cmd_info["id"]);
$error = false;
$partecipanti = $concorso->getPartecipanti();
$return = array();
$return["draw"] = (int)$_GET["draw"];
$return["recordsTotal"] = (int)0;
$return["recordsFiltered"] = (int)0;
$return["data"] = [];
if (count($partecipanti) > 0) {
$return["recordsTotal"] = count($partecipanti);
$return["recordsFiltered"] = count($partecipanti);
$tipiBuste = concorso::tipologieBusta();
$i = 0;
$richieste = [];
foreach($partecipanti AS $partecipante) {
$i++;
$row = [];
$row[] = $i;
ob_start();
?>= $partecipante["id"] ?>
$row[] = ob_get_clean();
reset($tipiBuste);
foreach($tipiBuste AS $id_busta => $busta) {
$label_locked = "Bloccata";
$color_locked = "warning";
$icon_locked = "lock";
if ($partecipante["escluso"] == "S") {
$label_locked = "Non ammesso";
$color_locked = "disabled";
$icon_locked = "ban";
}
if (!isset($richieste[$id_busta])) {
$richieste[$id_busta] = $concorso->getRichieste($id_busta);
}
if (!empty($richieste[$id_busta])) {
ob_start();
reset($richieste[$id_busta]);
$block = false;
$aperte = 0;
$presenti = 0;
foreach($richieste[$id_busta] AS $richiesta) {
$busta = $concorso->getBusta($partecipante["codice"],$richiesta["codice"]);
if (!empty($busta)) {
if (!$block) {
$block = !$concorso->checkOpeningPermission($partecipante["codice"],$richiesta["codice"]);
}
$presenti++;
if ($busta["open"] == "S") {
$aperte++;
}
}
}
if ($presenti > 0) {
if ($aperte == $presenti) {
$bg_open = "info";
$label_open = "Visualizza";
$icon_open = "folder-open";
} else {
$icon_open = "unlock";
if ($aperte > 0) {
$bg_open = "primary";
$label_open = "Continua";
} else {
$bg_open = "success";
$label_open = "Apri";
}
}
} else {
$block = true;
$label_locked = "Vuota";
$color_locked = "disabled";
$icon_locked = "circle";
}
?>
$row[] = ob_get_clean();
}
}
$return["data"][] = $row;
}
}
echo json_encode($return);
}
}
if ($error) {
header('HTTP/1.0 403 Forbidden');
die();
}