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.
140 righe
4.1 KiB
140 righe
4.1 KiB
<?php |
|
|
|
require_once "IDataClass.php"; |
|
/* |
|
* To change this license header, choose License Headers in Project Properties. |
|
* To change this template file, choose Tools | Templates |
|
* and open the template in the editor. |
|
*/ |
|
|
|
/** |
|
* Description of UTENTI |
|
* |
|
* @author Stefano |
|
*/ |
|
class Contributo_Provinciale extends DataClass { |
|
|
|
//put your code here |
|
const TABLE_NAME = "CONTRIBUTO_PROVINCIALE"; |
|
const SEQ_NAME = "CONTRIBUTO_PROVINCIALE_ID_SEQ"; |
|
|
|
public $ID = 0; // Primary key |
|
public $ID_BANDO = 0; |
|
public $PROVINCIA = ""; |
|
public $PERCENTUALE = 0; |
|
public $DOTAZIONE_PROVINCIALE = ""; |
|
public $CANCELLATO = 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)) { |
|
$this->_loadById($src, self::TABLE_NAME, true); |
|
} |
|
} |
|
|
|
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); |
|
} |
|
|
|
/* Funzione che restituisce la somma delle dotazioni provinciali |
|
* Somma totale |
|
*/ |
|
|
|
public function printView() { |
|
global $con; |
|
$sql = "SELECT * FROM " . self::TABLE_NAME; |
|
$query = $con->prepare($sql); |
|
try { |
|
$query->execute(); |
|
$it = $query->fetchAll(PDO::FETCH_ASSOC); |
|
} catch (Exception $exc) { |
|
echo $exc->getMessage(); |
|
} |
|
return $it; |
|
} |
|
|
|
public function sumPercentuale() { |
|
global $con; |
|
$sql = "SELECT SUM(PERCENTUALE) AS PERCENTUALE FROM " . self::TABLE_NAME; |
|
$query = $con->prepare($sql); |
|
try { |
|
$query->execute(); |
|
$it = $query->fetch(PDO::FETCH_ASSOC); |
|
} catch (Exception $exc) { |
|
echo $exc->getMessage(); |
|
} |
|
$firstSomma = round(ceil($it['PERCENTUALE']), 2); |
|
echo $firstSomma; |
|
} |
|
|
|
public function sumDotazione() { |
|
global $con; |
|
$sql = "SELECT SUM(DOTAZIONE_PROVINCIALE) AS SOMMA FROM " . self::TABLE_NAME; |
|
$query = $con->prepare($sql); |
|
try { |
|
$query->execute(); |
|
$it = $query->fetch(PDO::FETCH_ASSOC); |
|
} catch (Exception $exc) { |
|
echo $exc->getMessage(); |
|
} |
|
$firstSomma = round(ceil($it['SOMMA']), 2); |
|
$somma = number_format($firstSomma, 2, ",", "."); |
|
echo $somma; |
|
} |
|
|
|
public function Save() { |
|
global $con, $LoggedAccount; |
|
$vars = get_object_vars($this); |
|
$sql = Utils::prepareQuery(self::TABLE_NAME, $vars); |
|
$queryabi = $con->prepare($sql); |
|
foreach ($vars as $k => $v) { |
|
if ($k == "ID" && $v == 0) |
|
continue; |
|
$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); |
|
} |
|
|
|
/** |
|
* 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; |
|
} |
|
} |
|
|
|
}
|
|
|