From 6f5add82f8d11a6bb818f07e7d4656b139badec1 Mon Sep 17 00:00:00 2001 From: Karl Burkhart Date: Fri, 17 Dec 2010 13:50:30 +0000 Subject: [PATCH] --- include/wawi_bestellstatus.class.php | 18 ++++++++++++--- include/wawi_bestellung.class.php | 33 +++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/include/wawi_bestellstatus.class.php b/include/wawi_bestellstatus.class.php index 48ce73754..01de62be4 100644 --- a/include/wawi_bestellstatus.class.php +++ b/include/wawi_bestellstatus.class.php @@ -137,8 +137,9 @@ class wawi_bestellstatus extends basis_db * @param $bestellung_id * @param $status_kurzbz */ - public function isStatiVorhanden($bestellung_id, $status_kurzbz) + public function isStatiVorhanden($bestellung_id, $status_kurzbz='', $oe_kurzbz ='') { + $status=''; if(!is_numeric($bestellung_id) || $bestellung_id == '') { $this->errormsg = "Bestellung ID fehlerhaft."; @@ -149,15 +150,26 @@ class wawi_bestellstatus extends basis_db $this->errormsg = "Status Kurzbezeichnung ist fehlerhaft."; return false; } - + + if($oe_kurzbz!='') + { + $status .= " and oe_kurzbz = ".$this->addslashes($oe_kurzbz); + } + if($status_kurzbz!='') + { + $status.=" and bestellstatus_kurzbz = ".$this->addslashes($status_kurzbz); + } + $qry = "select bestellstatus.* from wawi.tbl_bestellung_bestellstatus as bestellstatus WHERE - bestellung_id = ".$this->addslashes($bestellung_id)." and bestellstatus_kurzbz = ".$this->addslashes($status_kurzbz).";"; + bestellung_id = ".$this->addslashes($bestellung_id).$status.";"; + if($this->db_query($qry)) { if($row = $this->db_fetch_object()) { $this->datum = $row->datum; + $this->insertvon = $row->insertvon; return true; } else diff --git a/include/wawi_bestellung.class.php b/include/wawi_bestellung.class.php index bb6bb4c59..a6e2eb24b 100644 --- a/include/wawi_bestellung.class.php +++ b/include/wawi_bestellung.class.php @@ -587,11 +587,38 @@ class wawi_bestellung extends basis_db { $oe = new organisationseinheit(); $bestellung = new wawi_bestellung(); + $bestellung->load($bestellung_id); + $brutto = $bestellung->getBrutto($bestellung_id); + $brutto = number_format($brutto,2,".",""); + $oe_bestellung = $bestellung->getOe(); + // oe der bestellung + $oe->load($oe_bestellung); + $oes = array(); - $oe->load($bestellung->getOe()); - - echo $oe->oe_kurzbz; + $qry = "WITH RECURSIVE oes(oe_kurzbz, oe_parent_kurzbz, freigabegrenze) as + ( + SELECT oe_kurzbz, oe_parent_kurzbz, freigabegrenze FROM public.tbl_organisationseinheit + WHERE oe_kurzbz='".addslashes($oe_bestellung)."' and aktiv = true + UNION ALL + SELECT o.oe_kurzbz, o.oe_parent_kurzbz, o.freigabegrenze FROM public.tbl_organisationseinheit o, oes + WHERE o.oe_kurzbz=oes.oe_parent_kurzbz and aktiv = true + ) + SELECT oe_kurzbz + FROM oes + WHERE freigabegrenze<='$brutto' + GROUP BY oe_kurzbz,freigabegrenze ORDER BY freigabegrenze"; + + if($this->db_query($qry)) + { + while($row = $this->db_fetch_object()) + { + $oes[] = $row->oe_kurzbz; + } + return $oes; + } + else + return false; }