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.
113 righe
3.1 KiB
113 righe
3.1 KiB
<?php |
|
|
|
require_once ROOT . "/lib/classes/IDataClass.php"; |
|
|
|
class AnagraficaCompagnie extends DataClass { |
|
const TABLE_NAME = "ANAG_COMPAGNIE"; |
|
|
|
public $ID = 0; |
|
public $NOME = ''; |
|
public $ADESIONE = 0; |
|
|
|
public function __construct($src = null) { |
|
global $con; |
|
if ($src == null) { |
|
return; |
|
} |
|
$stripSlashes = false; |
|
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); |
|
Utils::FillObjectFromRow($this, $it[0]); |
|
} catch (Exception $exc) { |
|
$exc->getMessage(); |
|
} |
|
} |
|
} |
|
|
|
|
|
public static function autocomplete($string = '', $andata = null, $ritorno = null) { |
|
global $con; |
|
$return = array(); |
|
|
|
$filter = ''; |
|
$searchFix = ''; |
|
if (!empty($andata) && !empty($ritorno)) { |
|
$filter = " (AEROPORTO = :andata OR AEROPORTO = :ritorno) AND "; |
|
}else{ |
|
return $return; |
|
} |
|
$string = "%" . strtolower($string) . "%"; |
|
$sql = "SELECT A.* FROM " . self::TABLE_NAME . " A INNER JOIN ".AeroportiCompagnie::TABLE_NAME." B ON B.COMPAGNIA = A.ID WHERE " . $filter . " LOWER(A.NOME) LIKE :term ".$searchFix." ORDER BY A.NOME"; |
|
|
|
$query = $con->prepare($sql); |
|
if (!empty($andata) && !empty($ritorno)) { |
|
$query->bindParam(":andata", $andata); |
|
$query->bindParam(":ritorno", $ritorno); |
|
} |
|
$query->bindParam(":term", $string); |
|
try { |
|
$query->execute(); |
|
while ($it = $query->fetch(PDO::FETCH_ASSOC)) { |
|
$descrizione = $it['NOME']; |
|
$row['id'] = $descrizione; |
|
$row['text'] = $descrizione; |
|
$row['label'] = $descrizione; |
|
$row['codice'] = $it['ID']; |
|
array_push($return, $row); |
|
} |
|
} catch (Exception $exc) { |
|
echo $exc->getMessage(); |
|
} |
|
|
|
return $return; |
|
} |
|
|
|
|
|
public function Parse(&$record, $campo = "") { |
|
array_push($record, array("Campo" => $campo, "Valore" => $this->$campo)); |
|
} |
|
|
|
} |
|
|
|
|
|
class AeroportiCompagnie extends DataClass { |
|
|
|
const TABLE_NAME = "AEROPORTI_COMPAGNIE"; |
|
|
|
|
|
public $AEROPORTO = ""; |
|
public $COMPAGNIA = 0; |
|
|
|
public function __construct($src = null) { |
|
global $con; |
|
$stripSlashes = false; |
|
if ($src == null) { |
|
return; |
|
} |
|
if (is_array($src)) { |
|
$this->_loadByRow($src, $stripSlashes); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function Parse(&$record, $campo = "") { |
|
array_push($record, array("Campo" => $campo, "Valore" => $this->$campo)); |
|
} |
|
|
|
|
|
} |
|
|
|
|