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; } }