diff --git a/content/statistik/mitarbeiterexport.xls.php b/content/statistik/mitarbeiterexport.xls.php index 6bb5b60bf..9beb16e27 100644 --- a/content/statistik/mitarbeiterexport.xls.php +++ b/content/statistik/mitarbeiterexport.xls.php @@ -157,7 +157,7 @@ array_multisort($nachname, SORT_ASC, $vorname, SORT_ASC, $mitarbeiterDAO->result } //Zustelladresse aus der Datenbank holen und dazuhaengen - $qry = "SELECT * FROM public.tbl_adresse WHERE person_id='$mitarbeiter->person_id' ORDER BY zustelladresse DESC LIMIT 1"; + $qry = "SELECT * FROM public.tbl_adresse WHERE person_id='$mitarbeiter->person_id' WHERE zustelladresse=true LIMIT 1"; if($result = pg_query($conn, $qry)) { if($row = pg_fetch_object($result)) diff --git a/content/statistik/studentenexport.xls.php b/content/statistik/studentenexport.xls.php index 5dc0fc707..56c78de44 100644 --- a/content/statistik/studentenexport.xls.php +++ b/content/statistik/studentenexport.xls.php @@ -252,7 +252,7 @@ loadVariables($conn, $user); //Zustelladresse //Zustelladresse aus der Datenbank holen und dazuhaengen - $qry_1 = "SELECT * FROM public.tbl_adresse WHERE person_id='$row->person_id' ORDER BY zustelladresse DESC LIMIT 1"; + $qry_1 = "SELECT * FROM public.tbl_adresse WHERE person_id='$row->person_id' AND zustelladresse=true LIMIT 1"; if($result_1 = pg_query($conn, $qry_1)) { if($row_1 = pg_fetch_object($result_1)) @@ -451,7 +451,7 @@ loadVariables($conn, $user); $i+=3; //Telefon - $qry_1 = "SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp in('mobil','telefon','so.tel') AND person_id='$row->person_id' ORDER BY zustellung DESC LIMIT 1"; + $qry_1 = "SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp in('mobil','telefon','so.tel') AND person_id='$row->person_id' AND zustellung=true LIMIT 1"; if($result_1 = pg_query($conn, $qry_1)) { if($row_1 = pg_fetch_object($result_1)) diff --git a/content/student/studentDBDML.php b/content/student/studentDBDML.php index 875d7ec31..d7fde6127 100644 --- a/content/student/studentDBDML.php +++ b/content/student/studentDBDML.php @@ -2933,7 +2933,7 @@ if(!$error) { if(is_numeric($person_id)) { - $qry = "SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp='email' AND person_id='$person_id' ORDER BY zustellung DESC LIMIT 1"; + $qry = "SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp='email' AND person_id='$person_id' AND zustellung=true LIMIT 1"; if($result = pg_query($conn, $qry)) { if($row = pg_fetch_object($result)) diff --git a/vilesci/stammdaten/reihungstestverwaltung.php b/vilesci/stammdaten/reihungstestverwaltung.php index 2d3bac0c6..421998f81 100644 --- a/vilesci/stammdaten/reihungstestverwaltung.php +++ b/vilesci/stammdaten/reihungstestverwaltung.php @@ -92,7 +92,7 @@ $worksheet->write(2,++$i,"ORT", $format_bold); $maxlength[$i] = 3; - $qry = "SELECT *, (SELECT kontakt FROM tbl_kontakt WHERE kontakttyp='email' AND person_id=tbl_prestudent.person_id ORDER BY zustellung desc, insertamum desc LIMIT 1) as email FROM public.tbl_prestudent JOIN public.tbl_person USING(person_id) WHERE reihungstest_id='$reihungstest->reihungstest_id' ORDER BY nachname, vorname"; + $qry = "SELECT *, (SELECT kontakt FROM tbl_kontakt WHERE kontakttyp='email' AND person_id=tbl_prestudent.person_id AND zustellung=true LIMIT 1) as email FROM public.tbl_prestudent JOIN public.tbl_person USING(person_id) WHERE reihungstest_id='$reihungstest->reihungstest_id' ORDER BY nachname, vorname"; if($result = pg_query($conn, $qry)) { @@ -121,7 +121,7 @@ if(strlen($row->email)>$maxlength[$i]) $maxlength[$i] = strlen($row->email); - $qry = "SELECT * FROM public.tbl_adresse WHERE person_id='$row->person_id' ORDER BY zustelladresse LIMIT 1"; + $qry = "SELECT * FROM public.tbl_adresse WHERE person_id='$row->person_id' AND zustelladresse=true LIMIT 1"; if($result_adresse = pg_query($conn, $qry)) { if($row_adresse = pg_fetch_object($result_adresse)) @@ -423,7 +423,7 @@ echo ''; //Liste der Interessenten die zum Reihungstest angemeldet sind - $qry = "SELECT *, (SELECT kontakt FROM tbl_kontakt WHERE kontakttyp='email' AND person_id=tbl_prestudent.person_id ORDER BY zustellung desc, insertamum desc LIMIT 1) as email FROM public.tbl_prestudent JOIN public.tbl_person USING(person_id) WHERE reihungstest_id='$reihungstest_id' ORDER BY nachname, vorname"; + $qry = "SELECT *, (SELECT kontakt FROM tbl_kontakt WHERE kontakttyp='email' AND person_id=tbl_prestudent.person_id AND zustellung=true LIMIT 1) as email FROM public.tbl_prestudent JOIN public.tbl_person USING(person_id) WHERE reihungstest_id='$reihungstest_id' ORDER BY nachname, vorname"; $mailto = ''; if($result = pg_query($conn, $qry)) { @@ -453,7 +453,7 @@