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.
122 righe
4.4 KiB
122 righe
4.4 KiB
<? |
|
|
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
|
|
|
|
if(!empty($_SESSION["utente"]) && !empty($_SESSION["utente"]->oe["codice"]) && isset($_GET["draw"])){ |
|
|
|
$return = array(); |
|
$return["draw"] = (int)$_GET["draw"]; |
|
$return["recordsTotal"] = (int)0; |
|
$return["recordsFiltered"] = (int)0; |
|
|
|
$bind = []; |
|
$bind[':codice_oe'] = $_SESSION["utente"]->oe["codice"]; |
|
|
|
$sql = "SELECT b_prodotti.* |
|
FROM b_prodotti |
|
WHERE soft_delete = 'N' |
|
AND codice_oe = :codice_oe |
|
AND codice NOT IN (SELECT codice_aggiornamento FROM b_prodotti WHERE codice_aggiornamento IS NOT NULL) "; |
|
|
|
$risultati = $pdo->go($sql . " GROUP BY b_prodotti.codice ",$bind); |
|
|
|
if ($risultati->rowCount() > 0 && !empty(PublicProdotto::getBandiMercato())) { |
|
|
|
$return["recordsTotal"] = (int)$risultati->rowCount(); |
|
|
|
if (!empty($_GET["search"]["value"])) { |
|
$sql .= "AND ( "; |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"codice"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"idVenditore"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"denominazione"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"brand"); |
|
$sql .= "(" . $suddivisione["sql"] . ") "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$sql .= ") "; |
|
} |
|
|
|
$order = "idVenditore "; |
|
|
|
if ($_GET["order"][0]["dir"] == "desc") { |
|
$order.= "DESC "; |
|
} else { |
|
$order.= "ASC "; |
|
} |
|
|
|
$sql .= " GROUP BY b_prodotti.codice "; |
|
$sql .= " ORDER BY " . $order . ", b_prodotti.denominazione ASC "; |
|
|
|
if ($_GET["length"] !== "-1") $sql.= "LIMIT ". (int)$_GET["start"] .", " . (int)$_GET["length"]; |
|
|
|
$risultati = $pdo->go($sql,$bind); |
|
|
|
if ($risultati->rowCount() > 0) { |
|
|
|
if (!empty($_GET["search"]["value"])) { |
|
$return["recordsFiltered"] = (int)$risultati->rowCount(); |
|
} else { |
|
$return["recordsFiltered"] = $return["recordsTotal"]; |
|
} |
|
|
|
$return["data"] = []; |
|
|
|
while($record = $risultati->fetch(PDO::FETCH_ASSOC)) { |
|
|
|
$stato = "text-danger"; |
|
$stato_label = __('disattivo'); |
|
if ($record["attivo"]=="S") { |
|
if ($record["confermato"]=="S") { |
|
$stato = "text-success"; |
|
$stato_label = __('attivo'); |
|
} else { |
|
$stato = "text-warning"; |
|
$stato_label = __('non confermato'); |
|
} |
|
} |
|
|
|
$row = []; |
|
$row[] = "<div id='flag_{$record['codice']}' class='fas fa-circle {$stato}' title='{$stato_label}'></div>"; |
|
$row[] = $record["codice"]; |
|
$row[] = $record["idVenditore"]; |
|
$row[] = "<strong>" . $record["denominazione"] . "</strong>"; |
|
$row[] = $record["brand"]; |
|
$row[] = number_format($record["prezzo"],2,",","."); |
|
|
|
|
|
$span = "<span class=\"far fa-handshake\"></span><span class='sr-only'>".__("network")."</span>"; |
|
|
|
$row[] = $span; |
|
$row[] = "<a href='/catalogo/edit.php?codice=".$record["codice"]."' title='".__("modifica")."' class='btn btn-info btn-sm'><span class='fa fa-pencil-alt'></span></a>"; |
|
$row[] = "<button onclick='showModalWithURL(\"versions/view.php?codice=".$record["codice"]."\")' title='".__("visualizza")."' class='btn btn-primary btn-sm'><span class='fa fa-search'></span></a>"; |
|
$row[] = "<button title='".__("cambia")."' class='btn btn-sm btn-warning' onclick='disabilitaP(".$record["codice"].",\"catalogo\");'><span class='fa fa-sync'></span></button>"; |
|
$row[] = "<button title='".__("elimina")."' class='btn btn-sm btn-danger' onclick='eliminaP(".$record["codice"].",\"catalogo\");'><span class='fa fa-times'></span></button>"; |
|
|
|
$return["data"][] = $row; |
|
|
|
} |
|
|
|
} else { |
|
$return["data"] = array(); |
|
} |
|
|
|
} else { |
|
$return["data"] = []; |
|
} |
|
|
|
echo json_encode($return); |
|
|
|
} |
|
?>
|