diff --git a/application/controllers/system/issues/Issues.php b/application/controllers/system/issues/Issues.php index 98787f703..f942b50d9 100644 --- a/application/controllers/system/issues/Issues.php +++ b/application/controllers/system/issues/Issues.php @@ -90,7 +90,7 @@ class Issues extends Auth_Controller private function _getOesForIssues() { // get oes of uid for which there is a current funktion - $all_oe_kurzbz_with_funktionen = array(); + $all_funktionen_oe_kurzbz = array(); $oe_kurzbz_for_funktion = array(); $benutzerfunktionRes = $this->BenutzerfunktionModel->getBenutzerFunktionByUid($this->_uid, null, date('Y-m-d'), date('Y-m-d')); @@ -101,13 +101,14 @@ class Issues extends Auth_Controller { foreach (getData($benutzerfunktionRes) as $benutzerfunktion) { - $all_oe_kurzbz_with_funktionen[$benutzerfunktion->oe_kurzbz][] = $benutzerfunktion->funktion_kurzbz; + $all_funktionen_oe_kurzbz[$benutzerfunktion->oe_kurzbz][] = $benutzerfunktion->funktion_kurzbz; // separate oes for the funktion needed for displaying issues if ($benutzerfunktion->funktion_kurzbz == self::FUNKTION_KURZBZ) { $oe_kurzbz_for_funktion[] = $benutzerfunktion->oe_kurzbz; + // permission also for all oes under the oe for which funktion is assigend $childOesFunktionRes = $this->OrganisationseinheitModel->getChilds($benutzerfunktion->oe_kurzbz); if (isError($childOesFunktionRes)) @@ -127,14 +128,14 @@ class Issues extends Auth_Controller } } - // add oes for which there is the issues_verwalten Berechtigung + // add oes for which there is the "manage issues" Berechtigung if (!$oe_kurzbz_berechtigt = $this->permissionlib->getOE_isEntitledFor(self::BERECHTIGUNG_KURZBZ)) show_error('Keine Berechtigung oder Fehler bei Berechtigungsprüfung'); $all_oe_kurzbz_berechtigt = array_unique(array_merge($oe_kurzbz_for_funktion, $oe_kurzbz_berechtigt)); return array( - 'all_oe_kurzbz_with_funktionen' => $all_oe_kurzbz_with_funktionen, + 'all_funktionen_oe_kurzbz' => $all_funktionen_oe_kurzbz, 'all_oe_kurzbz_berechtigt' => $all_oe_kurzbz_berechtigt ); } diff --git a/application/views/system/issues/issuesData.php b/application/views/system/issues/issuesData.php index 2b4551603..1f0bf12b0 100644 --- a/application/views/system/issues/issuesData.php +++ b/application/views/system/issues/issuesData.php @@ -1,7 +1,7 @@ $funktionen_kurzbz) + foreach ($all_funktionen_oe_kurzbz as $oe_kurzbz => $funktionen_kurzbz) { foreach ($funktionen_kurzbz as $funktion_kurzbz) { @@ -39,25 +39,25 @@ if (!isEmptyArray($all_oe_kurzbz_with_funktionen)) $query .= "))"; // close AND of exists, and exists -// show issue if it is assigend to oe of uid or to student of oe of uid +// show issue if it is assigend to oe of logged in user or to student of oe of logged in user if (!isEmptyArray($all_oe_kurzbz_berechtigt)) { - $query .= " OR iss.oe_kurzbz IN $ALL_OE_KURZBZ_BERECHTIGT /* if error is for studiengang oe */"; + $query .= " OR iss.oe_kurzbz IN $ALL_OE_KURZBZ_BERECHTIGT /* if issue is for oe */"; - $query .= " OR (iss.oe_kurzbz IS NULL AND EXISTS ( /* if person_id of error is a student of studiengang oe */ + $query .= " OR (iss.oe_kurzbz IS NULL AND EXISTS ( /* if person_id of issue is a student of studiengang oe */ SELECT 1 FROM public.tbl_prestudent ps JOIN public.tbl_prestudentstatus pss USING (prestudent_id) JOIN public.tbl_studiengang stg USING (studiengang_kz) WHERE person_id = iss.person_id AND stg.oe_kurzbz IN $ALL_OE_KURZBZ_BERECHTIGT AND pss.status_kurzbz IN $RELEVANT_PRESTUDENT_STATUS - AND NOT EXISTS (SELECT 1 + AND NOT EXISTS (SELECT 1 /* irrelevant if already finished studies and studied a while ago */ FROM public.tbl_prestudentstatus ps_finished JOIN public.tbl_studiensemester sem_finished USING (studiensemester_kurzbz) - WHERE prestudent_id = ps.prestudent_id /* irrelevant if already finished studies and studied a while ago */ + WHERE prestudent_id = ps.prestudent_id AND status_kurzbz IN ('Absolvent','Abbrecher','Abgewiesener') AND datum::date + interval '2 months' < NOW() - AND EXISTS (SELECT 1 FROM public.tbl_prestudent /* if more recent prestudent exists, their oe should get the issue */ + AND EXISTS (SELECT 1 FROM public.tbl_prestudent /* if more recent prestudent exists, still display the issue */ JOIN public.tbl_prestudentstatus USING (prestudent_id) JOIN public.tbl_studiensemester USING (studiensemester_kurzbz) WHERE tbl_prestudentstatus.status_kurzbz IN $RELEVANT_PRESTUDENT_STATUS