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.
84 righe
3.8 KiB
84 righe
3.8 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_modelli WHERE soft_delete = 'N' AND codice_ente = 0 "; |
|
$ris_modelli = $pdo->go($sql,$bind); |
|
if ($ris_modelli->rowCount() > 0) { |
|
$return["recordsTotal"] = (int)$ris_modelli->rowCount(); |
|
$filterApplied = false; |
|
if (!empty($_GET["search"]["value"])) { |
|
$filterApplied = true; |
|
$sql .= " AND ( "; |
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"tipologia"); |
|
$sql .= "(" . $suddivisione["sql"] . ") "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
$sql .= ") "; |
|
} |
|
$order = "tipologia ASC "; |
|
|
|
$sql .= "ORDER BY " . $order; |
|
if ($_GET["length"] !== "-1") { $sql.= "LIMIT ". (int)$_GET["start"] .", " . (int)$_GET["length"]; } |
|
$ris_modelli = $pdo->go($sql,$bind); |
|
if ($ris_modelli->rowCount() > 0) { |
|
if ($filterApplied) { |
|
$return["recordsFiltered"] = (int)$ris_modelli->rowCount(); |
|
} else { |
|
$return["recordsFiltered"] = $return["recordsTotal"]; |
|
} |
|
$return["data"] = array(); |
|
while($record = $ris_modelli->fetch(PDO::FETCH_ASSOC)) { |
|
$stato = "bg-danger"; |
|
$stato_label = __('disattivo'); |
|
if ($record["attivo"]=="S") { |
|
$stato = "bg-success"; |
|
$stato_label = __('attivo'); |
|
} |
|
$row = array(); |
|
$row[] = '<div class="status_flag '.$stato.'"><span class="sr-only">'.$stato_label.'</span></div>'; |
|
if (isset($_SESSION["ente"])) { |
|
$checkSpecific = $pdo->go("SELECT codice, attivo FROM b_modelli WHERE tipologia = :tipologia AND codice_ente = :codice_ente ",[":codice_ente"=>$_SESSION["ente"]->codice,":tipologia"=>$record["tipologia"]])->fetch(PDO::FETCH_ASSOC); |
|
$checkSpecific_codice = 0; |
|
$stato_specific = "bg-danger"; |
|
$stato_label_specific = __("Assente"); |
|
if (!empty($checkSpecific)) { |
|
$checkSpecific_codice = $checkSpecific["codice"]; |
|
$stato_specific = "bg-warning"; |
|
$stato_label_specific = __("disattivo"); |
|
if ($checkSpecific["attivo"] == "S") { |
|
$stato_specific = "bg-success"; |
|
$stato_label_specific = __("attivo"); |
|
} |
|
} |
|
$row[] = '<div id="flag_'.$checkSpecific_codice .'" class="status_flag '.$stato_specific.'"><span class="sr-only">'.$stato_label_specific.'</span></div>'; |
|
} |
|
$row[] = $record["tipologia"]; |
|
$row[] = $record["titolo"]; |
|
$row[] = "<a href='/backend/editor/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>"; |
|
if (isset($_SESSION["ente"])) { |
|
if (!empty($checkSpecific)) { |
|
$row[] = "<button title='".__("disabilita")."' class='btn btn-sm btn-warning' onclick='disabilita(".$checkSpecific["codice"].",\"editor\");'><span class='fa fa-sync'></span></button>"; |
|
} else { |
|
$row[] = ""; |
|
} |
|
} |
|
$return["data"][] = $row; |
|
} |
|
} else { |
|
$return["data"] = array(); |
|
} |
|
} else { |
|
$return["error"] = "No record"; |
|
} |
|
|
|
echo json_encode($return); |
|
} |
|
} |
|
?>
|
|
|