diff --git a/include/ort.class.php b/include/ort.class.php index 209f5bc1f..72c543808 100644 --- a/include/ort.class.php +++ b/include/ort.class.php @@ -499,5 +499,67 @@ class ort extends basis_db } return true; } + + /** + * Laedt einen Ort (Limit 1) anhand seiner Planbezeichnung + * @param boolean aktiv (optional) default:true + * @param boolean lehre (optional) default:true + * @return true wenn ok, false im Fehlerfall + */ + public function getOrtByPlanbezeichnung($planbezeichnung, $aktiv=true, $lehre=true) + { + $qry = 'SELECT * FROM public.tbl_ort WHERE planbezeichnung='.$this->db_add_param($planbezeichnung); + + if(!is_null($aktiv)) + { + $qry .= ' AND aktiv='.$this->db_add_param($aktiv, FHC_BOOLEAN); + } + if(!is_null($lehre)) + { + $qry .= ' AND lehre='.$this->db_add_param($lehre, FHC_BOOLEAN); + } + + $qry .= ' ORDER BY ort_kurzbz LIMIT 1;'; + + if(!$this->db_query($qry)) + { + $this->errormsg = 'Fehler beim Laden der Datensaetze'; + return false; + } + + if($this->db_query($qry)) + { + while($row = $this->db_fetch_object()) + { + $ort_obj = new ort(); + + $ort_obj->ort_kurzbz = $row->ort_kurzbz; + $ort_obj->bezeichnung = $row->bezeichnung; + $ort_obj->planbezeichnung = $row->planbezeichnung; + $ort_obj->max_person = $row->max_person; + $ort_obj->aktiv = $this->db_parse_bool($row->aktiv); + $ort_obj->lehre = $this->db_parse_bool($row->lehre); + $ort_obj->lageplan = $row->lageplan; + $ort_obj->dislozierung = $row->dislozierung; + $ort_obj->kosten = $row->kosten; + $ort_obj->reservieren = $this->db_parse_bool($row->reservieren); + $ort_obj->ausstattung = $row->ausstattung; + $ort_obj->stockwerk = $row->stockwerk; + $ort_obj->standort_id = $row->standort_id; + $ort_obj->telefonklappe = $row->telefonklappe; + $ort_obj->content_id = $row->content_id; + $ort_obj->m2 = $row->m2; + $ort_obj->oe_kurzbz = $row->oe_kurzbz; + $ort_obj->gebteil = $row->gebteil; + $this->result[] = $ort_obj; + } + return true; + } + else + { + $this->errormsg = 'Fehler beim Laden der Datensaetze'; + return false; + } + } } ?>