diff --git a/include/tags.class.php b/include/tags.class.php new file mode 100644 index 000000000..8edbb21f2 --- /dev/null +++ b/include/tags.class.php @@ -0,0 +1,343 @@ +, + * Andreas Oesterreicher and + * Karl Burkhart . + */ +/** + * Klasse Tags + */ + +require_once(dirname(__FILE__).'/basis_db.class.php'); +require_once(dirname(__FILE__).'/sprache.class.php'); + +class tags extends basis_db +{ + public $result = array(); // Konto Objekt + + //Tabellenspalten + public $tag; // integer + public $bestellung_id; // string + public $insertamum; // timestamp + public $insertvon; // string + + public $bestelldetail_id; // integer + + + /** + * Konstruktor + * + */ + public function __construct($tag=null) + { + parent::__construct(); + + if(!is_null($tag)) + $this->load($tag); + } + + /** + * + * Gibt alle Tags zurück + */ + public function getAll() + { + $qry = "Select * from public.tbl_tag; "; + + if($this->db_query($qry)) + { + while($row = $this->db_fetch_object()) + { + $tag = new tags(); + + $tag->tag = $row->tag; + + $this->result[] = $tag; + } + return true; + } + else + { + $this->errormsg = "Fehler bei der Abfrage aufgetreten."; + return false; + } + } + + /** + * + * Gibt die Tags einer Bestellung zurück + * @param $bestellung_id + */ + public function GetTagsByBestellung($bestellung_id = '') + { + /* if(!is_numeric($bestellung_id)) + { + $this->errormsg = "Ungültige Bestellung ID"; + return false; + }*/ + + $qry = "Select * from wawi.tbl_bestellungtag where bestellung_id = ".$bestellung_id.";"; + + if($this->db_query($qry)) + { + while($row = $this->db_fetch_object()) + { + $bestelltag = new tags(); + + $bestelltag->tag = $row->tag; + $bestelltag->bestellung_id = $row->bestellung_id; + $bestelltag->insertamum = $row->insertamum; + $bestelltag->insertvon = $row->insertvon; + + $this->result[] = $bestelltag; + } + } + else + { + $this->errormsg = "Fehler bei Abfrage aufgetreten."; + return false; + } + return true; + } + + /** + * + * gibt die Tags per Strichpunkt getrennt zurück + */ + public function GetStringTags() + { + $string = ''; + foreach($this->result as $row) + { + if($string!='') + $string.='; '; + $string.=($row->tag); + } + return $string; + } + + + /** + * + * Gibt alle Tags eines Bestelldetails zurück + * @param $bestelldetail_id + */ + public function GetTagsByBesteldetail($bestelldetail_id) + { + if($bestelldetail_id == '') + { + $this->errormsg = "Ungültige Bestelldetail ID"; + return false; + } + + $qry = "Select * from wawi.tbl_bestelldetailtag where bestelldetail_id = ".$bestelldetail_id.";"; + + if($this->db_query($qry)) + { + while($row = $this->db_fetch_object()) + { + $bestelltag = new tags(); + + $bestelltag->tag = $row->tag; + $bestelltag->bestelldetail_id = $row->bestelldetail_id; + $bestelltag->insertamum = $row->insertamum; + $bestelltag->insertvon = $row->insertvon; + + $this->result[] = $bestelltag; + } + } + else + { + $this->errormsg = "Fehler bei Abfrage aufgetreten."; + return false; + } + return true; + } + + /** + * + * return true wenn Tag schon vorhanden ist, false wenn Tag noch nicht vorhanden ist + */ + public function TagExists() + { + $qry = "Select * from public.tbl_tag where tag = ".$this->addslashes($this->tag).";"; + + if($this->db_query($qry)) + { + if($row = $this->db_fetch_object()) + return true; + else + return false; + } + else + return false; + } + + /** + * + * return true wenn Tag schon in der Zwischentabelle vorhanden ist, false wenn Tag noch nicht vorhanden ist + */ + public function BestellungTagExists() + { + $qry = "Select * from wawi.tbl_bestellungtag where tag = ".$this->addslashes($this->tag)." and bestellung_id = ".$this->addslashes($this->bestellung_id).";"; + + if($this->db_query($qry)) + { + if($row = $this->db_fetch_object()) + return true; + else + return false; + } + else + return false; + } + + /** + * + * Speichert den Tag in der Datenbank + */ + public function saveTag() + { + if($this->tag != '') + { + $qry = "Insert into public.tbl_tag (tag) values (".$this->addslashes($this->tag).");"; + + echo $qry; + + if($this->db_query($qry)) + { + return true; + } + else + { + return false; + } + } + } + + /** + * + * Speichert den Tag in tbl_bestelltag und weist dem Eintrag die Bestellung zu + * @param $bestellung_id + */ + public function saveBestellungTag() + { + if($this->tag != '') + { + $qry = "Insert into wawi.tbl_bestellungtag (tag, bestellung_id, insertamum, insertvon) + values(" + .$this->addslashes($this->tag)."," + .$this->addslashes($this->bestellung_id)."," + .$this->addslashes($this->insertamum)."," + .$this->addslashes($this->insertvon).");"; + + if(!$this->db_query($qry)) + { + $this->errormsg ="Fehler bei der Abfrage aufgetreten."; + return false; + } + + return true; + } + } + + /** + * + * Löscht alle Einträge in der Bestellungtag Zwischentabelle die nicht Teil der eingegeben + * @param unknown_type $tagArray + */ + public function deleteBestellungTag($tagArray) + { + $sqlTag = $this->implode4SQL($tagArray); + $qry = "DELETE from wawi.tbl_bestellungtag where bestellung_id = ".$this->bestellung_id." and tag not in(".$sqlTag.");"; + + if(!$this->db_query($qry)) + { + $this->errormsg ="Fehler bei der Abfrage aufgetreten."; + return false; + } + + return true; + } + + /** + * + * Speichert den Tag in tbl_bestelldetailtag und weist dem Eintrag das Bestelldetail zu + * @param $bestellung_id + */ + public function saveBestelldetailTag() + { + if($this->tag != '') + { + $qry = "Insert into wawi.tbl_bestelldetailtag (tag, bestelldetail_id, insertamum, insertvon) + values(" + .$this->addslashes($this->tag)."," + .$this->addslashes($this->bestelldetail_id)."," + .$this->addslashes($this->insertamum)."," + .$this->addslashes($this->insertvon).");"; + + if(!$this->db_query($qry)) + { + $this->errormsg ="Fehler bei der Abfrage aufgetreten."; + return false; + } + + return true; + } + } + + /** + * + * Löscht alle Einträge in der Bestellungtag Zwischentabelle die nicht Teil der eingegeben + * @param unknown_type $tagArray + */ + public function deleteBestelldetailTag($tagArray) + { + $sqlTag = $this->implode4SQL($tagArray); + $qry = "DELETE from wawi.tbl_bestelldetailtag where bestelldetail_id = ".$this->bestelldetail_id." and tag not in(".$sqlTag.");"; + + if(!$this->db_query($qry)) + { + $this->errormsg ="Fehler bei der Abfrage aufgetreten."; + return false; + } + + return true; + } + + /** + * + * return true wenn Tag schon in der Zwischentabelle vorhanden ist, false wenn Tag noch nicht vorhanden ist + */ + public function BestelldetailTagExists() + { + $qry = "Select * from wawi.tbl_bestelldetailtag where tag = ".$this->addslashes($this->tag)." and bestelldetail_id = ".$this->addslashes($this->bestelldetail_id).";"; + + if($this->db_query($qry)) + { + if($row = $this->db_fetch_object()) + return true; + else + return false; + } + else + return false; + } + +} + diff --git a/include/wawi_aufteilung.class.php b/include/wawi_aufteilung.class.php index 4dbcb435c..06ae06b39 100644 --- a/include/wawi_aufteilung.class.php +++ b/include/wawi_aufteilung.class.php @@ -167,5 +167,54 @@ class wawi_aufteilung extends basis_db } } + /** + * + * return true wenn es den Aufteilungseintrag schon gibt, false wenn es ihn noch nicht gibt + */ + public function AufteilungExists() + { + $qry = "SELECT * from wawi.tbl_aufteilung where bestellung_id = ".$this->addslashes($this->bestellung_id)." and oe_kurzbz = ".$this->addslashes($this->oe_kurzbz).";"; + + if($this->db_query($qry)) + { + if($row = $this->db_fetch_object()) + return true; + else + return false; + } + else + return false; + } + + /** + * + * Speichert die Aufteilung in der Datenbank + */ + public function saveAufteilung() + { + + if($this->new = true) + { + // insert + $qry= "Insert into wawi.tbl_aufteilung (bestellung_id, oe_kurzbz, anteil, updateamum, updatevon, insertamum, insertvon) values (" + .$this->addslashes($this->bestellung_id).", " + .$this->addslashes($this->oe_kurzbz).", " + .$this->addslashes($this->anteil).", " + .$this->addslashes($this->updateamum).", " + .$this->addslashes($this->updatevon).", " + .$this->addslashes($this->insertamum).", " + .$this->addslashes($this->insertvon).");"; + } + else + { + // update + } + + if($this->db_query($qry)) + return true; + else + return false; + + } } \ No newline at end of file diff --git a/include/wawi_bestellung.class.php b/include/wawi_bestellung.class.php index 66ac056fc..a0d2c502f 100644 --- a/include/wawi_bestellung.class.php +++ b/include/wawi_bestellung.class.php @@ -217,7 +217,7 @@ class wawi_bestellung extends basis_db if($kostenstelle_id!='') $qry.= ' AND kostenstelle_id='.$this->addslashes($kostenstelle_id); - echo $qry; + if(!$this->db_query($qry)) { $this->errormsg = "Fehler bei der Datenbankabfrage.";