diff --git a/.gitignore b/.gitignore index 96af3e5dc..7894692af 100644 --- a/.gitignore +++ b/.gitignore @@ -7,9 +7,11 @@ vendor/ .project .buildpath .ptp-sync* +.vscode/ .htaccess .htaccessbak +.htpasswd application/config/development/ application/config/extensions/ diff --git a/.htaccess_exmpl b/.htaccess_exmpl new file mode 100644 index 000000000..219cc3a41 --- /dev/null +++ b/.htaccess_exmpl @@ -0,0 +1,11 @@ +# Be careful if you change the AuthName, also change it in the configs +AuthName "FH-Complete" +AuthType Basic +# Change this to your root-folder +AuthUserFile /var/www/html/.htpasswd + +require valid-user + +# Follow symbolic links. +Options +FollowSymLinks + diff --git a/.htpasswd_exmpl b/.htpasswd_exmpl new file mode 100644 index 000000000..f8104a706 --- /dev/null +++ b/.htpasswd_exmpl @@ -0,0 +1,14 @@ +admin:$apr1$w6jylrnm$fbKTilbCkJ9M0cySq7lDi1 +pam:$apr1$TJRAwUxR$PifE5Lj0cs7yar7VuAlLC0 +assistenz1: +assistenz2: +assistenz2: +student1: +student2: +student3: +gl1: +gl2: +lektor1: +lektor2: +lektor3: +aufnahme: \ No newline at end of file diff --git a/application/config/anrechnung.php b/application/config/anrechnung.php index 768ec3197..2466d2bb1 100644 --- a/application/config/anrechnung.php +++ b/application/config/anrechnung.php @@ -21,3 +21,6 @@ $config['grades_blocking_application'] = array( $config['fbl'] = FALSE; //Enables Info Mails $config['send_mail'] = TRUE; + +// Display fields to explain equivalence of ECTS and LV-Inhalte +$config['explain_equivalence'] = TRUE; diff --git a/application/config/auth.php b/application/config/auth.php index 2e42a636c..b19b82d3d 100644 --- a/application/config/auth.php +++ b/application/config/auth.php @@ -5,7 +5,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); // Array or a string of authentication methods sorted by priority (highest to lowest) // NOTE: AUTH_HBALDAP works also as login page (old ugly HTTP basic authentication) // should be placed at the end of the array -$config['authentication_foreign_methods'] = array(AUTH_BT, AUTH_HBALDAP); +$config['authentication_foreign_methods'] = array(AUTH_BT, AUTH_HBA, AUTH_HBALDAP); // Login method $config['authentication_login'] = AUTH_LDAP; diff --git a/application/config/constants.php b/application/config/constants.php index cbbf55d8b..3489021e8 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -44,6 +44,7 @@ define('BEGINNING_OF_TIME', '1970-01-01'); |-------------------------------------------------------------------------- */ // Foreign authentication methods +define('AUTH_HBA', 'httpBasicAuth'); define('AUTH_HBALDAP', 'httpBasicAuthLDAP'); define('AUTH_BT', 'bewerbung'); diff --git a/application/controllers/Studentenverwaltung.php b/application/controllers/Studentenverwaltung.php new file mode 100644 index 000000000..e09d04c6a --- /dev/null +++ b/application/controllers/Studentenverwaltung.php @@ -0,0 +1,40 @@ +method] = ['admin:r', 'assistenz:r']; + parent::__construct($permissions); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + } + + /** + * @return void + */ + public function _remap() + { + $this->load->view('Studentenverwaltung', [ + 'permissions' => [ + 'student/bpk' => $this->permissionlib->isBerechtigt('student/bpk'), + 'student/alias' => $this->permissionlib->isBerechtigt('student/alias'), + 'basis/prestudent' => $this->permissionlib->isBerechtigt('basis/prestudent'), + 'basis/prestudentstatus' => $this->permissionlib->isBerechtigt('basis/prestudentstatus'), + 'assistenz_stgs' => $this->permissionlib->getSTG_isEntitledFor('assistenz'), + 'admin' => $this->permissionlib->isBerechtigt('admin'), + 'assistenz_schreibrechte' => $this->permissionlib->isBerechtigt('assistenz','suid'), + 'student/keine_studstatuspruefung' => $this->permissionlib->isBerechtigt('student/keine_studstatuspruefung'), + 'lehre/reihungstestAufsicht' => $this->permissionlib->isBerechtigt('lehre/reihungstestAufsicht') + ], + 'variables' => [ + 'semester_aktuell' => $this->variablelib->getVar('semester_aktuell') + ] + ]); + } +} diff --git a/application/controllers/api/frontend/v1/Udf.php b/application/controllers/api/frontend/v1/Udf.php new file mode 100644 index 000000000..4bdc613e0 --- /dev/null +++ b/application/controllers/api/frontend/v1/Udf.php @@ -0,0 +1,133 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the UDFLib (back-end) + * Provides data to the ajax get calls about the Udf component + * Listens to ajax post calls to change the Udf data + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Udf extends FHCAPI_Controller +{ + /** + * Calls the parent's constructor and prepares the UDFLib + */ + public function __construct() + { + // NOTE: UdfLib has its own permissions checks + parent::__construct([ + 'load' => self::PERM_LOGGED, + 'save' => self::PERM_LOGGED + ]); + + // Libraries + $this->load->library('form_validation'); + $this->load->library('UDFLib'); + + // Models + $this->load->model($this->getTargetModelPath(), 'TargetModel'); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Load all UDFs for a dataset + * + * @return void + */ + public function load() + { + $pks = $this->TargetModel->getPks(); + foreach ($pks as $id) + $this->form_validation->set_rules($id, $id, 'required'); + + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + $id = []; + foreach ($pks as $pk) + $id[$pk] = $this->input->post($pk); + if (!is_array($this->TargetModel->getPk())) + $id = current($id); + + $result = $this->udflib->getFieldArray($this->TargetModel, $id); + + $fields = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($fields); + } + + /** + * Saves UDFs to a dataset + * + * @return void + */ + public function save() + { + $pks = $this->TargetModel->getPks(); + foreach ($pks as $id) + $this->form_validation->set_rules($id, $id, 'required'); + + $result = $this->udflib->getCiValidations($this->TargetModel, $this->input->post()); + + $fieldValidations = $this->getDataOrTerminateWithError($result); + + $this->form_validation->set_rules($fieldvalidations); + + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + $id = []; + $fields = $this->input->post(); + foreach ($pks as $pk) { + $id[$pk] = $fields[$pk]; + unset($fields[$pk]); + } + if (!is_array($this->TargetModel->getPk())) + $id = current($id); + + $result = $this->TargetModel->update($id, $fields); + + $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(array_fill_keys(array_keys($fields), '')); + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * Get the path to the target model from the url + * + * @return string + */ + private function getTargetModelPath() + { + $ci_model_path = array_slice($this->uri->rsegments, 2); + if ($ci_model_path) + $ci_model_path[] = ucfirst(array_pop($ci_model_path)) . '_model'; + return implode(DIRECTORY_SEPARATOR, $ci_model_path); + } +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/betriebsmittel/BetriebsmittelP.php b/application/controllers/api/frontend/v1/betriebsmittel/BetriebsmittelP.php new file mode 100644 index 000000000..8e44b2326 --- /dev/null +++ b/application/controllers/api/frontend/v1/betriebsmittel/BetriebsmittelP.php @@ -0,0 +1,387 @@ + ['admin:r', 'assistenz:r'], + 'addNewBetriebsmittel' => self::PERM_LOGGED, + 'updateBetriebsmittel' => self::PERM_LOGGED, + 'loadBetriebsmittel' => ['admin:r', 'assistenz:r'], + 'deleteBetriebsmittel' => self::PERM_LOGGED, + 'getTypenBetriebsmittel' => ['admin:r', 'assistenz:r'], + 'loadInventarliste' => ['admin:r', 'assistenz:r'] + ]); + + //Load Models + $this->load->model('ressource/Betriebsmittel_model', 'BetriebsmittelModel'); + $this->load->model('ressource/Betriebsmittelperson_model', 'BetriebsmittelpersonModel'); + + // Additional Permission Checks + if ($this->router->method == 'addNewBetriebsmittel') { + $this->person_id = current(array_slice($this->uri->rsegments, 2)); + + $this->checkPermissionsForPerson( + $this->person_id, + ['admin:rw', 'mitarbeiter:rw', 'basis/betriebsmittel:rw'], + ['admin:rw', 'assistenz:rw', 'basis/betriebsmittel:rw'] + ); + } elseif ($this->router->method == 'updateBetriebsmittel' || $this->router->method == 'deleteBetriebsmittel') { + $betriebsmittelperson_id = current(array_slice($this->uri->rsegments, 2)); + $result = $this->BetriebsmittelpersonModel->load($betriebsmittelperson_id); + if (!hasData($result)) + show_404(); + $this->person_id = current(getData($result))->person_id; + + $this->checkPermissionsForPerson( + $this->person_id, + ['admin:rw', 'mitarbeiter:rw', 'basis/betriebsmittel:rw'], + ['admin:rw', 'assistenz:rw', 'basis/betriebsmittel:rw'] + ); + } + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('form_validation'); + + // Load language phrases + $this->loadPhrases([ + 'ui', + 'wawi' + ]); + } + + public function getAllBetriebsmittel($type_id, $id) + { + $result = $this->BetriebsmittelpersonModel->getBetriebsmittelData($id, $type_id); + + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + $this->terminateWithSuccess((getData($result) ?: [])); + } + + protected function validateNewOrUpdate() + { + $this->form_validation->set_rules('betriebsmitteltyp', 'Typ', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired') + ]); + + $this->form_validation->set_rules('kaution', 'Kaution', 'numeric|less_than_equal_to[9999.99]', [ + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric') + ]); + + $this->form_validation->set_rules('ausgegebenam', 'Ausgegeben am', 'required|is_valid_date', [ + 'required' => $this->p->t('ui', 'error_fieldRequired') + ]); + + if ($this->input->post('ausgegebenam') && $this->input->post('retouram')) { + $this->form_validation->set_rules('retouram', 'Retour am', [ + 'is_valid_date', + ['is_not_before_ausgegebenam', function ($value) { + return (new DateTime($value) >= new DateTime($this->input->post('ausgegebenam'))); + }] + ], [ + 'is_not_before_ausgegebenam' => $this->p->t('wawi', 'error_retourdatumVorAusgabe') + ]); + } else { + $this->form_validation->set_rules('retouram', 'Retour am', 'is_valid_date'); + } + + $this->form_validation->set_rules('anmerkung', 'Anmerkung', 'max_length[256]'); + + if ($this->input->post('betriebsmitteltyp') == 'Inventar') { + // Inventar + $this->form_validation->set_rules('betriebsmittel_id', 'Inventarnummer', 'required'); + } elseif ($this->input->post('betriebsmitteltyp') == 'Zutrittskarte') { + // Zutrittskarte + if ($this->input->post('nummer') === null && $this->input->post('nummer') === null) { + $this->form_validation->set_rules('nummer', 'Nummer', 'required', [ + 'required' => $this->p->t('wawi', 'error_zutrittskarteOhneNummer') + ]); + $this->form_validation->set_rules('nummer2', 'Nummer2', 'required', [ + 'required' => $this->p->t('wawi', 'error_zutrittskarteOhneNummer') + ]); + } else { + if ($this->input->post('nummer') === null) { + $result = $this->BetriebsmittelpersonModel->loadViewWhere([ + 'betriebsmitteltyp' => $this->input->post('betriebsmitteltyp'), + 'nummer2' => $this->input->post('nummer2'), + 'person_id !=' => $this->person_id, + 'retouram IS NULL' => null + ]); + if (hasData($result)) + $this->form_validation->set_rules('nummer2', 'Nummer2', 'is_array', [ + 'is_array' => $this->p->t('wawi', 'error_bmZutrittskarteOccupied', (array)current(getData($result))) + ]); + } else { + $result = $this->BetriebsmittelpersonModel->loadViewWhere([ + 'betriebsmitteltyp' => $this->input->post('betriebsmitteltyp'), + 'nummer' => $this->input->post('nummer'), + 'person_id !=' => $this->person_id, + 'retouram IS NULL' => null + ]); + if (hasData($result)) + $this->form_validation->set_rules('nummer', 'Nummer', 'is_array', [ + 'is_array' => $this->p->t('wawi', 'error_bmZutrittskarteOccupied', (array)current(getData($result))) + ]); + } + } + } + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + public function addNewBetriebsmittel($person_id) + { + $this->form_validation->set_rules('uid', 'UID', [ + ['uid_in_person', function ($value) use ($person_id) { + if ($value === null) + return true; + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $result = $this->BenutzerModel->loadWhere([ + 'uid' => $value, + 'person_id' => $person_id + ]); + + return hasData($result); + }] + ], [ + 'uid_in_person' => $this->p->t('person', 'error_uidNotInPerson') + ]); + $this->validateNewOrUpdate(); + + $betriebsmitteltyp = $this->input->post('betriebsmitteltyp'); + $nummer = $this->input->post('nummer'); + $nummer2 = $this->input->post('nummer2'); + $beschreibung = $this->input->post('beschreibung'); + $betriebsmittel_id = $this->input->post('betriebsmittel_id'); + $anmerkung = $this->input->post('anmerkung'); + $kaution = $this->input->post('kaution'); + $ausgegebenam = $this->input->post('ausgegebenam'); + $retouram = $this->input->post('retouram'); + $uid = $this->input->post('uid'); + + // NOTE(chris): transform_kartennummer + if ($betriebsmitteltyp == 'Zutrittskarte' && $nummer) + $nummer = is_numeric($nummer) ? ltrim($nummer, "0") : hexdec(implode("", array_reverse(str_split(trim($nummer))))); + + $this->db->trans_start(); + + if ($betriebsmitteltyp != 'Inventar') { + $this->BetriebsmittelModel->addOrder('updateamum', 'DESC'); + if ($betriebsmitteltyp == 'Zutrittskarte' && $nummer === null) { + $result = $this->BetriebsmittelModel->loadWhere([ + 'betriebsmitteltyp' => $betriebsmitteltyp, + 'nummer2' => $nummer2 + ]); + } else { + $result = $this->BetriebsmittelModel->loadWhere([ + 'betriebsmitteltyp' => $betriebsmitteltyp, + 'nummer' => $nummer + ]); + } + $data = $this->getDataOrTerminateWithError($result); + + if ($data) { + $data = current($data); + if ($data->nummer !== $nummer || $data->nummer2 !== $nummer2 || $data->beschreibung !== $beschreibung) { + $result = $this->BetriebsmittelModel->update($data->betriebsmittel_id, [ + 'nummer' => $nummer, + 'nummer2' => $nummer2, + 'beschreibung' => $beschreibung, + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ]); + $this->getDataOrTerminateWithError($result); + } + $betriebsmittel_id = $data->betriebsmittel_id; + } else { + $result = $this->BetriebsmittelModel->insert([ + 'betriebsmitteltyp' => $betriebsmitteltyp, + 'nummer' => $nummer, + 'nummer2' => $nummer2, + 'beschreibung' => $beschreibung, + 'reservieren' => false, + 'ort_kurzbz' => null, + 'insertamum' => date('c'), + 'insertvon' => getAuthUID(), + ]); + $betriebsmittel_id = $this->getDataOrTerminateWithError($result); + } + } + + $result = $this->BetriebsmittelpersonModel->insert([ + 'person_id' => $person_id, + 'betriebsmittel_id' => $betriebsmittel_id, + 'anmerkung' => $anmerkung, + 'kaution' => $kaution, + 'ausgegebenam' => $ausgegebenam, + 'retouram' => $retouram, + 'uid' => $uid, + 'insertamum' => date('c'), + 'insertvon' => getAuthUID() + ]); + + $data = $this->getDataOrTerminateWithError($result); + + $this->db->trans_complete(); + + $this->terminateWithSuccess(true); + } + + public function updateBetriebsmittel($betriebsmittelperson_id) + { + $this->validateNewOrUpdate(); + + $betriebsmitteltyp = $this->input->post('betriebsmitteltyp'); + $nummer = $this->input->post('nummer'); + $nummer2 = $this->input->post('nummer2'); + $beschreibung = $this->input->post('beschreibung'); + $betriebsmittel_id = $this->input->post('betriebsmittel_id'); + $anmerkung = $this->input->post('anmerkung'); + $kaution = $this->input->post('kaution'); + $ausgegebenam = $this->input->post('ausgegebenam'); + $retouram = $this->input->post('retouram'); + + // NOTE(chris): transform_kartennummer + if ($betriebsmitteltyp == 'Zutrittskarte' && $nummer) + $nummer = is_numeric($nummer) ? ltrim($nummer, "0") : hexdec(implode("", array_reverse(str_split(trim($nummer))))); + + $this->db->trans_start(); + + if ($betriebsmitteltyp != 'Inventar') { + $found = false; + if ($nummer !== null && $betriebsmittel_id !== null) { + $result = $this->BetriebsmittelModel->load($betriebsmittel_id); + $data = $this->getDataOrTerminateWithError($result); + if ($data && current($data)->nummer == $nummer) { + $found = true; + } + } + + if (!$found) { + $this->BetriebsmittelModel->addOrder('updateamum', 'DESC'); + if ($betriebsmitteltyp == 'Zutrittskarte' && $nummer === null) { + $result = $this->BetriebsmittelModel->loadWhere([ + 'betriebsmitteltyp' => $betriebsmitteltyp, + 'nummer2' => $nummer2 + ]); + } else { + $result = $this->BetriebsmittelModel->loadWhere([ + 'betriebsmitteltyp' => $betriebsmitteltyp, + 'nummer' => $nummer + ]); + } + $data = $this->getDataOrTerminateWithError($result); + } + + if ($data) { + $data = current($data); + if ($data->nummer !== $nummer || $data->nummer2 !== $nummer2 || $data->beschreibung !== $beschreibung) { + $result = $this->BetriebsmittelModel->update($data->betriebsmittel_id, [ + 'nummer' => $nummer, + 'nummer2' => $nummer2, + 'beschreibung' => $beschreibung, + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ]); + $this->getDataOrTerminateWithError($result); + } + $betriebsmittel_id = $data->betriebsmittel_id; + } else { + $result = $this->BetriebsmittelModel->insert([ + 'betriebsmitteltyp' => $betriebsmitteltyp, + 'nummer' => $nummer, + 'nummer2' => $nummer2, + 'beschreibung' => $beschreibung, + 'reservieren' => false, + 'ort_kurzbz' => null, + 'insertamum' => date('c'), + 'insertvon' => getAuthUID(), + ]); + $betriebsmittel_id = $this->getDataOrTerminateWithError($result); + } + } + + $result = $this->BetriebsmittelpersonModel->update($betriebsmittelperson_id, [ + 'betriebsmittel_id' => $betriebsmittel_id, + 'anmerkung' => $anmerkung, + 'kaution' => $kaution, + 'ausgegebenam' => $ausgegebenam, + 'retouram' => $retouram, + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ]); + + $data = $this->getDataOrTerminateWithError($result); + + $this->db->trans_complete(); + + $this->terminateWithSuccess(true); + } + + public function loadBetriebsmittel($betriebsmittelperson_id) + { + $result = $this->BetriebsmittelpersonModel->getBetriebsmittelData($betriebsmittelperson_id, 'betriebsmittelperson_id'); + + if (isError($result)) { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + if (!hasData($result)) { + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Betriebsmittelperson_id']), self::ERROR_TYPE_GENERAL); + } + + $this->terminateWithSuccess(current(getData($result))); + } + + public function deleteBetriebsmittel($betriebsmittelperson_id) + { + $result = $this->BetriebsmittelpersonModel->delete( + array('betriebsmittelperson_id' => $betriebsmittelperson_id, + ) + ); + + if (isError($result)) { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if (!hasData($result)) { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Betriebsmittelperson_id']), self::ERROR_TYPE_GENERAL); + } + return $this->outputJsonSuccess(current(getData($result))); + } + + public function getTypenBetriebsmittel() + { + $this->load->model('ressource/Betriebsmitteltyp_model', 'BetriebsmitteltypModel'); + + $this->BetriebsmitteltypModel->addOrder('beschreibung', 'ASC'); + $result = $this->BetriebsmitteltypModel->load(); // load All + + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function loadInventarliste($searchString) + { + $result = $this->BetriebsmittelModel->loadInventarliste($searchString); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } +} + + diff --git a/application/controllers/api/frontend/v1/notiz/NotizPerson.php b/application/controllers/api/frontend/v1/notiz/NotizPerson.php new file mode 100644 index 000000000..cb9d31024 --- /dev/null +++ b/application/controllers/api/frontend/v1/notiz/NotizPerson.php @@ -0,0 +1,51 @@ + ['admin:r', 'assistenz:r'], + 'getNotizen' => ['admin:r', 'assistenz:r'], + 'loadNotiz' => ['admin:r', 'assistenz:r'], + 'addNewNotiz' => ['admin:rw', 'assistenz:rw'], + 'updateNotiz' => ['admin:rw', 'assistenz:rw'], + 'deleteNotiz' => ['admin:rw', 'assistenz:rw'], + 'loadDokumente' => ['admin:r', 'assistenz:r'], + 'getMitarbeiter' => ['admin:r', 'assistenz:r'], + 'isBerechtigt' => ['admin:r', 'assistenz:r'], + ]); + } + + public function isBerechtigt($id, $typeId) + { + if($typeId != "person_id") + { + return $this->terminateWithError($this->p->t('ui', 'error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL); + } + + //TODO define permission + if (!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) + { + $result = $this->p->t('lehre', 'error_keineSchreibrechte'); + + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + return $this->outputJsonSuccess(true); + } + + public function loadDokumente() + { + $notiz_id = $this->input->post('notiz_id'); + + // TODO(chris): make CI variant of endpoint + $this->NotizModel->addSelect($this->NotizModel->escape(base_url('content/notizdokdownload.php?id=')) . ' || campus.tbl_dms_version.dms_id AS preview'); + + return parent::loadDokumente(); + } +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/studstatus/Leitung.php b/application/controllers/api/frontend/v1/studstatus/Leitung.php index 2699a3dbb..87099ad74 100644 --- a/application/controllers/api/frontend/v1/studstatus/Leitung.php +++ b/application/controllers/api/frontend/v1/studstatus/Leitung.php @@ -53,7 +53,8 @@ class Leitung extends FHCAPI_Controller // Load language phrases $this->loadPhrases([ - 'studierendenantrag' + 'studierendenantrag', + 'lehre' ]); } diff --git a/application/controllers/api/frontend/v1/stv/Address.php b/application/controllers/api/frontend/v1/stv/Address.php new file mode 100644 index 000000000..7685fcd04 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Address.php @@ -0,0 +1,66 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about addresses + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Address extends FHCAPI_Controller +{ + public function __construct() + { + parent::__construct([ + 'getNations' => self::PERM_LOGGED, + 'getPlaces' => self::PERM_LOGGED + ]); + } + + public function getNations() + { + $this->load->model('codex/Nation_model', 'NationModel'); + + $this->NationModel->addOrder('kurztext'); + + $result = $this->NationModel->load(); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getPlaces($plz) + { + $this->load->model('codex/Gemeinde_model', 'GemeindeModel'); + + $this->load->library('form_validation'); + + $this->form_validation->set_data(['address.plz' => $plz]); + + $this->form_validation->set_rules('address.plz', 'PLZ', 'numeric|less_than[10000]'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $result = $this->GemeindeModel->getGemeindeByPlz($plz); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php new file mode 100644 index 000000000..c28c49485 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -0,0 +1,233 @@ +. + */ + +if (!defined('BASEPATH')) exit('No direct script access allowed'); + +use CI3_Events as Events; + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about the StV Config + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Config extends FHCAPI_Controller +{ + + + public function __construct() + { + // TODO(chris): permissions + parent::__construct([ + 'student' => ['admin:r', 'assistenz:r'], + 'students' => ['admin:r', 'assistenz:r'] + ]); + + + // Load Phrases + $this->loadPhrases([ + 'global', + 'person', + 'lehre', + 'stv', + 'konto' + ]); + } + + public function student() + { + $result = []; + $result['details'] = [ + 'title' => $this->p->t('stv', 'tab_details'), + 'component' => './Stv/Studentenverwaltung/Details/Details.js' + ]; + $result['notes'] = [ + 'title' => $this->p->t('stv', 'tab_notes'), + 'component' => './Stv/Studentenverwaltung/Details/Notizen.js' + ]; + $result['contact'] = [ + 'title' => $this->p->t('stv', 'tab_contact'), + 'component' => './Stv/Studentenverwaltung/Details/Kontakt.js', + 'config' => [ + 'showBankaccount' => $this->permissionlib->isBerechtigt('mitarbeiter/bankdaten') + || $this->permissionlib->isBerechtigt('student/bankdaten') + ] + ]; + $result['prestudent'] = [ + 'title' => $this->p->t('stv', 'tab_prestudent'), + 'component' => './Stv/Studentenverwaltung/Details/Prestudent.js' + ]; + $result['status'] = [ + 'title' => 'Status', + 'component' => './Stv/Studentenverwaltung/Details/MultiStatus.js' + ]; + $result['banking'] = [ + 'title' => $this->p->t('stv', 'tab_banking'), + 'component' => './Stv/Studentenverwaltung/Details/Konto.js', + 'config' => [ + 'showZahlungsbestaetigung' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN), + 'showBuchungsnr' => $this->permissionlib->isBerechtigt('admin'), + 'showMahnspanne' => (!defined('FAS_KONTO_SHOW_MAHNSPANNE') || FAS_KONTO_SHOW_MAHNSPANNE===true), + 'showCreditpoints' => (defined('FAS_KONTO_SHOW_CREDIT_POINTS') && FAS_KONTO_SHOW_CREDIT_POINTS == 'true'), + 'columns' => $this->kontoColumns(), + 'additionalCols' => [] + ] + ]; + $result['resources'] = [ + 'title' => $this->p->t('stv', 'tab_resources'), + 'component' => './Stv/Studentenverwaltung/Details/Betriebsmittel.js' + ]; + /* TODO(chris): Ausgeblendet für Testing + $result['grades'] = [ + 'title' => $this->p->t('stv', 'tab_grades'), + 'component' => './Stv/Studentenverwaltung/Details/Noten.js' + ]; + */ + + Events::trigger('stv_conf_student', function & () use (&$result) { + return $result; + }); + + $this->terminateWithSuccess($result); + } + + public function students() + { + $result = []; + $result['banking'] = [ + 'title' => $this->p->t('stv', 'tab_banking'), + 'component' => './Stv/Studentenverwaltung/Details/Konto.js', + 'config' => [ + 'showZahlungsbestaetigung' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN), + 'showBuchungsnr' => $this->permissionlib->isBerechtigt('admin'), + 'showMahnspanne' => (!defined('FAS_KONTO_SHOW_MAHNSPANNE') || FAS_KONTO_SHOW_MAHNSPANNE===true), + 'showCreditpoints' => (defined('FAS_KONTO_SHOW_CREDIT_POINTS') && FAS_KONTO_SHOW_CREDIT_POINTS == 'true'), + 'columns' => $this->kontoColumnsMultiPerson(), + 'additionalCols' => [] + ] + ]; + $result['status'] = [ + 'title' => 'Status', + 'component' => './Stv/Studentenverwaltung/Details/MultiStatus.js', + 'config' => [ + 'changeStatusToAbbrecherStgl' => $this->permissionlib->isBerechtigt('admin'), + 'changeStatusToAbbrecherStud' => $this->permissionlib->isBerechtigt('admin'), + 'changeStatusToUnterbrecher' => $this->permissionlib->isBerechtigt('admin'), + 'changeStatusToDiplomand' => $this->permissionlib->isBerechtigt('admin'), + 'changeStatusToAbsolvent' => $this->permissionlib->isBerechtigt('admin') + ] + ]; + + Events::trigger('stv_conf_students', function & () use (&$result) { + return $result; + }); + + $this->terminateWithSuccess($result); + } + + protected function kontoColumns() + { + return [ + 'buchungsdatum' => [ + 'field' => "buchungsdatum", + 'title' => $this->p->t('konto', 'buchungsdatum') + ], + 'buchungstext' => [ + 'field' => "buchungstext", + 'title' => $this->p->t('konto', 'buchungstext') + ], + 'betrag' => [ + 'field' => "betrag", + 'title' => $this->p->t('konto', 'betrag') + ], + 'studiensemester_kurzbz' => [ + 'field' => "studiensemester_kurzbz", + 'title' => $this->p->t('lehre', 'studiensemester') + ], + 'buchungstyp_kurzbz' => [ + 'field' => "buchungstyp_kurzbz", + 'title' => $this->p->t('konto', 'buchungstyp'), + 'visible' => false + ], + 'buchungsnr' => [ + 'field' => "buchungsnr", + 'title' => $this->p->t('konto', 'buchungsnr'), + 'visible' => false + ], + 'insertvon' => [ + 'field' => "insertvon", + 'title' => $this->p->t('global', 'insertvon'), + 'visible' => false + ], + 'insertamum' => [ + 'field' => "insertamum", + 'title' => $this->p->t('global', 'insertamum'), + 'visible' => false + ], + 'kuerzel' => [ + 'field' => "kuerzel", + 'title' => $this->p->t('lehre', 'studiengang'), + 'visible' => false + ], + 'anmerkung' => [ + 'field' => "anmerkung", + 'title' => $this->p->t('global', 'anmerkung') + ], + 'actions' => [ + 'title' => $this->p->t('global', 'actions'), + 'frozen' => true + ] + ]; + } + protected function kontoColumnsMultiPerson() + { + return [ + 'person_id' => [ + 'field' => "person_id", + 'title' => $this->p->t('person', 'person_id') + ], + 'anrede' => [ + 'field' => "anrede", + 'title' => $this->p->t('person', 'anrede'), + 'visible' => false + ], + 'titelpost' => [ + 'field' => "titelpost", + 'title' => $this->p->t('person', 'titelpost'), + 'visible' => false + ], + 'titelpre' => [ + 'field' => "titelpre", + 'title' => $this->p->t('person', 'titelpre'), + 'visible' => false + ], + 'vorname' => [ + 'field' => "vorname", + 'title' => $this->p->t('person', 'vorname') + ], + 'vornamen' => [ + 'field' => "vornamen", + 'title' => $this->p->t('person', 'vornamen'), + 'visible' => false + ], + 'nachname' => [ + 'field' => "nachname", + 'title' => $this->p->t('person', 'nachname') + ] + ] + $this->kontoColumns(); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Favorites.php b/application/controllers/api/frontend/v1/stv/Favorites.php new file mode 100644 index 000000000..8d7a6cd14 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Favorites.php @@ -0,0 +1,71 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about favorite verbände + * Listens to ajax post calls to change the favorite verbände data + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Favorites extends FHCAPI_Controller +{ + public function __construct() + { + parent::__construct([ + 'index' => self::PERM_LOGGED, + 'set' => self::PERM_LOGGED + ]); + + // Load models + $this->load->model('system/Variable_model', 'VariableModel'); + + // TODO(chris): variable table might be to small to store favorites! + } + + public function index() + { + $result = $this->VariableModel->getVariables(getAuthUID(), ['stv_favorites']); + + $data = $this->getDataOrTerminateWithError($result); + + if (!$data) + $this->terminateWithSuccess(null); + else + $this->terminateWithSuccess($data['stv_favorites']); + } + + public function set() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('favorites', 'Favorites', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $favorites = $this->input->post('favorites'); + + $result = $this->VariableModel->setVariable(getAuthUID(), 'stv_favorites', $favorites); + + $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(true); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Filter.php b/application/controllers/api/frontend/v1/stv/Filter.php new file mode 100644 index 000000000..dbf70e4fb --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Filter.php @@ -0,0 +1,84 @@ +. + */ + +if (!defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about the Studiengang filter + * Listens to ajax post calls to change the Studiengang 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 +{ + /** + * Calls the parent's constructor and prepares libraries and phrases + */ + public function __construct() + { + parent::__construct([ + 'getStg' => self::PERM_LOGGED, + 'setStg' => self::PERM_LOGGED + ]); + + // Load models + $this->load->model('system/Variable_model', 'VariableModel'); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Get current setting + * + * @return void + */ + public function getStg() + { + $result = $this->VariableModel->getVariables(getAuthUID(), ['kontofilterstg']); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data['kontofilterstg'] == 'true'); + } + + /** + * Set current setting + * + * @return void + */ + public function setStg() + { + $this->load->library('form_validation'); + + $studiengang_kz = $this->input->post('studiengang_kz'); + + if ($studiengang_kz === null) { + $this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $result = $this->VariableModel->setVariable(getAuthUID(), 'kontofilterstg', $studiengang_kz ? 'true' : 'false'); + + $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(true); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Kontakt.php b/application/controllers/api/frontend/v1/stv/Kontakt.php new file mode 100644 index 000000000..379184ee0 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Kontakt.php @@ -0,0 +1,754 @@ + ['admin:r', 'assistenz:r'], + 'addNewAddress' => ['admin:rw', 'assistenz:rw'], + 'addNewContact' => ['admin:rw', 'assistenz:rw'], + 'addNewBankverbindung' => ['mitarbeiter/bankdaten:rw', 'student/bankdaten:rw'], + 'updateAddress' => ['admin:rw', 'assistenz:rw'], + 'updateContact' => ['admin:rw', 'assistenz:rw'], + 'updateBankverbindung' => ['mitarbeiter/bankdaten:rw', 'student/bankdaten:rw'], + 'loadAddress' => ['admin:r', 'assistenz:r'], + 'loadContact' => ['admin:r', 'assistenz:r'], + 'loadBankverbindung' => ['mitarbeiter/bankdaten:r', 'student/bankdaten:r'], + 'deleteAddress' => ['admin:rw', 'assistenz:rw'], + 'deleteContact' => ['admin:rw','assistenz:rw'], + 'deleteBankverbindung' => ['mitarbeiter/bankdaten:rw','astudent/bankdaten:rw'], + 'getAdressentypen' => ['admin:r', 'assistenz:r'], + 'getKontakttypen' => ['admin:r', 'assistenz:r'], + 'getFirmen' => ['admin:r', 'assistenz:r'], + 'getStandorte' => ['admin:r', 'assistenz:r'], + 'getStandorteByFirma' => ['admin:r', 'assistenz:r'], + 'getKontakte' => ['admin:r', 'assistenz:r'], + 'getBankverbindung' => ['mitarbeiter/bankdaten:r', 'student/bankdaten:r'] + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('form_validation'); + + // Load language phrases + $this->loadPhrases([ + 'ui', + 'person' + ]); + + // Load models + $this->load->model('person/Adresse_model', 'AdresseModel'); + $this->load->model('organisation/standort_model', 'StandortModel'); + $this->load->model('ressource/firma_model', 'FirmaModel'); + $this->load->model('person/Kontakt_model', 'KontaktModel'); + + // Extra Permissionchecks + $permsMa = []; + $permsStud = []; + switch ($this->router->method) { + case 'getBankverbindung': + case 'loadBankverbindung': + $permsMa = ['mitarbeiter/bankdaten:r']; + $permsStud = ['student/bankdaten:r']; + break; + case 'addNewBankverbindung': + case 'updateBankverbindung': + case 'deleteBankverbindung': + $permsMa = ['mitarbeiter/bankdaten:rw']; + $permsStud = ['student/bankdaten:rw']; + break; + case 'getAdressen': + case 'getKontakte': + case 'loadAddress': + case 'loadContact': + $permsMa = $permsStud = ['admin:r', 'assistenz:r']; + break; + case 'addNewAddress': + case 'addNewContact': + case 'updateAddress': + case 'updateContact': + case 'deleteAddress': + case 'deleteContact': + $permsMa = $permsStud = ['admin:rw', 'assistenz:rw']; + break; + } + if ($this->router->method == 'getAdressen' + || $this->router->method == 'getKontakte' + || $this->router->method == 'getBankverbindung' + || $this->router->method == 'addNewAddress' + || $this->router->method == 'addNewContact' + || $this->router->method == 'addNewBankverbindung' + ) { + $person_id = current(array_slice($this->uri->rsegments, 2)); + + $this->checkPermissionsForPerson($person_id, $permsMa, $permsStud); + } elseif ($this->router->method == 'loadAddress' + || $this->router->method == 'loadContact' + || $this->router->method == 'loadBankverbindung' + || $this->router->method == 'updateAddress' + || $this->router->method == 'updateContact' + || $this->router->method == 'updateBankverbindung' + || $this->router->method == 'deleteAddress' + || $this->router->method == 'deleteContact' + || $this->router->method == 'deleteBankverbindung' + ) { + $id = current(array_slice($this->uri->rsegments, 2)); + + $model = 'person/Adresse_model'; + if ($this->router->method == 'loadContact' + || $this->router->method == 'updateContact' + || $this->router->method == 'deleteContact' + ) { + $model = 'person/Kontakt_model'; + } elseif ($this->router->method == 'loadBankverbindung' + || $this->router->method == 'updateBankverbindung' + || $this->router->method == 'deleteBankverbindung' + ) { + $model = 'person/Bankverbindung_model'; + } + + $this->load->model($model, 'TempModel'); + $result = $this->TempModel->load($id); + $data = $this->getDataOrTerminateWithError($result); + if (!$result) + show_404(); + + $person_id = current($data)->person_id; + + $this->checkPermissionsForPerson($person_id, $permsMa, $permsStud); + } + } + public function getAdressen($person_id) + { + $this->AdresseModel->addSelect('public.tbl_adresse.*'); + $this->AdresseModel->addSelect('t.*'); + $this->AdresseModel->addSelect('f.firma_id'); + $this->AdresseModel->addSelect('f.name as firmenname'); + $this->AdresseModel->addJoin('public.tbl_adressentyp t', 'ON (t.adressentyp_kurzbz = public.tbl_adresse.typ)'); + $this->AdresseModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = public.tbl_adresse.firma_id)', 'LEFT'); + + $result = $this->AdresseModel->loadWhere( + array('person_id' => $person_id) + ); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess((getData($result) ?: [])); + } + + public function addNewAddress($person_id) + { + $this->form_validation->set_rules('plz', 'PLZ', 'required|numeric', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'PLZ']), + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'PLZ']) + ]); + + if(isset($_POST['gemeinde']) && isset($_POST['ort'])) + $this->form_validation->set_rules('plz', 'Postleitzahl', 'callback_validateLocationCombination', [ + 'validateLocationCombination' => $this->p->t('ui', 'error_location_combination') + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $uid = getAuthUID(); + $co_name = isset($_POST['co_name']) ? $_POST['co_name'] : null; + $strasse = isset($_POST['strasse']) ? $_POST['strasse'] : null; + $ort = isset($_POST['ort']) ? $_POST['ort'] : null; + $gemeinde = isset($_POST['gemeinde']) ? $_POST['gemeinde'] : null; + $nation = isset($_POST['nation']) ? $_POST['nation'] : null; + $name = isset($_POST['name']) ? $_POST['name'] : null; + $typ = isset($_POST['typ']) ? $_POST['typ'] : null; + $anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null; + + if(isset($_POST['firma'])) + { + $firma_id = $_POST['firma']['firma_id']; + } + else + $firma_id = null; + + $result = $this->AdresseModel->insert( + [ + 'person_id' => $person_id, + 'strasse' => $strasse, + 'insertvon' => $uid, + 'insertamum' => date('c'), + 'plz' => $_POST['plz'], + 'ort' => $ort, + 'gemeinde' => $gemeinde, + 'nation' => $nation, + 'heimatadresse' => $_POST['heimatadresse'], + 'zustelladresse' => $_POST['zustelladresse'], + 'co_name' => $co_name, + 'typ' => $typ, + 'firma_id' => $firma_id, + 'name' => $name, + 'rechnungsadresse' => $_POST['rechnungsadresse'], + 'anmerkung' => $anmerkung + + ] + ); + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->outputJsonSuccess(true); + } + + public function updateAddress($address_id) + { + $uid = getAuthUID(); + $this->form_validation->set_rules('plz', 'PLZ', 'required|numeric', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'PLZ']), + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'PLZ']) + ]); + + if(isset($_POST['gemeinde']) && isset($_POST['ort'])) + $this->form_validation->set_rules('plz', 'Postleitzahl', 'callback_validateLocationCombination', [ + 'validateLocationCombination' => $this->p->t('ui', 'error_location_combination') + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $this->load->model('person/Adresse_model', 'AdresseModel'); + + if(!$address_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL); + } + + if(isset($_POST['firma'])) + { + $firma_id = $_POST['firma']['firma_id']; + } + elseif(isset($_POST['firma_id'])) + { + $firma_id = $_POST['firma_id']; + } + else + $firma_id = null; + + $person_id = isset($_POST['person_id']) ? $_POST['person_id'] : null; + $co_name = isset($_POST['co_name']) ? $_POST['co_name'] : null; + $strasse = isset($_POST['strasse']) ? $_POST['strasse'] : null; + $ort = isset($_POST['ort']) ? $_POST['ort'] : null; + $gemeinde = isset($_POST['gemeinde']) ? $_POST['gemeinde'] : null; + $nation = isset($_POST['nation']) ? $_POST['nation'] : null; + $name = isset($_POST['name']) ? $_POST['name'] : null; + $typ = isset($_POST['typ']) ? $_POST['typ'] : null; + $anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null; + + $result = $this->AdresseModel->update( + [ + 'adresse_id' => $address_id + ], + [ 'person_id' => $person_id, + 'strasse' => $strasse, + 'updatevon' => $uid, + 'updateamum' => date('c'), + 'plz' => $_POST['plz'], + 'ort' => $ort, + 'gemeinde' => $gemeinde, + 'nation' => $nation, + 'heimatadresse' => $_POST['heimatadresse'], + 'zustelladresse' => $_POST['zustelladresse'], + 'co_name' => $co_name, + 'typ' => $typ, + 'firma_id' => $firma_id, + 'name' => $name, + 'rechnungsadresse' => $_POST['rechnungsadresse'], + 'anmerkung' => $anmerkung + ] + ); + + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->outputJsonSuccess(true); + } + + public function loadAddress($adresse_id) + { + $this->load->model('person/Adresse_model', 'AdresseModel'); + + $this->AdresseModel->addSelect('public.tbl_adresse.*'); + $this->AdresseModel->addSelect('t.*'); + $this->AdresseModel->addSelect('f.firma_id'); + $this->AdresseModel->addSelect('f.name as firmenname'); + $this->AdresseModel->addJoin('public.tbl_adressentyp t', 'ON (t.adressentyp_kurzbz = public.tbl_adresse.typ)'); + $this->AdresseModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = public.tbl_adresse.firma_id)', 'LEFT'); + + $this->AdresseModel->addLimit(1); + + $result = $this->AdresseModel->loadWhere( + array('adresse_id' => $adresse_id) + ); + if (isError($result)) { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + if (!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess(current(getData($result)) ? : null); + } + + public function deleteAddress($adresse_id) + { + $this->load->model('person/Adresse_model', 'AdresseModel'); + $result = $this->AdresseModel->load([ + 'adresse_id'=> $adresse_id, + ]); + if(isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $result = current(getData($result)); + + if($result->heimatadresse) + + $this->terminateWithError($this->p->t('person', 'error_deleteHomeAdress'), self::ERROR_TYPE_GENERAL); + + $result = $this->AdresseModel->delete( + array('adresse_id' => $adresse_id) + ); + + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if (!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL); + } + + return $this->terminateWithSuccess(current(getData($result)) ? : null); + } + + public function getAdressentypen() + { + $this->load->model('person/Adressentyp_model', 'AdressentypModel'); + + $result = $this->AdressentypModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getFirmen($searchString) + { + $this->load->model('ressource/firma_model', 'FirmaModel'); + + $result = $this->FirmaModel->searchFirmen($searchString); + if (isError($result)) { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess($result ?: []); + } + + public function getStandorte($searchString) + { + $this->load->model('organisation/standort_model', 'StandortModel'); + + $result = $this->StandortModel->searchStandorte($searchString); + if (isError($result)) { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess($result ?: []); + } + + public function getStandorteByFirma($firma_id) + { + $this->load->model('organisation/standort_model', 'StandortModel'); + + $result = $this->StandortModel->getStandorteByFirma($firma_id); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getKontakte($person_id) + { + $this->KontaktModel->addSelect("public.tbl_kontakt.*, + TO_CHAR (CASE + WHEN public.tbl_kontakt.updateamum >= public.tbl_kontakt.insertamum + THEN public.tbl_kontakt.updateamum + ELSE public.tbl_kontakt.insertamum + END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate, st.bezeichnung, f.name"); + $this->StandortModel->addJoin('public.tbl_standort st', 'ON (public.tbl_kontakt.standort_id = st.standort_id)', 'LEFT'); + $this->FirmaModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = st.firma_id)', 'LEFT'); + $result = $this->KontaktModel->loadWhere( + array('person_id' => $person_id) + ); + + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess((getData($result) ?: [])); + } + + public function getKontakttypen() + { + $this->load->model('person/Kontakttyp_model', 'KontakttypModel'); + + $result = $this->KontakttypModel->load(); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + else + { + $this->terminateWithSuccess(getData($result) ?: []); + } + } + + public function loadContact($kontakt_id) + { + $this->load->model('person/Kontakt_model', 'KontaktModel'); + + $this->KontaktModel->addSelect('*, public.tbl_kontakt.*'); + $this->KontaktModel->addSelect('st.kurzbz'); + $this->KontaktModel->addJoin('public.tbl_standort st', 'ON (public.tbl_kontakt.standort_id = st.standort_id)', 'LEFT'); + $this->FirmaModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = st.firma_id)', 'LEFT'); + + $this->KontaktModel->addLimit(1); + + $result = $this->KontaktModel->loadWhere( + array('kontakt_id' => $kontakt_id) + ); + if (isError($result)) { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if (!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL); + } + // $this->outputJsonSuccess(current(getData($result))); + $this->terminateWithSuccess(current(getData($result))); + } + + public function addNewContact($person_id) + { + if(($_POST['kontakttyp'] == 'email' && isset($_POST['kontakt']))) + { + $this->form_validation->set_rules('kontakt', 'Kontakt', 'required|valid_email', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt']), + 'valid_email' => $this->p->t('ui', 'error_fieldNoValidEmail', ['field' => 'Kontakt']) + ]); + } + else + { + $this->form_validation->set_rules('kontakt', 'Kontakt', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt']) + ]); + } + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $this->load->model('person/Kontakt_model', 'KontaktModel'); + + $uid = getAuthUID(); + + $kontakttyp = $this->input->post('kontakttyp'); + $anmerkung = $this->input->post('anmerkung'); + $kontakt = $this->input->post('kontakt'); + $ext_id = $this->input->post('ext_id'); + $standort_id = $this->input->post('standort_id'); + + $result = $this->KontaktModel->insert( + [ + 'person_id' => $person_id, + 'kontakttyp' => $kontakttyp, + 'anmerkung' => $anmerkung, + 'kontakt' => $kontakt, + 'zustellung' => $_POST['zustellung'], + 'insertvon' => $uid, + 'insertamum' => date('c'), + 'standort_id' => $standort_id, + 'ext_id' => $ext_id + ] + ); + + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + return $this->outputJsonSuccess(true); + } + + public function updateContact($kontakt_id) + { + $this->load->model('person/Kontakt_model', 'KontaktModel'); + + if(!$kontakt_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL); + } + + if(($_POST['kontakttyp'] == 'email' && isset($_POST['kontakt']))) + { + $this->form_validation->set_rules('kontakt', 'Kontakt', 'required|valid_email', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt']), + 'valid_email' => $this->p->t('ui', 'error_fieldNoValidEmail', ['field' => 'Kontakt']) + ]); + } + else + { + $this->form_validation->set_rules('kontakt', 'Kontakt', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt']) + ]); + } + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + +/* if(isset($_POST['standort'])) + { + $standort_id = $_POST['standort']['standort_id']; + } + else + $standort_id = null;*/ + + $uid = getAuthUID(); + $kontakttyp = $this->input->post('kontakttyp'); + $anmerkung = $this->input->post('anmerkung'); + $kontakt = $this->input->post('kontakt'); + $ext_id = $this->input->post('ext_id'); + $person_id = $this->input->post('person_id'); + $standort_id = $this->input->post('standort_id'); + + //return $this->terminateWithError("in update " . $standort_id, self::ERROR_TYPE_GENERAL); + + $result = $this->KontaktModel->update( + [ + 'kontakt_id' => $kontakt_id + ], + [ + 'person_id' => $person_id, + 'kontakttyp' => $kontakttyp, + 'anmerkung' => $anmerkung, + 'kontakt' => $kontakt, + 'zustellung' => $_POST['zustellung'], + 'insertvon' => $uid, + 'insertamum' => date('c'), + 'standort_id' => $standort_id, + 'ext_id' => $ext_id + ] + ); + + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->outputJsonSuccess(true); + } + + public function deleteContact($kontakt_id) + { + $this->load->model('person/Kontakt_model', 'KontaktModel'); + + $result = $this->KontaktModel->delete( + array('kontakt_id' => $kontakt_id) + ); + + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + elseif (!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(current(getData($result)) ? : null); + } + + public function getBankverbindung($person_id) + { + $this->load->model('person/Bankverbindung_model', 'BankverbindungModel'); + + $this->BankverbindungModel->addSelect('*'); + + $result = $this->BankverbindungModel->loadWhere( + array('person_id' => $person_id) + ); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess((getData($result) ?: [])); + } + + public function addNewBankverbindung($person_id) + { + $this->form_validation->set_rules('iban', 'IBAN', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'IBAN']) + ]); + + $this->form_validation->set_rules('typ', 'TYP', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'TYP']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $this->load->model('person/Bankverbindung_model', 'BankverbindungModel'); + + $ext_id = $this->input->post('ext_id'); + $oe_kurzbz = $this->input->post('oe_kurzbz'); + $orgform_kurzbz = $this->input->post('orgform_kurzbz'); + $name = $this->input->post('name'); + $anschrift = $this->input->post('anschrift'); + $bic = $this->input->post('bic'); + $blz = $this->input->post('blz'); + $kontonr = $this->input->post('kontonr'); + + $result = $this->BankverbindungModel->insert( + [ + 'person_id' => $person_id, + 'name' => $name, + 'anschrift' => $anschrift, + 'bic' => $bic, + 'iban' => $_POST['iban'], + 'blz' => $blz, + 'kontonr' => $kontonr, + 'insertvon' => 'uid', + 'insertamum' => date('c'), + 'typ' => $_POST['typ'], + 'verrechnung' => $_POST['verrechnung'], + 'ext_id' => $ext_id, + 'oe_kurzbz' => $oe_kurzbz, + 'orgform_kurzbz' => $orgform_kurzbz + ] + ); + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + return $this->outputJsonSuccess(true); + } + + public function loadBankverbindung($bankverbindung_id) + { + $this->load->model('person/Bankverbindung_model', 'BankverbindungModel'); + + $this->BankverbindungModel->addSelect('*'); + + $this->BankverbindungModel->addLimit(1); + + $result = $this->BankverbindungModel->loadWhere( + array('bankverbindung_id' => $bankverbindung_id) + ); + if (isError($result)) + { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + if (!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Bankverbindung_id']), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess(current(getData($result))); + } + + public function updateBankverbindung($bankverbindung_id) + { + $this->form_validation->set_rules('iban', 'IBAN', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'IBAN']) + ]); + + $this->form_validation->set_rules('typ', 'TYP', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'TYP']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $this->load->model('person/Bankverbindung_model', 'BankverbindungModel'); + + if(!$bankverbindung_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Bankverbindung_id']), self::ERROR_TYPE_GENERAL); + } + + $uid = getAuthUID(); + + $result = $this->BankverbindungModel->update( + [ + 'bankverbindung_id' => $bankverbindung_id + ], + [ + 'person_id' => $_POST['person_id'], + 'name' => $_POST['name'], + 'anschrift' => $_POST['anschrift'], + 'bic' => $_POST['bic'], + 'iban' => $_POST['iban'], + 'blz' => $_POST['blz'], + 'kontonr' => $_POST['kontonr'], + 'updatevon' => $uid, + 'updateamum' => date('c'), + 'typ' => $_POST['typ'], + 'verrechnung' => $_POST['verrechnung'], + 'ext_id' => $_POST['ext_id'], + 'oe_kurzbz' => $_POST['oe_kurzbz'], + 'orgform_kurzbz' => $_POST['orgform_kurzbz'] + ] + ); + + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->outputJsonSuccess(true); + } + + public function deleteBankverbindung($bankverbindung_id) + { + $this->load->model('person/Bankverbindung_model', 'BankverbindungModel'); + + $result = $this->BankverbindungModel->delete( + array('bankverbindung_id' => $bankverbindung_id) + ); + + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if (!hasData($result)) + { + $this->outputJson($result); + } + return $this->terminateWithSuccess(current(getData($result)) ? : null); + } + + public function validateLocationCombination() + { + $this->load->model('codex/Gemeinde_model', 'GemeindeModel'); + + return $this->GemeindeModel->checkLocation($_POST['plz'], $_POST['gemeinde'], $_POST['ort']); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Konto.php b/application/controllers/api/frontend/v1/stv/Konto.php new file mode 100644 index 000000000..ac36b5d8f --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Konto.php @@ -0,0 +1,495 @@ +. + */ + +if (!defined('BASEPATH')) exit('No direct script access allowed'); + +use CI3_Events as Events; + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about a Konto + * Listens to ajax post calls to change the Konto data + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Konto extends FHCAPI_Controller +{ + /** + * Calls the parent's constructor and prepares libraries and phrases + */ + public function __construct() + { + parent::__construct([ + 'get' => 'student/stammdaten:r', + 'getBuchungstypen' => self::PERM_LOGGED, + 'checkDoubles' => ['admin:r', 'assistenz:r'], + 'insert' => ['admin:w', 'assistenz:w'], + 'counter' => ['admin:w', 'assistenz:w'], + 'update' => ['admin:w', 'assistenz:w'], + 'delete' => ['admin:w', 'assistenz:w'] + ]); + + // Load models + $this->load->model('crm/Konto_model', 'KontoModel'); + + // Load language phrases + $this->loadPhrases([ + 'konto' + ]); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Get details for a prestudent + * + * @return void + */ + public function get() + { + $this->load->library('form_validation'); + + $person_id = $this->input->post('person_id'); + if (!$person_id || !is_array($person_id)) { + $this->form_validation->set_rules('person_id', 'Person ID', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + + $studiengang_kz = $this->input->post('studiengang_kz'); + + if ($this->input->post('only_open')) { + $result = $this->KontoModel->getOffeneBuchungen($person_id, $studiengang_kz); + } else { + $result = $this->KontoModel->getAlleBuchungen($person_id, $studiengang_kz); + } + + $result = $this->getDataOrTerminateWithError($result); + + // sort into tree + $childs = []; + $data = []; + foreach ($result as $entry) { + if ($entry->buchungsnr_verweis) { + if (isset($data[$entry->buchungsnr_verweis])) { + if (!isset($data[$entry->buchungsnr_verweis]->_children)) + $data[$entry->buchungsnr_verweis]->_children = []; + $data[$entry->buchungsnr_verweis]->_children[] = $entry; + } else { + if (!isset($childs[$entry->buchungsnr_verweis])) + $childs[$entry->buchungsnr_verweis] = []; + $childs[$entry->buchungsnr_verweis][] = $entry; + } + } else { + $data[$entry->buchungsnr] = $entry; + if (isset($childs[$entry->buchungsnr])) + $entry->_children = $childs[$entry->buchungsnr]; + } + } + + $this->terminateWithSuccess(array_values($data)); + } + + /** + * Get list of Buchungstypen + * + * @return void + */ + public function getBuchungstypen() + { + $this->load->model('crm/Buchungstyp_model', 'BuchungstypModel'); + + $result = $this->BuchungstypModel->load(); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * Check double Buchungen + * + * @return void + */ + public function checkDoubles() + { + if (!defined('FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK') || !FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK) + $this->terminateWithSuccess(false); + + $this->load->library('form_validation'); + + $person_ids = $this->input->post('person_id'); + + if (!$person_ids || !is_array($person_ids)) { + $person_ids = [$person_ids]; + $this->form_validation->set_rules('person_id', 'Person ID', 'required'); + } + $this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required'); + $this->form_validation->set_rules('buchungstyp_kurzbz', 'Buchungstyp', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + $buchungstypen = unserialize(FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK); + $buchung = $this->input->post('buchungstyp_kurzbz'); + + if (!isset($buchungstypen[$buchung])) + $this->terminateWithSuccess(false); + + $result = $this->KontoModel->checkDoubleBuchung($person_ids, $this->input->post('studiensemester_kurzbz'), $buchungstypen[$buchung]); + + $result = $this->getDataOrTerminateWithError($result); + + if (!$result) + $this->terminateWithSuccess(false); + + $persons = array_map(function ($row) { + return $row->nachname . ' ' . $row->vorname; + }, $result); + + $result = $this->p->t('konto', 'confirm_overwrite') . "\n"; + if (count($persons) > 10) { + $result .= "-" . implode("\n-", array_slice($persons, 0, 10)) . "\n"; + + if (count($persons) == 11) { + $result .= "\n" . $this->p->t('konto', 'confirm_overwrite_1_add_pers'); + } else { + $result .= "\n" . $this->p->t('konto', 'confirm_overwrite_x_add_pers', [ + 'x' => count($persons) - 10 + ]); + } + } else { + $result .= "-" . implode("\n-", $persons) . "\n"; + } + $result .= $this->p->t('konto', 'confirm_overwrite_proceed'); + + $this->addError($result, 'confirm'); + + $this->terminateWithSuccess(true); + } + + + /** + * Save Buchung + * + * @return void + */ + public function insert() + { + $this->load->library('form_validation'); + + $person_ids = $this->input->post('person_id'); + + if (!$person_ids || !is_array($person_ids)) { + $person_ids = [$person_ids]; + $this->form_validation->set_rules('person_id', 'Person ID', 'required'); + } + $this->form_validation->set_rules('betrag', 'Betrag', 'numeric'); + $this->form_validation->set_rules('buchungsdatum', 'Buchungsdatum', 'is_valid_date'); + $this->form_validation->set_rules('buchungstext', 'Buchungstext', 'max_length[256]'); + $this->form_validation->set_rules('mahnspanne', 'Mahnspanne', 'integer'); + $this->form_validation->set_rules('buchungstyp_kurzbz', 'Buchungstyp', 'required|max_length[32]'); + $this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required|max_length[16]'); + $this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required|has_permissions_for_stg[admin:rw,assistenz:rw]'); + $this->form_validation->set_rules('credit_points', 'Credit Points', 'numeric'); + + Events::trigger('konto_insert_validation', $this->form_validation); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + $allowed = [ + 'betrag', + 'buchungsdatum', + 'buchungstext', + 'mahnspanne', + 'buchungstyp_kurzbz', + 'studiensemester_kurzbz', + 'studiengang_kz', + 'credit_points', + 'anmerkung' + ]; + $data = [ + 'insertamum' => date('c'), + 'insertvon' => getAuthUID() + ]; + foreach ($allowed as $field) + if ($this->input->post($field) !== null) + $data[$field] = $this->input->post($field); + + if (defined('FAS_BUCHUNGSTYP_FIXE_KOSTENSTELLE') && isset(unserialize(FAS_BUCHUNGSTYP_FIXE_KOSTENSTELLE)[$data['buchungstyp_kurzbz']])) { + $data['kostenstelle'] = unserialize(FAS_BUCHUNGSTYP_FIXE_KOSTENSTELLE)[$data['buchungstyp_kurzbz']]; + } + + $result = []; + foreach ($person_ids as $person_id) { + $id = $this->KontoModel->insert(array_merge($data, ['person_id' => $person_id])); + if (isError($id)) { + $this->addError(getError($id), self::ERROR_TYPE_DB); + } else { + $kontodata = $this->KontoModel->withAdditionalInfo()->load(getData($id)); + if (isError($kontodata)) + $this->addError(getError($kontodata), self::ERROR_TYPE_DB); + else + $result[] = current(getData($kontodata)); + } + } + + if ($result) + $this->terminateWithSuccess($result); + + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + } + + /** + * Save Counter Buchung + * + * @return void + */ + public function counter() + { + $this->load->library('form_validation'); + + $buchungsnrs = $this->input->post('buchungsnr'); + + if (!$buchungsnrs || !is_array($buchungsnrs)) { + $buchungsnrs = $buchungsnrs ? [$buchungsnrs] : []; + $this->form_validation->set_rules('buchungsnr', 'Buchungsnr', 'required'); + } + $this->form_validation->set_rules('buchungsdatum', 'Buchungsdatum', 'is_valid_date'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $data = []; + $rules = []; + foreach ($buchungsnrs as $k => $buchungsnr) { + $result = $this->KontoModel->load($buchungsnr); + if (isError($result)) { + $rules[] = [ + 'field' => 'buchung[' . $k . ']', + 'label' => 'Buchung #' . $buchungsnr, + 'rules' => 'required', + 'errors' => [ + 'required' => getError($result) + ] + ]; + } elseif (!hasData($result)) { + $rules[] = [ + 'field' => 'buchung[' . $k . ']', + 'label' => 'Buchung #' . $buchungsnr, + 'rules' => 'required' + ]; + } else { + $data[$k] = get_object_vars(current(getData($result))); + $rules[] = [ + 'field' => 'buchung[' . $k . '][buchungsnr]', + 'label' => 'Buchung # ' . $buchungsnr, + 'rules' => 'required|numeric' + ]; + $rules[] = [ + 'field' => 'buchung[' . $k . '][studiengang_kz]', + 'label' => 'Buchung # ' . $buchungsnr, + 'rules' => 'required|has_permissions_for_stg[admin:rw,assistenz:rw]' + ]; + $rules[] = [ + 'field' => 'buchung[' . $k . '][buchungsnr_verweis]', + 'label' => 'Buchung # ' . $buchungsnr, + 'rules' => 'regex_match[/^$/]', + 'errors' => [ + 'regex_match' => $this->p->t('konto', 'error_counter_level') + ] + ]; + } + } + + $this->form_validation->reset_validation(); + $this->form_validation->set_data(['buchung' => $data]); + $this->form_validation->set_rules($rules); + + Events::trigger('konto_counter_validation', $this->form_validation); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $buchungsdatum = $this->input->post('buchungsdatum'); + + $newItems = []; + foreach ($data as $buchung) { + $result = $this->KontoModel->getDifferenz($buchung['buchungsnr']); + if (isError($result)) { + $this->addError(getError($result), self::ERROR_TYPE_GENERAL); + continue; + } + $betrag = $result->retval; + if ($betrag === null) { + $this->addError($this->p->t( + 'konto', + 'error_missing', + $buchung + ), self::ERROR_TYPE_GENERAL); + continue; + } + + + $result = $this->KontoModel->insert([ + 'person_id' => $buchung['person_id'], + 'studiengang_kz' => $buchung['studiengang_kz'], + 'studiensemester_kurzbz' => $buchung['studiensemester_kurzbz'], + 'buchungstext' => $buchung['buchungstext'], + 'buchungstyp_kurzbz' => $buchung['buchungstyp_kurzbz'], + 'credit_points' => $buchung['credit_points'], + 'zahlungsreferenz' => $buchung['zahlungsreferenz'], + 'betrag' => $betrag, + 'buchungsdatum' => $buchungsdatum, + 'mahnspanne' => '0', + 'buchungsnr_verweis' => $buchung['buchungsnr'], + 'insertamum' => date('c'), + 'insertvon' => getAuthUID(), + 'anmerkung' => '' + ]); + if (isError($result)) { + $this->addError(getError($result), self::ERROR_TYPE_GENERAL); + continue; + } + + $newItems = null; + // TODO(chris): get as tree? + /*$result = $this->KontoModel->withAdditionalInfo()->load($result->retval); + if (!hasData($result)) + $newItems = null; + elseif ($newItems !== null) + $newItems[] = current(getData($result));*/ + } + + $this->terminateWithSuccess($newItems); + } + + /** + * Save Buchung + * + * @return void + */ + public function update() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('buchungsnr', 'Buchungsnr', 'required'); + $this->form_validation->set_rules('betrag', 'Betrag', 'numeric'); + $this->form_validation->set_rules('buchungsdatum', 'Buchungsdatum', 'is_valid_date'); + $this->form_validation->set_rules('buchungstext', 'Buchungstext', 'max_length[256]'); + $this->form_validation->set_rules('mahnspanne', 'Mahnspanne', 'integer'); + $this->form_validation->set_rules('buchungstyp_kurzbz', 'Buchungstyp', 'required|max_length[32]'); + $this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required|max_length[16]'); + $this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required|has_permissions_for_stg[admin:rw,assistenz:rw]'); + $this->form_validation->set_rules('credit_points', 'Credit Points', 'numeric'); + + Events::trigger('konto_update_validation', $this->form_validation); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + $id = $this->input->post('buchungsnr'); + $allowed = [ + 'betrag', + 'buchungsdatum', + 'buchungstext', + 'mahnspanne', + 'buchungstyp_kurzbz', + 'studiensemester_kurzbz', + 'studiengang_kz', + 'credit_points', + 'anmerkung' + ]; + $data = [ + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ]; + foreach ($allowed as $field) + if ($this->input->post($field) !== null) + $data[$field] = $this->input->post($field); + + $result = $this->KontoModel->update($id, $data); + + $this->getDataOrTerminateWithError($result); + + $result = null; + // TODO(chris): get as tree? + /*$result = $this->KontoModel->withAdditionalInfo()->load($id); + + #$result = $this->getDataOrTerminateWithError($result); + if (isError($result)) + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + $result = $result->retval;*/ + + $this->terminateWithSuccess($result); + } + + /** + * Delete Buchung + * + * @return void + */ + public function delete() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('buchungsnr', 'Buchungsnr', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + $buchungsnr = $this->input->post('buchungsnr'); + + $result = $this->KontoModel->load($buchungsnr); + + $result = $this->getDataOrTerminateWithError($result); + + if (!$result) + $this->terminateWithError($this->p->t('konto', 'error_missing', [ + 'buchungsnr' => $buchungsnr + ])); + + $_POST['studiengang_kz'] = current($result)->studiengang_kz; + + $this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'has_permissions_for_stg[admin:rw,assistenz:rw]'); + + Events::trigger('konto_delete_validation', $this->form_validation); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + Events::trigger('konto_delete', $buchungsnr); + + $result = $this->KontoModel->delete($buchungsnr); + if (isError($result)) { + if (getCode($result) != 42) + $this->terminateWithError(getError($result)); + $this->terminateWithError($this->p->t('konto', 'error_delete_level')); + } + + $this->terminateWithSuccess(); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Lists.php b/application/controllers/api/frontend/v1/stv/Lists.php new file mode 100644 index 000000000..1c0c25db7 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Lists.php @@ -0,0 +1,147 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about generally used lists + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Lists extends FHCAPI_Controller +{ + public function __construct() + { + parent::__construct([ + 'getStudiensemester' => self::PERM_LOGGED, + 'getStgs' => self::PERM_LOGGED, + 'getSprachen' => self::PERM_LOGGED, + 'getGeschlechter' => self::PERM_LOGGED, + 'getAusbildungen' => self::PERM_LOGGED, + 'getOrgforms' => self::PERM_LOGGED, + 'getStati' => self::PERM_LOGGED + ]); + } + + public function getStudiensemester() + { + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->StudiensemesterModel->addOrder('ende'); + + $result = $this->StudiensemesterModel->load(); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getStgs() + { + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + + $this->StudiengangModel->addSelect('*'); + $this->StudiengangModel->addSelect('UPPER(typ || kurzbz) AS kuerzel'); + + $this->StudiengangModel->addOrder('typ'); + $this->StudiengangModel->addOrder('kurzbz'); + + $result = $this->StudiengangModel->load(); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getSprachen() + { + $this->load->model('system/Sprache_model', 'SpracheModel'); + + $this->SpracheModel->addOrder('sprache'); + + $result = $this->SpracheModel->load(); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getGeschlechter() + { + $this->load->model('person/Geschlecht_model', 'GeschlechtModel'); + + $this->GeschlechtModel->addOrder('sort'); + $this->GeschlechtModel->addOrder('geschlecht'); + + $this->GeschlechtModel->addSelect('*'); + #$this->GeschlechtModel->addTranslatedSelect("bezeichnung_mehrsprachig", "bezeichnung"); + $this->GeschlechtModel->addSelect("bezeichnung_mehrsprachig[(SELECT index FROM public.tbl_sprache WHERE sprache=" . $this->GeschlechtModel->escape(DEFAULT_LANGUAGE) . " LIMIT 1)] AS bezeichnung"); + + $result = $this->GeschlechtModel->load(); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getAusbildungen() + { + $this->load->model('codex/Ausbildung_model', 'AusbildungModel'); + + $this->AusbildungModel->addOrder('ausbildungcode'); + + $result = $this->AusbildungModel->load(); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getOrgforms() + { + $this->load->model('codex/Orgform_model', 'OrgformModel'); + + $this->OrgformModel->addOrder('bezeichnung'); + + $result = $this->OrgformModel->loadWhere(['rolle' => true]); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getStati() + { + $lang = getUserLanguage(); + $this->load->model('crm/Status_model', 'StatusModel'); + + $this->StatusModel->addSelect('*'); + #$this->StatusModel->addTranslatedSelect('bezeichnung_mehrsprachig', 'bezeichnung'); + $this->StatusModel->addSelect( + 'bezeichnung_mehrsprachig[( + SELECT index + FROM public.tbl_sprache + WHERE sprache=' . $this->StatusModel->escape($lang) . ' + LIMIT 1 + )] AS bezeichnung', + false + ); + #$this->StatusModel->addOrder('ext_id'); + + $result = $this->StatusModel->load(); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Notiz.php b/application/controllers/api/frontend/v1/stv/Notiz.php new file mode 100644 index 000000000..19e568f33 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Notiz.php @@ -0,0 +1,384 @@ + ['admin:r', 'assistenz:r'], + 'getNotizen' => ['admin:r', 'assistenz:r'], + 'loadNotiz' => ['admin:r', 'assistenz:r'], // TODO(manu): self::PERM_LOGGED + 'addNewNotiz' => ['admin:rw', 'assistenz:rw'], // TODO(manu): self::PERM_LOGGED + 'updateNotiz' => ['admin:rw', 'assistenz:rw'], // TODO(manu): self::PERM_LOGGED + 'deleteNotiz' => ['admin:r', 'assistenz:r'], + 'loadDokumente' => ['admin:r', 'assistenz:r'], + 'getMitarbeiter' => ['admin:r', 'assistenz:r'] + ]); + + //Load Models + $this->load->model('person/Notiz_model', 'NotizModel'); + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + } + +/* public function getUid() + { + $this->terminateWithSuccess(getAuthUID()); + }*/ + + + public function getNotizen($id, $type) + { + + //check if valid type + $result = $this->NotizzuordnungModel->isValidType($type); + if(isError($result)) + $this->terminateWithError($result->retval, self::ERROR_TYPE_GENERAL); + + //$this->terminateWithError(" after check type not valid", self::ERROR_TYPE_GENERAL); + $result = $this->NotizModel->getNotizWithDocEntries($id, $type); + + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + + // return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL); + + } + +/* public function loadNotiz() + { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + $notiz_id = $this->input->post('notiz_id'); + + //$this->load->model('person/Notiz_model', 'NotizModel'); + $this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT'); + $this->NotizModel->addSelect('*'); + $this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum + THEN public.tbl_notiz.updateamum ELSE public.tbl_notiz.insertamum END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate"); + $this->NotizModel->addLimit(1); + + $result = $this->NotizModel->loadWhere( + array('notiz_id' => $notiz_id) + ); + if (isError($result)) + { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + elseif (!hasData($result)) + { + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL); + } + else + { + $this->terminateWithSuccess(current(getData($result))); + } + } + + + public function updateNotiz() + { + $this->load->library('form_validation'); + $this->load->library('DmsLib'); + + if (isset($_POST['data'])) + { + $data = json_decode($_POST['data']); + unset($_POST['data']); + foreach ($data as $k => $v) { + $_POST[$k] = $v; + } + } + + $notiz_id = $this->input->post('notiz_id'); + + if(!$notiz_id) + { + $this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL); + } + + //Form Validation + $this->form_validation->set_rules('titel', 'Titel', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel']) + ]); + + $this->form_validation->set_rules('text', 'Text', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + //update Notiz + $uid = getAuthUID(); + $titel = $this->input->post('titel'); + $text = $this->input->post('text'); + $verfasser_uid = $this->input->post('verfasser'); + $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid; + $erledigt = $this->input->post('erledigt'); + $start = $this->input->post('start'); + $ende = $this->input->post('ende'); + + $result = $this->NotizModel->update( + [ + 'notiz_id' => $notiz_id + ], + [ + 'titel' => $titel, + 'updatevon' => $uid, + 'updateamum' => date('c'), + 'text' => $text, + 'verfasser_uid' => $verfasser_uid, + 'bearbeiter_uid' => $bearbeiter_uid, + 'start' => $start, + 'ende' => $ende, + 'erledigt' => $erledigt + ] + ); + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + //update(1) laden aller bereits mit dieser notiz_id verknüpften DMS-Einträge + $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); + $this->NotizdokumentModel->addJoin('campus.tbl_dms_version', 'dms_id'); + $dms_uploaded = null; + + $result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id)); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + elseif (!hasData($result)) + { + $dms_id_arr = null; + } + else + { + $result = getData($result); + foreach($result as $doc) { + $dms_id_arr[] = array( + 'name' => $doc->name, + 'dms_id' => $doc->dms_id + ); + } + } + + foreach ($_FILES as $k => $file) + { + //update(2) alle neuen files (alle außer type application/x.fhc-dms+json) anhängen + if($file["type"] == 'application/x.fhc-dms+json') + { + $dms_uploaded[] = array( + 'name' => $file["name"] + ); + } + else + { + $dms = array( + 'kategorie_kurzbz' => 'notiz', + 'version' => 0, + 'name' => $file["name"], + 'mimetype' => $file["type"], + 'insertamum' => date('c'), + 'insertvon' => $uid + ); + + //Todo(manu) check if filetypes weiter eingeschränkt werden sollen + //Todo(manu)check name files: nicht gleiches file 2mal hochladen + $result = $this->dmslib->upload($dms, $k, array('*')); + + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $dms_id = $result->retval['dms_id']; + + $result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id)); + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + } + } + + //update(3) check if Dateien gelöscht wurden + if(count($dms_uploaded) != count($dms_id_arr)) + { + if (count($dms_uploaded) == 0) + { + $filesDeleted = $dms_id_arr; + } + else + { + $upload_new_names = array_column($dms_uploaded, "name"); + + $filesDeleted = array_filter($dms_id_arr, function ($file) use ($upload_new_names) { + return !in_array($file["name"], $upload_new_names); + }); + } + + foreach ($filesDeleted as $file) + { + $result = $this->dmslib->removeAll($file['dms_id']); + + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + else + $this->outputJson($result); + } + } + return $this->terminateWithSuccess($result); + }*/ + + +/* public function deleteNotiz() + { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + $notiz_id = $this->input->post('notiz_id'); + $type = $this->input->post('type_id'); + $id = $this->input->post('id'); + + //dms_id auslesen aus notizdokument wenn vorhanden + $dms_id_arr = []; + $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); + + $result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id)); + + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + if(hasData($result)) + { + $result = getData($result); + foreach ($result as $doc) { + $dms_id_arr[] = $doc->dms_id; + } + } + + if($dms_id_arr) + { + $this->load->library('DmsLib'); + foreach($dms_id_arr as $dms_id) + { + $result = $this->dmslib->removeAll($dms_id); + + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + $this->outputJson($result); + } + } + + //delete Notizzuordnung + if($type == "software_id") + { + // Loads extension Model + $this->load->model('extensions/FHC-Core-Softwarebereitstellung/Softwarenotizzuordnung_model', 'ExtensionnotizzuordnungModel'); + $result = $this->ExtensionnotizzuordnungModel->delete([ + 'notiz_id' => $notiz_id, + 'id' => strval($id) + ], + [ + 'type_id' => $type + ]); + + } + else + { + //notizzuordnungsid! + $result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]); + } + + + $this->load->model('person/Notiz_model', 'NotizModel'); + //$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id'); + + //TODO (erweitern um Type_id) für Extensions, damit auch Notizzuordnung gelöscht werden kann + + //Löschen von Notiz + $result = $this->NotizModel->delete( + array('notiz_id' => $notiz_id) + ); + + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if(!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); + } + + return $this->terminateWithSuccess(current(getData($result))); + }*/ + +/* public function loadDokumente() + { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + $notiz_id = $this->input->post('notiz_id'); + + $this->NotizModel->addSelect('campus.tbl_dms_version.*'); + + $this->NotizModel->addJoin('public.tbl_notiz_dokument', 'ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)'); + $this->NotizModel->addJoin('campus.tbl_dms_version', 'ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)'); + + $result = $this->NotizModel->loadWhere( + array('public.tbl_notiz.notiz_id' => $notiz_id) + ); + if (isError($result)) { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + if(!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result)); + }*/ + +/* public function getMitarbeiter($searchString) + { + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); + $result = $this->MitarbeiterModel->searchMitarbeiter($searchString); + if (isError($result)) { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess($result); + }*/ + + public function isBerechtigt($id, $typeId) + { + if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) + { + $result = $this->p->t('lehre','error_keineSchreibrechte'); + + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + return success("berechtigt in überschreibender Funktion"); +/* return $this->terminateWithError('keine Berechtigung bro', self::ERROR_TYPE_GENERAL);*/ + } + +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/stv/Prestudent.php b/application/controllers/api/frontend/v1/stv/Prestudent.php new file mode 100644 index 000000000..ef9aeb111 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Prestudent.php @@ -0,0 +1,299 @@ + ['admin:r', 'assistenz:r'], + 'updatePrestudent' => ['admin:rw', 'assistenz:rw'], + 'getHistoryPrestudents' => ['admin:r', 'assistenz:r'], + 'getBezeichnungZGV' => ['admin:r', 'assistenz:r'], + 'getBezeichnungDZgv' => ['admin:r', 'assistenz:r'], + 'getBezeichnungMZgv' => ['admin:r', 'assistenz:r'], + 'getAusbildung' => ['admin:r', 'assistenz:r'], + 'getAufmerksamdurch' => ['admin:r', 'assistenz:r'], + 'getBerufstaetigkeit' => ['admin:r', 'assistenz:r'], + 'getTypenStg' => ['admin:r', 'assistenz:r'], + 'getStudienplaene' => ['admin:r', 'assistenz:r'], + 'getStudiengang' => ['admin:r', 'assistenz:r'] + ]); + + if ($this->router->method == 'updatePrestudent') { + $prestudent_id = current(array_slice($this->uri->rsegments, 2)); + $this->checkPermissionsForPrestudent($prestudent_id, ['admin:rw', 'assistenz:rw']); + } elseif ($this->router->method == 'get' + || $this->router->method == 'getStudienplaene' + || $this->router->method == 'getStudiengang' + ) { + $prestudent_id = current(array_slice($this->uri->rsegments, 2)); + $this->checkPermissionsForPrestudent($prestudent_id, ['admin:r', 'assistenz:r']); + } elseif ($this->router->method == 'getHistoryPrestudents') { + $person_id = current(array_slice($this->uri->rsegments, 2)); + $this->checkPermissionsForPerson($person_id, ['admin:r', 'assistenz:r'], ['admin:r', 'assistenz:r']); + } + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + // Load language phrases + $this->loadPhrases([ + 'ui', 'studierendenantrag', 'lehre' + ]); + } + + public function get($prestudent_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $this->PrestudentModel->addSelect('*'); + $result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]); + + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + if(!hasData($result)) + { + return show_404(); + } + $this->terminateWithSuccess(current(getData($result))); + } + + public function updatePrestudent($prestudent_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + // UDF + $this->load->library('UDFLib'); + + $result = $this->udflib->getCiValidations($this->PrestudentModel, $this->input->post()); + $udf_field_validations = $this->getDataOrTerminateWithError($result); + + //Form validation + $this->load->library('form_validation'); + + $this->form_validation->set_rules($udf_field_validations); + + $this->form_validation->set_rules('priorisierung', 'Priorisierung', 'numeric', [ + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Priorisierung']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $uid = getAuthUID(); + + $array_allowed_props_prestudent = [ + 'aufmerksamdurch_kurzbz', + 'studiengang_kz', + 'gsstudientyp_kurzbz', + 'person_id', + 'berufstaetigkeit_code', + 'ausbildungcode', + 'zgv_code', + 'zgvort', + 'zgvdatum', + 'zgvnation', + 'zgvmas_code', + 'zgvmaort', + 'zgvmadatum', + 'zgvmanation', + 'facheinschlberuf', + 'bismelden', + 'anmerkung', + 'dual', + 'zgvdoktor_code', + 'zgvdoktorort', + 'zgvdoktordatum', + 'zgvdoktornation', + 'aufnahmegruppe_kurzbz', + 'priorisierung', + 'foerderrelevant', + 'zgv_erfuellt', + 'zgvmas_erfuellt', + 'zgvdoktor_erfuellt', + 'mentor', + 'aufnahmeschluessel', + 'standort_code' + ]; + + // add UDFs + $result = $this->udflib->getDefinitionForModel($this->PrestudentModel); + + $definitions = $this->getDataOrTerminateWithError($result); + + foreach ($definitions as $def) + $array_allowed_props_prestudent[] = $def['name']; + + $update_prestudent = array(); + foreach ($array_allowed_props_prestudent as $prop) + { + $val = $this->input->post($prop); + if ($val !== null || $prop == 'foerderrelevant') { + $update_prestudent[$prop] = $val; + } + } + + $update_prestudent['updateamum'] = date('c'); + $update_prestudent['updatevon'] = $uid; + + if (count($update_prestudent)) + { + $result = $this->PrestudentModel->update( + $prestudent_id, + $update_prestudent + ); + $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess(true); + } + return $this->terminateWithSuccess(false); + } + + public function getHistoryPrestudents($person_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $result = $this->PrestudentModel->getHistoryPrestudents($person_id); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getBezeichnungZGV() + { + $this->load->model('codex/Zgv_model', 'ZgvModel'); + + $this->ZgvModel->addOrder('zgv_code'); + + $result = $this->ZgvModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getBezeichnungDZgv() + { + $this->load->model('codex/Zgvdoktor_model', 'ZgvdoktorModel'); + + $this->ZgvdoktorModel->addOrder('zgvdoktor_code'); + + $result = $this->ZgvdoktorModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getBezeichnungMZgv() + { + $this->load->model('codex/Zgvmaster_model', 'ZgvmasterModel'); + + $this->ZgvmasterModel->addOrder('zgvmas_code'); + + $result = $this->ZgvmasterModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getAusbildung() + { + $this->load->model('codex/Ausbildung_model', 'AusbildungModel'); + + $this->AusbildungModel->addOrder('ausbildungcode'); + + $result = $this->AusbildungModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getAufmerksamdurch() + { + $this->load->model('codex/Aufmerksamdurch_model', 'AufmerksamdurchModel'); + + $this->AufmerksamdurchModel->addOrder('aufmerksamdurch_kurzbz'); + + $result = $this->AufmerksamdurchModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getBerufstaetigkeit() + { + $this->load->model('codex/Berufstaetigkeit_model', 'BerufstaetigkeitModel'); + + $this->BerufstaetigkeitModel->addOrder('berufstaetigkeit_code'); + + $result = $this->BerufstaetigkeitModel->load(); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getTypenStg() + { + $this->load->model('education/Gsstudientyp_model', 'GsstudientypModel'); + + $this->GsstudientypModel->addOrder('gsstudientyp_kurzbz'); + + $result = $this->GsstudientypModel->load(); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getStudienplaene($prestudent_id) + { + $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + $result = $this->StudienplanModel->getStudienplaeneByPrestudents($prestudent_id); + + $data = $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($data); + } + + /** + * Gets details for the Studiengang of the Prestudent + * + * @param integer $prestudent_id + * + * @return stdClass + */ + public function getStudiengang($prestudent_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $this->PrestudentModel->addSelect('stg.*'); + + $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz'); + + $result = $this->PrestudentModel->load($prestudent_id); + + $stg = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($stg)); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Status.php b/application/controllers/api/frontend/v1/stv/Status.php new file mode 100644 index 000000000..074f4029e --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Status.php @@ -0,0 +1,1753 @@ + ['admin:r', 'assistenz:r'], + 'getMaxSemester' => ['admin:r', 'assistenz:r'], + 'changeStatus' => ['admin:rw', 'assistenz:rw'], + 'addStudent' => ['admin:rw', 'assistenz:rw'], + 'getStatusgruende' => self::PERM_LOGGED, + 'getLastBismeldestichtag' => self::PERM_LOGGED, + 'isLastStatus' => self::PERM_LOGGED, + 'getStatusarray' => self::PERM_LOGGED, + 'deleteStatus' => ['admin:rw','assistenz:rw'], + 'loadStatus' => ['admin:r', 'assistenz:r'], + 'insertStatus' => ['admin:rw', 'assistenz:rw'], + 'updateStatus' => ['admin:rw', 'assistenz:rw'], + 'advanceStatus' => ['admin:rw', 'assistenz:rw'], + 'confirmStatus' => ['admin:rw', 'assistenz:rw'], + + ]); + + //Load Models + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + $this->load->model('person/Person_model', 'PersonModel'); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('PrestudentstatusCheckLib'); + + // Additional Permission Checks + if ($this->router->method == 'insertStatus' + || $this->router->method == 'updateStatus' + || $this->router->method == 'confirmStatus' + || $this->router->method == 'deleteStatus' + || $this->router->method == 'advanceStatus' + || $this->router->method == 'changeStatus' + || $this->router->method == 'addStudent' + ) { + $prestudent_id = current(array_slice($this->uri->rsegments, 2)); + $this->checkPermissionsForPrestudent($prestudent_id, ['admin:rw', 'assistenz:rw']); + } + + // Load language phrases + $this->loadPhrases([ + 'global', 'ui', 'bismeldestichtag','lehre','studierendenantrag' + ]); + } + + public function getHistoryPrestudent($prestudent_id) + { + $result = $this->PrestudentstatusModel->getHistoryPrestudent($prestudent_id); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * Gets the maximum possible semester for one or more Studiengaenge. + * If there are more than one Studiengang each maximum is calculated and + * the smallest result is returned. + * + * @return void + */ + public function getMaxSemester() + { + $studiengang_kzs = $this->input->post('studiengang_kzs'); + + if (!$studiengang_kzs || !is_array($studiengang_kzs)) { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('studiengang_kzs', '', 'required|is_null', [ + 'is_null' => $this->p->t('ui', 'error_fieldMustBeArray') + ]); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + + if (defined('VORRUECKUNG_STATUS_MAX_SEMESTER') && VORRUECKUNG_STATUS_MAX_SEMESTER == false) + $this->terminateWithSuccess(100); + + $this->load->model('organisation/Lehrverband_model', 'LehrverbandModel'); + + $result = $this->LehrverbandModel->getMaxSemester($studiengang_kzs); + + $maxsem = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($maxsem ? current($maxsem)->maxsem : 10); + } + + public function getStatusgruende() + { + $this->load->model('crm/Statusgrund_model', 'StatusgrundModel'); + + $result = $this->StatusgrundModel->getAktiveGruende(); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getLastBismeldestichtag() + { + $this->load->model('codex/Bismeldestichtag_model', 'BismeldestichtagModel'); + + $result = $this->BismeldestichtagModel->getLastReachedMeldestichtag(); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function isLastStatus($prestudent_id) + { + $result = $this->PrestudentstatusModel->checkIfLastStatusEntry($prestudent_id); + + $result = $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($result); + } + + public function getStudiensemesterOfStatus($prestudent_id, $status) + { + $result = $this->PrestudentstatusModel->loadWhere([ + "prestudent_id" => $prestudent_id, + "status_kurzbz" => $status + ]); + $this->PrestudentstatusModel->addLimit(1); + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + $studiensem = current(getData($result)); + + return $studiensem->studiensemester_kurzbz; + } + + public function getStatusarray() + { + $this->load->model('crm/Status_model', 'StatusModel'); + $result = $this->StatusModel->getAllStatiWithStatusgruende(); + + if(isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * Changes the status of a prestudent with full additional logic. + * + * @param integer $prestudent_id + * + * @return stdClass + */ + public function changeStatus($prestudent_id) + { + $isBerechtigtNoStudstatusCheck = $this->permissionlib->isBerechtigt('student/keine_studstatuspruefung'); + + //GET lastStatus + $result = $this->PrestudentstatusModel->getLastStatus($prestudent_id); + + $lastStatusData = $this->getDataOrTerminateWithError($result); + $lastStatusData = current($lastStatusData); + + $this->load->model('person/Person_model', 'PersonModel'); + $this->PersonModel->addJoin('public.tbl_prestudent', 'person_id'); + $result = $this->PersonModel->loadWhere(['prestudent_id' => $prestudent_id]); + $prestudent_person = $this->getDataOrTerminateWithError($result); + $prestudent_person = current($prestudent_person); + + $studentName = trim($prestudent_person->vorname . ' ' . $prestudent_person->nachname); + + $status_kurzbz = $this->input->post('status_kurzbz'); + + $studiensemester_kurzbz = $lastStatusData->studiensemester_kurzbz; + if ($status_kurzbz == Prestudentstatus_model::STATUS_ABSOLVENT + || $status_kurzbz == Prestudentstatus_model::STATUS_DIPLOMAND + ) { + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); + } + + $ausbildungssemester = $lastStatusData->ausbildungssemester; + if ($status_kurzbz == Prestudentstatus_model::STATUS_STUDENT) { + $ausbildungssemester = $this->input->post('ausbildungssemester'); + } + + $statusgrund_id = $this->input->post('statusgrund_id'); + $datum_string = date('c'); + $datum = new DateTime($datum_string); + + //Form Validation + $this->load->library('form_validation'); + + $this->form_validation->set_rules( + 'status_kurzbz', + $this->p->t('global', 'status'), + [ + 'required', + //Check Reihungstest + ['reihungstest_check', function ($value) use ($prestudent_person) { + if (!REIHUNGSTEST_CHECK) + return true; + if ($value != Prestudentstatus_model::STATUS_BEWERBER) + return true; + $result = $this->prestudentstatuschecklib->checkIfAngetreten($prestudent_person); + return $this->getDataOrTerminateWithError($result); + }], + //Check ZGV + ['checkIfZGV', function ($value) use ($prestudent_person) { + if (defined("ZGV_CHECK") && !ZGV_CHECK) + return true; + if ($value != Prestudentstatus_model::STATUS_BEWERBER) + return true; + $result = $this->prestudentstatuschecklib->checkIfZGVEingetragen($prestudent_person); + return $this->getDataOrTerminateWithError($result); + }], + //Check ZGV Master + ['checkIfZGVMaster', function ($value) use ($prestudent_person) { + if (defined("ZGV_CHECK") && !ZGV_CHECK) + return true; + if ($value != Prestudentstatus_model::STATUS_BEWERBER) + return true; + $result = $this->prestudentstatuschecklib->checkIfZGVEingetragenMaster($prestudent_person); + return $this->getDataOrTerminateWithError($result); + }], + //Check Bewerberstatus + ['checkIfExistingBewerberstatus', function ($value) use ($prestudent_id) { + if ($value != Prestudentstatus_model::STATUS_AUFGENOMMENER + && $value != Prestudentstatus_model::STATUS_WARTENDER + ) + return true; + $result = $this->prestudentstatuschecklib->checkIfExistingBewerberstatus($prestudent_id); + return $this->getDataOrTerminateWithError($result); + }], + //Check If Student + ['status_stud_exists', function ($value) use ($prestudent_id) { + if ($value != Prestudentstatus_model::STATUS_STUDENT + && $value != Prestudentstatus_model::STATUS_ABBRECHER + ) + return true; // Only test if new status is Student + + $result = $this->prestudentstatuschecklib->checkIfExistingStudent($prestudent_id); + + return $this->getDataOrTerminateWithError($result); + }], + ], + [ + 'reihungstest_check' => $this->p->t('lehre', 'error_keinReihungstestverfahren', ['name' => $studentName]), + 'checkIfExistingBewerberstatus' => $this->p->t('lehre', 'error_keinBewerber', ['name' => $studentName]), + 'checkIfZGV' => $this->p->t('lehre', 'error_ZGVNichtEingetragen', ['name' => $studentName]), + 'checkIfZGVMaster' => $this->p->t('lehre', 'error_ZGVMasterNichtEingetragen', ['name' => $studentName]), + 'status_stud_exists' => $this->p->t('lehre', 'error_noStudstatus') + ] + ); + + if ($status_kurzbz == Prestudentstatus_model::STATUS_STUDENT) + $this->form_validation->set_rules('ausbildungssemester', $this->p->t('lehre', 'ausbildungssemester'), 'required|integer', [ + 'integer' => $this->p->t('ui', 'error_fieldNotInteger') + ]); + else + $this->form_validation->set_rules('ausbildungssemester', $this->p->t('lehre', 'ausbildungssemester'), 'integer', [ + 'integer' => $this->p->t('ui', 'error_fieldNotInteger') + ]); + + $this->form_validation->set_rules('statusgrund_id', $this->p->t('international', 'grund'), 'integer', [ + 'integer' => $this->p->t('ui', 'error_fieldNotInteger') + ]); + + $this->form_validation->set_rules('_default', '', [ + ['meldestichtag_not_exceeded', function () use ($datum, $isBerechtigtNoStudstatusCheck) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + + $result = $this->prestudentstatuschecklib->checkIfMeldestichtagErreicht($datum); + + return !$this->getDataOrTerminateWithError($result); + }], + //Check if Rolle already exists + ['rolle_doesnt_exist', function () use ($prestudent_id, $status_kurzbz, $studiensemester_kurzbz, $ausbildungssemester) { + if (!$status_kurzbz || !$studiensemester_kurzbz || !$ausbildungssemester) + return true; // Error will be handled by the required statements above + + $result = $this->PrestudentstatusModel->load([$ausbildungssemester, $studiensemester_kurzbz, $status_kurzbz, $prestudent_id]); + + return !$this->getDataOrTerminateWithError($result); + }], + ['history_timesequence', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$status_kurzbz) + return true; // Error will be handled by the required statement above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryTimesequence( + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester, + '', + '' + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_laststatus', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$status_kurzbz) + return true; // Error will be handled by the required statement above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryLaststatus( + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester, + '', + '' + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_unterbrecher', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$status_kurzbz) + return true; // Error will be handled by the required statement above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryUnterbrechersemester( + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester, + '', + '' + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_abbrecher', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$status_kurzbz) + return true; // Error will be handled by the required statement above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryAbbrechersemester( + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester, + '', + '' + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_diplomant', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$status_kurzbz) + return true; // Error will be handled by the required statement above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryDiplomant( + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester, + '', + '' + ); + + return $this->getDataOrTerminateWithError($result); + }] + ], [ + 'meldestichtag_not_exceeded' => $this->p->t('lehre', 'error_dataVorMeldestichtag'), + 'rolle_doesnt_exist' => $this->p->t('lehre', 'error_rolleBereitsVorhandenMitNamen', ['name' => $studentName]), + 'history_timesequence' => $this->p->t('lehre', 'error_statuseintrag_zeitabfolge'), + 'history_laststatus' => $this->p->t('lehre', 'error_endstatus'), + 'history_unterbrecher' => $this->p->t('lehre', 'error_consecutiveUnterbrecher'), + 'history_abbrecher' => $this->p->t('lehre', 'error_consecutiveUnterbrecherAbbrecher'), + 'history_diplomant' => $this->p->t('lehre', 'error_consecutiveDiplomandStudent') + ]); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + $this->load->library('PrestudentLib'); + + $this->db->trans_start(); + + switch($status_kurzbz){ + case Prestudentstatus_model::STATUS_ABBRECHER: + $result = $this->prestudentlib->setAbbrecher( + $prestudent_id, + $studiensemester_kurzbz, + null, + $statusgrund_id, + $datum_string, + null, + null + ); + break; + case Prestudentstatus_model::STATUS_UNTERBRECHER: + $result = $this->prestudentlib->setUnterbrecher( + $prestudent_id, + $studiensemester_kurzbz, + null, + null, + $ausbildungssemester, + $statusgrund_id + ); + break; + case Prestudentstatus_model::STATUS_STUDENT: + $result = $this->prestudentlib->setStudent( + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + break; + case Prestudentstatus_model::STATUS_DIPLOMAND: + $result = $this->prestudentlib->setDiplomand( + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + break; + case Prestudentstatus_model::STATUS_ABSOLVENT: + $result = $this->prestudentlib->setAbsolvent( + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + break; + case Prestudentstatus_model::STATUS_BEWERBER: + $result = $this->prestudentlib->setBewerber( + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + break; + case Prestudentstatus_model::STATUS_AUFGENOMMENER: + $result = $this->prestudentlib->setAufgenommener( + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + break; + case Prestudentstatus_model::STATUS_ABGEWIESENER: + $result = $this->prestudentlib->setAbgewiesener( + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + break; + case Prestudentstatus_model::STATUS_WARTENDER: + $result = $this->prestudentlib->setWartender( + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + break; + default: + $this->terminateWithError("Action not yet defined in Prestudentlib", self::ERROR_TYPE_GENERAL); + } + + $this->getDataOrTerminateWithError($result); + + $this->db->trans_complete(); + + $this->terminateWithSuccess($prestudent_id); + } + + public function addStudent($prestudent_id) + { + // Prepare lastAufgenommener Status + $this->PrestudentstatusModel->addOrder('datum', 'DESC'); + $this->PrestudentstatusModel->addOrder('insertamum', 'DESC'); + $this->PrestudentstatusModel->addLimit(1); + $result = $this->PrestudentstatusModel->loadWhere([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => Prestudentstatus_model::STATUS_AUFGENOMMENER + ]); + $lastAufgenommener = $this->getDataOrTerminateWithError($result); + + if ($lastAufgenommener) + $lastAufgenommener = current($lastAufgenommener); + + //get studentname for validations + $this->load->model('person/Person_model', 'PersonModel'); + $this->PersonModel->addJoin('public.tbl_prestudent', 'person_id'); + $result = $this->PersonModel->loadWhere(['prestudent_id' => $prestudent_id]); + $prestudent_person = $this->getDataOrTerminateWithError($result); + $prestudent_person = current($prestudent_person); + + $studentName = trim($prestudent_person->vorname . ' ' . $prestudent_person->nachname); + + + //Form Validation + $this->load->library('form_validation'); + + $this->form_validation->set_rules('statusgrund_id', $this->p->t('international', 'grund'), 'integer', [ + 'integer' => $this->p->t('ui', 'error_fieldNotInteger') + ]); + + $this->form_validation->set_rules('_default', '', [ + //Check ZGV + ['checkIfZGV', function () use ($prestudent_person) { + if (defined("ZGV_CHECK") && !ZGV_CHECK) + return true; + $result = $this->prestudentstatuschecklib->checkIfZGVEingetragen($prestudent_person); + return $this->getDataOrTerminateWithError($result); + }], + //Check ZGV Master + ['checkIfZGVMaster', function () use ($prestudent_person) { + if (defined("ZGV_CHECK") && !ZGV_CHECK) + return true; + $result = $this->prestudentstatuschecklib->checkIfZGVEingetragenMaster($prestudent_person); + return $this->getDataOrTerminateWithError($result); + }], + //Check Bewerberstatus + ['checkIfExistingBewerberstatus', function () use ($prestudent_id) { + $result = $this->prestudentstatuschecklib->checkIfExistingBewerberstatus($prestudent_id); + return $this->getDataOrTerminateWithError($result); + }], + //Check Aufgenommenerstatus + ['checkIfExistingAufgenommenerstatus', function () use ($lastAufgenommener) { + return !!$lastAufgenommener; + }], + //Check Bewerberstatus & Aufgenommenerstatus semester + ['checkIfLastBewerberAndAufgenommenerShareSemesters', function () use ($prestudent_id) { + $result = $this->prestudentstatuschecklib->checkIfLastBewerberAndAufgenommenerShareSemesters($prestudent_id); + return $this->getDataOrTerminateWithError($result); + }], + //Check If FirstStudent + ['check_isFirstStudStatus', function () use ($prestudent_id) { + $result = $this->prestudentstatuschecklib->checkIfExistingStudent($prestudent_id); + + return !$this->getDataOrTerminateWithError($result); + }], + //Check if Rolle already exists + ['rolle_doesnt_exist', function () use ($prestudent_id, $lastAufgenommener) { + if (!$lastAufgenommener) + return true; // Error will be handled by the checkIfExistingAufgenommenerstatus statement above + + $result = $this->PrestudentstatusModel->loadWhere([ + 'studiensemester_kurzbz' => $lastAufgenommener->studiensemester_kurzbz, + 'status_kurzbz' => Prestudentstatus_model::STATUS_STUDENT, + 'prestudent_id' => $prestudent_id + ]); + + return !$this->getDataOrTerminateWithError($result); + }] + ], [ + 'reihungstest_check' => $this->p->t('lehre', 'error_keinReihungstestverfahren', ['name' => $studentName]), + 'checkIfExistingBewerberstatus' => $this->p->t('lehre', 'error_keinBewerber', ['name' => $studentName]), + 'checkIfExistingAufgenommenerstatus' => $this->p->t('lehre', 'error_keinAufgenommener', ['name' => $studentName]), + 'checkIfLastBewerberAndAufgenommenerShareSemesters' => $this->p->t('lehre', 'error_lastBewerberAndAufgenommenerSemesters'), + 'checkIfZGV' => $this->p->t('lehre', 'error_ZGVNichtEingetragen', ['name' => $studentName]), + 'checkIfZGVMaster' => $this->p->t('lehre', 'error_ZGVMasterNichtEingetragen', ['name' => $studentName]), + 'check_isFirstStudStatus' => $this->p->t('lehre', 'error_personBereitsStudent', ['name' => $studentName]), + 'rolle_doesnt_exist' => $this->p->t('lehre', 'error_rolleBereitsVorhandenMitNamen', ['name' => $studentName]) + ]); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + // Start DB transaction + $this->db->trans_start(); + + $this->load->library('PrestudentLib'); + + $this->prestudentlib->setFirstStudent( + $prestudent_id, + $lastAufgenommener->studiensemester_kurzbz, + $lastAufgenommener->ausbildungssemester, + $lastAufgenommener->orgform_kurzbz, + $lastAufgenommener->studienplan_id, + $this->input->post('statusgrund_id') + ); + + $this->getDataOrTerminateWithError($result); + + $this->db->trans_commit(); + + return $this->outputJsonSuccess(true); + } + + public function loadStatus() + { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + $prestudent_id = $this->input->post('prestudent_id'); + $status_kurzbz = $this->input->post('status_kurzbz'); + $ausbildungssemester = $this->input->post('ausbildungssemester'); + $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); + + $result = $this->PrestudentstatusModel->loadWhere( + array( + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz, + 'ausbildungssemester' => $ausbildungssemester, + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ) + ); + if (isError($result)) + { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + elseif (!hasData($result)) + { + $this->terminateWithError($this->p->t('lehre', 'error_noStatusFound'), self::ERROR_TYPE_GENERAL); + } + else + { + $this->terminateWithSuccess(current(getData($result))); + } + } + + /** + * Delete a status entry + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param string $studiensemester_kurzbz + * @param integer $ausbildungssemester + * + * @return void + */ + public function deleteStatus($prestudent_id, $status_kurzbz, $studiensemester_kurzbz, $ausbildungssemester) + { + $result = $this->PrestudentstatusModel->load([ + $ausbildungssemester, + $studiensemester_kurzbz, + $status_kurzbz, + $prestudent_id + ]); + $oldstatus = $this->getDataOrTerminateWithError($result); + if (!$oldstatus) + show_404(); // Status that should be updated does not exist + + $oldstatus = current($oldstatus); + + + $erweiterteBerechtigung = + $this->permissionlib->isBerechtigt('admin', null, 'suid') + || $this->permissionlib->isBerechtigt('student/keine_studstatuspruefung', null, 'suid'); + + + //check if last status + $result = $this->PrestudentstatusModel->checkIfLastStatusEntry($prestudent_id); + + $result = $this->getDataOrTerminateWithError($result); + + $deletePrestudent = $result; + + + //Berechtigungen nach Check prüfen! + if (!$erweiterteBerechtigung) { + if ($status_kurzbz == Prestudentstatus_model::STATUS_STUDENT) + $this->terminateWithError( + $this->p->t('lehre', 'error_onlyAdminDeleteRolleStudent'), + self::ERROR_TYPE_GENERAL, + REST_Controller::HTTP_FORBIDDEN + ); + + if ($deletePrestudent) + $this->terminateWithError( + $this->p->t('lehre', 'error_onlyAdminDeleteLastStatus'), + self::ERROR_TYPE_GENERAL, + REST_Controller::HTTP_FORBIDDEN + ); + + $result = $this->prestudentstatuschecklib->checkIfMeldestichtagErreicht($oldstatus->datum); + + if (!$this->getDataOrTerminateWithError($result)) + $this->terminateWithError( + $this->p->t('lehre', 'error_dataVorMeldestichtag'), + self::ERROR_TYPE_GENERAL, + REST_Controller::HTTP_FORBIDDEN + ); + } + + // Start DB transaction + $this->db->trans_begin(); + + //Delete Status + $result = $this->PrestudentstatusModel->delete( + [ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz, + 'ausbildungssemester' => $ausbildungssemester, + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ] + ); + + $this->getDataOrTerminateWithError($result); + + //Delete Studentlehrverband if no Status left in this semester + $result = $this->PrestudentstatusModel->checkIfLastStatusEntry($prestudent_id, $studiensemester_kurzbz); + + $result = $this->getDataOrTerminateWithError($result); + if ($result) + { + //get student_uid + $this->load->model('crm/Student_model', 'StudentModel'); + $result = $this->StudentModel->loadWhere([ + 'prestudent_id' => $prestudent_id + ]); + + $student = $this->getDataOrTerminateWithError($result); + if ($student) + { + $student = current($student); + $this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel'); + $result = $this->StudentlehrverbandModel->delete( + array( + 'student_uid' => $student->student_uid, + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ) + ); + + $this->getDataOrTerminateWithError($result); + } + } + + //Delete Prestudent if no data is left + if ($deletePrestudent) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $result = $this->PrestudentModel->delete($prestudent_id); + + $this->getDataOrTerminateWithError($result); + } + + $this->db->trans_commit(); + + return $this->terminateWithSuccess(true); + } + + /** + * Inserts a status with less validations and extra logic for manual + * manipulation + * + * @param integer $prestudent_id + * + * @return void + */ + public function insertStatus($prestudent_id) + { + $isBerechtigtNoStudstatusCheck = $this->permissionlib->isBerechtigt('student/keine_studstatuspruefung'); + $isBerechtigtBasisPrestudentstatus = $this->permissionlib->isBerechtigt('basis/prestudentstatus'); + + + $authUID = getAuthUID(); + $status_kurzbz = $this->input->post('status_kurzbz'); + $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); + $ausbildungssemester = $this->input->post('ausbildungssemester'); + $datum = $this->input->post('datum'); + $bestaetigtam = $this->input->post('bestaetigtam'); + $orgform_kurzbz = $this->input->post('orgform_kurzbz'); + $anmerkung = $this->input->post('anmerkung'); + $bewerbung_abgeschicktamum = $this->input->post('bewerbung_abgeschicktamum'); + $studienplan_id = $this->input->post('studienplan_id'); + $rt_stufe = $this->input->post('rt_stufe'); + $statusgrund_id = $this->input->post('statusgrund_id'); + + + $this->load->library('form_validation'); + + $this->form_validation->set_rules('statusgrund_id', $this->p->t('international', 'grund'), 'integer', [ + 'integer' => $this->p->t('ui', 'error_fieldNotInteger') + ]); + + if (!$isBerechtigtBasisPrestudentstatus) + $this->form_validation->set_rules( + 'bewerbung_abgeschicktamum', + $this->p->t('lehre', 'bewerbung_abgeschickt_am'), + 'is_null', + [ + 'is_null' => $this->p->t('ui', 'error_fieldWriteAccess') + ] + ); + + $this->form_validation->set_rules( + 'datum', + $this->p->t('global', 'datum'), + [ + 'required', // In FAS empty datum results in todays + 'is_valid_date', + ['is_date_not_before_today', function ($value) { + if (!is_valid_date($value)) + return true; // Error will be handled by the is_valid_date statement above + $today = new DateTime('today'); + return (new DateTime($value) >= $today); + }], + ['meldestichtag_not_exceeded', function ($value) use ($isBerechtigtNoStudstatusCheck) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$value) + return true; // Error will be handled by the required statement above + + $result = $this->prestudentstatuschecklib->checkIfMeldestichtagErreicht($value); + + return !$this->getDataOrTerminateWithError($result); + }] + ], + [ + 'meldestichtag_not_exceeded' => $this->p->t('lehre', 'error_dataVorMeldestichtag'), + 'is_date_not_before_today' => $this->p->t('lehre', 'error_entryInPast') + ] + ); + + $this->form_validation->set_rules( + 'status_kurzbz', + $this->p->t('lehre', 'status_rolle'), + [ + 'required', + ['status_stud_exists', function ($value) use ($prestudent_id) { + if ($value != Prestudentstatus_model::STATUS_STUDENT) + return true; // Only test if new status is Student + + $result = $this->prestudentstatuschecklib->checkIfExistingStudent($prestudent_id); + + return $this->getDataOrTerminateWithError($result); + }] + ], + [ + 'status_stud_exists' => $this->p->t('lehre', 'error_noStudstatus') + ] + ); + + $this->form_validation->set_rules('studiensemester_kurzbz', $this->p->t('lehre', 'studiensemester'), 'required'); + + $this->form_validation->set_rules('ausbildungssemester', $this->p->t('lehre', 'ausbildungssemester'), 'required'); + + $this->form_validation->set_rules('bestaetigtam', $this->p->t('lehre', 'bestaetigt_am'), 'is_valid_date'); + + // Set Datum to null to prevent multiple is_valid_date checks in the following validation rules + if (!$datum || !is_valid_date($datum)) + $datum = null; + + $this->form_validation->set_rules('_default', '', [ + ['rolle_doesnt_exist', function () use ($prestudent_id, $status_kurzbz, $studiensemester_kurzbz, $ausbildungssemester) { + if (!$status_kurzbz || !$studiensemester_kurzbz || !$ausbildungssemester) + return true; // Error will be handled by the required statements above + + $result = $this->PrestudentstatusModel->load([$ausbildungssemester, $studiensemester_kurzbz, $status_kurzbz, $prestudent_id]); + + return !$this->getDataOrTerminateWithError($result); + }], + ['history_timesequence', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !$ausbildungssemester) + return true; // Error will be handled by the required statements above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryTimesequence( + $prestudent_id, + $status_kurzbz, + new DateTime($datum), + $studiensemester_kurzbz, + $ausbildungssemester, + '', + '' + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_laststatus', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !$ausbildungssemester) + return true; // Error will be handled by the required statements above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryLaststatus( + $prestudent_id, + $status_kurzbz, + new DateTime($datum), + $studiensemester_kurzbz, + $ausbildungssemester, + '', + '' + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_unterbrecher', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !$ausbildungssemester) + return true; // Error will be handled by the required statements above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryUnterbrechersemester( + $prestudent_id, + $status_kurzbz, + new DateTime($datum), + $studiensemester_kurzbz, + $ausbildungssemester, + '', + '' + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_abbrecher', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !$ausbildungssemester) + return true; // Error will be handled by the required statements above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryAbbrechersemester( + $prestudent_id, + $status_kurzbz, + new DateTime($datum), + $studiensemester_kurzbz, + $ausbildungssemester, + '', + '' + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_diplomant', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !$ausbildungssemester) + return true; // Error will be handled by the required statements above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryDiplomant( + $prestudent_id, + $status_kurzbz, + new DateTime($datum), + $studiensemester_kurzbz, + $ausbildungssemester, + '', + '' + ); + + return $this->getDataOrTerminateWithError($result); + }] + ], [ + 'rolle_doesnt_exist' => $this->p->t('lehre', 'error_rolleBereitsVorhanden'), + 'history_timesequence' => $this->p->t('lehre', 'error_statuseintrag_zeitabfolge'), + 'history_laststatus' => $this->p->t('lehre', 'error_endstatus'), + 'history_unterbrecher' => $this->p->t('lehre', 'error_consecutiveUnterbrecher'), + 'history_abbrecher' => $this->p->t('lehre', 'error_consecutiveUnterbrecherAbbrecher'), + 'history_diplomant' => $this->p->t('lehre', 'error_consecutiveDiplomandStudent') + ]); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + // Start DB transaction + $this->db->trans_start(); + + $this->updateLehrverbandForInsertAndUpdate($prestudent_id, $status_kurzbz, $studiensemester_kurzbz, $ausbildungssemester, $authUID); + + //insert status + $result = $this->PrestudentstatusModel->insert([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'ausbildungssemester' => $ausbildungssemester, + 'datum' => $datum, + 'insertamum' => date('c'), + 'insertvon' => $authUID, + 'orgform_kurzbz' => $orgform_kurzbz, + 'bestaetigtam' => $bestaetigtam, + 'bestaetigtvon' => $bestaetigtam ? $authUID : null, + 'anmerkung' => $anmerkung, + 'bewerbung_abgeschicktamum' => $bewerbung_abgeschicktamum, + 'studienplan_id' => $studienplan_id, + 'rt_stufe' => $rt_stufe, + 'statusgrund_id' => $statusgrund_id + ]); + + $this->getDataOrTerminateWithError($result); + + $this->db->trans_complete(); + + $this->terminateWithSuccess(true); + } + + /** + * Updates a status entry + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param string $key_studiensemester_kurzbz + * @param integer $key_ausbildungssemester + * + * @return void + */ + public function updateStatus($prestudent_id, $status_kurzbz, $key_studiensemester_kurzbz, $key_ausbildungssemester) + { + $result = $this->PrestudentstatusModel->load([ + $key_ausbildungssemester, + $key_studiensemester_kurzbz, + $status_kurzbz, + $prestudent_id + ]); + $oldstatus = $this->getDataOrTerminateWithError($result); + if (!$oldstatus) + show_404(); // Status that should be updated does not exist + + $oldstatus = current($oldstatus); + + + $isBerechtigtNoStudstatusCheck = $this->permissionlib->isBerechtigt('student/keine_studstatuspruefung'); + $isBerechtigtBasisPrestudentstatus = $this->permissionlib->isBerechtigt('basis/prestudentstatus'); + + + $authUID = getAuthUID(); + $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz') ?: $oldstatus->studiensemester_kurzbz; + $ausbildungssemester = $this->input->post('ausbildungssemester') ?: $oldstatus->ausbildungssemester; + $datum = $this->input->post('datum') ?: $oldstatus->datum; + + + //Form Validation + $this->load->library('form_validation'); + + $this->form_validation->set_rules('statusgrund_id', $this->p->t('international', 'grund'), 'integer', [ + 'integer' => $this->p->t('ui', 'error_fieldNotInteger') + ]); + + if (!$isBerechtigtBasisPrestudentstatus) + $this->form_validation->set_rules( + 'bewerbung_abgeschicktamum', + $this->p->t('lehre', 'bewerbung_abgeschickt_am'), + 'is_null', + [ + 'is_null' => $this->p->t('ui', 'error_fieldWriteAccess') + ] + ); + + $this->form_validation->set_rules( + 'datum', + $this->p->t('global', 'datum'), + [ + 'is_valid_date', + ['meldestichtag_not_exceeded', function ($value) use ($isBerechtigtNoStudstatusCheck) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$value) + return true; // Error will be handled by the required statement above + + $result = $this->prestudentstatuschecklib->checkIfMeldestichtagErreicht($value); + + return !$this->getDataOrTerminateWithError($result); + }] + ], + [ + 'meldestichtag_not_exceeded' => $this->p->t('lehre', 'error_dataVorMeldestichtag') + ] + ); + + $this->form_validation->set_rules('bestaetigtam', $this->p->t('lehre', 'bestaetigt_am'), 'is_valid_date'); + + if (!is_valid_date($datum)) + $datum = null; + + // Set Datum to null to prevent multiple is_valid_date checks in the following validation rules + $this->form_validation->set_rules('_default', '', [ + //Check if Rolle already exists + ['new_rolle_doesnt_exist', function () use ( + $prestudent_id, + $status_kurzbz, + $studiensemester_kurzbz, + $ausbildungssemester, + $key_studiensemester_kurzbz, + $key_ausbildungssemester + ) { + if ($key_studiensemester_kurzbz == $studiensemester_kurzbz + && $key_ausbildungssemester == $ausbildungssemester + ) + return true; // Primary key has not change we update in place + + $result = $this->PrestudentstatusModel->load([ + $ausbildungssemester, + $studiensemester_kurzbz, + $status_kurzbz, + $prestudent_id + ]); + return !$this->getDataOrTerminateWithError($result); + }], + ['history_timesequence', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester, + $key_studiensemester_kurzbz, + $key_ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$datum) + return true; // Error will be handled by the is_valid_date statement above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryTimesequence( + $prestudent_id, + $status_kurzbz, + new DateTime($datum), + $studiensemester_kurzbz, + $ausbildungssemester, + $key_studiensemester_kurzbz, + $key_ausbildungssemester + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_laststatus', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester, + $key_studiensemester_kurzbz, + $key_ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$datum) + return true; // Error will be handled by the is_valid_date statement above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryLaststatus( + $prestudent_id, + $status_kurzbz, + new DateTime($datum), + $studiensemester_kurzbz, + $ausbildungssemester, + $key_studiensemester_kurzbz, + $key_ausbildungssemester + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_unterbrecher', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester, + $key_studiensemester_kurzbz, + $key_ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$datum) + return true; // Error will be handled by the is_valid_date statement above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryUnterbrechersemester( + $prestudent_id, + $status_kurzbz, + new DateTime($datum), + $studiensemester_kurzbz, + $ausbildungssemester, + $key_studiensemester_kurzbz, + $key_ausbildungssemester + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_abbrecher', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester, + $key_studiensemester_kurzbz, + $key_ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$datum) + return true; // Error will be handled by the is_valid_date statement above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryAbbrechersemester( + $prestudent_id, + $status_kurzbz, + new DateTime($datum), + $studiensemester_kurzbz, + $ausbildungssemester, + $key_studiensemester_kurzbz, + $key_ausbildungssemester + ); + + return $this->getDataOrTerminateWithError($result); + }], + ['history_diplomant', function () use ( + $isBerechtigtNoStudstatusCheck, + $prestudent_id, + $status_kurzbz, + $datum, + $studiensemester_kurzbz, + $ausbildungssemester, + $key_studiensemester_kurzbz, + $key_ausbildungssemester + ) { + if ($isBerechtigtNoStudstatusCheck) + return true; // Skip if access right says so + if (!$datum) + return true; // Error will be handled by the is_valid_date statement above + + $result = $this->prestudentstatuschecklib->checkStatusHistoryDiplomant( + $prestudent_id, + $status_kurzbz, + new DateTime($datum), + $studiensemester_kurzbz, + $ausbildungssemester, + $key_studiensemester_kurzbz, + $key_ausbildungssemester + ); + + return $this->getDataOrTerminateWithError($result); + }] + ], [ + 'new_rolle_doesnt_exist' => $this->p->t('lehre', 'error_rolleBereitsVorhanden'), + 'history_timesequence' => $this->p->t('lehre', 'error_statuseintrag_zeitabfolge'), + 'history_laststatus' => $this->p->t('lehre', 'error_endstatus'), + 'history_unterbrecher' => $this->p->t('lehre', 'error_consecutiveUnterbrecher'), + 'history_abbrecher' => $this->p->t('lehre', 'error_consecutiveUnterbrecherAbbrecher'), + 'history_diplomant' => $this->p->t('lehre', 'error_consecutiveDiplomandStudent') + ]); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + // Start DB transaction + $this->db->trans_start(); + + $this->updateLehrverbandForInsertAndUpdate($prestudent_id, $status_kurzbz, $studiensemester_kurzbz, $ausbildungssemester, $authUID); + + //update status + $updateData = [ + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'ausbildungssemester' => $ausbildungssemester, + 'datum' => $datum, + 'updateamum' => date('c'), + 'updatevon' => $authUID + ]; + foreach ([ + 'orgform_kurzbz', + 'anmerkung', + 'bewerbung_abgeschicktamum', + 'studienplan_id', + 'rt_stufe', + 'statusgrund_id' + ] as $key) + if ($this->input->post($key)) + $updateData[$key] = $this->input->post($key); + + if ($this->input->post('bestaetigtam')) { + $updateData['bestaetigtam'] = $this->input->post('bestaetigtam'); + $updateData['bestaetigtvon'] = $authUID; + } + + $result = $this->PrestudentstatusModel->update([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz, + 'studiensemester_kurzbz' => $key_studiensemester_kurzbz, + 'ausbildungssemester' => $key_ausbildungssemester, + ], $updateData); + + $this->getDataOrTerminateWithError($result); + + $this->db->trans_commit(); + + return $this->outputJsonSuccess(true); + } + + /** + * Advances a status entry + * must be of type Student, Diplomand or Unterbrecher + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param string $key_studiensemester_kurzbz + * @param integer $key_ausbildungssemester + * + * @return void + */ + public function advanceStatus($prestudent_id, $status_kurzbz, $key_studiensemester_kurzbz, $key_ausbildungssemester) + { + $result = $this->PrestudentstatusModel->load([ + $key_ausbildungssemester, + $key_studiensemester_kurzbz, + $status_kurzbz, + $prestudent_id + ]); + $oldstatus = $this->getDataOrTerminateWithError($result); + if (!$oldstatus) + show_404(); // Status that should be updated does not exist + + $oldstatus = current($oldstatus); + + + //Target studiensemester_kurzbz + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $result = $this->StudiensemesterModel->getNextFrom($key_studiensemester_kurzbz); + + $studiensemester_kurzbz = $this->getDataOrTerminateWithError($result); + $studiensemester_kurzbz = current($studiensemester_kurzbz)->studiensemester_kurzbz; + + + //Target ausbildungssemester + $ausbildungssemester = $key_ausbildungssemester + 1; + + + //Form Validation + $this->load->library('form_validation'); + + $this->form_validation->set_data([ + 'status_kurzbz' => $status_kurzbz + ]); + + $this->form_validation->set_rules('status_kurzbz', $this->p->t('lehre', 'status_rolle'), [ + 'in_list[' . + Prestudentstatus_model::STATUS_STUDENT . ',' . + Prestudentstatus_model::STATUS_DIPLOMAND . ',' . + Prestudentstatus_model::STATUS_UNTERBRECHER . ']', + ['status_stud_exists', function ($value) use ($prestudent_id) { + if ($value != Prestudentstatus_model::STATUS_STUDENT) + return true; + + $result = $this->prestudentstatuschecklib->checkIfExistingStudent($prestudent_id); + + return $this->getDataOrTerminateWithError($result); + }] + ], [ + 'status_stud_exists' => $this->p->t('lehre', 'error_noStudstatus') + ]); + + $this->form_validation->set_rules('_default', '', [ + //Check if Rolle already exists + ['rolle_doesnt_exist', function () use ( + $prestudent_id, + $status_kurzbz, + $studiensemester_kurzbz, + $ausbildungssemester + ) { + $result = $this->PrestudentstatusModel->load([$ausbildungssemester, $studiensemester_kurzbz, $status_kurzbz, $prestudent_id]); + + return !$this->getDataOrTerminateWithError($result); + }] + ], [ + 'rolle_doesnt_exist' => $this->p->t('lehre', 'error_rolleBereitsVorhanden') + ]); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + // Start DB transaction + $this->db->trans_begin(); + + $authUID = getAuthUID(); + $now = date('c'); + + //insert prestudentstatus + $result = $this->PrestudentstatusModel->insert([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'ausbildungssemester' => $ausbildungssemester, + 'datum' => $now, + 'insertamum' => $now, + 'insertvon' => $authUID, + 'orgform_kurzbz' => $oldstatus->orgform_kurzbz, + 'studienplan_id' => $oldstatus->studienplan_id, + 'bestaetigtam' => $now, + 'bestaetigtvon' => $authUID, + 'anmerkung' => $oldstatus->anmerkung + ]); + + $this->getDataOrTerminateWithError($result); + + + //get student_uid + $this->load->model('crm/Student_model', 'StudentModel'); + $result = $this->StudentModel->loadWhere([ + 'prestudent_id' => $prestudent_id + ]); + + $student = $this->getDataOrTerminateWithError($result); + + if (!$student) + $this->terminateWithError($this->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id])); + $student = current($student); + + + //process studentlehrverband + $this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel'); + $result = $this->StudentlehrverbandModel->load([ + $key_studiensemester_kurzbz, + $student->student_uid + ]); + + $studentlvb = $this->getDataOrTerminateWithError($result); + if (!$studentlvb) + $this->terminateWithError($this->p->t('lehre', 'error_noStudentlehrverband')); + + //Data of current Semester + $studentlvb = current($studentlvb); + + + $newStudentlvb = [ + 'student_uid' => $studentlvb->student_uid, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'studiengang_kz' => $studentlvb->studiengang_kz, + 'semester' => $studentlvb->semester, + 'verband' => $studentlvb->verband, + 'gruppe' => $studentlvb->gruppe, + 'insertamum' => $now, + 'insertvon' => $authUID, + 'ext_id' => $studentlvb->ext_id + + ]; + + + $this->load->model('organisation/Lehrverband_model', 'LehrverbandModel'); + + $result = $this->LehrverbandModel->load([ + $student->gruppe, + $student->verband, + $ausbildungssemester, + $student->studiengang_kz + ]); + + $lv = $this->getDataOrTerminateWithError($result); + if ($lv) { + $newStudentlvb['semester'] = $ausbildungssemester; + } // If there is no lehrverband just use the same as in the previous studiensemester + + + //add studentlehrverband + $result = $this->StudentlehrverbandModel->insert($newStudentlvb); + + $this->getDataOrTerminateWithError($result); + + $this->db->trans_commit(); + + return $this->outputJsonSuccess(true); + } + + /** + * Confirms a status entry + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param string $key_studiensemester_kurzbz + * @param integer $key_ausbildungssemester + * + * @return void + */ + public function confirmStatus($prestudent_id, $status_kurzbz, $studiensemester_kurzbz, $ausbildungssemester) + { + $result = $this->PrestudentstatusModel->load([ + $ausbildungssemester, + $studiensemester_kurzbz, + $status_kurzbz, + $prestudent_id + ]); + $oldstatus = $this->getDataOrTerminateWithError($result); + if (!$oldstatus) + show_404(); // Status that should be updated does not exist + + $oldstatus = current($oldstatus); + + + $authUID = getAuthUID(); + $now = date('c'); + + //Form Validation + $this->load->library('form_validation'); + + $this->form_validation->set_rules('Status', '', [ + ['status_not_yet_confirmed', function () use ($oldstatus) { + return !$oldstatus->bestaetigtam; + }], + ['bewerbung_abgeschickt', function () use ($oldstatus) { + return !!$oldstatus->bewerbung_abgeschicktamum; + }] + ], [ + 'status_not_yet_confirmed' => $this->p->t('lehre', 'error_statusConfirmedYet'), + 'bewerbung_abgeschickt' => $this->p->t('lehre', 'error_bewerbungNochNichtAbgeschickt') + ]); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + //update status + $result = $this->PrestudentstatusModel->update([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'ausbildungssemester' => $ausbildungssemester, + ], [ + 'bestaetigtam' => $now, + 'bestaetigtvon' => $authUID, + 'updateamum' => $now, + 'updatevon' => $authUID + ]); + + $this->getDataOrTerminateWithError($result); + + + //Send Message + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $this->PrestudentModel->addSelect('p.*'); + $this->PrestudentModel->addSelect('stg.oe_kurzbz'); + $this->PrestudentModel->addSelect('stg.bezeichnung AS stg_bezeichnung'); + $this->PrestudentModel->addSelect('stg.email AS stg_email'); + $this->PrestudentModel->addSelect('plan.orgform_kurzbz'); + $this->PrestudentModel->addSelect('typ.bezeichnung AS typ_bezeichnung'); + + $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz'); + $this->PrestudentModel->addJoin('public.tbl_studiengangstyp typ', 'typ'); + $this->PrestudentModel->addJoin('public.tbl_studienplan plan', 'studienplan_id', 'LEFT'); + + $result = $this->PrestudentModel->load($prestudent_id); + + $studentdata = $this->getDataOrTerminateWithError($result); + + $this->load->library('MessageLib'); + $result = $this->messagelib->sendMessageUserTemplate( + $studentdata->person_id, // receiversPersonId + 'MailStatConfirm' . $status_kurzbz, // vorlage + [ + 'anrede' => $studentdata->anrede, + 'vorname' => $studentdata->vorname, + 'nachname' => $studentdata->nachname, + 'typ' => $studentdata->typ_bezeichnung, + 'studiengang' => $studentdata->stg_bezeichnung, + 'orgform' => $studentdata->orgform_kurzbz ?: $oldstatus->orgform_kurzbz, + 'stgMail' => $studentdata->stg_email + ], // parseData + null, // orgform + 1, // TODO + $studentdata->oe_kurzbz, // senderOU + null, // relationmessage_id + MSG_PRIORITY_NORMAL, // priority + true // multiPartMime + ); + + + $this->terminateWithSuccess(true); + } + + /** + * Helper function for insertStatus and updateStatus. + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param string $studiensemester_kurzbz + * @param integer $ausbildungssemester + * @param string $authUID + * + * @return void + */ + private function updateLehrverbandForInsertAndUpdate($prestudent_id, $status_kurzbz, $studiensemester_kurzbz, $ausbildungssemester, $authUID) + { + if (!in_array($status_kurzbz, [ + Prestudentstatus_model::STATUS_STUDENT, + Prestudentstatus_model::STATUS_DIPLOMAND, + Prestudentstatus_model::STATUS_ABSOLVENT, + Prestudentstatus_model::STATUS_INCOMING, + Prestudentstatus_model::STATUS_ABBRECHER, + Prestudentstatus_model::STATUS_UNTERBRECHER + ])) + return; // No Update necessary + + $result = $this->StudentModel->loadWhere([ + 'prestudent_id' => $prestudent_id + ]); + + $student = $this->getDataOrTerminateWithError($result); + + if (!$student) + return; // No Update necessary + + $student = current($student); + + $this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel'); + $result = $this->StudentlehrverbandModel->loadWhere([ + 'student_uid' => $student->student_uid, + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ]); + + $studentlvb = $this->getDataOrTerminateWithError($result); + + + $this->load->model('organisation/Lehrverband_model', 'LehrverbandModel'); + + $this->LehrverbandModel->addLimit(1); + $result = $this->LehrverbandModel->load([ + $student->gruppe, + $student->verband, + $ausbildungssemester, + $student->studiengang_kz + ]); + $lv = $this->getDataOrTerminateWithError($result); + + + if ($studentlvb && !$lv) + return; // No Update necessary + + if ($studentlvb) // Update current Student-Lehrverband entry + $this->StudentlehrverbandModel->update([ + 'student_uid' => $student->student_uid, + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ], [ + 'studiengang_kz' => $student->studiengang_kz, + 'semester' => $ausbildungssemester, + 'verband' => $student->verband, + 'gruppe' => $student->gruppe, + 'updateamum' => date('c'), + 'updatevon' => $authUID + ]); + else // Add new Student-Lehrverband entry + $this->StudentlehrverbandModel->insert([ + 'student_uid' => $student->student_uid, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'studiengang_kz' => $student->studiengang_kz, + 'semester' => $lv ? $ausbildungssemester : $student->semester, + 'verband' => $student->verband, + 'gruppe' => $student->gruppe, + 'insertamum' => date('c'), + 'insertvon' => $authUID + ]); + } + + /** + * Helper function for sanitizing Alias Name + * replaces empty spaces with underlines + * + * @param string $str + * + * @return string + */ + private function _sanitizeAliasName($str) + { + $str = sanitizeProblemChars($str); + return mb_strtolower(str_replace(' ', '_', $str)); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Student.php b/application/controllers/api/frontend/v1/stv/Student.php new file mode 100644 index 000000000..89c317ae4 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Student.php @@ -0,0 +1,562 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +use \DateTime as DateTime; + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about a Student + * Listens to ajax post calls to change the Student data + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Student extends FHCAPI_Controller +{ + /** + * Calls the parent's constructor and prepares libraries and phrases + */ + public function __construct() + { + parent::__construct([ + 'get' => ['admin:r', 'assistenz:r'], + 'save' => ['admin:rw', 'assistenz:rw'], + 'check' => ['admin:rw', 'assistenz:rw'], + 'add' => ['admin:rw', 'assistenz:rw'] // TODO(chris): extra permissions + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + if ($this->router->method == 'get' + || $this->router->method == 'save' + ) { + $prestudent_id = current(array_slice($this->uri->rsegments, 2)); + if ($this->router->method == 'get') + $this->checkPermissionsForPrestudent($prestudent_id, ['admin:r', 'assistenz:r']); + else + $this->checkPermissionsForPrestudent($prestudent_id, ['admin:rw', 'assistenz:rw']); + } + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Get details for a prestudent + * + * @param string $prestudent_id + * @return void + */ + public function get($prestudent_id) + { + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $this->PrestudentModel->addSelect('p.*'); + $this->PrestudentModel->addSelect('s.student_uid'); + $this->PrestudentModel->addSelect('matrikelnr'); + $this->PrestudentModel->addSelect('b.aktiv'); + $this->PrestudentModel->addSelect('v.semester'); + $this->PrestudentModel->addSelect('v.verband'); + $this->PrestudentModel->addSelect('v.gruppe'); + $this->PrestudentModel->addSelect('b.alias'); + + if (defined('ACTIVE_ADDONS') && strpos(ACTIVE_ADDONS, 'bewerbung') !== false) { + $this->PrestudentModel->addSelect( + "( + SELECT kontakt + FROM public.tbl_kontakt + WHERE kontakttyp='email' + AND person_id=p.person_id + AND zustellung + ORDER BY kontakt_id + LIMIT 1 + ) AS email_privat", + false + ); + } + + $this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_benutzer b', 'student_uid = uid', 'LEFT'); + $this->PrestudentModel->addJoin( + 'public.tbl_studentlehrverband v', + 'b.uid = v.student_uid AND v.studiensemester_kurzbz = ' . $this->PrestudentModel->escape($studiensemester_kurzbz), + 'LEFT' + ); + $this->PrestudentModel->addJoin('public.tbl_person p', 'p.person_id = tbl_prestudent.person_id'); + + $result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]); + + $student = $this->getDataOrTerminateWithError($result); + + if (!$student) + return show_404(); + + $this->terminateWithSuccess(current($student)); + } + + /** + * Saves data to a prestudent + * + * @param string $prestudent_id + * @return void + */ + public function save($prestudent_id) + { + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); + + $this->load->model('person/Person_model', 'PersonModel'); + $this->load->model('crm/Student_model', 'StudentModel'); + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel'); + + $this->load->library('form_validation'); + + $this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'is_valid_date'); + + $this->form_validation->set_rules('semester', 'Semester', 'integer'); + + $this->load->library('UDFLib'); + + $result = $this->udflib->getCiValidations($this->PersonModel, $this->input->post()); + + //TODO(Manu) check with Chris: input number not allowed + $udf_field_validations = $this->getDataOrTerminateWithError($result); + + $this->form_validation->set_rules($udf_field_validations); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $result = $this->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]); + + $student = $this->getDataOrTerminateWithError($result); + + $uid = $student ? current($student)->student_uid : null; + + $result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]); + + $person = $this->getDataOrTerminateWithError($result); + + $person_id = $person ? current($person)->person_id : null; + + + $array_allowed_props_lehrverband = ['verband', 'semester', 'gruppe']; + $update_lehrverband = array(); + foreach ($array_allowed_props_lehrverband as $prop) { + $val = $this->input->post($prop); + if ($val !== null) { + $update_lehrverband[$prop] = $val; + } + } + + $array_allowed_props_person = [ + 'anrede', + 'bpk', + 'titelpre', + 'titelpost', + 'nachname', + 'vorname', + 'vornamen', + 'wahlname', + 'gebdatum', + 'gebort', + 'geburtsnation', + 'svnr', + 'ersatzkennzeichen', + 'staatsbuergerschaft', + 'matr_nr', + 'sprache', + 'geschlecht', + 'familienstand', + 'foto', + 'anmerkung', + 'homepage' + ]; + + // add UDFs + $result = $this->udflib->getDefinitionForModel($this->PersonModel); + + $definitions = $this->getDataOrTerminateWithError($result); + + foreach ($definitions as $def) + $array_allowed_props_person[] = $def['name']; + + $update_person = array(); + foreach ($array_allowed_props_person as $prop) { + $val = $this->input->post($prop); + if ($val !== null) { + $update_person[$prop] = $val; + } + } + + $array_allowed_props_student = ['matrikelnr']; + $update_student = array(); + foreach ($array_allowed_props_student as $prop) { + $val = $this->input->post($prop); + if ($val !== null) { + $update_student[$prop] = $val; + } + } + + // Check PKs + if (count($update_lehrverband) + count($update_student) && $uid === null) { + // TODO(chris): phrase + $this->terminateWithValidationErrors(['' => "Kein/e StudentIn vorhanden!"]); + } + if (count($update_person) && $person_id === null) { + // TODO(chris): phrase + $this->terminateWithValidationErrors(['' => "Keine Person vorhanden!"]); + } + + // Do Updates + if (count($update_lehrverband)) { + $result = $this->StudentlehrverbandModel->update([ + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'student_uid' => $uid + ], $update_lehrverband); + $this->getDataOrTerminateWithError($result); + } + + if (count($update_person)) { + $result = $this->PersonModel->update( + $person_id, + $update_person + ); + $this->getDataOrTerminateWithError($result); + } + + + if (count($update_student)) { + $result = $this->StudentModel->update( + [$uid], + $update_student + ); + $this->getDataOrTerminateWithError($result); + } + + $this->terminateWithSuccess(array_fill_keys(array_merge( + array_keys($update_lehrverband), + array_keys($update_person), + array_keys($update_student) + ), '')); + } + + public function check() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'is_valid_date'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $vorname = $this->input->post('vorname'); + $nachname = $this->input->post('nachname'); + $gebdatum = $this->input->post('gebdatum'); + + if (!$vorname && !$nachname && !$gebdatum) + $this->terminateWithValidationErrors(['At least one of vorname, nachname or gebdatum must be set']); + + $this->load->model('person/Person_model', 'PersonModel'); + + if ($gebdatum) + $this->PersonModel->db->where('gebdatum', (new DateTime($gebdatum))->format('Y-m-d')); + if ($vorname && $nachname) { + $this->PersonModel->db->or_group_start(); + $this->PersonModel->db->where('LOWER(nachname)', 'LOWER(' . $this->PersonModel->db->escape($nachname) . ')', false); + $this->PersonModel->db->where('LOWER(vorname)', 'LOWER(' . $this->PersonModel->db->escape($vorname) . ')', false); + $this->PersonModel->db->group_end(); + } elseif ($nachname) { + $this->PersonModel->db->or_where('LOWER(nachname)', 'LOWER(' . $this->PersonModel->escape($nachname) . ')', false); + } + + $result = $this->PersonModel->load(); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function add() + { + if (!$this->input->post('person_id')) { + if (!isset($_POST['address']) || !is_array($_POST['address'])) + $_POST['address'] = []; + $_POST['address']['func'] = 1; + } + if ($this->input->post('incoming')) { + $_POST['ausbildungssemester'] = 0; + } + + $this->load->library('form_validation'); + + $this->form_validation->set_rules('nachname', 'Nachname', 'callback_requiredIfNotPersonId', [ + 'requiredIfNotPersonId' => $this->p->t('ui', 'error_required') + ]); + $this->form_validation->set_rules('geschlecht', 'Geschlecht', 'callback_requiredIfNotPersonId', [ + 'requiredIfNotPersonId' => $this->p->t('ui', 'error_required') + ]); + $this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'callback_isValidDate', [ + 'isValidDate' => $this->p->t('ui', 'error_invalid_date') + ]); + $this->form_validation->set_rules('address[func]', 'Address', 'required|integer|less_than[2]|greater_than[-2]'); + $this->form_validation->set_rules('address[plz]', 'PLZ', 'callback_requiredIfAddressFunc', [ + 'requiredIfAddressFunc' => $this->p->t('ui', 'error_required') + ]); + $this->form_validation->set_rules('address[gemeinde]', 'Gemeinde', 'callback_requiredIfAddressFunc', [ + 'requiredIfAddressFunc' => $this->p->t('ui', 'error_required') + ]); + $this->form_validation->set_rules('address[ort]', 'Ort', 'callback_requiredIfAddressFunc', [ + 'requiredIfAddressFunc' => $this->p->t('ui', 'error_required') + ]); + $this->form_validation->set_rules('address[address]', 'Adresse', 'callback_requiredIfAddressFunc', [ + 'requiredIfAddressFunc' => $this->p->t('ui', 'error_required') + ]); + $this->form_validation->set_rules('email', 'E-Mail', 'valid_email'); + $this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required'); + $this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required'); + $this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'required|integer|less_than[9]|greater_than[-1]'); + // TODO(chris): validate studienplan with studiengang, semester and orgform? + // TODO(chris): validate person_id, studiengang_kz, studiensemester_kurzbz, orgform_kurzbz, nation, gemeinde, ort, geschlecht? + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + // TODO(chris): This should be in a library + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + + $this->db->trans_start(); + + $result = $this->addInteressent(); + + $this->db->trans_complete(); + + if ($this->db->trans_status() === FALSE) + $this->terminateWithError('TODO(chris): TEXT', self::ERROR_TYPE_GENERAL); + + $this->terminateWithSuccess($result); + } + + protected function addInteressent() + { + // Person anlegen wenn nötig + $person_id = $this->input->post('person_id'); + if (!$person_id) { + $this->load->model('person/Person_model', 'PersonModel'); + + $data = [ + 'nachname' => $this->input->post('nachname'), + 'insertamum' => date('c'), + 'insertvon' => getAuthUID(), + 'zugangscode' => uniqid(), + 'aktiv' => true + ]; + if ($this->input->post('anrede')) + $data['anrede'] = $this->input->post('anrede'); + if ($this->input->post('titelpre')) + $data['titelpre'] = $this->input->post('titelpre'); + if ($this->input->post('titelpost')) + $data['titelpost'] = $this->input->post('titelpost'); + if ($this->input->post('vorname')) + $data['vorname'] = $this->input->post('vorname'); + if ($this->input->post('vornamen')) + $data['vornamen'] = $this->input->post('vornamen'); + if ($this->input->post('wahlname')) + $data['wahlname'] = $this->input->post('wahlname'); + if ($this->input->post('geschlecht')) + $data['geschlecht'] = $this->input->post('geschlecht'); + if ($this->input->post('gebdatum')) + $data['gebdatum'] = (new DateTime($this->input->post('datum_obj')))->format('Y-m-d'); + if ($this->input->post('geburtsnation')) + $data['geburtsnation'] = $this->input->post('geburtsnation'); + if ($this->input->post('staatsbuergerschaft')) + $data['staatsbuergerschaft'] = $this->input->post('staatsbuergerschaft'); + + $result = $this->PersonModel->insert($data); + $person_id = $this->getDataOrTerminateWithError($result); + } + + // Addresse anlegen + $anlegen = $this->input->post('address[func]'); + if ($anlegen) { + $this->load->model('person/Adresse_model', 'AdresseModel'); + + $data = [ + 'nation' => $this->input->post('address[nation]'), + 'strasse' => $this->input->post('address[address]'), + 'plz' => $this->input->post('address[plz]'), + 'ort' => $this->input->post('address[ort]'), + 'gemeinde' => $this->input->post('address[gemeinde]'), + 'typ' => 'h', + 'zustelladresse' => true, + ]; + if ($anlegen < 0) { // Überschreiben + $this->AdresseModel->addOrder('zustelladresse', 'DESC'); + $this->AdresseModel->addOrder('sort'); + $result = $this->AdresseModel->loadWhere([ + 'person_id' => $person_id + ]); + $address = $this->getDataOrTerminateWithError($result); + if ($address) { + $address = current($address); + + $data['updateamum'] = date('c'); + $data['updatevon'] = getAuthUID(); + + $result = $this->AdresseModel->update($address->adresse_id, $data); + $this->getDataOrTerminateWithError($result); + } else { + //Wenn keine Adrese vorhanden ist dann eine neue Anlegen + $anlegen = 1; + $data['heimatadresse'] = true; + } + } + if ($anlegen > 0) { + $data['person_id'] = $person_id; + $data['insertamum'] = date('c'); + $data['insertvon'] = getAuthUID(); + if (!isset($data['heimatadresse'])) + $data['heimatadresse'] = !$this->input->post('person_id'); + + $result = $this->AdresseModel->insert($data); + $this->getDataOrTerminateWithError($result); + } + } + + // Kontaktdaten + $kontaktdaten = []; + foreach (['email', 'telefon', 'mobil'] as $k) { + $v = $this->input->post($k); + if ($v) + $kontaktdaten[$k] = $v; + } + if (count($kontaktdaten)) { + $this->load->model('person/Kontakt_model', 'KontaktModel'); + + foreach ($kontaktdaten as $typ => $kontakt) { + $data = [ + 'person_id' => $person_id, + 'kontakttyp' => $typ, + 'kontakt' => $kontakt, + 'zustellung' => true, + 'insertamum' => date('c'), + 'insertvon' => getAuthUID() + ]; + $result = $this->KontaktModel->insert($data); + $this->getDataOrTerminateWithError($result); + } + } + + // Prestudent anlegen + $data = [ + 'aufmerksamdurch_kurzbz' => 'k.A.', + 'person_id' => $person_id, + 'studiengang_kz' => $this->input->post('studiengang_kz'), + 'ausbildungcode' => $this->input->post('letzteausbildung'), + 'anmerkung' => $this->input->post('anmerkungen'), + 'reihungstestangetreten' => false, + 'bismelden' => true + ]; + $ausbildungsart = $this->input->post('ausbildungsart'); + if ($ausbildungsart) + $data['anmerkung'] .= ' Ausbildungsart:' . $ausbildungsart; + // Incomings und ausserordentliche sind bei Meldung nicht förderrelevant + $incoming = $this->input->post('incoming'); + if ($incoming || substr($data['studiengang_kz'], 0, 1) == '9') + $data['foerderrelevant'] = false; + // Wenn die Person schon im System erfasst ist, dann die ZGV des Datensatzes uebernehmen + $this->PrestudentModel->addOrder('zgvmas_code'); + $this->PrestudentModel->addOrder('zgv_code', 'DESC'); + $this->PrestudentModel->addLimit(1); + $result = $this->PrestudentModel->loadWhere([ + 'person_id' => $person_id + ]); + $prestudent = $this->getDataOrTerminateWithError($result); + if ($prestudent) { + $prestudent = current($prestudent); + if ($prestudent->zgv_code) { + $data['zgv_code'] = $prestudent->zgv_code; + $data['zgvort'] = $prestudent->zgvort; + $data['zgvdatum'] = $prestudent->zgvdatum; + + $data['zgvmas_code'] = $prestudent->zgvmas_code; + $data['zgvmaort'] = $prestudent->zgvmaort; + $data['zgvmadatum'] = $prestudent->zgvmadatum; + } + } + // Prestudent speichern + $result = $this->PrestudentModel->insert($data); + $prestudent_id = $this->getDataOrTerminateWithError($result); + + // Prestudent Rolle Anlegen + $data = [ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $incoming ? 'Incoming' : 'Interessent', + 'studiensemester_kurzbz' => $this->input->post('studiensemester_kurzbz'), + 'ausbildungssemester' => $this->input->post('ausbildungssemester') ?: 0, + 'orgform_kurzbz' => $this->input->post('orgform_kurzbz') ?: null, + 'studienplan_id' => $this->input->post('studienplan_id') ?: null, + 'datum' => date('Y-m-d'), + 'insertamum' => date('c'), + 'insertvon' => getAuthUID() + ]; + $result = $this->PrestudentstatusModel->insert($data); + $this->getDataOrTerminateWithError($result); + + if ($incoming) { + // TODO(chris): IMPLEMENT! + //Matrikelnummer und UID generieren + //Benutzerdatensatz anlegen + //Studentendatensatz anlegen + //StudentLehrverband anlegen + } + + // TODO(chris): DEBUG + /*$result = $this->PrestudentModel->loadWhere([ + 'pestudent_id' => 1 + ]); + if (isError($result)) { + return $result; + }*/ + + $this->terminateWithSuccess(true); + } + + public function requiredIfNotPersonId($value) + { + if (isset($_POST['person_id'])) + return true; + return !!$value; + } + + public function requiredIfAddressFunc($value) + { + if (!$_POST['address']['func']) + return true; + return !!$value; + } +} diff --git a/application/controllers/api/frontend/v1/stv/Students.php b/application/controllers/api/frontend/v1/stv/Students.php new file mode 100644 index 000000000..5fb7b592c --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Students.php @@ -0,0 +1,743 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about listing students + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Students extends FHCAPI_Controller +{ + private $allowedStgs = []; + + + public function __construct() + { + $permissions = []; + $router = load_class('Router'); + $permissions[$router->method] = ['admin:r', 'assistenz:r']; + parent::__construct($permissions); + + $this->allowedStgs = $this->permissionlib->getSTG_isEntitledFor('admin') ?: []; + $this->allowedStgs = array_merge($this->allowedStgs, $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []); + + if (!$this->allowedStgs) { + $this->_outputAuthError([$router->method => ['admin:r', 'assistenz:r']]); + exit; + } + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + } + + /** + * Remap calls: + * / => return [] + * /inout => return [] + * /inout/incoming => getIncoming + * /inout/outgoing => getOutgoing + * /inout/gemeinsamestudien => getGemeinsamestudien + * /(studiengang_kz) => getStudents + * /(studiengang_kz)/prestudent => getPrestudents + * /(studiengang_kz)/prestudent/* => getPrestudents + * /(studiengang_kz)/(semester) => getStudents + * /(studiengang_kz)/(semester)/grp/(gruppe_kurzbz) => getStudents + * /(studiengang_kz)/(semester)/(verband) => getStudents + * /(studiengang_kz)/(semester)/(verband)/(gruppe) => getStudents + * /(studiengang_kz)/(org_form) => getStudents + * /(studiengang_kz)/(org_form)/prestudent => getPrestudents + * /(studiengang_kz)/(org_form)/prestudent/* => getPrestudents + * /(studiengang_kz)/(org_form)/(semester) => getStudents + * /(studiengang_kz)/(org_form)/(semester)/grp/(gruppe_kurzbz) + * => getStudents + * /(studiengang_kz)/(org_form)/(semester)/(verband) => getStudents + * /(studiengang_kz)/(org_form)/(semester)/(verband)/(gruppe) + * => getStudents + * /uid/(student_uid) => getStudent + * /prestudent/(prestudent_id) => getPrestudent + * /person/(person_id) => getPerson + * + * @param string $method + * @param array $params (optional) + * + * @return void + */ + public function _remap($method, $params = []) + { + if ($method == '' || $method == 'index') + return $this->terminateWithSuccess([]); + + if ($method == 'inout') { + if (!count($params)) + return $this->terminateWithSuccess([]); + switch ($params[0]) { + case 'incoming': + return $this->getIncoming(); + case 'outgoing': + return $this->getOutgoing(); + case 'gemeinsamestudien': + return $this->getGemeinsamestudien(); + default: + return show_404(); + } + } + + $count = count($params); + if (!$count) + return $this->getStudents($method); + + if ($method == 'uid' && $count == 1) + return $this->getStudent($params[0]); + + if ($method == 'prestudent' && $count == 1) + return $this->getPrestudent($params[0]); + + if ($method == 'person' && $count == 1) + return $this->getPerson($params[0]); + + if (is_numeric($params[0])) { + $sem = $params[0]; + if ($count == 3 && $params[1] == 'grp') { + $g = $params[2]; + $ver = null; + $grp = null; + } else { + $g = null; + $ver = $count > 1 ? $params[1] : null; + $grp = $count > 2 ? $params[2] : null; + } + return $this->getStudents($method, $sem, $ver, $grp, $g); + } elseif ($params[0] == 'prestudent') { + if ($count == 1) + return $this->getPrestudents($method); + if ($count == 2) + return $this->getPrestudents($method, $params[1]); + return $this->getPrestudents($method, $params[1], $params[$count-1]); + } else { + $org = $params[0]; + if ($count > 1 && $params[1] == 'prestudent') { + if ($count == 2) + return $this->getPrestudents($method, null, null, $org); + if ($count == 3) + return $this->getPrestudents($method, $params[2], null, $org); + return $this->getPrestudents($method, $params[2], $params[$count-1], $org); + } + $sem = $count > 1 ? $params[1] : null; + if ($count == 4 && $params[2] == 'grp') { + $g = $params[3]; + $ver = null; + $grp = null; + } else { + $g = null; + $ver = $count > 2 ? $params[2] : null; + $grp = $count > 3 ? $params[3] : null; + } + + return $this->getStudents($method, $sem, $ver, $grp, $g, $org); + } + + show_404(); + } + + /** + * @return void + */ + protected function getIncoming() + { + // TODO(chris): IMPLEMENT! + $this->terminateWithSuccess([]); + } + + /** + * @return void + */ + protected function getOutgoing() + { + // TODO(chris): IMPLEMENT! + $this->terminateWithSuccess([]); + } + + /** + * @return void + */ + protected function getGemeinsamestudien() + { + // TODO(chris): IMPLEMENT! + $this->terminateWithSuccess([]); + } + + /** + * @param integer $studiengang_kz + * @param string $studiensemester_kurzbz (optional) + * @param string $filter (optional) + * @param string $orgform_kurzbz (optional) + * + * @return void + */ + protected function getPrestudents($studiengang_kz, $studiensemester_kurzbz = null, $filter = null, $orgform_kurzbz = null) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $stdsemEsc = $studiensemester_kurzbz ? $this->PrestudentModel->escape($studiensemester_kurzbz) : 'NULL'; + + $selectRT = " + SELECT 1 + FROM public.tbl_rt_person + JOIN public.tbl_reihungstest r ON (rt_id = reihungstest_id) + WHERE person_id=p.person_id + AND studienplan_id IN ( + SELECT studienplan_id + FROM lehre.tbl_studienplan + JOIN lehre.tbl_studienordnung o USING(studienordnung_id) + WHERE o.studiengang_kz=tbl_prestudent.studiengang_kz + ) + AND r.studiensemester_kurzbz=" . $stdsemEsc; + + + $where = ['tbl_prestudent.studiengang_kz' => $studiengang_kz]; + + if ($orgform_kurzbz) { + $where['ps.orgform_kurzbz'] = $orgform_kurzbz; + } + + switch ($filter) { + case "interessenten": + $where['ps.status_kurzbz'] = 'Interessent'; + break; + case "bewerbungnichtabgeschickt": + $where['ps.status_kurzbz'] = 'Interessent'; + $where['bewerbung_abgeschicktamum'] = null; + break; + case "bewerbungabgeschickt": + $where['ps.status_kurzbz'] = 'Interessent'; + $where['bewerbung_abgeschicktamum IS NOT NULL'] = null; + $where['bestaetigtam'] = null; + break; + case "statusbestaetigt": + $where['ps.status_kurzbz'] = 'Interessent'; + $where['bestaetigtam IS NOT NULL'] = null; + break; + case "statusbestaetigtrtnichtangemeldet": + $where['ps.status_kurzbz'] = 'Interessent'; + $where['bestaetigtam IS NOT NULL'] = null; + $this->PrestudentModel->db->where('NOT EXISTS(' . $selectRT . ')', null, false); + break; + case "statusbestaetigtrtangemeldet": + $where['ps.status_kurzbz'] = 'Interessent'; + $where['bestaetigtam IS NOT NULL'] = null; + $this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false); + break; + case "zgv": + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + + $result = $this->StudiengangModel->load($studiengang_kz); + + $stg = $this->getDataOrTerminateWithError($result); + if (!$stg) + $this->terminateWithValidationErrors(['' => 'Studiengang does not exist']); // TODO(chris): phrase + $stg = current($stg); + + $where['ps.status_kurzbz'] = 'Interessent'; + + if ($stg->typ == 'm') { + $where['zgvmas_code IS NOT NULL'] = null; + if (defined('ZGV_ERFUELLT_ANZEIGEN') && ZGV_ERFUELLT_ANZEIGEN) + $where['zgvmas_erfuellt'] = true; + } elseif ($stg->typ == 'p') { + $where['zgvdoktor_code IS NOT NULL'] = null; + if (defined('ZGV_DOKTOR_ANZEIGEN') && ZGV_DOKTOR_ANZEIGEN) + $where['zgvdoktor_erfuellt'] = true; + } else { + $where['zgv_code IS NOT NULL'] = null; + if (defined('ZGV_ERFUELLT_ANZEIGEN') && ZGV_ERFUELLT_ANZEIGEN) + $where['zgv_erfuellt'] = true; + } + break; + case "reihungstestangemeldet": + $where['ps.status_kurzbz'] = 'Interessent'; + $this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false); + break; + case "reihungstestnichtangemeldet": + $where['ps.status_kurzbz'] = 'Interessent'; + $this->PrestudentModel->db->where('NOT EXISTS(' . $selectRT . ')', null, false); + break; + case "bewerber": + $where['ps.status_kurzbz'] = 'Bewerber'; + break; + case "bewerberrtnichtangemeldet": + $where['ps.status_kurzbz'] = 'Bewerber'; + $this->PrestudentModel->db->where('NOT EXISTS(' . $selectRT . ')', null, false); + break; + case "bewerberrtangemeldet": + $where['ps.status_kurzbz'] = 'Bewerber'; + $this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false); + break; + case "bewerberrtangemeldetteilgenommen": + $where['ps.status_kurzbz'] = 'Bewerber'; + $this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false); + $where['reihungstestangetreten'] = true; + break; + case "bewerberrtangemeldetnichtteilgenommen": + $where['ps.status_kurzbz'] = 'Bewerber'; + $this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false); + $where['reihungstestangetreten'] = false; + break; + case "aufgenommen": + $where['ps.status_kurzbz'] = 'Aufgenommener'; + break; + case "warteliste": + $where['ps.status_kurzbz'] = 'Wartender'; + break; + case "absage": + $where['ps.status_kurzbz'] = 'Abgewiesener'; + break; + case "incoming": + // NOTE(chris): in FAS it was not filtered for studiengang_kz + $where['ps.status_kurzbz'] = 'Incoming'; + break; + case "absolvent": + $where['ps.status_kurzbz'] = 'Absolvent'; + break; + case "diplomand": + $where['ps.status_kurzbz'] = 'Diplomand'; + break; + default: + if (!$studiensemester_kurzbz) { + // TODO(chris): this does not work with $orgform_kurzbz != null + $where['ps.status_kurzbz'] = null; + } else { + $this->PrestudentModel->db->where_in('ps.status_kurzbz', [ + 'Interessent', + 'Bewerber', + 'Aufgenommener', + 'Wartender', + 'Abgewiesener' + ]); + } + break; + } + + /* + $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', ' + pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) + AND pls.prestudent_id=tbl_prestudent.prestudent_id + AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL) + AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT'); + $this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', ' + ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') + AND ps.prestudent_id=tbl_prestudent.prestudent_id + AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') + AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')', 'LEFT');*/ + $this->prepareQuery($studiensemester_kurzbz); + + $this->PrestudentModel->addSelect(" + CASE WHEN ps.status_kurzbz IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') + THEN ps.ausbildungssemester::text + ELSE ''::text END AS semester", false); + $this->PrestudentModel->addSelect("'' AS verband"); + $this->PrestudentModel->addSelect("'' AS gruppe"); + $this->addSelectPrioRel(); + + $this->addFilter($studiensemester_kurzbz); + + $result = $this->PrestudentModel->loadWhere($where); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * @param integer $studiengang_kz + * @param integer $semester (optional) + * @param string $verband (optional) + * @param integer $gruppe (optional) + * @param string $gruppe_kurzbz (optional) + * @param string $orgform_kurzbz (optional) + * + * @return void + */ + protected function getStudents($studiengang_kz, $semester = null, $verband = null, $gruppe = null, $gruppe_kurzbz = null, $orgform_kurzbz = null) + { + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); + + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + /* + $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id'); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', ' + pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) + AND pls.prestudent_id=tbl_prestudent.prestudent_id + AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL) + AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT'); + $this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid'); + $this->PrestudentModel->addJoin( + 'public.tbl_studentlehrverband v', + 'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz) + );*/ + $this->prepareQuery($studiensemester_kurzbz, ''); + + $this->PrestudentModel->addSelect('v.semester'); + $this->PrestudentModel->addSelect('v.verband'); + $this->PrestudentModel->addSelect('v.gruppe'); + $this->PrestudentModel->addSelect("'' AS priorisierung_relativ"); + + + $where = []; + + if ($gruppe_kurzbz !== null) { + $this->PrestudentModel->addJoin('public.tbl_benutzergruppe g', 'uid'); + $where['g.gruppe_kurzbz'] = $gruppe_kurzbz; + $where['g.studiensemester_kurzbz'] = $studiensemester_kurzbz; + } else { + $where['v.studiengang_kz'] = $studiengang_kz; + + if ($semester !== null) + $where['v.semester'] = $semester; + + if ($verband !== null) + $where['v.verband'] = $verband; + + if ($gruppe !== null) + $where['v.gruppe'] = $gruppe; + + if (!$verband && !$gruppe && $orgform_kurzbz !== null) { + $this->PrestudentModel->db->where( + "( + SELECT orgform_kurzbz + FROM public.tbl_prestudentstatus + WHERE prestudent_id=tbl_prestudent.prestudent_id + AND studiensemester_kurzbz=" . $this->PrestudentModel->escape($studiensemester_kurzbz) . " + ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1 + ) =", + $this->PrestudentModel->escape($orgform_kurzbz), + false + ); + } + + } + + $this->addFilter($studiensemester_kurzbz); + + $result = $this->PrestudentModel->loadWhere($where); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * @param string $prestudent_id + * + * @return void + */ + protected function getPrestudent($prestudent_id) + { + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + /* + $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', ' + pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) + AND pls.prestudent_id=tbl_prestudent.prestudent_id + AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL) + AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT'); + $this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid', 'LEFT'); + $this->PrestudentModel->addJoin( + 'public.tbl_studentlehrverband v', + 'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz), + 'LEFT' + );*/ + $this->prepareQuery($studiensemester_kurzbz); + + $this->PrestudentModel->addSelect("COALESCE(v.semester::text, CASE WHEN public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') THEN public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)::text ELSE ''::text END) AS semester", false); + $this->PrestudentModel->addSelect('v.verband'); + $this->PrestudentModel->addSelect('v.gruppe'); + $this->addSelectPrioRel(); + + $this->addFilter($studiensemester_kurzbz); + + $result = $this->PrestudentModel->loadWhere([ + 'tbl_prestudent.prestudent_id' => $prestudent_id + ]); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * @param string $student_uid + * + * @return void + */ + protected function getStudent($student_uid) + { + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + /* + $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id'); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', ' + pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) + AND pls.prestudent_id=tbl_prestudent.prestudent_id + AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL) + AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT'); + $this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid'); + $this->PrestudentModel->addJoin( + 'public.tbl_studentlehrverband v', + 'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz), + 'LEFT' + );*/ + $this->prepareQuery($studiensemester_kurzbz); + + $this->PrestudentModel->addSelect('v.semester'); + $this->PrestudentModel->addSelect('v.verband'); + $this->PrestudentModel->addSelect('v.gruppe'); + $this->addSelectPrioRel(); + + $this->addFilter($studiensemester_kurzbz); + + $result = $this->PrestudentModel->loadWhere([ + 's.student_uid' => $student_uid + ]); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * @param integer $person_id + * + * @return void + */ + protected function getPerson($person_id) + { + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + /* + $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id'); + $this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid'); + $this->PrestudentModel->addJoin( + 'public.tbl_studentlehrverband v', + 'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz), + 'LEFT' + );*/ + $this->prepareQuery($studiensemester_kurzbz); + + $this->PrestudentModel->addSelect('v.semester'); + $this->PrestudentModel->addSelect('v.verband'); + $this->PrestudentModel->addSelect('v.gruppe'); + $this->addSelectPrioRel(); + + $this->addFilter($studiensemester_kurzbz); + + $result = $this->PrestudentModel->loadWhere([ + 'p.person_id' => $person_id + ]); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * @param string|null $studiensemester_kurzbz + * @param string $type + * + * @return void + */ + protected function prepareQuery($studiensemester_kurzbz, $type = 'LEFT') + { + $stdsemEsc = $studiensemester_kurzbz ? $this->PrestudentModel->escape($studiensemester_kurzbz) : 'NULL'; + + + $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); + $this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', $type); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', ' + pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) + AND pls.prestudent_id=tbl_prestudent.prestudent_id + AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL) + AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT'); + $this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT'); + $this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid', 'LEFT'); + $this->PrestudentModel->addJoin( + 'public.tbl_studentlehrverband v', + 'v.student_uid=s.student_uid AND v.studiensemester_kurzbz' . ($studiensemester_kurzbz ? '=' . $stdsemEsc : ' IS NULL'), + $type + ); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', ' + ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') + AND ps.prestudent_id=tbl_prestudent.prestudent_id + AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') + AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')', 'LEFT'); + + + $this->PrestudentModel->addSelect("b.uid"); + $this->PrestudentModel->addSelect('titelpre'); + $this->PrestudentModel->addSelect('nachname'); + $this->PrestudentModel->addSelect('vorname'); + $this->PrestudentModel->addSelect('wahlname'); + $this->PrestudentModel->addSelect('vornamen'); + $this->PrestudentModel->addSelect('titelpost'); + $this->PrestudentModel->addSelect('svnr'); + $this->PrestudentModel->addSelect('ersatzkennzeichen'); + $this->PrestudentModel->addSelect('gebdatum'); + $this->PrestudentModel->addSelect('geschlecht'); + + // semester + // verband + // gruppe + + $this->PrestudentModel->addSelect('UPPER(stg.typ || stg.kurzbz) AS studiengang'); + $this->PrestudentModel->addSelect('tbl_prestudent.studiengang_kz'); + $this->PrestudentModel->addSelect("s.matrikelnr"); + $this->PrestudentModel->addSelect('p.person_id'); + $this->PrestudentModel->addSelect('pls.status_kurzbz AS status'); + $this->PrestudentModel->addSelect('pls.datum AS status_datum'); + $this->PrestudentModel->addSelect('pls.bestaetigtam AS status_bestaetigung'); + $this->PrestudentModel->addSelect( + "(SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp='email' AND person_id=p.person_id AND zustellung LIMIT 1) AS mail_privat", + false + ); + $this->PrestudentModel->addSelect(" + CASE WHEN b.uid IS NOT NULL AND b.uid<>'' + THEN b.uid || " . $this->PrestudentModel->escape(DOMAIN) . " + ELSE '' END AS mail_intern", false); + $this->PrestudentModel->addSelect('p.anmerkung AS anmerkungen'); + $this->PrestudentModel->addSelect('tbl_prestudent.anmerkung'); + $this->PrestudentModel->addSelect('pls.orgform_kurzbz'); + $this->PrestudentModel->addSelect('aufmerksamdurch_kurzbz'); + $this->PrestudentModel->addSelect( + "(SELECT rt_gesamtpunkte AS punkte FROM public.tbl_prestudent WHERE prestudent_id=ps.prestudent_id) AS punkte", + false + ); + $this->PrestudentModel->addSelect('tbl_prestudent.aufnahmegruppe_kurzbz'); + $this->PrestudentModel->addSelect('tbl_prestudent.dual'); + $this->PrestudentModel->addSelect('p.matr_nr'); + $this->PrestudentModel->addSelect('sp.bezeichnung AS studienplan_bezeichnung'); + $this->PrestudentModel->addSelect('tbl_prestudent.prestudent_id'); + + // priorisierung_relativ + + $this->PrestudentModel->addSelect('mentor'); + $this->PrestudentModel->addSelect('b.aktiv AS bnaktiv'); + + /*$this->PrestudentModel->addSelect('tbl_prestudent.reihungstest_id'); + $this->PrestudentModel->addSelect('tbl_prestudent.anmeldungreihungstest'); + $this->PrestudentModel->addSelect('tbl_prestudent.gsstudientyp_kurzbz'); + $this->PrestudentModel->addSelect('tbl_prestudent.priorisierung'); + $this->PrestudentModel->addSelect('p.zugangscode'); + $this->PrestudentModel->addSelect('p.bpk');*/ + + $this->PrestudentModel->db->where_in('tbl_prestudent.studiengang_kz', $this->allowedStgs); + + $this->PrestudentModel->addOrder('nachname'); + $this->PrestudentModel->addOrder('vorname'); + } + + /** + * @return void + */ + protected function addSelectPrioRel() + { + $this->PrestudentModel->addSelect("( + SELECT count(*) + FROM ( + SELECT *, public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) AS laststatus + FROM PUBLIC.tbl_prestudent pss + JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id) + WHERE person_id = p.person_id + AND studiensemester_kurzbz = ( + SELECT studiensemester_kurzbz + FROM PUBLIC.tbl_prestudentstatus + WHERE prestudent_id = tbl_prestudent.prestudent_id + AND status_kurzbz = 'Interessent' + LIMIT 1 + ) + AND status_kurzbz = 'Interessent' + ) prest + WHERE laststatus NOT IN ('Abbrecher', 'Abgewiesener', 'Absolvent') + AND priorisierung <= tbl_prestudent.priorisierung + ) || ' (' || tbl_prestudent.priorisierung || ')' AS priorisierung_relativ", false); + } + + /** + * Adds additional filters to the query + * + * @param string $studiensemester_kurzbz + * + * @return void + */ + protected function addFilter($studiensemester_kurzbz) + { + $filter = $this->input->get('filter'); + if (isset($filter['konto_count_0'])) { + $bt = $this->PrestudentModel->escape($filter['konto_count_0']); + $stdsem = $this->PrestudentModel->escape($studiensemester_kurzbz); + + $this->PrestudentModel->db->where('( + SELECT count(*) + FROM public.tbl_konto + WHERE person_id=tbl_prestudent.person_id + AND buchungstyp_kurzbz=' . $bt . ' + AND studiensemester_kurzbz=' . $stdsem . ' + ) =', 0); + $this->PrestudentModel->db->where('get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) !=', 'Incoming'); + } + if (isset($filter['konto_missing_counter'])) { + $bt = $this->PrestudentModel->escape($filter['konto_missing_counter']); + $stg = ''; + if ($this->variablelib->getVar('kontofilterstg') == 'true') + $stg = ' AND studiengang_kz=tbl_prestudent.studiengang_kz'; + + $bt = $bt == 'alle' ? '' : ' AND buchungstyp_kurzbz=' . $bt; + + $this->PrestudentModel->db->where('( + SELECT sum(betrag) + FROM public.tbl_konto + WHERE person_id=tbl_prestudent.person_id' . + $bt . + $stg . ' + ) !=', 0); + } + } +} diff --git a/application/controllers/api/frontend/v1/stv/Verband.php b/application/controllers/api/frontend/v1/stv/Verband.php new file mode 100644 index 000000000..e8c532652 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Verband.php @@ -0,0 +1,493 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about verbände + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Verband extends FHCAPI_Controller +{ + public function __construct() + { + $permissions = []; + $router = load_class('Router'); + $permissions[$router->method] = ['admin:r', 'assistenz:r']; + parent::__construct($permissions); + + // Load Models + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + } + + /** + * Remap calls: + * / + * /(studiengang_kz) => getStudiengang + * /(studiengang_kz)/(semester) => getSemester + * /(studiengang_kz)/(semester)/(verband) => getVerband + * /(studiengang_kz)/(org_form) => getStudiengang + * /(studiengang_kz)/(org_form)/(semester) => getSemester + * /(studiengang_kz)/(org_form)/(semester)/(verband) => getVerband + * + * @param string $method + * @param array $params (optional) + * + * @return void + */ + public function _remap($method, $params = []) + { + if ($method == '' || $method == 'index') + return $this->getBase(); + + // NOTE(chris): Test if access is allowed ($method is the Studiengang) + if (!$this->permissionlib->isBerechtigt('assistenz', 's', $method) + && !$this->permissionlib->isBerechtigt('admin', 's', $method) + ) { + return $this->_outputAuthError([$method => ['admin:r', 'assistenz:r']]); + } + + $count = count($params); + if (!$count) + return $this->getStudiengang($method); + + if ($count == 1) { + if (is_numeric($params[0])) + return $this->getSemester($method, $params[0]); + elseif ($params[0] == 'prestudent') + return $this->terminateWithSuccess($this->getStdSem($method . '/prestudent/', $method)); + else + return $this->getStudiengang($method, $params[0]); + } + if ($count == 2) { + if (is_numeric($params[0])) + return $this->getVerband($method, $params[0], $params[1]); + elseif ($params[1] == 'prestudent') + return $this->terminateWithSuccess($this->getStdSem($method . '/' . $params[0] . '/prestudent/', $method)); + else + return $this->getSemester($method, $params[1], $params[0]); + } + if ($count == 3 && !is_numeric($params[0]) && is_numeric($params[1]) && !is_numeric($params[2])) + return $this->getVerband($method, $params[1], $params[2], $params[0]); + + show_404(); + } + + /** + * @return void + */ + protected function getBase() + { + $this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz'); + + $this->StudiengangModel->addDistinct(); + $this->StudiengangModel->addSelect("v.studiengang_kz AS link"); + $this->StudiengangModel->addSelect( + "CONCAT(kurzbzlang, ' (', UPPER(CONCAT(typ, kurzbz)), ') - ', tbl_studiengang.bezeichnung) AS name", + false + ); + $this->StudiengangModel->addSelect('erhalter_kz'); + $this->StudiengangModel->addSelect('typ'); + $this->StudiengangModel->addSelect('kurzbz'); + $this->StudiengangModel->addSelect('studiengang_kz'); + $this->StudiengangModel->addSelect('studiengang_kz AS stg_kz'); + + $this->StudiengangModel->addOrder('erhalter_kz'); + $this->StudiengangModel->addOrder('typ'); + $this->StudiengangModel->addOrder('kurzbz'); + + $stgs = $this->permissionlib->getSTG_isEntitledFor('admin') ?: []; + $stgs = array_merge($stgs, $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []); + + if (!$stgs) + $this->terminateWithSuccess([]); + + $this->StudiengangModel->db->where_in('studiengang_kz', $stgs); + + $result = $this->StudiengangModel->loadWhere(['v.aktiv' => true]); + + $list = $this->getDataOrTerminateWithError($result); + + if ($this->permissionlib->isBerechtigt('inout/uebersicht')) + $list[] = [ + 'name' => 'International', + 'link' => 'inout', + 'children' => [ + [ + 'name' => 'Incoming', + 'link' => 'inout/incoming', + 'leaf' => true + ], + [ + 'name' => 'Outgoing', + 'link' => 'inout/outgoing', + 'leaf' => true + ], + [ + 'name' => 'Gemeinsame Studien', + 'link' => 'inout/gemeinsamestudien', + 'leaf' => true + ] + ] + ]; + $this->terminateWithSuccess($list); + } + + /** + * @param integer $studiengang_kz + * @param string $orgform (optional) + * + * @return void + */ + protected function getStudiengang($studiengang_kz, $org_form = null) + { + $link = $studiengang_kz . '/'; + if ($org_form !== null) + $link .= $org_form . '/'; + + $this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz'); + + $this->StudiengangModel->addDistinct(); + $this->StudiengangModel->addSelect("CONCAT(" . $this->StudiengangModel->escape($link) . ", semester) AS link", false); + $this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester ORDER BY verband, gruppe LIMIT 1)) AS name", false); + + $this->StudiengangModel->addSelect('semester'); + $this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false); + + $this->StudiengangModel->addOrder('semester'); + + if ($org_form !== null) { + $this->StudiengangModel->db->group_start(); + $this->StudiengangModel->db->where('v.semester', 0); + $this->StudiengangModel->db->or_where('v.orgform_kurzbz', $org_form); + $this->StudiengangModel->db->group_end(); + } + + $result = $this->StudiengangModel->loadWhere([ + 'v.studiengang_kz' => $studiengang_kz, + 'v.aktiv' => true + ]); + $list = $this->getDataOrTerminateWithError($result); + + array_unshift($list, [ + 'name' => 'PreStudent', + 'link' => $link . 'prestudent', + 'children' => $this->getStdSem($link . 'prestudent/', $studiengang_kz) + ]); + + if ($org_form === null) { + // NOTE(chris): if mischform show orgforms + $result = $this->StudiengangModel->load($studiengang_kz); + $result = $this->getDataOrTerminateWithError($result); + if ($result) { + if (current($result)->mischform) { + $this->load->model('organisation/Studienordnung_model', 'StudienordnungModel'); + + $this->StudienordnungModel->addDistinct(); + $this->StudienordnungModel->addSelect("CONCAT(studiengang_kz, '/', p.orgform_kurzbz) AS link"); + $this->StudienordnungModel->addSelect("p.orgform_kurzbz AS name"); + + $this->StudienordnungModel->addJoin('lehre.tbl_studienplan p', 'studienordnung_id'); + + $result = $this->StudienordnungModel->loadWhere([ + 'aktiv' => true, + 'studiengang_kz' => $studiengang_kz, + 'p.orgform_kurzbz !=' => 'DDP' + ]); + $result = $this->getDataOrTerminateWithError($result); + + $list = array_merge($list, $result); + } + } + + } + $this->terminateWithSuccess($list); + } + + /** + * @param integer $studiengang_kz + * @param integer $semester + * @param string $orgform + * + * @return void + */ + protected function getSemester($studiengang_kz, $semester, $org_form = null) + { + $link = $studiengang_kz . '/'; + if ($org_form !== null) + $link .= $org_form . '/'; + $link .= $semester . '/'; + + + $this->load->model('organisation/Gruppe_model', 'GruppeModel'); + + $this->GruppeModel->addDistinct(); + $this->GruppeModel->addSelect("CONCAT(" . $this->GruppeModel->escape($link . 'grp/') . ", gruppe_kurzbz) AS link", false); + $this->GruppeModel->addSelect("CONCAT(gruppe_kurzbz, ' (', bezeichnung, ')') AS name", false); + $this->GruppeModel->addSelect("TRUE AS leaf", false); + + $this->GruppeModel->addSelect('sort'); + $this->GruppeModel->addSelect('gruppe_kurzbz'); + $this->GruppeModel->addSelect($this->GruppeModel->escape($studiengang_kz) . '::integer AS stg_kz', false); + + $this->GruppeModel->addOrder('sort'); + $this->GruppeModel->addOrder('gruppe_kurzbz'); + + $where = [ + 'studiengang_kz' => $studiengang_kz, + 'semester' => $semester, + 'lehre' => true, + 'sichtbar' => true, + 'aktiv' => true, + 'direktinskription' => false + ]; + + if ($org_form !== null) + $where['orgform_kurzbz'] = $org_form; + + $result = $this->GruppeModel->loadWhere($where); + + $list = $this->getDataOrTerminateWithError($result); + + $this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz'); + + $this->StudiengangModel->addSelect("CONCAT(" . $this->StudiengangModel->escape($link) . ", verband) AS link", false); + $this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband ORDER BY gruppe LIMIT 1)) AS name", false); + $this->StudiengangModel->addSelect("CASE WHEN MAX(gruppe)='' OR MAX(gruppe)=' ' THEN TRUE ELSE FALSE END AS leaf"); + + $this->StudiengangModel->addSelect('verband'); + $this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false); + + $this->StudiengangModel->addOrder('verband'); + + $this->StudiengangModel->addGroupBy('link, name, verband'); + + $where = [ + 'v.studiengang_kz' => $studiengang_kz, + 'v.semester' => $semester, + 'v.verband !=' => '', + 'v.aktiv' => true + ]; + + if ($org_form !== null && $semester) // NOTE(chris): on semester 0 show all? + $where['v.orgform_kurzbz'] = $org_form; + + $result = $this->StudiengangModel->loadWhere($where); + $result = $this->getDataOrTerminateWithError($result); + + $list = array_merge($list, $result); + + $this->terminateWithSuccess($list); + } + + /** + * @param integer $studiengang_kz + * @param integer $semester + * @param integer $verband + * @param string $orgform + * + * @return void + */ + protected function getVerband($studiengang_kz, $semester, $verband, $org_form = null) + { + $link = $studiengang_kz . '/'; + if ($org_form !== null) + $link .= $org_form . '/'; + $link .= $semester . '/'. $verband . '/'; + + + $this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz'); + + $this->StudiengangModel->addDistinct(); + $this->StudiengangModel->addSelect("CONCAT(" . $this->StudiengangModel->escape($link) . ", gruppe) AS link", false); + $this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, gruppe, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband AND gruppe=v.gruppe ORDER BY gruppe LIMIT 1)) AS name", false); + $this->StudiengangModel->addSelect("TRUE AS leaf", false); + + $this->StudiengangModel->addSelect('gruppe'); + $this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false); + + $this->StudiengangModel->addOrder('gruppe'); + + $where = [ + 'v.studiengang_kz' => $studiengang_kz, + 'v.semester' => $semester, + 'v.verband' => $verband, + 'v.gruppe !=' => '', + 'v.aktiv' => true + ]; + + if ($org_form !== null && $semester) // NOTE(chris): on semester 0 show all? + $where['v.orgform_kurzbz'] = $org_form; + + $result = $this->StudiengangModel->loadWhere($where); + + $list = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($list); + } + + /** + * @param string $link + * @param integer $studiengang_kz + * + * @return array + */ + protected function getStdSem($link, $studiengang_kz) + { + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->load->model('system/Variable_model', 'VariableModel'); + $result = $this->VariableModel->getVariables(getAuthUID(), ['number_displayed_past_studiensemester']); + $data = $this->getDataOrTerminateWithError($result); + $number_displayed_past_studiensemester = $data['number_displayed_past_studiensemester'] ?? null; + + $this->StudiensemesterModel->addPlusMinus(null, $number_displayed_past_studiensemester); + $this->StudiensemesterModel->addOrder('ende'); + $result = $this->StudiensemesterModel->load(); + + $studiensemester = $this->getDataOrTerminateWithError($result); + $result = []; + + $studiengang_kz = (int)$studiengang_kz; + + foreach ($studiensemester as $sem) { + $semlink = $link . $sem->studiensemester_kurzbz; + $intlink = $semlink . '/interessenten'; + $result[] = [ + 'name' => $sem->studiensemester_kurzbz, + 'link' => $semlink, + 'stg_kz' => $studiengang_kz, + 'children' => [ + [ + 'name' => 'Interessenten', + 'link' => $intlink, + 'stg_kz' => $studiengang_kz, + 'children' => [ + [ + 'name' => 'Bewerbung nicht abgeschickt', + 'link' => $intlink . '/bewerbungnichtabgeschickt', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ], + [ + 'name' => 'Bewerbung abgeschickt, Status unbestätigt', + 'link' => $intlink . '/bewerbungabgeschickt', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ], + [ + 'name' => 'ZGV erfüllt', + 'link' => $intlink . '/zgv', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ], + [ + 'name' => 'Status bestätigt', + 'link' => $intlink . '/statusbestaetigt', + 'stg_kz' => $studiengang_kz, + 'children' => [ + [ + 'name' => 'Nicht zum Reihungstest angemeldet', + 'link' => $intlink . '/statusbestaetigtrtnichtangemeldet', + 'leaf' => true + ], + [ + 'name' => 'Reihungstest angemeldet', + 'link' => $intlink . '/statusbestaetigtrtangemeldet', + 'leaf' => true + ] + ] + ], + [ + 'name' => 'Nicht zum Reihungstest angemeldet', + 'link' => $intlink . '/reihungstestnichtangemeldet', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ], + [ + 'name' => 'Reihungstest angemeldet', + 'link' => $intlink . '/reihungstestangemeldet', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ] + ] + ], + [ + 'name' => 'Bewerber', + 'link' => $semlink . '/bewerber', + 'stg_kz' => $studiengang_kz, + 'children' => [ + [ + 'name' => 'Nicht zum Reihungstest angemeldet', + 'link' => $intlink . '/bewerberrtnichtangemeldet', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ], + [ + 'name' => 'Reihungstest angemeldet', + 'link' => $intlink . '/bewerberrtangemeldet', + 'stg_kz' => $studiengang_kz, + 'children' => [ + [ + 'name' => 'Teilgenommen', + 'link' => $intlink . '/bewerberrtangemeldetteilgenommen', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ], + [ + 'name' => 'Nicht teilgenommen', + 'link' => $intlink . '/bewerberrtangemeldetnichtteilgenommen', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ] + ] + ] + ] + ], + [ + 'name' => 'Aufgenommen', + 'link' => $semlink . '/aufgenommen', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ], + [ + 'name' => 'Warteliste', + 'link' => $semlink . '/warteliste', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ], + [ + 'name' => 'Absage', + 'link' => $semlink . '/absage', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ], + [ + 'name' => 'Incoming', + 'link' => $semlink . '/incoming', + 'stg_kz' => $studiengang_kz, + 'leaf' => true + ] + ] + ]; + } + + return $result; + } +} diff --git a/application/controllers/codex/UHSTAT1.php b/application/controllers/codex/UHSTAT1.php index 4486f9d74..ff59ef41a 100644 --- a/application/controllers/codex/UHSTAT1.php +++ b/application/controllers/codex/UHSTAT1.php @@ -5,8 +5,12 @@ if (! defined("BASEPATH")) exit("No direct script access allowed"); class UHSTAT1 extends FHC_Controller { const BERECHTIGUNG_UHSTAT_VERWALTEN = 'student/uhstat1daten_verwalten'; + const LOGIN_SESSION_INDEX = 'bewerbung/user'; const PERSON_ID_SESSION_INDEX = 'bewerbung/personId'; const CODEX_OESTERREICH = 'A'; + const CODEX_UNKNOWN_YEAR = 9999; + const CODEX_UNKNOWN_NATION = 'XXX'; + const CODEX_UNKNOWN_BILDUNGMAX = 999; const LOWER_BOUNDARY_YEARS = 160; const UPPER_BOUNDARY_YEARS = 20; @@ -210,7 +214,9 @@ class UHSTAT1 extends FHC_Controller else return true; - if (!isset($bildungsstaat)) return true; + // if no Bildungsstaat or Bildungmax unknown - valid + if (!isset($bildungsstaat) || $bildungmax == self::CODEX_UNKNOWN_BILDUNGMAX) return true; + // find out if abschluss is in Austria $this->AbschlussModel->addSelect("in_oesterreich"); @@ -219,8 +225,11 @@ class UHSTAT1 extends FHC_Controller if (hasData($abschlussRes)) { $in_oesterreich = getData($abschlussRes)[0]->in_oesterreich; - // invalid if abschluss in Austria, but not Bildungsstaat, or abschluss not in Austria, but Bildungsstaat in Austria - return ($in_oesterreich && $bildungsstaat == self::CODEX_OESTERREICH) || (!$in_oesterreich && $bildungsstaat != self::CODEX_OESTERREICH); + + // valid if Bildungsstaat and Abschluss in Austria, or Bildungsstaat and Abschluss not in Austria + // (or Abschluss not in Austria and Bildungsstaat unknown) + return ($in_oesterreich && $bildungsstaat == self::CODEX_OESTERREICH) + || (!$in_oesterreich && ($bildungsstaat != self::CODEX_OESTERREICH || $bildungsstaat == self::CODEX_UNKNOWN_NATION)); } return false; @@ -363,7 +372,11 @@ class UHSTAT1 extends FHC_Controller // get realistic birth years, dated back from current year $currYear = date("Y"); - $formMetaData['jahre'] = range($currYear - self::UPPER_BOUNDARY_YEARS, $currYear - self::LOWER_BOUNDARY_YEARS); + $yearRange = range($currYear - self::UPPER_BOUNDARY_YEARS, $currYear - self::LOWER_BOUNDARY_YEARS); + $formMetaData['jahre'] = array_combine($yearRange, $yearRange); + + // add "unknown" option + $formMetaData['jahre'][self::CODEX_UNKNOWN_YEAR] = 'unbekannt'; return success($formMetaData); } @@ -411,7 +424,10 @@ class UHSTAT1 extends FHC_Controller private function _getValidPersonId($berechtigungsArt) { // if coming from bewerbungstool - person id is in session (person must be logged in bewerbungstool) - if (isset($_SESSION[self::PERSON_ID_SESSION_INDEX]) && is_numeric($_SESSION[self::PERSON_ID_SESSION_INDEX])) + if (isset($_SESSION[self::PERSON_ID_SESSION_INDEX]) + && is_numeric($_SESSION[self::PERSON_ID_SESSION_INDEX]) + && isset($_SESSION[self::LOGIN_SESSION_INDEX]) + ) return $_SESSION[self::PERSON_ID_SESSION_INDEX]; // if person id passed directly... diff --git a/application/controllers/components/stv/Noten.php b/application/controllers/components/stv/Noten.php new file mode 100644 index 000000000..fb61de065 --- /dev/null +++ b/application/controllers/components/stv/Noten.php @@ -0,0 +1,168 @@ + 'student/noten:r', + 'getZeugnis' => 'student/noten:r', + 'update' => ['admin:w', 'assistenz:w'] + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + } + + public function get() + { + $this->load->model('codex/Note_model', 'NoteModel'); + + $result = $this->NoteModel->addOrder('note'); + + $result = $this->NoteModel->load(); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + } + + return $this->outputJson($result); + } + + public function getZeugnis($prestudent_id, $all = null) + { + $this->load->model('crm/Student_model', 'StudentModel'); + $this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel'); + + $result = $this->StudentModel->loadWhere([ + 'prestudent_id' => $prestudent_id + ]); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + return $this->outputJson($result); + } + if (!hasData($result)) + return $this->outputJsonSuccess(null); + + $student_uid = current(getData($result))->student_uid; + + $studiensemester_kurzbz = ($all === null) ? $this->variablelib->getVar('semester_aktuell') : null; + + $result = $this->ZeugnisnoteModel->getZeugnisnoten($student_uid, $studiensemester_kurzbz); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + } + + return $this->outputJson($result); + } + + public function update() + { + $this->load->model('crm/Student_model', 'StudentModel'); + $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel'); + + $this->load->library('form_validation'); + + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + if (empty($_POST) || !is_array(current($_POST))) { + $result = $this->hasPermissionUpdate($this->input->post('lehrveranstaltung_id'), $this->input->post('student_uid')); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN); + return $this->outputJson($result); + } + + $this->form_validation->set_rules('lehrveranstaltung_id', 'Lehrverantaltung ID', 'required|numeric'); + $this->form_validation->set_rules('student_uid', 'Student UID', 'required'); + $this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester Kurzbezeichnung', 'required'); + $this->form_validation->set_rules('note', 'Note', 'required|numeric'); + $post = [$_POST]; + } else { + foreach ($_POST as $i => $data) { + $lvid = isset($data['lehrveranstaltung_id']) ? $data['lehrveranstaltung_id'] : null; + $uid = isset($data['student_uid']) ? $data['student_uid'] : null; + $result = $this->hasPermissionUpdate($lvid, $uid); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN); + return $this->outputJson($result); + } + + $this->form_validation->set_rules($i . '[lehrveranstaltung_id]', '#' . $i . ' Lehrverantaltung ID', 'required|numeric'); + $this->form_validation->set_rules($i . '[student_uid]', '#' . $i . ' Student UID', 'required'); + $this->form_validation->set_rules($i . '[studiensemester_kurzbz]', '#' . $i . ' Studiensemester Kurzbezeichnung', 'required'); + $this->form_validation->set_rules($i . '[note]', '#' . $i . ' Note', 'required|numeric'); + } + $post = $_POST; + } + if ($this->form_validation->run() == false) { + $this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST); + return $this->outputJsonError($this->form_validation->error_array()); + } + + $final_result = success(); + $this->ZeugnisnoteModel->db->trans_start(); + + foreach ($post as $i => $data) { + $note = $data['note']; + unset($data['note']); + $result = $this->ZeugnisnoteModel->update($data, [ + 'note' => $note, + 'benotungsdatum' => date('c'), + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ]); + if (isError($result)) { + $final_result = $result; + break; + } + } + + $this->ZeugnisnoteModel->db->trans_complete(); + + if (isError($final_result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + } + + $this->outputJson($final_result); + } + + protected function hasPermissionUpdate($lehrveranstaltung_id, $student_uid) + { + // TODO(chris): error phrases! + if ($lehrveranstaltung_id === null || $student_uid === null) + return success(); + $result = $this->StudentModel->load([$student_uid]); + if (isError($result)) + return $result; + if (!hasData($result)) + return error('Fehler beim Ermitteln des Studenten'); + $student = current(getData($result)); + + if ($this->permissionlib->isBerechtigt('admin', 'suid', $student->studiengang_kz)) + return success(); + if ($this->permissionlib->isBerechtigt('assistenz', 'suid', $student->studiengang_kz)) + return success(); + + $result = $this->StudienplanModel->getAllOesForLv($lehrveranstaltung_id); + if (isError($result)) + return $result; + $oes = getData($result) ?: []; + $result = $this->LehrveranstaltungModel->getStg($lehrveranstaltung_id); + if (isError($result)) + return $result; + if (hasData($result)) + $oes[] = current(getData($result)); + + foreach ($oes as $oe) { + if ($this->permissionlib->isBerechtigt('admin', 'suid', $oe->oe_kurzbz)) + return success(); + if ($this->permissionlib->isBerechtigt('assistenz', 'suid', $oe->oe_kurzbz)) + return success(); + } + + return error('Forbidden'); + } +} diff --git a/application/controllers/components/stv/Studienplan.php b/application/controllers/components/stv/Studienplan.php new file mode 100644 index 000000000..b60388ac1 --- /dev/null +++ b/application/controllers/components/stv/Studienplan.php @@ -0,0 +1,43 @@ + self::PERM_LOGGED + ]); + } + + public function get() + { + $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + + $_POST = json_decode($this->input->raw_input_stream, true); + + $this->load->library('form_validation'); + + $this->form_validation->set_rules('studiengang_kz', 'StudiengangKz', 'required|numeric'); + $this->form_validation->set_rules('studiensemester_kurzbz', 'StudiensemesterKurbz', 'required'); + $this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'numeric'); + + if ($this->form_validation->run() == false) { + $this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST); + return $this->outputJsonError($this->form_validation->error_array()); + } + + $studiengang_kz = $this->input->post('studiengang_kz'); + $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); + $ausbildungssemester = $this->input->post('ausbildungssemester') ?: null; + $orgform_kurzbz = $this->input->post('orgform_kurzbz') ?: null; + + $result = $this->StudienplanModel->getStudienplaeneBySemester($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester, $orgform_kurzbz); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + } + $this->outputJson($result); + } +} diff --git a/application/controllers/components/stv/Studiensemester.php b/application/controllers/components/stv/Studiensemester.php new file mode 100644 index 000000000..c3db99686 --- /dev/null +++ b/application/controllers/components/stv/Studiensemester.php @@ -0,0 +1,78 @@ + self::PERM_LOGGED, + 'now' => self::PERM_LOGGED, + 'set' => self::PERM_LOGGED + ]); + } + + public function index() + { + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->StudiensemesterModel->addOrder('start'); + + $result = $this->StudiensemesterModel->load(); + + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + } + $this->outputJson($result); + } + + public function now() + { + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $result = $this->StudiensemesterModel->getNearest(); + + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } + $result = getData($result) ?: []; + + if (count($result) != 1) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJsonError(count($result) ? 'Mehrere Studiensemester aktiv' : 'Kein Studiensemester aktiv'); + } else { + $this->outputJsonSuccess(current($result)->studiensemester_kurzbz); + } + } + + public function set() + { + $this->load->library('AuthLib'); + $this->load->library('form_validation'); + + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + $this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required'); + + if ($this->form_validation->run() == false) { + $this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST); + return $this->outputJsonError($this->form_validation->error_array()); + } + + $stdsem = $this->input->post('studiensemester'); + + $this->load->model('system/Variable_model', 'VariableModel'); + + $result = $this->VariableModel->setVariable(getAuthUID(), 'semester_aktuell', $stdsem); + + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + return $this->outputJson($result); + } + + $this->outputJsonSuccess(true); + } +} diff --git a/application/controllers/jobs/AntragJob.php b/application/controllers/jobs/AntragJob.php index 0bac8794f..46a31f3d6 100644 --- a/application/controllers/jobs/AntragJob.php +++ b/application/controllers/jobs/AntragJob.php @@ -29,6 +29,10 @@ class AntragJob extends JOB_Controller $this->load->model('crm/Student_model', 'StudentModel'); $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->loadPhrases([ + 'lehre' + ]); } /** @@ -417,7 +421,7 @@ class AntragJob extends JOB_Controller $this->StudierendenantragModel->db->where_in( 'public.get_rolle_prestudent(prestudent_id, studiensemester_kurzbz)', - $this->config->item('antrag_prestudentstatus_whitelist') + $this->config->item('antrag_prestudentstatus_whitelist_abmeldung') ); $result = $this->StudierendenantragModel->getWithLastStatusWhere([ @@ -451,11 +455,23 @@ class AntragJob extends JOB_Controller if (isError($result)) $this->logError(getError($result)); + $this->load->model('crm/Statusgrund_model', 'StatusgrundModel'); + $result = $this->StatusgrundModel->loadWhere(['statusgrund_kurzbz' => 'abbrecherStgl']); + if (isError($result)) { + $this->logError(getError($result)); + continue; + } elseif (!hasData($result)) { + $this->logError($this->p->t('lehre', 'error_noStatusgrund', ['statusgrund_kurzbz' => 'abbrecherStgl'])); + continue; + } + + $statusgrund = current(getData($result)); + $result = $this->prestudentlib->setAbbrecher( $antrag->prestudent_id, $antrag->studiensemester_kurzbz, 'AntragJob', - 'abbrecherStgl', + $statusgrund->statusgrund_id, $antrag->insertamum, null, $antrag->insertvon ?: $insertvon diff --git a/application/controllers/jobs/IssueResolver.php b/application/controllers/jobs/IssueResolver.php index be66a6b23..ca07439c3 100755 --- a/application/controllers/jobs/IssueResolver.php +++ b/application/controllers/jobs/IssueResolver.php @@ -9,8 +9,8 @@ class IssueResolver extends IssueResolver_Controller { parent::__construct(); - // set fehler codes which can be resolved by the job - // structure: fehlercode => class (library) name for resolving + // set fehler codes which can be resolved by the job, with own resolver defined + // structure: fehlercode => class (library) name for resolving in "resolvers" folder $this->_codeLibMappings = array( 'CORE_ZGV_0001' => 'CORE_ZGV_0001', 'CORE_ZGV_0002' => 'CORE_ZGV_0002', @@ -30,7 +30,6 @@ class IssueResolver extends IssueResolver_Controller 'CORE_STG_0002' => 'CORE_STG_0002', 'CORE_STG_0003' => 'CORE_STG_0003', 'CORE_STG_0004' => 'CORE_STG_0004', - 'CORE_STUDENTSTATUS_0001' => 'CORE_STUDENTSTATUS_0001', 'CORE_STUDENTSTATUS_0002' => 'CORE_STUDENTSTATUS_0002', 'CORE_STUDENTSTATUS_0003' => 'CORE_STUDENTSTATUS_0003', 'CORE_STUDENTSTATUS_0004' => 'CORE_STUDENTSTATUS_0004', @@ -51,5 +50,11 @@ class IssueResolver extends IssueResolver_Controller 'CORE_PERSON_0003' => 'CORE_PERSON_0003', 'CORE_PERSON_0004' => 'CORE_PERSON_0004' ); + + // fehler which are resolved by the job the same way as they are produced + // structure: fehlercode => class (library) name for resolving in "plausichecks" folder + $this->_codeProducerLibMappings = array( + 'CORE_STUDENTSTATUS_0001' => 'AbbrecherAktiv', + ); } } diff --git a/application/controllers/jobs/OneTimeMessages.php b/application/controllers/jobs/OneTimeMessages.php index 58bc1fb7c..525f63c3b 100644 --- a/application/controllers/jobs/OneTimeMessages.php +++ b/application/controllers/jobs/OneTimeMessages.php @@ -51,7 +51,7 @@ class OneTimeMessages extends JOB_Controller FROM public.tbl_prestudent p JOIN public.tbl_prestudentstatus ps USING (prestudent_id) JOIN public.tbl_studiengang s USING (studiengang_kz) - WHERE ps.status_kurzbz = \'Wartender\' + WHERE get_rolle_prestudent(ps.prestudent_id, NULL) = \'Wartender\' AND ps.studiensemester_kurzbz = ? AND ps.datum <= NOW() - \''.$days.' days\'::interval AND s.typ = ? diff --git a/application/controllers/lehre/anrechnung/RequestAnrechnung.php b/application/controllers/lehre/anrechnung/RequestAnrechnung.php index 3cba756cf..ebc272e3e 100644 --- a/application/controllers/lehre/anrechnung/RequestAnrechnung.php +++ b/application/controllers/lehre/anrechnung/RequestAnrechnung.php @@ -111,8 +111,13 @@ class requestAnrechnung extends Auth_Controller $lehrveranstaltung_id = $this->input->post('lv_id'); $studiensemester_kurzbz = $this->input->post('studiensemester'); $bestaetigung = $this->input->post('bestaetigung'); - $begruendung_ects = $this->input->post('begruendung_ects'); - $begruendung_lvinhalt = $this->input->post('begruendung_lvinhalt'); + $begruendung_ects = $this->config->item('explain_equivalence') === TRUE + ? $this->input->post('begruendung_ects') + : NULL; + $begruendung_lvinhalt = $this->config->item('explain_equivalence') === TRUE + ? $this->input->post('begruendung_lvinhalt') + : NULL; + // Validate data if (empty($_FILES['uploadfile']['name'])) @@ -124,8 +129,8 @@ class requestAnrechnung extends Auth_Controller isEmptyString($anmerkung) || isEmptyString($lehrveranstaltung_id) || isEmptyString($studiensemester_kurzbz) || - isEmptyString($begruendung_ects) || - isEmptyString($begruendung_lvinhalt)) + ($this->config->item('explain_equivalence') === TRUE && isEmptyString($begruendung_ects)) || + ($this->config->item('explain_equivalence') === TRUE && isEmptyString($begruendung_lvinhalt))) { return $this->outputJsonError($this->p->t('ui', 'errorFelderFehlen')); } @@ -168,7 +173,7 @@ class requestAnrechnung extends Auth_Controller // Hold just inserted DMS ID $lastInsert_dms_id = $result->retval['dms_id']; - + // Save Anrechnung and Anrechnungstatus $result = $this->AnrechnungModel->createAnrechnungsantrag( $prestudent_id, diff --git a/application/core/Auth_Controller.php b/application/core/Auth_Controller.php index d170a7eca..466627fe3 100644 --- a/application/core/Auth_Controller.php +++ b/application/core/Auth_Controller.php @@ -67,6 +67,108 @@ abstract class Auth_Controller extends FHC_Controller } } + /** + * Checks for Permissions depending if the given person is a + * Mitarbeiter and/or Student + * and exits/outputs an error if they are not met. + * + * @param integer $person_id + * @param array $permMa Perms if the person is a Mitarbeiter + * @param array $permStud Perms if the person is a Student + * + * @return void + */ + protected function checkPermissionsForPerson($person_id, $permMa, $permStud) + { + $res = $this->hasPermissionsForPerson($person_id, $permMa, $permStud); + + if ($res) { + $perm = array_keys(array_flip(array_merge($res|1 ? $permMa : [], $res|2 ? $permStud : []))); + $this->_outputAuthError([$this->router->method => $perm]); + } + } + + /** + * Checks for Permissions depending on the Studiengang of a Prestudent + * and exits/outputs an error if they are not met. + * + * @param integer $prestudent_id + * @param array $permStud Perms if the person is a Student + * + * @return void + */ + protected function checkPermissionsForPrestudent($prestudent_id, $permStud) + { + if (!$this->hasPermissionsForPrestudent($prestudent_id, $permStud)) { + $this->_outputAuthError([$this->router->method => $permStud]); + } + } + + /** + * Checks for Permissions depending if the given person is a + * Mitarbeiter and/or Student + * and returns the result. + * + * @param integer $person_id + * @param array $permMa Perms if the person is a Mitarbeiter + * @param array $permStud Perms if the person is a Student + * + * @return integer 0 if permission is granted + */ + protected function hasPermissionsForPerson($person_id, $permMa, $permStud) + { + $res = 3; + $this->load->model('person/Person_model', 'PersonModel'); + $this->PersonModel->addJoin('public.tbl_benutzer', 'person_id'); + $this->PersonModel->addJoin('public.tbl_mitarbeiter', 'uid = mitarbeiter_uid'); + $result = $this->PersonModel->load($person_id); + if (hasData($result)) { + if ($this->permissionlib->isEntitled(['a' => $permMa], 'a')) + return 0; + $res = 1; + } + $this->PersonModel->addJoin('public.tbl_prestudent', 'person_id'); + $result = $this->PersonModel->load($person_id); + if (hasData($result)) { + $permStudConverted = []; + foreach (getData($result) as $row) { + foreach ($permStud as $k => $v) { + if (!isset($permStudConverted[$k])) { + $permStudConverted[$k] = $this->permissionlib->convertAccessType($v); + } + if ($this->permissionlib->isBerechtigt($permStudConverted[$k][0], $permStudConverted[$k][1], $row->studiengang_kz)) + return 0; + } + } + $res += 2; + } + return $res; + } + + /** + * Checks for Permissions depending on the Studiengang of a Prestudent + * and returns the result. + * + * @param integer $prestudent_id + * @param array $permStud Perms if the person is a Student + * + * @return boolean + */ + protected function hasPermissionsForPrestudent($prestudent_id, $permStud) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $result = $this->PrestudentModel->load($prestudent_id); + if (!hasData($result)) + show_404(); + $stg = current(getData($result))->studiengang_kz; + foreach ($permStud as $k => $v) { + $perm = $this->permissionlib->convertAccessType($v); + if ($this->permissionlib->isBerechtigt($perm[0], $perm[1], $stg)) + return true; + } + return false; + } + /** * Outputs an error message and sets the HTTP Header. * This function is protected so that it can be overwritten. diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index 79040dc66..c799de516 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -827,6 +827,23 @@ class DB_Model extends CI_Model return $result; } + public function getDbTable() + { + return $this->dbTable; + } + + public function getPk() + { + return $this->pk; + } + + public function getPks() + { + if (is_array($this->pk)) + return $this->pk; + return [$this->pk]; + } + // ------------------------------------------------------------------------------------------ // Protected methods diff --git a/application/core/FHCAPI_Controller.php b/application/core/FHCAPI_Controller.php index 647032795..36388e271 100644 --- a/application/core/FHCAPI_Controller.php +++ b/application/core/FHCAPI_Controller.php @@ -94,7 +94,7 @@ class FHCAPI_Controller extends Auth_Controller // --------------------------------------------------------------- /** - * @param array $data + * @param string|array|object $data * @param string $type (optional) * @return void */ @@ -110,6 +110,8 @@ class FHCAPI_Controller extends Auth_Controller $error['messages'] = $data; else $error = $data; + } elseif (is_object($data)) { + $error = (array)$data; } else { $error['message'] = $data; } @@ -117,6 +119,9 @@ class FHCAPI_Controller extends Auth_Controller if ($type) $error['type'] = $type; + if (!isset($error['type'])) + $error['type'] = self::ERROR_TYPE_GENERAL; + $this->returnObj['errors'][] = $error; } diff --git a/application/core/IssueResolver_Controller.php b/application/core/IssueResolver_Controller.php index 758064ed8..ea278ddb0 100755 --- a/application/core/IssueResolver_Controller.php +++ b/application/core/IssueResolver_Controller.php @@ -5,21 +5,18 @@ */ abstract class IssueResolver_Controller extends JOB_Controller { - const CI_PATH = 'application'; - const CI_LIBRARY_FOLDER = 'libraries'; - const EXTENSIONS_FOLDER = 'extensions'; - const ISSUE_RESOLVERS_FOLDER = 'issues/resolvers'; - const CHECK_ISSUE_RESOLVED_METHOD_NAME = 'checkIfIssueIsResolved'; + // mappings in form fehlercode -> resolverlibrary name, fehler which have explicit resolver class defined + protected $_codeLibMappings = []; - protected $_codeLibMappings; + // mappings in form fehlercode -> producer library name, fehler which are resolved the same way they are produced + protected $_codeProducerLibMappings = []; public function __construct() { parent::__construct(); + // pass extension name if calling from extension $this->load->model('system/Issue_model', 'IssueModel'); - - $this->load->library('IssuesLib'); } /** @@ -27,97 +24,29 @@ abstract class IssueResolver_Controller extends JOB_Controller */ public function run() { + $this->load->library( + 'issues/PlausicheckResolverLib', + [ + 'extensionName' => $this->_extensionName ?? null, + 'codeLibMappings' => $this->_codeLibMappings, + 'codeProducerLibMappings' => $this->_codeProducerLibMappings + ] + ); + $this->logInfo("Issue resolve job started"); // load open issues with given errorcodes - $openIssuesRes = $this->IssueModel->getOpenIssues(array_keys($this->_codeLibMappings)); + $openIssuesRes = $this->IssueModel->getOpenIssues( + array_merge(array_keys($this->_codeLibMappings), array_keys($this->_codeProducerLibMappings)) + ); - // log error if occured - if (isError($openIssuesRes)) - { - $this->logError(getError($openIssuesRes)); - } - else - { - // log info if no data found - if (!hasData($openIssuesRes)) - { - $this->logInfo("No open issues found"); - } - else - { - $openIssues = getData($openIssuesRes); + $openIssues = hasData($openIssuesRes) ? getData($openIssuesRes) : []; - foreach ($openIssues as $issue) - { - // ignore if Fehlercode is not in libmappings (shouldn't be checked) - if (!isset($this->_codeLibMappings[$issue->fehlercode])) continue; + $result = $this->plausicheckresolverlib->resolvePlausicheckIssues($openIssues); - $libName = $this->_codeLibMappings[$issue->fehlercode]; - - // add person id and oe kurzbz automatically as params, merge it with additional params - // decode bewerbung_parameter into assoc array - $params = array_merge( - array('issue_id' => $issue->issue_id, 'issue_person_id' => $issue->person_id, 'issue_oe_kurzbz' => $issue->oe_kurzbz), - isset($issue->behebung_parameter) ? json_decode($issue->behebung_parameter, true) : array() - ); - - // if called from extension (extension name set), path includes extension names - $libRootPath = isset($this->_extensionName) ? self::EXTENSIONS_FOLDER . '/' . $this->_extensionName . '/' : ''; - - // path for loading issue library - $issuesLibPath = $libRootPath . self::ISSUE_RESOLVERS_FOLDER . '/'; - - // file path of library for check if file exists - $issuesLibFilePath = DOC_ROOT . self::CI_PATH - . '/' . $libRootPath . self::CI_LIBRARY_FOLDER . '/' . self::ISSUE_RESOLVERS_FOLDER . '/' . $libName . '.php'; - - // check if library file exists - if (!file_exists($issuesLibFilePath)) - { - // log error and continue with next issue if not - $this->logError("Issue library file " . $issuesLibFilePath . " does not exist"); - continue; - } - - // load library connected to fehlercode - $this->load->library($issuesLibPath . $libName); - - $lowercaseLibName = mb_strtolower($libName); - - // check if method is defined in library class - if (!is_callable(array($this->{$lowercaseLibName}, self::CHECK_ISSUE_RESOLVED_METHOD_NAME))) - { - // log error and continue with next issue if not - $this->logError("Method " . self::CHECK_ISSUE_RESOLVED_METHOD_NAME . " is not defined in library $lowercaseLibName"); - continue; - } - - // call the function for checking for issue resolution - $issueResolvedRes = $this->{$lowercaseLibName}->{self::CHECK_ISSUE_RESOLVED_METHOD_NAME}($params); - - if (isError($issueResolvedRes)) - { - $this->logError(getError($issueResolvedRes)); - } - else - { - $issueResolvedData = getData($issueResolvedRes); - - if ($issueResolvedData === true) - { - // set issue to resolved if needed - $behobenRes = $this->issueslib->setBehoben($issue->issue_id, null); - - if (isError($behobenRes)) - $this->logError(getError($behobenRes)); - else - $this->logInfo("Issue " . $issue->issue_id . " successfully resolved"); - } - } - } - } - } + // log if error, or log info if inserted new issue + foreach ($result->errors as $error) $this->logError($error); + foreach ($result->infos as $info) $this->logInfo($info); $this->logInfo("Issue resolve job ended"); } diff --git a/application/core/Notiz_Controller.php b/application/core/Notiz_Controller.php new file mode 100644 index 000000000..05f70ee85 --- /dev/null +++ b/application/core/Notiz_Controller.php @@ -0,0 +1,461 @@ + self::DEFAULT_PERMISSION_R, + 'getNotizen' => self::DEFAULT_PERMISSION_R, + 'loadNotiz' => self::DEFAULT_PERMISSION_R, + 'addNewNotiz' => self::DEFAULT_PERMISSION_RW, + 'updateNotiz' => self::DEFAULT_PERMISSION_RW, + 'deleteNotiz' => self::DEFAULT_PERMISSION_RW, + 'loadDokumente' => self::DEFAULT_PERMISSION_R, + 'getMitarbeiter' => self::DEFAULT_PERMISSION_R, + 'isBerechtigt' => self::DEFAULT_PERMISSION_R, + ]; + + if(!is_array($permissions)) + { + $this->terminateWithError("Notiz_controller construct: permissions must be an array"); + } + + $merged_permissions = array_merge($default_permissions, $permissions); + + parent::__construct($merged_permissions); + + //Load Models + $this->load->model('person/Notiz_model', 'NotizModel'); + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + } + + public function getUid() + { + $this->terminateWithSuccess(getAuthUID()); + } + + + //Override function for extensions + protected function assignNotiz($notiz_id, $id, $type) + { + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + $result = $this->NotizzuordnungModel->isValidType($type); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, $type => $id)); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return success(getData($result)); + } + + //Override function for extensions + protected function deleteNotizzuordnung($notiz_id, $id, $type) + { + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + $result = $this->NotizzuordnungModel->isValidType($type); + if (isError($result)) { + $this->terminateWithError('type not in table notizzuordnung enthalten..', self::ERROR_TYPE_GENERAL); + } + + $result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return success(getData($result)); + } + + + //Override function for extensions + public function getNotizen($id, $type) + { + $result = $this->NotizzuordnungModel->isValidType($type); + if(isError($result)) + $this->terminateWithError($result->retval, self::ERROR_TYPE_GENERAL); + + $result = $this->NotizModel->getNotizWithDocEntries($id, $type); + + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + + //Override function + protected function isBerechtigt($id, $typeId){ + return $this->terminateWithError("in abstract function: define right in extension", self::ERROR_TYPE_GENERAL); + } + + public function loadNotiz() + { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + $notiz_id = $this->input->post('notiz_id'); + + //$this->load->model('person/Notiz_model', 'NotizModel'); + $this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT'); + $this->NotizModel->addSelect('*'); + $this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum + THEN public.tbl_notiz.updateamum ELSE public.tbl_notiz.insertamum END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate"); + $this->NotizModel->addLimit(1); + + $result = $this->NotizModel->loadWhere( + array('notiz_id' => $notiz_id) + ); + if (isError($result)) + { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + elseif (!hasData($result)) + { + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL); + } + else + { + $this->terminateWithSuccess(current(getData($result))); + } + } + + public function addNewNotiz($id, $paramTyp = null) + { + $this->load->library('DmsLib'); + $this->load->library('form_validation'); + + $uid = getAuthUID(); + + if (isset($_POST['data'])) + { + $data = json_decode($_POST['data']); + unset($_POST['data']); + foreach ($data as $k => $v) { + $_POST[$k] = $v; + } + } + + //Form Validation + $this->form_validation->set_rules('titel', 'Titel', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel']) + ]); + + $this->form_validation->set_rules('text', 'Text', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $titel = $this->input->post('titel'); + $text = $this->input->post('text'); + $erledigt = $this->input->post('erledigt'); + $verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid; + $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : null; + $type = $this->input->post('typeId'); + $start = $this->input->post('start'); + $ende = $this->input->post('ende'); + + // Start DB transaction + $this->db->trans_start(); + + //Save note + $result = $this->NotizModel->insert(array('titel' => $titel, 'text' => $text, 'erledigt' => $erledigt, 'verfasser_uid' => $verfasser_uid, + "insertvon" => $verfasser_uid, 'start' => $start, 'ende' => $ende, 'bearbeiter_uid' => $bearbeiter_uid)); + + if (isError($result)) + { + $this->db->trans_rollback(); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + $notiz_id = $result->retval; + + //save Notizzuordnung + $result = $this->assignNotiz($notiz_id, $id, $type); + + if (isError($result)) + { + $this->db->trans_rollback(); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + //save Documents + $dms_id_arr = []; + foreach ($_FILES as $k => $file) + { + $dms = array( + 'kategorie_kurzbz' => 'notiz', + 'version' => 0, + 'name' => $file["name"], + 'mimetype' => $file["type"], + 'insertamum' => date('c'), + 'insertvon' => $uid + ); + + //Todo(manu) check if filetypes weiter eingeschränkt werden sollen + //Todo(manu)check name files: nicht gleiches file 2mal hochladen + //Todo define in dms component: readFile, downloadFile + $result = $this->dmslib->upload($dms, $k, ['*']); + /* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/ + if (isError($result)) + { + $this->db->trans_rollback(); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $dms_id_arr[] = $result->retval['dms_id']; + } + + //save entry in Notizdokument + if($dms_id_arr) + { + $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); + foreach($dms_id_arr as $dms_id) + { + $result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id)); + if (isError($result)) + { + $this->db->trans_rollback(); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + } + } + $this->db->trans_commit(); + return $this->terminateWithSuccess($result); + } + + public function updateNotiz() + { + $this->load->library('form_validation'); + $this->load->library('DmsLib'); + + if (isset($_POST['data'])) + { + $data = json_decode($_POST['data']); + unset($_POST['data']); + foreach ($data as $k => $v) { + $_POST[$k] = $v; + } + } + + $notiz_id = $this->input->post('notiz_id'); + + if(!$notiz_id) + { + $this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL); + } + + //Form Validation + $this->form_validation->set_rules('titel', 'Titel', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel']) + ]); + + $this->form_validation->set_rules('text', 'Text', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + //update Notiz + $uid = getAuthUID(); + $titel = $this->input->post('titel'); + $text = $this->input->post('text'); + $verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid; + $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid; + $erledigt = $this->input->post('erledigt'); + $start = $this->input->post('start'); + $ende = $this->input->post('ende'); + + $result = $this->NotizModel->update( + [ + 'notiz_id' => $notiz_id + ], + [ + 'titel' => $titel, + 'updatevon' => $uid, + 'updateamum' => date('c'), + 'text' => $text, + 'verfasser_uid' => $verfasser_uid, + 'bearbeiter_uid' => $bearbeiter_uid, + 'start' => $start, + 'ende' => $ende, + 'erledigt' => $erledigt + ] + ); + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + //update(1) loading all dms-entries with this notiz_id + $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); + $this->NotizdokumentModel->addJoin('campus.tbl_dms_version', 'dms_id'); + + $result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id)); + $result = $this->getDataOrTerminateWithError($result); + foreach ($result as $doc) { + $dms_id_arr[$doc->dms_id] = array( + 'name' => $doc->name, + 'dms_id' => $doc->dms_id + ); + } + + foreach ($_FILES as $k => $file) + { + //update(2) attach all new files (except type application/x.fhc-dms+json) + if($file["type"] == 'application/x.fhc-dms+json') + { + $jsonFile = json_decode(file_get_contents($file['tmp_name'])); + unset($dms_id_arr[$jsonFile->dms_id]); + #$dms_uploaded[] = $jsonFile->dms_id; + } + else + { + $dms = array( + 'kategorie_kurzbz' => 'notiz', + 'version' => 0, + 'name' => $file["name"], + 'mimetype' => $file["type"], + 'insertamum' => date('c'), + 'insertvon' => $uid + ); + + //Todo(manu) check if filetypes weiter eingeschränkt werden sollen + //Todo(manu)check name files: nicht gleiches file 2mal hochladen + //Todo define in dms component: readFile, downloadFile + $result = $this->dmslib->upload($dms, $k, array('*')); + + $result = $this->getDataOrTerminateWithError($result); + $dms_id = $result['dms_id']; + + $result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id)); + + $this->getDataOrTerminateWithError($result); + } + } + + //update(3) check if all files have been deleted + foreach ($dms_id_arr as $file) + { + $result = $this->dmslib->removeAll($file['dms_id']); + + $this->getDataOrTerminateWithError($result); + } + + return $this->terminateWithSuccess($result); + } + + public function deleteNotiz() + { + $this->load->library('DmsLib'); + + $notiz_id = $this->input->post('notiz_id'); + $typeId = $this->input->post('type_id'); + $id = $this->input->post('id'); + + //TODO(manu): define Permissions for deletion document if filecomponent finished + + //get dms_id from notizdokument + $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); + + $result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id)); + + $result = $this->getDataOrTerminateWithError($result); + + // Start DB transaction + $this->db->trans_start(); + + if ($result) + $this->load->library('DmsLib'); + + foreach ($result as $doc) { + $res = $this->dmslib->removeAll($doc->dms_id); + if (isError($result)) + { + $this->db->trans_rollback(); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + } + + //delete Notizzuordnung + $result = $this-> deleteNotizzuordnung($notiz_id, $id, $typeId); + if (isError($result)) + { + $this->db->trans_rollback(); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + $this->load->model('person/Notiz_model', 'NotizModel'); + + //Delete Note + $result = $this->NotizModel->delete($notiz_id); + + if (isError($result)) + { + $this->db->trans_rollback(); + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if(!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); + } + + $this->db->trans_complete(); + return $this->terminateWithSuccess(getData($result)); + } + + public function loadDokumente() + { + $notiz_id = $this->input->post('notiz_id'); + + $this->NotizModel->addSelect('campus.tbl_dms_version.*'); + + $this->NotizModel->addJoin('public.tbl_notiz_dokument', 'ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)'); + $this->NotizModel->addJoin('campus.tbl_dms_version', 'ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)'); + + $result = $this->NotizModel->loadWhere( + array('public.tbl_notiz.notiz_id' => $notiz_id) + ); + if (isError($result)) { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + if(!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result)); + } + + public function getMitarbeiter($searchString) + { + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); + $result = $this->MitarbeiterModel->searchMitarbeiter($searchString); + if (isError($result)) { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess($result); + } + +} \ No newline at end of file diff --git a/application/core/PlausiIssueProducer_Controller.php b/application/core/PlausiIssueProducer_Controller.php index 0dce7a487..5216d284c 100644 --- a/application/core/PlausiIssueProducer_Controller.php +++ b/application/core/PlausiIssueProducer_Controller.php @@ -5,61 +5,23 @@ */ abstract class PlausiIssueProducer_Controller extends JOB_Controller { - protected $_fehlerLibMappings; + protected $_fehlerLibMappings = []; protected $_app; - public function __construct($app = null) - { - parent::__construct(); - - // pass extension name if calling from extension - $extensionName = isset($this->_extensionName) ? $this->_extensionName : null; - - // load libraries - $this->load->library('issues/PlausicheckProducerLib', array('extensionName' => $extensionName, 'app' => $this->_app)); - $this->load->library('IssuesLib'); - } - protected function producePlausicheckIssues($params) { + $this->load->library( + 'issues/PlausicheckProducerLib', + ['extensionName' => $this->_extensionName ?? null, 'app' => $this->_app, 'fehlerLibMappings' => $this->_fehlerLibMappings] + ); + $this->logInfo("Plausicheck issue producer job started"); - // get the data returned by Plausicheck - foreach ($this->_fehlerLibMappings as $fehler_kurzbz => $libName) - { - // execute the check - $this->logInfo("Checking " . $fehler_kurzbz . "..."); - $plausicheckRes = $this->plausicheckproducerlib->producePlausicheckIssue( - $libName, - $fehler_kurzbz, - $params - ); + $result = $this->plausicheckproducerlib->producePlausicheckIssues($params); - if (isError($plausicheckRes)) $this->logError(getError($plausicheckRes)); - - if (hasData($plausicheckRes)) - { - $plausicheckData = getData($plausicheckRes); - - foreach ($plausicheckData as $plausiData) - { - // get the data needed for issue production - $person_id = isset($plausiData['person_id']) ? $plausiData['person_id'] : null; - $oe_kurzbz = isset($plausiData['oe_kurzbz']) ? $plausiData['oe_kurzbz'] : null; - $fehlertext_params = isset($plausiData['fehlertext_params']) ? $plausiData['fehlertext_params'] : null; - $resolution_params = isset($plausiData['resolution_params']) ? $plausiData['resolution_params'] : null; - - // write the issue - $addIssueRes = $this->issueslib->addFhcIssue($fehler_kurzbz, $person_id, $oe_kurzbz, $fehlertext_params, $resolution_params); - - // log if error, or log info if inserted new issue - if (isError($addIssueRes)) - $this->logError(getError($addIssueRes)); - elseif (hasData($addIssueRes) && is_integer(getData($addIssueRes))) - $this->logInfo("Plausicheck issue " . $fehler_kurzbz . " successfully produced, person_id: " . $person_id); - } - } - } + // log if error, or log info if inserted new issue + foreach ($result->errors as $error) $this->logError($error); + foreach ($result->infos as $info) $this->logInfo($info); $this->logInfo("Plausicheck issue producer job stopped"); } diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index 3e682e56c..40aed007c 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -422,3 +422,79 @@ function isValidDate($dateString) return false; } } + + +// ------------------------------------------------------------------------ +// Collection of utility functions for form validation purposes +// ------------------------------------------------------------------------ + +/** + * check if string can be converted to a date + */ +function is_valid_date($dateString) +{ + try + { + return (new DateTime($dateString)) !== false; + } + catch(Exception $e) + { + return false; + } +} + +/** + * check if given permissions are met + */ +function has_write_permissions($value, $permissions = '') +{ + if (!$permissions) + $permissions = $value; + $permissions = explode(',', $permissions); + + $CI =& get_instance(); + $CI->load->library('AuthLib'); + $CI->load->library('PermissionLib'); + + return $CI->permissionlib->hasAtLeastOne( + $permissions, + 'sometable', + PermissionLib::WRITE_RIGHT + ); +} + +/** + * check if has permissions for a studiengang_kz + */ +function has_permissions_for_stg($studiengang_kz, $permissions = '') +{ + if (!$permissions) + return false; + $permissions = explode(',', $permissions); + + $CI =& get_instance(); + $CI->load->library('AuthLib'); + $CI->load->library('PermissionLib'); + + foreach ($permissions as $perm) { + if (strpos($perm, PermissionLib::PERMISSION_SEPARATOR) === false) { + $CI->addError( + 'The given permission does not use the correct format', + FHCAPI_Controller::ERROR_TYPE_GENERAL + ); + return false; + } + + list($perm, $accesstype) = explode(PermissionLib::PERMISSION_SEPARATOR, $perm); + $at = ''; + if (strpos($accesstype, PermissionLib::READ_RIGHT) !== false) + $at = PermissionLib::SELECT_RIGHT; // S + if (strpos($accesstype, PermissionLib::WRITE_RIGHT) !== false) + $at .= PermissionLib::REPLACE_RIGHT.PermissionLib::DELETE_RIGHT; // UID + + if ($CI->permissionlib->isBerechtigt($perm, $at, $studiengang_kz)) + return true; + } + + return false; +} diff --git a/application/language/english/form_validation_lang.php b/application/language/english/form_validation_lang.php new file mode 100644 index 000000000..b8918a721 --- /dev/null +++ b/application/language/english/form_validation_lang.php @@ -0,0 +1,43 @@ +p->t('studierendenantrag', 'error_no_right')); + return error($this->_ci->p->t('studierendenantrag', 'error_no_right')); if ($insertvon == Studierendenantragstatus_model::INSERTVON_ABMELDUNGSTGL) { return $this->_ci->StudierendenantragstatusModel->resumeAntraegeForAbmeldungStgl($antrag_id); } @@ -257,18 +257,28 @@ class AntragLib if (isError($result)) $errors[] = getError($result); + $this->_ci->load->model('crm/Statusgrund_model', 'StatusgrundModel'); + $result = $this->_ci->StatusgrundModel->loadWhere(['statusgrund_kurzbz' => 'abbrecherStud']); + if (isError($result)) { + $errors[] = getError($result); + continue; + } elseif (!hasData($result)) { + $errors[] = $this->_ci->p->t('lehre', 'error_noStatusgrund', ['statusgrund_kurzbz' => 'abbrecherStud']); + continue; + } + $statusgrund = current(getData($result)); + $result = $this->_ci->prestudentlib->setAbbrecher( $antrag->prestudent_id, $antrag->studiensemester_kurzbz, $insertvon, - 'abbrecherStud', + $statusgrund->statusgrund_id, $antrag->datum, $insertam ); - if (isError($result)) - { + if (isError($result)) { $errors[] = getError($result); - return $errors; + continue; } $result = $this->_ci->PersonModel->loadPrestudent($antrag->prestudent_id); @@ -421,11 +431,20 @@ class AntragLib // NOTE(chris): here we should have error handling but at the // moment there is no way to notify the user for "soft" errors + $this->_ci->load->model('crm/Statusgrund_model', 'StatusgrundModel'); + $result = $this->_ci->StatusgrundModel->loadWhere(['statusgrund_kurzbz' => 'abbrecherStgl']); + if (isError($result)) + return $result; + if (!hasData($result)) + return error($this->_ci->p->t('lehre', 'error_noStatusgrund', ['statusgrund_kurzbz' => 'abbrecherStgl'])); + + $statusgrund = current(getData($result)); + $result = $this->_ci->prestudentlib->setAbbrecher( $antrag->prestudent_id, $antrag->studiensemester_kurzbz, $insertvon, - 'abbrecherStgl', + $statusgrund->statusgrund_id, $status->insertamum ); diff --git a/application/libraries/AuthLib.php b/application/libraries/AuthLib.php index de9c15350..67fd7d3d7 100644 --- a/application/libraries/AuthLib.php +++ b/application/libraries/AuthLib.php @@ -37,7 +37,8 @@ class AuthLib // Gets CI instance $this->_ci =& get_instance(); - if ($authenticate === true) $this->_authenticate(); // if required -> authenticate the current user + if ($authenticate === true) + $this->_authenticate(); // if required -> authenticate the current user } //------------------------------------------------------------------------------------------------------------------ @@ -361,6 +362,40 @@ class AuthLib return $bt; } + /** + * Checks if the user is already authenticated with HTTP basic authentication + * NOTE: this method also display a login, not possible to be avoided due HTTP basic authentication limitations + */ + private function _checkHBAuthentication() + { + $hta = error('Not authenticated', AUTH_NOT_AUTHENTICATED); // by default is NOT authenticated + + // Checks if an HTTP basic authentication is active and checks credentials using LDAP + if (!isset($_SERVER['PHP_AUTH_USER'])) + { + // If NOT send the header to perform an HTTP basic authentication + header('WWW-Authenticate: Basic realm="'.AUTH_NAME.'"'); + } + else // otherwise + { + // NOTE: Username needs to be trimmed and lowered because htaccess is allowing login + $hta = $this->_createAuthObjByPerson(array('uid' => mb_strtolower(trim($_SERVER['PHP_AUTH_USER'])))); + } + + // Invalid credentials + // NOTE: this is a corner case because of the HTTP basic authentication + if (getCode($hta) == AUTH_NOT_AUTHENTICATED || getCode($hta) == AUTH_INVALID_CREDENTIALS) + { + $this->_showInvalidAuthentication(); // this also stop the execution + } + elseif (isError($hta)) // display error and stop execution + { + $this->_showError(getError($hta)); + } + + return $hta; // if success then is returned! + } + /** * Checks if the user is already authenticated with HTTP basic authentication + LDAP * NOTE: this method also display a login, not possible to be avoided due HTTP basic authentication limitations @@ -436,6 +471,9 @@ class AuthLib case AUTH_BT: // Bewerbung tool $auth = $this->_checkBTAuthentication(); break; + case AUTH_HBA: // HTTP basic authentication + $auth = $this->_checkHBAuthentication(); + break; case AUTH_HBALDAP: // HTTP basic authentication + LDAP $auth = $this->_checkHBALDAPAuthentication(); break; diff --git a/application/libraries/IssuesLib.php b/application/libraries/IssuesLib.php index 9b3a9de6e..f38303b3c 100644 --- a/application/libraries/IssuesLib.php +++ b/application/libraries/IssuesLib.php @@ -246,7 +246,27 @@ class IssuesLib $fehlertext = vsprintf($fehlertextVorlage, $fehlertext_params); } - $openIssuesCountRes = $this->_ci->IssueModel->getOpenIssueCount($fehlercode, $person_id, $oe_kurzbz, $fehlercode_extern); + if (isset($resolution_params)) + { + if (is_array($resolution_params)) + { + foreach ($resolution_params as $resolution_key => $resolution_param) + { + if (!is_string($resolution_key)) + return error("Invalid parameter for resolution, must be an associative array"); + } + } + else + return error("Invalid parameters for resolution"); + } + + $openIssuesCountRes = $this->_ci->IssueModel->getOpenIssueCount( + $fehlercode, + $person_id, + $oe_kurzbz, + $fehlercode_extern, + $resolution_params + ); if (hasData($openIssuesCountRes)) { @@ -256,20 +276,6 @@ class IssuesLib if ($openIssueCount == 0) { - if (isset($resolution_params)) - { - if (is_array($resolution_params)) - { - foreach ($resolution_params as $resolution_key => $resolution_param) - { - if (!is_string($resolution_key)) - return error("Invalid parameter for resolution, must be an associative array"); - } - } - else - return error("Invalid parameters for resolution"); - } - // insert new issue return $this->_ci->IssueModel->insert( array( diff --git a/application/libraries/PermissionLib.php b/application/libraries/PermissionLib.php index bf8174cf4..857defbf7 100644 --- a/application/libraries/PermissionLib.php +++ b/application/libraries/PermissionLib.php @@ -147,19 +147,7 @@ class PermissionLib if (strpos($permissions[$pCounter], PermissionLib::PERMISSION_SEPARATOR) !== false) { // Retrieves permission and required access type from the $requiredPermissions array - list($permission, $requiredAccessType) = explode(PermissionLib::PERMISSION_SEPARATOR, $permissions[$pCounter]); - - $accessType = ''; - - // Set the access type - if (strpos($requiredAccessType, PermissionLib::READ_RIGHT) !== false) - { - $accessType = PermissionLib::SELECT_RIGHT; // S - } - if (strpos($requiredAccessType, PermissionLib::WRITE_RIGHT) !== false) - { - $accessType .= PermissionLib::REPLACE_RIGHT.PermissionLib::DELETE_RIGHT; // UID - } + list($permission, $accessType) = $this->convertAccessType($permissions[$pCounter]); if (!isEmptyString($accessType)) // if compliant { @@ -209,6 +197,24 @@ class PermissionLib return $checkPermissions; } + /** + * Retrieves permission and required access type from the newly formatted permission string + * + * @param string $permission + * + * @return array + */ + public function convertAccessType($permission) + { + list($permission, $reqAccessType) = explode(PermissionLib::PERMISSION_SEPARATOR, $permission); + $accessType = ''; + if (strpos($reqAccessType, PermissionLib::READ_RIGHT) !== false) + $accessType = PermissionLib::SELECT_RIGHT; + if (strpos($reqAccessType, PermissionLib::WRITE_RIGHT) !== false) + $accessType = PermissionLib::REPLACE_RIGHT.PermissionLib::DELETE_RIGHT; + return [$permission, $accessType]; + } + /** * Checks if at least one of the permissions given as parameter (requiredPermissions) belongs to the authenticated user * It checks the given permissions against a given method (controller method name) and a given permission type (R and/or W) diff --git a/application/libraries/PrestudentLib.php b/application/libraries/PrestudentLib.php index ae4ad59c6..af62668cf 100644 --- a/application/libraries/PrestudentLib.php +++ b/application/libraries/PrestudentLib.php @@ -35,8 +35,15 @@ class PrestudentLib $this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel'); } - public function setAbbrecher($prestudent_id, $studiensemester_kurzbz, $insertvon = null, $statusgrund_kurzbz = null, $datum = null, $bestaetigtam = null, $bestaetigtvon = null) - { + public function setAbbrecher( + $prestudent_id, + $studiensemester_kurzbz, + $insertvon = null, + $statusgrund_id = null, + $datum = null, + $bestaetigtam = null, + $bestaetigtvon = null + ) { if (!$insertvon) $insertvon = getAuthUID(); if (!$bestaetigtvon) @@ -70,8 +77,8 @@ class PrestudentLib if(!$bestaetigtam) $bestaetigtam = date('c'); - //Status und Statusgrund updaten - $result = $this->_ci->PrestudentstatusModel->withGrund($statusgrund_kurzbz)->insert([ + // Status und Statusgrund updaten + $result = $this->_ci->PrestudentstatusModel->insert([ 'prestudent_id' => $prestudent_id, 'status_kurzbz' => Prestudentstatus_model::STATUS_ABBRECHER, 'studiensemester_kurzbz' => $prestudent_status->studiensemester_kurzbz, @@ -82,13 +89,13 @@ class PrestudentLib 'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz, 'studienplan_id'=> $prestudent_status->studienplan_id, 'bestaetigtvon' => $bestaetigtvon, - 'bestaetigtam' => $bestaetigtam + 'bestaetigtam' => $bestaetigtam, + 'statusgrund_id' => $statusgrund_id ]); if (isError($result)) return $result; - //Verband anlegen $result = $this->_ci->LehrverbandModel->load([ 'studiengang_kz' => $student->studiengang_kz, @@ -134,7 +141,7 @@ class PrestudentLib ]); } - //noch nicht eingetragene Zeugnisnoten auf 9 setzen + // noch nicht eingetragene Zeugnisnoten auf 9 setzen $result = $this->_ci->ZeugnisnoteModel->getZeugnisnoten($student->student_uid, $prestudent_status->studiensemester_kurzbz); if (isError($result)) return $result; @@ -166,9 +173,9 @@ class PrestudentLib } - //Update Aktionen + // Update Aktionen - //StudentModel updaten + // StudentModel updaten $this->_ci->StudentModel->update([ 'student_uid' => $student->student_uid ], [ @@ -192,7 +199,7 @@ class PrestudentLib 'updatevon' => $insertvon ]); - //Benutzer inaktiv setzen + // Benutzer inaktiv setzen $this->_ci->BenutzerModel->update([ 'uid' => $student->student_uid ], [ @@ -206,17 +213,28 @@ class PrestudentLib return success(); } - public function setUnterbrecher($prestudent_id, $studiensemester_kurzbz, $studierendenantrag_id, $insertvon = null) - { + public function setUnterbrecher( + $prestudent_id, + $studiensemester_kurzbz, + $studierendenantrag_id = null, + $insertvon = null, + $ausbildungssemester = null, + $statusgrund_id = null + ) { $ausbildungssemester_plus = 0; + if (!$insertvon) $insertvon = getAuthUID(); + $result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz); + if (isError($result)) return $result; + $result = getData($result); - if (!$result) { + + if (!$result) { // NOTE(chris): no status in target stdsem //NOTE(manu): only valid if nextSemester focus max $result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id); @@ -224,7 +242,7 @@ class PrestudentLib return $result; $result = getData($result); - //check if ausbildungssemester is last + // check if ausbildungssemester is last $this->_ci->StudiengangModel->addJoin('public.tbl_prestudent p', 'studiengang_kz'); $res = $this->_ci->StudiengangModel->loadWhere(['p.prestudent_id' => $prestudent_id]); if(isError($res)) @@ -249,31 +267,47 @@ class PrestudentLib } $prestudent_status = current($result); + + $result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]); if (isError($result)) return $result; + $result = getData($result); + if (!$result) return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id])); $student = current($result); - $resultAntrag = $this->_ci->StudierendenantragModel->load($studierendenantrag_id); - if (isError($resultAntrag)) - return $resultAntrag; - $resultAntrag = getData($resultAntrag); - if (!$resultAntrag) - return error($this->_ci->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $studierendenantrag_id])); - $antrag = current($resultAntrag); + if ($studierendenantrag_id) + { + $resultAntrag = $this->_ci->StudierendenantragModel->load($studierendenantrag_id); + if (isError($resultAntrag)) + return $resultAntrag; + $resultAntrag = getData($resultAntrag); + if (!$resultAntrag) + return error($this->_ci->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $studierendenantrag_id])); - //Status updaten + $antrag = current($resultAntrag); + $anmerkung = 'Wiedereinstieg ' . $antrag->datum_wiedereinstieg; + } + else + $anmerkung = ''; + + if ($ausbildungssemester) + $semester = $ausbildungssemester; + else + $semester = $prestudent_status->ausbildungssemester + $ausbildungssemester_plus; + + // Status updaten $result = $this->_ci->PrestudentstatusModel->insert([ 'prestudent_id' => $prestudent_id, 'status_kurzbz' => Prestudentstatus_model::STATUS_UNTERBRECHER, 'studiensemester_kurzbz' => $studiensemester_kurzbz, - 'ausbildungssemester' => $prestudent_status->ausbildungssemester + $ausbildungssemester_plus, + 'ausbildungssemester' => $semester, 'datum' => date('c'), 'insertvon' => $insertvon, 'insertamum' => date('c'), @@ -281,7 +315,8 @@ class PrestudentLib 'studienplan_id'=> $prestudent_status->studienplan_id, 'bestaetigtvon' => $insertvon, 'bestaetigtam' => date('c'), - 'anmerkung'=> 'Wiedereinstieg ' . $antrag->datum_wiedereinstieg + 'anmerkung'=> $anmerkung, + 'statusgrund_id' => $statusgrund_id ]); if (isError($result)) @@ -332,7 +367,7 @@ class PrestudentLib ]); } - //noch nicht eingetragene Zeugnisnoten auf 9 setzen + // noch nicht eingetragene Zeugnisnoten auf 9 setzen $result = $this->_ci->ZeugnisnoteModel->getZeugnisnoten($student->student_uid, $studiensemester_kurzbz); if (isError($result)) return $result; @@ -363,10 +398,9 @@ class PrestudentLib } } + // Update Aktionen - //Update Aktionen - - //StudentModel updaten + // StudentModel updaten $this->_ci->StudentModel->update([ 'student_uid' => $student->student_uid ], [ @@ -409,4 +443,463 @@ class PrestudentLib return success(); } + + public function setStudent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id) + { + $authUID = getAuthUID(); + $now = date('c'); + + + $result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id); + + if (isError($result)) + return $result; + if (!hasData($result)) + return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudentstatus', [ + 'prestudent_id' => $prestudent_id + ])); + + $prestudent_status = current(getData($result)); + + + $result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]); + + if (isError($result)) + return $result; + if (!hasData($result)) + return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id])); + + $student = current(getData($result)); + + + $this->_ci->load->library('VariableLib', ['uid' => $authUID]); + $semester_aktuell = $this->_ci->variablelib->getVar('semester_aktuell'); + + + // Update Aktionen + + // Status updaten + $result = $this->_ci->PrestudentstatusModel->insert([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => Prestudentstatus_model::STATUS_STUDENT, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'statusgrund_id' => $statusgrund_id, + 'ausbildungssemester' => $ausbildungssemester, + 'datum' => $now, + 'insertvon' => $authUID, + 'insertamum' => $now, + 'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz, + 'studienplan_id'=> $prestudent_status->studienplan_id, + 'bestaetigtvon' => $authUID, + 'bestaetigtam' => $now + ]); + + if (isError($result)) + return $result; + + + // Student updaten + $result = $this->_ci->StudentModel->update([ + 'student_uid' => $student->student_uid + ], [ + 'semester' => $ausbildungssemester, + 'verband' => '', + 'gruppe' => '', + 'updatevon' => $authUID, + 'updateamum' => $now + ]); + + if (isError($result)) + return $result; + + + // Studentlehrverband updaten + $result = $this->_ci->StudentlehrverbandModel->update([ + 'student_uid' => $student->student_uid, + 'studiensemester_kurzbz' => $semester_aktuell + ], [ + 'semester' => $ausbildungssemester, + 'verband' => '', + 'gruppe' => '', + 'updatevon' => $authUID, + 'updateamum' => $now + ]); + + if (isError($result)) + return $result; + + + // Benutzer updaten + $result = $this->_ci->BenutzerModel->load([$student->student_uid]); + + if (isError($result)) + return $result; + if (!hasData($result)) + return error($this->_ci->p->t('person', 'error_noBenutzer')); + + $benutzer = current(getData($result)); + $updateData = [ + 'aktiv' => true, + 'updateamum' => $now, + 'updatevon' => $authUID + ]; + if (!$benutzer->aktiv) { + $updateData['updateaktivam'] = $now; + $updateData['updateaktivvon'] = $authUID; + } + + + $this->_ci->BenutzerModel->update([$student->student_uid], $updateData); + + return success(); + } + + public function setFirstStudent( + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $orgform_kurzbz, + $studienplan_id, + $statusgrund_id + ) { + $this->_ci->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); + $this->_ci->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz'); + $result = $this->_ci->PrestudentModel->load($prestudent_id); + + if (isError($result)) + return $result; + + if (!hasData($result)) + return error('No prestudent'); + + $student_data = current(getData($result)); + + + $authUID = getAuthUID(); + $now = date('c'); + $today = date('Y-m-d'); + + $jahr = mb_substr($studiensemester_kurzbz, 4, 2); + + + // Genererate Personenkennzeichen + $personenkennzeichen = $this->_ci->StudentModel->generateMatrikelnummer2( + $student_data->studiengang_kz, + $studiensemester_kurzbz, + $student_data->typ + ); + if (isError($personenkennzeichen)) + return $personenkennzeichen; + $personenkennzeichen = getData($personenkennzeichen); + + + // Generate UID + $uid = $this->_ci->StudentModel->generateUID( + $student_data->kurzbz, + $jahr, + $student_data->typ, + $personenkennzeichen, + $student_data->vorname, + $student_data->nachname + ); + if (isError($uid)) + return $uid; + $uid = getData($uid); + + + // Generate Matrikelnummer + $matrikelnummer = $this->_ci->BenutzerModel->generateMatrikelnummer( + $student_data->oe_kurzbz + ); + if (isError($matrikelnummer)) + return $matrikelnummer; + $matrikelnummer = getData($matrikelnummer); + + + // Generate Alias + $alias = ''; + if (!defined('GENERATE_ALIAS_STUDENT') + || GENERATE_ALIAS_STUDENT === true + ) { + $result = $this->_ci->BenutzerModel->generateAliasFromName($student_data->vorname, $student_data->nachname); + if (isError($result)) + return $result; + $alias = getData($result); + } + + // Generate Activation Key + $activationkey = $this->_ci->BenutzerModel->generateActivationkey(); + + + // Overwrite stuff + if (defined('SET_UID_AS_MATRIKELNUMMER') + && SET_UID_AS_MATRIKELNUMMER) + $matrikelnummer = $uid; + if (defined('SET_UID_AS_PERSONENKENNZEICHEN') + && SET_UID_AS_PERSONENKENNZEICHEN) + $personenkennzeichen = $uid; + + + // Update Person + $this->_ci->load->model('person/Person_model', 'PersonModel'); + $result = $this->_ci->PersonModel->update([ + 'person_id' => $student_data->person_id, + 'matr_nr' => null + ], [ + 'matr_nr' => $matrikelnummer + ]); + + if (isError($result)) + return $result; + + + // Add Benutzer + $result = $this->_ci->BenutzerModel->insert([ + 'uid' => $uid, + 'person_id' => $student_data->person_id, + 'aktiv' => true, + 'aktivierungscode' => $activationkey, + 'alias' => $alias, + 'insertvon' => $authUID, + 'insertamum' => $now, + ]); + + if (isError($result)) + return $result; + + + // Add Student + $result = $this->_ci->StudentModel->insert([ + 'student_uid' => $uid, + 'matrikelnr' => $personenkennzeichen, + 'prestudent_id' => $prestudent_id, + 'studiengang_kz' => $student_data->studiengang_kz, + 'semester' => $ausbildungssemester, + 'verband' => ' ', + 'gruppe' => ' ', + 'insertvon' => $authUID, + 'insertamum' => $now + ]); + + if (isError($result)) + return $result; + + + // Add Lehrverband if it does not exist + $result = $this->_ci->LehrverbandModel->load([' ', ' ', $ausbildungssemester, $student_data->studiengang_kz]); + + if (isError($result)) + return $result; + + if (!hasData($result)) { + $result = $this->_ci->LehrverbandModel->insert([ + 'studiengang_kz' => $student_data->studiengang_kz, + 'semester' => $ausbildungssemester, + 'verband' => ' ', + 'gruppe' => ' ', + 'aktiv' => true + ]); + + if (isError($result)) + return $result; + } + + + // Add Rolle + $result = $this->_ci->PrestudentstatusModel->insert([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => Prestudentstatus_model::STATUS_STUDENT, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'ausbildungssemester' => $ausbildungssemester, + 'orgform_kurzbz'=> $orgform_kurzbz, + 'studienplan_id'=> $studienplan_id, + 'datum' => $today, + 'insertamum' => $now, + 'insertvon' => $authUID, + 'bestaetigtam' => $today, + 'bestaetigtvon' => $authUID, + 'statusgrund_id' => $statusgrund_id + ]); + + if (isError($result)) + return $result; + + + // Add Studentlehrverband + $result = $this->_ci->StudentlehrverbandModel->insert([ + 'student_uid' => $uid, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'studiengang_kz' => $student_data->studiengang_kz, + 'semester' => $ausbildungssemester, + 'verband' => ' ', + 'gruppe' => ' ', + 'insertamum' => $now, + 'insertvon' => $authUID + ]); + + if (isError($result)) + return $result; + + return success(); + } + + public function setDiplomand($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id) + { + return $this->setBasic( + getAuthUID(), + date('c'), + Prestudentstatus_model::STATUS_DIPLOMAND, + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + } + + public function setAbsolvent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id) + { + $authUID = getAuthUID(); + $now = date('c'); + + + $result = $this->setBasic( + $authUID, + $now, + Prestudentstatus_model::STATUS_ABSOLVENT, + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + + if (isError($result)) + return $result; + + + // Load Student + $result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]); + + if (isError($result)) + return $result; + if (!hasData($result)) + return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id])); + + $student = current(getData($result)); + + + // Benutzer inaktiv setzen + $this->_ci->BenutzerModel->update([ + 'uid' => $student->student_uid + ], [ + 'aktiv' => false, + 'updateaktivvon' => $authUID, + 'updateaktivam' => $now, + 'updatevon' => $authUID, + 'updateamum' => $now + ]); + + if (isError($result)) + return $result; + + return success(); + } + + public function setBewerber($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id) + { + $result = $this->setBasic( + getAuthUID(), + date('c'), + Prestudentstatus_model::STATUS_BEWERBER, + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + + if (isError($result)) + return $result; + + if (SEND_BEWERBER_INFOMAIL) { + // TODO(chris): IMPLEMENT! + } + + return success(); + } + + public function setAufgenommener($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id) + { + return $this->setBasic( + getAuthUID(), + date('c'), + Prestudentstatus_model::STATUS_AUFGENOMMENER, + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + } + + public function setAbgewiesener($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id) + { + return $this->setBasic( + getAuthUID(), + date('c'), + Prestudentstatus_model::STATUS_ABGEWIESENER, + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + } + + public function setWartender($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id) + { + return $this->setBasic( + getAuthUID(), + date('c'), + Prestudentstatus_model::STATUS_WARTENDER, + $prestudent_id, + $studiensemester_kurzbz, + $ausbildungssemester, + $statusgrund_id + ); + } + + protected function setBasic($authUID, $now, $status_kurzbz, $prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id = null) + { + $result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id); + + if (isError($result)) + return $result; + if (!hasData($result)) + return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudentstatus', [ + 'prestudent_id' => $prestudent_id + ])); + + $prestudent_status = current(getData($result)); + + + // Update Aktionen + + // Status updaten + $result = $this->_ci->PrestudentstatusModel->insert([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'ausbildungssemester' => $ausbildungssemester, + 'datum' => $now, + 'insertvon' => $authUID, + 'insertamum' => $now, + 'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz, + 'studienplan_id'=> $prestudent_status->studienplan_id, + 'bestaetigtvon' => $authUID, + 'bestaetigtam' => $now, + 'statusgrund_id' => $statusgrund_id + ]); + + if (isError($result)) + return $result; + + return success(); + } } diff --git a/application/libraries/PrestudentstatusCheckLib.php b/application/libraries/PrestudentstatusCheckLib.php new file mode 100644 index 000000000..5e3d8a307 --- /dev/null +++ b/application/libraries/PrestudentstatusCheckLib.php @@ -0,0 +1,922 @@ +_ci =& get_instance(); + + $this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $this->_ci->load->model('person/Person_model', 'PersonModel'); + $this->_ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + $this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel'); + $this->_ci->load->model('crm/Student_model', 'StudentModel'); + $this->_ci->load->model('organisation/Studienplan_model', 'StudienplanModel'); + $this->_ci->load->model('codex/Bismeldestichtag_model', 'BismeldestichtagModel'); + } + + /** + * Checks if a status add is valid. + * @return object error if invalid + */ + public function checkStatusAdd( + $prestudent_id, + $status_kurzbz, + $new_status_studiensemester_kurzbz, + $new_status_datum, + $new_status_ausbildungssemester, + $new_studienplan_id + ) { + $studentName = ''; + + $nameRes = $this->_ci->PersonModel->loadPrestudent($prestudent_id); + + if (hasData($nameRes)) + { + $nameData = getData($nameRes)[0]; + $studentName = $nameData->vorname.' '.$nameData->nachname; + } + + // Datum des neuen Status darf nicht in Vergangenheit liegen, sonst Probleme wenn neues Datum < Bismeldedatum + if (new DateTime($new_status_datum) < new DateTime('today')) + return error($studentName . $this->_ci->p->t('lehre', 'error_entryInPast')); + + return $this->_checkIfValidStatusHistory( + $prestudent_id, + $status_kurzbz, + $new_status_studiensemester_kurzbz, + $new_status_datum, + $new_status_ausbildungssemester, + $new_studienplan_id + ); + } + + /** + * Checks if a status update is valid. + * @return error if invalid + */ + public function checkStatusUpdate( + $prestudent_id, + $status_kurzbz, + $new_status_studiensemester_kurzbz, + $new_status_datum, + $new_status_ausbildungssemester, + $new_studienplan_id, + $old_status_studiensemester, + $old_status_ausbildungssemester + ) { + + return $this->_checkIfValidStatusHistory( + $prestudent_id, + $status_kurzbz, + $new_status_studiensemester_kurzbz, + $new_status_datum, + $new_status_ausbildungssemester, + $new_studienplan_id, + $old_status_studiensemester, + $old_status_ausbildungssemester + ); + } + + /** + * Checks if a student already exists. + * + * @param integer $prestudent_id + * + * @return stdClass + */ + public function checkIfExistingStudent($prestudent_id) + { + $result = $this->_ci->StudentModel->loadWhere([ + 'prestudent_id' => $prestudent_id + ]); + + if (isError($result)) + return $result; + + return success(hasData($result)); + } + + /** + * Check if Reihungstest was admitted + * + * @param stdClass $prestudent + * + * @return stdClass + */ + public function checkIfAngetreten($prestudent) + { + return success($prestudent->reihungstestangetreten); + } + + /** + * Check if ZGV-Code is registered + * + * @param stdClass $prestudent + * + * @return stdClass + */ + public function checkIfZGVEingetragen($prestudent_person) + { + return success((boolean)$prestudent_person->zgv_code); + } + + /** + * Check if Master ZGV-Code is registered + * + * @param stdClass $prestudent + * + * @return booleans $zgv_code, error if not registered + */ + public function checkIfZGVEingetragenMaster($prestudent) + { + $this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel'); + $result = $this->_ci->StudiengangModel->load($prestudent->studiengang_kz); + if (isError($result)) + return $result; + if (!hasData($result)) + return error($this->_ci->p->t('studierendenantrag', 'error_no_stg', ['studiengang_kz' => $prestudent->studiengang_kz])); + + if (current($result->retval)->typ != 'm') + return success(true); // NOTE(chris): we only test master stgs, all other stgs should default to true + + return success((boolean)$prestudent->zgvmas_code); + } + + /** + * Checks if a bewerber status already exists. + * + * @param integer $prestudent_id + * + * @return stdClass + */ + public function checkIfExistingBewerberstatus($prestudent_id) + { + $result = $this->_ci->PrestudentstatusModel->loadWhere([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => Prestudentstatus_model::STATUS_BEWERBER + ]); + if (isError($result)) + return $result; + + return success(hasData($result)); + } + + + /** + * Checks if status aufgenommen already exists. + * + * @param integer $prestudent_id + * + * @return stdClass + */ + public function checkIfExistingAufgenommenerstatus($prestudent_id) + { + $result = $this->_ci->PrestudentstatusModel->loadWhere([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => Prestudentstatus_model::STATUS_AUFGENOMMENER + ]); + if (isError($result)) + return $result; + + return success(hasData($result)); + } + + /** + * Checks if the last Bewerber status and the last Aufgenommener status + * have the same studiensemester and ausbildungssemester. + * + * Attention: + * If one of those two status is missing the function returns true! + * + * @param integer $prestudent_id + * + * @return stdClass + */ + public function checkIfLastBewerberAndAufgenommenerShareSemesters($prestudent_id) + { + $this->_ci->PrestudentstatusModel->addOrder('datum', 'DESC'); + $this->_ci->PrestudentstatusModel->addOrder('insertamum', 'DESC'); + $this->_ci->PrestudentstatusModel->addLimit(1); + $result = $this->_ci->PrestudentstatusModel->loadWhere([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => Prestudentstatus_model::STATUS_BEWERBER + ]); + + if (isError($result)) + return $result; + if (!hasData($result)) + return success(true); + + $bewerber = current(getData($result)); + + $this->_ci->PrestudentstatusModel->addOrder('datum', 'DESC'); + $this->_ci->PrestudentstatusModel->addOrder('insertamum', 'DESC'); + $this->_ci->PrestudentstatusModel->addLimit(1); + $result = $this->_ci->PrestudentstatusModel->loadWhere([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => Prestudentstatus_model::STATUS_AUFGENOMMENER + ]); + + if (isError($result)) + return $result; + if (!hasData($result)) + return success(true); + + $aufgenommener = current(getData($result)); + + return success( + $bewerber->studiensemester_kurzbz == $aufgenommener->studiensemester_kurzbz + && $bewerber->ausbildungssemester == $aufgenommener->ausbildungssemester + ); + } + + /** + * Check if Bismeldestichtag erreicht + * + * @param DateTime $statusDatum + * @param string $studiensemester_kurzbz + * + * @return stdClass + */ + public function checkIfMeldestichtagErreicht($statusDatum, $studiensemester_kurzbz = null) + { + $result = $this->_ci->BismeldestichtagModel->checkIfMeldestichtagErreicht($statusDatum, $studiensemester_kurzbz); + + if (isError($result)) + return $result; + + return success(getData($result) == "1"); + } + + /** + * Runs all checks on Status History and saves it in cache. + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param DateTime $new_date + * @param string $new_studiensemester_kurzbz + * @param integer $new_ausbildungssemester + * @param string $old_studiensemester_kurzbz + * @param integer $old_ausbildungssemester + * + * @return stdClass + */ + protected function prepareStatusHistory( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ) { + // Generate key for caching + $primary = implode('|', [ + $prestudent_id, + $status_kurzbz, + $new_date->format('Y-m-d'), + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ]); + + if (isset($this->_cache_history[$primary])) + return $this->_cache_history[$primary]; + + $this->_ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + + // Get the history + $result = $this->_ci->PrestudentstatusModel->getHistoryWithNewOrEditedState( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ); + + if (isError($result)) + return $result; + + if (!hasData($result)) + return error('This is impossible'); + + $history = getData($result); + $historyCount = count($history); + + // Run checks + $checks = [ + 'timesequence' => true, + 'laststatus' => true, + 'unterbrechersemester' => true, + 'abbrechersemester' => true, + 'diplomant' => true, + 'student' => true + ]; + + for ($n = 0, $c = 1; $c < $historyCount; $n++, $c++) { + if (!$checks['timesequence'] + && !$checks['laststatus'] + && !$checks['unterbrechersemester'] + && !$checks['abbrechersemester'] + && !$checks['diplomant'] + && !$checks['student'] + ) + break; // early out + + $next = $history[$n]; + $current = $history[$c]; + + // Zeitabfolge ungültig? + if ($checks['timesequence'] + && $next->start < $current->start + ) + $checks['timesequence'] = false; + + // Abbrecher- oder Absolventenstatus muss Endstatus sein + if ($checks['laststatus'] + && in_array($current->status_kurzbz, [self::ABSOLVENT_STATUS, self::ABBRECHER_STATUS]) + ) + $checks['laststatus'] = false; + + // wenn Unterbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein + if ($checks['unterbrechersemester'] + && $current->status_kurzbz == self::UNTERBRECHER_STATUS + && $next->status_kurzbz == self::UNTERBRECHER_STATUS + && $current->ausbildungssemester != $next->ausbildungssemester + ) + $checks['unterbrechersemester'] = false; + + // wenn Abbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein + if ($checks['abbrechersemester'] + && $current->status_kurzbz == self::UNTERBRECHER_STATUS + && $next->status_kurzbz == self::ABBRECHER_STATUS + && $current->ausbildungssemester != $next->ausbildungssemester + ) + $checks['abbrechersemester'] = false; + + if (($checks['diplomant'] + || $checks['student']) + && $next->status_kurzbz == self::STUDENT_STATUS + ) { + $restl_stati = array_unique(array_column(array_slice($history, $c), 'status_kurzbz')); + + // keine Studenten nach Diplomand Status + if ($checks['diplomant'] + && in_array(self::DIPLOMAND_STATUS, $restl_stati) + ) + $checks['diplomant'] = false; + + // vor Studentenstatus müssen bestimmte Status vorhanden sein + if ($checks['student'] + && array_values(array_intersect($restl_stati, $this->_statusAbfolgeVorStudent)) != array_values($this->_statusAbfolgeVorStudent) + ) + $checks['student'] = false; + } + } + + $this->_cache_history[$primary] = success($checks); + + return success($checks); + } + + /** + * Checks if the time sequence of the status history is valid. + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param DateTime $new_date + * @param string $new_studiensemester_kurzbz + * @param integer $new_ausbildungssemester + * @param string $old_studiensemester_kurzbz + * @param integer $old_ausbildungssemester + * + * @return stdClass + */ + public function checkStatusHistoryTimesequence( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ) { + $result = $this->prepareStatusHistory( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ); + + if (isError($result)) + return $result; + + return success(getData($result)['timesequence']); + } + + /** + * Checks if the last status of the status history is not Abbrecher or + * Absolvent. + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param DateTime $new_date + * @param string $new_studiensemester_kurzbz + * @param integer $new_ausbildungssemester + * @param string $old_studiensemester_kurzbz + * @param integer $old_ausbildungssemester + * + * @return stdClass + */ + public function checkStatusHistoryLaststatus( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ) { + $result = $this->prepareStatusHistory( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ); + + if (isError($result)) + return $result; + + return success(getData($result)['laststatus']); + } + + /** + * Checks if two consecutively Unterbrecher have the same + * ausbildungssemester in the status history. + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param DateTime $new_date + * @param string $new_studiensemester_kurzbz + * @param integer $new_ausbildungssemester + * @param string $old_studiensemester_kurzbz + * @param integer $old_ausbildungssemester + * + * @return stdClass + */ + public function checkStatusHistoryUnterbrechersemester( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ) { + $result = $this->prepareStatusHistory( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ); + + if (isError($result)) + return $result; + + return success(getData($result)['unterbrechersemester']); + } + + /** + * Checks if an Unterbrecher followed by an Abbrecher have the same + * ausbildungssemester in the status history. + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param DateTime $new_date + * @param string $new_studiensemester_kurzbz + * @param integer $new_ausbildungssemester + * @param string $old_studiensemester_kurzbz + * @param integer $old_ausbildungssemester + * + * @return stdClass + */ + public function checkStatusHistoryAbbrechersemester( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ) { + $result = $this->prepareStatusHistory( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ); + + if (isError($result)) + return $result; + + return success(getData($result)['abbrechersemester']); + } + + /** + * Checks if no Diplomant is followed by a Student in the status history. + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param DateTime $new_date + * @param string $new_studiensemester_kurzbz + * @param integer $new_ausbildungssemester + * @param string $old_studiensemester_kurzbz + * @param integer $old_ausbildungssemester + * + * @return stdClass + */ + public function checkStatusHistoryDiplomant( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ) { + $result = $this->prepareStatusHistory( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ); + + if (isError($result)) + return $result; + + return success(getData($result)['diplomant']); + } + + /** + * Checks if a Student precedes given stati in the status history. + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param DateTime $new_date + * @param string $new_studiensemester_kurzbz + * @param integer $new_ausbildungssemester + * @param string $old_studiensemester_kurzbz + * @param integer $old_ausbildungssemester + * + * @return stdClass + */ + public function checkStatusHistoryStudent( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ) { + // TODO(chris): TEST + $result = $this->prepareStatusHistory( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ); + + if (isError($result)) + return $result; + + return success(getData($result)['student']); + } + + /** + * Checks if Personenkennzeichen is set correctly. + * + * @param integer $prestudent_id + * + * @return stdClass + */ + public function checkPersonenkennzeichen($prestudent_id) + { + // TODO(chris): TEST + $this->_ci->PrestudentstatusModel->addSelect('tbl_prestudentstatus.prestudent_id'); + $this->_ci->PrestudentstatusModel->addSelect('tbl_student.matrikelnr'); + + $this->_ci->PrestudentstatusModel->addJoin('public.tbl_student', 'prestudent_id'); + + $this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.datum', 'DESC'); + $this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.insertamum', 'DESC'); + $this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.ext_id', 'DESC'); + + $this->_ci->PrestudentstatusModel->addLimit(1); + + $result = $this->_ci->PrestudentstatusModel->loadWhere([ + 'tbl_prestudentstatus.prestudent_id' => $prestudent_id, + 'tbl_prestudentstatus.status_kurzbz' => self::STATUS_STUDENT + ]); + + if (isError($result)) + return $result; + + if (!hasData($result)) + return success(true); // Not a student yet so no wrong personenkennzeichen + + $data = current(getData($result)); + + $jahr = $this->_ci->StudiensemesterModel->getStudienjahrNumberFromStudiensemester($data->studiensemester_kurzbz); + + + return success($jahr == mb_substr($data->matrikelnr, 0, 2)); + } + + /** + * Checks if Orgform of Student status and Bewerber status match. + * + * @param integer $prestudent_id + * + * @return stdClass + */ + public function checkStudentOrgform($prestudent_id) + { + // TODO(chris): TEST + $result = $this->_ci->PrestudentstatusModel->getBewerberWhereOrgformNotStudent($prestudent_id); + + if (isError($result)) + return $result; + + return success(!hasData($result)); + } + + /** + * Check if History of StatusData is valid + * @param integer $prestudent_id + * @return error if not valid, array StatusArr if valid + */ + private function _checkIfValidStatusHistory( + $prestudent_id, + $status_kurzbz, + $new_status_studiensemester_kurzbz, + $new_status_datum, + $new_status_ausbildungssemester, + $new_studienplan_id, + $old_status_studiensemester = null, + $old_status_ausbildungssemester = null + ) { + //get start studiensemester + $semResult = $this->_ci->StudiensemesterModel->load([ + 'studiensemester_kurzbz' => $new_status_studiensemester_kurzbz + ]); + + if (isError($semResult)) + { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + return $this->outputJson(getError($semResult)); + } + + if (!hasData($semResult)) { + return error($this->_ci->p->t('lehre', 'error_noStudiensemester') . $new_status_studiensemester_kurzbz); + } + + $studiensemester = getData($semResult)[0]; + $new_status_semesterstart = $studiensemester->start; + + // get studienplan orgform + $new_studienplan_orgform_kurzbz = ''; + $this->_ci->StudienplanModel->addSelect('orgform_kurzbz'); + $stplResult = $this->_ci->StudienplanModel->load([ + 'studienplan_id' => $new_studienplan_id + ]); + + if (isError($stplResult)) + { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + return $this->outputJson(getError($stplResult)); + } + + if (hasData($stplResult)) $new_studienplan_orgform_kurzbz = getData($stplResult)[0]->orgform_kurzbz; + + + //get all prestudentstati + $resultPs = $this->_ci->PrestudentstatusModel->getAllPrestudentstatiWithStudiensemester($prestudent_id); + + if (isError($resultPs)) return $resultPs; + + $resultArr = hasData($resultPs) ? getData($resultPs) : []; + $statusArr = []; + + $newStatusInserted = false; + $new_status_datum_form = new DateTime($new_status_datum); + $new_status_semesterstart_form = new DateTime($new_status_semesterstart); + + if (!isEmptyArray($resultArr)) + { + // neuen Status zum Hinzufügen + $first_status = $resultArr[0]; + $neuer_status = new stdClass(); + $neuer_status->status_kurzbz = $status_kurzbz; + $neuer_status->studiensemester_kurzbz = $new_status_studiensemester_kurzbz; + $neuer_status->datum = $new_status_datum; + $neuer_status->ausbildungssemester = $new_status_ausbildungssemester; + $neuer_status->studienplan_orgform_kurzbz = $new_studienplan_orgform_kurzbz; + $neuer_status->matrikelnr = $first_status->matrikelnr; + $neuer_status->vorname = $first_status->vorname; + $neuer_status->nachname = $first_status->nachname; + + // Status, welcher gerade geändert wird, holen + $status_to_change = array_filter( + $resultArr, + function ($status) use ($status_kurzbz, $old_status_studiensemester, $old_status_ausbildungssemester) { + return + $status->status_kurzbz == $status_kurzbz + && $status->studiensemester_kurzbz == $old_status_studiensemester + && $status->ausbildungssemester == $old_status_ausbildungssemester; + } + ); + + if (!isEmptyArray($status_to_change)) + { + $status_to_change_index = key($status_to_change); + + // wenn sich Studiensemester und Ausbildungssemester nicht geändert haben... + if ($new_status_studiensemester_kurzbz == $old_status_studiensemester + && $new_status_ausbildungssemester == $old_status_ausbildungssemester) + { + // ...neuen status an selber stelle einfügen wie zu ändernder Status + $resultArr[$status_to_change_index] = (object)array_merge((array)$resultArr[$status_to_change_index], (array)$neuer_status); + $newStatusInserted = true; + } + else + { + // bei Status mit neuem Semester: alten Status entfernen + unset($resultArr[$status_to_change_index]); + } + } + } + + foreach ($resultArr as $row) + { + $studiensemester_start = new DateTime($row->studiensemester_start); + $status_datum = new DateTime($row->datum); + + if ($new_status_datum_form >= $status_datum && $new_status_semesterstart_form >= $studiensemester_start) + { + if (!$newStatusInserted) + { + // neuer Status erstmals größer als Datum eines bestehenden Status -> neuen Status EINMALIG einfügen für spätere Statusprüfung + $statusArr[] = $neuer_status; + $newStatusInserted = true; + } + $statusArr[] = $row; + } + elseif ($new_status_datum_form <= $status_datum && $new_status_semesterstart_form <= $studiensemester_start) + { + $statusArr[] = $row; + } + else + { + // Zeitabfolge ungültig, Fehler + return error($this->_ci->p->t('lehre', 'error_statuseintrag_zeitabfolge')); + } + } + + // erster Studentstatus + $ersterStudent = null; + + // Über alle gespeicherten Status gehen und Statusabfolge prüfen + for ($i = 0; $i < count($statusArr); $i++) + { + $curr_status = $statusArr[$i]; + $curr_status_kurzbz = $curr_status->status_kurzbz; + $curr_status_ausbildungssemester = $curr_status->ausbildungssemester; + $next_idx = $i - 1; //absteigend sortiert, nächster Status ist vorheriger Eintrag + $next_status = isset($statusArr[$next_idx]) ? $statusArr[$next_idx] : null; + + $studentName = $curr_status->vorname . ' ' . $curr_status->nachname; + + if ($curr_status_kurzbz == self::STUDENT_STATUS) $ersterStudent = $curr_status; + + // Abbrecher- oder Absolventenstatus muss Endstatus sein + if (isset($next_status) && in_array($curr_status_kurzbz, $this->_endStatusArr)) + { + return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_endstatus')); + } + + // wenn Unterbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein + if + ($curr_status_kurzbz == self::UNTERBRECHER_STATUS && isset($next_status) && $next_status->status_kurzbz == self::UNTERBRECHER_STATUS + && $curr_status_ausbildungssemester != $next_status->ausbildungssemester) + { + return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveUnterbrecher')); + } + + // wenn Abbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein + if (isset($next_status) + && $curr_status_kurzbz == self::UNTERBRECHER_STATUS + && $next_status->status_kurzbz == self::ABBRECHER_STATUS && $curr_status_ausbildungssemester != $next_status->ausbildungssemester) + { + return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveUnterbrecherAbbrecher')); + } + + if (isset($next_status) && $next_status->status_kurzbz == self::STUDENT_STATUS) + { + $restliche_status_obj = array_slice($statusArr, $i); + $restliche_status = array_unique(array_column($restliche_status_obj, 'status_kurzbz')); + $status_intersected = array_intersect($restliche_status, $this->_statusAbfolgeVorStudent); + + // Vor Studentstatus darf kein Diplomand Status vorhanden sein + if (in_array(self::DIPLOMAND_STATUS, $restliche_status)) + { + return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveDiplomandStudent')); + } + + // Vor Studentstatus müssen bestimmte Status vorhanden sein + if (array_values($status_intersected) != array_values(array_reverse($this->_statusAbfolgeVorStudent))) + { + return error( + $studentName . ' ' + . $this->_ci->p->t('lehre', 'error_wrongStatusOrderBeforeStudent', array(implode(', ', $this->_statusAbfolgeVorStudent))) + ); + } + } + } + + if (isset($ersterStudent)) + { + $studentName = $ersterStudent->vorname . ' ' . $ersterStudent->nachname; + + // wenn erster Studentstatus, checken ob Personenkennzeichen passt + $studienjahrNumber = $this->_ci->StudiensemesterModel->getStudienjahrNumberFromStudiensemester($ersterStudent->studiensemester_kurzbz); + + if ($studienjahrNumber != mb_substr($ersterStudent->matrikelnr, 0, 2)) + { + return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_personenkennzeichenPasstNichtZuStudiensemester')); + } + + // wenn erster Studentstatus, checken ob Orgform des Bewerbers mit Studenten übereinstimmt + if (!isEmptyArray( + array_filter( + $restliche_status_obj, + function ($s) use ($ersterStudent) { + return + $s->status_kurzbz == self::BEWERBER_STATUS + && ( + $s->studienplan_orgform_kurzbz != $ersterStudent->studienplan_orgform_kurzbz + ); + } + ) + ) + ) + { + return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_bewerberOrgformUngleichStudentOrgform')); + } + } + + return $resultPs; + } +} diff --git a/application/libraries/SearchBarLib.php b/application/libraries/SearchBarLib.php index 7197eae6a..b725f6e90 100644 --- a/application/libraries/SearchBarLib.php +++ b/application/libraries/SearchBarLib.php @@ -358,6 +358,35 @@ EOSC; */ private function _student($searchstr, $type) { + $dbModel = new DB_Model(); + + $students = $dbModel->execReadOnlyQuery(' + SELECT + \''.$type.'\' AS type, + s.student_uid AS uid, + s.matrikelnr, + p.person_id AS person_id, + p.vorname || \' \' || p.nachname AS name, + k.kontakt as email , + p.foto + FROM public.tbl_student s + JOIN public.tbl_benutzer b ON(b.uid = s.student_uid) + JOIN public.tbl_person p USING(person_id) + LEFT JOIN ( + SELECT kontakt, person_id + FROM public.tbl_kontakt + WHERE kontakttyp = \'email\' + ) as k USING(person_id) + WHERE b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\' + OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\' + OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\' + GROUP BY type, s.student_uid, s.matrikelnr, p.person_id, name, email, p.foto + '); + + // If something has been found then return it + if (hasData($students)) return getData($students); + + // Otherwise return an empty array return array(); } @@ -366,6 +395,41 @@ EOSC; */ private function _prestudent($searchstr, $type) { + $dbModel = new DB_Model(); + + $prestudent = $dbModel->execReadOnlyQuery(' + SELECT + \''.$type.'\' AS type, + ps.prestudent_id, + ps.studiengang_kz, + p.person_id AS person_id, + b.uid, + p.vorname || \' \' || p.nachname AS name, + ( + SELECT kontakt + FROM public.tbl_kontakt + WHERE kontakttyp = \'email\' + AND person_id = p.person_id + LIMIT 1 + ) as email, + p.foto, + sg.bezeichnung + FROM public.tbl_prestudent ps + LEFT JOIN public.tbl_student s USING (prestudent_id) + LEFT JOIN public.tbl_benutzer b ON (b.uid = s.student_uid) + JOIN public.tbl_person p ON (p.person_id = ps.person_id) + LEFT JOIN public.tbl_studiengang sg ON (sg.studiengang_kz = ps.studiengang_kz) + WHERE b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\' + OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\' + OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\' + or cast(ps.prestudent_id as text) ILIKE \'%'.$dbModel->escapeLIKE($searchstr).'%\' + GROUP BY type, b.uid, ps.prestudent_id, ps.studiengang_kz, sg.bezeichnung, s.student_uid, s.matrikelnr, p.person_id, name, email, p.foto + '); + + // If something has been found then return it + if (hasData($prestudent)) return getData($prestudent); + + // Otherwise return an empty array return array(); } diff --git a/application/libraries/UDFLib.php b/application/libraries/UDFLib.php index c5f0d3e98..7437c58ff 100644 --- a/application/libraries/UDFLib.php +++ b/application/libraries/UDFLib.php @@ -65,6 +65,8 @@ class UDFLib private $_udfUniqueId; // Property that contains the UDF widget unique id + private $_definition_cache = []; + /** * Gets CI instance */ @@ -157,7 +159,7 @@ class UDFLib $found = false; // used to check if the field is found or not in the json schema $this->_sortJsonSchemas($jsonSchemasArray); // Sort the list of UDF by sort property - + // Loops through json schemas foreach ($jsonSchemasArray as $jsonSchema) { @@ -292,7 +294,7 @@ class UDFLib // Checks if the requiredPermissions is available and it is a valid array or a valid string if (isset($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}) && (!isEmptyArray($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}) - || !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))) + || !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))) { // Then check if the user has the permissions to read such UDF if (!$this->_readAllowed($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})) @@ -353,7 +355,7 @@ class UDFLib // Checks if the requiredPermissions is available and it is a valid array or a valid string if (isset($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}) && (!isEmptyArray($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}) - || !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))) + || !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))) { // Then check if the user has the permissions to write such UDF if (!$this->_writeAllowed($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})) @@ -613,6 +615,162 @@ class UDFLib ); } + /** + * Gets the UDF definitions for a model + * + * @param DB_Model $targetModel + * + * @return stdClass + */ + public function getDefinitionForModel($targetModel) + { + $dbTable = $targetModel->getDbTable(); + if (!isset($this->_definition_cache[$dbTable])) { + $this->_ci->load->model('system/UDF_model', 'UDFModel'); + list($schema, $table) = explode('.', $dbTable); + $result = $this->_ci->UDFModel->loadWhere([ + 'schema' => $schema, + 'table' => $table + ]); + if (isError($result)) + return $result; + if (!hasData($result)) + $this->_definition_cache[$dbTable] = []; + else + $this->_definition_cache[$dbTable] = json_decode(current($result->retval)->jsons, true); + } + return success($this->_definition_cache[$dbTable]); + } + + /** + * Gets the UDFs for db entry with translated params and resolved listValues for dropdowns + * + * @param DB_Model $targetModel + * @param mixed $id + * + * @return stdClass + */ + public function getFieldArray($targetModel, $id) + { + // Load Libraries + $this->_ci->load->library('PhrasesLib'); + $this->_ci->load->library('PermissionLib'); + + $result = $this->getDefinitionForModel($targetModel); + if (isError($result)) + return $result; + $definitions = $result->retval; + + usort($definitions, function ($a, $b) { + return $a[self::SORT] - $b[self::SORT]; + }); + + $values = $targetModel->getUDFs($id); + + $fields = []; + foreach ($definitions as $field) { + // check read permissions + if (!$this->_ci->permissionlib->hasAtLeastOne( + $field[self::REQUIRED_PERMISSIONS_PARAMETER], + self::PERMISSION_TABLE_METHOD, + self::PERMISSION_TYPE_READ + )) + continue; + + // set value + if (isset($values[$field[self::NAME]])) { + $field['value'] = $values[$field[self::NAME]]; + } elseif (isset($field['defaultValue'])) { + $field['value'] = $field['defaultValue']; + } elseif (isset($field[self::TYPE]) && $field[self::TYPE] == 'checkbox') { + $field['value'] = false; + } else { + $field['value'] = ''; + } + + // translate params + foreach ([self::LABEL, self::TITLE, self::PLACEHOLDER] as $key) { + if (isset($field[$key])) { + $res = $this->_ci->phraseslib->getPhrases(self::PHRASES_APP_NAME, getUserLanguage(), $field[$key], null, null, 'no'); + if (hasData($res)) + $field[$key] = current(getData($res))->text; + } + } + + // check write permissions + $field['disabled'] = !$this->_ci->permissionlib->hasAtLeastOne( + $field[self::REQUIRED_PERMISSIONS_PARAMETER], + self::PERMISSION_TABLE_METHOD, + self::PERMISSION_TYPE_WRITE + ); + + // set listValues for dropdowns + if (isset($field[self::LIST_VALUES])) { + if (isset($field[self::LIST_VALUES]['enum'])) { + $field['options'] = $field[self::LIST_VALUES]['enum']; + } elseif (isset($field[self::LIST_VALUES]['sql'])) { + $res = $this->_ci->UDFModel->execReadOnlyQuery($field[self::LIST_VALUES]['sql']); + $field['options'] = hasData($res) ? getData($res) : []; + } + } + + // add to array + $fields[] = $field; + } + return success($fields); + } + + /** + * Gets a validation config array for CI form_validation + * + * @param DB_Model $targetModel + * @param array (optional) $filter + * + * @return stdClass + */ + public function getCiValidations($targetModel, $filter = null) + { + $result = $this->getDefinitionForModel($targetModel); + if (isError($result)) + return $result; + $definitions = getData($result); + + $result = []; + foreach ($definitions as $def) { + if ($filter && !isset($filter[$def['name']])) + continue; + $validations = []; + if (isset($def['requiredPermissions'])) + $validations[] = 'has_write_permissions[' . implode(',', $def['requiredPermissions']) . ']'; + if (isset($def['required'])) + $validations[] = 'required'; + if (isset($def['validation'])) { + if (isset($def['validation']['max-value'])) + $validations[] = 'less_than_equal_to[' . $def['validation']['max-value'] . ']'; + if (isset($def['validation']['min-value'])) + $validations[] = 'greater_than_equal_to[' . $def['validation']['min-value'] . ']'; + if (isset($def['validation']['max-length'])) + $validations[] = 'max_length[' . $def['validation']['max-length'] . ']'; + if (isset($def['validation']['min-length'])) + $validations[] = 'min_length[' . $def['validation']['min-length'] . ']'; + if (isset($def['validation']['regex']) && is_array($def['validation']['regex'])) { + foreach ($def['validation']['regex'] as $regex) { + if ($regex['language'] == 'php') { + $validations[] = 'regex_match[' . $regex['expression'] . ']'; + } + } + } + } + if ($validations) + $result[] = [ + 'field' => $def['name'], + 'label' => $def['title'], + 'rules' => $validations + ]; + } + return success($result); + } + // ------------------------------------------------------------------------------------------------- // Private methods // @@ -841,7 +999,7 @@ class UDFLib $htmlParameters[HTMLWidget::HTML_ID] = $jsonSchema->{self::NAME}; $htmlParameters[HTMLWidget::HTML_NAME] = $jsonSchema->{self::NAME}; } - + /** * Sort the list of UDF by sort property */ @@ -864,7 +1022,7 @@ class UDFLib return ($a->{self::SORT} < $b->{self::SORT}) ? -1 : 1; }); } - + /** * Loads the UDF description by the given schema and table */ diff --git a/application/libraries/issues/PlausicheckProducerLib.php b/application/libraries/issues/PlausicheckProducerLib.php index 3a51e2b1e..cea9967fb 100644 --- a/application/libraries/issues/PlausicheckProducerLib.php +++ b/application/libraries/issues/PlausicheckProducerLib.php @@ -12,18 +12,25 @@ class PlausicheckProducerLib private $_ci; // ci instance private $_extensionName; // name of extension - private $_konfiguration = array(); // configuration parameters + private $_konfiguration = []; // configuration parameters + private $_fehlerLibMappings = []; // mappings of fehler and libraries for producing them + private $_isForResolutionCheck = false; // mappings of fehler and libraries for producing them public function __construct($params = null) { // set extension name if called from extension if (isset($params['extensionName'])) $this->_extensionName = $params['extensionName']; + if (isset($params['fehlerLibMappings'])) $this->_fehlerLibMappings = $params['fehlerLibMappings']; + if (isset($params['isForResolutionCheck'])) $this->_isForResolutionCheck = $params['isForResolutionCheck']; // set application $app = isset($params['app']) ? $params['app'] : null; $this->_ci =& get_instance(); // get ci instance + // load libraries + $this->_ci->load->library('IssuesLib'); + // load models $this->_ci->load->model('system/Fehlerkonfiguration_model', 'FehlerkonfigurationModel'); @@ -41,6 +48,52 @@ class PlausicheckProducerLib } } + /** + * Produces multiple plausicheck issues at once and saved them to db. + * @param array $params passed to each plausicheck + * @return result object with occured error and info + */ + public function producePlausicheckIssues($params) + { + $result = new StdClass(); + $result->errors = []; + $result->infos = []; + + foreach ($this->_fehlerLibMappings as $fehler_kurzbz => $libName) + { + $plausicheckRes = $this->producePlausicheckIssue( + $libName, + $fehler_kurzbz, + $params + ); + + if (hasData($plausicheckRes)) + { + $plausicheckData = getData($plausicheckRes); + + foreach ($plausicheckData as $plausiData) + { + // get the data needed for issue production + $person_id = isset($plausiData['person_id']) ? $plausiData['person_id'] : null; + $oe_kurzbz = isset($plausiData['oe_kurzbz']) ? $plausiData['oe_kurzbz'] : null; + $fehlertext_params = isset($plausiData['fehlertext_params']) ? $plausiData['fehlertext_params'] : null; + $resolution_params = isset($plausiData['resolution_params']) ? $plausiData['resolution_params'] : null; + + // write the issue + $addIssueRes = $this->_ci->issueslib->addFhcIssue($fehler_kurzbz, $person_id, $oe_kurzbz, $fehlertext_params, $resolution_params); + + // log if error, or log info if inserted new issue + if (isError($addIssueRes)) + $result->errors[] = getError($addIssueRes); + elseif (hasData($addIssueRes) && is_integer(getData($addIssueRes))) + $result->infos[] = "Plausicheck issue " . $fehler_kurzbz . " successfully produced, person_id: " . $person_id; + } + } + } + + return $result; + } + /** * Executes plausicheck using a given library, returns the result. * @param $libName string name of library producing the issue @@ -66,7 +119,10 @@ class PlausicheckProducerLib $config = isset($this->_konfiguration[$fehler_kurzbz]) ? $this->_konfiguration[$fehler_kurzbz] : null; // load library connected to fehlercode - $this->_ci->load->library($issuesLibPath . $libName, $config); + $this->_ci->load->library( + $issuesLibPath . $libName, + ['configurationParams' => $config, 'isForResolutionCheck' => $this->_isForResolutionCheck] + ); $lowercaseLibName = mb_strtolower($libName); diff --git a/application/libraries/issues/PlausicheckResolverLib.php b/application/libraries/issues/PlausicheckResolverLib.php new file mode 100644 index 000000000..26da985f6 --- /dev/null +++ b/application/libraries/issues/PlausicheckResolverLib.php @@ -0,0 +1,136 @@ +_extensionName = $params['extensionName']; + if (isset($params['codeLibMappings'])) $this->_codeLibMappings = $params['codeLibMappings']; + if (isset($params['codeProducerLibMappings'])) $this->_codeProducerLibMappings = $params['codeProducerLibMappings']; + + $this->_ci =& get_instance(); // get ci instance + + $this->_ci->load->library('IssuesLib'); + $this->_ci->load->library('issues/PlausicheckProducerLib', ['extensionName' => $this->_extensionName, 'isForResolutionCheck' => true]); + } + + /** + * Reseolves multiple plausicheck issues at once. + * @param array $codeLibMappings contains fehler type to check and library responsible for check (fehlercode => libName) + * @param array $openIssues passed issues to resolve + * @return result object with occured error and info + */ + public function resolvePlausicheckIssues($openIssues) + { + $result = new StdClass(); + $result->errors = []; + $result->infos = []; + + foreach ($openIssues as $issue) + { + // add person id and oe kurzbz automatically as params, merge it with additional params + // decode bewerbung_parameter into assoc array + $params = array_merge( + array('issue_id' => $issue->issue_id, 'issue_person_id' => $issue->person_id, 'issue_oe_kurzbz' => $issue->oe_kurzbz), + isset($issue->behebung_parameter) ? json_decode($issue->behebung_parameter, true) : array() + ); + + $issueResolved = false; + + // ignore if Fehlercode is not in libmappings (shouldn't be checked) + if (isset($this->_codeLibMappings[$issue->fehlercode])) + { + $libName = $this->_codeLibMappings[$issue->fehlercode]; + + // if called from extension (extension name set), path includes extension names + $libRootPath = isset($this->_extensionName) ? self::EXTENSIONS_FOLDER . '/' . $this->_extensionName . '/' : ''; + + // path for loading issue library + $issuesLibPath = $libRootPath . self::ISSUE_RESOLVERS_FOLDER . '/'; + + // file path of library for check if file exists + $issuesLibFilePath = DOC_ROOT . self::CI_PATH + . '/' . $libRootPath . self::CI_LIBRARY_FOLDER . '/' . self::ISSUE_RESOLVERS_FOLDER . '/' . $libName . '.php'; + + // check if library file exists + if (!file_exists($issuesLibFilePath)) + { + // log error and continue with next issue if not + $result->errors[] = "Issue library file " . $issuesLibFilePath . " does not exist"; + continue; + } + + // load library connected to fehlercode + $this->_ci->load->library($issuesLibPath . $libName); + + $lowercaseLibName = mb_strtolower($libName); + + // check if method is defined in library class + if (!is_callable(array($this->_ci->{$lowercaseLibName}, self::CHECK_ISSUE_RESOLVED_METHOD_NAME))) + { + // log error and continue with next issue if not + $result->errors[] = "Method " . self::CHECK_ISSUE_RESOLVED_METHOD_NAME . " is not defined in library $lowercaseLibName"; + continue; + } + + // call the function for checking for issue resolution + $issueResolvedRes = $this->_ci->{$lowercaseLibName}->{self::CHECK_ISSUE_RESOLVED_METHOD_NAME}($params); + + if (isError($issueResolvedRes)) + { + $result->errors[] = getError($issueResolvedRes); + } + else + { + $issueResolved = getData($issueResolvedRes) === true; + } + } + elseif (isset($this->_codeProducerLibMappings[$issue->fehlercode])) + { + $libName = $this->_codeProducerLibMappings[$issue->fehlercode]; + + $issueResolvedRes = $this->_ci->plausicheckproducerlib->producePlausicheckIssue( + $libName, + $issue->fehler_kurzbz, + $params + ); + + if (isError($issueResolvedRes)) + { + $result->errors[] = getError($issueResolvedRes); + } + else + { + $issueResolved = !hasData($issueResolvedRes); + } + } + + // set issue to resolved if needed + if ($issueResolved) + { + $behobenRes = $this->_ci->issueslib->setBehoben($issue->issue_id, null); + + if (isError($behobenRes)) + $result->errors[] = getError($behobenRes); + else + $result->infos[] = "Issue " . $issue->issue_id . " successfully resolved"; + } + } + + return $result; + } +} diff --git a/application/libraries/issues/plausichecks/AbbrecherAktiv.php b/application/libraries/issues/plausichecks/AbbrecherAktiv.php index 9eae389b5..464b77a30 100644 --- a/application/libraries/issues/plausichecks/AbbrecherAktiv.php +++ b/application/libraries/issues/plausichecks/AbbrecherAktiv.php @@ -9,83 +9,21 @@ require_once('PlausiChecker.php'); */ class AbbrecherAktiv extends PlausiChecker { - public function executePlausiCheck($params) - { - $results = array(); + protected $_base_sql = " + SELECT + pre.person_id, pre.prestudent_id, stg.oe_kurzbz AS prestudent_stg_oe_kurzbz + FROM + public.tbl_prestudentstatus pre_status + JOIN public.tbl_prestudent pre USING(prestudent_id) + JOIN public.tbl_student student USING(prestudent_id) + JOIN public.tbl_benutzer benutzer on(benutzer.uid=student.student_uid) + JOIN public.tbl_studiengang stg ON pre.studiengang_kz = stg.studiengang_kz + WHERE + pre_status.status_kurzbz ='Abbrecher' + AND benutzer.aktiv=true"; - // get parameters from config - $exkludierte_studiengang_kz = isset($this->_config['exkludierteStudiengaenge']) ? $this->_config['exkludierteStudiengaenge'] : null; - - // pass parameters needed for plausicheck - $studiengang_kz = isset($params['studiengang_kz']) ? $params['studiengang_kz'] : null; - - // get all students failing the plausicheck - $prestudentRes = $this->getAbbrecherAktiv($studiengang_kz, null, $exkludierte_studiengang_kz); - - if (isError($prestudentRes)) return $prestudentRes; - - if (hasData($prestudentRes)) - { - $prestudents = getData($prestudentRes); - - // populate results with data necessary for writing issues - foreach ($prestudents as $prestudent) - { - $results[] = array( - 'person_id' => $prestudent->person_id, - 'oe_kurzbz' => $prestudent->prestudent_stg_oe_kurzbz, - 'fehlertext_params' => array('prestudent_id' => $prestudent->prestudent_id), - 'resolution_params' => array('prestudent_id' => $prestudent->prestudent_id) - ); - } - } - - // return the results - return success($results); - } - - /** - * Abbrecher cannot be active. - * @param studiengang_kz int if check is to be executed for certain Studiengang - * @param prestudent_id int if check is to be executed only for one prestudent - * @param exkludierte_studiengang_kz array if certain Studiengänge have to be excluded from check - * @return success with prestudents or error - */ - public function getAbbrecherAktiv($studiengang_kz = null, $prestudent_id = null, $exkludierte_studiengang_kz = null) - { - $params = array(); - - $qry = " - SELECT - pre.person_id, pre.prestudent_id, stg.oe_kurzbz AS prestudent_stg_oe_kurzbz - FROM - public.tbl_prestudentstatus pre_status - JOIN public.tbl_prestudent pre USING(prestudent_id) - JOIN public.tbl_student student USING(prestudent_id) - JOIN public.tbl_benutzer benutzer on(benutzer.uid=student.student_uid) - JOIN public.tbl_studiengang stg ON pre.studiengang_kz = stg.studiengang_kz - WHERE - pre_status.status_kurzbz ='Abbrecher' - AND benutzer.aktiv=true"; - - if (isset($studiengang_kz)) - { - $qry .= " AND stg.studiengang_kz = ?"; - $params[] = $studiengang_kz; - } - - if (isset($prestudent_id)) - { - $qry .= " AND pre.prestudent_id = ?"; - $params[] = $prestudent_id; - } - - if (isset($exkludierte_studiengang_kz) && !isEmptyArray($exkludierte_studiengang_kz)) - { - $qry .= " AND stg.studiengang_kz NOT IN ?"; - $params[] = $exkludierte_studiengang_kz; - } - - return $this->_db->execReadOnlyQuery($qry, $params); - } + protected $_config_params = ['exkludierteStudiengaenge' => " AND stg.studiengang_kz NOT IN ?"]; + protected $_params_for_checking = ['studiengang_kz' => " AND stg.studiengang_kz = ?", 'prestudent_id' => " AND pre.prestudent_id = ?"]; + protected $_fehlertext_params = ['prestudent_id']; + protected $_resolution_params = ['prestudent_id']; } diff --git a/application/libraries/issues/plausichecks/PlausiChecker.php b/application/libraries/issues/plausichecks/PlausiChecker.php index 086a44cc4..7e5fe7db0 100644 --- a/application/libraries/issues/plausichecks/PlausiChecker.php +++ b/application/libraries/issues/plausichecks/PlausiChecker.php @@ -6,15 +6,25 @@ abstract class PlausiChecker { protected $_ci; // code igniter instance - protected $_config; // configuration parameters for this plausicheck + protected $_config; // all applicable configuration parameters for this plausicheck protected $_db; // database for queries - public function __construct($configurationParams = null) + protected $_isForResolutionCheck; // if true, additional parameters only needed for resolution are checked + + protected $_config_params = []; // name of all config params which should be applied for this plausicheck, with sql [name] => [sql] + protected $_params_for_checking = []; // name of all passed params for checking, with sql [name] => [sql] + + protected $_fehlertext_params = []; // parameter names for fehlertext params used for this plausicheck + protected $_resolution_params = []; // parameter names for resolution params used for this plausicheck + + public function __construct($params = null) { $this->_ci =& get_instance(); // get code igniter instance // set configuration - $this->_config = $configurationParams; + $this->_config = $params['configurationParams'] ?? []; + + $this->_isForResolutionCheck = $params['isForResolutionCheck'] ?? false; // get database for queries $this->_db = new DB_Model(); @@ -25,5 +35,83 @@ abstract class PlausiChecker * @param $paramsForChecking array parameters needed for executing the check * @return array with objects which failed the plausi check */ - abstract public function executePlausiCheck($paramsForChecking); + public function executePlausiCheck($paramsForChecking) + { + $results = []; + $params = []; + $qry = $this->_base_sql; + + if ($this->_isForResolutionCheck == true) + { + foreach ($this->_resolution_params as $resParam) + { + if (!isset($paramsForChecking[$resParam])) + return error("$resParam missing".(isset($paramsForChecking['issue_id']) ? ", issue ID: ".$paramsForChecking['issue_id'] : "")); + } + } + + // add config params to query + if (isset($this->_config_params) && !isEmptyArray($this->_config_params)) + { + foreach ($this->_config_params as $param_name => $param_sql) + { + if (isset($this->_config[$param_name])) + { + $qry .= $param_sql; + $params[] = $this->_config[$param_name]; + } + } + } + + // add check params to query + if (isset($this->_params_for_checking) && !isEmptyArray($this->_params_for_checking)) + { + foreach ($this->_params_for_checking as $param_name => $param_sql) + { + if (isset($paramsForChecking[$param_name])) + { + $qry .= $param_sql; + $params[] = $paramsForChecking[$param_name]; + } + } + } + + $result = $this->_db->execReadOnlyQuery($qry, $params); + + if (isError($result)) return $result; + + if (hasData($result)) + { + $data = getData($result); + + // populate results with data necessary for writing issues + foreach ($data as $d) + { + $fehlertext_params = []; + $resolution_params = []; + + // add params for error texts + foreach ($this->_fehlertext_params as $param) + { + if (isset($d->{$param})) $fehlertext_params[$param] = $d->{$param}; + } + + // add params for resolution of issue + foreach ($this->_resolution_params as $param) + { + if (isset($d->{$param})) $resolution_params[$param] = $d->{$param}; + } + + $results[] = array( + 'person_id' => $d->person_id, + 'oe_kurzbz' => $d->prestudent_stg_oe_kurzbz, + 'fehlertext_params' => $fehlertext_params, + 'resolution_params' => $resolution_params + ); + } + } + + // return the results + return success($results); + } } diff --git a/application/models/codex/Bismeldestichtag_model.php b/application/models/codex/Bismeldestichtag_model.php index 6ab755c8b..319aa7be7 100644 --- a/application/models/codex/Bismeldestichtag_model.php +++ b/application/models/codex/Bismeldestichtag_model.php @@ -1,7 +1,6 @@ pk = 'meldestichtag_id'; } + public function getLastReachedMeldestichtag($studiensemester_kurzbz = null) + { + $this->addSelect('meldestichtag_id'); + $this->addSelect('meldestichtag'); + $this->addSelect('studiensemester_kurzbz'); + $this->addSelect('insertamum'); + $this->addSelect('insertvon'); + $this->addSelect('updateamum'); + $this->addSelect('updatevon'); + + if ($studiensemester_kurzbz) { + $this->db->where('studiensemester_kurzbz', $studiensemester_kurzbz); + } + + $this->addOrder('meldestichtag', 'DESC'); + $this->addLimit(1); + + return $this->loadWhere([ + 'meldestichtag < NOW()' => null + ]); + } + + /** + * Prüft, ob Meldestichtag für ein bestimmtes Statusdatum und Studiensemester erreicht ist. + * + * @param $status_datum + * @return boolean true wenn erreicht, oder false + */ + public function checkIfMeldestichtagErreicht($status_datum, $studiensemester_kurzbz = null) + { + $erreicht = false; + + if (isset($studiensemester_kurzbz)) + { + // Studiensemesterende holen + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $result = $this->StudiensemesterModel->loadWhere( + array( + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ) + ); + if(isError($result)) + { + return $result; + } + $result = current(getData($result)); + + $studiensemester_ende = new DateTime($result->ende); + } + + // letztes erreichtes Bismeldedatum holen + $result = $this->getLastReachedMeldestichtag(); + if (isError($result)) + { + return $result; + } + if (!hasData($result)) { + return success("0",'No Statusdata vorhanden'); + } + $stichtag = current(getData($result)); + $stichtag = new DateTime($stichtag->meldestichtag); + + $statusDatum = new DateTime($status_datum); + + // Prüfen, ob Studentstatusdatum oder Studiensemester vor dem Stichtagsdatum liegen + if (isset($statusDatum)) + { + if (isset($stichtag)) + $erreicht = $statusDatum < $stichtag; + } + + if (isset($studiensemester_ende)) + { + $erreicht = $erreicht || $studiensemester_ende < $stichtag; + } + + if ($erreicht) + return success("1", "Studentstatus mit Datum oder Semesterende vor erreichtem Meldestichtag können nicht hinzugefügt werden"); + + return success("0", "Meldestatus nicht erreicht"); + } + /** * Gets last Bismeldestichtag for a Studiensemester. * @param $studiensemester_kurzbz diff --git a/application/models/codex/Gemeinde_model.php b/application/models/codex/Gemeinde_model.php index c782346a0..670da739d 100644 --- a/application/models/codex/Gemeinde_model.php +++ b/application/models/codex/Gemeinde_model.php @@ -19,4 +19,13 @@ class Gemeinde_model extends DB_Model return $this->loadWhere(array("plz" => $plz)); } + + public function checkLocation($plz, $gemeinde, $ort) + { + $this->db->where('ortschaftsname', $ort); + $this->db->where('name', $gemeinde); + $this->db->where('plz', $plz); + + return (boolean)$this->db->count_all_results($this->dbTable); + } } \ No newline at end of file diff --git a/application/models/crm/Konto_model.php b/application/models/crm/Konto_model.php index e76ed9e7a..d130d5db8 100644 --- a/application/models/crm/Konto_model.php +++ b/application/models/crm/Konto_model.php @@ -1,4 +1,7 @@ pk = 'buchungsnr'; } + /** + * Insert Data into DB-Table + * + * @param array $data DataArray for Insert + * @return stdClass + */ + public function insert($data, $encryptedColumns = null) + { + if (isset($data['buchungsnr_verweis']) && $data['buchungsnr_verweis']) + return parent::insert($data, $encryptedColumns); + + $this->db->trans_begin(); + + $result = parent::insert($data, $encryptedColumns); + if (isError($result)) { + $this->db->trans_rollback(); + return $result; + } + + $buchungsnr = $result->retval; + // If studiengang_kz is not present in $data it will fail above since it is a not null field + $studiengang_kz = $data['studiengang_kz']; + + + $zahlungsreferenz = false; + Events::trigger('generate_zahlungsreferenz', $buchungsnr, $data, function ($value) use ($zahlungsreferenz) { + $zahlungsreferenz = $value; + }); + + if ($zahlungsreferenz === false) { + $result = $this->execQuery('SELECT UPPER(oe_kurzbz) || ? as zahlungsreferenz + FROM public.tbl_studiengang + WHERE studiengang_kz=?', [$buchungsnr, $studiengang_kz]); + if (isError($result)) { + $this->db->trans_rollback(); + return $result; + } + $zahlungsreferenz = current(getData($result))->zahlungsreferenz; + } elseif (isError($zahlungsreferenz)) { + $this->db->trans_rollback(); + return $zahlungsreferenz; + } + + + $result = $this->update($buchungsnr, [ + 'zahlungsreferenz' => $zahlungsreferenz + ]); + + if (isError($result)) { + $this->db->trans_rollback(); + return $result; + } + + $this->db->trans_commit(); + + return success($buchungsnr); + } + + /** + * Delete data from DB-Table + * + * @param string $id Primary Key for DELETE + * + * @return stdClass + */ + public function delete($id) + { + $this->db->where('buchungsnr_verweis', $id); + if ($this->db->count_all_results($this->dbTable)) + return error('Bitte zuerst die zugeordneten Buchungen loeschen', 42); + return parent::delete($id); + } + + /** + * Adds additional fields to the Query + * + * @return Konto_model + */ + public function withAdditionalInfo() + { + $this->addSelect($this->dbTable . '.*'); + $this->addSelect('UPPER(typ::varchar(1) || kurzbz) AS kuerzel'); + $this->addSelect('person.anrede'); + $this->addSelect('person.titelpost'); + $this->addSelect('person.titelpre'); + $this->addSelect('person.vorname'); + $this->addSelect('person.vornamen'); + $this->addSelect('person.nachname'); + + $this->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); + $this->addJoin('public.tbl_person person', 'person_id', 'LEFT'); + + Events::trigger('konto_query'); + + return $this; + } + + /** + * Get all accounting entries for a person optionally filtered by Studiengang + * + * @param integer|array $person_id + * @param string (optional) $studiengang_kz + * + * @return stdClass + */ + public function getAlleBuchungen($person_id, $studiengang_kz = '') + { + $this->withAdditionalInfo(); + + $this->addOrder('buchungsdatum'); + + if (is_array($person_id)) + $this->db->where_in('person_id', $person_id); + else + $this->db->where('person_id', $person_id); + + if ($studiengang_kz) + return $this->loadWhere([ + 'studiengang_kz' => $studiengang_kz + ]); + return $this->load(); + } + + /** + * Get all open accounting entries for a person optionally filtered by Studiengang + * + * @param integer|array $person_id + * @param string (optional) $studiengang_kz + * + * @return stdClass + */ + public function getOffeneBuchungen($person_id, $studiengang_kz = '') + { + $this->addSelect('buchungsnr'); + $this->db->where('(betrag + ( + SELECT CASE WHEN sum(betrag) is null THEN 0 ELSE sum(betrag) END + FROM ' . $this->dbTable . ' + WHERE buchungsnr_verweis=konto_a.buchungsnr + )) !=', 0, false); + if (is_array($person_id)) + $this->db->where_in('person_id', $person_id); + else + $this->db->where('person_id', $person_id); + $sql = $this->db->get_compiled_select($this->dbTable . ' konto_a'); + + $this->db->group_start(); + $this->db->where_in('buchungsnr', $sql, false); + $this->db->or_where_in('buchungsnr_verweis', $sql, false); + $this->db->group_end(); + + return $this->getAlleBuchungen($person_id, $studiengang_kz); + } + + /** + * Check double Buchungen + * + * @param array $person_ids + * @param string $studiensemester_kurzbz + * @param array $buchungstyp_kurzbzs + * + * @return stdClass + */ + public function checkDoubleBuchung($person_ids, $studiensemester_kurzbz, $buchungstyp_kurzbzs) + { + $this->addSelect('vorname'); + $this->addSelect('nachname'); + + $this->addJoin('public.tbl_person', 'person_id'); + + $this->db->where_in('person_id', $person_ids); + $this->db->where_in('buchungstyp_kurzbz', $buchungstyp_kurzbzs); + + $this->addGroupBy('vorname, nachname'); + $this->addOrder('nachname'); + $this->addOrder('vorname'); + + return $this->loadWhere([ + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ]); + } + + /** + * Berechnet den offenen Betrag einer Buchung + * + * @param integer $buchungsnr + * + * @return stdClass + */ + public function getDifferenz($buchungsnr) + { + $this->addSelect('buchungsnr_verweis'); + $this->db->where('buchungsnr', $buchungsnr); + $sql = $this->db->get_compiled_select($this->dbTable); + + $this->addSelect('buchungsnr_verweis'); + $this->db->where('buchungsnr', $buchungsnr); + $this->db->or_where('buchungsnr_verweis', '(' . $sql . ')', false); + $sql = $this->db->get_compiled_select($this->dbTable); + + $this->addSelect('sum(betrag) differenz'); + $this->db->where('buchungsnr', $buchungsnr); + $this->db->or_where('buchungsnr_verweis', $buchungsnr); + $this->db->or_where('buchungsnr', '(' . $sql . ')', false); + + $result = $this->load(); + if (isError($result)) + return $result; + if (!hasData($result)) + return success(null); + return success(current(getData($result))->differenz * -1); + } + /** * Sets a Payment as paid */ diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index 7b24b8769..242c26518 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -14,6 +14,39 @@ class Prestudent_model extends DB_Model $this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel'); } + /** + * Update Data in DB-Table + * + * @param string $id PK for DB-Table + * @param array $data DataArray for Insert + * @return array + */ + public function update($id, $data, $encryptedColumns = null) + { + if (isset($data['zgvmas_code']) + || isset($data['zgvmanation']) + || isset($data['zgv_code']) + || isset($data['zgvnation']) + ) { + /** + * Falls ZGV vorhanden, setze Ausstellungsstaat (für BIS-Meldung) + * auf Nation der höchsten angegebenen ZGV + */ + $case = '(CASE + WHEN zgvmas_code IS NOT NULL AND zgvmanation IS NOT NULL THEN zgvmanation + WHEN zgv_code IS NOT NULL AND zgvnation IS NOT NULL THEN zgvnation + ELSE NULL END)'; + + foreach (['zgvmas_code', 'zgvmanation', 'zgv_code', 'zgvnation'] as $key) + if (isset($data[$key])) + $case = str_replace($key, $this->escape($data[$key]), $case); + + $this->db->set('ausstellungsstaat', $case, false); + } + + return parent::update($id, $data, $encryptedColumns); + } + /** * getLastStatuses */ @@ -700,4 +733,33 @@ class Prestudent_model extends DB_Model return $this->execQuery($query, array($prestudent_id)); } + /** + * Gets history of all prestudents, person_id given + * @param int $person_id + * @return object + */ + public function getHistoryPrestudents($person_id) + { + + $query = " + SELECT ps.studiensemester_kurzbz, p.priorisierung, p.studiengang_kz, sg.kurzbzlang, ps.orgform_kurzbz, + ps.status_kurzbz, s.student_uid, sp.bezeichnung, ps.ausbildungssemester, + CONCAT(ps.status_kurzbz, ' (', ps.ausbildungssemester, '. Semester)') as status, p.prestudent_id + FROM public.tbl_prestudent p + JOIN ( + SELECT DISTINCT ON(prestudent_id) * + FROM public.tbl_prestudentstatus + WHERE prestudent_id IN (SELECT prestudent_id FROM public.tbl_prestudent WHERE person_id = ?) + ORDER BY prestudent_id, datum desc, insertamum desc + ) ps USING(prestudent_id) + JOIN public.tbl_status USING(status_kurzbz) + LEFT JOIN public.tbl_status_grund g USING (statusgrund_id) + JOIN public.tbl_studiengang sg USING(studiengang_kz) + LEFT JOIN lehre.tbl_studienplan sp USING (studienplan_id) + LEFT JOIN public.tbl_student s USING (prestudent_id) + ORDER BY p.priorisierung + "; + + return $this->execQuery($query, array($person_id)); + } } diff --git a/application/models/crm/Prestudentstatus_model.php b/application/models/crm/Prestudentstatus_model.php index b3dc45321..6405569db 100644 --- a/application/models/crm/Prestudentstatus_model.php +++ b/application/models/crm/Prestudentstatus_model.php @@ -5,6 +5,15 @@ class Prestudentstatus_model extends DB_Model const STATUS_ABBRECHER = 'Abbrecher'; const STATUS_UNTERBRECHER = 'Unterbrecher'; + const STATUS_STUDENT = 'Student'; + const STATUS_DIPLOMAND = 'Diplomand'; + const STATUS_ABSOLVENT = 'Absolvent'; + const STATUS_BEWERBER = 'Bewerber'; + const STATUS_AUFGENOMMENER = 'Aufgenommener'; + const STATUS_WARTENDER = 'Wartender'; + const STATUS_ABGEWIESENER = 'Abgewiesener'; + const STATUS_INTERESSENT = 'Interessent'; + const STATUS_INCOMING = 'Incoming'; /** * Constructor @@ -330,13 +339,252 @@ class Prestudentstatus_model extends DB_Model */ public function withGrund($statusgrund_kurzbz) { - if($statusgrund_kurzbz) + if ($statusgrund_kurzbz) $this->db->set( 'statusgrund_id', - '(SELECT statusgrund_id FROM public.tbl_status_grund WHERE statusgrund_kurzbz =' . $this->db->escape($statusgrund_kurzbz) .')', + '(SELECT statusgrund_id FROM public.tbl_status_grund WHERE statusgrund_kurzbz=' . $this->db->escape($statusgrund_kurzbz) . ')', false ); return $this; } + + /** + * Check if there is only one prestudentstatus left + * + * @param integer $prestudent_id + * @param string $studiensemester_kurzbz + * + * @return stdClass + */ + public function checkIfLastStatusEntry($prestudent_id, $studiensemester_kurzbz = null) + { + $this->addSelect('COUNT(*) AS anzahl', false); + + if ($studiensemester_kurzbz) + $this->db->where('studiensemester_kurzbz', $studiensemester_kurzbz); + + $result = $this->loadWhere([ + 'prestudent_id' => $prestudent_id + ]); + + if (isError($result)) + return $result; + + $resultObject = current($result->retval); + + $anzahl = (int)$resultObject->anzahl; + + if ($anzahl <= 1) + return success(true, $this->p->t('lehre', 'error_lastRole')); + + return success(false, $this->p->t('lehre', 'anzahl_existingRoles', ['anzahl' => $anzahl])); + } + + public function getAllPrestudentstatiWithStudiensemester($prestudent_id) + { + $qry = " + SELECT + tbl_prestudentstatus.status_kurzbz, + tbl_prestudentstatus.studiensemester_kurzbz, + tbl_prestudentstatus.ausbildungssemester, + tbl_prestudentstatus.datum, + s.start AS studiensemester_start, + pl.orgform_kurzbz AS studienplan_orgform_kurzbz, + stud.matrikelnr, + pers.vorname, + pers.nachname + FROM + public.tbl_prestudentstatus + JOIN public.tbl_studiensemester s USING (studiensemester_kurzbz) + JOIN public.tbl_prestudent USING (prestudent_id) + JOIN public.tbl_person pers USING (person_id) + LEFT JOIN public.tbl_student stud USING (prestudent_id) + LEFT JOIN lehre.tbl_studienplan pl USING (studienplan_id) + WHERE + prestudent_id = ? + ORDER BY + public.tbl_prestudentstatus.datum DESC, + public.tbl_prestudentstatus.insertamum DESC, + public.tbl_prestudentstatus.ext_id DESC + "; + + return $this->execQuery($qry, array($prestudent_id)); + } + + /** + * Gets status history of a prestudent + * This function uses the language of the logged in user to + * translate the given statusgrund + * + * @param integer $prestudent_id + * + * @return stdClass + */ + public function getHistoryPrestudent($prestudent_id) + { + $lang= getUserLanguage(); + $this->addSelect('tbl_prestudentstatus.prestudent_id'); + $this->addSelect('tbl_prestudentstatus.status_kurzbz'); + $this->addSelect('tbl_prestudentstatus.studiensemester_kurzbz'); + $this->addSelect('tbl_prestudentstatus.ausbildungssemester'); + $this->addSelect('tbl_prestudentstatus.datum'); + $this->addSelect("TO_CHAR(tbl_prestudentstatus.datum::timestamp, 'DD.MM.YYYY') AS format_datum"); + $this->addSelect('tbl_prestudentstatus.insertamum'); + $this->addSelect('tbl_prestudentstatus.insertvon'); + $this->addSelect('tbl_prestudentstatus.updateamum'); + $this->addSelect('tbl_prestudentstatus.updatevon'); + $this->addSelect('tbl_prestudentstatus.orgform_kurzbz'); + $this->addSelect('tbl_prestudentstatus.bestaetigtam'); + $this->addSelect("TO_CHAR(tbl_prestudentstatus.bestaetigtam::timestamp, 'DD.MM.YYYY') AS format_bestaetigtam"); + $this->addSelect('tbl_prestudentstatus.bestaetigtvon'); + $this->addSelect('tbl_prestudentstatus.bewerbung_abgeschicktamum'); + $this->addSelect("TO_CHAR(tbl_prestudentstatus.bewerbung_abgeschicktamum::timestamp, 'DD.MM.YYYY') AS format_bewerbung_abgeschicktamum"); + $this->addSelect('tbl_prestudentstatus.anmerkung'); + $this->addSelect('plan.studienplan_id'); + $this->addSelect('plan.bezeichnung'); + + $this->addSelect('grund.beschreibung[( + SELECT index + FROM public.tbl_sprache + WHERE sprache=' . $this->escape($lang) . ' + )] AS statusgrund_bezeichnung', false); + $this->addSelect("CASE + WHEN s.student_uid IS NOT NULL + AND tbl_prestudentstatus.status_kurzbz IN (" . implode(",", $this->escape([ + 'Student', + 'Diplomand', + 'Abbrecher', + 'Absolvent', + 'Ausserodentlicher', + 'Incoming', + 'Outgoing', + 'Unterbrecher' + ])) . ") + THEN lv.semester || lv.verband || lv.gruppe + ELSE '-' + END AS lehrverband", false); + + + $this->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT'); + $this->addJoin('public.tbl_status_grund grund', 'statusgrund_id', 'LEFT'); + $this->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT'); + $this->addJoin( + 'public.tbl_studentlehrverband lv', + 's.student_uid IS NOT NULL AND s.student_uid=lv.student_uid AND tbl_prestudentstatus.studiensemester_kurzbz=lv.studiensemester_kurzbz', + 'LEFT' + ); + + $this->addOrder('tbl_prestudentstatus.datum', 'DESC'); + $this->addOrder('tbl_prestudentstatus.insertamum', 'DESC'); + $this->addOrder('tbl_prestudentstatus.ext_id', 'DESC'); + + return $this->loadWhere([ + 'tbl_prestudentstatus.prestudent_id' => $prestudent_id + ]); + } + + /** + * Gets status history of a prestudent for checking purposes. + * This function adds the new state or replaces the edited. + * + * @param integer $prestudent_id + * @param string $status_kurzbz + * @param DateTime $new_date + * @param string $new_studiensemester_kurzbz + * @param integer $new_ausbildungssemester + * @param string $old_studiensemester_kurzbz + * @param integer $old_ausbildungssemester + * + * @return stdClass + */ + public function getHistoryWithNewOrEditedState( + $prestudent_id, + $status_kurzbz, + $new_date, + $new_studiensemester_kurzbz, + $new_ausbildungssemester, + $old_studiensemester_kurzbz, + $old_ausbildungssemester + ) { + $new_date = $new_date->format('Y-m-d'); + + $this->addSelect('status_kurzbz'); + $this->addSelect('studiensemester_kurzbz'); + $this->addSelect('ausbildungssemester'); + $this->addSelect('datum'); + $this->addSelect('insertamum'); + $this->addSelect('ext_id'); + + if ($old_studiensemester_kurzbz || $old_ausbildungssemester) { + $this->db->not_group_start(); + $this->db->where('status_kurzbz', $status_kurzbz); + $this->db->where('studiensemester_kurzbz', $old_studiensemester_kurzbz); + $this->db->where('ausbildungssemester', $old_ausbildungssemester); + $this->db->group_end(); + } + + $this->db->where('prestudent_id', $prestudent_id); + + $tmpTable = $this->db->get_compiled_select($this->dbTable); + + $tmpTable .= "UNION + SELECT " . + $this->escape($status_kurzbz) . " AS status_kurzbz, " . + $this->escape($new_studiensemester_kurzbz) . " AS studiensemester_kurzbz, " . + $this->escape($new_ausbildungssemester) . " AS ausbildungssemester, " . + $this->escape($new_date) . "::date AS datum," . + $this->escape(date('c')) . "::date AS insertamum," . + "NULL AS ext_id"; + + $this->addJoin('public.tbl_studiensemester sem', 'studiensemester_kurzbz'); + + $this->addOrder('s.datum', 'DESC'); + $this->addOrder('s.insertamum', 'DESC'); + $this->addOrder('s.ext_id', 'DESC'); + + $dbTable = $this->dbTable; + $this->dbTable = "(" . $tmpTable . ") s"; + + $result = $this->load(); + + $this->dbTable = $dbTable; + + return $result; + } + + /** + * For checks if Orgform of Student status and Bewerber status match. + * Returns any Bewerber status that does not match the first Student + * status' Orgform. + * + * @param integer $prestudent_id + * + * @return stdClass + */ + public function getBewerberWhereOrgformNotStudent($prestudent_id) + { + $this->addSelect('plan.orgform_kurzbz'); + + $this->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT'); + + $this->addOrder('tbl_prestudentstatus.datum', 'DESC'); + $this->addOrder('tbl_prestudentstatus.insertamum', 'DESC'); + $this->addOrder('tbl_prestudentstatus.ext_id', 'DESC'); + + $this->addLimit(1); + + $this->db->where('prestudent_id', $prestudent_id); + $this->db->where('status_kurzbz', self::STATUS_STUDENT); + + $sql = $this->db->get_compiled_select($this->dbTable); + + $this->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT'); + + $this->db->where('plan.orgform_kurzbz !=', '(' . $sql . ')', false); + return $this->loadWhere([ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => self::STATUS_BEWERBER + ]); + } } diff --git a/application/models/crm/Status_model.php b/application/models/crm/Status_model.php index 7b1b38ecb..1ee2a5199 100644 --- a/application/models/crm/Status_model.php +++ b/application/models/crm/Status_model.php @@ -11,4 +11,21 @@ class Status_model extends DB_Model $this->dbTable = 'public.tbl_status'; $this->pk = 'status_kurzbz'; } + + public function getAllStatiWithStatusgruende() + { + $lang = '[(SELECT index FROM public.tbl_sprache WHERE sprache=' . $this->escape(getUserLanguage()) . ' LIMIT 1)]'; + + $this->addSelect('sg.status_kurzbz'); + + $this->addSelect('statusgrund_id'); + $this->addSelect('sg.bezeichnung_mehrsprachig' . $lang . ' AS bezeichnung'); + $this->addSelect('sg.beschreibung' . $lang . ' AS beschreibung'); + + $this->addJoin('public.tbl_status_grund sg', 'ON (sg.status_kurzbz = public.tbl_status.status_kurzbz)', 'LEFT'); + + return $this->loadWhere([ + 'aktiv'=> true, + ]); + } } diff --git a/application/models/crm/Statusgrund_model.php b/application/models/crm/Statusgrund_model.php index d488e12d1..8fc2a3a62 100644 --- a/application/models/crm/Statusgrund_model.php +++ b/application/models/crm/Statusgrund_model.php @@ -27,4 +27,19 @@ class Statusgrund_model extends DB_Model return success($status->retval); } + + public function getAktiveGruende() + { + $lang = '[(SELECT index FROM public.tbl_sprache WHERE sprache=' . $this->escape(getUserLanguage()) . ' LIMIT 1)]'; + + $this->addSelect('tbl_status_grund.*'); + $this->addSelect('bezeichnung_mehrsprachig' . $lang . ' AS bezeichnung'); + $this->addSelect('beschreibung' . $lang . ' AS beschreibung'); + + $this->addOrder('bezeichnung_mehrsprachig' . $lang); + + return $this->loadWhere([ + 'aktiv' => true + ]); + } } diff --git a/application/models/crm/Student_model.php b/application/models/crm/Student_model.php index 4b0a70b1a..bd7ab41b6 100644 --- a/application/models/crm/Student_model.php +++ b/application/models/crm/Student_model.php @@ -1,4 +1,8 @@ = 90010 && $studiengang_kz <= 90019) + { + $matrikelnummer = sprintf("%02d", $jahr).$art.substr($studiengang_kz, 0, 4); + } + else + { + $matrikelnummer = sprintf("%02d", $jahr).$art.sprintf("%04d", $studiengang_kz); + } + + $qry = "SELECT matrikelnr FROM public.tbl_student WHERE matrikelnr LIKE ? ORDER BY matrikelnr DESC LIMIT 1"; + $matrikelnrres = $this->execQuery($qry, array($matrikelnummer.'%')); + + $max = 0; + if ($matrikelnrres && hasData($matrikelnrres)) { + $max = mb_substr($matrikelnrres->retval[0]->matrikelnr, 7); + if (!is_numeric($max)) { + $max = (int)$max; + } + } + + $max += 1; + return success($matrikelnummer.sprintf("%03d", $max)); + } + + /** + * Generiert die UID + * FORMAT: el07b001 + * $stgkzl: el = studiengangskuerzel + * $jahr: 07 = Jahr + * $stgtyp: b/m/d/x = Bachelor/Master/Diplom/Incoming + * $matrikelnummer + * 001 = Laufende Nummer Wenn StSem==SS dann wird zur Nummer 500 dazugezaehlt + * Bei Incoming im Masterstudiengang wird auch 500 dazugezaehlt + * + * @param string $stgkzl + * @param string $jahr + * @param string $stgtyp + * @param string $matrikelnummer + * @param string $vorname + * @param string $nachname + * + * @return stdClass + */ + public function generateUID($stgkzl, $jahr, $stgtyp, $matrikelnummer, $vorname, $nachname) + { + $uid = false; + + Events::trigger( + 'generate_student_uid', + function ($value) use ($uid) { + $uid = $value; + }, + $stgkzl, + $jahr, + $stgtyp, + $matrikelnummer, + $vorname, + $nachname + ); + + if ($uid !== false) + return success($uid); + + $art = mb_substr($matrikelnummer, 2, 1); + $nr = mb_substr($matrikelnummer, mb_strlen(trim($matrikelnummer))-3); + if($art=='2') //Sommersemester + $nr = $nr+500; + elseif($art=='0' && $stgtyp=='m') //Incoming im Masterstudiengang + $nr = $nr+500; + elseif($art=='4' && $stgtyp=='l') // Lehrgangsteilnehmer im Sommersemester + $nr = $nr+500; + + + return success(mb_strtolower($stgkzl.$jahr.($art!='0'?$stgtyp:'x').$nr)); + } + + /** * Get students UID by PrestudentID. * @param $prestudent_id @@ -78,7 +242,8 @@ class Student_model extends DB_Model OR lower(person.nachname) like ".$this->db->escape('%'.$filter.'%')." OR lower(person.vorname) like ".$this->db->escape('%'.$filter.'%')." OR lower(person.nachname || ' ' || person.vorname) like ".$this->db->escape('%'.$filter.'%')." - OR lower(person.vorname || ' ' || person.nachname) like ".$this->db->escape('%'.$filter.'%')); + OR lower(person.vorname || ' ' || person.nachname) like ".$this->db->escape('%'.$filter.'%') + ); return $result; } diff --git a/application/models/education/Gsstudientyp_model.php b/application/models/education/Gsstudientyp_model.php new file mode 100644 index 000000000..ca9106d99 --- /dev/null +++ b/application/models/education/Gsstudientyp_model.php @@ -0,0 +1,14 @@ +dbTable = 'bis.tbl_gsstudientyp'; + $this->pk = 'gsstudientyp_kurzbz'; + } +} \ No newline at end of file diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index 1f1b90131..cefd147b9 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -493,4 +493,11 @@ class Lehrveranstaltung_model extends DB_Model return $this->execQuery($qry, array($student_uid)); } + + public function getStg($lehrveranstaltung_id) + { + $this->addSelect('stg.*'); + $this->addJoin('public.tbl_studiengang stg', 'studiengang_kz'); + return $this->load($lehrveranstaltung_id); + } } diff --git a/application/models/education/Paabgabe_model.php b/application/models/education/Paabgabe_model.php index b876030a6..5fb58cc81 100644 --- a/application/models/education/Paabgabe_model.php +++ b/application/models/education/Paabgabe_model.php @@ -25,7 +25,7 @@ class Paabgabe_model extends DB_Model WHERE projektarbeit_id = ? AND paabgabetyp_kurzbz = 'end' AND paabg.abgabedatum IS NOT NULL - ORDER BY paabg.abgabedatum, paabg.datum DESC + ORDER BY paabg.abgabedatum DESC, paabg.datum DESC LIMIT 1"; return $this->execQuery($qry, array($projektarbeit_id)); diff --git a/application/models/education/Studentlehrverband_model.php b/application/models/education/Studentlehrverband_model.php index 765429396..2ef14e58e 100644 --- a/application/models/education/Studentlehrverband_model.php +++ b/application/models/education/Studentlehrverband_model.php @@ -11,5 +11,7 @@ class Studentlehrverband_model extends DB_Model $this->dbTable = 'public.tbl_studentlehrverband'; $this->pk = array('studiensemester_kurzbz', 'student_uid'); $this->hasSequence = false; + + $this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel'); } } diff --git a/application/models/organisation/Geschaeftsjahr_model.php b/application/models/organisation/Geschaeftsjahr_model.php index 4f0d03b73..fdd774a8c 100644 --- a/application/models/organisation/Geschaeftsjahr_model.php +++ b/application/models/organisation/Geschaeftsjahr_model.php @@ -32,11 +32,20 @@ class Geschaeftsjahr_model extends DB_Model * Gets next Geschaeftsjahr, as determined by its start date * @return array|null */ - public function getNextGeschaeftsjahr() + public function getNextGeschaeftsjahr($offsetDays=null) { $query = 'SELECT * - FROM public.tbl_geschaeftsjahr - WHERE start > now() + FROM public.tbl_geschaeftsjahr WHERE '; + + if(!is_null($offsetDays)) + { + $query .= "start > now() - '".$offsetDays." days'::interval"; + } + else + { + $query .= 'start > now()'; + } + $query .= ' ORDER BY start LIMIT 1'; diff --git a/application/models/organisation/Lehrverband_model.php b/application/models/organisation/Lehrverband_model.php index 953e4b7b2..0e760a116 100644 --- a/application/models/organisation/Lehrverband_model.php +++ b/application/models/organisation/Lehrverband_model.php @@ -11,4 +11,34 @@ class Lehrverband_model extends DB_Model $this->dbTable = 'public.tbl_lehrverband'; $this->pk = array('gruppe', 'verband', 'semester', 'studiengang_kz'); } + + /** + * Gets the maximum possible semester for one or more Studiengaenge. + * If there are more than one Studiengang each maximum is calculated and + * the smallest result is returned. + * + * @param array $studiengang_kzs + * + * @return stdClass + */ + public function getMaxSemester($studiengang_kzs) + { + $sqls = []; + foreach ($studiengang_kzs as $studiengang_kz) { + $this->addSelect('MAX(semester) AS maxsem'); + $this->db->where('studiengang_kz', $studiengang_kz); + $sqls[] = $this->db->get_compiled_select($this->dbTable); + } + + $this->addSelect('MIN(a.maxsem) AS maxsem'); + + $dbTable = $this->dbTable; + $this->dbTable = '(' . implode(' UNION ', $sqls) . ') AS a'; + + $result = $this->load(); + + $this->dbTable = $dbTable; + + return $result; + } } diff --git a/application/models/organisation/Standort_model.php b/application/models/organisation/Standort_model.php index 382236e2f..aeeab4497 100644 --- a/application/models/organisation/Standort_model.php +++ b/application/models/organisation/Standort_model.php @@ -11,4 +11,29 @@ class Standort_model extends DB_Model $this->dbTable = 'public.tbl_standort'; $this->pk = 'standort_id'; } + + public function searchStandorte($filter) + { + $filter = strtoLower($filter); + $qry = " + SELECT + s.kurzbz, s.standort_id + FROM + public.tbl_standort s + WHERE + lower (s.kurzbz) LIKE '%". $this->db->escape_like_str($filter)."%' + OR + lower (s.bezeichnung) LIKE '%". $this->db->escape_like_str($filter)."%'"; + + + return $this->execQuery($qry); + } + + public function getStandorteByFirma($firma_id) + { + $this->addSelect("DISTINCT ON (standort_id) bezeichnung, standort_id"); + + return $this->loadWhere(array("firma_id" => $firma_id)); + } } + diff --git a/application/models/organisation/Studienplan_model.php b/application/models/organisation/Studienplan_model.php index 8422f4607..e35ba52fb 100644 --- a/application/models/organisation/Studienplan_model.php +++ b/application/models/organisation/Studienplan_model.php @@ -106,4 +106,32 @@ class Studienplan_model extends DB_Model 'tbl_studienplan_lehrveranstaltung.semester' => $semester )); } + + public function getAllOesForLv($lehrveranstaltung_id) + { + $this->addDistinct('oe_kurzbz'); + + $this->addJoin('lehre.tbl_studienplan_lehrveranstaltung lv', 'studienplan_id'); + $this->addJoin('lehre.tbl_studienordnung', 'studienordnung_id'); + $this->addJoin('public.tbl_studiengang', 'studiengang_kz'); + + return $this->loadWhere([ + 'lv.lehrveranstaltung_id' => $lehrveranstaltung_id + ]); + } + + public function getStudienplaeneByPrestudents($prestudent_id) + { + $this->addDistinct(); + $this->addSelect($this->dbTable . '.*'); + $this->addSelect('sem.start AS start_stsem'); + $this->addJoin('lehre.tbl_studienordnung o', 'studienordnung_id'); + $this->addJoin('public.tbl_prestudent p', 'studiengang_kz'); + $this->addJoin('public.tbl_studiensemester sem', 'sem.studiensemester_kurzbz = o.gueltigvon', 'LEFT'); + $this->addOrder('sem.start'); + + return $this->loadWhere([ + 'prestudent_id' => $prestudent_id + ]); + } } diff --git a/application/models/organisation/Studiensemester_model.php b/application/models/organisation/Studiensemester_model.php index 45a4eac7c..c59c9d343 100644 --- a/application/models/organisation/Studiensemester_model.php +++ b/application/models/organisation/Studiensemester_model.php @@ -13,35 +13,35 @@ class Studiensemester_model extends DB_Model $this->hasSequence = false; } - /** - * Get actual Studiensemester. - * - * @return array - */ - public function getAkt() - { - return $this->loadWhere(array( - 'start <= ' => 'NOW()', - 'ende >= ' => 'NOW()' - ) - ); - } + /** + * Get actual Studiensemester. + * + * @return array + */ + public function getAkt() + { + return $this->loadWhere(array( + 'start <= ' => 'NOW()', + 'ende >= ' => 'NOW()' + ) + ); + } // Get next study semester public function getNext() - { - $query = ' - SELECT * - FROM - public.tbl_studiensemester - WHERE - start > now() - ORDER BY start - LIMIT 1; - '; + { + $query = ' + SELECT * + FROM + public.tbl_studiensemester + WHERE + start > now() + ORDER BY start + LIMIT 1; + '; - return $this->execQuery($query); - } + return $this->execQuery($query); + } /** * getLastOrAktSemester @@ -182,10 +182,10 @@ class Studiensemester_model extends DB_Model return success(array()); $query = " - SELECT * - FROM public.tbl_studiensemester - WHERE ( ?::date < ende AND ?::date > start ) - ORDER BY start DESC"; + SELECT * + FROM public.tbl_studiensemester + WHERE ( ?::date < ende AND ?::date > start ) + ORDER BY start DESC"; return $this->execQuery($query, array($from, $to)); } @@ -200,7 +200,7 @@ class Studiensemester_model extends DB_Model { $query = "SELECT studiensemester_kurzbz, start, ende FROM public.vw_studiensemester WHERE studiensemester_kurzbz <> ? - ORDER BY delta, start LIMIT 1"; + ORDER BY delta, start LIMIT 1"; return $this->execQuery($query, array($studiensemester_kurzbz)); } @@ -211,7 +211,46 @@ class Studiensemester_model extends DB_Model FROM public.tbl_studiensemester WHERE start >= NOW() OR (start <= NOW() AND ende >= NOW()) ORDER BY start'; - + return $this->execQuery($query); } + + /** + * Liefert ausgehend von heutigen Datum $plus studiensemester in die Zukunft und $minus Studiensemester in die Vergangenheit + * + * @param integer $plus Optional. Wieviele Studiensemester in die Zukunft sollen ausgegeben werden. Wenn NULL werden alle zukuenftigen geliefert. + * @param integer $minus Optional. Wieviele Studiensemester in die Vergangenheit sollen ausgegeben werden. Wenn NULL werden alle vergangenen geliefert. + * + * @return stdClass + */ + public function addPlusMinus($plus = null, $minus = null) + { + $this->addSelect($this->pk); + $this->addOrder('ende'); + if ($plus) + $this->addLimit($plus); + $this->db->where('start >= NOW()', null, false); + $plus = $this->db->get_compiled_select($this->dbTable); + + $this->addSelect($this->pk); + $this->addOrder('start', 'DESC'); + if ($minus) + $this->addLimit($minus); + $this->db->where('start <= NOW()', null, false); + $minus = $this->db->get_compiled_select($this->dbTable); + + $this->db->where_in($this->pk, '(' . $plus . ') UNION (' . $minus . ')', false); + } + + /** + * Holt letzen zwei Ziffern des Studienjahres von Studiensemester, z.B. 24 für WS2024 und SS2025 + * @param studiensemester_kurzbz + * @return string Studienjahr Nummer + */ + public function getStudienjahrNumberFromStudiensemester($studiensemester_kurzbz) + { + $studienjahrNumber = mb_substr($studiensemester_kurzbz, 4, 2); + if (is_numeric($studienjahrNumber) && mb_substr($studiensemester_kurzbz, 0, 2) == 'SS') (int)$studienjahrNumber -= 1; + return $studienjahrNumber; + } } diff --git a/application/models/person/Adresse_model.php b/application/models/person/Adresse_model.php index fb5112a8d..4dd03ea6b 100644 --- a/application/models/person/Adresse_model.php +++ b/application/models/person/Adresse_model.php @@ -24,4 +24,4 @@ class Adresse_model extends DB_Model $this->addSelect($select); return $this->loadWhere(array('person_id' => $person_id, 'zustelladresse'=> true)); } -} +} \ No newline at end of file diff --git a/application/models/person/Benutzer_model.php b/application/models/person/Benutzer_model.php index eff1329a6..65121dbb5 100644 --- a/application/models/person/Benutzer_model.php +++ b/application/models/person/Benutzer_model.php @@ -1,4 +1,7 @@ addLimit(1); $this->addSelect('vorname, nachname'); $this->addJoin('public.tbl_person', 'person_id'); $nameresult = $this->loadWhere(array('uid' => $uid)); - if (hasData($nameresult)) - { - $aliasdata = getData($nameresult); - $alias = $this->_sanitizeAliasName($aliasdata[0]->vorname).'.'.$this->_sanitizeAliasName($aliasdata[0]->nachname); - $aliasexists = $this->aliasExists($alias); + if (isError($nameresult)) + return $nameresult; - if (hasData($aliasexists) && !getData($aliasexists)[0]) - $aliasres = $alias; - } - return success($aliasres); + if (!hasData($nameresult)) + return success(''); + + $aliasdata = current(getData($nameresult)); + + return $this->generateAliasFromName($aliasdata->vorname, $aliasdata->nachname); + } + + /** + * Generates alias for a vor- and nachname. + * + * @param string $vorname + * @param string $nachname + * + * @return stdClass + */ + public function generateAliasFromName($vorname, $nachname) + { + $alias = $this->_sanitizeAliasName($vorname . '.' . $nachname); + + $result = $this->aliasExists($alias); + + if (isError($result)) + return $result; + + if (current(getData($result))) + return success(''); + + return success($alias); + } + + /** + * Generates a matrikelnummer + * + * @param string $oe_kurzbz + * + * @return stdClass + */ + public function generateMatrikelnummer($oe_kurzbz) + { + $matrikelnummer = false; + + Events::trigger( + 'generate_matrikelnummer', + function ($value) use ($matrikelnummer) { + $matrikelnummer = $value; + }, + $oe_kurzbz + ); + + if ($matrikelnummer !== false) + return success($matrikelnummer); + + return success(null); + } + + /** + * Generates an activation key + * + * @return string + */ + public function generateActivationkey() + { + $this->load->library('CryptLib'); + + $key = ''; + for ($i=0; $i<32; $i++) + $key .= ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'][mt_rand(0, 15)]; + + $value = uniqid(mt_rand(), true); + $length = strlen($value); + $value = str_pad($value, $length + 32 - ($length % 32), chr(0)); + + return md5($this->cryptlib->RIJNDAEL_256_ECB($value, $key, true)); } // -------------------------------------------------------------------------------------------- @@ -100,9 +169,10 @@ class Benutzer_model extends DB_Model * @param string $str * @return string */ + private function _sanitizeAliasName($str) { $str = sanitizeProblemChars($str); - return mb_strtolower(str_replace(' ','_', $str)); + return mb_strtolower(str_replace(' ', '_', $str)); } } diff --git a/application/models/person/Notiz_model.php b/application/models/person/Notiz_model.php index bfd8aa258..349eaac60 100644 --- a/application/models/person/Notiz_model.php +++ b/application/models/person/Notiz_model.php @@ -139,12 +139,51 @@ class Notiz_model extends DB_Model */ public function getNotiz($person_id) { - // Join with the table public.tbl_notizzuordnung using notiz_id + $this->addSelect('public.tbl_notiz.*'); $this->addJoin('public.tbl_notizzuordnung', 'notiz_id'); return $this->loadWhere(array('person_id' => $person_id)); } + /** + * gets all Notizen with Documententries for a certain type and type_id + * @param String type of id eg. person_id, prestudent_id, mitarbeiter_uid, projekt_kurzbz, projektphase_id, projekttask_id, + * bestellung_id, lehreinheit_id, anrechnung_id, uid) + * @param $id the corresponding id, part of public.tbl_notizzuordnung + */ + public function getNotizWithDocEntries($id, $type) + { + $qry = " + SELECT + n.*, count(dms_id) as countDoc, z.notizzuordnung_id, + TO_CHAR (CASE + WHEN n.updateamum >= n.insertamum THEN n.updateamum + ELSE n.insertamum + END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate, + regexp_replace(n.text, '<[^>]*>', '', 'g') as text_stripped, + TO_CHAR(n.start::timestamp, 'DD.MM.YYYY') AS start_format, + TO_CHAR(n.ende::timestamp, 'DD.MM.YYYY') AS ende_format, + z.notiz_id, z.person_id as id, ? as type_id + + FROM + public.tbl_notiz n + JOIN + public.tbl_notizzuordnung z USING (notiz_id) + LEFT JOIN + public.tbl_notiz_dokument dok USING (notiz_id) + LEFT JOIN + campus.tbl_dms_version USING (dms_id) + WHERE + z.$type = ? + GROUP BY + notiz_id, z.notizzuordnung_id + "; + + return $this->execQuery($qry, array($type, $id)); + + } + + /** * gets all Notizen for a person with a specific title * @param $person_id @@ -231,6 +270,4 @@ class Notiz_model extends DB_Model return $this->loadWhere(array('anrechnung_id' => $anrechnung_id)); } - // ------------------------------------------------------------------------------------------------------ - } diff --git a/application/models/person/Notizdokument_model.php b/application/models/person/Notizdokument_model.php new file mode 100644 index 000000000..6b141307f --- /dev/null +++ b/application/models/person/Notizdokument_model.php @@ -0,0 +1,14 @@ +dbTable = 'public.tbl_notiz_dokument'; + $this->pk= array('notiz_id' , 'dms_id'); + } +} \ No newline at end of file diff --git a/application/models/person/Notizzuordnung_model.php b/application/models/person/Notizzuordnung_model.php index 187a8399b..b94ff3fb6 100644 --- a/application/models/person/Notizzuordnung_model.php +++ b/application/models/person/Notizzuordnung_model.php @@ -11,4 +11,38 @@ class Notizzuordnung_model extends DB_Model $this->dbTable = 'public.tbl_notizzuordnung'; $this->pk = 'notizzuordnung_id'; } + + public function isValidType($type) + { + $validTypes = []; + + $qry = " + SELECT column_name + FROM information_schema.columns + WHERE table_schema = 'public' + AND table_name = 'tbl_notizzuordnung' + AND column_name not in ('notizzuordnung_id', 'notiz_id') + "; + + $type_arr = $this->execQuery($qry); + $type_arr = $type_arr->retval; + + foreach ($type_arr as $t) + { + $validTypes[] = $t->column_name; + } + + //TODO(manu) param id + if (in_array($type, $validTypes) ) + //if (in_array($type, $validTypes) ||($type == 'software_id')) //Just for testing + { + return success("Type " . $type . " is valid"); + // $result = success('Type of Id is valid'); + } + else + { + return error("Type " . $type . " is NOT valid"); + } + //return $result; + } } diff --git a/application/models/ressource/Betriebsmittel_model.php b/application/models/ressource/Betriebsmittel_model.php index 849a9199f..290c3491d 100644 --- a/application/models/ressource/Betriebsmittel_model.php +++ b/application/models/ressource/Betriebsmittel_model.php @@ -11,4 +11,24 @@ class Betriebsmittel_model extends DB_Model $this->dbTable = 'wawi.tbl_betriebsmittel'; $this->pk = 'betriebsmittel_id'; } + + /** + * load Liste Inventarnummern + */ + public function loadInventarliste($filter) + { + $filter = urldecode(strtoLower($filter)); + + $qry = " + SELECT + bm.inventarnummer, bm.betriebsmitteltyp, bm.betriebsmittel_id, CONCAT(bm.inventarnummer, ' ', bm.beschreibung) as dropdowntext + FROM + wawi.tbl_betriebsmittel bm + WHERE + upper(bm.inventarnummer) LIKE '%" .$this->db->escape_like_str($filter)."%' + OR + lower(bm.inventarnummer) LIKE '%" .$this->db->escape_like_str($filter)."%'"; + + return $this->execQuery($qry); + } } diff --git a/application/models/ressource/Betriebsmittelperson_model.php b/application/models/ressource/Betriebsmittelperson_model.php index 04878a9ad..39f08b5cd 100644 --- a/application/models/ressource/Betriebsmittelperson_model.php +++ b/application/models/ressource/Betriebsmittelperson_model.php @@ -96,4 +96,49 @@ class Betriebsmittelperson_model extends DB_Model return $this->loadWhere($condition); } + + public function getBetriebsmittelData($id, $type_id) + { + switch ($type_id) { + case 'person_id': + $cond = 'bmp.person_id'; + break; + case 'uid': + $cond = 'bmp.uid'; + break; + case 'betriebsmittelperson_id': + $cond = 'bmp.betriebsmittelperson_id'; + break; + default: + return error("ID nicht gültig"); + } + + $query = " + SELECT + bm.nummer, bmp.person_id, bm.betriebsmitteltyp, bmp.anmerkung as anmerkung, bmp.retouram, TO_CHAR(bmp.retouram::timestamp, 'DD.MM.YYYY') AS format_retour, bmp.ausgegebenam, TO_CHAR(bmp.ausgegebenam::timestamp, 'DD.MM.YYYY') AS format_ausgabe, bm.beschreibung, bmp.uid, bmp.kaution, bm.betriebsmittel_id, bmp.betriebsmittelperson_id, bm.inventarnummer, bm.nummer2 + FROM + wawi.tbl_betriebsmittelperson bmp + JOIN + wawi.tbl_betriebsmittel bm ON (bmp.betriebsmittel_id = bm.betriebsmittel_id) + WHERE + " . $cond . " = ? "; + + return $this->execQuery($query, array($id)); + } + + /** + * Perform a loadWhere on the vw_betriebsmittelperson DB View + * + * @param array $where + * + * @return stdClass + */ + public function loadViewWhere($where) + { + $table = $this->dbTable; + $this->dbTable = 'public.vw_betriebsmittelperson'; + $result = $this->loadWhere($where); + $this->dbTable = $table; + return $result; + } } diff --git a/application/models/ressource/Firma_model.php b/application/models/ressource/Firma_model.php index 1b8dfb51d..431f0815f 100644 --- a/application/models/ressource/Firma_model.php +++ b/application/models/ressource/Firma_model.php @@ -11,4 +11,18 @@ class Firma_model extends DB_Model $this->dbTable = 'public.tbl_firma'; $this->pk = 'firma_id'; } + + public function searchFirmen($filter) + { + $filter = strtoLower($filter); + $qry = " + SELECT + f.name, f.firma_id + FROM + public.tbl_firma f + WHERE + lower (f.name) LIKE '%". $this->db->escape_like_str($filter)."%'"; + + return $this->execQuery($qry); + } } diff --git a/application/models/ressource/Mitarbeiter_model.php b/application/models/ressource/Mitarbeiter_model.php index 900b88684..c38fcf054 100644 --- a/application/models/ressource/Mitarbeiter_model.php +++ b/application/models/ressource/Mitarbeiter_model.php @@ -216,4 +216,26 @@ class Mitarbeiter_model extends DB_Model return success($kurzbz); } + + public function searchMitarbeiter($filter) + { + $filter = strtoLower($filter); + $qry = " + SELECT + ma.mitarbeiter_uid, CONCAT(p.nachname, ' ', p.vorname, ' (', ma.mitarbeiter_uid , ')') as mitarbeiter + FROM + public.tbl_mitarbeiter ma + JOIN + public.tbl_benutzer b on (ma.mitarbeiter_uid = b.uid) + JOIN + public.tbl_person p on (p.person_id = b.person_id) + WHERE + lower (p.nachname) LIKE '%". $this->db->escape_like_str($filter)."%' + OR + lower (p.vorname) LIKE '%". $this->db->escape_like_str($filter)."%' + OR + (ma.mitarbeiter_uid) LIKE '%". $this->db->escape_like_str($filter)."%'"; + + return $this->execQuery($qry); + } } diff --git a/application/models/system/Issue_model.php b/application/models/system/Issue_model.php index ab1f9ba6e..331b0f050 100644 --- a/application/models/system/Issue_model.php +++ b/application/models/system/Issue_model.php @@ -22,13 +22,23 @@ class Issue_model extends DB_Model */ public function getOpenIssues($fehlercodes, $person_id = null, $oe_kurzbz = null, $fehlercode_extern = null) { - $params = array($fehlercodes); + $params = array(); // issue exists for a fehlercode (or fehlercode_extern), person_id, oe_kurzbz, if not verarbeitet yet - $qry = 'SELECT issue_id, fehlercode, inhalt, fehlercode_extern, inhalt_extern, person_id, oe_kurzbz, - behebung_parameter, datum, verarbeitetvon, verarbeitetamum - FROM system.tbl_issue - WHERE fehlercode IN ? - AND verarbeitetamum IS NULL'; + $qry = 'SELECT + iss.issue_id, iss.fehlercode, fe.fehler_kurzbz, iss.inhalt, iss.fehlercode_extern, + iss.inhalt_extern, iss.person_id, iss.oe_kurzbz, iss.behebung_parameter, + iss.datum, iss.verarbeitetvon, iss.verarbeitetamum + FROM + system.tbl_issue iss + JOIN system.tbl_fehler fe USING (fehlercode) + WHERE + verarbeitetamum IS NULL'; + + if (!isEmptyArray($fehlercodes)) + { + $qry .= ' AND fehlercode IN ?'; + $params[] = $fehlercodes; + } if (!isEmptyString($fehlercode_extern)) { @@ -59,7 +69,7 @@ class Issue_model extends DB_Model * @param string $fehlercode_extern if provided, only issues with this external fehlercode are counted (for identifying issues from external systems). * @return Object success with number of issues or error */ - public function getOpenIssueCount($fehlercode, $person_id = null, $oe_kurzbz = null, $fehlercode_extern = null) + public function getOpenIssueCount($fehlercode, $person_id = null, $oe_kurzbz = null, $fehlercode_extern = null, $behebung_parameter = null) { $params = array($fehlercode); // issue exists for a fehlercode (or fehlercode_extern), person_id, oe_kurzbz, if not verarbeitet yet @@ -85,6 +95,19 @@ class Issue_model extends DB_Model $params[] = $oe_kurzbz; } + if (isset($behebung_parameter) && !isEmptyArray($behebung_parameter)) + { + // convert array to JSON string for postgres + $behebung_parameter_string = json_encode($behebung_parameter); + + if ($behebung_parameter_string) + { + // check if jsonb value is equal to the passed parameters array (if value contains array and array contains value) + $qry .= ' AND behebung_parameter @> ? AND behebung_parameter <@ ?'; + $params = array_merge($params, array($behebung_parameter_string, $behebung_parameter_string)); + } + } + return $this->execQuery($qry, $params); } } diff --git a/application/models/vertragsbestandteil/GehaltsTyp_model.php b/application/models/vertragsbestandteil/GehaltsTyp_model.php new file mode 100644 index 000000000..c933a3b38 --- /dev/null +++ b/application/models/vertragsbestandteil/GehaltsTyp_model.php @@ -0,0 +1,28 @@ +dbTable = 'hr.tbl_gehaltstyp'; + $this->pk = 'gehaltstyp_kurzbz'; + } + + /** + * Gets Gehaltstyp for a Gehaltsbestandteil. + * @param int gehaltsbestandteil_id + * @return object the typ + */ + public function getGehaltstypByGehaltsbestandteil($gehaltsbestandteil_id) + { + $gehaltsTyp = null; + $this->addJoin('hr.tbl_gehaltsbestandteil', 'gehaltstyp_kurzbz'); + $result = $this->loadWhere(['gehaltsbestandteil_id' => $gehaltsbestandteil_id]); + + if (hasData($result)) $gehaltsTyp = getData($result)[0]; + + return $gehaltsTyp; + } +} diff --git a/application/views/Studentenverwaltung.php b/application/views/Studentenverwaltung.php new file mode 100644 index 000000000..2d0d22346 --- /dev/null +++ b/application/views/Studentenverwaltung.php @@ -0,0 +1,55 @@ + 'Studentenverwaltung', + 'axios027' => true, + 'bootstrap5' => true, + 'fontawesome6' => true, + 'vue3' => true, + 'primevue3' => true, + #'filtercomponent' => true, + 'tabulator5' => true, + 'tinymce5' => true, + 'phrases' => array( + 'global', + 'ui', + 'notiz', + ), + 'customCSSs' => [ + 'public/css/components/vue-datepicker.css', + 'public/css/components/primevue.css', + 'public/css/Studentenverwaltung.css' + ], + 'customJSs' => [ + #'vendor/npm-asset/primevue/tree/tree.min.js', + #'vendor/npm-asset/primevue/toast/toast.min.js' + ], + 'customJSModules' => [ + 'public/js/apps/Studentenverwaltung.js' + ] + ); + + $this->load->view('templates/FHC-Header', $includesArray); +?> + + !defined('GENERATE_ALIAS_STUDENT') ? true : GENERATE_ALIAS_STUDENT, + 'showZgvDoktor' => !defined('ZGV_DOKTOR_ANZEIGEN') ? false : ZGV_DOKTOR_ANZEIGEN, + 'showZgvErfuellt' => !defined('ZGV_ERFUELLT_ANZEIGEN') ? false : ZGV_ERFUELLT_ANZEIGEN +]; +?> + +
+ + +
+ +load->view('templates/FHC-Footer', $includesArray); ?> + diff --git a/application/views/codex/uhstat1.php b/application/views/codex/uhstat1.php index 78a30b3e5..a255781f1 100644 --- a/application/views/codex/uhstat1.php +++ b/application/views/codex/uhstat1.php @@ -74,16 +74,23 @@ $saved = isset($saved) && $saved === true;
- +
+ + + + +
@@ -94,16 +101,23 @@ $saved = isset($saved) && $saved === true; p->t('uhstat', 'inDenHeutigenGrenzen')).')' ?>
- +
+ + + + +
@@ -114,16 +128,23 @@ $saved = isset($saved) && $saved === true; p->t('uhstat', 'inDenHeutigenGrenzen')).')' ?>
- +
+ + + + +
@@ -161,16 +182,23 @@ $saved = isset($saved) && $saved === true;
- > + + $jahr): ?> + - - + + + + + +
@@ -181,16 +209,23 @@ $saved = isset($saved) && $saved === true; p->t('uhstat', 'inDenHeutigenGrenzen')).')' ?>
- +
+ + + + +
@@ -201,16 +236,23 @@ $saved = isset($saved) && $saved === true; p->t('uhstat', 'inDenHeutigenGrenzen')).')' ?>
- +
+ + + + +
@@ -271,7 +313,7 @@ $saved = isset($saved) && $saved === true; - - + + load->view('templates/FHC-Footer'); ?> diff --git a/application/views/lehre/Antrag/Student/List.php b/application/views/lehre/Antrag/Student/List.php index 614af5d79..4a4b4f064 100644 --- a/application/views/lehre/Antrag/Student/List.php +++ b/application/views/lehre/Antrag/Student/List.php @@ -150,8 +150,6 @@ $this->load->view( break; case Studierendenantrag_model::TYP_ABMELDUNG_STGL: $allowed = [ - Studierendenantragstatus_model::STATUS_APPROVED, - Studierendenantragstatus_model::STATUS_OBJECTED, Studierendenantragstatus_model::STATUS_OBJECTION_DENIED, Studierendenantragstatus_model::STATUS_DEREGISTERED ]; diff --git a/application/views/lehre/anrechnung/approveAnrechnungDetail.php b/application/views/lehre/anrechnung/approveAnrechnungDetail.php index 0970b6edd..c96631781 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungDetail.php +++ b/application/views/lehre/anrechnung/approveAnrechnungDetail.php @@ -1,4 +1,5 @@ load->config('anrechnung'); $this->load->view( 'templates/FHC-Header', array( @@ -172,14 +173,16 @@ $this->load->view( p->t('global', 'begruendung'); ?> begruendung ?> - - p->t('anrechnung', 'begruendungEctsLabel'); ?> - begruendung_ects ?> - - - p->t('anrechnung', 'begruendungLvinhaltLabel'); ?> - begruendung_lvinhalt ?> - + config->item('explain_equivalence')): ?> + + p->t('anrechnung', 'begruendungEctsLabel'); ?> + begruendung_ects ?> + + + p->t('anrechnung', 'begruendungLvinhaltLabel'); ?> + begruendung_lvinhalt ?> + + diff --git a/application/views/lehre/anrechnung/requestAnrechnung.php b/application/views/lehre/anrechnung/requestAnrechnung.php index 18fd66a67..bb3c48235 100644 --- a/application/views/lehre/anrechnung/requestAnrechnung.php +++ b/application/views/lehre/anrechnung/requestAnrechnung.php @@ -4,6 +4,7 @@ const CHAR_LENGTH150 = 150; const CHAR_LENGTH500 = 500; const CHAR_LENGTH1000 = 1000; +$this->load->config('anrechnung'); $this->load->view( 'templates/FHC-Header', array( @@ -200,27 +201,29 @@ $this->load->view( - -
-
-
-
- p->t('anrechnung', 'begruendungEcts'); ?>  - - - -
-
- - p->t('ui', 'maxZeichen'); ?> : + + config->item('explain_equivalence')): ?> + +
+
+
+
+ p->t('anrechnung', 'begruendungEcts'); ?>  + + + +
+
+ + p->t('ui', 'maxZeichen'); ?> : +
-
- -
+ +
@@ -240,6 +243,8 @@ $this->load->view(
+ +
diff --git a/application/views/lehre/anrechnung/reviewAnrechnungDetail.php b/application/views/lehre/anrechnung/reviewAnrechnungDetail.php index 08d23d8c4..98fee67a3 100644 --- a/application/views/lehre/anrechnung/reviewAnrechnungDetail.php +++ b/application/views/lehre/anrechnung/reviewAnrechnungDetail.php @@ -1,4 +1,5 @@ load->config('anrechnung'); $this->load->view( 'templates/FHC-Header', array( @@ -143,14 +144,16 @@ $this->load->view( target="_blank">dokumentname) ?> - - p->t('anrechnung', 'begruendungEctsLabel'); ?> - begruendung_ects ?> - - - p->t('anrechnung', 'begruendungLvinhaltLabel'); ?> - begruendung_lvinhalt ?> - + config->item('explain_equivalence')): ?> + + p->t('anrechnung', 'begruendungEctsLabel'); ?> + begruendung_ects ?> + + + p->t('anrechnung', 'begruendungLvinhaltLabel'); ?> + begruendung_lvinhalt ?> + + diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index ed9fa97b9..cf0658cf0 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -41,6 +41,7 @@ { generateCSSsInclude('vendor/fortawesome/font-awesome6/css/fontawesome.min.css'); generateCSSsInclude('vendor/fortawesome/font-awesome6/css/solid.min.css'); + generateCSSsInclude('vendor/fortawesome/font-awesome6/css/regular.min.css'); // NOTE(chris): for favorites in stv generateCSSsInclude('vendor/fortawesome/font-awesome6/css/brands.min.css'); } diff --git a/cis/private/tools/zeitaufzeichnung.php b/cis/private/tools/zeitaufzeichnung.php index 7b1fb1fbb..0b463fe37 100644 --- a/cis/private/tools/zeitaufzeichnung.php +++ b/cis/private/tools/zeitaufzeichnung.php @@ -1014,9 +1014,9 @@ if ($projekt->getProjekteMitarbeiter($user, true)) } echo " Projektübersichtexport"; - if($anzprojekte > 0) - echo " | ".$p->t("zeitaufzeichnung/projektexport").""; - echo " + //if($anzprojekte > 0) + echo " | ".$p->t("zeitaufzeichnung/projektexport").""; + echo " "; if ($p->t("dms_link/handbuchZeitaufzeichnung")!='') { diff --git a/composer.json b/composer.json index 9e0c0fb7c..27ded15b6 100644 --- a/composer.json +++ b/composer.json @@ -442,7 +442,6 @@ "squizlabs/php_codesniffer": "3.6.*", "phpmd/phpmd": "2.*", "phpmetrics/phpmetrics": "2.*", - "sebastian/phpcpd": "3.*", - "phpunit/phpunit": "^6" + "irstea/phpcpd-shim": "6.*" } } diff --git a/composer.lock b/composer.lock index 6eb3e0383..75dfe4587 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "eedcd2abe226d372ff8d735498eb3b0a", + "content-hash": "596f52b8203fb2ac2976d266bc875459", "packages": [ { "name": "afarkas/html5shiv", @@ -902,30 +902,32 @@ }, { "name": "fzaninotto/faker", - "version": "v1.9.2", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/fzaninotto/Faker.git", - "reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e" + "reference": "d0190b156bcca848d401fb80f31f504f37141c8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/848d8125239d7dbf8ab25cb7f054f1a630e68c2e", - "reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/d0190b156bcca848d401fb80f31f504f37141c8d", + "reference": "d0190b156bcca848d401fb80f31f504f37141c8d", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": ">=5.3.3" }, "require-dev": { - "ext-intl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7", - "squizlabs/php_codesniffer": "^2.9.2" + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~1.5" + }, + "suggest": { + "ext-intl": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.5.x-dev" } }, "autoload": { @@ -950,10 +952,10 @@ ], "support": { "issues": "https://github.com/fzaninotto/Faker/issues", - "source": "https://github.com/fzaninotto/Faker/tree/v1.9.2" + "source": "https://github.com/fzaninotto/Faker/tree/master" }, "abandoned": true, - "time": "2020-12-11T09:56:16+00:00" + "time": "2015-05-29T06:29:14+00:00" }, { "name": "joeldbirch/superfish", @@ -1015,12 +1017,12 @@ "version": "1.3.7", "source": { "type": "git", - "url": "https://github.com/justinrainbow/json-schema.git", + "url": "https://github.com/jsonrainbow/json-schema.git", "reference": "87b54b460febed69726c781ab67462084e97a105" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/87b54b460febed69726c781ab67462084e97a105", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/87b54b460febed69726c781ab67462084e97a105", "reference": "87b54b460febed69726c781ab67462084e97a105", "shasum": "" }, @@ -1075,8 +1077,8 @@ "schema" ], "support": { - "issues": "https://github.com/justinrainbow/json-schema/issues", - "source": "https://github.com/justinrainbow/json-schema/tree/master" + "issues": "https://github.com/jsonrainbow/json-schema/issues", + "source": "https://github.com/jsonrainbow/json-schema/tree/1.3.7" }, "time": "2014-08-25T02:48:14+00:00" }, @@ -1116,6 +1118,7 @@ "issues": "https://github.com/kingsquare/json-schema-form/issues", "source": "https://github.com/kingsquare/json-schema-form/tree/master" }, + "abandoned": true, "time": "2014-07-10T12:27:19+00:00" }, { @@ -1297,16 +1300,16 @@ }, { "name": "mottie/tablesorter", - "version": "v2.31.3", + "version": "v2.32.0", "source": { "type": "git", "url": "https://github.com/Mottie/tablesorter.git", - "reference": "7202d5faf8105a5ecd1a2b7a653777618713ffe5" + "reference": "1423f5408982f58d5baa97648d2e5ee0b55fd3b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Mottie/tablesorter/zipball/7202d5faf8105a5ecd1a2b7a653777618713ffe5", - "reference": "7202d5faf8105a5ecd1a2b7a653777618713ffe5", + "url": "https://api.github.com/repos/Mottie/tablesorter/zipball/1423f5408982f58d5baa97648d2e5ee0b55fd3b6", + "reference": "1423f5408982f58d5baa97648d2e5ee0b55fd3b6", "shasum": "" }, "require": { @@ -1331,7 +1334,8 @@ }, { "name": "Rob Garrison", - "email": "wowmotty@gmail.com" + "email": "wowmotty@gmail.com", + "homepage": "https://github.com/Mottie" } ], "description": "tablesorter (FORK) is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.", @@ -1352,7 +1356,7 @@ "source": "https://github.com/Mottie/tablesorter", "wiki": "https://github.com/Mottie/tablesorter/wiki" }, - "time": "2020-03-03T13:46:03+00:00" + "time": "2024-08-14T01:23:57+00:00" }, { "name": "nategood/httpful", @@ -1520,16 +1524,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "2.0.46", + "version": "2.0.47", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "498e67a0c82bd5791fda9b0dd0f4ec8e8aebb02d" + "reference": "b7d7d90ee7df7f33a664b4aea32d50a305d35adb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/498e67a0c82bd5791fda9b0dd0f4ec8e8aebb02d", - "reference": "498e67a0c82bd5791fda9b0dd0f4ec8e8aebb02d", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/b7d7d90ee7df7f33a664b4aea32d50a305d35adb", + "reference": "b7d7d90ee7df7f33a664b4aea32d50a305d35adb", "shasum": "" }, "require": { @@ -1610,7 +1614,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/2.0.46" + "source": "https://github.com/phpseclib/phpseclib/tree/2.0.47" }, "funding": [ { @@ -1626,7 +1630,7 @@ "type": "tidelift" } ], - "time": "2023-12-29T01:52:43+00:00" + "time": "2024-02-26T04:55:38+00:00" }, { "name": "rmariuzzo/jquery-checkboxes", @@ -1648,29 +1652,29 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.19.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b" + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/aed596913b70fae57be53d86faa2e9ef85a2297b", - "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.2" + }, + "provide": { + "ext-ctype": "*" }, "suggest": { "ext-ctype": "For best performance" }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.19-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1707,7 +1711,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.19.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" }, "funding": [ { @@ -1723,7 +1727,7 @@ "type": "tidelift" } ], - "time": "2020-10-23T09:01:57+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "tapmodo/jcrop", @@ -1773,30 +1777,30 @@ }, { "name": "twig/twig", - "version": "v1.42.5", + "version": "v1.44.8", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "87b2ea9d8f6fd014d0621ca089bb1b3769ea3f8e" + "reference": "b1f009c449e435a0384814e67205d9190a4d050e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/87b2ea9d8f6fd014d0621ca089bb1b3769ea3f8e", - "reference": "87b2ea9d8f6fd014d0621ca089bb1b3769ea3f8e", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/b1f009c449e435a0384814e67205d9190a4d050e", + "reference": "b1f009c449e435a0384814e67205d9190a4d050e", "shasum": "" }, "require": { - "php": ">=5.5.0", + "php": ">=7.2.5", "symfony/polyfill-ctype": "^1.8" }, "require-dev": { "psr/container": "^1.0", - "symfony/phpunit-bridge": "^4.4|^5.0" + "symfony/phpunit-bridge": "^4.4.9|^5.0.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.42-dev" + "dev-master": "1.44-dev" } }, "autoload": { @@ -1835,9 +1839,19 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/1.x" + "source": "https://github.com/twigphp/Twig/tree/v1.44.8" }, - "time": "2020-02-11T05:59:23+00:00" + "funding": [ + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2024-09-09T17:17:16+00:00" }, { "name": "vuejs/vuedatepicker_css", @@ -1879,30 +1893,38 @@ "packages-dev": [ { "name": "composer/pcre", - "version": "1.0.1", + "version": "3.3.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560" + "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/67a32d7d6f9f560b726ab25a061b38ff3a80c560", - "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560", + "url": "https://api.github.com/repos/composer/pcre/zipball/63aaeac21d7e775ff9bc9d45021e1745c97521c4", + "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4", "shasum": "" }, "require": { - "php": "^5.3.2 || ^7.0 || ^8.0" + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" }, "require-dev": { - "phpstan/phpstan": "^1.3", + "phpstan/phpstan": "^1.11.10", "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^4.2 || ^5" + "phpunit/phpunit": "^8 || ^9" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "1.x-dev" + "dev-main": "3.x-dev" + }, + "phpstan": { + "includes": [ + "extension.neon" + ] } }, "autoload": { @@ -1930,7 +1952,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/1.0.1" + "source": "https://github.com/composer/pcre/tree/3.3.1" }, "funding": [ { @@ -1946,31 +1968,31 @@ "type": "tidelift" } ], - "time": "2022-01-21T20:24:37+00:00" + "time": "2024-08-27T18:44:43+00:00" }, { "name": "composer/xdebug-handler", - "version": "2.0.5", + "version": "3.0.5", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "9e36aeed4616366d2b690bdce11f71e9178c579a" + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/9e36aeed4616366d2b690bdce11f71e9178c579a", - "reference": "9e36aeed4616366d2b690bdce11f71e9178c579a", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", "shasum": "" }, "require": { - "composer/pcre": "^1", - "php": "^5.3.2 || ^7.0 || ^8.0", + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", "psr/log": "^1 || ^2 || ^3" }, "require-dev": { "phpstan/phpstan": "^1.0", "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^4.2 || ^5.0 || ^6.0" + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" }, "type": "library", "autoload": { @@ -1994,9 +2016,9 @@ "performance" ], "support": { - "irc": "irc://irc.freenode.org/composer", + "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/2.0.5" + "source": "https://github.com/composer/xdebug-handler/tree/3.0.5" }, "funding": [ { @@ -2012,146 +2034,67 @@ "type": "tidelift" } ], - "time": "2022-02-24T20:20:32+00:00" + "time": "2024-05-06T16:37:16+00:00" }, { - "name": "doctrine/instantiator", - "version": "1.0.5", + "name": "irstea/phpcpd-shim", + "version": "6.0.3", "source": { "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" + "url": "https://gitlab.irstea.fr/pole-is/tools/phpcpd-shim.git", + "reference": "5829d11d1379fd92176b7e2105060c7f09f4fdda" }, "require": { - "php": ">=5.3,<8.0-DEV" + "ext-dom": "*", + "php": ">=7.3" }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "replace": { + "sebastian/phpcpd": "self.version" }, + "bin": [ + "phpcpd" + ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } + "exclude-from-classmap": [ + "phpcpd" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "description": "Shim repository for sebastian/phpcpd", + "homepage": "https://github.com/sebastianbergmann/phpcpd", "keywords": [ - "constructor", - "instantiate" + "shim" ], - "support": { - "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.0.5" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], - "time": "2015-06-14T21:17:01+00:00" - }, - { - "name": "myclabs/deep-copy", - "version": "1.7.0", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^4.1" - }, - "type": "library", - "autoload": { - "files": [ - "src/DeepCopy/deep_copy.php" - ], - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "support": { - "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.x" - }, - "time": "2017-10-19T19:58:43+00:00" + "time": "2020-12-08T03:20:09+00:00" }, { "name": "nikic/php-parser", - "version": "v4.18.0", + "version": "v4.19.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" + "reference": "0ed4c8949a32986043e977dbe14776c14d644c45" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ed4c8949a32986043e977dbe14776c14d644c45", + "reference": "0ed4c8949a32986043e977dbe14776c14d644c45", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.1" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", @@ -2187,9 +2130,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.2" }, - "time": "2023-12-10T21:03:43+00:00" + "time": "2024-09-17T19:36:00+00:00" }, { "name": "pdepend/pdepend", @@ -2254,279 +2197,6 @@ ], "time": "2023-12-17T18:09:59+00:00" }, - { - "name": "phar-io/manifest", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/phar-io/manifest.git", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-phar": "*", - "phar-io/version": "^1.0.1", - "php": "^5.6 || ^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "support": { - "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/master" - }, - "time": "2017-03-05T18:14:27+00:00" - }, - { - "name": "phar-io/version", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/phar-io/version.git", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Library for handling version information and constraints", - "support": { - "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/master" - }, - "time": "2017-03-05T17:38:23+00:00" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "^4.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/master" - }, - "time": "2017-09-11T18:02:19+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "4.3.4", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", - "shasum": "" - }, - "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", - "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", - "webmozart/assert": "^1.0" - }, - "require-dev": { - "doctrine/instantiator": "^1.0.5", - "mockery/mockery": "^1.0", - "phpdocumentor/type-resolver": "0.4.*", - "phpunit/phpunit": "^6.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/release/4.x" - }, - "time": "2019-12-28T18:55:12+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "0.5.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "cf842904952e64e703800d094cdf34e715a8a3ae" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/cf842904952e64e703800d094cdf34e715a8a3ae", - "reference": "cf842904952e64e703800d094cdf34e715a8a3ae", - "shasum": "" - }, - "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/master" - }, - "time": "2017-12-30T13:23:38+00:00" - }, { "name": "phpmd/phpmd", "version": "2.15.0", @@ -2679,516 +2349,26 @@ "time": "2023-03-08T15:03:36+00:00" }, { - "name": "phpspec/prophecy", - "version": "v1.10.3", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "451c3cd1418cf640de218914901e51b064abb093" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", - "reference": "451c3cd1418cf640de218914901e51b064abb093", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.10.3" - }, - "time": "2020-03-05T15:02:03+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "5.3.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "c89677919c5dd6d3b3852f230a663118762218ac" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac", - "reference": "c89677919c5dd6d3b3852f230a663118762218ac", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-xmlwriter": "*", - "php": "^7.0", - "phpunit/php-file-iterator": "^1.4.2", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^2.0.1", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.0", - "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "suggest": { - "ext-xdebug": "^2.5.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/5.3" - }, - "time": "2018-04-06T15:36:58+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "support": { - "irc": "irc://irc.freenode.net/phpunit", - "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/1.4.5" - }, - "time": "2017-11-27T13:52:08+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" - }, - "time": "2015-06-21T13:50:34+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.9", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/master" - }, - "time": "2017-02-26T11:10:40+00:00" - }, - { - "name": "phpunit/php-token-stream", + "name": "psr/container", "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "791198a2c6254db10131eecfe8c06670700904db" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", - "reference": "791198a2c6254db10131eecfe8c06670700904db", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.2.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", - "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" - }, - "abandoned": true, - "time": "2017-11-27T05:48:46+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "6.5.14", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bac23fe7ff13dbdb461481f706f0e9fe746334b7", - "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "myclabs/deep-copy": "^1.6.1", - "phar-io/manifest": "^1.0.1", - "phar-io/version": "^1.0", - "php": "^7.0", - "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^5.3", - "phpunit/php-file-iterator": "^1.4.3", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^1.0.9", - "phpunit/phpunit-mock-objects": "^5.0.9", - "sebastian/comparator": "^2.1", - "sebastian/diff": "^2.0", - "sebastian/environment": "^3.1", - "sebastian/exporter": "^3.1", - "sebastian/global-state": "^2.0", - "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^1.0", - "sebastian/version": "^2.0.1" - }, - "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2", - "phpunit/dbunit": "<3.0" - }, - "require-dev": { - "ext-pdo": "*" - }, - "suggest": { - "ext-xdebug": "*", - "phpunit/php-invoker": "^1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.5.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/6.5.14" - }, - "time": "2019-02-01T05:22:47+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "5.0.10", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/cd1cf05c553ecfec36b170070573e540b67d3f1f", - "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.5", - "php": "^7.0", - "phpunit/php-text-template": "^1.2.1", - "sebastian/exporter": "^3.1" - }, - "conflict": { - "phpunit/phpunit": "<6.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.5.11" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues", - "source": "https://github.com/sebastianbergmann/phpunit-mock-objects/tree/5.0.10" - }, - "abandoned": true, - "time": "2018-08-09T05:50:03+00:00" - }, - { - "name": "psr/container", - "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=7.4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -3203,7 +2383,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common Container Interface (PHP FIG PSR-11)", @@ -3217,36 +2397,36 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2017-02-14T16:28:37+00:00" + "time": "2021-11-05T16:47:00+00:00" }, { "name": "psr/log", - "version": "1.1.4", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "3.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -3267,741 +2447,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/3.0.2" }, - "time": "2021-05-03T11:20:27+00:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "phpunit/phpunit": "^8.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-11-30T08:15:22+00:00" - }, - { - "name": "sebastian/comparator", - "version": "2.1.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", - "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", - "shasum": "" - }, - "require": { - "php": "^7.0", - "sebastian/diff": "^2.0 || ^3.0", - "sebastian/exporter": "^3.1" - }, - "require-dev": { - "phpunit/phpunit": "^6.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "https://github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/master" - }, - "time": "2018-02-01T13:46:46+00:00" - }, - { - "name": "sebastian/diff", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", - "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/master" - }, - "time": "2017-08-03T08:09:46+00:00" - }, - { - "name": "sebastian/environment", - "version": "3.1.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/master" - }, - "time": "2017-07-01T08:51:00+00:00" - }, - { - "name": "sebastian/exporter", - "version": "3.1.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "73a9676f2833b9a7c36968f9d882589cd75511e6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/73a9676f2833b9a7c36968f9d882589cd75511e6", - "reference": "73a9676f2833b9a7c36968f9d882589cd75511e6", - "shasum": "" - }, - "require": { - "php": ">=7.0", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^8.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.5" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2022-09-14T06:00:17+00:00" - }, - { - "name": "sebastian/finder-facade", - "version": "1.2.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/finder-facade.git", - "reference": "4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f", - "reference": "4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f", - "shasum": "" - }, - "require": { - "symfony/finder": "~2.3|~3.0|~4.0", - "theseer/fdomdocument": "~1.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "FinderFacade is a convenience wrapper for Symfony's Finder component.", - "homepage": "https://github.com/sebastianbergmann/finder-facade", - "support": { - "issues": "https://github.com/sebastianbergmann/finder-facade/issues", - "source": "https://github.com/sebastianbergmann/finder-facade/tree/master" - }, - "abandoned": true, - "time": "2017-11-18T17:31:49+00:00" - }, - { - "name": "sebastian/global-state", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/2.0.0" - }, - "time": "2017-04-27T15:39:26+00:00" - }, - { - "name": "sebastian/object-enumerator", - "version": "3.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", - "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", - "shasum": "" - }, - "require": { - "php": ">=7.0", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "support": { - "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.4" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-11-30T07:40:27+00:00" - }, - { - "name": "sebastian/object-reflector", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", - "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", - "shasum": "" - }, - "require": { - "php": ">=7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Allows reflection of object attributes, including inherited and non-public ones", - "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "support": { - "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.2" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-11-30T07:37:18+00:00" - }, - { - "name": "sebastian/phpcpd", - "version": "3.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpcpd.git", - "reference": "dfed51c1288790fc957c9433e2f49ab152e8a564" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpcpd/zipball/dfed51c1288790fc957c9433e2f49ab152e8a564", - "reference": "dfed51c1288790fc957c9433e2f49ab152e8a564", - "shasum": "" - }, - "require": { - "php": "^5.6|^7.0", - "phpunit/php-timer": "^1.0.6", - "sebastian/finder-facade": "^1.1", - "sebastian/version": "^1.0|^2.0", - "symfony/console": "^2.7|^3.0|^4.0" - }, - "bin": [ - "phpcpd" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Copy/Paste Detector (CPD) for PHP code.", - "homepage": "https://github.com/sebastianbergmann/phpcpd", - "support": { - "issues": "https://github.com/sebastianbergmann/phpcpd/issues", - "source": "https://github.com/sebastianbergmann/phpcpd/tree/master" - }, - "abandoned": true, - "time": "2017-11-16T08:49:28+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "3.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/367dcba38d6e1977be014dc4b22f47a484dac7fb", - "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb", - "shasum": "" - }, - "require": { - "php": ">=7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "support": { - "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-11-30T07:34:24+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "shasum": "" - }, - "require": { - "php": ">=5.6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/master" - }, - "time": "2015-07-28T20:34:47+00:00" - }, - { - "name": "sebastian/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "support": { - "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/master" - }, - "time": "2016-10-03T07:35:21+00:00" + "time": "2024-09-11T13:17:53+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -4075,35 +2523,34 @@ }, { "name": "symfony/config", - "version": "v3.4.47", + "version": "v7.1.1", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f" + "reference": "2210fc99fa42a259eb6c89d1f724ce0c4d62d5d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f", - "reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f", + "url": "https://api.github.com/repos/symfony/config/zipball/2210fc99fa42a259eb6c89d1f724ce0c4d62d5d2", + "reference": "2210fc99fa42a259eb6c89d1f724ce0c4d62d5d2", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/filesystem": "~2.8|~3.0|~4.0", + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/filesystem": "^7.1", "symfony/polyfill-ctype": "~1.8" }, "conflict": { - "symfony/dependency-injection": "<3.3", - "symfony/finder": "<3.3" + "symfony/finder": "<6.4", + "symfony/service-contracts": "<2.5" }, "require-dev": { - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/event-dispatcher": "~3.3|~4.0", - "symfony/finder": "~3.3|~4.0", - "symfony/yaml": "~3.0|~4.0" - }, - "suggest": { - "symfony/yaml": "To use the yaml reference dumper" + "symfony/event-dispatcher": "^6.4|^7.0", + "symfony/finder": "^6.4|^7.0", + "symfony/messenger": "^6.4|^7.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/yaml": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -4128,10 +2575,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Config Component", + "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/config/tree/v3.4.47" + "source": "https://github.com/symfony/config/tree/v7.1.1" }, "funding": [ { @@ -4147,199 +2594,43 @@ "type": "tidelift" } ], - "time": "2020-10-24T10:57:07+00:00" - }, - { - "name": "symfony/console", - "version": "v3.4.47", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "a10b1da6fc93080c180bba7219b5ff5b7518fe81" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/a10b1da6fc93080c180bba7219b5ff5b7518fe81", - "reference": "a10b1da6fc93080c180bba7219b5ff5b7518fe81", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0|~4.0", - "symfony/polyfill-mbstring": "~1.0" - }, - "conflict": { - "symfony/dependency-injection": "<3.4", - "symfony/process": "<3.3" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~3.3|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.3|~4.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/console/tree/v3.4.47" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-24T10:57:07+00:00" - }, - { - "name": "symfony/debug", - "version": "v3.4.47", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "ab42889de57fdfcfcc0759ab102e2fd4ea72dcae" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/ab42889de57fdfcfcc0759ab102e2fd4ea72dcae", - "reference": "ab42889de57fdfcfcc0759ab102e2fd4ea72dcae", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/http-kernel": "~2.8|~3.0|~4.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/debug/tree/v3.4.47" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "abandoned": "symfony/error-handler", - "time": "2020-10-24T10:57:07+00:00" + "time": "2024-05-31T14:57:53+00:00" }, { "name": "symfony/dependency-injection", - "version": "v3.4.47", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b" + "reference": "38465f925ec4e0707b090e9147c65869837d639d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/51d2a2708c6ceadad84393f8581df1dcf9e5e84b", - "reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/38465f925ec4e0707b090e9147c65869837d639d", + "reference": "38465f925ec4e0707b090e9147c65869837d639d", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "psr/container": "^1.0" + "php": ">=8.2", + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/service-contracts": "^3.5", + "symfony/var-exporter": "^6.4|^7.0" }, "conflict": { - "symfony/config": "<3.3.7", - "symfony/finder": "<3.3", - "symfony/proxy-manager-bridge": "<3.4", - "symfony/yaml": "<3.4" + "ext-psr": "<1.1|>=2", + "symfony/config": "<6.4", + "symfony/finder": "<6.4", + "symfony/yaml": "<6.4" }, "provide": { - "psr/container-implementation": "1.0" + "psr/container-implementation": "1.1|2.0", + "symfony/service-implementation": "1.1|2.0|3.0" }, "require-dev": { - "symfony/config": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "symfony/config": "", - "symfony/expression-language": "For using expressions in service container configuration", - "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", - "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", - "symfony/yaml": "" + "symfony/config": "^6.4|^7.0", + "symfony/expression-language": "^6.4|^7.0", + "symfony/yaml": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -4364,10 +2655,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony DependencyInjection Component", + "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v3.4.47" + "source": "https://github.com/symfony/dependency-injection/tree/v7.1.5" }, "funding": [ { @@ -4383,25 +2674,96 @@ "type": "tidelift" } ], - "time": "2020-10-24T10:57:07+00:00" + "time": "2024-09-20T08:28:38+00:00" }, { - "name": "symfony/filesystem", - "version": "v3.4.47", + "name": "symfony/deprecation-contracts", + "version": "v3.5.0", "source": { "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "e58d7841cddfed6e846829040dca2cca0ebbbbb3" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/e58d7841cddfed6e846829040dca2cca0ebbbbb3", - "reference": "e58d7841cddfed6e846829040dca2cca0ebbbbb3", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v7.1.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/61fe0566189bf32e8cfee78335d8776f64a66f5a", + "reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "require-dev": { + "symfony/process": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -4426,10 +2788,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Filesystem Component", + "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v3.4.47" + "source": "https://github.com/symfony/filesystem/tree/v7.1.5" }, "funding": [ { @@ -4445,94 +2807,33 @@ "type": "tidelift" } ], - "time": "2020-10-24T10:57:07+00:00" - }, - { - "name": "symfony/finder", - "version": "v3.4.47", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "b6b6ad3db3edb1b4b1c1896b1975fb684994de6e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/b6b6ad3db3edb1b4b1c1896b1975fb684994de6e", - "reference": "b6b6ad3db3edb1b4b1c1896b1975fb684994de6e", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/finder/tree/v3.4.47" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-11-16T17:02:08+00:00" + "time": "2024-09-17T09:16:35+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.19.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "b5f7b932ee6fa802fc792eabd77c4c88084517ce" + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b5f7b932ee6fa802fc792eabd77c4c88084517ce", - "reference": "b5f7b932ee6fa802fc792eabd77c4c88084517ce", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" }, "suggest": { "ext-mbstring": "For best performance" }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.19-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -4570,7 +2871,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.19.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" }, "funding": [ { @@ -4586,130 +2887,47 @@ "type": "tidelift" } ], - "time": "2020-10-23T09:01:57+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { - "name": "theseer/fdomdocument", - "version": "1.6.7", + "name": "symfony/service-contracts", + "version": "v3.5.0", "source": { "type": "git", - "url": "https://github.com/theseer/fDOMDocument.git", - "reference": "5cddd4f9076a9a2b85c5135935bba2dcb3ed7574" + "url": "https://github.com/symfony/service-contracts.git", + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/fDOMDocument/zipball/5cddd4f9076a9a2b85c5135935bba2dcb3ed7574", - "reference": "5cddd4f9076a9a2b85c5135935bba2dcb3ed7574", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", "shasum": "" }, "require": { - "ext-dom": "*", - "lib-libxml": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "php": ">=7.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "lead" - } - ], - "description": "The classes contained within this repository extend the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.", - "homepage": "https://github.com/theseer/fDOMDocument", - "support": { - "issues": "https://github.com/theseer/fDOMDocument/issues", - "source": "https://github.com/theseer/fDOMDocument/tree/1.6.7" - }, - "abandoned": true, - "time": "2022-01-25T23:10:35+00:00" - }, - { - "name": "theseer/tokenizer", - "version": "1.1.3", - "source": { - "type": "git", - "url": "https://github.com/theseer/tokenizer.git", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": "^7.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - } - ], - "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "support": { - "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/master" - }, - "time": "2019-06-13T22:48:21+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.9.1", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", - "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0 || ^8.0", - "symfony/polyfill-ctype": "^1.8" + "php": ">=8.1", + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" }, "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<3.9.1" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^7.5.13" + "ext-psr": "<1.1|>=2" }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, "autoload": { "psr-4": { - "Webmozart\\Assert\\": "src/" - } + "Symfony\\Contracts\\Service\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -4717,21 +2935,118 @@ ], "authors": [ { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Assertions to validate method input/output with nice error messages.", + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", "keywords": [ - "assert", - "check", - "validate" + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" ], "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.9.1" + "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" }, - "time": "2020-07-08T17:02:28+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, + { + "name": "symfony/var-exporter", + "version": "v7.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-exporter.git", + "reference": "b80a669a2264609f07f1667f891dbfca25eba44c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/b80a669a2264609f07f1667f891dbfca25eba44c", + "reference": "b80a669a2264609f07f1667f891dbfca25eba44c", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "symfony/property-access": "^6.4|^7.0", + "symfony/serializer": "^6.4|^7.0", + "symfony/var-dumper": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\VarExporter\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows exporting any serializable PHP data structure to plain PHP code", + "homepage": "https://symfony.com", + "keywords": [ + "clone", + "construct", + "export", + "hydrate", + "instantiate", + "lazy-loading", + "proxy", + "serialize" + ], + "support": { + "source": "https://github.com/symfony/var-exporter/tree/v7.1.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-06-28T08:00:31+00:00" } ], "aliases": [], @@ -4743,5 +3058,5 @@ "php": ">=5.6.40" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/config/global.config-default.inc.php b/config/global.config-default.inc.php index d12b23828..b945a15d2 100644 --- a/config/global.config-default.inc.php +++ b/config/global.config-default.inc.php @@ -332,4 +332,6 @@ define('DOCSBOX_ENABLED', false); // (true | false) define('DIENSTVERHAELTNIS_SUPPORT', false); +// Falls Studstatus (Abmeldung, AbmeldungStg, Unterbrechung, Wiederholung) verwendet wird zeige Hinweistext bei Eingabe einer kommissionellen oder zusaetzlichen kommissionellen Pruefung +define('FAS_STUDSTATUS_SHOW_KOMM_PRFG_HINT', false); ?> diff --git a/content/student/studentoverlay.js.php b/content/student/studentoverlay.js.php index 8be20d32d..d2030f493 100644 --- a/content/student/studentoverlay.js.php +++ b/content/student/studentoverlay.js.php @@ -5139,6 +5139,7 @@ function StudentPruefungNeu() document.getElementById('student-pruefung-menulist-note').value='9'; document.getElementById('student-pruefung-textbox-datum').value=''; document.getElementById('student-pruefung-textbox-anmerkung').value=''; + StudentPruefungTypChange(); } // **** @@ -5190,6 +5191,17 @@ function StudentPruefungLVAChange() LEDropDown.selectedIndex=-1; } +// **** +// * Wenn der Typ der Pruefung geaendert wird, dann wird ein Hinweistext angezeigt. +// **** +function StudentPruefungTypChange() +{ + var typ = document.getElementById('student-pruefung-menulist-typ').value; + var hinweisid = document.getElementById('student-pruefung-textbox-datum-hinweis'); + if(hinweisid === null) return; + hinweisid.hidden = (typ != 'kommPruef' && typ != 'zusKommPruef'); +} + // **** // * Speichert die Pruefung // **** @@ -5424,6 +5436,7 @@ function StudentPruefungAuswahl() document.getElementById('student-pruefung-checkbox-neu').checked=false; document.getElementById('student-pruefung-textbox-pruefung_id').value=pruefung_id; document.getElementById('student-pruefung-textbox-punkte').value=punkte; + StudentPruefungTypChange(); } function StudentPruefungFilterStsem() diff --git a/content/student/studentpruefungoverlay.xul.php b/content/student/studentpruefungoverlay.xul.php index 2c2a3970a..b1fa4c325 100644 --- a/content/student/studentpruefungoverlay.xul.php +++ b/content/student/studentpruefungoverlay.xul.php @@ -34,6 +34,11 @@ if(defined('CIS_GESAMTNOTE_PUNKTE') && CIS_GESAMTNOTE_PUNKTE) else $punktehidden = 'true'; +if(defined('FAS_STUDSTATUS_SHOW_KOMM_PRFG_HINT') && FAS_STUDSTATUS_SHOW_KOMM_PRFG_HINT) + $show_komm_prfg_hint = true; +else + $show_komm_prfg_hint = false; + echo ''; ?> @@ -203,7 +208,8 @@ echo '';
diff --git a/public/js/components/searchbar/prestudent.js b/public/js/components/searchbar/prestudent.js new file mode 100644 index 000000000..0f7429075 --- /dev/null +++ b/public/js/components/searchbar/prestudent.js @@ -0,0 +1,88 @@ +import action from "./action.js"; +import actions from "./actions.js"; + +export default { + props: [ "res", "actions" ], + components: { + action: action, + actions: actions + }, + emits: [ 'actionexecuted' ], + template: ` + + `, + methods: { + }, + computed: { + mailtourl: function() { + return 'mailto:' + this.res.email; + } + } +}; \ No newline at end of file diff --git a/public/js/components/searchbar/searchbar.js b/public/js/components/searchbar/searchbar.js index 1f4dfc94b..d23ab2226 100644 --- a/public/js/components/searchbar/searchbar.js +++ b/public/js/components/searchbar/searchbar.js @@ -2,6 +2,8 @@ import person from "./person.js"; import raum from "./raum.js"; import employee from "./employee.js"; import organisationunit from "./organisationunit.js"; +import student from "./student.js"; +import prestudent from "./prestudent.js"; export default { props: [ "searchoptions", "searchfunction" ], @@ -24,7 +26,9 @@ export default { person: person, raum: raum, employee: employee, - organisationunit: organisationunit + organisationunit: organisationunit, + student: student, + prestudent: prestudent }, template: `
Es wurden keine Ergebnisse gefunden.