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.
189 righe
6.0 KiB
189 righe
6.0 KiB
<?php |
|
|
|
require_once ROOT . "lib/classes/IDataClass.php"; |
|
/** |
|
* Description of UTENTI |
|
* |
|
* @author Stefano |
|
*/ |
|
class DocumentiBando extends DataClass { |
|
|
|
const TABLE_NAME = "DOCUMENTI_BANDO"; |
|
const SEQ_NAME = "DOCUMENTI_BANDO_ID_SEQ"; |
|
|
|
public $ID = 0; // Primary key |
|
public $NOME = ""; |
|
public $OBBLIGO = 0; |
|
public $PRIORITA = 0; |
|
public $FASE = 0; |
|
public $CANCELLATO = 0; |
|
public $TIPO_FIRMATARIO = 0; |
|
public $ESTENZIONE_FILE = ""; |
|
public $VERIFICA_FIRMA_P7M = 0; |
|
public $FILE_DA_GENERARE = 0; |
|
public $MODULE = '';// Modull WS che genera il PDF se $FILE_DA_GENERARE è impostato a 1 |
|
public $OBBLIGO_CONDIZIONATO = '';// TABELLA|COLONNA|VALORE |
|
|
|
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 Count($filter = null) { |
|
return parent::_count(self::TABLE_NAME, $filter); |
|
} |
|
|
|
public static function load($fase = null, $obbligo = 1) { |
|
global $con; |
|
$rows = array(); |
|
|
|
$filter = (!empty($fase) ? " AND FASE <= :fase " : ""); |
|
$filter .= ($obbligo >= 0 ? " AND OBBLIGO = :obbligo " : ""); |
|
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE CANCELLATO = 0 " . $filter . " ORDER BY ID ASC "; |
|
|
|
$query = $con->prepare($sql); |
|
if (!empty($fase)) { |
|
$query->bindParam(":fase", $fase); |
|
} |
|
if ($obbligo >= 0) { |
|
$query->bindParam(":obbligo", $obbligo); |
|
} |
|
try { |
|
$query->execute(); |
|
$rows = $query->fetchAll(PDO::FETCH_ASSOC); |
|
} catch (Exception $exc) { |
|
$exc->getMessage(); |
|
} |
|
|
|
return $rows; |
|
} |
|
|
|
/** |
|
* |
|
* @global type $con |
|
* @param type $ateco |
|
* @param type $fase |
|
* @return \DocumentiBando |
|
*/ |
|
public static function loadFromCheckFinale($fase = null) { |
|
global $con; |
|
$return = array(); |
|
|
|
$filter = (!empty($fase) ? " AND FASE <= :fase " : ""); |
|
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE (OBBLIGO >= 1 OR (OBBLIGO = 0 AND OBBLIGO_CONDIZIONATO is not null )) AND CANCELLATO = 0 " . $filter . " ORDER BY ID ASC "; |
|
|
|
$query = $con->prepare($sql); |
|
if (!empty($fase)) { |
|
$query->bindParam(":fase", $fase); |
|
} |
|
try { |
|
$query->execute(); |
|
$r = $query->fetchAll(PDO::FETCH_ASSOC); |
|
foreach ($r as $res) { |
|
$doc = new DocumentiBando($res); |
|
$return[]= $doc ; |
|
} |
|
} catch (Exception $exc) { |
|
$exc->getMessage(); |
|
} |
|
|
|
return $return; |
|
} |
|
|
|
public function Save() { |
|
global $con, $LoggedAccount; |
|
$vars = get_object_vars($this); |
|
UNSET($vars['DATA_PRESENTAZIONE']); |
|
$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['erroreDescrizione'] = $exc->getMessage(); |
|
} |
|
return $it; |
|
} |
|
|
|
public function compareAtecoDomanda($idDocumento = 0, $ateco = 0, $tipo_istanza = ISTANZA_INDIVIDUALE) { |
|
$response = false; |
|
if (intval($idDocumento) >= 0 && intval($ateco) >= 0) { |
|
$documento_bando = new DocumentiBando($idDocumento); |
|
if ($documento_bando->ATECO == $ateco && $tipo_istanza <= $documento_bando->FASE) { |
|
$response = true; |
|
} |
|
} |
|
return $response; |
|
} |
|
|
|
public function compareBandoDomanda($idDocumento = 0, $idBando = 0) { |
|
$response = false; |
|
if (intval($idDocumento) >= 0 && intval($idBando) >= 0) { |
|
$documento_bando = new DocumentiBando($idDocumento); |
|
if ($documento_bando->ID_BANDO == $idBando) { |
|
$response = true; |
|
} |
|
} |
|
return $response; |
|
} |
|
|
|
/** |
|
* Elimina l'oggetto corrente dal database e restituisce TRUE se ha successo |
|
* |
|
* @return bool Risultato booleano dell'operazione |
|
*/ |
|
public function Delete() { |
|
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 = "") { |
|
array_push($record, array("Campo" => $campo, "Valore" => $this->$campo)); |
|
} |
|
|
|
public function getPathInfoDocumento() { |
|
$response = array(); |
|
|
|
switch ($this->FASE) { |
|
case DOCUMENTI_FASE_1: |
|
case DOCUMENTI_FASE_2: |
|
if ($this->OBBLIGO == 1 OR ($this->OBBLIGO == 0 && $this->OBBLIGO_CONDIZIONATO !="") ) { |
|
$response["TIPO_DOCUMENTO"] = TIPO_UPLOAD_OBBLIGATORIO; |
|
$response["PATH_DOCUMENTO"] = "obbligatori"; |
|
} else if ($this->OBBLIGO == 2) { |
|
$response["TIPO_DOCUMENTO"] = TIPO_UPLOAD_ISTANZA; |
|
$response["PATH_DOCUMENTO"] = "istanza"; |
|
} else { |
|
$response["TIPO_DOCUMENTO"] = TIPO_UPLOAD_OPZIONALE; |
|
$response["PATH_DOCUMENTO"] = "opzionali"; |
|
} |
|
break; |
|
default : |
|
$response = array(); |
|
break; |
|
} |
|
|
|
return $response; |
|
} |
|
|
|
}
|
|
|