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.
120 righe
4.8 KiB
120 righe
4.8 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
|
|
if (! empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice)) { |
|
|
|
$return = []; |
|
$return["draw"] = (int) $_POST["draw"]; |
|
$return["recordsTotal"] = (int) 0; |
|
$return["recordsFiltered"] = (int) 0; |
|
|
|
if (isset($_POST["draw"])) { |
|
|
|
$limit = ""; |
|
if(isset($_POST["start"]) && isset($_POST["length"]) && (int) $_POST["length"] > 0) { |
|
$start = (int) $_POST["start"]; |
|
$end = (int) $_POST["length"]; |
|
$limit = "LIMIT {$start}, {$end}"; |
|
} |
|
|
|
$select = "SELECT * "; |
|
$count = "SELECT COUNT(codice)"; |
|
$from = "FROM b_categorie_documentali"; |
|
$where = ["soft_delete = 'N'"]; |
|
$bind = []; |
|
|
|
if(! empty($_SESSION["ente"])) { |
|
$where[] = "(codice_ente IS NULL OR codice_ente = :codice_ente)"; |
|
$bind[":codice_ente"] = $_SESSION["ente"]->codice; |
|
} else { |
|
$where[] = "(codice_ente IS NULL)"; |
|
} |
|
|
|
$total = $pdo->go("{$count} {$from} WHERE {$where[0]}", $bind)->fetch(PDO::FETCH_COLUMN, 0); |
|
if($total > 0) { |
|
|
|
$return["recordsTotal"] = (int) $total; |
|
$return["recordsFiltered"] = (int) $total; |
|
|
|
$moduli = array_filter($config["moduli"], function(&$settings) { return $settings["completed"] == "S" && ! $settings["nascosto"]; }); |
|
$moduli = array_column($config["moduli"], "titolo", 'id'); |
|
|
|
$order = ["column" => "codice", "dir" => $_POST["order"][0]["dir"] ?? "DESC"]; |
|
switch($_POST["order"][0]["column"]) { |
|
case "0": $order["column"] = "codice"; break; |
|
case "2": $order["column"] = "modulo"; break; |
|
case "3": $order["column"] = "titolo"; break; |
|
} |
|
|
|
if(! empty($_POST["titolo"])) { |
|
$where = ["titolo LIKE :titolo"]; |
|
$bind[":titolo"] = "%{$_POST["titolo"]}%"; |
|
} |
|
|
|
if(! empty($_POST["modulo"])) { |
|
$where = ["modulo = :modulo"]; |
|
$bind[":modulo"] = $_POST["modulo"]; |
|
} |
|
|
|
$where = "WHERE " . implode(" AND ", $where); |
|
$result = $pdo->go("{$select} {$from} {$where} ORDER BY {$order["column"]} {$order["dir"]} {$limit}", $bind); |
|
|
|
$check = $pdo->prepare("SELECT codice FROM b_categorie_documentali_escluse WHERE codice_categoria = :codice_categoria AND codice_ente = :codice_ente"); |
|
$check->bindValue(":codice_ente", $_SESSION["ente"]->codice); |
|
while ($record = $result->fetch(PDO::FETCH_ASSOC)) { |
|
|
|
$row = []; |
|
$row[] = $record["codice"]; |
|
$row[] = $moduli[$record["modulo"]] ?? "Tutti i moduli"; |
|
$row[] = $record["titolo"]; |
|
|
|
ob_start(); |
|
?> |
|
<div class="dropdown"> |
|
<button class="btn btn-secondary btn-block dropdown-toggle" type="button" data-toggle="dropdown" aria-expanded="false"> |
|
<span class="fa fa-cog"></span> |
|
</button> |
|
<div class="dropdown-menu"> |
|
<? if((empty($record["codice_ente"]) && empty($_SESSION["ente"])) || (! empty($_SESSION["ente"]) && $record["codice_ente"] == $_SESSION["ente"]->codice)) : ?> |
|
<a class="text-secondary dropdown-item" title="<?= __("Modifica") ?>" role="button" onclick="showModalWithURL('edit.php?codice=<?= $record['codice'] ?>')"><i style="width: 18px" class="fas fa-pencil-alt mr-2"></i><?= __('Modifica') ?></a> |
|
<div class="dropdown-divider"></div> |
|
<a class="text-danger dropdown-item" onclick="elimina('<?= $record['codice'] ?>', 'classificazione-documentale')" title="<?= __("Elimina") ?>" role="button" href="javascript:void(0)"><i class="fas fa-trash mr-2"></i> <?= __('Elimina') ?></a> |
|
<? elseif (! empty($_SESSION["ente"]) && empty($record["codice_ente"])) : ?> |
|
<? |
|
$title = "Disabilita"; |
|
$class = "text-danger"; |
|
$check->bindValue(":codice_categoria", $record["codice"]); |
|
$check->execute(); |
|
if($check->rowCount() == 1) { |
|
$row["DT_RowClass"] = "table-danger"; |
|
$title = "Abilita"; |
|
$class = "text-dark"; |
|
} |
|
?> |
|
<div class="dropdown-divider"></div> |
|
<a class="<?= $class ?> dropdown-item" onclick="confirmBeforeSubmit('<?= $record['codice'] ?>', 'toggle.php')" title="<?= __($title) ?>" role="button" href="javascript:void(0)"><i class="fas fa-toggle-off"></i> <?= __($title) ?></a> |
|
<? endif; ?> |
|
</div> |
|
</div> |
|
<? |
|
|
|
$row[] = ob_get_clean(); |
|
|
|
|
|
$return["data"][] = $row; |
|
|
|
} |
|
|
|
} |
|
|
|
echo json_encode($return, JSON_PRETTY_PRINT); |
|
exit(); |
|
|
|
} |
|
|
|
} |
|
|
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
?>
|
|
|