diff --git a/application/controllers/api/frontend/fas/studstatus/Wiederholung.php b/application/controllers/api/frontend/fas/studstatus/Wiederholung.php new file mode 100644 index 000000000..c6e5a4fa9 --- /dev/null +++ b/application/controllers/api/frontend/fas/studstatus/Wiederholung.php @@ -0,0 +1,161 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + + +/** + * This controller operates between (interface) the JS (FAS) and the AntragLib (back-end) + * This controller works with calls on the HTTP GET or POST and the output is always RDF + */ +class Wiederholung extends Auth_Controller +{ + + /** + * Calls the parent's constructor and loads the FilterCmptLib + */ + public function __construct() + { + parent::__construct([ + 'getLvs' => ['student/studierendenantrag:r', 'student/noten:r'], + 'moveLvsToZeugnis' => ['student/studierendenantrag:w', 'student/noten:w'] + ]); + + // Libraries + $this->load->library('AntragLib'); + + // Load language phrases + $this->loadPhrases([ + 'global', + 'studierendenantrag' + ]); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + public function getLvs($prestudent_id) + { + // header für no cache + $this->output->set_header("Cache-Control: no-cache"); + $this->output->set_header("Cache-Control: post-check=0, pre-check=0", false); + $this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + $this->output->set_header("Pragma: no-cache"); + $this->output->set_header("Content-type: application/xhtml+xml"); + + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $sem_akt = $this->variablelib->getVar('semester_aktuell'); + + + $result = $this->antraglib->getLvsForPrestudent($prestudent_id, $sem_akt); + $lvs = $this->getDataOrTerminateWithError($result) ?: []; + + $rdf_url = 'http://www.technikum-wien.at/antragnote'; + + $this->load->view('lehre/Antrag/Wiederholung/getLvs.rdf.php', [ + 'url' => $rdf_url, + 'lvs' => $lvs + ]); + } + + public function moveLvsToZeugnis() + { + $anzahl = $this->input->post('anzahl'); + $student_uid = $this->input->post('student_uid'); + $this->load->model('education/Studierendenantraglehrveranstaltung_model', 'StudierendenantraglehrveranstaltungModel'); + $this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel'); + + $errormsg = array(); + + for($i=0; $i<$anzahl; $i++) + { + $id = $this->input->post('studierendenantrag_lehrveranstaltung_id_' . $i); + $result =$this->StudierendenantraglehrveranstaltungModel->load($id); + if(isError($result)) + { + $errormsg[] = getError($result); + } + elseif(!hasData($result)) + { + $errormsg[] = $this->p->t('studierendenantrag', 'error_no_lv_in_application'); + } + else + { + $antragLv = getData($result)[0]; + $result= $this->ZeugnisnoteModel->load([ + 'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id, + 'student_uid'=> $student_uid, + 'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz + ]); + if(isError($result)) + { + $errormsg[] = getError($result); + } + else + { + if (hasData($result)) + { + $result = $this->ZeugnisnoteModel->update( + [ + 'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id, + 'student_uid'=> $student_uid, + 'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz + ], + [ + 'note'=> $antragLv->note, + 'uebernahmedatum' => date('c'), + 'benotungsdatum' => $antragLv->insertamum, + 'updateamum' => date('c'), + 'bemerkung'=>$antragLv->anmerkung, + 'updatevon'=>getAuthUID() + ] + ); + } + else + { + $result = $this->ZeugnisnoteModel->insert([ + 'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id, + 'student_uid'=> $student_uid, + 'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz, + 'note'=> $antragLv->note, + 'uebernahmedatum' => date('c'), + 'benotungsdatum' => $antragLv->insertamum, + 'insertamum' => date('c'), + 'bemerkung'=>$antragLv->anmerkung, + 'insertvon'=>getAuthUID() + ]); + } + if(isError($result)) + { + $errormsg[] = getError($result); + } + } + } + } + + if($errormsg) + $return = false; + else + $return = true; + + $this->load->view('lehre/Antrag/Wiederholung/moveLvs.rdf.php', [ + 'return' => $return, + 'errormsg' => $errormsg + ]); + } +} diff --git a/application/controllers/api/frontend/v1/studstatus/Abmeldung.php b/application/controllers/api/frontend/v1/studstatus/Abmeldung.php new file mode 100644 index 000000000..875b6484c --- /dev/null +++ b/application/controllers/api/frontend/v1/studstatus/Abmeldung.php @@ -0,0 +1,187 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +use \REST_Controller as REST_Controller; +use \Studierendenantrag_model as Studierendenantrag_model; + +/** + * This controller operates between (interface) the JS (GUI) and the AntragLib (back-end) + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Abmeldung extends FHCAPI_Controller +{ + + /** + * Calls the parent's constructor and loads the AntragLib + */ + public function __construct() + { + parent::__construct([ + 'getDetailsForNewAntrag' => self::PERM_LOGGED, + 'getDetailsForAntrag' => self::PERM_LOGGED, + 'createAntrag' => self::PERM_LOGGED, + 'cancelAntrag' => self::PERM_LOGGED + ]); + + // Libraries + $this->load->library('AntragLib'); + + // Load language phrases + $this->loadPhrases([ + 'studierendenantrag' + ]); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Retrieves data of the current studiengang for the current user + */ + + public function getDetailsForNewAntrag($prestudent_id) + { + if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, true)) + $this->terminateWithError('Forbidden', self::ERROR_TYPE_AUTH, REST_Controller::HTTP_FORBIDDEN); + + $result = $this->antraglib->getPrestudentAbmeldeBerechtigt($prestudent_id); + $result = $this->getDataOrTerminateWithError($result); + + if (!$result) { + $this->terminateWithError( + $this->p->t('studierendenantrag', 'error_no_student'), + self::ERROR_TYPE_AUTH, + REST_Controller::HTTP_FORBIDDEN + ); + } elseif ($result == -3) { + $this->terminateWithError( + $this->p->t('studierendenantrag', 'error_stg_blacklist'), + self::ERROR_TYPE_AUTH, + REST_Controller::HTTP_FORBIDDEN + ); + } elseif ($result == -1) { + $result = $this->antraglib->getDetailsForLastAntrag( + $prestudent_id, + [ + Studierendenantrag_model::TYP_ABMELDUNG, + Studierendenantrag_model::TYP_ABMELDUNG_STGL + ] + ); + + $data = $this->getDataOrTerminateWithError($result); + + $data->canCancel = ( + $data->status == Studierendenantragstatus_model::STATUS_CREATED && + $this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id) + ); + + $this->terminateWithSuccess($data); + } + + $result = $this->antraglib->getDetailsForNewAntrag($prestudent_id); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getDetailsForAntrag($studierendenantrag_id) + { + if (!$this->antraglib->isEntitledToShowAntrag($studierendenantrag_id)) + return show_404(); + + $result = $this->antraglib->getDetailsForAntrag($studierendenantrag_id); + + $data = $this->getDataOrTerminateWithError($result); + + if ($data->typ !== Studierendenantrag_model::TYP_ABMELDUNG_STGL && $data->typ !== Studierendenantrag_model::TYP_ABMELDUNG) + return show_404(); + + $data->canCancel = ( + $data->status == Studierendenantragstatus_model::STATUS_CREATED && + $this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id) + ); + + $this->terminateWithSuccess($data); + } + + public function createAntrag() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required'); + $this->form_validation->set_rules('prestudent_id', 'Prestudent ID', 'required'); + $this->form_validation->set_rules('grund', 'Grund', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $grund = $this->input->post('grund'); + $studiensemester = $this->input->post('studiensemester'); + $prestudent_id = $this->input->post('prestudent_id'); + + $result = $this->antraglib->getPrestudentAbmeldeBerechtigt($prestudent_id); + $result = $this->getDataOrTerminateWithError($result); + if (!$result) + $this->terminateWithError($this->p->t('studierendenantrag', 'error_no_student'), self::ERROR_TYPE_GENERAL); + elseif ($result == -3) + $this->terminateWithError($this->p->t('studierendenantrag', 'error_stg_blacklist'), self::ERROR_TYPE_GENERAL); + elseif ($result < 0) + $this->terminateWithError($this->p->t('studierendenantrag', 'error_antrag_exists'), self::ERROR_TYPE_GENERAL); + + $result = $this->antraglib->createAbmeldung($prestudent_id, $studiensemester, getAuthUID(), $grund); + $data = $this->getDataOrTerminateWithError($result); + + $result = $this->antraglib->getDetailsForAntrag($data); + if (!hasData($result)) + return $this->terminateWithSuccess(true); + + $data = getData($result); + $data->canCancel = (boolean)$this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id); + + $this->terminateWithSuccess($data); + } + + public function cancelAntrag() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('antrag_id', 'Antrag ID', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $antrag_id = $this->input->post('antrag_id'); + + if (!$this->antraglib->isEntitledToCancelAntrag($antrag_id)) + $this->terminateWithError('Forbidden', self::ERROR_TYPE_AUTH, REST_Controller::HTTP_FORBIDDEN); + + $result = $this->antraglib->cancelAntrag($antrag_id, getAuthUID()); + $this->getDataOrTerminateWithError($result); + + $result = $this->antraglib->getDetailsForAntrag($antrag_id); + if (!hasData($result)) + $this->terminateWithSuccess($antrag_id); + + $data = getData($result); + + $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/api/frontend/v1/studstatus/Leitung.php b/application/controllers/api/frontend/v1/studstatus/Leitung.php new file mode 100644 index 000000000..2699a3dbb --- /dev/null +++ b/application/controllers/api/frontend/v1/studstatus/Leitung.php @@ -0,0 +1,428 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +use \stdClass as stdClass; +use \Studierendenantrag_model as Studierendenantrag_model; + +/** + * This controller operates between (interface) the JS (GUI) and the AntragLib (back-end) + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Leitung extends FHCAPI_Controller +{ + + /** + * Calls the parent's constructor and loads the AntragLib + */ + public function __construct() + { + parent::__construct([ + 'getActiveStgs' => ['student/antragfreigabe:r', 'student/studierendenantrag:r'], + 'getAntraege' => ['student/antragfreigabe:r', 'student/studierendenantrag:r'], + 'getHistory' => ['student/antragfreigabe:r', 'student/studierendenantrag:r'], + 'getPrestudents' => 'student/studierendenantrag:w', + 'approveAntrag' => 'student/antragfreigabe:w', + 'rejectAntrag' => 'student/antragfreigabe:w', + 'reopenAntrag' => 'student/studierendenantrag:w', + 'pauseAntrag' => ['student/antragfreigabe:w', 'student/studierendenantrag:w'], + 'unpauseAntrag' => ['student/antragfreigabe:w', 'student/studierendenantrag:w'], + 'objectAntrag' => ['student/antragfreigabe:w', 'student/studierendenantrag:w'], + 'approveObjection' => ['student/antragfreigabe:w', 'student/studierendenantrag:w'], + 'denyObjection' => ['student/antragfreigabe:w', 'student/studierendenantrag:w'] + ]); + + // Libraries + $this->load->library('AntragLib'); + + // Load language phrases + $this->loadPhrases([ + 'studierendenantrag' + ]); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + public function getActiveStgs() + { + $studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/antragfreigabe') ?: []; + $studiengaenge = array_merge($studiengaenge, $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag') ?: []); + + $result = $this->StudierendenantragModel->loadStgsWithAntraege($studiengaenge); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getAntraege($studiengang = null, $extra = null) + { + if ($studiengang && $studiengang == 'todo') { + $studiengang = $extra; + $extra = true; + } else { + $extra = false; + } + + $studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/antragfreigabe'); + if(!is_array($studiengaenge)) + $studiengaenge = []; + + + $stgsNeuanlage = $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag'); + if(!is_array($stgsNeuanlage)) + $stgsNeuanlage = []; + + $studiengaenge = array_unique(array_merge($studiengaenge, $stgsNeuanlage)); + + if ($studiengang) { + if (!in_array($studiengang, $studiengaenge)) + $this->terminateWithError( + 'Forbidden', + self::ERROR_TYPE_AUTH, + REST_Controller::HTTP_FORBIDDEN + ); + $studiengaenge = [$studiengang]; + } + + $antraege = []; + if ($studiengaenge) { + $result = $extra + ? $this->StudierendenantragModel->loadActiveForStudiengaenge($studiengaenge) + : $this->StudierendenantragModel->loadForStudiengaenge($studiengaenge); + + $antraege = $this->getDataOrTerminateWithError($result); + } + + $this->terminateWithSuccess($antraege ?: []); + } + + public function getHistory($studierendenantrag_id) + { + if (!$this->antraglib->isEntitledToSeeHistoryForAntrag($studierendenantrag_id)) + $this->terminateWithError( + 'Forbidden', + self::ERROR_TYPE_AUTH, + REST_Controller::HTTP_FORBIDDEN + ); + + $result = $this->antraglib->getAntragHistory($studierendenantrag_id); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data ?: []); + } + + public function getPrestudents() + { + $query = $this->input->post('query'); + + $studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag'); + + $result = $this->antraglib->getAktivePrestudentenInStgs($studiengaenge, $query); + $result = $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($result ?: []); + } + + public function approveAntrag() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules( + 'studierendenantrag_id', + 'Studierenden Antrag', + [ + 'required', + ['isEntitledToApproveAntrag', [$this->antraglib, 'isEntitledToApproveAntrag']], + ], + [ + 'isEntitledToApproveAntrag' => $this->p->t('studierendenantrag', 'error_no_right') + ] + ); + $this->form_validation->set_rules( + 'typ', + 'Typ', + 'required|in_list[' . implode(',', [ + Studierendenantrag_model::TYP_ABMELDUNG, + Studierendenantrag_model::TYP_ABMELDUNG_STGL, + Studierendenantrag_model::TYP_UNTERBRECHUNG, + Studierendenantrag_model::TYP_WIEDERHOLUNG + ]) . ']' + ); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $studierendenantrag_id = $this->input->post('studierendenantrag_id'); + switch ($this->input->post('typ')) { + case Studierendenantrag_model::TYP_ABMELDUNG: + case Studierendenantrag_model::TYP_ABMELDUNG_STGL: + $result = $this->antraglib->approveAbmeldung([$studierendenantrag_id], getAuthUID()); + break; + case Studierendenantrag_model::TYP_UNTERBRECHUNG: + $result = $this->antraglib->approveUnterbrechung([$studierendenantrag_id], getAuthUID()); + break; + case Studierendenantrag_model::TYP_WIEDERHOLUNG: + $result = $this->antraglib->approveWiederholung($studierendenantrag_id, getAuthUID()); + break; + } + $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($studierendenantrag_id); + } + + public function rejectAntrag() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules( + 'studierendenantrag_id', + 'Studierenden Antrag', + [ + 'required', + ['isEntitledToRejectAntrag', [$this->antraglib, 'isEntitledToRejectAntrag']], + ], + [ + 'isEntitledToRejectAntrag' => $this->p->t('studierendenantrag', 'error_no_right') + ] + ); + $this->form_validation->set_rules('grund', 'Grund', 'required'); + $this->form_validation->set_rules( + 'typ', + 'Typ', + 'required|in_list[' . implode(',', [ + Studierendenantrag_model::TYP_UNTERBRECHUNG + ]) . ']' + ); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $studierendenantrag_id = $this->input->post('studierendenantrag_id'); + $grund = $this->input->post('grund'); + + $result = $this->antraglib->rejectUnterbrechung([$studierendenantrag_id], getAuthUID(), $grund); + $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($studierendenantrag_id); + } + + public function reopenAntrag() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules( + 'studierendenantrag_id', + 'Studierenden Antrag', + [ + 'required', + ['isEntitledToReopenAntrag', [$this->antraglib, 'isEntitledToReopenAntrag']], + ], + [ + 'isEntitledToReopenAntrag' => $this->p->t('studierendenantrag', 'error_no_right') + ] + ); + $this->form_validation->set_rules( + 'typ', + 'Typ', + 'required|in_list[' . implode(',', [ + Studierendenantrag_model::TYP_WIEDERHOLUNG + ]) . ']' + ); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $studierendenantrag_id = $this->input->post('studierendenantrag_id'); + + $result = $this->antraglib->reopenWiederholung($studierendenantrag_id, getAuthUID()); + $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($studierendenantrag_id); + } + + public function pauseAntrag() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules( + 'studierendenantrag_id', + 'Studierenden Antrag', + [ + 'required', + ['isEntitledToPauseAntrag', [$this->antraglib, 'isEntitledToPauseAntrag']], + ['antragCanBeManualPaused', [$this->antraglib, 'antragCanBeManualPaused']] + ], + [ + 'isEntitledToPauseAntrag' => $this->p->t('studierendenantrag', 'error_no_right'), + 'antragCanBeManualPaused' => $this->p->t( + 'studierendenantrag', + 'error_not_pauseable', + ['id' => $this->input->post('studierendenantrag_id')] + ) + ] + ); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $studierendenantrag_id = $this->input->post('studierendenantrag_id'); + + $result = $this->antraglib->pauseAntrag($studierendenantrag_id, getAuthUID()); + $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($studierendenantrag_id); + } + + public function unpauseAntrag() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules( + 'studierendenantrag_id', + 'Studierenden Antrag', + [ + 'required', + ['isEntitledToUnpauseAntrag', [$this->antraglib, 'isEntitledToUnpauseAntrag']], + ['antragCanBeManualUnpaused', [$this->antraglib, 'antragCanBeManualUnpaused']] + ], + [ + 'isEntitledToUnpauseAntrag' => $this->p->t('studierendenantrag', 'error_no_right'), + 'antragCanBeManualUnpaused' => $this->p->t( + 'studierendenantrag', + 'error_not_paused', + ['id' => $this->input->post('studierendenantrag_id')] + ) + ] + ); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $studierendenantrag_id = $this->input->post('studierendenantrag_id'); + + $result = $this->antraglib->unpauseAntrag($studierendenantrag_id, getAuthUID()); + $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($studierendenantrag_id); + } + + public function objectAntrag() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules( + 'studierendenantrag_id', + 'Studierenden Antrag', + [ + 'required', + ['isEntitledToObjectAntrag', [$this->antraglib, 'isEntitledToObjectAntrag']], + ['canBeObjected', function ($a) { + return $this->antraglib->hasType($a, Studierendenantrag_model::TYP_ABMELDUNG_STGL); + }] + ], + [ + 'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'), + 'canBeObjected' => $this->p->t( + 'studierendenantrag', + 'error_no_objection' + ) + ] + ); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $studierendenantrag_id = $this->input->post('studierendenantrag_id'); + + $result = $this->antraglib->objectAbmeldung($studierendenantrag_id, getAuthUID()); + $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($studierendenantrag_id); + } + + public function approveObjection() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules( + 'studierendenantrag_id', + 'Studierenden Antrag', + [ + 'required', + ['isEntitledToObjectAntrag', [$this->antraglib, 'isEntitledToObjectAntrag']], + ['isObjected', function ($a) { + return $this->antraglib->hasStatus($a, Studierendenantragstatus_model::STATUS_OBJECTED); + }] + ], + [ + 'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'), + 'isObjected' => $this->p->t( + 'studierendenantrag', + 'error_not_objected' + ) + ] + ); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $studierendenantrag_id = $this->input->post('studierendenantrag_id'); + + $result = $this->antraglib->cancelAntrag($studierendenantrag_id, getAuthUID()); + $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($studierendenantrag_id); + } + + public function denyObjection() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules( + 'studierendenantrag_id', + 'Studierenden Antrag', + [ + 'required', + ['isEntitledToObjectAntrag', [$this->antraglib, 'isEntitledToObjectAntrag']], + ['isObjected', function ($a) { + return $this->antraglib->hasStatus($a, Studierendenantragstatus_model::STATUS_OBJECTED); + }] + ], + [ + 'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'), + 'isObjected' => $this->p->t( + 'studierendenantrag', + 'error_not_objected' + ) + ] + ); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $studierendenantrag_id = $this->input->post('studierendenantrag_id'); + $grund = $this->input->post('grund'); + + $result = $this->antraglib->denyObjectionAbmeldung($studierendenantrag_id, getAuthUID(), $grund); + $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($studierendenantrag_id); + } +} diff --git a/application/controllers/components/Antrag/Unterbrechung.php b/application/controllers/api/frontend/v1/studstatus/Unterbrechung.php similarity index 52% rename from application/controllers/components/Antrag/Unterbrechung.php rename to application/controllers/api/frontend/v1/studstatus/Unterbrechung.php index f19139e00..abf58cf4f 100644 --- a/application/controllers/components/Antrag/Unterbrechung.php +++ b/application/controllers/api/frontend/v1/studstatus/Unterbrechung.php @@ -1,4 +1,20 @@ . + */ if (! defined('BASEPATH')) exit('No direct script access allowed'); @@ -6,23 +22,28 @@ use \Studierendenantrag_model as Studierendenantrag_model; use \DateTime as DateTime; /** - * + * This controller operates between (interface) the JS (GUI) and the AntragLib (back-end) + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON */ -class Unterbrechung extends FHC_Controller +class Unterbrechung extends FHCAPI_Controller { /** - * Calls the parent's constructor and loads the FilterCmptLib + * Calls the parent's constructor and loads the AntragLib */ public function __construct() { - parent::__construct(); + parent::__construct([ + 'getDetailsForNewAntrag' => self::PERM_LOGGED, + 'getDetailsForAntrag' => self::PERM_LOGGED, + 'createAntrag' => self::PERM_LOGGED, + 'cancelAntrag' => self::PERM_LOGGED + ]); // Configs $this->load->config('studierendenantrag'); // Libraries - $this->load->library('AuthLib'); $this->load->library('AntragLib'); // Load language phrases @@ -38,74 +59,62 @@ class Unterbrechung extends FHC_Controller public function getDetailsForNewAntrag($prestudent_id) { - if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, false)) { - $this->output->set_status_header(403); - return $this->outputJsonError('Forbidden'); - } + if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, false)) + $this->terminateWithError('Forbidden', self::ERROR_TYPE_AUTH, REST_Controller::HTTP_FORBIDDEN); + $result = $this->antraglib->getPrestudentUnterbrechungsBerechtigt($prestudent_id); - if (isError($result)) { - $this->output->set_status_header(500); - return $this->outputJsonError(getError($result)); - } - $result = $result->retval; + $result = $this->getDataOrTerminateWithError($result); + if (!$result) { - $this->output->set_status_header(403); - return $this->outputJsonError($this->p->t('studierendenantrag', 'error_no_student')); - } - elseif ($result == -1) - { + $this->terminateWithError( + $this->p->t('studierendenantrag', 'error_no_student'), + self::ERROR_TYPE_AUTH, + REST_Controller::HTTP_FORBIDDEN + ); + } elseif ($result == -1) { $result = $this->antraglib->getDetailsForLastAntrag($prestudent_id, Studierendenantrag_model::TYP_UNTERBRECHUNG); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } + + $data = $this->getDataOrTerminateWithError($result); - return $this->outputJsonSuccess(getData($result)); - } - elseif ($result == -2) - { + return $this->terminateWithSuccess($data); + } elseif ($result == -2) { $result = $this->antraglib->getDetailsForLastAntrag($prestudent_id); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } - $result = getData($result); - $this->output->set_status_header(400); - return $this->outputJsonError($this->p->t('studierendenantrag', 'error_antrag_pending', [ + $data = $this->getDataOrTerminateWithError($result); + + return $this->terminateWithError($this->p->t('studierendenantrag', 'error_antrag_pending', [ 'typ' => $this->p->t('studierendenantrag', 'antrag_typ_' . $result->typ) ])); - } - elseif ($result == -3) - { - $this->output->set_status_header(403); - return $this->outputJsonError($this->p->t('studierendenantrag', 'error_stg_blacklist')); - } - $result = $this->antraglib->getDetailsForNewAntrag($prestudent_id); - if (isError($result)) { - return $this->outputJsonError(getError($result)); + } elseif ($result == -3) { + $this->terminateWithError( + $this->p->t('studierendenantrag', 'error_stg_blacklist'), + self::ERROR_TYPE_AUTH, + REST_Controller::HTTP_FORBIDDEN + ); } - $data = getData($result); + $result = $this->antraglib->getDetailsForNewAntrag($prestudent_id); + + $data = $this->getDataOrTerminateWithError($result); $data->studiensemester = $this->antraglib->getSemesterForUnterbrechung($prestudent_id, null); - $this->outputJsonSuccess($data); + $this->terminateWithSuccess($data); } public function getDetailsForAntrag($studierendenantrag_id) { - if (!$this->antraglib->isEntitledToShowAntrag($studierendenantrag_id)) return show_404(); + if (!$this->antraglib->isEntitledToShowAntrag($studierendenantrag_id)) + return show_404(); $result = $this->antraglib->getDetailsForAntrag($studierendenantrag_id); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } - $data = getData($result); + $data = $this->getDataOrTerminateWithError($result); if ($data->typ !== Studierendenantrag_model::TYP_UNTERBRECHUNG) return show_404(); - $this->outputJsonSuccess($data); + $this->terminateWithSuccess($data); } public function createAntrag() @@ -125,9 +134,8 @@ class Unterbrechung extends FHC_Controller ] ); - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); + if (!$this->form_validation->run()) { + $this->terminateWithValidationErrors($this->form_validation->error_array()); } $grund = $this->input->post('grund'); @@ -137,25 +145,17 @@ class Unterbrechung extends FHC_Controller $dms_id = null; $result = $this->antraglib->getPrestudentUnterbrechungsBerechtigt($prestudent_id, $studiensemester, $datum_wiedereinstieg); - if (isError($result)) { - return $this->outputJsonError(['db' => getError($result)]); - } - $result = $result->retval; - if (!$result) - { - return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_no_student')]); - } - elseif ($result == -3) - { - return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_stg_blacklist')]); - } - elseif ($result < 0) - { - return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_antrag_exists')]); - } - if(isset($_FILES['attachment']) && (!isset($_FILES['attachment']['error']) || $_FILES['attachment']['error'] != UPLOAD_ERR_NO_FILE)) - { + $result = $this->getDataOrTerminateWithError($result); + + if (!$result) + $this->terminateWithError($this->p->t('studierendenantrag', 'error_no_student'), self::ERROR_TYPE_GENERAL); + elseif ($result == -3) + $this->terminateWithError($this->p->t('studierendenantrag', 'error_stg_blacklist'), self::ERROR_TYPE_GENERAL); + elseif ($result < 0) + $this->terminateWithError($this->p->t('studierendenantrag', 'error_antrag_exists'), self::ERROR_TYPE_GENERAL); + + if (isset($_FILES['attachment']) && (!isset($_FILES['attachment']['error']) || $_FILES['attachment']['error'] != UPLOAD_ERR_NO_FILE)) { $this->load->library('DmsLib'); $dms = $this->config->item('unterbrechung_dms'); @@ -167,53 +167,46 @@ class Unterbrechung extends FHC_Controller $allowed_filetypes = $this->config->item('unterbrechung_dms_filetypes') ?: ['*']; $result = $this->dmslib->upload($dms, 'attachment', $allowed_filetypes); - if(isError($result)) - { - return $this->outputJsonError(['db' => getError($result)]); - } - $dms_id = getData($result)['dms_id']; + + $data = $this->getDataOrTerminateWithError($result); + + $dms_id = $data['dms_id']; } $result = $this->antraglib->createUnterbrechung($prestudent_id, $studiensemester, getAuthUID(), $grund, $datum_wiedereinstieg, $dms_id); - if(isError($result)) - { - return $this->outputJsonError(['db' => getError($result)]); - } - $antragId = getData($result); + $antragId = $this->getDataOrTerminateWithError($result); + $result = $this->antraglib->getDetailsForAntrag($antragId); - if(!hasData($result)) - return $this->outputJsonSuccess($antragId); - $this->outputJsonSuccess(getData($result)); + if (!hasData($result)) + $this->terminateWithSuccess($antragId); + + $this->terminateWithSuccess(getData($result)); } public function cancelAntrag() { $this->load->library('form_validation'); - $_POST = json_decode($this->input->raw_input_stream, true); - $this->form_validation->set_rules('antrag_id', 'Antrag ID', 'required'); - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); + if (!$this->form_validation->run()) { + $this->terminateWithValidationErrors($this->form_validation->error_array()); } $antrag_id = $this->input->post('antrag_id'); $result = $this->antraglib->cancelAntrag($antrag_id, getAuthUID()); - if (isError($result)) - { - return $this->outputJsonError(['db' => getError($result)]); - } + + $this->getDataOrTerminateWithError($result); $result = $this->antraglib->getDetailsForAntrag($antrag_id); if (!hasData($result)) - return $this->outputJsonSuccess($antrag_id); - $this->outputJsonSuccess(getData($result)); + return $this->terminateWithSuccess($antrag_id); + + $this->terminateWithSuccess(getData($result)); } public function isValidDate($date) diff --git a/application/controllers/api/frontend/v1/studstatus/Wiederholung.php b/application/controllers/api/frontend/v1/studstatus/Wiederholung.php new file mode 100644 index 000000000..1a8f70d52 --- /dev/null +++ b/application/controllers/api/frontend/v1/studstatus/Wiederholung.php @@ -0,0 +1,258 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +use \REST_Controller as REST_Controller; +use \Studierendenantragstatus_model as Studierendenantragstatus_model; + +/** + * This controller operates between (interface) the JS (GUI) and the AntragLib (back-end) + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Wiederholung extends FHCAPI_Controller +{ + + /** + * Calls the parent's constructor and loads the FilterCmptLib + */ + public function __construct() + { + parent::__construct([ + 'getDetailsForNewAntrag' => self::PERM_LOGGED, + 'createAntrag' => self::PERM_LOGGED, + 'cancelAntrag' => self::PERM_LOGGED, + 'getLvs' => self::PERM_LOGGED, + 'saveLvs' => ['student/studierendenantrag:w'] + ]); + + // Libraries + $this->load->library('AntragLib'); + + // Load language phrases + $this->loadPhrases([ + 'global', + 'studierendenantrag' + ]); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Retrieves data of the current studiengang for the current user + */ + + public function getDetailsForNewAntrag($prestudent_id) + { + if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, false)) + $this->terminateWithError('Forbidden', self::ERROR_TYPE_AUTH, REST_Controller::HTTP_FORBIDDEN); + + $result = $this->antraglib->getPrestudentWiederholungsBerechtigt($prestudent_id); + $result = $this->getDataOrTerminateWithError($result); + + if (!$result) { + $this->terminateWithError( + $this->p->t('studierendenantrag', 'error_no_student_no_failed_exam'), + self::ERROR_TYPE_AUTH, + REST_Controller::HTTP_FORBIDDEN + ); + } elseif ($result == -1) { + $result = $this->antraglib->getDetailsForLastAntrag($prestudent_id, Studierendenantrag_model::TYP_WIEDERHOLUNG); + $data = $this->getDataOrTerminateWithError($result); + + $result = $this->antraglib->getFailedExamForPrestudent($prestudent_id, $data->datum, $data->studiensemester_kurzbz); + // NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt() + $pruefungsdata = current(getData($result)); + + $data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz; + $data->lvbezeichnung = $pruefungsdata->lvbezeichnung; + $data->pruefungsdatum = $pruefungsdata->datum; + + $this->terminateWithSuccess($data); + } elseif ($result == -2) { + $result = $this->antraglib->getDetailsForLastAntrag($prestudent_id); + $result = $this->getDataOrTerminateWithError($result); + + $this->terminateWithError( + $this->p->t('studierendenantrag', 'error_antrag_pending', [ + 'typ' => $this->p->t('studierendenantrag', 'antrag_typ_' . $result->typ) + ]), + self::ERROR_TYPE_GENERAL, + REST_Controller::HTTP_BAD_REQUEST + ); + } elseif ($result == -3) { + $this->terminateWithError( + $this->p->t('studierendenantrag', 'error_stg_blacklist'), + self::ERROR_TYPE_GENERAL, + REST_Controller::HTTP_BAD_REQUEST + ); + } + + $result = $this->antraglib->getDetailsForNewAntrag($prestudent_id); + $data = $this->getDataOrTerminateWithError($result); + + $result = $this->antraglib->getFailedExamForPrestudent($prestudent_id); + // NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt() + $pruefungsdata = current(getData($result)); + + $data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz; + $data->lvbezeichnung = $pruefungsdata->lvbezeichnung; + $data->pruefungsdatum = $pruefungsdata->datum; + + $this->terminateWithSuccess($data); + } + + public function createAntrag() + { + $this->createAntragWithStatus(true); + } + + public function cancelAntrag() + { + $this->createAntragWithStatus(false); + } + + protected function createAntragWithStatus($repeat) + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('prestudent_id', 'Prestudent ID', 'required'); + $this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $prestudent_id = $this->input->post('prestudent_id'); + $studiensemester = $this->input->post('studiensemester'); + + $result = $this->antraglib->getPrestudentWiederholungsBerechtigt($prestudent_id); + $result = $this->getDataOrTerminateWithError($result); + + if (!$result) { + $this->terminateWithError($this->p->t('studierendenantrag', 'error_no_student'), self::ERROR_TYPE_GENERAL); + } elseif ($result == -1) { + $result = $this->PrestudentstatusModel->getLastStatus($prestudent_id); + $result = $this->getDataOrTerminateWithError($result); + if (!$result) + $this->terminateWithError($this->p->t('studierendenantrag', 'error_no_prestudentstatus', [ + 'prestudent_id' => $prestudent_id + ]), self::ERROR_TYPE_GENERAL); + if (!in_array(current($result)->status_kurzbz, $this->config->item('antrag_prestudentstatus_whitelist'))) + $this->terminateWithError($this->p->t('studierendenantrag', 'error_no_student'), self::ERROR_TYPE_GENERAL); + } elseif ($result == -2) { + $this->terminateWithError($this->p->t('studierendenantrag', 'error_antrag_exists'), self::ERROR_TYPE_GENERAL); + } elseif ($result == -3) { + $this->terminateWithError($this->p->t('studierendenantrag', 'error_stg_blacklist'), self::ERROR_TYPE_GENERAL); + } + + $result = $this->antraglib->createWiederholung($prestudent_id, $studiensemester, getAuthUID(), $repeat); + $antragId = $this->getDataOrTerminateWithError($result); + + $result = $this->antraglib->getDetailsForAntrag($antragId); + + if (!hasData($result)) + $this->terminateWithSuccess(true); + + $data = getData($result); + + $result = $this->antraglib->getFailedExamForPrestudent($prestudent_id); + // NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt() + $pruefungsdata = current(getData($result)); + + $data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz; + $data->lvbezeichnung = $pruefungsdata->lvbezeichnung; + $data->pruefungsdatum = $pruefungsdata->datum; + + $this->terminateWithSuccess($data); + } + + + public function getLvs($antrag_id) + { + $result = $this->antraglib->getLvsForAntrag($antrag_id); + if (isError($result)) { + $error = getError($result); + if ($error == 'Forbidden') + $this->terminateWithError( + $error, + self::ERROR_TYPE_AUTH, + REST_Controller::HTTP_FORBIDDEN + ); + $this->terminateWithError( + $error, + self::ERROR_TYPE_GENERAL + ); + } + $lvs = getData($result); + + $this->terminateWithSuccess($lvs); + } + + public function saveLvs() + { + $forbiddenLvs = $this->input->post('forbiddenLvs'); + $mandatoryLvs = $this->input->post('mandatoryLvs'); + $antragsLvs = array_merge($forbiddenLvs, $mandatoryLvs); + + if (!$antragsLvs) + $this->terminateWithError($this->p->t('studierendenantrag', 'error_no_lv'), self::ERROR_TYPE_GENERAL); + + $insert = array_map(function ($lv) { + return [ + 'studierendenantrag_id' => $lv['studierendenantrag_id'], + 'lehrveranstaltung_id' => $lv['lehrveranstaltung_id'], + 'note' => $lv['zugelassen'] + ? ($lv['zugelassen'] == 1 ? 0 : $this->config->item('wiederholung_note_angerechnet')) + : $this->config->item('wiederholung_note_nicht_zugelassen'), + 'anmerkung' => $lv['anmerkung'], + 'insertvon' => getAuthUID(), + 'studiensemester_kurzbz' => $lv['studiensemester_kurzbz'] + ]; + }, $antragsLvs); + + $antrag_ids = array_unique(array_map(function ($lv) { + return $lv['studierendenantrag_id']; + }, $insert)); + + foreach ($antrag_ids as $antrag_id) { + $result = $this->StudierendenantragModel->loadIdAndStatusWhere([ + 'studierendenantrag_id' => $antrag_id + ]); + $antrag = $this->getDataOrTerminateWithError($result); + if (!$antrag) + $this->terminateWithError( + $this->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $antrag_id]), + self::ERROR_TYPE_GENERAL + ); + $antrag = current($antrag); + + if ($antrag->status != Studierendenantragstatus_model::STATUS_CREATED + && $antrag->status != Studierendenantragstatus_model::STATUS_LVSASSIGNED) + $this->terminateWithError( + $this->p->t('studierendenantrag', 'error_antrag_locked'), + self::ERROR_TYPE_GENERAL + ); + } + + $result = $this->antraglib->saveLvs($insert); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/components/Antrag/Abmeldung.php b/application/controllers/components/Antrag/Abmeldung.php deleted file mode 100644 index f30de6803..000000000 --- a/application/controllers/components/Antrag/Abmeldung.php +++ /dev/null @@ -1,218 +0,0 @@ -load->library('AuthLib'); - $this->load->library('AntragLib'); - - // Load language phrases - $this->loadPhrases([ - 'studierendenantrag' - ]); - } - - //------------------------------------------------------------------------------------------------------------------ - // Public methods - - /** - * Retrieves data of the current studiengang for the current user - */ - - public function getDetailsForNewAntrag($prestudent_id) - { - if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, true)) { - $this->output->set_status_header(403); - return $this->outputJsonError('Forbidden'); - } - $result = $this->antraglib->getPrestudentAbmeldeBerechtigt($prestudent_id); - if (isError($result)) { - $this->output->set_status_header(500); - return $this->outputJsonError(getError($result)); - } - $result = $result->retval; - if (!$result) { - $this->output->set_status_header(403); - return $this->outputJsonError($this->p->t('studierendenantrag', 'error_no_student')); - } - elseif ($result == -3) - { - $this->output->set_status_header(403); - return $this->outputJsonError($this->p->t('studierendenantrag', 'error_stg_blacklist')); - } - elseif ($result == -1) - { - $result = $this->antraglib->getDetailsForLastAntrag( - $prestudent_id, - [ - Studierendenantrag_model::TYP_ABMELDUNG, - Studierendenantrag_model::TYP_ABMELDUNG_STGL - ] - ); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } - - $data = getData($result); - - $data->canCancel = ( - $data->status == Studierendenantragstatus_model::STATUS_CREATED && - $this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id) - ); - - return $this->outputJsonSuccess($data); - } - - $result = $this->antraglib->getDetailsForNewAntrag($prestudent_id); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } - - $this->outputJsonSuccess(getData($result)); - } - - public function getDetailsForAntrag($studierendenantrag_id) - { - if (!$this->antraglib->isEntitledToShowAntrag($studierendenantrag_id)) return show_404(); - - $result = $this->antraglib->getDetailsForAntrag($studierendenantrag_id); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } - - $data = getData($result); - - if ($data->typ !== Studierendenantrag_model::TYP_ABMELDUNG_STGL && $data->typ !== Studierendenantrag_model::TYP_ABMELDUNG) - return show_404(); - - $data->canCancel = ( - $data->status == Studierendenantragstatus_model::STATUS_CREATED && - $this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id) - ); - - $this->outputJsonSuccess($data); - } - - public function createAntrag() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required'); - $this->form_validation->set_rules('prestudent_id', 'Prestudent ID', 'required'); - $this->form_validation->set_rules('grund', 'Grund', 'required'); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $grund = $this->input->post('grund'); - $studiensemester = $this->input->post('studiensemester'); - $prestudent_id = $this->input->post('prestudent_id'); - - $result = $this->antraglib->getPrestudentAbmeldeBerechtigt($prestudent_id); - if (isError($result)) { - return $this->outputJsonError(['db' => getError($result)]); - } - $result = $result->retval; - if (!$result) - { - return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_no_student')]); - } - elseif ($result == -3) - { - return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_stg_blacklist')]); - } - elseif ($result < 0) - { - return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_antrag_exists')]); - } - - $result = $this->antraglib->createAbmeldung($prestudent_id, $studiensemester, getAuthUID(), $grund); - if (isError($result)) - { - return $this->outputJsonError(['db' => getError($result)]); - } - - $result = $this->antraglib->getDetailsForAntrag(getData($result)); - if (!hasData($result)) - return $this->outputJsonSuccess(true); - - $data = getData($result); - $data->canCancel = (boolean)$this->antraglib->isEntitledToCancelAntrag($data->studierendenantrag_id); - - $this->outputJsonSuccess($data); - } - - public function cancelAntrag() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules('antrag_id', 'Antrag ID', 'required'); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $antrag_id = $this->input->post('antrag_id'); - if(!$this->antraglib->isEntitledToCancelAntrag($antrag_id)) - { - $this->output->set_status_header(403); - - return $this->outputJsonError('Forbidden'); - } - - $result = $this->antraglib->cancelAntrag($antrag_id, getAuthUID()); - if(isError($result)) - { - return $this->outputJsonError(['db' => getError($result)]); - } - - $result = $this->antraglib->getDetailsForAntrag($antrag_id); - - if (!hasData($result)) - return $this->outputJsonSuccess($antrag_id); - $this->outputJsonSuccess(getData($result)); - } - - public function getStudiengaengeAssistenz() - { - $this->load->library('PermissionLib'); - - $_POST = json_decode($this->input->raw_input_stream, true); - $query = $this->input->post('query'); - - $studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag'); - - $result = $this->antraglib->getAktivePrestudentenInStgs($studiengaenge, $query); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } - $result = getData($result); - if (!$result) { - return $this->outputJsonSuccess([]); - } - - return $this->outputJsonSuccess($result); - } -} diff --git a/application/controllers/components/Antrag/Leitung.php b/application/controllers/components/Antrag/Leitung.php deleted file mode 100644 index 437030d08..000000000 --- a/application/controllers/components/Antrag/Leitung.php +++ /dev/null @@ -1,479 +0,0 @@ -load->library('AuthLib'); - $this->load->library('AntragLib'); - - // Load language phrases - $this->loadPhrases([ - 'studierendenantrag' - ]); - } - - - //------------------------------------------------------------------------------------------------------------------ - // Public methods - - public function getActiveStgs() - { - $studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/antragfreigabe') ?: []; - $studiengaenge = array_merge($studiengaenge, $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag') ?: []); - - $result = $this->StudierendenantragModel->loadStgsWithAntraege($studiengaenge); - if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - } - $this->outputJson($result); - } - - public function getAntraege($studiengang = null, $extra = null) - { - if ($studiengang && $studiengang == 'todo') { - $studiengang = $extra; - $extra = true; - } else { - $extra = false; - } - - if ($studiengang) { - $studiengaenge = [$studiengang]; - } else { - $studiengaenge =$this->permissionlib->getSTG_isEntitledFor('student/antragfreigabe'); - if(!is_array($studiengaenge)) - $studiengaenge = []; - - - $stgsNeuanlage = $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag'); - if(!is_array($stgsNeuanlage)) - $stgsNeuanlage = []; - - $studiengaenge = array_unique(array_merge($studiengaenge, $stgsNeuanlage)); - } - - - $antraege = []; - if ($studiengaenge) { - $result = $extra - ? $this->StudierendenantragModel->loadActiveForStudiengaenge($studiengaenge) - : $this->StudierendenantragModel->loadForStudiengaenge($studiengaenge); - if (isError($result)) { - $this->output->set_status_header(500); - return $this->outputJson('Internal Server Error'); - } - if(hasData($result)) - { - $antraege = getData($result); - } - } - - $this->outputJson($antraege); - } - - public function reopenAntrag() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules( - 'studierendenantrag_id', - 'Studierenden Antrag', - 'required|callback_isEntitledToReopenAntrag', - [ - 'isEntitledToReopenAntrag' => $this->p->t('studierendenantrag', 'error_no_right') - ] - ); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $studierendenantrag_id = $this->input->post('studierendenantrag_id'); - - $result = $this->antraglib->reopenWiederholung($studierendenantrag_id, getAuthUID()); - - if (isError($result)) - return $this->outputJsonError(['studierendenantrag_id' => getError($result)]); - - $this->outputJsonSuccess($studierendenantrag_id); - } - - public function pauseAntrag() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules( - 'studierendenantrag_id', - 'Studierenden Antrag', - [ - 'required', - [ - 'isEntitledToPauseAntrag', - [$this->antraglib, 'isEntitledToPauseAntrag'] - ], - [ - 'antragCanBeManualPaused', - [$this->antraglib, 'antragCanBeManualPaused'] - ] - ], - [ - 'isEntitledToPauseAntrag' => $this->p->t('studierendenantrag', 'error_no_right'), - 'antragCanBeManualPaused' => $this->p->t( - 'studierendenantrag', - 'error_not_pauseable', - ['id' => $this->input->post('studierendenantrag_id')] - ) - ] - ); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $studierendenantrag_id = $this->input->post('studierendenantrag_id'); - - $result = $this->antraglib->pauseAntrag($studierendenantrag_id, getAuthUID()); - - if (isError($result)) - return $this->outputJsonError(['studierendenantrag_id' => getError($result)]); - - $this->outputJsonSuccess($studierendenantrag_id); - } - - public function unpauseAntrag() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules( - 'studierendenantrag_id', - 'Studierenden Antrag', - [ - 'required', - [ - 'isEntitledToUnpauseAntrag', - [$this->antraglib, 'isEntitledToUnpauseAntrag'] - ], - [ - 'antragCanBeManualUnpaused', - [$this->antraglib, 'antragCanBeManualUnpaused'] - ] - ], - [ - 'isEntitledToUnpauseAntrag' => $this->p->t('studierendenantrag', 'error_no_right'), - 'antragCanBeManualUnpaused' => $this->p->t( - 'studierendenantrag', - 'error_not_paused', - ['id' => $this->input->post('studierendenantrag_id')] - ) - ] - ); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $studierendenantrag_id = $this->input->post('studierendenantrag_id'); - - $result = $this->antraglib->unpauseAntrag($studierendenantrag_id, getAuthUID()); - - if (isError($result)) - return $this->outputJsonError(['studierendenantrag_id' => getError($result)]); - - $this->outputJsonSuccess($studierendenantrag_id); - } - - public function objectAntrag() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules( - 'studierendenantrag_id', - 'Studierenden Antrag', - 'required|callback_isEntitledToObjectAntrag|callback_canBeObjected', - [ - 'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'), - 'canBeObjected' => $this->p->t('studierendenantrag', 'error_no_objection') - ] - ); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $studierendenantrag_id = $this->input->post('studierendenantrag_id'); - - $result = $this->antraglib->objectAbmeldung($studierendenantrag_id, getAuthUID()); - - if (isError($result)) - return $this->outputJsonError(['studierendenantrag_id' => getError($result)]); - - $this->outputJsonSuccess($studierendenantrag_id); - } - - public function objectionDeny() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules( - 'studierendenantrag_id', - 'Studierenden Antrag', - 'required|callback_isEntitledToObjectAntrag|callback_isObjected', - [ - 'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'), - 'isObjected' => $this->p->t('studierendenantrag', 'error_not_objected') - ] - ); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $studierendenantrag_id = $this->input->post('studierendenantrag_id'); - $grund = $this->input->post('grund'); - - $result = $this->antraglib->denyObjectionAbmeldung($studierendenantrag_id, getAuthUID(), $grund); - - if (isError($result)) - return $this->outputJsonError(['studierendenantrag_id' => getError($result)]); - - $this->outputJsonSuccess($studierendenantrag_id); - } - - public function objectionApprove() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules( - 'studierendenantrag_id', - 'Studierenden Antrag', - 'required|callback_isEntitledToObjectAntrag|callback_isObjected', - [ - 'isEntitledToObjectAntrag' => $this->p->t('studierendenantrag', 'error_no_right'), - 'isObjected' => $this->p->t('studierendenantrag', 'error_not_objected') - ] - ); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $studierendenantrag_id = $this->input->post('studierendenantrag_id'); - - $result = $this->antraglib->cancelAntrag($studierendenantrag_id, getAuthUID()); - - if (isError($result)) - return $this->outputJsonError(['studierendenantrag_id' => getError($result)]); - - $this->outputJsonSuccess($studierendenantrag_id); - } - - public function isEntitledToReopenAntrag($studierendenantrag_id) - { - return $this->antraglib->isEntitledToReopenAntrag($studierendenantrag_id); - } - - public function isEntitledToObjectAntrag($studierendenantrag_id) - { - return $this->antraglib->isEntitledToObjectAntrag($studierendenantrag_id); - } - - public function isEntitledToRejectAntrag($studierendenantrag_id) - { - return $this->antraglib->isEntitledToRejectAntrag($studierendenantrag_id); - } - - public function canBeObjected($studierendenantrag_id) - { - return $this->antraglib->hasType($studierendenantrag_id, Studierendenantrag_model::TYP_ABMELDUNG_STGL); - } - - public function isObjected($studierendenantrag_id) - { - return $this->antraglib->hasStatus($studierendenantrag_id, Studierendenantragstatus_model::STATUS_OBJECTED); - } - - - public function approveAbmeldung() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules( - 'studierendenantrag_id', - 'Studierenden Antrag', - 'required|callback_isEntitledToApproveAntrag', - [ - 'isEntitledToApproveAntrag' => $this->p->t('studierendenantrag', 'error_no_right') - ] - ); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $studierendenantrag_id = $this->input->post('studierendenantrag_id'); - - $result = $this->antraglib->approveAbmeldung([$studierendenantrag_id], getAuthUID()); - if (isError($result)) - { - return $this->outputJsonError(['db' => getError($result)]); - } - - return $this->outputJsonSuccess($studierendenantrag_id); - } - - public function approveAbmeldungStgl() - { - return $this->approveAbmeldung(); - } - - public function approveUnterbrechung() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules( - 'studierendenantrag_id', - 'Studierenden Antrag', - 'required|callback_isEntitledToApproveAntrag', - [ - 'isEntitledToApproveAntrag' => $this->p->t('studierendenantrag', 'error_no_right') - ] - ); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $studierendenantrag_id = $this->input->post('studierendenantrag_id'); - - $result = $this->antraglib->approveUnterbrechung([$studierendenantrag_id], getAuthUID()); - if (isError($result)) - { - return $this->outputJsonError(['db' => getError($result)]); - } - - return $this->outputJsonSuccess($studierendenantrag_id); - } - - public function rejectUnterbrechung() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules( - 'studierendenantrag_id', - 'Studierenden Antrag', - 'required|callback_isEntitledToRejectAntrag', - [ - 'isEntitledToRejectAntrag' => $this->p->t('studierendenantrag', 'error_no_right') - ] - ); - $this->form_validation->set_rules('grund', 'Grund', 'required'); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $studierendenantrag_id = $this->input->post('studierendenantrag_id'); - $grund = $this->input->post('grund'); - - $result = $this->antraglib->rejectUnterbrechung([$studierendenantrag_id], getAuthUID(), $grund); - if (isError($result)) - { - return $this->outputJsonError(['db' => getError($result)]); - } - - return $this->outputJsonSuccess($studierendenantrag_id); - } - - public function approveWiederholung() - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules( - 'studierendenantrag_id', - 'Studierenden Antrag', - 'required|callback_isEntitledToApproveAntrag', - [ - 'isEntitledToApproveAntrag' => $this->p->t('studierendenantrag', 'error_no_right') - ] - ); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $studierendenantrag_id = $this->input->post('studierendenantrag_id'); - - $result = $this->antraglib->approveWiederholung($studierendenantrag_id, getAuthUID()); - if (isError($result)) - { - return $this->outputJsonError(['db' => getError($result)]); - } - - return $this->outputJsonSuccess($studierendenantrag_id); - } - - public function isEntitledToApproveAntrag($studierendenantrag_id) - { - return $this->antraglib->isEntitledToApproveAntrag($studierendenantrag_id); - } - - public function getHistory($studierendenantrag_id) - { - if (!$this->antraglib->isEntitledToSeeHistoryForAntrag($studierendenantrag_id)) { - $this->output->set_status_header(403); - return $this->outputJson('Forbidden'); - } - - $result = $this->antraglib->getAntragHistory($studierendenantrag_id); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } - - $this->outputJsonSuccess(getData($result) ?: []); - } -} diff --git a/application/controllers/components/Antrag/Wiederholung.php b/application/controllers/components/Antrag/Wiederholung.php deleted file mode 100644 index 2c672be54..000000000 --- a/application/controllers/components/Antrag/Wiederholung.php +++ /dev/null @@ -1,384 +0,0 @@ -load->config('studierendenantrag'); - - // Libraries - $this->load->library('AuthLib'); - $this->load->library('PermissionLib'); - $this->load->library('AntragLib'); - - $requiredPermissions = [ - 'saveLvs' => ['student/studierendenantrag:w'], - 'getLvsAsRdf' => ['student/studierendenantrag:r', 'student/noten:r'], - 'moveLvsToZeugnis' => ['student/studierendenantrag:w', 'student/noten:w'] - ]; - - if (isset($requiredPermissions[$this->router->method])) { - if (!$this->permissionlib->isEntitled($requiredPermissions, $this->router->method)) { - $this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN); - $this->outputJson('Forbidden'); - exit; - } - } - - // Load language phrases - $this->loadPhrases([ - 'global', - 'studierendenantrag' - ]); - } - - - //------------------------------------------------------------------------------------------------------------------ - // Public methods - - /** - * Retrieves data of the current studiengang for the current user - */ - - public function getDetailsForNewAntrag($prestudent_id) - { - if (!$this->antraglib->isEntitledToCreateAntragFor($prestudent_id, false)) { - $this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN); - return $this->outputJsonError('Forbidden'); - } - $result = $this->antraglib->getPrestudentWiederholungsBerechtigt($prestudent_id); - if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJsonError(getError($result)); - } - $result = $result->retval; - if (!$result) { - $this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN); - return $this->outputJsonError($this->p->t('studierendenantrag', 'error_no_student_no_failed_exam')); - } - elseif ($result == -1) - { - $result = $this->antraglib->getDetailsForLastAntrag($prestudent_id, Studierendenantrag_model::TYP_WIEDERHOLUNG); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } - $data = getData($result); - - $result = $this->antraglib->getFailedExamForPrestudent($prestudent_id, $data->datum, $data->studiensemester_kurzbz); - // NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt() - $pruefungsdata = current(getData($result)); - - $data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz; - $data->lvbezeichnung = $pruefungsdata->lvbezeichnung; - $data->pruefungsdatum = $pruefungsdata->datum; - - return $this->outputJsonSuccess($data); - } - elseif ($result == -2) - { - $result = $this->antraglib->getDetailsForLastAntrag($prestudent_id); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } - - $result = getData($result); - $this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST); - return $this->outputJsonError($this->p->t('studierendenantrag', 'error_antrag_pending', [ - 'typ' => $this->p->t('studierendenantrag', 'antrag_typ_' . $result->typ) - ])); - } - elseif ($result == -3) - { - $this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST); - return $this->outputJsonError($this->p->t('studierendenantrag', 'error_stg_blacklist')); - } - - $result = $this->antraglib->getDetailsForNewAntrag($prestudent_id); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } - - $data = getData($result); - - $result = $this->antraglib->getFailedExamForPrestudent($prestudent_id); - // NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt() - $pruefungsdata = current(getData($result)); - - $data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz; - $data->lvbezeichnung = $pruefungsdata->lvbezeichnung; - $data->pruefungsdatum = $pruefungsdata->datum; - - $this->outputJsonSuccess($data); - } - - public function createAntrag() - { - $this->createAntragWithStatus(true); - } - - public function cancelAntrag() - { - $this->createAntragWithStatus(false); - } - - protected function createAntragWithStatus($repeat) - { - $this->load->library('form_validation'); - - $_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules('prestudent_id', 'Prestudent ID', 'required'); - $this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required'); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $prestudent_id = $this->input->post('prestudent_id'); - $studiensemester = $this->input->post('studiensemester'); - - $result = $this->antraglib->getPrestudentWiederholungsBerechtigt($prestudent_id); - if (isError($result)) { - return $this->outputJsonError(['db' => getError($result)]); - } - $result = $result->retval; - if (!$result) - { - return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_no_student')]); - } - elseif ($result == -1) - { - $result = $this->PrestudentstatusModel->getLastStatus($prestudent_id); - if (isError($result)) - return $this->outputJsonError(['db' => getError($result)]); - if (!hasData($result)) - return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_no_prestudentstatus', [ - 'prestudent_id' => $prestudent_id - ])]); - if (!in_array(current(getData($result))->status_kurzbz, $this->config->item('antrag_prestudentstatus_whitelist'))) - return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_no_student')]); - } - elseif ($result == -2) - { - return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_antrag_exists')]); - } - elseif ($result == -3) - { - return $this->outputJsonError(['db' => $this->p->t('studierendenantrag', 'error_stg_blacklist')]); - } - - $result = $this->antraglib->createWiederholung($prestudent_id, $studiensemester, getAuthUID(), $repeat); - if(isError($result)) - { - return $this->outputJsonError(['db' => getError($result)]); - } - - $antragId = getData($result); - $result = $this->antraglib->getDetailsForAntrag($antragId); - - if(!hasData($result)) - return $this->outputJsonSuccess(true); - - $data = getData($result); - - $result = $this->antraglib->getFailedExamForPrestudent($prestudent_id); - // NOTE(chris): error handling for this function should already happenden in antraglib->getPrestudentWiederholungsBerechtigt() - $pruefungsdata = current(getData($result)); - - $data->studiensemester_kurzbz = $pruefungsdata->studiensemester_kurzbz; - $data->lvbezeichnung = $pruefungsdata->lvbezeichnung; - $data->pruefungsdatum = $pruefungsdata->datum; - - $this->outputJsonSuccess($data); - } - - - public function getLvs($antrag_id) - { - $result = $this->antraglib->getLvsForAntrag($antrag_id); - if (isError($result)) { - $error = getError($result); - if ($error == 'Forbidden') - $this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN); - return $this->outputJsonError(getError($result)); - } - $lvs = getData($result); - - $this->outputJsonSuccess($lvs); - } - - public function saveLvs() - { - $result = $this->getPostJSON(); - $antragsLvs = array_merge($result->forbiddenLvs, $result->mandatoryLvs); - - $insert = array_map(function ($lv) { - return [ - 'studierendenantrag_id' => $lv->studierendenantrag_id, - 'lehrveranstaltung_id' => $lv->lehrveranstaltung_id, - 'note' => $lv->zugelassen - ? ($lv->zugelassen == 1 ? 0 : $this->config->item('wiederholung_note_angerechnet')) - : $this->config->item('wiederholung_note_nicht_zugelassen'), - 'anmerkung' => $lv->anmerkung, - 'insertvon' => getAuthUID(), - 'studiensemester_kurzbz' => $lv->studiensemester_kurzbz - ]; - }, $antragsLvs); - - $antrag_ids = array_unique(array_map(function ($lv) { - return $lv['studierendenantrag_id']; - }, $insert)); - - foreach ($antrag_ids as $antrag_id) { - $result = $this->StudierendenantragModel->loadIdAndStatusWhere([ - 'studierendenantrag_id' => $antrag_id - ]); - if (isError($result)) - return $this->outputJsonError(getError($result)); - if (!hasData($result)) - return $this->outputJsonError($this->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $antrag_id])); - $antrag = current(getData($result)); - if ($antrag->status != Studierendenantragstatus_model::STATUS_CREATED - && $antrag->status != Studierendenantragstatus_model::STATUS_LVSASSIGNED) - return $this->outputJsonError($this->p->t('studierendenantrag', 'error_antrag_locked')); - } - - if(!$antragsLvs) - return $this->outputJsonError($this->p->t('studierendenantrag', 'error_no_lv')); - - $result = $this->antraglib->saveLvs($insert); - - if (isError($result)) - return $this->outputJsonError(getError($result)); - - $this->outputJsonSuccess(getData($result)); - } - - public function getLvsAsRdf($prestudent_id) - { - // header für no cache - $this->output->set_header("Cache-Control: no-cache"); - $this->output->set_header("Cache-Control: post-check=0, pre-check=0", false); - $this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); - $this->output->set_header("Pragma: no-cache"); - $this->output->set_header("Content-type: application/xhtml+xml"); - - $this->load->library('VariableLib', ['uid' => getAuthUID()]); - $sem_akt = $this->variablelib->getVar('semester_aktuell'); - - - $result = $this->antraglib->getLvsForPrestudent($prestudent_id, $sem_akt); - if (isError($result)) { - return $this->outputJsonError(getError($result)); - } - - $lvs = getData($result) ?: []; - $rdf_url = 'http://www.technikum-wien.at/antragnote'; - - $this->load->view('lehre/Antrag/Wiederholung/getLvs.rdf.php', [ - 'url' => $rdf_url, - 'lvs' => $lvs - ]); - } - - public function moveLvsToZeugnis() - { - $anzahl = $this->input->post('anzahl'); - $student_uid = $this->input->post('student_uid'); - $this->load->model('education/Studierendenantraglehrveranstaltung_model', 'StudierendenantraglehrveranstaltungModel'); - $this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel'); - - $errormsg = array(); - - for($i=0; $i<$anzahl; $i++) - { - $id = $this->input->post('studierendenantrag_lehrveranstaltung_id_' . $i); - $result =$this->StudierendenantraglehrveranstaltungModel->load($id); - if(isError($result)) - { - $errormsg[] = getError($result); - } - elseif(!hasData($result)) - { - $errormsg[] = $this->p->t('studierendenantrag', 'error_no_lv_in_application'); - } - else - { - $antragLv = getData($result)[0]; - $result= $this->ZeugnisnoteModel->load([ - 'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id, - 'student_uid'=> $student_uid, - 'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz - ]); - if(isError($result)) - { - $errormsg[] = getError($result); - } - else - { - if (hasData($result)) - { - $result = $this->ZeugnisnoteModel->update( - [ - 'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id, - 'student_uid'=> $student_uid, - 'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz - ], - [ - 'note'=> $antragLv->note, - 'uebernahmedatum' => date('c'), - 'benotungsdatum' => $antragLv->insertamum, - 'updateamum' => date('c'), - 'bemerkung'=>$antragLv->anmerkung, - 'updatevon'=>getAuthUID() - ] - ); - } - else - { - $result = $this->ZeugnisnoteModel->insert([ - 'lehrveranstaltung_id'=> $antragLv->lehrveranstaltung_id, - 'student_uid'=> $student_uid, - 'studiensemester_kurzbz' => $antragLv->studiensemester_kurzbz, - 'note'=> $antragLv->note, - 'uebernahmedatum' => date('c'), - 'benotungsdatum' => $antragLv->insertamum, - 'insertamum' => date('c'), - 'bemerkung'=>$antragLv->anmerkung, - 'insertvon'=>getAuthUID() - ]); - } - if(isError($result)) - { - $errormsg[] = getError($result); - } - } - } - } - - if($errormsg) - $return = false; - else - $return = true; - - $this->load->view('lehre/Antrag/Wiederholung/moveLvs.rdf.php', [ - 'return' => $return, - 'errormsg' => $errormsg - ]); - } -} diff --git a/application/libraries/AntragLib.php b/application/libraries/AntragLib.php index 7d1b6a5ac..ce4485279 100644 --- a/application/libraries/AntragLib.php +++ b/application/libraries/AntragLib.php @@ -2058,7 +2058,7 @@ class AntragLib */ public function isEntitledToUnpauseAntrag($antrag_id) { - return $this->hasAccessToAntrag($antrag_id, 'student/studierendenantrag'); + return ($this->hasAccessToAntrag($antrag_id, 'student/antragfreigabe') || $this->hasAccessToAntrag($antrag_id, 'student/studierendenantrag')); } /** diff --git a/application/views/lehre/Antrag/Create.php b/application/views/lehre/Antrag/Create.php index f0b681c2a..91b20c9b7 100644 --- a/application/views/lehre/Antrag/Create.php +++ b/application/views/lehre/Antrag/Create.php @@ -11,6 +11,7 @@ $sitesettings = array( 'customJSModules' => array('public/js/apps/lehre/Antrag.js'), 'customCSSs' => array( 'public/css/Fhc.css', + 'public/css/components/primevue.css', 'vendor/vuejs/vuedatepicker_css/main.css' ), 'customJSs' => array( diff --git a/application/views/lehre/Antrag/Leitung/List.php b/application/views/lehre/Antrag/Leitung/List.php index 9c0749dae..1225b16b6 100644 --- a/application/views/lehre/Antrag/Leitung/List.php +++ b/application/views/lehre/Antrag/Leitung/List.php @@ -20,7 +20,8 @@ $sitesettings = array( ), 'customJSModules' => array('public/js/apps/lehre/Antrag/Leitung.js'), 'customCSSs' => array( - 'public/css/Fhc.css' + 'public/css/Fhc.css', + 'public/css/components/primevue.css', ), 'customJSs' => array( ) diff --git a/application/views/lehre/Antrag/Student/List.php b/application/views/lehre/Antrag/Student/List.php index 55e7ec5df..614af5d79 100644 --- a/application/views/lehre/Antrag/Student/List.php +++ b/application/views/lehre/Antrag/Student/List.php @@ -10,7 +10,8 @@ $sitesettings = array( ), 'customJSModules' => array('public/js/apps/lehre/Antrag/Student.js'), 'customCSSs' => array( - 'public/css/Fhc.css' + 'public/css/Fhc.css', + 'public/css/components/primevue.css', ), 'customJSs' => array( ) diff --git a/application/views/lehre/Antrag/Wiederholung/Student.php b/application/views/lehre/Antrag/Wiederholung/Student.php index 9c2db040e..2171d6928 100644 --- a/application/views/lehre/Antrag/Wiederholung/Student.php +++ b/application/views/lehre/Antrag/Wiederholung/Student.php @@ -14,6 +14,8 @@ $sitesettings = array( ), 'customJSModules' => array('public/js/apps/lehre/Antrag/Lvzuweisung.js'), 'customCSSs' => array( + 'public/css/Fhc.css', + 'public/css/components/primevue.css', ), 'customJSs' => array( ) @@ -30,7 +32,7 @@ $this->load->view(

p->t('studierendenantrag', 'title_lvzuweisen', ['name' => $antrag->name]);?>

- status != Studierendenantragstatus_model::STATUS_CREATED && $antrag->status != Studierendenantragstatus_model::STATUS_LVSASSIGNED) ? ' disabled' : ''; ?>> + status != Studierendenantragstatus_model::STATUS_CREATED && $antrag->status != Studierendenantragstatus_model::STATUS_LVSASSIGNED) ? ' disabled' : ''; ?>>
diff --git a/content/student/studentoverlay.js.php b/content/student/studentoverlay.js.php index 11a4d862f..8be20d32d 100644 --- a/content/student/studentoverlay.js.php +++ b/content/student/studentoverlay.js.php @@ -1658,7 +1658,7 @@ function StudentAuswahl() var antragnotentree = document.getElementById('student-antragnoten-tree'); - url='index.ci.php/components/Antrag/Wiederholung/getLvsAsRdf/'+prestudent_id+"?"+gettimestamp(); + url='index.ci.php/api/frontend/fas/studstatus/Wiederholung/getLvs/'+prestudent_id+"?"+gettimestamp(); try { @@ -4764,7 +4764,7 @@ function StudentNotenMoveFromAntrag() var paramList= ''; var i = 0; - var url = 'index.ci.php/components/Antrag/Wiederholung/moveLvsToZeugnis'; + var url = 'index.ci.php/api/frontend/fas/studstatus/Wiederholung/moveLvsToZeugnis'; var req = new phpRequest(url,'',''); for (var t = 0; t < numRanges; t++) diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index 08deb26b3..41c89ef50 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -19,10 +19,12 @@ import search from "./search.js"; import phrasen from "./phrasen.js"; import navigation from "./navigation.js"; import filter from "./filter.js"; +import studstatus from "./studstatus.js"; export default { search, phrasen, navigation, - filter + filter, + studstatus }; diff --git a/public/js/api/studstatus.js b/public/js/api/studstatus.js new file mode 100644 index 000000000..d0fc4b074 --- /dev/null +++ b/public/js/api/studstatus.js @@ -0,0 +1,220 @@ +/** + * Copyright (C) 2024 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + abmeldung: { + getDetails(antrag_id, prestudent_id) { + const url = '/api/frontend/v1/studstatus/abmeldung/' + + (antrag_id !== undefined ? 'getDetailsForAntrag/' + antrag_id : 'getDetailsForNewAntrag/' + prestudent_id); + return this.$fhcApi.get(url); + }, + create(stdsem, prestudent_id, grund) { + return this.$fhcApi.post('/api/frontend/v1/studstatus/abmeldung/createAntrag', { + studiensemester: stdsem, + prestudent_id, + grund + }, { + errorHandling: 'strict' + }); + }, + cancel(antrag_id) { + if (!Array.isArray(antrag_id)) + return this.$fhcApi.post( + '/api/frontend/v1/studstatus/abmeldung/cancelAntrag', + { antrag_id } + ); + return Promise.allSettled(antrag_id.map(antrag => this.$fhcApi.post( + '/api/frontend/v1/studstatus/abmeldung/cancelAntrag', + { antrag_id: antrag.studierendenantrag_id }, + { errorHeader: '#' + antrag.studierendenantrag_id } + ))); + } + }, + unterbrechung: { + getDetails(antrag_id, prestudent_id) { + const url = '/api/frontend/v1/studstatus/unterbrechung/' + + (antrag_id !== undefined ? 'getDetailsForAntrag/' + antrag_id : 'getDetailsForNewAntrag/' + prestudent_id); + return this.$fhcApi.get(url); + }, + create(studiensemester, prestudent_id, grund, datum_wiedereinstieg, attachment) { + return this.$fhcApi.post('/api/frontend/v1/studstatus/unterbrechung/createAntrag', { + studiensemester, + prestudent_id, + grund, + datum_wiedereinstieg, + attachment + }, { + errorHandling: 'strict' + }); + }, + cancel(antrag_id) { + return this.$fhcApi.post('/api/frontend/v1/studstatus/unterbrechung/cancelAntrag', { + antrag_id + }, { + errorHandling: 'strict' + }); + } + }, + wiederholung: { + getDetails(prestudent_id) { + const url = '/api/frontend/v1/studstatus/wiederholung/getDetailsForNewAntrag/' + prestudent_id; + return this.$fhcApi.get(url) + }, + getLvs(antrag_id) { + const url = '/api/frontend/v1/studstatus/wiederholung/getLvs/' + antrag_id; + return this.$fhcApi.get(url) + }, + create(prestudent_id, studiensemester) { + return this.$fhcApi.post('/api/frontend/v1/studstatus/wiederholung/createAntrag', { + prestudent_id, + studiensemester + }, { + errorHandling: 'strict' + }); + }, + cancel(prestudent_id, studiensemester) { + return this.$fhcApi.post('/api/frontend/v1/studstatus/wiederholung/cancelAntrag', { + prestudent_id, + studiensemester + }, { + errorHandling: 'strict' + }); + }, + saveLvs(forbiddenLvs, mandatoryLvs) { + return this.$fhcApi.post('/api/frontend/v1/studstatus/wiederholung/saveLvs', { + forbiddenLvs, + mandatoryLvs + }); + } + }, + leitung: { + getStgs() { + return this.$fhcApi.get('/api/frontend/v1/studstatus/leitung/getActiveStgs'); + }, + getAntraege(url, config, params) { + return this.$fhcApi + .get('/api/frontend/v1/studstatus/leitung/getAntraege/' + url) + .then(res => res.data); // Return data for tabulator + }, + getHistory(antrag_id) { + return this.$fhcApi.get('/api/frontend/v1/studstatus/leitung/getHistory/' + antrag_id) + }, + getPrestudents(query, signal) { + return this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/getPrestudents', + { query }, + { signal } + ); + }, + approve(antrag) { + if (!Array.isArray(antrag)) + return this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/approveAntrag', + antrag + ); + return Promise.allSettled(antrag.map(a => this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/approveAntrag', + a, + { errorHeader: '#' + a.studierendenantrag_id } + ))); + }, + reject(antrag) { + if (!Array.isArray(antrag)) + return this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/rejectAntrag', + antrag + ); + return Promise.allSettled(antrag.map(a => this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/rejectAntrag', + a, + { errorHeader: '#' + a.studierendenantrag_id } + ))); + }, + reopen(antrag) { + if (!Array.isArray(antrag)) + return this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/reopenAntrag', + antrag + ); + return Promise.allSettled(antrag.map(a => this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/reopenAntrag', + a, + { errorHeader: '#' + a.studierendenantrag_id } + ))); + }, + pause(antrag) { + if (!Array.isArray(antrag)) + return this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/pauseAntrag', + antrag + ); + return Promise.allSettled(antrag.map(a => this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/pauseAntrag', + a, + { errorHeader: '#' + a.studierendenantrag_id } + ))); + }, + unpause(antrag) { + if (!Array.isArray(antrag)) + return this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/unpauseAntrag', + antrag + ); + return Promise.allSettled(antrag.map(a => this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/unpauseAntrag', + a, + { errorHeader: '#' + a.studierendenantrag_id } + ))); + }, + object(antrag) { + if (!Array.isArray(antrag)) + return this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/objectAntrag', + antrag + ); + return Promise.allSettled(antrag.map(a => this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/objectAntrag', + a, + { errorHeader: '#' + a.studierendenantrag_id } + ))); + }, + approveObjection(antrag) { + if (!Array.isArray(antrag)) + return this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/approveObjection', + antrag + ); + return Promise.allSettled(antrag.map(a => this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/approveObjection', + a, + { errorHeader: '#' + a.studierendenantrag_id } + ))); + }, + denyObjection(antrag) { + if (!Array.isArray(antrag)) + return this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/denyObjection', + antrag + ); + return Promise.allSettled(antrag.map(a => this.$fhcApi.post( + '/api/frontend/v1/studstatus/leitung/denyObjection', + a, + { errorHeader: '#' + a.studierendenantrag_id } + ))); + } + } +}; \ No newline at end of file diff --git a/public/js/apps/lehre/Antrag.js b/public/js/apps/lehre/Antrag.js index 00a5877b3..d0c8ab89a 100644 --- a/public/js/apps/lehre/Antrag.js +++ b/public/js/apps/lehre/Antrag.js @@ -1,12 +1,10 @@ import StudierendenantragAntrag from "../../components/Studierendenantrag/Antrag.js"; import StudierendenantragStatus from "../../components/Studierendenantrag/Status.js"; import StudierendenantragInfoblock from "../../components/Studierendenantrag/Infoblock.js"; -import VueDatePicker from "../../components/vueDatepicker.js.php"; import Phrasen from '../../plugin/Phrasen.js'; const app = Vue.createApp({ components: { - VueDatePicker, StudierendenantragAntrag, StudierendenantragStatus, StudierendenantragInfoblock diff --git a/public/js/components/Studierendenantrag/Form/Abmeldung.js b/public/js/components/Studierendenantrag/Form/Abmeldung.js index d72f84265..e6e649e11 100644 --- a/public/js/components/Studierendenantrag/Form/Abmeldung.js +++ b/public/js/components/Studierendenantrag/Form/Abmeldung.js @@ -1,10 +1,16 @@ import {CoreFetchCmpt} from '../../Fetch.js'; +import CoreForm from '../../Form/Form.js'; +import FormValidation from '../../Form/Validation.js'; +import FormInput from '../../Form/Input.js'; var _uuid = 0; export default { components: { - CoreFetchCmpt + CoreFetchCmpt, + CoreForm, + FormValidation, + FormInput }, emits: [ 'setInfos', @@ -18,9 +24,8 @@ export default { return { data: null, saving: false, - errors: { - grund: [], - default: [] + formData: { + grund: '' } } }, @@ -34,24 +39,14 @@ export default { case 'Genehmigt': return 'success'; default: return 'warning'; } - }, - loadUrl() { - if (this.studierendenantragId) - return '/components/Antrag/Abmeldung/getDetailsForAntrag/'+ - this.studierendenantragId; - return '/components/Antrag/Abmeldung/getDetailsForNewAntrag/' + - this.prestudentId; } }, methods: { load() { - return axios.get( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - this.loadUrl - ).then( - result => { - this.data = result.data.retval; + return this.$fhcApi.factory + .studstatus.abmeldung.getDetails(this.studierendenantragId, this.prestudentId) + .then(result => { + this.data = result.data; if (this.data.status) { const msg = (this.data.status == 'Pause' && this.data.status_insertvon == "Studienabbruch") ? Vue.computed(() => { let status = this.$p.t('studierendenantrag/status_stop'); @@ -63,8 +58,7 @@ export default { }); } return result; - } - ); + }); }, createAntrag() { bootstrap.Modal.getOrCreateInstance(this.$refs.modal).hide(); @@ -73,52 +67,39 @@ export default { severity: 'warning' }); this.saving = true; - for(var k in this.errors) - this.errors[k] = []; - axios.post( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/components/Antrag/Abmeldung/createAntrag/', { - studiensemester: this.data.studiensemester_kurzbz, - prestudent_id: this.data.prestudent_id, - grund: this.$refs.grund.value - } - ).then( - result => { - if (result.data.error) - { - for (var k in result.data.retval) - { - if (this.errors[k] !== undefined) - this.errors[k].push(result.data.retval[k]); - else - this.errors.default.push(result.data.retval[k]); - } - this.$emit('setStatus', { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), - severity: 'danger' + + this.$refs.form.clearValidation(); + this.$refs.form.factory + .studstatus.abmeldung.create( + this.data.studiensemester_kurzbz, + this.data.prestudent_id, + this.formData.grund + ) + .then(result => { + if (result.data === true) + document.location += ""; + + this.data = result.data; + if (this.data.status) + this.$emit("setStatus", { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), + severity: this.statusSeverity }); - } else - { - if (result.data.retval === true) - document.location += ""; - this.data = result.data.retval; - if (this.data.status) { - this.$emit("setStatus", { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), - severity: this.statusSeverity - }); - } - else - this.$emit('setStatus', { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_open')})), - severity:'success' - }); - } + this.$emit('setStatus', { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_open')})), + severity:'success' + }); this.saving = false; - } - ); + }) + .catch(error => { + this.$emit('setStatus', { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), + severity: 'danger' + }); + this.saving = false; + this.$fhcAlert.handleSystemError(error); + }); }, cancelAntrag() { this.$emit('setStatus', { @@ -126,51 +107,37 @@ export default { severity: 'warning' }); this.saving = true; - for(var k in this.errors) - this.errors[k] = []; - axios.post( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/components/Antrag/Abmeldung/cancelAntrag/', { - antrag_id: this.data.studierendenantrag_id - } - ).then( - result => { - if (result.data.error) - { - for (var k in result.data.retval) - { - if (this.errors[k] !== undefined) - this.errors[k].push(result.data.retval[k]); - else - this.errors.default.push(result.data.retval[k]); - } - this.$emit('setStatus', { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), - severity:'danger' + + this.$refs.form.clearValidation(); + this.$refs.form.factory + .studstatus.abmeldung.cancel( + this.data.studierendenantrag_id + ) + .then(result => { + if (Number.isInteger(result.data)) + document.location = document.location.replace(/abmeldung\/([0-9]*)\/[0-9]*[\/]?$/, 'abmeldung/$1') + "/" + result.data; + + this.data = result.data; + if (this.data.status) + this.$emit("setStatus", { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), + severity: this.statusSeverity }); - } else - { - if (Number.isInteger(result.data.retval)) { - document.location = document.location.replace(/abmeldung\/([0-9]*)\/[0-9]*[\/]?$/, 'abmeldung/$1') + "/" + result.data.retval; - } - this.data = result.data.retval; - if (this.data.status) { - this.$emit("setStatus", { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), - severity: this.statusSeverity - }); - } - else - this.$emit('setStatus', { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_cancelled')})), - severity: 'danger' - }); - } + this.$emit('setStatus', { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_cancelled')})), + severity: 'danger' + }); this.saving = false; - } - ); + }) + .catch(error => { + this.$emit('setStatus', { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), + severity: 'danger' + }); + this.saving = false; + this.$fhcAlert.handleSystemError(error); + }); } }, created() { @@ -179,10 +146,9 @@ export default { template: `
-
+
- + @@ -219,19 +185,16 @@ export default {
{{data.grund}}
- - -
- {{errors.grund.join(".")}} -
+ > +
- + + - - ` + ` } diff --git a/public/js/components/Studierendenantrag/Form/AbmeldungStgl.js b/public/js/components/Studierendenantrag/Form/AbmeldungStgl.js index 7e8cd01fc..004f6f4d0 100644 --- a/public/js/components/Studierendenantrag/Form/AbmeldungStgl.js +++ b/public/js/components/Studierendenantrag/Form/AbmeldungStgl.js @@ -1,10 +1,16 @@ import {CoreFetchCmpt} from '../../Fetch.js'; +import CoreForm from '../../Form/Form.js'; +import FormValidation from '../../Form/Validation.js'; +import FormInput from '../../Form/Input.js'; var _uuid = 0; export default { components: { - CoreFetchCmpt + CoreFetchCmpt, + CoreForm, + FormValidation, + FormInput }, emits: [ 'setInfos', @@ -18,9 +24,8 @@ export default { return { data: null, saving: false, - errors: { - grund: [], - default: [] + formData: { + grund: '' } } }, @@ -35,24 +40,14 @@ export default { case 'Abgemeldet': return 'success'; default: return 'warning'; } - }, - loadUrl() { - if (this.studierendenantragId) - return '/components/Antrag/Abmeldung/getDetailsForAntrag/'+ - this.studierendenantragId; - return '/components/Antrag/Abmeldung/getDetailsForNewAntrag/' + - this.prestudentId; } }, methods: { load() { - return axios.get( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - this.loadUrl - ).then( - result => { - this.data = result.data.retval; + return this.$fhcApi.factory + .studstatus.abmeldung.getDetails(this.studierendenantragId, this.prestudentId) + .then(result => { + this.data = result.data; if (this.data.status) { const msg = (this.data.status == 'Pause' && this.data.status_insertvon == "Studienabbruch") ? Vue.computed(() => { let status = this.$p.t('studierendenantrag/status_stop'); @@ -64,8 +59,7 @@ export default { }); } return result; - } - ); + }); }, createAntrag() { bootstrap.Modal.getOrCreateInstance(this.$refs.modal).hide(); @@ -74,63 +68,44 @@ export default { severity: 'warning' }); this.saving = true; - for(var k in this.errors) - this.errors[k] = []; - axios.post( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/components/Antrag/Abmeldung/createAntrag/', { - studiensemester: this.data.studiensemester_kurzbz, - prestudent_id: this.data.prestudent_id, - grund: this.$refs.grund.value - } - ).then( - result => { - if (result.data.error) - { - for (var k in result.data.retval) - { - if (this.errors[k] !== undefined) - this.errors[k].push(result.data.retval[k]); - else - this.errors.default.push(result.data.retval[k]); - } - this.$emit('setStatus', { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), - severity: 'danger' - }); - } - else - { - if (result.data.retval === true) - document.location += ""; - this.data = result.data.retval; - if (this.data.status) { - this.$emit("setStatus", { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), - severity: this.statusSeverity - }); - } - else - this.$emit('setStatus', { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_open')})), - severity:'success' - }); - } - this.saving = false; - } - ); - }, - appendDropDownText(event){ - let templateText = this.$refs.grund; - if(event.target.value) - { - let templateT= this.$p.t('studierendenantrag', event.target.value); - templateText.value = templateT; - } - else - templateText.value = ''; + this.$refs.form.clearValidation(); + this.$refs.form.factory + .studstatus.abmeldung.create( + this.data.studiensemester_kurzbz, + this.data.prestudent_id, + this.formData.grund + ) + .then(result => { + if (result.data === true) + document.location += ""; + + this.data = result.data; + if (this.data.status) + this.$emit("setStatus", { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), + severity: this.statusSeverity + }); + else + this.$emit('setStatus', { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_open')})), + severity:'success' + }); + this.saving = false; + }) + .catch(error => { + this.$emit('setStatus', { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), + severity: 'danger' + }); + this.saving = false; + this.$fhcAlert.handleSystemError(error); + }); + }, + appendDropDownText(event) { + this.formData.grund = event.target.value + ? this.$p.t('studierendenantrag', event.target.value) + : ''; }, }, created() { @@ -139,8 +114,9 @@ export default { template: `
-
+
+
{{$p.t('lehre', 'studiengang')}}
@@ -181,8 +157,7 @@ export default {
- @@ -199,19 +174,17 @@ export default { -
- -
- {{errors.grund.join(".")}} -
+ > +
@@ -257,7 +230,7 @@ export default {
- + - - ` + ` } diff --git a/public/js/components/Studierendenantrag/Form/Unterbrechung.js b/public/js/components/Studierendenantrag/Form/Unterbrechung.js index a2058b5bf..a58cf5e77 100644 --- a/public/js/components/Studierendenantrag/Form/Unterbrechung.js +++ b/public/js/components/Studierendenantrag/Form/Unterbrechung.js @@ -1,12 +1,15 @@ import {CoreFetchCmpt} from '../../Fetch.js'; -import VueDatepicker from '../../vueDatepicker.js.php'; +import CoreForm from '../../Form/Form.js'; +import FormValidation from '../../Form/Validation.js'; +import FormInput from '../../Form/Input.js'; -var _uuid = 0; export default { components: { CoreFetchCmpt, - VueDatepicker + CoreForm, + FormValidation, + FormInput }, emits: [ 'setInfos', @@ -20,12 +23,7 @@ export default { return { data: null, saving: false, - errors: { - grund: [], - studiensemester: [], - datum_wiedereinstieg: [], - default: [] - }, + attachment: [], stsem: null, currentWiedereinstieg: '', siteUrl: FHC_JS_DATA_STORAGE_OBJECT.app_root + @@ -45,13 +43,6 @@ export default { default: return 'warning'; } }, - loadUrl() { - if (this.studierendenantragId) - return '/components/Antrag/Unterbrechung/getDetailsForAntrag/'+ - this.studierendenantragId; - return '/components/Antrag/Unterbrechung/getDetailsForNewAntrag/' + - this.prestudentId; - }, datumWsFormatted() { let datumUnformatted = ''; @@ -81,26 +72,24 @@ export default { }, methods: { load() { - return axios.get( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - this.loadUrl - ).then( - result => { - this.data = result.data.retval; - if (this.data.status) { - const msg = (this.data.status == 'Pause' && this.data.status_insertvon == "Studienabbruch") ? Vue.computed(() => { - let status = this.$p.t('studierendenantrag/status_stop'); - return this.$p.t('studierendenantrag', 'status_x', {status}); - }) : Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})); - this.$emit("setStatus", { - msg, - severity: this.statusSeverity - }); + return this.$fhcApi.factory + .studstatus.unterbrechung.getDetails(this.studierendenantragId, this.prestudentId) + .then( + result => { + this.data = result.data; + if (this.data.status) { + const msg = (this.data.status == 'Pause' && this.data.status_insertvon == "Studienabbruch") ? Vue.computed(() => { + let status = this.$p.t('studierendenantrag/status_stop'); + return this.$p.t('studierendenantrag', 'status_x', {status}); + }) : Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})); + this.$emit("setStatus", { + msg, + severity: this.statusSeverity + }); + } + return result; } - return result; - } - ); + ); }, createAntrag() { this.$emit('setStatus', { @@ -108,63 +97,41 @@ export default { severity: 'warning' }); this.saving = true; - for(var k in this.errors) - this.errors[k] = []; - var formData = new FormData(); - var attachment = this.$refs.attachment; - formData.append("attachment", attachment.files[0]); - formData.append("studiensemester", this.stsem !== null && this.data.studiensemester[this.stsem].studiensemester_kurzbz); - formData.append("prestudent_id", this.data.prestudent_id); - formData.append("grund", this.$refs.grund.value); - formData.append("datum_wiedereinstieg", this.stsem !== null && this.currentWiedereinstieg); + this.$refs.form.clearValidation(); + this.$refs.form.factory + .studstatus.unterbrechung.create( + this.stsem !== null && this.data.studiensemester[this.stsem].studiensemester_kurzbz, + this.data.prestudent_id, + this.data.grund, + this.stsem !== null && this.currentWiedereinstieg, + this.attachment + ) + .then(result => { + if (Number.isInteger(result.data)) + document.location += "/" + result.data; - axios.post( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/components/Antrag/Unterbrechung/createAntrag/', - formData, - { - headers: { - 'Content-Type': 'multipart/form-data' - } - } - ).then( - result => { - if (result.data.error) - { - for (var k in result.data.retval) - { - if (this.errors[k] !== undefined) - this.errors[k].push(result.data.retval[k]); - else - this.errors.default.push(result.data.retval[k]); - } - this.$emit('setStatus', { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), - severity: 'danger' + this.data = result.data; + if (this.data.status) + this.$emit("setStatus", { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), + severity: this.statusSeverity }); - } else - { - if (Number.isInteger(result.data.retval)) - document.location += "/" + result.data.retval; - this.data = result.data.retval; - if (this.data.status) { - this.$emit("setStatus", { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), - severity: this.statusSeverity - }); - } - else - this.$emit('setStatus', { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_created')})), - severity: 'info' - }); - } + this.$emit('setStatus', { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_created')})), + severity: 'info' + }); this.saving = false; - } - ); + }) + .catch(error => { + this.$emit('setStatus', { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), + severity: 'danger' + }); + this.saving = false; + this.$fhcAlert.handleSystemError(error); + }); }, cancelAntrag() { this.$emit('setStatus', { @@ -172,63 +139,45 @@ export default { severity: 'warning' }); this.saving = true; - for(var k in this.errors) - this.errors[k] = []; - axios.post( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/components/Antrag/Unterbrechung/cancelAntrag/', { - antrag_id: this.data.studierendenantrag_id - } - ).then( - result => { - if (result.data.error) - { - for (var k in result.data.retval) - { - if (this.errors[k] !== undefined) - this.errors[k].push(result.data.retval[k]); - else - this.errors.default.push(result.data.retval[k]); - } + + this.$refs.form.clearValidation(); + this.$refs.form.factory + .studstatus.unterbrechung.cancel( + this.data.studierendenantrag_id + ) + .then(result => { + if (Number.isInteger(result.data)) + document.location = document.location.replace(/unterbrechung\/([0-9]*)\/[0-9]*[\/]?$/, 'unterbrechung/$1') + "/" + result.data; + + this.data = result.data; + if (this.data.status) + this.$emit("setStatus", { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), + severity: this.statusSeverity + }); + else this.$emit('setStatus', { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_cancelled')})), severity: 'danger' }); - } - else - { - if (Number.isInteger(result.data.retval)) { - document.location = document.location.replace(/unterbrechung\/([0-9]*)\/[0-9]*[\/]?$/, 'unterbrechung/$1') + "/" + result.data.retval; - } - this.data = result.data.retval; - if (this.data.status) { - this.$emit("setStatus", { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), - severity: this.statusSeverity - }); - } - else - this.$emit('setStatus', { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_cancelled')})), - severity: 'danger' - }); - } this.saving = false; - } - ); + }) + .catch(error => { + this.$emit('setStatus', { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), + severity: 'danger' + }); + this.saving = false; + this.$fhcAlert.handleSystemError(error); + }); } }, - created() { - this.uuid = _uuid++; - }, template: `
-
+
- +
{{$p.t('lehre', 'studiengang')}}
@@ -260,93 +209,99 @@ export default {
-
- {{data.studiensemester_kurzbz}} -
-
- -
- {{errors.studiensemester.join(".")}} + +
+ {{data.studiensemester_kurzbz}}
+ + +
- -
- {{datumWsFormatted}} -
-
- -
-
- -
- -
- {{errors.datum_wiedereinstieg.join(".")}} + +
+ {{datumWsFormatted}} +
+ + + + + +
-
-
{{$p.t('studierendenantrag', 'antrag_grund')}}:
- -
-
- - -
- {{errors.grund.join(".")}} -
+ > +
-
{{$p.t('studierendenantrag', 'antrag_dateianhaenge')}} {{$p.t('studierendenantrag', 'no_attachments')}}
-
- - -
+ +
-
+ - - ` + ` } diff --git a/public/js/components/Studierendenantrag/Form/Wiederholung.js b/public/js/components/Studierendenantrag/Form/Wiederholung.js index eca1dba94..a899d242c 100644 --- a/public/js/components/Studierendenantrag/Form/Wiederholung.js +++ b/public/js/components/Studierendenantrag/Form/Wiederholung.js @@ -1,12 +1,13 @@ import {CoreFetchCmpt} from '../../Fetch.js'; -import VueDatepicker from '../../vueDatepicker.js.php'; +import CoreForm from '../../Form/Form.js'; +import FormValidation from '../../Form/Validation.js'; -var _uuid = 0; export default { components: { CoreFetchCmpt, - VueDatepicker + CoreForm, + FormValidation }, emits: [ 'setInfos', @@ -22,12 +23,6 @@ export default { return { data: null, saving: false, - errors: { - grund: [], - default: [] - }, - siteUrl: FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router, infos: [] } }, @@ -45,10 +40,6 @@ export default { default: return 'warning'; } }, - loadUrl() { - return '/components/Antrag/Wiederholung/getDetailsForNewAntrag/' + - this.prestudentId; - }, datumPruefungFormatted() { if(!this.data.pruefungsdatum) return ''; @@ -58,13 +49,12 @@ export default { }, methods: { load() { - return axios.get( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - this.loadUrl - ).then( - result => { - this.data = result.data.retval; + return this.$fhcApi.factory + .studstatus.wiederholung.getDetails( + this.prestudentId + ) + .then(result => { + this.data = result.data; if (!this.data.status || this.data.status == 'ErsteAufforderungVersandt' || this.data.status == 'ZweiteAufforderungVersandt') { this.data.status = 'Offen'; this.data.statustyp = this.$p.t('studierendenantrag', 'status_open'); @@ -79,8 +69,7 @@ export default { severity: this.statusSeverity }); return result; - } - ); + }); }, createAntrag() { this.createAntragWithStatus(true); @@ -89,7 +78,7 @@ export default { this.createAntragWithStatus(false); }, createAntragWithStatus(repeat) { - let func = repeat ? 'createAntrag' : 'cancelAntrag'; + let func = repeat ? 'create' : 'cancel'; let nextState = repeat ? 'Erstellt' : 'Verzichtet'; this.$emit('setStatus', { @@ -97,54 +86,36 @@ export default { severity: 'warning' }); this.saving = true; - for(var k in this.errors) - this.errors[k] = []; - axios.post( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/components/Antrag/Wiederholung/' + func + '/', - { - prestudent_id: this.data.prestudent_id, - studiensemester: this.data.studiensemester_kurzbz - } - ).then( - result => { - if (result.data.error) - { - for (var k in result.data.retval) - { - if (this.errors[k] !== undefined) - this.errors[k].push(result.data.retval[k]); - else - this.errors.default.push(result.data.retval[k]); - } - this.$emit('setStatus', { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), - severity: 'danger' - }); - } - else - { - if (result.data.retval === true) - document.location += ""; - this.data = result.data.retval; - if (!this.data.status) - this.data.status = nextState; - this.$emit('update:status', this.data.status); - this.$emit("setStatus", { - msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), - severity: this.statusSeverity - }); - } + this.$refs.form.factory + .studstatus.wiederholung[func]( + this.data.prestudent_id, + this.data.studiensemester_kurzbz + ) + .then(result => { + if (result.data === true) + document.location += ""; + + this.data = result.data; + if (!this.data.status) + this.data.status = nextState; + this.$emit('update:status', this.data.status); + this.$emit("setStatus", { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.data.statustyp})), + severity: this.statusSeverity + }); this.saving = false; - } - ); + }) + .catch(error => { + this.$emit('setStatus', { + msg: Vue.computed(() => this.$p.t('studierendenantrag', 'status_x', {status: this.$p.t('studierendenantrag', 'status_error')})), + severity: 'danger' + }); + this.saving = false; + this.$fhcAlert.handleSystemError(error); + }); } }, - created() { - this.uuid = _uuid++; - }, mounted() { this.infos = [...Array(5).keys()].map(n => ({ body: Vue.computed(() => this.$p.t('studierendenantrag', 'infotext_Wiederholung_' + n)) @@ -154,10 +125,9 @@ export default { template: `
-
+
- +
{{$p.t('lehre', 'studiengang')}}
@@ -206,7 +176,7 @@ export default { {{$p.t('studierendenantrag/antrag_Wiederholung_button_no')}} --> - +
{{$p.t('lehre', 'studiengang')}}