mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 16:32:20 +00:00
add prefiltering on validity period form component
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user