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.
74 righe
3.4 KiB
74 righe
3.4 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice)) { |
|
if (isset($_GET["draw"])) { |
|
|
|
$return = array(); |
|
$return["draw"] = (int)$_GET["draw"]; |
|
$return["recordsTotal"] = (int)0; |
|
$return["recordsFiltered"] = (int)0; |
|
$bind = array(); |
|
$sql = "SELECT * FROM b_form WHERE soft_delete = 'N' "; |
|
if (!empty($_SESSION["ente"]->codice)) { |
|
$sql .= " AND codice_ente = :codice_ente "; |
|
$bind[":codice_ente"] = $_SESSION["ente"]->codice; |
|
} else { |
|
$sql .= " AND codice_ente = 0 "; |
|
} |
|
|
|
$ris_utenti = $pdo->go($sql,$bind); |
|
if ($ris_utenti->rowCount() > 0) { |
|
$return["recordsTotal"] = (int)$ris_utenti->rowCount(); |
|
$filterApplied = false; |
|
if (!empty($_GET["search"]["value"])) { |
|
$filterApplied = true; |
|
$sql .= " AND ( "; |
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"id"); |
|
$sql .= "(" . $suddivisione["sql"] . ") "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
$sql .= ") "; |
|
} |
|
$order = "id ASC "; |
|
|
|
$sql .= "ORDER BY " . $order; |
|
if ($_GET["length"] !== "-1") { $sql.= "LIMIT ". (int)$_GET["start"] .", " . (int)$_GET["length"]; } |
|
$ris_utenti = $pdo->go($sql,$bind); |
|
if ($ris_utenti->rowCount() > 0) { |
|
if ($filterApplied) { |
|
$return["recordsFiltered"] = (int)$ris_utenti->rowCount(); |
|
} else { |
|
$return["recordsFiltered"] = $return["recordsTotal"]; |
|
} |
|
$return["data"] = array(); |
|
while($record = $ris_utenti->fetch(PDO::FETCH_ASSOC)) { |
|
$stato = "bg-disabled"; |
|
$stato_label = __('disattivo'); |
|
if ($record["attivo"]=="S") { |
|
$stato = "bg-active"; |
|
$stato_label = __('attivo'); |
|
} |
|
$row = array(); |
|
$row[] = '<div id="flag_'.$record["codice"].'" class="status_flag '.$stato.'"><span class="sr-only">'.$stato_label.'</span></div>'; |
|
$row[] = $record["id"]; |
|
$record["titolo"] = json_decode($record["titolo"],true)[$_SESSION["language"]]; |
|
$record["descrizione"] = json_decode($record["descrizione"],true)[$_SESSION["language"]]; |
|
$row[] = $record["titolo"]; |
|
$row[] = $record["descrizione"]; |
|
$row[] = "<button title='".__("anteprima")."' class='btn btn-sm btn-default' onclick='showModalWithURL(\"preview.php?codice=".$record["codice"]."\");'><span class='fa fa-search'></span></button>"; |
|
$row[] = "<a href='/backend/form/edit.php?codice=".$record["codice"]."' title='".__("modifica")."' class='btn-info btn btn-sm' style='padding-top:6px;'><span class='fa fa-pencil-alt'></span></a>"; |
|
$row[] = "<button title='".__("Attiva/Disattiva")."' class='btn btn-sm btn-warning' onclick='disabilita(".$record["codice"].",\"form\");'><span class='fa fa-sync'></span></button>"; |
|
$row[] = "<button title='".__("elimina")."' class='btn btn-sm btn-danger' onclick='elimina(".$record["codice"].",\"form\");'><span class='fa fa-times'></span></button>"; |
|
$return["data"][] = $row; |
|
} |
|
} else { |
|
$return["data"] = array(); |
|
} |
|
} else { |
|
$return["error"] = "No record"; |
|
} |
|
|
|
echo json_encode($return); |
|
} |
|
} |
|
?>
|
|
|