diff --git a/include/prestudent.class.php b/include/prestudent.class.php index b9909306c..31d5f69ef 100644 --- a/include/prestudent.class.php +++ b/include/prestudent.class.php @@ -2327,55 +2327,49 @@ class prestudent extends person * false wenn nicht vorhanden * false und errormsg wenn Fehler aufgetreten ist */ - public function existsZGVIntern($person_id) - { - if (!is_numeric($person_id)) - { - $this->errormsg = 'Person_id muss eine gueltige Zahl sein'; - return false; - } + public function existsZGVIntern($person_id) + { + if (!is_numeric($person_id)) + { + $this->errormsg = 'Person_id muss eine gueltige Zahl sein'; + return false; + } + $qry = "SELECT count(*) as anzahl FROM public.tbl_prestudent + JOIN public.tbl_prestudentstatus USING (prestudent_id) + JOIN public.tbl_studiengang USING (studiengang_kz) + WHERE person_id = ".$this->db_add_param($person_id, FHC_INTEGER)." + AND status_kurzbz in ('Absolvent','Diplomand','Unterbrecher','Student') + AND typ = 'b' + AND get_rolle_prestudent(prestudent_id, null) != 'Abbrecher';"; - echo $qry = " - SELECT t.prestudent_id, t.status_kurzbz, t.bestaetigtam FROM - ( - SELECT prestudent_id, status_kurzbz, bestaetigtam, - RANK() OVER (PARTITION BY prestudent_id ORDER BY bestaetigtam DESC) stat_rank - FROM public.tbl_prestudent - JOIN public.tbl_prestudentstatus USING (prestudent_id) - WHERE person_id= ".$this->db_add_param($person_id, FHC_INTEGER)." - AND bestaetigtam is not NULL - AND status_kurzbz in ('Absolvent','Diplomand','Unterbrecher','Student') - ) as t - WHERE stat_rank = 1"; - - $db = new basis_db(); - $arrayPrestudents = array(); - - if ($db->db_query($qry)) - { - $num_rows = $db->db_num_rows(); - - if ($num_rows > 0) - { - while ($row = $db->db_fetch_object()) - { - $arrayPrestudents[] = $row->status_kurzbz; - } - if ($arrayPrestudents) - { - return true; - } - } - else - return false; - } - else - { - $this->errormsg = 'Fehler beim Laden der Daten'; - return false; - } - } + if ($this->db_query($qry)) + { + if ($row = $this->db_fetch_object()) + { + if ($row->anzahl > 0) + { + $this->errormsg = ''; + return true; + } + else + { + $this->errormsg = ''; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } /**