diff --git a/application/components/filters/Vertragsverwaltung.php b/application/components/filters/Vertragsverwaltung.php new file mode 100644 index 000000000..b96aee8ea --- /dev/null +++ b/application/components/filters/Vertragsverwaltung.php @@ -0,0 +1,36 @@ + 'core', + 'datasetName' => 'vertragsverwaltung', + 'query' => ' + SELECT + uid, + person_id, + vorname, + nachname, + gebdatum, + vertragsarten, + unternehmen, + ids, + aktiv + FROM + ( + SELECT + b.uid , p.person_id, + p.vorname, p.nachname, + gebdatum, + STRING_AGG(DISTINCT va.bezeichnung, \', \') AS Vertragsarten, + STRING_AGG(DISTINCT u.bezeichnung, \', \') AS Unternehmen, + STRING_AGG(d.dienstverhaeltnis_id::TEXT, \', \') AS ids, + b.aktiv + FROM + hr.tbl_dienstverhaeltnis d + JOIN public.tbl_benutzer b ON d.mitarbeiter_uid = b.uid + JOIN public.tbl_person p ON p.person_id = b.person_id + JOIN public.tbl_organisationseinheit u ON d.oe_kurzbz = u.oe_kurzbz + JOIN hr.tbl_vertragsart va ON d.vertragsart_kurzbz = va.vertragsart_kurzbz + GROUP BY b.uid, p.person_id, p.vorname, p.nachname, b.aktiv + ) as vertragsdaten + ', + 'requiredPermissions' => 'vertrag/mitarbeiter' + ); diff --git a/application/config/navigation.php b/application/config/navigation.php index f7ba8dca3..c70aba57c 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -163,6 +163,13 @@ $config['navigation_header'] = array( 'expand' => true, 'sort' => 50, 'requiredPermissions' => 'lehre/gruppenmanager:r' + ), + 'vertragsverwaltung' => array( + 'link' => site_url('vertragsverwaltung'), + 'description' => 'Vertragsverwaltung', + 'expand' => true, + 'sort' => 51, + 'requiredPermissions' => 'vertrag/mitarbeiter:r' ) ) ), @@ -335,6 +342,18 @@ $config['navigation_menu']['system/issues/Issues/*'] = array( 'target' => '_blank', 'requiredPermissions' => array('admin:rw') ), + +); + +$config['navigation_menu']['vertragsverwaltung/*'] = array( + 'vertragsverwaltung' => array( + 'link' => site_url('vertragsverwaltung'), + 'description' => 'Vertragsverwaltung', + 'icon' => 'home', + 'sort' => 100, + 'target' => '_blank', + 'requiredPermissions' => array('vertrag/mitarbeiter:r') + ) ); $config['navigation_menu']['apps'] = [ diff --git a/application/config/stv.php b/application/config/stv.php index 8942c35e6..34a30a96e 100644 --- a/application/config/stv.php +++ b/application/config/stv.php @@ -130,3 +130,16 @@ $config['students_tab_order'] = [ 'combinePeople', 'archive', ]; + +$config['stv_prestudent_tags'] = [ + 'prioone' => ['readonly' => false], + 'priotwo' => ['readonly' => true], + 'hinweis' => ['readonly' => false], + 'hinweis_assistenz' => ['readonly' => true], + 'hinweis_kf' => ['readonly' => true], + 'hinweis_lehrende' => ['readonly' => false], + 'hinweis_stg_kf' => ['readonly' => true], + 'finished_stg' => ['readonly' => true], + 'finished_kf' => ['readonly' => true], + 'inwork_kf' => ['readonly' => true], +]; diff --git a/application/controllers/Cis/MyLv.php b/application/controllers/Cis/MyLv.php index 49a938553..819d56b05 100644 --- a/application/controllers/Cis/MyLv.php +++ b/application/controllers/Cis/MyLv.php @@ -33,9 +33,4 @@ class MyLv extends Auth_Controller $this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'MyLv']); } - - public function Info($studien_semester,$lvid) - { - $this->load->view('Cis/LvInfo',['lvid'=> $lvid, 'studien_semester' => $studien_semester]); - } } diff --git a/application/controllers/Studentenverwaltung.php b/application/controllers/Studentenverwaltung.php index 36c91d5f6..1699ba740 100644 --- a/application/controllers/Studentenverwaltung.php +++ b/application/controllers/Studentenverwaltung.php @@ -28,7 +28,7 @@ class Studentenverwaltung extends Auth_Controller 'basis/prestudentstatus' => $this->permissionlib->isBerechtigt('basis/prestudentstatus'), 'assistenz_stgs' => $this->permissionlib->getSTG_isEntitledFor('assistenz'), 'admin' => $this->permissionlib->isBerechtigt('admin'), - 'assistenz_schreibrechte' => $this->permissionlib->isBerechtigt('assistenz','suid'), + 'assistenz_schreibrechte' => $this->permissionlib->isBerechtigt('assistenz', 'suid'), 'student/keine_studstatuspruefung' => $this->permissionlib->isBerechtigt('student/keine_studstatuspruefung'), 'lehre/reihungstestAufsicht' => $this->permissionlib->isBerechtigt('lehre/reihungstestAufsicht'), 'system/change_outputformat' => $this->permissionlib->getOE_isEntitledFor('system/change_outputformat'), @@ -43,3 +43,5 @@ class Studentenverwaltung extends Auth_Controller ]); } } + + diff --git a/application/controllers/Vertragsverwaltung.php b/application/controllers/Vertragsverwaltung.php new file mode 100644 index 000000000..f68ed1737 --- /dev/null +++ b/application/controllers/Vertragsverwaltung.php @@ -0,0 +1,30 @@ +method] = ['vertrag/mitarbeiter:r']; + #$permissions[$router->method] = ['admin:rw']; + parent::__construct($permissions); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + } + + /** + * @return void + */ + public function _remap() + { + $this->load->view('Vertragsverwaltung', [ + 'permissions' => [ + 'vertragsverwaltung_schreibrechte' => $this->permissionlib->isBerechtigt('vertrag/mitarbeiter', 'suid') + ] + ]); + } +} diff --git a/application/controllers/api/frontend/v1/detailheader/Detailheader.php b/application/controllers/api/frontend/v1/detailheader/Detailheader.php new file mode 100644 index 000000000..ada10c5b6 --- /dev/null +++ b/application/controllers/api/frontend/v1/detailheader/Detailheader.php @@ -0,0 +1,53 @@ + ['vertrag/mitarbeiter:r'], + 'getPersonAbteilung' => ['vertrag/mitarbeiter:r'], + 'getLeitungOrg' => ['vertrag/mitarbeiter:r'], + ]); + } + + public function getHeader($person_id) + { + $this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel'); + + $result = $this->Mitarbeitermodel->getHeader($person_id); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } + + public function getPersonAbteilung($mitarbeiter_uid) + { + $this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel'); + + $result = $this->Mitarbeitermodel->getPersonAbteilung($mitarbeiter_uid); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } + + public function getLeitungOrg($oekurzbz) + { + $this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel'); + + $result = $this->Mitarbeitermodel->getLeitungOrg($oekurzbz); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } + +} + + diff --git a/application/controllers/api/frontend/v1/fotoHandling/Foto.php b/application/controllers/api/frontend/v1/fotoHandling/Foto.php new file mode 100644 index 000000000..4945ddd85 --- /dev/null +++ b/application/controllers/api/frontend/v1/fotoHandling/Foto.php @@ -0,0 +1,237 @@ + ['admin:r', 'assistenz:r'], + 'deleteFoto' => ['admin:r', 'assistenz:r'], + ]); + + //Load Models and Libraries + $this->load->model('person/Person_model', 'PersonModel'); + $this->load->model("crm/Akte_model", "AkteModel"); + $this->load->model('person/Fotostatusperson_model', 'FotostatusPersonModel'); + + $this->loadPhrases([ + 'ui', + 'header' + ]); + } + + public function uploadFoto($person_id) + { + if(!$person_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person_id']), self::ERROR_TYPE_GENERAL); + } + + $data = json_decode(file_get_contents("php://input"), true); + + if (!empty($data['image'])) + { + $base64 = $data['image']; + $resizedImage1 = $this->_resize($base64, 827, 1063); + + if (is_null($resizedImage1)) + return $this->terminateWithError($this->p->t('header', 'error_fotoupload'), self::ERROR_TYPE_GENERAL); + + $akte = $this->AkteModel->loadWhere(array('person_id' => $person_id, 'dokument_kurzbz' => 'Lichtbil')); + + $akteUpdateData = array( + 'dokument_kurzbz' => 'Lichtbil', + 'person_id' => $person_id, + 'inhalt' => $resizedImage1, + 'mimetype' => 'image/jpg', + 'erstelltam' => date('c'), + 'gedruckt' => false, + 'titel' => 'Lichtbild_' . $person_id . '.jpg', + 'bezeichnung' => 'Lichtbild gross', + 'insertamum' => date('c'), + 'insertvon' => getAuthUID(), + ); + + if (hasData($akte)) { + $akte_id = getData($akte)[0]->akte_id; + + $akteUpdateData['updateamum'] = date('c'); + $akteUpdateData['updatevon'] = getAuthUID(); + $akteResult = $this->AkteModel->update(array('akte_id' => $akte_id), $akteUpdateData); + } else { + $akteResult = $this->AkteModel->insert($akteUpdateData); + } + + if (isError($akteResult)) { + return $this->terminateWithError(getError($akteResult), self::ERROR_TYPE_GENERAL); + } + + $resizedImage2 = $this->_resize($base64, 101, 130); + + if (is_null($resizedImage2)) + return $this->terminateWithError($this->p->t('header', 'error_fotoupload'), self::ERROR_TYPE_GENERAL); + + $result = $this->_updateFoto($person_id, $resizedImage2); + + if (!isError($result)) { + $this->FotostatusPersonModel->insert(array( + 'person_id' => $person_id, + 'fotostatus_kurzbz' => 'hochgeladen', + 'datum' => date('Y-m-d'), + 'updateamum' => date('c'), + 'updatevon' => getAuthUID(), + 'insertamum' => date('c'), + 'insertvon' => getAuthUID(), + )); + + return $this->terminateWithSuccess($base64); + } + } + else + { + $this->terminateWithError($this->p->t('header', 'error_noPhoto'), self::ERROR_TYPE_GENERAL); + } + } + + public function deleteFoto($person_id) + { + if(!$person_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person_id']), self::ERROR_TYPE_GENERAL); + } + + $result = $this->_deleteFoto($person_id); + + if (isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess($result); + } + + private function _resize($imageData, $maxwidth, $maxheight, $quality = 90) + { + $meta = getimagesize($imageData); + if (!$meta) + { + return null; + } + + $src_width = $meta[0]; + $src_height = $meta[1]; + $mime = $meta['mime']; + + switch ($mime) { + case 'image/jpeg': + case 'image/jpg': + $imagecreated = imagecreatefromjpeg($imageData); + break; + case 'image/png': + $imagecreated = imagecreatefrompng($imageData); + break; + case 'image/gif': + $imagecreated = imagecreatefromgif($imageData); + break; + default: + return null; + } + + + if (!$imagecreated) + { + return null; + } + + $src_aspect_ratio = $src_width / $src_height; + $thu_aspect_ratio = $maxwidth / $maxheight; + + if ($src_width <= $maxwidth && $src_height <= $maxheight) + { + $thu_width = $src_width; + $thu_height = $src_height; + } + elseif ($thu_aspect_ratio > $src_aspect_ratio) + { + $thu_width = (int) ($maxheight * $src_aspect_ratio); + $thu_height = $maxheight; + } + else + { + $thu_width = $maxwidth; + $thu_height = (int) ($maxwidth / $src_aspect_ratio); + } + + $imageScaled = imagecreatetruecolor($thu_width, $thu_height); + + if ($mime === 'image/png') + { + $background = imagecolorallocate($imageScaled , 0, 0, 0); + imagecolortransparent($imageScaled, $background); + imagealphablending($imageScaled, false); + imagesavealpha($imageScaled, true); + } + + imagecopyresampled($imageScaled, $imagecreated, 0, 0, 0, 0, $thu_width, $thu_height, $src_width, $src_height); + + if ($mime === "image/gif") + { + $background = imagecolorallocate($imageScaled, 0, 0, 0); + imagecolortransparent($imageScaled, $background); + } + + if (!empty($imageScaled)) + { + ob_start(); + + if ($mime == 'image/png') + imagepng($imageScaled, NULL); + else if ($mime === 'image/gif') + imagegif($imageScaled, NULL); + else + imagejpeg($imageScaled, NULL, $quality); + + $resizedImageData = ob_get_contents(); + ob_end_clean(); + @imagedestroy($imagecreated); + @imagedestroy($imageScaled); + + + if (!empty($resizedImageData)) + { + return base64_encode($resizedImageData); + } + return null; + } + return null; + } + + private function _updateFoto($person_id, $foto) + { + $personJson['foto'] = $foto; + $result = $this->PersonModel->update($person_id, $personJson); + + if (isError($result)) + { + return error($result->msg, EXIT_ERROR); + } + + return $result; + } + + private function _deleteFoto($person_id) + { + $personJson['foto'] = null; + $result = $this->PersonModel->update($person_id, $personJson); + + if (isError($result)) + { + return error($result->msg, EXIT_ERROR); + } + + return $result; + } +} diff --git a/application/controllers/api/frontend/v1/notiz/NotizAnrechnung.php b/application/controllers/api/frontend/v1/notiz/NotizAnrechnung.php new file mode 100644 index 000000000..30dae9a50 --- /dev/null +++ b/application/controllers/api/frontend/v1/notiz/NotizAnrechnung.php @@ -0,0 +1,44 @@ + ['admin:r', 'assistenz:r'], + ]); + + //Load Models + $this->load->model('person/Notiz_model', 'NotizModel'); + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + } + + public function isBerechtigt($id, $typeId) + { + if($typeId != "anrechnung_id") + { + $this->terminateWithError($this->p->t('ui','error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL); + } + + //TODO define permission + if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) + { + $result = $this->p->t('lehre','error_keineSchreibrechte'); + + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess("berechtigt in überschreibender Funktion"); + } +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/notiz/NotizBestellung.php b/application/controllers/api/frontend/v1/notiz/NotizBestellung.php new file mode 100644 index 000000000..e30628f33 --- /dev/null +++ b/application/controllers/api/frontend/v1/notiz/NotizBestellung.php @@ -0,0 +1,43 @@ + ['admin:r', 'assistenz:r'], + ]); + + //Load Models + $this->load->model('person/Notiz_model', 'NotizModel'); + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + } + + public function isBerechtigt($id, $typeId) + { + if($typeId != "bestellung_id") + { + $this->terminateWithError($this->p->t('ui','error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL); + } + //TODO define permission + if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) + { + $result = $this->p->t('lehre','error_keineSchreibrechte'); + + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess("berechtigt in überschreibender Funktion"); + } +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/notiz/NotizLehreinheit.php b/application/controllers/api/frontend/v1/notiz/NotizLehreinheit.php index f8e1f816b..a3b96d477 100644 --- a/application/controllers/api/frontend/v1/notiz/NotizLehreinheit.php +++ b/application/controllers/api/frontend/v1/notiz/NotizLehreinheit.php @@ -17,5 +17,106 @@ class NotizLehreinheit extends Notiz_Controller 'getMitarbeiter' => ['admin:r', 'assistenz:r'], 'isBerechtigt' => ['admin:r', 'assistenz:r'], ]); + + //Load Models + $this->load->model('person/Notiz_model', 'NotizModel'); + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + $this->load->model('education/Lehreinheit_model', 'LehreinheitModel'); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + //Permission checks for allowed Oes + $allowedOes = $this->permissionlib->getOE_isEntitledFor('assistenz') ?: []; + + if ($this->router->method == 'addNewNotiz') + { + $json = $this->input->post('data'); + $post_data = json_decode($json, true); + $lehreinheit_id = $post_data['id']; + + if(!$lehreinheit_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Lehreinheit ID']), self::ERROR_TYPE_GENERAL); + } + $this->_checkAllowedOesFromLehreinheit($lehreinheit_id, $allowedOes); + } + + if ($this->router->method == 'updateNotiz') + { + $json = $this->input->post('data'); + $post_data = json_decode($json, true); + $notiz_id = $post_data['notiz_id']; + + if(!$notiz_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Notiz ID']), self::ERROR_TYPE_GENERAL); + } + + //get lehreinheit_id + $result = $this->NotizzuordnungModel->loadWhere(['notiz_id' => $notiz_id]); + + $data = $this->getDataOrTerminateWithError($result); + $lehreinheit_id = current($data)->lehreinheit_id; + + if(!$lehreinheit_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Lehreinheit ID']), self::ERROR_TYPE_GENERAL); + } + $this->_checkAllowedOesFromLehreinheit($lehreinheit_id, $allowedOes); + } + + if ($this->router->method == 'deleteNotiz') + { + $notiz_id = $this->input->post('notiz_id'); + $lehreinheit_id = $this->input->post('id'); + + if(!$notiz_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Notiz ID']), self::ERROR_TYPE_GENERAL); + } + + if(!$lehreinheit_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Lehreinheit ID']), self::ERROR_TYPE_GENERAL); + } + $this->_checkAllowedOesFromLehreinheit($lehreinheit_id, $allowedOes); + } + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); } -} \ No newline at end of file + + private function _checkAllowedOesFromLehreinheit($lehreinheit_id, $allowedOes) + { + //get oe from lehreinheit + $result = $this->LehreinheitModel->getOes($lehreinheit_id); + $data = $this->getDataOrTerminateWithError($result); + $oes = current($data); + + if (!in_array($oes, $allowedOes)) + { + return $this->terminateWithError($this->p->t('ui', 'error_keineBerechtigungStg') . " " . $oes, self::ERROR_TYPE_GENERAL); + } + } + + public function isBerechtigt($id, $typeId) + { + if($typeId != "lehreinheit_id") + { + $this->terminateWithError($this->p->t('ui','error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL); + } + + if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) + { + $result = $this->p->t('lehre','error_keineSchreibrechte'); + + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess("berechtigt in überschreibender Funktion"); + } + + +} diff --git a/application/controllers/api/frontend/v1/notiz/NotizMitarbeiter.php b/application/controllers/api/frontend/v1/notiz/NotizMitarbeiter.php new file mode 100644 index 000000000..f7de4b47b --- /dev/null +++ b/application/controllers/api/frontend/v1/notiz/NotizMitarbeiter.php @@ -0,0 +1,44 @@ + ['admin:r', 'assistenz:r'], + ]); + + //Load Models + $this->load->model('person/Notiz_model', 'NotizModel'); + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + } + + public function isBerechtigt($id, $typeId) + { + if($typeId != "mitarbeiter_uid") + { + $this->terminateWithError($this->p->t('ui','error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL); + } + + //TODO define permission + if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) + { + $result = $this->p->t('lehre','error_keineSchreibrechte'); + + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess("berechtigt in überschreibender Funktion"); + } +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/notiz/NotizPerson.php b/application/controllers/api/frontend/v1/notiz/NotizPerson.php index 23a8fd199..7f0645bc6 100644 --- a/application/controllers/api/frontend/v1/notiz/NotizPerson.php +++ b/application/controllers/api/frontend/v1/notiz/NotizPerson.php @@ -20,33 +20,123 @@ class NotizPerson extends Notiz_Controller 'isBerechtigt' => ['admin:r', 'assistenz:r'], 'getCountNotes' => ['admin:r', 'assistenz:r'], ]); + + //Load Models + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $this->load->model('crm/Student_model', 'StudentModel'); + + //Permission checks for allowed Oes + if ($this->router->method == 'addNewNotiz') + { + $json = $this->input->post('data'); + $post_data = json_decode($json, true); + $person_id = $post_data['id']; + + $allowedStgs = $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []; + + if(!$person_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person ID']), self::ERROR_TYPE_GENERAL); + } + $this->_checkIfBerechtigungForOneUidExists($person_id, $allowedStgs); + } + + if ( $this->router->method == 'updateNotiz') + { + $json = $this->input->post('data'); + $post_data = json_decode($json, true); + $notiz_id = $post_data['notiz_id']; + + if(!$notiz_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Notiz ID']), self::ERROR_TYPE_GENERAL); + } + + //get person_id + $result = $this->NotizzuordnungModel->loadWhere(['notiz_id' => $notiz_id]); + + $data = $this->getDataOrTerminateWithError($result); + $person_id = current($data)->person_id; + + $allowedStgs = $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []; + $this->_checkIfBerechtigungForOneUidExists($person_id, $allowedStgs); + } + + if ($this->router->method == 'deleteNotiz' ) + { + $notiz_id = $this->input->post('notiz_id'); + $person_id = $this->input->post('id'); + + if(!$notiz_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Notiz ID']), self::ERROR_TYPE_GENERAL); + } + + if(!$person_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'person ID']), self::ERROR_TYPE_GENERAL); + } + + $allowedStgs = $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []; + $this->_checkIfBerechtigungForOneUidExists($person_id, $allowedStgs); + } } public function isBerechtigt($id, $typeId) { if($typeId != "person_id") { - return $this->terminateWithError($this->p->t('ui', 'error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL); + $this->terminateWithError($this->p->t('ui', 'error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL); } - //TODO define permission if (!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) { $result = $this->p->t('lehre', 'error_keineSchreibrechte'); - - return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } - return $this->outputJsonSuccess(true); + $this->terminateWithSuccess("berechtigt in überschreibender Funktion"); } - public function loadDokumente() + //stv: if person has permission of one studiengang of person -> permission to add/update/delete Note + private function _checkIfBerechtigungForOneUidExists($person_id, $allowedStgs) { - $notiz_id = $this->input->post('notiz_id'); + //get all studentUids of person_id + $result = $this->BenutzerModel->loadWhere(['person_id' => $person_id]); + $data = $this->getDataOrTerminateWithError($result); - // TODO(chris): make CI variant of endpoint - $this->NotizModel->addSelect($this->NotizModel->escape(base_url('content/notizdokdownload.php?id=')) . ' || campus.tbl_dms_version.dms_id AS preview'); - - return parent::loadDokumente(); + $checkarray = []; + foreach ($data as $item) + { + //check if isStudent + $result = $this->StudentModel->isStudent($item->uid); + + $isStudent = $this->getDataOrTerminateWithError($result); + if($isStudent) + { + $checkarray[] = $this->_checkAllowedStgsFromUid($item->uid, $allowedStgs); + } + + } + if (!in_array(1, $checkarray)) + return $this->terminateWithError($this->p->t('ui', 'error_keineBerechtigungStg'), self::ERROR_TYPE_GENERAL); } -} \ No newline at end of file + + private function _checkAllowedStgsFromUid($student_uid, $allowedStgs) + { + $this->load->model('crm/Student_model', 'StudentModel'); + $result = $this->StudentModel->loadWhere(['student_uid' => $student_uid]); + + $data = $this->getDataOrTerminateWithError($result); + $studiengang_kz = current($data)->studiengang_kz; + + if (!in_array($studiengang_kz, $allowedStgs)) + { + return 0; + } + else + { + return 1; + } + } +} diff --git a/application/controllers/api/frontend/v1/notiz/NotizPrestudent.php b/application/controllers/api/frontend/v1/notiz/NotizPrestudent.php new file mode 100644 index 000000000..5e6cd747c --- /dev/null +++ b/application/controllers/api/frontend/v1/notiz/NotizPrestudent.php @@ -0,0 +1,117 @@ + ['admin:r', 'assistenz:r'], + ]); + + //Load Models + $this->load->model('person/Notiz_model', 'NotizModel'); + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + $this->load->model('crm/Student_model', 'StudentModel'); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + + //Permission checks for Studiengangsarray + $allowedStgs = $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []; + + if ($this->router->method == 'addNewNotiz') + { + $json = $this->input->post('data'); + $post_data = json_decode($json, true); + $prestudent_id = $post_data['id']; + + if(!$prestudent_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Lehreinheit ID']), self::ERROR_TYPE_GENERAL); + } + $this->_checkAllowedOesFromPrestudent($prestudent_id, $allowedStgs); + } + + if ($this->router->method == 'updateNotiz') + { + $json = $this->input->post('data'); + $post_data = json_decode($json, true); + $notiz_id = $post_data['notiz_id']; + + if(!$notiz_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Notiz ID']), self::ERROR_TYPE_GENERAL); + } + + //get prestudent_id + $result = $this->NotizzuordnungModel->loadWhere(['notiz_id' => $notiz_id]); + + $data = $this->getDataOrTerminateWithError($result); + $prestudent_id = current($data)->prestudent_id; + + if(!$prestudent_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + } + $this->_checkAllowedOesFromPrestudent($prestudent_id, $allowedStgs); + } + + if ($this->router->method == 'deleteNotiz') + { + $notiz_id = $this->input->post('notiz_id'); + $prestudent_id = $this->input->post('id'); + + if(!$notiz_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Notiz ID']), self::ERROR_TYPE_GENERAL); + } + + if(!$prestudent_id) + { + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL); + } + $this->_checkAllowedOesFromPrestudent($prestudent_id, $allowedStgs); + } + } + + public function isBerechtigt($id, $typeId) + { + if($typeId != "prestudent_id") + { + $this->terminateWithError($this->p->t('ui','error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL); + } + + if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) + { + $result = $this->p->t('lehre','error_keineSchreibrechte'); + + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess("berechtigt in überschreibender Funktion"); + } + + private function _checkAllowedOesFromPrestudent($prestudent_id, $allowedStgs) + { + $student_uid = $this->StudentModel->getUID($prestudent_id); + + $result = $this->StudentModel->loadWhere(['student_uid' => $student_uid]); + + $data = $this->getDataOrTerminateWithError($result); + $studiengang_kz = current($data)->studiengang_kz; + + if (!in_array($studiengang_kz, $allowedStgs)) + { + return $this->terminateWithError($this->p->t('ui', 'error_keineBerechtigungStg'), self::ERROR_TYPE_GENERAL); + } + } + +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/notiz/NotizProjekt.php b/application/controllers/api/frontend/v1/notiz/NotizProjekt.php new file mode 100644 index 000000000..9cdde36ae --- /dev/null +++ b/application/controllers/api/frontend/v1/notiz/NotizProjekt.php @@ -0,0 +1,32 @@ + ['admin:r', 'assistenz:r'], + ]); + } + + public function isBerechtigt($id, $typeId) + { + if($typeId != "projekt_kurzbz") + { + $this->terminateWithError($this->p->t('ui','error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL); + } + + //TODO define permission + if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) + { + $result = $this->p->t('lehre','error_keineSchreibrechte'); + + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess("berechtigt in überschreibender Funktion"); + } +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/notiz/NotizProjektphase.php b/application/controllers/api/frontend/v1/notiz/NotizProjektphase.php new file mode 100644 index 000000000..7a82c658e --- /dev/null +++ b/application/controllers/api/frontend/v1/notiz/NotizProjektphase.php @@ -0,0 +1,32 @@ + ['admin:r', 'assistenz:r'], + ]); + } + + public function isBerechtigt($id, $typeId) + { + if($typeId != "projektphase_id") + { + $this->terminateWithError($this->p->t('ui','error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL); + } + + //TODO define permission + if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) + { + $result = $this->p->t('lehre','error_keineSchreibrechte'); + + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess("berechtigt in überschreibender Funktion"); + } +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/notiz/NotizProjekttask.php b/application/controllers/api/frontend/v1/notiz/NotizProjekttask.php new file mode 100644 index 000000000..aadb04f40 --- /dev/null +++ b/application/controllers/api/frontend/v1/notiz/NotizProjekttask.php @@ -0,0 +1,32 @@ + ['admin:r', 'assistenz:r'], + ]); + } + + public function isBerechtigt($id, $typeId) + { + if($typeId != "projekttask_id") + { + $this->terminateWithError($this->p->t('ui','error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL); + } + + //TODO define permission + if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) + { + $result = $this->p->t('lehre','error_keineSchreibrechte'); + + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess("berechtigt in überschreibender Funktion"); + } +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php b/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php index 26033908d..437ba42ad 100644 --- a/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php +++ b/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php @@ -36,15 +36,44 @@ class Aufnahmetermine extends FHCAPI_Controller // Load models $this->load->model('crm/Reihungstest_model', 'ReihungstestModel'); $this->load->model('crm/RtPerson_model', 'RtPersonModel'); + $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + $this->load->model('organisation/Studienordnung_model', 'StudienordnungModel'); + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); } public function getAufnahmetermine($person_id) { $result = $this->ReihungstestModel->getReihungstestPerson($person_id); + $arrayRt = $this->getDataOrTerminateWithError($result); - $data = $this->getDataOrTerminateWithError($result); + foreach ($arrayRt as $item) { + //Studienplan + $result = $this->StudienplanModel->loadWhere([ + 'studienplan_id' => $item->studienplan_id + ]); + $data = $this->getDataOrTerminateWithError($result); + $studienordnung_id_ber = current($data)->studienordnung_id; - $this->terminateWithSuccess($data); + //Studienordnung + $result = $this->StudienordnungModel->loadWhere([ + 'studienordnung_id' => $studienordnung_id_ber + ]); + $data = $this->getDataOrTerminateWithError($result); + $studiengang_kz_ber = current($data)->studiengang_kz; + + //Studiengang von studiengang_kz_ber + $result = $this->StudiengangModel->load($studiengang_kz_ber); + $data = $this->getDataOrTerminateWithError($result); + + $studiengangkurzbzlang_ber = current($data)->kurzbzlang; + $typ_ber = current($data)->typ; + + //add to Array + $item->studiengang_kz_ber = $studiengang_kz_ber; + $item->studiengangkurzbzlang_ber = $studiengangkurzbzlang_ber; + $item->studiengangtyp_ber = $typ_ber; + } + $this->terminateWithSuccess($arrayRt); } public function insertAufnahmetermin() @@ -60,7 +89,6 @@ class Aufnahmetermine extends FHCAPI_Controller return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person ID']), self::ERROR_TYPE_GENERAL); } - $rt_id = (isset($formData['rt_id']) && !empty($formData['rt_id'])) ? $formData['rt_id'] : null; $anmeldedatum = (isset($formData['anmeldedatum']) && !empty($formData['anmeldedatum'])) ? $formData['anmeldedatum'] : null; $teilgenommen = (isset($formData['teilgenommen']) && !empty($formData['teilgenommen'])) ? $formData['teilgenommen'] : false; @@ -224,7 +252,11 @@ class Aufnahmetermine extends FHCAPI_Controller ) ); - $data = $this->getDataOrTerminateWithError($result); + //check if existing placementtest + if(!hasData($result)) + $this->terminateWithSuccess([]); + else + $data = getData($result); $studienplan_arr = []; $include_ids = []; @@ -233,12 +265,18 @@ class Aufnahmetermine extends FHCAPI_Controller if($item->studienplan_id != null) $studienplan_arr[] = $item->studienplan_id; } + if(!hasData($studienplan_arr)) + $this->terminateWithSuccess([]); //get Placementtests Person $person_id = $this->_getPersonId($prestudent_id); $resultRt = $this->ReihungstestModel->getReihungstestPerson($person_id); - $dataRt = $this->getDataOrTerminateWithError($resultRt); + //check if existing placementtest + if(!hasData($result)) + $this->terminateWithSuccess([]); + else + $dataRt = getData($resultRt); foreach ($dataRt as $item) { @@ -354,6 +392,7 @@ class Aufnahmetermine extends FHCAPI_Controller $person_id = $this->input->get('person_id'); $punkte = $this->input->get('punkte'); $reihungstest_id = $this->input->get('reihungstest_id'); + $has_excluded_gebiete = $this->input->get('hasExcludedAreas'); if(!$reihungstest_id) { @@ -364,22 +403,27 @@ class Aufnahmetermine extends FHCAPI_Controller $studiengang_kz = $this->input->get('studiengang_kz'); $this->load->model('testtool/Ablauf_model', 'AblaufModel'); - $result = $this->AblaufModel->getAblaufGebieteAndGewichte($studiengang_kz); + $result = $this->AblaufModel->getAblaufGebieteAndGewichte($studiengang_kz, 1); $data = $this->getDataOrTerminateWithError($result); $weightedArray = []; + $basis_gebiet_id_arr = []; + $basis_gebiet_id_toString = ''; foreach ($data as $abl) { $weightedArray[$abl->gebiet_id] = $abl->gewicht; + $basis_gebiet_id_arr[]= $abl->gebiet_id; } + $basis_gebiet_id_toString = implode(', ', $basis_gebiet_id_arr); - $result = $this->ReihungstestModel->getReihungstestErgebnisPerson($person_id, $punkte, $reihungstest_id, $weightedArray); - -/* if (isError($result)) - { - $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); - }*/ - + $result = $this->ReihungstestModel->getReihungstestErgebnisPerson( + $person_id, + $punkte, + $reihungstest_id, + $weightedArray, + $has_excluded_gebiete, + $basis_gebiet_id_toString + ); $this->terminateWithSuccess($result); } diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index c787381f0..bc1fbebfe 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -200,7 +200,8 @@ class Config extends FHCAPI_Controller 'type' => 'select', 'values' => $buchungstyp_kurzbz_plus_all, 'value_key' => 'buchungstyp_kurzbz', - 'label_key' => 'beschreibung' + 'label_key' => 'beschreibung', + 'default' => 'all' ], 'samestg' => [ 'type' => 'bool', @@ -226,7 +227,8 @@ class Config extends FHCAPI_Controller 'type' => 'select', 'values' => $buchungstyp_kurzbz_plus_all, 'value_key' => 'buchungstyp_kurzbz', - 'label_key' => 'beschreibung' + 'label_key' => 'beschreibung', + 'default' => 'all' ], 'samestg' => [ 'type' => 'bool', diff --git a/application/controllers/api/frontend/v1/stv/Dokumente.php b/application/controllers/api/frontend/v1/stv/Dokumente.php index 9f54d0aa4..b8c7830bd 100644 --- a/application/controllers/api/frontend/v1/stv/Dokumente.php +++ b/application/controllers/api/frontend/v1/stv/Dokumente.php @@ -753,6 +753,10 @@ class Dokumente extends FHCAPI_Controller ); $data = $this->getDataOrTerminateWithError($result); + if(!(is_array($data) && count($data) > 0)) + { + return null; + } $student = current($data); return $student->student_uid; diff --git a/application/controllers/api/frontend/v1/stv/Student.php b/application/controllers/api/frontend/v1/stv/Student.php index 2fb354f0c..7694807e7 100644 --- a/application/controllers/api/frontend/v1/stv/Student.php +++ b/application/controllers/api/frontend/v1/stv/Student.php @@ -108,6 +108,10 @@ class Student extends FHCAPI_Controller $this->PrestudentModel->addSelect('p.matr_nr'); $this->PrestudentModel->addSelect('p.anrede'); $this->PrestudentModel->addSelect('p.zugangscode'); + if($this->permissionlib->isBerechtigt('student/bpk')) + { + $this->PrestudentModel->addSelect('p.bpk'); + } if (defined('ACTIVE_ADDONS') && strpos(ACTIVE_ADDONS, 'bewerbung') !== false) { $this->PrestudentModel->addSelect( diff --git a/application/controllers/api/frontend/v1/stv/Students.php b/application/controllers/api/frontend/v1/stv/Students.php index acacca052..55f4b8976 100644 --- a/application/controllers/api/frontend/v1/stv/Students.php +++ b/application/controllers/api/frontend/v1/stv/Students.php @@ -611,7 +611,7 @@ class Students extends FHCAPI_Controller if (!$verband && !$gruppe && $orgform_kurzbz !== null) { $this->PrestudentModel->db->where( "( - SELECT orgform_kurzbz + SELECT orgform_kurzbz FROM public.tbl_prestudentstatus WHERE prestudent_id=tbl_prestudent.prestudent_id AND studiensemester_kurzbz=" . $this->PrestudentModel->escape($studiensemester_kurzbz) . " @@ -850,6 +850,41 @@ class Students extends FHCAPI_Controller { $stdsemEsc = $studiensemester_kurzbz ? $this->PrestudentModel->escape($studiensemester_kurzbz) : 'NULL'; + $this->load->config('stv'); + $tags = $this->config->item('stv_prestudent_tags'); + + $whereTags = ''; + if (is_array($tags) && !isEmptyArray($tags)) { + $tags = array_keys($tags); + + foreach ($tags as $key => $tag) { + $tags[$key] = $this->db->escape($tag); + } + $whereTags = " AND nt.typ_kurzbz IN (" . implode(",", $tags) . ")"; + } + $subQueryTag = " + ( + SELECT + tag.prestudent_id, + COALESCE(json_agg(tag ORDER BY tag.done), '[]'::json) AS tags + FROM ( + SELECT DISTINCT ON (n.notiz_id) + n.notiz_id AS id, + nt.typ_kurzbz, + array_to_json(nt.bezeichnung_mehrsprachig)->>0 AS beschreibung, + n.text AS notiz, + nt.style, + n.erledigt AS done, + nz.prestudent_id + FROM public.tbl_notizzuordnung AS nz + JOIN public.tbl_notiz AS n ON nz.notiz_id = n.notiz_id + JOIN public.tbl_notiz_typ AS nt ON n.typ = nt.typ_kurzbz " + . $whereTags . + " + ) AS tag + GROUP BY tag.prestudent_id + ) AS tag_data_agg + "; $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); @@ -872,8 +907,11 @@ class Students extends FHCAPI_Controller AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')', 'LEFT'); + $this->PrestudentModel->addJoin($subQueryTag, 'tag_data_agg.prestudent_id = tbl_prestudent.prestudent_id', 'LEFT'); + $this->PrestudentModel->addSelect("b.uid"); + $this->PrestudentModel->addSelect('tag_data_agg.tags'); $this->PrestudentModel->addSelect('titelpre'); $this->PrestudentModel->addSelect('nachname'); $this->PrestudentModel->addSelect('vorname'); @@ -931,6 +969,7 @@ class Students extends FHCAPI_Controller $this->PrestudentModel->addSelect('mentor'); $this->PrestudentModel->addSelect('b.aktiv AS bnaktiv'); + $this->PrestudentModel->addSelect('unruly'); $this->PrestudentModel->db->where_in('tbl_prestudent.studiengang_kz', $this->allowedStgs); diff --git a/application/controllers/api/frontend/v1/stv/Tags.php b/application/controllers/api/frontend/v1/stv/Tags.php new file mode 100644 index 000000000..3004a1f3b --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Tags.php @@ -0,0 +1,48 @@ + self::BERECHTIGUNG_KURZBZ, + 'getTags' => self::BERECHTIGUNG_KURZBZ, + 'addTag' => self::BERECHTIGUNG_KURZBZ, + 'updateTag' => self::BERECHTIGUNG_KURZBZ, + 'doneTag' => self::BERECHTIGUNG_KURZBZ, + 'deleteTag' => self::BERECHTIGUNG_KURZBZ + ]); + + $this->config->load('stv'); + } + + public function getTag($readonly_tags = null) + { + parent::getTag($this->config->item('stv_prestudent_tags')); + } + public function getTags($tags = null) + { + parent::getTags($this->config->item('stv_prestudent_tags')); + } + public function addTag($withZuordnung = true, $updatable_tags = null) + { + parent::addTag(true, $this->config->item('stv_prestudent_tags')); + } + public function updateTag($updatable_tags = null) + { + parent::updateTag($this->config->item('stv_prestudent_tags')); + } + public function deleteTag($withZuordnung = true, $updatable_tags = null) + { + parent::deleteTag(true, $this->config->item('stv_prestudent_tags')); + } + public function doneTag($updatable_tags = null) + { + parent::doneTag($this->config->item('stv_prestudent_tags')); + } +} diff --git a/application/controllers/api/frontend/v1/vertraege/Config.php b/application/controllers/api/frontend/v1/vertraege/Config.php new file mode 100644 index 000000000..a4ebd8c48 --- /dev/null +++ b/application/controllers/api/frontend/v1/vertraege/Config.php @@ -0,0 +1,62 @@ +. + */ + +if (!defined('BASEPATH')) exit('No direct script access allowed'); + +use CI3_Events as Events; + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about the VV Config + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Config extends FHCAPI_Controller +{ + public function __construct() + { + parent::__construct([ + 'printDocument' => ['vertrag/mitarbeiter:r'], + ]); + } + + public function printDocument() + { + $params = []; + $menu = []; + + Events::trigger( + 'multiActionPrintHonorarvertrag', + // passing $menu per reference + function & () use (&$menu) { + return $menu; + }, + $params + ); + + if (is_array($menu) && isset($menu[0])) + { + $this->terminateWithSuccess($menu[0]); + } + else + { + // $this->terminateWithError('Error with Event 'multiActionPrintHonorarvertrag'); + $this->terminateWithSuccess(); + + } + } +} diff --git a/application/controllers/api/frontend/v1/vertraege/Vertraege.php b/application/controllers/api/frontend/v1/vertraege/Vertraege.php index bb14bc511..c0683e999 100644 --- a/application/controllers/api/frontend/v1/vertraege/Vertraege.php +++ b/application/controllers/api/frontend/v1/vertraege/Vertraege.php @@ -26,9 +26,6 @@ class Vertraege extends FHCAPI_Controller 'deleteLehrauftrag' =>['vertrag/mitarbeiter:w'], 'deleteBetreuung' =>['vertrag/mitarbeiter:w'], 'getMitarbeiter' => ['vertrag/mitarbeiter:r'], - 'getHeader' => ['vertrag/mitarbeiter:r'], - 'getPersonAbteilung' => ['vertrag/mitarbeiter:r'], - 'getLeitungOrg' => ['vertrag/mitarbeiter:r'], ]); //Load Models and Libraries @@ -241,7 +238,7 @@ class Vertraege extends FHCAPI_Controller } } $this->db->trans_complete(); - $this->terminateWithSuccess(true); + $this->terminateWithSuccess($vertrag_id); } public function updateContract() @@ -358,7 +355,7 @@ class Vertraege extends FHCAPI_Controller } $this->db->trans_complete(); - $this->terminateWithSuccess(true); + $this->terminateWithSuccess($vertrag_id); } public function loadContract($vertrag_id) @@ -684,37 +681,4 @@ class Vertraege extends FHCAPI_Controller } return $this->terminateWithSuccess(getData($result)); } - - public function getPersonAbteilung($mitarbeiter_uid) - { - $this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel'); - - $result = $this->Mitarbeitermodel->getPersonAbteilung($mitarbeiter_uid); - - $data = $this->getDataOrTerminateWithError($result); - - $this->terminateWithSuccess(current($data)); - } - - public function getLeitungOrg($oekurzbz) - { - $this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel'); - - $result = $this->Mitarbeitermodel->getLeitungOrg($oekurzbz); - - $data = $this->getDataOrTerminateWithError($result); - - $this->terminateWithSuccess(current($data)); - } - - public function getHeader($person_id) - { - $this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel'); - - $result = $this->Mitarbeitermodel->getHeader($person_id); - - $data = $this->getDataOrTerminateWithError($result); - - $this->terminateWithSuccess(current($data)); - } } diff --git a/application/core/CI3_Events.php b/application/core/CI3_Events.php index 37f6c3f21..ad4aea729 100644 --- a/application/core/CI3_Events.php +++ b/application/core/CI3_Events.php @@ -35,7 +35,7 @@ class CI3_Events }); self::$eventsSorted[$event] = true; } - + foreach (self::$events[$event] as $conf) { $conf[1](...$args); } diff --git a/application/core/Notiz_Controller.php b/application/core/Notiz_Controller.php index cfc54d5f5..923970923 100644 --- a/application/core/Notiz_Controller.php +++ b/application/core/Notiz_Controller.php @@ -8,7 +8,7 @@ abstract class Notiz_Controller extends FHCAPI_Controller { const DEFAULT_PERMISSION_R = 'admin:r'; const DEFAULT_PERMISSION_RW = 'admin:rw'; - //public function __construct($zuordnung = 'person/Notizzuordnung_model') + public function __construct($permissions) { $default_permissions = [ @@ -97,13 +97,13 @@ abstract class Notiz_Controller extends FHCAPI_Controller if (isError($result)) { $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } - return $this->terminateWithSuccess(getData($result) ?: []); + $this->terminateWithSuccess(getData($result) ?: []); } //Override function protected function isBerechtigt($id, $typeId){ - return $this->terminateWithError("in abstract function: define right in extension", self::ERROR_TYPE_GENERAL); + $this->terminateWithError("in abstract function: define right in extension", self::ERROR_TYPE_GENERAL); } public function loadNotiz() @@ -112,7 +112,6 @@ abstract class Notiz_Controller extends FHCAPI_Controller $notiz_id = $this->input->post('notiz_id'); - //$this->load->model('person/Notiz_model', 'NotizModel'); $this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT'); $this->NotizModel->addSelect('*'); $this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum @@ -143,14 +142,9 @@ abstract class Notiz_Controller extends FHCAPI_Controller $uid = getAuthUID(); - if (isset($_POST['data'])) - { - $data = json_decode($_POST['data']); - unset($_POST['data']); - foreach ($data as $k => $v) { - $_POST[$k] = $v; - } - } + $json = $this->input->post('data'); + $post_data = json_decode($json, true); + $this->form_validation->set_data($post_data); //Form Validation $this->form_validation->set_rules('titel', 'Titel', 'required', [ @@ -166,26 +160,25 @@ abstract class Notiz_Controller extends FHCAPI_Controller $this->terminateWithValidationErrors($this->form_validation->error_array()); } - $titel = $this->input->post('titel'); - $text = $this->input->post('text'); - $erledigt = $this->input->post('erledigt'); - $verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid; - $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : null; - $type = $this->input->post('typeId'); - $start = $this->input->post('start'); - $ende = $this->input->post('ende'); + $titel = $post_data['titel']; + $text = $post_data['text']; + $erledigt = $post_data['erledigt']; + $bearbeiter_uid = isset($post_data['bearbeiter']) ? $post_data['bearbeiter'] : null; + $type = $post_data['typeId']; + $start = isset($post_data['start']) ? $post_data['start'] : null; + $ende = isset($post_data['ende']) ? $post_data['ende'] : null; // Start DB transaction $this->db->trans_start(); //Save note - $result = $this->NotizModel->insert(array('titel' => $titel, 'text' => $text, 'erledigt' => $erledigt, 'verfasser_uid' => $verfasser_uid, - "insertvon" => $verfasser_uid, 'start' => $start, 'ende' => $ende, 'bearbeiter_uid' => $bearbeiter_uid)); + $result = $this->NotizModel->insert(array('titel' => $titel, 'text' => $text, 'erledigt' => $erledigt, 'verfasser_uid' => $uid, + "insertvon" => $uid, 'start' => $start, 'ende' => $ende, 'bearbeiter_uid' => $bearbeiter_uid)); if (isError($result)) { $this->db->trans_rollback(); - return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } $notiz_id = $result->retval; @@ -220,7 +213,7 @@ abstract class Notiz_Controller extends FHCAPI_Controller if (isError($result)) { $this->db->trans_rollback(); - return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } $dms_id_arr[] = $result->retval['dms_id']; } @@ -235,34 +228,28 @@ abstract class Notiz_Controller extends FHCAPI_Controller if (isError($result)) { $this->db->trans_rollback(); - return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } } } $this->db->trans_commit(); - return $this->terminateWithSuccess($result); + $this->terminateWithSuccess($result); } public function updateNotiz() { + $this->load->library('form_validation'); $this->load->library('DmsLib'); - if (isset($_POST['data'])) - { - $data = json_decode($_POST['data']); - unset($_POST['data']); - foreach ($data as $k => $v) { - $_POST[$k] = $v; - } - } + $json = $this->input->post('data'); + $post_data = json_decode($json, true); - $notiz_id = $this->input->post('notiz_id'); + $this->form_validation->set_data($post_data); - if(!$notiz_id) - { - $this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL); - } + $this->form_validation->set_rules('notiz_id', 'Notiz ID', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'notiz_id']) + ]); //Form Validation $this->form_validation->set_rules('titel', 'Titel', 'required', [ @@ -280,25 +267,23 @@ abstract class Notiz_Controller extends FHCAPI_Controller //update Notiz $uid = getAuthUID(); - $titel = $this->input->post('titel'); - $text = $this->input->post('text'); - $verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid; - $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid; - $erledigt = $this->input->post('erledigt'); - $start = $this->input->post('start'); - $ende = $this->input->post('ende'); + $titel = $post_data['titel']; + $text = $post_data['text']; + $bearbeiter_uid = isset($post_data['bearbeiter']) ? $post_data['bearbeiter'] : $post_data['bearbeiter_uid']; + $erledigt = $post_data['erledigt']; + $start = $post_data['start']; + $ende = $post_data['ende']; $result = $this->NotizModel->update( [ - 'notiz_id' => $notiz_id + 'notiz_id' => $post_data['notiz_id'], ], [ 'titel' => $titel, 'updatevon' => $uid, 'updateamum' => date('c'), 'text' => $text, - 'verfasser_uid' => $verfasser_uid, - 'bearbeiter_uid' => $bearbeiter_uid, + 'bearbeiter_uid' => isEmptyString($bearbeiter_uid) ? null : $bearbeiter_uid, 'start' => $start, 'ende' => $ende, 'erledigt' => $erledigt @@ -306,7 +291,7 @@ abstract class Notiz_Controller extends FHCAPI_Controller ); if (isError($result)) { - return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } //update(1) loading all dms-entries with this notiz_id @@ -314,7 +299,7 @@ abstract class Notiz_Controller extends FHCAPI_Controller $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); $this->NotizdokumentModel->addJoin('campus.tbl_dms_version', 'dms_id'); - $result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id)); + $result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $post_data['notiz_id'])); $result = $this->getDataOrTerminateWithError($result); foreach ($result as $doc) { $dms_id_arr[$doc->dms_id] = array( @@ -351,7 +336,7 @@ abstract class Notiz_Controller extends FHCAPI_Controller $result = $this->getDataOrTerminateWithError($result); $dms_id = $result['dms_id']; - $result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id)); + $result = $this->NotizdokumentModel->insert(array('notiz_id' => $post_data['notiz_id'], 'dms_id' => $dms_id)); $this->getDataOrTerminateWithError($result); } @@ -365,7 +350,7 @@ abstract class Notiz_Controller extends FHCAPI_Controller $this->getDataOrTerminateWithError($result); } - return $this->terminateWithSuccess($result); + $this->terminateWithSuccess($result); } public function deleteNotiz() @@ -416,15 +401,15 @@ abstract class Notiz_Controller extends FHCAPI_Controller if (isError($result)) { $this->db->trans_rollback(); - return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } if(!hasData($result)) { - return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); + $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); } $this->db->trans_complete(); - return $this->terminateWithSuccess(getData($result)); + $this->terminateWithSuccess(getData($result)); } public function loadDokumente() @@ -440,14 +425,14 @@ abstract class Notiz_Controller extends FHCAPI_Controller array('public.tbl_notiz.notiz_id' => $notiz_id) ); if (isError($result)) { - return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } if(!hasData($result)) { - return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); + $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); } - return $this->terminateWithSuccess(getData($result)); + $this->terminateWithSuccess(getData($result)); } public function getMitarbeiter($searchString) @@ -457,7 +442,7 @@ abstract class Notiz_Controller extends FHCAPI_Controller if (isError($result)) { $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } - return $this->terminateWithSuccess($result); + $this->terminateWithSuccess($result); } public function getCountNotes($person_id) @@ -476,4 +461,4 @@ abstract class Notiz_Controller extends FHCAPI_Controller return $this->terminateWithSuccess($anzahl->anzahl ?: 0); } -} \ No newline at end of file +} diff --git a/application/helpers/hlp_header_helper.php b/application/helpers/hlp_header_helper.php index 4f5a65cf7..937d5c3ff 100644 --- a/application/helpers/hlp_header_helper.php +++ b/application/helpers/hlp_header_helper.php @@ -279,3 +279,199 @@ function absoluteJsImportUrl($relurl) } return $url; } + +/* + * Manipulate CI views includes Array to load + * - public/js/FhcApps.js via customJSs and + * - app customisation js and/or css from extensions via customJSModules + * if customJSModules contains at least one vuejs app and customisation files + * exist in extensions + */ +class ExtendableAppsHelper +{ + private static $instance = null; + + protected $extensions; + + protected $customCSSs; + protected $customJSs; + protected $customJSModules; + + protected $initialised; + protected $appscount; + + protected $extCustomCSSs; + protected $extCustomJSs; + protected $extCustomJSModules; + + private function __construct() + { + $this->extensions = array(); + $this->customCSSs = null; + $this->customJSs = null; + $this->customJSModules = null; + + $this->initialised = false; + $this->appscount = 0; + + $this->extCustomCSSs = null; + $this->extCustomJSs = null; + $this->extCustomJSModules = null; + } + + public static function getInstance() + { + if(self::$instance === null) + { + self::$instance = new ExtendableAppsHelper(); + } + return self::$instance; + } + + public function init($customCSSs, $customJSs, $customJSModules) + { + if($this->initialised) + { + return; + } + + $this->customCSSs = $customCSSs; + $this->customJSs = $customJSs; + $this->customJSModules = $customJSModules; + $this->initialised = true; + + if(!isset($this->customJSModules)) + { + return; + } + + if(!is_array($this->customJSModules)) + { + $this->customJSModules = array($this->customJSModules); + } + + if(count($this->customJSModules) < 1) + { + return; + } + + $this->buildExtensionsList(); + $this->prepareExtendedArrays(); + } + + public function getCustomCSSs() + { + if(is_null($this->extCustomCSSs)) + { + return $this->customCSSs; + } + return $this->extCustomCSSs; + } + + public function getCustomJSs() + { + if(is_null($this->extCustomJSs)) + { + return $this->customJSs; + } + return $this->extCustomJSs; + } + + public function getCustomJSModules() + { + if(is_null($this->extCustomJSModules)) + { + return $this->customJSModules; + } + return $this->extCustomJSModules; + } + + protected function buildExtensionsList() + { + $this->extensions = array(); + $fsiterator = new FilesystemIterator(FHCPATH . 'application/extensions'); + foreach ($fsiterator as $fsitem) + { + if(preg_match('/^FHC-Core-/', $fsitem->getBasename())) + { + $this->extensions[] = $fsitem->getBasename(); + } + } + } + + protected function prepareExtendedArrays() + { + $this->appscount = 0; + $this->initExtCustomCSSs(); + $this->extCustomJSModules = array(); + foreach($this->customJSModules as $item) + { + $matches = array(); + if(preg_match('#^public/(extensions/FHC-Core-.+)?js/apps/(.*)\.js$#', $item, $matches)) + { + $this->appscount++; + + $fhcextension = $matches[1]; + $app = $matches[2]; + + $extend_js_suffix = 'js/extend_app/' . $fhcextension . $app . '.js'; + $extend_css_suffix = 'css/extend_app/' . $fhcextension . $app . '.css'; + + foreach($this->extensions as $extension) + { + $extend_js = 'public/extensions/' . $extension . '/' . $extend_js_suffix; + $extend_css = 'public/extensions/' . $extension . '/' . $extend_css_suffix; + + if(is_readable(FHCPATH . $extend_js)) + { + array_push($this->extCustomJSModules, $extend_js); + } + + if(is_readable(FHCPATH . $extend_css)) + { + array_push($this->extCustomCSSs, $extend_css); + } + } + } + array_push($this->extCustomJSModules, $item); + } + + if($this->appscount > 0) + { + $this->addFhcAppsJs(); + } + } + + protected function initExtCustomCSSs() + { + if(!isset($this->customCSSs)) + { + $this->extCustomCSSs = array(); + } + elseif(!is_array($this->customCSSs)) + { + $this->extCustomCSSs = array($this->customCSSs); + } + else + { + $this->extCustomCSSs = $this->customCSSs; + } + } + + protected function addFhcAppsJs() + { + if(!isset($this->customJSs)) + { + $this->extCustomJSs = array(); + } + elseif(!is_array($this->customJSs)) + { + $this->extCustomJSs = array($this->customJSs); + } + else + { + $this->extCustomJSs = $this->customJSs; + } + array_push($this->extCustomJSs, 'public/js/FhcApps.js'); + } +} diff --git a/application/libraries/DocsboxLib.php b/application/libraries/DocsboxLib.php index f9167c379..184855ad8 100644 --- a/application/libraries/DocsboxLib.php +++ b/application/libraries/DocsboxLib.php @@ -180,7 +180,8 @@ class DocsboxLib } // Just started or still working on it elseif ($getStatusResponse->body->status == self::STATUS_WORKING - || $getStatusResponse->body->status == self::STATUS_STARTED) + || $getStatusResponse->body->status == self::STATUS_STARTED + || $getStatusResponse->body->status == self::STATUS_QUEUED) { // go on! } diff --git a/application/models/accounting/Vertrag_model.php b/application/models/accounting/Vertrag_model.php index 4c036369b..97b5c72b6 100644 --- a/application/models/accounting/Vertrag_model.php +++ b/application/models/accounting/Vertrag_model.php @@ -490,6 +490,175 @@ class Vertrag_model extends DB_Model return $bezeichnung; } + /** + * Loads all Contracts of a Person + * @param $person_id + * @return array of objects + */ + public function loadContractsOfPerson($person_id) + { + $query = " + SELECT + *, + tbl_vertrag.bezeichnung as bezeichnung, + tbl_vertragstyp.bezeichnung as vertragstyp_bezeichnung, + tbl_vertrag.vertragsdatum, + (SELECT bezeichnung FROM lehre.tbl_vertragsstatus + JOIN lehre.tbl_vertrag_vertragsstatus USING(vertragsstatus_kurzbz) + WHERE vertrag_id=tbl_vertrag.vertrag_id ORDER BY datum desc limit 1) as status, anmerkung, + CASE + WHEN EXISTS ( + SELECT 1 + FROM lehre.tbl_vertrag_vertragsstatus + WHERE vertrag_id = tbl_vertrag.vertrag_id + AND vertragsstatus_kurzbz = 'abgerechnet' + ) THEN true + ELSE false + END AS isAbgerechnet + FROM + lehre.tbl_vertrag + LEFT JOIN lehre.tbl_vertragstyp USING(vertragstyp_kurzbz) + WHERE person_id= ?"; + + + return $this->execQuery($query, array($person_id)); + } + + /** + * Loads all Contracts of a Person that are not assigned yet + * @param $person_id + * @return array of objects + */ + public function loadContractsOfPersonNotAssigned($person_id) + { + $query = " +SELECT + 'Lehrauftrag' as type, + lehreinheit_id, + mitarbeiter_uid, + null as pruefung_id, + null as projektarbeit_id, + (tbl_lehreinheitmitarbeiter.semesterstunden*tbl_lehreinheitmitarbeiter.stundensatz) as betrag1, + tbl_lehreinheit.studiensemester_kurzbz, + null as betreuerart_kurzbz, + ( SELECT + upper(tbl_studiengang.typ || tbl_studiengang.kurzbz) || tbl_lehrveranstaltung.semester || '-' || tbl_lehrveranstaltung.kurzbz || '-' || tbl_lehreinheit.lehrform_kurzbz + FROM + lehre.tbl_lehrveranstaltung + JOIN public.tbl_studiengang USING(studiengang_kz) + WHERE + lehrveranstaltung_id=tbl_lehreinheit.lehrveranstaltung_id) + as bezeichnung + FROM + lehre.tbl_lehreinheitmitarbeiter + JOIN lehre.tbl_lehreinheit USING(lehreinheit_id) + WHERE + mitarbeiter_uid IN (SELECT uid FROM public.tbl_benutzer WHERE person_id=?) + AND vertrag_id IS NULL + UNION + SELECT + 'Betreuung' as type, + tbl_projektarbeit.lehreinheit_id as lehreinheit_id, + null as mitarbeiter_uid, + null::integer as pruefung_id, + projektarbeit_id, + (tbl_projektbetreuer.stunden*tbl_projektbetreuer.stundensatz) as betrag1, + tbl_lehreinheit.studiensemester_kurzbz, + tbl_projektbetreuer.betreuerart_kurzbz, + (SELECT nachname || ' ' || vorname FROM public.tbl_person JOIN public.tbl_benutzer USING(person_id) WHERE uid=tbl_projektarbeit.student_uid) + as bezeichnung + FROM + lehre.tbl_projektbetreuer + JOIN lehre.tbl_projektarbeit USING(projektarbeit_id) + JOIN lehre.tbl_lehreinheit USING(lehreinheit_id) + WHERE + tbl_projektbetreuer.person_id=? + AND vertrag_id IS NULL + "; + + return $this->execQuery($query, array($person_id, $person_id)); + } + + /** + * Loads all Contracts of a Person that are assigned yet + * @param $person_id, $vertrag_id + * @return array of objects + */ + + public function loadContractsOfPersonAssigned($person_id, $vertrag_id) + { + $query = " + SELECT + 'Lehrauftrag' as type, + lehreinheit_id, + mitarbeiter_uid, + null as pruefung_id, + null as projektarbeit_id, + (tbl_lehreinheitmitarbeiter.semesterstunden * tbl_lehreinheitmitarbeiter.stundensatz) as betrag, + tbl_lehreinheit.studiensemester_kurzbz, + null as betreuerart_kurzbz, + ( SELECT + upper(tbl_studiengang.typ || tbl_studiengang.kurzbz) || tbl_lehrveranstaltung.semester || '-' || tbl_lehrveranstaltung.kurzbz || '-' || tbl_lehreinheit.lehrform_kurzbz + FROM + lehre.tbl_lehrveranstaltung + JOIN public.tbl_studiengang USING(studiengang_kz) + WHERE + lehrveranstaltung_id=tbl_lehreinheit.lehrveranstaltung_id) + as bezeichnung, vertrag_id + FROM + lehre.tbl_lehreinheitmitarbeiter + JOIN lehre.tbl_lehreinheit USING(lehreinheit_id) + WHERE + mitarbeiter_uid IN (SELECT uid FROM public.tbl_benutzer WHERE person_id=?) + AND vertrag_id = ? + UNION + SELECT + 'Betreuung' as type, + tbl_projektarbeit.lehreinheit_id as lehreinheit_id, + null as mitarbeiter_uid, + null::integer as pruefung_id, + projektarbeit_id, + (tbl_projektbetreuer.stunden * tbl_projektbetreuer.stundensatz) as betrag, + tbl_lehreinheit.studiensemester_kurzbz, + tbl_projektbetreuer.betreuerart_kurzbz, + (SELECT nachname || ' ' || vorname FROM public.tbl_person JOIN public.tbl_benutzer USING(person_id) WHERE uid=tbl_projektarbeit.student_uid) + as bezeichnung, vertrag_id + FROM + lehre.tbl_projektbetreuer + JOIN lehre.tbl_projektarbeit USING(projektarbeit_id) + JOIN lehre.tbl_lehreinheit USING(lehreinheit_id) + WHERE + tbl_projektbetreuer.person_id=? + AND vertrag_id = ? + "; + + return $this->execQuery($query, array($person_id, $vertrag_id, $person_id, $vertrag_id)); + } + + /** + * Returns all stati of a contract + * + * @param $vertrag_id + * @return array + */ + public function getStatiOfContract($vertrag_id) + { + $query = " + SELECT + *, + tbl_vertrag_vertragsstatus.datum, + tbl_vertrag_vertragsstatus.insertamum, + tbl_vertrag_vertragsstatus.updateamum + FROM + lehre.tbl_vertrag_vertragsstatus + JOIN lehre.tbl_vertragsstatus USING(vertragsstatus_kurzbz) + WHERE + tbl_vertrag_vertragsstatus.vertrag_id = ? + ORDER BY tbl_vertrag_vertragsstatus.datum DESC"; + + return $this->execQuery($query, array($vertrag_id)); + } + private function _updateVertragRelevant($vertrag_id) { $this->LehreinheitmitarbeiterModel->update( diff --git a/application/models/accounting/Vertragstyp_model.php b/application/models/accounting/Vertragstyp_model.php index 42d248217..a3275af6e 100644 --- a/application/models/accounting/Vertragstyp_model.php +++ b/application/models/accounting/Vertragstyp_model.php @@ -11,4 +11,5 @@ class Vertragstyp_model extends DB_Model $this->dbTable = 'lehre.tbl_vertragstyp'; $this->pk = 'vertragstyp_kurzbz'; } + } diff --git a/application/models/accounting/Vertragvertragsstatus_model.php b/application/models/accounting/Vertragvertragsstatus_model.php index 78a065540..75b0794cc 100644 --- a/application/models/accounting/Vertragvertragsstatus_model.php +++ b/application/models/accounting/Vertragvertragsstatus_model.php @@ -190,4 +190,6 @@ class Vertragvertragsstatus_model extends DB_Model return $this->loadWhere($condition); } + + } diff --git a/application/models/crm/Reihungstest_model.php b/application/models/crm/Reihungstest_model.php index a685b01cd..efef0a8fa 100644 --- a/application/models/crm/Reihungstest_model.php +++ b/application/models/crm/Reihungstest_model.php @@ -10,7 +10,7 @@ class Reihungstest_model extends DB_Model parent::__construct(); $this->dbTable = 'public.tbl_reihungstest'; $this->pk = 'reihungstest_id'; - } + } /** * Gets a test from a test id only if it is available @@ -42,8 +42,8 @@ class Reihungstest_model extends DB_Model /** * Checks if there are active studyplans which have no public placement tests assigned yet. * Only check assignment to studyplans that are - * - Bachelor, - * - active, + * - Bachelor, + * - active, * - set as online application * - valid for 1st terms * @return array Returns object array with studyplans that have no public placement tests assigned yet. @@ -97,7 +97,7 @@ class Reihungstest_model extends DB_Model USING (reihungstest_id) WHERE datum >= now() - AND + AND oeffentlich = \'t\' ) '; @@ -105,7 +105,7 @@ class Reihungstest_model extends DB_Model return $this->execQuery($query); } - /** + /** * Gets amount of free places. * @return array Returns object array with faculty and amount of free places * for each public actual placement test date. @@ -432,10 +432,10 @@ class Reihungstest_model extends DB_Model } /** - * Loads all applicants of a placement test - * @param integer $reihungstest_id ID of placement test - * @return array Returns object array with data of applicants. - */ + * Loads all applicants of a placement test + * @param integer $reihungstest_id ID of placement test + * @return array Returns object array with data of applicants. + */ public function getApplicantsOfPlacementTest($reihungstest_id) { $query = ' @@ -556,13 +556,22 @@ class Reihungstest_model extends DB_Model * Calculates Result of Placement Test for a given Person and given placementtest * and with taking account of weighting per area * - * @param $person_id ID of Person - * @param $punkte if true result is points else result is percentage of sum - * @param $reihungstest_id ID of Placementtest - * @param $weightedArray array of weighting per area (gewicht per gebiet_id) - * @return float result + * @param Number $person_id ID of Person + * @param Boolean $punkte if true result is points else result is percentage of sum + * @param Number $reihungstest_id ID of Placementtest + * @param Array $weightedArray array of weighting per area (gewicht per gebiet_id) + * @param Boolean $has_excluded_gebiete if true, areas in the configArray will be excluded + * @param Array $basis_gebiet_id_toString areas to exclude + * @return float result points of RT */ - public function getReihungstestErgebnisPerson($person_id, $punkte, $reihungstest_id, $weightedArray = null) + public function getReihungstestErgebnisPerson( + $person_id, + $punkte, + $reihungstest_id, + $weightedArray = null, + $has_excluded_gebiete = false, + $basis_gebiet_id_toString = null + ) { $parametersArray = array($reihungstest_id); @@ -577,6 +586,35 @@ class Reihungstest_model extends DB_Model WHERE reihungstest_id = ? "; + //areas of Studiengang + if (!empty($basis_gebiet_id_toString)) + { + $qry .= " + AND + gebiet_id IN (". $basis_gebiet_id_toString. ") + "; + } + + //areas to exclude + if($has_excluded_gebiete) + { + if (defined('FAS_REIHUNGSTEST_EXCLUDE_GEBIETE') && !empty(FAS_REIHUNGSTEST_EXCLUDE_GEBIETE)) + { + $excluded_gebiete = unserialize(FAS_REIHUNGSTEST_EXCLUDE_GEBIETE); + $exclude_gebiet_id_arr = $excluded_gebiete; + if (is_array($exclude_gebiet_id_arr) && count($exclude_gebiet_id_arr) > 0) + { + $exclude_gebiet_id_toString = implode(', ', $exclude_gebiet_id_arr); + $qry .= " + AND + gebiet_id NOT IN (". $exclude_gebiet_id_toString. ") + -- AND + -- typ = 'b' + "; + } + } + } + //using prestudent Status to avoid to get the sum of more than 1 placement tests $qry .= " AND prestudent_id = ( diff --git a/application/models/ressource/Mitarbeiter_model.php b/application/models/ressource/Mitarbeiter_model.php index a650643f1..d8bbd7d63 100644 --- a/application/models/ressource/Mitarbeiter_model.php +++ b/application/models/ressource/Mitarbeiter_model.php @@ -209,7 +209,7 @@ class Mitarbeiter_model extends DB_Model { $qry = " SELECT - titelpre, vorname, nachname, titelpost, foto, foto_sperre, person_id, alias, telefonklappe + titelpre, vorname, nachname, titelpost, foto, foto_sperre, person_id, alias, telefonklappe, personalnummer, mitarbeiter_uid FROM public.tbl_person JOIN public.tbl_benutzer b USING(person_id) @@ -363,14 +363,14 @@ class Mitarbeiter_model extends DB_Model $returnwert .= ", ma.mitarbeiter_uid, CONCAT(p.nachname, ' ', p.vorname, ' (', ma.mitarbeiter_uid , ')') as mitarbeiter"; $qry = " - SELECT " . $returnwert . " - FROM + SELECT " . $returnwert . " + FROM public.tbl_mitarbeiter ma - JOIN + JOIN public.tbl_benutzer b on (ma.mitarbeiter_uid = b.uid) - JOIN + JOIN public.tbl_person p on (p.person_id = b.person_id) - WHERE + WHERE lower (p.nachname) LIKE '%". $this->db->escape_like_str($filter)."%' OR lower (p.vorname) LIKE '%". $this->db->escape_like_str($filter)."%' @@ -393,14 +393,14 @@ class Mitarbeiter_model extends DB_Model public function getMitarbeiterFromLV($lehrveranstaltung_id) { $qry = "SELECT DISTINCT - lehrveranstaltung_id, uid, vorname, wahlname, vornamen, nachname, titelpre, titelpost, kurzbz, mitarbeiter_uid - FROM + lehrveranstaltung_id, uid, vorname, wahlname, vornamen, nachname, titelpre, titelpost, kurzbz, mitarbeiter_uid + FROM lehre.tbl_lehreinheitmitarbeiter, campus.vw_mitarbeiter, lehre.tbl_lehreinheit - WHERE + WHERE lehrveranstaltung_id= ? - AND - mitarbeiter_uid=uid - AND + AND + mitarbeiter_uid=uid + AND tbl_lehreinheitmitarbeiter.lehreinheit_id=tbl_lehreinheit.lehreinheit_id;"; $parametersArray = array($lehrveranstaltung_id); diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index 19129b606..3e59d7250 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -276,6 +276,8 @@ class Message_model extends DB_Model s.message_id, s.person_id, MAX(s.insertamum) as lastinserted from public.tbl_msg_status s + join + filtered_messages fm on fm.message_id = s.message_id and fm.recipient_id = s.person_id group by s.message_id, s.person_id ) ls diff --git a/application/views/Cis/LvInfo.php b/application/views/Cis/LvInfo.php deleted file mode 100644 index 49a7b7a85..000000000 --- a/application/views/Cis/LvInfo.php +++ /dev/null @@ -1,15 +0,0 @@ - 'LvInfo', - 'customJSModules' => ['public/js/apps/Cis/LvInfo.js'] -); - -$this->load->view('templates/CISVUE-Header', $includesArray); -?> - -