mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -27,6 +27,11 @@ require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
|
||||
class betriebsmittelperson extends basis_db
|
||||
{
|
||||
# public $schema_inventar='public';
|
||||
public $schema_inventar='wawi';
|
||||
public $debug=false; // boolean
|
||||
|
||||
|
||||
public $new; // boolean
|
||||
public $result = array();
|
||||
|
||||
@@ -48,6 +53,7 @@ class betriebsmittelperson extends basis_db
|
||||
public $nummer;
|
||||
public $betriebsmitteltyp;
|
||||
public $beschreibung;
|
||||
public $oe_kurzbz;
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
@@ -82,9 +88,8 @@ class betriebsmittelperson extends basis_db
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT * FROM public.tbl_betriebsmittel JOIN public.tbl_betriebsmittelperson USING(betriebsmittel_id)
|
||||
$qry = "SELECT * FROM ".$this->schema_inventar.".tbl_betriebsmittel JOIN ".$this->schema_inventar.".tbl_betriebsmittelperson USING(betriebsmittel_id)
|
||||
WHERE betriebsmittel_id='".addslashes($betriebsmittel_id)."' AND person_id='".addslashes($person_id)."'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
@@ -95,7 +100,6 @@ class betriebsmittelperson extends basis_db
|
||||
$this->nummer = $row->nummer;
|
||||
$this->nummerintern = $row->nummerintern;
|
||||
$this->reservieren = ($row->reservieren=='t'?true:false);
|
||||
$this->ort_kurzbz = $row->ort_kurzbz;
|
||||
$this->person_id = $row->person_id;
|
||||
$this->anmerkung = $row->anmerkung;
|
||||
$this->kaution = $row->kaution;
|
||||
@@ -106,17 +110,18 @@ class betriebsmittelperson extends basis_db
|
||||
$this->updateamum = $row->updateamum;
|
||||
$this->updatevon = $row->updatevon;
|
||||
$this->ext_id = $row->ext_id;
|
||||
$this->ort_kurzbz = $row->ort_kurzbz;
|
||||
return $this->result=$row;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Es wurde kein passender Datensatz gefunden';
|
||||
$this->errormsg = 'Es wurde kein passender Datensatz gefunden '.($this->debug?$this->db_last_error()."<br />$qry<br />":'');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
$this->errormsg = 'Fehler beim Laden der Daten '.($this->debug?$this->db_last_error()."<br />$qry<br />":'');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -181,21 +186,20 @@ class betriebsmittelperson extends basis_db
|
||||
if($new)
|
||||
{
|
||||
//Pruefen ob dieses Betriebsmittel dieser Person schon zugeordnet ist
|
||||
$qry = "SELECT 1 FROM public.tbl_betriebsmittelperson
|
||||
WHERE person_id='".addslashes($this->person_id)."' AND
|
||||
betriebsmittel_id='".addslashes($this->betriebsmittel_id)."'";
|
||||
|
||||
$qry = "SELECT 1 FROM ".$this->schema_inventar.".tbl_betriebsmittelperson
|
||||
WHERE person_id=".$this->addslashes($this->person_id)." AND
|
||||
betriebsmittel_id=".$this->addslashes($this->betriebsmittel_id);
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($this->db_num_rows()>0)
|
||||
{
|
||||
$this->errormsg = 'Dieses Betriebsmittel ist der Person bereits zugeordnet';
|
||||
$this->errormsg = 'Dieses Betriebsmittel ist der Person bereits zugeordnet '.($this->debug?$this->db_last_error()."<br />$qry<br />":'');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Neuen Datensatz einfuegen
|
||||
|
||||
$qry='INSERT INTO public.tbl_betriebsmittelperson (betriebsmittel_id, person_id, anmerkung, kaution,
|
||||
$qry='INSERT INTO '.$this->schema_inventar.'.tbl_betriebsmittelperson (betriebsmittel_id, person_id, anmerkung, kaution,
|
||||
ausgegebenam, retouram, ext_id, insertamum, insertvon, updateamum, updatevon) VALUES('.
|
||||
$this->addslashes($this->betriebsmittel_id).', '.
|
||||
$this->addslashes($this->person_id).', '.
|
||||
@@ -212,7 +216,7 @@ class betriebsmittelperson extends basis_db
|
||||
//Pruefen ob betriebsmittel_id eine gueltige Zahl ist
|
||||
if(!is_numeric($this->betriebsmittel_id) || !is_numeric($this->person_id))
|
||||
{
|
||||
$this->errormsg = 'betriebsmittel_id und Person_id muessen gueltige Zahlen sein';
|
||||
$this->errormsg = 'betriebsmittel_id und Person_id muessen gueltige Zahlen sein '.($this->debug?$this->db_last_error()."<br />$qry<br />":'');
|
||||
return false;
|
||||
}
|
||||
if($this->betriebsmittel_id_old=='')
|
||||
@@ -220,7 +224,7 @@ class betriebsmittelperson extends basis_db
|
||||
if($this->person_id_old=='')
|
||||
$this->person_id_old = $this->person_id;
|
||||
|
||||
$qry='UPDATE public.tbl_betriebsmittelperson SET '.
|
||||
$qry='UPDATE '.$this->schema_inventar.'.tbl_betriebsmittelperson SET '.
|
||||
'betriebsmittel_id='.$this->addslashes($this->betriebsmittel_id).', '.
|
||||
'person_id='.$this->addslashes($this->person_id).', '.
|
||||
'anmerkung='.$this->addslashes($this->anmerkung).', '.
|
||||
@@ -240,7 +244,7 @@ class betriebsmittelperson extends basis_db
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = "Fehler beim Speichern der Betriebsmittelperson";
|
||||
$this->errormsg = "Fehler beim Speichern der Betriebsmittelperson ".($this->debug?$this->db_last_error()."<br />$qry<br />":'');;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -251,28 +255,25 @@ class betriebsmittelperson extends basis_db
|
||||
* @param $person_id ID die geloescht werden soll
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function delete($betriebsmittel_id, $person_id)
|
||||
public function delete($betriebsmittel_id, $person_id=null)
|
||||
{
|
||||
if(!is_numeric($betriebsmittel_id))
|
||||
{
|
||||
$this->errormsg = 'Betriebsmittel_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!is_numeric($person_id))
|
||||
if($person_id && !is_numeric($person_id))
|
||||
{
|
||||
$this->errormsg = 'Person_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "DELETE FROM public.tbl_betriebsmittelperson
|
||||
WHERE betriebsmittel_id='".addslashes($betriebsmittel_id)."' AND person_id='".addslashes($person_id)."'";
|
||||
|
||||
$qry = 'DELETE FROM '.$this->schema_inventar.'.tbl_betriebsmittelperson
|
||||
WHERE betriebsmittel_id='.$this->addslashes($betriebsmittel_id).($person_id?' and person_id='.$this->addslashes($person_id):'');
|
||||
if($this->db_query($qry))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Loeschen der Daten';
|
||||
$this->errormsg = 'Fehler beim Loeschen der Daten '.($this->debug?$this->db_last_error()."<br />$qry<br />":'');;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -284,13 +285,14 @@ class betriebsmittelperson extends basis_db
|
||||
*/
|
||||
public function getBetriebsmittelPerson($person_id, $betriebsmitteltyp=null)
|
||||
{
|
||||
$this->result=array();
|
||||
$this->errormsg = '';
|
||||
if(!is_numeric($person_id))
|
||||
{
|
||||
$this->errormsg = 'Person_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT * FROM public.tbl_betriebsmittel JOIN public.tbl_betriebsmittelperson USING(betriebsmittel_id)
|
||||
$qry = "SELECT * FROM ".$this->schema_inventar.".tbl_betriebsmittel JOIN ".$this->schema_inventar.".tbl_betriebsmittelperson USING(betriebsmittel_id)
|
||||
WHERE person_id='".addslashes($person_id)."'";
|
||||
if(!is_null($betriebsmitteltyp))
|
||||
$qry.=" AND betriebsmitteltyp='".addslashes($betriebsmitteltyp)."'";
|
||||
@@ -319,16 +321,175 @@ class betriebsmittelperson extends basis_db
|
||||
$bm->updateamum = $row->updateamum;
|
||||
$bm->updatevon = $row->updatevon;
|
||||
$bm->ext_id = $row->ext_id;
|
||||
|
||||
$bm->oe_kurzbz = $row->oe_kurzbz;
|
||||
$this->result[] = $bm;
|
||||
}
|
||||
return true;
|
||||
if (count($this->result)==1)
|
||||
{
|
||||
$this->betriebsmittel_id = $this->result[0]->betriebsmittel_id;
|
||||
$this->beschreibung = $this->result[0]->beschreibung;
|
||||
$this->betriebsmitteltyp = $this->result[0]->betriebsmitteltyp;
|
||||
$this->nummer = $this->result[0]->nummer;
|
||||
$this->nummerintern = $this->result[0]->nummerintern;
|
||||
$this->reservieren = ($this->result[0]->reservieren=='t'?true:false);
|
||||
$this->ort_kurzbz = $this->result[0]->ort_kurzbz;
|
||||
$this->person_id = $this->result[0]->person_id;
|
||||
$this->anmerkung = $this->result[0]->anmerkung;
|
||||
$this->kaution = $this->result[0]->kaution;
|
||||
$this->ausgegebenam = $this->result[0]->ausgegebenam;
|
||||
$this->retouram = $this->result[0]->retouram;
|
||||
$this->insertamum = $this->result[0]->insertamum;
|
||||
$this->insertvon = $this->result[0]->insertvon;
|
||||
$this->updateamum = $this->result[0]->updateamum;
|
||||
$this->updatevon = $this->result[0]->updatevon;
|
||||
$this->ext_id = $this->result[0]->ext_id;
|
||||
$this->oe_kurzbz = $this->result[0]->oe_kurzbz;
|
||||
}
|
||||
return $this->result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
$this->errormsg = 'Fehler beim Laden der Daten '.($this->debug?$this->db_last_error()."<br />$qry<br />":'');;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt das Betriebsmittel mit der ID $betriebsmittel_id
|
||||
* @param $betriebsmittel_id ID des zu ladenden Betriebsmittels
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function load_betriebsmittelpersonen($betriebsmittel_id)
|
||||
{
|
||||
$this->result=array();
|
||||
$this->errormsg='';
|
||||
|
||||
if(!is_numeric($betriebsmittel_id))
|
||||
{
|
||||
$this->errormsg = 'Betriebsmittel_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry='';
|
||||
$qry.='SELECT * ';
|
||||
$qry.=' FROM '.$this->schema_inventar.'.tbl_betriebsmittel JOIN '.$this->schema_inventar.'.tbl_betriebsmittelperson USING(betriebsmittel_id)';
|
||||
$qry.=' WHERE betriebsmittel_id='.$this->addslashes($betriebsmittel_id);
|
||||
$qry.=' order by ausgegebenam desc, retouram desc ';
|
||||
$qry.=' limit 1';
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->betriebsmittel_id = $row->betriebsmittel_id;
|
||||
$this->beschreibung = $row->beschreibung;
|
||||
$this->betriebsmitteltyp = $row->betriebsmitteltyp;
|
||||
$this->nummer = $row->nummer;
|
||||
$this->nummerintern = $row->nummerintern;
|
||||
$this->reservieren = ($row->reservieren=='t'?true:false);
|
||||
$this->ort_kurzbz = $row->ort_kurzbz;
|
||||
$this->person_id = $row->person_id;
|
||||
$this->anmerkung = $row->anmerkung;
|
||||
$this->kaution = $row->kaution;
|
||||
$this->ausgegebenam = $row->ausgegebenam;
|
||||
$this->retouram = $row->retouram;
|
||||
$this->insertamum = $row->insertamum;
|
||||
$this->insertvon = $row->insertvon;
|
||||
$this->updateamum = $row->updateamum;
|
||||
$this->updatevon = $row->updatevon;
|
||||
$this->ext_id = $row->ext_id;
|
||||
$this->oe_kurzbz = $row->oe_kurzbz;
|
||||
return $this->result=$row;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten '.($this->debug?$this->db_last_error()."<br> $qry <br>":'');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt das Betriebsmittel mit der ID $betriebsmittel_id
|
||||
* @param $betriebsmittel_id ID des zu ladenden Betriebsmittels
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function getbetriebsmittelpersonen($betriebsmittel_id)
|
||||
{
|
||||
$this->result=array();
|
||||
$this->errormsg='';
|
||||
|
||||
if(!is_numeric($betriebsmittel_id))
|
||||
{
|
||||
$this->errormsg = 'Betriebsmittel_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
$qry='';
|
||||
$qry.='SELECT * ';
|
||||
$qry.=' FROM '.$this->schema_inventar.'.tbl_betriebsmittel JOIN '.$this->schema_inventar.'.tbl_betriebsmittelperson USING(betriebsmittel_id)';
|
||||
$qry.=' WHERE betriebsmittel_id='.$this->addslashes($betriebsmittel_id);
|
||||
$qry.=' order by ausgegebenam desc, retouram desc';
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$bm = new betriebsmittelperson();
|
||||
|
||||
$bm->betriebsmittel_id = $row->betriebsmittel_id;
|
||||
$bm->beschreibung = $row->beschreibung;
|
||||
$bm->betriebsmitteltyp = $row->betriebsmitteltyp;
|
||||
$bm->nummer = $row->nummer;
|
||||
$bm->nummerintern = $row->nummerintern;
|
||||
$bm->reservieren = ($row->reservieren=='t'?true:false);
|
||||
$bm->ort_kurzbz = $row->ort_kurzbz;
|
||||
$bm->person_id = $row->person_id;
|
||||
$bm->anmerkung = $row->anmerkung;
|
||||
$bm->kaution = $row->kaution;
|
||||
$bm->ausgegebenam = $row->ausgegebenam;
|
||||
$bm->retouram = $row->retouram;
|
||||
$bm->insertamum = $row->insertamum;
|
||||
$bm->insertvon = $row->insertvon;
|
||||
$bm->updateamum = $row->updateamum;
|
||||
$bm->updatevon = $row->updatevon;
|
||||
$bm->ext_id = $row->ext_id;
|
||||
$bm->oe_kurzbz = $row->oe_kurzbz;
|
||||
$this->result[] = $bm;
|
||||
}
|
||||
if (count($this->result)==1)
|
||||
{
|
||||
$this->betriebsmittel_id = $this->result[0]->betriebsmittel_id;
|
||||
$this->beschreibung = $this->result[0]->beschreibung;
|
||||
$this->betriebsmitteltyp = $this->result[0]->betriebsmitteltyp;
|
||||
$this->nummer = $this->result[0]->nummer;
|
||||
$this->nummerintern = $this->result[0]->nummerintern;
|
||||
$this->reservieren = ($this->result[0]->reservieren=='t'?true:false);
|
||||
$this->ort_kurzbz = $this->result[0]->ort_kurzbz;
|
||||
$this->person_id = $this->result[0]->person_id;
|
||||
$this->anmerkung = $this->result[0]->anmerkung;
|
||||
$this->kaution = $this->result[0]->kaution;
|
||||
$this->ausgegebenam = $this->result[0]->ausgegebenam;
|
||||
$this->retouram = $this->result[0]->retouram;
|
||||
$this->insertamum = $this->result[0]->insertamum;
|
||||
$this->insertvon = $this->result[0]->insertvon;
|
||||
$this->updateamum = $this->result[0]->updateamum;
|
||||
$this->updatevon = $this->result[0]->updatevon;
|
||||
$this->ext_id = $this->result[0]->ext_id;
|
||||
$this->oe_kurzbz = $this->result[0]->oe_kurzbz;
|
||||
}
|
||||
|
||||
return $this->result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten '.($this->debug?$this->db_last_error()."<br />$qry<br />":'');;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
+230
-143
@@ -1,144 +1,231 @@
|
||||
<?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 betriebsmitteltyp (FAS-Online)
|
||||
* @create 13-01-2007
|
||||
*/
|
||||
require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
|
||||
class betriebsmitteltyp extends basis_db
|
||||
{
|
||||
public $new;
|
||||
public $result = array();
|
||||
|
||||
//Tabellenspalten
|
||||
public $betriebsmitteltyp; //string
|
||||
public $beschreibung; //string
|
||||
public $anzahl; //smallint
|
||||
public $kaution; //numeric(5,2)
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
* @param $betriebsmitteltyp
|
||||
*/
|
||||
public function __construct($betriebsmitteltyp=null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if($betriebsmitteltyp!=null)
|
||||
$this->load($betriebsmitteltyp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt die Funktion mit der ID $betriebsmitteltyp
|
||||
* @param $betriebsmitteltyp
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function load($betriebsmitteltyp)
|
||||
{
|
||||
$this->errormsg = 'Noch nicht implementiert';
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle BetriebsmittelTypen
|
||||
* @return true wenn ok, false wenn Fehler
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$qry = "SELECT * FROM public.tbl_betriebsmitteltyp ORDER BY betriebsmitteltyp";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$bmt = new betriebsmitteltyp();
|
||||
|
||||
$bmt->betriebsmitteltyp = $row->betriebsmitteltyp;
|
||||
$bmt->beschreibung = $row->beschreibung;
|
||||
$bmt->anzahl = $row->anzahl;
|
||||
$bmt->kaution = $row->kaution;
|
||||
|
||||
$this->result[] = $bmt;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert die Daten in die Datenbank
|
||||
* @return true wenn erfolgreich, false im Fehlerfall
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$dbanzahl=0;
|
||||
$qry='';
|
||||
$qry1='SELECT * FROM public.tbl_betriebsmitteltyp WHERE beschreibung='.$this->addslashes($this->beschreibung).';';
|
||||
if($this->db_query($qry1))
|
||||
{
|
||||
if($this->db_num_rows()>0) //eintrag gefunden
|
||||
{
|
||||
if($row1 = $this->db_fetch_object())
|
||||
{
|
||||
if($row1->anzahl==null)
|
||||
$dbanzahl=0;
|
||||
else
|
||||
$dbanzahl=$row1->anzahl;
|
||||
|
||||
$qry='UPDATE public.tbl_betriebsmitteltyp SET '.
|
||||
'anzahl ='.addslashes($dbanzahl)."+".addslashes($this->anzahl).' '.
|
||||
'WHERE beschreibung='.$this->addslashes($this->beschreibung).';';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry='INSERT INTO public.tbl_betriebsmitteltyp (betriebsmitteltyp, beschreibung, anzahl, kaution) VALUES('.
|
||||
$this->addslashes($this->betriebsmitteltyp).', '.
|
||||
$this->addslashes($this->beschreibung).', '.
|
||||
$this->addslashes($this->anzahl).', '.
|
||||
$this->addslashes($this->kaution).');';
|
||||
}
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern des Betriebsmitteltypen-Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Zugriff auf den Betriebsmitteltypen-Datensatz';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
<?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 betriebsmitteltyp (FAS-Online)
|
||||
* @create 13-01-2007
|
||||
*/
|
||||
require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
|
||||
class betriebsmitteltyp extends basis_db
|
||||
{
|
||||
private $schema_inventar='wawi';
|
||||
|
||||
public $debug=false; // boolean
|
||||
public $new; // boolean
|
||||
public $result = array();
|
||||
|
||||
//Tabellenspalten
|
||||
public $betriebsmitteltyp; //string
|
||||
public $beschreibung; //string
|
||||
public $anzahl; //smallint
|
||||
public $kaution; //numeric(5,2)
|
||||
public $typ_code; //string(2)
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
* @param $betriebsmitteltyp
|
||||
*/
|
||||
public function __construct($betriebsmitteltyp=null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if($betriebsmitteltyp!=null)
|
||||
$this->load($betriebsmitteltyp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt die Funktion mit der ID $betriebsmitteltyp
|
||||
* @param $betriebsmitteltyp
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function load($betriebsmitteltyp)
|
||||
{
|
||||
// Initialisieren Variable
|
||||
$qry='';
|
||||
$where='';
|
||||
$this->result=array();
|
||||
$this->errormsg = '';
|
||||
// Select erzeugen
|
||||
$qry.=' select * FROM '.$this->schema_inventar.'.tbl_betriebsmitteltyp';
|
||||
$qry.=" where betriebsmitteltyp >'' ";
|
||||
|
||||
// Bedingungen hinzufuegen
|
||||
$where.=" AND trim(UPPER(betriebsmitteltyp)) like '%".mb_strtoupper(trim(addslashes(str_replace(array('*',';',' ',"'",'"'),'%',trim($betriebsmitteltyp)))))."%' " ;
|
||||
$qry.=$where;
|
||||
|
||||
// Sortierung
|
||||
$qry.=' order by betriebsmitteltyp ';
|
||||
|
||||
// Datenbankabfrage - ausfuehren
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$bmt = new betriebsmitteltyp();
|
||||
$bmt->betriebsmitteltyp = $row->betriebsmitteltyp;
|
||||
$bmt->beschreibung = $row->beschreibung;
|
||||
$bmt->anzahl = $row->anzahl;
|
||||
$bmt->kaution = $row->kaution;
|
||||
$bmt->typ_code = $row->typ_code;
|
||||
$this->result[] = $bmt;
|
||||
}
|
||||
return $this->result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten '.($this->debug?$this->db_last_error():'');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle BetriebsmittelTypen
|
||||
* @return true wenn ok, false wenn Fehler
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$this->result=array();
|
||||
$this->errormsg = '';
|
||||
$qry = "SELECT * FROM ".$this->schema_inventar.".tbl_betriebsmitteltyp ORDER BY betriebsmitteltyp";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$bmt = new betriebsmitteltyp();
|
||||
|
||||
$bmt->betriebsmitteltyp = $row->betriebsmitteltyp;
|
||||
$bmt->beschreibung = $row->beschreibung;
|
||||
$bmt->anzahl = $row->anzahl;
|
||||
$bmt->kaution = $row->kaution;
|
||||
$bmt->typ_code = $row->typ_code;
|
||||
|
||||
$this->result[] = $bmt;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten '.($this->debug?$this->db_last_error():'');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert die Daten in die Datenbank
|
||||
* @return true wenn erfolgreich, false im Fehlerfall
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$this->errormsg = '';
|
||||
$dbanzahl=0;
|
||||
$qry='';
|
||||
$qry1='SELECT * FROM '.$this->schema_inventar.'.tbl_betriebsmitteltyp WHERE beschreibung='.$this->addslashes($this->beschreibung).';';
|
||||
if($this->db_query($qry1))
|
||||
{
|
||||
if($this->db_num_rows()>0) //eintrag gefunden
|
||||
{
|
||||
if($row1 = $this->db_fetch_object())
|
||||
{
|
||||
if($row1->anzahl==null)
|
||||
$dbanzahl=0;
|
||||
else
|
||||
$dbanzahl=$row1->anzahl;
|
||||
|
||||
$qry='UPDATE '.$this->schema_inventar.'.tbl_betriebsmitteltyp SET '.
|
||||
'anzahl ='.addslashes($dbanzahl)."+".addslashes($this->anzahl).' '.
|
||||
'WHERE beschreibung='.$this->addslashes($this->beschreibung).'; ' ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry='INSERT INTO '.$this->schema_inventar.'.tbl_betriebsmitteltyp (betriebsmitteltyp, beschreibung, anzahl, kaution,typ_code) VALUES('.
|
||||
$this->addslashes($this->betriebsmitteltyp).', '.
|
||||
$this->addslashes($this->beschreibung).', '.
|
||||
$this->addslashes($this->anzahl).', '.
|
||||
$this->addslashes($this->kaution).', '.
|
||||
$this->addslashes($this->typ_code).');';
|
||||
}
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern des Betriebsmitteltypen-Datensatzes '.($this->debug?$this->db_last_error():'');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Zugriff auf den Betriebsmitteltypen-Datensatz '.($this->debug?$this->db_last_error():'');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert die Daten in die Datenbank
|
||||
* @return true wenn erfolgreich, false im Fehlerfall
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$this->errormsg = '';
|
||||
$qry='UPDATE '.$this->schema_inventar.'.tbl_betriebsmitteltyp SET '.
|
||||
'beschreibung ='.$this->addslashes($this->beschreibung).', '.
|
||||
'anzahl ='.$this->addslashes($this->anzahl).', '.
|
||||
'kaution ='.$this->addslashes($this->kaution).', '.
|
||||
'typ_code ='.$this->addslashes($this->typ_code).' '.
|
||||
'WHERE betriebsmitteltyp='.$this->addslashes($this->betriebsmitteltyp).'; ' ;
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern des Betriebsmitteltypen-Datensatzes '.($this->debug?$this->db_last_error():'');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Speichert die Daten in die Datenbank
|
||||
* @return true wenn erfolgreich, false im Fehlerfall
|
||||
*/
|
||||
public function check_beschreibung()
|
||||
{
|
||||
$this->errormsg = '';
|
||||
$qry='UPDATE '.$this->schema_inventar.'.tbl_betriebsmitteltyp SET '.
|
||||
'beschreibung = trim(betriebsmitteltyp) '.
|
||||
' where beschreibung is null ';
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Pruefen der Beschreibung des Betriebsmitteltypen-Datensatzes '.($this->debug?$this->db_last_error():'');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
+549
-357
@@ -1,358 +1,550 @@
|
||||
<?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 firma
|
||||
* @create 18-12-2006
|
||||
*/
|
||||
require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
|
||||
class firma extends basis_db
|
||||
{
|
||||
public $new; // boolean
|
||||
public $result = array(); // adresse Objekt
|
||||
|
||||
//Tabellenspalten
|
||||
public $firma_id; // integer
|
||||
public $name; // string
|
||||
public $adresse; // string
|
||||
public $email; // string
|
||||
public $telefon; // string
|
||||
public $fax; // string
|
||||
public $anmerkung; // string
|
||||
public $ext_id; // integer
|
||||
public $insertamum; // timestamp
|
||||
public $insertvon; // bigint
|
||||
public $updateamum; // timestamp
|
||||
public $updatevon; // bigint
|
||||
public $firmentyp_kurzbz;
|
||||
public $schule; // boolean
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
* @param $firma_id ID der Firma die geladen werden soll (Default=null)
|
||||
*/
|
||||
public function __construct($firma_id=null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if(!is_null($firma_id))
|
||||
$this->load($firma_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt die Firma mit der ID $firma_id
|
||||
* @param $firma_id ID der zu ladenden Funktion
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function load($firma_id)
|
||||
{
|
||||
if(!is_numeric($firma_id))
|
||||
{
|
||||
$this->errormsg = 'Firma_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SElECT * FROM public.tbl_firma WHERE firma_id='$firma_id'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->firma_id = $row->firma_id;
|
||||
$this->name = $row->name;
|
||||
$this->adresse = $row->adresse;
|
||||
$this->email = $row->email;
|
||||
$this->telefon = $row->telefon;
|
||||
$this->fax = $row->fax;
|
||||
$this->anmerkung = $row->anmerkung;
|
||||
$this->firmentyp_kurzbz = $row->firmentyp_kurzbz;
|
||||
$this->updateamum = $row->updateamum;
|
||||
$this->updatevon = $row->updatevon;
|
||||
$this->insertamum = $row->insertamum;
|
||||
$this->insertvon = $row->insertvon;
|
||||
$this->ext_id = $row->ext_id;
|
||||
$this->schule = ($row->schule=='t'?true:false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Datensatz wurde nicht gefunden';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft die Variablen auf Gueltigkeit
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
protected function validate()
|
||||
{
|
||||
//Gesamtlaenge pruefen
|
||||
if(mb_strlen($this->name)>128)
|
||||
{
|
||||
$this->errormsg = 'Name darf nicht länger als 128 Zeichen sein';
|
||||
return false;
|
||||
}
|
||||
if(mb_strlen($this->anmerkung)>256)
|
||||
{
|
||||
$this->errormsg = 'Anmerkung darf nicht länger als 256 Zeichen sein';
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->errormsg = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert den aktuellen Datensatz in die Datenbank
|
||||
* Wenn $neu auf true gesetzt ist wird ein neuer Datensatz angelegt
|
||||
* andernfalls wird der Datensatz mit der ID in $firma_id aktualisiert
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
//Variablen pruefen
|
||||
if(!$this->validate())
|
||||
return false;
|
||||
|
||||
if($this->new)
|
||||
{
|
||||
//Neuen Datensatz einfuegen
|
||||
$qry='INSERT INTO public.tbl_firma (name, adresse, email, telefon, fax, anmerkung,
|
||||
firmentyp_kurzbz, updateamum, updatevon, insertamum, insertvon, ext_id, schule) VALUES('.
|
||||
$this->addslashes($this->name).', '.
|
||||
$this->addslashes($this->adresse).', '.
|
||||
$this->addslashes($this->email).', '.
|
||||
$this->addslashes($this->telefon).', '.
|
||||
$this->addslashes($this->fax).', '.
|
||||
$this->addslashes($this->anmerkung).', '.
|
||||
$this->addslashes($this->firmentyp_kurzbz).', '.
|
||||
$this->addslashes($this->updateamum).', '.
|
||||
$this->addslashes($this->updatevon).', '.
|
||||
$this->addslashes($this->insertamum).', '.
|
||||
$this->addslashes($this->insertvon).', '.
|
||||
$this->addslashes($this->ext_id).','.
|
||||
($this->schule?'true':'false').'); ';
|
||||
}
|
||||
else
|
||||
{
|
||||
//Updaten des bestehenden Datensatzes
|
||||
|
||||
//Pruefen ob firma_id eine gueltige Zahl ist
|
||||
if(!is_numeric($this->firma_id))
|
||||
{
|
||||
$this->errormsg = 'firma_id muss eine gueltige Zahl sein';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry='UPDATE public.tbl_firma SET '.
|
||||
'firma_id='.$this->addslashes($this->firma_id).', '.
|
||||
'name='.$this->addslashes($this->name).', '.
|
||||
'adresse='.$this->addslashes($this->adresse).', '.
|
||||
'email='.$this->addslashes($this->email).', '.
|
||||
'telefon='.$this->addslashes($this->telefon).', '.
|
||||
'fax='.$this->addslashes($this->fax).', '.
|
||||
'anmerkung='.$this->addslashes($this->anmerkung).', '.
|
||||
'updateamum= now(), '.
|
||||
'updatevon='.$this->addslashes($this->updatevon).', '.
|
||||
'firmentyp_kurzbz='.$this->addslashes($this->firmentyp_kurzbz).', '.
|
||||
'schule='.($this->schule?'true':'false').' '.
|
||||
'WHERE firma_id='.$this->addslashes($this->firma_id).';';
|
||||
}
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($this->new)
|
||||
{
|
||||
//Sequence lesen
|
||||
$qry="SELECT currval('public.tbl_firma_firma_id_seq') as id;";
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->firma_id = $row->id;
|
||||
$this->db_query('COMMIT');
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen der Sequence';
|
||||
$this->db_query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen der Sequence';
|
||||
$this->db_query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern des Firma-Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loescht den Datenensatz mit der ID die uebergeben wird
|
||||
* @param $firma_id ID die geloescht werden soll
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function delete($firma_id)
|
||||
{
|
||||
if(!is_numeric($firma_id))
|
||||
{
|
||||
$this->errormsg = 'Firma_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT * FROM public.tbl_firma WHERE firma_id='$firma_id'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Loeschen der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle Firmen
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$qry = "SElECT * FROM public.tbl_firma ORDER BY name";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$fa = new firma();
|
||||
|
||||
$fa->firma_id = $row->firma_id;
|
||||
$fa->name = $row->name;
|
||||
$fa->adresse = $row->adresse;
|
||||
$fa->email = $row->email;
|
||||
$fa->telefon = $row->telefon;
|
||||
$fa->fax = $row->fax;
|
||||
$fa->anmerkung = $row->anmerkung;
|
||||
$fa->firmentyp_kurzbz = $row->firmentyp_kurzbz;
|
||||
$fa->updateamum = $row->updateamum;
|
||||
$fa->updatevon = $row->updatevon;
|
||||
$fa->insertamum = $row->insertamum;
|
||||
$fa->insertvon = $row->insertvon;
|
||||
$fa->ext_id = $row->ext_id;
|
||||
$fa->schule = ($row->schule=='t'?true:false);
|
||||
$this->result[] = $fa;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert alle vorhandenen Firmentypen
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function getFirmenTypen()
|
||||
{
|
||||
$qry = "SELECT * FROM public.tbl_firmentyp ORDER BY firmentyp_kurzbz";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$fa = new firma();
|
||||
$fa->firmentyp_kurzbz = $row->firmentyp_kurzbz;
|
||||
$fa->beschreibung = $row->beschreibung;
|
||||
|
||||
$this->result[] = $fa;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen der Firmentypen';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle Firmen eines bestimmen Firmentyps
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function getFirmen($firmentyp_kurzbz='')
|
||||
{
|
||||
$qry = "SElECT * FROM public.tbl_firma";
|
||||
|
||||
if($firmentyp_kurzbz!='')
|
||||
$qry.=" WHERE firmentyp_kurzbz='".addslashes($firmentyp_kurzbz)."'";
|
||||
$qry.=" ORDER BY name";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$fa = new firma();
|
||||
|
||||
$fa->firma_id = $row->firma_id;
|
||||
$fa->name = $row->name;
|
||||
$fa->adresse = $row->adresse;
|
||||
$fa->email = $row->email;
|
||||
$fa->telefon = $row->telefon;
|
||||
$fa->fax = $row->fax;
|
||||
$fa->anmerkung = $row->anmerkung;
|
||||
$fa->firmentyp_kurzbz = $row->firmentyp_kurzbz;
|
||||
$fa->updateamum = $row->updateamum;
|
||||
$fa->updatevon = $row->updatevon;
|
||||
$fa->insertamum = $row->insertamum;
|
||||
$fa->insertvon = $row->insertvon;
|
||||
$fa->ext_id = $row->ext_id;
|
||||
$fa->schule = ($row->schule=='t'?true:false);
|
||||
$this->result[] = $fa;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
<?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> and.
|
||||
* Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at>.
|
||||
*/
|
||||
/**
|
||||
* Klasse firma
|
||||
* @create 18-12-2006
|
||||
*/
|
||||
require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
|
||||
class firma extends basis_db
|
||||
{
|
||||
public $new; // boolean
|
||||
public $result = array(); // adresse Objekt
|
||||
|
||||
//Tabellenspalten
|
||||
public $firma_id; // integer
|
||||
public $name; // string
|
||||
public $anmerkung; // string
|
||||
public $ext_id; // integer
|
||||
public $insertamum; // timestamp
|
||||
public $insertvon; // bigint
|
||||
public $updateamum; // timestamp
|
||||
public $updatevon; // bigint
|
||||
public $firmentyp_kurzbz;
|
||||
public $schule; // boolean
|
||||
// Neu in Rel. 2.0
|
||||
public $steuernummer; // string
|
||||
public $gesperrt; // boolean
|
||||
public $aktiv; // boolean
|
||||
public $finanzamt; // string
|
||||
|
||||
// firma_organisationseinheit
|
||||
public $oe_kurzbz; // string
|
||||
public $oe_parent_kurzbz; // string
|
||||
public $firma_organisationseinheit_id; // integer
|
||||
public $organisationseinheittyp_kurzbz; // string
|
||||
|
||||
public $bezeichnung; // string
|
||||
public $kundennummer; // integer
|
||||
public $oe_aktiv; // boolean
|
||||
public $mailverteiler; // string
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
* @param $firma_id ID der Firma die geladen werden soll (Default=null)
|
||||
*/
|
||||
public function __construct($firma_id=null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if(!is_null($firma_id))
|
||||
$this->load($firma_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt die Firma mit der ID $firma_id
|
||||
* @param $firma_id ID der zu ladenden Funktion
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function load($firma_id)
|
||||
{
|
||||
if(!is_numeric($firma_id))
|
||||
{
|
||||
$this->errormsg = 'Firma_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SElECT * FROM public.tbl_firma WHERE firma_id='$firma_id'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->firma_id = $row->firma_id;
|
||||
$this->name = $row->name;
|
||||
$this->anmerkung = $row->anmerkung;
|
||||
$this->firmentyp_kurzbz = $row->firmentyp_kurzbz;
|
||||
$this->updateamum = $row->updateamum;
|
||||
$this->updatevon = $row->updatevon;
|
||||
$this->insertamum = $row->insertamum;
|
||||
$this->insertvon = $row->insertvon;
|
||||
$this->ext_id = $row->ext_id;
|
||||
$this->schule = ($row->schule=='t'?true:false);
|
||||
// Neu in Rel. 2.0
|
||||
$this->steuernummer = $row->steuernummer;
|
||||
$this->gesperrt = ($row->gesperrt=='t'?true:false);
|
||||
$this->aktiv = ($row->aktiv=='t'?true:false);
|
||||
$this->finanzamt = $row->finanzamt;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Datensatz wurde nicht gefunden';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft die Variablen auf Gueltigkeit
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
protected function validate()
|
||||
{
|
||||
//Gesamtlaenge pruefen
|
||||
if(mb_strlen($this->name)>128)
|
||||
{
|
||||
$this->errormsg = 'Name darf nicht länger als 128 Zeichen sein';
|
||||
return false;
|
||||
}
|
||||
if(mb_strlen($this->anmerkung)>256)
|
||||
{
|
||||
$this->errormsg = 'Anmerkung darf nicht länger als 256 Zeichen sein';
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->errormsg = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert den aktuellen Datensatz in die Datenbank
|
||||
* Wenn $neu auf true gesetzt ist wird ein neuer Datensatz angelegt
|
||||
* andernfalls wird der Datensatz mit der ID in $firma_id aktualisiert
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
//Variablen pruefen
|
||||
if(!$this->validate())
|
||||
return false;
|
||||
|
||||
if($this->new)
|
||||
{
|
||||
//Neuen Datensatz einfuegen
|
||||
$qry='INSERT INTO public.tbl_firma (name, anmerkung,
|
||||
firmentyp_kurzbz, updateamum, updatevon, insertamum, insertvon, ext_id, schule,steuernummer,
|
||||
gesperrt,aktiv,finanzamt) VALUES('.
|
||||
$this->addslashes($this->name).', '.
|
||||
$this->addslashes($this->anmerkung).', '.
|
||||
$this->addslashes($this->firmentyp_kurzbz).', '.
|
||||
$this->addslashes($this->updateamum).', '.
|
||||
$this->addslashes($this->updatevon).', '.
|
||||
$this->addslashes($this->insertamum).', '.
|
||||
$this->addslashes($this->insertvon).', '.
|
||||
$this->addslashes($this->ext_id).','.
|
||||
($this->schule?'true':'false').','.
|
||||
$this->addslashes($this->steuernummer).', '.
|
||||
($this->gesperrt?'true':'false').','.
|
||||
($this->aktiv?'true':'false').','.
|
||||
($this->finanzamt?$this->addslashes($this->finanzamt):'null').' ); ';
|
||||
}
|
||||
else
|
||||
{
|
||||
//Updaten des bestehenden Datensatzes
|
||||
|
||||
//Pruefen ob firma_id eine gueltige Zahl ist
|
||||
if(!is_numeric($this->firma_id))
|
||||
{
|
||||
$this->errormsg = 'firma_id muss eine gueltige Zahl sein';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry='UPDATE public.tbl_firma SET '.
|
||||
'firma_id='.$this->addslashes($this->firma_id).', '.
|
||||
'name='.$this->addslashes($this->name).', '.
|
||||
'anmerkung='.$this->addslashes($this->anmerkung).', '.
|
||||
'updateamum= now(), '.
|
||||
'updatevon='.$this->addslashes($this->updatevon).', '.
|
||||
'firmentyp_kurzbz='.$this->addslashes($this->firmentyp_kurzbz).', '.
|
||||
'schule='.($this->schule?'true':'false').', '.
|
||||
'steuernummer='.$this->addslashes($this->steuernummer).', '.
|
||||
'gesperrt='.($this->gesperrt?'true':'false').', '.
|
||||
'aktiv='.($this->aktiv?'true':'false').', '.
|
||||
'finanzamt='.($this->finanzamt?addslashes($this->finanzamt):'null').' '.
|
||||
'WHERE firma_id='.$this->addslashes($this->firma_id).';';
|
||||
}
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($this->new)
|
||||
{
|
||||
//Sequence lesen
|
||||
$qry="SELECT currval('public.tbl_firma_firma_id_seq') as id;";
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->firma_id = $row->id;
|
||||
$this->db_query('COMMIT');
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen der Sequence';
|
||||
$this->db_query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen der Sequence';
|
||||
$this->db_query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern des Firma-Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loescht den Datenensatz mit der ID die uebergeben wird
|
||||
* @param $firma_id ID die geloescht werden soll
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function delete($firma_id)
|
||||
{
|
||||
if(!is_numeric($firma_id))
|
||||
{
|
||||
$this->errormsg = 'Firma_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT * FROM public.tbl_firma WHERE firma_id='$firma_id'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Loeschen der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle Firmen
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$qry = "SElECT * FROM public.tbl_firma ORDER BY name";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$fa = new firma();
|
||||
|
||||
$fa->firma_id = $row->firma_id;
|
||||
$fa->name = $row->name;
|
||||
$fa->anmerkung = $row->anmerkung;
|
||||
$fa->firmentyp_kurzbz = $row->firmentyp_kurzbz;
|
||||
$fa->updateamum = $row->updateamum;
|
||||
$fa->updatevon = $row->updatevon;
|
||||
$fa->insertamum = $row->insertamum;
|
||||
$fa->insertvon = $row->insertvon;
|
||||
$fa->ext_id = $row->ext_id;
|
||||
$fa->schule = ($row->schule=='t'?true:false);
|
||||
// Neu in Rel. 2.0
|
||||
$fa->steuernummer = $row->steuernummer;
|
||||
$fa->gesperrt = ($row->gesperrt=='t'?true:false);
|
||||
$fa->aktiv = ($row->aktiv=='t'?true:false);
|
||||
$fa->finanzamt = $row->finanzamt;
|
||||
|
||||
$this->result[] = $fa;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert alle vorhandenen Firmentypen
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function getFirmenTypen()
|
||||
{
|
||||
$qry = "SELECT * FROM public.tbl_firmentyp ORDER BY firmentyp_kurzbz";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$fa = new firma();
|
||||
$fa->firmentyp_kurzbz = $row->firmentyp_kurzbz;
|
||||
$fa->beschreibung = $row->beschreibung;
|
||||
|
||||
$this->result[] = $fa;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen der Firmentypen';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle Firmen eines bestimmen Firmentyps
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function getFirmen($firmentyp_kurzbz='')
|
||||
{
|
||||
$qry = "SElECT * FROM public.tbl_firma";
|
||||
|
||||
if($firmentyp_kurzbz!='')
|
||||
$qry.=" WHERE firmentyp_kurzbz='".addslashes($firmentyp_kurzbz)."'";
|
||||
$qry.=" ORDER BY name";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$fa = new firma();
|
||||
|
||||
$fa->firma_id = $row->firma_id;
|
||||
$fa->name = $row->name;
|
||||
$fa->anmerkung = $row->anmerkung;
|
||||
$fa->firmentyp_kurzbz = $row->firmentyp_kurzbz;
|
||||
$fa->updateamum = $row->updateamum;
|
||||
$fa->updatevon = $row->updatevon;
|
||||
$fa->insertamum = $row->insertamum;
|
||||
$fa->insertvon = $row->insertvon;
|
||||
$fa->ext_id = $row->ext_id;
|
||||
$fa->schule = ($row->schule=='t'?true:false);
|
||||
// Neu in Rel. 2.0
|
||||
$fa->steuernummer = $row->steuernummer;
|
||||
$fa->gesperrt = ($row->gesperrt=='t'?true:false);
|
||||
$fa->aktiv = ($row->aktiv=='t'?true:false);
|
||||
$fa->finanzamt = $row->finanzamt;
|
||||
|
||||
$this->result[] = $fa;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle Firmen Standorte, und Adressen nach Suchstring und/oder eines bestimmen Firmentyps
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function searchFirma($filter='',$firmentyp_kurzbz='')
|
||||
{
|
||||
$this->result = array();
|
||||
$this->errormsg = '';
|
||||
|
||||
$qry =" SElECT tbl_firma.* ";
|
||||
$qry.=" ,tbl_standort.kurzbz,tbl_standort.adresse_id,tbl_standort.standort_id,tbl_standort.bezeichnung ";
|
||||
$qry.=" ,person_id, tbl_adresse.name as adress_name, strasse, plz, ort, gemeinde,nation,typ,heimatadresse,zustelladresse ";
|
||||
$qry.=" FROM public.tbl_firma, public.tbl_standort ";
|
||||
$qry.=" left outer join public.tbl_adresse on ( tbl_adresse.adresse_id=tbl_standort.adresse_id ) ";
|
||||
$qry.=" WHERE tbl_standort.firma_id=tbl_firma.firma_id ";
|
||||
|
||||
if($filter!='')
|
||||
$qry.= " and ( lower(tbl_firma.name) like lower('%$filter%')
|
||||
OR lower(kurzbz) like lower('%$filter%')
|
||||
|
||||
OR lower(tbl_adresse.name) like lower('%$filter%')
|
||||
OR lower(plz) like lower('%$filter%')
|
||||
OR lower(ort) like lower('%$filter%')
|
||||
OR lower(strasse) like lower('%$filter%')
|
||||
|
||||
OR lower(bezeichnung) like lower('%$filter%')
|
||||
OR lower(anmerkung) like lower('%$filter%')
|
||||
".(is_numeric($filter)?" OR tbl_firma.firma_id='$filter'":'')."
|
||||
) ";
|
||||
|
||||
if($firmentyp_kurzbz!='')
|
||||
$qry.=" and firmentyp_kurzbz='".addslashes($firmentyp_kurzbz)."'";
|
||||
$qry.=" ORDER BY name ";
|
||||
if($filter=='' && $firmentyp_kurzbz=='')
|
||||
$qry.=" limit 500 ";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$fa = new firma();
|
||||
|
||||
$fa->firma_id = $row->firma_id;
|
||||
$fa->name = $row->name;
|
||||
$fa->anmerkung = $row->anmerkung;
|
||||
$fa->firmentyp_kurzbz = $row->firmentyp_kurzbz;
|
||||
$fa->updateamum = $row->updateamum;
|
||||
$fa->updatevon = $row->updatevon;
|
||||
$fa->insertamum = $row->insertamum;
|
||||
$fa->insertvon = $row->insertvon;
|
||||
$fa->ext_id = $row->ext_id;
|
||||
$fa->schule = ($row->schule=='t'?true:false);
|
||||
// Neu in Rel. 2.0
|
||||
$fa->steuernummer = $row->steuernummer;
|
||||
$fa->gesperrt = ($row->gesperrt=='t'?true:false);
|
||||
$fa->aktiv = ($row->aktiv=='t'?true:false);
|
||||
$fa->finanzamt = $row->finanzamt;
|
||||
|
||||
// Standort
|
||||
$fa->kurzbz = $row->kurzbz;
|
||||
$fa->adresse_id = $row->adresse_id;
|
||||
$fa->standort_id = $row->standort_id;
|
||||
$fa->bezeichnung = $row->bezeichnung;
|
||||
// Adresse
|
||||
$fa->person_id = $row->person_id;
|
||||
$fa->adresse_id = $row->adresse_id;
|
||||
$fa->strasse = $row->strasse;
|
||||
$fa->plz = $row->plz;
|
||||
$fa->ort = $row->ort;
|
||||
$fa->gemeinde = $row->gemeinde;
|
||||
$fa->nation = $row->nation;
|
||||
$fa->typ = $row->typ;
|
||||
$fa->adress_name = $row->adress_name;
|
||||
$fa->heimatadresse = ($row->heimatadresse=='t'?true:false);
|
||||
$fa->zustelladresse = ($row->zustelladresse=='t'?true:false);
|
||||
|
||||
$this->result[] = $fa;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle Firmen - Organisationseinheiten nach Firmen ID und/oder OE Kurzbz und/oder Zwischentabellen ID
|
||||
* @param $firma_id ID die gelesen werden soll
|
||||
* @param $oe_kurzbz Organisationskurzbezeichnung
|
||||
* @param $firma_organisationseinheit_id Zwischentabellen ID
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function load_firmaorganisationseinheit($firma_id='',$oe_kurzbz='',$firma_organisationseinheit_id='')
|
||||
{
|
||||
$this->result = array();
|
||||
$this->errormsg = '';
|
||||
if($firma_id && !is_numeric($firma_id))
|
||||
{
|
||||
$this->errormsg = 'Firma_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry =" select tbl_firma.* ";
|
||||
|
||||
$qry.=", tbl_firma_organisationseinheit.firma_organisationseinheit_id ,tbl_firma_organisationseinheit.kundennummer ,tbl_firma_organisationseinheit.oe_kurzbz ";
|
||||
|
||||
$qry.=" ,tbl_organisationseinheit.oe_parent_kurzbz,tbl_organisationseinheit.bezeichnung,tbl_organisationseinheit.bezeichnung ,tbl_organisationseinheit.organisationseinheittyp_kurzbz,tbl_organisationseinheit.aktiv as oe_aktiv,tbl_organisationseinheit.mailverteiler ";
|
||||
|
||||
$qry.=" FROM public.tbl_firma, public.tbl_firma_organisationseinheit ";
|
||||
$qry.=" left outer join public.tbl_organisationseinheit on ( tbl_organisationseinheit.oe_kurzbz=tbl_firma_organisationseinheit.oe_kurzbz ) ";
|
||||
$qry.=" WHERE tbl_firma.firma_id=tbl_firma_organisationseinheit.firma_id ";
|
||||
|
||||
|
||||
if($firma_organisationseinheit_id!='')
|
||||
$qry.=" and tbl_firma_organisationseinheit.firma_organisationseinheit_id='".addslashes($firma_organisationseinheit_id)."'";
|
||||
if($firma_id!='')
|
||||
$qry.=" and tbl_firma_organisationseinheit.firma_id='".addslashes($firma_id)."'";
|
||||
if($oe_kurzbz!='')
|
||||
$qry.=" and tbl_firma_organisationseinheit.oe_kurzbz='".addslashes($oe_kurzbz)."'";
|
||||
|
||||
$qry.=" ORDER BY tbl_firma_organisationseinheit.oe_kurzbz ";
|
||||
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$fa = new firma();
|
||||
|
||||
$fa->firma_id = $row->firma_id;
|
||||
$fa->name = $row->name;
|
||||
$fa->anmerkung = $row->anmerkung;
|
||||
$fa->firmentyp_kurzbz = $row->firmentyp_kurzbz;
|
||||
$fa->updateamum = $row->updateamum;
|
||||
$fa->updatevon = $row->updatevon;
|
||||
$fa->insertamum = $row->insertamum;
|
||||
$fa->insertvon = $row->insertvon;
|
||||
$fa->ext_id = $row->ext_id;
|
||||
$fa->schule = ($row->schule=='t'?true:false);
|
||||
// Neu in Rel. 2.0
|
||||
$fa->steuernummer = $row->steuernummer;
|
||||
$fa->gesperrt = ($row->gesperrt=='t'?true:false);
|
||||
$fa->aktiv = ($row->aktiv=='t'?true:false);
|
||||
$fa->finanzamt = $row->finanzamt;
|
||||
// firma_organisationseinheit
|
||||
$fa->oe_kurzbz = $row->oe_kurzbz;
|
||||
// organisationseinheit
|
||||
$fa->firma_organisationseinheit_id = $row->firma_organisationseinheit_id;
|
||||
$fa->oe_parent_kurzbz = $row->oe_parent_kurzbz;
|
||||
$fa->organisationseinheittyp_kurzbz = $row->organisationseinheittyp_kurzbz;
|
||||
$fa->bezeichnung = $row->bezeichnung;
|
||||
$fa->kundennummer = $row->kundennummer;
|
||||
|
||||
$fa->oe_aktiv = $row->oe_aktiv;
|
||||
$fa->mailverteiler = $row->mailverteiler;
|
||||
|
||||
$this->result[] = $fa;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
+407
-332
@@ -1,333 +1,408 @@
|
||||
<?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 kontakt
|
||||
* @create 20-12-2006
|
||||
*/
|
||||
require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
|
||||
class kontakt extends basis_db
|
||||
{
|
||||
public $new; // boolean
|
||||
public $result = array(); // adresse Objekt
|
||||
|
||||
//Tabellenspalten
|
||||
public $kontakt_id; // integer
|
||||
public $person_id; // integer
|
||||
public $firma_id; // integer
|
||||
public $kontakttyp; // string
|
||||
public $anmerkung; // string
|
||||
public $kontakt; // string
|
||||
public $zustellung; // boolean
|
||||
public $ext_id; // integer
|
||||
public $insertamum; // timestamp
|
||||
public $insertvon; // bigint
|
||||
public $updateamum; // timestamp
|
||||
public $updatevon; // bigint
|
||||
|
||||
public $beschreibung;
|
||||
public $firma_name;
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
* @param $kontakt_id ID der Adresse die geladen werden soll (Default=null)
|
||||
*/
|
||||
public function __construct($kontakt_id=null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if(!is_null($kontakt_id))
|
||||
$this->load($kontakt_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt einen Kontakt mit der ID $kontakt_id
|
||||
* @param $kontakt_id ID des zu ladenden Kontaktes
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function load($kontakt_id)
|
||||
{
|
||||
if(!is_numeric($kontakt_id))
|
||||
{
|
||||
$this->errormsg = 'Kontakt_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT tbl_kontakt.*, tbl_firma.name as firma_name
|
||||
FROM public.tbl_kontakt LEFT JOIN public.tbl_firma USING(firma_id) WHERE kontakt_id='$kontakt_id'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->kontakt_id = $row->kontakt_id;
|
||||
$this->person_id = $row->person_id;
|
||||
$this->firma_id = $row->firma_id;
|
||||
$this->firma_name = $row->firma_name;
|
||||
$this->kontakttyp = $row->kontakttyp;
|
||||
$this->anmerkung = $row->anmerkung;
|
||||
$this->kontakt = $row->kontakt;
|
||||
$this->zustellung = ($row->zustellung=='t'?true:false);
|
||||
$this->updateamum = $row->updateamum;
|
||||
$this->updatevon = $row->updatevon;
|
||||
$this->insertamum = $row->insertamum;
|
||||
$this->insertvon = $row->insertvon;
|
||||
$this->ext_id = $row->ext_id;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Datensatz wurde nicht gefunden';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft die Variablen auf Gueltigkeit
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
|
||||
//Gesamtlaenge pruefen
|
||||
//$this->errormsg='Eine der Gesamtlaengen wurde ueberschritten';
|
||||
if(mb_strlen($this->kontakttyp)>32)
|
||||
{
|
||||
$this->errormsg = 'kontakttyp darf nicht länger als 32 Zeichen sein';
|
||||
return false;
|
||||
}
|
||||
if(mb_strlen($this->anmerkung)>64)
|
||||
{
|
||||
$this->errormsg = 'anmerkung darf nicht länger als 64 Zeichen sein';
|
||||
return false;
|
||||
}
|
||||
if(mb_strlen($this->kontakt)>128)
|
||||
{
|
||||
$this->errormsg = 'kontakt darf nicht länger als 128 Zeichen sein';
|
||||
return false;
|
||||
}
|
||||
if($this->kontakttyp=='email' && !strstr($this->kontakt, '@'))
|
||||
{
|
||||
$this->errormsg = 'Wenn der Typ E-Mail ausgewählt wurde, muss der Kontakt ein @ enthalten!';
|
||||
return false;
|
||||
}
|
||||
$this->errormsg = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert den aktuellen Datensatz in die Datenbank
|
||||
* Wenn $neu auf true gesetzt ist wird ein neuer Datensatz angelegt
|
||||
* andernfalls wird der Datensatz mit der ID in $kontakt_id aktualisiert
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
//Variablen pruefen
|
||||
if(!$this->validate())
|
||||
return false;
|
||||
|
||||
if($this->new)
|
||||
{
|
||||
//Neuen Datensatz einfuegen
|
||||
|
||||
$qry='BEGIN;INSERT INTO public.tbl_kontakt (person_id, firma_id, kontakttyp, anmerkung, kontakt, zustellung, ext_id, insertamum, insertvon, updateamum, updatevon) VALUES('.
|
||||
$this->addslashes($this->person_id).', '.
|
||||
$this->addslashes($this->firma_id).', '.
|
||||
$this->addslashes($this->kontakttyp).', '.
|
||||
$this->addslashes($this->anmerkung).', '.
|
||||
$this->addslashes($this->kontakt).', '.
|
||||
($this->zustellung?'true':'false').', '.
|
||||
$this->addslashes($this->ext_id).', now(), '.
|
||||
$this->addslashes($this->insertvon).', now(), '.
|
||||
$this->addslashes($this->updatevon).');';
|
||||
}
|
||||
else
|
||||
{
|
||||
//Updaten des bestehenden Datensatzes
|
||||
|
||||
//Pruefen ob kontakt_id eine gueltige Zahl ist
|
||||
if(!is_numeric($this->kontakt_id))
|
||||
{
|
||||
$this->errormsg = 'kontakt_id muss eine gueltige Zahl sein';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry='UPDATE public.tbl_kontakt SET '.
|
||||
'person_id='.$this->addslashes($this->person_id).', '.
|
||||
'firma_id='.$this->addslashes($this->firma_id).', '.
|
||||
'kontakttyp='.$this->addslashes($this->kontakttyp).', '.
|
||||
'anmerkung='.$this->addslashes($this->anmerkung).', '.
|
||||
'kontakt='.$this->addslashes($this->kontakt).', '.
|
||||
'zustellung='.($this->zustellung?'true':'false').', '.
|
||||
'ext_id='.$this->addslashes($this->ext_id).', '.
|
||||
'updateamum= now(), '.
|
||||
'updatevon='.$this->addslashes($this->updatevon).' '.
|
||||
'WHERE kontakt_id='.$this->addslashes($this->kontakt_id).';';
|
||||
}
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
//Sequence auslesen um die eingefuegte ID zu ermitteln
|
||||
if($this->new)
|
||||
{
|
||||
$qry = "SELECT currval('public.tbl_kontakt_kontakt_id_seq') as id";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->kontakt_id = $row->id;
|
||||
$this->db_query('COMMIT');
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen er Sequence';
|
||||
$this->db_query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen der Sequence';
|
||||
$this->db_query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loescht den Datenensatz mit der ID die uebergeben wird
|
||||
* @param $kontakt_id ID die geloescht werden soll
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function delete($kontakt_id)
|
||||
{
|
||||
if(!is_numeric($kontakt_id))
|
||||
{
|
||||
$this->errormsg = 'Kontakt_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "DELETE FROM public.tbl_kontakt WHERE kontakt_id='$kontakt_id'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Loeschen der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle Kontaktdaten einer Person
|
||||
* @param person_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function load_pers($person_id)
|
||||
{
|
||||
if(!is_numeric($person_id))
|
||||
{
|
||||
$this->errormsg = 'Person_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT tbl_kontakt.*, tbl_firma.name as firma_name
|
||||
FROM public.tbl_kontakt LEFT JOIN public.tbl_firma USING(firma_id) WHERE person_id='$person_id'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$obj = new kontakt();
|
||||
|
||||
$obj->kontakt_id = $row->kontakt_id;
|
||||
$obj->person_id = $row->person_id;
|
||||
$obj->firma_id = $row->firma_id;
|
||||
$obj->firma_name = $row->firma_name;
|
||||
$obj->kontakttyp = $row->kontakttyp;
|
||||
$obj->anmerkung = $row->anmerkung;
|
||||
$obj->kontakt = $row->kontakt;
|
||||
$obj->zustellung = ($row->zustellung=='t'?true:false);
|
||||
$obj->updateamum = $row->updateamum;
|
||||
$obj->updatevon = $row->updatevon;
|
||||
$obj->insertamum = $row->insertamum;
|
||||
$obj->insertvon = $row->insertvon;
|
||||
$obj->ext_id = $row->ext_id;
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle Kontakttypen
|
||||
* @return true wenn ok
|
||||
* false im Fehlerfall
|
||||
*/
|
||||
public function getKontakttyp()
|
||||
{
|
||||
$qry = "SELECT * FROM public.tbl_kontakttyp ORDER BY beschreibung";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$obj = new kontakt();
|
||||
|
||||
$obj->kontakttyp = $row->kontakttyp;
|
||||
$obj->beschreibung = $row->beschreibung;
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
<?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 kontakt
|
||||
* @create 20-12-2006
|
||||
*/
|
||||
require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
|
||||
class kontakt extends basis_db
|
||||
{
|
||||
public $new; // boolean
|
||||
public $result = array(); // adresse Objekt
|
||||
|
||||
//Tabellenspalten
|
||||
public $kontakt_id; // integer
|
||||
public $person_id; // integer
|
||||
public $firma_id; // integer
|
||||
public $standort_id; // integer
|
||||
|
||||
public $kontakttyp; // string
|
||||
public $anmerkung; // string
|
||||
public $kontakt; // string
|
||||
public $zustellung; // boolean
|
||||
public $ext_id; // integer
|
||||
public $insertamum; // timestamp
|
||||
public $insertvon; // bigint
|
||||
public $updateamum; // timestamp
|
||||
public $updatevon; // bigint
|
||||
|
||||
public $beschreibung;
|
||||
public $firma_name;
|
||||
|
||||
|
||||
public $anrede;
|
||||
public $titelpost;
|
||||
public $titelpre;
|
||||
public $nachname;
|
||||
public $vorname;
|
||||
public $vornamen;
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
* @param $kontakt_id ID der Adresse die geladen werden soll (Default=null)
|
||||
*/
|
||||
public function __construct($kontakt_id=null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if(!is_null($kontakt_id))
|
||||
$this->load($kontakt_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt einen Kontakt mit der ID $kontakt_id
|
||||
* @param $kontakt_id ID des zu ladenden Kontaktes
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function load($kontakt_id)
|
||||
{
|
||||
if(!is_numeric($kontakt_id))
|
||||
{
|
||||
$this->errormsg = 'Kontakt_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT tbl_kontakt.*, tbl_firma.name as firma_name
|
||||
FROM public.tbl_kontakt LEFT JOIN public.tbl_firma USING(firma_id) WHERE kontakt_id='$kontakt_id'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->kontakt_id = $row->kontakt_id;
|
||||
$this->person_id = $row->person_id;
|
||||
$this->standort_id = $row->standort_id;
|
||||
$this->firma_id = $row->firma_id;
|
||||
$this->firma_name = $row->firma_name;
|
||||
$this->kontakttyp = $row->kontakttyp;
|
||||
$this->anmerkung = $row->anmerkung;
|
||||
$this->kontakt = $row->kontakt;
|
||||
$this->zustellung = ($row->zustellung=='t'?true:false);
|
||||
$this->updateamum = $row->updateamum;
|
||||
$this->updatevon = $row->updatevon;
|
||||
$this->insertamum = $row->insertamum;
|
||||
$this->insertvon = $row->insertvon;
|
||||
$this->ext_id = $row->ext_id;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Datensatz wurde nicht gefunden';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft die Variablen auf Gueltigkeit
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
|
||||
//Gesamtlaenge pruefen
|
||||
//$this->errormsg='Eine der Gesamtlaengen wurde ueberschritten';
|
||||
if(mb_strlen($this->kontakttyp)>32)
|
||||
{
|
||||
$this->errormsg = 'kontakttyp darf nicht länger als 32 Zeichen sein';
|
||||
return false;
|
||||
}
|
||||
if(mb_strlen($this->anmerkung)>64)
|
||||
{
|
||||
$this->errormsg = 'anmerkung darf nicht länger als 64 Zeichen sein';
|
||||
return false;
|
||||
}
|
||||
if(mb_strlen($this->kontakt)>128)
|
||||
{
|
||||
$this->errormsg = 'kontakt darf nicht länger als 128 Zeichen sein';
|
||||
return false;
|
||||
}
|
||||
if($this->kontakttyp=='email' && !strstr($this->kontakt, '@'))
|
||||
{
|
||||
$this->errormsg = 'Wenn der Typ E-Mail ausgewählt wurde, muss der Kontakt ein @ enthalten!';
|
||||
return false;
|
||||
}
|
||||
$this->errormsg = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert den aktuellen Datensatz in die Datenbank
|
||||
* Wenn $neu auf true gesetzt ist wird ein neuer Datensatz angelegt
|
||||
* andernfalls wird der Datensatz mit der ID in $kontakt_id aktualisiert
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
//Variablen pruefen
|
||||
if(!$this->validate())
|
||||
return false;
|
||||
|
||||
if($this->new)
|
||||
{
|
||||
//Neuen Datensatz einfuegen
|
||||
$qry='BEGIN;INSERT INTO public.tbl_kontakt (person_id, firma_id,standort_id, kontakttyp, anmerkung, kontakt, zustellung, ext_id, insertamum, insertvon, updateamum, updatevon) VALUES('.
|
||||
$this->addslashes($this->person_id).', '.
|
||||
$this->addslashes($this->firma_id).', '.
|
||||
$this->addslashes($this->standort_id).', '.
|
||||
$this->addslashes($this->kontakttyp).', '.
|
||||
$this->addslashes($this->anmerkung).', '.
|
||||
$this->addslashes($this->kontakt).', '.
|
||||
($this->zustellung?'true':'false').', '.
|
||||
$this->addslashes($this->ext_id).', now(), '.
|
||||
$this->addslashes($this->insertvon).', now(), '.
|
||||
$this->addslashes($this->updatevon).');';
|
||||
}
|
||||
else
|
||||
{
|
||||
//Updaten des bestehenden Datensatzes
|
||||
|
||||
//Pruefen ob kontakt_id eine gueltige Zahl ist
|
||||
if(!is_numeric($this->kontakt_id))
|
||||
{
|
||||
$this->errormsg = 'kontakt_id muss eine gueltige Zahl sein';
|
||||
return false;
|
||||
}
|
||||
$qry='UPDATE public.tbl_kontakt SET '.
|
||||
'person_id='.$this->addslashes($this->person_id).', '.
|
||||
'firma_id='.$this->addslashes($this->firma_id).', '.
|
||||
'standort_id='.$this->addslashes($this->standort_id).', '.
|
||||
'kontakttyp='.$this->addslashes($this->kontakttyp).', '.
|
||||
'anmerkung='.$this->addslashes($this->anmerkung).', '.
|
||||
'kontakt='.$this->addslashes($this->kontakt).', '.
|
||||
'zustellung='.($this->zustellung?'true':'false').', '.
|
||||
'ext_id='.$this->addslashes($this->ext_id).', '.
|
||||
'updateamum= now(), '.
|
||||
'updatevon='.$this->addslashes($this->updatevon).' '.
|
||||
'WHERE kontakt_id='.$this->addslashes($this->kontakt_id).';';
|
||||
}
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
//Sequence auslesen um die eingefuegte ID zu ermitteln
|
||||
if($this->new)
|
||||
{
|
||||
$qry = "SELECT currval('public.tbl_kontakt_kontakt_id_seq') as id";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->kontakt_id = $row->id;
|
||||
$this->db_query('COMMIT');
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen er Sequence';
|
||||
$this->db_query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen der Sequence';
|
||||
$this->db_query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loescht den Datenensatz mit der ID die uebergeben wird
|
||||
* @param $kontakt_id ID die geloescht werden soll
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function delete($kontakt_id)
|
||||
{
|
||||
if(!is_numeric($kontakt_id))
|
||||
{
|
||||
$this->errormsg = 'Kontakt_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "DELETE FROM public.tbl_kontakt WHERE kontakt_id='$kontakt_id'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Loeschen der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle Kontaktdaten einer Person
|
||||
* @param person_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function load_pers($person_id)
|
||||
{
|
||||
if(!is_numeric($person_id))
|
||||
{
|
||||
$this->errormsg = 'Person_id ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT tbl_kontakt.*, tbl_firma.name as firma_name
|
||||
FROM public.tbl_kontakt LEFT JOIN public.tbl_firma USING(firma_id) WHERE person_id='$person_id'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$obj = new kontakt();
|
||||
|
||||
$obj->kontakt_id = $row->kontakt_id;
|
||||
$obj->person_id = $row->person_id;
|
||||
$obj->standort_id = $row->standort_id;
|
||||
$obj->firma_id = $row->firma_id;
|
||||
$obj->firma_name = $row->firma_name;
|
||||
$obj->kontakttyp = $row->kontakttyp;
|
||||
$obj->anmerkung = $row->anmerkung;
|
||||
$obj->kontakt = $row->kontakt;
|
||||
$obj->zustellung = ($row->zustellung=='t'?true:false);
|
||||
$obj->updateamum = $row->updateamum;
|
||||
$obj->updatevon = $row->updatevon;
|
||||
$obj->insertamum = $row->insertamum;
|
||||
$obj->insertvon = $row->insertvon;
|
||||
$obj->ext_id = $row->ext_id;
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Laedt alle Kontaktdaten zu einem Standort
|
||||
* @param standort_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function load_standort($standort_id='',$firma_id='')
|
||||
{
|
||||
if(!is_numeric($standort_id))
|
||||
{
|
||||
$this->errormsg = 'Standort ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT tbl_kontakt.*, tbl_standort.kurzbz as standort_kurzbz, tbl_standort.bezeichnung as standort_bezeichnung
|
||||
,tbl_person.anrede,tbl_person.titelpost,tbl_person.titelpre,tbl_person.nachname,tbl_person.vorname,tbl_person.vornamen
|
||||
FROM public.tbl_kontakt
|
||||
LEFT JOIN public.tbl_standort USING(standort_id,firma_id)
|
||||
LEFT JOIN public.tbl_person USING(person_id)
|
||||
WHERE standort_id>0
|
||||
";
|
||||
if(is_numeric($standort_id))
|
||||
$qry.=" and standort_id='".addslashes($standort_id)."'";
|
||||
if(is_numeric($firma_id))
|
||||
$qry.=" and tbl_kontakt.firma_id='".addslashes($firma_id)."'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$obj = new kontakt();
|
||||
|
||||
$obj->kontakt_id = $row->kontakt_id;
|
||||
$obj->person_id = $row->person_id;
|
||||
$obj->standort_id = $row->standort_id;
|
||||
$obj->firma_id = $row->firma_id;
|
||||
$obj->standort_kurzbz = $row->standort_kurzbz;
|
||||
$obj->standort_bezeichnung = $row->standort_bezeichnung;
|
||||
$obj->kontakttyp = $row->kontakttyp;
|
||||
$obj->anmerkung = $row->anmerkung;
|
||||
$obj->kontakt = $row->kontakt;
|
||||
$obj->zustellung = ($row->zustellung=='t'?true:false);
|
||||
$obj->updateamum = $row->updateamum;
|
||||
$obj->updatevon = $row->updatevon;
|
||||
$obj->insertamum = $row->insertamum;
|
||||
$obj->insertvon = $row->insertvon;
|
||||
$obj->ext_id = $row->ext_id;
|
||||
$obj->anrede=$row->anrede;
|
||||
$obj->titelpost=$row->titelpost;
|
||||
$obj->titelpre=$row->titelpre;
|
||||
$obj->nachname=$row->nachname;
|
||||
$obj->vorname=$row->vorname;
|
||||
$obj->vornamen=$row->vornamen;
|
||||
$this->result[] = $row;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle Kontakttypen
|
||||
* @return true wenn ok
|
||||
* false im Fehlerfall
|
||||
*/
|
||||
public function getKontakttyp()
|
||||
{
|
||||
$qry = "SELECT * FROM public.tbl_kontakttyp ORDER BY beschreibung";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$obj = new kontakt();
|
||||
|
||||
$obj->kontakttyp = $row->kontakttyp;
|
||||
$obj->beschreibung = $row->beschreibung;
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1566,6 +1566,7 @@ class moodle_course extends basis_db
|
||||
}
|
||||
}
|
||||
}
|
||||
var_dump($courses);
|
||||
return $courses;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class ort extends basis_db
|
||||
public $kosten; // numeric(8,2)
|
||||
public $ausstattung;
|
||||
public $stockwerk; // integer
|
||||
public $standort_kurzbz; // varchar(16)
|
||||
public $standort_id; // varchar(16)
|
||||
public $telefonklappe; // varchar(8)
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ class ort extends basis_db
|
||||
$ort_obj->reservieren = ($row->reservieren=='t'?true:false);
|
||||
$ort_obj->ausstattung = $row->ausstattung;
|
||||
$ort_obj->stockwerk = $row->stockwerk;
|
||||
$ort_obj->standort_kurzbz = $row->standort_kurzbz;
|
||||
$ort_obj->standort_id = $row->standort_id;
|
||||
$ort_obj->telefonklappe = $row->telefonklappe;
|
||||
|
||||
$this->result[] = $ort_obj;
|
||||
@@ -110,7 +110,7 @@ class ort extends basis_db
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT * FROM public.tbl_ort WHERE ort_kurzbz = '".addslashes($ort_kurzbz)."';";
|
||||
$qry = "SELECT * FROM public.tbl_ort WHERE trim(ort_kurzbz) = '".addslashes(trim($ort_kurzbz))."';";
|
||||
|
||||
if(!$this->db_query($qry))
|
||||
{
|
||||
@@ -132,7 +132,7 @@ class ort extends basis_db
|
||||
$this->reservieren = ($row->reservieren=='t'?true:false);
|
||||
$this->ausstattung = $row->ausstattung;
|
||||
$this->stockwerk = $row->stockwerk;
|
||||
$this->standort_kurzbz = $row->standort_kurzbz;
|
||||
$this->standort_id = $row->standort_id;
|
||||
$this->telefonklappe = $row->telefonklappe;
|
||||
}
|
||||
else
|
||||
@@ -189,7 +189,7 @@ class ort extends basis_db
|
||||
{
|
||||
//Neuen Datensatz anlegen
|
||||
$qry = 'INSERT INTO public.tbl_ort (ort_kurzbz, bezeichnung, planbezeichnung, max_person, aktiv, lehre, reservieren, lageplan,
|
||||
dislozierung, kosten, stockwerk, standort_kurzbz, telefonklappe) VALUES ('.
|
||||
dislozierung, kosten, stockwerk, standort_id, telefonklappe) VALUES ('.
|
||||
$this->addslashes($this->ort_kurzbz).', '.
|
||||
$this->addslashes($this->bezeichnung).', '.
|
||||
$this->addslashes($this->planbezeichnung).', '.
|
||||
@@ -201,7 +201,7 @@ class ort extends basis_db
|
||||
$this->addslashes($this->dislozierung).', '.
|
||||
$this->addslashes(str_replace(",",".",$this->kosten)).', '.
|
||||
$this->addslashes($this->stockwerk).','.
|
||||
$this->addslashes($this->standort_kurzbz).','.
|
||||
$this->addslashes($this->standort_id).','.
|
||||
$this->addslashes($this->telefonklappe).');';
|
||||
}
|
||||
else
|
||||
@@ -218,7 +218,7 @@ class ort extends basis_db
|
||||
'lageplan='.$this->addslashes($this->lageplan).', '.
|
||||
'dislozierung='.$this->addslashes($this->dislozierung).', '.
|
||||
'kosten='.$this->addslashes(str_replace(",",".",$this->kosten)).', '.
|
||||
'standort_kurzbz='.$this->addslashes($this->standort_kurzbz).', '.
|
||||
'standort_id='.$this->addslashes($this->standort_id).', '.
|
||||
'telefonklappe='.$this->addslashes($this->telefonklappe).', '.
|
||||
'stockwerk='.$this->addslashes($this->stockwerk).' '.
|
||||
'WHERE ort_kurzbz = '.$this->addslashes($this->ort_kurzbz).';';
|
||||
@@ -314,7 +314,7 @@ class ort extends basis_db
|
||||
$ort_obj->reservieren = ($row->reservieren=='t'?true:false);
|
||||
$ort_obj->ausstattung = $row->ausstattung;
|
||||
$ort_obj->stockwerk = $row->stockwerk;
|
||||
$ort_obj->standort_kurzbz = $row->standort_kurzbz;
|
||||
$ort_obj->standort_id = $row->standort_id;
|
||||
$ort_obj->telefonklappe = $row->telefonklappe;
|
||||
|
||||
$this->result[] = $ort_obj;
|
||||
|
||||
@@ -536,6 +536,109 @@ class person extends basis_db
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Laedt alle standorte zu einer Person die dem Standort zugeordnet sind
|
||||
* @param $standort_id ID des Standortes
|
||||
* @param $person_id ID der Person die Zugeordnet ist
|
||||
* @param $firma_id ID der Firma zu der die standortn geladen werden sollen
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function load_personfunktion($standort_id='',$person_id='',$firma_id='',$funktion_kurzbz='',$personfunktionstandort_id='')
|
||||
{
|
||||
$this->result=array();
|
||||
$this->errormsg = '';
|
||||
|
||||
//Lesen der Daten aus der Datenbank
|
||||
$qry=" SELECT tbl_person.*
|
||||
,tbl_personfunktionstandort.personfunktionstandort_id,tbl_personfunktionstandort.person_id ,tbl_personfunktionstandort.funktion_kurzbz ,tbl_personfunktionstandort.standort_id
|
||||
,tbl_personfunktionstandort.position,tbl_personfunktionstandort.anrede
|
||||
,tbl_standort.adresse_id,tbl_standort.kurzbz,tbl_standort.bezeichnung,tbl_standort.firma_id
|
||||
,tbl_funktion.beschreibung as funktion_beschreibung , tbl_funktion.aktiv as funktion_aktiv,tbl_funktion.fachbereich as funktion_fachbereich,tbl_funktion.semester as funktion_semester
|
||||
";
|
||||
$qry.=" FROM public.tbl_person,public.tbl_personfunktionstandort
|
||||
LEFT JOIN public.tbl_standort USING(standort_id)
|
||||
LEFT JOIN public.tbl_funktion USING(funktion_kurzbz)
|
||||
";
|
||||
$qry.=" WHERE tbl_person.person_id=tbl_personfunktionstandort.person_id";
|
||||
|
||||
if($personfunktionstandort_id!='')
|
||||
$qry.=" and tbl_personfunktionstandort.personfunktionstandort_id='".addslashes($personfunktionstandort_id)."'";
|
||||
if(is_numeric($standort_id))
|
||||
$qry.=" and tbl_personfunktionstandort.standort_id='".addslashes($standort_id)."'";
|
||||
if(is_numeric($person_id))
|
||||
$qry.=" and tbl_personfunktionstandort.person_id='".addslashes($person_id)."'";
|
||||
if(is_numeric($firma_id))
|
||||
$qry.=" and public.tbl_standort.firma_id='".addslashes($firma_id)."'";
|
||||
if($funktion_kurzbz!='')
|
||||
$qry.=" and tbl_personfunktionstandort.funktion_kurzbz='".addslashes($funktion_kurzbz)."'";
|
||||
|
||||
|
||||
|
||||
if(!$this->db_query($qry))
|
||||
{
|
||||
$this->errormsg = 'Fehler bei einer Datenbankabfrage';
|
||||
return false;
|
||||
}
|
||||
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$adr_obj = new person();
|
||||
$adr_obj->person_id = $row->person_id;
|
||||
$adr_obj->staatsbuergerschaft = $row->staatsbuergerschaft;
|
||||
$adr_obj->geburtsnation = $row->geburtsnation;
|
||||
$adr_obj->sprache = $row->sprache;
|
||||
$adr_obj->anrede = $row->anrede;
|
||||
$adr_obj->titelpost = $row->titelpost;
|
||||
$adr_obj->titelpre = $row->titelpre;
|
||||
$adr_obj->nachname = $row->nachname;
|
||||
$adr_obj->vorname = $row->vorname;
|
||||
$adr_obj->vornamen = $row->vornamen;
|
||||
$adr_obj->gebdatum = $row->gebdatum;
|
||||
$adr_obj->gebort = $row->gebort;
|
||||
$adr_obj->gebzeit = $row->gebzeit;
|
||||
$adr_obj->foto = $row->foto;
|
||||
$adr_obj->anmerkungen = $row->anmerkung;
|
||||
$adr_obj->homepage = $row->homepage;
|
||||
$adr_obj->svnr = $row->svnr;
|
||||
$adr_obj->ersatzkennzeichen = $row->ersatzkennzeichen;
|
||||
$adr_obj->familienstand = $row->familienstand;
|
||||
$adr_obj->geschlecht = $row->geschlecht;
|
||||
$adr_obj->anzahlkinder = $row->anzahlkinder;
|
||||
$adr_obj->aktiv = $row->aktiv;
|
||||
$adr_obj->updateamum = $row->updateamum;
|
||||
$adr_obj->updatevon = $row->updatevon;
|
||||
$adr_obj->insertamum = $row->insertamum;
|
||||
$adr_obj->insertvon = $row->insertvon;
|
||||
$adr_obj->ext_id = $row->ext_id;
|
||||
$adr_obj->kurzbeschreibung = $row->kurzbeschreibung;
|
||||
|
||||
|
||||
$adr_obj->standort_id = $row->standort_id;
|
||||
$adr_obj->adresse_id = $row->adresse_id;
|
||||
$adr_obj->kurzbz = $row->kurzbz;
|
||||
$adr_obj->bezeichnung = $row->bezeichnung;
|
||||
$adr_obj->firma_id = $row->firma_id;
|
||||
|
||||
$adr_obj->personfunktionstandort_id = $row->personfunktionstandort_id;
|
||||
|
||||
$adr_obj->funktion_kurzbz = $row->funktion_kurzbz;
|
||||
|
||||
$adr_obj->position = $row->position;
|
||||
$adr_obj->anrede = $row->anrede;
|
||||
|
||||
$adr_obj->funktion_beschreibung = $row->funktion_beschreibung;
|
||||
$adr_obj->funktion_aktiv = ($row->funktion_aktiv=='t'?true:false);
|
||||
$adr_obj->funktion_fachbereich = $row->funktion_fachbereich;
|
||||
$adr_obj->funktion_semester = $row->funktion_semester;
|
||||
|
||||
$this->result[] = $adr_obj;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -314,7 +314,7 @@
|
||||
<tr>
|
||||
<td class="tdwidth10" nowrap> </td>
|
||||
|
||||
<td class="tdwrap"><a href="private/info/uternehmenskommunikation.html" class="MenuItem" target="content"><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> Unternehmens-<br> kommunikation</a></td>
|
||||
<td class="tdwrap"><a href="private/info/unternehmenskommunikation.html" class="MenuItem" target="content"><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> Unternehmens-<br> kommunikation</a></td>
|
||||
<!--
|
||||
<td class="tdwrap"><a href="../documents/management/" class="MenuItem" target="content"><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> Unternehmens-<br> kommunikation</a></td>
|
||||
-->
|
||||
@@ -581,7 +581,7 @@
|
||||
<table class="tabcontent" id="QM_DE" style="display: none">
|
||||
<tr>
|
||||
<td class="tdwidth10" nowrap> </td>
|
||||
<td class="tdwrap"><a target="content" class="Item" href="private/info/qm/Qualitaetsmanagementhandbuch.php?lang="><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> QM-Handbuch</a></td>
|
||||
<td class="tdwrap"><a target="content" class="Item" href="private/info/qm/Qualitaetsmanagementhandbuch.php?lang="><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> CRM@FHTW</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tdwidth10" nowrap> </td>
|
||||
@@ -611,10 +611,13 @@
|
||||
<td class="tdwidth10" nowrap> </td>
|
||||
<td class="tdwrap"><a href="private/info/qm/info.html" target="content" class="MenuItem" onClick="return(js_toggle_container('QM_EN'));"><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> English</a>
|
||||
<table class="tabcontent" id="QM_EN" style="display:none">
|
||||
<tr>
|
||||
|
||||
<!-- EN QM Handbuch CRM@FHTW ist nun in Documents/Support Documents CRM@FHTW-->
|
||||
<tr style="display:none;">
|
||||
<td class="tdwidth10" nowrap> </td>
|
||||
<td class="tdwrap"><a target="_blank" class="Item" href="private/info/qm/Qualitaetsmanagementhandbuch.php?lang=en" ><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> QM-Handbook</a></td>
|
||||
<td class="tdwrap"><a target="content" class="Item" href="private/info/qm/Qualitaetsmanagementhandbuch.php?lang=en" ><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> QM-Handbook</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="tdwidth10" nowrap> </td>
|
||||
<td class="tdwrap"><a class="Item" href="private/info/qm/organigramm_en.html" target="content"><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> Organigram</a></td>
|
||||
@@ -645,18 +648,18 @@
|
||||
|
||||
<!-- Hauptmenue - Unternehmenskommunikation -->
|
||||
<tr>
|
||||
<td class="tdwrap"><a href="private/info/uternehmenskommunikation.html" class="MenuItem" target="content" onClick="js_toggle_container('uternehmenskommunikation');"><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> Uternehmenskommunikation</a></td>
|
||||
<td class="tdwrap"><a href="private/info/unternehmenskommunikation.html" class="MenuItem" target="content" onClick="js_toggle_container('unternehmenskommunikation');"><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> Unternehmenskommunikation</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tdwrap">
|
||||
<table class="tabcontent" id="uternehmenskommunikation" style="display: none;">
|
||||
<table class="tabcontent" id="unternehmenskommunikation" style="display: none;">
|
||||
<tr>
|
||||
<td class="tdwidth10" nowrap> </td>
|
||||
<td class="tdwrap"><a class="Item" href="private/info/uternehmenskommunikation/logo.html" target="content"><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> Logo</a></td>
|
||||
<td class="tdwrap"><a class="Item" href="private/info/unternehmenskommunikation/logo.html" target="content"><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> Logo</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tdwidth10" nowrap> </td>
|
||||
<td class="tdwrap"><a href="private/info/uternehmenskommunikation/CorporateWordingManual.html" class="Item" target="content"><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> Corporate Wording Manual</a></td>
|
||||
<td class="tdwrap"><a href="private/info/unternehmenskommunikation/CorporateWordingManual.html" class="Item" target="content"><img src="../skin/images/menu_item.gif" alt="menu item" width="7" height="9"> Corporate Wording Manual</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
@@ -148,7 +148,7 @@ $menu=array
|
||||
'lvverteilung'=>array('name'=>'LVVerteilung', 'link'=>'lehre/lv_verteilung/lv_verteilung.php', 'target'=>'main'),
|
||||
'Kreuzerllistekopieren'=>array('name'=>'Kreuzerllisten kopieren', 'link'=>'https://cis.technikum-wien.at/cis/private/lehre/benotungstool/copy_uebung.php', 'target'=>'_blank'),
|
||||
'LDAPCheck'=>array('name'=>'LDAPCheck', 'link'=>'personen/ldap_check.php', 'target'=>'main'),
|
||||
'Firmenwartung'=>array('name'=>'Firmenwartung', 'link'=>'stammdaten/firma_zusammen_frameset.html', 'target'=>'main'),
|
||||
'Firmenwartung'=>array('name'=>'Firmenwartung', 'link'=>'stammdaten/firma_zusammen_uebersicht.php', 'target'=>'main'),
|
||||
|
||||
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user