diff --git a/application/config/javascript.php b/application/config/javascript.php index f3237fde3..6f82810e2 100644 --- a/application/config/javascript.php +++ b/application/config/javascript.php @@ -6,4 +6,4 @@ $config['use_vuejs_dev_version'] = false; // use bundled javascript $config['use_bundled_javascript'] = false; // systemerror_mailto use in FHC-Alert Plugin - if empty Link will not be rendered -$config['systemerror_mailto'] = ''; \ No newline at end of file +$config['systemerror_mailto'] = ''; diff --git a/application/config/stv.php b/application/config/stv.php index 31ce3f521..1fdd5b28a 100644 --- a/application/config/stv.php +++ b/application/config/stv.php @@ -52,7 +52,11 @@ $config['tabs'] = ], ], ], - ] + ], + 'exemptions' => [ + //if true, Anrechnungen can be added and edited in tab Anrechnungen + 'editableAnrechnungen' => false, + ], ]; // List of fields to show when ZGV_DOKTOR_ANZEIGEN is defined diff --git a/application/controllers/NeueNachricht.php b/application/controllers/NeueNachricht.php new file mode 100644 index 000000000..9b61b78ef --- /dev/null +++ b/application/controllers/NeueNachricht.php @@ -0,0 +1,30 @@ +method] = ['vertrag/mitarbeiter:r']; + parent::__construct($permissions); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + } + + /** + * @return void + */ + public function _remap() + { + //now working + $this->load->view('Nachrichten', [ + 'permissions' => [ + 'assistenz_schreibrechte' => $this->permissionlib->isBerechtigt('assistenz','suid'), + ] + ]); + } +} diff --git a/application/controllers/api/frontend/v1/Documents.php b/application/controllers/api/frontend/v1/Documents.php index 60010e14d..ebd1b269b 100644 --- a/application/controllers/api/frontend/v1/Documents.php +++ b/application/controllers/api/frontend/v1/Documents.php @@ -43,7 +43,8 @@ class Documents extends FHCAPI_Controller parent::__construct([ 'permissionAlternativeFormat' => self::PERM_LOGGED, 'archive' => ['admin:rw', 'assistenz:rw'], - 'archiveSigned' => ['admin:rw', 'assistenz:rw'] + 'archiveSigned' => ['admin:rw', 'assistenz:rw'], + 'download' => ['admin:rw', 'assistenz:rw'] ]); // Load Phrases @@ -66,7 +67,7 @@ class Documents extends FHCAPI_Controller } /** - * Download a not signed document. + * Archive a not signed document. * * @param string $xml (optional) * @param string $xsl (optional) @@ -79,7 +80,7 @@ class Documents extends FHCAPI_Controller } /** - * Download a signed document. + * Archive a signed document. * * @param string $xml (optional) * @param string $xsl (optional) @@ -91,6 +92,42 @@ class Documents extends FHCAPI_Controller return $this->_archive($xml, $xsl, getAuthUID()); } + /** + * + * @return void + */ + public function download($xml, $xsl, $sign_user = null) + { + $akteExportData = $this->_getAkteExportData($xml, $xsl, $sign_user); + + $akteData = $akteData['akteData']; + $exportData = $akteData['exportData']; + + /** + * [ + 'vorlage' => $vorlage, + 'xml_data' => $data, + 'oe_kurzbz' => $xsl_oe_kurzbz, + 'version' => $version, + 'outputformat' => $outputformat, + 'sign_user' => $sign_user + ] + */ + + // Output + $result = $this->documentexportlib->showContent( + $akteData['akteData']['inhalt'], + $exportData['vorlage'], + $exportData['xml_data'], + $exportData['oe_kurzbz'], + $exportData['version'], + $exportData['outputformat'], + $exportData['sign_user'] + ); + + $this->terminateWithSuccess(true); + } + /** * Helper function for archive() and archiveSigned() * @@ -100,16 +137,36 @@ class Documents extends FHCAPI_Controller * * @return void */ - public function _archive($xml, $xsl, $sign_user = null) + private function _archive($xml, $xsl, $sign_user = null) + { + $akteData = $this->_getAkteExportData($xml, $xsl, $sign_user); + + $this->load->model('crm/Akte_model', 'AkteModel'); + $result = $this->AkteModel->insert($akteData['akteData']); + $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(true); + } + + /** + * @param string $xml + * @param string $xsl + * @param string $sign_user (optional) + * + * @return array with Akte data and export data + */ + private function _getAkteExportData($xml, $xsl, $sign_user = null) { if (!$xml || !$xsl) { $this->load->library('form_validation'); if (!$xml) { $xml = $this->input->post_get('xml'); + $this->addMeta('xml', $xml); $this->form_validation->set_rules('xml', 'xml', 'required'); } if (!$xsl) { $xsl = $this->input->post_get('xsl'); + $this->addMeta('xsl', $xsl); $this->form_validation->set_rules('xsl', 'xsl', 'required'); } @@ -151,6 +208,7 @@ class Documents extends FHCAPI_Controller $this->load->model('system/Vorlage_model', 'VorlageModel'); $result = $this->VorlageModel->load($xsl); + $this->addMeta("ress", $result); $vorlage = current($this->getDataOrTerminateWithError($result)); if (!$vorlage) show_404(); @@ -171,6 +229,7 @@ class Documents extends FHCAPI_Controller $studiengang_kz = null; if ($akteData['uid']) { $this->load->model('crm/Student_model', 'StudentModel'); + $this->StudentModel->addSelect('tbl_student.*, UPPER(typ || kurzbz) AS kuerzel'); $this->StudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz', 'LEFT'); $result = $this->StudentModel->load([$akteData['uid']]); $student = current($this->getDataOrTerminateWithError($result)); @@ -318,6 +377,7 @@ class Documents extends FHCAPI_Controller $result = $this->VorlagestudiengangModel->getCurrent($xsl, $xsl_oe_kurzbz, $version); $access_rights = current($this->getDataOrTerminateWithError($result)); + // TODO: was bedeutet wenn keine berechtigung? if (!$access_rights || !$access_rights->berechtigung) return show_404(); @@ -413,10 +473,17 @@ class Documents extends FHCAPI_Controller $akteData['titel'] .= '.pdf'; $akteData['inhalt'] = base64_encode($content); - $this->load->model('crm/Akte_model', 'AkteModel'); - $result = $this->AkteModel->insert($akteData); - $this->getDataOrTerminateWithError($result); - - $this->terminateWithSuccess(true); + return [ + 'akteData' => $akteData, + 'exportData' => + [ + 'vorlage' => $vorlage, + 'xml_data' => $data, + 'oe_kurzbz' => $xsl_oe_kurzbz, + 'version' => $version, + 'outputformat' => $outputformat, + 'sign_user' => $sign_user + ] + ]; } } diff --git a/application/controllers/api/frontend/v1/betriebsmittel/BetriebsmittelP.php b/application/controllers/api/frontend/v1/betriebsmittel/BetriebsmittelP.php index 8e9d931f2..05d7c66c2 100644 --- a/application/controllers/api/frontend/v1/betriebsmittel/BetriebsmittelP.php +++ b/application/controllers/api/frontend/v1/betriebsmittel/BetriebsmittelP.php @@ -75,8 +75,9 @@ class BetriebsmittelP extends FHCAPI_Controller '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('kaution', 'Kaution', 'callback_valid_number|callback_not_less_than_equal', [ + 'valid_number' => $this->p->t('ui', 'error_fieldNoValidNumber'), + 'not_less_than_equal' => $this->p->t('ui', 'error_fieldLessThan1000'), ]); $this->form_validation->set_rules('ausgegebenam', 'Ausgegeben am', 'required|is_valid_date', [ @@ -158,6 +159,7 @@ class BetriebsmittelP extends FHCAPI_Controller ], [ 'uid_in_person' => $this->p->t('person', 'error_uidNotInPerson') ]); + $this->validateNewOrUpdate(); $betriebsmitteltyp = $this->input->post('betriebsmitteltyp'); @@ -167,6 +169,7 @@ class BetriebsmittelP extends FHCAPI_Controller $betriebsmittel_id = $this->input->post('betriebsmittel_id'); $anmerkung = $this->input->post('anmerkung'); $kaution = $this->input->post('kaution'); + if($kaution) $kaution = str_replace(',', '.', $kaution); $ausgegebenam = $this->input->post('ausgegebenam'); $retouram = $this->input->post('retouram'); $uid = $this->input->post('uid'); @@ -250,6 +253,7 @@ class BetriebsmittelP extends FHCAPI_Controller $betriebsmittel_id = $this->input->post('betriebsmittel_id'); $anmerkung = $this->input->post('anmerkung'); $kaution = $this->input->post('kaution'); + if($kaution) $kaution = str_replace(',', '.', $kaution); $ausgegebenam = $this->input->post('ausgegebenam'); $retouram = $this->input->post('retouram'); @@ -382,6 +386,26 @@ class BetriebsmittelP extends FHCAPI_Controller $this->terminateWithSuccess($data); } + + public function valid_number($number) + { + if(is_null($number)) return true; + $number = str_replace(',', '.', $number); + if (!is_numeric($number)) + { + return false; + } + return true; + } + + public function not_less_than_equal($number) + { + $number = str_replace(',', '.', $number); + if ($number < 1000) + return true; + return false; + + } } diff --git a/application/controllers/api/frontend/v1/funktionen/Funktionen.php b/application/controllers/api/frontend/v1/funktionen/Funktionen.php new file mode 100644 index 000000000..b2787072b --- /dev/null +++ b/application/controllers/api/frontend/v1/funktionen/Funktionen.php @@ -0,0 +1,328 @@ + ['admin:r', 'assistenz:r'], + 'getAllUserFunctions' => ['admin:r', 'assistenz:r'], + 'getOrgHeads' => ['admin:r', 'assistenz:r'], + 'getOrgetsForCompany' => ['admin:r', 'assistenz:r'], + 'getAllOrgUnits' => ['admin:r', 'assistenz:r'], + 'loadFunction' => ['admin:r', 'assistenz:r'], + 'insertFunction' => ['admin:rw', 'assistenz:rw'], + 'updateFunction' => ['admin:rw', 'assistenz:rw'], + 'deleteFunction' => ['admin:rw', 'assistenz:rw'], + ) + ); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('form_validation'); + + // Load language phrases + $this->loadPhrases([ + 'ui', + ]); + + // Load models + $this->load->model('extensions/FHC-Core-Personalverwaltung/Api_model', 'ApiModel'); + $this->load->model('ressource/Funktion_model', 'FunktionModel'); + $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + + $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); + } + + public function getAllFunctions() + { + $this->FunktionModel->addSelect("funktion_kurzbz"); + $this->FunktionModel->addSelect("beschreibung"); + $this->FunktionModel->addSelect("aktiv"); + $this->FunktionModel->addSelect("beschreibung AS label"); + $this->FunktionModel->addOrder("beschreibung"); + $result = $this->FunktionModel->load(); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getOrgHeads() + { + $result = $this->OrganisationseinheitModel->getHeads(); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getAllUserFunctions($uid) + { + if(!$uid) + { + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'UID']), self::ERROR_TYPE_GENERAL); + } + + $sql = " + SELECT + dv.dienstverhaeltnis_id, + un.bezeichnung || ' (' || TO_CHAR(dv.von, 'DD.MM.YYYY') || CASE WHEN dv.bis IS NOT NULL THEN ' - ' + || TO_CHAR(dv.bis, 'DD.MM.YYYY') ELSE '' END || ')' AS dienstverhaeltnis_unternehmen , + '[' || oet.bezeichnung || '] ' || oe.bezeichnung AS funktion_oebezeichnung, + f.beschreibung AS funktion_beschreibung, + bf.*, + fb.bezeichnung AS fachbereich_bezeichnung, + CASE + WHEN + bf.datum_bis IS NOT NULL AND bf.datum_bis::date < now()::date + THEN + false + ELSE + true + END aktiv + FROM + public.tbl_benutzerfunktion bf + JOIN + public.tbl_organisationseinheit oe ON oe.oe_kurzbz = bf.oe_kurzbz + JOIN + public.tbl_organisationseinheittyp oet ON oe.organisationseinheittyp_kurzbz = oet.organisationseinheittyp_kurzbz + JOIN + public.tbl_funktion f ON f.funktion_kurzbz = bf.funktion_kurzbz + LEFT JOIN + hr.tbl_vertragsbestandteil_funktion vf ON vf.benutzerfunktion_id = bf.benutzerfunktion_id + LEFT JOIN + hr.tbl_vertragsbestandteil v ON vf.vertragsbestandteil_id = v.vertragsbestandteil_id + LEFT JOIN + hr.tbl_dienstverhaeltnis dv ON v.dienstverhaeltnis_id = dv.dienstverhaeltnis_id + LEFT JOIN + public.tbl_organisationseinheit un ON dv.oe_kurzbz = un.oe_kurzbz + LEFT JOIN + public.tbl_fachbereich fb ON fb.fachbereich_kurzbz = bf.fachbereich_kurzbz + WHERE + bf.uid = ? + ORDER BY + bf.datum_von, bf.datum_von ASC"; + + $benutzerfunktionen = $this->BenutzerfunktionModel->execReadOnlyQuery($sql, array($uid)); + $data = $this->getDataOrTerminateWithError($benutzerfunktionen); + + $this->terminateWithSuccess($data); + } + + /* + * returns list of all organisation units + * as key value list to be used in select or autocomplete + */ + public function getAllOrgUnits() + { + $sql = " + SELECT + oe.oe_kurzbz, oe.aktiv, + '[' || COALESCE(oet.bezeichnung, oet.organisationseinheittyp_kurzbz) || + '] ' || COALESCE(oe.bezeichnung, oe.oe_kurzbz) AS label + FROM public.tbl_organisationseinheit oe + JOIN public.tbl_organisationseinheittyp oet ON oe.organisationseinheittyp_kurzbz = oet.organisationseinheittyp_kurzbz + ORDER BY oet.bezeichnung ASC, oe.bezeichnung ASC"; + + $result = $this->OrganisationseinheitModel->execReadOnlyQuery($sql); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /* + * return list of child orgets for a given company orget_kurzbz + * as key value list to be used in select or autocomplete + */ + public function getOrgetsForCompany($companyOrgetkurzbz = null) + { + $sql = " + SELECT + oe.oe_kurzbz, oe.aktiv, + '[' || COALESCE(oet.bezeichnung, oet.organisationseinheittyp_kurzbz) || + '] ' || COALESCE(oe.bezeichnung, oe.oe_kurzbz) AS label + FROM ( + WITH RECURSIVE oes(oe_kurzbz, oe_parent_kurzbz) as + ( + SELECT oe_kurzbz, oe_parent_kurzbz FROM public.tbl_organisationseinheit + WHERE oe_kurzbz=? + UNION ALL + SELECT o.oe_kurzbz, o.oe_parent_kurzbz FROM public.tbl_organisationseinheit o, oes + WHERE o.oe_parent_kurzbz=oes.oe_kurzbz + ) + SELECT oe_kurzbz + FROM oes + GROUP BY oe_kurzbz + ) c + JOIN public.tbl_organisationseinheit oe ON oe.oe_kurzbz = c.oe_kurzbz + JOIN public.tbl_organisationseinheittyp oet ON oe.organisationseinheittyp_kurzbz = oet.organisationseinheittyp_kurzbz + ORDER BY oet.bezeichnung ASC, oe.bezeichnung ASC"; + + $childorgets = $this->OrganisationseinheitModel->execReadOnlyQuery($sql, array($companyOrgetkurzbz)); + $data = $this->getDataOrTerminateWithError($childorgets); + + $this->terminateWithSuccess($data); + } + + public function loadFunction($benutzerfunktion_id) + { + $this->BenutzerfunktionModel->addSelect("*"); + $result = $this->BenutzerfunktionModel->loadWhere( + array('benutzerfunktion_id' => $benutzerfunktion_id) + ); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } + + public function insertFunction() + { + $this->load->library('form_validation'); + $authUID = getAuthUID(); + + $uid = $this->input->post('uid'); + + if(!$uid) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'UID']), self::ERROR_TYPE_GENERAL); + } + + $formData = $this->input->post('formData'); + + $datum_von = $formData['datum_von'] ?? null; + $datum_bis = $formData['datum_bis'] ?? null; + $formData['oe_kurzbz'] = is_array($formData['oe_kurzbz']) ? $formData['oe_kurzbz']['oe_kurzbz'] : $formData['oe_kurzbz']; + $formData['funktion_kurzbz'] = is_array($formData['funktion_kurzbz']) + ? $formData['funktion_kurzbz']['funktion_kurzbz'] + : $formData['funktion_kurzbz']; + $bezeichnung = $formData['bezeichnung'] ?? null; + $wochenstunden = $formData['wochenstunden'] ?? null; + + $this->form_validation->set_data($formData); + $this->form_validation->set_rules('datum_von', 'VonDatum', 'required|is_valid_date', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'VonDatum']), + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'VonDatum']) + ]); + $this->form_validation->set_rules('datum_bis', 'BisDatum', 'is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'BisDatum']) + ]); + $this->form_validation->set_rules('oe_kurzbz', 'Organisationseinheit', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Organisationseinheit']) + ]); + $this->form_validation->set_rules('funktion_kurzbz', 'Funktion', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Funktion']) + ]); + $this->form_validation->set_rules('wochenstunden', 'Wochenstunden', 'numeric', [ + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Wochenstunden']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $result = $this->BenutzerfunktionModel->insert([ + 'uid' => $uid, + 'datum_von' => $datum_von, + 'datum_bis' => $datum_bis , + 'oe_kurzbz' => $formData['oe_kurzbz'], + 'funktion_kurzbz' => $formData['funktion_kurzbz'], + 'bezeichnung' => $bezeichnung, + 'wochenstunden' => $wochenstunden, + 'insertamum' => date('c'), + 'insertvon' => $authUID, + ]); + + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + public function updateFunction() + { + $this->load->library('form_validation'); + $authUID = getAuthUID(); + + $uid = $this->input->post('uid'); + + if(!$uid) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'UID']), self::ERROR_TYPE_GENERAL); + } + $benutzerfunktion_id = $this->input->post('benutzerfunktion_id'); + + if(!$benutzerfunktion_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Benutzerfunktion ID']), self::ERROR_TYPE_GENERAL); + } + + $formData = $this->input->post('formData'); + + $datum_von = $formData['datum_von'] ?? null; + $datum_bis = $formData['datum_bis'] ?? null; + $formData['oe_kurzbz'] = is_array($formData['oe_kurzbz']) ? $formData['oe_kurzbz']['oe_kurzbz'] : $formData['oe_kurzbz']; + $formData['funktion_kurzbz'] = is_array($formData['funktion_kurzbz']) + ? $formData['funktion_kurzbz']['funktion_kurzbz'] + : $formData['funktion_kurzbz']; + $bezeichnung = $formData['bezeichnung'] ?? null; + $wochenstunden = $formData['wochenstunden'] ?? null; + + $this->form_validation->set_data($formData); + $this->form_validation->set_rules('datum_von', 'VonDatum', 'required|is_valid_date', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'VonDatum']), + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'VonDatum']) + ]); + $this->form_validation->set_rules('datum_bis', 'BisDatum', 'is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'BisDatum']) + ]); + $this->form_validation->set_rules('oe_kurzbz', 'Organisationseinheit', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Organisationseinheit']) + ]); + $this->form_validation->set_rules('funktion_kurzbz', 'Funktion', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Funktion']) + ]); + $this->form_validation->set_rules('wochenstunden', 'Wochenstunden', 'numeric', [ + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Wochenstunden']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $result = $this->BenutzerfunktionModel->update( + [ + 'benutzerfunktion_id' => $benutzerfunktion_id, + ], + [ + 'uid' => $uid, + 'datum_von' => $datum_von, + 'datum_bis' => $datum_bis , + 'oe_kurzbz' => $formData['oe_kurzbz'], + 'funktion_kurzbz' => $formData['funktion_kurzbz'], + 'bezeichnung' => $bezeichnung, + 'wochenstunden' => $wochenstunden, + 'updateamum' => date('c'), + 'updatevon' => $authUID, + ] + ); + + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + public function deleteFunction($benutzerfunktion_id) + { + $result = $this->BenutzerfunktionModel->delete( + array('benutzerfunktion_id' => $benutzerfunktion_id) + ); + + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/api/frontend/v1/messages/Messages.php b/application/controllers/api/frontend/v1/messages/Messages.php new file mode 100644 index 000000000..dbc11735a --- /dev/null +++ b/application/controllers/api/frontend/v1/messages/Messages.php @@ -0,0 +1,458 @@ + ['admin:r', 'assistenz:r'], + 'getVorlagen' => ['admin:r', 'assistenz:r'], + 'getMessageVarsPerson' => ['admin:r', 'assistenz:r'], + 'getMsgVarsPrestudent' => ['admin:r', 'assistenz:r'], + 'getMsgVarsLoggedInUser' => ['admin:r', 'assistenz:r'], + 'getNameOfDefaultRecipient' => ['admin:r', 'assistenz:r'], + 'sendMessage' => ['admin:r', 'assistenz:r'], + 'deleteMessage' => ['admin:r', 'assistenz:r'], + 'getVorlagentext' => ['admin:r', 'assistenz:r'], + 'getPreviewText' => ['admin:r', 'assistenz:r'], + 'getReplyData' => ['admin:r', 'assistenz:r'], + 'getPersonId' => ['admin:r', 'assistenz:r'], + 'getUid' => ['admin:r', 'assistenz:r'], + ]); + + //Load Models + $this->load->model('system/Message_model', 'MessageModel'); + $this->load->model('CL/Messages_model', 'MessagesModel'); + + // Additional Permission Checks + //TODO(manu) check permissions + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('form_validation'); + $this->load->library('MessageLib'); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + } + + public function getMessages($id, $type_id, $size, $page) + { + if($type_id != 'person_id'){ + $id = $this->_getPersonId($id, $type_id); + } + + $offset = $size * ($page - 1); + $limit = $size; + + $result = $this->MessageModel->getMessagesForTable($id, $offset, $limit); + + $data = $this->getDataOrTerminateWithError($result); + + $this->addMeta('count', $data['count']); + + $this->terminateWithSuccess($data['data']); + } + + public function getVorlagen() + { + //get oe of user + $uid = getAuthUID(); + $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $result = $this->BenutzerfunktionModel->getBenutzerfunktionByUid($uid, 'oezuordnung'); + + $data = $this->getDataOrTerminateWithError($result); + $oe_kurzbz = current($data); + + $this->load->model('system/Vorlage_model', 'VorlageModel'); + + $result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz->oe_kurzbz); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + + //If admin + $this->VorlageModel->addOrder('vorlage_kurzbz', 'ASC'); + $result = $this->VorlageModel->loadWhere( + array( + 'mimetype' => 'text/html' + )); + + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getVorlagentext($vorlage_kurzbz) + { + //$this->terminateWithError("vor " . $vorlage_kurzbz, self::ERROR_TYPE_GENERAL); + //$studiengang_kz = 227; //TODO(Manu) dynamisieren NULL + $studiengang_kz = 0; + $this->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel'); + $this->VorlagestudiengangModel->addOrder('version', 'DESC'); + + $result = $this->VorlagestudiengangModel->loadWhere( + [ + 'vorlage_kurzbz' =>$vorlage_kurzbz, + 'studiengang_kz' => $studiengang_kz + ]); + + $data = $this->getDataOrTerminateWithError($result); + + //not correct with Vorlage + $vorlage = current($data); + + //$this->terminateWithSuccess($data); + $this->terminateWithSuccess($vorlage->text); + } + + public function getMessageVarsPerson($id, $typeId) + { + $person_id = ($typeId == 'mitarbeiter_uid') ? $this->_getPersonId($id, $typeId) : $id; + $result = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getMsgVarsPrestudent($id, $typeId) + { + $prestudent_id = ($typeId == 'uid') ? $this->_getPrestudentIdFromUid($id) : $id; + $result = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getMsgVarsLoggedInUser() + { + $result = $this->MessageModel->getMsgVarsLoggedInUser(); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getNameOfDefaultRecipient($id, $type_id) + { + $id = ($type_id != 'person_id') ? $this->_getPersonId($id, $type_id) : $id; + + $this->load->model('person/Person_model', 'PersonModel'); + + $result = $this->PersonModel->load($id); + $data = $this->getDataOrTerminateWithError($result); + $name = current($data); + + $this->terminateWithSuccess($name->vorname . " " . $name->nachname ); + } + + public function sendMessage($recipient_id) + { + //has to be uid + // $this->terminateWithError("uid", $recipient_id, self::ERROR_TYPE_GENERAL); + + //default setting + $receiversPersonId = $this->_getPersonId($recipient_id, 'uid'); + + $uid = getAuthUID(); + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $result = $this->BenutzerModel->loadWhere( + ['uid' => $uid] + ); + + $data = $this->getDataOrTerminateWithError($result); + $benutzer = current($data); + + if (isset($_POST['data'])) + { + $data = json_decode($_POST['data']); + unset($_POST['data']); + foreach ($data as $k => $v) { + $_POST[$k] = $v; + } + } + + $this->load->library('form_validation'); + + $this->form_validation->set_rules('subject', 'Betreff', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Betreff']) + ]); + + $this->form_validation->set_rules('body', 'Text', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $subject = $this->input->post('subject'); + $body = $this->input->post('body'); + $relationmessage_id = $this->input->post('relationmessage_id'); + + $typeId = $this->input->post('type_id'); + $id = $this->input->post('id'); + + if($typeId == 'uid') + { + $prestudent_id = $this-> _getPrestudentIdFromUid($id); + + //parseMessagetext for variables Prestudent + $result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $body); + $bodyParsed = $this->getDataOrTerminateWithError($result); + } + if($typeId == 'mitarbeiter_uid') + { + $person_id = $this->_getPersonId($id, $typeId); + + $result = $this->MessagesModel->parseMessageTextPerson($person_id, $body); + $bodyParsed = $this->getDataOrTerminateWithError($result); + $this->terminateWithError($bodyParsed, self::ERROR_TYPE_GENERAL); + + } + elseif($typeId == 'person_id') + { + $result = $this->MessagesModel->parseMessageTextPerson($id, $body); + $bodyParsed = $this->getDataOrTerminateWithError($result); + } + elseif($typeId == 'prestudent_id') + { + // $this->terminateWithError("prestudent_id ", self::ERROR_TYPE_GENERAL); + + $result = $this->MessagesModel->parseMessageTextPrestudent($id, $body); + $bodyParsed = $this->getDataOrTerminateWithError($result); + } + else + { + $this->terminateWithError("type_id " . $typeId . " not valid", self::ERROR_TYPE_GENERAL); + } + + $result = $this->messagelib->sendMessageUser($receiversPersonId, $subject, $bodyParsed, $benutzer->person_id, null, $relationmessage_id); + + $this->terminateWithSuccess($result); + } + + public function getPreviewText($id, $type_id) + { + if (isset($_POST['data'])) + { + $data = json_decode($_POST['data']); + unset($_POST['data']); + } + else + $this->terminateWithError("Textbody missing ", self::ERROR_TYPE_GENERAL); + + switch($type_id) + { + case 'uid': + $prestudent_id = $this->_getPrestudentIdFromUid($id); + $result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $data); + break; + case 'prestudent_id': + $result = $this->MessagesModel->parseMessageTextPrestudent($id, $data); + break; + case 'person_id': + $result = $this->MessagesModel->parseMessageTextPerson($id, $data); + break; + case 'mitarbeiter_uid': + { + $person_id = $this->_getPersonId($id, $type_id); + $result = $this->MessagesModel->parseMessageTextPerson($person_id, $data); + } + break; + default: + $this->terminateWithError("MESSAGES::getPreviewText logic for type_id " . $type_id . " not defined yet", self::ERROR_TYPE_GENERAL); + break; + } + + $bodyParsed = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($bodyParsed); + } + + public function getReplyData($messageId) + { + //TODO(Manu) validation of messageId: if number + + $this->MessageModel->addSelect('public.tbl_msg_message.*'); + $this->MessageModel->addSelect('r.*'); + $this->MessageModel->addSelect('p.nachname'); + $this->MessageModel->addSelect('p.vorname'); + $this->MessageModel->addJoin('public.tbl_msg_recipient r', 'ON (r.message_id = public.tbl_msg_message.message_id)'); + $this->MessageModel->addJoin('public.tbl_person p', 'ON (p.person_id = public.tbl_msg_message.person_id)'); + + $result = $this->MessageModel->loadWhere( + array('r.message_id' => $messageId) + ); + + $dataMessage = $this->getDataOrTerminateWithError($result); + $prefix = "Re: "; // reply subject prefix + + $subject = $dataMessage[0]->subject; + $body = $dataMessage[0]->body; + + + $replyBody = $this->_getReplyBody($body, $dataMessage[0]->nachname, $dataMessage[0]->vorname, $dataMessage[0]->insertamum); + + $dataMessage[0]->replyBody = $replyBody; + $dataMessage[0]->rest = "Help Manu"; + $dataMessage[0]->replySubject = $prefix . $subject; + + $this->terminateWithSuccess($dataMessage); + } + + public function deleteMessage($messageId) + { + // Start DB transaction + $this->db->trans_begin(); + + $result = $this->MessageModel->deleteMessageRecipient($messageId); + if (isError($result)) { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + + } + + $result = $this->MessageModel->deleteMessageStatus($messageId); + if (isError($result)) { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + $result = $this->MessageModel->deleteMessage($messageId); + if (isError($result)) { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + $this->db->trans_commit(); + + $this->terminateWithSuccess($result); + } + + public function getPersonId($id, $typeId) + { + if ($typeId == 'uid' || $typeId == 'mitarbeiter_uid') + { + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $result = $this->BenutzerModel->loadWhere( + ['uid' => $id] + ); + } + elseif($typeId == 'prestudent_id') + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $result = $this->PrestudentModel->loadWhere( + ['prestudent_id' => $id] + ); + } + + $data = $this->getDataOrTerminateWithError($result); + $person = current($data); + + $this->terminateWithSuccess($person->person_id); + } + + public function getUid($id, $typeId) + { + if (!$typeId) + { + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Type ID']), self::ERROR_TYPE_GENERAL); + } + elseif ($typeId == 'person_id') + { + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $result = $this->BenutzerModel->loadWhere( + ['person_id' => $id] + ); + } + elseif($typeId == 'prestudent_id') + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $result = $this->PrestudentModel->loadWhere( + ['prestudent_id' => $id] + ); + + $data = $this->getDataOrTerminateWithError($result); + $person = current($data); + $person_id = $person->person_id; + + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $result = $this->BenutzerModel->loadWhere( + ['person_id' => $person_id] + ); + } + elseif($typeId == 'uid' || $typeId == 'mitarbeiter_uid') + { + $this->terminateWithSuccess($id); + } + else + { + $this->terminateWithError("MESSAGES::getUID logic for type_id " . $typeId . " not defined yet", self::ERROR_TYPE_GENERAL); + } + + $data = $this->getDataOrTerminateWithError($result); + $benutzer = current($data); + + $this->terminateWithSuccess($benutzer->uid); + } + + private function _getPersonId($id, $typeId) + { + if ($typeId == 'uid' || $typeId == 'mitarbeiter_uid') + { + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $result = $this->BenutzerModel->loadWhere( + ['uid' => $id] + ); + } + elseif($typeId == 'prestudent_id') + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $result = $this->PrestudentModel->loadWhere( + ['prestudent_id' => $id] + ); + } + + $data = $this->getDataOrTerminateWithError($result); + $person = current($data); + + return $person->person_id; + } + + private function _getPrestudentIdFromUid($uid) + { + // $this->terminateWithError($uid, self::ERROR_TYPE_GENERAL); + $this->load->model('crm/Student_model', 'StudentModel'); + $result = $this->StudentModel->loadWhere( + ['student_uid' => $uid] + ); + + $data = $this->getDataOrTerminateWithError($result); + $student = current($data); + // $this->terminateWithError($student->prestudent_id, self::ERROR_TYPE_GENERAL); + return $student->prestudent_id; + } + + private function _getReplyBody($body, $receiverName, $receiverSurname, $sentDate) + { + // To quote a reply body message + $bodyFormat = "
+
+
+ + On %s %s %s wrote: + +
+
+ %s +
"; + return sprintf( + $bodyFormat, + date_format(date_create($sentDate), 'd.m.Y H:i'), $receiverName, $receiverSurname, $body + ); + } +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/stv/Abschlusspruefung.php b/application/controllers/api/frontend/v1/stv/Abschlusspruefung.php index daaf043b5..d8bc067f9 100644 --- a/application/controllers/api/frontend/v1/stv/Abschlusspruefung.php +++ b/application/controllers/api/frontend/v1/stv/Abschlusspruefung.php @@ -20,6 +20,8 @@ class Abschlusspruefung extends FHCAPI_Controller 'getBeurteilungen' => ['admin:rw', 'assistenz:rw'], 'getAkadGrade' => ['admin:rw', 'assistenz:rw'], 'getMitarbeiter' => ['admin:rw', 'assistenz:rw'], + 'getAllMitarbeiter' => ['admin:rw', 'assistenz:rw'], + 'getAllPersons' => ['admin:rw', 'assistenz:rw'], 'getPruefer' => ['admin:rw', 'assistenz:rw'], 'getTypStudiengang' => ['admin:rw', 'assistenz:rw'], 'checkForExistingExams' => ['admin:rw', 'assistenz:rw'], @@ -38,6 +40,51 @@ class Abschlusspruefung extends FHCAPI_Controller // Load models $this->load->model('education/Abschlusspruefung_model', 'AbschlusspruefungModel'); + + + //Permission checks for Studiengangsarray + $allowedStgs = $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []; + + if ($this->router->method == 'insertAbschlusspruefung' || $this->router->method == 'updateAbschlusspruefung') + { + $student_uid = $this->input->post('uid') ?: ($this->input->post('formData')['student_uid'] ?? null); + + if(!$student_uid) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Student UID']), self::ERROR_TYPE_GENERAL); + } + $this->_checkAllowedStgsFromUid($student_uid, $allowedStgs); + } + + if ($this->router->method == 'deleteAbschlusspruefung') + { + $abschlusspruefung_id = $this->input->post('id'); + + if(!$abschlusspruefung_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Abschlusspruefung ID']), self::ERROR_TYPE_GENERAL); + } + $result = $this->AbschlusspruefungModel->load( + array('abschlusspruefung_id' => $abschlusspruefung_id) + ); + $data = $this->getDataOrTerminateWithError($result); + $student_uid = current($data)->student_uid; + + $this->_checkAllowedStgsFromUid($student_uid, $allowedStgs); + } + } + + private function _checkAllowedStgsFromUid($student_uid, $allowedStgs) + { + $this->load->model('crm/Student_model', 'StudentModel'); + $result = $this->StudentModel->loadWhere(['student_uid' => $student_uid]); + $data = $this->getDataOrTerminateWithError($result); + $studiengang_kz = current($data)->studiengang_kz; + + if (!in_array($studiengang_kz, $allowedStgs)) + { + return $this->terminateWithError($this->p->t('ui', 'error_keineBerechtigungStg'), self::ERROR_TYPE_GENERAL); + } } public function getAbschlusspruefung($student_uid) @@ -149,16 +196,16 @@ class Abschlusspruefung extends FHCAPI_Controller { $studiengang_kz= $this->input->post('studiengang_kz'); -/* if (!$studiengang_kzs || !is_array($studiengang_kzs)) { - $this->load->library('form_validation'); + /* 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') - ]); + $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 (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + }*/ $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); @@ -224,19 +271,7 @@ class Abschlusspruefung extends FHCAPI_Controller $formData = $this->input->post('formData'); - $_POST['pruefungstyp_kurzbz'] = $formData['pruefungstyp_kurzbz']; - $_POST['akadgrad_id']= $formData['akadgrad_id']; - $_POST['vorsitz'] = isset($formData['vorsitz']['mitarbeiter_uid']) ? $formData['vorsitz']['mitarbeiter_uid'] : $formData['vorsitz']; - $_POST['pruefer1'] = isset($formData['pruefer1']['person_id']) ? $formData['pruefer1']['person_id'] : $formData['pruefer1']; - $_POST['pruefer2'] = isset($formData['pruefer2']['person_id']) ? $formData['pruefer2']['person_id'] : $formData['pruefer2']; - $_POST['pruefer3'] = isset($formData['pruefer3']['person_id']) ? $formData['pruefer3']['person_id'] : $formData['pruefer3']; - $_POST['pruefungsantritt_kurzbz'] = $formData['pruefungsantritt_kurzbz']; - $_POST['abschlussbeurteilung_kurzbz'] = $formData['abschlussbeurteilung_kurzbz']; - $_POST['datum']= $formData['datum']; - $_POST['sponsion']= $formData['sponsion']; - $_POST['anmerkung'] = $formData['anmerkung']; - $_POST['protokoll']= $formData['protokoll']; - $_POST['note'] = $formData['note']; + $this->form_validation->set_data($formData); $this->form_validation->set_rules('pruefungstyp_kurzbz', 'Typ', 'required', [ 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Typ']) @@ -261,19 +296,19 @@ class Abschlusspruefung extends FHCAPI_Controller $result = $this->AbschlusspruefungModel->insert([ 'student_uid' => $student_uid, - 'pruefungstyp_kurzbz' => $this->input->post('pruefungstyp_kurzbz'), - 'akadgrad_id' => $this->input->post('akadgrad_id'), - 'vorsitz' => $this->input->post('vorsitz'), - 'pruefungsantritt_kurzbz' => $this->input->post('pruefungsantritt_kurzbz'), - 'abschlussbeurteilung_kurzbz' => $this->input->post('abschlussbeurteilung_kurzbz'), - 'datum' => $this->input->post('datum'), //TODO(Manu) check if minute format like FAS - 'sponsion' => $this->input->post('sponsion'), - 'pruefer1' => $this->input->post('pruefer1'), - 'pruefer2' => $this->input->post('pruefer2'), - 'pruefer3' => $this->input->post('pruefer3'), - 'protokoll' => $this->input->post('protokoll'), - 'note' => $this->input->post('note'), - 'anmerkung' => $this->input->post('anmerkung'), + 'pruefungstyp_kurzbz' => $formData['pruefungstyp_kurzbz'], + 'akadgrad_id' => $formData['akadgrad_id'], + 'vorsitz' => $formData['vorsitz'], + 'pruefungsantritt_kurzbz' => $formData['pruefungsantritt_kurzbz'], + 'abschlussbeurteilung_kurzbz' => $formData['abschlussbeurteilung_kurzbz'], + 'datum' => $formData['datum'], //TODO(Manu) check if minute format like FAS + 'sponsion' => $formData['sponsion'], + 'pruefer1' => $formData['pruefer1'], + 'pruefer2' => $formData['pruefer2'], + 'pruefer3' => $formData['pruefer3'], + 'protokoll' => $formData['protokoll'], + 'note' => $formData['note'], + 'anmerkung' => $formData['anmerkung'], 'insertamum' => date('c'), 'insertvon' => getAuthUID() ]); @@ -295,25 +330,17 @@ class Abschlusspruefung extends FHCAPI_Controller } $formData = $this->input->post('formData'); - $_POST['student_uid'] = $formData['student_uid']; - $_POST['pruefungstyp_kurzbz'] = $formData['pruefungstyp_kurzbz']; - $_POST['akadgrad_id']= $formData['akadgrad_id']; - $_POST['vorsitz'] = isset($formData['vorsitz']['mitarbeiter_uid']) ? $formData['vorsitz']['mitarbeiter_uid'] : $formData['vorsitz']; - $_POST['pruefer1'] = isset($formData['pruefer1']['person_id']) ? $formData['pruefer1']['person_id'] : $formData['pruefer1']; - $_POST['pruefer2'] = isset($formData['pruefer2']['person_id']) ? $formData['pruefer2']['person_id'] : $formData['pruefer2']; - $_POST['pruefer3'] = isset($formData['pruefer3']['person_id']) ? $formData['pruefer3']['person_id'] : $formData['pruefer3']; - $_POST['pruefungsantritt_kurzbz'] = $formData['pruefungsantritt_kurzbz']; - $_POST['abschlussbeurteilung_kurzbz'] = $formData['abschlussbeurteilung_kurzbz']; - $_POST['datum']= $formData['datum']; - $_POST['sponsion']= $formData['sponsion']; - $_POST['anmerkung'] = $formData['anmerkung']; - $_POST['protokoll']= $formData['protokoll']; - $_POST['note'] = $formData['note']; + $vorsitz = isset($formData['vorsitz']['mitarbeiter_uid']) ? $formData['vorsitz']['mitarbeiter_uid'] : $formData['vorsitz']; + $pruefer1 = isset($formData['pruefer1']['person_id']) ? $formData['pruefer1']['person_id'] : $formData['pruefer1']; + $pruefer2 = isset($formData['pruefer2']['person_id']) ? $formData['pruefer2']['person_id'] : $formData['pruefer2']; + $pruefer3 = isset($formData['pruefer3']['person_id']) ? $formData['pruefer3']['person_id'] : $formData['pruefer3']; + + $this->form_validation->set_data($formData); $this->form_validation->set_rules('pruefungstyp_kurzbz', 'Typ', 'required', [ 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Typ']) ]); - + $this->form_validation->set_rules('akadgrad_id', 'AkadGrad', 'required', [ 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'AkadGrad']) ]); @@ -334,25 +361,25 @@ class Abschlusspruefung extends FHCAPI_Controller $result = $this->AbschlusspruefungModel->update( [ - 'abschlusspruefung_id' => $abschlusspruefung_id + 'abschlusspruefung_id' => $abschlusspruefung_id ], [ - 'student_uid' => $this->input->post('student_uid'), - 'pruefungstyp_kurzbz' => $this->input->post('pruefungstyp_kurzbz'), - 'akadgrad_id' => $this->input->post('akadgrad_id'), - 'vorsitz' => $this->input->post('vorsitz'), - 'pruefungsantritt_kurzbz' => $this->input->post('pruefungsantritt_kurzbz'), - 'abschlussbeurteilung_kurzbz' => $this->input->post('abschlussbeurteilung_kurzbz'), - 'datum' => $this->input->post('datum'), - 'sponsion' => $this->input->post('sponsion'), - 'pruefer1' => $this->input->post('pruefer1'), - 'pruefer2' => $this->input->post('pruefer2'), - 'pruefer3' => $this->input->post('pruefer3'), - 'protokoll' => $this->input->post('protokoll'), - 'note' => $this->input->post('note'), - 'anmerkung' => $this->input->post('anmerkung'), - 'insertamum' => date('c'), - 'insertvon' => getAuthUID() + 'student_uid' => $formData['student_uid'], + 'pruefungstyp_kurzbz' => $formData['pruefungstyp_kurzbz'], + 'akadgrad_id' => $formData['akadgrad_id'], + 'vorsitz' => $vorsitz, + 'pruefungsantritt_kurzbz' => $formData['pruefungsantritt_kurzbz'], + 'abschlussbeurteilung_kurzbz' => $formData['abschlussbeurteilung_kurzbz'], + 'datum' => $formData['datum'], + 'sponsion' => $formData['sponsion'], + 'pruefer1' => $pruefer1, + 'pruefer2' => $pruefer2, + 'pruefer3' => $pruefer3, + 'protokoll' => $formData['protokoll'], + 'note' => $formData['note'], + 'anmerkung' => $formData['anmerkung'], + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() ] ); @@ -417,4 +444,58 @@ class Abschlusspruefung extends FHCAPI_Controller } $this->terminateWithSuccess('step3'); } + + /* + * returns list of all Mitarbeiter + * as key value list to be used in select or autocomplete + */ + public function getAllMitarbeiter() + { + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); + + $sql = " + SELECT + ma.mitarbeiter_uid as mitarbeiter_uid, + CONCAT(p.nachname, ' ', p.vorname, ' (', ma.mitarbeiter_uid, ')') as label + FROM + public.tbl_mitarbeiter ma + JOIN public.tbl_benutzer bn ON (bn.uid = ma.mitarbeiter_uid) + JOIN public.tbl_person p ON (p.person_id = bn.person_id) + ORDER BY + p.nachname ASC + "; + + $result = $this->MitarbeiterModel->execReadOnlyQuery($sql); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /* + * returns list of all Persons + * as key value list to be used in select or autocomplete + */ + public function getAllPersons() + { + $this->load->model('person/Person_model', 'PersonModel'); + + $sql = " + SELECT + p.vorname, p.nachname, p.person_id, + CONCAT(p.nachname, ' ', p.vorname) as label + FROM + public.tbl_person p + -- JOIN public.tbl_benutzer bn ON (p.person_id = bn.person_id) + -- and bn.aktiv = 'true' + ORDER BY + p.nachname ASC + "; + + //TODO(manu) check if filter active benutzer + + $result = $this->PersonModel->execReadOnlyQuery($sql); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } } diff --git a/application/controllers/api/frontend/v1/stv/Address.php b/application/controllers/api/frontend/v1/stv/Address.php index 324e306f3..d14111e99 100644 --- a/application/controllers/api/frontend/v1/stv/Address.php +++ b/application/controllers/api/frontend/v1/stv/Address.php @@ -31,6 +31,11 @@ class Address extends FHCAPI_Controller 'getNations' => self::PERM_LOGGED, 'getPlaces' => self::PERM_LOGGED ]); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); } public function getNations() @@ -53,7 +58,11 @@ class Address extends FHCAPI_Controller $this->form_validation->set_data(['address.plz' => $plz]); - $this->form_validation->set_rules('address.plz', 'PLZ', 'required|numeric|less_than[10000]'); + $this->form_validation->set_rules('address.plz', 'PLZ', 'required|numeric|less_than[10000]', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'PLZ']), + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'PLZ']), + 'less_than' => $this->p->t('ui', 'error_fieldLessThan10000', ['field' => 'PLZ']) + ]); if (!$this->form_validation->run()) $this->terminateWithValidationErrors($this->form_validation->error_array()); diff --git a/application/controllers/api/frontend/v1/stv/Akte.php b/application/controllers/api/frontend/v1/stv/Akte.php new file mode 100644 index 000000000..1d38c96d4 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Akte.php @@ -0,0 +1,70 @@ +. + */ + +if (!defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * Controller for downloading Akte + */ +class Akte extends Auth_Controller +{ + /** + * Calls the parent's constructor and prepares libraries and phrases + */ + public function __construct() + { + parent::__construct([ + 'download' => ['admin:w', 'assistenz:w'], + ]); + + // Load models + $this->load->model('crm/Akte_model', 'AkteModel'); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * + * Downloads an Akte + */ + public function download() + { + $akte_id = $this->input->get('akte_id'); + + if (!is_numeric($akte_id)) $this->terminateWithError('akte Id missing'); + + $result = $this->AkteModel->load($akte_id); + + if (!hasData($result)) $this->terminateWithError('Akte not found'); + + $data = getData($result)[0]; + + if (isset($data->inhalt) && $data->inhalt != '') + { + header('Content-Description: File Transfer'); + header('Content-Type: '. $data->mimetype); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Disposition: attachment; filename="'.$data->titel.'"'); + echo base64_decode($data->inhalt); + die(); + } + } +} diff --git a/application/controllers/api/frontend/v1/stv/Anrechnungen.php b/application/controllers/api/frontend/v1/stv/Anrechnungen.php new file mode 100644 index 000000000..251e2d5bd --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Anrechnungen.php @@ -0,0 +1,256 @@ + ['admin:r', 'assistenz:r'], + 'deleteAnrechnung' => ['admin:rw', 'assistenz:rw'], + 'getLehrveranstaltungen' => ['admin:r', 'assistenz:r'], + 'getBegruendungen' => ['admin:r', 'assistenz:r'], + 'getLektoren' => ['admin:r', 'assistenz:r'], + 'getLvsKompatibel' => ['admin:r', 'assistenz:r'], + 'insertAnrechnung' => ['admin:rw', 'assistenz:rw'], + 'loadAnrechnung' => ['admin:rw', 'assistenz:rw'], + 'updateAnrechnung' => ['admin:rw', 'assistenz:rw'], + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + // Load language phrases + $this->loadPhrases([ + 'ui', 'lehre' + ]); + + // Load models + $this->load->model('education/Anrechnung_model', 'AnrechnungsModel'); + } + + public function getAnrechnungen($prestudent_id) + { + $result = $this->AnrechnungsModel->getAnrechnungsData($prestudent_id); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getBegruendungen() + { + $this->load->model('education/Anrechnungbegruendung_model', 'AnrechnungbegrueundungsModel'); + + $result = $this->AnrechnungbegrueundungsModel->load(); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getLehrveranstaltungen($prestudent_id) + { + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + $result = $this->PrestudentstatusModel->getLastStatus($prestudent_id); + + $data = $this->getDataOrTerminateWithError($result); + $studienplan_id = current($data)->studienplan_id; + + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $result = $this->LehrveranstaltungModel->getLvsByStudienplanId($studienplan_id); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getLvsKompatibel($lehrveranstaltung_id) + { + $this->AnrechnungsModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'ON (lv.lehrveranstaltung_id = lehre.tbl_anrechnung.lehrveranstaltung_id)'); + $result = $this->AnrechnungsModel->loadWhere( + ['lehrveranstaltung_id_kompatibel' => $lehrveranstaltung_id] + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getLektoren($studiengang_kz) + { + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); + + $result = $this->MitarbeiterModel->getLektoren($studiengang_kz); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function insertAnrechnung() + { + $this->load->library('form_validation'); + + $prestudent_id = $this->input->post('prestudent_id'); + + if(!$prestudent_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Student UID']), self::ERROR_TYPE_GENERAL); + } + + $formData = $this->input->post('formData'); + $_POST['lehrveranstaltung_id'] = + (isset($formData['lehrveranstaltung_id']) && !empty($formData['lehrveranstaltung_id'])) + ? $formData['lehrveranstaltung_id'] + : null; + $_POST['lehrveranstaltung_id_kompatibel'] = + (isset($formData['lehrveranstaltung_id_kompatibel']) && !empty($formData['lehrveranstaltung_id_kompatibel'])) + ? $formData['lehrveranstaltung_id_kompatibel'] + : null; + $_POST['begruendung'] = + (isset($formData['begruendung_id']) && !empty($formData['begruendung_id'])) + ? $formData['begruendung_id'] + : null; + $_POST['genehmigtVon'] = (isset($formData['genehmigt_von']) && !empty($formData['genehmigt_von'])) + ? $formData['genehmigt_von'] + : null; + + $this->form_validation->set_rules('lehrveranstaltung_id', 'Lehrveranstaltung_id', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung']) + ]); + + $this->form_validation->set_rules('begruendung', 'Begruendung', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Begruendung']) + ]); + + if($_POST['begruendung'] == 2) + { + $this->form_validation->set_rules('lehrveranstaltung_id_kompatibel', 'Lehrveranstaltung_id', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung Kompatibel']) + ]); + } + + $this->form_validation->set_rules('genehmigtVon', 'GenehmigtVon', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'GenehmigtVon']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $result = $this->AnrechnungsModel->insert( + [ + 'prestudent_id' => $prestudent_id, + 'lehrveranstaltung_id' => $_POST['lehrveranstaltung_id'], + 'lehrveranstaltung_id_kompatibel' => $_POST['lehrveranstaltung_id_kompatibel'], + 'begruendung_id' => $_POST['begruendung'], + 'genehmigt_von' => $_POST['genehmigtVon'] + ] + ); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function loadAnrechnung($anrechnung_id) + { + $this->AnrechnungsModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'ON (lv.lehrveranstaltung_id = lehre.tbl_anrechnung.lehrveranstaltung_id)'); + $result = $this->AnrechnungsModel->loadWhere( + array('anrechnung_id' => $anrechnung_id) + ); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } + + public function updateAnrechnung() + { + $this->load->library('form_validation'); + + $anrechnung_id = $this->input->post('anrechnung_id'); + + if(!$anrechnung_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Anrechnung UID']), self::ERROR_TYPE_GENERAL); + } + + $formData = $this->input->post('formData'); + $_POST['lehrveranstaltung_id'] = + (isset($formData['lehrveranstaltung_id']) && !empty($formData['lehrveranstaltung_id'])) + ? $formData['lehrveranstaltung_id'] + : null; + $_POST['lehrveranstaltung_id_kompatibel'] = + (isset($formData['lehrveranstaltung_id_kompatibel']) && !empty($formData['lehrveranstaltung_id_kompatibel'])) + ? $formData['lehrveranstaltung_id_kompatibel'] + : null; + $_POST['begruendung'] = (isset($formData['begruendung_id']) && !empty($formData['begruendung_id'])) ? $formData['begruendung_id'] : null; + $_POST['genehmigtVon'] = (isset($formData['genehmigt_von']) && !empty($formData['genehmigt_von'])) ? $formData['genehmigt_von'] : null; + + $this->form_validation->set_rules('lehrveranstaltung_id', 'Lehrveranstaltung_id', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung']) + ]); + + $this->form_validation->set_rules('begruendung', 'Begruendung', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Begruendung']) + ]); + + if($_POST['begruendung'] == 2) + { + $this->form_validation->set_rules('lehrveranstaltung_id_kompatibel', 'Lehrveranstaltung_id', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung Kompatibel']) + ]); + } + + $this->form_validation->set_rules('genehmigtVon', 'GenehmigtVon', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'GenehmigtVon']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $result = $this->AnrechnungsModel->update( + [ + 'anrechnung_id' => $anrechnung_id, + ], + [ + + 'lehrveranstaltung_id' => $_POST['lehrveranstaltung_id'], + 'lehrveranstaltung_id_kompatibel' => $_POST['lehrveranstaltung_id_kompatibel'], + 'begruendung_id' => $_POST['begruendung'], + 'genehmigt_von' => $_POST['genehmigtVon'] + ] + ); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function deleteAnrechnung($anrechnung_id) + { + // Start DB transaction + $this->db->trans_begin(); + + //delete anrechnung_id of table tbl_anrechnung_anrechnungstatus + $this->load->model('education/Anrechnunganrechnungstatus_model','AnrechnungAnrechnungstatusModel'); + $result = $this->AnrechnungAnrechnungstatusModel->delete( + array('anrechnung_id' => $anrechnung_id) + ); + $this->getDataOrTerminateWithError($result); + + //delete anrechnung_id of table tbl_anrechnung + $result = $this->AnrechnungsModel->delete( + array('anrechnung_id' => $anrechnung_id) + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->db->trans_commit(); + + $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Archiv.php b/application/controllers/api/frontend/v1/stv/Archiv.php new file mode 100644 index 000000000..91fc9643d --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Archiv.php @@ -0,0 +1,272 @@ +. + */ + +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 archive documents + * Listens to ajax post calls to change the archive documents + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Archiv extends FHCAPI_Controller +{ + /** + * Calls the parent's constructor and prepares libraries and phrases + */ + public function __construct() + { + parent::__construct([ + 'get' => ['admin:r', 'assistenz:r'], + 'getArchivVorlagen' => ['admin:r', 'assistenz:r'], + 'archive' => ['admin:w', 'assistenz:w'], + 'download' => ['admin:w', 'assistenz:w'], + 'update' => ['admin:w'], + 'delete' => ['admin:w', 'assistenz:w'] + ]); + + // Load models + $this->load->model('crm/Akte_model', 'AkteModel'); + $this->load->model('system/Vorlage_model', 'VorlageModel'); + + // Load language phrases + $this->loadPhrases([ + 'archiv' + ]); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Get archive documents for a person + + * @return void + */ + public function get() + { + $person_id = $this->input->post('person_id'); + + $this->load->library('form_validation'); + + 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()); + } + + $result = $this->AkteModel->getArchiv($person_id); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * Get Vorlagen for archiving documents + * @return void + */ + public function getArchivVorlagen() + { + $result = $this->VorlageModel->getArchivVorlagen(); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * + * @param + * @return object success or error + */ + public function download() + { + $akte_id = $this->input->get('akte_id'); + + if (!is_numeric($akte_id)) $this->terminateWithError('akte Id missing'); + + $result = $this->AkteModel->load($akte_id); + + + if (!hasData($result)) $this->terminateWithError('Akte not found'); + + $data = $this->getDataOrTerminateWithError($result); + + $data = getData($result)[0]; + //$this->addMeta("daa", $data->inhalt); + + $fileObj = new stdClass(); + if (isset($data->inhalt) && $data->inhalt != '') + { + // Define handle to output stream + $tmpFilePointer = fopen("php://output", 'w'); + $meta_data = stream_get_meta_data($tmpFilePointer); + $filename = $meta_data["uri"]; + fwrite($tmpFilePointer, $data->inhalt); + + header('Content-Description: File Transfer'); + header('Content-Type: '. $data->mimetype); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + //header('Content-Length: ' . filesize($fileObj->file)); + //header("Content-type: $data->mimetype"); + header('Content-Disposition: attachment; filename="'.$data->titel.'"'); + readfile($filename); + //echo base64_decode($data->inhalt); + die(); + //~ $fileObj->file = $data->inhalt; + //~ $fileObj->name = $data->titel; + //~ $fileObj->mimetype = $data->mimetype; + //~ $fileObj->disposition = 'attachment'; + } + else + { + $this->load->library('AkteLib'); + + $result = $this->aktelib->get($akte_id); + } + + /* $fileObj->filename + * $fileObj->file + * $fileObj->name + * $fileObj->mimetype + * $fileObj->disposition*/ + } + + /** + * Updating an Akte + * @return void + */ + public function update() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('akte_id', 'Akte Id', 'required'); + $this->form_validation->set_rules('signiert', 'Signiert', 'is_bool'); + $this->form_validation->set_rules('stud_selfservice', 'Self-Service', 'is_bool'); + + //Events::trigger('konto_update_validation', $this->form_validation); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $id = $this->input->post('akte_id'); + + // get the akte + $result = $this->AkteModel->load($id); + + if (!hasData($result)) $this->terminateWithError("Akte not found!"); + + $akte = getData($result)[0]; + + $allowed = [ + 'signiert', + 'stud_selfservice' + ]; + + $data = [ + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ]; + + // if Akte has Inhalt directly in Akte table + if (isset($_FILES['datei']['tmp_name'])) + { + $this->addMeta('read', "read"); + // update inhalt directly + + // get tmp file + $filename = $_FILES['datei']['tmp_name']; + // open it + $fp = fopen($filename,'r'); + // read it + $content = fread($fp, filesize($filename)); + fclose($fp); + // encode it + $data['inhalt'] = base64_encode($content); + $this->addMeta('content', base64_encode($content)); + } + + + foreach ($allowed as $field) + if ($this->input->post($field) !== null) + $data[$field] = $this->input->post($field); + + $this->addMeta("data", $data); + + $result = $this->AkteModel->update($id, $data); + + $this->getDataOrTerminateWithError($result); + + $result = null; + + $this->terminateWithSuccess($result); + } + + + /** + * Delete archived Akte + * + * @return void + */ + public function delete() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('akte_id', 'Akte ID', 'required'); + $this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'has_permissions_for_stg[admin:rw,assistenz:rw]'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $akte_id = $this->input->post('akte_id'); + + $result = $this->AkteModel->load($akte_id); + + if (!hasData($result)) + { + $this->terminateWithError($this->p->t('archiv', 'error_missing', [ + 'akte_id' => $akte_id + ])); + } + + $result = getData($result)[0]; + + if ($result->dokument_kurzbz == 'Ausbvert' + && isset($result->akzeptiertamum) + && !isEmptyString($result->akzeptiertamum) + && !has_permissions_for_stg($this->input->post('studiengang_kz'), 'admin:rw') + ) + { + $this->terminateWithError($this->p->t('archiv', 'nur_admins_loschen_ausbildungsvertraege', [ + 'akte_id' => $akte_id + ])); + } + + $result = $this->AkteModel->delete($akte_id); + if (isError($result)) $this->terminateWithError(getError($result)); + + $this->terminateWithSuccess(); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php b/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php new file mode 100644 index 000000000..86b739c90 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php @@ -0,0 +1,413 @@ + ['admin:r', 'assistenz:r'], + 'loadAufnahmetermin' => ['admin:r', 'assistenz:r'], + 'insertAufnahmetermin' => ['admin:rw', 'assistenz:rw'], + 'updateAufnahmetermin' => ['admin:rw', 'assistenz:rw'], + 'deleteAufnahmetermin' => ['admin:rw', 'assistenz:rw'], + 'getListPlacementTests' => ['admin:r', 'assistenz:r'], + 'getListStudyPlans' => ['admin:r', 'assistenz:r'], + 'loadDataRtPrestudent' => ['admin:r', 'assistenz:r'], + 'insertOrUpdateDataRtPrestudent' => ['admin:r', 'assistenz:r'], + 'loadAufnahmegruppen' => ['admin:r', 'assistenz:r'], + 'getResultReihungstest' => ['admin:r', 'assistenz:r'], + 'getZukuenftigeReihungstestStg' => ['admin:r', 'assistenz:r'], + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('form_validation'); + + // Load language phrases + $this->loadPhrases([ + 'ui', + 'admission' + ]); + + // Load models + $this->load->model('crm/Reihungstest_model', 'ReihungstestModel'); + $this->load->model('crm/RtPerson_model', 'RtPersonModel'); + } + + public function getAufnahmetermine($person_id) + { + $result = $this->ReihungstestModel->getReihungstestPerson($person_id); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function insertAufnahmetermin() + { + $this->load->library('form_validation'); + $authUID = getAuthUID(); + + $formData = $this->input->post('formData'); + $person_id = $this->input->post('person_id'); + + if(!$person_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person ID']), self::ERROR_TYPE_GENERAL); + } + + + $rt_id = (isset($formData['rt_id']) && !empty($formData['rt_id'])) ? $formData['rt_id'] : null; + $anmeldedatum = (isset($formData['anmeldedatum']) && !empty($formData['anmeldedatum'])) ? $formData['anmeldedatum'] : null; + $teilgenommen = (isset($formData['teilgenommen']) && !empty($formData['teilgenommen'])) ? $formData['teilgenommen'] : false; + $studienplan_id = (isset($formData['studienplan_id']) && !empty($formData['studienplan_id'])) ? $formData['studienplan_id'] : null; + $punkte = (isset($formData['punkte']) && !empty($formData['punkte'])) ? $formData['punkte'] : null; + + //validation if there is already an RT with chosen data existing + $result = $this->RtPersonModel->loadWhere( + array( + 'rt_id' => $rt_id, + 'person_id' => $person_id, + 'studienplan_id' => $studienplan_id, + ) + ); + $data = getData($result); + if($data) + return $this->terminateWithError("Error", self::ERROR_TYPE_GENERAL); + + $this->form_validation->set_data($formData); + + $this->form_validation->set_rules('punkte', 'Punkte', 'numeric', [ + 'required' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Punkte']) + ]); + $this->form_validation->set_rules('studienplan_id', 'studienplan_id', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Studienplan']) + ]); + $this->form_validation->set_rules('rt_id', 'Reihungstest_id', 'required', [ + 'is_valid_date' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Reihungstest']) + ]); + $this->form_validation->set_rules('anmeldedatum', 'AnmeldeDatum', 'is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Anmeldedatum']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $result = $this->RtPersonModel->insert([ + 'person_id' => $person_id, + 'rt_id' => $rt_id, + 'anmeldedatum' => $anmeldedatum, + 'teilgenommen' => $teilgenommen, + 'studienplan_id' => $studienplan_id, + 'punkte' => $punkte, + 'insertamum' => date('c'), + 'insertvon' => $authUID, + ]); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function loadAufnahmetermin($rt_person_id) + { + $result = $this->RtPersonModel->loadWhere( + array('rt_person_id' => $rt_person_id) + ); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } + + public function updateAufnahmetermin() + { + $this->load->library('form_validation'); + $authUID = getAuthUID(); + + $formData = $this->input->post('formData'); + $rt_person_id = $this->input->post('rt_person_id'); + $person_id = (isset($formData['person_id']) && !empty($formData['person_id'])) ? $formData['person_id'] : null; + + + if(!$person_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person ID']), self::ERROR_TYPE_GENERAL); + } + if(!$rt_person_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'RT_Person ID']), self::ERROR_TYPE_GENERAL); + } + + $rt_id = (isset($formData['rt_id']) && !empty($formData['rt_id'])) ? $formData['rt_id'] : null; + $anmeldedatum = (isset($formData['anmeldedatum']) && !empty($formData['anmeldedatum'])) ? $formData['anmeldedatum'] : null; + $teilgenommen = (isset($formData['teilgenommen']) && !empty($formData['teilgenommen'])) ? $formData['teilgenommen'] : false; + $studienplan_id = (isset($formData['studienplan_id']) && !empty($formData['studienplan_id'])) ? $formData['studienplan_id'] : null; + $punkte = (isset($formData['punkte']) && !empty($formData['punkte'])) ? $formData['punkte'] : null; + + $this->form_validation->set_data($formData); + + $this->form_validation->set_rules('punkte', 'Punkte', 'numeric', [ + 'required' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Punkte']) + ]); + $this->form_validation->set_rules('studienplan_id', 'studienplan_id', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Studienplan']) + ]); + $this->form_validation->set_rules('rt_id', 'Reihungstest_id', 'required', [ + 'is_valid_date' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Reihungstest']) + ]); + + $this->form_validation->set_rules('anmeldedatum', 'AnmeldeDatum', 'is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Anmeldedatum']) + ]); + + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $result = $this->RtPersonModel->update( + [ + 'rt_person_id' => $rt_person_id, + ], + [ + 'rt_id' => $rt_id, + 'anmeldedatum' => $anmeldedatum, + 'teilgenommen' => $teilgenommen, + 'studienplan_id' => $studienplan_id, + 'punkte' => $punkte, + 'insertamum' => date('c'), + 'insertvon' => $authUID, + ] + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function deleteAufnahmetermin($rt_person_id) + { + $result = $this->RtPersonModel->delete( + array('rt_person_id' => $rt_person_id) + ); + + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + public function getListPlacementTests($prestudent_id) + { + if(!$prestudent_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + } + + //get studienplan array + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + + $this->PrestudentstatusModel->addSelect('*'); + $this->PrestudentstatusModel->addSelect('sp.studienplan_id'); + + $this->PrestudentstatusModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT'); + + $result = $this->PrestudentstatusModel->loadWhere( + array( + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => 'Interessent' + ) + ); + + $data = $this->getDataOrTerminateWithError($result); + + $studienplan_arr = []; + $include_ids = []; + foreach ($data as $item) + { + if($item->studienplan_id != null) + $studienplan_arr[] = $item->studienplan_id; + } + + //get Placementtests Person + $person_id = $this->_getPersonId($prestudent_id); + $resultRt = $this->ReihungstestModel->getReihungstestPerson($person_id); + + $dataRt = $this->getDataOrTerminateWithError($resultRt); + + foreach ($dataRt as $item) + { + if(!in_array($item->studienplan_id, $studienplan_arr)) + $studienplan_arr[] = $item->studienplan_id; + if(!in_array($item->rt_id, $include_ids) && ($item->rt_id != null)) + $include_ids[] = $item->rt_id; + } + + $result = $this->ReihungstestModel->getReihungstestByStudyPlanAndIds($studienplan_arr, $include_ids); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getListStudyPlans($person_id) + { + $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + + $result = $this->StudienplanModel->getStudienplaeneForPerson($person_id); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function loadDataRtPrestudent($prestudent_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $this->PrestudentModel->addSelect(["reihungstestangetreten"]); + $this->PrestudentModel->addSelect(["rt_gesamtpunkte"]); + $this->PrestudentModel->addSelect(["aufnahmegruppe_kurzbz"]); + $result = $this->PrestudentModel->loadWhere( + array('prestudent_id' => $prestudent_id) + ); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } + + public function insertOrUpdateDataRtPrestudent() + { + $this->load->library('form_validation'); + $authUID = getAuthUID(); + + $formData = $this->input->post('formData'); + $prestudent_id = $this->input->post('prestudent_id'); + + if(!$prestudent_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + } + $rt_gesamtpunkte = + (isset($formData['rt_gesamtpunkte']) && !empty($formData['rt_gesamtpunkte'])) + ? $formData['rt_gesamtpunkte'] + : null; + $reihungstestangetreten = + (isset($formData['reihungstestangetreten']) && !empty($formData['reihungstestangetreten'])) + ? $formData['reihungstestangetreten'] + : null; + $aufnahmegruppe_kurzbz = + (isset($formData['aufnahmegruppe_kurzbz']) && !empty($formData['aufnahmegruppe_kurzbz'])) + ? $formData['aufnahmegruppe_kurzbz'] + : null; + + $this->form_validation->set_data($formData); + + $this->form_validation->set_rules('rt_gesamtpunkte', 'Rt_gesamtpunkte', 'numeric', [ + 'required' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Rt_gesamtpunkte']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $result = $this->PrestudentModel->update( + [ + 'prestudent_id' => $prestudent_id, + ], + [ + 'reihungstestangetreten' => $reihungstestangetreten, + 'rt_gesamtpunkte' => $rt_gesamtpunkte, + 'aufnahmegruppe_kurzbz' => $aufnahmegruppe_kurzbz, + 'updateamum' => date('c'), + 'updatevon' => $authUID, + ] + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function loadAufnahmegruppen() + { + $uid = $this->input->get('uid'); + $studiensemester_kurzbz = $this->input->get('studiensemester_kurzbz'); + + $this->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel'); + + $result = $this->BenutzergruppeModel->loadAufnahmegruppen($uid, $studiensemester_kurzbz); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(($data)); + } + + public function getResultReihungstest() + { + $person_id = $this->input->get('person_id'); + $punkte = $this->input->get('punkte'); + $reihungstest_id = $this->input->get('reihungstest_id'); + + if(!$reihungstest_id) + { + $this->terminateWithSuccess(null); + } + + //for gewichtung + $studiengang_kz = $this->input->get('studiengang_kz'); + + $this->load->model('testtool/Ablauf_model', 'AblaufModel'); + $result = $this->AblaufModel->getAblaufGebieteAndGewichte($studiengang_kz); + $data = $this->getDataOrTerminateWithError($result); + + $weightedArray = []; + foreach ($data as $abl) + { + $weightedArray[$abl->gebiet_id] = $abl->gewicht; + } + + $result = $this->ReihungstestModel->getReihungstestErgebnisPerson($person_id, $punkte, $reihungstest_id, $weightedArray); + +/* if (isError($result)) + { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + }*/ + + $this->terminateWithSuccess($result); + } + + public function getZukuenftigeReihungstestStg() + { + $studiengang_kz = $this->input->get('studiengang_kz'); + if(!$studiengang_kz) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Studiengang_kz']), self::ERROR_TYPE_GENERAL); + } + + $result = $this->ReihungstestModel->getZukuenftigeReihungstestStg($studiengang_kz); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + private function _getPersonId($prestudent_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $result = $this->PrestudentModel->loadWhere( + ['prestudent_id' => $prestudent_id] + ); + + $data = $this->getDataOrTerminateWithError($result); + $person = current($data); + + return $person->person_id; + } +} diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index 42de1b02f..adf9f729e 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -83,6 +83,10 @@ class Config extends FHCAPI_Controller 'title' => 'Status', 'component' => './Stv/Studentenverwaltung/Details/MultiStatus.js' ]; + $result['documents'] = [ + 'title' => $this->p->t('stv', 'tab_documents'), + 'component' => './Stv/Studentenverwaltung/Details/Dokumente.js' + ]; $result['banking'] = [ 'title' => $this->p->t('stv', 'tab_banking'), 'component' => './Stv/Studentenverwaltung/Details/Konto.js', @@ -99,6 +103,15 @@ class Config extends FHCAPI_Controller 'title' => $this->p->t('stv', 'tab_resources'), 'component' => './Stv/Studentenverwaltung/Details/Betriebsmittel.js' ]; + $result['groups'] = [ + 'title' => $this->p->t('stv', 'tab_groups'), + 'component' => './Stv/Studentenverwaltung/Details/Gruppen.js' + ]; + $result['messages'] = [ + 'title' => $this->p->t('stv', 'tab_messages'), + 'component' => './Stv/Studentenverwaltung/Details/Messages.js' + ]; + $result['grades'] = [ 'title' => $this->p->t('stv', 'tab_grades'), 'component' => './Stv/Studentenverwaltung/Details/Noten.js', @@ -117,6 +130,12 @@ class Config extends FHCAPI_Controller 'component' => './Stv/Studentenverwaltung/Details/Pruefung.js' ]; + $result['exemptions'] = [ + 'title' => $this->p->t('lehre', 'anrechnungen'), + 'component' => './Stv/Studentenverwaltung/Details/Anrechnungen.js', + 'config' => $config['exemptions'] + ]; + $result['finalexam'] = [ 'title' => $this->p->t('stv', 'tab_finalexam'), 'component' => './Stv/Studentenverwaltung/Details/Abschlusspruefung.js', @@ -128,6 +147,34 @@ class Config extends FHCAPI_Controller 'component' => './Stv/Studentenverwaltung/Details/Mobility.js' ]; + $result['archive'] = [ + 'title' => $this->p->t('stv', 'tab_archive'), + 'component' => './Stv/Studentenverwaltung/Details/Archiv.js', + 'config' => [ + 'showEdit' => $this->permissionlib->isBerechtigt('admin') + ] + ]; + + $result['jointstudies'] = [ + 'title' => $this->p->t('stv', 'tab_jointstudies'), + 'component' => './Stv/Studentenverwaltung/Details/JointStudies.js' + ]; + + $result['coursedates'] = [ + 'title' => $this->p->t('stv', 'tab_courseDates'), + 'component' => './Stv/Studentenverwaltung/Details/Lehrveranstaltungstermine.js' + ]; + + $result['admissionDates'] = [ + 'title' => $this->p->t('stv', 'tab_admissionDates'), + 'component' => './Stv/Studentenverwaltung/Details/Aufnahmetermine.js' + ]; + + $result['functions'] = [ + 'title' => $this->p->t('stv', 'tab_functions'), + 'component' => './Stv/Studentenverwaltung/Details/Funktionen.js' + ]; + Events::trigger('stv_conf_student', function & () use (&$result) { return $result; }); @@ -163,10 +210,17 @@ class Config extends FHCAPI_Controller ] ]; $result['finalexam'] = [ - 'title' => $this->p->t('stv', 'tab_finalexam'), + 'title' => $this->p->t('stv', 'tab_finalexam'), 'component' => './Stv/Studentenverwaltung/Details/Abschlusspruefung.js', 'config' => $config['finalexam'] ]; + $result['archive'] = [ + 'title' => $this->p->t('stv', 'tab_archive'), + 'component' => './Stv/Studentenverwaltung/Details/Archiv.js', + 'config' => [ + 'showEdit' => $this->permissionlib->isBerechtigt('admin') + ] + ]; Events::trigger('stv_conf_students', function & () use (&$result) { return $result; @@ -303,7 +357,7 @@ class Config extends FHCAPI_Controller $title_eng = $this->p->t("global", "englisch"); $title_ff = $this->p->t("stv", "document_certificate"); $title_lv = $this->p->t("stv", "document_coursecertificate"); - + $link_ff = "documents/export/" . "zertifikat.rdf.php/" . "Zertifikat" . diff --git a/application/controllers/api/frontend/v1/stv/Dokumente.php b/application/controllers/api/frontend/v1/stv/Dokumente.php new file mode 100644 index 000000000..18c976eb6 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Dokumente.php @@ -0,0 +1,569 @@ + ['admin:r', 'assistenz:r'], + 'getDocumentsAccepted' => ['admin:r', 'assistenz:r'], + 'deleteZuordnung' => ['admin:rw', 'assistenz:rw'], + 'createZuordnung' => ['admin:rw', 'assistenz:rw'], + 'loadAkte' => ['admin:rw', 'assistenz:rw'], + 'deleteAkte' => ['admin:rw', 'assistenz:rw'], + 'updateAkte' => ['admin:rw', 'assistenz:rw'], + 'getDoktypen' => ['admin:r', 'assistenz:r'], + 'uploadDokument' => ['admin:rw', 'assistenz:rw'], + 'download' => ['admin:rw', 'assistenz:rw'], + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('form_validation'); + $this->load->library('DmsLib', array('who' => getAuthUID())); + + // Load language phrases + $this->loadPhrases([ + 'ui', + 'dokumente' + ]); + + // Load models + $this->load->model('crm/Akte_model', 'AkteModel'); + $this->load->model('crm/Dokument_model', 'DokumentModel'); + $this->load->model('crm/Dokumentprestudent_model', 'DokumentprestudentModel'); + + //TODO(Manu) check additional Berechtigungen + //TODO(Manu) check if using dokument lib instead of dokument model? + } + + public function getDocumentsUnaccepted($prestudent_id, $studiengang_kz) + { + if(!$prestudent_id) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + + if (!is_numeric($prestudent_id)) + $this->terminateWithError($this->p->t('ui', 'error_valueNotNumeric', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + + if(!$studiengang_kz) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Studiengang_kz']), self::ERROR_TYPE_GENERAL); + + $person_id = $this->_getPersonId($prestudent_id); + $result = $this->DokumentModel->getUnacceptedDocuments($prestudent_id, $person_id); + + $dataAkteUnaccepted = $this->getDataOrTerminateWithError($result); + $resultMd = $this->_getMissingDocuments($studiengang_kz, $prestudent_id); + + $data = $this->_mergeDocuments($dataAkteUnaccepted, $resultMd); + + $this->terminateWithSuccess($data); + } + + public function getDocumentsAccepted($prestudent_id, $studiengang_kz) + { + if(!$prestudent_id) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + + if (!is_numeric($prestudent_id)) + $this->terminateWithError($this->p->t('ui', 'error_valueNotNumeric', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + + if(!$studiengang_kz) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Studiengang_kz']), self::ERROR_TYPE_GENERAL); + + $resultPreDoc = $this->_getPrestudentDokumente($prestudent_id); + + $arrayAccepted = []; + $person_id = $this->_getPersonId($prestudent_id); + + $docNames = array_map(function ($item) { + return $item->dokument_kurzbz; + }, $resultPreDoc); + + foreach($docNames as $doc) + { + $result = $this->AkteModel->getAktenFAS($person_id, $doc, $studiengang_kz, $prestudent_id, true); + + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if (hasData($result)) + { + $data = getData($result); + foreach ($data as $value) + { + array_push($arrayAccepted, $value); + } + } + } + + //Mapping with document_kurzbz + $preDocMap = []; + foreach ($resultPreDoc as $pre) { + $preDocMap[$pre->dokument_kurzbz] = $pre; + } + + $mergedArray = []; + foreach ($arrayAccepted as $doc) { + $merged = clone $doc; + + if (isset($preDocMap[$doc->dokument_kurzbz])) { + $merged->docdatum = $preDocMap[$doc->dokument_kurzbz]->docdatum; + $merged->insertvonma = $preDocMap[$doc->dokument_kurzbz]->insertvonma; + $merged->bezeichnung = $preDocMap[$doc->dokument_kurzbz]->bezeichnung; + } else { + $merged->akzeptiertdatum = null; + $merged->akzeptiertvon = null; + } + + $mergedArray[] = $merged; + } + + $this->terminateWithSuccess($mergedArray); + } + + public function deleteZuordnung($prestudent_id, $dokument_kurzbz) + { + if(!$prestudent_id) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + + if (!is_numeric($prestudent_id)) + $this->terminateWithError($this->p->t('ui', 'error_valueNotNumeric', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + + if(!$dokument_kurzbz) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Dokument_kurzbz']), self::ERROR_TYPE_GENERAL); + + $result = $this->DokumentprestudentModel->delete( + [ + 'prestudent_id' => $prestudent_id, + 'dokument_kurzbz' => $dokument_kurzbz + ] + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function loadAkte($akte_id) + { + if (!$akte_id) + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Akte ID']), self::ERROR_TYPE_GENERAL); + + $this->AkteModel->addSelect('public.tbl_akte.*'); + $this->AkteModel->addSelect("CONCAT(public.tbl_person.vorname, ' ' , public.tbl_person.nachname) AS namePerson"); + $this->AkteModel->addJoin('public.tbl_person', 'person_id'); + $result = $this->AkteModel->loadWhere( + [ + 'akte_id' => $akte_id, + ] + ); + + $data = $this->getDataOrTerminateWithError($result); + $data = current($data); + $this->terminateWithSuccess($data); + } + + public function updateAkte() + { + $this->form_validation->set_rules('akte_id', 'Akte ID', 'required', [ + 'required' => $this->p->t('dokumente', 'err_updateNotAllowed') + ]); + + $this->form_validation->set_rules('dokument_kurzbz', 'Dokumenttyp', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Dokumenttyp']) + ]); + + $this->form_validation->set_rules('nachreichung_am', 'Nachreichung am', 'is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Nachreichung am']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $uid = getAuthUID(); + + $result = $this->AkteModel->update( + [ + 'akte_id' => $this->input->post('akte_id'), + ], + [ + 'dokument_kurzbz' => $this->input->post('dokument_kurzbz'), + 'anmerkung_intern' => $this->input->post('anmerkung_intern'), + 'titel_intern' => $this->input->post('titel_intern'), + 'nachgereicht_am' => $this->input->post('nachgereicht_am'), + 'updateamum' => date('c'), + 'updatevon' => $uid, + ] + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } + + public function createZuordnung($prestudent_id, $dokument_kurzbz) + { + if (!$prestudent_id) + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + + if(!$dokument_kurzbz) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Dokument_kurzbz']), self::ERROR_TYPE_GENERAL); + + $uid = getAuthUid(); + + //check if more than 1 dokumentkurzbz + //if() + + $result = $this->DokumentprestudentModel->insert( + [ + 'prestudent_id' => $prestudent_id, + 'dokument_kurzbz' => $dokument_kurzbz, + 'mitarbeiter_uid' => $uid, + 'datum' => date('c'), + 'insertamum' => date('c'), + 'insertvon' => $uid, + ] + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function deleteAkte($akte_id) + { + if (!$akte_id) + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Akte ID']), self::ERROR_TYPE_GENERAL); + + $result = $this->AkteModel->load($akte_id); + $dataAkte = $this->getDataOrTerminateWithError($result); + + $logdata_akte = var_export($dataAkte, true); + + $dms_id = current($dataAkte)->dms_id; + $nachgereicht = current($dataAkte)->nachgereicht; + $inhalt = current($dataAkte)->inhalt; + $inhaltVorhanden = $inhalt != ''; + $uid = getAuthUid(); + + $this->db->trans_start(); + + if($dms_id) + { + $this->load->model('content/Dms_model', 'DmsModel'); + $result = $this->DmsModel->load($dms_id); + $data = $this->getDataOrTerminateWithError($result); + + $logdata_dms = (array)$data; + $logdata_dms = "Logdata: " . var_export($logdata_dms, true); + + //delete from dmsLib + $this->load->library('DmsLib'); + $person_id = current($dataAkte)->person_id; + $result = $this->dmslib->delete($person_id, $dms_id); + $this->getDataOrTerminateWithError($result); + + //LOGGING Dms ID + $this->load->model('system/Log_model', 'LogModel'); + $result = $this->LogModel->insert([ + 'executetime' => date('c'), + 'mitarbeiter_uid' => $uid, + 'beschreibung' => "Löschen der DMS_ID ". $dms_id, + 'sql' => $logdata_dms + ]); + $this->getDataOrTerminateWithError($result); + + //delete akte + $result = $this->AkteModel->delete( + [ + 'akte_id' => $akte_id + ] + ); + $data = $this->getDataOrTerminateWithError($result); + + //Logging Deletion Akte + $result = $this->LogModel->insert([ + 'executetime' => date('c'), + 'mitarbeiter_uid' => $uid, + 'beschreibung' => "Löschen der Akte ". $akte_id, + 'sql' => "DELETE FROM public.tbl_akte WHERE akte_id=" .$akte_id. " LogData: ". $logdata_akte + ]); + $this->getDataOrTerminateWithError($result); + $this->db->trans_complete(); + $this->terminateWithSuccess($data); + } + elseif (!!$dms_id || ($nachgereicht && !$inhaltVorhanden)) + { + $result = $this->AkteModel->delete( + [ + 'akte_id' => $akte_id + ] + ); + $data = $this->getDataOrTerminateWithError($result); + + $result = $this->LogModel->insert([ + 'executetime' => date('c'), + 'mitarbeiter_uid' => $uid, + 'beschreibung' => "Löschen der Akte ". $akte_id, + 'sql' => "DELETE FROM public.tbl_akte WHERE akte_id=" .$akte_id. " LogData: ". $logdata_akte + ]); + $this->getDataOrTerminateWithError($result); + + $this->db->trans_complete(); + $this->terminateWithSuccess($data); + } + else + $this->terminateWithError($this->p->t('dokumente', 'err_deleteDokHere'), self::ERROR_TYPE_GENERAL); + } + + public function uploadDokument() + { + $this->load->library('DmsLib'); + $prestudent_id = $this->input->post('prestudent_id'); + $anmerkung_intern = $this->input->post('anmerkung_intern'); + $titel_intern = $this->input->post('titel_intern'); + $dokument_kurzbz = $this->input->post('dokument_kurzbz'); + + $this->form_validation->set_rules('prestudent_id', 'Prestudent_id', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Prestudent ID']) + ]); + + $this->form_validation->set_rules('dokument_kurzbz', 'Dokumenttyp', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Dokumenttyp']) + ]); + + //validation if attachment was added + $this->form_validation->set_rules('anhang', 'Attachment', 'callback_file_check'); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $this->db->trans_start(); + $uid = getAuthUID(); + + $dms = array( + 'kategorie_kurzbz' => 'Akte', + 'version' => 0, + 'name' => $_FILES['anhang']['name'], + 'mimetype' => $_FILES['anhang']['type'], + 'insertamum' => date('c'), + 'insertvon' => $uid + ); + + $result = $this->dmslib->upload($dms, 'anhang', array("jpg", "png", "pdf")); + + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $dms_id = $result->retval['dms_id']; + + $person_id = $this->_getPersonId($prestudent_id); + + $result = $this->DokumentModel->load($dokument_kurzbz); + $data = $this->getDataOrTerminateWithError($result); + + $bezeichnung = current($data)->bezeichnung; + + //save entry in akte + if($dms_id) + { + $result = $this->AkteModel->insert([ + 'person_id' => $person_id, + 'dms_id' => $dms_id, + 'dokument_kurzbz' => $dokument_kurzbz, + 'mimetype' => $_FILES['anhang']['type'], + 'insertamum' => date('c'), + 'erstelltam' => date('c'), + 'insertvon' => $uid, + 'anmerkung_intern' => $anmerkung_intern, + 'titel_intern' => $titel_intern, + 'bezeichnung' => $bezeichnung, + 'titel' => $_FILES['anhang']['name'] + ]); + + $data = $this->getDataOrTerminateWithError($result); + $this->db->trans_complete(); + $this->terminateWithSuccess($data); + } + $this->db->trans_complete(); + $this->terminateWithSuccess($data); + } + + public function getDoktypen() + { + $this->DokumentModel->addSelect('dokument_kurzbz'); + $this->DokumentModel->addSelect('bezeichnung'); + $this->DokumentModel->addOrder('dokument_kurzbz', 'ASC'); + $result = $this->DokumentModel->load(); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function download() + { + //TODO(Manu) check filetype, Decoding + $akte_id = $this->input->get('akte_id'); + + if(!$akte_id) + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Akte ID']), self::ERROR_TYPE_GENERAL); + + if (!is_numeric($akte_id)) + $this->terminateWithError($this->p->t('ui', 'error_valueNotNumeric', ['value' => 'Akte ID']), self::ERROR_TYPE_GENERAL); + + + $result = $this->AkteModel->load($akte_id); + if (!hasData($result)) $this->terminateWithError('Akte not found'); + $data = getData($result)[0]; + + $mimetype = $data->mimetype; + $filecontentbase64 = $data->inhalt; + $filename = $data->titel; + + if(intval($data->dms_id) > 0) + { + $dmsdokres = $this->dmslib->read($data->dms_id); + if (!hasData($dmsdokres)) $this->terminateWithError('DMS File not found'); + $dmsdok = getData($dmsdokres)[0]; + + $mimetype = $dmsdok->mimetype; + $filecontentbase64 = $dmsdok->file_content; + $filename = $dmsdok->name; + } + + $filecontent = ''; + + if (!empty($filecontentbase64)) { + $filecontent = base64_decode($filecontentbase64, true); + + if ($filecontent === false) { + $this->terminateWithError('Base64-Dekodierung failed.'); + } + } + + $this->terminateWithFileOutput($mimetype, $filecontent, $filename); + } + + private function _getMissingDocuments($studiengang_kz, $prestudent_id) + { + $result = $this->DokumentModel->getMissingDocuments($studiengang_kz, $prestudent_id); + + $data = $this->getDataOrTerminateWithError($result); + + return $data; + } + + private function _getUnacceptedDocuments($prestudent_id) + { + $person_id = $this->_getPersonId($prestudent_id); + $result = $this->DokumentModel->getUnacceptedDocuments($prestudent_id, $person_id); + + $data = $this->getDataOrTerminateWithError($result); + + return $data; + } + + /** + * helper function for merging objects + * sorts object after merging according to dokument_kurzbz + * @param $original object of documents of akte + * @param object $toMerge documents to merge (of dokumentprestudent, dokumentstudiengang) + * @return Array mergedObject + */ + private function _mergeDocuments($original, $toMerge) + { + $existingKurzbez = []; + foreach ($original as $doc) { + $existingKurzbez[$doc->dokument_kurzbz] = true; + } + + foreach ($toMerge as $doc) { + if (!isset($existingKurzbez[$doc->dokument_kurzbz])) { + $original[] = $doc; + $existingKurzbez[$doc->dokument_kurzbz] = true; + } + else + { + foreach($original as $docOriginal) + { + if ($docOriginal->dokument_kurzbz == $doc->dokument_kurzbz) + { + $docOriginal->pflicht = $doc->pflicht; + $docOriginal->onlinebewerbung = $doc->onlinebewerbung; + } + } + } + } + + usort($original, function ($a, $b) { + return strcmp($a->dokument_kurzbz, $b->dokument_kurzbz); + }); + + return $original; + } + + private function _getDocumentsOfAkte($person_id) + { + $result = $this->AkteModel->getAktenFAS($person_id); + + $data = $this->getDataOrTerminateWithError($result); + + return $data; + } + + private function _getPrestudentDokumente($prestudent_id) + { + $result = $this->DokumentprestudentModel->getPrestudentDokumente($prestudent_id); + + $data = $this->getDataOrTerminateWithError($result); + + return $data; + } + + private function _getPersonId($prestudent_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $result = $this->PrestudentModel->loadWhere( + ['prestudent_id' => $prestudent_id] + ); + + $data = $this->getDataOrTerminateWithError($result); + $person = current($data); + + return $person->person_id; + } + + public function file_check($str) + { + if (isset($_FILES['anhang']) && $_FILES['anhang']['size'] > 0) + { + $allowed_mime_types = ['image/jpeg', 'image/png', 'application/pdf']; + $mime = mime_content_type($_FILES['anhang']['tmp_name']); + + if (in_array($mime, $allowed_mime_types)) + { + return true; + } else + { + $this->form_validation->set_message('file_check', $this->p->t('dokumente', 'error_fileType')); + return false; + } + } + else + { + $this->form_validation->set_message('file_check', $this->p->t('dokumente', 'error_fileMissing')); + return false; + } + } +} diff --git a/application/controllers/api/frontend/v1/stv/GemeinsameStudien.php b/application/controllers/api/frontend/v1/stv/GemeinsameStudien.php new file mode 100644 index 000000000..97dad48fd --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/GemeinsameStudien.php @@ -0,0 +1,287 @@ + ['admin:r', 'assistenz:r'], + 'loadStudie' => ['admin:r', 'assistenz:r'], + 'insertStudie' => ['admin:rw', 'assistenz:rw'], + 'updateStudie' => ['admin:rw', 'assistenz:rw'], + 'deleteStudie' => ['admin:rw', 'assistenz:rw'], + 'getProgramsStudien' => ['admin:r', 'assistenz:r'], + 'getTypenMobility' => ['admin:r', 'assistenz:r'], + 'getStudiensemester' => ['admin:r', 'assistenz:r'], + 'getStudienprogramme' => ['admin:r', 'assistenz:r'], + 'getPartnerfirmen' => ['admin:r', 'assistenz:r'], + 'getStatiPrestudent' => ['admin:r', 'assistenz:r'], + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('form_validation'); + + // Load language phrases + $this->loadPhrases([ + 'ui', + 'jointstudies' + ]); + + // Load models + $this->load->model('codex/Mobilitaet_model', 'MobilitaetModel'); + + //TODO(check if additional Permissions necessary): 'student/stammdaten' + } + + public function getStudien($prestudent_id) + { + $this->MobilitaetModel->addSelect('mobilitaet_id'); + $this->MobilitaetModel->addSelect('mobilitaetstyp_kurzbz'); + $this->MobilitaetModel->addSelect('prestudent_id'); + $this->MobilitaetModel->addSelect('studiensemester_kurzbz'); + $this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.mobilitaetsprogramm_code'); + $this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.gsprogramm_id'); + $this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.firma_id'); + $this->MobilitaetModel->addSelect('status_kurzbz'); + $this->MobilitaetModel->addSelect('ausbildungssemester'); + $this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.insertvon'); + $this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.insertamum'); + $this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.updatevon'); + $this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.updateamum'); + $this->MobilitaetModel->addSelect('mp.kurzbz'); + $this->MobilitaetModel->addSelect('gp.gsprogrammtyp_kurzbz'); + $this->MobilitaetModel->addSelect('gp.bezeichnung as studienprogramm'); + $this->MobilitaetModel->addSelect('f.name as partner'); + + $this->MobilitaetModel->addJoin('bis.tbl_mobilitaetsprogramm mp', 'ON (mp.mobilitaetsprogramm_code = bis.tbl_mobilitaet.mobilitaetsprogramm_code)', 'LEFT'); + $this->MobilitaetModel->addJoin('bis.tbl_gsprogramm gp', 'ON (gp.gsprogramm_id = bis.tbl_mobilitaet.gsprogramm_id)', 'LEFT'); + $this->MobilitaetModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = bis.tbl_mobilitaet.firma_id)', 'LEFT'); + + $result = $this->MobilitaetModel->loadWhere([ + 'prestudent_id' => $prestudent_id, + ]); + + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + public function getTypenMobility() + { + $this->load->model('codex/Mobilitaetstyp_model', 'MobilitaetstypModel'); + + $result = $this->MobilitaetstypModel->load(); + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + public function getStudiensemester() + { + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->StudiensemesterModel->addOrder('studienjahr_kurzbz', 'DESC'); + $result = $this->StudiensemesterModel->load(); + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + public function getStudienprogramme() + { + $this->load->model('codex/Gsprogramm_model', 'GsprogrammModel'); + + $result = $this->GsprogrammModel->load(); + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + public function getPartnerfirmen() + { + $this->load->model('ressource/Firma_model', 'FirmaModel'); + + $result = $this->FirmaModel->loadWhere( + ['partner_code !=' => null] + ); + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + public function getStatiPrestudent() + { + $this->load->model('crm/Status_model', 'StatusModel'); + + $result = $this->StatusModel->load(); + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + public function loadStudie($mobilitaet_id) + { + $result = $this->MobilitaetModel->load($mobilitaet_id); + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess(current($data)); + } + + public function insertStudie() + { + $this->load->library('form_validation'); + $authUID = getAuthUID(); + + $prestudent_id = $this->input->post('prestudent_id'); + if(!$prestudent_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + } + + $formData = $this->input->post('formData'); + $ausbildungssemester = (isset($formData['ausbildungssemester']) && !empty($formData['ausbildungssemester'])) + ? $formData['ausbildungssemester'] + : null; + $mobilitaetstyp_kurzbz = (isset($formData['mobilitaetstyp_kurzbz']) && !empty($formData['mobilitaetstyp_kurzbz'])) + ? $formData['mobilitaetstyp_kurzbz'] + : null; + $studiensemester_kurzbz = (isset($formData['studiensemester_kurzbz']) && !empty($formData['studiensemester_kurzbz'])) + ? $formData['studiensemester_kurzbz'] : null; + + $this->form_validation->set_data($formData); + + $this->form_validation->set_rules('mobilitaetstyp_kurzbz', 'Typ', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Typ']) + ]); + + $this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Studiensemester']) + ]); + + $this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'required|numeric', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Ausbildungssemester']), + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Ausbildungssemester']), + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $status_kurzbz = (isset($formData['status_kurzbz']) && !empty($formData['status_kurzbz'])) + ? $formData['status_kurzbz'] + : null; + $mobilitaetsprogramm_code = (isset($formData['mobilitaetsprogramm_code']) && !empty($formData['mobilitaetsprogramm_code'])) + ? $formData['mobilitaetsprogramm_code'] + : null; + $gsprogramm_id = (isset($formData['gsprogramm_id']) && !empty($formData['gsprogramm_id'])) + ? $formData['gsprogramm_id'] + : null; + $firma_id= (isset($formData['firma_id']) && !empty($formData['firma_id'])) ? $formData['firma_id'] : null; + + $result = $this->MobilitaetModel->insert([ + 'prestudent_id' => $prestudent_id, + 'mobilitaetstyp_kurzbz' =>$mobilitaetstyp_kurzbz, + 'status_kurzbz' => $status_kurzbz, + 'studiensemester_kurzbz' =>$studiensemester_kurzbz, + 'mobilitaetsprogramm_code' => $mobilitaetsprogramm_code, + 'gsprogramm_id' => $gsprogramm_id, + 'firma_id' => $firma_id, + 'ausbildungssemester' =>$ausbildungssemester, + 'insertvon' => $authUID, + 'insertamum' => date('c'), + ]); + + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + public function updateStudie() + { + $this->load->library('form_validation'); + $authUID = getAuthUID(); + + $prestudent_id = $this->input->post('prestudent_id'); + if(!$prestudent_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + } + + $formData = $this->input->post('formData'); + + $mobilitaet_id = (isset($formData['mobilitaet_id']) && !empty($formData['mobilitaet_id'])) + ? $formData['mobilitaet_id'] : + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Mobilitaet ID']), self::ERROR_TYPE_GENERAL); + $ausbildungssemester = (isset($formData['ausbildungssemester']) && !empty($formData['ausbildungssemester'])) + ? $formData['ausbildungssemester'] + : null; + $mobilitaetstyp_kurzbz = (isset($formData['mobilitaetstyp_kurzbz']) && !empty($formData['mobilitaetstyp_kurzbz'])) + ? $formData['mobilitaetstyp_kurzbz'] + : null; + $studiensemester_kurzbz = (isset($formData['studiensemester_kurzbz']) && !empty($formData['studiensemester_kurzbz'])) + ? $formData['studiensemester_kurzbz'] + : null; + + $this->form_validation->set_data($formData); + + $this->form_validation->set_rules('mobilitaetstyp_kurzbz', 'Typ', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Typ']) + ]); + + $this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Studiensemester']) + ]); + + $this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'required|numeric', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Ausbildungssemester']), + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Ausbildungssemester']), + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $status_kurzbz = (isset($formData['status_kurzbz']) && !empty($formData['status_kurzbz'])) ? $formData['status_kurzbz'] : null; + $mobilitaetsprogramm_code = (isset($formData['mobilitaetsprogramm_code']) && !empty($formData['mobilitaetsprogramm_code'])) + ? $formData['mobilitaetsprogramm_code'] + : null; + $gsprogramm_id = (isset($formData['gsprogramm_id']) && !empty($formData['gsprogramm_id'])) + ? $formData['gsprogramm_id'] + : null; + $firma_id= (isset($formData['firma_id']) && !empty($formData['firma_id'])) ? $formData['firma_id'] : null; + + $result = $this->MobilitaetModel->update( + [ + 'mobilitaet_id' => $mobilitaet_id, + ], + [ + 'prestudent_id' => $prestudent_id, + 'mobilitaetstyp_kurzbz' => $mobilitaetstyp_kurzbz, + 'status_kurzbz' => $status_kurzbz, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'mobilitaetsprogramm_code' => $mobilitaetsprogramm_code, + 'gsprogramm_id' => $gsprogramm_id, + 'firma_id' => $firma_id, + 'ausbildungssemester' => $ausbildungssemester, + 'updatevon' => $authUID, + 'updateamum' => date('c'), + ] + ); + + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + public function deleteStudie($mobilitaet_id) + { + if(!$mobilitaet_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Mobilität ID']), self::ERROR_TYPE_GENERAL); + } + $result = $this->MobilitaetModel->delete( + array('mobilitaet_id' => $mobilitaet_id) + ); + + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Gruppen.php b/application/controllers/api/frontend/v1/stv/Gruppen.php new file mode 100644 index 000000000..c30816f2a --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Gruppen.php @@ -0,0 +1,80 @@ + ['admin:r', 'assistenz:r'], + 'deleteGruppe' => ['admin:rw', 'assistenz:rw'], + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + // Load language phrases + $this->loadPhrases([ + 'ui', 'gruppenmanagement' + ]); + + // Load models + $this->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel'); + $this->load->model('organisation/Gruppe_model', 'GruppeModel'); + } + + public function getGruppen($student_uid) + { + $this->BenutzergruppeModel ->addSelect('gruppe_kurzbz'); + $this->BenutzergruppeModel ->addSelect('bezeichnung'); + $this->BenutzergruppeModel ->addSelect('generiert'); + $this->BenutzergruppeModel ->addSelect('uid'); + $this->BenutzergruppeModel ->addSelect('studiensemester_kurzbz'); + $this->BenutzergruppeModel ->addJoin('public.tbl_gruppe', 'gruppe_kurzbz'); + $this->BenutzergruppeModel-> addOrder('bezeichnung', 'ASC'); + + $result = $this->BenutzergruppeModel->loadWhere( + array( + 'uid' => $student_uid + ) + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function deleteGruppe() + { + $student_uid = $this->input->post('id'); + $gruppe_kurzbz = $this->input->post('gruppe_kurzbz'); + + //Validate if automatic group generation + $result = $this->GruppeModel-> loadWhere( + array( + 'gruppe_kurzbz' => $gruppe_kurzbz + ) + ); + $data = $this->getDataOrTerminateWithError($result); + $generation = current($data); + + if($generation->generiert) + { + $this->terminateWithError($this->p->t('gruppenmanagement', 'error_deleteGeneratedGroups'), self::ERROR_TYPE_GENERAL); + } + + $result = $this->BenutzergruppeModel->delete( + array( + 'gruppe_kurzbz' => $gruppe_kurzbz, + 'uid' => $student_uid + ) + ); + + $data = $this->getDataOrTerminateWithError($result); + + return $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Kontakt.php b/application/controllers/api/frontend/v1/stv/Kontakt.php index bcd38853c..9b713b5f9 100644 --- a/application/controllers/api/frontend/v1/stv/Kontakt.php +++ b/application/controllers/api/frontend/v1/stv/Kontakt.php @@ -28,7 +28,8 @@ class Kontakt extends FHCAPI_Controller 'getStandorte' => ['admin:r', 'assistenz:r'], 'getStandorteByFirma' => ['admin:r', 'assistenz:r'], 'getKontakte' => ['admin:r', 'assistenz:r'], - 'getBankverbindung' => ['mitarbeiter/bankdaten:r', 'student/bankdaten:r'] + 'getBankverbindung' => ['mitarbeiter/bankdaten:r', 'student/bankdaten:r'], + 'getAllFirmen' => ['admin:r', 'assistenz:r'] ]); // Load Libraries @@ -46,6 +47,7 @@ class Kontakt extends FHCAPI_Controller $this->load->model('organisation/standort_model', 'StandortModel'); $this->load->model('ressource/firma_model', 'FirmaModel'); $this->load->model('person/Kontakt_model', 'KontaktModel'); + $this->load->model('person/Kontakttyp_model', 'KontakttypModel'); // Extra Permissionchecks $permsMa = []; @@ -196,13 +198,7 @@ class Kontakt extends FHCAPI_Controller $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; + $firma_id = isset($_POST['firma_id']) ? $_POST['firma_id'] : null; $result = $this->AdresseModel->insert( [ @@ -269,17 +265,6 @@ class Kontakt extends FHCAPI_Controller 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; @@ -289,6 +274,7 @@ class Kontakt extends FHCAPI_Controller $name = isset($_POST['name']) ? $_POST['name'] : null; $typ = isset($_POST['typ']) ? $_POST['typ'] : null; $anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null; + $firma_id = isset($_POST['firma_id']) ? $_POST['firma_id'] : null; $result = $this->AdresseModel->update( [ @@ -443,8 +429,10 @@ class Kontakt extends FHCAPI_Controller THEN public.tbl_kontakt.updateamum ELSE public.tbl_kontakt.insertamum END) AS lastUpdate, st.bezeichnung, f.name"); + $this->KontakttypModel->addSelect("kt.beschreibung as kontakttypbeschreibung"); $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'); + $this->KontakttypModel->addJoin('public.tbl_kontakttyp kt', 'ON (public.tbl_kontakt.kontakttyp = kt.kontakttyp)'); $result = $this->KontaktModel->loadWhere( array('person_id' => $person_id) ); @@ -594,8 +582,8 @@ class Kontakt extends FHCAPI_Controller 'anmerkung' => $anmerkung, 'kontakt' => $kontakt, 'zustellung' => $_POST['zustellung'], - 'insertvon' => $uid, - 'insertamum' => date('c'), + 'updatevon' => $uid, + 'updateamum' => date('c'), 'standort_id' => $standort_id, 'ext_id' => $ext_id ] @@ -670,6 +658,7 @@ class Kontakt extends FHCAPI_Controller $iban = $this->input->post('iban'); $typ = $this->input->post('typ'); $verrechnung = $this->input->post('verrechnung'); + $uid = getAuthUID(); $result = $this->BankverbindungModel->insert( [ @@ -680,7 +669,7 @@ class Kontakt extends FHCAPI_Controller 'iban' => $iban, 'blz' => $blz, 'kontonr' => $kontonr, - 'insertvon' => 'uid', + 'insertvon' => $uid, 'insertamum' => date('c'), 'typ' => $typ, 'verrechnung' => $verrechnung, @@ -797,4 +786,25 @@ class Kontakt extends FHCAPI_Controller return $this->GemeindeModel->checkLocation($_POST['plz'], $_POST['gemeinde'], $_POST['ort']); } + + /* + * returns list of all companies + * as key value list to be used in select or autocomplete + */ + public function getAllFirmen() + { + $sql = " + SELECT + f.firma_id, f.name, + f.name AS label + FROM public.tbl_firma f + ORDER BY f.name ASC"; + + $result = $this->FirmaModel->execReadOnlyQuery($sql); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + } diff --git a/application/controllers/api/frontend/v1/stv/Konto.php b/application/controllers/api/frontend/v1/stv/Konto.php index ac36b5d8f..a33680ea0 100644 --- a/application/controllers/api/frontend/v1/stv/Konto.php +++ b/application/controllers/api/frontend/v1/stv/Konto.php @@ -116,6 +116,8 @@ class Konto extends FHCAPI_Controller { $this->load->model('crm/Buchungstyp_model', 'BuchungstypModel'); + $this->BuchungstypModel->addOrder('beschreibung'); + $result = $this->BuchungstypModel->load(); $data = $this->getDataOrTerminateWithError($result); diff --git a/application/controllers/api/frontend/v1/stv/LvTermine.php b/application/controllers/api/frontend/v1/stv/LvTermine.php new file mode 100644 index 000000000..c29f56964 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/LvTermine.php @@ -0,0 +1,408 @@ + ['admin:r', 'assistenz:r'], + 'getStudiensemester' => ['admin:r', 'assistenz:r'], + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('form_validation'); + + // Load language phrases + $this->loadPhrases([ + 'ui', + ]); + + // Load models + $this->load->model('ressource/Stundenplan_model', 'StundenplanModel'); + + //query verwenden wie im Cis endpoint + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel'); + $this->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel'); + } + + //TODO Build own lib or combine with Controller Stundenplan.php + //here use of logic of Stundenplan.php, extended with parameters uid, grouping, and used dbTable + public function getStundenplan($uid, $start_date = null, $end_date = null, $groupConsecutiveHours = false, $dbStundenplanTable = "stundenplan") + { + $student_uid = $uid; + $semester_range = $this->studienSemesterErmitteln($start_date, $end_date); + + $this->sortStudienSemester($semester_range); + $this->applyLoadUeberSemesterHaelfte($semester_range); + + $benutzer_gruppen = $this->fetchBenutzerGruppenFromStudiensemester($semester_range, $student_uid); + $student_lehrverband = $this->fetchStudentlehrverbandFromStudiensemester($semester_range, $student_uid); + + if(!$groupConsecutiveHours) + $stundenplan_query = $this->StundenplanModel->getStundenplanQuery( + $start_date, + $end_date, + $semester_range, + $benutzer_gruppen, + $student_lehrverband + ); + else + $stundenplan_query = $this->StundenplanModel->getStundenplanQuery( + $start_date, + $end_date, + $semester_range, + $benutzer_gruppen, + $student_lehrverband, + true, + $dbStundenplanTable + ); + + if(!$stundenplan_query) + { + $this->terminateWithSuccess([]); + } + + if($groupConsecutiveHours) + { + $stundenplan_data = $this->StundenplanModel->stundenplanGruppierungConsecutive($stundenplan_query); + } + else + { + $stundenplan_data = $this->StundenplanModel->stundenplanGruppierung($stundenplan_query); + } + + $stundenplan_data = $this->getDataOrTerminateWithError($stundenplan_data) ?? []; + $this->terminateWithSuccess($stundenplan_data); + + $this->expand_object_information($stundenplan_data); + + $this->returnObj['$stundenplan_query'] = $stundenplan_query; + $this->returnObj['$student_lehrverband'] = $student_lehrverband; + $this->returnObj['$benutzer_gruppen'] = $benutzer_gruppen; + $this->terminateWithSuccess($stundenplan_data); + } + + public function getStudiensemester() + { + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->StudiensemesterModel->addOrder('studienjahr_kurzbz', 'DESC'); + $result = $this->StudiensemesterModel->load(); + $data = $this->getDataOrTerminateWithError($result); + $this->terminateWithSuccess($data); + } + + //copied from Stundenplan.php + private function studienSemesterErmitteln($start_date, $end_date) + { + // gets all studiensemester from the student from start_date to end_date + $semester_range = $this->StudiensemesterModel->getByDateRange($start_date, $end_date); + $semester_range = array_map( + function ($sem) { + return $sem->studiensemester_kurzbz; + }, + $this->getDataOrTerminateWithError($semester_range) + ); + + // if no studiensemester is found for the given timespan, get the nearest studiensemester + if(count($semester_range) == 0) + { + $aktuelle_studiensemester = $this->StudiensemesterModel->getNearest(); + $aktuelle_studiensemester = $this->getDataOrTerminateWithError($aktuelle_studiensemester); + if (count($aktuelle_studiensemester) == 0) { + $this->terminateWithError("No aktuelles semester"); + } + $aktuelle_studiensemester = current($aktuelle_studiensemester)->studiensemester_kurzbz; + // push aktuelles semester in active semester array + array_push($semester_range, $aktuelle_studiensemester); + } + return $semester_range; + } + + //copied from Stundenplan.php + private function sortStudienSemester(&$semester_range) + { + usort( + $semester_range, + function ($first, $second) { + $sem_first = null; + $year_first = null; + $match_first = null; + + $sem_second = null; + $year_second = null; + $match_second = null; + + preg_match('/([WS]+)([0-9]+)/', $first, $match_first); + preg_match('/([WS]+)([0-9]+)/', $second, $match_second); + + $sem_first = $match_first[1]; + $year_first = intval($match_first[2]); + + $sem_second = $match_second[1]; + $year_second = intval($match_second[2]); + + if($year_first < $year_second) + { + return -1; + } + elseif($year_first > $year_second) + { + return 1; + } + elseif($year_first == $year_second && $sem_first > $sem_second) + { + return 1; + } + elseif($year_first == $year_second && $sem_first < $sem_second) + { + return -1; + } + return 0; + } + ); + } + + //copied from Stundenplan.php + private function applyLoadUeberSemesterHaelfte(&$semester_range) + { + /* + @var($semester_collection) + convert the array of studiensemester into an associative array with the studiensemester as the key + and the values of each key are the studiensemester needed for the query associated to that studiensemester + example: + + #INPUT: + ['WS2023','SS2024','WS2024'] + #OUTPUT: + [ + 'WS2023' => ['SS2023','WS2023'] + 'SS2024' => ['WS2023','SS2024'] + 'WS2024' => ['SS2024','WS2024'] + ] + */ + $semester_collection = []; + foreach($semester_range as $studiensemester) + { + $previous_studiensemester = $this->StudiensemesterModel->getPreviousFrom($studiensemester); + $previous_studiensemester = $this->getDataOrTerminateWithError($previous_studiensemester); + if (count($previous_studiensemester) == 0) { + $this->terminateWithError("No previous semester"); + } + $previous_studiensemester = current($previous_studiensemester)->studiensemester_kurzbz; + $semester_collection[$studiensemester] = [$previous_studiensemester, $studiensemester]; + } + + /* + @var($studienSemesterDateRanges) + fetches for each studiensemester the start and end date, (SS) summer studiensemester are extended by 1 month to cover the summerbreak + based on the LVPLAN_LOAD_UEBER_SEMESTERHAELFTE constant it will load both the semester and the previous semester with the full date range + or the semester with the full date range and the previous semester with the half date range: + + #INPUT: + [ + 'WS2023' => ['SS2023','WS2023'] + 'SS2024' => ['WS2023','SS2024'] + 'WS2024' => ['SS2024','WS2024'] + ] + #OUTPUT: depends whether LVPLAN_LOAD_UEBER_SEMESTERHAELFTE is true or false + ~ if LVPLAN_LOAD_UEBER_SEMESTERHAELFTE == true + [ + "SS2024": [ + "WS2023": [ + "start"=> "2024-02-03", + "ende"=> "2024-08-31" + ], + "SS2024": [ + "start"=> "2024-02-03", + "ende"=> "2024-08-31" + ] + ] + ] + ~ if LVPLAN_LOAD_UEBER_SEMESTERHAELFTE == false + [ + "SS2024": [ + "WS2023": [ + "start"=> "2024-02-03", + "ende"=> "2024-05-17" + ], + "SS2024": [ + "start"=> "2024-02-03", + "ende"=> "2024-08-31" + ] + ] + ] + */ + $studienSemesterDateRanges=[]; + foreach($semester_collection as $semester_original => $semester_adjoint) + { + $semester_start_ende = $this->StudiensemesterModel->getStartEndeFromStudiensemester($semester_original); + $semester_start_ende = current($this->getDataOrTerminateWithError($semester_start_ende)); + + // initialize empty arrays to add key value pairs + $studienSemesterDateRanges[$semester_original] = []; + + // check if the studiensemester is a summer semester and add 1 month to bridge the school summer break + $match = null; + preg_match("/^(SS)([0-9]+)/", $semester_original, $match); + if(count($match) >0) + { + $one_month = new DateInterval('P1M'); + $one_day = DateInterval::createFromDateString('1 days'); + $summer_studiensemester_end_date = DateTime::createFromFormat('Y-m-d', $semester_start_ende->ende); + $summer_studiensemester_end_date->add($one_month); + $summer_studiensemester_end_date->sub($one_day); + $semester_start_ende->ende = date_format($summer_studiensemester_end_date, 'Y-m-d'); + } + if (defined('LVPLAN_LOAD_UEBER_SEMESTERHAELFTE') && LVPLAN_LOAD_UEBER_SEMESTERHAELFTE === true) + { + foreach($semester_adjoint as $adjoint) + { + $studienSemesterDateRanges[$semester_original][$adjoint]=$semester_start_ende; + } + } + else + { + //TODO: half of a DateInterval might not be correctly calculated + // calculate the half of the studiensemester + $studiensemester_start_date = DateTime::createFromFormat('Y-m-d', $semester_start_ende->start); + $studiensemester_end_date = DateTime::createFromFormat('Y-m-d', $semester_start_ende->ende); + $studiensemester_time_difference = $studiensemester_start_date->diff($studiensemester_end_date); + $half_dateNumber = ceil($studiensemester_time_difference->d/2)+ceil(($studiensemester_time_difference->m*30)/2); + $half_dateInterval = new DateInterval('P'.strval($half_dateNumber) .'D'); + $studiensemester_half = date_format($studiensemester_start_date->add($half_dateInterval), 'Y-m-d'); + + $first_half = new stdClass(); + $first_half->start = $semester_start_ende->start; + $first_half->ende = $studiensemester_half; + + $studienSemesterDateRanges[$semester_original][$semester_adjoint[0]] = $first_half; + $studienSemesterDateRanges[$semester_original][$semester_adjoint[1]] = $semester_start_ende; + } + $semester_range = $studienSemesterDateRanges; + } + } + + //copied from Stundenplan.php, extended with $student_uid + private function fetchBenutzerGruppenFromStudiensemester($semester_range, $student_uid) + { + //$student_uid = getAuthUID(); + $benutzer_gruppen = []; + // for each studiensemester fetch the benutzer gruppen and add them to an associate $bentuzer_gruppen array + /* + [ + ['WS2023'] => [['gruppe1_SS2023','gruppe2_SS2023'],['gruppe1_WS2023','gruppe2_WS2023']], + ['SS2024'] => [['gruppe1_WS2023','gruppe2_WS2023'],['gruppe1_SS2024','gruppe2_SS2024']], + ['WS2024'] => [['gruppe1_SS2024','gruppe2_SS2024'],['gruppe1_WS2024','gruppe2_WS2024']], + ] + */ + foreach($semester_range as $semester_key => $semester_array) + { + $benutzer_gruppen[$semester_key] = []; + // each semester could have ajoint semesters that need to be checked + foreach($semester_array as $semester => $semester_date_range) + { + // for each active semester query the benutzer_gruppen associated to the semester + $benutzer_query = $this->BenutzergruppeModel->execReadOnlyQuery(" + SELECT * FROM tbl_benutzergruppe where uid = ? AND studiensemester_kurzbz = ?", [$student_uid, $semester]); + $benutzer_query_result = $this->getDataOrTerminateWithError($benutzer_query); + array_push( + $benutzer_gruppen[$semester_key], + array_map( + function ($item) { + return "'".$item->gruppe_kurzbz. "'"; + }, + $benutzer_query_result + ) + ); + } + } + + // merge the gruppen of each studiensemester together for the original studiensemester + /* + [ + ['WS2023'] => ['gruppe1_SS2023','gruppe2_SS2023','gruppe1_WS2023','gruppe2_WS2023'], + ['SS2024'] => ['gruppe1_WS2023','gruppe2_WS2023','gruppe1_SS2024','gruppe2_SS2024'], + ['WS2024'] => ['gruppe1_SS2024','gruppe2_SS2024','gruppe1_WS2024','gruppe2_WS2024'], + ] + */ + $benutzer_gruppen = array_map( + function ($gruppe) { + $merged_gruppe = []; + foreach($gruppe as $gruppen_array) + { + $merged_gruppe = array_merge($merged_gruppe, $gruppen_array); + } + return $merged_gruppe; + }, + $benutzer_gruppen + ); + + return $benutzer_gruppen; + } + + //copied from Stundenplan.php, extended with $student_uid + private function fetchStudentlehrverbandFromStudiensemester($semester_range, $student_uid) + { + //$student_uid = getAuthUID(); + $student_lehrverband = []; + // for each studiensemester fetch the studentlehrverbaende and add them to an associate $student_lehrverband array + /* + [ + ['WS2023'] => [ [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ] ], + ['SS2024'] => [ [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ], [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ] ], + ['WS2024'] => [ [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ], [ ['stg_kz'=>298,'semester'=>3,'verband'=>"A",'gruppe'=>""] ] ], + ] + */ + foreach($semester_range as $semester_key => $semester_array) + { + $student_lehrverband[$semester_key] = []; + foreach($semester_array as $semester => $semester_date_range) + { + // for each active semester query the student_lehrverband associated to the semester + $lehrverband_query = $this->BenutzergruppeModel->execReadOnlyQuery(" + SELECT * FROM tbl_studentlehrverband where student_uid = ? AND studiensemester_kurzbz = ?", [$student_uid, $semester]); + $lehrverband_query_result = $this->getDataOrTerminateWithError($lehrverband_query); + array_push($student_lehrverband[$semester_key], array_map( + function ($item) { + $result = new stdClass(); + $result->studiengang_kz = $item->studiengang_kz; + $result->semester = $item->semester; + $result->verband = $item->verband; + $result->gruppe = $item->gruppe; + return $result; + }, + $lehrverband_query_result)); + } + } + + // merge the studentlehrverband of each studiensemester together for the original studiensemester + /* + [ + ['WS2023'] => [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ], + ['SS2024'] => [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""], ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ], + ['WS2024'] => [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""], ['stg_kz'=>298,'semester'=>3,'verband'=>"A",'gruppe'=>""] ], + ] + */ + $student_lehrverband = array_map( + function ($studentlehrverband) { + $merged_studentlehrverband = []; + foreach($studentlehrverband as $studentlehrverband_array) + { + $merged_studentlehrverband = array_merge($merged_studentlehrverband, $studentlehrverband_array); + } + return $merged_studentlehrverband; + }, + $student_lehrverband + ); + + return $student_lehrverband; + } +} diff --git a/application/controllers/api/frontend/v1/stv/Mobility.php b/application/controllers/api/frontend/v1/stv/Mobility.php index 2ab0ac682..f61816086 100644 --- a/application/controllers/api/frontend/v1/stv/Mobility.php +++ b/application/controllers/api/frontend/v1/stv/Mobility.php @@ -3,6 +3,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); use \DateTime as DateTime; +use CI3_Events as Events; class Mobility extends FHCAPI_Controller { @@ -40,13 +41,54 @@ class Mobility extends FHCAPI_Controller // Load models $this->load->model('codex/Bisio_model', 'BisioModel'); + + //Permission checks for Studiengangsarray + $allowedStgs = $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []; + + if ($this->router->method == 'insertMobility' || $this->router->method == 'updateMobility') + { + $student_uid = $this->input->post('uid'); + if(!$student_uid) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Student UID']), self::ERROR_TYPE_GENERAL); + } + $this->_checkAllowedStgsFromUid($student_uid, $allowedStgs); + } + + if ($this->router->method == 'deleteMobility') { + $bisio_id = $this->input->post('bisio_id'); + if(!$bisio_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Bisio ID']), self::ERROR_TYPE_GENERAL); + } + $result = $this->BisioModel->load( + array('bisio_id' => $bisio_id) + ); + $data = $this->getDataOrTerminateWithError($result); + $student_uid = current($data)->student_uid; + + $this->_checkAllowedStgsFromUid($student_uid, $allowedStgs); + } + } + + private function _checkAllowedStgsFromUid($student_uid, $allowedStgs) + { + $this->load->model('crm/Student_model', 'StudentModel'); + $result = $this->StudentModel->loadWhere(['student_uid' => $student_uid]); + $data = $this->getDataOrTerminateWithError($result); + $studiengang_kz = current($data)->studiengang_kz; + + if (!in_array($studiengang_kz, $allowedStgs)) + { + return $this->terminateWithError($this->p->t('ui', 'error_keineBerechtigungStg'), self::ERROR_TYPE_GENERAL); + } } public function getMobilitaeten($student_uid) { $this->BisioModel->addSelect("*"); $this->BisioModel->addJoin('bis.tbl_mobilitaetsprogramm mp', 'ON (mp.mobilitaetsprogramm_code = bis.tbl_bisio.mobilitaetsprogramm_code)', 'LEFT'); - $this->BisioModel->addJoin('lehre.tbl_lehreinheit le', 'ON (le.lehreinheit_id = bis.tbl_bisio.lehreinheit_id)','LEFT'); + $this->BisioModel->addJoin('lehre.tbl_lehreinheit le', 'ON (le.lehreinheit_id = bis.tbl_bisio.lehreinheit_id)', 'LEFT'); $this->BisioModel->addOrder('von', 'DESC'); $this->BisioModel->addOrder('bis', 'DESC'); $this->BisioModel->addOrder('bisio_id', 'DESC'); @@ -83,14 +125,20 @@ class Mobility extends FHCAPI_Controller $formData = $this->input->post('formData'); - $_POST['von'] = (isset($formData['von']) && !empty($formData['von'])) ? $formData['von'] : null; - $_POST['bis'] = (isset($formData['bis']) && !empty($formData['bis'])) ? $formData['bis'] : null; - $_POST['nation_code'] = (isset($formData['nation_code']) && !empty($formData['nation_code'])) ? $formData['nation_code'] : 'A'; - $_POST['mobilitaetsprogramm_code'] = (isset($formData['mobilitaetsprogramm_code']) && !empty($formData['mobilitaetsprogramm_code'])) ? $formData['mobilitaetsprogramm_code'] : null; - $_POST['herkunftsland_code'] = (isset($formData['herkunftsland_code']) && !empty($formData['herkunftsland_code'])) ? $formData['herkunftsland_code'] : 'A'; - $_POST['ects_erworben'] = (isset($formData['ects_erworben']) && !empty($formData['ects_erworben'])) ? $formData['ects_erworben'] : null; - $_POST['ects_angerechnet'] = (isset($formData['ects_angerechnet']) && !empty($formData['ects_angerechnet'])) ? $formData['ects_angerechnet'] : null; - $_POST['lehreinheit_id'] = (isset($formData['lehreinheit_id']) && !empty($formData['lehreinheit_id'])) ? $formData['lehreinheit_id'] : null; + $von = $formData['von'] ?? null; + $bis = $formData['bis'] ?? null; + $nation_code = $formData['nation_code'] ?? null; + $mobilitaetsprogramm_code = $formData['mobilitaetsprogramm_code'] ?? null; + $herkunftsland_code = $formData['herkunftsland_code'] ?? null; + $ects_erworben = $formData['ects_erworben'] ?? null; + $ects_angerechnet = $formData['ects_angerechnet'] ?? null; + $lehreinheit_id = $formData['lehreinheit_id'] ?? null; + $ort = $formData['ort'] ?? null; + $universitaet = $formData['universitaet'] ?? null; + $localPurposes = $formData['localPurposes'] ?? null; + $localSupports = $formData['localSupports'] ?? null; + + $this->form_validation->set_data($formData); $this->form_validation->set_rules('nation_code', 'Nation_code', 'required', [ 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Nation_code']) @@ -126,23 +174,18 @@ class Mobility extends FHCAPI_Controller $this->terminateWithValidationErrors($this->form_validation->error_array()); } - $ort = (isset($formData['ort']) && !empty($formData['ort'])) ? $formData['ort'] : null; - $universitaet = (isset($formData['universitaet']) && !empty($formData['universitaet'])) ? $formData['universitaet'] : null; - $localPurposes = (isset($formData['localPurposes']) && !empty($formData['localPurposes'])) ? $formData['localPurposes'] : null; - $localSupports = (isset($formData['localSupports']) && !empty($formData['localSupports'])) ? $formData['localSupports'] : null; - $result = $this->BisioModel->insert([ 'student_uid' => $student_uid, - 'von' => $_POST['von'], - 'bis' => $_POST['bis'], - 'mobilitaetsprogramm_code' => $_POST['mobilitaetsprogramm_code'], - 'nation_code' => $_POST['nation_code'], - 'herkunftsland_code' => $_POST['herkunftsland_code'], - 'lehreinheit_id' => $_POST['lehreinheit_id'], + 'von' => $von, + 'bis' => $bis, + 'mobilitaetsprogramm_code' => $mobilitaetsprogramm_code, + 'nation_code' => $nation_code, + 'herkunftsland_code' => $herkunftsland_code, + 'lehreinheit_id' => $lehreinheit_id, 'ort' => $ort, 'universitaet' => $universitaet, - 'ects_erworben' => $_POST['ects_erworben'] , - 'ects_angerechnet' => $_POST['ects_angerechnet'], + 'ects_erworben' => $ects_erworben , + 'ects_angerechnet' => $ects_angerechnet, 'insertamum' => date('c'), 'insertvon' => $authUID, ]); @@ -171,7 +214,7 @@ class Mobility extends FHCAPI_Controller { $this->BisioModel->addSelect("*"); $this->BisioModel->addJoin('bis.tbl_mobilitaetsprogramm mp', 'ON (mp.mobilitaetsprogramm_code = bis.tbl_bisio.mobilitaetsprogramm_code)', 'LEFT'); - $this->BisioModel->addJoin('lehre.tbl_lehreinheit le', 'ON (le.lehreinheit_id = bis.tbl_bisio.lehreinheit_id)','LEFT'); + $this->BisioModel->addJoin('lehre.tbl_lehreinheit le', 'ON (le.lehreinheit_id = bis.tbl_bisio.lehreinheit_id)', 'LEFT'); $result = $this->BisioModel->loadWhere( array('bisio_id' => $bisio_id) ); @@ -194,14 +237,18 @@ class Mobility extends FHCAPI_Controller } $formData = $this->input->post('formData'); - $_POST['von'] = (isset($formData['von']) && !empty($formData['von'])) ? $formData['von'] : null; - $_POST['bis'] = (isset($formData['bis']) && !empty($formData['bis'])) ? $formData['bis'] : null; - $_POST['nation_code'] = (isset($formData['nation_code']) && !empty($formData['nation_code'])) ? $formData['nation_code'] : 'A'; - $_POST['mobilitaetsprogramm_code'] = (isset($formData['mobilitaetsprogramm_code']) && !empty($formData['mobilitaetsprogramm_code'])) ? $formData['mobilitaetsprogramm_code'] : null; - $_POST['herkunftsland_code'] = (isset($formData['herkunftsland_code']) && !empty($formData['herkunftsland_code'])) ? $formData['herkunftsland_code'] : 'A'; - $_POST['ects_erworben'] = (isset($formData['ects_erworben']) && !empty($formData['ects_erworben'])) ? $formData['ects_erworben'] : null; - $_POST['ects_angerechnet'] = (isset($formData['ects_angerechnet']) && !empty($formData['ects_angerechnet'])) ? $formData['ects_angerechnet'] : null; - $_POST['lehreinheit_id'] = (isset($formData['lehreinheit_id']) && !empty($formData['lehreinheit_id'])) ? $formData['lehreinheit_id'] : null; + $von = $formData['von'] ?? null; + $bis = $formData['bis'] ?? null; + $nation_code = $formData['nation_code'] ?? null; + $mobilitaetsprogramm_code = $formData['mobilitaetsprogramm_code'] ?? null; + $herkunftsland_code = $formData['herkunftsland_code'] ?? null; + $ects_erworben = $formData['ects_erworben'] ?? null; + $ects_angerechnet = $formData['ects_angerechnet'] ?? null; + $lehreinheit_id = $formData['lehreinheit_id'] ?? null; + $ort = $formData['ort'] ?? null; + $universitaet = $formData['universitaet'] ?? null; + + $this->form_validation->set_data($formData); $this->form_validation->set_rules('nation_code', 'Nation_code', 'required', [ 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Nation_code']) @@ -209,6 +256,7 @@ class Mobility extends FHCAPI_Controller $this->form_validation->set_rules('herkunftsland_code', 'Herkunftsland_code', 'required', [ 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Herkunftsland_code']) ]); + $this->form_validation->set_rules('mobilitaetsprogramm_code', 'Mobilitaetsprogramm_code', 'required', [ 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Mobilitaetsprogramm_code']) ]); @@ -243,16 +291,17 @@ class Mobility extends FHCAPI_Controller ], [ 'student_uid' => $student_uid, - 'von' => $_POST['von'], - 'bis' => $_POST['bis'], - 'mobilitaetsprogramm_code' => $_POST['mobilitaetsprogramm_code'], - 'nation_code' => $_POST['nation_code'], - 'herkunftsland_code' => $_POST['herkunftsland_code'], - 'lehreinheit_id' => $_POST['lehreinheit_id'], - 'ort' => $formData['ort'], - 'universitaet' => $formData['universitaet'], - 'ects_erworben' => $_POST['ects_erworben'] , - 'ects_angerechnet' => $_POST['ects_angerechnet'], + + 'von' => $von, + 'bis' => $bis, + 'mobilitaetsprogramm_code' => $mobilitaetsprogramm_code, + 'nation_code' => $nation_code, + 'herkunftsland_code' => $herkunftsland_code, + 'lehreinheit_id' => $lehreinheit_id, + 'ort' => $ort, + 'universitaet' => $universitaet, + 'ects_erworben' => $ects_erworben , + 'ects_angerechnet' => $ects_angerechnet, 'updateamum' => date('c'), 'updatevon' => $authUID, ] @@ -263,30 +312,12 @@ class Mobility extends FHCAPI_Controller $this->terminateWithSuccess(current($data)); } - public function deleteMobility($bisio_id) + public function deleteMobility() { - //check if extension table exists - $result = $this->BisioModel->tableExists('extension', 'tbl_mo_bisioidzuordnung'); - $data = $this->getDataOrTerminateWithError($result); + $bisio_id = $this->input->post('bisio_id'); - //if table exists check if existing entry - if(!empty($data)) - { - $this->BisioModel->addSelect("count(*)"); - $this->BisioModel->addJoin('extension.tbl_mo_bisioidzuordnung mo', 'ON (mo.bisio_id = bis.tbl_bisio.bisio_id)', 'LEFT'); - - $resultCheckMo = $this->BisioModel->loadWhere( - array('mo.bisio_id' => $bisio_id) - ); - - $resultCheckMo = $this->getDataOrTerminateWithError($resultCheckMo); - $count = current($resultCheckMo)->count; - - $existsInExtension = $count > 0 ? true : false; - - if($existsInExtension) - $this->terminateWithError($this->p->t('mobility', 'error_existingEntryInExtension'), self::ERROR_TYPE_GENERAL); - } + //check if entry in MobilityOnline extension exists + Events::trigger('mobility_delete', $bisio_id); $result = $this->BisioModel->delete( array('bisio_id' => $bisio_id) @@ -294,6 +325,7 @@ class Mobility extends FHCAPI_Controller $data = $this->getDataOrTerminateWithError($result); $this->terminateWithSuccess($data); + } public function getLVList($studiengang_kz) @@ -475,7 +507,6 @@ class Mobility extends FHCAPI_Controller if($local_support){ $aufenthaltfoerderung_code = $local_support; } - $this->load->model('codex/Bisioaufenthaltfoerderung_model', 'BisioaufenthaltfoerderungModel'); if(!$local_support) diff --git a/application/controllers/api/frontend/v1/stv/Prestudent.php b/application/controllers/api/frontend/v1/stv/Prestudent.php index 0b06b9667..4d0aa5fe1 100644 --- a/application/controllers/api/frontend/v1/stv/Prestudent.php +++ b/application/controllers/api/frontend/v1/stv/Prestudent.php @@ -136,10 +136,21 @@ class Prestudent extends FHCAPI_Controller $update_prestudent = array(); foreach ($array_allowed_props_prestudent as $prop) { - $val = $this->input->post($prop); - if ($val !== null || $prop == 'foerderrelevant') { + $val = $this->input->post($prop, true); + + if ($val !== null || $prop === 'foerderrelevant') { $update_prestudent[$prop] = $val; } + + // allowed to be null, but has to be in postparameter + if ( + in_array($prop, ['zgvdatum', 'zgvmadatum', 'zgvdoktordatum', 'zgv_code', 'zgvmas_code', 'zgvdoktor_code']) + && !isset($update_prestudent[$prop]) + && array_key_exists($prop, $_POST) + ) + { + $update_prestudent[$prop] = null; + } } $update_prestudent['updateamum'] = date('c'); @@ -174,7 +185,11 @@ class Prestudent extends FHCAPI_Controller { $this->load->model('codex/Zgv_model', 'ZgvModel'); - $this->ZgvModel->addOrder('zgv_code'); + $this->ZgvModel->addSelect('zgv_code'); + $this->ZgvModel->addSelect('zgv_bez'); + $this->ZgvModel->addSelect('aktiv'); + $this->ZgvModel->addSelect('zgv_bez as label'); + $this->ZgvModel->addOrder('zgv_bez'); $result = $this->ZgvModel->load(); if (isError($result)) @@ -188,7 +203,11 @@ class Prestudent extends FHCAPI_Controller { $this->load->model('codex/Zgvdoktor_model', 'ZgvdoktorModel'); - $this->ZgvdoktorModel->addOrder('zgvdoktor_code'); + $this->ZgvdoktorModel->addSelect('zgvdoktor_code'); + $this->ZgvdoktorModel->addSelect('zgvdoktor_bez'); + $this->ZgvdoktorModel->addSelect('aktiv'); + $this->ZgvdoktorModel->addSelect('zgvdoktor_bez as label'); + $this->ZgvdoktorModel->addOrder('zgvdoktor_bez'); $result = $this->ZgvdoktorModel->load(); if (isError($result)) @@ -202,7 +221,11 @@ class Prestudent extends FHCAPI_Controller { $this->load->model('codex/Zgvmaster_model', 'ZgvmasterModel'); - $this->ZgvmasterModel->addOrder('zgvmas_code'); + $this->ZgvmasterModel->addSelect('zgvmas_code'); + $this->ZgvmasterModel->addSelect('zgvmas_bez'); + $this->ZgvmasterModel->addSelect('aktiv'); + $this->ZgvmasterModel->addSelect('zgvmas_bez as label'); + $this->ZgvmasterModel->addOrder('zgvmas_bez'); $result = $this->ZgvmasterModel->load(); if (isError($result)) diff --git a/application/controllers/api/frontend/v1/stv/Status.php b/application/controllers/api/frontend/v1/stv/Status.php index 8167bd90f..fcc8007cd 100644 --- a/application/controllers/api/frontend/v1/stv/Status.php +++ b/application/controllers/api/frontend/v1/stv/Status.php @@ -739,8 +739,12 @@ class Status extends FHCAPI_Controller // Start DB transaction $this->db->trans_begin(); + //Delete Studentlehrverband if no Status left in this semester + $cilsresult = $this->PrestudentstatusModel->checkIfLastStatusEntry($prestudent_id, $studiensemester_kurzbz); + $isLastPrestudentStatusForSemester = $this->getDataOrTerminateWithError($cilsresult); + //Delete Status - $result = $this->PrestudentstatusModel->delete( + $delpsresult = $this->PrestudentstatusModel->delete( [ 'prestudent_id' => $prestudent_id, 'status_kurzbz' => $status_kurzbz, @@ -748,14 +752,9 @@ class Status extends FHCAPI_Controller 'studiensemester_kurzbz' => $studiensemester_kurzbz ] ); + $this->getDataOrTerminateWithError($delpsresult); - $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) + if ($isLastPrestudentStatusForSemester) { //get student_uid $this->load->model('crm/Student_model', 'StudentModel'); @@ -1529,9 +1528,32 @@ class Status extends FHCAPI_Controller $newStudentlvb['semester'] = $ausbildungssemester; } // If there is no lehrverband just use the same as in the previous studiensemester - - //add studentlehrverband - $result = $this->StudentlehrverbandModel->insert($newStudentlvb); + $checkres = $this->StudentlehrverbandModel->load(array( + 'student_uid' => $studentlvb->student_uid, + 'studiensemester_kurzbz' => $studiensemester_kurzbz + )); + if(hasData($checkres)) + { + $result = $this->StudentlehrverbandModel->update( + array( + 'student_uid' => $studentlvb->student_uid, + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ), + array( + 'studiengang_kz' => $studentlvb->studiengang_kz, + 'semester' => $studentlvb->semester, + 'verband' => $studentlvb->verband, + 'gruppe' => $studentlvb->gruppe, + 'updateamum' => $now, + 'updatevon' => $authUID + ) + ); + } + else + { + //add studentlehrverband + $result = $this->StudentlehrverbandModel->insert($newStudentlvb); + } $this->getDataOrTerminateWithError($result); diff --git a/application/controllers/api/frontend/v1/stv/Student.php b/application/controllers/api/frontend/v1/stv/Student.php index f24ef62bb..17cec8b26 100644 --- a/application/controllers/api/frontend/v1/stv/Student.php +++ b/application/controllers/api/frontend/v1/stv/Student.php @@ -72,9 +72,22 @@ class Student extends FHCAPI_Controller { $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $this->PrestudentModel->addSelect('p.*'); + $this->PrestudentModel->addSelect('p.person_id'); + $this->PrestudentModel->addSelect('p.titelpre'); + $this->PrestudentModel->addSelect('p.nachname'); + $this->PrestudentModel->addSelect('p.vorname'); + $this->PrestudentModel->addSelect('p.wahlname'); + $this->PrestudentModel->addSelect('p.vornamen'); + $this->PrestudentModel->addSelect('p.titelpost'); + $this->PrestudentModel->addSelect('p.svnr'); + $this->PrestudentModel->addSelect('p.ersatzkennzeichen'); + $this->PrestudentModel->addSelect('p.gebdatum'); + $this->PrestudentModel->addSelect('p.geschlecht'); + $this->PrestudentModel->addSelect('p.foto'); + $this->PrestudentModel->addSelect('p.foto_sperre'); $this->PrestudentModel->addSelect('s.student_uid'); $this->PrestudentModel->addSelect('matrikelnr'); $this->PrestudentModel->addSelect('b.aktiv'); @@ -82,6 +95,15 @@ class Student extends FHCAPI_Controller $this->PrestudentModel->addSelect('v.verband'); $this->PrestudentModel->addSelect('v.gruppe'); $this->PrestudentModel->addSelect('b.alias'); + $this->PrestudentModel->addSelect('p.geburtsnation'); + $this->PrestudentModel->addSelect('p.sprache'); + $this->PrestudentModel->addSelect('p.gebort'); + $this->PrestudentModel->addSelect('p.homepage'); + $this->PrestudentModel->addSelect('p.anmerkung'); + $this->PrestudentModel->addSelect('p.familienstand'); + $this->PrestudentModel->addSelect('p.staatsbuergerschaft'); + $this->PrestudentModel->addSelect('p.matr_nr'); + $this->PrestudentModel->addSelect('p.anrede'); if (defined('ACTIVE_ADDONS') && strpos(ACTIVE_ADDONS, 'bewerbung') !== false) { $this->PrestudentModel->addSelect( @@ -97,6 +119,16 @@ class Student extends FHCAPI_Controller false ); } + $this->PrestudentModel->addSelect( + "( + SELECT status_kurzbz + FROM public.tbl_prestudentstatus pss + WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id + AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " + ORDER BY GREATEST(pss.datum, '0001-01-01') DESC + LIMIT 1 + ) AS statusofsemester" + ); $this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT'); $this->PrestudentModel->addJoin('public.tbl_benutzer b', 'student_uid = uid', 'LEFT'); @@ -106,17 +138,34 @@ class Student extends FHCAPI_Controller 'LEFT' ); $this->PrestudentModel->addJoin('public.tbl_person p', 'p.person_id = tbl_prestudent.person_id'); +/* $this->PrestudentModel->addJoin('public.tbl_prestudentstatus pss', 'pss.prestudent_id = tbl_prestudent.prestudent_id + AND pss.studiensemester_kurzbz = ' . $this->PrestudentModel->escape($studiensemester_kurzbz), + 'LEFT');*/ - $result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]); + $result = $this->PrestudentModel->loadWhere(['tbl_prestudent.prestudent_id' => $prestudent_id]); $student = $this->getDataOrTerminateWithError($result); if (!$student) return show_404(); + $this->terminateWithSuccess(current($student)); } + protected function isLaufendesSemester($selectedSemester) + { + $laufendesStudiensemester = ''; + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $result = $this->StudiensemesterModel->getNearest(); + if(hasData($result)) { + $laufendesStudiensemester = (getData($result))[0]->studiensemester_kurzbz; + } + + $islaufendesSemester = $selectedSemester === $laufendesStudiensemester; + return $islaufendesSemester; + } + /** * Saves data to a prestudent * @@ -125,24 +174,36 @@ class Student extends FHCAPI_Controller */ public function save($prestudent_id) { - $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); - $this->load->model('person/Person_model', 'PersonModel'); + $this->load->model('person/Benutzer_model', 'BenutzerModel'); $this->load->model('crm/Student_model', 'StudentModel'); $this->load->model('crm/Prestudent_model', 'PrestudentModel'); $this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel'); + $this->load->model('organisation/Lehrverband_model', 'LehrverbandModel'); $this->load->library('form_validation'); + $authuid = getAuthUID(); + $now = date('c'); + + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); + $this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'is_valid_date'); - $this->form_validation->set_rules('semester', 'Semester', 'integer'); + $this->form_validation->set_rules('semester', 'Semester', 'integer', [ + 'integer' => $this->p->t('ui', 'error_fieldNotInteger') + ] + ); + + $this->form_validation->set_rules('alias', 'Alias', 'regex_match[/^[-a-z0-9\_\.]*[a-z0-9]{1,}\.[-a-z0-9\_]{1,}$/]', + [ + 'regex_match' => $this->p->t('ui', 'error_fieldInvalidAlias') + ]); $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); @@ -197,7 +258,7 @@ class Student extends FHCAPI_Controller 'anmerkung', 'homepage' ]; - + // add UDFs $result = $this->udflib->getDefinitionForModel($this->PersonModel); @@ -215,6 +276,10 @@ class Student extends FHCAPI_Controller } $array_allowed_props_student = ['matrikelnr']; + if($this->isLaufendesSemester($studiensemester_kurzbz)) + { + $array_allowed_props_student = ['matrikelnr', 'verband', 'semester', 'gruppe']; + } $update_student = array(); foreach ($array_allowed_props_student as $prop) { $val = $this->input->post($prop); @@ -223,6 +288,15 @@ class Student extends FHCAPI_Controller } } + $array_allowed_props_benutzer = ['aktiv', 'alias']; + $update_benutzer = array(); + foreach ($array_allowed_props_benutzer as $prop) { + $val = $this->input->post($prop); + if ($val !== null) { + $update_benutzer[$prop] = $val; + } + } + // Check PKs if (count($update_lehrverband) + count($update_student) && $uid === null) { $this->terminateWithValidationErrors(['' => $this->p->t('lehre', 'error_no_student')]); @@ -230,16 +304,47 @@ class Student extends FHCAPI_Controller if (count($update_person) && $person_id === null) { $this->terminateWithValidationErrors(['' => $this->p->t('lehre', 'error_no_person')]); } + if (count($update_benutzer) && $uid === null) { + $this->terminateWithValidationErrors(['' => $this->p->t('lehre', 'error_no_student')]); + } // Do Updates if (count($update_lehrverband)) { + $curstudlvb = $this->StudentlehrverbandModel->load([ 'studiensemester_kurzbz' => $studiensemester_kurzbz, 'student_uid' => $uid ]); + $data = $this->getDataOrTerminateWithError($curstudlvb); + $data = current($data); + + $verbandCurrent = $data->verband; + $studiengang_kz = $data->studiengang_kz; + $semesterCurrent = $data->semester; + $gruppeCurrent = $data->gruppe; + + $verband = isset($update_lehrverband['verband']) ? $update_lehrverband['verband'] : $verbandCurrent; + $gruppe = isset($update_lehrverband['gruppe']) ? $update_lehrverband['gruppe'] : $gruppeCurrent; + $semester = isset($update_lehrverband['semester']) ? $update_lehrverband['semester'] : $semesterCurrent; + + //check if existing Lehrverband of new data to avoid Error + $result = $this->LehrverbandModel->loadWhere([ + 'verband' => $verband, + 'gruppe' => $gruppe, + 'semester' => $semester, + 'studiengang_kz' => $studiengang_kz, + ]); + + if(!hasData($result)) + { + $this->terminateWithError($this->p->t('lehre', 'error_noLehrverband'), self::ERROR_TYPE_GENERAL); + } + if(hasData($curstudlvb) && count(getData($curstudlvb)) > 0 ) { + $update_lehrverband['updatevon'] = $authuid; + $update_lehrverband['updateamum'] = $now; $result = $this->StudentlehrverbandModel->update([ 'studiensemester_kurzbz' => $studiensemester_kurzbz, 'student_uid' => $uid @@ -247,6 +352,8 @@ class Student extends FHCAPI_Controller } else { + $update_lehrverband['insertvon'] = $authuid; + $update_lehrverband['insertamum'] = $now; $result = $this->StudentlehrverbandModel->insert(array_merge([ 'studiensemester_kurzbz' => $studiensemester_kurzbz, 'student_uid' => $uid, @@ -258,6 +365,8 @@ class Student extends FHCAPI_Controller } if (count($update_person)) { + $update_person['updatevon'] = $authuid; + $update_person['updateamum'] = $now; $result = $this->PersonModel->update( $person_id, $update_person @@ -267,6 +376,8 @@ class Student extends FHCAPI_Controller if (count($update_student)) { + $update_student['updatevon'] = $authuid; + $update_student['updateamum'] = $now; $result = $this->StudentModel->update( [$uid], $update_student @@ -274,10 +385,26 @@ class Student extends FHCAPI_Controller $this->getDataOrTerminateWithError($result); } + if (count($update_benutzer)) { + $update_benutzer['updatevon'] = $authuid; + $update_benutzer['updateamum'] = $now; + if (array_key_exists("aktiv", $update_benutzer)) + { + $update_benutzer['updateaktivvon'] = $authuid; + $update_benutzer['updateaktivam'] = $now; + } + $result = $this->BenutzerModel->update( + [$uid], + $update_benutzer + ); + $this->getDataOrTerminateWithError($result); + } + $this->terminateWithSuccess(array_fill_keys(array_merge( array_keys($update_lehrverband), array_keys($update_person), - array_keys($update_student) + array_keys($update_student), + array_keys($update_benutzer) ), '')); } diff --git a/application/controllers/api/frontend/v1/stv/Students.php b/application/controllers/api/frontend/v1/stv/Students.php index 5fb7b592c..df8793368 100644 --- a/application/controllers/api/frontend/v1/stv/Students.php +++ b/application/controllers/api/frontend/v1/stv/Students.php @@ -70,7 +70,7 @@ class Students extends FHCAPI_Controller * /(studiengang_kz)/(org_form)/(semester)/(verband) => getStudents * /(studiengang_kz)/(org_form)/(semester)/(verband)/(gruppe) * => getStudents - * /uid/(student_uid) => getStudent + * /student/(student_uid) => getStudent * /prestudent/(prestudent_id) => getPrestudent * /person/(person_id) => getPerson * @@ -223,25 +223,25 @@ class Students extends FHCAPI_Controller break; case "bewerbungnichtabgeschickt": $where['ps.status_kurzbz'] = 'Interessent'; - $where['bewerbung_abgeschicktamum'] = null; + $where['ps.bewerbung_abgeschicktamum'] = null; break; case "bewerbungabgeschickt": $where['ps.status_kurzbz'] = 'Interessent'; - $where['bewerbung_abgeschicktamum IS NOT NULL'] = null; - $where['bestaetigtam'] = null; + $where['ps.bewerbung_abgeschicktamum IS NOT NULL'] = null; + $where['ps.bestaetigtam'] = null; break; case "statusbestaetigt": $where['ps.status_kurzbz'] = 'Interessent'; - $where['bestaetigtam IS NOT NULL'] = null; + $where['ps.bestaetigtam IS NOT NULL'] = null; break; case "statusbestaetigtrtnichtangemeldet": $where['ps.status_kurzbz'] = 'Interessent'; - $where['bestaetigtam IS NOT NULL'] = null; + $where['ps.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; + $where['ps.bestaetigtam IS NOT NULL'] = null; $this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false); break; case "zgv": @@ -358,6 +358,18 @@ class Students extends FHCAPI_Controller $this->PrestudentModel->addSelect("'' AS gruppe"); $this->addSelectPrioRel(); + //add status per semester + $this->PrestudentModel->addSelect( + "( + SELECT status_kurzbz + FROM public.tbl_prestudentstatus pss + WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id + AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " + ORDER BY GREATEST(pss.datum, '0001-01-01') DESC + LIMIT 1 + ) AS statusofsemester" + ); + $this->addFilter($studiensemester_kurzbz); $result = $this->PrestudentModel->loadWhere($where); @@ -380,7 +392,6 @@ class Students extends FHCAPI_Controller 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'); @@ -406,6 +417,18 @@ class Students extends FHCAPI_Controller $this->PrestudentModel->addSelect('v.gruppe'); $this->PrestudentModel->addSelect("'' AS priorisierung_relativ"); + //add status per semester + $this->PrestudentModel->addSelect( + "( + SELECT status_kurzbz + FROM public.tbl_prestudentstatus pss + WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id + AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " + ORDER BY GREATEST(pss.datum, '0001-01-01') DESC + LIMIT 1 + ) AS statusofsemester" + ); + $where = []; @@ -482,6 +505,19 @@ class Students extends FHCAPI_Controller $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'); + + //add status per semester + $this->PrestudentModel->addSelect( + "( + SELECT status_kurzbz + FROM public.tbl_prestudentstatus pss + WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id + AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " + ORDER BY GREATEST(pss.datum, '0001-01-01') DESC + LIMIT 1 + ) AS statusofsemester" + ); + $this->addSelectPrioRel(); $this->addFilter($studiensemester_kurzbz); @@ -527,8 +563,23 @@ class Students extends FHCAPI_Controller $this->PrestudentModel->addSelect('v.semester'); $this->PrestudentModel->addSelect('v.verband'); $this->PrestudentModel->addSelect('v.gruppe'); + + //add status per semester + $this->PrestudentModel->addSelect( + "( + SELECT status_kurzbz + FROM public.tbl_prestudentstatus pss + WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id + AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " + ORDER BY GREATEST(pss.datum, '0001-01-01') DESC + LIMIT 1 + ) AS statusofsemester" + ); + $this->addSelectPrioRel(); + + $this->addFilter($studiensemester_kurzbz); $result = $this->PrestudentModel->loadWhere([ @@ -565,6 +616,19 @@ class Students extends FHCAPI_Controller $this->PrestudentModel->addSelect('v.semester'); $this->PrestudentModel->addSelect('v.verband'); $this->PrestudentModel->addSelect('v.gruppe'); + + //add status per semester + $this->PrestudentModel->addSelect( + "( + SELECT status_kurzbz + FROM public.tbl_prestudentstatus pss + WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id + AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " + ORDER BY GREATEST(pss.datum, '0001-01-01') DESC + LIMIT 1 + ) AS statusofsemester" + ); + $this->addSelectPrioRel(); $this->addFilter($studiensemester_kurzbz); @@ -622,6 +686,8 @@ class Students extends FHCAPI_Controller $this->PrestudentModel->addSelect('ersatzkennzeichen'); $this->PrestudentModel->addSelect('gebdatum'); $this->PrestudentModel->addSelect('geschlecht'); + $this->PrestudentModel->addSelect('foto'); + $this->PrestudentModel->addSelect('foto_sperre'); // semester // verband @@ -629,6 +695,7 @@ class Students extends FHCAPI_Controller $this->PrestudentModel->addSelect('UPPER(stg.typ || stg.kurzbz) AS studiengang'); $this->PrestudentModel->addSelect('tbl_prestudent.studiengang_kz'); + $this->PrestudentModel->addSelect('stg.bezeichnung AS stg_bezeichnung'); $this->PrestudentModel->addSelect("s.matrikelnr"); $this->PrestudentModel->addSelect('p.person_id'); $this->PrestudentModel->addSelect('pls.status_kurzbz AS status'); @@ -640,7 +707,7 @@ class Students extends FHCAPI_Controller ); $this->PrestudentModel->addSelect(" CASE WHEN b.uid IS NOT NULL AND b.uid<>'' - THEN b.uid || " . $this->PrestudentModel->escape(DOMAIN) . " + THEN CONCAT(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'); @@ -709,7 +776,12 @@ class Students extends FHCAPI_Controller */ protected function addFilter($studiensemester_kurzbz) { - $filter = $this->input->get('filter'); + $filter = json_decode($this->input->get('filter'), true); + if (!is_array($filter)) + { + $this->addMeta('addfilter', 'invalid filter: ' . $this->input->get('filter')); + return; + } if (isset($filter['konto_count_0'])) { $bt = $this->PrestudentModel->escape($filter['konto_count_0']); $stdsem = $this->PrestudentModel->escape($studiensemester_kurzbz); diff --git a/application/controllers/api/frontend/v1/vertraege/Vertraege.php b/application/controllers/api/frontend/v1/vertraege/Vertraege.php new file mode 100644 index 000000000..bb14bc511 --- /dev/null +++ b/application/controllers/api/frontend/v1/vertraege/Vertraege.php @@ -0,0 +1,720 @@ + ['vertrag/mitarbeiter:r'], + 'getAllContractsNotAssigned' => ['vertrag/mitarbeiter:r'], + 'getAllContractsAssigned' => ['vertrag/mitarbeiter:r'], + 'getAllContractTypes' => ['vertrag/mitarbeiter:r'], + 'getAllContractStati' => ['vertrag/mitarbeiter:r'], + 'getStatiOfContract' => ['vertrag/mitarbeiter:r'], + 'loadContract' => ['vertrag/mitarbeiter:r'], + 'loadContractStatus' => ['vertrag/mitarbeiter:r'], + 'updateContract' =>['vertrag/mitarbeiter:w'], + 'addNewContract' =>['vertrag/mitarbeiter:w'], + 'deleteContract' =>['vertrag/mitarbeiter:w'], + 'insertContractStatus' =>['vertrag/mitarbeiter:w'], + 'deleteContractStatus' =>['vertrag/mitarbeiter:w'], + 'updateContractStatus' =>['vertrag/mitarbeiter:w'], + 'deleteLehrauftrag' =>['vertrag/mitarbeiter:w'], + 'deleteBetreuung' =>['vertrag/mitarbeiter:w'], + 'getMitarbeiter' => ['vertrag/mitarbeiter:r'], + 'getHeader' => ['vertrag/mitarbeiter:r'], + 'getPersonAbteilung' => ['vertrag/mitarbeiter:r'], + 'getLeitungOrg' => ['vertrag/mitarbeiter:r'], + ]); + + //Load Models and Libraries + $this->load->model('accounting/Vertrag_model', 'VertragModel'); + $this->load->model('accounting/Vertragsstatus_model', 'VertragsstatusModel'); + $this->load->model('accounting/Vertragstyp_model', 'VertragstypModel'); + $this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel'); + + // Load language phrases + $this->loadPhrases([ + 'ui', + 'vertrag' + ]); + } + + public function getAllVertraege($person_id) + { + $result = $this->VertragModel->loadContractsOfPerson($person_id); + + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess((getData($result) ?: [])); + } + + public function getAllContractsNotAssigned($person_id) + { + $result = $this->VertragModel->loadContractsOfPersonNotAssigned($person_id); + + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess((getData($result) ?: [])); + } + + public function getAllContractsAssigned($person_id, $vertrag_id) + { + $result = $this->VertragModel->loadContractsOfPersonAssigned($person_id, $vertrag_id); + + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess((getData($result) ?: [])); + } + + public function getStatiOfContract($person_id, $vertrag_id) + { + //check if vertrag_id corresponds with person_id and return null if not + $result = $this->VertragModel->loadWhere( + array( + 'vertrag_id' => $vertrag_id, + 'person_id' => $person_id + ) + ); + if(!hasData($result)) + { + $this->terminateWithSuccess([]); + } + + $result = $this->VertragModel->getStatiOfContract($vertrag_id); + + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess((getData($result) ?: [])); + } + + public function getAllContractTypes() + { + $result = $this->VertragstypModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getAllContractStati() + { + $result = $this->VertragsstatusModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess(getData($result) ?: []); + } + + public function addNewContract() + { + $this->load->library('form_validation'); + + $person_id = $this->input->post('person_id'); + + if(!$person_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person_id']), self::ERROR_TYPE_GENERAL); + } + + $formData = $this->input->post('formData'); + $vertragstyp_kurzbz = $formData['vertragstyp_kurzbz'] ?? null; + $vertragsdatum = $formData['vertragsdatum'] ?? null; + $bezeichnung = $formData['bezeichnung'] ?? null; + $betrag = $formData['betrag'] ?? null; + $vertragsstunden = $formData['vertragsstunden'] ?? null; + $vertragsstunden_studiensemester_kurzbz = $formData['vertragsstunden_studiensemester_kurzbz'] ?? null; + $anmerkung = $formData['anmerkung'] ?? null; + + $this->form_validation->set_data($formData); + $this->form_validation->set_rules('bezeichnung', 'Bezeichnung', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Bezeichnung']) + ]); + + $this->form_validation->set_rules('vertragstyp_kurzbz', 'Vertragstyp', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Vertragstyp']) + ]); + $this->form_validation->set_rules('vertragsdatum', 'Vertragsdatum', 'required|is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Vertragsdatum']), + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Vertragsdatum']) + ]); + $this->form_validation->set_rules('betrag', 'Betrag', 'required|numeric', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Betrag']), + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Betrag']) + ]); + $this->form_validation->set_rules('vertragsstunden', 'Stunden(Vertrags-Urfassung)', 'numeric', [ + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Stunden(Vertrags-Urfassung)']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $lehrauftraege = $this->input->post('clickedRows'); + + $this->db->trans_start(); + + $result = $this->VertragModel->insert([ + 'person_id' => $person_id, + 'vertragsdatum' => $vertragsdatum, + 'bezeichnung' => $bezeichnung, + 'vertragstyp_kurzbz' => $vertragstyp_kurzbz, + 'betrag' => $betrag, + 'vertragsstunden' => $vertragsstunden, + 'vertragsstunden_studiensemester_kurzbz' => $vertragsstunden_studiensemester_kurzbz, + 'anmerkung' => $anmerkung, + 'insertamum' => date('c'), + 'insertvon' => getAuthUID() + ]); + + $this->getDataOrTerminateWithError($result); + $vertrag_id = $result->retval; + + $status_result = $this->VertragvertragsstatusModel->insert([ + 'vertrag_id' => $vertrag_id, + 'uid' => getAuthUID(), + 'vertragsstatus_kurzbz' => 'neu', + 'insertamum' => date('c'), + 'insertvon' => getAuthUID(), + 'datum' => date('c') + ]); + + if (!$status_result) { + $this->db->trans_rollback(); + $this->terminateWithError($this->p->t('vertrag', 'error_insertOrUpdateStatusVertrag'), self::ERROR_TYPE_GENERAL); + } + + //Hinzufügen der Lehraufträge + foreach ($lehrauftraege as $row) + { + if ($row['type'] == 'Lehrauftrag') + { + $this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); + + $result_lehrauftrag = $this->LehreinheitmitarbeiterModel->update( + [ + 'lehreinheit_id' => $row['lehreinheit_id'], + 'mitarbeiter_uid' => $row['mitarbeiter_uid'] + ], + [ + 'vertrag_id' => $vertrag_id + ] + ); + + if (!$result_lehrauftrag) { + $this->db->trans_rollback(); + $this->terminateWithError($this->p->t('vertrag', 'error_addOrUpdateLehrauftraege'), self::ERROR_TYPE_GENERAL); + } + } + + if ($row['type'] == 'Betreuung') + { + $this->load->model('education/Projektbetreuer_model', 'Projektbetreuermodel'); + + $result_projektbetreuer = $this->Projektbetreuermodel->update( + [ + 'person_id' => $person_id, + 'projektarbeit_id' => $row['projektarbeit_id'], + 'betreuerart_kurzbz' => $row['betreuerart_kurzbz'] + ], + [ + 'vertrag_id' => $vertrag_id + ] + ); + + if (!$result_projektbetreuer) + { + $this->db->trans_rollback(); + $this->terminateWithError($this->p->t('vertrag', 'error_addOrUpdateLehrauftraege'), self::ERROR_TYPE_GENERAL); + } + } + } + $this->db->trans_complete(); + $this->terminateWithSuccess(true); + } + + public function updateContract() + { + $this->load->library('form_validation'); + + $vertrag_id = $this->input->post('vertrag_id'); + $person_id = $this->input->post('person_id'); + $formData = $this->input->post('formData'); + $lehrauftraege = $this->input->post('clickedRows'); + + $vertragstyp_kurzbz = $formData['vertragstyp_kurzbz'] ?? null; + $vertragsdatum = $formData['vertragsdatum'] ?? null; + $bezeichnung = $formData['bezeichnung'] ?? null; + $betrag = $formData['betrag'] ?? null; + $vertragsstunden = $formData['vertragsstunden'] ?? null; + $vertragsstunden_studiensemester_kurzbz = $formData['vertragsstunden_studiensemester_kurzbz'] ?? null; + $anmerkung = $formData['anmerkung'] ?? null; + + + $this->form_validation->set_data($formData); + $this->form_validation->set_rules('bezeichnung', 'Bezeichnung', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Bezeichnung']) + ]); + + $this->form_validation->set_rules('vertragstyp_kurzbz', 'Vertragstyp', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Vertragstyp']) + ]); + $this->form_validation->set_rules('vertragsdatum', 'Vertragsdatum', 'required|is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Vertragsdatum']), + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Vertragsdatum']) + ]); + $this->form_validation->set_rules('betrag', 'Betrag', 'required|numeric', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Betrag']), + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Betrag']) + ]); + $this->form_validation->set_rules('vertragsstunden', 'Stunden(Vertrags-Urfassung)', 'numeric', [ + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Stunden(Vertrags-Urfassung)']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $this->db->trans_start(); + + $result = $this->VertragModel->update( + $vertrag_id, + [ + 'person_id' => $person_id, + 'vertragsdatum' => $vertragsdatum, + 'bezeichnung' => $bezeichnung, + 'vertragstyp_kurzbz' => $vertragstyp_kurzbz, + 'betrag' => $betrag, + 'vertragsstunden' => $vertragsstunden, + 'vertragsstunden_studiensemester_kurzbz' => $vertragsstunden_studiensemester_kurzbz, + 'anmerkung' => $anmerkung, + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ] + ); + + $this->getDataOrTerminateWithError($result); + + //Adding of Lehraufträge + foreach ($lehrauftraege as $row) + { + if ($row['type'] == 'Lehrauftrag') + { + $this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); + + $result_lehrauftrag = $this->LehreinheitmitarbeiterModel->update( + [ + 'lehreinheit_id' => $row['lehreinheit_id'], + 'mitarbeiter_uid' => $row['mitarbeiter_uid'] + ], + [ + 'vertrag_id' => $vertrag_id, + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ] + ); + + if (!$result_lehrauftrag) { + $this->db->trans_rollback(); + $this->terminateWithError($this->p->t('vertrag', 'error_addOrUpdateLehrauftraege'), self::ERROR_TYPE_GENERAL); + } + } + + if ($row['type'] == 'Betreuung') + { + $this->load->model('education/Projektbetreuer_model', 'Projektbetreuermodel'); + + $result_projektbetreuer = $this->Projektbetreuermodel->update( + [ + 'person_id' => $person_id, + 'projektarbeit_id' => $row['projektarbeit_id'], + 'betreuerart_kurzbz' => $row['betreuerart_kurzbz'] + ], + [ + 'vertrag_id' => $vertrag_id, + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ] + ); + + if (!$result_projektbetreuer) + { + $this->db->trans_rollback(); + $this->terminateWithError($this->p->t('vertrag', 'error_addOrUpdateLehrauftraege'), self::ERROR_TYPE_GENERAL); + } + } + } + $this->db->trans_complete(); + + $this->terminateWithSuccess(true); + } + + public function loadContract($vertrag_id) + { + $result = $this->VertragModel->load($vertrag_id); + + if (isError($result)) { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + + if (!hasData($result)) { + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Vertrag_id']), self::ERROR_TYPE_GENERAL); + } + + $this->terminateWithSuccess(current(getData($result))); + } + + public function deleteContract($vertrag_id) + { + $this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); + + //check if attached Lehrauftrag + $resultLehrauftrag = $this->LehreinheitmitarbeiterModel->load([ + 'vertrag_id' => $vertrag_id + ]); + + if(hasData($resultLehrauftrag)) + { + $resultLehrauftrag = getData($resultLehrauftrag); + foreach($resultLehrauftrag as $lehrauftrag) + { + $result = $this->LehreinheitmitarbeiterModel->update( + [ + 'lehreinheit_id' => $lehrauftrag->lehreinheit_id, + 'mitarbeiter_uid' => $lehrauftrag->mitarbeiter_uid, + 'vertrag_id' => $vertrag_id + ], + [ + 'vertrag_id' => null, + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ] + ); + + $this->getDataOrTerminateWithError($result); + } + } + + //if attached Betreuung + $this->load->model('education/Projektbetreuer_model', 'Projektbetreuermodel'); + + //if attached Betreuung + $resultBetreuung = $this->Projektbetreuermodel->load([ + 'vertrag_id' => $vertrag_id + ]); + + if(hasData($resultBetreuung)) + { + $resultBetreuung = getData($resultBetreuung); + foreach($resultBetreuung as $betreuung) + { + $result = $this->Projektbetreuermodel->update( + [ + 'person_id' => $betreuung->person_id, + 'projektarbeit_id' => $betreuung->projektarbeit_id, + 'betreuerart_kurzbz' => $betreuung->betreuerart_kurzbz, + 'vertrag_id' => $vertrag_id + ], + [ + 'vertrag_id' => null, + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + + ] + ); + + $this->getDataOrTerminateWithError($result); + } + } + + $result = $this->VertragvertragsstatusModel->load([ + 'vertrag_id' => $vertrag_id + ]); + + if(hasData($result)) + { + $data = getData($result); + foreach ($data as $item) + { + //delete all entries in lehre.tbl_vertrag_vertragsstatus + $result = $this->VertragvertragsstatusModel->delete([ + 'vertrag_id' => $vertrag_id, + 'vertragsstatus_kurzbz' => $item->vertragsstatus_kurzbz, + 'uid' => $item->uid + ]); + if(isError($result)) + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + } + + //delete Contract + $result = $this->VertragModel->delete( + array('vertrag_id' => $vertrag_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' => 'Vertrag_id']), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(current(getData($result))); + } + + public function insertContractStatus() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('vertragsstatus_kurzbz', 'vertragsstatus_kurzbz', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'vertragsstatus_kurzbz']) + ]); + $this->form_validation->set_rules('datum', 'Datum', 'required|is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Datum']), + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Datum']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $result = $this->VertragvertragsstatusModel->loadWhere( + array( + 'vertrag_id' => $this->input->post('vertrag_id'), + 'vertragsstatus_kurzbz' => $this->input->post('vertragsstatus_kurzbz') + ) + ); + + if (hasData($result)) + { + $this->terminateWithError($this->p->t('vertrag', 'error_statusVorhanden'), self::ERROR_TYPE_GENERAL); + } + + $status_result = $this->VertragvertragsstatusModel->insert([ + 'vertrag_id' => $this->input->post('vertrag_id'), + 'uid' => getAuthUID(), + 'vertragsstatus_kurzbz' => $this->input->post('vertragsstatus_kurzbz'), + 'insertamum' => date('c'), + 'insertvon' => getAuthUID(), + 'datum' => $this->input->post('datum') + ]); + + if (!$status_result) { + $this->terminateWithError('Fehler beim Hinzufügen des Vertragsstatus.'); + } + + return $this->terminateWithSuccess(current(getData($status_result))); + } + + public function deleteContractStatus() + { + $status = $this->input->post('vertragsstatus_kurzbz'); + $vertrag_id = $this->input->post('vertrag_id'); + + $result = $this->VertragvertragsstatusModel->delete( + array( + 'vertrag_id' => $vertrag_id, + 'vertragsstatus_kurzbz' => $status + ) + ); + + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if (!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'vertragsstatus_kurzb']), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(current(getData($result))); + } + + public function loadContractStatus() + { + $status = $this->input->get('vertragsstatus_kurzbz'); + $vertrag_id = $this->input->get('vertrag_id'); + + $result = $this->VertragvertragsstatusModel->loadWhere( + array( + 'vertrag_id' => $vertrag_id, + 'vertragsstatus_kurzbz' => $status + ) + ); + if (!$result) { + $this->terminateWithError('Status not existing'); + } + return $this->terminateWithSuccess(current(getData($result))); + } + + public function updateContractStatus() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('vertragsstatus_kurzbz', 'vertragsstatus_kurzbz', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'vertragsstatus_kurzbz']) + ]); + $this->form_validation->set_rules('datum', 'Datum', 'required|is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Datum']), + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Datum']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $status_result = $this->VertragvertragsstatusModel->update( + [ + 'vertrag_id' => $this->input->post('vertrag_id'), + 'vertragsstatus_kurzbz' => $this->input->post('vertragsstatus_kurzbz') + ], + [ + 'uid' => getAuthUID(), + 'updateamum' => date('c'), + 'updatevon' => getAuthUID(), + 'datum' => $this->input->post('datum') + ] + ); + + if (!$status_result) { + $this->terminateWithError('Fehler beim Updaten des Vertragsstatus.'); + } + + return $this->terminateWithSuccess(current(getData($status_result))); + } + + public function deleteLehrauftrag() + { + $lehreinheit_id = $this->input->post('lehreinheit_id'); + $mitarbeiter_uid = $this->input->post('mitarbeiter_uid'); + $vertrag_id = $this->input->post('vertrag_id'); + + $this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); + + //kein delete: ein update, bei dem die vertrag_id auf null gesetzt wird + $result = $this->LehreinheitmitarbeiterModel->update( + [ + 'lehreinheit_id' => $lehreinheit_id, + 'mitarbeiter_uid' => $mitarbeiter_uid, + 'vertrag_id' => $vertrag_id + ], + [ + 'vertrag_id' => null, + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ] + ); + + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if (!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Id_Lehrauftrag']), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(current(getData($result))); + } + + public function deleteBetreuung() + { + $person_id= $this->input->post('person_id'); + $projektarbeit_id = $this->input->post('projektarbeit_id'); + $betreuerart_kurzbz = $this->input->post('betreuerart_kurzbz'); + $vertrag_id = $this->input->post('vertrag_id'); + + $this->load->model('education/Projektbetreuer_model', 'Projektbetreuermodel'); + + $result = $this->Projektbetreuermodel->update( + [ + 'person_id' => $person_id, + 'projektarbeit_id' => $projektarbeit_id, + 'betreuerart_kurzbz' => $betreuerart_kurzbz, + 'vertrag_id' => $vertrag_id + ], + [ + 'vertrag_id' => null, + 'updateamum' => date('c'), + 'updatevon' => getAuthUID() + ] + ); + + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if (!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Id_Projektbetreuung']), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(current(getData($result))); + } + + public function getMitarbeiter() + { + $this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel'); + + $result = $this->Mitarbeitermodel->getPersonenWithContractDetails(); + + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + if (!hasData($result)) + { + //return data before PV21 (with filter fix angestellt, active and with bisverwendung) + $result = $this->Mitarbeitermodel->getPersonal(true, true, true); + if (isError($result)) + { + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + } + return $this->terminateWithSuccess(getData($result)); + } + + public function getPersonAbteilung($mitarbeiter_uid) + { + $this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel'); + + $result = $this->Mitarbeitermodel->getPersonAbteilung($mitarbeiter_uid); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } + + public function getLeitungOrg($oekurzbz) + { + $this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel'); + + $result = $this->Mitarbeitermodel->getLeitungOrg($oekurzbz); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } + + public function getHeader($person_id) + { + $this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel'); + + $result = $this->Mitarbeitermodel->getHeader($person_id); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } +} diff --git a/application/controllers/api/frontend/v1/vorlagen/Vorlagen.php b/application/controllers/api/frontend/v1/vorlagen/Vorlagen.php new file mode 100644 index 000000000..01edb33d1 --- /dev/null +++ b/application/controllers/api/frontend/v1/vorlagen/Vorlagen.php @@ -0,0 +1,63 @@ + ['admin:r', 'assistenz:r'], + 'getVorlagenByLoggedInUser' => ['admin:r', 'assistenz:r'], + ]); + + //Load Models + $this->load->model('system/Vorlage_model', 'VorlageModel'); + + // Additional Permission Checks + //TODO(manu) check permissions + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('form_validation'); + $this->load->library('VorlageLib'); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + } + + public function getVorlagen() + { + $this->load->model('system/Vorlage_model', 'VorlageModel'); + + $this->VorlageModel->addOrder('vorlage_kurzbz', 'ASC'); + + $result = $this->VorlageModel->loadWhere( + array( + 'mimetype' => 'text/html' + )); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getVorlagenByLoggedInUser() + { + //get oe of user + $uid = getAuthUID(); + $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $result = $this->BenutzerfunktionModel->getBenutzerfunktionByUid($uid, 'oezuordnung'); + + $data = $this->getDataOrTerminateWithError($result); + $oe_kurzbz = current($data); + + $result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz->oe_kurzbz); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + +} \ No newline at end of file diff --git a/application/core/FHCAPI_Controller.php b/application/core/FHCAPI_Controller.php index c1e57a0f2..6697953bc 100644 --- a/application/core/FHCAPI_Controller.php +++ b/application/core/FHCAPI_Controller.php @@ -81,8 +81,11 @@ class FHCAPI_Controller extends Auth_Controller // For JSON Requests (as opposed to multipart/form-data) get the $_POST variable from the input stream instead if ($this->input->get_request_header('Content-Type', true) == 'application/json') - $_POST = json_decode($this->security->xss_clean($this->input->raw_input_stream), true); - elseif (isset($_POST['_jsondata'])) { + { + $_POST = json_decode($this->input->raw_input_stream, true); + } + elseif (isset($_POST['_jsondata'])) + { $_POST = array_merge($_POST, json_decode($_POST['_jsondata'], true)); unset($_POST['_jsondata']); } @@ -223,6 +226,39 @@ class FHCAPI_Controller extends Auth_Controller return $result->retval; } + protected function terminateWithFileOutput($contenttype, $content, $filename=null) + { + $this->clearOutputBuffering(); + $this->output->set_status_header(200) + ->set_content_type($contenttype) + ->set_header('Expires: 0') + ->set_header('Cache-Control: no-store, no-cache, must-revalidate') + ->set_header('Pragma: public') + ->set_header('Content-Length: ' . strlen($content)); + + if($filename) + { + $cleanedfilename = preg_replace('/[^a-zA-Z0-9\-_.]/', '_', $filename); + $this->output->set_header('Content-Disposition: attachment; filename="' + . $cleanedfilename . '"'); + } + else + { + $this->output->set_header('Content-Disposition: inline'); + } + + $this->output->set_output($content) + ->_display(); + exit(); + } + + private function clearOutputBuffering() + { + while(ob_get_level() > 0) + { + ob_end_clean(); + } + } // --------------------------------------------------------------- // Security diff --git a/application/models/codex/Bisio_model.php b/application/models/codex/Bisio_model.php index 5ecd4bb51..1cff1dc54 100644 --- a/application/models/codex/Bisio_model.php +++ b/application/models/codex/Bisio_model.php @@ -44,27 +44,4 @@ class Bisio_model extends DB_Model else return success("Bisio not found"); } - - /** - * checks, if an (extension) table exists to avoid later errors - * @param String $schema like 'extension' - * @param String $table like 'tbl_mo_bisiozuordnung' - * @return boolean - */ - public function tableExists($schema, $table) - { - $params = array($schema, $table); - - $qry = "SELECT - 1 - FROM - information_schema.role_table_grants - WHERE - table_schema = ? - AND table_name = ?"; - - $result = $this->execQuery($qry, $params); - - return $result; - } } diff --git a/application/models/codex/Mobilitaetstyp_model.php b/application/models/codex/Mobilitaetstyp_model.php new file mode 100644 index 000000000..f93f588a0 --- /dev/null +++ b/application/models/codex/Mobilitaetstyp_model.php @@ -0,0 +1,14 @@ +dbTable = 'bis.tbl_mobilitaetstyp'; + $this->pk = 'mobilitaetstyp_kurzbz'; + } +} diff --git a/application/models/crm/Akte_model.php b/application/models/crm/Akte_model.php index 57b6e0665..601019d3a 100644 --- a/application/models/crm/Akte_model.php +++ b/application/models/crm/Akte_model.php @@ -92,7 +92,7 @@ class Akte_model extends DB_Model a.anmerkung, a.nachgereicht, a.nachgereicht_am, - CASE WHEN MAX(dp.dokument_kurzbz) IS NOT NULL THEN TRUE ELSE FALSE END AS accepted + CASE WHEN MAX(dp.dokument_kurzbz) IS NOT NULL THEN TRUE ELSE FALSE END AS accepted, FROM public.tbl_akte a INNER JOIN public.tbl_prestudent p USING(person_id) LEFT JOIN public.tbl_dokumentprestudent dp USING(prestudent_id, dokument_kurzbz) @@ -111,6 +111,61 @@ class Akte_model extends DB_Model return $this->execQuery($query, $parametersArray); } + /** + * getAktenAccepted FAS + */ + public function getAktenFAS($person_id, $dokument_kurzbz = null, $stg_kz = null, $prestudent_id = null, $returnInhalt = false) + { + $query = 'SELECT + a.akte_id, + a.bezeichnung, + a.dokument_kurzbz, + a.titel_intern, + a.anmerkung_intern, + a.insertamum as hochgeladenamum, + a.updatevon, a.insertvon, a.uid, + a.dms_id, a.anmerkung as infotext, + a.nachgereicht, + CASE + WHEN inhalt IS NOT NULL OR a.dms_id IS NOT NULL + THEN true + ELSE false + END AS vorhanden, + a.nachgereicht_am, + ausstellungsnation, formal_geprueft_amum, archiv, + signiert, stud_selfservice, akzeptiertamum, inhalt + FROM public.tbl_akte a + WHERE a.person_id = ?'; + + $parametersArray = array($person_id); + + if (!isEmptyString($dokument_kurzbz)) + { + $query .= " AND dokument_kurzbz = ? + AND dokument_kurzbz NOT IN ('Zeugnis','DiplSupp','Bescheid')"; + array_push($parametersArray, $dokument_kurzbz); + } + + if($stg_kz != null && $prestudent_id != null) + { + $query.= " AND dokument_kurzbz not in ( + SELECT dokument_kurzbz + FROM public.tbl_dokument + JOIN public.tbl_dokumentstudiengang USING(dokument_kurzbz) + WHERE studiengang_kz= ? + AND dokument_kurzbz NOT IN( + SELECT dokument_kurzbz FROM public.tbl_dokumentprestudent + JOIN public.tbl_dokument USING(dokument_kurzbz) + WHERE prestudent_id=?))"; + array_push($parametersArray, $stg_kz); + array_push($parametersArray, $prestudent_id); + } + + $query .= ' ORDER BY erstelltam'; + + return $this->execQuery($query, $parametersArray); + } + /** * getAktenAcceptedDms */ @@ -195,9 +250,9 @@ class Akte_model extends DB_Model } /** - * Liefert die Archivdokumente einer Person + * Liefert die Archivdokumente einer Person/mehrerer Personen * - * @param integer $person_id + * @param integer/array $person_id * @param boolean|null $signiert Wenn true werden nur Dokumente geliefert die digital signiert wurden. * @param boolean|null $stud_selfservice Wenn true werden nur Dokumente geliefert die Studierende selbst herunterladen duerfen. * @@ -237,10 +292,14 @@ class Akte_model extends DB_Model if ($stud_selfservice !== null) $this->db->where('stud_selfservice', (boolean)$stud_selfservice); + if (is_array($person_id)) + $this->db->where_in('person_id', $person_id); + else + $this->db->where('person_id', $person_id); + $this->addOrder('erstelltam', 'DESC'); return $this->loadWhere([ - 'person_id' => $person_id, 'archiv' => true ]); } diff --git a/application/models/crm/Dokument_model.php b/application/models/crm/Dokument_model.php index 7ef2be716..8008202c1 100644 --- a/application/models/crm/Dokument_model.php +++ b/application/models/crm/Dokument_model.php @@ -11,4 +11,91 @@ class Dokument_model extends DB_Model $this->dbTable = 'public.tbl_dokument'; $this->pk = 'dokument_kurzbz'; } + + /** + * Loads all missing Documents of a Studiengang + * a Prestudent has not submitted + * @param integer studiengang_kz + * @param integer prestudent_id + * @param boolean archivdokumente + * Default: true. + * If false, documents that are archivable (tbl_vorlage.archivierbar e.g. certificate, notice, ...) not retrieved + * @return Array of Documents || error + */ + public function getMissingDocuments($studiengang_kz, $prestudent_id = null, $archivdokumente = false, $person_id = null) + { + $parametersArray = array($studiengang_kz); + + $qry = "SELECT + tbl_dokument.* , + tbl_dokumentstudiengang.* + FROM public.tbl_dokument + JOIN public.tbl_dokumentstudiengang USING(dokument_kurzbz) + LEFT JOIN public.tbl_vorlage ON (tbl_dokument.dokument_kurzbz = tbl_vorlage.vorlage_kurzbz) + WHERE studiengang_kz = ? "; + + if($prestudent_id) + { + array_push($parametersArray, $prestudent_id); + $qry.=" AND tbl_dokument.dokument_kurzbz NOT IN ( + SELECT dokument_kurzbz FROM public.tbl_dokumentprestudent WHERE prestudent_id= ?)"; + } + + if(!$archivdokumente) + { + $qry.=" AND (tbl_vorlage.archivierbar = FALSE OR tbl_vorlage.archivierbar IS NULL)"; + } + + $qry.=" ORDER BY tbl_dokument.dokument_kurzbz;"; + + return $this->execQuery($qry, $parametersArray); + } + + public function getUnacceptedDocuments($prestudent_id, $person_id) + { + $parametersArray = array($person_id, $prestudent_id); + + $qry = " SELECT + a.akte_id, + a.bezeichnung, + a.dokument_kurzbz, + a.titel_intern, + a.anmerkung_intern, + a.insertamum as hochgeladenamum, + a.updatevon, + a.insertvon, + a.uid, + a.dms_id, + a.anmerkung as infotext, + a.nachgereicht, + CASE + WHEN inhalt IS NOT NULL + OR a.dms_id IS NOT NULL THEN true + ELSE false + END AS vorhanden, + a.nachgereicht_am, + ausstellungsnation, + formal_geprueft_amum, + archiv, + signiert, + stud_selfservice, + akzeptiertamum, + inhalt + FROM + public.tbl_akte a + WHERE + a.person_id = ? + AND a.dokument_kurzbz NOT IN ( + SELECT + dokument_kurzbz + FROM + public.tbl_dokumentprestudent + WHERE + prestudent_id = ? + ) + AND a.dokument_kurzbz NOT IN ('Zeugnis','DiplSupp','Bescheid') + ORDER BY a.dokument_kurzbz;"; + + return $this->execQuery($qry, $parametersArray); + } } diff --git a/application/models/crm/Dokumentprestudent_model.php b/application/models/crm/Dokumentprestudent_model.php index 0a6669359..6b1c222a8 100644 --- a/application/models/crm/Dokumentprestudent_model.php +++ b/application/models/crm/Dokumentprestudent_model.php @@ -69,4 +69,41 @@ class Dokumentprestudent_model extends DB_Model return $result; } + + /** + * Loads all Documents of Prestudent, already submitted + * @param integer prestudent_id + * @param boolean archivdokumente Default true. if false, archivable Documents (tbl_vorlage.archivierbar zB Zeugnis, Bescheid, ...) not retrieved + * @return Array of Documents || error + */ + public function getPrestudentDokumente($prestudent_id, $archivdokumente = true) + { + $parametersArray = array($prestudent_id); + + $qry = "SELECT + d.bezeichnung, + d.dokument_kurzbz, + dp.datum as Docdatum, + dp.mitarbeiter_uid as DocMitarbeiter_uid, + dp.insertamum as Docinsertamum, + dp.prestudent_id, + CONCAT(p.vorname, ' ', p.nachname) as insertvonma + FROM + public.tbl_dokumentprestudent dp + JOIN public.tbl_dokument d USING(dokument_kurzbz) + LEFT JOIN public.tbl_vorlage v ON (d.dokument_kurzbz = v.vorlage_kurzbz) + LEFT JOIN public.tbl_benutzer bn ON (bn.uid = dp.mitarbeiter_uid) + LEFT JOIN public.tbl_person p ON (p.person_id = bn.person_id) + WHERE + prestudent_id = ?"; + + if(!$archivdokumente) + { + $qry.=" AND (v.archivierbar = FALSE OR v.archivierbar IS NULL)"; + } + + $qry.=" ORDER BY d.bezeichnung ASC"; + + return $this->execQuery($qry, $parametersArray); + } } diff --git a/application/models/crm/Reihungstest_model.php b/application/models/crm/Reihungstest_model.php index 86ebfd0af..a685b01cd 100644 --- a/application/models/crm/Reihungstest_model.php +++ b/application/models/crm/Reihungstest_model.php @@ -511,4 +511,250 @@ class Reihungstest_model extends DB_Model return $this->execQuery($query, array($date, $studiengang_kz)); } -} \ No newline at end of file + + /** + * Loads all placement tests of a given person + * @param integer $person_id + * @return array Returns object array with data of placement tests + */ + public function getReihungstestPerson($person_id) + { + $query = ' + SELECT + tbl_rt_person.*, + tbl_reihungstest.studiengang_kz, + tbl_reihungstest.anmerkung, + tbl_reihungstest.datum, + tbl_reihungstest.uhrzeit, + tbl_reihungstest.ext_id, + tbl_reihungstest.max_teilnehmer, + tbl_reihungstest.oeffentlich, + tbl_reihungstest.freigeschaltet, + tbl_reihungstest.studiensemester_kurzbz as studiensemester, + tbl_reihungstest.stufe, + tbl_reihungstest.anmeldefrist, + tbl_reihungstest.aufnahmegruppe_kurzbz, + tbl_studiengang.typ, + UPPER(typ::varchar(1) || kurzbz) AS stg_kuerzel, + so.studiengangbezeichnung, + so.studiengangbezeichnung_englisch, + so.studiengangkurzbzlang + FROM + public.tbl_rt_person + JOIN public.tbl_reihungstest ON (rt_id=reihungstest_id) + JOIN public.tbl_studiengang ON tbl_reihungstest.studiengang_kz = tbl_studiengang.studiengang_kz + JOIN lehre.tbl_studienplan sp USING(studienplan_id) + JOIN lehre.tbl_studienordnung so USING(studienordnung_id) + WHERE + tbl_rt_person.person_id = ? + ORDER BY datum, uhrzeit ASC'; + + return $this->execQuery($query, array($person_id)); + } + + /** + * Calculates Result of Placement Test for a given Person and given placementtest + * and with taking account of weighting per area + * + * @param $person_id ID of Person + * @param $punkte if true result is points else result is percentage of sum + * @param $reihungstest_id ID of Placementtest + * @param $weightedArray array of weighting per area (gewicht per gebiet_id) + * @return float result + */ + public function getReihungstestErgebnisPerson($person_id, $punkte, $reihungstest_id, $weightedArray = null) + { + $parametersArray = array($reihungstest_id); + + $qry = " + SELECT DISTINCT ON (vw_auswertung_ablauf.gebiet_id) gebiet_id, + vw_auswertung_ablauf.*, + tbl_studiengang.typ + FROM + testtool.vw_auswertung_ablauf + JOIN + public.tbl_studiengang USING (studiengang_kz) + WHERE + reihungstest_id = ? "; + + //using prestudent Status to avoid to get the sum of more than 1 placement tests + $qry .= " + AND prestudent_id = ( + SELECT + prestudent_id + FROM + public.tbl_rt_person + JOIN + public.tbl_prestudent USING(person_id) + JOIN + public.tbl_prestudentstatus USING (prestudent_id, studienplan_id) + JOIN + tbl_reihungstest ON ( + tbl_rt_person.rt_id = tbl_reihungstest.reihungstest_id + ) + WHERE + tbl_rt_person.person_id = ? + AND + tbl_rt_person.rt_id = ? + AND + tbl_prestudentstatus.status_kurzbz = 'Interessent' + AND + tbl_prestudentstatus.studiensemester_kurzbz = tbl_reihungstest.studiensemester_kurzbz + ORDER BY tbl_reihungstest.datum DESC, tbl_prestudent.priorisierung ASC LIMIT 1 + ) + "; + array_push($parametersArray, $person_id); + array_push($parametersArray, $reihungstest_id); + + $resultRtPerson = $this->execQuery($qry, $parametersArray); + + $ergebnis = 0; + $summeGewicht = 0; + + foreach ($resultRtPerson->retval as $row) + { + $prozent = 0; + if($row->punkte>=$row->maxpunkte) + { + $prozent = 100; + $row->punkte = $row->maxpunkte; + } + else + $prozent = (($row->punkte + $row->offsetpunkte)/($row->maxpunkte + $row->offsetpunkte))*100; + + if($punkte == 'true') + { + if($row->punkte) + { + $ergebnis += $row->punkte; + } + } + else + { + if ($row->punkte) + { + $gew = isset($weightedArray[$row->gebiet_id]) ? $weightedArray[$row->gebiet_id] : 1; + $ergebnis += $prozent * $gew; + $summeGewicht += $gew; + } + } + } + $return = $summeGewicht > 0 + ? number_format($ergebnis/$summeGewicht, 4, '.', '') + : number_format($ergebnis, 4, '.', ''); + + return $return; + } + + /** + * returns Reihungstests for given studyplans and include_ids + * + * @param Array $studienplan_arr array of studienplaene + * @param Array $include_ids array of include_ids + * @return Array List of Reihungstests + */ + public function getReihungstestByStudyPlanAndIds($studienplan_arr, $include_ids = null) + { + $studienplan_ids_string = implode(',', $studienplan_arr); + $studienplan_arr = explode(',', $studienplan_ids_string); + + $parametersArray = array($studienplan_arr); + + $qry = " + SELECT + distinct a.*, + CASE EXTRACT(DOW FROM a.datum) + WHEN 0 THEN 'So' + WHEN 1 THEN 'Mo' + WHEN 2 THEN 'Di' + WHEN 3 THEN 'Mi' + WHEN 4 THEN 'Do' + WHEN 5 THEN 'Fr' + WHEN 6 THEN 'Sa' + END AS wochentag, + sg.kurzbzlang as stg, + ( + SELECT count(*) FROM public.tbl_rt_person + WHERE rt_id = a.reihungstest_id + ) as angemeldete_teilnehmer + FROM + public.tbl_reihungstest a + JOIN public.tbl_rt_studienplan USING(reihungstest_id) + JOIN public.tbl_studiengang sg USING(studiengang_kz) + WHERE studienplan_id IN ?"; + + if($include_ids && is_array($include_ids) && count($include_ids) > 0) + { + $include_ids_string = implode(',', $include_ids); + $include_ids = explode(',', $include_ids_string); + + array_push($parametersArray, $include_ids); + + $qry .= "OR reihungstest_id in ?"; + } + $qry .= "ORDER BY a.datum DESC"; + + return $this->execQuery($qry, $parametersArray); + } + /** + * returns Reihungstests for given studyplans and include_ids + * + * @param Integer $studiengang_kz + * @param $include_id optional (here null) + * @return Array List of Reihungstests + */ + public function getZukuenftigeReihungstestStg($studiengang_kz, $include_id = null) + { + $parametersArray = array($studiengang_kz, $studiengang_kz, $include_id); + + $qry = " + SELECT *, + CASE EXTRACT(DOW FROM a.datum) + WHEN 0 THEN 'So' + WHEN 1 THEN 'Mo' + WHEN 2 THEN 'Di' + WHEN 3 THEN 'Mi' + WHEN 4 THEN 'Do' + WHEN 5 THEN 'Fr' + WHEN 6 THEN 'Sa' + END AS wochentag, + ( + SELECT count(*) FROM public.tbl_prestudent + WHERE reihungstest_id=a.reihungstest_id + ) as angemeldete_teilnehmer + FROM + ( + SELECT *, '1' as sortierung, + ( + SELECT upper(typ || kurzbz) FROM public.tbl_studiengang + WHERE studiengang_kz=tbl_reihungstest.studiengang_kz + ) as stg + FROM + public.tbl_reihungstest + WHERE + datum>=now()-'1 days'::interval AND studiengang_kz=? + UNION + SELECT *, '2' as sortierung, + ( + SELECT upper(typ || kurzbz) FROM public.tbl_studiengang + WHERE studiengang_kz=tbl_reihungstest.studiengang_kz + ) as stg + FROM + public.tbl_reihungstest + WHERE datum>=now()-'1 days'::interval AND studiengang_kz!=? + UNION + SELECT *, '0' as sortierung, + ( + SELECT upper(typ || kurzbz) FROM public.tbl_studiengang + WHERE studiengang_kz=tbl_reihungstest.studiengang_kz + ) as stg + FROM + public.tbl_reihungstest + WHERE reihungstest_id=? + ORDER BY sortierung, stg, datum + ) a + "; + + return $this->execQuery($qry, $parametersArray); + } +} diff --git a/application/models/education/Anrechnung_model.php b/application/models/education/Anrechnung_model.php index cbfdb6607..0b81be80c 100644 --- a/application/models/education/Anrechnung_model.php +++ b/application/models/education/Anrechnung_model.php @@ -202,4 +202,66 @@ class Anrechnung_model extends DB_Model return success(); } + + /** + * Get Anrechnungsdata for Table Anrechnungen + * + * @param $prestudent_id + * @return array + */ + public function getAnrechnungsData($prestudent_id) + { + $qry = ' + SELECT + lehre.tbl_anrechnung.anrechnung_id, + lehre.tbl_anrechnung.prestudent_id, + lehre.tbl_anrechnung.lehrveranstaltung_id, + lehre.tbl_lehrveranstaltung.bezeichnung AS bez_lehrveranstaltung, + lehre.tbl_anrechnung_begruendung.bezeichnung AS begruendung, + lehre.tbl_anrechnung_anrechnungstatus.status_kurzbz AS status, + genehmigt_von, + lehre.tbl_anrechnung.insertamum, + lehre.tbl_anrechnung.insertvon, + lehre.tbl_anrechnung.updateamum, + lehre.tbl_anrechnung.updatevon, + lehrveranstaltung_id_kompatibel, + lv_comp.bezeichnung as lehrveranstaltung_bez_kompatibel, + count(nz.notizzuordnung_id) AS notizen_anzahl + FROM + lehre.tbl_anrechnung + JOIN lehre.tbl_lehrveranstaltung USING (lehrveranstaltung_id) + LEFT JOIN lehre.tbl_lehrveranstaltung lv_comp ON (lehre.tbl_anrechnung.lehrveranstaltung_id_kompatibel = lv_comp.lehrveranstaltung_id) + JOIN lehre.tbl_anrechnung_begruendung USING (begruendung_id) + LEFT JOIN lehre.tbl_anrechnung_anrechnungstatus ON (lehre.tbl_anrechnung_anrechnungstatus.anrechnung_id = lehre.tbl_anrechnung.anrechnung_id) + AND lehre.tbl_anrechnung_anrechnungstatus.insertamum = ( + SELECT MAX(insertamum) + FROM lehre.tbl_anrechnung_anrechnungstatus + WHERE anrechnung_id = lehre.tbl_anrechnung.anrechnung_id + ) + LEFT JOIN lehre.tbl_anrechnungstatus USING (status_kurzbz) + LEFT JOIN public.tbl_notizzuordnung nz ON (nz.anrechnung_id = lehre.tbl_anrechnung.anrechnung_id) + WHERE + lehre.tbl_anrechnung.prestudent_id = ? + GROUP BY + nz.anrechnung_id, + lehre.tbl_anrechnung.anrechnung_id, + lehre.tbl_anrechnung.prestudent_id, + lehre.tbl_anrechnung.lehrveranstaltung_id, + bez_lehrveranstaltung, + begruendung, + status, + genehmigt_von, + lehre.tbl_anrechnung.insertamum, + lehre.tbl_anrechnung.insertvon, + lehre.tbl_anrechnung.updateamum, + lehre.tbl_anrechnung.updatevon, + lehrveranstaltung_id_kompatibel, + lehrveranstaltung_bez_kompatibel + ORDER BY + lehre.tbl_anrechnung.updateamum ASC + '; + + return $this->execQuery($qry, array($prestudent_id)); + + } } diff --git a/application/models/education/Anrechnunganrechnungstatus_model.php b/application/models/education/Anrechnunganrechnungstatus_model.php new file mode 100644 index 000000000..68b319506 --- /dev/null +++ b/application/models/education/Anrechnunganrechnungstatus_model.php @@ -0,0 +1,14 @@ +dbTable = 'lehre.tbl_anrechnung_anrechnungstatus'; + $this->pk = 'anrechnungstatus_id'; + } +} diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index 056fb45d7..77ed7b4b0 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -988,4 +988,41 @@ class Lehrveranstaltung_model extends DB_Model return $this->execQuery($qry, $params); } + + /** + * Gets lehrveranstaltungen of Studienplan + * @param $studienplan_id ID des Studienplans + * @param $semester Semester optional + * @return array|null + */ + public function getLvsByStudienplanId($studienplan_id, $semester = null) + { + $params = array($studienplan_id); + + $qry = "SELECT tbl_lehrveranstaltung.*, + tbl_studienplan_lehrveranstaltung.studienplan_lehrveranstaltung_id, + tbl_studienplan_lehrveranstaltung.semester as stpllv_semester, + tbl_studienplan_lehrveranstaltung.pflicht as stpllv_pflicht, + tbl_studienplan_lehrveranstaltung.koordinator as stpllv_koordinator, + tbl_studienplan_lehrveranstaltung.studienplan_lehrveranstaltung_id_parent, + tbl_studienplan_lehrveranstaltung.sort stpllv_sort, + tbl_studienplan_lehrveranstaltung.curriculum, + tbl_studienplan_lehrveranstaltung.export, + tbl_studienplan_lehrveranstaltung.genehmigung + FROM lehre.tbl_lehrveranstaltung + JOIN lehre.tbl_studienplan_lehrveranstaltung + USING(lehrveranstaltung_id) + WHERE tbl_studienplan_lehrveranstaltung.studienplan_id = ? + "; + + if ($semester !== null) + { + $qry.= " AND tbl_studienplan_lehrveranstaltung.semester = ?"; + $params[] = $semester; + } + + $qry .= " ORDER BY stpllv_sort, semester, sort"; + + return $this->execQuery($qry, $params); + } } diff --git a/application/models/organisation/Organisationseinheit_model.php b/application/models/organisation/Organisationseinheit_model.php index 1b1a826aa..ba91964f6 100644 --- a/application/models/organisation/Organisationseinheit_model.php +++ b/application/models/organisation/Organisationseinheit_model.php @@ -191,7 +191,7 @@ class Organisationseinheit_model extends DB_Model /** * @param string $oe_kurzbz - * + * * @return stdClass */ public function getWithType($oe_kurzbz) @@ -203,18 +203,14 @@ class Organisationseinheit_model extends DB_Model } /** - * Get OEs by eventQuery string. Use with autocomplete event queries. - * @param $eventQuery String - * @return array + * get highest organisation units */ - public function getAutocompleteSuggestions($eventQuery) + public function getHeads() { - $this->addSelect('oe_kurzbz'); - $this->addSelect('organisationseinheittyp_kurzbz, oe_kurzbz, bezeichnung, aktiv, lehre'); - $this->addOrder('organisationseinheittyp_kurzbz, bezeichnung'); + $this->addSelect('*'); + $this->addSelect('oe_kurzbz as head'); + $result = $this->loadWhere(array('oe_parent_kurzbz' => null, 'aktiv' => true)); - return $this->loadWhere(" - oe_kurzbz ILIKE '%". $this->escapeLike($eventQuery). "%' - "); + return $result; } } diff --git a/application/models/organisation/Studienplan_model.php b/application/models/organisation/Studienplan_model.php index e35ba52fb..569aebd0b 100644 --- a/application/models/organisation/Studienplan_model.php +++ b/application/models/organisation/Studienplan_model.php @@ -134,4 +134,17 @@ class Studienplan_model extends DB_Model 'prestudent_id' => $prestudent_id ]); } + + public function getStudienplaeneForPerson($person_id) + { + $this->addDistinct(); + $this->addSelect($this->dbTable . '.*'); + $this->addSelect('ps.*'); + $this->addJoin('public.tbl_prestudentstatus pss', 'studienplan_id'); + $this->addJoin('public.tbl_prestudent ps', 'prestudent_id'); + + return $this->loadWhere([ + 'person_id' => $person_id + ]); + } } diff --git a/application/models/person/Benutzergruppe_model.php b/application/models/person/Benutzergruppe_model.php index fba797641..271402ffe 100644 --- a/application/models/person/Benutzergruppe_model.php +++ b/application/models/person/Benutzergruppe_model.php @@ -33,4 +33,16 @@ class Benutzergruppe_model extends DB_Model $uids = (hasData($res)) ? getData($res) : array(); return $uids; } + + /** + * Laedt die Aufnahmegruppe(n) in Abhängigkeit von User und Studiensemester + * @param uid, gruppe_kurzbz, studiensemester_kurzbz + * @return array + */ + public function loadAufnahmegruppen($uid, $stsem) + { + $query = " + SELECT * FROM tbl_gruppe WHERE aufnahmegruppe=true;"; + return $this->execReadOnlyQuery($query); + } } diff --git a/application/models/person/Notiz_model.php b/application/models/person/Notiz_model.php index 2e99d1cdd..1835296fe 100644 --- a/application/models/person/Notiz_model.php +++ b/application/models/person/Notiz_model.php @@ -154,8 +154,21 @@ class Notiz_model extends DB_Model public function getNotizWithDocEntries($id, $type) { $qry = " - SELECT - n.*, count(dms_id) as countDoc, z.notizzuordnung_id, + SELECT + n.*, + CASE + WHEN person_verfasser.vorname IS NOT NULL AND person_verfasser.vorname != '' + OR person_verfasser.nachname IS NOT NULL AND person_verfasser.nachname != '' + THEN CONCAT(person_verfasser.vorname, ' ', person_verfasser.nachname) + ELSE NULL + END AS verfasser, + CASE + WHEN person_bearbeiter.vorname IS NOT NULL AND person_bearbeiter.vorname != '' + OR person_bearbeiter.nachname IS NOT NULL AND person_bearbeiter.nachname != '' + THEN CONCAT(person_bearbeiter.vorname, ' ', person_bearbeiter.nachname) + ELSE NULL + END AS bearbeiter, + count(dms_id) as countDoc, z.notizzuordnung_id, (CASE WHEN n.updateamum >= n.insertamum THEN n.updateamum ELSE n.insertamum @@ -173,10 +186,20 @@ class Notiz_model extends DB_Model public.tbl_notiz_dokument dok USING (notiz_id) LEFT JOIN campus.tbl_dms_version USING (dms_id) + LEFT JOIN + public.tbl_benutzer p_verfasser ON (p_verfasser.uid = n.verfasser_uid) + LEFT JOIN + public.tbl_person person_verfasser ON (person_verfasser.person_id = p_verfasser.person_id) + LEFT JOIN + public.tbl_benutzer p_bearbeiter ON (p_bearbeiter.uid = n.bearbeiter_uid) + LEFT JOIN + public.tbl_person person_bearbeiter ON (person_bearbeiter.person_id = p_bearbeiter.person_id) WHERE z.$type = ? GROUP BY - notiz_id, z.notizzuordnung_id + notiz_id, z.notizzuordnung_id, + person_verfasser.vorname, person_verfasser.nachname, + person_bearbeiter.vorname, person_bearbeiter.nachname "; return $this->execQuery($qry, array($type, $id)); diff --git a/application/models/ressource/Mitarbeiter_model.php b/application/models/ressource/Mitarbeiter_model.php index 836f5d65a..bf4672070 100644 --- a/application/models/ressource/Mitarbeiter_model.php +++ b/application/models/ressource/Mitarbeiter_model.php @@ -12,34 +12,34 @@ class Mitarbeiter_model extends DB_Model $this->pk = 'mitarbeiter_uid'; } - /** - * Checks if the user is a Mitarbeiter. - * @param string $uid - * @param boolean null $fixangestellt - * @return array - */ - public function isMitarbeiter($uid, $fixangestellt = null) - { - $this->addSelect('1'); + /** + * Checks if the user is a Mitarbeiter. + * @param string $uid + * @param boolean null $fixangestellt + * @return array + */ + public function isMitarbeiter($uid, $fixangestellt = null) + { + $this->addSelect('1'); - if (is_bool($fixangestellt)) - { - $result = $this->loadWhere(array('mitarbeiter_uid' => $uid, 'fixangestellt' => $fixangestellt)); - } - else // default - { - $result = $this->loadWhere(array('mitarbeiter_uid' => $uid)); - } + if (is_bool($fixangestellt)) + { + $result = $this->loadWhere(array('mitarbeiter_uid' => $uid, 'fixangestellt' => $fixangestellt)); + } + else // default + { + $result = $this->loadWhere(array('mitarbeiter_uid' => $uid)); + } - if(hasData($result)) - { - return success(true); - } - else - { - return success(false); - } - } + if(hasData($result)) + { + return success(true); + } + else + { + return success(false); + } + } /** * Laedt das Personal @@ -98,6 +98,129 @@ class Mitarbeiter_model extends DB_Model return $this->execQuery($qry, $params); } + /** + * gibt Personen mit Übersicht von Vertragsdaten aus + * + * @return array + */ + public function getPersonenWithContractDetails($person_id = null) + { + $qry = " + SELECT + b.uid , p.person_id, + p.vorname, p.nachname, + gebdatum, + COALESCE(b.alias, b.uid) AS email, + STRING_AGG(DISTINCT va.bezeichnung, ', ') AS Vertragsarten, + STRING_AGG(DISTINCT u.bezeichnung, ', ') AS Unternehmen, + STRING_AGG(d.dienstverhaeltnis_id::TEXT, ', ') AS ids, + b.aktiv + FROM + hr.tbl_dienstverhaeltnis d + JOIN + public.tbl_benutzer b ON d.mitarbeiter_uid = b.uid + JOIN + public.tbl_person p ON p.person_id = b.person_id + JOIN + public.tbl_organisationseinheit u ON d.oe_kurzbz = u.oe_kurzbz + JOIN + hr.tbl_vertragsart va ON d.vertragsart_kurzbz = va.vertragsart_kurzbz + "; + + if($person_id) + { + $qry .= " WHERE p.person_id = ?"; + } + + $qry.= " + GROUP BY + b.uid, p.person_id, p.vorname, p.nachname, b.alias + ORDER BY + p.nachname, p.vorname; + "; + + $params = array($person_id); + + return $this->execQuery($qry, $params); + } + + /** + * get current disciplinary Abteilung of person + * + * @param $person_id + * + * @return Array benutzerfunktionsdata + */ + public function getPersonAbteilung($uid) + { + $qry = " + SELECT + bf.benutzerfunktion_id, bf.fachbereich_kurzbz, bf.uid, bf.funktion_kurzbz, bf.updateamum, + bf.updatevon, bf.insertamum, bf.insertvon, bf.ext_id, bf.semester, bf.oe_kurzbz, + bf.datum_von, bf.datum_bis, bf.bezeichnung, bf.wochenstunden, + oe.oe_kurzbz, oe.oe_parent_kurzbz, oe.bezeichnung, + oe.organisationseinheittyp_kurzbz, oe.aktiv, oe.mailverteiler, + oe.freigabegrenze, oe.kurzzeichen, oe.lehre, oe.standort, + oe.warn_semesterstunden_frei, oe.warn_semesterstunden_fix, oe.standort_id + FROM tbl_benutzerfunktion bf + JOIN public.tbl_organisationseinheit oe USING(oe_kurzbz) + WHERE uid = ? + AND funktion_kurzbz = 'oezuordnung' + AND datum_von <= NOW() + AND (datum_bis IS NULL OR datum_bis >= NOW()) + "; + $result = $this->execQuery($qry, [$uid]); + + return $result; + } + + /** + * get Leitung / Vorgesetzten of current OE + * + * @param $oe_kurzbz + * + * @return Array persondata / benutzerfunktionsdata + */ + public function getLeitungOrg($oe_kurzbz) + { + $qry = " + SELECT bf.benutzerfunktion_id,bf.fachbereich_kurzbz,bf.uid,bf.funktion_kurzbz, + bf.updateamum,bf.updatevon,bf.insertamum,bf.insertvon,bf.ext_id,bf.semester, + bf.oe_kurzbz,bf.datum_von,bf.datum_bis,bf.bezeichnung,bf.wochenstunden, + p.person_id, p.vorname,p.nachname,p.titelpre,p.titelpost + FROM public.tbl_benutzerfunktion bf JOIN public.tbl_organisationseinheit oe USING(oe_kurzbz) + JOIN public.tbl_benutzer b USING (uid) JOIN public.tbl_mitarbeiter ma ON(b.uid=ma.mitarbeiter_uid) + JOIN public.tbl_person p USING(person_id) + WHERE funktion_kurzbz='Leitung' AND oe.oe_kurzbz = ? + AND datum_von<=now() AND (datum_bis is null OR datum_bis>=now()); + "; + + return $this->execQuery($qry, array($oe_kurzbz)); + } + + /** + * get persondata for person_id + * + * @param $oe_kurzbz + * + * @return Array persondata + */ + public function getHeader($person_id) + { + $qry = " + SELECT + titelpre, vorname, nachname, titelpost, foto, foto_sperre, person_id, alias, telefonklappe + FROM + public.tbl_person + JOIN public.tbl_benutzer b USING(person_id) + JOIN public.tbl_mitarbeiter ma ON (ma.mitarbeiter_uid = b.uid) + WHERE + person_id = ? + "; + + return $this->execQuery($qry, array($person_id)); + } + /** * Gibt ein Array mit den UIDs der Vorgesetzten zurück * @return object @@ -213,7 +336,7 @@ class Mitarbeiter_model extends DB_Model if (hasData($kurzbzexists) && getData($kurzbzexists)[0]) return error('No Kurzbezeichnung could be generated'); - + return success($kurzbz); } @@ -240,13 +363,13 @@ class Mitarbeiter_model extends DB_Model $qry = " SELECT " . $returnwert . " FROM - public.tbl_mitarbeiter ma + public.tbl_mitarbeiter ma JOIN - public.tbl_benutzer b on (ma.mitarbeiter_uid = b.uid) + public.tbl_benutzer b on (ma.mitarbeiter_uid = b.uid) JOIN - public.tbl_person p on (p.person_id = b.person_id) + public.tbl_person p on (p.person_id = b.person_id) WHERE - lower (p.nachname) LIKE '%". $this->db->escape_like_str($filter)."%' + lower (p.nachname) LIKE '%". $this->db->escape_like_str($filter)."%' OR lower (p.vorname) LIKE '%". $this->db->escape_like_str($filter)."%' OR @@ -261,14 +384,14 @@ class Mitarbeiter_model extends DB_Model * @param $lehrveranstaltung_id * @return array with Mitarbeiter and their Lehreinheiten */ - public function getMitarbeiterFromLV($lehrveranstaltung_id){ - //TODO(manu) maybe filter that in pruefungslist.js ? - $qry = "SELECT DISTINCT - lehrveranstaltung_id, uid, vorname, wahlname, vornamen, nachname, titelpre, titelpost, kurzbz, mitarbeiter_uid + public function getMitarbeiterFromLV($lehrveranstaltung_id) + { + $qry = "SELECT DISTINCT + lehrveranstaltung_id, uid, vorname, wahlname, vornamen, nachname, titelpre, titelpost, kurzbz, mitarbeiter_uid FROM - lehre.tbl_lehreinheitmitarbeiter, campus.vw_mitarbeiter, lehre.tbl_lehreinheit + lehre.tbl_lehreinheitmitarbeiter, campus.vw_mitarbeiter, lehre.tbl_lehreinheit WHERE - lehrveranstaltung_id= ? + lehrveranstaltung_id= ? AND mitarbeiter_uid=uid AND @@ -278,4 +401,33 @@ class Mitarbeiter_model extends DB_Model return $this->execQuery($qry, $parametersArray); } + + /** + * Get Lektoren by studiengang_kz + * + * @param $studiengang_kz + * @return array with Mitarbeiter + */ + public function getLektoren($studiengang_kz) + { + $qry = " + SELECT DISTINCT + campus.vw_mitarbeiter.uid, + campus.vw_mitarbeiter.vorname, + campus.vw_mitarbeiter.nachname, + studiengang_kz, + tbl_studiengang.typ, + tbl_studiengang.kurzbz AS stg_kurzbz + FROM + campus.vw_mitarbeiter + JOIN public.tbl_benutzerfunktion USING (uid) + JOIN public.tbl_studiengang USING(oe_kurzbz) + WHERE studiengang_kz = ? + AND lektor is true + ORDER BY campus.vw_mitarbeiter.nachname"; + + $parametersArray = array($studiengang_kz); + + return $this->execQuery($qry, $parametersArray); + } } diff --git a/application/models/ressource/Stundenplan_model.php b/application/models/ressource/Stundenplan_model.php index 012ce0a57..ac20c96c3 100644 --- a/application/models/ressource/Stundenplan_model.php +++ b/application/models/ressource/Stundenplan_model.php @@ -50,7 +50,6 @@ class Stundenplan_model extends DB_Model */ public function groupedCalendarEvents($ort_kurzbz,$start_date,$end_date){ - $gruppierteEvents= $this->execReadOnlyQuery(" SELECT @@ -186,6 +185,99 @@ class Stundenplan_model extends DB_Model return $query_result; } + /** + * groups rows of a subquery that fetches data from the lehre.vw_stundenplan table or lehre.vw_stundenplandev + * @param string $stundenplanViewQuery the subquery used to group the result regarding consecutive hours (Tab LV Termine) + * + * @return stdClass + */ + public function stundenplanGruppierungConsecutive($stundenplanViewQuery) + { + $query_result = $this->execReadOnlyQuery(" + SELECT + distinct lehrveranstaltung_id, + datum, + MIN(beginn) as beginn, + MAX(ende) as ende, + type, + topic, + gruppe, + ort_kurzbz, + lehreinheit_id, + lehrfach_bez, + lektor, + lektorname, + gruppen_kuerzel, + farbe + FROM + ( + SELECT + 'lehreinheit' as type, beginn, ende, datum, + CONCAT(lehrfach,'-',lehrform) as topic, + array_agg(DISTINCT lektor) as lektor, + array_agg(DISTINCT lektorname) as lektorname, + array_agg(DISTINCT (gruppe,verband,semester,studiengang_kz,gruppen_kuerzel)) as gruppe, + array_agg(DISTINCT (gruppen_kuerzel)) as gruppen_kuerzel, + string_agg(DISTINCT ort_kurzbz, '/') as ort_kurzbz, + array_agg(DISTINCT lehreinheit_id) as lehreinheit_id, + titel, lehrfach, lehrform, lehrfach_bez, organisationseinheit, farbe, lehrveranstaltung_id + + FROM + ( + SELECT unr,datum,beginn, ende, + CASE + WHEN sp.mitarbeiter_kurzbz IS NOT NULL THEN sp.mitarbeiter_kurzbz + ELSE lektor + END as lektor, + CASE + WHEN gruppe_kurzbz IS NOT NULL THEN gruppe_kurzbz + ELSE (SELECT UPPER(typ || kurzbz) + FROM public.tbl_studiengang + WHERE studiengang_kz=sp.studiengang_kz) || COALESCE(sp.semester,'0') || COALESCE(sp.verband,'') || COALESCE(sp.gruppe,'') + END as gruppen_kuerzel, + (SELECT bezeichnung + FROM public.tbl_organisationseinheit + WHERE oe_kurzbz IN( + SELECT oe_kurzbz + FROM lehre.tbl_lehrveranstaltung + WHERE lehrveranstaltung_id = sp.lehrveranstaltung_id + )) as organisationseinheit, + ort_kurzbz, studiengang_kz, titel,lehreinheit_id,lehrfach_id,sp.anmerkung,fix,lehrveranstaltung_id, + stg_kurzbzlang,stg_bezeichnung,stg_typ,fachbereich_kurzbz,lehrfach,lehrfach_bez,farbe,lehrform, + anmerkung_lehreinheit,gruppe, verband, semester,stg_kurzbz, + CONCAT(p.nachname, ' ', p.vorname) as lektorname + + FROM (".$stundenplanViewQuery.") sp + JOIN lehre.tbl_stunde ON lehre.tbl_stunde.stunde = sp.stunde + LEFT JOIN public.tbl_benutzer bn ON bn.uid = sp.uid + LEFT JOIN public.tbl_person p ON p.person_id = bn.person_id + ) as subquery + + GROUP BY unr, datum, beginn, ende, ort_kurzbz, titel, lehrform, lehrfach, lehrfach_bez, organisationseinheit, + farbe, lehrveranstaltung_id + + ORDER BY datum, beginn) t + + GROUP BY + lehrveranstaltung_id, + type, + datum, + topic, + lektor, + lehrfach_bez, + gruppe, + ort_kurzbz, + lehreinheit_id, + lektorname, + gruppen_kuerzel, + farbe + ORDER BY + datum, beginn + " + ); + return $query_result; + } + /** * queries Stundenplan but for a whole lva, irrespective of who is requesting it * @@ -300,10 +392,13 @@ class Stundenplan_model extends DB_Model /** * NO STANDALONE FUNCTION - Generates a SQL query string to fetch 'stundenplan' events for a specific student within the current semester. * + * @param isLvList if condition needed for Tab LV Termine is given + * @param db_stpl_table enables switch to db 'stundenplandev' + * * @return mixed */ - public function getStundenplanQuery($start_date, $end_date,$semester,$gruppen,$studentlehrverbaende){ - + public function getStundenplanQuery($start_date, $end_date, $semester, $gruppen, $studentlehrverbaende, $isLvList=false, $db_stpl_table='stundenplan'){ + // helper function to check if either $gruppen or $studentlehrverbaende are empty for each semester $emptyCheck = function($toBeCheckedArray) use ($semester){ $result = true; @@ -325,7 +420,7 @@ class Stundenplan_model extends DB_Model $query = "select sp.* - from lehre.vw_stundenplan sp + from lehre.vw_".$db_stpl_table." sp WHERE sp.datum >= ".$this->escape($start_date)." AND sp.datum <= ".$this->escape($end_date); @@ -335,10 +430,10 @@ class Stundenplan_model extends DB_Model { $query .= " AND ( "; } - + foreach($semester as $sem => $semester_date_range) { - + foreach($semester_date_range as $sem_date => $sem_date_range) { // if there are not groups for the semester skip the iteration step @@ -358,7 +453,13 @@ class Stundenplan_model extends DB_Model { $query = substr($query, 0, -2); } - + + //Condition for showLVList FHC4 + if(!$isLvList) + $stringGroupLv = "AND gruppe_kurzbz is null"; + else + $stringGroupLv =""; + foreach($semester as $sem=>$semester_date_range) { foreach($semester_date_range as $sem_date => $sem_date_range) @@ -373,10 +474,10 @@ class Stundenplan_model extends DB_Model // Eintraege fuer den ganzen Verband $query .= "OR (sp.studiengang_kz = ".$this->escape($lehrverband->studiengang_kz)." AND sp.semester = ".$this->escape($lehrverband->semester)." AND sp.verband = ".$this->escape($lehrverband->verband)." AND (sp.gruppe is null OR sp.gruppe='') AND sp.datum BETWEEN ".$this->escape($sem_date_range->start)." AND ".$this->escape($sem_date_range->ende).")"; // Eintraege fuer das ganze Semester - $query .= "OR (sp.studiengang_kz = ".$this->escape($lehrverband->studiengang_kz)." AND sp.semester = ".$this->escape($lehrverband->semester)." AND (sp.verband is null OR sp.verband='') AND sp.datum BETWEEN ".$this->escape($sem_date_range->start)." AND ".$this->escape($sem_date_range->ende).") AND gruppe_kurzbz is null)"; - + $query .= "OR (sp.studiengang_kz = ".$this->escape($lehrverband->studiengang_kz)." AND sp.semester = ".$this->escape($lehrverband->semester)." AND (sp.verband is null OR sp.verband='') AND sp.datum BETWEEN ".$this->escape($sem_date_range->start) + ." AND ".$this->escape($sem_date_range->ende).")". $stringGroupLv. ")"; + $query .="OR"; - } } } @@ -434,5 +535,4 @@ class Stundenplan_model extends DB_Model return $this->execQuery($query, [$uid, $uid]); } - } diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index d9f8585ed..e0a185f9b 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -85,7 +85,7 @@ class Message_model extends DB_Model */ public function getMessagesOfPerson($person_id, $status = null) { - $sql = 'SELECT m.message_id, + $sql = "SELECT m.message_id, m.person_id, m.subject, m.body, @@ -122,7 +122,7 @@ class Message_model extends DB_Model ) s ON (m.message_id = s.message_id AND re.person_id = s.person_id) WHERE se.person_id = ? OR re.person_id = ? - '; + "; if (is_numeric($status)) { @@ -230,4 +230,135 @@ class Message_model extends DB_Model return $this->execQuery($query, $params); } + + /** + * Gets messages for a person for tableMessages. + * @param $person_id + * paginationInitialPage: 1, + * @param $offset number to skip, calculated by tabulatorParam paginationInitialPage and paginationSize, refers to specified numer of skipped items + * and page + * @param $limit refers to tabulatorParam paginationSize + * @return array|null + */ + public function getMessagesForTable($person_id, $offset, $limit) + { + $sql_base = " + SELECT + m.message_id AS message_id, + m.subject AS subject, + m.body AS body, + m.insertamum AS insertamum, + m.relationmessage_id AS relationmessage_id, + (SELECT COALESCE(titelpre,'') || ' ' || COALESCE(vorname,'') || ' ' || COALESCE(nachname,'') || ' ' || COALESCE(titelpost,'') FROM public.tbl_person WHERE person_id = m.person_id) as sender, + (SELECT COALESCE(titelpre,'') || ' ' || COALESCE(vorname,'') || ' ' || COALESCE(nachname,'') || ' ' || COALESCE(titelpost,'') FROM public.tbl_person WHERE person_id = r.person_id) as recipient, + m.person_id as sender_id, + r.person_id as recipient_id, + MAX(ss.status) as status, + MAX(ss.insertamum) as statusdatum + FROM public.tbl_msg_message m + JOIN public.tbl_msg_recipient r USING(message_id) + JOIN public.tbl_msg_status ss ON(r.message_id = ss.message_id AND ss.person_id = r.person_id) + WHERE m.person_id = ? + GROUP BY m.message_id, m.subject, m.body, m.insertamum, m.relationmessage_id, sender, recipient, sender_id, recipient_id + UNION ALL + SELECT + m.message_id AS message_id, + m.subject AS subject, + m.body AS body, + m.insertamum AS insertamum, + m.relationmessage_id AS relationmessage_id, + (SELECT COALESCE(titelpre,'') || ' ' || COALESCE(vorname,'') || ' ' || COALESCE(nachname,'') || ' ' || COALESCE(titelpost,'') FROM public.tbl_person WHERE person_id = m.person_id) as sender, + (SELECT COALESCE(titelpre,'') || ' ' || COALESCE(vorname,'') || ' ' || COALESCE(nachname,'') || ' ' || COALESCE(titelpost,'') FROM public.tbl_person WHERE person_id = r.person_id) as recipient, + m.person_id as sender_id, + r.person_id as recipient_id, + MAX(ss.status) as status, + MAX(ss.insertamum) as statusdatum + FROM public.tbl_msg_recipient r + JOIN public.tbl_msg_status ss USING(message_id, person_id) + JOIN public.tbl_msg_message m USING(message_id) + WHERE r.person_id = ? + GROUP BY m.message_id, m.subject, m.body, m.insertamum, m.relationmessage_id, sender, recipient, sender_id, recipient_id + "; + $sql = " + SELECT COUNT(*) AS count FROM ( + " . $sql_base . " + ) a + "; + + $parametersArray = array($person_id, $person_id); + + $count = $this->execQuery($sql, $parametersArray); + + if (isError($count)) + return $count; + + $count = ceil(current(getData($count))->count/$limit); + $sql = " + SELECT * FROM ( + " . $sql_base . " + ) a + ORDER BY insertamum DESC + LIMIT ? + OFFSET ? + "; + + $parametersArray = array($person_id, $person_id, $limit, $offset); + + $data = $this->execQuery($sql, $parametersArray); + + if (isError($data)) + return $data; + + $data = getData($data); + + return success(['data' => $data, 'count' => $count]); + } + + /** + * Deletes entry in dependency table tbl_msg_recipient + * + * @param $message_id + * @return boolean success + */ + public function deleteMessageRecipient($message_id) + { + $sql = " + DELETE FROM public.tbl_msg_recipient + WHERE message_id = ?; + "; + + return $this->execQuery($sql, array($message_id)); + } + + /** + * Deletes entry in dependency table tbl_msg_status + * + * @param $message_id + * @return boolean success + */ + public function deleteMessageStatus($message_id) + { + $sql = " + DELETE FROM public.tbl_msg_status + WHERE message_id = ?; + "; + + return $this->execQuery($sql, array($message_id)); + } + /** + * Deletes entry in dependency table tbl_msg_message + * + * @param $message_id + * @return boolean success + */ + public function deleteMessage($message_id) + { + $sql = " + DELETE FROM public.tbl_msg_message + WHERE message_id = ?; + "; + + return $this->execQuery($sql, array($message_id)); + } + } diff --git a/application/models/system/Vorlage_model.php b/application/models/system/Vorlage_model.php index 8022e71fc..e3c00818a 100644 --- a/application/models/system/Vorlage_model.php +++ b/application/models/system/Vorlage_model.php @@ -13,7 +13,7 @@ class Vorlage_model extends DB_Model } /** - * Returns mume types + * Returns mime types */ public function getMimeTypes() { @@ -21,4 +21,130 @@ class Vorlage_model extends DB_Model return $this->execQuery($query); } + + /** + * Returns all Vorlagen for archive + */ + public function getArchivVorlagen() + { + $query ="SELECT * FROM public.tbl_vorlage WHERE archivierbar=true ORDER BY bezeichnung"; + + return $this->execQuery($query); + } + + /** + * Returns all Vorlagen + * that belongs to the organisation units of the user + * and the parents of those organisation units until the root of the + * @param Array Array of $oe_kurzbz + * @return object Array of Vorlagen + */ + public function getAllVorlagenByOe($oe_kurzbz) + { + // Loads library OrganisationseinheitLib + $this->load->library('OrganisationseinheitLib'); + + $vorlage = success(array()); // Default value + + $table = '( + SELECT v.vorlage_kurzbz, + v.bezeichnung, + vs.version, + vs.oe_kurzbz, + vs.aktiv, + vs.subject, + vs.text, + v.mimetype + FROM tbl_vorlagestudiengang vs + JOIN tbl_vorlage v USING(vorlage_kurzbz) + ) templates'; + + $alias = 'templates'; + + $fields = array( + 'templates.vorlage_kurzbz AS id', + 'templates.bezeichnung || \' (\' || UPPER(templates.oe_kurzbz) || \')\' AS description' + ); + + $where = 'templates.aktiv = TRUE + AND templates.subject IS NOT NULL + AND templates.text IS NOT NULL + AND templates.mimetype = \'text/html\' + GROUP BY 1, 2, 3'; + + $order_by = 'description ASC'; + + if (!is_array($oe_kurzbz)) + { + $vorlage = $this->organisationseinheitlib->treeSearchEntire( + $table, + $alias, + $fields, + $where, + $order_by, + $oe_kurzbz + ); + } + else // is an array + { + // Get the vorlage for each organisation unit + foreach($oe_kurzbz as $val) + { + $tmpVorlage = $this->organisationseinheitlib->treeSearchEntire( + $table, + $alias, + $fields, + $where, + $order_by, + $val + ); + + // Everything is ok and data are inside + if (hasData($tmpVorlage)) + { + // If it's the first vorlage copy it + if (!hasData($vorlage)) + { + for ($j = 0; $j < count(getData($tmpVorlage)); $j++) + { + if (getData($tmpVorlage)[$j]->id != '') + { + array_push($vorlage->retval, getData($tmpVorlage)[$j]); + } + } + } + else // checks for duplicates, if it's not already present push it into the array getData($vorlage) + { + for ($j = 0; $j < count(getData($tmpVorlage)); $j++) + { + $found = false; + $currentTmpVorlageData = null; + + for ($i = 0; $i < count(getData($vorlage)); $i++) + { + $currentTmpVorlageData = getData($tmpVorlage)[$j]; + + if (getData($vorlage)[$i]->id == getData($tmpVorlage)[$j]->id + && getData($vorlage)[$i]->_pk == getData($tmpVorlage)[$j]->_pk + && getData($vorlage)[$i]->_ppk == getData($tmpVorlage)[$j]->_ppk + && getData($vorlage)[$i]->_jtpk == getData($tmpVorlage)[$j]->_jtpk) + { + $found = true; + break; + } + } + + if (!$found && $currentTmpVorlageData->id != '') + { + array_push($vorlage->retval, $currentTmpVorlageData); + } + } + } + } + } + } + + return $vorlage; + } + } diff --git a/application/models/testtool/Ablauf_model.php b/application/models/testtool/Ablauf_model.php index 748926658..d6d6ebe74 100644 --- a/application/models/testtool/Ablauf_model.php +++ b/application/models/testtool/Ablauf_model.php @@ -11,4 +11,31 @@ class Ablauf_model extends DB_Model $this->dbTable = 'testtool.tbl_ablauf'; $this->pk = 'ablauf_id'; } + + /** + * Returns Weighting of the respective ranking test areas + * @param $studiengang_kz Studiengang_kz + * @param $semester Integer optional + * @return array of weightings per ranking test areas of given studiengang + */ + public function getAblaufGebieteAndGewichte($studiengang_kz, $semester = null) + { + $parametersArray = array($studiengang_kz); + + $qry = " + SELECT + tbl_ablauf.gebiet_id, tbl_ablauf.gewicht + FROM + testtool.tbl_ablauf + WHERE + tbl_ablauf.studiengang_kz= ?"; + + if($semester) + { + $qry .= " AND semester = ?"; + array_push($parametersArray, $semester); + + } + return $this->execQuery($qry, $parametersArray); + } } diff --git a/application/views/Nachrichten.php b/application/views/Nachrichten.php new file mode 100644 index 000000000..cf34bfd53 --- /dev/null +++ b/application/views/Nachrichten.php @@ -0,0 +1,48 @@ + 'Nachrichten', + 'axios027' => true, + 'bootstrap5' => true, + 'fontawesome6' => true, + 'vue3' => true, + 'primevue3' => true, + #'filtercomponent' => true, + 'tabulator5' => true, + 'tinymce5' => true, + 'phrases' => array( + 'global', + 'ui', + ), + 'customCSSs' => [ + 'public/css/components/vue-datepicker.css', + 'public/css/components/primevue.css', + ], + 'customJSs' => [ + #'vendor/npm-asset/primevue/tree/tree.min.js', + #'vendor/npm-asset/primevue/toast/toast.min.js' + ], + 'customJSModules' => [ + 'public/js/apps/Nachrichten.js' + ] +); + +$this->load->view('templates/FHC-Header', $includesArray); +?> + + !defined('DOMAIN') ? 'notDefined' : DOMAIN, +]; +?> + +
+ + +
+ +load->view('templates/FHC-Footer', $includesArray); ?> + diff --git a/application/views/Studentenverwaltung.php b/application/views/Studentenverwaltung.php index c10dc475a..01e611657 100644 --- a/application/views/Studentenverwaltung.php +++ b/application/views/Studentenverwaltung.php @@ -15,11 +15,14 @@ 'notiz', ), 'customCSSs' => [ + #datepicker fuer component functions 'public/css/components/vue-datepicker.css', 'public/css/components/primevue.css', - 'public/css/Studentenverwaltung.css' + 'public/css/Studentenverwaltung.css', + 'public/css/components/function.css' ], 'customJSs' => [ + 'vendor/vuejs/vuedatepicker_js/vue-datepicker.iife.js' #'vendor/npm-asset/primevue/tree/tree.min.js', #'vendor/npm-asset/primevue/toast/toast.min.js' ], @@ -37,7 +40,10 @@ $configArray = [ //replaced by possibility to hide each formular field via config stv.php #'showZgvDoktor' => !defined('ZGV_DOKTOR_ANZEIGEN') ? false : ZGV_DOKTOR_ANZEIGEN, #'showZgvErfuellt' => !defined('ZGV_ERFUELLT_ANZEIGEN') ? false : ZGV_ERFUELLT_ANZEIGEN - 'showHintKommPrfg' => !defined('FAS_STUDSTATUS_SHOW_KOMM_PRFG_HINT') ? false : FAS_STUDSTATUS_SHOW_KOMM_PRFG_HINT + 'showHintKommPrfg' => !defined('FAS_STUDSTATUS_SHOW_KOMM_PRFG_HINT') ? false : FAS_STUDSTATUS_SHOW_KOMM_PRFG_HINT, + 'showAufnahmegruppen' => !defined('FAS_REIHUNGSTEST_AUFNAHMEGRUPPEN') ? false : FAS_REIHUNGSTEST_AUFNAHMEGRUPPEN, + 'allowUebernahmePunkte' => !defined('FAS_REIHUNGSTEST_PUNKTEUEBERNAHME') ? true : FAS_REIHUNGSTEST_PUNKTEUEBERNAHME, + 'useReihungstestPunkte' => !defined('FAS_REIHUNGSTEST_PUNKTE') ? true : FAS_REIHUNGSTEST_PUNKTE, ]; ?> diff --git a/merge_FHC4_55354_55991_55992_60874_60875_61229_61230_61231_TabAbschlusspruefung b/merge_FHC4_55354_55991_55992_60874_60875_61229_61230_61231_TabAbschlusspruefung new file mode 100644 index 000000000..e69de29bb diff --git a/public/css/Fhc.css b/public/css/Fhc.css index 376206f6e..5e810da66 100644 --- a/public/css/Fhc.css +++ b/public/css/Fhc.css @@ -98,3 +98,10 @@ padding-right: .375rem; background-image: none; } + +.modal-msg { + max-width: 1378px; +} +.modal-msg .modal-content { + height: 95vh; +} \ No newline at end of file diff --git a/public/css/Studentenverwaltung.css b/public/css/Studentenverwaltung.css index 1ccac1273..bb2588926 100644 --- a/public/css/Studentenverwaltung.css +++ b/public/css/Studentenverwaltung.css @@ -4,6 +4,7 @@ @import './components/FilterComponent.css'; @import './components/Tabs.css'; @import './components/Notiz.css'; +@import './components/Messages.css'; html { font-size: .875em; @@ -53,11 +54,12 @@ html { } /* Dropdown AbschlusspruefungList.js */ -.tabulator-row { +.stv-details-abschlusspruefung .tabulator-row { overflow: visible !important; } -.tabulator-cell { +/* to avoid interference with Notiz.css and overflow for textfield */ +.stv-details-abschlusspruefung .tabulator-cell { overflow: visible !important; } @@ -77,6 +79,10 @@ html { overflow: visible !important; } +.highlight-row { + background-color: #e5aeae !important; +} + @media (min-width: 768px) { #sidebarMenu { visibility: visible!important; @@ -140,4 +146,16 @@ html { } .override_filtercmpt_actions_style div.d-flex.align-items-baseline { align-items: end !important; +} + +.stv-details-details-foto img { + max-width: 150px; +} + +.msg_preview { + margin-bottom: -1px; +} + +.tiny-90 div.tox.tox-tinymce { + height: 90% !important; } \ No newline at end of file diff --git a/public/css/components/Messages.css b/public/css/components/Messages.css new file mode 100644 index 000000000..1c004f6b0 --- /dev/null +++ b/public/css/components/Messages.css @@ -0,0 +1,4 @@ +.twoColumns { + height: 400px; + overflow-y: auto; +} diff --git a/public/css/components/Notiz.css b/public/css/components/Notiz.css index 75c69ec80..badfa4538 100644 --- a/public/css/components/Notiz.css +++ b/public/css/components/Notiz.css @@ -3,4 +3,24 @@ } .notizText { color: darkblue; -} \ No newline at end of file +} + +/* Enforce content clipping in the scrollable section */ +.tabulator .tabulator-tableHolder { + overflow-x: hidden; + position: relative; +} + +.tabulator .tabulator-table { + overflow-x: hidden; + table-layout: fixed; + width: 100%; +} + +.tabulator .tabulator-cell { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 100%; +} + diff --git a/public/css/components/function.css b/public/css/components/function.css new file mode 100644 index 000000000..3e5e4a632 --- /dev/null +++ b/public/css/components/function.css @@ -0,0 +1,3 @@ +.item-inactive { + text-decoration: line-through; +} \ No newline at end of file diff --git a/public/css/components/primevue.css b/public/css/components/primevue.css index 38b15004b..fbbae4e58 100644 --- a/public/css/components/primevue.css +++ b/public/css/components/primevue.css @@ -5249,6 +5249,8 @@ } .p-toast .p-toast-message .p-toast-message-content .p-toast-message-text { margin: 0 0 0 1rem; + flex: 1 0 0%; + word-break: break-word; } .p-toast .p-toast-message .p-toast-message-content .p-toast-message-icon { font-size: 2rem; @@ -5314,6 +5316,15 @@ .p-toast .p-toast-message.p-toast-message-error .p-toast-icon-close { color: #721c24; } +.p-toast.p-component.p-toast-top-right.fhc-alert { + max-height: calc(100vh - 20px - 1rem); + overflow: auto; +} + +.p-toast-message-text .alertCollapseText { + overflow: auto; + max-height: 30rem; +} .p-galleria .p-galleria-close { margin: 0.5rem; diff --git a/public/css/components/vue-datepicker.css b/public/css/components/vue-datepicker.css index c2551b9d8..efca42f4f 100644 --- a/public/css/components/vue-datepicker.css +++ b/public/css/components/vue-datepicker.css @@ -43,4 +43,12 @@ --dp-border-color-hover: var(--bs-success); } .form-control.is-invalid ~ .dp__clear_icon, -.was-validated .form-control:invalid ~ .dp__clear_icon { margin-right: calc(1.5em + .75rem - 12px) } +.was-validated .form-control:invalid ~ .dp__clear_icon { + margin-right: calc(1.5em + .75rem - 12px); +} +.p-component .dp__input_icons { + box-sizing: content-box !important; +} +.input-group .dp__input_icons { + z-index: 3; +} \ No newline at end of file diff --git a/public/js/api/factory/detailHeader.js b/public/js/api/factory/detailHeader.js new file mode 100644 index 000000000..74563bd4b --- /dev/null +++ b/public/js/api/factory/detailHeader.js @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + getHeader(person_id){ + return { + method: 'get', + url: 'api/frontend/v1/vertraege/vertraege/getHeader/' + person_id, + }; + }, + getPersonAbteilung(mitarbeiter_uid){ + return { + method: 'get', + url: 'api/frontend/v1/vertraege/vertraege/getPersonAbteilung/' + mitarbeiter_uid, + }; + }, + getLeitungOrg(oekurzbz){ + return { + method: 'get', + url: 'api/frontend/v1/vertraege/vertraege/getLeitungOrg/' + oekurzbz, + }; + }, +} \ No newline at end of file diff --git a/public/js/api/factory/functions.js b/public/js/api/factory/functions.js new file mode 100644 index 000000000..ef0be43cb --- /dev/null +++ b/public/js/api/factory/functions.js @@ -0,0 +1,89 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +export default { + getOrgHeads() { + var url = 'api/frontend/v1/funktionen/Funktionen/getOrgHeads'; + return { + method: 'get', + url, + }; + }, + getOrgetsForCompany(unternehmen) { + var url = 'api/frontend/v1/funktionen/Funktionen/getOrgetsForCompany' + + '/' + unternehmen; + return { + method: 'get', + url, + }; + }, + getAllOrgUnits(filterStudent) { + var url = 'api/frontend/v1/funktionen/Funktionen/getAllOrgUnits'; + return { + method: 'get', + url, + }; + }, + getAllUserFunctions(mitarbeiter_uid) { + var url = 'api/frontend/v1/funktionen/Funktionen/getAllUserFunctions' + + '/' + mitarbeiter_uid; + return { + method: 'get', + url, + }; + }, + getAllFunctions() { + var url = 'api/frontend/v1/funktionen/Funktionen/getAllFunctions'; + return { + method: 'get', + url, + }; + }, + addFunction(params) { + return { + method: 'post', + url: 'api/frontend/v1/funktionen/Funktionen/insertFunction/', + params + }; + }, + loadFunction(benutzerfunktion_id) { + var url = 'api/frontend/v1/funktionen/Funktionen/loadFunction' + + '/' + benutzerfunktion_id; + return { + method: 'get', + url, + }; + }, + updateFunction(params) { + return { + method: 'post', + url: 'api/frontend/v1/funktionen/Funktionen/updateFunction/', + params + }; + }, + deleteFunction(benutzerfunktion_id) { + return { + method: 'post', + url: 'api/frontend/v1/funktionen/Funktionen/deleteFunction/' + benutzerfunktion_id + }; + }, + getOes(head, searchString) { + return { + method: 'get', + url: 'api/frontend/v1/funktionen/Funktionen/searchOes/' + head + '/' + searchString + }; + }, +}; \ No newline at end of file diff --git a/public/js/api/factory/messages/messages.js b/public/js/api/factory/messages/messages.js new file mode 100644 index 000000000..cec34ad8b --- /dev/null +++ b/public/js/api/factory/messages/messages.js @@ -0,0 +1,110 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + getMessages(params) { + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getMessages/' + + params.id + '/' + + params.type + '/' + + params.size + '/' + + params.page + }; + }, + getVorlagen(){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getVorlagen/' + }; + }, + getMsgVarsLoggedInUser(){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getMsgVarsLoggedInUser/' + }; + }, + getMessageVarsPerson(userParams){ + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/getMessageVarsPerson/' + userParams.id + '/' + userParams.type_id + }; + }, + getMsgVarsPrestudent(userParams){ + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/getMsgVarsPrestudent/' + userParams.id + '/' + userParams.type_id + }; + }, + getPersonId(params){ + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/getPersonId/' + params.id + '/' + params.type_id + }; + }, + getUid(userParams){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getUid/' + userParams.id + '/' + userParams.type_id + }; + }, + getVorlagentext(vorlage_kurzbz){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getVorlagentext/' + vorlage_kurzbz + }; + }, + getNameOfDefaultRecipient(params){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getNameOfDefaultRecipient/' + params.id + '/' + params.type_id + }; + }, + getPreviewText(userParams, params){ + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/getPreviewText/' + userParams.id + '/' + userParams.type_id, + params + }; + }, + getReplyData(messageId){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getReplyData/' + messageId + }; + }, + sendMessageFromModalContext(id, params) { + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/sendMessage/' + id, + params + }; + }, + sendMessage(id, params) { + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/sendMessage/' + id, + params + }; + }, + deleteMessage(messageId){ + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/deleteMessage/' + messageId + }; + } +} \ No newline at end of file diff --git a/public/js/api/factory/stv.js b/public/js/api/factory/stv.js index 7ea387263..95bc227f5 100644 --- a/public/js/api/factory/stv.js +++ b/public/js/api/factory/stv.js @@ -29,6 +29,7 @@ import exam from './stv/exam.js'; import abschlusspruefung from './stv/abschlusspruefung.js'; import grades from './stv/grades.js'; import mobility from './stv/mobility.js'; +import admissionDates from './stv/admissionDates.js'; export default { app, @@ -44,5 +45,6 @@ export default { exam, abschlusspruefung, grades, - mobility + mobility, + admissionDates }; \ No newline at end of file diff --git a/public/js/api/factory/stv/abschlusspruefung.js b/public/js/api/factory/stv/abschlusspruefung.js index 37e442b19..db8403b48 100644 --- a/public/js/api/factory/stv/abschlusspruefung.js +++ b/public/js/api/factory/stv/abschlusspruefung.js @@ -105,7 +105,19 @@ export default { return { method: 'post', url: 'api/frontend/v1/stv/abschlusspruefung/checkForExistingExams/', - params: { uid } + params: { uids } + }; + }, + getAllMitarbeiter(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/abschlusspruefung/getAllMitarbeiter/' + }; + }, + getAllPersons(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/abschlusspruefung/getAllPersons/' }; } }; \ No newline at end of file diff --git a/public/js/api/factory/stv/admissionDates.js b/public/js/api/factory/stv/admissionDates.js new file mode 100644 index 000000000..a6d743276 --- /dev/null +++ b/public/js/api/factory/stv/admissionDates.js @@ -0,0 +1,99 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + getAufnahmetermine(person_id) { + return { + method: 'get', + url: 'api/frontend/v1/stv/aufnahmetermine/getAufnahmetermine/' + person_id, + }; + }, + getListPlacementTests(prestudent_id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/aufnahmetermine/getListPlacementTests/' + prestudent_id, + }; + }, + getListStudyPlans(person_id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/aufnahmetermine/getListStudyPlans/' + person_id, + }; + }, + addNewPlacementTest(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/aufnahmetermine/insertAufnahmetermin/', + params + }; + }, + loadPlacementTest(rt_person_id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/aufnahmetermine/loadAufnahmetermin/' + rt_person_id, + }; + }, + updatePlacementTest(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/aufnahmetermine/updateAufnahmetermin/', + params + }; + }, + deletePlacementTest(rt_person_id){ + return { + method: 'post', + url: 'api/frontend/v1/stv/aufnahmetermine/deleteAufnahmetermin/' + rt_person_id + }; + }, + loadDataRtPrestudent(prestudent_id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/aufnahmetermine/loadDataRtPrestudent/' + prestudent_id, + }; + }, + saveDataRtPrestudent(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/aufnahmetermine/insertOrUpdateDataRtPrestudent/', + params + }; + }, + loadAufnahmegruppen(params){ + return { + method: 'get', + url: 'api/frontend/v1/stv/aufnahmetermine/loadAufnahmegruppen/', + params + }; + }, + getResultReihungstest(params){ + return { + method: 'get', + url: 'api/frontend/v1/stv/aufnahmetermine/getResultReihungstest/', + params + }; + }, + loadFutureReihungstests(params){ + return { + method: 'get', + url: 'api/frontend/v1/stv/aufnahmetermine/getZukuenftigeReihungstestStg/', + params + }; + }, + + +} \ No newline at end of file diff --git a/public/js/api/factory/stv/coursedates.js b/public/js/api/factory/stv/coursedates.js new file mode 100644 index 000000000..71ded7285 --- /dev/null +++ b/public/js/api/factory/stv/coursedates.js @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + getCourselist(params) { + return { + method: 'get', + url: 'api/frontend/v1/stv/LvTermine/getStundenplan/' + params.student_uid + '/' + + params.start_date + '/' + + params.end_date + '/' + + params.group_consecutiveHours + '/' + + params.dbStundenplanTable + }; + }, + getStudiensemester(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/LvTermine/getStudiensemester/' + }; + }, +} \ No newline at end of file diff --git a/public/js/api/factory/stv/documents.js b/public/js/api/factory/stv/documents.js new file mode 100644 index 000000000..1898023cd --- /dev/null +++ b/public/js/api/factory/stv/documents.js @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + getDocumentsUnaccepted(params) { + return { + method: 'get', + url: 'api/frontend/v1/stv/dokumente/getDocumentsUnaccepted/' + params.id + '/' + params.studiengang_kz + }; + }, + getDocumentsAccepted(params) { + return { + method: 'get', + url: 'api/frontend/v1/stv/dokumente/getDocumentsAccepted/' + params.id + '/' + params.studiengang_kz + }; + }, + deleteZuordnung(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/dokumente/deleteZuordnung/' + params.prestudent_id + '/' + params.dokument_kurzbz + }; + }, + createZuordnung(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/dokumente/createZuordnung/' + params.prestudent_id + '/' + params.dokument_kurzbz + }; + }, + loadAkte(akte_id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/dokumente/loadAkte/' + akte_id + }; + }, + getDoktypen(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/dokumente/getDoktypen/' + }; + }, + updateFile(akte_id, params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/dokumente/updateAkte/' + akte_id, + params + }; + }, + deleteFile(akte_id){ + console.log("in deleteFile " + akte_id); + return { + method: 'post', + url: 'api/frontend/v1/stv/dokumente/deleteAkte/' + akte_id, + }; + }, + uploadFile(prestudent_id, params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/dokumente/uploadDokument/' + prestudent_id, + params + }; + }, +} \ No newline at end of file diff --git a/public/js/api/factory/stv/exemptions.js b/public/js/api/factory/stv/exemptions.js new file mode 100644 index 000000000..2bf8ee610 --- /dev/null +++ b/public/js/api/factory/stv/exemptions.js @@ -0,0 +1,75 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + getAnrechnungen(id) { + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/getAnrechnungen/' + id + }; + }, + getLehrveranstaltungen(prestudent_id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/getLehrveranstaltungen/' + prestudent_id + }; + }, + getBegruendungen(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/getBegruendungen/' + }; + }, + getLvsKompatibel(lv_id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/getLvsKompatibel/' + lv_id + }; + }, + getLektoren(studiengang_kz){ + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/getLektoren/' + studiengang_kz + }; + }, + addNewAnrechnung(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/anrechnungen/insertAnrechnung/', + params + }; + }, + loadAnrechnung(anrechnung_id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/loadAnrechnung/' + anrechnung_id + }; + }, + editAnrechnung(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/anrechnungen/updateAnrechnung/', + params + }; + }, + deleteAnrechnung(anrechnung_id){ + return { + method: 'post', + url: 'api/frontend/v1/stv/anrechnungen/deleteAnrechnung/' + anrechnung_id + }; + }, +} diff --git a/public/js/api/factory/stv/group.js b/public/js/api/factory/stv/group.js new file mode 100644 index 000000000..b395fbf43 --- /dev/null +++ b/public/js/api/factory/stv/group.js @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + getGruppen(id) { + return { + method: 'get', + url: 'api/frontend/v1/stv/Gruppen/getGruppen/' + id + }; + }, + deleteGroup(params) { + return { + method: 'post', + url: 'api/frontend/v1/stv/Gruppen/deleteGruppe/', + params + }; + } +} + diff --git a/public/js/api/factory/stv/jointstudies.js b/public/js/api/factory/stv/jointstudies.js new file mode 100644 index 000000000..18f398bb4 --- /dev/null +++ b/public/js/api/factory/stv/jointstudies.js @@ -0,0 +1,81 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + getStudies(uid) { + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getStudien/' + uid + }; + }, + getTypenMobility(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getTypenMobility/' + }; + }, + getStudiensemester(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getStudiensemester/' + }; + }, + getStudyprograms(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getStudienprogramme/' + }; + }, + getListPartner(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getPartnerfirmen/' + }; + }, + getStatiPrestudent(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getStatiPrestudent/' + }; + }, + loadStudy(id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/loadStudie/' + id + }; + }, + insertStudy(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/GemeinsameStudien/insertStudie/', + params + }; + }, + updateStudy(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/GemeinsameStudien/updateStudie/', + params + }; + }, + deleteStudy(id){ + return { + method: 'post', + url: 'api/frontend/v1/stv/GemeinsameStudien/deleteStudie/' + id + }; + }, +} diff --git a/public/js/api/factory/stv/kontakt/address.js b/public/js/api/factory/stv/kontakt/address.js index 78027835f..4402b50d6 100644 --- a/public/js/api/factory/stv/kontakt/address.js +++ b/public/js/api/factory/stv/kontakt/address.js @@ -67,5 +67,11 @@ export default { method: 'get', url: 'api/frontend/v1/stv/address/getNations/' }; + }, + getAllFirmen(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/kontakt/getAllFirmen/' + } } }; \ No newline at end of file diff --git a/public/js/api/factory/stv/mobility.js b/public/js/api/factory/stv/mobility.js index 262dbcf55..fc4fd17b4 100644 --- a/public/js/api/factory/stv/mobility.js +++ b/public/js/api/factory/stv/mobility.js @@ -51,7 +51,8 @@ export default { deleteMobility(bisio_id) { return { method: 'post', - url: 'api/frontend/v1/stv/mobility/deleteMobility/' + bisio_id + url: 'api/frontend/v1/stv/mobility/deleteMobility/', + params: { bisio_id } }; }, getLVList(studiengang_kz) { @@ -100,7 +101,7 @@ export default { deleteMobilityPurpose(params) { return { method: 'post', - url: 'api/frontend/v1/stv/mobility/deleteMobilityPurpose/' + params.bisio_id, + url: 'api/frontend/v1/stv/mobility/deleteMobilityPurpose/', params }; }, @@ -108,7 +109,7 @@ export default { return { method: 'post', url: 'api/frontend/v1/stv/mobility/addMobilityPurpose/' + params.bisio_id, - params + params: params }; }, deleteMobilitySupport(params) { diff --git a/public/js/api/factory/vorlagen.js b/public/js/api/factory/vorlagen.js new file mode 100644 index 000000000..f62f65e47 --- /dev/null +++ b/public/js/api/factory/vorlagen.js @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + getVorlagen() { + return { + method: 'get', + url: 'api/frontend/v1/vorlagen/vorlagen/getVorlagen/' + }; + }, + getVorlagenByLoggedInUser() { + return { + method: 'get', + url: 'api/frontend/v1/vorlagen/vorlagen/getVorlagenByLoggedInUser/' + }; + }, + +}; diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index 378d979ab..1a4db034e 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -33,6 +33,8 @@ import ort from "./ort.js"; import cms from "./cms.js"; import lehre from "./lehre.js"; import addons from "./addons.js"; +import messages from "./messages.js"; +import vorlagen from "./vorlagen.js"; import studiengang from "./studiengang.js"; import menu from "./menu.js"; import dashboard from "./dashboard.js"; @@ -57,6 +59,9 @@ export default { ort, cms, lehre, + addons, + messages, + vorlagen, addons, studiengang, menu, diff --git a/public/js/api/messages.js b/public/js/api/messages.js new file mode 100644 index 000000000..f1378c69d --- /dev/null +++ b/public/js/api/messages.js @@ -0,0 +1,5 @@ +import person from "./messages/person.js"; + +export default { + person +} \ No newline at end of file diff --git a/public/js/api/messages/person.js b/public/js/api/messages/person.js new file mode 100644 index 000000000..e2d2fd0c4 --- /dev/null +++ b/public/js/api/messages/person.js @@ -0,0 +1,47 @@ +export default { + getMessages(url, config, params) { + return this.$fhcApi.get('api/frontend/v1/messages/messages/getMessages/' + params.id + '/' + params.type + '/' + params.size + '/' + params.page); + }, + getVorlagen(){ + return this.$fhcApi.get('api/frontend/v1/messages/messages/getVorlagen/'); + }, + getMsgVarsLoggedInUser(){ + return this.$fhcApi.get('api/frontend/v1/messages/messages/getMsgVarsLoggedInUser/'); + }, + getMessageVarsPerson(params){ + return this.$fhcApi.get('api/frontend/v1/messages/messages/getMessageVarsPerson/' + params.id + '/' + params.type_id); + }, + getMsgVarsPrestudent(params){ + return this.$fhcApi.get('api/frontend/v1/messages/messages/getMsgVarsPrestudent/' + params.id + '/' + params.type_id); + }, + getPersonId(params){ + return this.$fhcApi.get('api/frontend/v1/messages/messages/getPersonId/'+ params.id + '/' + params.type_id); + }, + getUid(params){ + return this.$fhcApi.get('api/frontend/v1/messages/messages/getUid/'+ params.id + '/' + params.type_id); + }, + getVorlagentext(vorlage_kurzbz){ + return this.$fhcApi.get('api/frontend/v1/messages/messages/getVorlagentext/' + vorlage_kurzbz); + }, + getNameOfDefaultRecipient(params){ + return this.$fhcApi.get('api/frontend/v1/messages/messages/getNameOfDefaultRecipient/' + params.id + '/' + params.type_id); + }, + getPreviewText(params, data){ + return this.$fhcApi.post('api/frontend/v1/messages/messages/getPreviewText/' + params.id + '/' + params.type_id, + data); + }, + getReplyData(messageId){ + return this.$fhcApi.get('api/frontend/v1/messages/messages/getReplyData/' + messageId); + }, + sendMessageFromModalContext(form, id, data) { + return this.$fhcApi.post(form,'api/frontend/v1/messages/messages/sendMessage/' + id, + data); + }, + sendMessage(id, data) { + return this.$fhcApi.post('api/frontend/v1/messages/messages/sendMessage/' + id, + data); + }, + deleteMessage(messageId){ + return this.$fhcApi.post('api/frontend/v1/messages/messages/deleteMessage/' + messageId); + } +} \ No newline at end of file diff --git a/public/js/api/stv.js b/public/js/api/stv.js index ae88b0516..8a4e568ea 100644 --- a/public/js/api/stv.js +++ b/public/js/api/stv.js @@ -2,6 +2,7 @@ import verband from './stv/verband.js'; import students from './stv/students.js'; import filter from './stv/filter.js'; import konto from './stv/konto.js'; +import group from './stv/group.js'; import kontakt from './stv/kontakt.js'; import prestudent from './stv/prestudent.js'; import status from './stv/status.js'; @@ -10,12 +11,18 @@ import exam from './stv/exam.js'; import abschlusspruefung from './stv/abschlusspruefung.js'; import grades from './stv/grades.js'; import mobility from './stv/mobility.js'; +import archiv from './stv/archiv.js'; +import documents from './stv/documents.js'; +import exemptions from './stv/exemptions.js'; +import jointstudies from "./stv/jointstudies.js"; +import courselist from './stv/courselist.js'; export default { verband, students, filter, konto, + group, kontakt, prestudent, status, @@ -24,6 +31,11 @@ export default { abschlusspruefung, grades, mobility, + archiv, + documents, + exemptions, + jointstudies, + courselist, configStudent() { return this.$fhcApi.get('api/frontend/v1/stv/config/student'); }, diff --git a/public/js/api/stv/archiv.js b/public/js/api/stv/archiv.js new file mode 100644 index 000000000..9b8bdf416 --- /dev/null +++ b/public/js/api/stv/archiv.js @@ -0,0 +1,36 @@ +export default { + tabulatorConfig(config, self) { + config.ajaxURL = 'api/frontend/v1/stv/archiv/get'; + config.ajaxParams = () => { + const params = { + person_id: self.modelValue.person_id || self.modelValue.map(e => e.person_id) + }; + return params; + }; + config.ajaxRequestFunc = (url, config, params) => this.$fhcApi.post(url, params, config); + config.ajaxResponse = (url, params, response) => response.data; + + return config; + }, + getArchivVorlagen() { + return this.$fhcApi.post('api/frontend/v1/stv/archiv/getArchivVorlagen'); + }, + archive(data) { + return this.$fhcApi.post( + 'api/frontend/v1/documents/archive', + data + ); + }, + archiveSigned(data) { + return this.$fhcApi.post( + 'api/frontend/v1/documents/archiveSigned', + data + ); + }, + update(data) { + return this.$fhcApi.post('api/frontend/v1/stv/archiv/update', data); + }, + delete({akte_id, studiengang_kz}) { + return this.$fhcApi.post('api/frontend/v1/stv/archiv/delete', {akte_id, studiengang_kz}); + } +}; diff --git a/public/js/api/stv/courselist.js b/public/js/api/stv/courselist.js new file mode 100644 index 000000000..6bd999e5f --- /dev/null +++ b/public/js/api/stv/courselist.js @@ -0,0 +1,15 @@ +export default { + getCourselist(url, config, params) { + //corresponding logic controller Stundenplan.php + return this.$fhcApi.get('api/frontend/v1/stv/LvTermine/getStundenplan/' + + params.student_uid + '/' + + params.start_date + '/' + + params.end_date + '/' + + params.group_consecutiveHours + '/' + + params.dbStundenplanTable + ); + }, + getStudiensemester(){ + return this.$fhcApi.get('api/frontend/v1/stv/LvTermine/getStudiensemester/'); + }, +} \ No newline at end of file diff --git a/public/js/api/stv/documents.js b/public/js/api/stv/documents.js new file mode 100644 index 000000000..9934520fc --- /dev/null +++ b/public/js/api/stv/documents.js @@ -0,0 +1,33 @@ +export default { + getDocumentsUnaccepted(url, config, params) { + return this.$fhcApi.get('api/frontend/v1/stv/dokumente/getDocumentsUnaccepted/' + params.id + '/' + params.studiengang_kz); + }, + getDocumentsAccepted(url, config, params) { + return this.$fhcApi.get('api/frontend/v1/stv/dokumente/getDocumentsAccepted/' + params.id + '/' + params.studiengang_kz); + }, + deleteZuordnung(params){ + return this.$fhcApi.post('api/frontend/v1/stv/dokumente/deleteZuordnung/' + params.prestudent_id + '/' + params.dokument_kurzbz); + }, + createZuordnung(params){ + return this.$fhcApi.post('api/frontend/v1/stv/dokumente/createZuordnung/' + + params.prestudent_id + '/' + + params.dokument_kurzbz); + }, + loadAkte(akte_id){ + return this.$fhcApi.get('api/frontend/v1/stv/dokumente/loadAkte/' + akte_id); + }, + getDoktypen(){ + return this.$fhcApi.get('api/frontend/v1/stv/dokumente/getDoktypen/'); + }, + updateFile(akte_id, data){ + return this.$fhcApi.post('api/frontend/v1/stv/dokumente/updateAkte/' + akte_id, + data); + }, + deleteFile(akte_id){ + return this.$fhcApi.post('api/frontend/v1/stv/dokumente/deleteAkte/' + akte_id); + }, + uploadFile(prestudent_id, data){ + return this.$fhcApi.post('api/frontend/v1/stv/dokumente/uploadDokument/' + prestudent_id, + data); + }, +} \ No newline at end of file diff --git a/public/js/api/stv/exemptions.js b/public/js/api/stv/exemptions.js new file mode 100644 index 000000000..f8b421200 --- /dev/null +++ b/public/js/api/stv/exemptions.js @@ -0,0 +1,29 @@ +export default { + getAnrechnungen(url, config, params) { + return this.$fhcApi.get('api/frontend/v1/stv/anrechnungen/getAnrechnungen/' + params.id); + }, + getLehrveranstaltungen(prestudent_id){ + return this.$fhcApi.get('api/frontend/v1/stv/anrechnungen/getLehrveranstaltungen/' + prestudent_id); + }, + getBegruendungen(){ + return this.$fhcApi.get('api/frontend/v1/stv/anrechnungen/getBegruendungen/'); + }, + getLvsKompatibel(lv_id){ + return this.$fhcApi.get('api/frontend/v1/stv/anrechnungen/getLvsKompatibel/' + lv_id); + }, + getLektoren(studiengang_kz){ + return this.$fhcApi.get('api/frontend/v1/stv/anrechnungen/getLektoren/' + studiengang_kz); + }, + addNewAnrechnung(form, data){ + return this.$fhcApi.post(form, 'api/frontend/v1/stv/anrechnungen/insertAnrechnung/', data); + }, + loadAnrechnung(anrechnung_id){ + return this.$fhcApi.get('api/frontend/v1/stv/anrechnungen/loadAnrechnung/' + anrechnung_id); + }, + editAnrechnung(form, data){ + return this.$fhcApi.post(form, 'api/frontend/v1/stv/anrechnungen/updateAnrechnung/', data); + }, + deleteAnrechnung(anrechnung_id){ + return this.$fhcApi.post('api/frontend/v1/stv/anrechnungen/deleteAnrechnung/' + anrechnung_id); + }, +} \ No newline at end of file diff --git a/public/js/api/stv/group.js b/public/js/api/stv/group.js new file mode 100644 index 000000000..af6e6e122 --- /dev/null +++ b/public/js/api/stv/group.js @@ -0,0 +1,8 @@ +export default { + getGruppen(url, config, params) { + return this.$fhcApi.get('api/frontend/v1/stv/Gruppen/getGruppen/' + params.id); + }, + deleteGroup(params) { + return this.$fhcApi.post('api/frontend/v1/stv/Gruppen/deleteGruppe/', params); + } +} \ No newline at end of file diff --git a/public/js/api/stv/jointstudies.js b/public/js/api/stv/jointstudies.js new file mode 100644 index 000000000..b550852df --- /dev/null +++ b/public/js/api/stv/jointstudies.js @@ -0,0 +1,33 @@ +export default { + getStudies(url, config, params) { + return this.$fhcApi.get('api/frontend/v1/stv/GemeinsameStudien/getStudien/' + params.id); + }, + getTypenMobility(){ + return this.$fhcApi.get('api/frontend/v1/stv/GemeinsameStudien/getTypenMobility/'); + }, + getStudiensemester(){ + return this.$fhcApi.get('api/frontend/v1/stv/GemeinsameStudien/getStudiensemester/'); + }, + getStudyprograms(){ + return this.$fhcApi.get('api/frontend/v1/stv/GemeinsameStudien/getStudienprogramme/'); + }, + getListPartner(){ + return this.$fhcApi.get('api/frontend/v1/stv/GemeinsameStudien/getPartnerfirmen/'); + }, + getStatiPrestudent(){ + return this.$fhcApi.get('api/frontend/v1/stv/GemeinsameStudien/getStatiPrestudent/'); + }, + loadStudy(id){ + return this.$fhcApi.get('api/frontend/v1/stv/GemeinsameStudien/loadStudie/' + id); + }, + insertStudy(form, data){ + return this.$fhcApi.post(form,'api/frontend/v1/stv/GemeinsameStudien/insertStudie/', data); + }, + updateStudy(form, data){ + return this.$fhcApi.post(form,'api/frontend/v1/stv/GemeinsameStudien/updateStudie/', data); + }, + deleteStudy(id){ + return this.$fhcApi.post('api/frontend/v1/stv/GemeinsameStudien/deleteStudie/' + id); + }, + +} \ No newline at end of file diff --git a/public/js/api/vorlagen.js b/public/js/api/vorlagen.js new file mode 100644 index 000000000..2933ccf97 --- /dev/null +++ b/public/js/api/vorlagen.js @@ -0,0 +1,8 @@ +export default { + getVorlagen() { + return this.$fhcApi.get('api/frontend/v1/vorlagen/vorlagen/getVorlagen/'); + }, + getVorlagenByLoggedInUser() { + return this.$fhcApi.get('api/frontend/v1/vorlagen/vorlagen/getVorlagenByLoggedInUser/'); + } +} \ No newline at end of file diff --git a/public/js/apps/Messages/NewMessage.js b/public/js/apps/Messages/NewMessage.js new file mode 100644 index 000000000..693c8b0e2 --- /dev/null +++ b/public/js/apps/Messages/NewMessage.js @@ -0,0 +1,27 @@ +//TODO Manu +//use this instead of Nachrichten.js +import NewMessage from "../../components/Messages/Details/NewMessage/NewDiv.js"; +import Phrasen from "../../plugin/Phrasen.js"; + +const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router; + +const router = VueRouter.createRouter({ + history: VueRouter.createWebHistory(), + routes: [ + { path: `/${ciPath}/NeueNachricht`, component: NewMessage }, + { path: `/${ciPath}/NeueNachricht/:id`, component: NewMessage }, + { path: `/${ciPath}/NeueNachricht/:id/:typeId`, component: NewMessage }, + ] +}); + +const app = Vue.createApp(); + +app + .use(router) + .use(primevue.config.default, { + zIndex: { + overlay: 1100 + } + }) + .use(Phrasen) + .mount('#main'); diff --git a/public/js/apps/Nachrichten.js b/public/js/apps/Nachrichten.js new file mode 100644 index 000000000..84b9ddee5 --- /dev/null +++ b/public/js/apps/Nachrichten.js @@ -0,0 +1,26 @@ +import NewMessage from "../components/Messages/Details/NewMessage/NewDiv.js"; + +import Phrasen from "../plugin/Phrasen.js"; + +const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router; + +const router = VueRouter.createRouter({ + history: VueRouter.createWebHistory(), + routes: [ + { path: `/${ciPath}/NeueNachricht/:id/:typeId`, component: NewMessage }, + { path: `/${ciPath}/NeueNachricht/:id/:typeId/:messageId`, component: NewMessage }, + ] +}); + + +const app = Vue.createApp(); + +app + .use(router) + .use(primevue.config.default, { + zIndex: { + overlay: 1100 + } + }) + .use(Phrasen) + .mount('#main'); \ No newline at end of file diff --git a/public/js/components/Betriebsmittel/Betriebsmittel.js b/public/js/components/Betriebsmittel/Betriebsmittel.js index 39681ffb4..6d976a1fa 100644 --- a/public/js/components/Betriebsmittel/Betriebsmittel.js +++ b/public/js/components/Betriebsmittel/Betriebsmittel.js @@ -137,8 +137,6 @@ export default { layout: 'fitColumns', layoutColumnsOnNewData: false, height: '550', - selectableRangeMode: 'click', - selectable: true, persistenceID: 'core-betriebsmittel' }, tabulatorEvents: [ @@ -311,6 +309,7 @@ export default { table-only :side-menu="false" reload + :reload-btn-infotext="this.$p.t('table', 'reload')" new-btn-show :new-btn-label="this.$p.t('ui', 'betriebsmittel')" @click:new="actionNewBetriebsmittel" @@ -427,6 +426,7 @@ export default { v-model="formData.ausgegebenam" auto-apply :enable-time-picker="false" + text-input format="dd.MM.yyyy" preview-format="dd.MM.yyyy" :teleport="true" @@ -442,6 +442,7 @@ export default { v-model="formData.retouram" auto-apply :enable-time-picker="false" + text-input format="dd.MM.yyyy" preview-format="dd.MM.yyyy" :teleport="true" diff --git a/public/js/components/Bootstrap/Modal.js b/public/js/components/Bootstrap/Modal.js index 2b3223ff7..af81e469f 100644 --- a/public/js/components/Bootstrap/Modal.js +++ b/public/js/components/Bootstrap/Modal.js @@ -23,9 +23,17 @@ export default { }, noCloseBtn: Boolean, dialogClass: [String,Array,Object], + headerClass: { + type: [String,Array,Object], + default: '' + }, bodyClass: { type: [String,Array,Object], default: 'px-4 py-5' + }, + footerClass: { + type: [String,Array,Object], + default: '' } }, emits: [ @@ -117,15 +125,16 @@ export default { template: `