diff --git a/application/config/anrechnung.php b/application/config/anrechnung.php index c2e38385c..768ec3197 100644 --- a/application/config/anrechnung.php +++ b/application/config/anrechnung.php @@ -6,10 +6,6 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); // Deadline for Application given as Time-Interval after Semesterstart. $config['interval_blocking_application'] = 'P1M'; -// Application submission period given by start- and enddate. -$config['submit_application_start'] = '05.09.2022'; -$config['submit_application_end'] = '22.09.2022'; - // Lehrveranstaltungen with these grades will be blocked for application $config['grades_blocking_application'] = array( 5, // nicht genügend @@ -19,4 +15,9 @@ $config['grades_blocking_application'] = array( 14, // nicht bestanden, 15, // nicht teilgenommen 18 // unentschuldigt -); \ No newline at end of file +); + +//Enables Fachbereichsleiter instead of LV Leiter +$config['fbl'] = FALSE; +//Enables Info Mails +$config['send_mail'] = TRUE; diff --git a/application/config/db_crypt.php b/application/config/db_crypt.php index 72f8c30d8..b9360861b 100644 --- a/application/config/db_crypt.php +++ b/application/config/db_crypt.php @@ -3,7 +3,7 @@ /** * Copyright (C) 2023 fhcomplete.org * - * This program is free software: you can redistribute it and/or modify + * 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. diff --git a/application/config/navigation.php b/application/config/navigation.php index 092c00cc5..928f5bae3 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -164,7 +164,14 @@ $config['navigation_header'] = array( 'expand' => true, 'sort' => 20, 'requiredPermissions' => 'system/developer:r' - ) + ), + 'anrechnungen' => array( + 'link' => site_url('lehre/anrechnung/AdminAnrechnung'), + 'description' => 'Anrechnungen', + 'expand' => true, + 'sort' => 30, + 'requiredPermissions' => 'lehre/anrechnungszeitfenster:rw' + ) ) ) ) @@ -184,6 +191,15 @@ $config['navigation_menu']['Vilesci/index'] = array( ) ); +$config['navigation_menu']['Vilesci/index'] = array( + 'dashboard' => array( + 'link' => '#', + 'description' => 'Dashboard', + 'icon' => 'dashboard', + 'sort' => 1 + ) +); + $config['navigation_menu']['organisation/Reihungstest/index'] = array( 'reihungstestverwalung' => array( 'link' => base_url('vilesci/stammdaten/reihungstestverwaltung.php'), diff --git a/application/controllers/Test.php b/application/controllers/Test.php new file mode 100644 index 000000000..2a7aa4e4e --- /dev/null +++ b/application/controllers/Test.php @@ -0,0 +1,16 @@ + 'CORE_STUDENTSTATUS_0012', 'CORE_STUDENTSTATUS_0013' => 'CORE_STUDENTSTATUS_0013', 'CORE_STUDENTSTATUS_0014' => 'CORE_STUDENTSTATUS_0014', + 'CORE_STUDENTSTATUS_0015' => 'CORE_STUDENTSTATUS_0015', 'CORE_PERSON_0001' => 'CORE_PERSON_0001', 'CORE_PERSON_0002' => 'CORE_PERSON_0002', 'CORE_PERSON_0003' => 'CORE_PERSON_0003', diff --git a/application/controllers/jobs/vertragsbestandteil_test/VertragsbestandteilTest.php b/application/controllers/jobs/vertragsbestandteil_test/VertragsbestandteilTest.php index 407a5ba24..d22ddb85f 100644 --- a/application/controllers/jobs/vertragsbestandteil_test/VertragsbestandteilTest.php +++ b/application/controllers/jobs/vertragsbestandteil_test/VertragsbestandteilTest.php @@ -17,6 +17,8 @@ class VertragsbestandteilTest extends JOB_Controller $this->load->library('vertragsbestandteil/VertragsbestandteilLib', null, 'VertragsbestandteilLib'); + $this->load->library('vertragsbestandteil/GehaltsbestandteilLib', + null, 'GehaltsbestandteilLib'); } public function testFetch() @@ -84,4 +86,29 @@ class VertragsbestandteilTest extends JOB_Controller echo "Insert failed.\n"; } } + + public function testGehaltsbestandteilInsert() + { + $data = new stdClass(); + $data->gehaltsbestandteil_id = 2; + /* + $data->dienstverhaeltnis_id = 39; + $data->vertragsbestandteil_id = 123; + $data->gehaltstyp_kurzbz = 'zulage'; + $data->von = '2023-04-01'; + $data->bis = '2023-08-31'; + $data->anmerkung = 'test anmerkung'; + $data->grundbetrag = 100; + $data->betrag_valorisiert = 100; + $data->valorisierung = true; + */ + $data->auszahlungen = 12; + + $gb = new \vertragsbestandteil\Gehaltsbestandteil(); + $gb->hydrateByStdClass($data); + + print_r($gb->toStdClass()); + + $this->GehaltsbestandteilLib->storeGehaltsbestandteil($gb); + } } diff --git a/application/controllers/lehre/anrechnung/AdminAnrechnung.php b/application/controllers/lehre/anrechnung/AdminAnrechnung.php new file mode 100644 index 000000000..3c3fd3fc2 --- /dev/null +++ b/application/controllers/lehre/anrechnung/AdminAnrechnung.php @@ -0,0 +1,187 @@ + 'lehre/anrechnungszeitfenster:rw', + 'save' => 'lehre/anrechnungszeitfenster:rw', + 'edit' => 'lehre/anrechnungszeitfenster:rw', + 'delete' => 'lehre/anrechnungszeitfenster:rw' + ) + ); + + // Load models + $this->load->model('education/Anrechnung_model', 'AnrechnungModel'); + $this->load->model('education/Anrechnungszeitraum_model', 'AnrechnungszeitraumModel'); + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + // Load libraries + $this->load->library('WidgetLib'); + $this->load->library('PermissionLib'); + $this->load->library('AnrechnungLib'); + + + // Load language phrases + $this->loadPhrases( + array( + 'global', + 'ui', + 'lehre', + 'anrechnung', + 'table' + ) + ); + + $this->_setAuthUID(); + + $this->setControllerId(); + } + + public function index() + { + // Set nearest Studiensemester as default + $result = $this->StudiensemesterModel->getNearest(); + $studiensemester_kurzbz = hasData($result) ? getData($result)[0]->studiensemester_kurzbz : ''; + + // Get existing Anrechnungszeitraeume + $this->AnrechnungszeitraumModel->addOrder('anrechnungszeitraum_id', 'DESC'); + $result = $this->AnrechnungszeitraumModel->load(); + $anrechnungszeitraum_arr = hasData($result) ? getData($result) : array(); + + $viewData = array( + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'anrechnungszeitraum_arr' => $anrechnungszeitraum_arr + ); + + $this->load->view('lehre/anrechnung/adminAnrechnung.php', $viewData); + } + + /** + * Save new Anrechnungszeitraum. + */ + public function save() + { + $this->_validate($this->input->post()); + + $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); + $anrechnungstart = $this->input->post('anrechnungstart'); + $anrechnungende = $this->input->post('anrechnungende'); + + $result = $this->AnrechnungszeitraumModel->insertAzr($studiensemester_kurzbz, $anrechnungstart, $anrechnungende); + + if (isError($result)) + { + $this->terminateWithJsonError(getError($result)); + } + + if (hasData($result)) + { + $this->outputJsonSuccess(array('anrechnungszeitraum_id' => getData($result))); + } + } + + /** + * Edit Anrechnungszeitraum. + */ + public function edit() + { + $this->_validate($this->input->post()); + + $anrechnungszeitraum_id = $this->input->post('anrechnungszeitraum_id'); + $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); + $anrechnungstart = $this->input->post('anrechnungstart'); + $anrechnungende = $this->input->post('anrechnungende'); + + $result = $this->AnrechnungszeitraumModel->updateAzr( + $anrechnungszeitraum_id, + $studiensemester_kurzbz, + $anrechnungstart, + $anrechnungende + ); + + if (isError($result)) + { + $this->terminateWithJsonError(getError($result)); + } + + if (hasData($result)) + { + $this->outputJsonSuccess(array('anrechnungszeitraum_id' => getData($result))); + } + } + + /** + * Delete Anrechnungszeitraum. + */ + public function delete() + { + $anrechnungszeitraum_id = $this->input->post('anrechnungszeitraum_id'); + + $result = $this->AnrechnungszeitraumModel->deleteAzr($anrechnungszeitraum_id); + + if (isError($result)) + { + $this->terminateWithJsonError(getError($result)); + } + + if (hasData($result)) + { + $this->outputJsonSuccess(array('anrechnungszeitraum_id' => getData($result))); + } + } + + /** + * Validates post parameters. + * + * @param $post + */ + private function _validate($post) + { + $studiensemester_kurzbz = $post['studiensemester_kurzbz']; + $anrechnungstart = $post['anrechnungstart']; + $anrechnungende = $post['anrechnungende']; + + if (isEmptyString($studiensemester_kurzbz) + || isEmptyString($anrechnungstart) + || isEmptyString($anrechnungende)) + { + $this->terminateWithJsonError($this->p->t('ui', 'errorFelderFehlen')); + } + + if ($anrechnungstart > $anrechnungende) + { + $this->terminateWithJsonError($this->p->t('ui', 'errorStartdatumNachEndedatum')); + } + + $result = $this->StudiensemesterModel->load($studiensemester_kurzbz); + $studiensemester = getData($result)[0]; + + if ($anrechnungstart < $studiensemester->start || $anrechnungstart > $studiensemester->ende) + { + $this->terminateWithJsonError($this->p->t('ui', 'errorStartdatumNichtInStudiensemester')); + } + + if ($anrechnungende < $studiensemester->start || $anrechnungende > $studiensemester->ende) + { + $this->terminateWithJsonError($this->p->t('ui', 'errorEndedatumNichtInStudiensemester')); + } + + + } + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } +} \ No newline at end of file diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php index 1f5c853db..8f71dc8d0 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php @@ -33,6 +33,9 @@ class approveAnrechnungDetail extends Auth_Controller ) ); + //Load configs + $this->load->config('anrechnung'); + // Load models $this->load->model('education/Anrechnung_model', 'AnrechnungModel'); $this->load->model('education/Anrechnungstatus_model', 'AnrechnungstatusModel'); @@ -90,7 +93,8 @@ class approveAnrechnungDetail extends Auth_Controller $antragData = $this->anrechnunglib->getAntragData( $anrechnungData->prestudent_id, $anrechnungData->studiensemester_kurzbz, - $anrechnungData->lehrveranstaltung_id + $anrechnungData->lehrveranstaltung_id, + $anrechnungData->anrechnung_id ); // Get Empfehlung data @@ -209,48 +213,46 @@ class approveAnrechnungDetail extends Auth_Controller */ public function requestRecommendation() { - $data = $this->input->post('data'); + $anrechnung_id = $this->input->post('anrechnung_id'); - if(isEmptyArray($data)) + if(isEmptyString($anrechnung_id)) { return $this->outputJsonError('Fehler beim Übertragen der Daten.'); } $retval = array(); - $counter = 0; + + // Check if Anrechnungs-LV has lector + if (!$this->anrechnunglib->LVhasLector($anrechnung_id)) + { + $this->terminateWithJsonError('LV has no lector'); + } - foreach ($data as $item) - { - // Check if Anrechnungs-LV has lector - if (!$this->anrechnunglib->LVhasLector($item['anrechnung_id'])) - { - // Count up LV with no lector - $counter++; + // Get Fachbereichsleitung or LV Leitung. + if($this->config->item('fbl') === TRUE) + { + $result = $this->anrechnunglib->getLeitungOfLvOe($anrechnung_id); + } + else + { + // If LV Leitung is not present, gets all LV lectors. + $result = $this->anrechnunglib->getLectors($anrechnung_id); + } - // Break, if LV has no lector - break; - } + $empfehlungsanfrage_an = !isEmptyArray($result) ? implode(', ', array_column($result, 'fullname')) : ''; - // Get full name of LV Leitung. - // If LV Leitung is not present, get full name of LV lectors. - $lector_arr = $this->anrechnunglib->getLectors($item['anrechnung_id']); - $empfehlungsanfrage_an = !isEmptyArray($lector_arr) - ? implode(', ', array_column($lector_arr, 'fullname')) - : ''; - - // Request Recommendation - if($this->anrechnunglib->requestRecommendation($item['anrechnung_id'])) - { - $retval[]= array( - 'anrechnung_id' => $item['anrechnung_id'], - 'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR, - 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR), - 'empfehlung_anrechnung' => null, - 'empfehlungsanfrageAm' => (new DateTime())->format('d.m.Y'), - 'empfehlungsanfrageAn' => $empfehlungsanfrage_an - ); - } - } + // Request Recommendation + if($this->anrechnunglib->requestRecommendation($anrechnung_id)) + { + $retval[]= array( + 'anrechnung_id' => $anrechnung_id, + 'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR, + 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR), + 'empfehlung_anrechnung' => null, + 'empfehlungsanfrageAm' => (new DateTime())->format('d.m.Y'), + 'empfehlungsanfrageAn' => $empfehlungsanfrage_an + ); + } /** * Send mails to lectors @@ -259,21 +261,24 @@ class approveAnrechnungDetail extends Auth_Controller * */ if (!isEmptyArray($retval)) { - self::_sendSanchoMailToLectors($retval); + if ($this->config->item('send_mail') === TRUE) + { + $this->_sendSanchoMailToLectors($anrechnung_id); + } // Output json to ajax return $this->outputJsonSuccess($retval); } // Output json to ajax - if (isEmptyArray($retval) && $counter > 0) + if (isEmptyArray($retval)) { - return $this->outputJsonError( + $this->terminateWithJsonError( "Empfehlung wurde nicht angefordert,\nDer LV sind keine LektorInnen zugeteilt." ); } - return $this->outputJsonError($this->p->t('ui', 'errorNichtAusgefuehrt')); + $this->terminateWithJsonError($this->p->t('ui', 'errorNichtAusgefuehrt')); } /** @@ -467,39 +472,33 @@ class approveAnrechnungDetail extends Auth_Controller /** * Send mail to lectors asking for recommendation. (first to LV-Leitung, if not present to all lectors of lv) - * @param $mail_params + * @param $anrechnung_id * @return bool */ - private function _sendSanchoMailToLectors($mail_params) + private function _sendSanchoMailToLectors($anrechnung_id) { - // Get Lehrveranstaltungen - $anrechnung_arr = array(); - - foreach ($mail_params as $item) - { - $this->AnrechnungModel->addSelect('lehrveranstaltung_id, studiensemester_kurzbz'); - $anrechnung_arr[]= array( - 'lehrveranstaltung_id' => $this->AnrechnungModel->load($item['anrechnung_id'])->retval[0]->lehrveranstaltung_id, - 'studiensemester_kurzbz' => $this->AnrechnungModel->load($item['anrechnung_id'])->retval[0]->studiensemester_kurzbz - ); - } - - $anrechnung_arr = array_unique($anrechnung_arr, SORT_REGULAR); - + $lehrveranstaltung_id = $this->AnrechnungModel->load($anrechnung_id)->retval[0]->lehrveranstaltung_id; + $studiensemester_kurzbz = $this->AnrechnungModel->load($anrechnung_id)->retval[0]->studiensemester_kurzbz; /** - * Get lectors (prio for LV-Leitung, if not present to all lectors of LV. + * Get mail receivers. + * If config is default (lectors): prio for LV-Leitung, if not present to all lectors of LV. * Anyway this function will receive a unique array to avoid sending more mails to one and the same lector. * **/ - $lector_arr = $this->_getLectors($anrechnung_arr); + if ($this->config->item('fbl') === TRUE) + { + $receiver_arr = $this->_getLeitungOfLvOe($lehrveranstaltung_id); + } + else + { + $receiver_arr = $this->_getLectors($studiensemester_kurzbz, $lehrveranstaltung_id); + } - - - // Send mail to lectors - foreach ($lector_arr as $lector) + // Send mail + foreach ($receiver_arr as $receiver) { - $to = $lector->uid; - $vorname = $lector->vorname; + $to = $receiver->uid. '@'. DOMAIN;; + $vorname = $receiver->vorname; // Get full name of stgl $this->load->model('person/Person_model', 'PersonModel'); @@ -537,35 +536,30 @@ class approveAnrechnungDetail extends Auth_Controller * @param $anrechnung_arr * @return array */ - private function _getLectors($anrechnung_arr) + private function _getLectors($studiensemester_kurzbz, $lehrveranstaltung_id) { $lector_arr = array(); - // Get lectors - foreach($anrechnung_arr as $anrechnung) - { - $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); - $result = $this->LehrveranstaltungModel->getLecturersByLv($anrechnung['studiensemester_kurzbz'], $anrechnung['lehrveranstaltung_id']); + $result = $this->LehrveranstaltungModel->getLecturersByLv($studiensemester_kurzbz, $lehrveranstaltung_id); - if (!$result = getData($result)) - { - show_error('Failed retrieving lectors of Lehrveranstaltung'); - } + if (!$result = getData($result)) + { + show_error('Failed retrieving lectors of Lehrveranstaltung'); + } - // Check if lv has LV-Leitung - $key = array_search(true, array_column($result, 'lvleiter')); + // Check if lv has LV-Leitung + $key = array_search(true, array_column($result, 'lvleiter')); - // If lv has LV-Leitung, keep only the one - if ($key !== false) - { - $lector_arr[]= $result[$key]; - } - // ...otherwise keep all lectors - else - { - $lector_arr = array_merge($lector_arr, $result); - } - } + // If lv has LV-Leitung, keep only the one + if ($key !== false) + { + $lector_arr[]= $result[$key]; + } + // ...otherwise keep all lectors + else + { + $lector_arr = array_merge($lector_arr, $result); + } /** * NOTE: This step is only done to make the array unique by uid, vorname and nachname in the following step @@ -584,6 +578,14 @@ class approveAnrechnungDetail extends Auth_Controller } + // Get Leitungen of Lehrveranstaltungs-Organisationseinheit + private function _getLeitungOfLvOe($lehrveranstaltung_id) + { + $result = $this->LehrveranstaltungModel->getLeitungOfLvOe($lehrveranstaltung_id); + + return hasData($result) ? getData($result) : show_error('Failed retrieving Leitung of Lehrveranstaltungs-Organisationseinheit'); + } + private function _saveEmpfehlungsNotiz($anrechnung_id, $empfehlungstext, $notiz_id) { $this->load->model('person/Notiz_model', 'NotizModel'); @@ -606,8 +608,5 @@ class approveAnrechnungDetail extends Auth_Controller trim($empfehlungstext), $this->_uid ); - - } - } diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index 9eb0c9734..f13814e66 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -28,6 +28,9 @@ class approveAnrechnungUebersicht extends Auth_Controller ) ); + // Load configs + $this->load->config('anrechnung'); + // Load models $this->load->model('education/Anrechnung_model', 'AnrechnungModel'); $this->load->model('education/Anrechnungstatus_model', 'AnrechnungstatusModel'); @@ -78,6 +81,19 @@ class approveAnrechnungUebersicht extends Auth_Controller show_error(getError($studiengang_kz_arr)); } + // Get oes the user is entitled for + $oe_kurzbz_arr_schreibberechtigt = array(); + if ($oe_arr = $this->permissionlib->getOE_isEntitledFor(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN)) + { + foreach($oe_arr as $oe) + { + $berechtigt = $this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN, 'suid', $oe); + + if ($berechtigt) $oe_kurzbz_arr_schreibberechtigt[]= $oe; + } + } + + // Check if permission is readonly $hasReadOnlyAccess = $this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN, 's') && !$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN, 'suid'); @@ -87,9 +103,11 @@ class approveAnrechnungUebersicht extends Auth_Controller $viewData = array( 'studiensemester_selected' => $studiensemester_kurzbz, - 'studiengaenge_entitled' => $studiengang_kz_arr, + 'studiengaenge_entitled' => $studiengang_kz_arr, // alle STG mit Lese- und Schreibberechtigung + 'oes_schreibberechtigt' => $oe_kurzbz_arr_schreibberechtigt, // alle STG nur mit Schreibberechtigung 'hasReadOnlyAccess' => $hasReadOnlyAccess, - 'hasCreateAnrechnungAccess' => $hasCreateAnrechnungAccess + 'hasCreateAnrechnungAccess' => $hasCreateAnrechnungAccess, + 'configFachbereichsleitung' => $this->config->item('fbl') ); $this->load->view('lehre/anrechnung/approveAnrechnungUebersicht.php', $viewData); @@ -207,14 +225,20 @@ class approveAnrechnungUebersicht extends Auth_Controller // Request Recommendation if($this->anrechnunglib->requestRecommendation($item['anrechnung_id'])) { - // Get full name of LV Leitung. - // If LV Leitung is not present, get full name of LV lectors. - $lector_arr = $this->anrechnunglib->getLectors($item['anrechnung_id']); - $empfehlungsanfrage_an = !isEmptyArray($lector_arr) - ? implode(', ', array_column($lector_arr, 'fullname')) - : ''; + // Get full name of Fachbereichsleitung or LV Leitung. + if($this->config->item('fbl') === TRUE) + { + $result = $this->anrechnunglib->getLeitungOfLvOe($item['anrechnung_id']); + } + else + { + // If LV Leitung is not present, get full name of LV lectors. + $result = $this->anrechnunglib->getLectors($item['anrechnung_id']); + } - $retval[]= array( + $empfehlungsanfrage_an = !isEmptyArray($result) ? implode(', ', array_column($result, 'fullname')) : ''; + + $retval[]= array( 'anrechnung_id' => $item['anrechnung_id'], 'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR, 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR), @@ -226,19 +250,27 @@ class approveAnrechnungUebersicht extends Auth_Controller } /** - * Send mails to lectors + * Send mails * NOTE: mails are sent at the end to ensure sending only ONE mail to each LV-Leitung or lector * even if they are required for more recommendations * */ if (!isEmptyArray($retval)) { - self::_sendSanchoMailToLectors($retval); + if ($this->config->item('send_mail') === TRUE) + { + $this->_sendSanchoMail($retval); + } } // Output json to ajax - if (isEmptyArray($retval) && $counter == 0) + if (isEmptyArray($retval)) { - return $this->outputJsonError('Es wurden keine Empfehlungen angefordert'); + if ($counter > 0) + { + $this->terminateWithJsonError('Bei '. $counter.' LV sind keine LektorInnen zugeteilt.'); + } + + $this->terminateWithJsonError('Es wurden keine Empfehlungen angefordert'); } return $this->outputJsonSuccess($retval); @@ -316,7 +348,7 @@ class approveAnrechnungUebersicht extends Auth_Controller * @param $mail_params * @return bool */ - private function _sendSanchoMailToLectors($mail_params) + private function _sendSanchoMail($mail_params) { // Get Lehrveranstaltungen $anrechnung_arr = array(); @@ -332,18 +364,25 @@ class approveAnrechnungUebersicht extends Auth_Controller $anrechnung_arr = array_unique($anrechnung_arr, SORT_REGULAR); - - /** - * Get lectors (prio for LV-Leitung, if not present to all lectors of LV. - * Anyway this function will receive a unique array to avoid sending more mails to one and the same lector. - * **/ - $lector_arr = $this->_getLectors($anrechnung_arr); + /** + * Get mail receivers. + * If retrieving lectors: prio for LV-Leitung, if not present to all lectors of LV. + * This function will receive a unique array to avoid sending more mails to one and the same user. + **/ + if($this->config->item('fbl') === TRUE) + { + $receiver_arr = $this->_getLeitungOfLvOe($anrechnung_arr); + } + else + { + $receiver_arr = $this->_getLectors($anrechnung_arr); + } // Send mail to lectors - foreach ($lector_arr as $lector) + foreach ($receiver_arr as $receiver) { - $to = $lector->uid; - $vorname = $lector->vorname; + $to = $receiver->uid. '@'. DOMAIN; + $vorname = $receiver->vorname; // Get full name of stgl $this->load->model('person/Person_model', 'PersonModel'); @@ -427,4 +466,34 @@ class approveAnrechnungUebersicht extends Auth_Controller return $lector_arr; } + + /** + * Get Leitungen of Lehrveranstaltungs-Organisationseinheit with unique uids. + * + * @param $anrechnung_arr + * @return array + */ + private function _getLeitungOfLvOe($anrechnung_arr) + { + $oeLeitung_arr = array(); + + // Get Leitungen + foreach($anrechnung_arr as $anrechnung) + { + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $result = $this->LehrveranstaltungModel->getLeitungOfLvOe($anrechnung['lehrveranstaltung_id']); + + if (!hasData($result)) + { + show_error('No Leitung found'); + } + + $oeLeitung_arr = array_merge($oeLeitung_arr, getData($result)); + } + + // Make array unique + $oeLeitung_arr = array_unique($oeLeitung_arr, SORT_REGULAR); + + return $oeLeitung_arr; + } } diff --git a/application/controllers/lehre/anrechnung/RequestAnrechnung.php b/application/controllers/lehre/anrechnung/RequestAnrechnung.php index fbaac9b3e..e9059720b 100644 --- a/application/controllers/lehre/anrechnung/RequestAnrechnung.php +++ b/application/controllers/lehre/anrechnung/RequestAnrechnung.php @@ -80,11 +80,7 @@ class requestAnrechnung extends Auth_Controller $prestudent_id = getData($result)[0]->prestudent_id; // Check if application deadline is expired - $is_expired = self::_isExpired( - $this->config->item('submit_application_start'), - $this->config->item('submit_application_end'), - $studiensemester_kurzbz - ); + $is_expired = $this->_isExpired($studiensemester_kurzbz); // Check if Lehrveranstaltung was already graded with application blocking grades $is_blocked = self::_LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id); @@ -93,7 +89,7 @@ class requestAnrechnung extends Auth_Controller $anrechnungData = $this->anrechnunglib->getAnrechnungDataByLv($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id); // Get Antrag data - $antragData = $this->anrechnunglib->getAntragData($prestudent_id, $studiensemester_kurzbz, $lehrveranstaltung_id); + $antragData = $this->anrechnunglib->getAntragData($prestudent_id, $studiensemester_kurzbz, $lehrveranstaltung_id, $anrechnungData->anrechnung_id); $viewData = array( 'antragData' => $antragData, @@ -234,32 +230,30 @@ class requestAnrechnung extends Auth_Controller * @return bool True if deadline is expired * @throws Exception */ - private function _isExpired($start, $ende, $studiensemester_kurzbz) + private function _isExpired($studiensemester_kurzbz) { - $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $today = new DateTime('today midnight'); - // If start is not given, set to Semesterstart. - if (!isset($start) || isEmptyString($start)) - { - $this->StudiensemesterModel->addSelect('start'); - $result = $this->StudiensemesterModel->load($studiensemester_kurzbz); - $start = getData($result)[0]->start; - } + // Load all Anrechnungszeitfenster for this Studiensemester + $this->load->model('education/Anrechnungszeitraum_model', 'AnrechnungszeitraumModel'); + $result = $this->AnrechnungszeitraumModel->loadWhere(array('studiensemester_kurzbz' => $studiensemester_kurzbz)); - // If ende is not given, set to Semesterende. - if (!isset($ende) || isEmptyString($ende)) - { - $this->StudiensemesterModel->addSelect('ende'); - $result = $this->StudiensemesterModel->load($studiensemester_kurzbz); - $ende = getData($result)[0]->ende; - } + if (hasData($result)) + { + // Loop through Anrechnungszeitfenster + foreach (getData($result) as $azrObj) + { + $start = new DateTime($azrObj->anrechnungstart); + $ende = new DateTime($azrObj->anrechnungende); - $today = new DateTime('today midnight'); - $start = new DateTime($start); - $ende = new DateTime($ende); + // Return false if today is at least within one Anrechnungszeitraum + if (($today >= $start && $today <= $ende)) return false; - // True if expired - return ($today < $start || $today > $ende); + } + } + + // Return true if today is in none Anrechnungszeitraum + return true; } /** diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php index 1bd92004d..d141a0635 100644 --- a/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php @@ -28,6 +28,9 @@ class reviewAnrechnungDetail extends Auth_Controller ) ); + // Load configs + $this->load->config('anrechnung'); + // Load models $this->load->model('education/Anrechnung_model', 'AnrechnungModel'); $this->load->model('education/Anrechnungstatus_model', 'AnrechnungstatusModel'); @@ -84,16 +87,21 @@ class reviewAnrechnungDetail extends Auth_Controller $antragData = $this->anrechnunglib->getAntragData( $anrechnungData->prestudent_id, $anrechnungData->studiensemester_kurzbz, - $anrechnungData->lehrveranstaltung_id + $anrechnungData->lehrveranstaltung_id, + $anrechnungData->anrechnung_id ); // Get Empfehlung data $empfehlungData = $this->anrechnunglib->getEmpfehlungData($anrechnung_id); + // False if LV-Leitung is present and user is not LV-Leitung. Otherwise always true. + $isEmpfehlungsberechtigt = $this->anrechnunglib->isEmpfehlungsberechtigt($anrechnung_id); + $viewData = array( 'antragData' => $antragData, 'anrechnungData' => $anrechnungData, - 'empfehlungData' => $empfehlungData + 'empfehlungData' => $empfehlungData, + 'isEmpfehlungsberechtigt' => $isEmpfehlungsberechtigt ); $this->load->view('lehre/anrechnung/reviewAnrechnungDetail.php', $viewData); @@ -140,10 +148,13 @@ class reviewAnrechnungDetail extends Auth_Controller * Send mails to STGL (if not present STGL, send to STGL assistance) * NOTE: mails are sent at the end to ensure sending only one mail to each STGL * */ - if (!$this->_sendSanchoMails($json, true)) - { - return $this->outputJsonError('Failed sending emails'); - } + if ($this->config->item('send_mail') === TRUE) + { + if (!$this->_sendSanchoMails($json, true)) + { + return $this->outputJsonError('Failed sending emails'); + } + } return $this->outputJsonSuccess($json); } @@ -191,10 +202,13 @@ class reviewAnrechnungDetail extends Auth_Controller if (isset($json) && !isEmptyArray($json)) { // Send mails to STGL (if not present STGL, send to STGL assistance) - if (!$this->_sendSanchoMails($json, false)) - { - return $this->outputJsonError('Failed sending emails'); - } + if ($this->config->item('send_mail') === TRUE) + { + if (!$this->_sendSanchoMails($json, false)) + { + return $this->outputJsonError('Failed sending emails'); + } + } return $this->outputJsonSuccess($json); } @@ -253,8 +267,14 @@ class reviewAnrechnungDetail extends Auth_Controller show_error('Failed retrieving Anrechnung'); } - $result = $this->LehrveranstaltungModel - ->getLecturersByLv($result->studiensemester_kurzbz, $result->lehrveranstaltung_id); + if($this->config->item('fbl') === TRUE) + { + $result = $this->LehrveranstaltungModel->getLeitungOfLvOe($result->lehrveranstaltung_id); + } + else + { + $result = $this->LehrveranstaltungModel->getLecturersByLv($result->studiensemester_kurzbz, $result->lehrveranstaltung_id); + } if($result = getData($result)) { @@ -282,14 +302,20 @@ class reviewAnrechnungDetail extends Auth_Controller show_error('Failed retrieving Anrechnung'); } - $result = $this->LehrveranstaltungModel - ->getLecturersByLv($result->studiensemester_kurzbz, $result->lehrveranstaltung_id); + if($this->config->item('fbl') === TRUE) + { + $result = $this->LehrveranstaltungModel->getLeitungOfLvOe($result->lehrveranstaltung_id); + } + else + { + $result = $this->LehrveranstaltungModel->getLecturersByLv($result->studiensemester_kurzbz, $result->lehrveranstaltung_id); + } if($result = getData($result)) { - $entitled_lector_arr = array_column($result, 'uid'); + $entitled_uid_arr = array_column($result, 'uid'); - if (in_array($this->_uid, $entitled_lector_arr)) + if (in_array($this->_uid, $entitled_uid_arr)) { return; } diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php index c63d0af69..6d4107936 100644 --- a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php @@ -26,6 +26,9 @@ class reviewAnrechnungUebersicht extends Auth_Controller ) ); + // Load configs + $this->load->config('anrechnung'); + // Load models $this->load->model('education/Anrechnung_model', 'AnrechnungModel'); $this->load->model('education/Anrechnungstatus_model', 'AnrechnungstatusModel'); @@ -72,7 +75,8 @@ class reviewAnrechnungUebersicht extends Auth_Controller } $viewData = array( - 'studiensemester_selected' => $studiensemester_kurzbz + 'studiensemester_selected' => $studiensemester_kurzbz, + 'configFachbereichsleitung' => $this->config->item('fbl') ); $this->load->view('lehre/anrechnung/reviewAnrechnungUebersicht.php', $viewData); @@ -111,16 +115,19 @@ class reviewAnrechnungUebersicht extends Auth_Controller * Send mails to STGL (if not present STGL, send to STGL assistance) * NOTE: mails are sent at the end to ensure sending only one mail to each STGL * */ - if (!$this->_sendSanchoMails($json, true)) - { - show_error('Failed sending emails'); - } + if ($this->config->item('send_mail') === TRUE) + { + if (!$this->_sendSanchoMails($json, true)) + { + show_error('Failed sending emails'); + } + } return $this->outputJsonSuccess($json); } else { - return $this->outputJsonError($this->p->t('ui', 'errorNichtAusgefuehrt')); + $this->terminateWithJsonError($this->p->t('ui', 'errorNichtAusgefuehrt')); } } @@ -154,10 +161,13 @@ class reviewAnrechnungUebersicht extends Auth_Controller if (isset($json) && !isEmptyArray($json)) { // Send mails to STGL (if not present STGL, send to STGL assistance) - if (!$this->_sendSanchoMails($json, false)) - { - show_error('Failed sending emails'); - } + if ($this->config->item('send_mail') === TRUE) + { + if (!$this->_sendSanchoMails($json, false)) + { + show_error('Failed sending emails'); + } + } return $this->outputJsonSuccess($json); } @@ -217,14 +227,20 @@ class reviewAnrechnungUebersicht extends Auth_Controller show_error('Failed retrieving Anrechnung'); } - $result = $this->LehrveranstaltungModel - ->getLecturersByLv($result->studiensemester_kurzbz, $result->lehrveranstaltung_id); + if ($this->config->item('fbl') === TRUE) + { + $result = $this->LehrveranstaltungModel->getLeitungOfLvOe($result->lehrveranstaltung_id); + } + else + { + $result = $this->LehrveranstaltungModel->getLecturersByLv($result->studiensemester_kurzbz, $result->lehrveranstaltung_id); + } if($result = getData($result)) { - $entitled_lector_arr = array_column($result, 'uid'); + $entitled_uid_arr = array_column($result, 'uid'); - if (in_array($this->_uid, $entitled_lector_arr)) + if (in_array($this->_uid, $entitled_uid_arr)) { return; } diff --git a/application/controllers/system/MigrateContract.php b/application/controllers/system/MigrateContract.php index cefc080d6..7583fedb3 100644 --- a/application/controllers/system/MigrateContract.php +++ b/application/controllers/system/MigrateContract.php @@ -1,10 +1,10 @@ load->model('codex/bisverwendung_model', 'BisVerwendungModel'); $this->load->model('person/benutzerfunktion_model', 'BenutzerfunktionModel'); - + $this->matching_ba1_vertragsart = array( '101'=>'DV zum Bund', '102'=>'DV anderen Gebietskörperschaft', - '103'=>'EchterDV', + '103'=>'echterdv', '104'=>'Lehr- oder Ausbildungsverhältnis', - '105'=>'ext. LehrendeR (freier DV)', + '105'=>'freierdv', '106'=>'Andere Bildungseinrichtung', - '107'=>'Werkvertrag (Sonstiges)', - '108'=>'Stud. Hilfskraft (Echter DV)', - '109'=>'Überlassungsvertrag', - '110'=>'Echter Freier DV', - '111'=>'EchterDV', //All-In + '107'=>'werkvertrag', + '108'=>'studentischehilfskr', + '109'=>'ueberlassungsvertrag', + '110'=>'echterfreier', + '111'=>'echterdv', //All-In ); } @@ -55,6 +56,161 @@ class MigrateContract extends CLI_Controller */ //$this->outputJson($contracts); var_dump($contracts); + $this->_saveJSON($contracts); + } + + private function _saveJSON($contracts) + { + $this->load->model('vertragsbestandteil/Dienstverhaeltnis_model','DienstverhaeltnisModel'); + $this->load->model('vertragsbestandteil/Vertragsbestandteil_model','VertragsbestandteilModel'); + $this->load->model('vertragsbestandteil/VertragsbestandteilStunden_model','VertragsbestandteilStundenModel'); + $this->load->model('vertragsbestandteil/VertragsbestandteilZeitaufzeichnung_model','VertragsbestandteilZeitaufzeichnungModel'); + $this->load->model('vertragsbestandteil/VertragsbestandteilFreitext_model','VertragsbestandteilFreitextModel'); + $this->load->model('vertragsbestandteil/VertragsbestandteilFunktion_model','VertragsbestandteilFunktionModel'); + $this->load->model('vertragsbestandteil/VertragsbestandteilKarenz_model','VertragsbestandteilKarenzModel'); + + $failed = false; + $this->db->trans_begin(); + + foreach($contracts['dv'] as $row_dv) + { + // Dienstvertrag erstellen + $resultDV = $this->DienstverhaeltnisModel->insert( + array( + 'mitarbeiter_uid' => $row_dv['mitarbeiter_uid'], + 'vertragsart_kurzbz' => $row_dv['vertragsart_kurzbz'], + 'oe_kurzbz' => $row_dv['oe_kurzbz'], + 'von' => $row_dv['von'], + 'bis' => $row_dv['bis'], + 'insertamum' => date('Y-m-d H:i:s'), + 'insertvon' => 'MigrateContract' + ) + ); + + if (isSuccess($resultDV) && hasData($resultDV)) + { + $dv_id = getData($resultDV); + + // Vertragsbetandteile erstellen + foreach($row_dv['vbs'] as $row_vbs) + { + $resultVBS = $this->VertragsbestandteilModel->insert( + array( + 'dienstverhaeltnis_id' => $dv_id, + 'vertragsbestandteiltyp_kurzbz' => $row_vbs['vertragsbestandteiltyp_kurzbz'], + 'von' => $row_vbs['von'], + 'bis' => $row_vbs['bis'], + 'insertamum' => date('Y-m-d H:i:s'), + 'insertvon' => 'MigrateContract' + ) + ); + + if (isSuccess($resultVBS) && hasData($resultVBS)) + { + $vbs_id = getData($resultVBS); + echo 'VBS:'.$vbs_id; + + switch($row_vbs['vertragsbestandteiltyp_kurzbz']) + { + case 'stunden': + $resultVBS = $this->_insertVBSStunden($vbs_id, $row_vbs); + break; + case 'zeitaufzeichnung': + $resultVBS = $this->_insertVBSZeitaufzeichnung($vbs_id, $row_vbs); + break; + case 'funktion': + $resultVBS = $this->_insertVBSFunktion($vbs_id, $row_vbs); + break; + case 'freitext': + $resultVBS = $this->_insertVBSFreitext($vbs_id, $row_vbs); + break; + case 'karenz': + $resultVBS = $this->_insertVBSKarenz($vbs_id, $row_vbs); + break; + } + + if (isError($resultVBS)) + { + echo "FAILED:".getError($resultVBS); + $failed = true; + } + } + else + { + $failed = true; + } + } + } + else + { + $failed = true; + } + } + + if(!$failed) + { + $this->db->trans_commit(); + } + else + { + echo "ROLLBACK"; + $this->db->trans_rollback(); + } + } + + private function _insertVBSKarenz($vbs_id, $row_vbs) + { + return $this->VertragsbestandteilKarenzModel->insert( + array( + 'vertragsbestandteil_id' => $vbs_id, + 'karenztyp_kurzbz' => $row_vbs['karenztyp_kurzbz'] + ) + ); + } + + private function _insertVBSFreitext($vbs_id, $row_vbs) + { + return $this->VertragsbestandteilFreitextModel->insert( + array( + 'vertragsbestandteil_id' => $vbs_id, + 'freitexttyp_kurzbz' => $row_vbs['freitexttyp_kurzbz'], + 'titel' => $row_vbs['titel'], + 'anmerkung' => $row_vbs['anmerkung'] + ) + ); + } + + private function _insertVBSFunktion($vbs_id, $row_vbs) + { + return $this->VertragsbestandteilFunktionModel->insert( + array( + 'vertragsbestandteil_id' => $vbs_id, + 'benutzerfunktion_id' => $row_vbs['benutzerfunktion_id'] + ) + ); + } + + private function _insertVBSZeitaufzeichnung($vbs_id, $row_vbs) + { + return $this->VertragsbestandteilZeitaufzeichnungModel->insert( + array( + 'vertragsbestandteil_id' => $vbs_id, + 'zeitaufzeichnung' => $row_vbs['zeitaufzeichnung'], + 'azgrelevant' => $row_vbs['azgrelevant'], + 'homeoffice' => $row_vbs['homeoffice'] + ) + ); + } + + private function _insertVBSStunden($vbs_id, $row_vbs) + { + return $this->VertragsbestandteilStundenModel->insert( + array( + 'vertragsbestandteil_id' => $vbs_id, + 'wochenstunden' => $row_vbs['wochenstunden'], + 'teilzeittyp_kurzbz' => $row_vbs['teilzeittyp_kurzbz'] + ) + ); } /** @@ -128,7 +284,7 @@ class MigrateContract extends CLI_Controller $karenztyp = 'bildungskarenz'; else $karenztyp = 'elternkarenz'; - + // VBS anlegen und Funktion zuweisen $newVBSIndex = $this->_getNewVBSIndex($contracts, $dv); $contracts['dv'][$dv]['vbs'][$newVBSIndex]['vertragsbestandteiltyp_kurzbz'] = 'karenz'; @@ -138,10 +294,10 @@ class MigrateContract extends CLI_Controller $contracts['dv'][$dv]['vbs'][$newVBSIndex]['geplanter_geburtstermin'] = null; $contracts['dv'][$dv]['vbs'][$newVBSIndex]['tatsaechlicher_geburtstermin'] = null; $contracts['dv'][$dv]['vbs'][$newVBSIndex]['hint'] = 'Dauer:'.$dauer; - } + } } - /** + /** * Holt die Funktionen die Vertragsrelevant sind und verknüpft diese */ private function _addVertragsbestandteilFunktion(&$contracts, $user) @@ -169,7 +325,7 @@ class MigrateContract extends CLI_Controller && ($row_contract['bis'] == '' || $row_contract['bis'] >= $row_funktion->datum_von) && ( ( - isset($row_funktion->datum_bis) && isset($row_contract['bis']) + isset($row_funktion->datum_bis) && isset($row_contract['bis']) && $row_funktion->datum_bis <= $row_contract['bis'] ) || $row_funktion->datum_bis == '' @@ -194,7 +350,7 @@ class MigrateContract extends CLI_Controller if ($dtende_fkt < $dtende_dv) $endedatum = $row_funktion->datum_bis; else - $endedatum = $row_contract['von']; + $endedatum = $row_contract['bis']; // VBS anlegen und Funktion zuweisen $newVBSIndex = $this->_getNewVBSIndex($contracts, $dv); @@ -215,7 +371,7 @@ class MigrateContract extends CLI_Controller } /** - * Prueft ob schon ein Vertragsbestandteil fuer Zeitaufzeichnung vorhanden ist das in den Zeitraum passt + * Prueft ob schon ein Vertragsbestandteil fuer Zeitaufzeichnung vorhanden ist das in den Zeitraum passt * bzw direkt anschließt. Wenn es direkt anschließend ist und die Art gleich sind wird die Laufzeit verlaengert * Ansonsten wird ein neuer VBS angelegt */ @@ -227,7 +383,7 @@ class MigrateContract extends CLI_Controller { if ($row_vbs['vertragsbestandteiltyp_kurzbz'] == 'zeitaufzeichnung') { - if ($this->_isVBSAngrenzend($row_verwendung, $row_vbs) + if ($this->_isVBSAngrenzend($row_verwendung, $row_vbs) && $row_vbs['zeitaufzeichnung'] == $row_verwendung->zeitaufzeichnungspflichtig && $row_vbs['azgrelevant'] == $row_verwendung->azgrelevant && $row_vbs['homeoffice'] == $row_verwendung->homeoffice @@ -290,7 +446,7 @@ class MigrateContract extends CLI_Controller } /** - * Prueft ob schon ein Vertragsbestandteil mit diesem Stundenausmass vorhanden ist das in den Zeitraum passt + * Prueft ob schon ein Vertragsbestandteil mit diesem Stundenausmass vorhanden ist das in den Zeitraum passt * bzw direkt anschließt. Wenn es direkt anschließend ist und die Stunden gleich sind wird die Laufzeit verlaengert * Ansonsten wird ein neuer VBS angelegt */ @@ -303,10 +459,10 @@ class MigrateContract extends CLI_Controller { foreach ($contracts['dv'][$dv]['vbs'] as $index_vbs=>$row_vbs) { - if ($row_vbs['vertragsbestandteiltyp_kurzbz'] == 'stunden') + if ($row_vbs['vertragsbestandteiltyp_kurzbz'] == 'stunden' || ($row_vbs['vertragsbestandteiltyp_kurzbz'] == 'karenz' && $row_verwendung->vertragsstunden === '0.00')) { - if ($this->_isVBSAngrenzend($row_verwendung, $row_vbs) && $row_vbs['wochenstunden'] == $row_verwendung->vertragsstunden) - { + if ($this->_isVBSAngrenzend($row_verwendung, $row_vbs) && ($row_vbs['wochenstunden'] == $row_verwendung->vertragsstunden || $row_verwendung->vertragsstunden === '0.00')) + { // stunden bleiben gleich - Ende des VBS verlaengern $contracts['dv'][$dv]['vbs'][$index_vbs]['bis'] = $row_verwendung->ende; return true; @@ -366,8 +522,8 @@ class MigrateContract extends CLI_Controller (isset($row_dv['bis']) && $row_verwendung->ende != '' && ($row_dv['bis'] == '' || $row_dv['bis'] >= $row_verwendung->ende) ) || // direkt angrenzend an dieses DV - (isset($row_dv['bis']) - && ($row_dv['bis'] == '' + (isset($row_dv['bis']) + && ($row_dv['bis'] == '' || $row_dv['bis'] == $dtstart->sub(new DateInterval('P1D'))->format('Y-m-d') ) ) @@ -379,11 +535,12 @@ class MigrateContract extends CLI_Controller } } } - + $newDvIndex = $this->_getNewDVIndex($contracts); $contracts['dv'][$newDvIndex]['mitarbeiter_uid'] = $row_verwendung->mitarbeiter_uid; $contracts['dv'][$newDvIndex]['von'] = $row_verwendung->beginn; $contracts['dv'][$newDvIndex]['bis'] = $row_verwendung->ende; + $contracts['dv'][$newDvIndex]['oe_kurzbz'] = $this->OE_DEFAULT; $contracts['dv'][$newDvIndex]['vertragsart_kurzbz'] = $this->matching_ba1_vertragsart[$row_verwendung->ba1code]; return $newDvIndex; @@ -407,7 +564,7 @@ class MigrateContract extends CLI_Controller { if (isset($contracts['dv']) && is_array($contracts['dv'])) return max(array_keys($contracts['dv'])) + 1; - else + else return 0; } } diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index d027e559e..548b071d3 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -142,12 +142,6 @@ class InfoCenter extends Auth_Controller 'reloadNotizen' => array('infocenter:r', 'lehre/zgvpruefung:r'), 'reloadLogs' => 'infocenter:r', 'outputAkteContent' => array('infocenter:r', 'lehre/zgvpruefung:r'), - 'getPostponeDate' => array('infocenter:r', 'lehre/zgvpruefung:r'), - 'park' => 'infocenter:rw', - 'unpark' => 'infocenter:rw', - 'setOnHold' => 'infocenter:rw', - 'removeOnHold' => array('infocenter:rw', 'lehre/zgvpruefung:rw'), - 'getStudienjahrEnd' => array('infocenter:r', 'lehre/zgvpruefung:r'), 'setNavigationMenuArrayJson' => 'infocenter:r', 'getAbsageData' => 'infocenter:r', 'saveAbsageForAll' => 'infocenter:rw', @@ -164,6 +158,7 @@ class InfoCenter extends Auth_Controller $this->load->model('crm/Statusgrund_model', 'StatusgrundModel'); $this->load->model('crm/ZGVPruefung_model', 'ZGVPruefungModel'); $this->load->model('crm/ZGVPruefungStatus_model', 'ZGVPruefungStatusModel'); + $this->load->model('crm/Rueckstellung_model', 'RueckstellungModel'); $this->load->model('person/Notiz_model', 'NotizModel'); $this->load->model('person/Person_model', 'PersonModel'); $this->load->model('system/Message_model', 'MessageModel'); @@ -606,7 +601,7 @@ class InfoCenter extends Auth_Controller } /** - * Sendet bei einer neuen ZGV Prüfung die Mail raus an den Studiengang + * Sendet bei einer neuen ZGV Prüfung eine Mail an den Studiengang */ private function sendZgvMail($mail, $typ, $person){ $data = array( @@ -697,7 +692,7 @@ class InfoCenter extends Auth_Controller /** * Fügt einen neuen ZGV Status hinzu oder updated einen bestehenden - * Falls es erfolgreich war, sendet er die Mail raus + * Falls es erfolgreich war, wird eine Mail rausgeschickt */ public function zgvRueckfragen() { @@ -751,7 +746,8 @@ class InfoCenter extends Auth_Controller $this->sendZgvMail($mail, $typ, $person); elseif (isError($insert)) $this->terminateWithJsonError('Fehler beim Speichern'); - }else + } + else { $insert = $this->ZGVPruefungModel->insert( array( @@ -781,7 +777,7 @@ class InfoCenter extends Auth_Controller } $hold = false; - if ($this->personloglib->getOnHoldDate($person_id) !== null) + if (hasData($this->RueckstellungModel->getByPersonId($person_id, 'onhold_zgv'))) $hold = true; $this->outputJsonSuccess( @@ -1162,107 +1158,7 @@ class InfoCenter extends Auth_Controller ->set_output($aktecontent->retval) ->_display(); } - - /** - * Gets the date until which a person is parked - * @param $person_id - */ - public function getPostponeDate($person_id) - { - $result = array( - 'type' => null, - 'date' => null - ); - - $parkedDate = $this->personloglib->getParkedDate($person_id); - - if (isset($parkedDate)) - { - $result['type'] = 'parked'; - $result['date'] = $parkedDate; - } - else - { - $onholdDate = $this->personloglib->getOnHoldDate($person_id); - - if (isset($onholdDate)) - { - $result['type'] = 'onhold'; - $result['date'] = $onholdDate; - } - } - - $this->outputJsonSuccess($result); - } - - /** - * Initializes parking of a person, i.e. a person is not expected to do any actions while parked - */ - public function park() - { - $person_id = $this->input->post('person_id'); - $date = $this->input->post('parkdate'); - - $result = $this->personloglib->park($person_id, date_format(date_create($date), 'Y-m-d'), self::TAETIGKEIT, self::APP, null, $this->_uid); - - $this->outputJson($result); - } - - /** - * Removes parking of a person - */ - public function unPark() - { - $person_id = $this->input->post('person_id'); - - $result = $this->personloglib->unPark($person_id); - - $this->outputJson($result); - } - - /** - * Sets a person on hold ("zurückstellen") - */ - public function setOnHold() - { - $person_id = $this->input->post('person_id'); - $date = $this->input->post('onholddate'); - - $result = $this->personloglib->setOnHold($person_id, date_format(date_create($date), 'Y-m-d'), self::TAETIGKEIT, self::APP, null, $this->_uid); - - $this->outputJson($result); - } - - /** - * Removed on hold status of a person - */ - public function removeOnHold() - { - $person_id = $this->input->post('person_id'); - - $result = $this->personloglib->removeOnHold($person_id); - - $this->outputJson($result); - } - - /** - * Gets the End date of the current Studienjahr - */ - public function getStudienjahrEnd() - { - $this->load->model('organisation/studienjahr_model', 'StudienjahrModel'); - - $result = $this->StudienjahrModel->getCurrStudienjahr(); - - $json = null; - - if (hasData($result)) - { - $json = $result->retval[0]->ende; - } - - $this->outputJsonSuccess(array($json)); - } + /** * Wrapper for setNavigationMenu, returns JSON message @@ -1484,7 +1380,6 @@ class InfoCenter extends Auth_Controller if($nachreichungAm < $today) $this->terminateWithJsonError($this->p->t('infocenter', 'nachreichDatumNichtVergangenheit')); - $akte = $this->AkteModel->loadWhere(array('person_id' => $person_id, 'dokument_kurzbz' => $allowedTypes[$typ])); if (hasData($akte)) { diff --git a/application/controllers/system/infocenter/Rueckstellung.php b/application/controllers/system/infocenter/Rueckstellung.php new file mode 100644 index 000000000..62af633ca --- /dev/null +++ b/application/controllers/system/infocenter/Rueckstellung.php @@ -0,0 +1,135 @@ + array('infocenter:r', 'lehre/zgvpruefung:r'), + 'set' => array('infocenter:r', 'lehre/zgvpruefung:r'), + 'delete' => array('infocenter:r', 'lehre/zgvpruefung:r'), + 'getStatus' => array('infocenter:rw', 'lehre/zgvpruefung:rw') + ) + ); + + $this->load->model('crm/Rueckstellung_model', 'RueckstellungModel'); + $this->load->model('crm/RueckstellungStatus_model', 'RueckstellungStatusModel'); + $this->load->model('person/Person_model', 'PersonModel'); + $this->load->library('PersonLogLib'); + + $this->_setAuthUID(); // sets property uid + + $this->_ci =& get_instance(); // get code igniter instance + } + + public function get($person_id) + { + $result = null; + $rueckstellung = $this->_ci->RueckstellungModel->getByPersonId($person_id); + + if (isError($rueckstellung)) + $this->terminateWithJsonError($this->_ci->p->t('ui', 'fehlerBeimLesen')); + + if (hasData($rueckstellung)) + { + $rueckstellung = getData($rueckstellung)[0]; + $fullName = getData($this->_ci->PersonModel->getFullName($rueckstellung->insertvon)); + + $result = array( + 'von' => $fullName, + 'bezeichnung' => $rueckstellung->bezeichnung, + 'bis' => $rueckstellung->datum_bis, + 'status_kurzbz' => $rueckstellung->status_kurzbz + ); + + if ($rueckstellung->status_kurzbz === 'parked' && $rueckstellung->datum_bis < date('Y-m-d')) + { + $this->_ci->RueckstellungModel->delete(array('person_id' => $person_id, 'status_kurzbz' => 'parked')); + $result = null; + } + } + + $this->outputJsonSuccess($result); + } + + public function set() + { + $person_id = $this->input->post('person_id'); + $datum_bis = $this->input->post('datum_bis'); + $status_kurzbz = $this->input->post('status_kurzbz'); + + $result = $this->_ci->RueckstellungModel->insert( + array('person_id' => $person_id, + 'status_kurzbz' => $status_kurzbz, + 'datum_bis' => date_format(date_create($datum_bis), 'Y-m-d'), + 'insertvon' => $this->_uid + ) + ); + + if (isError($result)) + $this->terminateWithJsonError(getError($result)); + + $this->_log($person_id, $status_kurzbz); + + $this->outputJson($result); + } + + public function delete() + { + $person_id = $this->input->post('person_id'); + $status = $this->input->post('status'); + + $result = $this->_ci->RueckstellungModel->delete(array('person_id' => $person_id, 'status_kurzbz' => $status)); + + if (isError($result)) + $this->terminateWithJsonError($this->_ci->p->t('ui', 'fehlerBeimSpeichern')); + + $this->outputJson($result); + } + + public function getStatus($aktiv = true) + { + $this->_ci->RueckstellungStatusModel->addOrder('sort'); + $result = $this->_ci->RueckstellungStatusModel->loadWhere(array('aktiv' => $aktiv)); + + if (isError($result)) + $this->terminateWithJsonError($this->_ci->p->t('ui', 'fehlerBeimLesen')); + + $this->outputJsonSuccess(getData($result)); + } + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } + + private function _log($person_id, $status_kurzbz) + { + $message = "Person $person_id set to $status_kurzbz"; + + $this->_ci->personloglib->log( + $person_id, + 'Action', + array( + 'name' => 'Person status set', + 'message' => $message, + 'success' => true + ), + 'bewerbung', + 'infocenter', + null, + $this->_uid + ); + } +} \ No newline at end of file diff --git a/application/controllers/system/issues/Plausichecks.php b/application/controllers/system/issues/Plausichecks.php index 748361321..2dd166794 100644 --- a/application/controllers/system/issues/Plausichecks.php +++ b/application/controllers/system/issues/Plausichecks.php @@ -4,6 +4,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class Plausichecks extends Auth_Controller { + const GENERIC_ISSUE_OCCURED_TEXT = 'Issue aufgetreten'; + public function __construct() { parent::__construct( @@ -78,20 +80,27 @@ class Plausichecks extends Auth_Controller // optionally replace fehler parameters in text, output the fehlertext if (hasData($fehlerRes)) { + // use issue fehler text from database if present $fehlerText = getData($fehlerRes)[0]->fehlertext; if (!isEmptyArray($fehlertext_params)) { + // replace placeholder with params, if present if (count($fehlertext_params) != substr_count($fehlerText, '%s')) $this->terminateWithJsonError('Wrong number of parameters for Fehlertext, fehler_kurzbz ' . $fehler_kurzbz); $fehlerText = vsprintf($fehlerText, $fehlertext_params); } - - if (isset($person_id)) $fehlerText .= "; person_id: $person_id"; - if (isset($oe_kurzbz)) $fehlerText .= "; oe_kurzbz: $oe_kurzbz"; - $issueTexts[$fehler_kurzbz][] = $fehlerText; } + else // if no issue text found, use generic text + { + $fehlerText = self::GENERIC_ISSUE_OCCURED_TEXT; + } + + // add generic parameters to issue text + if (isset($person_id)) $fehlerText .= "; person_id: $person_id"; + if (isset($oe_kurzbz)) $fehlerText .= "; oe_kurzbz: $oe_kurzbz"; + $issueTexts[$fehler_kurzbz][] = $fehlerText; } } } diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index 062bc06c2..79040dc66 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -17,6 +17,8 @@ * along with this program. If not, see . */ +use \stdClass as stdClass; + if (!defined('BASEPATH')) exit('No direct script access allowed'); /** @@ -120,11 +122,15 @@ class DB_Model extends CI_Model if (is_null($this->dbTable)) return error('The given database table name is not valid', EXIT_MODEL); // If this table has UDF and the validation of them is ok - if (isError($validate = $this->_prepareUDFsWrite($data, $this->dbTable))) return $validate; + $validate = $this->_prepareUDFsWrite($data, $this->dbTable); + if (isError($validate)) return $validate; // Add the pgp_sym_eccrypt postgresql function to the set clause if needed $this->_addEncrypt($encryptedColumns, $data); + // Add the pgp_sym_eccrypt postgresql function to the set clause if needed + if (!empty($encryptedColumns)) $this->_addEncrypt($encryptedColumns, $data); + // DB-INSERT $insert = $this->db->insert($this->dbTable, $data); @@ -174,7 +180,8 @@ class DB_Model extends CI_Model if (is_null($this->dbTable)) return error('The given database table name is not valid', EXIT_MODEL); // If this table has UDF and the validation of them is ok - if (isError($validate = $this->_prepareUDFsWrite($data, $this->dbTable, $id))) return $validate; + $validate = $this->_prepareUDFsWrite($data, $this->dbTable, $id); + if (isError($validate)) return $validate; $tmpId = $id; @@ -341,7 +348,8 @@ class DB_Model extends CI_Model // NOTE: $this->db->list_fields($tables[$t]) doesn't work if there are two tables with // the same name in two different schemas, use this workaround $fields = array(); - if (isSuccess($lstColumns = $this->_list_columns($schemaAndTable->schema, $schemaAndTable->table))) + $lstColumns = $this->_list_columns($schemaAndTable->schema, $schemaAndTable->table); + if (isSuccess($lstColumns)) { $fields = $lstColumns->retval; } @@ -419,7 +427,8 @@ class DB_Model extends CI_Model $tmpFilteredArray = array_filter(get_object_vars($sideTableObj)); if (isset($tmpFilteredArray) && count($tmpFilteredArray) > 0) { - if (($k = $this->_findMainTable($mainTableObj, $returnArray)) === false) + $k = $this->_findMainTable($mainTableObj, $returnArray); + if ($k === false) { $mainTableObj->{$sideTableProperty} = array($sideTableObj); $returnArray[$returnArrayCounter++] = $mainTableObj; @@ -802,8 +811,7 @@ class DB_Model extends CI_Model $cleanedQuery = trim(preg_replace('/\t|\n|\r|;/', '', $query)); // // - if ( - (stripos($cleanedQuery, 'INSERT') > 0 || stripos($cleanedQuery, 'INSERT') == false) + if ((stripos($cleanedQuery, 'INSERT') > 0 || stripos($cleanedQuery, 'INSERT') == false) && (stripos($cleanedQuery, 'UPDATE') > 0 || stripos($cleanedQuery, 'UPDATE') == false) && (stripos($cleanedQuery, 'CREATE') > 0 || stripos($cleanedQuery, 'CREATE') == false) && (stripos($cleanedQuery, 'DELETE') > 0 || stripos($cleanedQuery, 'DELETE') == false) @@ -881,7 +889,8 @@ class DB_Model extends CI_Model $result->schema = DB_Model::DEFAULT_SCHEMA; // If a schema is specified - if (($pos = strpos($schemaAndTable, '.')) !== false) + $pos = strpos($schemaAndTable, '.'); + if ($pos !== false) { $result->schema = substr($schemaAndTable, 0, $pos); $result->table = substr($schemaAndTable, $pos + 1); @@ -900,6 +909,9 @@ class DB_Model extends CI_Model */ private function _addEncrypt($encryptedColumns, &$data) { + // If encryptedColumns is not defined then exit + if (isEmptyArray($encryptedColumns)) return; + $tmpData = array(); // Temporary array used to copy not encrypted columns // For each column that is going to be inserted/updated @@ -911,9 +923,8 @@ class DB_Model extends CI_Model && array_key_exists(self::CRYPT_PASSWORD_NAME, $encryptedColumns[$column])) { // Password to encrypt data - $encryptionPassword = $this->config->item(self::CRYPT_CONF_PASSWORDS)[ - $encryptedColumns[$column][self::CRYPT_PASSWORD_NAME] - ]; + $cryptConfPasswords = $this->config->item(self::CRYPT_CONF_PASSWORDS); + $encryptionPassword = $cryptConfPasswords[$encryptedColumns[$column][self::CRYPT_PASSWORD_NAME]]; // Add the encrypted column to the set clause without escaping $this->db->set( @@ -952,15 +963,11 @@ class DB_Model extends CI_Model && array_key_exists(self::CRYPT_PASSWORD_NAME, $definition)) { // And if exists the wanted password to decrypt in the configs - if (array_key_exists( - $definition[self::CRYPT_PASSWORD_NAME], - $this->config->item(self::CRYPT_CONF_PASSWORDS)) - ) + if (array_key_exists($definition[self::CRYPT_PASSWORD_NAME], $this->config->item(self::CRYPT_CONF_PASSWORDS))) { // Password to decrypt data - $decryptionPassword = $this->config->item(self::CRYPT_CONF_PASSWORDS)[ - $definition[self::CRYPT_PASSWORD_NAME] - ]; + $cryptConfPasswords = $this->config->item(self::CRYPT_CONF_PASSWORDS); + $decryptionPassword = $cryptConfPasswords[$definition[self::CRYPT_PASSWORD_NAME]]; // Find and replace all the occurrences of the provided encrypted columns // with the postgresql decryption function @@ -997,15 +1004,11 @@ class DB_Model extends CI_Model && array_key_exists(self::CRYPT_PASSWORD_NAME, $definition)) { // And if exists the wanted password to decrypt in the configs - if (array_key_exists( - $definition[self::CRYPT_PASSWORD_NAME], - $this->config->item(self::CRYPT_CONF_PASSWORDS)) - ) + if (array_key_exists($definition[self::CRYPT_PASSWORD_NAME], $this->config->item(self::CRYPT_CONF_PASSWORDS))) { // Password to decrypt data - $decryptionPassword = $this->config->item(self::CRYPT_CONF_PASSWORDS)[ - $definition[self::CRYPT_PASSWORD_NAME] - ]; + $cryptConfPasswords = $this->config->item(self::CRYPT_CONF_PASSWORDS); + $decryptionPassword = $cryptConfPasswords[$definition[self::CRYPT_PASSWORD_NAME]]; // ----------------------------------------- // SELECT @@ -1063,14 +1066,12 @@ class DB_Model extends CI_Model ) { // Then rename the column using the postgresql decryption function - $tmpWhere[ - sprintf( - self::CRYPT_WHERE_TEMPLATE, - $encryptedColumn, - $decryptionPassword, - $definition[self::CRYPT_CAST] - ).$operator - ] = $condition; + $tmpWhere[sprintf( + self::CRYPT_WHERE_TEMPLATE, + $encryptedColumn, + $decryptionPassword, + $definition[self::CRYPT_CAST] + ).$operator] = $condition; } else // otherwise copy the column as it is { @@ -1127,11 +1128,11 @@ class DB_Model extends CI_Model { if ($id != null) { - $prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $this->dbTable, $this->_getUDFsNoPerms($id)); + $prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $schemaAndTable, $this->_getUDFsNoPerms($id)); } else { - $prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $this->dbTable); + $prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $schemaAndTable); } } diff --git a/application/core/IEncryption.php b/application/core/IEncryption.php new file mode 100644 index 000000000..6b9132c23 --- /dev/null +++ b/application/core/IEncryption.php @@ -0,0 +1,24 @@ +. + */ + +interface IEncryption +{ + public function getEncryptedColumns(): array; +} + diff --git a/application/libraries/AnrechnungLib.php b/application/libraries/AnrechnungLib.php index 86a81fb55..d8c4b1fd3 100644 --- a/application/libraries/AnrechnungLib.php +++ b/application/libraries/AnrechnungLib.php @@ -37,19 +37,30 @@ class AnrechnungLib * @param $lv_id * @return StdClass */ - public function getAntragData($prestudent_id, $studiensemester_kurzbz, $lv_id) + public function getAntragData($prestudent_id, $studiensemester_kurzbz, $lv_id, $anrechnung_id = null) { $antrag_data = new StdClass(); // Get students UID. $uid = $this->ci->StudentModel->getUID($prestudent_id); - - // Get lehrveranstaltung data. Break, if course is not assigned to student. - if(!$lv = getData($this->ci->LehrveranstaltungModel->getLvByStudent($uid, $studiensemester_kurzbz, $lv_id))[0]) + + // If Anrechnung exists + if (is_numeric($anrechnung_id)) { - show_error('You are not assigned to this course yet.'); + // Just load LV by lv_id + $result = $this->ci->LehrveranstaltungModel->load($lv_id); + $lv = getData($result)[0]; } - + // If Anrechnung not exists + else + { + // Load LV, but check if student is assigned to that LV. Break, if not. + if(!$lv = getData($this->ci->LehrveranstaltungModel->getLvByStudent($uid, $studiensemester_kurzbz, $lv_id))[0]) + { + show_error('You are not assigned to this course yet.'); + } + } + // Get the students personal data if (!$person = getData($this->ci->PersonModel->getByUid($uid))[0]) { @@ -274,14 +285,21 @@ class AnrechnungLib if (hasData($result)) { $empfehlung_data->empfehlungsanfrageAm = (new DateTime($result->retval[0]->insertamum))->format('d.m.Y'); - - // Get lectors who received request for recommendation - $lector_arr = self::getLectors($anrechnung_id); - - if (!isEmptyArray($lector_arr)) - { - $empfehlung_data->empfehlungsanfrageAn = implode(', ', array_column($lector_arr, 'fullname')); - } + + // Get users who received request for recommendation + if($this->ci->config->item('fbl') === TRUE) + { + $res = $this->getLeitungOfLvOe($anrechnung_id); + } + else + { + $res = $this->getLectors($anrechnung_id); + } + + if (!isEmptyArray($res)) + { + $empfehlung_data->empfehlungsanfrageAn = implode(', ', array_column($res, 'fullname')); + } } if (is_null($anrechnung->empfehlung_anrechnung)) @@ -741,6 +759,25 @@ class AnrechnungLib // Continue, if LV has no lector (there is no one to ask for recommendation) return hasData($result) ? true : false; } + + /** + * Check if user is allowed to recommend Anrechnung. + * + * @param $anrechnung_id + * @return bool + */ + public function isEmpfehlungsberechtigt($anrechnung_id) + { + if($this->ci->config->item('fbl') === TRUE) + { + return true; + } + // Get lv-leitungen or, if not present, all lectors of lv. + $lector_arr = $this->getLectors($anrechnung_id); + + // Return false if lv-leitung is present and user is not lv-leitung. Otherways return always true. + return in_array(getAuthUID(), array_column($lector_arr, 'uid')); + } /** * Get LV Leitung. If not present, get all LV lectors. @@ -774,11 +811,14 @@ class AnrechnungLib // Check if lv has LV-Leitung $key = array_search(true, array_column($result, 'lvleiter')); - - // If lv has LV-Leitung, keep only the one + + // If lv has 1 or more LV-Leitungen, keep only them if ($key !== false) { - $lector_arr[]= $result[$key]; + foreach ($result as $lector) + { + if ($lector->lvleiter) $lector_arr[]= $lector; + } } // ...otherwise keep all lectors else @@ -803,6 +843,40 @@ class AnrechnungLib return $lector_arr; } + /** + * Get Leitung of Lehrveranstaltungs-Organisationseinheit. + * + * @param $anrechnung_id + * @return false|mixed|null + */ + public function getLeitungOfLvOe($anrechnung_id) + { + $this->ci->AnrechnungModel->addSelect('lehrveranstaltung_id'); + $result = $this->ci->AnrechnungModel->load($anrechnung_id); + + $lehrveranstaltung_id = getData($result)[0]->lehrveranstaltung_id; + + // Get Leitungen + $result = $this->ci->LehrveranstaltungModel->getLeitungOfLvOe($lehrveranstaltung_id); + + if (!hasData($result)) + { + return false; + } + + $oeLeitung_arr = getData($result); + + foreach ($oeLeitung_arr as $oeLeitung) + { + $oeLeitung->fullname = $oeLeitung->vorname. ' '. $oeLeitung->nachname; + } + + // Now make the array unique + $oeLeitung_arr = array_unique($oeLeitung_arr, SORT_REGULAR); + + return $oeLeitung_arr; + } + // Return an object with Anrechnungdata private function _setAnrechnungDataObject($anrechnung) { diff --git a/application/libraries/FilterCmptLib.php b/application/libraries/FilterCmptLib.php index 3e885b6e7..8b13ae3e5 100644 --- a/application/libraries/FilterCmptLib.php +++ b/application/libraries/FilterCmptLib.php @@ -508,10 +508,12 @@ class FilterCmptLib $saveCustomFilter = true; } - if ($saveCustomFilter === true) + if ($saveCustomFilter === true) { - $this->_setSessionElement(FilterCmptLib::SESSION_SIDE_MENU, - $this->_generateFilterMenu($this->_app, $this->_datasetName)); + $this->_setSessionElement( + FilterCmptLib::SESSION_SIDE_MENU, + $this->_generateFilterMenu($this->_app, $this->_datasetName) + ); } return $saveCustomFilter; diff --git a/application/libraries/FilterWidgetLib.php b/application/libraries/FilterWidgetLib.php index 72a749d60..9968767d9 100644 --- a/application/libraries/FilterWidgetLib.php +++ b/application/libraries/FilterWidgetLib.php @@ -19,6 +19,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +use \stdClass as stdClass; + /** * FilterWidget logic */ @@ -139,7 +141,7 @@ class FilterWidgetLib /** * Gets the CI instance and loads message helper */ - public function __construct($params = null) + public function __construct() { $this->_ci =& get_instance(); // get code igniter instance } @@ -409,7 +411,7 @@ class FilterWidgetLib public function getFilterName($filterJson) { $filterName = $filterJson->name; // always present, used as default - $trimedname = (isset($filterJson->namePhrase)?trim($filterJson->namePhrase):''); + // Filter name from phrases system if (isset($filterJson->namePhrase) && !isEmptyString($filterJson->namePhrase)) { @@ -470,7 +472,8 @@ class FilterWidgetLib if (in_array($selectedField, $fields)) { // If the selected field is present in the list of the selected fields by the current filter - if (($pos = array_search($selectedField, $selectedFields)) !== false) + $pos = array_search($selectedField, $selectedFields); + if ($pos !== false) { // Then remove it and shift the rest of elements by one if needed array_splice($selectedFields, $pos, 1); @@ -769,7 +772,6 @@ class FilterWidgetLib $this->_ci->load->library('NavigationLib', array(self::NAVIGATION_PAGE => $navigationPage)); $filterMenu = null; - $currentMenu = $this->_ci->navigationlib->getSessionMenu(); // The navigation menu currently stored in session $session = $this->getSession(); // The filter currently stored in session (the one that is currently used) if ($session != null) diff --git a/application/libraries/PersonLogLib.php b/application/libraries/PersonLogLib.php index fe9a82504..f4f434fad 100644 --- a/application/libraries/PersonLogLib.php +++ b/application/libraries/PersonLogLib.php @@ -7,9 +7,6 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); */ class PersonLogLib { - const PARKED_LOGNAME = 'Parked'; - const ONHOLD_LOGNAME = 'Onhold'; - /** * Constructor */ @@ -78,168 +75,6 @@ class PersonLogLib else show_error(getError($result)); } - - /** - * Parks a person, i.e. marks a person so no actions are expected for the person (e.g. as a prestudent) - * Done by adding a logentry in the future - * @param $person_id - * @param $date - * @param $taetigkeit_kurzbz - * @param string $app - * @param null $oe_kurzbz - * @param null $user - * @return insert object - */ - public function park($person_id, $date, $taetigkeit_kurzbz, $app = 'core', $oe_kurzbz = null, $user = null) - { - $onhold = $this->getOnHoldDate($person_id); - - if (hasData($onhold)) - return error("Person already on hold"); - - $logjson = array( - 'name' => self::PARKED_LOGNAME - ); - - return $this->_savePsLog($person_id, $date, $taetigkeit_kurzbz, $logjson, $app, $oe_kurzbz, $user); - } - - /** - * Unparks a person, i.e. removes all log entries in the future with logname for parking - * @param $person_id - * @return array with deleted logids - */ - public function unPark($person_id) - { - $deleted = array(); - - $result = $this->ci->PersonLogModel->getLogsInFuture($person_id); - if (hasData($result)) - { - foreach ($result->retval as $log) - { - $logdata = json_decode($log->logdata); - if (isset($logdata->name) && $logdata->name === self::PARKED_LOGNAME) - { - $delresult = $this->ci->PersonLogModel->deleteLog($log->log_id); - if (isSuccess($delresult)) - { - $deleted[] = $log->log_id; - } - } - } - } - - return success($deleted); - } - - /** - * Gets date until which a person is parked - * @param $person_id - * @return the date if person is parked, null otherwise - */ - public function getParkedDate($person_id) - { - $result = $this->ci->PersonLogModel->getLogsInFuture($person_id); - - $parkeddate = null; - - if (hasData($result)) - { - foreach ($result->retval as $log) - { - $logdata = json_decode($log->logdata); - if (isset($logdata->name) && $logdata->name === self::PARKED_LOGNAME) - { - $parkeddate = $log->zeitpunkt; - break; - } - } - } - - return $parkeddate; - } - - /** - * Sets person on hold, i.e. marks a person so no actions are expected for the person (e.g. as a prestudent). - * Done by adding a logentry with a special name. can be undone only manually by clicking button. - * @param $person_id - * @param $date - * @param $taetigkeit_kurzbz - * @param string $app - * @param null $oe_kurzbz - * @param null $user - * @return array - */ - public function setOnHold($person_id, $date, $taetigkeit_kurzbz, $app = 'core', $oe_kurzbz = null, $user = null) - { - $parked = $this->getParkedDate($person_id); - - if (hasData($parked)) - return error("Person already parked"); - - $logjson = array( - 'name' => self::ONHOLD_LOGNAME - ); - - return $this->_savePsLog($person_id, $date, $taetigkeit_kurzbz, $logjson, $app, $oe_kurzbz, $user); - } - - /** - * Removes on hold status, i.e. removes all log entries with logname for on hold - * @param $person_id - * @return array - */ - public function removeOnHold($person_id) - { - $deleted = array(); - - $result = $this->ci->PersonLogModel->filterLog($person_id); - if (hasData($result)) - { - foreach ($result->retval as $log) - { - $logdata = json_decode($log->logdata); - if (isset($logdata->name) && $logdata->name === self::ONHOLD_LOGNAME) - { - $delresult = $this->ci->PersonLogModel->deleteLog($log->log_id); - if (isSuccess($delresult)) - { - $deleted[] = $log->log_id; - } - } - } - } - return success($deleted); - } - - /** - * Gets date until which a person is on hold - * @param $person_id - * @return the date if person is on hold, null otherwise - */ - public function getOnHoldDate($person_id) - { - $result = $this->ci->PersonLogModel->filterLog($person_id); - - $onholddate = null; - - if (hasData($result)) - { - foreach ($result->retval as $log) - { - $logdata = json_decode($log->logdata); - if (isset($logdata->name) && $logdata->name === self::ONHOLD_LOGNAME) - { - $onholddate = $log->zeitpunkt; - break; - } - } - } - - return $onholddate; - } - /** * Saves a processstate log with specified parameters, including a specified log date. * @param $person_id diff --git a/application/libraries/TableWidgetLib.php b/application/libraries/TableWidgetLib.php index 9637122a7..3af99cca7 100644 --- a/application/libraries/TableWidgetLib.php +++ b/application/libraries/TableWidgetLib.php @@ -93,7 +93,7 @@ class TableWidgetLib /** * Gets the CI instance and loads message helper */ - public function __construct($params = null) + public function __construct() { $this->_ci =& get_instance(); // get code igniter instance } diff --git a/application/libraries/issues/PlausicheckLib.php b/application/libraries/issues/PlausicheckLib.php index 5105169dd..19442de3c 100644 --- a/application/libraries/issues/PlausicheckLib.php +++ b/application/libraries/issues/PlausicheckLib.php @@ -86,16 +86,22 @@ class PlausicheckLib JOIN public.tbl_prestudentstatus status USING(prestudent_id) JOIN public.tbl_benutzer benutzer on(benutzer.uid = student.student_uid) JOIN public.tbl_studiengang stg ON prestudent.studiengang_kz = stg.studiengang_kz + LEFT JOIN lehre.tbl_studienplan stpl USING (studienplan_id) WHERE benutzer.aktiv = true - AND status.status_kurzbz='Student' + AND status.status_kurzbz IN ('Student', 'Unterbrecher', 'Abbrecher', 'Diplomand', 'Absolvent') AND studiengang.studiengang_kz < 10000 AND status.studiensemester_kurzbz = ? + AND NOT (status.orgform_kurzbz IS NULL AND studiengang.mischform = FALSE) AND NOT EXISTS( - SELECT 1 FROM lehre.tbl_studienplan - JOIN lehre.tbl_studienordnung USING(studienordnung_id) + SELECT 1 + FROM + lehre.tbl_studienplan + JOIN + lehre.tbl_studienordnung USING(studienordnung_id) WHERE - tbl_studienordnung.studiengang_kz = prestudent.studiengang_kz + tbl_studienplan.studienplan_id = stpl.studienplan_id + AND tbl_studienordnung.studiengang_kz = prestudent.studiengang_kz AND tbl_studienplan.orgform_kurzbz = status.orgform_kurzbz)"; if (isset($prestudent_id)) @@ -106,7 +112,7 @@ class PlausicheckLib if (isset($studiengang_kz)) { - $qry .= " AND stg.studiengang_kz = ?"; + $qry .= " AND studiengang.studiengang_kz = ?"; $params[] = $studiengang_kz; } @@ -879,6 +885,57 @@ class PlausicheckLib return $this->_db->execReadOnlyQuery($qry, $params); } + /** + * Student with active status should have been charged, i.e. have a Kontobuchung with a negative or zero value. + * @param studiensemester_kurzbz string if check is to be executed for certain Studiensemester + * @param studiengang_kz int if check is to be executed for certain Studiengang + * @param prestudent_id int if check is to be executed only for one prestudent + * @return success with prestudents or error + */ + public function getAktiverStudentstatusOhneKontobuchung($studiensemester_kurzbz, $studiengang_kz = null, $prestudent_id = null) + { + $params = array($studiensemester_kurzbz); + + $qry = " + SELECT + DISTINCT ON (pre.prestudent_id) + pre.person_id, pre.prestudent_id, stg.oe_kurzbz AS prestudent_stg_oe_kurzbz, status.studiensemester_kurzbz + FROM + public.tbl_prestudent pre + JOIN public.tbl_person pers USING(person_id) + JOIN public.tbl_prestudentstatus status USING(prestudent_id) + JOIN public.tbl_studiengang stg USING(studiengang_kz) + WHERE + status.studiensemester_kurzbz = ? + AND status.status_kurzbz IN ('Student', 'Incoming') + AND NOT EXISTS ( + SELECT 1 + FROM + public.tbl_konto + WHERE + person_id = pers.person_id + AND studiensemester_kurzbz = status.studiensemester_kurzbz + AND buchungsnr_verweis IS NULL + AND betrag <= 0 + ) + AND stg.melderelevant + AND pre.bismelden"; + + if (isset($studiengang_kz)) + { + $qry .= " AND stg.studiengang_kz = ?"; + $params[] = $studiengang_kz; + } + + if (isset($prestudent_id)) + { + $qry .= " AND pre.prestudent_id = ?"; + $params[] = $prestudent_id; + } + + return $this->_db->execReadOnlyQuery($qry, $params); + } + //------------------------------------------------------------------------------------------------------------------ // Person checks diff --git a/application/libraries/issues/PlausicheckProducerLib.php b/application/libraries/issues/PlausicheckProducerLib.php index c1e15151f..dde9b5396 100644 --- a/application/libraries/issues/PlausicheckProducerLib.php +++ b/application/libraries/issues/PlausicheckProducerLib.php @@ -18,6 +18,7 @@ class PlausicheckProducerLib 'AbschlussstatusFehlt' => 'AbschlussstatusFehlt', 'AktSemesterNull' => 'AktSemesterNull', 'AktiverStudentOhneStatus' => 'AktiverStudentOhneStatus', + 'AktiverStudentstatusOhneKontobuchung' => 'AktiverStudentstatusOhneKontobuchung', 'AusbildungssemPrestudentUngleichAusbildungssemStatus' => 'AusbildungssemPrestudentUngleichAusbildungssemStatus', 'BewerberNichtZumRtAngetreten' => 'BewerberNichtZumRtAngetreten', 'DatumAbschlusspruefungFehlt' => 'DatumAbschlusspruefungFehlt', diff --git a/application/libraries/issues/plausichecks/AktiverStudentstatusOhneKontobuchung.php b/application/libraries/issues/plausichecks/AktiverStudentstatusOhneKontobuchung.php new file mode 100644 index 000000000..baa35bc57 --- /dev/null +++ b/application/libraries/issues/plausichecks/AktiverStudentstatusOhneKontobuchung.php @@ -0,0 +1,50 @@ +_ci->plausichecklib->getAktiverStudentstatusOhneKontobuchung($studiensemester_kurzbz, $studiengang_kz); + + if (isError($prestudentRes)) return $prestudentRes; + + if (hasData($prestudentRes)) + { + $prestudents = getData($prestudentRes); + + // populate results with data necessary for writing issues + foreach ($prestudents as $prestudent) + { + $results[] = array( + 'person_id' => $prestudent->person_id, + 'oe_kurzbz' => $prestudent->prestudent_stg_oe_kurzbz, + 'fehlertext_params' => array( + 'prestudent_id' => $prestudent->prestudent_id, + 'studiensemester_kurzbz' => $prestudent->studiensemester_kurzbz + ), + 'resolution_params' => array( + 'prestudent_id' => $prestudent->prestudent_id, + 'studiensemester_kurzbz' => $prestudent->studiensemester_kurzbz + ) + ); + } + } + + // return the results + return success($results); + } +} diff --git a/application/libraries/issues/resolvers/CORE_STUDENTSTATUS_0015.php b/application/libraries/issues/resolvers/CORE_STUDENTSTATUS_0015.php new file mode 100644 index 000000000..aafee1124 --- /dev/null +++ b/application/libraries/issues/resolvers/CORE_STUDENTSTATUS_0015.php @@ -0,0 +1,36 @@ +_ci =& get_instance(); // get code igniter instance + + $this->_ci->load->library('issues/PlausicheckLib'); + + // check if issue persists + $checkRes = $this->_ci->plausichecklib->getAktiverStudentstatusOhneKontobuchung( + $params['studiensemester_kurzbz'], + null, + $params['prestudent_id'] + ); + + if (isError($checkRes)) return $checkRes; + + if (hasData($checkRes)) + return success(false); // not resolved if issue is still present + else + return success(true); // resolved otherwise + } +} diff --git a/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php b/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php index c7820f65a..3bd36aa78 100644 --- a/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php +++ b/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php @@ -1,7 +1,8 @@ isvalid = false; + $this->validationerrors = array(); + } + + public function hydrateByStdClass($data) + { + isset($data->dienstverhaeltnis_id) && $this->setDienstverhaeltnis_id($data->dienstverhaeltnis_id); + isset($data->mitarbeiter_uid) && $this->setMitarbeiter_uid($data->mitarbeiter_uid); + isset($data->vertragsart_kurzbz) && $this->setVertragsart_kurzbz($data->vertragsart_kurzbz); + isset($data->oe_kurzbz) && $this->setOe_kurzbz($data->oe_kurzbz); + isset($data->von) && $this->setVon($data->von); + isset($data->bis) && $this->setBis($data->bis); + isset($data->insertamum) && $this->setInsertamum($data->insertamum); + isset($data->insertvon) && $this->setInsertvon($data->insertvon); + isset($data->updateamum) && $this->setUpdateamum($data->updateamum); + isset($data->updatevon) && $this->setUpdatevon($data->updatevon); + } + public function toStdClass(): \stdClass { $tmp = array( - 'dienstverhaeltnis_id' => $this->getDienstverhaeltnisId(), - 'vertragsart_kurzbz' => $this->getVertragsartKurzbz(), - 'unternehmen' => $this->getUnternehmen(), - 'gueltig_ab' => $this->getGueltigAb(), - 'gueltig_bis' => $this->getGueltigBis(), + 'dienstverhaeltnis_id' => $this->getDienstverhaeltnis_id(), + 'mitarbeiter_uid' => $this->getMitarbeiter_uid(), + 'vertragsart_kurzbz' => $this->getVertragsart_kurzbz(), + 'oe_kurzbz' => $this->getOe_kurzbz(), + 'von' => $this->getVon(), + 'bis' => $this->getBis(), + 'insertamum' => $this->getInsertamum(), + 'insertvon' => $this->getInsertvon(), + 'updateamum' => $this->getUpdateamum(), + 'updatevon' => $this->getUpdatevon() ); $tmp = array_filter($tmp, function($v) { @@ -42,103 +73,183 @@ class Dienstverhaeltnis { public function __toString() { $txt = <<getDienstverhaeltnisId()} - vertragsart_kurzbz: {$this->getVertragsartKurzbz()} - gueltig_ab: {$this->getGueltigAb()} - gueltig_bis: {$this->getGueltigBis()} + dienstverhaeltnis_id: {$this->getDienstverhaeltnis_id()} + mitarbeiter_uid: {$this->getMitarbeiter_uid()} + vertragsart_kurzbz: {$this->getVertragsart_kurzbz()} + oe_kurzbz: {$this->getOe_kurzbz()} + von: {$this->getVon()} + bis: {$this->getBis()} EOTXT; return $txt; } + public function getDienstverhaeltnis_id() + { + return $this->dienstverhaeltnis_id; + } - /** - * Get the value of dienstverhaeltnis_id - */ - public function getDienstverhaeltnisId() - { - return $this->dienstverhaeltnis_id; - } + public function getMitarbeiter_uid() + { + return $this->mitarbeiter_uid; + } - /** - * Set the value of dienstverhaeltnis_id - */ - public function setDienstverhaeltnisId($dienstverhaeltnis_id): self - { - $this->dienstverhaeltnis_id = $dienstverhaeltnis_id; + public function getVertragsart_kurzbz() + { + return $this->vertragsart_kurzbz; + } - return $this; - } + public function getOe_kurzbz() + { + return $this->oe_kurzbz; + } - /** - * Get the value of unternehmen - */ - public function getUnternehmen() - { - return $this->unternehmen; - } + public function getVon() + { + return $this->von; + } - /** - * Set the value of unternehmen - */ - public function setUnternehmen($unternehmen): self - { - $this->unternehmen = $unternehmen; + public function getBis() + { + return $this->bis; + } - return $this; - } + public function getInsertamum() + { + return $this->insertamum; + } - /** - * Get the value of vertragsart_kurzbz - */ - public function getVertragsartKurzbz() - { - return $this->vertragsart_kurzbz; - } + public function getInsertvon() + { + return $this->insertvon; + } - /** - * Set the value of vertragsart_kurzbz - */ - public function setVertragsartKurzbz($vertragsart_kurzbz): self - { - $this->vertragsart_kurzbz = $vertragsart_kurzbz; + public function getUpdateamum() + { + return $this->updateamum; + } - return $this; - } + public function getUpdatevon() + { + return $this->updatevon; + } - /** - * Get the value of gueltig_ab - */ - public function getGueltigAb() - { - return $this->gueltig_ab; - } + public function setDienstverhaeltnis_id($dienstverhaeltnis_id) + { + $this->dienstverhaeltnis_id = $dienstverhaeltnis_id; + return $this; + } - /** - * Set the value of gueltig_ab - */ - public function setGueltigAb($gueltig_ab): self - { - $this->gueltig_ab = $gueltig_ab; + public function setMitarbeiter_uid($mitarbeiter_uid) + { + $this->mitarbeiter_uid = $mitarbeiter_uid; + return $this; + } - return $this; - } + public function setVertragsart_kurzbz($vertragsart_kurzbz) + { + $this->vertragsart_kurzbz = $vertragsart_kurzbz; + return $this; + } - /** - * Get the value of gueltig_bis - */ - public function getGueltigBis() - { - return $this->gueltig_bis; - } + public function setOe_kurzbz($oe_kurzbz) + { + $this->oe_kurzbz = $oe_kurzbz; + return $this; + } - /** - * Set the value of gueltig_bis - */ - public function setGueltigBis($gueltig_bis): self - { - $this->gueltig_bis = $gueltig_bis; + public function setVon($von) + { + $this->von = $von; + return $this; + } - return $this; - } + public function setBis($bis) + { + $this->bis = $bis; + return $this; + } + + public function setInsertamum($insertamum) + { + $this->insertamum = $insertamum; + return $this; + } + + public function setInsertvon($insertvon) + { + $this->insertvon = $insertvon; + return $this; + } + + public function setUpdateamum($updateamum) + { + $this->updateamum = $updateamum; + return $this; + } + + public function setUpdatevon($updatevon) + { + $this->updatevon = $updatevon; + return $this; + } + + public function isValid() + { + return $this->isvalid; + } + + public function getValidationErrors() + { + return $this->validationerrors; + } + + public function validate() { + //do Validation here + $ci = get_instance(); + $ci->load->library('vertragsbestandteil/VertragsbestandteilLib', + null, 'VertragsbestandteilLib'); + + if( empty($this->mitarbeiter_uid) ) { + $this->validationerrors[] = 'Mitarbeiter_UID fehlt.'; + } + + if( empty($this->oe_kurzbz) ) { + $this->validationerrors[] = 'Unternehmen fehlt.'; + } + + if( empty($this->vertragsart_kurzbz) ) { + $this->validationerrors[] = 'Vertragsart fehlt.'; + } + + $von = \DateTimeImmutable::createFromFormat('Y-m-d', $this->von); + $bis = \DateTimeImmutable::createFromFormat('Y-m-d', $this->bis); + + if( false === $von ) { + $this->validationerrors[] = 'Beginn muss ein gültiges Datum sein.'; + } + + if( $this->bis !== null && $bis === false ) { + $this->validationerrors[] = 'Ende muss ein gültiges Datum oder leer sein.'; + } + + if( $this-> bis !== null && $von && $bis && $von > $bis ) { + $this->validationerrors[] = 'Das Beginndatum muss vor dem Endedatum liegen.'; + } + + // TODO check for overlapping DVs + if( $ci->VertragsbestandteilLib->isOverlappingExistingDV($this) ) + { + $this->validationerrors[] = 'Es existiert bereits ein überlappendes Dienstverhältnis'; + } + + // return status after Validation + if( count($this->validationerrors) > 0 ) { + $this->isvalid = false; + } else { + $this->isvalid = true; + } + + return $this->isvalid; + } } \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/Gehaltsbestandteil.php b/application/libraries/vertragsbestandteil/Gehaltsbestandteil.php new file mode 100644 index 000000000..130c18547 --- /dev/null +++ b/application/libraries/vertragsbestandteil/Gehaltsbestandteil.php @@ -0,0 +1,331 @@ +isvalid = false; + $this->validationerrors = array(); + } + + public function hydrateByStdClass($data) + { + isset($data->gehaltsbestandteil_id) && $this->setGehaltsbestandteil_id($data->gehaltsbestandteil_id); + isset($data->dienstverhaeltnis_id) && $this->setDienstverhaeltnis_id($data->dienstverhaeltnis_id); + isset($data->vertragsbestandteil_id) && $this->setVertragsbestandteil_id($data->vertragsbestandteil_id); + isset($data->gehaltstyp_kurzbz) && $this->setGehaltstyp_kurzbz($data->gehaltstyp_kurzbz); + isset($data->von) && $this->setVon($data->von); + isset($data->bis) && $this->setBis($data->bis); + isset($data->anmerkung) && $this->setAnmerkung($data->anmerkung); + isset($data->grundbetrag) && $this->setGrundbetrag($data->grundbetrag); + isset($data->betrag_valorisiert) && $this->setBetrag_valorisiert($data->betrag_valorisiert); + isset($data->valorisierungssperre) && $this->setValorisierungssperre($data->valorisierungssperre); + isset($data->valorisierung) && $this->setValorisierung($data->valorisierung); + isset($data->auszahlungen) && $this->setAuszahlungen($data->auszahlungen); + + isset($data->insertamum) && $this->setInsertamum($data->insertamum); + isset($data->insertvon) && $this->setInsertvon($data->insertvon); + isset($data->updateamum) && $this->setUpdateamum($data->updateamum); + isset($data->updatevon) && $this->setUpdatevon($data->updatevon); + } + + public function getGehaltsbestandteil_id() + { + return $this->gehaltsbestandteil_id; + } + + public function getDienstverhaeltnis_id() + { + return $this->dienstverhaeltnis_id; + } + + public function getVertragsbestandteil_id() + { + return $this->vertragsbestandteil_id; + } + + public function getGehaltstyp_kurzbz() + { + return $this->gehaltstyp_kurzbz; + } + + public function getVon() + { + return $this->von; + } + + public function getBis() + { + return $this->bis; + } + + public function getAnmerkung() + { + return $this->anmerkung; + } + + public function getGrundbetrag() + { + return $this->grundbetrag; + } + + public function getBetrag_valorisiert() + { + return $this->betrag_valorisiert; + } + + public function getValorisierungssperre() + { + return $this->valorisierungssperre; + } + + public function getValorisierung() + { + return $this->valorisierung; + } + + public function getAuszahlungen() + { + return $this->auszahlungen; + } + + public function getInsertamum() + { + return $this->insertamum; + } + + public function getInsertvon() + { + return $this->insertvon; + } + + public function getUpdateamum() + { + return $this->updateamum; + } + + public function getUpdatevon() + { + return $this->updatevon; + } + + public function setGehaltsbestandteil_id($gehaltsbestandteil_id) + { + $this->gehaltsbestandteil_id = $gehaltsbestandteil_id; + return $this; + } + + public function setDienstverhaeltnis_id($dienstverhaeltnis_id) + { + $this->dienstverhaeltnis_id = $dienstverhaeltnis_id; + return $this; + } + + public function setVertragsbestandteil_id($vertragsbestandteil_id) + { + $this->vertragsbestandteil_id = $vertragsbestandteil_id; + return $this; + } + + public function setGehaltstyp_kurzbz($gehaltstyp_kurzbz) + { + $this->gehaltstyp_kurzbz = $gehaltstyp_kurzbz; + return $this; + } + + public function setVon($von) + { + $this->von = $von; + return $this; + } + + public function setBis($bis) + { + $this->bis = $bis; + return $this; + } + + public function setAnmerkung($anmerkung) + { + $this->anmerkung = $anmerkung; + return $this; + } + + public function setGrundbetrag($grundbetrag) + { + $this->grundbetrag = $grundbetrag; + return $this; + } + + public function setBetrag_valorisiert($betrag_valorisiert) + { + $this->betrag_valorisiert = $betrag_valorisiert; + return $this; + } + + public function setValorisierungssperre($valorisierungssperre) + { + $this->valorisierungssperre = $valorisierungssperre; + return $this; + } + + public function setValorisierung($valorisierung) + { + $this->valorisierung = $valorisierung; + return $this; + } + + public function setAuszahlungen($auszahlungen) + { + $this->auszahlungen = $auszahlungen; + return $this; + } + + public function setInsertamum($insertamum) + { + $this->insertamum = $insertamum; + return $this; + } + + public function setInsertvon($insertvon) + { + $this->insertvon = $insertvon; + return $this; + } + + public function setUpdateamum($updateamum) + { + $this->updateamum = $updateamum; + return $this; + } + + public function setUpdatevon($updatevon) + { + $this->updatevon = $updatevon; + return $this; + } + + public function toStdClass(): \stdClass + { + $tmp = array( + 'gehaltsbestandteil_id' => $this->getGehaltsbestandteil_id(), + 'dienstverhaeltnis_id' => $this->getDienstverhaeltnis_id(), + 'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(), + 'gehaltstyp_kurzbz' => $this->getGehaltstyp_kurzbz(), + 'von' => $this->getVon(), + 'bis' => $this->getBis(), + 'anmerkung' => $this->getAnmerkung(), + 'grundbetrag' => $this->getGrundbetrag(), + 'betrag_valorisiert' => $this->getBetrag_valorisiert(), + 'valorisierungssperre' => $this->getValorisierungssperre(), + 'valorisierung' => $this->getValorisierung(), + 'auszahlungen' => $this->getAuszahlungen(), + 'insertamum' => $this->getInsertamum(), + 'insertvon' => $this->getInsertvon(), + 'updateamum' => $this->getUpdateamum(), + 'updatevon' => $this->getUpdatevon() + ); + + $tmp = array_filter($tmp, function($v) { + return !is_null($v); + }); + + return (object) $tmp; + } + + public function __toString() + { + $txt = <<getGehaltsbestandteil_id()} + dienstverhaeltnis_id: {$this->getDienstverhaeltnis_id()} + vertragsbestandteil_id: {$this->getVertragsbestandteil_id()} + gehaltstyp_kurzbz: {$this->getGehaltstyp_kurzbz()} + von: {$this->getVon()} + bis: {$this->getBis()} + anmerkung: {$this->getAnmerkung()} + grundbetrag: {$this->getGrundbetrag()} + betrag_valorisiert: {$this->getBetrag_valorisiert()} + valorisierungssperre: {$this->getValorisierungssperre()} + valorisierung: {$this->getValorisierung()} + auszahlungen: {$this->getAuszahlungen()} + insertamum: {$this->getInsertamum()} + insertvon: {$this->getInsertvon()} + updateamum: {$this->getUpdateamum()} + updatevon: {$this->getUpdatevon()} + +EOTXT; + return $txt; + } + + public function isValid() + { + return $this->isvalid; + } + + public function getValidationErrors() + { + return $this->validationerrors; + } + + public function validate() { + //do Validation here + if( empty($this->gehaltstyp_kurzbz) ) + { + $this->validationerrors[] = "Ein Gehaltstyp muss ausgewählt sein."; + } + + if( empty($this->grundbetrag) ) + { + $this->validationerrors[] = "Betrag fehlt."; + } + + $von = \DateTimeImmutable::createFromFormat('Y-m-d', $this->von); + $bis = \DateTimeImmutable::createFromFormat('Y-m-d', $this->bis); + + if( false === $von ) { + $this->validationerrors[] = 'Beginn muss ein gültiges Datum sein.'; + } + + if( $this->bis !== null && $bis === false ) { + $this->validationerrors[] = 'Ende muss ein gültiges Datum oder leer sein.'; + } + + if( $this-> bis !== null && $von && $bis && $von > $bis ) { + $this->validationerrors[] = 'Das Beginndatum muss vor dem Endedatum liegen.'; + } + + // return status after Validation + if( count($this->validationerrors) > 0 ) { + $this->isvalid = false; + } else { + $this->isvalid = true; + } + + return $this->isvalid; + } +} diff --git a/application/libraries/vertragsbestandteil/GehaltsbestandteilLib.php b/application/libraries/vertragsbestandteil/GehaltsbestandteilLib.php new file mode 100644 index 000000000..e72de9cd9 --- /dev/null +++ b/application/libraries/vertragsbestandteil/GehaltsbestandteilLib.php @@ -0,0 +1,96 @@ +loggedInUser = getAuthUID(); + $this->CI = get_instance(); + $this->CI->load->model('vertragsbestandteil/Gehaltsbestandteil_model', + 'GehaltsbestandteilModel'); + $this->GehaltsbestandteilModel = $this->CI->GehaltsbestandteilModel; + } + + public function fetchGehaltsbestandteile($dienstverhaeltnis_id, $stichtag=null) + { + return $this->GehaltsbestandteilModel->getGehaltsbestandteile($dienstverhaeltnis_id, $stichtag); + } + + public function fetchGehaltsbestandteil($gehaltsbestandteil_id) + { + return $this->GehaltsbestandteilModel->getGehaltsbestandteil($gehaltsbestandteil_id); + } + + public function storeGehaltsbestandteile($gehaltsbestandteile) + { + foreach( $gehaltsbestandteile as $gehaltsbestandteil ) + { + $this->storeGehaltsbestandteil($gehaltsbestandteil); + } + } + + public function storeGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil) + { + try + { + if( intval($gehaltsbestandteil->getGehaltsbestandteil_id()) > 0 ) + { + $this->updateGehaltsbestandteil($gehaltsbestandteil); + } + else + { + $this->insertGehaltsbestandteil($gehaltsbestandteil); + } + } + catch (Exception $ex) + { + log_message('debug', "Storing Gehaltsbestandteil failed. " . $ex->getMessage()); + throw new Exception('Storing Gehaltsbestandteil failed.'); + } + } + + protected function insertGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil) + { + $gehaltsbestandteil->setInsertvon($this->loggedInUser) + ->setInsertamum(strftime('%Y-%m-%d %H:%M:%S')); + $ret = $this->GehaltsbestandteilModel->insert($gehaltsbestandteil->toStdClass(), + $this->GehaltsbestandteilModel->getEncryptedColumns()); + if( hasData($ret) ) + { + $gehaltsbestandteil->setGehaltsbestandteil_id(getData($ret)); + } + else + { + throw new Exception('error inserting gehaltsbestandteil'); + } + } + + protected function updateGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil) + { + $gehaltsbestandteil->setUpdatevon($this->loggedInUser) + ->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S')); + $ret = $this->GehaltsbestandteilModel->update($gehaltsbestandteil->getGehaltsbestandteil_id(), + $gehaltsbestandteil->toStdClass(), + $this->GehaltsbestandteilModel->getEncryptedColumns()); + + if(isError($ret) ) + { + throw new Exception('error updating gehaltsbestandteil'); + } + } +} diff --git a/application/libraries/vertragsbestandteil/IValidation.php b/application/libraries/vertragsbestandteil/IValidation.php new file mode 100644 index 000000000..2898ec41b --- /dev/null +++ b/application/libraries/vertragsbestandteil/IValidation.php @@ -0,0 +1,16 @@ +gehaltsbestandteile = array(); + $this->isvalid = false; + $this->validationerrors = array(); + } + public function hydrateByStdClass($data) { isset($data->vertragsbestandteil_id) && $this->setVertragsbestandteil_id($data->vertragsbestandteil_id); @@ -30,6 +42,19 @@ abstract class Vertragsbestandteil implements \JsonSerializable isset($data->updatevon) && $this->setUpdatevon($data->updatevon); } + public function addGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil) + { + $gehaltsbestandteil->setDienstverhaeltnis_id($this->getDienstverhaeltnis_id()); + $gehaltsbestandteil->setVertragsbestandteil_id($this->getVertragsbestandteil_id()); + $this->gehaltsbestandteile[] = $gehaltsbestandteil; + return $this; + } + + public function getGehaltsbestandteile() + { + return $this->gehaltsbestandteile; + } + public function getVertragsbestandteil_id() { return $this->vertragsbestandteil_id; @@ -78,12 +103,20 @@ abstract class Vertragsbestandteil implements \JsonSerializable public function setVertragsbestandteil_id($vertragsbestandteil_id) { $this->vertragsbestandteil_id = $vertragsbestandteil_id; + foreach ($this->gehaltsbestandteile as $gehaltsbestandteil) + { + $gehaltsbestandteil->setVertragsbestandteil_id($vertragsbestandteil_id); + } return $this; } public function setDienstverhaeltnis_id($dienstverhaeltnis_id) { $this->dienstverhaeltnis_id = $dienstverhaeltnis_id; + foreach ($this->gehaltsbestandteile as $gehaltsbestandteil) + { + $gehaltsbestandteil->setDienstverhaeltnis_id($dienstverhaeltnis_id); + } return $this; } @@ -151,7 +184,9 @@ abstract class Vertragsbestandteil implements \JsonSerializable public function jsonSerialize() { - return get_object_vars($this); + $vars = get_object_vars($this); + unset($vars['CI']); + return $vars; } public function __toString() @@ -171,5 +206,44 @@ EOTXT; } - public abstract function toStdClass(); + public function beforePersist() { + // can be overridden in childs + } + + public function isValid() + { + return $this->isvalid; + } + + public function getValidationErrors() + { + return $this->validationerrors; + } + + public function validate() { + $von = \DateTimeImmutable::createFromFormat('Y-m-d', $this->von); + $bis = \DateTimeImmutable::createFromFormat('Y-m-d', $this->bis); + + if( false === $von ) { + $this->validationerrors[] = 'Beginn muss ein gültiges Datum sein.'; + } + + if( $this->bis !== null && $bis === false ) { + $this->validationerrors[] = 'Ende muss ein gültiges Datum oder leer sein.'; + } + + if( $this-> bis !== null && $von && $bis && $von > $bis ) { + $this->validationerrors[] = 'Das Beginndatum muss vor dem Endedatum liegen.'; + } + + if( count($this->validationerrors) > 0 ) { + $this->isvalid = false; + } else { + $this->isvalid = true; + } + + return $this->isvalid; + } + + public abstract function toStdClass(); } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilBefristung.php b/application/libraries/vertragsbestandteil/VertragsbestandteilBefristung.php deleted file mode 100644 index a2585b5e9..000000000 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilBefristung.php +++ /dev/null @@ -1,89 +0,0 @@ -setVertragsbestandteiltyp_kurzbz( - VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_BEFRISTUNG); - } - - public function hydrateByStdClass($data) - { - parent::hydrateByStdClass($data); - isset($data->befristet) && $this->setBefristet($data->befristet); - isset($data->befristet_bis) && $this->setBefristetBis($data->befristet_bis); - } - - - /** - * Get the value of befristet - */ - public function getBefristet() - { - return $this->befristet; - } - - /** - * Set the value of befristet - */ - public function setBefristet($befristet): self - { - $this->befristet = $befristet; - - return $this; - } - - /** - * Get the value of befristet_bis - */ - public function getBefristetBis() - { - return $this->befristet_bis; - } - - /** - * Set the value of befristet_bis - */ - public function setBefristetBis($befristet_bis): self - { - $this->befristet_bis = $befristet_bis; - - return $this; - } - - public function toStdClass(): \stdClass - { - $tmp = array( - 'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(), - 'befristet' => $this->getBefristet(), - 'befristet_bis' => $this->getBefristetBis() - ); - - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); - - return (object) $tmp; - } - - public function __toString() - { - $txt = <<getBefristet()} - befristet_bis: {$this->getBefristetBis()} - -EOTXT; - return parent::__toString() . $txt; - } - - - -} diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php b/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php index a00417272..220ee5dff 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php @@ -35,39 +35,13 @@ class VertragsbestandteilFactory $vertragsbestandteil = null; switch ($vertragsbestandteiltyp_kurzbz) { - - case self::VERTRAGSBESTANDTEIL_STUNDEN: - $vertragsbestandteil = new VertragsbestandteilStunden(); - $vertragsbestandteil->hydrateByStdClass($data); - break; - - case self::VERTRAGSBESTANDTEIL_FUNKTION: - $vertragsbestandteil = new VertragsbestandteilFunktion(); - $vertragsbestandteil->hydrateByStdClass($data); - break; - - case self::VERTRAGSBESTANDTEIL_GEHALT: - $vertragsbestandteil = new VertragsbestandteilGehalt(); - $vertragsbestandteil->hydrateByStdClass($data); - break; - - case self::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST: - $vertragsbestandteil = new VertragsbestandteilKuendigungsfrist(); - $vertragsbestandteil->hydrateByStdClass($data); - break; - case self::VERTRAGSBESTANDTEIL_FREITEXT: $vertragsbestandteil = new VertragsbestandteilFreitext(); $vertragsbestandteil->hydrateByStdClass($data); break; - - case self::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG: - $vertragsbestandteil = new VertragsbestandteilZeitaufzeichnung(); - $vertragsbestandteil->hydrateByStdClass($data); - break; - - case self::VERTRAGSBESTANDTEIL_BEFRISTUNG: - $vertragsbestandteil = new VertragsbestandteilBefristung(); + + case self::VERTRAGSBESTANDTEIL_FUNKTION: + $vertragsbestandteil = new VertragsbestandteilFunktion(); $vertragsbestandteil->hydrateByStdClass($data); break; @@ -76,11 +50,26 @@ class VertragsbestandteilFactory $vertragsbestandteil->hydrateByStdClass($data); break; + case self::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST: + $vertragsbestandteil = new VertragsbestandteilKuendigungsfrist(); + $vertragsbestandteil->hydrateByStdClass($data); + break; + + case self::VERTRAGSBESTANDTEIL_STUNDEN: + $vertragsbestandteil = new VertragsbestandteilStunden(); + $vertragsbestandteil->hydrateByStdClass($data); + break; + case self::VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH: $vertragsbestandteil = new VertragsbestandteilUrlaubsanspruch(); $vertragsbestandteil->hydrateByStdClass($data); break; - + + case self::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG: + $vertragsbestandteil = new VertragsbestandteilZeitaufzeichnung(); + $vertragsbestandteil->hydrateByStdClass($data); + break; + default: throw new Exception('Unknown vertragsbestandteiltyp_kurzbz ' . $vertragsbestandteiltyp_kurzbz); @@ -96,28 +85,22 @@ class VertragsbestandteilFactory $vertragsbestandteildbmodel = null; switch ($vertragsbestandteil_kurzbz) { - case self::VERTRAGSBESTANDTEIL_STUNDEN: - $CI->load->model('vertragsbestandteil/VertragsbestandteilStunden_model', - 'VertragsbestandteilStunden_model'); - $vertragsbestandteildbmodel = $CI->VertragsbestandteilStunden_model; + case self::VERTRAGSBESTANDTEIL_FREITEXT: + $CI->load->model('vertragsbestandteil/VertragsbestandteilFreitext_model', + 'VertragsbestandteilFreitext_model'); + $vertragsbestandteildbmodel = $CI->VertragsbestandteilFreitext_model; break; - + case self::VERTRAGSBESTANDTEIL_FUNKTION: $CI->load->model('vertragsbestandteil/VertragsbestandteilFunktion_model', 'VertragsbestandteilFunktion_model'); $vertragsbestandteildbmodel = $CI->VertragsbestandteilFunktion_model; break; - - case self::VERTRAGSBESTANDTEIL_GEHALT: - $CI->load->model('vertragsbestandteil/Gehaltsbestandteil_model', - 'Gehaltsbestandteil_model'); - $vertragsbestandteildbmodel = $CI->Gehaltsbestandteil_model; - break; - - case self::VERTRAGSBESTANDTEIL_FREITEXT: - $CI->load->model('vertragsbestandteil/VertragsbestandteilFreitext_model', - 'VertragsbestandteilFreitext_model'); - $vertragsbestandteildbmodel = $CI->VertragsbestandteilFreitext_model; + + case self::VERTRAGSBESTANDTEIL_KARENZ: + $CI->load->model('vertragsbestandteil/VertragsbestandteilKarenz_model', + 'VertragsbestandteilKarenz_model'); + $vertragsbestandteildbmodel = $CI->VertragsbestandteilKarenz_model; break; case self::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST: @@ -125,24 +108,24 @@ class VertragsbestandteilFactory 'VertragsbestandteilKuendigungsfrist_model'); $vertragsbestandteildbmodel = $CI->VertragsbestandteilKuendigungsfrist_model; break; - - case self::VERTRAGSBESTANDTEIL_KARENZ: - $CI->load->model('vertragsbestandteil/VertragsbestandteilKarenz_model', - 'VertragsbestandteilKarenz_model'); - $vertragsbestandteildbmodel = $CI->VertragsbestandteilKarenz_model; + + case self::VERTRAGSBESTANDTEIL_STUNDEN: + $CI->load->model('vertragsbestandteil/VertragsbestandteilStunden_model', + 'VertragsbestandteilStunden_model'); + $vertragsbestandteildbmodel = $CI->VertragsbestandteilStunden_model; break; - - case self::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG: - $CI->load->model('vertragsbestandteil/VertragsbestandteilZeitaufzeichnung_model', - 'VertragsbestandteilZeitaufzeichnung_model'); - $vertragsbestandteildbmodel = $CI->VertragsbestandteilZeitaufzeichnung_model; - break; - + case self::VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH: $CI->load->model('vertragsbestandteil/VertragsbestandteilUrlaubsanspruch_model', 'VertragsbestandteilUrlaubsanspruch_model'); $vertragsbestandteildbmodel = $CI->VertragsbestandteilUrlaubsanspruch_model; break; + + case self::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG: + $CI->load->model('vertragsbestandteil/VertragsbestandteilZeitaufzeichnung_model', + 'VertragsbestandteilZeitaufzeichnung_model'); + $vertragsbestandteildbmodel = $CI->VertragsbestandteilZeitaufzeichnung_model; + break; default: throw new Exception('Unknown vertragsbestandteil_kurzbz ' diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilFreitext.php b/application/libraries/vertragsbestandteil/VertragsbestandteilFreitext.php index b1beefa43..eb6d84350 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilFreitext.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilFreitext.php @@ -6,12 +6,13 @@ use vertragsbestandteil\VertragsbestandteilFactory; class VertragsbestandteilFreitext extends Vertragsbestandteil { - protected $anmerkung; - protected $kuendigungrelevant; protected $freitexttyp_kurzbz; + protected $titel; + protected $anmerkung; public function __construct() { + parent::__construct(); $this->setVertragsbestandteiltyp_kurzbz( VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_FREITEXT); } @@ -19,18 +20,19 @@ class VertragsbestandteilFreitext extends Vertragsbestandteil public function hydrateByStdClass($data) { parent::hydrateByStdClass($data); - isset($data->anmerkung) && $this->setAnmerkung($data->anmerkung); - isset($data->kuendigungrelevant) && $this->setKuendigungrelevant($data->kuendigungrelevant); + isset($data->freitexttyp) && $this->setFreitexttypKurzbz($data->freitexttyp); isset($data->freitexttyp_kurzbz) && $this->setFreitexttypKurzbz($data->freitexttyp_kurzbz); + isset($data->titel) && $this->setTitel($data->titel); + isset($data->freitext) && $this->setAnmerkung($data->freitext); } public function toStdClass(): \stdClass { $tmp = array( 'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(), - 'anmerkung' => $this->getAnmerkung(), - 'kuendigungrelevant' => $this->getKuendigungrelevant(), - 'freitexttyp_kurzbz' => $this->getFreitexttypKurzbz() + 'freitexttyp_kurzbz' => $this->getFreitexttypKurzbz(), + 'titel' => $this->getTitel(), + 'anmerkung' => $this->getAnmerkung() ); $tmp = array_filter($tmp, function($v) { @@ -44,7 +46,7 @@ class VertragsbestandteilFreitext extends Vertragsbestandteil { $txt = <<getAnmerkung()} - kuendigungrelevant: {$this->getKuendigungrelevant()} + titel: {$this->getTitel()} freitexttyp_kurzbz: {$this->getFreitexttypKurzbz()} EOTXT; @@ -70,19 +72,19 @@ EOTXT; } /** - * Get the value of kuendigungrelevant + * Get the value of titel */ - public function getKuendigungrelevant() + public function getTitel() { - return $this->kuendigungrelevant; + return $this->titel; } /** - * Set the value of kuendigungrelevant + * Set the value of titel */ - public function setKuendigungrelevant($kuendigungrelevant): self + public function setTitel($titel): self { - $this->kuendigungrelevant = $kuendigungrelevant; + $this->titel = $titel; return $this; } @@ -104,4 +106,9 @@ EOTXT; return $this; } + + public function validate() + { + return parent::validate(); + } } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilFunktion.php b/application/libraries/vertragsbestandteil/VertragsbestandteilFunktion.php index d59e1b158..727d2b548 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilFunktion.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilFunktion.php @@ -12,22 +12,45 @@ use vertragsbestandteil\VertragsbestandteilFactory; class VertragsbestandteilFunktion extends Vertragsbestandteil { protected $benutzerfunktion_id; - protected $anmerkung; - protected $kuendigungsrelevant; + protected $benutzerfunktiondata; + protected $CI; + public function __construct() { + parent::__construct(); + $this->benutzerfunktiondata = null; + $this->setVertragsbestandteiltyp_kurzbz( VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_FUNKTION); + + $this->CI = get_instance(); + $this->CI->load->model('person/Benutzerfunktion_model', + 'BenutzerfunktionModel'); + } + + public function beforePersist() + { + if( $this->benutzerfunktiondata === null) + { + return; + } + + $ret = $this->CI->BenutzerfunktionModel->insert($this->benutzerfunktiondata); + + if(isError($ret) ) + { + throw new Exception('failed to create Benutzerfunktion'); + } + + $this->setBenutzerfunktion_id(getData($ret)); } public function toStdClass() { $tmp = array( 'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(), - 'benutzerfunktion_id' => $this->getBenutzerfunktion_id(), - 'anmerkung' => $this->getAnmerkung(), - 'kuendigungsrelevant' => $this->getKuendigungsrelevant() + 'benutzerfunktion_id' => $this->getBenutzerfunktion_id() ); $tmp = array_filter($tmp, function($v) { @@ -41,8 +64,6 @@ class VertragsbestandteilFunktion extends Vertragsbestandteil { $txt = <<getBenutzerfunktion_id()} - anmerkung: {$this->getAnmerkung()} - kuendigungsrelevant: {$this->getKuendigungsrelevant()} EOTXT; return parent::__toString() . $txt; @@ -51,40 +72,68 @@ EOTXT; public function hydrateByStdClass($data) { parent::hydrateByStdClass($data); + isset($data->benutzerfunktionid) && $this->setBenutzerfunktion_id($data->benutzerfunktionid); isset($data->benutzerfunktion_id) && $this->setBenutzerfunktion_id($data->benutzerfunktion_id); - isset($data->anmerkung) && $this->setAnmerkung($data->anmerkung); - isset($data->kuendigungsrelevant) && $this->setKuendigungsrelevant($data->kuendigungsrelevant); + isset($data->funktion) && isset($data->orget) + && isset($data->mitarbeiter_uid) && $this->createBenutzerfunktionData($data); + isset($data->funktion_bezeichnung) && isset($data->oe_bezeichnung) + && $this->createBenutzerfunktionData4Display($data); + } - + public function getBenutzerfunktion_id() { return $this->benutzerfunktion_id; } - - public function getAnmerkung() - { - return $this->anmerkung; - } - - public function getKuendigungsrelevant() - { - return $this->kuendigungsrelevant; - } public function setBenutzerfunktion_id($benutzerfunktion_id) { $this->benutzerfunktion_id = $benutzerfunktion_id; return $this; } - public function setAnmerkung($anmerkung) + + protected function createBenutzerfunktionData($data) { - $this->anmerkung = $anmerkung; - return $this; + if( empty($data->funktion) || empty($data->orget) ) + { + return; + } + + $this->benutzerfunktiondata = (object) array( + 'funktion_kurzbz' => $data->funktion, + 'oe_kurzbz' => $data->orget, + 'uid' => $data->mitarbeiter_uid, + 'datum_von' => $this->getVon(), + 'datum_bis' => $this->getBis(), + 'insertamum' => strftime('%Y-%m-%d %H:%M:%S'), + 'insertvon' => getAuthUID() + ); } - public function setKuendigungsrelevant($kuendigungsrelevant) + protected function createBenutzerfunktionData4Display($data) { - $this->kuendigungsrelevant = $kuendigungsrelevant; - return $this; + if( empty($data->funktion_bezeichnung) || empty($data->oe_bezeichnung) ) + { + return; + } + + $this->benutzerfunktiondata = (object) array( + 'funktion_kurzbz' => $data->funktion_kurzbz, + 'funktion_bezeichnung' => $data->funktion_bezeichnung, + 'oe_kurzbz' => $data->oe_kurzbz, + 'oe_bezeichnung' => $data->oe_bezeichnung, + 'oe_kurzbz_sap' => $data->oe_kurzbz_sap + ); + } + + public function validate() + { + if( (intval($this->benutzerfunktion_id) < 1) + && ($this->benutzerfunktiondata === NULL) ) { + $this->validationerrors[] = 'Eine bestehende Funktion oder eine ' + . 'Funktion und eine Organisationseinheit müssen ausgewählt sein.'; + } + + return parent::validate(); } } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilGehalt.php b/application/libraries/vertragsbestandteil/VertragsbestandteilGehalt.php deleted file mode 100644 index cdb06b26b..000000000 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilGehalt.php +++ /dev/null @@ -1,245 +0,0 @@ -setVertragsbestandteiltyp_kurzbz( - VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_GEHALT); - } - - public function hydrateByStdClass($data) - { - parent::hydrateByStdClass($data); - isset($data->gehalt_von) && $this->setGehaltVon($data->gehalt_von); - isset($data->gehalt_bis) && $this->setGehaltBis($data->gehalt_bis); - isset($data->anmerkung) && $this->setAnmerkung($data->anmerkung); - isset($data->gehalt_dienstverhaeltnis_id) && $this->setGehaltDienstverhaeltnisID($data->gehalt_dienstverhaeltnis_id); - isset($data->gehaltstyp_kurzbz) && $this->setGehaltstypKurzbz($data->gehaltstyp_kurzbz); - isset($data->valorisierungssperre) && $this->setValorisierungssperre($data->valorisierungssperre); - } - - public function getGehaltVon() - { - return $this->gehalt_von; - } - - public function getGehaltBis() - { - return $this->gehalt_bis; - } - - public function setGehaltVon($von) - { - $this->gehalt_von = $von; - return $this; - } - - public function setGehaltBis($bis) - { - $this->gehalt_bis = $bis; - return $this; - } - - /** - * Get the value of gehaltsbestandteil_id - */ - public function getGehaltsbestandteilId() - { - return $this->gehaltsbestandteil_id; - } - - /** - * Set the value of gehaltsbestandteil_id - */ - public function setGehaltsbestandteilId($gehaltsbestandteil_id): self - { - $this->gehaltsbestandteil_id = $gehaltsbestandteil_id; - - return $this; - } - - /** - * Get the value of anmerkung - */ - public function getAnmerkung() - { - return $this->anmerkung; - } - - /** - * Set the value of anmerkung - */ - public function setAnmerkung($anmerkung): self - { - $this->anmerkung = $anmerkung; - - return $this; - } - - /** - * Get the value of grundbetrag - */ - public function getGrundbetrag() - { - return $this->grundbetrag; - } - - /** - * Set the value of grundbetrag - */ - public function setGrundbetrag($grundbetrag): self - { - $this->grundbetrag = $grundbetrag; - - return $this; - } - - /** - * Get the value of betrag_valorisiert - */ - public function getBetragValorisiert() - { - return $this->betrag_valorisiert; - } - - /** - * Set the value of betrag_valorisiert - */ - public function setBetragValorisiert($betrag_valorisiert): self - { - $this->betrag_valorisiert = $betrag_valorisiert; - - return $this; - } - - /** - * Get the value of valorisieren - */ - public function getValorisieren() - { - return $this->valorisieren; - } - - /** - * Set the value of valorisieren - */ - public function setValorisieren($valorisieren): self - { - $this->valorisieren = $valorisieren; - - return $this; - } - - /** - * Get the value of dienstverhaeltnis_id - */ - public function getGehaltDienstverhaeltnisID() - { - return $this->gehalt_dienstverhaeltnis_id; - } - - /** - * Set the value of dienstverhaeltnis_id - */ - public function setGehaltDienstverhaeltnisID($dienstverhaeltnis_id): self - { - $this->gehalt_dienstverhaeltnis_id = $dienstverhaeltnis_id; - - return $this; - } - - /** - * Get the value of gehaltstyp_kurzbz - */ - public function getGehaltstypKurzbz() - { - return $this->gehaltstyp_kurzbz; - } - - /** - * Set the value of gehaltstyp_kurzbz - */ - public function setGehaltstypKurzbz($gehaltstyp_kurzbz): self - { - $this->gehaltstyp_kurzbz = $gehaltstyp_kurzbz; - - return $this; - } - - /** - * Get the value of valorisierungssperre - */ - public function getValorisierungssperre() - { - return $this->valorisierungssperre; - } - - /** - * Set the value of valorisierungssperre - */ - public function setValorisierungssperre($valorisierungssperre): self - { - $this->valorisierungssperre = $valorisierungssperre; - - return $this; - } - - - - - public function toStdClass(): \stdClass - { - $tmp = array( - 'von' => $this->getVon(), - 'bis' => $this->getBis(), - 'gehalt_von' => $this->getGehaltVon(), - 'gehalt_bis' => $this->getGehaltBis(), - 'gehalt_dienstverhaeltnis_id' => $this->getGehaltDienstverhaeltnisID(), - 'grundbetrag' => $this->getGrundbetrag(), - 'betrag_valorisiert' => $this->getBetragValorisiert(), - 'valorisieren' => $this->getValorisieren(), - 'gehaltstyp_kurzbz' => $this->getGehaltstypKurzbz(), - 'valorisierungssperre' => $this->getValorisierungssperre(), - 'anmerkung' => $this->getAnmerkung() - ); - - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); - - return (object) $tmp; - } - - public function __toString() - { - $txt = <<getVon()} - bis: {$this->getBis()} - grundbetrag: {$this->getGrundbetrag()} - valorisieren: {$this->getValorisieren()} - -EOTXT; - return parent::__toString() . $txt; - } - - -} diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilKarenz.php b/application/libraries/vertragsbestandteil/VertragsbestandteilKarenz.php index 3c9f7b38d..ca237f275 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilKarenz.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilKarenz.php @@ -12,6 +12,7 @@ class VertragsbestandteilKarenz extends Vertragsbestandteil public function __construct() { + parent::__construct(); $this->setVertragsbestandteiltyp_kurzbz( VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_KARENZ); } @@ -104,5 +105,8 @@ EOTXT; return parent::__toString() . $txt; } - + public function validate() + { + return parent::validate(); + } } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilKuendigungsfrist.php b/application/libraries/vertragsbestandteil/VertragsbestandteilKuendigungsfrist.php index 18b220b37..1d2788b57 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilKuendigungsfrist.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilKuendigungsfrist.php @@ -11,6 +11,7 @@ class VertragsbestandteilKuendigungsfrist extends Vertragsbestandteil public function __construct() { + parent::__construct(); $this->setVertragsbestandteiltyp_kurzbz( VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST); } @@ -83,5 +84,30 @@ EOTXT; return parent::__toString() . $txt; } - + public function validate() + { + if( !(filter_var($this->arbeitgeber_frist, FILTER_VALIDATE_INT, + array( + 'options' => array( + 'min_range' => 0, + 'max_range' => 52 + ) + ) + )) ) { + $this->validationerrors[] = 'Arbeitgeberfrist muss eine Wochenanzahl im Bereich 1 bis 52 sein.'; + } + + if( !(filter_var($this->arbeitnehmer_frist, FILTER_VALIDATE_INT, + array( + 'options' => array( + 'min_range' => 1, + 'max_range' => 52 + ) + ) + )) ) { + $this->validationerrors[] = 'Arbeitnehmerfrist muss eine Wochenanzahl im Bereich 1 bis 52 sein.'; + } + + return parent::validate(); + } } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilLehre.php b/application/libraries/vertragsbestandteil/VertragsbestandteilLehre.php deleted file mode 100644 index 2c665cbf5..000000000 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilLehre.php +++ /dev/null @@ -1,65 +0,0 @@ -setVertragsbestandteiltyp_kurzbz( - VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_LEHRE); - } - - public function hydrateByStdClass($data) - { - parent::hydrateByStdClass($data); - isset($data->inkludierte_lehre) && $this->setInkludierteLehre($data->inkludierte_lehre); - } - - /** - * Get the value of inkludierte_lehre - */ - public function getInkludierteLehre() - { - return $this->inkludierte_lehre; - } - - /** - * Set the value of inkludierte_lehre - */ - public function setInkludierteLehre($inkludierte_lehre): self - { - $this->inkludierte_lehre = $inkludierte_lehre; - - return $this; - } - - public function toStdClass(): \stdClass - { - $tmp = array( - 'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(), - 'inkludierte_lehre' => $this->getInkludierteLehre(), - ); - - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); - - return (object) $tmp; - } - - public function __toString() - { - $txt = <<getInkludierteLehre()} - -EOTXT; - return parent::__toString() . $txt; - } - - -} diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php index 8e5daa520..6df37263c 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php @@ -1,9 +1,16 @@ loggedInUser = getAuthUID(); $this->CI = get_instance(); + $this->CI->load->model('vertragsbestandteil/Dienstverhaeltnis_model', + 'DienstverhaeltnisModel'); + $this->DienstverhaeltnisModel = $this->CI->DienstverhaeltnisModel; $this->CI->load->model('vertragsbestandteil/Vertragsbestandteil_model', 'VertragsbestandteilModel'); $this->VertragsbestandteilModel = $this->CI->VertragsbestandteilModel; + $this->CI->load->library('vertragsbestandteil/GehaltsbestandteilLib', + null, 'GehaltsbestandteilLib'); + $this->GehaltsbestandteilLib = $this->CI->GehaltsbestandteilLib; } public function handleGUIData($guidata, $employeeUID, $userUID) @@ -40,6 +62,18 @@ class VertragsbestandteilLib return $ret; } + public function fetchDienstverhaeltnis($dienstverhaeltnis_id) + { + $result = $this->DienstverhaeltnisModel->load($dienstverhaeltnis_id); + $dv = null; + if(null !== ($row = getData($result))) + { + $dv = new Dienstverhaeltnis(); + $dv->hydrateByStdClass($row[0]); + } + return $dv; + } + public function fetchVertragsbestandteile($dienstverhaeltnis_id, $stichtag=null) { return $this->VertragsbestandteilModel->getVertragsbestandteile($dienstverhaeltnis_id, $stichtag); @@ -50,6 +84,18 @@ class VertragsbestandteilLib return $this->VertragsbestandteilModel->getVertragsbestandteil($vertragsbestandteil_id); } + public function storeDienstverhaeltnis(Dienstverhaeltnis $dv) + { + if( intval($dv->getDienstverhaeltnis_id()) > 0 ) + { + $this->updateDienstverhaeltnis($dv); + } + else + { + $this->insertDienstverhaeltnis($dv); + } + } + public function storeVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) { $this->CI->db->trans_begin(); @@ -74,12 +120,30 @@ class VertragsbestandteilLib { log_message('debug', "Transaction rolled back. " . $ex->getMessage()); $this->CI->db->trans_rollback(); + throw new Exception('Storing Vertragsbestandteil failed.'); } } - protected function insertVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil, - Vertragsbestandteil $vertragsbestandteil_secondary = null /* i.e. Gehaltsbestandteil connected to Stunden*/) + protected function insertDienstverhaeltnis(Dienstverhaeltnis $dv) { + $dv->setInsertvon($this->loggedInUser) + ->setInsertamum(strftime('%Y-%m-%d %H:%M:%S')); + $ret = $this->DienstverhaeltnisModel->insert($dv->toStdClass()); + if( hasData($ret) ) + { + $dv->setDienstverhaeltnis_id(getData($ret)); + } + else + { + throw new Exception('error inserting dienstverhaeltnis'); + } + } + + protected function insertVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) + { + $vertragsbestandteil->setInsertvon($this->loggedInUser) + ->setInsertamum(strftime('%Y-%m-%d %H:%M:%S')); + $vertragsbestandteil->beforePersist(); $ret = $this->VertragsbestandteilModel->insert($vertragsbestandteil->baseToStdClass()); if( hasData($ret) ) { @@ -99,40 +163,36 @@ class VertragsbestandteilLib throw new Exception('error updating vertragsbestandteil ' . $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); } - - if ($vertragsbestandteil_secondary == null) return; - - if (!is_array($vertragsbestandteil_secondary)) - { - $vertragsbestandteil_secondary = [$vertragsbestandteil_secondary]; - } - - foreach ($vertragsbestandteil_secondary as $vb) - { - $specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel( - $vb->getVertragsbestandteiltyp_kurzbz()); - - if ($specialisedModel instanceof IEncryption) - { - $retspecial = $specialisedModel->insert($vb->toStdClass(), $specialisedModel->getEncryptedColumns()); - } else - { - $retspecial = $specialisedModel->insert($vb->toStdClass()); - } - - if(isError($retspecial) ) - { - throw new Exception('error updating secondary vertragsbestandteil ' - . $vb->getVertragsbestandteiltyp_kurzbz()); - } - } + try + { + $gehaltsbestandteile = $vertragsbestandteil->getGehaltsbestandteile(); + $this->GehaltsbestandteilLib->storeGehaltsbestandteile($gehaltsbestandteile); + } + catch(Exception $ex) + { + throw new Exception('VertragsbestandteilLib insertVertragsbestandteil ' + . 'failed to store Gehaltsbestandteile. ' . $ex->getMessage()); + } + } + + protected function updateDienstverhaeltnis(Dienstverhaeltnis $dv) + { + $dv->setUpdatevon($this->loggedInUser) + ->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S')); + $ret = $this->DienstverhaeltnisModel->update($dv->getDienstverhaeltnis_id(), + $dv->toStdClass()); + if(isError($ret) ) + { + throw new Exception('error updating dienstverhaeltnis'); + } } protected function updateVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) { - $vertragsbestandteil->setUpdateamum(strftime('%Y-%m-%d %H:%M')) - ->setUpdatevon('ma0080'); + $vertragsbestandteil->setUpdatevon($this->loggedInUser) + ->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S')); + $vertragsbestandteil->beforePersist(); $ret = $this->VertragsbestandteilModel->update($vertragsbestandteil->getVertragsbestandteil_id(), $vertragsbestandteil->baseToStdClass()); @@ -151,5 +211,26 @@ class VertragsbestandteilLib throw new Exception('error updating vertragsbestandteil ' . $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); } + + try + { + $gehaltsbestandteile = $vertragsbestandteil->getGehaltsbestandteile(); + $this->GehaltsbestandteilLib->storeGehaltsbestandteile($gehaltsbestandteile); + } + catch(Exception $ex) + { + throw new Exception('VertragsbestandteilLib updateVertragsbestandteil ' + . 'failed to store Gehaltsbestandteile. ' . $ex->getMessage()); + } + } + + public function isOverlappingExistingDV(Dienstverhaeltnis $dv) + { + return $this->DienstverhaeltnisModel->isOverlappingExistingDV( + $dv->getMitarbeiter_uid(), + $dv->getOe_kurzbz(), + $dv->getVon(), + $dv->getBis() + ); } } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilStunden.php b/application/libraries/vertragsbestandteil/VertragsbestandteilStunden.php index 5f03c8030..d11e04994 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilStunden.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilStunden.php @@ -1,9 +1,12 @@ setVertragsbestandteiltyp_kurzbz( VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_STUNDEN); } @@ -24,7 +28,7 @@ class VertragsbestandteilStunden extends Vertragsbestandteil { parent::hydrateByStdClass($data); isset($data->wochenstunden) && $this->setWochenstunden($data->wochenstunden); - isset($data->karenz) && $this->setKarenz($data->karenz); + isset($data->teilzeittyp_kurzbz) && $this->setTeilzeittyp_kurzbz($data->teilzeittyp_kurzbz); } public function getWochenstunden() @@ -32,9 +36,9 @@ class VertragsbestandteilStunden extends Vertragsbestandteil return $this->wochenstunden; } - public function getKarenz() + public function getTeilzeittyp_kurzbz() { - return $this->karenz; + return $this->teilzeittyp_kurzbz; } public function setWochenstunden($wochenstunden) @@ -43,9 +47,9 @@ class VertragsbestandteilStunden extends Vertragsbestandteil return $this; } - public function setKarenz($karenz) + public function setTeilzeittyp_kurzbz($teilzeittyp_kurzbz) { - $this->karenz = $karenz; + $this->teilzeittyp_kurzbz = $teilzeittyp_kurzbz; return $this; } @@ -54,7 +58,7 @@ class VertragsbestandteilStunden extends Vertragsbestandteil $tmp = array( 'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(), 'wochenstunden' => $this->getWochenstunden(), - 'karenz' => $this->getKarenz() + 'teilzeittyp_kurzbz' => $this->getTeilzeittyp_kurzbz() ); $tmp = array_filter($tmp, function($v) { @@ -68,9 +72,25 @@ class VertragsbestandteilStunden extends Vertragsbestandteil { $txt = <<getWochenstunden()} - karenz: {$this->getKarenz()} + teilzeittyp_kurzbz: {$this->getTeilzeittyp_kurzbz()} EOTXT; return parent::__toString() . $txt; } + + public function validate() + { + if( !(filter_var($this->wochenstunden, FILTER_VALIDATE_FLOAT, + array( + 'options' => array( + 'min_range' => 0, + 'max_range' => 100 + ) + ) + )) ) { + $this->validationerrors[] = 'Stunden muss eine Kommazahl im Bereich 0 bis 100 sein.'; + } + + return parent::validate(); + } } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilUrlaubsanspruch.php b/application/libraries/vertragsbestandteil/VertragsbestandteilUrlaubsanspruch.php index 285d7e8ad..fde150317 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilUrlaubsanspruch.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilUrlaubsanspruch.php @@ -10,6 +10,7 @@ class VertragsbestandteilUrlaubsanspruch extends Vertragsbestandteil public function __construct() { + parent::__construct(); $this->setVertragsbestandteiltyp_kurzbz( VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH); } @@ -61,5 +62,19 @@ EOTXT; return parent::__toString() . $txt; } - + public function validate() + { + if( !(filter_var($this->tage, FILTER_VALIDATE_INT, + array( + 'options' => array( + 'min_range' => 1, + 'max_range' => 50 + ) + ) + )) ) { + $this->validationerrors[] = 'Urlaubsanspruch muss eine Tagesanzahl im Bereich 1 bis 50 sein.'; + } + + return parent::validate(); + } } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung.php b/application/libraries/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung.php index fb715304c..3fce91995 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung.php @@ -12,6 +12,7 @@ class VertragsbestandteilZeitaufzeichnung extends Vertragsbestandteil public function __construct() { + parent::__construct(); $this->setVertragsbestandteiltyp_kurzbz( VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG); } @@ -104,6 +105,9 @@ class VertragsbestandteilZeitaufzeichnung extends Vertragsbestandteil EOTXT; return parent::__toString() . $txt; } - + public function validate() + { + return parent::validate(); + } } diff --git a/application/libraries/vertragsbestandteil/gui/AbstractBestandteil.php b/application/libraries/vertragsbestandteil/gui/AbstractBestandteil.php deleted file mode 100644 index 861dcf11a..000000000 --- a/application/libraries/vertragsbestandteil/gui/AbstractBestandteil.php +++ /dev/null @@ -1,86 +0,0 @@ -getTypeString())) - { - throw new \Exception('wrong type string: "'.$decoded['type'].'" should be "'.$this->getTypeString().'"'); - } - } - - /** - * Get the value of type - */ - public function getType() - { - return $this->type; - } - - /** - * Set the value of type - */ - public function setType($type): self - { - $this->type = $type; - - return $this; - } - - /** - * Get the value of guioptions - */ - public function getGuioptions() - { - return $this->guioptions; - } - - /** - * Set the value of guioptions - */ - public function setGuioptions($guioptions): self - { - $this->guioptions = $guioptions; - - return $this; - } - - /** - * Get the value of data - */ - public function getData() - { - return $this->data; - } - - /** - * Set the value of data - */ - public function setData($data): self - { - $this->data = $data; - - return $this; - } -} \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/gui/AbstractGUIVertragsbestandteil.php b/application/libraries/vertragsbestandteil/gui/AbstractGUIVertragsbestandteil.php deleted file mode 100644 index 63906e42e..000000000 --- a/application/libraries/vertragsbestandteil/gui/AbstractGUIVertragsbestandteil.php +++ /dev/null @@ -1,143 +0,0 @@ -vbsLib = new VertragsbestandteilLib(); - } - - abstract public function generateVertragsbestandteil($id); - - /** - * Get the value of uuid - */ - public function getUuid() - { - return $this->uuid; - } - - /** - * Set the value of uuid - */ - public function setUuid($uuid): self - { - $this->uuid = $uuid; - - return $this; - } - - - - /** - * Get the value of hasGBS - */ - public function getHasGBS() - { - return $this->hasGBS; - } - - /** - * Set the value of hasGBS - */ - public function setHasGBS($hasGBS): self - { - $this->hasGBS = $hasGBS; - - return $this; - } - - - - /** - * Get the value of gbs - */ - public function getGbs() - { - return $this->gbs; - } - - /** - * Set the value of gbs - */ - public function setGbs($gbs): self - { - $this->gbs = $gbs; - - return $this; - } -} \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/gui/FormData.php b/application/libraries/vertragsbestandteil/gui/FormData.php deleted file mode 100644 index 9c24e3f99..000000000 --- a/application/libraries/vertragsbestandteil/gui/FormData.php +++ /dev/null @@ -1,105 +0,0 @@ -checkType($decoded); - // preserve gui data - $this->mapChildren($decoded); - // data contains DV - $this->mapData($decoded); - // vbs array - $this->mapVbs($decoded); - } - - public function generateJSON() - { - $json = json_encode([ - "children" => $this->children, - "data" => $this->generateDvJSON(), - "vbs" => $this->generateVbsJSON() - ]); - return $json; - } - - private function mapChildren(&$decoded) - { - $decodedData = null; - if (!$this->getJSONData($decodedData, $decoded, 'children')) - { - throw new \Exception('missing children'); - } - $this->getJSONData($this->data['children'], $decodedData, 'children'); - } - - private function mapData(&$decoded) - { - $decodedData = null; - if (!$this->getJSONData($decodedData, $decoded, 'data')) - { - throw new \Exception('missing data'); - } - - $this->getJSONDataInt($this->data['dienstverhaeltnisid'], $decodedData, 'dienstverhaeltnisid'); - $this->getJSONData($this->data['unternehmen'], $decodedData, 'unternehmen'); - $this->getJSONData($this->data['vertragsart_kurzbz'], $decodedData, 'vertragsart_kurzbz'); - $this->getJSONData($this->data['gueltigkeit'], $decodedData, 'gueltigkeit'); - } - - private function generateDvJSON() - { - return json_encode($this->data); - } - - - private function mapVbs(&$decoded) - { - if (!$this->getJSONData($this->vbs, $decoded, 'vbs')) - { - throw new \Exception('missing vbs'); - } - //$this->getJSONData($this->vbs, $decodedData, 'vbs'); - } - - private function generateVbsJSON() - { - return json_encode($this->vbs); - } - - /** - * Get the value of children - */ - public function getChildren() - { - return $this->children; - } - - - /** - * Get the value of vbs - */ - public function getVbs() - { - return $this->vbs; - } - - -} \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/gui/GUIGehaltsbestandteil.php b/application/libraries/vertragsbestandteil/gui/GUIGehaltsbestandteil.php deleted file mode 100644 index 713ee64a0..000000000 --- a/application/libraries/vertragsbestandteil/gui/GUIGehaltsbestandteil.php +++ /dev/null @@ -1,89 +0,0 @@ -type = GUIVertragsbestandteilStunden::TYPE_STRING; - $this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => true]; - $this->data = [ "gehaltstyp" => "", - "betrag" => "", - "gueltigkeit" => [ - "guioptions" => ["sharedstatemode" => "reflect"], - "data" => ["gueltig_ab" => "", "gueltig_bis" => ""] - ], - "valorisierung" => true - ]; - } - - public function getTypeString(): string - { - return GUIGehaltsbestandteil::TYPE_STRING; - } - - public function mapJSON(&$decoded) - { - //$decoded = json_decode($jsondata); - $this->checkType($decoded); - $this->mapGUIOptions($decoded); - $this->mapData($decoded); - } - - private function mapGUIOptions(&$decoded) - { - $decodedGUIOptions = null; - if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions')) - { - throw new \Exception('missing guioptions'); - } - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'id'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'removable'); - } - - private function mapData(&$decoded) - { - $decodedData = null; - if (!$this->getJSONData($decodedData, $decoded, 'data')) - { - throw new \Exception('missing data'); - } - $this->getJSONData($this->data['id'], $decodedData, 'id'); - $this->getJSONData($this->data['gehaltstyp'], $decodedData, 'gehaltstyp'); - $this->getJSONDataInt($this->data['betrag'], $decodedData, 'betrag'); - $gueltigkeit = new GUIGueltigkeit(); - $gueltigkeit->mapJSON($decodedData['gueltigkeit']); - $this->data['gueltigkeit'] = $gueltigkeit; - $this->getJSONData($this->data['valorisierung'], $decodedData, 'valorisierung'); - } - -} \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/gui/GUIGueltigkeit.php b/application/libraries/vertragsbestandteil/gui/GUIGueltigkeit.php deleted file mode 100644 index c1acec672..000000000 --- a/application/libraries/vertragsbestandteil/gui/GUIGueltigkeit.php +++ /dev/null @@ -1,76 +0,0 @@ -mapGuioptions($decoded); - $this->mapData($decoded); - } - - private function mapGuioptions(&$decoded) - { - $decodedData = null; - if (!$this->getJSONData($decodedData, $decoded, 'guioptions')) - { - throw new \Exception('missing guioptions'); - } - $this->getJSONData($this->guioptions, $decodedData, 'guioptions'); - } - - private function mapData(&$decoded) - { - $decodedData = null; - if (!$this->getJSONData($decodedData, $decoded, 'data')) - { - throw new \Exception('missing data'); - } - $this->getJSONData($this->data['gueltig_ab'], $decodedData, 'gueltig_ab'); - $this->getJSONData($this->data['gueltig_bis'], $decodedData, 'gueltig_bis'); - - } - - /** - * Get the value of guioptions - */ - public function getGuioptions() - { - return $this->guioptions; - } - - /** - * Get the value of data - */ - public function getData() - { - return $this->data; - } - - public function jsonSerialize() { - return ["guioptions" => $this->guioptions, - "data" => $this->data]; - } -} \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/gui/GUIHandler.php b/application/libraries/vertragsbestandteil/gui/GUIHandler.php deleted file mode 100644 index 7a5695b44..000000000 --- a/application/libraries/vertragsbestandteil/gui/GUIHandler.php +++ /dev/null @@ -1,167 +0,0 @@ -employeeUID = $employeeUID; - $this->userUID = $userUID; - $this->CI = get_instance(); - $this->CI->load->model('vertragsbestandteil/Dienstverhaeltnis_model', - 'Dienstverhaeltnis_model'); - - - } - - /** - * main entry (called from VetragsbestandteilLib) - * @param string $guidata JSON submitted by editor - * @param string $employeeUID uid of the employee - * @param string $userUID uid of the user currently editing the employee data - * @return string JSON for GUI client - */ - public function handle($guidata) - { - $decoded = json_decode($guidata, true); - $formDataMapper = new FormData(); - $formDataMapper->mapJSON($decoded); - - // DV - $dvData = $formDataMapper->getData(); - $this->handleDV($dvData); - - // VBS - $vbsList = $formDataMapper->getVbs(); - - foreach ($vbsList as $vbsID => $vbs) { - $this->handleVBS($dvData['dienstverhaeltnis_id'] ,$vbs); - } - - return $formDataMapper->generateJSON(); - } - - /** - * dienstverhaeltnisid - * unternehmen - * vertragsart_kurzbz - * gueltigkeit - */ - private function handleDV(&$dv) - { - $dienstverhaeltnisid = $dv['dienstverhaeltnisid']; - - if (isset($dienstverhaeltnisid) && intval($dienstverhaeltnisid > 0)) - { - // DV exists - $ret = $this->updateDV($dv); - } else { - // DV is new - $ret = $this->insertDV($dv); - // write back new id - $dv['dienstverhaeltnisid'] = $ret['dienstverhaeltnis_id']; - } - - } - - private function handleVBS($vbs) - { - $vbsMapper = GUIHandlerFactory::getGUIHandler($vbs['type']); - $vbsMapper->mapJSON($vbs); - $vbsData = $vbsMapper->getData(); - - // merge GUI-Data with DB-Data - $vbsInstance = $vbsMapper->generateVertragsbestandteil($vbsData['id']); - - // TODO Validate? - - // store - $this->VertragsbestandteilLib->store($vbsInstance); - - // GBS - /* - foreach ($vbsMapper->getGbs() as $gbs) - { - $gbsData = $gbs->getData(); - $this->handleGBS($gbsData); - }*/ - } - - - // GBS without connection to VBS - private static function handleGBS($gbs) - { - // TODO - } - - - // ------------------------------------ - // DV does not have a dedicated handler - - private function insertDV($dvJSON) - { - $now = new DateTime(); - $dvJSON['insertvon'] = $this->userUID; - $dvJSON['insertamum'] = $now->format(DateTime::ATOM); - - $result = $this->CI->Dienstverhaeltnis_model->insert($dvJSON); - - if (isError($result)) - { - throw Exception($result->msg); - } - - $record = $this->CI->Dienstverhaeltnis_model->load($result->retval); - - return $record; - } - - private function updateDV($dvJSON) - { - $now = new DateTime(); - $dvJSON['updatevon'] = getAuthUID(); - $dvJSON['updateamum'] = $now->format(DateTime::ATOM); - - unset($dvJSON['insertamum']); - unset($dvJSON['insertvon']); - - - $result = $this->CI->Dienstverhaeltnis_model->update($dvJSON['kontakt_id'], $dvJSON); - - if (isError($result)) - { - return error($result->msg, EXIT_ERROR); - } - - $record = $this->CI->Dienstverhaeltnis_model->load($result->retval); - - return $record; - } - - private function deleteDV($dv_id) - { - $result = $this->CI->Dienstverhaeltnis_model->delete($dv_id); - - if (isError($result)) - { - return error($result->msg, EXIT_ERROR); - } - - return success($dv_id); - } - -} \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/gui/GUIHandlerFactory.php b/application/libraries/vertragsbestandteil/gui/GUIHandlerFactory.php deleted file mode 100644 index ff1a7581d..000000000 --- a/application/libraries/vertragsbestandteil/gui/GUIHandlerFactory.php +++ /dev/null @@ -1,30 +0,0 @@ -type = GUIVertragsbestandteilFunktion::TYPE_STRING; - $this->hasGBS = true; - $this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => false]; - $this->data = ["funktion" => "Leitung", - "orget" => "", - "gueltigkeit" => [ - "guioptions" => ["sharedstatemode" => "reflect"], - "data" => ["gueltig_ab" => "", "gueltig_bis" => ""] - ] - ]; - $this->gbs = []; - } - - public function getTypeString(): string - { - return GUIVertragsbestandteilFunktion::TYPE_STRING; - } - - /** - * parse JSON into object - * @param string $jsondata - */ - public function mapJSON(&$decoded) - { - $this->checkType($decoded); - $this->mapGUIOptions($decoded); - $this->mapData($decoded); - $this->mapGBS($decoded); - } - - /** - * ["id" => null, - * "infos" => [], - * "errors" => [], - * "removeable" => true - * ] - * @param mixed $decoded decoded JSON data (use associative array) - */ - private function mapGUIOptions(&$decoded) - { - $decodedGUIOptions = null; - if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions')) - { - throw new \Exception('missing guioptions'); - } - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'id'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors'); - $this->getJSONDataBool($this->guioptions, $decodedGUIOptions, 'removable'); - } - - /** - * { - * "funktion": "Leitung", - * "orget": "sdf", - * "gueltigkeit": { - * "guioptions": { - * "sharedstatemode": "reflect" - * }, - * "data": { - * "gueltig_ab": "", - * "gueltig_bis": "" - * } - * } - * } - */ - private function mapData(&$decoded) - { - $decodedData = null; - if (!$this->getJSONData($decodedData, $decoded, 'data')) - { - throw new \Exception('missing data'); - } - $this->getJSONData($this->data['funktion'], $decodedData, 'funktion'); - $this->getJSONData($this->data['orget'], $decodedData, 'orget'); - $gueltigkeit = new GUIGueltigkeit(); - $gueltigkeit->mapJSON($decodedData['gueltigkeit']); - $this->data['gueltigkeit'] = $gueltigkeit; - } - - private function mapGBS(&$decoded) - { - //echo "gbs: ";var_dump($decoded); - $decodedGbsList = []; - if (!$this->getJSONData($decodedGbsList, $decoded, 'gbs')) - { - throw new \Exception('missing gbs'); - } - $guiGBS = null; - foreach ($decodedGbsList as $decodedGbs) { - $guiGBS = new GUIGehaltsbestandteil(); - $guiGBS->mapJSON($decodedGbs); - $this->gbs[] = $guiGBS; - } - } - - - public function generateVertragsbestandteil($id) { - // TODO - } - - public function jsonSerialize() { - return [ - "type" => $this->type, - "guioptions" => $this->guioptions, - "data" => $this->data, - "gbs" => $this->gbs]; - } - -} \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilKuendigungsfrist.php b/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilKuendigungsfrist.php deleted file mode 100644 index 8d706ef26..000000000 --- a/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilKuendigungsfrist.php +++ /dev/null @@ -1,118 +0,0 @@ -type = GUIVertragsbestandteilKuendigungsfrist::TYPE_STRING; - $this->hasGBS = false; - $this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => true]; - $this->data = ["arbeitnehmer_frist" => "", - "arbeitgeber_frist" => "", - "gueltigkeit" => [ - "guioptions" => ["sharedstatemode" => "reflect"], - "data" => ["gueltig_ab" => "", "gueltig_bis" => ""] - ] - ]; - } - - public function getTypeString(): string - { - return GUIVertragsbestandteilKuendigungsfrist::TYPE_STRING; - } - - /** - * parse JSON into object - * @param string $jsondata - */ - public function mapJSON(&$decoded) - { - $this->checkType($decoded); - $this->mapGUIOptions($decoded); - $this->mapData($decoded); - } - - /** - * ["id" => null, - * "infos" => [], - * "errors" => [], - * "removeable" => true - * ] - * @param mixed $decoded decoded JSON data (use associative array) - */ - private function mapGUIOptions(&$decoded) - { - $decodedGUIOptions = null; - if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions')) - { - throw new \Exception('missing guioptions'); - } - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'id'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors'); - $this->getJSONDataBool($this->guioptions, $decodedGUIOptions, 'removable'); - } - - /** - */ - private function mapData(&$decoded) - { - $decodedData = null; - if (!$this->getJSONData($decodedData, $decoded, 'data')) - { - throw new \Exception('missing data'); - } - $this->getJSONDataInt($this->data['arbeitnehmer_frist'], $decodedData, 'arbeitnehmer_frist'); - $this->getJSONDataInt($this->data['arbeitgeber_frist'], $decodedData, 'arbeitgeber_frist'); - $this->getJSONData($this->data['gueltigkeit'], $decodedData, 'gueltigkeit'); - } - - private function mapGBS() - { - $decodedGbsList = []; - if (!$this->getJSONData($decodedGbsList, $decoded, 'gbs')) - { - throw new \Exception('missing gbs'); - } - $guiGBS = null; - foreach ($decodedGbsList as $decodedGbs) { - $guiGBS = new GUIGehaltsbestandteil(); - $guiGBS->mapJSON($decodedGbs); - } - } - - public function generateVertragsbestandteil($id) { - // TODO - } - - public function jsonSerialize() { - return [ - "type" => $this->type, - "guioptions" => $this->guioptions, - "data" => $this->data]; - } - -} \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilStunden.php b/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilStunden.php deleted file mode 100644 index 60accea05..000000000 --- a/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilStunden.php +++ /dev/null @@ -1,131 +0,0 @@ -type = GUIVertragsbestandteilStunden::TYPE_STRING; - $this->hasGBS = true; - $this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => true]; - $this->data = ["stunden" => "", - "gueltigkeit" => [ - "guioptions" => ["sharedstatemode" => "reflect"], - "data" => ["gueltig_ab" => "", "gueltig_bis" => ""] - ] - ]; - $this->gbs = []; - } - - public function getTypeString(): string - { - return GUIVertragsbestandteilStunden::TYPE_STRING; - } - - /** - * parse JSON into object - * @param string $jsondata - */ - public function mapJSON(&$decoded) - { - $this->checkType($decoded); - $this->mapGUIOptions($decoded); - $this->mapData($decoded); - $this->mapGBS($decoded); - } - - /** - * ["id" => null, - * "infos" => [], - * "errors" => [], - * "removeable" => true - * ] - * @param mixed $decoded decoded JSON data (use associative array) - */ - private function mapGUIOptions(&$decoded) - { - $decodedGUIOptions = null; - if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions')) - { - throw new \Exception('missing guioptions'); - } - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'id'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors'); - $this->getJSONDataBool($this->guioptions, $decodedGUIOptions, 'removable'); - } - - /** - * { - * "stunden": "38,5", - * "gueltigkeit": { - * "guioptions": { - * "sharedstatemode": "reflect" - * }, - * "data": { - * "gueltig_ab": "1.1.2011", - * "gueltig_bis": "" - * } - * } - */ - private function mapData(&$decoded) - { - $decodedData = null; - if (!$this->getJSONData($decodedData, $decoded, 'data')) - { - throw new \Exception('missing data'); - } - $this->getJSONDataFloat($this->data['stunden'], $decodedData, 'stunden'); - $gueltigkeit = new GUIGueltigkeit(); - $gueltigkeit->mapJSON($decodedData['gueltigkeit']); - $this->data['gueltigkeit'] = $gueltigkeit; - } - - private function mapGBS(&$decoded) - { - $decodedGbsList = []; - if (!$this->getJSONData($decodedGbsList, $decoded, 'gbs')) - { - throw new \Exception('missing gbs'); - } - $guiGBS = null; - foreach ($decodedGbsList as $decodedGbs) { - $guiGBS = new GUIGehaltsbestandteil(); - $guiGBS->mapJSON($decodedGbs); - $this->gbs[] = $guiGBS; - } - } - - public function generateVertragsbestandteil($id) - { - $vbs = null; - if (isset($vbsData['id']) && $vbsData['id'] > 0) - { - // load VBS - $vbs = $this->vbsLib->fetchVertragsbestandteil($vbsData['id']); - } else { - $vbs = new vertragsbestandteil\VertragsbestandteilStunden(); - } - // merge - $vbs->setWochenstunden($this->data['stunden']); - $vbs->setVon($this->data['gueltigkeit']->getData()['gueltig_ab']); - $vbs->setBis($this->data['gueltigkeit']->getData()['gueltig_bis']); - return $vbs; - } - - public function jsonSerialize() { - return [ - "type" => $this->type, - "guioptions" => $this->guioptions, - "data" => $this->data, - "gbs" => $this->gbs]; - } - -} \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilZeitaufzeichnung.php b/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilZeitaufzeichnung.php deleted file mode 100644 index dacee544c..000000000 --- a/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilZeitaufzeichnung.php +++ /dev/null @@ -1,103 +0,0 @@ -type = GUIVertragsbestandteilZeitaufzeichnung::TYPE_STRING; - $this->hasGBS = false; - $this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => true]; - $this->data = null; - } - - public function getTypeString(): string - { - return GUIVertragsbestandteilZeitaufzeichnung::TYPE_STRING; - } - - /** - * parse JSON into object - * @param string $jsondata - */ - public function mapJSON(&$decoded) - { - $this->checkType($decoded); - $this->mapGUIOptions($decoded); - $this->mapData($decoded); - } - - /** - * ["id" => null, - * "infos" => [], - * "errors" => [], - * "removeable" => true - * ] - * @param mixed $decoded decoded JSON data (use associative array) - */ - private function mapGUIOptions(&$decoded) - { - $decodedGUIOptions = null; - if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions')) - { - throw new \Exception('missing guioptions'); - } - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'id'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors'); - $this->getJSONDataBool($this->guioptions, $decodedGUIOptions, 'removable'); - } - - private function mapData(&$decoded) - { - $decodedData = null; - if (!$this->getJSONData($decodedData, $decoded, 'data')) - { - throw new \Exception('missing data'); - } - $this->getJSONDataBool($this->data['zeitaufzeichnung'], $decodedData, 'zeitaufzeichnung'); - $this->getJSONDataBool($this->data['azgrelevant'], $decodedData, 'azgrelevant'); - $this->getJSONDataBool($this->data['homeoffice'], $decodedData, 'homeoffice'); - $gueltigkeit = new GUIGueltigkeit(); - $gueltigkeit->mapJSON($decodedData['gueltigkeit']); - $this->data['gueltigkeit'] = $gueltigkeit; - } - - public function generateVertragsbestandteil($id) { - // TODO - } - - public function jsonSerialize() { - return [ - "type" => $this->type, - "guioptions" => $this->guioptions, - "data" => $this->data]; - } -} \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilZusatzvereinbarung.php b/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilZusatzvereinbarung.php deleted file mode 100644 index 606f57b0e..000000000 --- a/application/libraries/vertragsbestandteil/gui/GUIVertragsbestandteilZusatzvereinbarung.php +++ /dev/null @@ -1,139 +0,0 @@ -type = GUIVertragsbestandteilZusatzvereinbarung::TYPE_STRING; - $this->hasGBS = true; - $this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => true]; - $this->data = null; - $this->gbs = []; - } - - public function getTypeString(): string - { - return GUIVertragsbestandteilZusatzvereinbarung::TYPE_STRING; - } - - /** - * parse JSON into object - * @param string $jsondata - */ - public function mapJSON(&$decoded) - { - $this->checkType($decoded); - $this->mapGUIOptions($decoded); - $this->mapData($decoded); - $this->mapGBS($decoded); - } - - /** - * ["id" => null, - * "infos" => [], - * "errors" => [], - * "removeable" => true - * ] - * @param mixed $decoded decoded JSON data (use associative array) - */ - private function mapGUIOptions(&$decoded) - { - $decodedGUIOptions = null; - if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions')) - { - throw new \Exception('missing guioptions'); - } - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'id'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos'); - $this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors'); - $this->getJSONDataBool($this->guioptions, $decodedGUIOptions, 'removable'); - } - - /** - * { - * "freitexttyp": "allin", - * "titel": "Lorem ipsum ", - * "freitext": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. \nAt vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. ", - * "kuendigungsrelevant": "", - * "gueltigkeit": { - * "guioptions": { - * "sharedstatemode": "reflect" - * }, - * "data": { - * "gueltig_ab": "1.1.2010", - * "gueltig_bis": "" - * } - */ - private function mapData(&$decoded) - { - $decodedData = null; - if (!$this->getJSONData($decodedData, $decoded, 'data')) - { - throw new \Exception('missing data'); - } - $this->getJSONDataString($this->data['freitexttyp'], $decodedData, 'freitexttyp'); - $this->getJSONDataString($this->data['titel'], $decodedData, 'titel'); - $this->getJSONDataString($this->data['freitext'], $decodedData, 'freitext'); - $gueltigkeit = new GUIGueltigkeit(); - $gueltigkeit->mapJSON($decodedData['gueltigkeit']); - $this->data['gueltigkeit'] = $gueltigkeit; - } - - private function mapGBS(&$decoded) - { - $decodedGbsList = []; - if (!$this->getJSONData($decodedGbsList, $decoded, 'gbs')) - { - throw new \Exception('missing gbs'); - } - $guiGBS = null; - foreach ($decodedGbsList as $decodedGbs) { - $guiGBS = new GUIGehaltsbestandteil(); - $guiGBS->mapJSON($decodedGbs); - $this->gbs[] = $guiGBS; - } - } - - public function generateVertragsbestandteil($id) { - // TODO - } - - public function jsonSerialize() { - return [ - "type" => $this->type, - "guioptions" => $this->guioptions, - "data" => $this->data, - "gbs" => $this->gbs]; - } - -} \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/gui/JSONData.php b/application/libraries/vertragsbestandteil/gui/JSONData.php deleted file mode 100644 index 77ea19ce4..000000000 --- a/application/libraries/vertragsbestandteil/gui/JSONData.php +++ /dev/null @@ -1,53 +0,0 @@ -dbTable = 'public.tbl_rueckstellung_status'; + $this->pk = 'status_kurzbz'; + } +} \ No newline at end of file diff --git a/application/models/crm/Rueckstellung_model.php b/application/models/crm/Rueckstellung_model.php new file mode 100644 index 000000000..d2c39ffde --- /dev/null +++ b/application/models/crm/Rueckstellung_model.php @@ -0,0 +1,33 @@ +dbTable = 'public.tbl_rueckstellung'; + $this->pk = 'rueckstellung_id'; + $this->hasSequence = true; + } + + public function getByPersonId($person_id, $status = null) + { + $language_index = getUserLanguage() == 'German' ? 0 : 1; + + $this->addLimit(1); + $this->addJoin('tbl_rueckstellung_status', 'status_kurzbz'); + $this->addSelect('*, + array_to_json(bezeichnung_mehrsprachig::varchar[])->>'.$language_index . 'as bezeichnung'); + $this->addOrder('datum_bis', 'DESC'); + + $where['person_id'] = $person_id; + + if (!isEmptyString($status)) + $where['status_kurzbz'] = $status; + + return $this->loadWhere($where); + } +} \ No newline at end of file diff --git a/application/models/education/Anrechnungszeitraum_model.php b/application/models/education/Anrechnungszeitraum_model.php new file mode 100644 index 000000000..e6f0f13d3 --- /dev/null +++ b/application/models/education/Anrechnungszeitraum_model.php @@ -0,0 +1,87 @@ +dbTable = 'lehre.tbl_anrechnungszeitraum'; + $this->pk = 'anrechnungszeitraum_id'; + } + + /** + * Save new Anrechnungszeitraum. + * + * @param $studiensemester_kurzbz + * @param $anrechnungstart + * @param $anrechnungende + * @return array|stdClass + */ + public function insertAzr($studiensemester_kurzbz, $anrechnungstart, $anrechnungende) + { + $result = $this->insert(array( + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'anrechnungstart' => $anrechnungstart, + 'anrechnungende' => $anrechnungende, + 'insertvon' => getAuthUID() + )); + + if (isError($result)) + { + return error('Fehler bei Anrechnungszeitraum speichern.'); + } + + // Return new anrechnungszeitraum_id + return success($result->retval); + } + + /** + * Delete Anrechnungszeitraum. + * + * @param $anrechnungszeitraum_id + * @return array|stdClass + */ + public function deleteAzr($anrechnungszeitraum_id) + { + $result = $this->delete(array('anrechnungszeitraum_id' => $anrechnungszeitraum_id)); + + if (isError($result)) + { + return error('Fehler bei Anrechnungszeitraum löschen.'); + } + + return success($result->retval); + } + + /** + * Update existing Anrechnungszeitraum. + * + * @param $anrechnungszeitraum_id + * @param $studiensemester_kurzbz + * @param $anrechnungstart + * @param $anrechnungende + * @return array|stdClass + */ + public function updateAzr($anrechnungszeitraum_id, $studiensemester_kurzbz, $anrechnungstart, $anrechnungende) + { + $result = $this->update( + $anrechnungszeitraum_id, + array( + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'anrechnungstart' => $anrechnungstart, + 'anrechnungende' => $anrechnungende + ) + ); + + if (isError($result)) + { + return error('Fehler bei Anrechnungszeitraum update.'); + } + + return success($result->retval); + } + +} diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index f54443955..1f1b90131 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -200,6 +200,28 @@ class Lehrveranstaltung_model extends DB_Model return $this->execQuery($query, array($lehrveranstaltung_id, $studiensemester_kurzbz)); } + /** + * Gets all Leiter of Lehrveranstaltungsorganisationseinheit + * @param $lehrveranstaltung_id + * @return array|null + */ + public function getLeitungOfLvOe($lehrveranstaltung_id) + { + $query = "select distinct vorname, nachname, uid + FROM + lehre.tbl_lehrveranstaltung lv + JOIN public.tbl_organisationseinheit og using (oe_kurzbz) + JOIN public.tbl_benutzerfunktion bf using (oe_kurzbz) + join public.tbl_benutzer b using (uid) + join public.tbl_person p using (person_id) + where + bf.datum_von <= now()::date + and (bf.datum_bis >= now()::date or bf.datum_bis is null) + and bf.funktion_kurzbz = 'Leitung' -- Leitung of LV-OE + and lehrveranstaltung_id = ?"; + + return $this->execQuery($query, array($lehrveranstaltung_id)); + } /** * Gets Lehrveranstaltungen of a student diff --git a/application/models/education/Paabgabe_model.php b/application/models/education/Paabgabe_model.php index 087c27663..b876030a6 100644 --- a/application/models/education/Paabgabe_model.php +++ b/application/models/education/Paabgabe_model.php @@ -1,7 +1,6 @@ dbTable = 'campus.tbl_paabgabe'; $this->pk = 'paabgabe_id'; } + + /** + * Gets last Endabgabe of a Projektarbeit, including filename. + * @param int $projektarbeit_id + * @return object + */ + public function getEndabgabe($projektarbeit_id) + { + $qry = "SELECT paabgabe_id, student_uid, paabg.datum, paabg.abgabedatum, projekttyp_kurzbz, titel, titel_english, + paabgabe_id || '_' || student_uid || '.pdf' AS filename + FROM campus.tbl_paabgabe paabg + JOIN lehre.tbl_projektarbeit USING (projektarbeit_id) + WHERE projektarbeit_id = ? + AND paabgabetyp_kurzbz = 'end' + AND paabg.abgabedatum IS NOT NULL + ORDER BY paabg.abgabedatum, paabg.datum DESC + LIMIT 1"; + + return $this->execQuery($qry, array($projektarbeit_id)); + } } diff --git a/application/models/education/Projektbetreuer_model.php b/application/models/education/Projektbetreuer_model.php index 0200f6468..95950bf95 100644 --- a/application/models/education/Projektbetreuer_model.php +++ b/application/models/education/Projektbetreuer_model.php @@ -54,18 +54,28 @@ class Projektbetreuer_model extends DB_Model $qry = "SELECT DISTINCT ON (pers.person_id) pers.person_id, betreuerart_kurzbz, vorname, nachname, trim(COALESCE(titelpre,'')||' '||COALESCE(vorname,'')||' '||COALESCE(nachname,'')||' '||COALESCE(titelpost,'')) as voller_name, anrede, titelpre, titelpost, gebdatum, geschlecht, pa.projekttyp_kurzbz, - ben.uid, ben.alias, ma.personalnummer, mitarbeiter_uid, student_uid - FROM lehre.tbl_projektarbeit pa - JOIN lehre.tbl_projektbetreuer USING (projektarbeit_id) - JOIN public.tbl_person pers USING (person_id) - LEFT JOIN public.tbl_benutzer ben USING (person_id) - LEFT JOIN public.tbl_mitarbeiter ma ON ben.uid = ma.mitarbeiter_uid - WHERE ben.aktiv - AND projektarbeit_id = ? - AND betreuerart_kurzbz = ? - ORDER BY pers.person_id, CASE WHEN ma.mitarbeiter_uid IS NULL THEN 1 ELSE 0 END, /*Mitarbeiter account first*/ - CASE WHEN ben.uid IS NULL THEN 1 ELSE 0 END, /*user with account first*/ - ben.insertamum"; + ben.uid, ben.alias, ma.personalnummer, mitarbeiter_uid, student_uid, + ( + SELECT kontakt + FROM public.tbl_kontakt + WHERE kontakttyp = 'email' + AND person_id = pers.person_id + ORDER BY + CASE WHEN zustellung THEN 0 ELSE 1 END, + insertamum DESC NULLS LAST + LIMIT 1 + ) AS private_email + FROM lehre.tbl_projektarbeit pa + JOIN lehre.tbl_projektbetreuer USING (projektarbeit_id) + JOIN public.tbl_person pers USING (person_id) + LEFT JOIN public.tbl_benutzer ben USING (person_id) + LEFT JOIN public.tbl_mitarbeiter ma ON ben.uid = ma.mitarbeiter_uid + WHERE (ben.aktiv OR ben.aktiv IS NULL) + AND projektarbeit_id = ? + AND betreuerart_kurzbz = ? + ORDER BY pers.person_id, CASE WHEN ma.mitarbeiter_uid IS NULL THEN 1 ELSE 0 END, /*Mitarbeiter account first*/ + CASE WHEN ben.uid IS NULL THEN 1 ELSE 0 END, /*user with account first*/ + ben.insertamum"; return $this->execQuery($qry, array($projektarbeit_id, $betreuerart_kurzbz)); } @@ -77,14 +87,14 @@ class Projektbetreuer_model extends DB_Model */ public function getBetreuerByToken($zugangstoken) { - $qry = ' + $qry = " SELECT tbl_projektbetreuer.person_id, tbl_projektbetreuer.projektarbeit_id, student_uid FROM lehre.tbl_projektbetreuer JOIN lehre.tbl_projektarbeit USING (projektarbeit_id) WHERE zugangstoken = ? AND zugangstoken_gueltigbis >= NOW() ORDER BY tbl_projektbetreuer.insertamum DESC, projektarbeit_id DESC LIMIT 1 - '; + "; return $this->execQuery($qry, array($zugangstoken)); } @@ -96,31 +106,60 @@ class Projektbetreuer_model extends DB_Model * @param $student_uid string uid des Studenten der Arbeit abgibt * @return object | bool */ - public function getZweitbegutachterWithToken($erstbegutachter_person_id, $projektarbeit_id, $student_uid) + public function getZweitbegutachterWithToken($erstbegutachter_person_id, $projektarbeit_id, $student_uid, $zweitbegutachter_person_id = null) { - $qry_betr = "SELECT betr.person_id, betr.projektarbeit_id, pers.anrede, betr.zugangstoken, betr.zugangstoken_gueltigbis, tbl_benutzer.uid, kontakt, - trim(COALESCE(titelpre,'')||' '||COALESCE(vorname,'')||' '||COALESCE(nachname,'')||' '||COALESCE(titelpost,'')) as voller_name, - CASE WHEN tbl_benutzer.uid IS NULL THEN kontakt ELSE tbl_benutzer.uid || '@".DOMAIN."' END AS email, abg.abgabedatum - FROM lehre.tbl_projektbetreuer betr - JOIN lehre.tbl_projektarbeit parb ON betr.projektarbeit_id = parb.projektarbeit_id - JOIN public.tbl_person pers ON betr.person_id = pers.person_id - LEFT JOIN public.tbl_kontakt ON pers.person_id = tbl_kontakt.person_id AND kontakttyp = 'email' AND zustellung = true - LEFT JOIN public.tbl_benutzer ON pers.person_id = tbl_benutzer.person_id - LEFT JOIN campus.tbl_paabgabe abg ON betr.projektarbeit_id = abg.projektarbeit_id AND abg.paabgabetyp_kurzbz = 'end' - WHERE betr.betreuerart_kurzbz = 'Zweitbegutachter' - AND betr.projektarbeit_id = ? - AND parb.student_uid = ? - AND EXISTS ( - SELECT 1 FROM lehre.tbl_projektbetreuer - WHERE person_id = ? - AND betreuerart_kurzbz = 'Erstbegutachter' - AND projektarbeit_id = betr.projektarbeit_id - ) - AND (tbl_benutzer.aktiv OR tbl_benutzer.aktiv IS NULL) - ORDER BY betr.insertamum DESC - LIMIT 1"; + $params = array($erstbegutachter_person_id, $erstbegutachter_person_id, $projektarbeit_id, $student_uid); - return $this->execQuery($qry_betr, array($projektarbeit_id, $student_uid, $erstbegutachter_person_id)); + $qry_betr = "SELECT betr.person_id, betr.projektarbeit_id, pers.anrede, betr.zugangstoken, betr.zugangstoken_gueltigbis, tbl_benutzer.uid, + trim(COALESCE(titelpre,'')||' '||COALESCE(vorname,'')||' '||COALESCE(nachname,'')||' '||COALESCE(titelpost,'')) as voller_name, + CASE WHEN tbl_benutzer.uid IS NULL THEN kontakt ELSE tbl_benutzer.uid || '@".DOMAIN."' END AS email, kontakt, + abg.abgabedatum, betr.betreuerart_kurzbz + FROM lehre.tbl_projektbetreuer betr + JOIN lehre.tbl_projektarbeit parb ON betr.projektarbeit_id = parb.projektarbeit_id + JOIN public.tbl_person pers ON betr.person_id = pers.person_id + LEFT JOIN public.tbl_kontakt ON pers.person_id = tbl_kontakt.person_id AND kontakttyp = 'email' AND zustellung = true + LEFT JOIN public.tbl_benutzer ON pers.person_id = tbl_benutzer.person_id + LEFT JOIN campus.tbl_paabgabe abg ON betr.projektarbeit_id = abg.projektarbeit_id AND abg.paabgabetyp_kurzbz = 'end' + WHERE + ( + ( + betr.betreuerart_kurzbz = 'Zweitbegutachter' + AND EXISTS ( + SELECT 1 FROM lehre.tbl_projektbetreuer + WHERE person_id = ? + AND betreuerart_kurzbz = 'Erstbegutachter' + AND projektarbeit_id = betr.projektarbeit_id + ) + ) + OR /* either Zweitbegutachter of masterarbeit, or Kommissionsprüfer if Kommission */ + ( + betr.betreuerart_kurzbz = 'Senatsmitglied' + AND EXISTS ( + SELECT 1 FROM lehre.tbl_projektbetreuer + WHERE person_id = ? + AND betreuerart_kurzbz = 'Senatsvorsitz' + AND projektarbeit_id = betr.projektarbeit_id + ) + ) + ) + AND betr.projektarbeit_id = ? + AND parb.student_uid = ? + AND (tbl_benutzer.aktiv OR tbl_benutzer.aktiv IS NULL)"; + + if (isset($zweitbegutachter_person_id)) + { + $qry_betr .= " AND betr.person_id = ?"; + $params[] = $zweitbegutachter_person_id; + } + + $qry_betr .= " ORDER BY betr.person_id DESC, + (CASE WHEN EXISTS ( /* if multiple accounts, prioritize mitarbeiter */ + SELECT 1 FROM public.tbl_mitarbeiter ma + WHERE ma.mitarbeiter_uid = tbl_benutzer.uid + ) THEN 0 ELSE 1 END), betr.insertamum DESC + LIMIT 1"; + + return $this->execQuery($qry_betr, $params); } /** @@ -131,23 +170,23 @@ class Projektbetreuer_model extends DB_Model */ public function generateZweitbegutachterToken($zweitbegutachter_person_id, $projektarbeit_id) { - $betreuerUidQry = "SELECT uid, zugangstoken, zugangstoken_gueltigbis, tbl_projektbetreuer.person_id + $betreuerUidQry = "SELECT uid, zugangstoken, zugangstoken_gueltigbis, tbl_projektbetreuer.person_id, betreuerart_kurzbz FROM lehre.tbl_projektbetreuer JOIN public.tbl_person USING(person_id) LEFT JOIN public.tbl_benutzer USING(person_id) WHERE projektarbeit_id = ? AND tbl_projektbetreuer.person_id = ? - AND betreuerart_kurzbz = 'Zweitbegutachter' + AND betreuerart_kurzbz IN ('Zweitbegutachter', 'Senatsmitglied') LIMIT 1"; - $betreueruidres = $this->execQuery($betreuerUidQry, array($projektarbeit_id, $zweitbegutachter_person_id)); + $betreueruidRes = $this->execQuery($betreuerUidQry, array($projektarbeit_id, $zweitbegutachter_person_id)); - if (!hasData($betreueruidres)) + if (!hasData($betreueruidRes)) return error('Zweitbegutachter nicht gefunden'); - $row_betr = getData($betreueruidres)[0]; + $zweitbetreuer = getData($betreueruidRes)[0]; - if (!isset($row_betr->uid)) + if (!isset($zweitbetreuer->uid)) { do { $token = generateToken(16); @@ -156,8 +195,8 @@ class Projektbetreuer_model extends DB_Model $result = $this->update( array('projektarbeit_id' => $projektarbeit_id, - 'person_id' => $row_betr->person_id, - 'betreuerart_kurzbz' => 'Zweitbegutachter'), + 'person_id' => $zweitbetreuer->person_id, + 'betreuerart_kurzbz' => $zweitbetreuer->betreuerart_kurzbz), array('zugangstoken' => $token, 'zugangstoken_gueltigbis' => date('Y-m-d', strtotime('+1 year'))) ); @@ -167,4 +206,29 @@ class Projektbetreuer_model extends DB_Model else return success("Account vorhanden, kein Token benötigt"); } + + /** + * Gets betreuerart of a Betreuer for a Projektarbeit. + * Main Betreuer are prioritized (normally one Betreuer should be assigned to a Projektarbeit another time with a different Betreuerart). + * @param int projektarbeit_id + * @param int betreuer_person_id + * @return object success or error + */ + public function getBetreuerart($projektarbeit_id, $betreuer_person_id) + { + $qry = "SELECT betreuerart_kurzbz + FROM lehre.tbl_projektbetreuer + WHERE projektarbeit_id = ? + AND person_id = ? + ORDER BY CASE WHEN betreuerart_kurzbz = 'Senatsvorsitz' THEN 1 /*Senatsvorsitz has priority*/ + WHEN betreuerart_kurzbz = 'Begutachter' THEN 2 + WHEN betreuerart_kurzbz = 'Erstbegutachter' THEN 3 + WHEN betreuerart_kurzbz = 'Zweitbegutachter' THEN 4 + WHEN betreuerart_kurzbz = 'Senatsmitglied' THEN 5 + ELSE 5 + END, insertamum DESC + LIMIT 1"; + + return $this->execQuery($qry, array($projektarbeit_id, $betreuer_person_id)); + } } diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index cf99099fe..c326f23ad 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -88,7 +88,7 @@ class Person_model extends DB_Model if (isset($person['svnr']) && $person['svnr'] != '') { $this->PersonModel->addOrder('svnr', 'DESC'); - $result = $this->PersonModel->loadWhere(array( + $result = $this->PersonModel->loadWhere(array( 'person_id != ' => $person['person_id'], 'SUBSTRING(svnr FROM 1 FOR 10) = ' => $person['svnr']) ); @@ -156,7 +156,8 @@ class Person_model extends DB_Model 'lower(nachname) like '.$this->db->escape('%'.$filter.'%')." OR lower(vorname) like ".$this->db->escape('%'.$filter.'%')." OR lower(nachname || ' ' || vorname) like ".$this->db->escape('%'.$filter.'%')." - OR lower(vorname || ' ' || nachname) like ".$this->db->escape('%'.$filter.'%')); + OR lower(vorname || ' ' || nachname) like ".$this->db->escape('%'.$filter.'%') + ); return $result; } @@ -170,8 +171,12 @@ class Person_model extends DB_Model */ public function getPersonStammdaten($person_id, $zustellung_only = false) { - $this->addSelect('public.tbl_person.*, tbl_person.staatsbuergerschaft AS staatsbuergerschaft_code, tbl_person.geburtsnation AS geburtsnation_code, - s.kurztext as staatsbuergerschaft, g.kurztext as geburtsnation'); + $this->addSelect('public.tbl_person.*, + tbl_person.staatsbuergerschaft AS staatsbuergerschaft_code, + tbl_person.geburtsnation AS geburtsnation_code, + s.kurztext as staatsbuergerschaft, + g.kurztext as geburtsnation' + ); $this->addJoin('bis.tbl_nation s', 'public.tbl_person.staatsbuergerschaft = s.nation_code', 'LEFT'); $this->addJoin('bis.tbl_nation g', 'public.tbl_person.geburtsnation = g.nation_code', 'LEFT'); @@ -276,7 +281,8 @@ class Person_model extends DB_Model */ public function getFullName($uid) { - if (!$result = getData($this->getByUid($uid))[0]) + $result = getData($this->getByUid($uid))[0]; + if (!$result) { show_error('Failed loading person'); } diff --git a/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php b/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php index 3c43a6fb1..5544aa6d9 100644 --- a/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php +++ b/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php @@ -27,6 +27,8 @@ class Dienstverhaeltnis_model extends DB_Model tbl_mitarbeiter.fixangestellt, tbl_person.person_id, tbl_benutzer.alias, + org.oe_kurzbz, + org.bezeichnung oe_bezeichnung, dv.von, dv.bis, dv.vertragsart_kurzbz, @@ -36,6 +38,7 @@ class Dienstverhaeltnis_model extends DB_Model JOIN tbl_benutzer ON tbl_mitarbeiter.mitarbeiter_uid::text = tbl_benutzer.uid::text JOIN tbl_person USING (person_id) JOIN hr.tbl_dienstverhaeltnis dv ON(tbl_benutzer.uid::text = dv.mitarbeiter_uid::text) + JOIN public.tbl_organisationseinheit org USING(oe_kurzbz) WHERE tbl_benutzer.uid=? ORDER BY dv.von desc "; @@ -45,8 +48,12 @@ class Dienstverhaeltnis_model extends DB_Model } - public function getCurrentDVByPersonUID($uid) + public function getCurrentDVByPersonUID($uid, $dateAsUnixTS) { + + $date = DateTime::createFromFormat( 'U', $dateAsUnixTS ); + $datestring = $date->format("Y-m-d"); + $qry = " SELECT dv.dienstverhaeltnis_id, @@ -58,19 +65,45 @@ class Dienstverhaeltnis_model extends DB_Model tbl_person.person_id, tbl_benutzer.alias, dv.von, - dv.bis, - dv.vertragsart_kurzbz, + dv.bis, + dv.vertragsart_kurzbz, dv.updateamum, dv.updatevon FROM tbl_mitarbeiter JOIN tbl_benutzer ON tbl_mitarbeiter.mitarbeiter_uid::text = tbl_benutzer.uid::text JOIN tbl_person USING (person_id) JOIN hr.tbl_dienstverhaeltnis dv ON(tbl_benutzer.uid::text = dv.mitarbeiter_uid::text) - WHERE tbl_benutzer.uid=? and (dv.von<=CURRENT_DATE::text::date and (dv.bis is null OR dv.bis>=CURRENT_DATE::text::date)) + WHERE tbl_benutzer.uid=? and (dv.von<=? and (dv.bis is null OR dv.bis>=?)) ORDER BY dv.von desc "; - return $this->execQuery($qry, array($uid)); + return $this->execQuery($qry, array($uid, $datestring, $datestring)); } + public function isOverlappingExistingDV($mitarbeiter_uid, $oe_kurzbz, $von, $bis) + { + $query = <<= dv.von +EOSQL; + + $ret = $this->execReadOnlyQuery($query, + array($mitarbeiter_uid, $oe_kurzbz, $von, $bis)); + + if( ($dvcount = getData($ret)) && ($dvcount[0]->dvcount > 0) ) { + return true; + } + + return false; + } } \ No newline at end of file diff --git a/application/models/vertragsbestandteil/Gehaltsbestandteil_model.php b/application/models/vertragsbestandteil/Gehaltsbestandteil_model.php index fce950012..8236867ba 100644 --- a/application/models/vertragsbestandteil/Gehaltsbestandteil_model.php +++ b/application/models/vertragsbestandteil/Gehaltsbestandteil_model.php @@ -1,7 +1,8 @@ 'ENCRYPTIONKEY', 'betrag_valorisiert' => 'ENCRYPTIONKEY']; + return array( + 'grundbetrag' => array( + DB_Model::CRYPT_CAST => 'numeric', + DB_Model::CRYPT_PASSWORD_NAME => 'ENCRYPTIONKEY' + ), + 'betrag_valorisiert' => array( + DB_Model::CRYPT_CAST => 'numeric', + DB_Model::CRYPT_PASSWORD_NAME => 'ENCRYPTIONKEY' + ) + ); } public function getCurrentGBTByDV($dienstverhaeltnis_id) - { + {/* $qry = " SELECT gehaltsbestandteil_id, @@ -28,18 +38,90 @@ class Gehaltsbestandteil_model extends DB_Model implements IEncryption dienstverhaeltnis_id, gehaltstyp_kurzbz, valorisierungssperre, - valorisieren, - grundbetrag, - betrag_valorisiert, + gbt.valorisierung, + grundbetrag as grund_betrag_decrypted, + betrag_valorisiert as betrag_val_decrypted, gt.bezeichnung as gehaltstyp_bezeichnung FROM hr.tbl_gehaltsbestandteil gbt JOIN hr.tbl_gehaltstyp gt using(gehaltstyp_kurzbz) WHERE gbt.dienstverhaeltnis_id=? AND (gbt.von<=CURRENT_DATE::text::date and (gbt.bis is null OR gbt.bis>=CURRENT_DATE::text::date)) ORDER BY gt.sort + "; */ + + $qry = " + SELECT + gehaltsbestandteil_id, + von, + bis, + anmerkung, + dienstverhaeltnis_id, + gehaltstyp_kurzbz, + valorisierungssperre, + gbt.valorisierung, + grundbetrag as grund_betrag_decrypted, + betrag_valorisiert as betrag_val_decrypted, + gt.bezeichnung as gehaltstyp_bezeichnung + FROM hr.tbl_gehaltsbestandteil gbt JOIN hr.tbl_gehaltstyp gt using(gehaltstyp_kurzbz) + WHERE gbt.dienstverhaeltnis_id=? + ORDER BY gt.sort "; return $this->execQuery($qry, array($dienstverhaeltnis_id), $this->getEncryptedColumns()); - } + + public function getGehaltsbestandteile($dienstverhaeltnis_id=1, $stichtag=null) + { + $stichtagclause = ''; + if( !is_null($stichtag) ) + { + $date = strftime('%Y-%m-%d', strtotime($stichtag)); + $stichtagclause = 'AND ' . $this->escape($date) + . ' BETWEEN COALESCE(v.von, \'1970-01-01\'::date)' + . ' AND COALESCE(v.bis, \'2170-01-01\'::date)'; + } -} \ No newline at end of file + $sql = <<execReadOnlyQuery( + $query, + array($dienstverhaeltnis_id), + $this->getEncryptedColumns() + ); + + $gehaltsbestandteile = array(); + if( null !== ($rows = getData($query)) ) + { + foreach( $rows as $row ) { + $tmpgb = new Gehaltsbestandteil(); + $tmpgb->hydrateByStdClass($row); + $gehaltsbestandteile[] = $tmpgb; + } + } + + return $gehaltsbestandteile; + } + + + public function getGehaltsbestandteil($id) + { + $query = $this->load($id, $this->getEncryptedColumns()); + $gehaltsbestandteil = null; + + if( null !== ($row = getData($query)) ) + { + $gehaltsbestandteil = new Gehaltsbestandteil(); + $gehaltsbestandteil->hydrateByStdClass($row[0]); + } + + return $gehaltsbestandteil; + } +} diff --git a/application/models/vertragsbestandteil/VertragsbestandteilBefristung_model.php b/application/models/vertragsbestandteil/VertragsbestandteilBefristung_model.php deleted file mode 100644 index 9166b1c06..000000000 --- a/application/models/vertragsbestandteil/VertragsbestandteilBefristung_model.php +++ /dev/null @@ -1,14 +0,0 @@ -dbTable = 'hr.tbl_vertragsbestandteil_befristung'; - $this->pk = 'vertragsbestandteil_id'; - } -} diff --git a/application/models/vertragsbestandteil/VertragsbestandteilFreitext_model.php b/application/models/vertragsbestandteil/VertragsbestandteilFreitext_model.php index d47ce53df..7da091f11 100644 --- a/application/models/vertragsbestandteil/VertragsbestandteilFreitext_model.php +++ b/application/models/vertragsbestandteil/VertragsbestandteilFreitext_model.php @@ -1,6 +1,6 @@ dbTable = 'hr.tbl_vertragsbestandteil_kv'; - $this->pk = 'vertragsbestandteil_id'; - } -} diff --git a/application/models/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung_model.php b/application/models/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung_model.php index 89ae0ba0a..8e2d45e1a 100644 --- a/application/models/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung_model.php +++ b/application/models/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung_model.php @@ -1,6 +1,6 @@ pk = 'vertragsbestandteil_id'; } + protected function getVertragsbestandteilSQL() + { + $sql = <<getVertragsbestandteilSQL()} WHERE v.dienstverhaeltnis_id = {$this->escape($dienstverhaeltnis_id)} {$stichtagclause} @@ -53,10 +79,16 @@ class Vertragsbestandteil_model extends DB_Model EOSQL; // echo $sql . "\n\n"; - $query = $this->db->query($sql); // TODO add decryption + $query = $this->execReadOnlyQuery($sql); // TODO add decryption + $data = getData($query); + + if ($data == null) + { + return array(); + } $vertragsbestandteile = array(); - foreach( $query->result() as $row ) { + foreach( $data as $row ) { try { $vertragsbestandteile[] = VertragsbestandteilFactory::getVertragsbestandteil($row); @@ -67,6 +99,7 @@ EOSQL; } } + $dummy = json_encode($vertragsbestandteile); return $vertragsbestandteile; } @@ -75,23 +108,7 @@ EOSQL; { $sql = <<getVertragsbestandteilSQL()} WHERE v.vertragsbestandteil_id = {$this->escape($id)} ; diff --git a/application/views/lehre/anrechnung/adminAnrechnung.php b/application/views/lehre/anrechnung/adminAnrechnung.php new file mode 100644 index 000000000..cb9a55c18 --- /dev/null +++ b/application/views/lehre/anrechnung/adminAnrechnung.php @@ -0,0 +1,137 @@ + $this->p->t('anrechnung', 'anrechnungenVerwalten'), + 'jquery3' => true, + 'jqueryui1' => true, + 'bootstrap3' => true, + 'fontawesome6' => true, + 'ajaxlib' => true, + 'dialoglib' => true, + 'tabulator4' => true, + 'tablewidget' => true, + 'sbadmintemplate3' => true, + 'navigationwidget' => true, + 'phrases' => array( + 'anrechnung' => array( + 'anrechnungenVerwalten', + 'anrechnungszeitraumFestlegen', + 'anrechnungszeitraumHinzufuegen', + 'anrechnungszeitraumSpeichern', + 'anrechnungszeitraumStart', + 'anrechnungszeitraumEnde' + ), + 'ui' => array( + 'aktion', + 'geloescht', + 'gespeichert', + 'frageSicherLoeschen', + 'spaltenEinstellen' + ), + 'lehre' => array('studiensemester'), + 'table' => array( + 'spaltenEinAusblenden', + 'spaltenEinAusblendenMitKlickOeffnen', + 'spaltenEinAusblendenAufEinstellungenKlicken', + 'spaltenEinAusblendenMitKlickAktivieren', + 'spaltenEinAusblendenMitKlickSchliessen', + 'spaltenbreiteVeraendern', + 'spaltenbreiteVeraendernText', + 'spaltenbreiteVeraendernInfotext', + 'zeilenAuswaehlen', + 'zeilenAuswaehlenEinzeln', + 'zeilenAuswaehlenBereich', + 'zeilenAuswaehlenAlle' + ) + ), + 'customJSs' => array( + 'public/js/bootstrapper.js', + 'public/js/lehre/anrechnung/adminAnrechnung.js' + ), + 'customCSSs' => array( + 'public/css/sbadmin2/tablesort_bootstrap.css' + ) +); + +$this->load->view('templates/FHC-Header', $includesArray); +?> + + + + widgetlib->widget('NavigationWidget'); ?> + + + + + + + p->t('anrechnung', 'anrechnungenVerwalten'); ?> + + + + p->t('anrechnung', 'anrechnungszeitraumFestlegen'); ?> + + + + + p->t('anrechnung', 'anrechnungszeitraumHinzufuegen'); ?> + + + + + + + + load->view('lehre/anrechnung/adminAnrechnungData.php'); ?> + + + + + + + + + + × + + + + + + + Studiensemester + widgetlib->widget( + 'Studiensemester_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $studiensemester_kurzbz + ), + array( + 'name' => 'studiensemester', + 'id' => 'studiensemester' + ) + ); + ?> + + + Anr.-Zeitraum Start + + + + Anr.-Zeitraum Ende + + + + + + + + + + + + + +load->view('templates/FHC-Footer', $includesArray); ?> + diff --git a/application/views/lehre/anrechnung/adminAnrechnungData.php b/application/views/lehre/anrechnung/adminAnrechnungData.php new file mode 100644 index 000000000..652c349d8 --- /dev/null +++ b/application/views/lehre/anrechnung/adminAnrechnungData.php @@ -0,0 +1,45 @@ + $query, + 'tableUniqueId' => 'adminAnrechnung', + 'requiredPermissions' => 'lehre/anrechnungszeitfenster', + 'datasetRepresentation' => 'tabulator', + 'columnsAliases' => array( + 'AzrID', + ucfirst($this->p->t('lehre', 'studiensemester')), + ucfirst($this->p->t('anrechnung', 'anrechnungszeitraumStart')), + ucfirst($this->p->t('anrechnung', 'anrechnungszeitraumEnde')), + ucfirst($this->p->t('ui', 'bearbeitetAm')), + ucfirst($this->p->t('ui', 'bearbeitetVon')), + ), + 'datasetRepOptions' => '{ + height: func_height(this), + layout: "fitDataFill", + persistentLayout:true, + autoResize: false, // prevent auto resizing of table (false to allow adapting table size when cols are (de-)activated + headerFilterPlaceholder: " ", + index: "anrechnungszeitraum_id", // assign specific column as unique id (important for row indexing) + selectable: false, // allow row selection + tableWidgetHeader: true, + tableBuilt: function(){ + func_tableBuilt(this); + }, + }', + 'datasetRepFieldsDefs' => '{ + anrechnungszeitraum_id: {visible: false, headerFilter:"input"}, + studiensemester_kurzbz: {headerFilter:"input"}, + anrechnungstart: {headerFilter:"input", formatter: formatDate}, + anrechnungende: {headerFilter:"input", formatter: formatDate}, + insertamum: {visible: false, headerFilter:"input"}, + insertvon: {visible: false, headerFilter:"input"} + }' +); + +echo $this->widgetlib->widget('TableWidget', $filterWidgetArray); \ No newline at end of file diff --git a/application/views/lehre/anrechnung/approveAnrechnungDetail.php b/application/views/lehre/anrechnung/approveAnrechnungDetail.php index bc3b6215a..87b9d53cc 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungDetail.php +++ b/application/views/lehre/anrechnung/approveAnrechnungDetail.php @@ -23,6 +23,7 @@ $this->load->view( 'systemfehler', 'bitteMindEinenAntragWaehlen', 'bitteBegruendungAngeben', + 'bitteBegruendungVervollstaendigen', 'empfehlungWurdeAngefordert', 'anrechnungenWurdenGenehmigt', 'anrechnungenWurdenAbgelehnt', @@ -322,14 +323,6 @@ $this->load->view( - - p->t('anrechnung', 'genehmigungNegativKenntnisseNichtGleichwertig'); ?> - - - - p->t('anrechnung', 'genehmigungNegativEctsHoechstgrenzeUeberschritten'); ?> load->view( + + p->t('anrechnung', 'genehmigungNegativKenntnisseNichtGleichwertigWeil'); ?> + + + + p->t('anrechnung', 'genehmigungNegativEmpfehlungstextUebernehmen'); ?> load->view( + + p->t('anrechnung', 'andereBegruendung'); ?> + load->view( - load->view('lehre/anrechnung/approveAnrechnungUebersichtData.php'); ?> + load->view('lehre/anrechnung/approveAnrechnungUebersichtData.php'); ?> @@ -145,18 +145,13 @@ $this->load->view( - p->t('anrechnung', 'genehmigungNegativKenntnisseNichtGleichwertig'); ?> - - - - p->t('anrechnung', 'genehmigungNegativEctsHoechstgrenzeUeberschritten'); ?> + p->t('anrechnung', 'genehmigungNegativKenntnisseNichtGleichwertigWeilHinweis'); ?> >' . $LANGUAGE_INDEX . ', - array_to_json(zgv.bezeichnung::varchar[])->>' . $LANGUAGE_INDEX . ' + zgvmaster.bezeichnung[' . $LANGUAGE_INDEX . '], + zgv.bezeichnung[' . $LANGUAGE_INDEX . '] ) AS zgv FROM public.tbl_prestudent LEFT JOIN bis.tbl_zgv zgv USING (zgv_code) @@ -71,6 +76,7 @@ $query = ' anrechnungen.lehrveranstaltung_id, anrechnungen.begruendung_id, anrechnungen.dms_id, + anrechnungen.schreibberechtigt, anrechnungen.studiensemester_kurzbz, anrechnungen.studiengang_kz, anrechnungen.stg_bezeichnung, @@ -89,7 +95,7 @@ $query = ' anrechnungen.antragsdatum, anrechnungen.empfehlung_anrechnung, anrechnungen.status_kurzbz, - array_to_json(anrechnungstatus.bezeichnung_mehrsprachig::varchar[])->>' . $LANGUAGE_INDEX . ' AS "status_bezeichnung", + anrechnungstatus.bezeichnung_mehrsprachig[' . $LANGUAGE_INDEX . '] AS "status_bezeichnung", anrechnungen.prestudent_id, CASE WHEN (anrechnungen.empfehlung_anrechnung IS NULL AND anrechnungen.status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_STGL . '\') THEN NULL @@ -101,8 +107,39 @@ $query = ' AND status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR . '\' ORDER BY insertamum DESC LIMIT 1) - END "empfehlungsanfrageAm", - CASE + END "empfehlungsanfrageAm",'; + +if ($configFachbereichsleitung === TRUE) +{ + $query.= ' CASE + WHEN (anrechnungen.empfehlung_anrechnung IS NULL AND anrechnungen.status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_STGL . '\') THEN NULL + ELSE + (SELECT COALESCE( + STRING_AGG(CONCAT_WS(\' \', vorname, nachname), \', \') + ) empfehlungsanfrageAn + FROM ( + SELECT DISTINCT ON (benutzer.uid) bf.uid, vorname, nachname + FROM lehre.tbl_lehreinheit + JOIN lehre.tbl_lehrveranstaltung lv using (lehrveranstaltung_id) + JOIN public.tbl_organisationseinheit og using (oe_kurzbz) + JOIN public.tbl_benutzerfunktion bf using (oe_kurzbz) + JOIN public.tbl_benutzer benutzer ON bf.uid = benutzer.uid + JOIN public.tbl_person USING (person_id) + WHERE studiensemester_kurzbz = \'' . $STUDIENSEMESTER . '\' + and bf.datum_von <= now() + and (bf.datum_bis >= now() or bf.datum_bis is null) + AND bf.funktion_kurzbz = \'Leitung\' + AND lehrveranstaltung_id = anrechnungen.lehrveranstaltung_id + AND benutzer.aktiv = TRUE + AND tbl_person.aktiv = TRUE + ORDER BY benutzer.uid, nachname, vorname + ) as tmp_empfehlungsanfrageEmpfaenger + ) + END "empfehlungsanfrageAn"'; +} +else +{ + $query.= ' CASE WHEN (anrechnungen.empfehlung_anrechnung IS NULL AND anrechnungen.status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_STGL . '\') THEN NULL ELSE (SELECT COALESCE( @@ -122,10 +159,12 @@ $query = ' AND benutzer.aktiv = TRUE AND tbl_person.aktiv = TRUE ORDER BY benutzer.uid, lvleiter DESC, nachname, vorname - ) as tmp_lvlektoren + ) as tmp_empfehlungsanfrageEmpfaenger ) - END "empfehlungsanfrageAn" - FROM anrechnungen + END "empfehlungsanfrageAn"'; +} + +$query.= ' FROM anrechnungen JOIN lehre.tbl_anrechnungstatus as anrechnungstatus ON (anrechnungstatus.status_kurzbz = anrechnungen.status_kurzbz) WHERE studiensemester_kurzbz = \'' . $STUDIENSEMESTER . '\' AND studiengang_kz IN (' . $STUDIENGAENGE_ENTITLED . ') @@ -141,6 +180,7 @@ $filterWidgetArray = array( 'lehrveranstaltung_id', 'begruendung_id', 'dms_id', + 'Schreibberechtigt', 'studiensemester_kurzbz', 'studiengang_kz', ucfirst($this->p->t('lehre', 'studiengang')), @@ -167,9 +207,7 @@ $filterWidgetArray = array( 'datasetRepOptions' => '{ height: func_height(this), layout: "fitColumns", // fit columns to width of table - persistentLayout:true, - persistentSort:true, - persistentFilter:true, + persistenceID: "approveAnrechnungUebersicht_V1", autoResize: false, // prevent auto resizing of table (false to allow adapting table size when cols are (de-)activated headerFilterPlaceholder: " ", index: "anrechnung_id", // assign specific column as unique id (important for row indexing) @@ -200,6 +238,10 @@ $filterWidgetArray = array( lehrveranstaltung_id: {visible: false, headerFilter:"input"}, begruendung_id: {visible: false, headerFilter:"input"}, dms_id: {visible: false, headerFilter:"input"}, + schreibberechtigt: { + formatter:"tickCross", align:"center", + headerFilter:"tickCross", headerFilterParams:{tristate: true}, headerFilterFunc: hf_schreibberechtigt + }, studiensemester_kurzbz: {visible: false, headerFilter:"input"}, studiengang_kz: {visible: false, headerFilter:"input"}, stg_bezeichnung: {headerFilter:"input"}, @@ -212,7 +254,7 @@ $filterWidgetArray = array( ectsSumBeruflich: {visible: false, headerFilter:"input", align:"right"}, begruendung: {headerFilter:"input", visible: true}, student: {headerFilter:"input"}, - zgv: {visible: false, headerFilter:"input"}, + zgv: {headerFilter:"input"}, dokument_bezeichnung: {headerFilter:"input", formatter:"link", formatterParams: paramLookup_dokBez}, anmerkung_student: {headerFilter:"input"}, antragsdatum: {align:"center", headerFilter:"input", mutator: mut_formatStringDate}, diff --git a/application/views/lehre/anrechnung/createAnrechnungData.php b/application/views/lehre/anrechnung/createAnrechnungData.php index 643c64626..c09d8926c 100644 --- a/application/views/lehre/anrechnung/createAnrechnungData.php +++ b/application/views/lehre/anrechnung/createAnrechnungData.php @@ -2,7 +2,7 @@ $STUDIENSEMESTER = $studiensemester_selected; $STUDIENGAENGE_ENTITLED = implode(', ', $studiengaenge_entitled); -$LANGUAGE_INDEX = getUserLanguage() == 'German' ? '0' : '1'; +$LANGUAGE_INDEX = getUserLanguage() == 'German' ? '1' : '2'; $query = ' SELECT pst.prestudent_id, @@ -14,8 +14,8 @@ $query = ' nachname, vorname, (SELECT COALESCE( - array_to_json(zgvmaster.bezeichnung::varchar[])->>' . $LANGUAGE_INDEX . ', - array_to_json(zgv.bezeichnung::varchar[])->>' . $LANGUAGE_INDEX . ' + zgvmaster.bezeichnung[' . $LANGUAGE_INDEX . '], + zgv.bezeichnung[' . $LANGUAGE_INDEX . '] ) AS zgv FROM public.tbl_prestudent LEFT JOIN bis.tbl_zgv zgv USING (zgv_code) diff --git a/application/views/lehre/anrechnung/reviewAnrechnungDetail.php b/application/views/lehre/anrechnung/reviewAnrechnungDetail.php index 462124666..4c67c939a 100644 --- a/application/views/lehre/anrechnung/reviewAnrechnungDetail.php +++ b/application/views/lehre/anrechnung/reviewAnrechnungDetail.php @@ -21,6 +21,7 @@ $this->load->view( 'systemfehler', 'bitteMindEinenAntragWaehlen', 'bitteBegruendungAngeben', + 'bitteBegruendungVervollstaendigen', 'anrechnungenWurdenEmpfohlen', 'anrechnungenWurdenNichtEmpfohlen' ), @@ -234,13 +235,16 @@ $this->load->view( - p->t('anrechnung', 'empfehlungNegativKenntnisseNichtGleichwertig'); ?> + p->t('anrechnung', 'empfehlungNegativKenntnisseNichtGleichwertigWeil'); ?> + + p->t('anrechnung', 'andereBegruendung'); ?> + load->view( empfehlung) ? '' : 'disabled' ?>> + empfehlung) && $isEmpfehlungsberechtigt) ? '' : 'disabled' ?>> p->t('anrechnung', 'nichtEmpfehlen')); ?> empfehlung) ? '' : 'disabled' ?>> + empfehlung) && $isEmpfehlungsberechtigt) ? '' : 'disabled' ?>> p->t('anrechnung', 'empfehlen')); ?> diff --git a/application/views/lehre/anrechnung/reviewAnrechnungUebersicht.php b/application/views/lehre/anrechnung/reviewAnrechnungUebersicht.php index ae5e08055..7485a1812 100644 --- a/application/views/lehre/anrechnung/reviewAnrechnungUebersicht.php +++ b/application/views/lehre/anrechnung/reviewAnrechnungUebersicht.php @@ -117,7 +117,7 @@ $this->load->view( - load->view('lehre/anrechnung/reviewAnrechnungUebersichtData.php'); ?> + load->view('lehre/anrechnung/reviewAnrechnungUebersichtData.php');?> @@ -139,12 +139,8 @@ $this->load->view( - - p->t('anrechnung', 'empfehlungNegativKenntnisseNichtGleichwertig'); ?> - - - + + p->t('anrechnung', 'empfehlungNegativKenntnisseNichtGleichwertigWeilHinweis'); ?> >' . $LANGUAGE_INDEX . ', - array_to_json(zgv.bezeichnung::varchar[])->>' . $LANGUAGE_INDEX . ' + zgvmaster.bezeichnung[' . $LANGUAGE_INDEX . '], + zgv.bezeichnung[' . $LANGUAGE_INDEX . '] ) AS zgv FROM public.tbl_prestudent LEFT JOIN bis.tbl_zgv zgv USING (zgv_code) @@ -37,7 +37,8 @@ $query = ' WHERE anrechnung_id = anrechnung.anrechnung_id ORDER BY insertamum DESC LIMIT 1 - ) AS status_kurzbz + ) AS status_kurzbz, + anrechnungstatus.bezeichnung_mehrsprachig[' . $LANGUAGE_INDEX . '] AS "status_bezeichnung" FROM lehre.tbl_anrechnung AS anrechnung JOIN public.tbl_prestudent USING (prestudent_id) JOIN public.tbl_person AS person USING (person_id) @@ -46,25 +47,83 @@ $query = ' LEFT JOIN campus.tbl_dms_version AS dmsversion USING (dms_id) JOIN lehre.tbl_anrechnung_anrechnungstatus USING (anrechnung_id) JOIN lehre.tbl_anrechnung_begruendung AS begruendung USING (begruendung_id) - ) + JOIN lehre.tbl_anrechnungstatus as anrechnungstatus USING (status_kurzbz) + WHERE studiensemester_kurzbz = \'' . $STUDIENSEMESTER . '\' + -- Order to distinct on last anrechnungstatus + ORDER BY anrechnung.anrechnung_id, lehre.tbl_anrechnung_anrechnungstatus.insertamum DESC + ), + -- Allen Lektoren einer LV und flag, welche LV-Leitung innehaben + tbl_lvleitungen AS + ( + SELECT DISTINCT ON (benutzer.uid, lehrveranstaltung_id) lehrveranstaltung_id, uid, + CASE WHEN lehrfunktion_kurzbz = \'LV-Leitung\' THEN TRUE + ELSE FALSE + END AS lvleiter + FROM lehre.tbl_lehreinheit + JOIN anrechnungen USING (lehrveranstaltung_id) -- LVs auf Anrechnungen beschränken + JOIN lehre.tbl_lehreinheitmitarbeiter lema USING (lehreinheit_id) + JOIN public.tbl_benutzer benutzer ON lema.mitarbeiter_uid = benutzer.uid + JOIN public.tbl_person USING (person_id) + WHERE tbl_lehreinheit.studiensemester_kurzbz = \'' . $STUDIENSEMESTER . '\' + AND benutzer.aktiv = TRUE + AND tbl_person.aktiv = TRUE + ORDER BY lehrveranstaltung_id, benutzer.uid, lehrfunktion_kurzbz DESC + )'; - SELECT DISTINCT ON (anrechnungen.*, lema.mitarbeiter_uid) anrechnungen.*, - array_to_json(anrechnungstatus.bezeichnung_mehrsprachig::varchar[])->>' . $LANGUAGE_INDEX . ' AS "status_bezeichnung" - FROM anrechnungen - JOIN lehre.tbl_anrechnungstatus as anrechnungstatus ON (anrechnungstatus.status_kurzbz = anrechnungen.status_kurzbz) - JOIN lehre.tbl_lehreinheit le USING (lehrveranstaltung_id) - JOIN lehre.tbl_lehreinheitmitarbeiter lema USING (lehreinheit_id) - WHERE anrechnungen.studiensemester_kurzbz = \'' . $STUDIENSEMESTER . '\' - AND le.studiensemester_kurzbz = anrechnungen.studiensemester_kurzbz - AND lema.mitarbeiter_uid = \'' . $LEKTOR_UID . '\' - AND le.lehre = TRUE - AND EXISTS ( - SELECT 1 - FROM lehre.tbl_anrechnung_anrechnungstatus - WHERE anrechnung_id = anrechnungen.anrechnung_id - AND status_kurzbz=\'inProgressLektor\' - ) -'; +if ($configFachbereichsleitung === TRUE) +{ + $query.= ' + SELECT + -- immer empfehlungsberechtigt, da hier nur Leitungen der LV-OE eine Empfehlungsanfrage erhalten + TRUE AS empfehlungsberechtigt, + anrechnungen.* + FROM anrechnungen + JOIN lehre.tbl_lehrveranstaltung lv using (lehrveranstaltung_id) + JOIN public.tbl_organisationseinheit og using (oe_kurzbz) -- OE der LV + JOIN public.tbl_benutzerfunktion bf using (oe_kurzbz) + -- Aktive Leitung der LV-OE + WHERE bf.funktion_kurzbz = \'Leitung\' + and bf.datum_von <= now() + and (bf.datum_bis >= now() or bf.datum_bis is null) + AND bf.uid = \'' . $LEKTOR_UID . '\' + -- check, dass es für diese Anrechnung eine Empfehlungsanfrage gibt + AND EXISTS ( + SELECT 1 + FROM lehre.tbl_anrechnung_anrechnungstatus + WHERE anrechnung_id = anrechnungen.anrechnung_id + AND status_kurzbz=\'inProgressLektor\' + ) + order by empfehlung_anrechnung NULLS FIRST, antragsdatum + '; +} +else +{ + $query.= ' + SELECT DISTINCT ON (anrechnungen.*, lema.mitarbeiter_uid) + CASE + -- erst prüfen, ob es überhaupt eine LV Leitung gibt (wenn nicht, dann immer empfehlungsberechtigt) + WHEN EXISTS (SELECT 1 FROM tbl_lvleitungen WHERE lehrveranstaltung_id = anrechnungen.lehrveranstaltung_id AND lvleiter = TRUE) + -- wenn ja, return true, wenn user LV Leitung ist oder false, wenn nicht + THEN (SELECT EXISTS (SELECT 1 FROM tbl_lvleitungen WHERE lehrveranstaltung_id = anrechnungen.lehrveranstaltung_id AND lvleiter = TRUE AND uid = \'' . $LEKTOR_UID . '\')) + -- wenn es keine LV Leitung, return immer true + ELSE TRUE + END AS empfehlungsberechtigt, + anrechnungen.* + FROM anrechnungen + JOIN lehre.tbl_lehreinheit le USING (lehrveranstaltung_id) + JOIN lehre.tbl_lehreinheitmitarbeiter lema USING (lehreinheit_id) + WHERE le.studiensemester_kurzbz = anrechnungen.studiensemester_kurzbz + AND lema.mitarbeiter_uid = \'' . $LEKTOR_UID . '\' + AND le.lehre = TRUE + -- check, dass es für diese Anrechnung eine Empfehlungsanfrage gibt + AND EXISTS ( + SELECT 1 + FROM lehre.tbl_anrechnung_anrechnungstatus + WHERE anrechnung_id = anrechnungen.anrechnung_id + AND status_kurzbz=\'inProgressLektor\' + ) + '; +} $filterWidgetArray = array( 'query' => $query, @@ -72,6 +131,7 @@ $filterWidgetArray = array( 'requiredPermissions' => 'lehre/anrechnung_empfehlen', 'datasetRepresentation' => 'tabulator', 'columnsAliases' => array( + 'Empfehlungsberechtigt', 'anrechnung_id', 'lehrveranstaltung_id', 'begruendung_id', @@ -98,6 +158,7 @@ $filterWidgetArray = array( persistentSort:true, autoResize: false, // prevent auto resizing of table (false to allow adapting table size when cols are (de-)activated headerFilterPlaceholder: " ", + initialHeaderFilter: [{field:"empfehlungsberechtigt", value: true}], index: "anrechnung_id", // assign specific column as unique id (important for row indexing) selectable: true, // allow row selection selectableRangeMode: "click", // allow range selection using shift end click on end of range @@ -122,6 +183,9 @@ $filterWidgetArray = array( } }', // tabulator properties 'datasetRepFieldsDefs' => '{ + empfehlungsberechtigt: {formatter:"tickCross", align:"center", headerTooltip:"Berechtigt wenn man die LV leitet oder wenn der LV keine LV-Leitung zugeordnet ist.", + headerFilter:"tickCross", headerFilterParams:{"tristate": true}, headerFilterFunc: hf_empfehlungsberechtigt + }, anrechnung_id: {visible: false, headerFilter:"input"}, lehrveranstaltung_id: {visible: false, headerFilter:"input"}, begruendung_id: {visible: false, headerFilter:"input"}, @@ -133,7 +197,7 @@ $filterWidgetArray = array( ects: {headerFilter:"input", align:"center"}, student: {headerFilter:"input"}, begruendung: {headerFilter:"input"}, - zgv: {visible: false, headerFilter:"input"}, + zgv: {headerFilter:"input"}, dokument_bezeichnung: {headerFilter:"input", formatter:"link", formatterParams: paramLookup_dokBez}, anmerkung_student: {headerFilter:"input"}, antragsdatum: {align:"center", headerFilter:"input", mutator: mut_formatStringDate}, diff --git a/application/views/system/infocenter/infocenterAbgewiesenData.php b/application/views/system/infocenter/infocenterAbgewiesenData.php index 40582a668..d09f0f41e 100644 --- a/application/views/system/infocenter/infocenterAbgewiesenData.php +++ b/application/views/system/infocenter/infocenterAbgewiesenData.php @@ -7,10 +7,11 @@ $STUDIENSEMESTER = '\''.$this->variablelib->getVar('infocenter_studiensemester').'\''; $LOGDATA_NAME = '\'Message sent\''; $LOGDATA_VON = '\'online\''; + $STUDIENGEBUEHR_ANZAHLUNG = '\'StudiengebuehrAnzahlung\''; $query = ' SELECT - p.person_id AS "PersonID", + p.person_id AS "PersonId", ps.prestudent_id AS "PreStudentID", p.vorname AS "Vorname", p.nachname AS "Nachname", @@ -37,7 +38,15 @@ $query = ' AND l.zeitpunkt >= pss.insertamum ORDER BY l.log_id DESC LIMIT 1 - ) AS "Nachricht" + ) AS "Nachricht", + ( + SELECT SUM(konto.betrag) + FROM public.tbl_konto konto + LEFT JOIN tbl_konto skonto ON (skonto.buchungsnr_verweis = konto.buchungsnr) + WHERE konto.person_id = p.person_id + AND konto.studiensemester_kurzbz = '. $STUDIENSEMESTER .' + AND konto.buchungstyp_kurzbz = '. $STUDIENGEBUEHR_ANZAHLUNG .' + ) AS "Kaution" FROM public.tbl_prestudentstatus pss JOIN public.tbl_prestudent ps USING(prestudent_id) @@ -60,14 +69,16 @@ $query = ' 'filter_id' => $this->input->get('filter_id'), 'requiredPermissions' => 'infocenter', 'datasetRepresentation' => 'tablesorter', + 'checkboxes' => 'PersonId', 'columnsAliases' => array( - 'PersonID', + 'PersonId', 'PreStudentID', - 'Vorname', - 'Nachname', - 'Studiengang', - 'Abgewiesen am', - 'Nachricht' + ucfirst($this->p->t('person', 'vorname')) , + ucfirst($this->p->t('person', 'nachname')), + ucfirst($this->p->t('lehre', 'studiengang')), + ucfirst($this->p->t('infocenter', 'abgewiesenam')), + ucfirst($this->p->t('global', 'nachricht')), + ucfirst($this->p->t('infocenter', 'kaution')) ), 'formatRow' => function($datasetRaw) { @@ -80,6 +91,19 @@ $query = ' $datasetRaw->{'Nachricht'} = 'Ja'; } + if ($datasetRaw->{'Kaution'} === null) + { + $datasetRaw->{'Kaution'} = '-'; + } + else if ($datasetRaw->{'Kaution'} === '0.00') + { + $datasetRaw->{'Kaution'} = 'Bezahlt'; + } + else + { + $datasetRaw->{'Kaution'} = 'Offen'; + } + $datasetRaw->{'AbgewiesenAm'} = date_format(date_create($datasetRaw->{'AbgewiesenAm'}),'Y-m-d H:i'); return $datasetRaw; } diff --git a/application/views/system/infocenter/infocenterData.php b/application/views/system/infocenter/infocenterData.php index de2bd1bca..bb5b84479 100644 --- a/application/views/system/infocenter/infocenterData.php +++ b/application/views/system/infocenter/infocenterData.php @@ -7,13 +7,12 @@ $STUDIENGANG_TYP = '\''.$this->variablelib->getVar('infocenter_studiensgangtyp').'\''; $TAETIGKEIT_KURZBZ = '\'bewerbung\', \'kommunikation\''; $LOGDATA_NAME = '\'Login with code\', \'Login with user\', \'Interessent rejected\', \'Attempt to register with existing mailadress\', \'Access code sent\', \'Personal data saved\''; - $LOGDATA_NAME_PARKED = '\'Parked\''; - $LOGDATA_NAME_ONHOLD = '\'Onhold\''; - $LOGTYPE_KURZBZ = '\'Processstate\''; + $POSTPONE_STATUS_PARKED = '\'parked\''; $STATUS_KURZBZ = '\'Wartender\', \'Bewerber\', \'Aufgenommener\', \'Student\''; $ADDITIONAL_STG = $this->config->item('infocenter_studiengang_kz'); $AKTE_TYP = '\'identity\', \'zgv_bakk\''; $STUDIENSEMESTER = '\''.$this->variablelib->getVar('infocenter_studiensemester').'\''; + $STUDIENGEBUEHR_ANZAHLUNG = '\'StudiengebuehrAnzahlung\''; $ORG_NAME = '\'InfoCenter\''; $ONLINE = '\'online\''; @@ -27,8 +26,6 @@ p.staatsbuergerschaft AS "Nation", pl.zeitpunkt AS "LockDate", pl.lockuser AS "LockUser", - pd.parkdate AS "ParkDate", - ohd.onholddate AS "OnholdDate", ( SELECT l.zeitpunkt FROM system.tbl_log l @@ -276,9 +273,9 @@ ) AS "ZGVMNationGruppe", ( SELECT tbl_organisationseinheit.bezeichnung - FROM public.tbl_benutzerfunktion + FROM public.tbl_benutzerfunktion JOIN public.tbl_organisationseinheit USING(oe_kurzbz) - WHERE (tbl_benutzerfunktion.datum_von IS NULL OR tbl_benutzerfunktion.datum_von <= now()) + WHERE (tbl_benutzerfunktion.datum_von IS NULL OR tbl_benutzerfunktion.datum_von <= now()) AND (tbl_benutzerfunktion.datum_bis IS NULL OR tbl_benutzerfunktion.datum_bis >= now()) AND tbl_organisationseinheit.bezeichnung = '.$ORG_NAME.' AND tbl_benutzerfunktion.uid = ( @@ -290,8 +287,18 @@ ORDER BY l.log_id DESC LIMIT 1 ) - LIMIT 1 - ) AS "InfoCenterMitarbeiter" + LIMIT 1 + ) AS "InfoCenterMitarbeiter", + rueck.datum_bis AS "HoldDate", + rueck.bezeichnung AS "Rueckstellgrund", + ( + SELECT SUM(konto.betrag) + FROM public.tbl_konto konto + LEFT JOIN tbl_konto skonto ON (skonto.buchungsnr_verweis = konto.buchungsnr) + WHERE konto.person_id = p.person_id + AND konto.studiensemester_kurzbz = '. $STUDIENSEMESTER .' + AND konto.buchungstyp_kurzbz = '. $STUDIENGEBUEHR_ANZAHLUNG .' + ) AS "Kaution" FROM public.tbl_person p LEFT JOIN ( SELECT tpl.person_id, @@ -302,22 +309,24 @@ JOIN public.tbl_person sp ON sb.person_id = sp.person_id WHERE tpl.app = '.$APP.' ) pl USING(person_id) - LEFT JOIN ( - SELECT l.person_id, - l.zeitpunkt AS parkdate - FROM system.tbl_log l - WHERE l.logtype_kurzbz = '.$LOGTYPE_KURZBZ.' - AND l.logdata->>\'name\' = '.$LOGDATA_NAME_PARKED.' - AND l.zeitpunkt >= NOW() - ) pd USING(person_id) LEFT JOIN ( - SELECT l.person_id, - l.zeitpunkt AS onholddate - FROM system.tbl_log l - WHERE l.logtype_kurzbz = '.$LOGTYPE_KURZBZ.' - AND l.logdata->>\'name\' = '.$LOGDATA_NAME_ONHOLD.' - AND l.zeitpunkt >= NOW() - ) ohd USING(person_id) + SELECT + tbl_rueckstellung.person_id, + tbl_rueckstellung.datum_bis, + tbl_rueckstellung.status_kurzbz, + array_to_json(bezeichnung_mehrsprachig::varchar[])->>0 as bezeichnung + FROM public.tbl_rueckstellung + JOIN public.tbl_rueckstellung_status USING(status_kurzbz) + JOIN public.tbl_person sp ON tbl_rueckstellung.person_id = sp.person_id + WHERE tbl_rueckstellung.rueckstellung_id = + ( + SELECT srueck.rueckstellung_id + FROM public.tbl_rueckstellung srueck + WHERE srueck.person_id = tbl_rueckstellung.person_id + AND datum_bis >= NOW() + ORDER BY srueck.datum_bis DESC LIMIT 1 + ) + ) rueck ON rueck.person_id = p.person_id WHERE EXISTS ( SELECT 1 @@ -344,7 +353,12 @@ AND spss.studiensemester_kurzbz = '.$STUDIENSEMESTER.' ) ) - ORDER BY "LastAction" ASC'; + ORDER BY CASE + WHEN rueck.status_kurzbz IS NULL THEN 1 + WHEN rueck.status_kurzbz = ' .$POSTPONE_STATUS_PARKED .' THEN 2 + WHEN rueck.status_kurzbz != '. $POSTPONE_STATUS_PARKED .' THEN 3 + END, + rueck.datum_bis NULLS LAST, "LastAction" ASC'; $filterWidgetArray = array( 'query' => $query, @@ -366,8 +380,6 @@ ucfirst($this->p->t('person', 'nation')), ucfirst($this->p->t('global', 'sperrdatum')), ucfirst($this->p->t('global', 'gesperrtVon')), - ucfirst($this->p->t('global', 'parkdatum')), - ucfirst($this->p->t('global', 'rueckstelldatum')), ucfirst($this->p->t('global', 'letzteAktion')), 'Aktionstyp', 'AnzahlAktePflicht', @@ -383,7 +395,10 @@ 'ZGV Nation MA', 'ZGV Gruppe BA', 'ZGV Gruppe MA', - 'InfoCenter Mitarbeiter' + 'InfoCenter Mitarbeiter', + ucfirst($this->p->t('infocenter', 'rueckstelldatum')), + ucfirst($this->p->t('infocenter', 'rueckstellgrund')), + ucfirst($this->p->t('infocenter', 'kaution')) ), 'formatRow' => function($datasetRaw) { @@ -430,18 +445,13 @@ $datasetRaw->{'LockUser'} = '-'; } - if ($datasetRaw->{'ParkDate'} == null) + if ($datasetRaw->{'HoldDate'} == null) { - $datasetRaw->{'ParkDate'} = '-'; - } - - if ($datasetRaw->{'OnholdDate'} == null) - { - $datasetRaw->{'OnholdDate'} = '-'; + $datasetRaw->{'HoldDate'} = '-'; } else { - $datasetRaw->{'OnholdDate'} = date_format(date_create($datasetRaw->{'OnholdDate'}), 'Y-m-d H:i'); + $datasetRaw->{'HoldDate'} = date_format(date_create($datasetRaw->{'HoldDate'}), 'Y-m-d H:i'); } if ($datasetRaw->{'StgAbgeschickt'} == null) @@ -493,6 +503,24 @@ $datasetRaw->{'InfoCenterMitarbeiter'} = 'Ja'; } + if ($datasetRaw->{'Rueckstellgrund'} === null) + { + $datasetRaw->{'Rueckstellgrund'} = '-'; + } + + if ($datasetRaw->{'Kaution'} === null) + { + $datasetRaw->{'Kaution'} = '-'; + } + else if ($datasetRaw->{'Kaution'} === '0.00') + { + $datasetRaw->{'Kaution'} = 'Bezahlt'; + } + else + { + $datasetRaw->{'Kaution'} = 'Offen'; + } + return $datasetRaw; }, 'markRow' => function($datasetRaw) { @@ -504,16 +532,12 @@ $mark = FilterWidget::DEFAULT_MARK_ROW_CLASS; } - if ($datasetRaw->OnholdDate != null) - { + if ($datasetRaw->Rueckstellgrund != null && $datasetRaw->Rueckstellgrund !== 'Parken') $mark = "onhold"; - } // Parking has priority over locking - if ($datasetRaw->ParkDate != null) - { + if ($datasetRaw->Rueckstellgrund === 'Parken') $mark = "text-info"; - } return $mark; } diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 066e5cff6..401e34099 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -24,42 +24,15 @@ 'public/js/tablesort/tablesort.js', 'public/js/infocenter/messageList.js', 'public/js/infocenter/infocenterDetails.js', + 'public/js/infocenter/rueckstellung.js', 'public/js/infocenter/zgvUeberpruefung.js', 'public/js/infocenter/docUeberpruefung.js', 'public/js/infocenter/stammdaten.js' ), 'phrases' => array( - 'infocenter' => array( - 'notizHinzufuegen', - 'notizAendern', - 'bewerberParken', - 'bewerberAusparken', - 'nichtsZumAusparken', - 'fehlerBeimAusparken', - 'fehlerBeimParken', - 'bewerberGeparktBis', - 'bewerberOnHold', - 'bewerberOnHoldEntfernen', - 'bewerberOnHoldBis', - 'nichtsZumEntfernen', - 'fehlerBeimEntfernen', - 'rueckstelldatumUeberschritten', - 'parkenZurueckstellenInfo', - 'zgvInPruefung', - 'zgvErfuellt', - 'zgvNichtErfuellt', - 'zgvErfuelltPruefung', - 'datumUngueltig', - 'nachreichDatumNichtVergangenheit' - ), - 'ui' => array( - 'gespeichert', - 'fehlerBeimSpeichern' - ), - 'global' => array( - 'bis', - 'zeilen' - ) + 'infocenter', + 'ui', + 'global' ) ); diff --git a/application/views/system/infocenter/infocenterFreigegebenData.php b/application/views/system/infocenter/infocenterFreigegebenData.php index 13e1d5549..32315c145 100644 --- a/application/views/system/infocenter/infocenterFreigegebenData.php +++ b/application/views/system/infocenter/infocenterFreigegebenData.php @@ -13,6 +13,7 @@ $ORG_NAME = '\'InfoCenter\''; $IDENTITY = '\'identity\''; $ONLINE = '\'online\''; + $STUDIENGEBUEHR_ANZAHLUNG = '\'StudiengebuehrAnzahlung\''; $query = ' SELECT @@ -264,7 +265,15 @@ $query = ' WHERE akte.person_id = p.person_id AND dokument_kurzbz = '. $IDENTITY .' LIMIT 1 - ) AS "AktenId" + ) AS "AktenId", + ( + SELECT SUM(konto.betrag) + FROM public.tbl_konto konto + LEFT JOIN tbl_konto skonto ON (skonto.buchungsnr_verweis = konto.buchungsnr) + WHERE konto.person_id = p.person_id + AND konto.studiensemester_kurzbz = '. $STUDIENSEMESTER .' + AND konto.buchungstyp_kurzbz = '. $STUDIENGEBUEHR_ANZAHLUNG .' + ) AS "Kaution" FROM public.tbl_person p LEFT JOIN ( SELECT tpl.person_id, @@ -337,7 +346,8 @@ $query = ' 'ZGV Nation BA', 'ZGV Nation MA', 'InfoCenter Mitarbeiter', - 'Identitätsnachweis' + 'Identitätsnachweis', + ucfirst($this->p->t('infocenter', 'kaution')) ), 'formatRow' => function($datasetRaw) { @@ -453,6 +463,18 @@ $query = ' $datasetRaw->{'AktenId'} = '-'; } + if ($datasetRaw->{'Kaution'} === null) + { + $datasetRaw->{'Kaution'} = '-'; + } + else if ($datasetRaw->{'Kaution'} === '0.00') + { + $datasetRaw->{'Kaution'} = 'Bezahlt'; + } + else + { + $datasetRaw->{'Kaution'} = 'Offen'; + } return $datasetRaw; }, diff --git a/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php b/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php index ea1fab83c..e6b6d2495 100644 --- a/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php +++ b/application/views/system/infocenter/infocenterReihungstestAbsolviertData.php @@ -9,6 +9,7 @@ $ADDITIONAL_STG = $this->config->item('infocenter_studiengang_kz'); $STUDIENSEMESTER = '\''.$this->variablelib->getVar('infocenter_studiensemester').'\''; $ORG_NAME = '\'InfoCenter\''; + $STUDIENGEBUEHR_ANZAHLUNG = '\'StudiengebuehrAnzahlung\''; $query = ' SELECT @@ -195,7 +196,14 @@ $query = ' LIMIT 1 ) LIMIT 1 - ) AS "InfoCenterMitarbeiter" + ) AS "InfoCenterMitarbeiter", + ( + SELECT SUM(konto.betrag) + FROM public.tbl_konto konto + WHERE konto.person_id = p.person_id + AND konto.studiensemester_kurzbz = '. $STUDIENSEMESTER .' + AND konto.buchungstyp_kurzbz = '. $STUDIENGEBUEHR_ANZAHLUNG .' + ) AS "Kaution" FROM public.tbl_person p LEFT JOIN ( SELECT tpl.person_id, @@ -256,7 +264,8 @@ $query = ' 'Reihungstest Datum', 'ZGV Nation BA', 'ZGV Nation MA', - 'InfoCenter Mitarbeiter' + 'InfoCenter Mitarbeiter', + ucfirst($this->p->t('infocenter', 'kaution')) ), 'formatRow' => function($datasetRaw) { @@ -359,6 +368,19 @@ $query = ' $datasetRaw->{'InfoCenterMitarbeiter'} = 'Ja'; } + if ($datasetRaw->{'Kaution'} === null) + { + $datasetRaw->{'Kaution'} = '-'; + } + else if ($datasetRaw->{'Kaution'} === '0.00') + { + $datasetRaw->{'Kaution'} = 'Bezahlt'; + } + else + { + $datasetRaw->{'Kaution'} = 'Offen'; + } + return $datasetRaw; }, 'markRow' => function($datasetRaw) { diff --git a/application/views/system/infocenter/infocenterZgvDetails.php b/application/views/system/infocenter/infocenterZgvDetails.php index cf3ffad8b..7636647ab 100644 --- a/application/views/system/infocenter/infocenterZgvDetails.php +++ b/application/views/system/infocenter/infocenterZgvDetails.php @@ -26,6 +26,7 @@ 'public/js/tablesort/tablesort.js', 'public/js/infocenter/messageList.js', 'public/js/infocenter/infocenterDetails.js', + 'public/js/infocenter/rueckstellung.js', 'public/js/infocenter/zgvUeberpruefung.js' ), 'phrases' => array( diff --git a/application/views/system/infocenter/infocenterZgvUeberpruefungData.php b/application/views/system/infocenter/infocenterZgvUeberpruefungData.php index 5bfa5b078..d088d6b51 100644 --- a/application/views/system/infocenter/infocenterZgvUeberpruefungData.php +++ b/application/views/system/infocenter/infocenterZgvUeberpruefungData.php @@ -5,6 +5,7 @@ $INTERESSENT_STATUS = '\'Interessent\''; $TAETIGKEIT_KURZBZ = '\'bewerbung\', \'kommunikation\''; $LOGDATA_NAME = '\'Login with code\', \'Login with user\', \'New application\''; $oeKurz = '\''. implode('\',\'', $oeKurz) . '\''; +$ABGEWIESENER_STATUS = '\'Abgewiesener\''; $query = ' SELECT @@ -22,6 +23,7 @@ $query = ' AND zgvstatus.datum IN ( SELECT MAX(zgvstatus.datum) FROM public.tbl_zgvpruefungstatus_status zgvstatus GROUP BY zgvstatus.zgvpruefung_id) + AND get_rolle_prestudent(prestudent_id, NULL) != '. $ABGEWIESENER_STATUS .' ORDER BY ps.prestudent_id '; diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index 4c40e434a..45bcf7e04 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -554,7 +554,7 @@ class FilterWidget extends Widget private function _setFilterMenu() { // Generates the filters structure array - $filterMenu = $this->filterwidgetlib->generateFilterMenu( + $this->filterwidgetlib->generateFilterMenu( $this->router->directory.$this->router->class.'/'.$this->router->method ); } @@ -633,7 +633,7 @@ class FilterWidget extends Widget { $columnsNames = array(); - foreach ($columns as $key => $obj) + foreach ($columns as $obj) { if (isset($obj->name)) { diff --git a/application/widgets/TableWidget.php b/application/widgets/TableWidget.php index a1a15d508..e59efce10 100644 --- a/application/widgets/TableWidget.php +++ b/application/widgets/TableWidget.php @@ -440,24 +440,6 @@ class TableWidget extends Widget return !isset($class) ? '' : $class; } - /** - * Utility method that retrieves the name of the columns present in a table JSON definition - */ - private function _getColumnsNames($columns) - { - $columnsNames = array(); - - foreach ($columns as $key => $obj) - { - if (isset($obj->name)) - { - $columnsNames[] = $obj->name; - } - } - - return $columnsNames; - } - /** * Loads a view using the given viewName and eventually other parameters */ @@ -467,3 +449,4 @@ class TableWidget extends Widget $ci->load->view($viewName, $parameters); } } + diff --git a/cis/private/lehre/abgabe_lektor.php b/cis/private/lehre/abgabe_lektor.php index 70f80f7ba..3d20c8a7e 100644 --- a/cis/private/lehre/abgabe_lektor.php +++ b/cis/private/lehre/abgabe_lektor.php @@ -61,8 +61,10 @@ $sql_query = "SELECT FROM (SELECT tbl_person.vorname, tbl_person.nachname, tbl_studiengang.typ, tbl_studiengang.kurzbz, tbl_projektarbeit.projekttyp_kurzbz, tbl_projekttyp.bezeichnung, tbl_projektarbeit.titel, tbl_projektarbeit.projektarbeit_id, - tbl_projektbetreuer.betreuerart_kurzbz, tbl_benutzer.uid, tbl_student.matrikelnr, tbl_lehreinheit.studiensemester_kurzbz - FROM lehre.tbl_projektarbeit LEFT JOIN lehre.tbl_projektbetreuer using(projektarbeit_id) + tbl_projektbetreuer.betreuerart_kurzbz, tbl_betreuerart.beschreibung AS betreuerart_beschreibung, tbl_benutzer.uid, tbl_student.matrikelnr, tbl_lehreinheit.studiensemester_kurzbz + FROM lehre.tbl_projektarbeit + LEFT JOIN lehre.tbl_projektbetreuer using(projektarbeit_id) + LEFT JOIN lehre.tbl_betreuerart using(betreuerart_kurzbz) LEFT JOIN public.tbl_benutzer on(uid=student_uid) LEFT JOIN public.tbl_student on(public.tbl_benutzer.uid=public.tbl_student.student_uid) LEFT JOIN public.tbl_person on(tbl_benutzer.person_id=tbl_person.person_id) @@ -75,8 +77,7 @@ $sql_query = "SELECT WHERE public.tbl_benutzer.person_id=lehre.tbl_projektbetreuer.person_id AND public.tbl_benutzer.uid=".$db->db_add_param($getuid).") ".($showall?'':' AND public.tbl_benutzer.aktiv AND lehre.tbl_projektarbeit.note IS NULL ')." - AND (betreuerart_kurzbz='Betreuer' OR betreuerart_kurzbz='Begutachter' OR betreuerart_kurzbz='Erstbegutachter' - OR betreuerart_kurzbz='Zweitbegutachter' OR betreuerart_kurzbz='Erstbetreuer') + AND betreuerart_kurzbz IN ('Betreuer', 'Begutachter', 'Erstbegutachter', 'Zweitbegutachter', 'Erstbetreuer', 'Senatsvorsitz', 'Senatsmitglied') ORDER BY tbl_projektarbeit.projektarbeit_id, betreuerart_kurzbz desc) as xy ORDER BY nachname"; @@ -112,7 +113,7 @@ else $htmlstr .= " ".strtoupper($row->typ.$row->kurzbz)."\n"; $htmlstr .= " ".$db->convert_html_chars($row->studiensemester_kurzbz)."\n"; $htmlstr .= " ".$db->convert_html_chars($row->titel)."\n"; - $htmlstr .= " ".$db->convert_html_chars($row->betreuerart_kurzbz)."\n"; + $htmlstr .= " ".($row->betreuerart_beschreibung == null ? $db->convert_html_chars($row->betreuerart_kurzbz) : $db->convert_html_chars($row->betreuerart_beschreibung))."\n"; $htmlstr .= " \n"; $i++; } @@ -127,11 +128,11 @@ echo ' '.$p->t('abgabetool/abgabetool').' - - - - - + + + + + - - - - - - - - -'; - - echo ''.$p->t('abgabetool/ueberschrift'); - if(trim($uid)!='') - echo " ($uid $vorname $nachname) ".$p->t('global/handbuch').""; - echo ''; - echo $htmlstr; - echo ' -