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/Filter.php b/application/controllers/api/frontend/v1/Filter.php new file mode 100644 index 000000000..45838fc5f --- /dev/null +++ b/application/controllers/api/frontend/v1/Filter.php @@ -0,0 +1,231 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the FilterCmptLib (back-end) + * Provides data to the ajax get calls about the filter component + * Listens to ajax post calls to change the filter data + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Filter extends FHCAPI_Controller +{ + const FILTER_UNIQUE_ID = 'filterUniqueId'; // Name of the filter cmpt unique id (mandatory) + const FILTER_TYPE = 'filterType'; // The filter type (PHP filter definition) used (mandatory) + const FILTER_ID = 'filterId'; // The id of the used filter (optional) + + /** + * Calls the parent's constructor and loads the FilterCmptLib + */ + public function __construct() + { + // NOTE: FilterCmpt has its own permissions checks + parent::__construct([ + 'getFilter' => self::PERM_LOGGED, + 'removeFilterField' => self::PERM_LOGGED, + 'addFilterField' => self::PERM_LOGGED, + 'applyFilterFields' => self::PERM_LOGGED, + 'removeCustomFilter' => self::PERM_LOGGED, + 'saveCustomFilter' => self::PERM_LOGGED, + 'reloadDataset' => self::PERM_LOGGED + ]); + + // Loads the FiltersModel + $this->load->model('system/Filters_model', 'FiltersModel'); + + // Loads the FilterCmptLib with HTTP GET/POST parameters + $this->_startFilterCmptLib(); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Retrieves data about the current filter from the session and will be written on the output in JSON format + */ + public function getFilter() + { + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $session = $this->filtercmptlib->getSession(); + if (is_object($session)) { + // If stdClass it is an retval object + $session = $this->getDataOrTerminateWithError($session); + } + $this->terminateWithSuccess($session); + } + + /** + * Remove an applied filter (SQL where condition) from the current filter + */ + public function removeFilterField() + { + $this->form_validation->set_rules('filterField', 'filterField', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $result = $this->filtercmptlib->removeFilterField($this->input->post('filterField')); + + if (!$result) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $this->terminateWithSuccess('Field removed'); + } + + /** + * Add a filter (SQL where clause) to be applied to the current filter + */ + public function addFilterField() + { + $this->form_validation->set_rules('filterField', 'filterField', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $result = $this->filtercmptlib->addFilterField($this->input->post('filterField')); + + if (!$result) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $this->terminateWithSuccess('Field added'); + } + + /** + * Apply the filter changes + */ + public function applyFilterFields() + { + $this->form_validation->set_rules('filterFields', 'filterFields', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $result = $this->filtercmptlib->applyFilterFields($this->input->post('filterFields')); + + if (!$result) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $this->terminateWithSuccess('Applied'); + } + + /** + * Save the current filter as a custom filter for this user with the given description + */ + public function saveCustomFilter() + { + $this->form_validation->set_rules('customFilterName', 'customFilterName', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $result = $this->filtercmptlib->saveCustomFilter($this->input->post('customFilterName')); + + if (!$result) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $this->terminateWithSuccess('Saved'); + } + + /** + * Remove a custom filter by its filterId + */ + public function removeCustomFilter() + { + $this->form_validation->set_rules('filterId', 'filterId', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $result = $this->filtercmptlib->removeCustomFilter($this->input->post('filterId')); + + if (!$result) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $this->terminateWithSuccess('Removed'); + } + + /** + * Reloads the dataset + */ + public function reloadDataset() + { + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $this->filtercmptlib->reloadDataset(); + + $this->terminateWithSuccess('Success'); + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Loads the FilterCmptLib with the FILTER_UNIQUE_ID parameter + * If the parameter FILTER_UNIQUE_ID is not given then the execution of the controller is terminated and + * an error message is printed + */ + private function _startFilterCmptLib() + { + $filterUniqueId = null; + $filterType = null; + $filterId = null; + + $validations = [ + [ + 'field' => self::FILTER_UNIQUE_ID, + 'label' => self::FILTER_UNIQUE_ID, + 'rules' => 'required' + ], + [ + 'field' => self::FILTER_TYPE, + 'label' => self::FILTER_TYPE, + 'rules' => 'required' + ], + ]; + + $this->load->library('form_validation'); + + if ($this->input->method() == 'get') + $this->form_validation->set_data($this->input->get()); + $this->form_validation->set_rules($validations); + + if ($this->form_validation->run()) { + $filterUniqueId = $this->input->post_get(self::FILTER_UNIQUE_ID); + $filterType = $this->input->post_get(self::FILTER_TYPE); + $filterId = $this->input->post_get(self::FILTER_ID); + + // Loads the FilterCmptLib that contains all the used logic + $this->load->library( + 'FilterCmptLib', + array( + 'filterUniqueId' => $filterUniqueId, + 'filterType' => $filterType, + 'filterId' => $filterId + ) + ); + + // Start the component + $this->filtercmptlib->start(); + } + } +} + diff --git a/application/controllers/api/frontend/v1/Navigation.php b/application/controllers/api/frontend/v1/Navigation.php new file mode 100644 index 000000000..6cbbbd385 --- /dev/null +++ b/application/controllers/api/frontend/v1/Navigation.php @@ -0,0 +1,101 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the NavigationLib (back-end) + * Provides data to the ajax get calls about the filter + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Navigation extends FHCAPI_Controller +{ + const NAVIGATION_PAGE_PARAM = 'navigation_page'; // Navigation page parameter name + + /** + * Loads the NavigationLib where the used logic lies + */ + public function __construct() + { + parent::__construct([ + 'menu' => self::PERM_LOGGED, + 'header' => self::PERM_LOGGED + ]); + + $this->_loadNavigationLib(); // Loads the NavigationLib with parameters + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * This function creates the left Menu for each Page + * @param NAVIGATION_PAGE_PARAM GET Parameter witch holds the currently called Page + * @return JSON object with the Menu Entries + */ + public function menu() + { + $menuArray = $this->navigationlib->getMenuArray($this->input->get(self::NAVIGATION_PAGE_PARAM)); + + $this->terminateWithSuccess($menuArray); + } + + /** + * This function creates the Top Menu for each Page + * @param NAVIGATION_PAGE_PARAM GET Parameter witch holds the currently called Page + * @return JSON object with the Menu Entries + */ + public function header() + { + $headerArray = $this->navigationlib->getHeaderArray($this->input->get(self::NAVIGATION_PAGE_PARAM)); + + $this->terminateWithSuccess($headerArray); + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Loads the NavigationLib with the NAVIGATION_PAGE_PARAM parameter + * If the parameter NAVIGATION_PAGE_PARAM is not given then the execution of the controller is terminated and + * an error message is printed + */ + private function _loadNavigationLib() + { + // If the parameter NAVIGATION_PAGE_PARAM is present in the HTTP GET or POST + if (isset($_GET[self::NAVIGATION_PAGE_PARAM]) || isset($_POST[self::NAVIGATION_PAGE_PARAM])) + { + // If it is present in the HTTP GET + if (isset($_GET[self::NAVIGATION_PAGE_PARAM])) + { + $navigationPage = $this->input->get(self::NAVIGATION_PAGE_PARAM); // is retrieved from the HTTP GET + } + elseif (isset($_POST[self::NAVIGATION_PAGE_PARAM])) // Else if it is present in the HTTP POST + { + $navigationPage = $this->input->post(self::NAVIGATION_PAGE_PARAM); // is retrieved from the HTTP POST + } + + // Loads the NavigationLib that contains all the used logic + $this->load->library('NavigationLib', array(self::NAVIGATION_PAGE_PARAM => $navigationPage)); + } + else // Otherwise an error will be written in the output + { + show_error('Parameter "' . self::NAVIGATION_PAGE_PARAM . '" not provided!'); + } + } +} diff --git a/application/controllers/api/frontend/v1/Phrasen.php b/application/controllers/api/frontend/v1/Phrasen.php new file mode 100644 index 000000000..472308d2b --- /dev/null +++ b/application/controllers/api/frontend/v1/Phrasen.php @@ -0,0 +1,46 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the PhrasesLib (back-end) + * Provides data to the ajax get calls about the Phrasen plugin + * This controller works with JSON calls on the HTTP GET and the output is always JSON + */ +class Phrasen extends FHCAPI_Controller +{ + public function __construct() + { + parent::__construct([ + 'loadModule' => self::PERM_ANONYMOUS + ]); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * @param string $module + */ + public function loadModule($module) + { + $this->load->library('PhrasesLib', [$module], 'pj'); + $this->terminateWithSuccess(json_decode($this->pj->getJSON())); + } +} diff --git a/application/controllers/api/frontend/v1/Searchbar.php b/application/controllers/api/frontend/v1/Searchbar.php new file mode 100644 index 000000000..8b383e042 --- /dev/null +++ b/application/controllers/api/frontend/v1/Searchbar.php @@ -0,0 +1,69 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the SearchBarLib (back-end) + * Provides data to the ajax get calls about the searchbar component + * This controller works with JSON calls on the HTTP GET and the output is always JSON + */ +class Searchbar extends FHCAPI_Controller +{ + const SEARCHSTR_PARAM = 'searchstr'; + const TYPES_PARAM = 'types'; + + /** + * Object initialization + */ + public function __construct() + { + // NOTE(chris): additional permission checks will be done in SearchBarLib + parent::__construct([ + 'search' => self::PERM_LOGGED + ]); + + // Load the library SearchBarLib + $this->load->library('SearchBarLib'); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Gets a JSON body via HTTP POST and provides the parameters + */ + public function search() + { + $this->load->library('form_validation'); + + // Checks if the searchstr and the types parameters are in the POSTed JSON + $this->form_validation->set_rules(self::SEARCHSTR_PARAM, null, 'required'); + $this->form_validation->set_rules(self::TYPES_PARAM . '[]', null, 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithError(SearchBarLib::ERROR_WRONG_JSON, self::ERROR_TYPE_GENERAL); + + // Convert to json the result from searchbarlib->search + $result = $this->searchbarlib->search($this->input->post(self::SEARCHSTR_PARAM), $this->input->post(self::TYPES_PARAM)); + if (property_exists($result, 'error')) + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + $this->terminateWithSuccess($result); + } +} + 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/controllers/components/Filter.php b/application/controllers/components/Filter.php index bde7d7ed7..617edd69f 100644 --- a/application/controllers/components/Filter.php +++ b/application/controllers/components/Filter.php @@ -9,6 +9,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON * NOTE: extends the FHC_Controller instead of the Auth_Controller because the FilterCmpt has its * own permissions check + * TODO(chris): deprecated */ class Filter extends FHC_Controller { diff --git a/application/controllers/components/Phrasen.php b/application/controllers/components/Phrasen.php index 87516ce00..3ac35a652 100644 --- a/application/controllers/components/Phrasen.php +++ b/application/controllers/components/Phrasen.php @@ -3,7 +3,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); /** - * + * TODO(chris): deprecated */ class Phrasen extends FHC_Controller { diff --git a/application/controllers/components/SearchBar.php b/application/controllers/components/SearchBar.php index d19113177..eac1a4cbc 100644 --- a/application/controllers/components/SearchBar.php +++ b/application/controllers/components/SearchBar.php @@ -3,7 +3,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); /** - * + * TODO(chris): deprecated */ class SearchBar extends FHC_Controller { @@ -21,7 +21,7 @@ class SearchBar extends FHC_Controller // NOTE: // - A user must be authenticated via another controller to access this one // - It is loaded to be able to call the isLogged function later - $this->load->library('AuthLib', array(false)); + $this->load->library('AuthLib'); // Load the library SearchBarLib $this->load->library('SearchBarLib'); diff --git a/application/controllers/jobs/ReihungstestJob.php b/application/controllers/jobs/ReihungstestJob.php index c31ed54c9..b55287439 100644 --- a/application/controllers/jobs/ReihungstestJob.php +++ b/application/controllers/jobs/ReihungstestJob.php @@ -1023,7 +1023,7 @@ class ReihungstestJob extends JOB_Controller { $studiengang = $this->StudiengangModel->load($stg); $mailcontent = ''; - + $content = false; foreach ($orgform AS $art=>$value) { // Orgform nur dazu schreiben, wenn es mehr als Eine gibt @@ -1044,6 +1044,7 @@ class ReihungstestJob extends JOB_Controller $mailcontent .= ''.$bewerber.''; } $mailcontent .= '

'; + $content = true; } if (isset($value['AufnahmeHoeherePrio']) && !isEmptyArray($value['AufnahmeHoeherePrio'])) { @@ -1058,6 +1059,7 @@ class ReihungstestJob extends JOB_Controller $mailcontent .= ''.$bewerber.''; } $mailcontent .= ''; + $content = true; } if (isset($value['AbgewiesenHoeherePrio']) && !isEmptyArray($value['AbgewiesenHoeherePrio'])) { @@ -1071,6 +1073,7 @@ class ReihungstestJob extends JOB_Controller $mailcontent .= ''.$bewerber.''; } $mailcontent .= ''; + $content = true; } if ($bcc != '' && isset($value['AbgewiesenWeilBewerber']) && !isEmptyArray($value['AbgewiesenWeilBewerber'])) { @@ -1085,13 +1088,14 @@ class ReihungstestJob extends JOB_Controller $mailcontent .= ''.$bewerber.''; } $mailcontent .= ''; + $content = true; } } $mailcontent_data_arr['table'] = $mailcontent; // Send email in Sancho design - if (!isEmptyString($mailcontent)) + if (!isEmptyString($mailcontent) && $content === true) { sendSanchoMail( 'Sancho_ReihungstestteilnehmerJob', diff --git a/application/controllers/system/MigrateContract.php b/application/controllers/system/MigrateContract.php index 99b894473..93fd275a3 100644 --- a/application/controllers/system/MigrateContract.php +++ b/application/controllers/system/MigrateContract.php @@ -400,6 +400,11 @@ class MigrateContract extends CLI_Controller */ private function _addVertragsbestandteilZeitaufzeichnung(&$contracts, $dv, $row_verwendung) { + if( is_null($row_verwendung->zeitaufzeichnungspflichtig) || is_null($row_verwendung->azgrelevant) ) + { + return; + } + if (isset($contracts['dv'][$dv]['vbs'])) { foreach ($contracts['dv'][$dv]['vbs'] as $index_vbs=>$row_vbs) @@ -677,4 +682,35 @@ class MigrateContract extends CLI_Controller else return 0; } + + /** + * Habilitation wird aus der Tabelle bis.tbl_bisverwendung in die Tabelle public.tbl_mitarbeiter uebernommen + * Sofern die Person einmal in den Verwendungen eine habiliation eingetragen hat wird diese in den MA-Datensatz übernommen + * Da es in der regel öfter vorkommt dass das hakerl vergessen wurde beim Vertragswechsel als dass die person die habiliation verliert. + */ + public function migrateHabilitation() + { + $this->load->model('ressource/Mitarbeiter_model','MitarbeiterModel'); + $db = new DB_Model(); + + $qry = " + SELECT + distinct mitarbeiter_uid + FROM + bis.tbl_bisverwendung + WHERE + habilitation=true"; + + $resultHabilitation = $db->execReadOnlyQuery($qry); + + if (isSuccess($resultHabilitation) && hasData($resultHabilitation)) + { + $habilitationen = getData($resultHabilitation); + + foreach ($habilitationen as $row_habilitationen) + { + $this->MitarbeiterModel->update($row_habilitationen->mitarbeiter_uid, array('habilitation'=>true)); + } + } + } } diff --git a/application/controllers/system/MigrateHourlyRate.php b/application/controllers/system/MigrateHourlyRate.php index 4fed2f585..734934ad0 100644 --- a/application/controllers/system/MigrateHourlyRate.php +++ b/application/controllers/system/MigrateHourlyRate.php @@ -25,6 +25,7 @@ class MigrateHourlyRate extends CLI_Controller public function index($user = null) { + echo "Lehre Stundensaetze werden migriert.\n"; $mitarbeiterResult = $this->_getMitarbeiterStunden($user); if (isError($mitarbeiterResult)) return $mitarbeiterResult; if (!hasData($mitarbeiterResult)) return error('Keine Mitarbeiterstunden gefunden'); @@ -38,20 +39,59 @@ class MigrateHourlyRate extends CLI_Controller if (isError($insertResult)) return $insertResult; } - $sapResult = $this->_getSapStunden($user); - if (isError($sapResult)) return $sapResult; - if (!hasData($sapResult)) return error('Keinen kalkulatorischen Stundensaetze gefunden'); - - $mitarbeiterArray = getData($sapResult); - - foreach ($mitarbeiterArray as $mitarbeiter) + if( $this->checkIfSAPSyncTableExists() ) { - $this->_getUnternehmen($mitarbeiter); - $insertResult = $this->_addStundensatz($mitarbeiter, self::STUNDENSTAZTYP_KALKULATORISCH, date_format(date_create($mitarbeiter->beginn), 'Y-m-d')); - if (isError($insertResult)) return $insertResult; + echo "SAP Sync Tabelle gefunden. SAP Stundensaetze werden migriert.\n"; + $sapResult = $this->_getSapStunden($user); + if (isError($sapResult)) return $sapResult; + if (!hasData($sapResult)) return error('Keinen kalkulatorischen Stundensaetze gefunden'); + + $mitarbeiterArray = getData($sapResult); + + foreach ($mitarbeiterArray as $mitarbeiter) + { + $this->_getUnternehmen($mitarbeiter); + $insertResult = $this->_addStundensatz($mitarbeiter, self::STUNDENSTAZTYP_KALKULATORISCH, date_format(date_create($mitarbeiter->beginn), 'Y-m-d')); + if (isError($insertResult)) return $insertResult; + } + } + else + { + echo "SAP Sync Tabelle nicht gefunden. Ignoriere SAP Stundensaetze.\n"; } } + protected function checkIfSAPSyncTableExists() + { + $dbModel = new DB_Model(); + $params = array( + DB_NAME, + 'sync', + 'tbl_sap_stundensatz' + ); + + $sql = "SELECT + 1 AS exists + FROM + information_schema.tables + WHERE + table_catalog = ? AND + table_schema = ? AND + table_name = ?"; + + $res = $dbModel->execReadOnlyQuery($sql, $params); + + if( hasData($res) ) + { + return true; + } + else + { + return false; + } + } + + private function _getSapStunden($user = null) { $dbModel = new DB_Model(); diff --git a/application/controllers/system/MigrateSalary.php b/application/controllers/system/MigrateSalary.php index e8771f913..4bd1d3e7d 100644 --- a/application/controllers/system/MigrateSalary.php +++ b/application/controllers/system/MigrateSalary.php @@ -3,7 +3,7 @@ * Job zur einmaligen Import der Gehälter * * Aufruf (Encode / im Filenmae mit %2F): - * php index.ci.php system/MigrateSalary/import filename + * php index.ci.php system/MigrateSalary/import filename * */ /* @@ -34,7 +34,7 @@ class MigrateSalary extends CLI_Controller $this->load->model('vertragsbestandteil/VertragsbestandteilStunden_model','VertragsbestandteilStundenModel'); $this->load->model('vertragsbestandteil/VertragsbestandteilFreitext_model','VertragsbestandteilFreitextModel'); $this->load->model('vertragsbestandteil/VertragsbestandteilFunktion_model','VertragsbestandteilFunktionModel'); - + } // ----------------------------------------------------------------------------------------------------------------- @@ -45,7 +45,7 @@ class MigrateSalary extends CLI_Controller */ public function import($file) { - + // CSV Laden $file = urldecode($file); if($handle = fopen($file, "r")) @@ -108,8 +108,8 @@ class MigrateSalary extends CLI_Controller } else { - if ($data[$i] != '' - && isset($gehaltsarr[$gehaltsindex]) && isset($gehaltsarr[$gehaltsindex]['betrag']) + if ($data[$i] != '' + && isset($gehaltsarr[$gehaltsindex]) && isset($gehaltsarr[$gehaltsindex]['betrag']) && $gehaltsarr[$gehaltsindex]['betrag'] == $data[$i]) { // Gehalt bleibt gleich @@ -138,30 +138,31 @@ class MigrateSalary extends CLI_Controller } } } - + $monat++; } // Zeile zu Ende - Ende Datum setzen wenn nicht für alle Monate ein Eintrag vorhanden ist if($monat < count($monate) && isset($gehaltsarr[$gehaltsindex])) - $gehaltsarr[$gehaltsindex]['ende'] == $monate[$monat-1]; - + $gehaltsarr[$gehaltsindex]['ende'] = $monate[$monat-1]; + } $this->_saveGehalt($lastuser, $gehaltsarr); } } /** - * Ermittelt das passende Dienstverhaeltnis uns speichert den + * Ermittelt das passende Dienstverhaeltnis uns speichert den * Gehaltsbestandteil */ private function _saveGehalt($uid, $gehaltsarr) - { + { $failed = false; $this->db->trans_begin(); foreach($gehaltsarr as $row_gehalt) { + //var_dump($row_gehalt); $auszahlungen = 14; $dvid = ''; $vbsid = ''; @@ -171,16 +172,18 @@ class MigrateSalary extends CLI_Controller //DV und VBS Ermitteln $dv = $this->DienstverhaeltnisModel->getDVByPersonUID($uid, $this->OE_DEFAULT, $row_gehalt['beginn']); - if (!hasData($dv)) + // Wenn keiner gefunden wird oder mit Monatsersteln nur ein externer gefunden wird, weitersuchen ob im Monat noch ein + // "richtiger" Vertrag startet + if (!hasData($dv) || getData($dv)[0]->vertragsart_kurzbz='externerLehrender') { $date = new DateTime($row_gehalt['beginn']); $date->modify('last day of this month'); $last_day_this_month = $date->format('Y-m-d'); - // Wenn mit Monatsersten kein DV gefunden wird, wird stattdessen mit Monatsletzten gesucht um DVs zu finden + // Wenn mit Monatsersten kein DV gefunden wird, wird stattdessen mit Monatsletzten gesucht um DVs zu finden // für Personen die erst später im Monat in ihr DV einsteigen - $dv = $this->DienstverhaeltnisModel->getDVByPersonUID($uid, $this->OE_DEFAULT, $last_day_this_month); - + $dv = $this->DienstverhaeltnisModel->getDVByPersonUIDOverlapping($uid, $this->OE_DEFAULT, $row_gehalt['beginn'], $last_day_this_month); + if (!hasData($dv)) { echo "\nKein passendes DV gefunden für User ".$uid." und Datum ".$row_gehalt['beginn']." -> ROLLBACK\n"; @@ -189,34 +192,53 @@ class MigrateSalary extends CLI_Controller } else { - // Gehaltsstart wird auf den Start des DV korrigiert wenn nicht der Monatserste - $row_gehalt['beginn'] = getData($dv)[0]->von; + $resultdata = getData($dv); + foreach($resultdata as $dvdata) + { + // Externer DV wird in Monatsmitte zu echten DV - daher weitersuchen bei externenDVs da + // diese sowieso kein Gehalt zugeordnet haben + if($dvdata->vertragsart_kurzbz != 'externerLehrender') + { + $dvid = $dvdata->dienstverhaeltnis_id; + // Gehaltsstart wird auf den Start des DV korrigiert wenn nicht der Monatserste + // nur wenn das Beginndatum vor dem DV-Start liegt da sonst das Datum korrigiert wird + // wenn der Vertragsbestandteil wechselt + if($row_gehalt['beginn'] < $dvdata->von) + $row_gehalt['beginn'] = $dvdata->von; + break; + } + } } } - - $resultdata = getData($dv); - if (count($resultdata) !== 1) + else { - echo "Kein oder Mehrere DVs gefunden -> ROLLBACK"; + $resultdata = getData($dv); + + if (count($resultdata) == 1) + $dvid = $resultdata[0]->dienstverhaeltnis_id; + } + + if ($dvid == '') + { + echo "Kein oder mehrere DVs gefunden -> ROLLBACK"; $failed = true; break; } - $dvid = $resultdata[0]->dienstverhaeltnis_id; - $allin = $this->_isAllIn($dvid, $row_gehalt['beginn']); $db = new DB_Model(); $resultVBS = $this->_getVBS($dvid, $row_gehalt['beginn']); - + if (hasData($resultVBS)) { $vbsid = getData($resultVBS)[0]->vertragsbestandteil_id; + $vbsbis = getData($resultVBS)[0]->bis; } else { - echo "Vertragsbestandteil wurde nicht gefunden -> ROLLBACK"; + echo "Vertragsbestandteil fuer $uid DV $dvid wurde nicht gefunden mit Beginn ".$row_gehalt['beginn']."-> ROLLBACK"; $failed = true; break; } @@ -246,7 +268,7 @@ class MigrateSalary extends CLI_Controller ); if (isset($row_gehalt['ende']) && $row_gehalt['ende']!='') $data['bis'] = $row_gehalt['ende']; - + $resultVBS = $this->VertragsbestandteilModel->Insert($data); if(!isSuccess($resultVBS)) { @@ -286,7 +308,7 @@ class MigrateSalary extends CLI_Controller ); if (isset($row_gehalt['ende']) && $row_gehalt['ende']!='') $data['bis'] = $row_gehalt['ende']; - + $resultVBS = $this->VertragsbestandteilModel->Insert($data); if(!isSuccess($resultVBS)) { @@ -356,16 +378,24 @@ class MigrateSalary extends CLI_Controller $date->modify('last day of this month'); $last_day_this_month = $date->format('Y-m-d'); - // TODO: wenn das Dienstverhaeltnis in diesem Monat endet und nicht der Monatsletzte ist, + // Wenn das Dienstverhaeltnis in diesem Monat endet und nicht der Monatsletzte ist, // dann muss hier das Ende Datum des DV stehen bzw das Ende // oder das Ende des VBS falls die Person in der Monatsmitte Stunden wechselt $data['bis'] = $last_day_this_month; + + // Wenn der Vertragsbestandteil endet bevor das Gehalt endet, dann wir das Gehaltsende auf VBS Ende gesetzt + //echo "Ende des VBS: $vbsbis Ende des Gehalt: ".$data['bis']; + if ($vbsbis != '' && $vbsbis < $data['bis']) + { + $data['bis'] = $vbsbis; + //echo "Gehalt auf vbs ende gesetzt"; + } } $ret = $this->GehaltsbestandteilModel->insert($data, $this->GehaltsbestandteilModel->getEncryptedColumns() ); - } + } if(!$failed) { @@ -375,7 +405,7 @@ class MigrateSalary extends CLI_Controller { echo "ROLLBACK"; $this->db->trans_rollback(); - } + } } /** @@ -386,17 +416,17 @@ class MigrateSalary extends CLI_Controller $db = new DB_Model(); $qry = " - SELECT - * - FROM - hr.tbl_vertragsbestandteil + SELECT + * + FROM + hr.tbl_vertragsbestandteil JOIN hr.tbl_vertragsbestandteil_freitext USING(vertragsbestandteil_id) - WHERE - dienstverhaeltnis_id=".$db->escape($dvid)." - AND vertragsbestandteiltyp_kurzbz='freitext' + WHERE + dienstverhaeltnis_id=".$db->escape($dvid)." + AND vertragsbestandteiltyp_kurzbz='freitext' AND ".$db->escape($datum)." BETWEEN von AND COALESCE(bis, '2999-12-31') AND freitexttyp_kurzbz='allin'"; - + $resultAllIn = $db->execReadOnlyQuery($qry); if (hasData($resultAllIn)) @@ -410,15 +440,15 @@ class MigrateSalary extends CLI_Controller $db = new DB_Model(); $qry = " - SELECT - * - FROM - hr.tbl_vertragsbestandteil - WHERE - dienstverhaeltnis_id=".$db->escape($dvid)." - AND vertragsbestandteiltyp_kurzbz='stunden' + SELECT + * + FROM + hr.tbl_vertragsbestandteil + WHERE + dienstverhaeltnis_id=".$db->escape($dvid)." + AND vertragsbestandteiltyp_kurzbz='stunden' AND ".$db->escape($datum)." BETWEEN von AND COALESCE(bis, '2999-12-31')"; - + $resultVBS = $db->execReadOnlyQuery($qry); return $resultVBS; @@ -430,22 +460,22 @@ class MigrateSalary extends CLI_Controller private function _getUser($svnr) { $db = new DB_Model(); - + $qry = " - SELECT - mitarbeiter_uid - FROM - public.tbl_person + SELECT + mitarbeiter_uid + FROM + public.tbl_person JOIN public.tbl_benutzer using(person_id) JOIN public.tbl_mitarbeiter ON(uid=mitarbeiter_uid) WHERE tbl_person.svnr = ". $db->escape($svnr)." AND EXISTS( - SELECT - 1 - FROM - hr.tbl_dienstverhaeltnis - WHERE + SELECT + 1 + FROM + hr.tbl_dienstverhaeltnis + WHERE mitarbeiter_uid=tbl_mitarbeiter.mitarbeiter_uid AND oe_kurzbz=". $db->escape($this->OE_DEFAULT)." ) diff --git a/application/controllers/system/Navigation.php b/application/controllers/system/Navigation.php index c3764b612..71ab1c81b 100644 --- a/application/controllers/system/Navigation.php +++ b/application/controllers/system/Navigation.php @@ -22,6 +22,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); * This controller operates between (interface) the JS (GUI) and the NavigationLib (back-end) * Provides data to the ajax get calls about the filter * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + * TODO(chris): deprecated */ class Navigation extends FHC_Controller { diff --git a/application/core/Auth_Controller.php b/application/core/Auth_Controller.php index c407a106f..d170a7eca 100644 --- a/application/core/Auth_Controller.php +++ b/application/core/Auth_Controller.php @@ -7,6 +7,10 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); */ abstract class Auth_Controller extends FHC_Controller { + // Special Permissions + const PERM_ANONYMOUS = 'anonymous'; // Everyone + const PERM_LOGGED = 'logged_in'; // Every registered user + /** * Extends this controller if authentication is required */ @@ -14,17 +18,41 @@ abstract class Auth_Controller extends FHC_Controller { parent::__construct(); - // Loads authentication library and starts authentication - $this->load->library('AuthLib'); + if (!is_array($requiredPermissions) || isEmptyArray($requiredPermissions)) + show_error('The given permissions is not a valid array or it is an empty one'); + + if (!isset($requiredPermissions[$this->router->method])) + show_error('The given permission array does not contain the given method or is not correctly set'); + + $anonAllowed = false; + if ($requiredPermissions[$this->router->method] == self::PERM_ANONYMOUS) + $anonAllowed = true; + elseif (is_array($requiredPermissions[$this->router->method]) + && in_array(self::PERM_ANONYMOUS, $requiredPermissions[$this->router->method])) + $anonAllowed = true; - // Checks if the caller is allowed to access to this content - $this->_isAllowed($requiredPermissions); + if ($anonAllowed) { + // Loads authentication library without authentication + $this->load->library('AuthLib', [false]); + + // Loads helper since it would only be called on authentication + $this->load->helper('hlp_authentication'); + } else { + // Loads authentication library and starts authentication + $this->load->library('AuthLib'); + + // Checks if the caller is allowed to access to this content + $this->_isAllowed($requiredPermissions); + } } /** * Checks if the caller is allowed to access to this content with the given permissions * If it is not allowed will set the HTTP header with code 401 * Wrapper for permissionlib->isEntitled + * + * @param array $requiredPermissions + * @return void */ private function _isAllowed($requiredPermissions) { @@ -34,28 +62,43 @@ abstract class Auth_Controller extends FHC_Controller // Checks if this user is entitled to access to this content if (!$this->permissionlib->isEntitled($requiredPermissions, $this->router->method)) { - $this->output->set_status_header(REST_Controller::HTTP_UNAUTHORIZED); // set the HTTP header as unauthorized - - $this->load->library('EPrintfLib'); // loads the EPrintfLib to format the output - - // Prints the main error message - $this->eprintflib->printError('You are not allowed to access to this content'); - // Prints the called controller name - $this->eprintflib->printInfo('Controller name: '.$this->router->class); - // Prints the called controller method name - $this->eprintflib->printInfo('Method name: '.$this->router->method); - // Prints the required permissions needed to access to this method - $this->eprintflib->printInfo('Required permissions: '.$this->_rpsToString($requiredPermissions, $this->router->method)); - + $this->_outputAuthError($requiredPermissions); exit; // immediately terminate the execution } } + /** + * Outputs an error message and sets the HTTP Header. + * This function is protected so that it can be overwritten. + * + * @param array $requiredPermissions + * @return void + */ + protected function _outputAuthError($requiredPermissions) + { + $this->output->set_status_header(REST_Controller::HTTP_UNAUTHORIZED); // set the HTTP header as unauthorized + + $this->load->library('EPrintfLib'); // loads the EPrintfLib to format the output + + // Prints the main error message + $this->eprintflib->printError('You are not allowed to access to this content'); + // Prints the called controller name + $this->eprintflib->printInfo('Controller name: '.$this->router->class); + // Prints the called controller method name + $this->eprintflib->printInfo('Method name: '.$this->router->method); + // Prints the required permissions needed to access to this method + $this->eprintflib->printInfo('Required permissions: '.$this->_rpsToString($requiredPermissions, $this->router->method)); + } + /** * Converts an array of permissions to a string that contains them as a comma separated list * Ex: ", , " + * + * @param array $requiredPermissions + * @param string $method + * @return void */ - private function _rpsToString($requiredPermissions, $method) + final protected function _rpsToString($requiredPermissions, $method) { $strRequiredPermissions = ''; // string that contains all the required permissions needed to access to this method diff --git a/application/core/FHCAPI_Controller.php b/application/core/FHCAPI_Controller.php index e59740ded..647032795 100644 --- a/application/core/FHCAPI_Controller.php +++ b/application/core/FHCAPI_Controller.php @@ -5,7 +5,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); /** * Controller using JSON */ -class FHCAPI_Controller extends FHC_Controller +class FHCAPI_Controller extends Auth_Controller { /** @@ -19,12 +19,13 @@ class FHCAPI_Controller extends FHC_Controller /** * Error types */ - const ERROR_TYPE_PHP = 'php'; // TODO(chris): php types from severity? + const ERROR_TYPE_PHP = 'php'; const ERROR_TYPE_EXCEPTION = 'exception'; const ERROR_TYPE_GENERAL = 'general'; const ERROR_TYPE_404 = '404'; const ERROR_TYPE_DB = 'db'; const ERROR_TYPE_VALIDATION = 'validation'; + const ERROR_TYPE_AUTH = 'auth'; /** * Return Object @@ -45,10 +46,6 @@ class FHCAPI_Controller extends FHC_Controller if (is_cli()) show_404(); - parent::__construct(); - - $this->config->set_item('error_views_path', VIEWPATH.'errors'.DIRECTORY_SEPARATOR.'json'.DIRECTORY_SEPARATOR); - global $g_result; $g_result = $this; @@ -74,18 +71,14 @@ class FHCAPI_Controller extends FHC_Controller } } - #$this->returnObj['test'] = implode('/n', headers_list()); - return json_encode($this->returnObj); }); - // Load libraries - $this->load->library('AuthLib'); - $this->load->library('PermissionLib'); - - // Checks if the caller is allowed to access to this content - $this->_isAllowed($requiredPermissions); + // NOTE(chris): overwrite error_views_path before constructor + load_class('Config')->set_item('error_views_path', VIEWPATH.'errors'.DIRECTORY_SEPARATOR.'json'.DIRECTORY_SEPARATOR); + parent::__construct($requiredPermissions); + // For JSON Requests (as opposed to multipart/form-data) get the $_POST variable from the input stream instead if ($this->input->get_request_header('Content-Type', true) == 'application/json') $_POST = json_decode($this->security->xss_clean($this->input->raw_input_stream), true); @@ -136,15 +129,25 @@ class FHCAPI_Controller extends FHC_Controller $this->returnObj['data'] = $data; } + /** + * @param string $key + * @param mixed $value + * @return void + */ + public function addMeta($key, $value) + { + if (!isset($this->returnObj['meta'])) + $this->returnObj['meta'] = []; + $this->returnObj['meta'][$key] = $value; + } + /** * @param string $status * @return void */ public function setStatus($status) { - if (!isset($this->returnObj['meta'])) - $this->returnObj['meta'] = []; - $this->returnObj['meta']['status'] = $status; + $this->addMeta('status', $status); } @@ -152,6 +155,17 @@ class FHCAPI_Controller extends FHC_Controller // Handle Output object - Shortcut functions // --------------------------------------------------------------- + /** + * @param mixed $data (optional) + * @return void + */ + protected function terminateWithSuccess($data = null) + { + $this->setData($data); + $this->setStatus(self::STATUS_SUCCESS); + exit; + } + /** * @param array $errors * @return void @@ -164,25 +178,15 @@ class FHCAPI_Controller extends FHC_Controller exit(EXIT_ERROR); } - /** - * @param mixed $data (optional) - * @return void - */ - protected function terminateWithSuccess($data = null) - { - $this->setData($data); - $this->setStatus(self::STATUS_SUCCESS); - exit; - } - /** * @param array $error * @param string $type (optional) + * @param integer $status (optional) * @return void */ - protected function terminateWithError($error, $type = null) + protected function terminateWithError($error, $type = null, $status = REST_Controller::HTTP_INTERNAL_SERVER_ERROR) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->output->set_status_header($status); $this->addError($error, $type); $this->setStatus(self::STATUS_ERROR); exit; @@ -193,63 +197,35 @@ class FHCAPI_Controller extends FHC_Controller * @param string $errortype * @return void */ - protected function checkForErrors($result, $errortype = self::ERROR_TYPE_GENERAL) + protected function getDataOrTerminateWithError($result, $errortype = self::ERROR_TYPE_GENERAL) { - // TODO(chris): IMPLEMENT! if (isError($result)) { $this->terminateWithError(getError($result), $errortype); } return $result->retval; } - // TODO(chris): complete list - // --------------------------------------------------------------- // Security // --------------------------------------------------------------- /** - * Checks if the caller is allowed to access to this content with the given permissions - * If it is not allowed will set the HTTP header with code 401 - * Wrapper for permissionlib->isEntitled + * Outputs an error message and sets the HTTP Header. + * This overwrites the default behaviour to output a json object. * * @param array $requiredPermissions * @return void */ - protected function _isAllowed($requiredPermissions) + protected function _outputAuthError($requiredPermissions) { - // Checks if this user is entitled to access to this content - if (!$this->permissionlib->isEntitled($requiredPermissions, $this->router->method)) - { - $this->output->set_status_header(isLogged() ? REST_Controller::HTTP_FORBIDDEN : REST_Controller::HTTP_UNAUTHORIZED); + $this->output->set_status_header(isLogged() ? REST_Controller::HTTP_FORBIDDEN : REST_Controller::HTTP_UNAUTHORIZED); - $this->addError([ - 'message' => 'You are not allowed to access to this content', - 'controller' => $this->router->class, - 'method' => $this->router->method, - 'required_permissions' => $this->_rpsToString($requiredPermissions, $this->router->method) - ]); - exit; // immediately terminate the execution - } - } - - /** - * Converts an array of permissions to a string that contains them as a comma separated list - * Ex: ", , " - * - * @param array $requiredPermissions - * @param string $method - * @return void - */ - protected function _rpsToString($requiredPermissions, $method) - { - if (!isset($requiredPermissions[$method])) - return ''; - - if (!is_array($requiredPermissions[$method])) - return $requiredPermissions[$method]; - - return implode(', ', $requiredPermissions[$method]); + $this->addError([ + 'message' => 'You are not allowed to access to this content', + 'controller' => $this->router->class, + 'method' => $this->router->method, + 'required_permissions' => $this->_rpsToString($requiredPermissions, $this->router->method) + ], self::ERROR_TYPE_AUTH); } } 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/libraries/PermissionLib.php b/application/libraries/PermissionLib.php index 09f89abee..bf8174cf4 100644 --- a/application/libraries/PermissionLib.php +++ b/application/libraries/PermissionLib.php @@ -21,6 +21,8 @@ require_once(FHCPATH.'include/functions.inc.php'); require_once(FHCPATH.'include/wawi_kostenstelle.class.php'); require_once(FHCPATH.'include/benutzerberechtigung.class.php'); +use \benutzerberechtigung as benutzerberechtigung; + class PermissionLib { // Available rights in the DB @@ -65,8 +67,10 @@ class PermissionLib if (!is_cli()) { // API Caller rights initialization + $authObj = $this->_ci->authlib->getAuthObj(); self::$bb = new benutzerberechtigung(); - self::$bb->getBerechtigungen(($this->_ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME}); + if ($authObj) + self::$bb->getBerechtigungen($authObj->{AuthLib::AO_USERNAME}); } } @@ -166,6 +170,16 @@ class PermissionLib if ($checkPermissions === true) break; } } + elseif ($permissions[$pCounter] == Auth_Controller::PERM_ANONYMOUS) + { + $checkPermissions = true; + break; + } + elseif ($permissions[$pCounter] == Auth_Controller::PERM_LOGGED) + { + $checkPermissions = isLogged(); + break; + } else { show_error('The given permission does not use the correct format'); diff --git a/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php b/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php index 5745c2196..309d3dfdc 100644 --- a/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php +++ b/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php @@ -247,7 +247,7 @@ EOTXT; $this->validationerrors[] = 'Das Beginndatum muss vor dem Endedatum liegen.'; } - if( $this->checkoverlap && !($this->vertragsart_kurzbz === 'werkvertrag') + if( $this->checkoverlap && !(in_array($this->vertragsart_kurzbz, array('werkvertrag', 'studentischehilfskr')) ) && $ci->VertragsbestandteilLib->isOverlappingExistingDV($this) ) { $this->validationerrors[] = 'Es existiert bereits ein überlappendes Dienstverhältnis'; diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php index 8fb3900d5..297896a02 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php @@ -26,30 +26,35 @@ class VertragsbestandteilLib { const INCLUDE_FUTURE = true; const DO_NOT_INCLUDE_FUTURE = false; - + protected $CI; /** @var Dienstverhaeltnis_model */ protected $DienstverhaeltnisModel; /** @var Vertragsbestandteil_model */ protected $VertragsbestandteilModel; - /** + /** @var Benutzer_model */ + protected $BenutzerModel; + /** * @var GehaltsbestandteilLib */ protected $GehaltsbestandteilLib; - + protected $loggedInUser; - + public function __construct() { $this->loggedInUser = getAuthUID(); $this->CI = get_instance(); - $this->CI->load->model('vertragsbestandteil/Dienstverhaeltnis_model', + $this->CI->load->model('vertragsbestandteil/Dienstverhaeltnis_model', 'DienstverhaeltnisModel'); $this->DienstverhaeltnisModel = $this->CI->DienstverhaeltnisModel; - $this->CI->load->model('vertragsbestandteil/Vertragsbestandteil_model', + $this->CI->load->model('vertragsbestandteil/Vertragsbestandteil_model', 'VertragsbestandteilModel'); $this->VertragsbestandteilModel = $this->CI->VertragsbestandteilModel; - $this->CI->load->library('vertragsbestandteil/GehaltsbestandteilLib', + $this->CI->load->model('person/benutzer_model', + 'BenutzerModel'); + $this->BenutzerModel = $this->CI->BenutzerModel; + $this->CI->load->library('vertragsbestandteil/GehaltsbestandteilLib', null, 'GehaltsbestandteilLib'); $this->GehaltsbestandteilLib = $this->CI->GehaltsbestandteilLib; } @@ -63,49 +68,54 @@ class VertragsbestandteilLib } catch (Exception $ex) { log_message('debug', "Error handling json data from GUI. " . $ex->getMessage()); - } + } return $ret; } + public function fetchDienstverhaeltnisse($unternehmen, $stichtag=null, $mitarbeiteruid=null) { + $dvs = $this->DienstverhaeltnisModel->fetchDienstverhaeltnisse($unternehmen, $stichtag, $mitarbeiteruid); + return $dvs; + } + public function fetchDienstverhaeltnis($dienstverhaeltnis_id) { $result = $this->DienstverhaeltnisModel->load($dienstverhaeltnis_id); $dv = null; - if(null !== ($row = getData($result))) + if(null !== ($row = getData($result))) { $dv = new Dienstverhaeltnis(); $dv->hydrateByStdClass($row[0], true); } return $dv; } - + public function fetchVertragsbestandteile($dienstverhaeltnis_id, $stichtag=null, $includefuture=false) { $vbs = $this->VertragsbestandteilModel->getVertragsbestandteile($dienstverhaeltnis_id, $stichtag, $includefuture); $gbs = $this->GehaltsbestandteilLib->fetchGehaltsbestandteile($dienstverhaeltnis_id, $stichtag, $includefuture); - + $gbsByVBid = array(); - foreach( $gbs as $gb ) + foreach( $gbs as $gb ) { - if( intval($gb->getVertragsbestandteil_id()) > 0 ) + if( intval($gb->getVertragsbestandteil_id()) > 0 ) { - if( !isset($gbsByVBid[$gb->getVertragsbestandteil_id()]) + if( !isset($gbsByVBid[$gb->getVertragsbestandteil_id()]) || !is_array($gbsByVBid[$gb->getVertragsbestandteil_id()]) ) { $gbsByVBid[$gb->getVertragsbestandteil_id()] = array(); } $gbsByVBid[$gb->getVertragsbestandteil_id()][] = $gb; } } - + foreach ($vbs as $vb) { - if( isset($gbsByVBid[$vb->getVertragsbestandteil_id()]) ) + if( isset($gbsByVBid[$vb->getVertragsbestandteil_id()]) ) { $vb->setGehaltsbestandteile($gbsByVBid[$vb->getVertragsbestandteil_id()]); } } - + return $vbs; } @@ -113,22 +123,22 @@ class VertragsbestandteilLib { return $this->VertragsbestandteilModel->getVertragsbestandteil($vertragsbestandteil_id); } - + public function storeDienstverhaeltnis(Dienstverhaeltnis $dv) { if( intval($dv->getDienstverhaeltnis_id()) > 0 ) { $this->updateDienstverhaeltnis($dv); } - else + else { - $this->insertDienstverhaeltnis($dv); + $this->insertDienstverhaeltnis($dv); } } - - public function storeVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) + + public function storeVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) { - $this->CI->db->trans_begin(); + $this->CI->db->trans_begin(); try { $this->setUIDtoPGSQL(); @@ -144,7 +154,7 @@ class VertragsbestandteilLib { log_message('debug', "Transaction failed"); throw new Exception("Transaction failed"); - } + } $this->CI->db->trans_commit(); } catch (Exception $ex) @@ -152,7 +162,7 @@ class VertragsbestandteilLib log_message('debug', "Transaction rolled back. " . $ex->getMessage()); $this->CI->db->trans_rollback(); throw new Exception('Storing Vertragsbestandteil failed.'); - } + } } public function deleteDienstverhaeltnis(Dienstverhaeltnis $dv) @@ -220,13 +230,13 @@ class VertragsbestandteilLib throw new Exception('Delete Vertragsbestandteil failed.'); } } - + protected function insertDienstverhaeltnis(Dienstverhaeltnis $dv) { $dv->setInsertvon($this->loggedInUser) ->setInsertamum(strftime('%Y-%m-%d %H:%M:%S')); $ret = $this->DienstverhaeltnisModel->insert($dv->toStdClass()); - if( hasData($ret) ) + if( hasData($ret) ) { $dv->setDienstverhaeltnis_id(getData($ret)); } @@ -235,14 +245,14 @@ class VertragsbestandteilLib throw new Exception('error inserting dienstverhaeltnis'); } } - + protected function insertVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) { $vertragsbestandteil->setInsertvon($this->loggedInUser) ->setInsertamum(strftime('%Y-%m-%d %H:%M:%S')); $vertragsbestandteil->beforePersist(); $ret = $this->VertragsbestandteilModel->insert($vertragsbestandteil->baseToStdClass()); - if( hasData($ret) ) + if( hasData($ret) ) { $vertragsbestandteil->setVertragsbestandteil_id(getData($ret)); } @@ -254,19 +264,19 @@ class VertragsbestandteilLib $specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel( $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); $retspecial = $specialisedModel->insert($vertragsbestandteil->toStdClass()); - + if(isError($retspecial) ) { - throw new Exception('error updating vertragsbestandteil ' + throw new Exception('error updating vertragsbestandteil ' . $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); } - - try + + try { $gehaltsbestandteile = $vertragsbestandteil->getGehaltsbestandteile(); $this->GehaltsbestandteilLib->storeGehaltsbestandteile($gehaltsbestandteile); - } - catch(Exception $ex) + } + catch(Exception $ex) { throw new Exception('VertragsbestandteilLib insertVertragsbestandteil ' . 'failed to store Gehaltsbestandteile. ' . $ex->getMessage()); @@ -278,7 +288,7 @@ class VertragsbestandteilLib if(!$dv->isDirty()) { return; } - + $dv->setUpdatevon($this->loggedInUser) ->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S')); $ret = $this->DienstverhaeltnisModel->update($dv->getDienstverhaeltnis_id(), @@ -288,20 +298,20 @@ class VertragsbestandteilLib throw new Exception('error updating dienstverhaeltnis'); } } - + private function deleteVertragsbestandteilHelper(Vertragsbestandteil $vertragsbestandteil) { $specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel( $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); $retspecial = $specialisedModel->delete($vertragsbestandteil->getVertragsbestandteil_id()); - + if(isError($retspecial) ) { throw new Exception('error deleting vertragsbestandteil ' . $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); } - + try { $gehaltsbestandteile = $vertragsbestandteil->getGehaltsbestandteile(); @@ -320,76 +330,118 @@ class VertragsbestandteilLib { throw new Exception('error deleting vertragsbestandteil'); } - + $vertragsbestandteil->afterDelete(); } protected function updateVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) { - if($vertragsbestandteil->isDirty()) { + if($vertragsbestandteil->isDirty()) { $vertragsbestandteil->setUpdatevon($this->loggedInUser) ->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S')); $vertragsbestandteil->beforePersist(); $basedata = $vertragsbestandteil->baseToStdClass(); - if( count((array) $basedata) > 0 ) + if( count((array) $basedata) > 0 ) { $ret = $this->VertragsbestandteilModel->update( - $vertragsbestandteil->getVertragsbestandteil_id(), + $vertragsbestandteil->getVertragsbestandteil_id(), $basedata); if(isError($ret) ) { throw new Exception('error updating vertragsbestandteil'); - } + } } $specialisedData = $vertragsbestandteil->toStdClass(); - if( count((array) $specialisedData) > 0 ) + if( count((array) $specialisedData) > 0 ) { $specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel( $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); $retspecial = $specialisedModel->update( - $vertragsbestandteil->getVertragsbestandteil_id(), + $vertragsbestandteil->getVertragsbestandteil_id(), $specialisedData); if(isError($retspecial) ) { - throw new Exception('error updating vertragsbestandteil ' + throw new Exception('error updating vertragsbestandteil ' . $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); } } } - - try + + try { $gehaltsbestandteile = $vertragsbestandteil->getGehaltsbestandteile(); $this->GehaltsbestandteilLib->storeGehaltsbestandteile($gehaltsbestandteile); - } - catch(Exception $ex) + } + catch(Exception $ex) { throw new Exception('VertragsbestandteilLib updateVertragsbestandteil ' . 'failed to store Gehaltsbestandteile. ' . $ex->getMessage()); } } - - public function isOverlappingExistingDV(Dienstverhaeltnis $dv) + + public function isOverlappingExistingDV(Dienstverhaeltnis $dv) { return $this->DienstverhaeltnisModel->isOverlappingExistingDV( - $dv->getMitarbeiter_uid(), - $dv->getOe_kurzbz(), - $dv->getVon(), + $dv->getMitarbeiter_uid(), + $dv->getOe_kurzbz(), + $dv->getVon(), $dv->getBis(), $dv->getDienstverhaeltnis_id() ); } - + + protected function hasOtherActiveDV(Dienstverhaeltnis $dv, $duedate) + { + $hasotheractivedv = false; + $result = $this->DienstverhaeltnisModel->getDVByPersonUID($dv->getMitarbeiter_uid(), null, $duedate); + $dvs = getData($result); + foreach ($dvs as $tmpdv) + { + if(intval($tmpdv->dienstverhaeltnis_id) !== intval($dv->getDienstverhaeltnis_id())) + { + $hasotheractivedv = true; + break; + } + } + return $hasotheractivedv; + } + + /** + * like endDienstverhaeltnis, but also sets aktiv flag to false + */ + public function deactivateDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate, $deactivate) + { + $result = $this->endDienstverhaeltnis($dv, $enddate); + if ( $result === true) + { + if (!$deactivate) return $result; + + if(!$this->hasOtherActiveDV($dv, $enddate)) + { + $result = $this->BenutzerModel->update( + array('uid' => $dv->getMitarbeiter_uid()), + array( + 'aktiv' => false, + 'updateaktivam' => date('Y-m-d'), + 'updateaktivvon' => $this->loggedInUser + ) + ); + } + } + + return $result; + } + public function endDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate) { - if( $dv->getBis() !== null && $dv->getBis() < $enddate ) + if( $dv->getBis() !== null && $dv->getBis() < $enddate ) { return 'Dienstverhältnis ist bereits beendet.'; } - + $this->CI->db->trans_begin(); try { @@ -401,13 +453,13 @@ class VertragsbestandteilLib { $this->GehaltsbestandteilLib->endGehaltsbestandteil($gb, $enddate); } - + $vbs = $this->fetchVertragsbestandteile($dv->getDienstverhaeltnis_id()); foreach ($vbs as $vb) { $this->endVertragsbestandteil($vb, $enddate); - } - + } + $dv->setBis($enddate); $this->updateDienstverhaeltnis($dv); @@ -428,23 +480,23 @@ class VertragsbestandteilLib } return true; } - + public function endVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil, $enddate) { - if( $vertragsbestandteil->getBis() !== null && $vertragsbestandteil->getBis() < $enddate ) + if( $vertragsbestandteil->getBis() !== null && $vertragsbestandteil->getBis() < $enddate ) { return; } - + $vertragsbestandteil->setBis($enddate); $this->updateVertragsbestandteil($vertragsbestandteil); } - + protected function setUIDtoPGSQL() { $ret = $this->VertragsbestandteilModel - ->execReadOnlyQuery('SET LOCAL pv21.uid TO \'' + ->execReadOnlyQuery('SET LOCAL pv21.uid TO \'' . $this->loggedInUser . '\''); - if(isError($ret)) + if(isError($ret)) { throw new Exception('error setting uid to pgsql'); } diff --git a/application/models/codex/Bismeldestichtag_model.php b/application/models/codex/Bismeldestichtag_model.php index 1a45f0fbd..6ab755c8b 100644 --- a/application/models/codex/Bismeldestichtag_model.php +++ b/application/models/codex/Bismeldestichtag_model.php @@ -11,4 +11,25 @@ class Bismeldestichtag_model extends DB_Model $this->dbTable = 'bis.tbl_bismeldestichtag'; $this->pk = 'meldestichtag_id'; } + + /** + * Gets last Bismeldestichtag for a Studiensemester. + * @param $studiensemester_kurzbz + * @return object success or error + */ + public function getByStudiensemester($studiensemester_kurzbz) + { + $query = ' + SELECT + meldestichtag + FROM + bis.tbl_bismeldestichtag + JOIN public.tbl_studiensemester USING (studiensemester_kurzbz) + WHERE + studiensemester_kurzbz = ? + ORDER BY meldestichtag DESC + LIMIT 1'; + + return $this->execQuery($query, array($studiensemester_kurzbz)); + } } diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php index d232e14d6..4bbb63805 100644 --- a/application/models/organisation/Studiengang_model.php +++ b/application/models/organisation/Studiengang_model.php @@ -563,7 +563,7 @@ class Studiengang_model extends DB_Model $this->addJoin('public.tbl_student stud', 'p.prestudent_id=stud.prestudent_id', 'LEFT'); $this->db->where_in($this->dbTable . '.studiengang_kz', $studiengang_kzs); - $this->db->where_in('ps.status_kurzbz', $this->config->item('antrag_prestudentstatus_whitelist')); + $this->db->where_in('ps.status_kurzbz', $this->config->item('antrag_prestudentstatus_whitelist_abmeldung')); $this->db->where($this->dbTable . ".aktiv", true); if ($not_antrag_typ !== null && is_array($not_antrag_typ)) { diff --git a/application/models/ressource/Zeitaufzeichnung_model.php b/application/models/ressource/Zeitaufzeichnung_model.php index b44861d13..8639a716a 100644 --- a/application/models/ressource/Zeitaufzeichnung_model.php +++ b/application/models/ressource/Zeitaufzeichnung_model.php @@ -21,4 +21,26 @@ class Zeitaufzeichnung_model extends DB_Model return $this->execQuery($qry); } + + public function getFullInterval($uid, $fromDate, $toDate) + { + $qry = <<execQuery($qry, array($uid, $fromDate, $toDate, $uid, $fromDate, $toDate, $fromDate, $toDate)); + } } diff --git a/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php b/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php index 5b276c55e..2fdfcffe2 100644 --- a/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php +++ b/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php @@ -18,7 +18,7 @@ class Dienstverhaeltnis_model extends DB_Model $result = null; $qry = " - SELECT + SELECT dv.dienstverhaeltnis_id, tbl_benutzer.uid, tbl_mitarbeiter.personalnummer, @@ -30,8 +30,8 @@ class Dienstverhaeltnis_model extends DB_Model org.oe_kurzbz, org.bezeichnung oe_bezeichnung, dv.von, - dv.bis, - dv.vertragsart_kurzbz, + dv.bis, + dv.vertragsart_kurzbz, dv.updateamum, dv.updatevon FROM tbl_mitarbeiter @@ -59,13 +59,13 @@ class Dienstverhaeltnis_model extends DB_Model "; return $this->execQuery($qry, $data); - + } public function getDVByID($dvid) { $this->addSelect('hr.tbl_dienstverhaeltnis.*, public.tbl_organisationseinheit.bezeichnung as unternehmen'); $this->addJoin('public.tbl_organisationseinheit', 'hr.tbl_dienstverhaeltnis.oe_kurzbz = public.tbl_organisationseinheit.oe_kurzbz'); - $result = $this->load($dvid); + $result = $this->load($dvid); if (hasData($result)) { return $result; @@ -81,7 +81,7 @@ class Dienstverhaeltnis_model extends DB_Model $datestring = $date->format("Y-m-d"); $qry = " - SELECT + SELECT dv.dienstverhaeltnis_id, tbl_benutzer.uid, tbl_mitarbeiter.personalnummer, @@ -115,26 +115,26 @@ class Dienstverhaeltnis_model extends DB_Model $params = array_merge($params, array($dvid, $dvid)); $dvidclause = <<= COALESCE(vb.von, '1970-01-01'::date) - AND - COALESCE(dv.bis::date, '2170-12-31'::date) <= COALESCE(vb.bis, '2170-12-31') + AND + vb.vertragsbestandteiltyp_kurzbz = 'karenz' + AND + dv.von::date >= COALESCE(vb.von, '1970-01-01'::date) + AND + COALESCE(dv.bis::date, '2170-12-31'::date) <= COALESCE(vb.bis, '2170-12-31') ) = 0 AND dv.dienstverhaeltnis_id != ? EODVIDC; - + } - + $query = <<= dv.von + AND + COALESCE(?::date, '2170-12-31'::date) >= dv.von AND ( - SELECT - COUNT(*) AS karenzen - FROM - hr.tbl_vertragsbestandteil vb - WHERE + SELECT + COUNT(*) AS karenzen + FROM + hr.tbl_vertragsbestandteil vb + WHERE vb.dienstverhaeltnis_id = dv.dienstverhaeltnis_id - AND - vb.vertragsbestandteiltyp_kurzbz = 'karenz' - AND - ?::date >= COALESCE(vb.von, '1970-01-01'::date) - AND - COALESCE(?::date, '2170-12-31'::date) <= COALESCE(vb.bis, '2170-12-31') - ) = 0 + AND + vb.vertragsbestandteiltyp_kurzbz = 'karenz' + AND + ?::date >= COALESCE(vb.von, '1970-01-01'::date) + AND + COALESCE(?::date, '2170-12-31'::date) <= COALESCE(vb.bis, '2170-12-31') + ) = 0 {$dvidclause} EOSQL; - + $ret = $this->execReadOnlyQuery($query, $params); - + if( ($dvcount = getData($ret)) && ($dvcount[0]->dvcount > 0) ) { return true; } - - return false; + + return false; } -} \ No newline at end of file + + public function getDVByPersonUIDOverlapping($uid, $oe_kurzbz=null, $beginn=null, $ende=null) + { + $result = null; + + $qry = " + SELECT + dv.dienstverhaeltnis_id, + tbl_benutzer.uid, + tbl_mitarbeiter.personalnummer, + tbl_mitarbeiter.kurzbz, + tbl_mitarbeiter.lektor, + tbl_mitarbeiter.fixangestellt, + tbl_person.person_id, + tbl_benutzer.alias, + org.oe_kurzbz, + org.bezeichnung oe_bezeichnung, + dv.von, + dv.bis, + dv.vertragsart_kurzbz, + dv.updateamum, + dv.updatevon + FROM tbl_mitarbeiter + JOIN tbl_benutzer ON tbl_mitarbeiter.mitarbeiter_uid::text = tbl_benutzer.uid::text + JOIN tbl_person USING (person_id) + JOIN hr.tbl_dienstverhaeltnis dv ON(tbl_benutzer.uid::text = dv.mitarbeiter_uid::text) + JOIN public.tbl_organisationseinheit org USING(oe_kurzbz) + WHERE tbl_benutzer.uid=?"; + $data = array($uid); + + if(!is_null($oe_kurzbz)) + { + $qry.=" AND oe_kurzbz=?"; + $data[] = $oe_kurzbz; + } + + if (!is_null($beginn) && !is_null($ende)) + { + $qry.=" AND (?,?) OVERLAPS (dv.von, COALESCE(dv.bis, '2999-12-31'))"; + $data[] = $beginn; + $data[] = $ende; + } + + $qry .=" + ORDER BY dv.von desc + "; + + return $this->execQuery($qry, $data); + + } + + public function fetchDienstverhaeltnisse($unternehmen, $stichtag=null, $mitarbeiteruid=null) { + $where = "oe_kurzbz = " . $this->escape($unternehmen); + if( !is_null($stichtag) ) + { + $where .= " AND " . $this->escape($stichtag) . " BETWEEN COALESCE(von, '1970-01-01') AND COALESCE(bis, '2070-12-31')"; + } + if( !is_null($mitarbeiteruid) ) + { + $where .= " AND mitarbeiter_uid = " . $this->escape($mitarbeiteruid); + } + $res = $this->loadWhere($where); + $dvs = array(); + if(hasData($res) ) + { + $dvs = getData($res); + } + return $dvs; + } +} 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/application/views/system/logs/testSearch.php b/application/views/system/logs/testSearch.php index 882b953f5..57ed0d48a 100644 --- a/application/views/system/logs/testSearch.php +++ b/application/views/system/logs/testSearch.php @@ -1,13 +1,12 @@ 'Test Search', - 'jquery3' => true, 'bootstrap5' => true, 'fontawesome6' => true, - 'tablesorter2' => true, + 'tabulator5' => true, + 'primevue3' => true, + 'axios027' => true, 'vue3' => true, - 'ajaxlib' => true, - 'jqueryui1' => true, 'filtercomponent' => true, 'navigationcomponent' => true, 'phrases' => array( @@ -17,8 +16,8 @@ 'customCSSs' => array( 'public/css/components/verticalsplit.css', 'public/css/components/searchbar.css', + 'public/css/components/primevue.css', ), - 'customJSs' => array('vendor/axios/axios/axios.min.js'), 'customJSModules' => array('public/js/apps/TestSearch.js') ); @@ -40,17 +39,17 @@
- + - + - +
diff --git a/cis/private/info/service_uebersicht.php b/cis/private/info/service_uebersicht.php index 27759e6c6..348a82b0d 100644 --- a/cis/private/info/service_uebersicht.php +++ b/cis/private/info/service_uebersicht.php @@ -45,25 +45,22 @@ echo ' - - - - - -'; + + + + + + '; + +const MOODLE_ADDON_KURZBZ = 'moodle'; // Load Addons to get Moodle_Path $addon_obj = new addon(); -if ($addon_obj->loadAddons()) + +// include moodle addon config if active +if ($addon_obj->checkActiveAddon(MOODLE_ADDON_KURZBZ) && file_exists('../../../addons/'.MOODLE_ADDON_KURZBZ.'/config.inc.php')) { - if (count($addon_obj->result) > 0) - { - foreach ($addon_obj->result as $row) - { - if (file_exists('../../../addons/'.$row->kurzbz.'/config.inc.php')) - include_once('../../../addons/'.$row->kurzbz.'/config.inc.php'); - } - } + include_once('../../../addons/'.MOODLE_ADDON_KURZBZ.'/config.inc.php'); } echo ' @@ -117,6 +114,7 @@ echo ' '; +$servicekategorie_arr = $service->getKategorieArray(); if($oe_kurzbz!='') { @@ -134,6 +132,7 @@ echo ' + @@ -159,6 +158,8 @@ foreach($service->result as $row) echo ''; //echo ''; //echo ''; + $title = (isset($servicekategorie_arr[$row->servicekategorie_kurzbz])?$servicekategorie_arr[$row->servicekategorie_kurzbz]:''); + echo ''; echo ''; + $anzahl_spalten = $this->db_num_fields($this->data); + for($spalte=0;$spalte<$anzahl_spalten;$spalte++) + { + $this->html.= ''; + $this->csv.='"'.$this->db_field_name($this->data,$spalte).'",'; + } + $this->html.= ''; + $this->csv=substr($this->csv,0,-1)."\n"; + while($row = $this->db_fetch_object($this->data)) + { + $this->html.= ''; + $anzahl_spalten = $this->db_num_fields($this->data); + + for($spalte=0;$spalte<$anzahl_spalten;$spalte++) + { + $name = $this->db_field_name($this->data,$spalte); + $this->html.= ''; + // Umwandeln von Punkt in Komma bei Float-Werten + if (is_numeric($row->$name)) + { + if (strpos($row->$name,'.') != false) + $row->$name = number_format($row->$name,2,",",""); + } + $this->csv.= '"'.$row->$name.'",'; + } + + $this->json[] = $row; + $this->html.= ''; + $this->csv=substr($this->csv,0,-1)."\n"; + $this->countRows++; + } + $this->html.= ''; + } + return true; + } + else + { + $this->errormsg= 'Zu dieser Statistik gibt es keine SQL Abfrage'; + return false; + } + } + + function getHtmlTable($id, $class='') + { + return '

'.$this->countRows.' Zeilen

'.$p->t("global/bezeichnung").' '.$p->t("services/leistung").' '.$p->t("services/design").''.$p->t("services/kritikalitaet").' '.$p->t("services/details").'
',$design,'',$betrieb,'',$operativ,'',$title,''.($row->content_id!=''?'Details':''); if (defined("ADDON_MOODLE_PATH")) echo ' '.($row->ext_id!=''?'Beschreibung':''); diff --git a/cis/private/lehre/anwesenheitsliste.php b/cis/private/lehre/anwesenheitsliste.php index 8b1f28408..0ba5531c8 100644 --- a/cis/private/lehre/anwesenheitsliste.php +++ b/cis/private/lehre/anwesenheitsliste.php @@ -62,7 +62,7 @@ $stsem = $_GET['stsem']; else die($p->t('anwesenheitsliste/studiensemesterIstUngueltig')); - + $covidhelper = new CovidHelper(); ?> "; - $qry = "SELECT *, tbl_lehreinheitgruppe.studiengang_kz, tbl_lehreinheitgruppe.semester FROM lehre.tbl_lehreinheit JOIN lehre.tbl_lehreinheitgruppe USING(lehreinheit_id) JOIN lehre.tbl_lehrveranstaltung USING(lehrveranstaltung_id) - WHERE lehrveranstaltung_id='$lvid' AND studiensemester_kurzbz=".$db->db_add_param($stsem); - $qry = "SELECT *, tbl_lehreinheitgruppe.studiengang_kz, tbl_lehreinheitgruppe.semester ,tbl_lehreinheit.lehrform_kurzbz FROM lehre.tbl_lehreinheit JOIN lehre.tbl_lehreinheitgruppe USING(lehreinheit_id) @@ -213,7 +210,7 @@ $covidhelper = new CovidHelper(); $covid_content = "".$covid_content."

".$p->t('anwesenheitsliste/covidstatuslisten')."

"; else $covid_content = ($covidhelper->isUdfDefined()) ? $p->t('anwesenheitsliste/keineStudentenVorhanden') : ''; - + if($aw_content!='') $aw_content = "".$aw_content."

".$p->t('anwesenheitsliste/anwesenheitslisten')."

"; else @@ -241,9 +238,9 @@ $covidhelper = new CovidHelper(); { $covid_content = ''; } - + echo " - + diff --git a/cis/private/lehre/benotungstool/lvgesamtnoteverwalten.php b/cis/private/lehre/benotungstool/lvgesamtnoteverwalten.php index 6dce2b6ae..a799c9fad 100644 --- a/cis/private/lehre/benotungstool/lvgesamtnoteverwalten.php +++ b/cis/private/lehre/benotungstool/lvgesamtnoteverwalten.php @@ -102,6 +102,22 @@ $noten_obj->getAll(); $sprachen = new sprache(); $sprachen->getAll(true); + +$noten_array = array(); +$js_noten=''; +foreach ($noten_obj->result as $row) +{ + $js_noten .= " noten_array['" . $row->note . "']='" . addslashes($row->bezeichnung) . "';\n"; + $noten_array[$row->note]['bezeichnung'] = $row->bezeichnung; + $noten_array[$row->note]['positiv'] = $row->positiv; + $noten_array[$row->note]['aktiv'] = $row->aktiv; + $noten_array[$row->note]['lehre'] = $row->lehre; + $noten_array[$row->note]['lkt_ueberschreibbar'] = $row->lkt_ueberschreibbar; + $noten_array[$row->note]['anmerkung'] = $row->anmerkung; + foreach ($sprachen->result as $s) + $noten_array[$row->note]['bezeichnung_mehrsprachig'][$s->sprache] = $row->bezeichnung_mehrsprachig[$s->sprache]; +} + $errormsg = ''; // eingetragene lv-gesamtnoten freigeben @@ -326,19 +342,7 @@ echo ' var noten_array = Array(); '; -$noten_array = array(); -foreach ($noten_obj->result as $row) -{ - echo " noten_array['" . $row->note . "']='" . addslashes($row->bezeichnung) . "';\n"; - $noten_array[$row->note]['bezeichnung'] = $row->bezeichnung; - $noten_array[$row->note]['positiv'] = $row->positiv; - $noten_array[$row->note]['aktiv'] = $row->aktiv; - $noten_array[$row->note]['lehre'] = $row->lehre; - $noten_array[$row->note]['lkt_ueberschreibbar'] = $row->lkt_ueberschreibbar; - $noten_array[$row->note]['anmerkung'] = $row->anmerkung; - foreach ($sprachen->result as $s) - $noten_array[$row->note]['bezeichnung_mehrsprachig'][$s->sprache] = $row->bezeichnung_mehrsprachig[$s->sprache]; -} +echo $js_noten; ?> @@ -806,16 +810,16 @@ foreach ($noten_obj->result as $row) for(row in rows) { linenumber++; - if( rows[row] == '' ) + if( rows[row] == '' ) { //skip empty lines continue; } zeile = rows[row].split(" "); - + if( zeile.length < 2 ) { - alertMsg = alertMsg + "Zeile " + linenumber + ': ' + alertMsg = alertMsg + "Zeile " + linenumber + ': ' + 'Zu wenig Paramter - 2 erforderlich. ' + 'Die Zeile wurde uebersprungen.' + "\n\n"; continue; @@ -917,36 +921,36 @@ foreach ($noten_obj->result as $row) for(row in rows) { linenumber++; - if( rows[row] == '' ) + if( rows[row] == '' ) { //skip empty lines continue; } zeile = rows[row].split(" "); - + if( zeile.length < 3 ) { - alertMsg = alertMsg + "Zeile " + linenumber + ': ' + alertMsg = alertMsg + "Zeile " + linenumber + ': ' + 'Zu wenig Paramter - 3 erforderlich. ' + 'Die Zeile wurde uebersprungen.' + "\n\n"; continue; } - + if( zeile[1] == '' && zeile[2] == '' ) { - // ignore lines just copied from excel + // ignore lines just copied from excel continue; } - - if( zeile[2] == '' ) + + if( zeile[2] == '' ) { alertMsg = alertMsg + "Zeile " + linenumber + ': ' + "Die Note oder Punkte fehlen. " + "Die Zeile wurde uebersprungen. \n\n"; - continue; + continue; } - - if (CIS_GESAMTNOTE_PUNKTE == false) + + if (CIS_GESAMTNOTE_PUNKTE == false) { // check for valid grades if (validGrades.indexOf(zeile[2]) === -1) @@ -958,7 +962,7 @@ foreach ($noten_obj->result as $row) } } - if( !zeile[1].match(/[0-9]{2}\.[0-9]{2}\.[0-9]{4}/) ) + if( !zeile[1].match(/[0-9]{2}\.[0-9]{2}\.[0-9]{4}/) ) { alertMsg = alertMsg + "Zeile " + linenumber + ': ' + "Das Datum "+zeile[1]+" fehlt oder ist nicht zulaessig. " diff --git a/cis/private/lehre/benotungstool/nachpruefungeintragen.php b/cis/private/lehre/benotungstool/nachpruefungeintragen.php index 873c0f173..55954fcda 100644 --- a/cis/private/lehre/benotungstool/nachpruefungeintragen.php +++ b/cis/private/lehre/benotungstool/nachpruefungeintragen.php @@ -251,7 +251,7 @@ else // deshalb wird hier versucht eine passende Lehreinheit zu ermitteln. $lehreinheit_id = getLehreinheit($db, $lvid, $student_uid, $stsem); - $response = savePruefung($lvid, $student_uid, $stsem, $lehreinheit_id, $datum, $typ, $note); + $response = savePruefung($lvid, $student_uid, $stsem, $lehreinheit_id, $datum, $typ, $note, $punkte); echo $response; } else diff --git a/cis/private/pdfExport.php b/cis/private/pdfExport.php index 6db6f885a..ad2bb1fae 100644 --- a/cis/private/pdfExport.php +++ b/cis/private/pdfExport.php @@ -65,6 +65,11 @@ $xsl_stg_kz = 0; $sign = false; +/* Signing on CIS disabled +if(isset($_GET['sign'])) + $sign = true; +*/ + // Direkte uebergabe des Studienganges dessen Vorlage verwendet werden soll if (isset($_GET['xsl_stg_kz'])) $xsl_stg_kz = $_GET['xsl_stg_kz']; @@ -298,22 +303,18 @@ if ((((isset($_GET["uid"]) && $user == $_GET["uid"])) || $rechte->isBerechtigt(' $dokument->setFilename($filename); - if (!$dokument->create($output)) - die($dokument->errormsg); - if ($sign === true) { - if ($dokument->sign($user)) - { - $dokument->output(); - } - else + if (!$dokument->sign($user)) { echo $dokument->errormsg; } } - else - $dokument->output(); + + if (!$dokument->create($output)) + die($dokument->errormsg); + + $dokument->output(); $dokument->close(); } else diff --git a/cis/private/tools/zeitaufzeichnung.php b/cis/private/tools/zeitaufzeichnung.php index 46fd2c4c3..7b1fb1fbb 100644 --- a/cis/private/tools/zeitaufzeichnung.php +++ b/cis/private/tools/zeitaufzeichnung.php @@ -1222,7 +1222,6 @@ if ($projekt->getProjekteMitarbeiter($user, true)) '; - $anzahl_spalten = $this->db_num_fields($this->data); - for($spalte=0;$spalte<$anzahl_spalten;$spalte++) - { - $this->html.= ''; - $this->csv.='"'.$this->db_field_name($this->data,$spalte).'",'; - } - $this->html.= ''; - $this->csv=substr($this->csv,0,-1)."\n"; - while($row = $this->db_fetch_object($this->data)) - { - $this->html.= ''; - $anzahl_spalten = $this->db_num_fields($this->data); - - for($spalte=0;$spalte<$anzahl_spalten;$spalte++) - { - $name = $this->db_field_name($this->data,$spalte); - $this->html.= ''; - // Umwandeln von Punkt in Komma bei Float-Werten - if (is_numeric($row->$name)) - { - if (strpos($row->$name,'.') != false) - $row->$name = number_format($row->$name,2,",",""); - } - $this->csv.= '"'.$row->$name.'",'; - } - - $this->json[] = $row; - $this->html.= ''; - $this->csv=substr($this->csv,0,-1)."\n"; - $this->countRows++; - } - $this->html.= ''; - } - return true; - } - else - { - $this->errormsg= 'Zu dieser Statistik gibt es keine SQL Abfrage'; - return false; - } - } - - function getHtmlTable($id, $class='') - { - return '

'.$this->countRows.' Zeilen

$aw_content $covid_content"; break; case 'datepicker': - $html .= ''; + $html .= 'kurzbz])) + { + $html .= ' value="'.$getParams[$filter->kurzbz].'"'; + } + $html .= ' >'; $html .= ''; break; + case 'text': + $html .= 'htmlattr; + if (isset($getParams[$filter->kurzbz])) + { + $html .= ' value="'.$getParams[$filter->kurzbz].'"'; + } + $html .= '>'; + break; } return $html; } diff --git a/include/mitarbeiter.class.php b/include/mitarbeiter.class.php index bb2a7b478..2802e241d 100644 --- a/include/mitarbeiter.class.php +++ b/include/mitarbeiter.class.php @@ -1889,6 +1889,46 @@ class mitarbeiter extends benutzer } + /** + * Liefert alle Mitarbeiter*innen + * + * @param $filter + * @return boolean + */ + public function getAll() + { + $qry = ' + SELECT + ma.mitarbeiter_uid, p.nachname, p.vorname, b.alias + FROM + public.tbl_mitarbeiter ma + JOIN public.tbl_benutzer b ON (mitarbeiter_uid=uid) + JOIN public.tbl_person p USING(person_id) + ORDER BY p.nachname + '; + + if($this->db_query($qry)) + { + while($row = $this->db_fetch_object()) + { + $ma_obj = new mitarbeiter(); + + $ma_obj->nachname = $row->nachname; + $ma_obj->vorname = $row->vorname; + $ma_obj->mitarbeiter_uid = $row->mitarbeiter_uid; + $ma_obj->alias = $row->alias; + + $this->maData[] = $ma_obj; + } + return true; + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } + /** * Generiert nächste freie Personalnummer anhand der sequence tbl_mitarbeiter_personalnummer_seq * @return string $personalnummer @@ -1947,6 +1987,5 @@ class mitarbeiter extends benutzer return true; } } - } ?> diff --git a/include/projekt.class.php b/include/projekt.class.php index 389d7140c..1dd7f60fb 100644 --- a/include/projekt.class.php +++ b/include/projekt.class.php @@ -413,6 +413,8 @@ class projekt extends basis_db AND mitarbeiter_uid=" . $this->db_add_param($mitarbeiter_uid); } + $qry .= ' ORDER BY titel'; + if ($result = $this->db_query($qry)) { while ($row = $this->db_fetch_object($result)) diff --git a/include/projektphase.class.php b/include/projektphase.class.php index c1cd8322c..c7b224861 100644 --- a/include/projektphase.class.php +++ b/include/projektphase.class.php @@ -190,7 +190,7 @@ class projektphase extends basis_db if(!is_null($foreignkey)) $qry .= " and projektphase_fk is NULL"; - $qry .= " ORDER BY start, projektphase_fk DESC;"; + $qry .= " ORDER BY tbl_projektphase.start, tbl_projektphase.bezeichnung, projektphase_fk DESC;"; if($this->db_query($qry)) { @@ -794,7 +794,8 @@ class projektphase extends basis_db ) ) AND mitarbeiter_uid = ".$this->db_add_param($mitarbeiter_uid)." - AND tbl_projekt.projekt_kurzbz = ".$this->db_add_param($projekt_kurzbz); + AND tbl_projekt.projekt_kurzbz = ".$this->db_add_param($projekt_kurzbz). " + ORDER BY tbl_projektphase.start, tbl_projektphase.bezeichnung"; if($result = $this->db_query($qry)) { diff --git a/include/statistik.class.php b/include/statistik.class.php index 34477a548..fd48e7d28 100644 --- a/include/statistik.class.php +++ b/include/statistik.class.php @@ -1,655 +1,656 @@ -, - * Andreas Oesterreicher - * Karl Burkhart . - */ -require_once(dirname(__FILE__).'/basis_db.class.php'); - -class statistik extends basis_db -{ - public $new; - public $statistik_obj=array(); - public $result=array(); - - public $statistik_kurzbz; - public $content_id; - public $bezeichnung; - public $url; - public $sql; - public $gruppe; - public $publish; - public $insertamum; - public $insertvon; - public $updateamum; - public $udpatevon; - public $berechtigung_kurzbz; - public $preferences; - - public $studiengang_kz; // integer - public $prestudent_id; // integer - public $geschlecht; // char(1) - public $studiensemester_kurzbz;// varchar(16) - public $ausbildungssemester;// smallint - - public $anzahl; //Hilfsvariable fuer Group BY Abfragen - - // Daten der Statistik - public $data; // DB ressource - public $html; - public $countRows; - public $csv; - public $json; - - /** - * Konstruktor - */ - public function __construct($statistik_kurzbz=null) - { - parent::__construct(); - - if(!is_null($statistik_kurzbz)) - $this->load($statistik_kurzbz); - else - $this->new=true; - } - - /** - * Laedt eine Statistik - * @param $statistik_kurzbz - */ - public function load($statistik_kurzbz) - { - $qry = "SELECT - * - FROM - public.tbl_statistik - WHERE - statistik_kurzbz = " . $this->db_add_param($statistik_kurzbz); - - if($result = $this->db_query($qry)) - { - if($row = $this->db_fetch_object($result)) - { - $this->statistik_kurzbz = $row->statistik_kurzbz; - $this->content_id = $row->content_id; - $this->bezeichnung = $row->bezeichnung; - $this->url = $row->url; - $this->sql = $row->sql; - $this->gruppe = $row->gruppe; - $this->publish = $this->db_parse_bool($row->publish); - $this->insertamum = $row->insertamum; - $this->insertvon = $row->insertvon; - $this->updateamum = $row->updateamum; - $this->udpatevon = $row->updatevon; - $this->berechtigung_kurzbz = $row->berechtigung_kurzbz; - $this->preferences = $row->preferences; - $this->new = false; - - return true; - } - else - { - $this->errormsg = 'Dieser Eintrag wurde nicht gefunden: ' . $statistik_kurzbz; - return false; - } - } - else - { - $this->errormsg = 'Fehler beim Laden der Daten'; - return false; - } - } - - /** - * Laedt alle Statistiken - * @return true wenn ok, sonst false - */ - public function getAll($order = FALSE) - { - $qry = 'SELECT * FROM public.tbl_statistik'; - - if($order) - $qry .= ' ORDER BY ' . $order; - - if($result = $this->db_query($qry)) - { - while($row = $this->db_fetch_object($result)) - { - $obj = new statistik(); - - $obj->statistik_kurzbz = $row->statistik_kurzbz; - $obj->content_id = $row->content_id; - $obj->bezeichnung = $row->bezeichnung; - $obj->url = $row->url; - $obj->sql = $row->sql; - $obj->gruppe = $row->gruppe; - $obj->publish = $this->db_parse_bool($row->publish); - $obj->insertamum = $row->insertamum; - $obj->insertvon = $row->insertvon; - $obj->updateamum = $row->updateamum; - $obj->updatevon = $row->updatevon; - $obj->berechtigung_kurzbz = $row->berechtigung_kurzbz; - $obj->preferences = $row->preferences; - - $this->result[] = $obj; - } - - return true; - } - else - { - $this->errormsg = 'Fehler beim Laden der Daten'; - return false; - } - } - /** - * Laedt alle Statistiken einer Gruppe, Parameter publish zum Filtern. - * @return true wenn ok, sonst false - */ - public function getGruppe($gruppe,$publish=null) - { - $qry = "SELECT * FROM public.tbl_statistik WHERE gruppe=".$this->db_add_param($gruppe); - if ($publish===true) - $qry.=' AND publish '; - elseif ($publish===false) - $qry.=' AND NOT publish '; - $qry.=' ORDER BY bezeichnung;'; - - if($result = $this->db_query($qry)) - { - while($row = $this->db_fetch_object($result)) - { - $obj = new statistik(); - - $obj->statistik_kurzbz = $row->statistik_kurzbz; - $obj->content_id = $row->content_id; - $obj->bezeichnung = $row->bezeichnung; - $obj->url = $row->url; - $obj->sql = $row->sql; - $obj->gruppe = $row->gruppe; - $obj->publish = $this->db_parse_bool($row->publish); - $obj->insertamum = $row->insertamum; - $obj->insertvon = $row->insertvon; - $obj->updateamum = $row->updateamum; - $obj->udpatevon = $row->updatevon; - $obj->berechtigung_kurzbz = $row->berechtigung_kurzbz; - $obj->preferences = $row->preferences; - - $this->result[] = $obj; - } - - return true; - } - else - { - $this->errormsg = 'Fehler beim Laden der Daten'; - return false; - } - } - /** - * Laedt alle Statistik Gruppen, Parameter publish zum Filtern. - * @return true wenn ok, sonst false - */ - public function getAnzahlGruppe($publish = null) - { - $qry = 'SELECT gruppe, count(*) AS anzahl FROM public.tbl_statistik '; - - if($publish === true) - { - $qry .= 'WHERE publish '; - } - elseif($publish === false) - { - $qry .= 'WHERE NOT publish '; - } - - $qry .= ' GROUP BY gruppe ORDER BY gruppe;'; - - if($result = $this->db_query($qry)) - { - while($row = $this->db_fetch_object($result)) - { - $obj = new statistik(); - - $obj->gruppe = $row->gruppe; - $obj->anzahl = $row->anzahl; - - $this->result[] = $obj; - } - - return true; - } - else - { - $this->errormsg = 'Fehler beim Laden der Daten'; - return false; - } - } - /** - * Speichert einen Statistik Datensatz - * @param $new boolean - * @return boolean true wenn ok false im Fehlerfalls - */ - public function save($new=null) - { - if(is_null($new)) - $new = $this->new; - - /* Da derzeit die statistik_kurzbz der primary key in der DB ist, - * darf er vorerst nur [a-zA-Z0-9_] (\w) enthalten. (bis auf autoincrement - * integer umgestellt ist) - */ - $this->statistik_kurzbz = preg_replace('/\W/', '', $this->statistik_kurzbz); - - if($new) - { - $qry = 'INSERT INTO public.tbl_statistik(statistik_kurzbz, content_id, bezeichnung, url, sql, - gruppe, publish, insertamum, insertvon, updateamum, updatevon, preferences, berechtigung_kurzbz) VALUES('. - $this->db_add_param($this->statistik_kurzbz).','. - $this->db_add_param($this->content_id,FHC_INTEGER).','. - $this->db_add_param($this->bezeichnung).','. - $this->db_add_param($this->url).','. - $this->db_add_param($this->sql).','. - $this->db_add_param($this->gruppe).','. - $this->db_add_param($this->publish, FHC_BOOLEAN).','. - $this->db_add_param($this->insertamum).','. - $this->db_add_param($this->insertvon).','. - $this->db_add_param($this->updateamum).','. - $this->db_add_param($this->updatevon).','. - $this->db_add_param($this->preferences).','. - $this->db_add_param($this->berechtigung_kurzbz).');'; - } - else - { - if($this->statistik_kurzbz_orig=='') - $this->statistik_kurzbz_orig=$this->statistik_kurzbz; - $qry = 'UPDATE public.tbl_statistik SET - content_id='.$this->db_add_param($this->content_id,FHC_INTEGER).','. - ' bezeichnung='.$this->db_add_param($this->bezeichnung).','. - ' statistik_kurzbz='.$this->db_add_param($this->statistik_kurzbz).','. - ' url='.$this->db_add_param($this->url).','. - ' sql='.$this->db_add_param($this->sql).','. - ' gruppe='.$this->db_add_param($this->gruppe).','. - ' publish='.$this->db_add_param($this->publish, FHC_BOOLEAN).','. - ' insertamum='.$this->db_add_param($this->insertamum).','. - ' insertvon='.$this->db_add_param($this->insertvon).','. - ' updateamum='.$this->db_add_param($this->updateamum).','. - ' updatevon='.$this->db_add_param($this->updatevon).','. - ' preferences='.$this->db_add_param($this->preferences).','. - ' berechtigung_kurzbz='.$this->db_add_param($this->berechtigung_kurzbz). - ' WHERE statistik_kurzbz='.$this->db_add_param($this->statistik_kurzbz_orig,FHC_STRING,false); - } - //echo $qry; - if($this->db_query($qry)) - { - return true; - } - else - { - $this->errormsg='Fehler beim Speichern der Daten'; - return false; - } - } - - /** - * Liefert ein Array mit den Menueeintraegen der Statistiken - * Mit dem Returnwert dieser Funktion wird die entsprechende Stelle im - * Menue ueberschrieben - * @return Array fuer Menue - */ - public function getMenueArray() - { - $arr = array(); - - $qry = "SELECT - * - FROM - public.tbl_statistik - ORDER BY gruppe, bezeichnung, statistik_kurzbz"; - - if($result = $this->db_query($qry)) - { - $lastgruppe=''; - while($row = $this->db_fetch_object($result)) - { - if($row->gruppe!='' && $row->gruppe!=$lastgruppe) - { - $arr[$row->gruppe]=array('name'=>$row->gruppe); - $lastgruppe=$row->gruppe; - } - if($row->gruppe!='') - { - $arr[$row->gruppe][$row->statistik_kurzbz]=array('name'=>$row->bezeichnung, 'link'=>APP_ROOT.'vilesci/statistik/statistik_frameset.php?statistik_kurzbz='.$row->statistik_kurzbz, 'target'=>'main'); - if($row->berechtigung_kurzbz!='') - $arr[$row->gruppe][$row->statistik_kurzbz]['permissions']=array($row->berechtigung_kurzbz); - } - else - { - $arr[$row->statistik_kurzbz]=array('name'=>$row->bezeichnung, 'link'=>APP_ROOT.'vilesci/statistik/statistik_frameset.php?statistik_kurzbz='.$row->statistik_kurzbz, 'target'=>'main'); - if($row->berechtigung_kurzbz!='') - $arr[$row->statistik_kurzbz]['permissions']=array($row->berechtigung_kurzbz); - } - } - } - return $arr; - } - - /** - * Loescht einen Eintrag - * - * @param $statistik_kurzbz - * @return true wenn ok, sonst false - */ - public function delete($statistik_kurzbz) - { - $qry = "DELETE FROM public.tbl_statistik WHERE statistik_kurzbz=".$this->db_add_param($statistik_kurzbz).";"; - - if($this->db_query($qry)) - { - return true; - } - else - { - $this->errormsg='Fehler beim Löschen des Eintrages'; - return false; - } - } - - - - /** - * Laedt bestimmte PreStudenten - * @param studiengang_kz KZ des Studienganges der zu Laden ist - * @param studiensemester_kurzbz Studiensemester - * @param ausbildungssemester KZ Ausbildungssemester - * @param datum_stichtag Stichtag im ISO-Format, Ergebniss filtert auf <= (kleiner,gleich) - * @return true wenn ok, false im Fehlerfall - */ - public function get_prestudenten($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester=null, $datum_stichtag=null) - { - if(!is_numeric($studiengang_kz)) - { - $this->errormsg = 'Studiengang_kz muss eine gueltige Zahl sein'; - return false; - } - - if($ausbildungssemester!='' && !is_numeric($ausbildungssemester)) - { - $this->errormsg = 'Ausbildungssemester muss eine gueltige Zahl sein'; - return false; - } - - // Neue Studenten ermitteln - $qry=" - SELECT - DISTINCT prestudent_id, geschlecht, studiengang_kz, ausbildungssemester, studiensemester_kurzbz - FROM - public.tbl_prestudent - JOIN public.tbl_prestudentstatus status USING (prestudent_id) - JOIN public.tbl_person USING (person_id) - WHERE - status_kurzbz='Student' - AND NOT EXISTS(SELECT 1 FROM public.tbl_prestudentstatus WHERE status_kurzbz='Student' AND datumdb_query($qry)) - { - while($row = $this->db_fetch_object($result)) - { - $stat_obj = new statistik(); - $stat_obj->studiengang_kz=$row->studiengang_kz; - $stat_obj->ausbildungssemester=$row->ausbildungssemester; - $stat_obj->prestudent_id=$row->prestudent_id; - $stat_obj->geschlecht=$row->geschlecht; - $stat_obj->studiensemester_kurzbz=$row->studiensemester_kurzbz; - $this->statistik_obj[]=$stat_obj; - } - } - else - { - $this->errormsg = 'Datensatz konnte nicht geladen werden'; - return false; - } - - return true; - } - - /** - * - * Liefert die DropOut Rate - * @param unknown_type $studiengang_kz - * @param unknown_type $studiensemester_kurzbz - * @param unknown_type $ausbildungssemester - * @param unknown_type $datum_stichtag - */ - public function get_DropOut($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester=null, $datum_stichtag=null) - { - $this->statistik_obj=array(); - - if(!is_numeric($studiengang_kz)) - { - $this->errormsg = 'Studiengang_kz muss eine gueltige Zahl sein'; - return false; - } - - if($ausbildungssemester!='' && !is_numeric($ausbildungssemester)) - { - $this->errormsg = 'Ausbildungssemester muss eine gueltige Zahl sein'; - return false; - } - - // Neue Studenten ermitteln - $qry="SELECT DISTINCT prestudent_id, geschlecht, studiengang_kz, ausbildungssemester, studiensemester_kurzbz - FROM tbl_prestudent JOIN tbl_prestudentstatus USING (prestudent_id) JOIN tbl_person USING (person_id) - WHERE (status_kurzbz='Abbrecher') - AND studiengang_kz=".$this->db_add_param($studiengang_kz); - if($ausbildungssemester!='') - $qry.=" AND ausbildungssemester=".$this->db_add_param($ausbildungssemester); - - $qry.=" AND (studiensemester_kurzbz=".$this->db_add_param($studiensemester_kurzbz); - if (!is_null($datum_stichtag)) - $qry.=" AND datum <=".$this->db_add_param($datum_stichtag); - $qry.=') '; - $qry.=" ORDER BY prestudent_id;"; - - if($result = $this->db_query($qry)) - { - while($row = $this->db_fetch_object($result)) - { - $stat_obj = new statistik(); - $stat_obj->studiengang_kz=$row->studiengang_kz; - $stat_obj->ausbildungssemester=$row->ausbildungssemester; - $stat_obj->prestudent_id=$row->prestudent_id; - $stat_obj->geschlecht=$row->geschlecht; - $stat_obj->studiensemester_kurzbz=$row->studiensemester_kurzbz; - $this->statistik_obj[]=$stat_obj; - } - } - else - { - $this->errormsg = 'Datensatz konnte nicht geladen werden'; - return false; - } - - return true; - } - - /** - * Laedt die Daten einer Statistik (derzeit nur SQL) - * @param $statistik_kurzbz - */ - public function loadData() - { - $this->html=''; - $this->csv=''; - $this->json=array(); - $this->countRows=0; - set_time_limit(600); - - // In case a decryption function is used then perform password substitution - $this->sql = $this->replaceSQLDecryptionPassword($this->sql); - - if($this->sql!='') - { - $sql = $this->sql; - - // Wenn im SQL ein $user vorkommt wird das durch den eingeloggten User ersetzt - if(strpos($sql, '$user')!==false) - { - $uid = get_uid(); - $sql = str_replace('$user',$this->db_add_param($uid),$sql); - } - foreach($_REQUEST as $name=>$value) - { - // Inputs, die in eckigen Klammern stehen, werden als Array interpretiert - if (is_string($value) && substr($value, 0, 1) == '[' && substr($value, -1) == ']') - { - //Eckige Klammern entfernen und String aufsplitten - $value = substr($value, 1); - $value = substr($value, 0, -1); - $value = explode(',', $value); - } - if (is_array($value)) - { - $in = $this->db_implode4SQL($value); - $sql = str_replace('$'.$name,$in,$sql); - } - else - $sql = str_replace('$'.$name,$this->db_add_param($value),$sql); - } - if($this->data = $this->db_query($sql)) - { - $this->html.= '
'.$this->convert_html_chars($this->db_field_name($this->data,$spalte)).'
'.$this->convert_html_chars($row->$name).'
'.$this->html.'
'; - } - - function getCSV() - { - return $this->csv; - } - - function writeCSV($filename, $delimiter=',', $enclosure='"') - { - $fh=fopen($filename,'w'); - - $fieldnames=array(); - for ($i=0; $i < $this->db_num_fields($this->data); $i++) - $fieldnames[]=$this->db_field_name($this->data,$i); - fputcsv($fh, $fieldnames, $delimiter, $enclosure); - $this->db_result_seek($this->data,0); - while ($row = $this->db_fetch_row($this->data)) - fputcsv($fh, $row, $delimiter, $enclosure); - fclose($fh); - return true; - } - - function getJSON() - { - return json_encode($this->json); - } - - function getArray() - { - return $this->json; - } - - /** - * - * Parst Variablen aus einem String und liefert diese als Array zurueck - * @param $value String mit Variablen - * z.B.: "Select * from tbl_person where person_id<'$person_id'" - * oder "../content/statistik/bewerberstatistik.php?stsem=$StSem&stg_kz=$stg_kz" - * - * @return Array mit den Variablennamen - */ - function parseVars($value) - { - $result = array(); - - $check = '/\$[0-9A-z]+/'; - preg_match_all($check, $value, $result); - $result = $result[0]; - $vars = array(); - for($i=0;$i, + * Andreas Oesterreicher + * Karl Burkhart . + */ +require_once(dirname(__FILE__).'/basis_db.class.php'); + +class statistik extends basis_db +{ + public $new; + public $statistik_obj=array(); + public $result=array(); + + public $statistik_kurzbz; + public $content_id; + public $bezeichnung; + public $url; + public $sql; + public $gruppe; + public $publish; + public $insertamum; + public $insertvon; + public $updateamum; + public $udpatevon; + public $berechtigung_kurzbz; + public $preferences; + + public $studiengang_kz; // integer + public $prestudent_id; // integer + public $geschlecht; // char(1) + public $studiensemester_kurzbz;// varchar(16) + public $ausbildungssemester;// smallint + + public $anzahl; //Hilfsvariable fuer Group BY Abfragen + + // Daten der Statistik + public $data; // DB ressource + public $html; + public $countRows; + public $csv; + public $json; + + /** + * Konstruktor + */ + public function __construct($statistik_kurzbz=null) + { + parent::__construct(); + + if(!is_null($statistik_kurzbz)) + $this->load($statistik_kurzbz); + else + $this->new=true; + } + + /** + * Laedt eine Statistik + * @param $statistik_kurzbz + */ + public function load($statistik_kurzbz) + { + $qry = "SELECT + * + FROM + public.tbl_statistik + WHERE + statistik_kurzbz = " . $this->db_add_param($statistik_kurzbz); + + if($result = $this->db_query($qry)) + { + if($row = $this->db_fetch_object($result)) + { + $this->statistik_kurzbz = $row->statistik_kurzbz; + $this->content_id = $row->content_id; + $this->bezeichnung = $row->bezeichnung; + $this->url = $row->url; + $this->sql = $row->sql; + $this->gruppe = $row->gruppe; + $this->publish = $this->db_parse_bool($row->publish); + $this->insertamum = $row->insertamum; + $this->insertvon = $row->insertvon; + $this->updateamum = $row->updateamum; + $this->udpatevon = $row->updatevon; + $this->berechtigung_kurzbz = $row->berechtigung_kurzbz; + $this->preferences = $row->preferences; + $this->new = false; + + return true; + } + else + { + $this->errormsg = 'Dieser Eintrag wurde nicht gefunden: ' . $statistik_kurzbz; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } + + /** + * Laedt alle Statistiken + * @return true wenn ok, sonst false + */ + public function getAll($order = FALSE) + { + $qry = 'SELECT * FROM public.tbl_statistik'; + + if($order) + $qry .= ' ORDER BY ' . $order; + + if($result = $this->db_query($qry)) + { + while($row = $this->db_fetch_object($result)) + { + $obj = new statistik(); + + $obj->statistik_kurzbz = $row->statistik_kurzbz; + $obj->content_id = $row->content_id; + $obj->bezeichnung = $row->bezeichnung; + $obj->url = $row->url; + $obj->sql = $row->sql; + $obj->gruppe = $row->gruppe; + $obj->publish = $this->db_parse_bool($row->publish); + $obj->insertamum = $row->insertamum; + $obj->insertvon = $row->insertvon; + $obj->updateamum = $row->updateamum; + $obj->updatevon = $row->updatevon; + $obj->berechtigung_kurzbz = $row->berechtigung_kurzbz; + $obj->preferences = $row->preferences; + + $this->result[] = $obj; + } + + return true; + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } + /** + * Laedt alle Statistiken einer Gruppe, Parameter publish zum Filtern. + * @return true wenn ok, sonst false + */ + public function getGruppe($gruppe,$publish=null) + { + $qry = "SELECT * FROM public.tbl_statistik WHERE gruppe=".$this->db_add_param($gruppe); + if ($publish===true) + $qry.=' AND publish '; + elseif ($publish===false) + $qry.=' AND NOT publish '; + $qry.=' ORDER BY bezeichnung;'; + + if($result = $this->db_query($qry)) + { + while($row = $this->db_fetch_object($result)) + { + $obj = new statistik(); + + $obj->statistik_kurzbz = $row->statistik_kurzbz; + $obj->content_id = $row->content_id; + $obj->bezeichnung = $row->bezeichnung; + $obj->url = $row->url; + $obj->sql = $row->sql; + $obj->gruppe = $row->gruppe; + $obj->publish = $this->db_parse_bool($row->publish); + $obj->insertamum = $row->insertamum; + $obj->insertvon = $row->insertvon; + $obj->updateamum = $row->updateamum; + $obj->udpatevon = $row->updatevon; + $obj->berechtigung_kurzbz = $row->berechtigung_kurzbz; + $obj->preferences = $row->preferences; + + $this->result[] = $obj; + } + + return true; + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } + /** + * Laedt alle Statistik Gruppen, Parameter publish zum Filtern. + * @return true wenn ok, sonst false + */ + public function getAnzahlGruppe($publish = null) + { + $qry = 'SELECT gruppe, count(*) AS anzahl FROM public.tbl_statistik '; + + if($publish === true) + { + $qry .= 'WHERE publish '; + } + elseif($publish === false) + { + $qry .= 'WHERE NOT publish '; + } + + $qry .= ' GROUP BY gruppe ORDER BY gruppe;'; + + if($result = $this->db_query($qry)) + { + while($row = $this->db_fetch_object($result)) + { + $obj = new statistik(); + + $obj->gruppe = $row->gruppe; + $obj->anzahl = $row->anzahl; + + $this->result[] = $obj; + } + + return true; + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } + /** + * Speichert einen Statistik Datensatz + * @param $new boolean + * @return boolean true wenn ok false im Fehlerfalls + */ + public function save($new=null) + { + if(is_null($new)) + $new = $this->new; + + /* Da derzeit die statistik_kurzbz der primary key in der DB ist, + * darf er vorerst nur [a-zA-Z0-9_] (\w) enthalten. (bis auf autoincrement + * integer umgestellt ist) + */ + $this->statistik_kurzbz = preg_replace('/\W/', '', $this->statistik_kurzbz); + + if($new) + { + $qry = 'INSERT INTO public.tbl_statistik(statistik_kurzbz, content_id, bezeichnung, url, sql, + gruppe, publish, insertamum, insertvon, updateamum, updatevon, preferences, berechtigung_kurzbz) VALUES('. + $this->db_add_param($this->statistik_kurzbz).','. + $this->db_add_param($this->content_id,FHC_INTEGER).','. + $this->db_add_param($this->bezeichnung).','. + $this->db_add_param($this->url).','. + $this->db_add_param($this->sql).','. + $this->db_add_param($this->gruppe).','. + $this->db_add_param($this->publish, FHC_BOOLEAN).','. + $this->db_add_param($this->insertamum).','. + $this->db_add_param($this->insertvon).','. + $this->db_add_param($this->updateamum).','. + $this->db_add_param($this->updatevon).','. + $this->db_add_param($this->preferences).','. + $this->db_add_param($this->berechtigung_kurzbz).');'; + } + else + { + if($this->statistik_kurzbz_orig=='') + $this->statistik_kurzbz_orig=$this->statistik_kurzbz; + $qry = 'UPDATE public.tbl_statistik SET + content_id='.$this->db_add_param($this->content_id,FHC_INTEGER).','. + ' bezeichnung='.$this->db_add_param($this->bezeichnung).','. + ' statistik_kurzbz='.$this->db_add_param($this->statistik_kurzbz).','. + ' url='.$this->db_add_param($this->url).','. + ' sql='.$this->db_add_param($this->sql).','. + ' gruppe='.$this->db_add_param($this->gruppe).','. + ' publish='.$this->db_add_param($this->publish, FHC_BOOLEAN).','. + ' insertamum='.$this->db_add_param($this->insertamum).','. + ' insertvon='.$this->db_add_param($this->insertvon).','. + ' updateamum='.$this->db_add_param($this->updateamum).','. + ' updatevon='.$this->db_add_param($this->updatevon).','. + ' preferences='.$this->db_add_param($this->preferences).','. + ' berechtigung_kurzbz='.$this->db_add_param($this->berechtigung_kurzbz). + ' WHERE statistik_kurzbz='.$this->db_add_param($this->statistik_kurzbz_orig,FHC_STRING,false); + } + //echo $qry; + if($this->db_query($qry)) + { + return true; + } + else + { + $this->errormsg='Fehler beim Speichern der Daten'; + return false; + } + } + + /** + * Liefert ein Array mit den Menueeintraegen der Statistiken + * Mit dem Returnwert dieser Funktion wird die entsprechende Stelle im + * Menue ueberschrieben + * @return Array fuer Menue + */ + public function getMenueArray() + { + $arr = array(); + + $qry = "SELECT + * + FROM + public.tbl_statistik + ORDER BY gruppe, bezeichnung, statistik_kurzbz"; + + if($result = $this->db_query($qry)) + { + $lastgruppe=''; + while($row = $this->db_fetch_object($result)) + { + if($row->gruppe!='' && $row->gruppe!=$lastgruppe) + { + $arr[$row->gruppe]=array('name'=>$row->gruppe); + $lastgruppe=$row->gruppe; + } + if($row->gruppe!='') + { + $arr[$row->gruppe][$row->statistik_kurzbz]=array('name'=>$row->bezeichnung, 'link'=>APP_ROOT.'vilesci/statistik/statistik_frameset.php?statistik_kurzbz='.$row->statistik_kurzbz, 'target'=>'main'); + if($row->berechtigung_kurzbz!='') + $arr[$row->gruppe][$row->statistik_kurzbz]['permissions']=array($row->berechtigung_kurzbz); + } + else + { + $arr[$row->statistik_kurzbz]=array('name'=>$row->bezeichnung, 'link'=>APP_ROOT.'vilesci/statistik/statistik_frameset.php?statistik_kurzbz='.$row->statistik_kurzbz, 'target'=>'main'); + if($row->berechtigung_kurzbz!='') + $arr[$row->statistik_kurzbz]['permissions']=array($row->berechtigung_kurzbz); + } + } + } + return $arr; + } + + /** + * Loescht einen Eintrag + * + * @param $statistik_kurzbz + * @return true wenn ok, sonst false + */ + public function delete($statistik_kurzbz) + { + $qry = "DELETE FROM public.tbl_statistik WHERE statistik_kurzbz=".$this->db_add_param($statistik_kurzbz).";"; + + if($this->db_query($qry)) + { + return true; + } + else + { + $this->errormsg='Fehler beim Löschen des Eintrages'; + return false; + } + } + + + + /** + * Laedt bestimmte PreStudenten + * @param studiengang_kz KZ des Studienganges der zu Laden ist + * @param studiensemester_kurzbz Studiensemester + * @param ausbildungssemester KZ Ausbildungssemester + * @param datum_stichtag Stichtag im ISO-Format, Ergebniss filtert auf <= (kleiner,gleich) + * @return true wenn ok, false im Fehlerfall + */ + public function get_prestudenten($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester=null, $datum_stichtag=null) + { + if(!is_numeric($studiengang_kz)) + { + $this->errormsg = 'Studiengang_kz muss eine gueltige Zahl sein'; + return false; + } + + if($ausbildungssemester!='' && !is_numeric($ausbildungssemester)) + { + $this->errormsg = 'Ausbildungssemester muss eine gueltige Zahl sein'; + return false; + } + + // Neue Studenten ermitteln + $qry=" + SELECT + DISTINCT prestudent_id, geschlecht, studiengang_kz, ausbildungssemester, studiensemester_kurzbz + FROM + public.tbl_prestudent + JOIN public.tbl_prestudentstatus status USING (prestudent_id) + JOIN public.tbl_person USING (person_id) + WHERE + status_kurzbz='Student' + AND NOT EXISTS(SELECT 1 FROM public.tbl_prestudentstatus WHERE status_kurzbz='Student' AND datumdb_query($qry)) + { + while($row = $this->db_fetch_object($result)) + { + $stat_obj = new statistik(); + $stat_obj->studiengang_kz=$row->studiengang_kz; + $stat_obj->ausbildungssemester=$row->ausbildungssemester; + $stat_obj->prestudent_id=$row->prestudent_id; + $stat_obj->geschlecht=$row->geschlecht; + $stat_obj->studiensemester_kurzbz=$row->studiensemester_kurzbz; + $this->statistik_obj[]=$stat_obj; + } + } + else + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + return true; + } + + /** + * + * Liefert die DropOut Rate + * @param unknown_type $studiengang_kz + * @param unknown_type $studiensemester_kurzbz + * @param unknown_type $ausbildungssemester + * @param unknown_type $datum_stichtag + */ + public function get_DropOut($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester=null, $datum_stichtag=null) + { + $this->statistik_obj=array(); + + if(!is_numeric($studiengang_kz)) + { + $this->errormsg = 'Studiengang_kz muss eine gueltige Zahl sein'; + return false; + } + + if($ausbildungssemester!='' && !is_numeric($ausbildungssemester)) + { + $this->errormsg = 'Ausbildungssemester muss eine gueltige Zahl sein'; + return false; + } + + // Neue Studenten ermitteln + $qry="SELECT DISTINCT prestudent_id, geschlecht, studiengang_kz, ausbildungssemester, studiensemester_kurzbz + FROM tbl_prestudent JOIN tbl_prestudentstatus USING (prestudent_id) JOIN tbl_person USING (person_id) + WHERE (status_kurzbz='Abbrecher') + AND studiengang_kz=".$this->db_add_param($studiengang_kz); + if($ausbildungssemester!='') + $qry.=" AND ausbildungssemester=".$this->db_add_param($ausbildungssemester); + + $qry.=" AND (studiensemester_kurzbz=".$this->db_add_param($studiensemester_kurzbz); + if (!is_null($datum_stichtag)) + $qry.=" AND datum <=".$this->db_add_param($datum_stichtag); + $qry.=') '; + $qry.=" ORDER BY prestudent_id;"; + + if($result = $this->db_query($qry)) + { + while($row = $this->db_fetch_object($result)) + { + $stat_obj = new statistik(); + $stat_obj->studiengang_kz=$row->studiengang_kz; + $stat_obj->ausbildungssemester=$row->ausbildungssemester; + $stat_obj->prestudent_id=$row->prestudent_id; + $stat_obj->geschlecht=$row->geschlecht; + $stat_obj->studiensemester_kurzbz=$row->studiensemester_kurzbz; + $this->statistik_obj[]=$stat_obj; + } + } + else + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + return true; + } + + /** + * Laedt die Daten einer Statistik (derzeit nur SQL) + * @param $statistik_kurzbz + */ + public function loadData() + { + $this->html=''; + $this->csv=''; + $this->json=array(); + $this->countRows=0; + set_time_limit(600); + + // In case a decryption function is used then perform password substitution + $this->sql = $this->replaceSQLDecryptionPassword($this->sql); + + if($this->sql!='') + { + $sql = $this->sql; + + // Wenn im SQL ein $user vorkommt wird das durch den eingeloggten User ersetzt + if(strpos($sql, '$user')!==false) + { + $uid = get_uid(); + $sql = str_replace('$user',$this->db_add_param($uid),$sql); + } + + foreach($_REQUEST as $name=>$value) + { + // Inputs, die in eckigen Klammern stehen, werden als Array interpretiert + if (is_string($value) && substr($value, 0, 1) == '[' && substr($value, -1) == ']') + { + //Eckige Klammern entfernen und String aufsplitten + $value = substr($value, 1); + $value = substr($value, 0, -1); + $value = explode(',', $value); + } + if (is_array($value)) + { + $in = $this->db_implode4SQL($value); + $sql = str_replace('$'.$name,$in,$sql); + } + else + $sql = str_replace('$'.$name,$this->db_add_param($value),$sql); + } + if($this->data = $this->db_query($sql)) + { + $this->html.= '
'.$this->convert_html_chars($this->db_field_name($this->data,$spalte)).'
'.$this->convert_html_chars($row->$name).'
'.$this->html.'
'; + } + + function getCSV() + { + return $this->csv; + } + + function writeCSV($filename, $delimiter=',', $enclosure='"') + { + $fh=fopen($filename,'w'); + + $fieldnames=array(); + for ($i=0; $i < $this->db_num_fields($this->data); $i++) + $fieldnames[]=$this->db_field_name($this->data,$i); + fputcsv($fh, $fieldnames, $delimiter, $enclosure); + $this->db_result_seek($this->data,0); + while ($row = $this->db_fetch_row($this->data)) + fputcsv($fh, $row, $delimiter, $enclosure); + fclose($fh); + return true; + } + + function getJSON() + { + return json_encode($this->json); + } + + function getArray() + { + return $this->json; + } + + /** + * + * Parst Variablen aus einem String und liefert diese als Array zurueck + * @param $value String mit Variablen + * z.B.: "Select * from tbl_person where person_id<'$person_id'" + * oder "../content/statistik/bewerberstatistik.php?stsem=$StSem&stg_kz=$stg_kz" + * + * @return Array mit den Variablennamen + */ + function parseVars($value) + { + $result = array(); + + $check = '/\$[0-9A-z]+/'; + preg_match_all($check, $value, $result); + $result = $result[0]; + $vars = array(); + for($i=0;$i'Mitarbeiter','permissions'=>array('admin','mitarbeiter','support'), 'Übersicht'=>array('name'=>'Übersicht', 'link'=>'personen/lektor_uebersicht.php', 'target'=>'main'), 'Zeitsperren'=>array('name'=>'Zeitsperren/Urlaub', 'link'=>'personen/urlaubsverwaltung.php', 'target'=>'main','permissions'=>array('mitarbeiter/zeitsperre:begrenzt')), + 'Projektexport'=>array('name'=>'Projektexport', 'link'=>'personen/projektexport.php', 'target'=>'main','permissions'=>array('mitarbeiter/zeitsperre')), ), 'Betriebsmittel'=>array('name'=>'Betriebsmittel', 'link'=>'stammdaten/betriebsmittel_frameset.php', 'target'=>'main','permissions'=>array('basis/betriebsmittel')), 'AnwesenheitslistenBarcode'=>array('name'=>'Anwesenheitslisten mit Barcodes', 'link'=>'personen/anwesenheitslisten_barcode.php', 'target'=>'main','permissions'=>array('basis/person')), diff --git a/locale/de-AT/services.php b/locale/de-AT/services.php index 1b03bc956..159efd2e9 100644 --- a/locale/de-AT/services.php +++ b/locale/de-AT/services.php @@ -5,6 +5,7 @@ $this->phrasen['services/details']='Details'; $this->phrasen['services/filtern']='Filtern'; $this->phrasen['services/leistung']='Leistung'; $this->phrasen['services/design']='Verantwortlich'; +$this->phrasen['services/kritikalitaet']='Kritikalität'; $this->phrasen['services/betrieb']='Betrieb'; $this->phrasen['services/operativ']='Operativ'; ?> diff --git a/locale/en-US/services.php b/locale/en-US/services.php index d3c0642fa..ac31031a9 100644 --- a/locale/en-US/services.php +++ b/locale/en-US/services.php @@ -5,6 +5,7 @@ $this->phrasen['services/details']='Details'; $this->phrasen['services/filtern']='Filter'; $this->phrasen['services/leistung']='Service'; $this->phrasen['services/design']='Design'; +$this->phrasen['services/kritikalitaet']='Criticality'; $this->phrasen['services/betrieb']='Running'; $this->phrasen['services/operativ']='Operating'; -?> \ No newline at end of file +?> diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js new file mode 100644 index 000000000..41c89ef50 --- /dev/null +++ b/public/js/api/fhcapifactory.js @@ -0,0 +1,30 @@ +/** + * 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 . + */ + +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, + studstatus +}; diff --git a/public/js/api/filter.js b/public/js/api/filter.js new file mode 100644 index 000000000..a5920c758 --- /dev/null +++ b/public/js/api/filter.js @@ -0,0 +1,89 @@ +/** + * 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 { + saveCustomFilter(wsParams) { + return this.$fhcApi.post( + '/api/frontend/v1/filter/saveCustomFilter', + { + filterUniqueId: wsParams.filterUniqueId, + filterType: wsParams.filterType, + customFilterName: wsParams.customFilterName + } + ); + }, + removeCustomFilter(wsParams) { + return this.$fhcApi.post( + '/api/frontend/v1/filter/removeCustomFilter', + { + filterUniqueId: wsParams.filterUniqueId, + filterType: wsParams.filterType, + filterId: wsParams.filterId + } + ); + }, + applyFilterFields(wsParams) { + return this.$fhcApi.post( + '/api/frontend/v1/filter/applyFilterFields', + { + filterUniqueId: wsParams.filterUniqueId, + filterType: wsParams.filterType, + filterFields: wsParams.filterFields + } + ); + }, + addFilterField(wsParams) { + return this.$fhcApi.post( + '/api/frontend/v1/filter/addFilterField', + { + filterUniqueId: wsParams.filterUniqueId, + filterType: wsParams.filterType, + filterField: wsParams.filterField + } + ); + }, + removeFilterField(wsParams) { + return this.$fhcApi.post( + '/api/frontend/v1/filter/removeFilterField', + { + filterUniqueId: wsParams.filterUniqueId, + filterType: wsParams.filterType, + filterField: wsParams.filterField + } + ); + }, + getFilterById(wsParams) { + return this.$fhcApi.get( + '/api/frontend/v1/filter/getFilter', + { + filterUniqueId: wsParams.filterUniqueId, + filterType: wsParams.filterType, + filterId: wsParams.filterId + } + ); + }, + getFilter(wsParams) { + return this.$fhcApi.get( + '/api/frontend/v1/filter/getFilter', + { + filterUniqueId: wsParams.filterUniqueId, + filterType: wsParams.filterType + } + ); + } +}; + diff --git a/public/js/api/navigation.js b/public/js/api/navigation.js new file mode 100644 index 000000000..05006331f --- /dev/null +++ b/public/js/api/navigation.js @@ -0,0 +1,32 @@ +/** + * 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 { + getHeader(navigation_page) { + return this.$fhcApi.get( + '/api/frontend/v1/navigation/header', + { navigation_page } + ); + }, + getMenu: function(navigation_page) { + return this.$fhcApi.get( + '/api/frontend/v1/navigation/menu', + { navigation_page } + ); + } +}; + diff --git a/public/js/api/phrasen.js b/public/js/api/phrasen.js new file mode 100644 index 000000000..896641bcf --- /dev/null +++ b/public/js/api/phrasen.js @@ -0,0 +1,22 @@ +/** + * 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 { + loadCategory(category) { + return this.$fhcApi.get('/api/frontend/v1/phrasen/loadModule/' + category); + } +}; diff --git a/public/js/api/search.js b/public/js/api/search.js new file mode 100644 index 000000000..4655d8fa8 --- /dev/null +++ b/public/js/api/search.js @@ -0,0 +1,27 @@ +/** + * 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 { + search(searchsettings) { + const url = '/api/frontend/v1/searchbar/search'; + return this.$fhcApi.post(url, searchsettings); + }, + searchdummy(searchsettings) { + const url = 'public/js/apps/api/dummyapi.php/Search'; + return this.$fhcApi.post(url, searchsettings); + } +}; \ No newline at end of file diff --git a/public/js/api/studstatus.js b/public/js/api/studstatus.js new file mode 100644 index 000000000..87d6840b1 --- /dev/null +++ b/public/js/api/studstatus.js @@ -0,0 +1,223 @@ +/** + * 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: signal, + timeout: 30000 + } + ); + }, + 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/TestSearch.js b/public/js/apps/TestSearch.js index d4aa35312..469aaeb09 100644 --- a/public/js/apps/TestSearch.js +++ b/public/js/apps/TestSearch.js @@ -1,195 +1,195 @@ -import {CoreFilterCmpt} from '../components/Filter.js'; -import {CoreNavigationCmpt} from '../components/Navigation.js'; -import verticalsplit from "../components/verticalsplit/verticalsplit.js"; -import searchbar from "../components/searchbar/searchbar.js"; -import fhcapifactory from "./api/fhcapifactory.js"; +import {CoreFilterCmpt} from '../components/filter/Filter.js'; +import {CoreNavigationCmpt} from '../components/navigation/Navigation.js'; +import CoreVerticalsplit from "../components/verticalsplit/verticalsplit.js"; +import CoreSearchbar from "../components/searchbar/searchbar.js"; +import FhcApi from "../plugin/FhcApi.js"; -Vue.$fhcapi = fhcapifactory; - -Vue.createApp({ - "data": function() { - return { - "title": "Test Search", - "appSideMenuEntries": {}, - "searchbaroptions": { - "types": [ - "person", - "raum", - "mitarbeiter", - "student", - "prestudent", - "document", - "cms", - "organisationunit" - ], - "actions": { - "person": { - "defaultaction": { - "type": "link", - "action": function(data) { - //alert('person defaultaction ' + JSON.stringify(data)); - //window.location.href = data.profil; - return data.profil; - } - }, - "childactions": [ - { - "label": "testchildaction1", - "icon": "fas fa-check-circle", - "type": "function", - "action": function(data) { - alert('person testchildaction 01 ' + JSON.stringify(data)); - } - }, - { - "label": "testchildaction2", - "icon": "fas fa-file-csv", - "type": "function", - "action": function(data) { - alert('person testchildaction 02 ' + JSON.stringify(data)); - } - } - ] - }, - "raum": { - "defaultaction": { - "type": "function", - "action": function(data) { - alert('raum defaultaction ' + JSON.stringify(data)); - } - }, - "childactions": [ - { - "label": "Rauminformation", - "icon": "fas fa-info-circle", - "type": "link", - "action": function(data) { - return data.infolink; - } - }, - { - "label": "Raumreservierung", - "icon": "fas fa-bookmark", - "type": "link", - "action": function(data) { - return data.booklink; - } - } - ] - }, - "employee": { - "defaultaction": { - "type": "function", - "action": function(data) { - alert('employee defaultaction ' + JSON.stringify(data)); - } - }, - "childactions": [ - { - "label": "testchildaction1", - "icon": "fas fa-address-book", - "type": "function", - "action": function(data) { - alert('employee testchildaction 01 ' + JSON.stringify(data)); - } - }, - { - "label": "testchildaction2", - "icon": "fas fa-user-slash", - "type": "function", - "action": function(data) { - alert('employee testchildaction 02 ' + JSON.stringify(data)); - } - }, - { - "label": "testchildaction3", - "icon": "fas fa-bell", - "type": "function", - "action": function(data) { - alert('employee testchildaction 03 ' + JSON.stringify(data)); - } - }, - { - "label": "testchildaction4", - "icon": "fas fa-calculator", - "type": "function", - "action": function(data) { - alert('employee testchildaction 04 ' + JSON.stringify(data)); - } - } - ] - }, - "organisationunit": { - "defaultaction": { - "type": "function", - "action": function(data) { - alert('organisationunit defaultaction ' + JSON.stringify(data)); - } - }, - "childactions": [] - } - } - }, - "searchbaroptions2": { - "types": [ - "raum", - "organisationunit" - ], - "actions": { - "raum": { - "defaultaction": { - "type": "function", - "action": function(data) { - alert('raum defaultaction ' + JSON.stringify(data)); - } - }, - "childactions": [ - { - "label": "Rauminformation", - "icon": "fas fa-info-circle", - "type": "link", - "action": function(data) { - return data.infolink; - } - }, - { - "label": "Raumreservierung", - "icon": "fas fa-bookmark", - "type": "link", - "action": function(data) { - return data.booklink; - } - } - ] - }, - "organisationunit": { - "defaultaction": { - "type": "function", - "action": function(data) { - alert('organisationunit defaultaction ' + JSON.stringify(data)); - } - }, - "childactions": [] - } - } - } - }; - }, - "components": { - "CoreNavigationCmpt": CoreNavigationCmpt, - "CoreFilterCmpt": CoreFilterCmpt, - "verticalsplit": verticalsplit, - "searchbar": searchbar - }, - "methods": { - "newSideMenuEntryHandler": function(payload) { - this.appSideMenuEntries = payload; - }, - "searchfunction": function(searchsettings) { - return Vue.$fhcapi.Search.search(searchsettings); - }, - "searchfunctiondummy": function(searchsettings) { - return Vue.$fhcapi.Search.searchdummy(searchsettings); - } - } -}).mount('#main'); +const app = Vue.createApp({ + components: { + CoreNavigationCmpt, + CoreFilterCmpt, + CoreVerticalsplit, + CoreSearchbar + }, + data() { + return { + title: "Test Search", + appSideMenuEntries: {}, + searchbaroptions: { + types: [ + "person", + "raum", + "mitarbeiter", + "student", + "prestudent", + "document", + "cms", + "organisationunit" + ], + actions: { + person: { + defaultaction: { + type: "link", + action(data) { + //alert('person defaultaction ' + JSON.stringify(data)); + //window.location.href = data.profil; + return data.profil; + } + }, + childactions: [ + { + label: "testchildaction1", + icon: "fas fa-check-circle", + type: "function", + action(data) { + alert('person testchildaction 01 ' + JSON.stringify(data)); + } + }, + { + label: "testchildaction2", + icon: "fas fa-file-csv", + type: "function", + action(data) { + alert('person testchildaction 02 ' + JSON.stringify(data)); + } + } + ] + }, + raum: { + defaultaction: { + type: "function", + action(data) { + alert('raum defaultaction ' + JSON.stringify(data)); + } + }, + childactions: [ + { + label: "Rauminformation", + icon: "fas fa-info-circle", + type: "link", + action(data) { + return data.infolink; + } + }, + { + label: "Raumreservierung", + icon: "fas fa-bookmark", + type: "link", + action(data) { + return data.booklink; + } + } + ] + }, + employee: { + defaultaction: { + type: "function", + action(data) { + alert('employee defaultaction ' + JSON.stringify(data)); + } + }, + childactions: [ + { + label: "testchildaction1", + icon: "fas fa-address-book", + type: "function", + action(data) { + alert('employee testchildaction 01 ' + JSON.stringify(data)); + } + }, + { + label: "testchildaction2", + icon: "fas fa-user-slash", + type: "function", + action(data) { + alert('employee testchildaction 02 ' + JSON.stringify(data)); + } + }, + { + label: "testchildaction3", + icon: "fas fa-bell", + type: "function", + action(data) { + alert('employee testchildaction 03 ' + JSON.stringify(data)); + } + }, + { + label: "testchildaction4", + icon: "fas fa-calculator", + type: "function", + action(data) { + alert('employee testchildaction 04 ' + JSON.stringify(data)); + } + } + ] + }, + organisationunit: { + defaultaction: { + type: "function", + action(data) { + alert('organisationunit defaultaction ' + JSON.stringify(data)); + } + }, + childactions: [] + } + } + }, + searchbaroptions2: { + types: [ + "raum", + "organisationunit" + ], + actions: { + raum: { + defaultaction: { + type: "function", + action(data) { + alert('raum defaultaction ' + JSON.stringify(data)); + } + }, + childactions: [ + { + label: "Rauminformation", + icon: "fas fa-info-circle", + type: "link", + action(data) { + return data.infolink; + } + }, + { + label: "Raumreservierung", + icon: "fas fa-bookmark", + type: "link", + action(data) { + return data.booklink; + } + } + ] + }, + organisationunit: { + defaultaction: { + type: "function", + action(data) { + alert('organisationunit defaultaction ' + JSON.stringify(data)); + } + }, + childactions: [] + } + } + } + }; + }, + methods: { + newSideMenuEntryHandler(payload) { + this.appSideMenuEntries = payload; + }, + searchfunction(searchsettings) { + return this.$fhcApi.factory.search.search(searchsettings); + }, + searchfunctiondummy(searchsettings) { + return this.$fhcApi.factory.search.searchdummy(searchsettings); + } + } +}); +app.use(FhcApi) +app.mount('#main'); 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/Fetch.js b/public/js/components/Fetch.js index 9a34e1a3f..2f7985649 100644 --- a/public/js/components/Fetch.js +++ b/public/js/components/Fetch.js @@ -99,8 +99,10 @@ export const CoreFetchCmpt = { * */ errorHandler: function(error) { - if (error.response.data.retval) + if (error.response?.data?.retval) this.setError(error.response.data.retval); + else if (error.data?.message) + this.setError(error.data.message); else this.setError(error.message); }, diff --git a/public/js/components/Form/Form.js b/public/js/components/Form/Form.js index 9a729b88f..fb264e0fe 100644 --- a/public/js/components/Form/Form.js +++ b/public/js/components/Form/Form.js @@ -46,7 +46,8 @@ export default { const factory = Object.create(Object.getPrototypeOf(this.$fhcApi.factory), Object.getOwnPropertyDescriptors(this.$fhcApi.factory)); factory.$fhcApi = { get: this.get, - post: this.post + post: this.post, + _defaultErrorHandlers: this.$fhcApi._defaultErrorHandlers }; return factory; } diff --git a/public/js/components/Studierendenantrag/Form/Abmeldung.js b/public/js/components/Studierendenantrag/Form/Abmeldung.js index d72f84265..1660957c5 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,8 @@ export default { }); } return result; - } - ); + }) + .catch(this.$fhcAlert.handleSystemError); }, createAntrag() { bootstrap.Modal.getOrCreateInstance(this.$refs.modal).hide(); @@ -73,52 +68,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 +108,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 +147,9 @@ export default { template: `
-
+
- + @@ -219,19 +186,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')}}