permission($radice, $_GET["fascicolo"])) { $npa = NuovaPiattaformaAppalti::init($_GET["fascicolo"]); $return = [ "draw" => (int) $_GET["draw"], "recordsTotal" => (int) 0, "recordsFiltered" => (int) 0 ]; $count = "SELECT COUNT(b_npa_lotti.codice)"; $select = "SELECT b_npa_lotti.*"; $from = "FROM b_npa_lotti"; $where = "WHERE codice_npa = :codice_npa"; $bind = [":codice_npa" => $npa->fascicolo["codice"]]; $result = $pdo->go("{$count} {$from} {$where}", $bind); if($result->rowCount() > 0) { $join = null; $return["recordsTotal"] = $result->fetch(PDO::FETCH_COLUMN, 0); if(! empty($_GET["cerca"])) { $bind[":ricerca"] = "%{$_GET["cerca"]}%"; $clauses[] = "b_npa_lotti.cig LIKE :ricerca"; } if(! empty($npa->fascicolo["modulo_riferimento"]) && ! empty($npa->fascicolo["id_riferimento"])) { switch($npa->fascicolo["modulo_riferimento"]) { case 'gare': $select = "{$select}, b_gare_lotti.numero, b_gare_lotti.oggetto"; $join = "JOIN b_gare_lotti ON b_gare_lotti.codice = b_npa_lotti.lotto_riferimento"; if(! empty($_GET["cerca"])) { $clauses[] = "b_gare_lotti.oggetto LIKE :ricerca"; $clauses[] = "b_gare_lotti.descrizione LIKE :ricerca"; $clauses[] = "b_gare_lotti.numero LIKE :ricerca"; } break; default: break; } } if(!empty($clauses)) { $clauses = "(" . implode(") OR (", $clauses) . ")"; $where = "{$where} AND ($clauses)"; } $dir = "ASC"; if(! empty($_GET["order"]) && $_GET["order"][0]["dir"] == "desc") { $dir = "DESC"; } $order = "ORDER BY b_npa_lotti.codice {$dir}"; switch($_GET["order"][0]["column"]) { case "2": $order = "ORDER BY b_simog_lotti.cig {$dir}"; break; } $result = $pdo->go("{$select} {$from} {$join} {$where} {$order}", $bind); if($result->rowCount() > 0) { // Verifica se l'utente ha un ruolo (deleghe NPA) per accedere al fascicolo dell'operatore economico $fvoe = false; if(! empty($_SESSION["utente"]) && $_SESSION["utente"]->authenticationLevel >= 2) { $utente = $_SESSION["utente"]->getInfo()["cf"]; $cfs = $npa->getUserFromRole(DelegheRoles::ANY, RoleSyncBehaviour::NEVER_SYNC); if(in_array($utente, $cfs)) { $fvoe = true; } } $return["recordsFiltered"] = $result->rowCount(); while($lot = $result->fetch(PDO::FETCH_ASSOC)) { $cig = $lot["cig"]; $status = "primary"; $linkBDNCP = ""; if(empty($cig)) { $cig = __("CIG MANCANTE"); $status = "warning"; } else { $linkBDNCP = NuovaPiattaformaAppalti::getBDNCPLink($cig); } // $id = "LOT-" . str_pad($lot["numero"], 4, "0", STR_PAD_LEFT); $row = []; $row[0] = "
"; $row[1] = "