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.
103 righe
2.9 KiB
103 righe
2.9 KiB
<?php |
|
|
|
/** |
|
* Description of AnagraficaDichiarazioni |
|
* |
|
* @author Anselmo |
|
*/ |
|
class AnagraficaDichiarazioni extends DataClass { |
|
|
|
const TABLE_NAME = "ANAG_DICHIARAZIONI"; |
|
|
|
public $ID = 0; |
|
public $CODICE = ""; |
|
public $DESCRIZIONE = ""; |
|
public $CANCELLATO = 0; |
|
public $POSIZIONE = 0; |
|
public $OBBLIGO = 0; |
|
|
|
|
|
|
|
public static function Count($filter = null) { |
|
return parent::_count(self::TABLE_NAME, $filter); |
|
} |
|
|
|
/** |
|
* Load delle sanzioni |
|
* |
|
* * return |
|
* For $id => array of AnagraficaSanzioni, for other array of array of AnagraficaSanzioni |
|
* |
|
* * params: |
|
* $id (int): load single rows from id |
|
* $descrizione (string): filter from like descrizione |
|
* $codice (int): filter from codice |
|
*/ |
|
public static function load($id = 0, $descrizione = '', $codice = 0, $obbligo = 0) { |
|
global $con; |
|
$rows = array(); |
|
$order = " ORDER BY POSIZIONE"; |
|
$filter = " CANCELLATO = 0 "; |
|
if (!empty($id)) { |
|
$filter = " ID = :id"; |
|
} else { |
|
if (!empty($descrizione)) { |
|
$filter = " DESCRIZIONE LIKE %:descrizione% "; |
|
} |
|
if (!empty($codice)) { |
|
$filter .= ($filter != "" ? " AND " : "") . " CODICE = :codice "; |
|
} |
|
if(intval($obbligo)>0){ |
|
$filter .= ($filter != "" ? " AND " : "") . " OBBLIGO = :obbligo "; |
|
} |
|
} |
|
$filter = ($filter != "" ? " WHERE " : "") . $filter; |
|
|
|
$sql = "SELECT * FROM " . self::TABLE_NAME . $filter. $order; |
|
|
|
$query = $con->prepare($sql); |
|
if (!empty($id)) { |
|
$query->bindParam(":id", $id); |
|
} else { |
|
if (!empty($descrizione)) { |
|
$query->bindParam(":descrizione", $descrizione); |
|
} |
|
if (!empty($codice)) { |
|
$query->bindParam(":codice", $codice); |
|
} |
|
if(intval($obbligo)>0){ |
|
$query->bindParam(":obbligo", $obbligo); |
|
} |
|
} |
|
try { |
|
$query->execute(); |
|
$rows = $query->fetchAll(PDO::FETCH_ASSOC); |
|
if (!empty($id) && count($rows) > 0) { |
|
return $rows[0]; |
|
} |
|
} catch (Exception $exc) { |
|
echo $exc->getMessage(); |
|
} |
|
return $rows; |
|
} |
|
|
|
public static function getObblGruopByCodice(){ |
|
$anag_sanzioni = self::load(0, '', 0, 1); |
|
$res = array(); |
|
foreach ($anag_sanzioni as $value) { |
|
$res[$value['CODICE']][] = $value; |
|
} |
|
return $res; |
|
} |
|
|
|
public static function getGruopByCodice(){ |
|
$anag_sanzioni = self::load(); |
|
$res = array(); |
|
foreach ($anag_sanzioni as $value) { |
|
$res[$value['CODICE']][] = $value; |
|
} |
|
return $res; |
|
} |
|
|
|
|
|
}
|
|
|