$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[] = "
"; $row[] = $record["codice"]; $row[] = $record["idVenditore"]; $row[] = "" . $record["denominazione"] . ""; $row[] = $record["brand"]; $row[] = number_format($record["prezzo"],2,",","."); $span = "".__("network").""; $row[] = $span; $row[] = ""; $row[] = "