mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
182 lines
4.3 KiB
PHP
182 lines
4.3 KiB
PHP
<?php
|
|
/* Copyright (C) 2006 Technikum-Wien
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
|
*
|
|
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
|
|
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
|
|
* Rudolf Hangl <rudolf.hangl@technikum-wien.at>.
|
|
*/
|
|
/**
|
|
* Klasse ortraumtyp (FAS-Online)
|
|
* @create 04-12-2006
|
|
*/
|
|
require_once(dirname(__FILE__).'/basis_db.class.php');
|
|
|
|
class raumtyp extends basis_db
|
|
{
|
|
public $new; // boolean
|
|
public $result = array(); // fachbereich Objekt
|
|
|
|
//Tabellenspalten
|
|
public $beschreibung; // string
|
|
public $raumtyp_kurzbz; // string
|
|
|
|
|
|
/**
|
|
* Konstruktor
|
|
* @param $ort_kurzbz und hierarchie ID des zu ladenden Raumtyps
|
|
*/
|
|
public function __construct($raumtyp_kurzbz=null)
|
|
{
|
|
parent::__construct();
|
|
|
|
if($raumtyp_kurzbz != null)
|
|
$this->load($raumtyp_kurzbz);
|
|
}
|
|
|
|
/**
|
|
* Laedt alle verfuegbaren Raumtypen
|
|
* @return true wenn ok, false im Fehlerfall
|
|
*/
|
|
public function getAll()
|
|
{
|
|
$qry = 'SELECT * FROM public.tbl_raumtyp ORDER BY raumtyp_kurzbz;';
|
|
|
|
if(!$this->db_query($qry))
|
|
{
|
|
$this->errormsg = 'Fehler beim Laden der Datensaetze';
|
|
return false;
|
|
}
|
|
|
|
while($row = $this->db_fetch_object())
|
|
{
|
|
$raumtyp_obj = new raumtyp();
|
|
|
|
$raumtyp_obj->beschreibung = $row->beschreibung;
|
|
$raumtyp_obj->raumtyp_kurzbz = $row->raumtyp_kurzbz;
|
|
|
|
|
|
$this->result[] = $raumtyp_obj;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Laedt einen Raumtyp
|
|
* @param $raumtyp ID des zu ladenden Raumtyps
|
|
* @return true wenn ok, false im Fehlerfall
|
|
*/
|
|
public function load($raumtyp_kurzbz)
|
|
{
|
|
if($raumtyp_kurzbz == '')
|
|
{
|
|
$this->errormsg = 'Kein gültiger Schlüssel vorhanden';
|
|
return false;
|
|
}
|
|
|
|
$qry = "SELECT * FROM public.tbl_raumtyp WHERE raumtyp_kurzbz = '".addslashes($raumtyp_kurzbz)."';";
|
|
|
|
if(!$this->db_query($qry))
|
|
{
|
|
$this->errormsg = 'Fehler beim Laden des Datensatzes';
|
|
return false;
|
|
}
|
|
|
|
if($row = $this->db_fetch_object())
|
|
{
|
|
$this->beschreibung = $row->beschreibung;
|
|
$this->raumtyp_kurzbz = $row->kurzbz;
|
|
|
|
}
|
|
else
|
|
{
|
|
$this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden';
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Prueft die Gueltigkeit der Variablen
|
|
* @return true wenn ok, false im Fehlerfall
|
|
*/
|
|
public function validate()
|
|
{
|
|
//Laenge Pruefen
|
|
if(strlen($this->beschreibung)>256)
|
|
{
|
|
$this->errormsg = 'Beschreibung darf nicht laenger als 256 Zeichen sein';
|
|
return false;
|
|
}
|
|
if(strlen($this->raumtyp_kurzbz)>8)
|
|
{
|
|
$this->errormsg = 'Raumtyp_kurzbz darf nicht laenger als 8 Zeichen sein';
|
|
return false;
|
|
}
|
|
if($this->raumtyp_kurzbz == '')
|
|
{
|
|
$this->errormsg = 'Keine gültige Kurzbz';
|
|
return false;
|
|
}
|
|
$this->errormsg = '';
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Speichert den aktuellen Datensatz
|
|
* @return true wenn ok, false im Fehlerfall
|
|
*/
|
|
public function save()
|
|
{
|
|
//Gueltigkeit der Variablen pruefen
|
|
if(!$this->validate())
|
|
return false;
|
|
|
|
if($this->new)
|
|
{
|
|
//Pruefen ob id gültig ist
|
|
if($this->raumtyp_kurzbz == '')
|
|
{
|
|
$this->errormsg = 'Keine gültige ID';
|
|
return false;
|
|
}
|
|
//Neuen Datensatz anlegen
|
|
$qry = 'INSERT INTO public.tbl_raumtyp (beschreibung, raumtyp_kurzbz) VALUES ('.
|
|
$this->addslashes($this->beschreibung).', '.
|
|
$this->addslashes($this->raumtyp_kurzbz).');';
|
|
|
|
}
|
|
else
|
|
{
|
|
//bestehenden Datensatz akualisieren
|
|
$qry = 'UPDATE public.tbl_raumtyp SET '.
|
|
'beschreibung='.$this->addslashes($this->beschreibung).' '.
|
|
'WHERE raumtyp_kurzbz = '.$this->addslashes($this->ort_kurzbz).';';
|
|
}
|
|
|
|
if($this->db_query($qry))
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
$this->errormsg = 'Fehler beim Speichern des Datensatzes';
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
?>
|