mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-22 17:32:18 +00:00
add prefiltering on validity period form component
This commit is contained in:
@@ -120,7 +120,7 @@ $route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/prestudent/(:num)'] = 'a
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/person/(:num)'] = 'api/frontend/v1/stv/Students/getPerson/$1/$2';
|
||||
|
||||
|
||||
$route['lehre/ClassSchedule/(:any)/(:any)'] = 'lehre/ClassSchedule/index';
|
||||
$route['lehre/ClassSchedule/.*'] = 'lehre/ClassSchedule/index';
|
||||
|
||||
// load routes from extensions, also look for environment-specific configs
|
||||
$subdirs = ['application/config/extensions', 'application/config/' . ENVIRONMENT . '/extensions'];
|
||||
|
||||
@@ -27,6 +27,7 @@ class ClassScheduleApi extends FHCAPI_Controller
|
||||
{
|
||||
parent::__construct([
|
||||
'getAllClassTimeValidityPeriods'=> array('lehre/unterrichtszeiten_gk:r'),
|
||||
'getAllClassTimeValidityPeriodsPerOrganizationalUnit' => array('lehre/unterrichtszeiten_gk:r'),
|
||||
'getClassTimeValidityPeriod' => array('lehre/unterrichtszeiten_gk:r'),
|
||||
'createClassTimeSlotValidityPeriod' => array('lehre/unterrichtszeiten_gk:rw'),
|
||||
'updateClassTimeSlotValidityPeriod' => array('lehre/unterrichtszeiten_gk:rw'),
|
||||
@@ -60,14 +61,40 @@ class ClassScheduleApi extends FHCAPI_Controller
|
||||
|
||||
public function getAllClassTimeValidityPeriods()
|
||||
{
|
||||
$this->ClassTimeSlotValidityPeriodModel->addSelect(
|
||||
'lehre.tbl_unterrichtszeiten_gueltigkeit.*,' .
|
||||
'public.tbl_organisationseinheit.bezeichnung as organisationseinheit_bezeichnung,' .
|
||||
'public.tbl_organisationseinheit.organisationseinheittyp_kurzbz as organisationseinheit_organisationseinheittyp_kurzbz,' .
|
||||
'lehre.tbl_studienplan.bezeichnung as studienplan_bezeichnung,' .
|
||||
'lehre.tbl_unterrichtszeiten_typ.bezeichnung_mehrsprachig as unterrichtszeiten_typ_bezeichnung_mehrsprachig, '
|
||||
);
|
||||
$this->ClassTimeSlotValidityPeriodModel->addJoin('lehre.tbl_studienplan', 'lehre.tbl_studienplan.studienplan_id=lehre.tbl_unterrichtszeiten_gueltigkeit.studienplan_id', 'LEFT');
|
||||
$this->ClassTimeSlotValidityPeriodModel->addJoin('public.tbl_organisationseinheit', 'public.tbl_organisationseinheit.oe_kurzbz=lehre.tbl_unterrichtszeiten_gueltigkeit.oe_kurzbz', 'LEFT');
|
||||
$this->ClassTimeSlotValidityPeriodModel->addJoin('lehre.tbl_unterrichtszeiten_typ', 'lehre.tbl_unterrichtszeiten_typ.unterrichtszeitentyp_kurzbz=lehre.tbl_unterrichtszeiten_gueltigkeit.unterrichtszeitentyp_kurzbz', 'LEFT');
|
||||
$this->ClassTimeSlotValidityPeriodModel->addOrder('gueltig_von', 'DESC');
|
||||
$class_time_slot_validity_period_res = $this->ClassTimeSlotValidityPeriodModel->load();
|
||||
$class_time_slot_validity_period_res = $this->getDataOrTerminateWithError($class_time_slot_validity_period_res);
|
||||
$this->terminateWithSuccess($class_time_slot_validity_period_res);
|
||||
}
|
||||
|
||||
public function getAllClassTimeValidityPeriodsPerOrganizationalUnit($organizationUnitId)
|
||||
{
|
||||
$this->ClassTimeSlotValidityPeriodModel->addSelect(
|
||||
'lehre.tbl_unterrichtszeiten_gueltigkeit.*,' .
|
||||
'public.tbl_organisationseinheit.bezeichnung as organisationseinheit_bezeichnung,' .
|
||||
'public.tbl_organisationseinheit.organisationseinheittyp_kurzbz as organisationseinheit_organisationseinheittyp_kurzbz,' .
|
||||
'lehre.tbl_studienplan.bezeichnung as studienplan_bezeichnung,' .
|
||||
'lehre.tbl_unterrichtszeiten_typ.bezeichnung_mehrsprachig as unterrichtszeiten_typ_bezeichnung_mehrsprachig, '
|
||||
);
|
||||
$this->ClassTimeSlotValidityPeriodModel->addJoin('lehre.tbl_studienplan', 'lehre.tbl_studienplan.studienplan_id=lehre.tbl_unterrichtszeiten_gueltigkeit.studienplan_id', 'LEFT');
|
||||
$this->ClassTimeSlotValidityPeriodModel->addJoin('public.tbl_organisationseinheit', 'public.tbl_organisationseinheit.oe_kurzbz=lehre.tbl_unterrichtszeiten_gueltigkeit.oe_kurzbz', 'LEFT');
|
||||
$this->ClassTimeSlotValidityPeriodModel->addJoin('lehre.tbl_unterrichtszeiten_typ', 'lehre.tbl_unterrichtszeiten_typ.unterrichtszeitentyp_kurzbz=lehre.tbl_unterrichtszeiten_gueltigkeit.unterrichtszeitentyp_kurzbz', 'LEFT');
|
||||
$this->ClassTimeSlotValidityPeriodModel->addOrder('gueltig_von', 'DESC');
|
||||
$class_time_slot_validity_period_res = $this->ClassTimeSlotValidityPeriodModel->loadWhere(['lehre.tbl_unterrichtszeiten_gueltigkeit.oe_kurzbz' => $organizationUnitId]);
|
||||
$class_time_slot_validity_period_res = $this->getDataOrTerminateWithError($class_time_slot_validity_period_res);
|
||||
$this->terminateWithSuccess($class_time_slot_validity_period_res);
|
||||
}
|
||||
|
||||
public function getClassTimeValidityPeriod($classTimeSlotValidityPeriodId)
|
||||
{
|
||||
$this->ClassTimeSlotValidityPeriodModel->addSelect('lehre.tbl_unterrichtszeiten_gueltigkeit.*, public.tbl_organisationseinheit.oe_kurzbz as oe_kurzbz, lehre.tbl_studienplan.studienplan_id, lehre.tbl_studienplan.bezeichnung as studienplan_bezeichnung');
|
||||
|
||||
@@ -21,6 +21,7 @@ class Studienplan extends FHCAPI_Controller
|
||||
// TODO(chris): access!
|
||||
parent::__construct([
|
||||
'getAllStudyPlans' => self::PERM_LOGGED,
|
||||
'getStudyPlansByOrganizationalUnitAndSemesterDates' => self::PERM_LOGGED,
|
||||
'getBySemester' => self::PERM_LOGGED
|
||||
]);
|
||||
}
|
||||
@@ -33,6 +34,26 @@ class Studienplan extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($studien_plan_result);
|
||||
}
|
||||
|
||||
public function getStudyPlansByOrganizationalUnitAndSemesterDates($organizationalUnitShortCode)
|
||||
{
|
||||
$this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$this->load->model('organisation/Studienordnung_model', 'StudienordnungModel');
|
||||
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
|
||||
$startDate = date('Y-m-d', strtotime($this->input->get('filter[startDate]')));
|
||||
$endDate = date('Y-m-d', strtotime($this->input->get('filter[endDate]')));
|
||||
if (!$startDate || !$endDate) {
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Start- oder Enddatum']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$studyPlansResponse = $this->StudienplanModel->getStudyPlansForOrganizationalUnitAndDatesQueryResponse($organizationalUnitShortCode, $startDate, $endDate);
|
||||
if (isError($studyPlansResponse)) $this->terminateWithError(getError($studyPlansResponse), self::ERROR_TYPE_DB);
|
||||
if (!hasData($studyPlansResponse)) return $this->terminateWithSuccess(null);
|
||||
|
||||
return $this->terminateWithSuccess($this->getDataOrTerminateWithError($studyPlansResponse));
|
||||
}
|
||||
|
||||
public function getBySemester()
|
||||
{
|
||||
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
|
||||
@@ -26,7 +26,9 @@ class Studiensemester extends FHCAPI_Controller
|
||||
'getAll' => self::PERM_LOGGED,
|
||||
'getAktNext' => self::PERM_LOGGED,
|
||||
'getStudienjahrByStudiensemester' => self::PERM_LOGGED,
|
||||
'getAllStudiensemesterAndAktOrNext' => self::PERM_LOGGED
|
||||
'getAllStudiensemesterAndAktOrNext' => self::PERM_LOGGED,
|
||||
'getStudySemestersByOrganizationalUnitAndDates' => self::PERM_LOGGED,
|
||||
'getStudySemestersByStudyPlanAndDates' => self::PERM_LOGGED,
|
||||
)
|
||||
);
|
||||
// Load model StudiensemesterModel
|
||||
@@ -166,4 +168,51 @@ class Studiensemester extends FHCAPI_Controller
|
||||
|
||||
$this->terminateWithSuccess(array($studiensemester, $aktuell));
|
||||
}
|
||||
|
||||
public function getStudySemestersByOrganizationalUnitAndDates($organizationalUnitShortCode)
|
||||
{
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$this->load->model('organisation/Studienordnung_model', 'StudienordnungModel');
|
||||
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
|
||||
$startDate = date('Y-m-d', strtotime($this->input->get('filter[startDate]')));
|
||||
$endDate = date('Y-m-d', strtotime($this->input->get('filter[endDate]')));
|
||||
if (!$startDate || !$endDate) {
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Start- oder Enddatum']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$studyPlansResponse = $this->StudienplanModel->getStudyPlansForOrganizationalUnitQueryResponse($organizationalUnitShortCode);
|
||||
if (isError($studyPlansResponse)) $this->terminateWithError(getError($studyPlansResponse), self::ERROR_TYPE_DB);
|
||||
if (!hasData($studyPlansResponse)) return $this->terminateWithSuccess(null);
|
||||
|
||||
$studyPlans = $this->getDataOrTerminateWithError($studyPlansResponse);
|
||||
$studyPlansIds = array_map(function ($studyPlan) { return $studyPlan->studienplan_id; }, $studyPlans);
|
||||
|
||||
$studySemestersResponse = $this->StudiensemesterModel->getStudySemestersByStudyPlansAndDatesQueryResponse($studyPlansIds, $startDate, $endDate);
|
||||
if (isError($studySemestersResponse)) $this->terminateWithError(getError($studySemestersResponse), self::ERROR_TYPE_DB);
|
||||
if (!hasData($studySemestersResponse)) return $this->terminateWithSuccess([]);
|
||||
|
||||
$studySemesters = $this->getDataOrTerminateWithError($studySemestersResponse);
|
||||
|
||||
return $this->terminateWithSuccess($studySemesters);
|
||||
}
|
||||
|
||||
public function getStudySemestersByStudyPlanAndDates()
|
||||
{
|
||||
$studyPlansId = $this->input->get('filter[studyPlanId]');
|
||||
|
||||
$startDate = date('Y-m-d', strtotime($this->input->get('filter[startDate]')));
|
||||
$endDate = date('Y-m-d', strtotime($this->input->get('filter[endDate]')));
|
||||
if (!$startDate || !$endDate) {
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Start- oder Enddatum']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$studySemestersResponse = $this->StudiensemesterModel->getStudySemestersByStudyPlansAndDatesQueryResponse([$studyPlansId], $startDate, $endDate);
|
||||
if (isError($studySemestersResponse)) $this->terminateWithError(getError($studySemestersResponse), self::ERROR_TYPE_DB);
|
||||
if (!hasData($studySemestersResponse)) return $this->terminateWithSuccess([]);
|
||||
|
||||
$studySemesters = $this->getDataOrTerminateWithError($studySemestersResponse);
|
||||
|
||||
return $this->terminateWithSuccess($studySemesters);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,5 +168,30 @@ class Studienplan_model extends DB_Model
|
||||
return $this->loadWhere([
|
||||
'person_id' => $person_id
|
||||
]);
|
||||
}
|
||||
|
||||
public function getStudyPlansForOrganizationalUnitQueryResponse($organizationalUnitShortCode)
|
||||
{
|
||||
$query = "SELECT sp.* FROM lehre.tbl_studienplan sp
|
||||
JOIN lehre.tbl_studienordnung so ON sp.studienordnung_id = so.studienordnung_id
|
||||
JOIN public.tbl_studiengang sg ON so.studiengang_kz = sg.studiengang_kz
|
||||
WHERE sg.oe_kurzbz = ?";
|
||||
|
||||
return $this->execReadOnlyQuery($query, array($organizationalUnitShortCode));
|
||||
}
|
||||
|
||||
public function getStudyPlansForOrganizationalUnitAndDatesQueryResponse($organizationalUnitShortCode, $startDate, $endDate)
|
||||
{
|
||||
$query = "SELECT DISTINCT sp.* FROM lehre.tbl_studienplan sp
|
||||
JOIN lehre.tbl_studienordnung so ON sp.studienordnung_id = so.studienordnung_id
|
||||
JOIN public.tbl_studiengang sg ON so.studiengang_kz = sg.studiengang_kz
|
||||
AND sg.oe_kurzbz = ? AND sp.studienplan_id IN (
|
||||
SELECT sps.studienplan_id
|
||||
FROM lehre.tbl_studienplan_semester sps
|
||||
JOIN public.tbl_studiensemester ss ON ss.studiensemester_kurzbz = sps.studiensemester_kurzbz
|
||||
WHERE (ss.start >= ? AND ss.ende <= ?) OR (ss.start <= ? AND ss.ende >= ?)
|
||||
)";
|
||||
|
||||
return $this->execReadOnlyQuery($query, array($organizationalUnitShortCode, $startDate, $endDate, $startDate, $endDate));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,4 +347,24 @@ class Studiensemester_model extends DB_Model
|
||||
$result = $this->load($studiensemester_kurzbz);
|
||||
return hasData($result);
|
||||
}
|
||||
|
||||
public function getStudySemestersByStudyPlansAndDatesQueryResponse($studyPlanIds, $fromDate, $toDate)
|
||||
{
|
||||
$subQuery = "(
|
||||
SELECT ARRAY_AGG(DISTINCT sp.semester)
|
||||
FROM lehre.tbl_studienplan_semester sp
|
||||
WHERE sp.studienplan_id IN ?
|
||||
AND sp.studiensemester_kurzbz = s.studiensemester_kurzbz
|
||||
) AS semester_numbers";
|
||||
|
||||
$query = "SELECT DISTINCT s.*," . $subQuery . "
|
||||
FROM public.tbl_studiensemester s
|
||||
JOIN lehre.tbl_studienplan_semester sp ON sp.studiensemester_kurzbz = s.studiensemester_kurzbz
|
||||
WHERE sp.studienplan_id IN ? AND (
|
||||
(s.start >= ? AND s.ende <= ?) OR
|
||||
(s.start <= ? AND s.ende >= ?)
|
||||
)";
|
||||
|
||||
return $this->execQuery($query, array($studyPlanIds, $studyPlanIds, $fromDate, $toDate, $fromDate, $toDate));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user