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.
 
 
 

279 righe
8.8 KiB

<?php
require_once "IDataClass.php";
/**
* Description of Faq
*
* @author Anselmo
*/
class Faq extends DataClass {
const TABLE_NAME = "FAQ";
const SEQ_NAME = "FAQ_ID_SEQ";
public $ID = 0; // Primary key
public $ID_UID_FIEBASE_ADMIN = 0;
public $OGGETTO = "";
public $DOMANDA = "";
public $PUBBLICATA = 0;
public $CANCELLATO = 0;
public $DATA_INSERIMENTO = 'SYSTIMESTAMP';
public $ID_CATEGORIA = 0;
public function __construct($src = null) {
global $con;
if ($src == null)
return;
if (is_array($src)) {
if (isset($src['ID']) && $src['ID'] > 0) {
$this->_loadAndFillObject($src['ID'], self::TABLE_NAME, $src);
} else {
$this->_loadByRow($src, $stripSlashes);
}
} elseif (intval($src)) {
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE ID = :id";
$query = $con->prepare($sql);
$query->bindParam(":id", $src);
try {
$query->execute();
$it = $query->fetchAll(PDO::FETCH_ASSOC);
$it[0]['DOMANDA'] = html_entity_decode(htmlspecialchars_decode(stream_get_contents($it[0]['DOMANDA'])));
Utils::FillObjectFromRow($this, $it[0]);
} catch (Exception $exc) {
$exc->getMessage();
}
}
}
/**
* Restituisce il totale i
*
* @param bool $filter Se specificato, filtra i comune in funzione dei parametri specificati in esso specificato
* @return int
*/
public static function Count($filter = null) {
return parent::_count(self::TABLE_NAME, $filter);
}
public static function LoadDataTable($searchQuery = "", $searchArray = array(), $columnName = array(), $columnSortOrder = array(), $start = 0, $offset = 0) {
return parent::_loadDataTable(self::TABLE_NAME, $searchQuery, $searchArray, $columnName, $columnSortOrder, $start, $offset);
}
public function Save() {
global $con, $LoggedAccount;
$this->ID_UID_FIEBASE_ADMIN = $LoggedAccount->ID;
$vars = get_object_vars($this);
$sql = Utils::prepareQuery(self::TABLE_NAME, $vars);
$queryabi = $con->prepare($sql);
$ins = false;
foreach ($vars as $k => $v) {
if ($k == "ID" && $v == 0) {
$ins = true;
continue;
}
if ($k == "DATA_INSERIENTO" && $ins) {
$queryabi->bindValue(":" . $k, date('d-m-Y'));
} else {
$queryabi->bindValue(":" . $k, $v);
}
}
try {
$it = parent::_Save($queryabi);
} catch (Exception $exc) {
$it['descrizioneErrore'] = $exc->getMessage();
}
return $it;
}
public function Delete() {
return parent::_Delete(self::TABLE_NAME, "ID = " . $this->ID);
}
public function Load($id_categoria = 0, $cancellato = 0) {
global $con;
$where = "PUBBLICATA = 1 ";
$order = " ORDER BY ID";
if (intval($cancellato) >= 0)
$where .= ($where == "" ? "" : " AND ") . "CANCELLATO = :cancellato";
if (intval($id_categoria) >= 0)
$where .= ($where == "" ? "" : " AND ") . "ID_CATEGORIA = :id_categoria";
$sql = "SELECT * FROM " . self::TABLE_NAME;
if ($where != "")
$sql .= " WHERE $where $order";
$query = $con->prepare($sql);
if (intval($cancellato) >= 0)
$query->bindParam(":CANCELLATO", intval($cancellato));
if (intval($id_categoria) >= 0)
$query->bindParam(":ID_CATEGORIA", intval($id_categoria));
try {
$query->execute();
//$it = $query->fetch(PDO::FETCH_ASSOC);
$res = array();
$i=0;
while ($it = $query->fetch(PDO::FETCH_ASSOC)) {
$it['DOMANDA'] = html_entity_decode(htmlspecialchars_decode(stream_get_contents($it['DOMANDA'])));
array_push($res, $it);
}
//Utils::print_array($res);
/*for($i=0; count($it)<$i; $i++){
$it[$i]['DOMANDA'] = html_entity_decode(htmlspecialchars_decode(stream_get_contents($it[$i]['DOMANDA'])));
}*/
} catch (Exception $exc) {
$res['esito'] = -999;
$res['descrizioneErrore'] = $exc->getMessage();
}
return $res;
}
/**
* Elimina l'oggetto corrente dal database e restituisce TRUE se ha successo
*
* @return bool Risultato booleano dell'operazione
*/
public function LogicalDelete() {
return parent::_LogicalDelete(self::TABLE_NAME, "ID = " . $this->ID);
}
/**
* Funzione per la visualizzazione dei logs
* @param type $record
* @param type $campo
*/
public function Parse(&$record, $campo = "") {
$props = get_class_vars(get_class($this));
switch ($campo) {
default:
array_push($record, array("Campo" => $campo, "Valore" => $this->$campo));
break;
}
}
}
class FaqUtenti extends DataClass {
const TABLE_NAME = "FAQ_UTENTI";
const SEQ_NAME = "FAQ_UTENTI_ID_SEQ";
const SP_ = "SPFAQUTENTISAVE";
public $ID = 0; // Primary key
public $ID_ACCOUNT = 0;
public $DOMANDA = "";
public $DATA_INSERIMENTO = null;
public $NOME = '';
public $COGNOME = '';
public $EMAIL = '';
public $STATO = 0;
public $ID_CATEGORIA = 0;
public function __construct($src = null) {
global $con;
if ($src == null)
return;
if (is_array($src)) {
if (isset($src['ID']) && $src['ID'] > 0) {
$this->_loadAndFillObject($src['ID'], self::TABLE_NAME, $src);
} else {
$this->_loadByRow($src, $stripSlashes);
}
} elseif (intval($src)) {
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE ID = :id";
$query = $con->prepare($sql);
$query->bindParam(":id", $src);
try {
$query->execute();
$it = $query->fetchAll(PDO::FETCH_ASSOC);
$it[0]['DOMANDA'] = html_entity_decode(htmlspecialchars_decode(stream_get_contents($it[0]['DOMANDA'])));
Utils::FillObjectFromRow($this, $it[0]);
} catch (Exception $exc) {
$exc->getMessage();
}
}
}
/**
* Restituisce il totale i
*
* @param bool $filter Se specificato, filtra i comune in funzione dei parametri specificati in esso specificato
* @return int
*/
public static function Count($filter = null) {
return parent::_count(self::TABLE_NAME, $filter);
}
public static function LoadDataTable($searchQuery = "", $searchArray = array(), $columnName = array(), $columnSortOrder = array(), $start = 0, $offset = 0) {
return parent::_loadDataTable(self::TABLE_NAME, $searchQuery, $searchArray, $columnName, $columnSortOrder, $start, $offset);
}
public function Save() {
global $con, $LoggedAccount;
// 1,2,3,4,5,6,7,8
$sql = "CALL " . self::SP_ . " (?,?,?,?,?,?,?,?)";
$this->ID_ACCOUNT = $LoggedAccount->ID;
$query = $con->prepare($sql);
$query->bindParam(1, $this->ID);
$query->bindParam(2, $this->ID_ACCOUNT);
$query->bindParam(3, $this->DOMANDA, PDO::PARAM_STR, strlen($this->DOMANDA));
$query->bindParam(4, $this->NOME);
$query->bindParam(5, $this->COGNOME);
$query->bindParam(6, $this->EMAIL);
$query->bindParam(7, $this->STATO);
$query->bindParam(8, $this->ID_CATEGORIA);
try {
$it = parent::_Save($query);
} catch (Exception $exc) {
$it['descrizioneErrore'] = $exc->getMessage();
}
return $it;
}
public function Delete() {
return parent::_Delete(self::TABLE_NAME, "ID = " . $this->id);
}
/**
* Elimina l'oggetto corrente dal database e restituisce TRUE se ha successo
*
* @return bool Risultato booleano dell'operazione
*/
public function LogicalDelete() {
return parent::_LogicalDelete(self::TABLE_NAME, "ID = " . $this->id);
}
/**
* Funzione per la visualizzazione dei logs
* @param type $record
* @param type $campo
*/
public function Parse(&$record, $campo = "") {
$props = get_class_vars(get_class($this));
switch ($campo) {
default:
array_push($record, array("Campo" => $campo, "Valore" => $this->$campo));
break;
}
}
}