diff --git a/application/config/cis.php b/application/config/cis.php index 82655f244..8d3bc347e 100644 --- a/application/config/cis.php +++ b/application/config/cis.php @@ -7,3 +7,9 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); $config['cis_menu_root_content_id'] = 11087; // send Mails for ProfilUpdate $config['cis_send_profil_update_mails'] = true; +// Vilesci CI BaseUrl +$config['cis_vilesci_base_url'] = defined('VILESCI_ROOT') ? VILESCI_ROOT : APP_ROOT; +$config['cis_vilesci_index_page'] = 'index.ci.php'; +// Cis CI BaseUrl +$config['cis_base_url'] = defined('CIS_ROOT') ? CIS_ROOT : APP_ROOT; +$config['cis_index_page'] = 'cis.php'; diff --git a/application/config/lvverwaltung.php b/application/config/lvverwaltung.php new file mode 100644 index 000000000..4fe09bff3 --- /dev/null +++ b/application/config/lvverwaltung.php @@ -0,0 +1,11 @@ + ['readonly' => false], + 'tag_1' => ['readonly' => true] +]; +*/ + +$config['lvverwaltung_tags'] = []; \ No newline at end of file diff --git a/application/config/navigation.php b/application/config/navigation.php index 5cbb6512c..11fd1a3a6 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -64,7 +64,7 @@ $config['navigation_header'] = array( 'lehrveranstaltungen' => array( 'link' => site_url('lehre/lvplanung/LvTemplateUebersicht'), 'icon' => '', - 'description' => 'Lehrveranstaltungen', + 'description' => 'Lehrveranstaltungen Templates', 'sort' => 15 ), 'reihungstest' => array( @@ -81,6 +81,16 @@ $config['navigation_header'] = array( 'sort' => 30, 'requiredPermissions' => 'infocenter:r' ), + 'lvverwaltung' => array( + 'link' => site_url('LVVerwaltung'), + 'icon' => '', + 'description' => 'LV Verwaltung', + 'requiredPermissions' => array( + 'admin:r', + 'assistenz:r' + ), + 'sort' => 35 + ), 'lehrauftrag' => array( 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/Dashboard'), 'description' => 'Lehrauftrag', diff --git a/application/config/routes.php b/application/config/routes.php index 52bf535ca..de8e6e098 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -63,6 +63,7 @@ $route['api/v1/system/[S|s]prache/(:any)'] = 'api/v1/system/sprache2/$1'; $route['Cis/LvPlan/.*'] = 'Cis/LvPlan/index/$1'; $route['Cis/MyLvPlan/.*'] = 'Cis/MyLvPlan/index/$1'; +$route['Cis/MyLv/.*'] = 'Cis/MyLv/index/$1'; // Studierendenverwaltung List Routes $route['api/frontend/v1/stv/[sS]tudents/inout'] = 'api/frontend/v1/stv/Students/index'; diff --git a/application/config/searchcis.php b/application/config/searchcis.php index e3d1e2213..12bad025d 100644 --- a/application/config/searchcis.php +++ b/application/config/searchcis.php @@ -27,7 +27,7 @@ $config['student']['resultfields'] = [ "(p.vorname || ' ' || p.nachname) AS name", "ARRAY[s.student_uid || '@' || '" . DOMAIN . "'] AS email", "CASE - WHEN p.foto IS NOT NULL THEN 'data:image/jpeg' || CONVERT_FROM(DECODE('3b','hex'), 'UTF8') || 'base64,' || p.foto + WHEN (p.foto_sperre = false AND p.foto IS NOT NULL) THEN 'data:image/jpeg' || CONVERT_FROM(DECODE('3b','hex'), 'UTF8') || 'base64,' || p.foto ELSE NULL END AS photo_url", "b.aktiv" diff --git a/application/config/stv.php b/application/config/stv.php index 675899108..42afc318c 100644 --- a/application/config/stv.php +++ b/application/config/stv.php @@ -83,3 +83,33 @@ if (!defined('ZGV_DOKTOR_ANZEIGEN') || !ZGV_DOKTOR_ANZEIGEN) { $fieldsZgvDoktor ); } + +$config['student_tab_order'] = [ + 'details', + 'notes', + 'messages', + 'contact', + 'prestudent', + 'status', + 'documents', + 'archive', + 'banking', + 'grades', + 'exam', + 'exemptions', + 'finalexam', + 'mobility', + 'jointstudies', + 'admissionDates', + 'groups', + 'functions', + 'coursedates', + 'resources', +]; +$config['students_tab_order'] = [ + 'banking', + 'status', + 'groups', + 'finalexam', + 'archive', +]; diff --git a/application/controllers/Cis/ProfilUpdate.php b/application/controllers/Cis/ProfilUpdate.php index c47b7540b..74641d748 100644 --- a/application/controllers/Cis/ProfilUpdate.php +++ b/application/controllers/Cis/ProfilUpdate.php @@ -9,54 +9,21 @@ if (!defined('BASEPATH')) class ProfilUpdate extends Auth_Controller { - public static $STATUS_PENDING = NULL; - public static $STATUS_ACCEPTED = NULL; - public static $STATUS_REJECTED = NULL; - - public static $TOPICS = []; - - public function __construct() { parent::__construct([ 'index' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r'], - 'id' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r'], - 'getProfilUpdateWithPermission' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r'], - 'acceptProfilRequest' => ['student/stammdaten:rw', 'mitarbeiter/stammdaten:rw'], - 'denyProfilRequest' => ['student/stammdaten:rw', 'mitarbeiter/stammdaten:rw'], 'show' => ['basis/cis:r'], - - 'insertProfilRequest' => ['basis/cis:rw'], - 'updateProfilRequest' => ['basis/cis:rw'], - 'deleteProfilRequest' => ['basis/cis:rw'], - 'selectProfilRequest' => ['basis/cis:r'], - 'insertFile' => ['basis/cis:rw'], - 'getProfilRequestFiles' => ['basis/cis:r'], - 'getStatus' => ['basis/cis:r'], - 'getTopic' => ['basis/cis:r'], + 'id' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r'] ]); - $this->load->config('cis'); - $this->load->model('person/Profil_update_model', 'ProfilUpdateModel'); - $this->load->model('person/Kontakt_model', 'KontaktModel'); - $this->load->model('person/Adresse_model', 'AdresseModel'); - $this->load->model('person/Adressentyp_model', 'AdressenTypModel'); - $this->load->model('person/Person_model', 'PersonModel'); $this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel'); $this->load->model('crm/Student_model', 'StudentModel'); - $this->load->model('person/Benutzer_model', 'BenutzerModel'); - $this->load->model('system/Sprache_model', 'SpracheModel'); - $this->load->model('person/Profil_update_status_model', 'ProfilUpdateStatusModel'); - $this->load->model('person/Profil_update_topic_model', 'ProfilUpdateTopicModel'); // Load language phrases $this->loadPhrases( array( - 'ui', - 'global', - 'person', - 'profil', 'profilUpdate' ) ); @@ -64,32 +31,10 @@ class ProfilUpdate extends Auth_Controller $this->load->library('DmsLib'); $this->load->library('PermissionLib'); - //? put the uid and pid inside the controller for reusability $this->uid = getAuthUID(); $this->pid = getAuthPersonID(); - - // setup the ProfilUpdate states - $this->ProfilUpdateStatusModel->addSelect(['status_kurzbz']); - $status_kurzbz = $this->ProfilUpdateStatusModel->load(); - if (hasData($status_kurzbz)) { - list($status_pending, $status_accepted, $status_rejected) = getData($status_kurzbz); - - self::$STATUS_PENDING = $status_pending->status_kurzbz; - self::$STATUS_ACCEPTED = $status_accepted->status_kurzbz; - self::$STATUS_REJECTED = $status_rejected->status_kurzbz; - } - // setup the ProfilUpdate topics - $this->ProfilUpdateTopicModel->addSelect(['topic_kurzbz']); - $topic_kurzbz = $this->ProfilUpdateTopicModel->load(); - - if (hasData($topic_kurzbz)) { - foreach (getData($topic_kurzbz) as $topic) { - self::$TOPICS[$topic->topic_kurzbz] = $topic->topic_kurzbz; - } - } } - public function index() { $this->load->view('Cis/ProfilUpdate'); @@ -100,129 +45,14 @@ class ProfilUpdate extends Auth_Controller $this->load->view('Cis/ProfilUpdate', ['profil_update_id' => $profil_update_id]); } - public function getStatus() - { - echo json_encode([self::$STATUS_PENDING => self::$STATUS_PENDING, self::$STATUS_ACCEPTED => self::$STATUS_ACCEPTED, self::$STATUS_REJECTED => self::$STATUS_REJECTED]); - } - - public function getTopic() - { - echo json_encode(self::$TOPICS); - } - - private function sendEmail_onProfilUpdate_response($uid, $topic, $status) - { - if($this->config->item('cis_send_profil_update_mails') === false) - { - return; - } - - $this->load->helper('hlp_sancho_helper'); - $email = $uid . "@" . DOMAIN; - - - function languageQuery($language) - { - return "select index from public.tbl_sprache where sprache = '" + $language + "'"; - } - $this->ProfilUpdateStatusModel->addSelect(["bezeichnung_mehrsprachig[(" . languageQuery('German') . ")] as status_de", "bezeichnung_mehrsprachig[(" . languageQuery('English') . ")] as status_en"]); - $status_translation = $this->ProfilUpdateStatusModel->loadWhere(["status_kurzbz" => $status]); - if (isError($status_translation)) { - show_error($this->p->t('profilUpdate', 'ProfilUpdateStatusTranslationError')); - } - $status_translation = hasData($status_translation) ? getData($status_translation)[0] : null; - if (isset($status_translation)) { - $mail_res = sendSanchoMail("profil_update_response", ['topic' => $topic, 'status_de' => $status_translation->status_de, 'status_en' => $status_translation->status_en, 'href' => APP_ROOT . 'Cis/Profil'], $email, ("Profil Änderung " . $this->p->t('profilUpdate', 'pending'))); - if (!$mail_res) { - show_error($this->p->t('profilUpdate', 'profilUpdate_email_error')); - } - } - - } - - - private function sendEmail_onProfilUpdate_insertion($uid, $profil_update_id, $topic) - { - if($this->config->item('cis_send_profil_update_mails') === false) - { - return; - } - - $this->load->helper('hlp_sancho_helper'); - $emails = []; - - $isMitarbeiter_res = $this->MitarbeiterModel->isMitarbeiter($uid); - if (isError($isMitarbeiter_res)) { - show_error($this->p->t('profilUpdate', 'profilUpdate_mitarbeiterCheck_error')); - } - $isMitarbeiter_res = getData($isMitarbeiter_res); - - //! if the $uid is a mitarbeiter and student, only the hr is notified by email - if ($isMitarbeiter_res) { - //? user is not a student therefore he is a mitarbeiter, send email to Personalverwaltung - //? use constant variable MAIL_GST to mail to the personalverwaltung - $this->MitarbeiterModel->addSelect([TRUE]); - $this->MitarbeiterModel->addJoin("public.tbl_benutzer", "public.tbl_benutzer.uid = public.tbl_mitarbeiter.mitarbeiter_uid"); - //? check if the the userID is a mitarbeiter and if the benutzer is active - $res = $this->MitarbeiterModel->loadWhere(["public.tbl_mitarbeiter.mitarbeiter_uid" => $uid, "public.tbl_benutzer.aktiv" => TRUE]); - if (isError($res)) { - show_error("was not able to query the mitarbeiter and benutzer by the uid: " . $uid); - } - if (hasData($res)) { - array_push($emails, MAIL_GST); - } else { - show_error($this->p->t('profilUpdate', 'profilUpdate_mitarbeiterCheck_error')); - } - } else { - //? if it is not a mitarbeiter, check whether it is a student and send email to studiengang - $isStudent_res = $this->StudentModel->isStudent($uid); - if (isError($isStudent_res)) { - show_error($this->p->t('profilUpdate', 'profilUpdate_studentCheck_error')); - } - $isStudent_res = getData($isStudent_res); - if ($isStudent_res) { - //? Send email to the Studiengangsassistentinnen - $this->StudentModel->addSelect(["public.tbl_studiengang.email"]); - $this->StudentModel->addJoin("public.tbl_benutzer", "public.tbl_benutzer.uid = public.tbl_student.student_uid"); - $this->StudentModel->addJoin("public.tbl_prestudent", "public.tbl_benutzer.person_id = public.tbl_prestudent.person_id"); - $this->StudentModel->addJoin("public.tbl_prestudentstatus", "public.tbl_prestudentstatus.prestudent_id = public.tbl_prestudent.prestudent_id"); - $this->StudentModel->addJoin("public.tbl_studiengang", "public.tbl_studiengang.studiengang_kz = public.tbl_prestudent.studiengang_kz"); - //* check if the benutzer itself is active - //* check if the student status is Student or Diplomand (active students) - $this->StudentModel->db->where_in("public.tbl_prestudentstatus.status_kurzbz", ['Student', 'Diplomand']); - $res = $this->StudentModel->loadWhere(["public.tbl_benutzer.aktiv" => TRUE, "public.tbl_student.student_uid" => $uid]); - if (isError($res)) { - show_error(getData($res)); - } else { - $res = hasData($res) ? getData($res) : []; - foreach ($res as $emailObj) { - array_push($emails, $emailObj->email); - } - } - } - } - $mail_res = []; - //? sending email - foreach ($emails as $email) { - array_push($mail_res, sendSanchoMail("profil_update", ['uid' => $uid, 'topic' => $topic, 'href' => APP_ROOT . 'Cis/ProfilUpdate/id/' . $profil_update_id], $email, ("Profil Änderung von " . $uid))); - } - foreach ($mail_res as $m_res) { - if (!$m_res) { - show_error($this->p->t('profilUpdate', 'profilUpdate_email_error')); - } - } - - } - - public function show($dms_id) { - $profil_update = $this->ProfilUpdateModel->loadWhere(['attachment_id' => $dms_id]); $profil_update = hasData($profil_update) ? getData($profil_update)[0] : null; //? checks if an profil update exists with the dms_id requested from the user - if ($profil_update) { + if ($profil_update) + { $is_mitarbeiter_profil_update = getData($this->MitarbeiterModel->isMitarbeiter($profil_update->uid)); $is_student_profil_update = getData($this->StudentModel->isStudent($profil_update->uid)); @@ -230,7 +60,8 @@ class ProfilUpdate extends Auth_Controller $this->permissionlib->isBerechtigt('student/stammdaten:r') && $is_student_profil_update || $this->permissionlib->isBerechtigt('mitarbeiter/stammdaten:r') && $is_mitarbeiter_profil_update || $this->uid == $profil_update->uid - ) { + ) + { // Get file to be downloaded from DMS $newFilename = $this->uid . "/document_" . $dms_id; $download = $this->dmslib->download($dms_id); @@ -239,576 +70,17 @@ class ProfilUpdate extends Auth_Controller // Download file $this->outputFile(getData($download)); - - - } else { + } + else + { show_error($this->p->t('profilUpdate', 'profilUpdate_permission_error')); return; } - - } else { + } + else + { show_error($this->p->t('profilUpdate', 'profilUpdate_dms_error')); return; } - } - - - public function insertFile($replace) - { - $replace = json_decode($replace); - - if (!count($_FILES)) { - echo json_encode([]); - return; - } - - //? if replace is set it contains the profil_update_id in which the attachment_id has to be replaced - if (isset($replace)) { - $this->ProfilUpdateModel->addSelect(["attachment_id"]); - $profilUpdate = $this->ProfilUpdateModel->load([$replace]); - if (isError($profilUpdate)) { - return json_encode(error($this->p->t('profilUpdate', 'profilUpdate_loading_error'))); - } - //? get the attachmentID - $dms_id = hasData($profilUpdate) ? getData($profilUpdate)[0]->attachment_id : null; - - //? delete old dms_file of Profil Update - $this->deleteOldVersionFile($dms_id); - } - - - $files = $_FILES['files']; - $file_count = count($files['name']); - - $res = []; - - for ($i = 0; $i < $file_count; $i++) { - $_FILES['files']['name'] = $files['name'][$i]; - $_FILES['files']['type'] = $files['type'][$i]; - $_FILES['files']['tmp_name'] = $files['tmp_name'][$i]; - $_FILES['files']['error'] = $files['error'][$i]; - $_FILES['files']['size'] = $files['size'][$i]; - - $dms = [ - "kategorie_kurzbz" => "profil_aenderung", - "version" => 0, - "name" => $_FILES['files']['name'], - "mimetype" => $_FILES['files']['type'], - "beschreibung" => $this->uid . " Profil Änderung", - "insertvon" => $this->uid, - "insertamum" => "NOW()", - ]; - - $tmp_res = $this->dmslib->upload($dms, 'files', array("jpg", "png", "pdf")); - - $tmp_res = hasData($tmp_res) ? getData($tmp_res) : null; - array_push($res, $tmp_res); - } - - echo json_encode($res); - } - - - public function selectProfilRequest() - { - $_GET = json_decode($this->input->raw_input_stream, true); - $uid = $this->input->get('uid'); - $id = $this->input->get('id'); - $whereClause = ['uid' => $this->uid]; - - if (isset($uid)) - $whereClause['uid'] = $uid; - if (isset($id)) - $whereClause['id'] = $id; - - $res = $this->ProfilUpdateModel->getProfilUpdatesWhere($whereClause); - $res = hasData($res) ? getData($res) : null; - echo json_encode($res); - - } - - - public function getProfilRequestFiles() - { - $id = json_decode($this->input->raw_input_stream); - - $this->ProfilUpdateModel->addSelect(["attachment_id"]); - $attachmentID = $this->ProfilUpdateModel->load([$id]); - if (isError($attachmentID)) { - return json_encode(error($this->p->t('profilUpdate', 'profilUpdate_loading_error'))); - } - //? get the attachmentID - $dms_id = hasData($attachmentID) ? getData($attachmentID)[0]->attachment_id : null; - - //? get the name to the file - $this->DmsVersionModel->addSelect(["name", "dms_id"]); - $attachment = $this->DmsVersionModel->load([$dms_id, 0]); - if (isError($attachment)) { - return json_encode(error($this->p->t('profilUpdate', 'profilUpdate_dmsVersion_error'))); - } - $attachment = hasData($attachment) ? getData($attachment) : null; - //? returns {name:..., dms_id:...} - echo json_encode($attachment); - } - - public function insertProfilRequest() - { - - $json = json_decode($this->input->raw_input_stream); - - $payload = $json->payload; - $identifier = property_exists($json->payload, "kontakt_id") ? "kontakt_id" : (property_exists($json->payload, "adresse_id") ? "adresse_id" : null); - - $data = ["topic" => $json->topic, "uid" => $this->uid, "requested_change" => json_encode($payload), "insertamum" => "NOW()", "insertvon" => $this->uid, "status" => self::$STATUS_PENDING ?: 'Pending']; - - //? insert fileID in the dataset if sent with post request - if (isset($json->fileID)) { - $data['attachment_id'] = $json->fileID; - - } - - //? loops over all updateRequests from a user to validate if the new request is valid - $res = $this->ProfilUpdateModel->getProfilUpdatesWhere(["uid" => $this->uid]); - if (isError($res)) { - show_error($this->p->t('profilUpdate', 'profilUpdate_loading_error')); - } - $res = hasData($res) ? getData($res) : null; - - //? the user cannot delete a zustelladresse/kontakt - if (isset($payload->delete) && $payload->{$identifier == "kontakt_id" ? "zustellung" : "zustelladresse"}) { - echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_deleteZustellung_error'))); - return; - } - - //? if the user tries to delete a adresse, checks whether the adresse is a heimatadresse, if so an error is raised - if (isset($payload->delete) && $identifier == "adresse_id") { - $adr = $this->AdresseModel->load($payload->$identifier); - $adr = getData($adr)[0]; - if ($adr->heimatadresse) { - echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_deleteZustellung_error'))); - return; - } - } - - if ($res) { - $pending_changes = array_filter($res, function ($element) { - return $element->status == (self::$STATUS_PENDING ?: "Pending"); - }); - - foreach ($pending_changes as $update_request) { - $existing_change = $update_request->requested_change; - - //? the user can add as many new kontakte/adressen as he likes - if (!isset($payload->add) && property_exists($existing_change, $identifier) && property_exists($payload, $identifier) && $existing_change->$identifier == $payload->$identifier) { - //? the kontakt_id / adresse_id of a change has to be unique - echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_changeTwice_error'))); - return; - } - - //? if it is not updating any kontakt/adresse, the topic has to be unique - elseif (!$identifier && $update_request->topic == $json->topic) { - echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_changeTopicTwice_error', ['0' => $update_request->topic]))); - return; - } - } - } - - $insertID = $this->ProfilUpdateModel->insert($data); - - if (isError($insertID)) { - show_error(getData($insertID)); - } else { - $insertID = hasData($insertID) ? getData($insertID) : null; - - //? sends emails to the correspondents of the $uid - $this->sendEmail_onProfilUpdate_insertion($this->uid, $insertID, $json->topic); - echo json_encode(success($insertID)); - } - } - - public function updateProfilRequest() - { - $json = json_decode($this->input->raw_input_stream); - - $updateData = ["requested_change" => json_encode($json->payload), "updateamum" => "NOW()", "updatevon" => $this->uid]; - if (isset($json->fileID)) { - $updateData['attachment_id'] = json_decode($json->fileID); - } - $updateID = $this->ProfilUpdateModel->update([$json->ID], $updateData); - //? insert fileID in the dataset if sent with post request - - if (isError($updateID)) { - //catch error - } else { - $updateID = hasData($updateID) ? getData($updateID)[0] : null; - //TODO: should an email be sent to the responsable people when the user changes his profil update - echo json_encode(success($updateID)); - } - } - - public function deleteProfilRequest() - { - - $json = json_decode($this->input->raw_input_stream); - $delete_res = $this->ProfilUpdateModel->delete([$json]); - echo json_encode($delete_res); - } - - - public function getProfilUpdateWithPermission($status = null) - { - // early return if no status has been passed as argument - if (!isset($status)) { - echo json_encode($this->ProfilUpdateModel->getProfilUpdateWithPermission()); - return; - } - - // get the sprache of the user - $sprachenIndex = $this->SpracheModel->loadWhere(["sprache" => getUserLanguage()]); - $sprachenIndex = hasData($sprachenIndex) ? getData($sprachenIndex)[0]->index : null; - - if (isset($sprachenIndex) && isset($status)) { - // get the corresponding status kurz_bz primary key out of the translation - $status = $this->ProfilUpdateStatusModel->execReadOnlyQuery("select * from public.tbl_profil_update_status where ? = ANY(bezeichnung_mehrsprachig)", [$status]); - $status = hasData($status) ? getData($status)[0]->status_kurzbz : null; - $res = $this->ProfilUpdateModel->getProfilUpdateWithPermission(isset($status) ? ['status' => $status] : null); - - echo json_encode($res); - } - } - - - - private function getOE_from_student($student_uid) - { - - //? returns the oe_einheit eines Studenten - $query = "SELECT public.tbl_studiengang.oe_kurzbz - FROM public.tbl_student - JOIN public.tbl_studiengang ON tbl_student.studiengang_kz = public.tbl_studiengang.studiengang_kz - WHERE public.tbl_student.student_uid = ?;"; - - $res = $this->StudentModel->execReadOnlyQuery($query, [$student_uid]); - if (!isSuccess($res)) { - show_error($this->p->t('profilUpdate', 'profilUpdate_loadingOE_error')); - } - $res = hasData($res) ? getData($res) : []; - $res = array_map( - function ($item) { - return $item->oe_kurzbz; - }, - $res - ); - return $res; - } - - - public function acceptProfilRequest() - { - $_POST = json_decode($this->input->raw_input_stream, true); - $id = $this->input->post('profil_update_id', true); - $uid = $this->input->post('uid', true); - - //? fetching person_id using UID - $personID = $this->PersonModel->getByUid($uid); - $personID = hasData($personID) ? getData($personID)[0]->person_id : null; - $status_message = $this->input->post('status_message', true); - $topic = $this->input->post('topic', true); - - //! somehow the xss check converted boolean false to empty string - $requested_change = $this->input->post('requested_change'); - - //! check for required information - if (!isset($id) || !isset($uid) || !isset($personID) || !isset($requested_change) || !isset($topic)) { - return json_encode(error($this->p->t('profilUpdate', 'profilUpdate_requiredInformation_error'))); - } - - $is_mitarbeiter_profil_update = getData($this->MitarbeiterModel->isMitarbeiter($uid)); - $is_student_profil_update = getData($this->StudentModel->isStudent($uid)); - - - //? check if the permissions are set correctly - if ( - $this->permissionlib->isBerechtigt('student/stammdaten', "suid", $this->getOE_from_student($uid)) && $is_student_profil_update || - $this->permissionlib->isBerechtigt('mitarbeiter/stammdaten', "suid") && $is_mitarbeiter_profil_update - ) { - - if (is_array($requested_change) && array_key_exists("adresse_id", $requested_change)) { - $insertID = $this->handleAdresse($requested_change, $personID); - $insertID = hasData($insertID) ? getData($insertID) : null; - if (isset($insertID)) { - $requested_change['adresse_id'] = $insertID; - $update_res = $this->updateRequestedChange($id, $requested_change); - if (isError($update_res)) { - echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_address_error', [$insertID]))); - return; - } - } - - } else if (is_array($requested_change) && array_key_exists("kontakt_id", $requested_change)) { - $insertID = $this->handleKontakt($requested_change, $personID); - $insertID = hasData($insertID) ? getData($insertID) : null; - if (isset($insertID)) { - $requested_change['kontakt_id'] = $insertID; - $update_res = $this->updateRequestedChange($id, $requested_change); - if (isError($update_res)) { - echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_kontakt_error', [$insertID]))); - return; - } - } - - - } else { - switch ($topic) { - // mapping phrasen to database columns to make the update with the correct column names - case self::$TOPICS['Titel']: - $topic = "titelpre"; - break; - case self::$TOPICS['Postnomen']: - $topic = "titelpost"; - break; - case self::$TOPICS['Vorname']: - $topic = "vorname"; - break; - case self::$TOPICS['Nachname']: - $topic = "nachname"; - break; - default: - show_error($this->p->t('profilUpdate', 'profilUpdate_topic_error', [$topic])); - return; - } - - $result = $this->PersonModel->update($personID, [$topic => $requested_change["value"]]); - if (isError($result)) { - echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_insert_error'))); - return; - } - } - $this->sendEmail_onProfilUpdate_response($uid, $topic, self::$STATUS_ACCEPTED); - - echo json_encode($this->setStatusOnUpdateRequest($id, self::$STATUS_ACCEPTED, $status_message, $requested_change)); - } else { - show_error($this->p->t('profilUpdate', 'profilUpdate_permission_error')); - } - - - } - - public function denyProfilRequest() - { - - $_POST = json_decode($this->input->raw_input_stream, true); - $id = $this->input->post('profil_update_id', true); - $uid = $this->input->post('uid', true); - $topic = $this->input->post('topic', true); - $status_message = $this->input->post('status_message', true); - - $is_mitarbeiter_profil_update = getData($this->MitarbeiterModel->isMitarbeiter($uid)); - $is_student_profil_update = getData($this->StudentModel->isStudent($uid)); - - - if ( - $this->permissionlib->isBerechtigt('student/stammdaten', "suid", $this->getOE_from_student($uid)) && $is_student_profil_update || - $this->permissionlib->isBerechtigt('mitarbeiter/stammdaten', "suid") && $is_mitarbeiter_profil_update - ) { - $this->sendEmail_onProfilUpdate_response($uid, $topic, self::$STATUS_REJECTED); - echo json_encode($this->setStatusOnUpdateRequest($id, self::$STATUS_REJECTED, $status_message)); - } else { - show_error($this->p->t('profilUpdate', 'profilUpdate_permission_error')); - } - - - } - - private function updateRequestedChange($id, $requested_change) - { - return $this->ProfilUpdateModel->update([$id], ['requested_change' => json_encode($requested_change)]); - } - - private function setStatusOnUpdateRequest($id, $status, $status_message) - { - return $this->ProfilUpdateModel->update([$id], ["status" => $status, "status_timestamp" => "NOW()", "status_message" => $status_message]); - } - - private function deleteOldVersionFile($dms_id) - { - if (!isset($dms_id)) { - return; - } - - //? collect all the results of the deleted versions in an array - $res = array(); - - //? delete all the different versions of the dms_file - $dmsVersions = $this->DmsVersionModel->loadWhere(["dms_id" => $dms_id]); - $dmsVersions = hasData($dmsVersions) ? getData($dmsVersions) : null; - if (isset($dmsVersions)) { - $zwischen_res = array_map(function ($item) { - return $item->version; - }, $dmsVersions); - foreach ($zwischen_res as $version) { - array_push($res, $this->DmsVersionModel->delete([$dms_id, $version])); - } - } else { - echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_dmsVersion_error'))); - } - - //? returns a result for each deleted dms_file - return $res; - } - - - private function handleKontakt($requested_change, $personID) - { - $kontakt_id = $requested_change["kontakt_id"]; - //? removes the kontakt_id because we don't want to update the kontakt_id in the database - unset($requested_change["kontakt_id"]); - - - //! ADD - if (array_key_exists('add', $requested_change) && $requested_change['add']) { - //? removes add flag - unset($requested_change['add']); - $requested_change['person_id'] = $personID; - $requested_change['insertamum'] = "NOW()"; - $requested_change['insertvon'] = getAuthUID(); - $insertID = $this->KontaktModel->insert($requested_change); - $insert_kontakt_id = $insertID; - if (isError($insert_kontakt_id)) { - show_error($this->p->t('profilUpdate', 'profilUpdate_insertKontakt_error')); - } - $insert_kontakt_id = hasData($insert_kontakt_id) ? getData($insert_kontakt_id) : null; - if ($insert_kontakt_id) { - $this->handleDupplicateZustellKontakte($requested_change['zustellung'], $insert_kontakt_id); - } - - - } - //! DELETE - elseif (array_key_exists('delete', $requested_change) && $requested_change['delete']) { - $this->KontaktModel->delete($kontakt_id); - } - //! UPDATE - else { - $requested_change['updateamum'] = "NOW()"; - $requested_change['updatevon'] = getAuthUID(); - - $update_kontakt_id = $this->KontaktModel->update($kontakt_id, $requested_change); - - if (isError($update_kontakt_id)) { - show_error($this->p->t('profilUpdate', 'profilUpdate_updateKontakt_error')); - } - $update_kontakt_id = hasData($update_kontakt_id) ? getData($update_kontakt_id) : null; - if ($update_kontakt_id) { - $this->handleDupplicateZustellKontakte($requested_change['zustellung'], $update_kontakt_id); - } - } - return isset($insertID) ? $insertID : null; - } - - private function handleAdresse($requested_change, $personID) - { - - $this->AdressenTypModel->addSelect(["adressentyp_kurzbz"]); - $adr_kurzbz = $this->AdressenTypModel->loadWhere(["bezeichnung" => $requested_change['typ']]); - $adr_kurzbz = hasData($adr_kurzbz) ? getData($adr_kurzbz)[0]->adressentyp_kurzbz : null; - //? replace the address_typ with its correct kurzbz foreign key - $requested_change['typ'] = $adr_kurzbz; - - $adresse_id = $requested_change["adresse_id"]; - //? removes the adresse_id because we don't want to update the kontakt_id in the database - unset($requested_change["adresse_id"]); - - - //! ADD - if (array_key_exists('add', $requested_change) && $requested_change['add']) { - - //? removes add flag - unset($requested_change['add']); - $requested_change['insertamum'] = "NOW()"; - $requested_change['insertvon'] = getAuthUID(); - $requested_change['person_id'] = $personID; - //TODO: zustelladresse, heimatadresse, rechnungsadresse und nation werden nicht beachtet - $insertID = $this->AdresseModel->insert($requested_change); - $insert_adresse_id = $insertID; - if (isError($insert_adresse_id)) { - show_error($this->p->t('profilUpdate', 'profilUpdate_insertAdresse_error')); - } - $insert_adresse_id = hasData($insert_adresse_id) ? getData($insert_adresse_id) : null; - if ($insert_adresse_id) { - $this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $insert_adresse_id); - } - - } - //! DELETE - elseif (array_key_exists('delete', $requested_change) && $requested_change['delete']) { - $this->AdresseModel->delete($adresse_id); - } - //! UPDATE - else { - $requested_change['updateamum'] = "NOW()"; - $requested_change['updatevon'] = getAuthUID(); - $update_adresse_id = $this->AdresseModel->update($adresse_id, $requested_change); - if (isError($update_adresse_id)) { - show_error($this->p->t('profilUpdate', 'profilUpdate_updateAdresse_error')); - } - $update_adresse_id = hasData($update_adresse_id) ? getData($update_adresse_id) : null; - if ($update_adresse_id) { - $this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $update_adresse_id); - } - } - return isset($insertID) ? $insertID : null; - } - - - private function handleDupplicateZustellKontakte($zustellung, $kontakt_id) - { - if ($zustellung) { - $this->PersonModel->addSelect("public.tbl_kontakt.kontakt_id"); - $this->PersonModel->addJoin("public.tbl_kontakt", "public.tbl_kontakt.person_id = public.tbl_person.person_id"); - $zustellKontakteArray = $this->PersonModel->loadWhere(["public.tbl_person.person_id" => $this->pid, "zustellung" => TRUE]); - if (!isSuccess($zustellKontakteArray)) { - return error($this->p->t('profilUpdate', 'profilUpdate_loadingZustellkontakte_error')); - } - $zustellKontakteArray = hasData($zustellKontakteArray) ? getData($zustellKontakteArray) : null; - - if ($zustellung && count($zustellKontakteArray) > 0) { - $zustellKontakteArray = array_filter($zustellKontakteArray, function ($kontakt) use ($kontakt_id) { - return $kontakt->kontakt_id != $kontakt_id; - }); - foreach ($zustellKontakteArray as $kontakt) { - $this->KontaktModel->update($kontakt->kontakt_id, ["zustellung" => FALSE]); - } - - } - } - } - - private function handleDupplicateZustellAdressen($zustellung, $adresse_id) - { - if ($zustellung) { - $this->PersonModel->addSelect("public.tbl_adresse.adresse_id"); - $this->PersonModel->addJoin("public.tbl_adresse", "public.tbl_adresse.person_id = public.tbl_person.person_id"); - $zustellAdressenArray = $this->PersonModel->loadWhere(["public.tbl_person.person_id" => $this->pid, "zustelladresse" => TRUE]); - if (!isSuccess($zustellAdressenArray)) { - return error($this->p->t('profilUpdate', 'profilUpdate_loadingZustellAdressen_error')); - } - $zustellAdressenArray = hasData($zustellAdressenArray) ? getData($zustellAdressenArray) : null; - - if ($zustellung && count($zustellAdressenArray) > 0) { - - $zustellAdressenArray = array_filter($zustellAdressenArray, function ($adresse) use ($adresse_id) { - - return $adresse->adresse_id != $adresse_id; - }); - foreach ($zustellAdressenArray as $adresse) { - $this->AdresseModel->update($adresse->adresse_id, ["zustelladresse" => FALSE]); - } - - } - } - } - - -} \ No newline at end of file +} diff --git a/application/controllers/LVVerwaltung.php b/application/controllers/LVVerwaltung.php new file mode 100644 index 000000000..2a79d6375 --- /dev/null +++ b/application/controllers/LVVerwaltung.php @@ -0,0 +1,42 @@ +method] = ['admin:r', 'assistenz:r']; + parent::__construct($permissions); + + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + } + + /** + * @return void + */ + public function _remap() + { + $this->load->view('LVVerwaltung', [ + 'permissions' => [ + 'lehre/lehrveranstaltung' => $this->permissionlib->isBerechtigt('lehre/lehrveranstaltung'), + 'lv-plan/gruppenentfernen' => $this->permissionlib->isBerechtigt('lv-plan/gruppenentfernen'), + 'lv-plan/lektorentfernen' => $this->permissionlib->isBerechtigt('lv-plan/lektorentfernen'), + ], + 'variables' => [ + 'semester_aktuell' => $this->variablelib->getVar('semester_aktuell') + ], + 'configs' => [ + 'showVertragsdetails' => defined('FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN') && FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN, + 'showGewichtung' => defined('CIS_GESAMTNOTE_GEWICHTUNG') && CIS_GESAMTNOTE_GEWICHTUNG, + 'lehreinheitAnmerkungDefault' => defined('LEHREINHEIT_ANMERKUNG_DEFAULT') ? LEHREINHEIT_ANMERKUNG_DEFAULT : '', + 'lehreinheitRaumtypDefault' => defined('DEFAULT_LEHREINHEIT_RAUMTYP') ? DEFAULT_LEHREINHEIT_RAUMTYP : '', + 'lehreinheitRaumtypAlternativeDefault' => defined('DEFAULT_LEHREINHEIT_RAUMTYP_ALTERNATIV') ? DEFAULT_LEHREINHEIT_RAUMTYP_ALTERNATIV : '' + ] + ]); + + } +} diff --git a/application/controllers/api/frontend/v1/Lehrveranstaltung.php b/application/controllers/api/frontend/v1/Lehrveranstaltung.php new file mode 100644 index 000000000..2e254bfc8 --- /dev/null +++ b/application/controllers/api/frontend/v1/Lehrveranstaltung.php @@ -0,0 +1,265 @@ +. + */ + +if (!defined('BASEPATH')) + exit('No direct script access allowed'); + +class Lehrveranstaltung extends FHCAPI_Controller +{ + private $_ci; + private $_uid; + + public function __construct() + { + parent::__construct([ + 'getByEmp' => ['admin:r', 'assistenz:r'], + 'getByStg' => ['admin:r', 'assistenz:r'], + 'loadByLV' => ['admin:r', 'assistenz:r'], + ]); + + $this->_ci = &get_instance(); + $this->_setAuthUID(); + + $this->_ci->load->model('education/Lehreinheit_model', 'LehreinheitModel'); + $this->_ci->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->_ci->load->library('VariableLib', ['uid' => $this->_uid]); + + $this->loadPhrases( + array( + 'ui' + ) + ); + } + + public function getByEmp($studiensemester_kurzbz = null, $mitarbeiter_uid = null, $stg_kz = null) + { + + if (is_null($mitarbeiter_uid)) + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $studiensemester_kurzbz = $this->getStudiensemesterKurzbz($studiensemester_kurzbz); + + $lehrveranstaltungen = $this->_ci->LehreinheitModel->getLvsByEmployee($mitarbeiter_uid, $studiensemester_kurzbz, $stg_kz); + $lehrveranstaltungen_data = $this->getDataOrTerminateWithError($lehrveranstaltungen); + + $tree = []; + + foreach ($lehrveranstaltungen_data as $lehrveranstaltung) + { + $lehreinheiten = $this->_ci->LehreinheitModel->getByLvidStudiensemester($lehrveranstaltung->lehrveranstaltung_id, $studiensemester_kurzbz, $mitarbeiter_uid); + $lehreinheiten_data = $this->getDataOrTerminateWithError($lehreinheiten); + + if (!isset($lehrveranstaltung->_children)) + { + $lehrveranstaltung->_children = $lehreinheiten_data; + } + $tree[] = $lehrveranstaltung; + } + + $this->terminateWithSuccess($tree); + } + public function getByStg($studiensemester_kurzbz = null, $studiengang_kz = null, $semester = null) + { + if (is_null($studiengang_kz) || !preg_match("/^-?[1-9][0-9]*$/", (string)$studiengang_kz)) + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $verband = null; + if (!is_null($semester) && !is_numeric($semester)) + { + $verband = $semester; + $semester = null; + } + + $this->_ci->load->model('organisation/Studienplan_model', 'StudienplanModel'); + + $studiensemester_kurzbz = $this->getStudiensemesterKurzbz($studiensemester_kurzbz); + $studienplan_data = $this->_ci->StudienplanModel->getStudienplaeneBySemester($studiengang_kz, $studiensemester_kurzbz, $semester, $verband); + + $studienplan_ids = array(); + $only_ids = array(); + $placeholders = array(); + + if (hasData($studienplan_data)) + { + foreach (getData($studienplan_data) as $studienplan) { + $placeholders[] = "(?, ?)"; + $studienplan_ids[] = $studienplan->studienplan_id; + $studienplan_ids[] = $studienplan->semester; + $only_ids[] = $studienplan->studienplan_id; + } + } + + $lehrveranstaltungen_data = $this->_ci->LehrveranstaltungModel->getLvsByStudiengang($studienplan_ids, $placeholders, $only_ids, $studiengang_kz, $studiensemester_kurzbz, $semester, $verband); + $lehrveranstaltungen_data = hasData($lehrveranstaltungen_data) ? getData($lehrveranstaltungen_data) : array(); + + $tree = []; + foreach ($lehrveranstaltungen_data as $row) + { + $rowData = $row; + + $lehreinheiten_data = $this->_ci->LehreinheitModel->getByLvidStudiensemester($row->lehrveranstaltung_id, $studiensemester_kurzbz); + + if (hasData($lehreinheiten_data)) + { + $lehreinheiten = getData($lehreinheiten_data); + $rowData->_children = $lehreinheiten; + } + + if (!isEmptyString($row->studienplan_lehrveranstaltung_id_parent)) + { + $child = $this->_ci->StudienplanModel->loadStudienplanLehrveranstaltung($row->studienplan_lehrveranstaltung_id_parent); + + if (hasData($child)) + { + $child = getData($child)[0]; + $searchId = $child->lehrveranstaltung_id; + + foreach ($lehrveranstaltungen_data as &$searchParent) + { + if ($searchParent->lehrveranstaltung_id === $searchId) + { + if (!isset($searchParent->_children)) + { + $searchParent->_children = []; + } + + if (is_array($searchParent->_children)) + { + $searchParent->_children[] = $row; + } + else + { + $searchParent->_children = [$searchParent->_children, $row]; + } + break; + } + } + + } + } + else + { + $tree[] = $rowData; + } + } + + $counter = 0; + $this->assignUniqueIndex($tree, $counter); + $this->terminateWithSuccess($tree); + } + + + public function loadByLV($lehrveranstaltung_id = null) + { + if (is_null($lehrveranstaltung_id) || !ctype_digit((string)$lehrveranstaltung_id)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $this->_ci->LehrveranstaltungModel->addSelect('lehrveranstaltung_id, lehrform_kurzbz, lehre, bezeichnung as lvbezeichnung, sprache'); + $lehrveranstaltung_result = $this->_ci->LehrveranstaltungModel->loadWhere(array('lehrveranstaltung_id' => $lehrveranstaltung_id)); + $lehrveranstaltung_result = $this->getDataOrTerminateWithError($lehrveranstaltung_result); + $lehrveranstaltung = $lehrveranstaltung_result[0]; + + $this->_ci->LehreinheitModel->addSelect('lehrveranstaltung_id_kompatibel'); + $this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehrveranstaltung_kompatibel', 'lehrveranstaltung_id'); + $lehrfaecher = $this->_ci->LehreinheitModel->loadWhere(array('lehrveranstaltung_id' => $lehrveranstaltung->lehrveranstaltung_id)); + + $lehrfaecher_array = []; + if (hasData($lehrfaecher)) + $lehrfaecher_array = array_merge($lehrfaecher_array, array_column(getData($lehrfaecher), 'lehrveranstaltung_id_kompatibel')); + + $lehrfaecher_array[] = $lehrveranstaltung->lehrveranstaltung_id; + + $this->_ci->LehrveranstaltungModel->addDistinct('lehrfach_id'); + $this->_ci->LehrveranstaltungModel->addSelect("tbl_lehrveranstaltung.lehrveranstaltung_id, CONCAT(tbl_lehrveranstaltung.bezeichnung || '(' || tbl_lehrveranstaltung.oe_kurzbz || ')') as lehrfach"); + $this->_ci->LehrveranstaltungModel->db->where_in('tbl_lehrveranstaltung.lehrveranstaltung_id', $lehrfaecher_array); + $lehrfaecher_result = $this->_ci->LehrveranstaltungModel->load(); + + $lehrfaecher_array = hasData($lehrfaecher_result) ? getData($lehrfaecher_result) : array(); + + $lehrveranstaltung->lehrfaecher = $lehrfaecher_array; + $this->terminateWithSuccess($lehrveranstaltung); + } + + /* + * (david) ggf. im naechsten release + * public function loadByOrganization($oe_kurzbz) + { + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); + + $lehrveranstaltungen = $this->LehrveranstaltungModel->getLvsByOrganization($oe_kurzbz); + $lehrveranstaltungen_data = $this->getDataOrTerminateWithError($lehrveranstaltungen); + $tree = []; + + foreach ($lehrveranstaltungen_data as $lehrveranstaltung) + { + $lehreinheiten = $this->LehreinheitModel->getByLvidStudiensemester($lehrveranstaltung->lehrveranstaltung_id, $studiensemester_kurzbz); + $lehreinheiten_data = $this->getDataOrTerminateWithError($lehreinheiten); + + if (!isset($lehrveranstaltung->_children)) + { + + $lehrveranstaltung->_children = $lehreinheiten_data; + } + $tree[] = $lehrveranstaltung; + } + $this->terminateWithSuccess($tree); + }*/ + + /*public function loadByFachbereich($fachbereich, $mitarbeiter_uid = null) + { + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); + + $this->LehreinheitModel->getLvsByFachbereich($fachbereich, $studiensemester_kurzbz, $mitarbeiter_uid); + }*/ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) + show_error('User authentification failed'); + } + + private function assignUniqueIndex(&$nodes, &$counter) + { + foreach ($nodes as &$node) + { + $node->uniqueindex = $counter++; + if (!empty($node->_children) && is_array($node->_children)) + { + $this->assignUniqueIndex($node->_children, $counter); + } + } + } + + private function getStudiensemesterKurzbz($studiensemester_kurzbz = null) + { + if (!is_null($studiensemester_kurzbz)) + { + $studiensemester_result = $this->_ci->StudiensemesterModel->load($studiensemester_kurzbz); + + if (isError($studiensemester_result) || !hasData($studiensemester_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + return getData($studiensemester_result)[0]->studiensemester_kurzbz; + } + + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + } +} diff --git a/application/controllers/api/frontend/v1/LvPlan.php b/application/controllers/api/frontend/v1/LvPlan.php index 3b6b55911..28b48e3f1 100644 --- a/application/controllers/api/frontend/v1/LvPlan.php +++ b/application/controllers/api/frontend/v1/LvPlan.php @@ -176,6 +176,7 @@ class LvPlan extends FHCAPI_Controller { $this->load->model('ressource/Stunde_model', 'StundeModel'); + $this->StundeModel->addOrder('stunde', 'ASC'); $stunden = $this->StundeModel->load(); $stunden = $this->getDataOrTerminateWithError($stunden); diff --git a/application/controllers/api/frontend/v1/ProfilUpdate.php b/application/controllers/api/frontend/v1/ProfilUpdate.php index 929ea49d6..bbfed651c 100644 --- a/application/controllers/api/frontend/v1/ProfilUpdate.php +++ b/application/controllers/api/frontend/v1/ProfilUpdate.php @@ -573,8 +573,7 @@ class ProfilUpdate extends FHCAPI_Controller { // early return if no status has been passed as argument if (!isset($status)) { - echo json_encode($this->ProfilUpdateModel->getProfilUpdateWithPermission()); - return; + $this->terminateWithSuccess($this->ProfilUpdateModel->getProfilUpdateWithPermission()); } // get the sprache of the user @@ -587,7 +586,7 @@ class ProfilUpdate extends FHCAPI_Controller $status = hasData($status) ? getData($status)[0]->status_kurzbz : null; $res = $this->ProfilUpdateModel->getProfilUpdateWithPermission(isset($status) ? ['status' => $status] : null); - echo json_encode($res); + $this->terminateWithSuccess($res); } } @@ -641,6 +640,7 @@ class ProfilUpdate extends FHCAPI_Controller $this->StudentModel->addJoin("public.tbl_prestudent", "public.tbl_benutzer.person_id = public.tbl_prestudent.person_id"); $this->StudentModel->addJoin("public.tbl_prestudentstatus", "public.tbl_prestudentstatus.prestudent_id = public.tbl_prestudent.prestudent_id"); $this->StudentModel->addJoin("public.tbl_studiengang", "public.tbl_studiengang.studiengang_kz = public.tbl_prestudent.studiengang_kz"); + $this->StudentModel->addGroupBy(["public.tbl_studiengang.email"]); //* check if the benutzer itself is active //* check if the student status is Student or Diplomand (active students) $this->StudentModel->db->where_in("public.tbl_prestudentstatus.status_kurzbz", ['Student', 'Diplomand']); @@ -657,8 +657,10 @@ class ProfilUpdate extends FHCAPI_Controller } $mail_res = []; //? sending email - foreach ($emails as $email) { - array_push($mail_res, sendSanchoMail("profil_update", ['uid' => $uid, 'topic' => $topic, 'href' => APP_ROOT . 'Cis/ProfilUpdate/id/' . $profil_update_id], $email, ("Profil Änderung von " . $uid))); + foreach ($emails as $email) + { + $href = $this->config->item('cis_vilesci_base_url') . $this->config->item('cis_vilesci_index_page') . '/Cis/ProfilUpdate/id/' . $profil_update_id; + array_push($mail_res, sendSanchoMail("profil_update", ['uid' => $uid, 'topic' => $topic, 'href' => $href], $email, ("Profil Änderung von " . $uid))); } foreach ($mail_res as $m_res) { if (!$m_res) { @@ -681,21 +683,21 @@ class ProfilUpdate extends FHCAPI_Controller function languageQuery($language) { - return "select index from public.tbl_sprache where sprache = '" + $language + "'"; + return "select index from public.tbl_sprache where sprache = '" . $language . "'"; } $this->ProfilUpdateStatusModel->addSelect(["bezeichnung_mehrsprachig[(" . languageQuery('German') . ")] as status_de", "bezeichnung_mehrsprachig[(" . languageQuery('English') . ")] as status_en"]); $status_translation = $this->ProfilUpdateStatusModel->loadWhere(["status_kurzbz" => $status]); - if (isError($status_translation)) { $this->terminateWithError($this->p->t('profilUpdate', 'ProfilUpdateStatusTranslationError')); } $status_translation = hasData($status_translation) ? getData($status_translation)[0] : null; - - if (isset($status_translation)) { - $mail_res = sendSanchoMail("profil_update_response", ['topic' => $topic, 'status_de' => $status_translation->status_de, 'status_en' => $status_translation->status_en, 'href' => APP_ROOT . 'Cis/Profil'], $email, ("Profil Änderung " . $this->p->t('profilUpdate', 'pending'))); + if (isset($status_translation)) + { + $href = $this->config->item('cis_base_url') . $this->config->item('cis_index_page') . '/Cis/Profil'; + $mail_res = sendSanchoMail("profil_update_response", ['topic' => $topic, 'status_de' => $status_translation->status_de, 'status_en' => $status_translation->status_en, 'href' => $href], $email, ("Profil Änderung " . $status_translation->status_de . ' / Profile Update ' . $status_translation->status_en)); if (!$mail_res) { $this->addError($this->p->t('profilUpdate', 'profilUpdate_email_error')); } diff --git a/application/controllers/api/frontend/v1/lv/DirektGruppe.php b/application/controllers/api/frontend/v1/lv/DirektGruppe.php new file mode 100644 index 000000000..2dcf7d3cb --- /dev/null +++ b/application/controllers/api/frontend/v1/lv/DirektGruppe.php @@ -0,0 +1,110 @@ +. + */ + +if (!defined('BASEPATH')) + exit('No direct script access allowed'); + +class DirektGruppe extends FHCAPI_Controller +{ + private $_ci; + public function __construct() + { + parent::__construct([ + 'add' => ['admin:rw', 'assistenz:rw'], + 'delete' => ['admin:rw', 'assistenz:rw'], + 'getByLehreinheit' => ['admin:r', 'assistenz:r'], + ]); + + $this->_ci = &get_instance(); + + $this->loadPhrases([ + 'ui' + ]); + $this->_ci->load->model('education/Lehreinheitgruppe_model', 'LehreinheitgruppeModel'); + $this->_ci->load->model('education/lehreinheit_model', 'LehreinheitModel'); + $this->_ci->load->model('person/Benutzer_model', 'BenutzerModel'); + } + + public function add() + { + $uid = $this->input->post('uid'); + $lehreinheit_id = $this->input->post('lehreinheit_id'); + + $this->checkPermission($lehreinheit_id, $uid); + + $result = $this->_ci->LehreinheitgruppeModel->direktUserAdd($uid, $lehreinheit_id); + + if (isError($result)) + $this->terminateWithError(getError($result)); + + $this->terminateWithSuccess($result); + } + + public function delete() + { + $uid = $this->input->post('uid'); + $lehreinheit_id = $this->input->post('lehreinheit_id'); + + $this->checkPermission($lehreinheit_id, $uid); + + $result = $this->_ci->LehreinheitgruppeModel->direktUserDelete($uid, $lehreinheit_id); + + if (isError($result)) + $this->terminateWithError(getError($result)); + + $this->terminateWithSuccess($result); + } + + public function getByLehreinheit($lehreinheit_id = null) + { + $this->checkPermission($lehreinheit_id); + $gruppen = $this->_ci->LehreinheitgruppeModel->getDirectGroup($lehreinheit_id); + $this->terminateWithSuccess(hasData($gruppen) ? getData($gruppen) : array()); + } + + private function checkPermission($lehreinheit_id, $uid = false) + { + if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $lehreinheit_result = $this->_ci->LehreinheitModel->load($lehreinheit_id); + + if (!hasData($lehreinheit_result) || isError($lehreinheit_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + if ($uid) + { + $benuzuer_result = $this->_ci->BenutzerModel->load(array($uid)); + if (!hasData($benuzuer_result) || isError($benuzuer_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + } + + $result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id); + + if (isError($result)) + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + $oe_array = []; + if (hasData($result)) + $oe_array = getData($result); + + if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') && + !$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid')) + $this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess')); + } +} diff --git a/application/controllers/api/frontend/v1/lv/Favorites.php b/application/controllers/api/frontend/v1/lv/Favorites.php new file mode 100644 index 000000000..080a4ec6e --- /dev/null +++ b/application/controllers/api/frontend/v1/lv/Favorites.php @@ -0,0 +1,47 @@ + self::PERM_LOGGED, + 'set' => self::PERM_LOGGED + ]); + + // Load models + $this->load->model('system/Variable_model', 'VariableModel'); + } + + public function index() + { + $result = $this->VariableModel->getVariables(getAuthUID(), ['lv_favorites']); + + $data = $this->getDataOrTerminateWithError($result); + + if (!$data) + $this->terminateWithSuccess(null); + else + $this->terminateWithSuccess(isset($data['lv_favorites']) ? $data['lv_favorites'] : null); + } + + public function set() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('favorites', 'Favorites', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $favorites = $this->input->post('favorites'); + + $result = $this->VariableModel->setVariable(getAuthUID(), 'lv_favorites', $favorites); + + $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(true); + } +} diff --git a/application/controllers/api/frontend/v1/lv/Gruppe.php b/application/controllers/api/frontend/v1/lv/Gruppe.php new file mode 100644 index 000000000..83a4fb696 --- /dev/null +++ b/application/controllers/api/frontend/v1/lv/Gruppe.php @@ -0,0 +1,195 @@ + ['admin:rw', 'assistenz:rw'], + 'delete' => ['admin:rw', 'assistenz:rw'], + 'deleteFromLVPlan' => ['admin:rw', 'assistenz:rw'], + 'getBenutzer' => ['admin:r', 'assistenz:r'], + 'getAll' => ['admin:r', 'assistenz:r'], + 'getByLehreinheit' => ['admin:r', 'assistenz:r'], + ]); + + $this->_ci = &get_instance(); + $this->_setAuthUID(); + $this->_ci->load->library('PhrasesLib'); + $this->loadPhrases( + array( + 'ui' + ) + ); + + $this->_ci->load->model('organisation/Gruppe_model', 'GruppeModel'); + $this->_ci->load->model('organisation/Lehrverband_model', 'LehrverbandModel'); + $this->_ci->load->model('education/Lehreinheitgruppe_model', 'LehreinheitgruppeModel'); + $this->_ci->load->model('person/Person_model', 'PersonModel'); + $this->_ci->load->model('ressource/stundenplandev_model', 'StundenplandevModel'); + } + + public function delete() + { + $lehreinheitgruppe_id = $this->input->post('lehreinheitgruppe_id'); + $lehreinheit_id = $this->input->post('lehreinheit_id'); + + if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id) || is_null($lehreinheitgruppe_id) || !ctype_digit((string)$lehreinheitgruppe_id)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $lehreinheitgruppe_result = $this->_ci->LehreinheitgruppeModel->loadWhere(array('lehreinheitgruppe_id' => $lehreinheitgruppe_id)); + if (!hasData($lehreinheitgruppe_result) || isError($lehreinheitgruppe_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $this->checkPermission($lehreinheit_id); + + $result = $this->_ci->LehreinheitgruppeModel->deleteGroup($lehreinheit_id, $lehreinheitgruppe_id); + + if (isError($result)) + $this->terminateWithError(getError($result)); + + $this->terminateWithSuccess($result); + } + + public function add() + { + $lehreinheit_id = $this->input->post('lehreinheit_id'); + $gid = $this->input->post('gid'); + $lehrverband = $this->input->post('lehrverband'); + + if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id) || is_null($gid) || !ctype_digit((string)$gid) || is_null($lehrverband)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $this->checkPermission($lehreinheit_id); + + $result = $this->_ci->LehreinheitgruppeModel->addGroup($lehreinheit_id, $gid, !($lehrverband === 'false')); + + if (isError($result)) + $this->terminateWithError(getError($result)); + + $this->terminateWithSuccess($result); + } + + public function getByLehreinheit($lehreinheit_id = null) + { + if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $this->checkPermission($lehreinheit_id); + + $gruppen = $this->_ci->LehreinheitgruppeModel->getByLehreinheit($lehreinheit_id); + $this->terminateWithSuccess(hasData($gruppen) ? getData($gruppen) : array()); + } + + public function deleteFromLVPlan() + { + $lehreinheit_id = $this->input->post('lehreinheit_id'); + $lehreinheitgruppe_id = $this->input->post('lehreinheitgruppe_id'); + + if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id) || is_null($lehreinheitgruppe_id) || !ctype_digit((string)$lehreinheitgruppe_id)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $lehreinheitgruppe_result = $this->_ci->LehreinheitgruppeModel->loadWhere(array('lehreinheitgruppe_id' => $lehreinheitgruppe_id)); + if (!hasData($lehreinheitgruppe_result) || isError($lehreinheitgruppe_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $this->checkPermission($lehreinheit_id); + + $result = $this->_ci->StundenplandevModel->deleteGroupPlanning($lehreinheit_id, $lehreinheitgruppe_id); + + if (isError($result)) + $this->terminateWithError(getError($result)); + + $this->terminateWithSuccess($result); + } + + + public function getAll() + { + $this->_ci->GruppeModel->addSelect('gruppe_kurzbz, + studiengang_kz, + semester, + bezeichnung, + gid, + \'false\' as lehrverband'); + $gruppen_result = $this->_ci->GruppeModel->loadWhere(array('sichtbar' => true, 'aktiv' => true, 'lehre' => true, 'direktinskription' => false, 'semester IS NOT NULL' => null)); + + $gruppen_array = array(); + + if (isError($gruppen_result)) + $this->terminateWithError(getError($gruppen_result), self::ERROR_TYPE_GENERAL); + + if (hasData($gruppen_result)) + $gruppen_array = getData($gruppen_result); + + $this->_ci->LehrverbandModel->addSelect('CONCAT(UPPER(CONCAT(typ, kurzbz)), \'\', semester, verband, COALESCE(gruppe,\'\')) as gruppe_kurzbz, + studiengang_kz, + semester, + tbl_lehrverband.bezeichnung, + gid, + \'true\' as lehrverband'); + $this->_ci->LehrverbandModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + $this->_ci->LehrverbandModel->addOrder('verband'); + $this->_ci->LehrverbandModel->addOrder('gruppe'); + $lehrverband_result = $this->_ci->LehrverbandModel->loadWhere(array('tbl_lehrverband.aktiv' => true)); + + $lehrverband_array = array(); + + if (isError($lehrverband_result)) + $this->terminateWithError(getError($lehrverband_result), self::ERROR_TYPE_GENERAL); + + if (hasData($lehrverband_result)) + $lehrverband_array = getData($lehrverband_result); + + $all_gruppen = array_merge($gruppen_array, $lehrverband_array); + + $this->terminateWithSuccess($all_gruppen); + } + + public function getBenutzer() + { + $this->_ci->PersonModel->addSelect('vorname, nachname, uid, semester, UPPER(CONCAT(tbl_studiengang.typ, tbl_studiengang.kurzbz)) as studiengang'); + $this->_ci->PersonModel->addJoin('public.tbl_benutzer', 'person_id'); + $this->_ci->PersonModel->addJoin('public.tbl_mitarbeiter', 'uid = mitarbeiter_uid', 'LEFT'); + $this->_ci->PersonModel->addJoin('public.tbl_student', 'uid = student_uid', 'LEFT'); + $this->_ci->PersonModel->addJoin('public.tbl_studiengang', 'studiengang_kz', 'LEFT'); + + $personen = $this->_ci->PersonModel->loadWhere(array('tbl_benutzer.aktiv' => true)); + $this->terminateWithSuccess(hasData($personen) ? getData($personen) : array()); + } + + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) + show_error('User authentification failed'); + } + + private function checkPermission($lehreinheit_id) + { + $lehreinheit_result = $this->_ci->LehreinheitModel->load($lehreinheit_id); + + if (!hasData($lehreinheit_result) || isError($lehreinheit_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id); + + if (isError($result)) + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + $oe_array = []; + if (hasData($result)) + $oe_array = getData($result); + + if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') && + !$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid') && + !$this->_ci->permissionlib->isBerechtigtMultipleOe('lv-plan', $oe_array, 'suid')) + $this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess')); + } + +} diff --git a/application/controllers/api/frontend/v1/lv/Lehreinheit.php b/application/controllers/api/frontend/v1/lv/Lehreinheit.php new file mode 100644 index 000000000..958007901 --- /dev/null +++ b/application/controllers/api/frontend/v1/lv/Lehreinheit.php @@ -0,0 +1,446 @@ + ['admin:rw', 'assistenz:rw'], + 'copy' => ['admin:rw', 'assistenz:rw'], + 'delete' => ['admin:rw', 'assistenz:rw'], + 'update' => ['admin:rw', 'assistenz:rw'], + + 'get' => ['admin:r', 'assistenz:r'], + 'getStudiensemester' => ['admin:r', 'assistenz:r'], + 'getLehrfach' => ['admin:r', 'assistenz:r'], + 'getSprache' => ['admin:r', 'assistenz:r'], + 'getRaumtyp' => ['admin:r', 'assistenz:r'], + 'getLehrform' => ['admin:r', 'assistenz:r'] + ]); + + $this->_ci = &get_instance(); + $this->_setAuthUID(); + $this->_ci->load->library('VariableLib', ['uid' => $this->_uid]); + $this->_ci->load->library('PhrasesLib'); + $this->loadPhrases( + array( + 'global', + 'ui' + ) + ); + + $this->_ci->load->model('education/Lehreinheit_model', 'LehreinheitModel'); + $this->_ci->load->model('education/Lehreinheitgruppe_model', 'LehreinheitgruppeModel'); + $this->_ci->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); + } + + public function get($lehreinheit_id) + { + $lehreinheit = $this->checkLehreinheit($lehreinheit_id); + $lehreinheit->lehrfaecher = $this->getLehrfaecher($lehreinheit); + $this->terminateWithSuccess($lehreinheit); + } + + private function getLehrfaecher($lehreinheit) + { + $lehrfacher_array = array($lehreinheit->lehrfach_id); + $this->_ci->LehreinheitModel->addSelect('lehrveranstaltung_id_kompatibel'); + $this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehrveranstaltung_kompatibel', 'lehrveranstaltung_id'); + $lehrfaecher = $this->_ci->LehreinheitModel->loadWhere(array('lehrveranstaltung_id' => $lehreinheit->lehrveranstaltung_id)); + + + if (hasData($lehrfaecher)) + $lehrfaecher_array = array_merge($lehrfacher_array, array_column(getData($lehrfaecher), 'lehrveranstaltung_id_kompatibel')); + + $lehrfaecher_array[] = $lehreinheit->lehrveranstaltung_id; + + $this->_ci->LehrveranstaltungModel->addDistinct('lehrfach_id'); + $this->_ci->LehrveranstaltungModel->addSelect("tbl_lehrveranstaltung.lehrveranstaltung_id, CONCAT(tbl_lehrveranstaltung.bezeichnung || '(' || tbl_lehrveranstaltung.oe_kurzbz || ')') as lehrfach"); + $this->_ci->LehrveranstaltungModel->db->where_in('tbl_lehrveranstaltung.lehrveranstaltung_id', $lehrfaecher_array); + $lehrfaecher_result = $this->_ci->LehrveranstaltungModel->load(); + + return hasData($lehrfaecher_result) ? getData($lehrfaecher_result) : array(); + } + + public function add() + { + $lehrveranstaltung_id = $this->input->post('lehrveranstaltung_id'); + + if (is_null($lehrveranstaltung_id) || !ctype_digit((string)$lehrveranstaltung_id)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $lehrveranstaltung_result = $this->_ci->LehrveranstaltungModel->loadWhere(array('lehrveranstaltung_id' => $lehrveranstaltung_id)); + + if (!hasData($lehrveranstaltung_result) || isError($lehrveranstaltung_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $lehrveranstaltung = getData($lehrveranstaltung_result)[0]; + + $oe_result = $this->_ci->LehrveranstaltungModel->getAllOe($lehrveranstaltung->lehrveranstaltung_id); + $oe_array = hasData($oe_result) ? array_column(getData($oe_result), 'oe_kurzbz') : array(); + + if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') && + !$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid') && + !$this->_ci->permissionlib->isBerechtigtMultipleOe('lv-plan', $oe_array, 'suid')) + $this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess')); + + $this->_ci->load->library('form_validation'); + + $updatableFields = array( + 'lehrveranstaltung_id', + 'studiensemester_kurzbz', + 'lehrfach_id', + 'lehrform_kurzbz', + 'stundenblockung', + 'wochenrythmus', + 'gewicht', + 'start_kw', + 'raumtyp', + 'raumtypalternativ', + 'sprache', + 'lehre', + 'anmerkung', + 'lvnr', + 'unr', + ); + + foreach ($updatableFields as $field) + { + switch ($field) { + case 'lehrveranstaltung_id': + $this->form_validation->set_rules($field, 'Lehrveranstaltung ID', 'required|integer'); + break; + case 'studiensemester_kurzbz': + $this->form_validation->set_rules($field, 'Studiensemester', 'required|max_length[16]'); + break; + case 'lehrfach_id': + $this->form_validation->set_rules($field, 'Lehrfach ID', 'required|integer'); + break; + case 'lehrform_kurzbz': + $this->form_validation->set_rules($field, 'Lehrform', 'required|max_length[8]'); + break; + case 'stundenblockung': + $this->form_validation->set_rules($field, 'Stundenblockung', 'required|integer|greater_than_equal_to[0]'); + break; + case 'wochenrythmus': + $this->form_validation->set_rules($field, 'Wochenrhytmus', 'required|integer|greater_than_equal_to[0]'); + break; + case 'start_kw': + $this->form_validation->set_rules($field, 'Start KW', 'integer|greater_than[0]|less_than_equal_to[53]'); + break; + case 'gewicht': + $this->form_validation->set_rules($field, 'Gewicht', 'numeric'); + break; + case 'raumtyp': + $this->form_validation->set_rules($field, 'Raumtyp', 'required|max_length[16]'); + break; + case 'raumtypalternativ': + $this->form_validation->set_rules($field, 'Raumtyp Alternativ', 'required|max_length[16]'); + break; + case 'sprache': + $this->form_validation->set_rules($field, 'Sprache', 'required|max_length[16]'); + break; + case 'lvnr': + $this->form_validation->set_rules($field, 'LVNR', 'integer'); + break; + case 'unr': + $this->form_validation->set_rules($field, 'UNR', 'integer'); + break; + case 'lehre': + $this->form_validation->set_rules($field, 'Lehre', 'trim'); + break; + case 'anmerkung': + $this->form_validation->set_rules($field, 'Anmerkung', 'trim'); + break; + } + } + + if ($this->form_validation->run() === false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $updateData = array(); + foreach ($updatableFields as $field) + { + $value = $this->input->post($field); + + if ($value !== null) + { + $updateData[$field] = $value; + } + } + + $updateData['insertvon'] = $this->_uid; + $updateData['insertamum'] = date('Y-m-d H:i:s'); + + $result = $this->_ci->LehreinheitModel->insert( + $updateData + ); + + if (!isset($updateData['unr'])) + { + $unr = getData($result); + $this->_ci->LehreinheitModel->update($unr, array('unr' => $unr)); + } + + $this->terminateWithSuccess($result); + } + + public function copy() + { + $lehreinheit_id = $this->input->post('lehreinheit_id'); + $art = $this->input->post('art'); + + $lehreinheit_old = $this->checkLehreinheit($lehreinheit_id); + $this->checkPermission($lehreinheit_old->lehreinheit_id); + + $lehreinheit_new = $lehreinheit_old; + + $lehreinheit_new->unr = null; + unset($lehreinheit_new->lehreinheit_id); + $lehreinheit_new->updateamum = date('Y-m-d H:i:s'); + $lehreinheit_new->updatevon = $this->_uid; + $lehreinheit_new->insertamum = date('Y-m-d H:i:s'); + $lehreinheit_new->insertvon = $this->_uid; + + $insert_result = $this->_ci->LehreinheitModel->insert($lehreinheit_new); + + if (isError($insert_result)) + $this->terminateWithError(getError($insert_result), self::ERROR_TYPE_GENERAL); + + $lehreinheit_id_new = getData($insert_result); + + $this->_ci->LehreinheitModel->update(array('lehreinheit_id' => $lehreinheit_id_new), array('unr' => $lehreinheit_id_new)); + if (in_array($art, array('gruppen', 'alle'))) + { + $gruppen_result = $this->_ci->LehreinheitgruppeModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id)); + + if (isError($gruppen_result)) + $this->terminateWithError(getError($gruppen_result), self::ERROR_TYPE_GENERAL); + + if (hasData($gruppen_result)) + { + $gruppen = getData($gruppen_result); + + foreach ($gruppen as $gruppe) + { + $gruppe_new = $gruppe; + unset($gruppe_new->lehreinheitgruppe_id); + $gruppe_new->lehreinheit_id = $lehreinheit_id_new; + $gruppe_new->insertamum = date('Y-m-d H:i:s'); + $gruppe_new->insertvon = $this->_uid; + $gruppe_new->updateamum = date('Y-m-d H:i:s'); + $gruppe_new->updatevon = $this->_uid; + + $gruppe_new_result = $this->_ci->LehreinheitgruppeModel->insert($gruppe_new); + + if (isError($gruppe_new_result)) + $this->terminateWithError(getError($gruppe_new_result), self::ERROR_TYPE_GENERAL); + } + } + } + + if (in_array($art, array('lektoren', 'alle'))) + { + $lektoren_result = $this->_ci->LehreinheitmitarbeiterModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id)); + + if (isError($lektoren_result)) + $this->terminateWithError(getError($lektoren_result), self::ERROR_TYPE_GENERAL); + + if (hasData($lektoren_result)) + { + $lektoren = getData($lektoren_result); + + foreach ($lektoren as $lektor) + { + + $lektor_new = $lektor; + $lektor_new->lehreinheit_id = $lehreinheit_id_new; + $lektor_new->insertamum = date('Y-m-d H:i:s'); + $lektor_new->insertvon = $this->_uid; + $lektor_new->updateamum = date('Y-m-d H:i:s'); + $lektor_new->updatevon = $this->_uid; + unset($lektor_new->vertrag_id); + + $lektor_new_result = $this->_ci->LehreinheitmitarbeiterModel->insert((array)$lektor_new); + + if (isError($lektor_new_result)) + $this->terminateWithError(getError($lektor_new_result), self::ERROR_TYPE_GENERAL); + } + } + } + + $this->terminateWithSuccess("Erfolgeich gespeichert"); + } + + public function delete() + { + $lehreinheit_id = $this->input->post('lehreinheit_id'); + $lehreinheit = $this->checkLehreinheit($lehreinheit_id); + $this->checkPermission($lehreinheit->lehreinheit_id); + + $result = $this->_ci->LehreinheitModel->deleteLehreinheit($lehreinheit->lehreinheit_id); + + if (isError($result)) + $this->terminateWithValidationErrors(getError($result)); + + $this->terminateWithSuccess('Erfolgreich geloescht'); + } + + public function update() + { + $lehreinheit = $this->checkLehreinheit($this->input->post('lehreinheit_id')); + + $this->checkPermission($lehreinheit->lehreinheit_id); + + $this->_ci->load->library('form_validation'); + + $formData = $this->input->post('formData'); + + $updatableFields = array( + 'lehrveranstaltung_id', + 'studiensemester_kurzbz', + 'lehrfach_id', + 'lehrform_kurzbz', + 'stundenblockung', + 'wochenrythmus', + 'gewicht', + 'start_kw', + 'raumtyp', + 'raumtypalternativ', + 'sprache', + 'lehre', + 'anmerkung', + 'lvnr', + 'unr', + ); + + $this->form_validation->set_data($formData); + + foreach ($updatableFields as $field) + { + if (array_key_exists($field, $formData)) + { + switch ($field) + { + case 'lehrveranstaltung_id': + $this->form_validation->set_rules($field, 'Lehrveranstaltung ID', 'required|integer'); + break; + case 'studiensemester_kurzbz': + $this->form_validation->set_rules($field, 'Studiensemester', 'required|max_length[16]'); + break; + case 'lehrfach_id': + $this->form_validation->set_rules($field, 'Lehrfach ID', 'required|integer'); + break; + case 'lehrform_kurzbz': + $this->form_validation->set_rules($field, 'Lehrform', 'required|max_length[8]'); + break; + case 'stundenblockung': + $this->form_validation->set_rules($field, 'Stundenblockung', 'required|integer|greater_than_equal_to[0]'); + break; + case 'wochenrythmus': + $this->form_validation->set_rules($field, 'Wochenrhytmus', 'required|integer|greater_than_equal_to[0]'); + break; + case 'start_kw': + $this->form_validation->set_rules($field, 'Start KW', 'integer|greater_than[0]|less_than_equal_to[53]'); + break; + case 'gewicht': + $this->form_validation->set_rules($field, 'Gewicht', 'numeric|greater_than_equal_to[0]'); + break; + case 'raumtyp': + $this->form_validation->set_rules($field, 'Raumtyp', 'required|max_length[16]'); + break; + case 'raumtypalternativ': + $this->form_validation->set_rules($field, 'Raumtyp Alternativ', 'required|max_length[16]'); + break; + case 'sprache': + $this->form_validation->set_rules($field, 'Sprache', 'required|max_length[16]'); + break; + case 'lvnr': + $this->form_validation->set_rules($field, 'LVNR', 'integer'); + break; + case 'unr': + $this->form_validation->set_rules($field, 'UNR', 'integer|greater_than_equal_to[0]'); + break; + case 'lehre': + $this->form_validation->set_rules($field, 'Lehre', 'trim'); + break; + case 'anmerkung': + $this->form_validation->set_rules($field, 'Anmerkung', 'trim'); + break; + } + } + } + + if ($this->form_validation->run() === false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $updateData = []; + foreach ($updatableFields as $field) + { + if (array_key_exists($field, $formData)) + { + $updateData[$field] = $formData[$field]; + } + } + + + $updateData['updatevon'] = $this->_uid; + $updateData['updateamum'] = date('Y-m-d H:i:s'); + $result = $this->_ci->LehreinheitModel->update( + [ + 'lehreinheit_id' => $this->input->post('lehreinheit_id'), + ], + $updateData + ); + + if (isError($result)) + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + $this->terminateWithSuccess($this->p->t('global', 'gespeichert')); + } + + + private function checkPermission($lehreinheit_id) + { + $result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id); + + if (isError($result)) + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + $oe_array = []; + if (hasData($result)) + $oe_array = getData($result); + + if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') && + !$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid') && + !$this->_ci->permissionlib->isBerechtigtMultipleOe('lv-plan', $oe_array, 'suid')) + $this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess')); + } + private function checkLehreinheit($lehreinheit_id) + { + if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $lehreinheit_result = $this->_ci->LehreinheitModel->load($lehreinheit_id); + + if (!hasData($lehreinheit_result) || isError($lehreinheit_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + return getData($lehreinheit_result)[0]; + } + + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) + show_error('User authentification failed'); + } +} diff --git a/application/controllers/api/frontend/v1/lv/Lektor.php b/application/controllers/api/frontend/v1/lv/Lektor.php new file mode 100644 index 000000000..68bec1bc4 --- /dev/null +++ b/application/controllers/api/frontend/v1/lv/Lektor.php @@ -0,0 +1,409 @@ + ['admin:rw', 'assistenz:rw'], + 'update' => ['admin:rw', 'assistenz:rw'], + 'cancelVertrag' => ['admin:rw', 'assistenz:rw'], + 'deleteLVPlan' => ['admin:rw', 'assistenz:rw'], + 'deletePerson' => ['admin:rw', 'assistenz:rw'], + 'getLehrfunktionen' => ['admin:r', 'assistenz:r'], + 'getLektoren' => ['admin:r', 'assistenz:r'], + 'getLektorenByLE' => ['admin:r', 'assistenz:r'], + 'getLektorDaten' => ['admin:r', 'assistenz:r'], + 'getLektorVertrag' => ['admin:r', 'assistenz:r'], + + ]); + + $this->_ci = &get_instance(); + $this->_setAuthUID(); + $this->_ci->load->library('VariableLib', ['uid' => $this->_uid]); + $this->_ci->load->library('PermissionLib'); + $this->_ci->load->library('LektorLib'); + $this->_ci->load->library('form_validation'); + $this->loadPhrases([ + 'ui' + ]); + + $this->_ci->load->model('accounting/Vertrag_model', 'VertragModel'); + $this->_ci->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); + $this->_ci->load->model('education/lehreinheit_model', 'LehreinheitModel'); + $this->_ci->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); + $this->_ci->load->model('ressource/stundenplandev_model', 'StundenplandevModel'); + $this->_ci->load->model('ressource/Stundensatz_model', 'StundensatzModel'); + + } + + private function checkMitarbeiter($mitarbeiter_uid) + { + if (is_null($mitarbeiter_uid)) + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid); + + if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result)) + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + } + + public function add() + { + $lehreinheit_id = $this->input->post('lehreinheit_id'); + $mitarbeiter_uid = $this->input->post('mitarbeiter_uid'); + + $this->checkLehreinheit($lehreinheit_id); + $this->checkMitarbeiter($mitarbeiter_uid); + $lehrfach_permission = $this->checkLehrfachPermission($lehreinheit_id, array('assistenz', 'admin')); + $lehreinheit_permission = $this->checkPermission($lehreinheit_id, array('admin', 'assistenz', 'lv-plan')); + + if (!$lehrfach_permission && !$lehreinheit_permission) + $this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess')); + + $result = $this->_ci->lektorlib->addLektorToLehreinheit($lehreinheit_id, $mitarbeiter_uid); + + if (isError($result)) $this->terminateWithError(getError($result)); + + $this->terminateWithSuccess("Erfolgreich gespeichert"); + } + + public function update() + { + $formData = $this->input->post('formData'); + $lehreinheit_id = $this->input->post('lehreinheit_id'); + $mitarbeiter_uid = $this->input->post('mitarbeiter_uid'); + + $this->checkLehreinheit($lehreinheit_id); + $this->checkMitarbeiter($mitarbeiter_uid); + + $updatableFields = array( + 'lehrfunktion_kurzbz', + 'planstunden', + 'stundensatz', + 'faktor', + 'anmerkung', + 'bismelden', + 'semesterstunden', + 'mitarbeiter_uid' + ); + + $this->form_validation->set_data($formData); + + foreach ($updatableFields as $field) + { + if (array_key_exists($field, $formData)) + { + switch ($field) + { + case 'lehrfunktion_kurzbz': + $this->form_validation->set_rules($field, 'Lehrfunktion', 'required|max_length[16]'); + break; + case 'planstunden': + $this->form_validation->set_rules($field, 'Planstunden', 'integer|greater_than_equal_to[0]'); + break; + case 'stundensatz': + $formData['stundensatz'] = str_replace(',', '.', $formData['stundensatz']); + $this->form_validation->set_rules($field, 'Stundensatz', 'callback__check_stundensatz'); + break; + case 'faktor': + $this->form_validation->set_rules($field, 'Faktor', 'numeric|greater_than_equal_to[0]'); + break; + case 'anmerkung': + $this->form_validation->set_rules($field, 'Anmerkung', 'max_length[256]'); + break; + case 'bismelden': + $this->form_validation->set_rules($field, 'Bis Melden', 'trim'); + break; + case 'semesterstunden': + $formData['semesterstunden'] = str_replace(',', '.', $formData['semesterstunden']); + $this->form_validation->set_rules($field, 'Semesterstunden', 'callback__check_semesterstunden'); + break; + case 'mitarbeiter_uid': + $this->form_validation->set_rules($field, 'Semesterstunden', 'required|max_length[32]'); + break; + } + } + } + if (!$this->form_validation->run()) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + if (isset($formData['semesterstunden']) && (!is_numeric($formData['semesterstunden']) || $formData['semesterstunden'] === '')) + { + $formData['semesterstunden'] = null; + } + + $lehreinheit_permission = $this->checkPermission($lehreinheit_id, array('admin', 'assistenz', 'lv-plan')); + + if (!$lehreinheit_permission) + $this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess')); + + $result = $this->_ci->lektorlib->updateLektorFromLehreinheit($lehreinheit_id, $mitarbeiter_uid, $formData); + + if (isError($result)) $this->terminateWithError(getError($result)); + $this->terminateWithSuccess($result); + } + + public function _check_stundensatz($value) + { + $value = str_replace(',', '.', $value); + + if (!is_numeric($value)) + { + $this->form_validation->set_message('_check_decimal', 'Das Feld {field} muss eine Zahl sein.'); + return false; + } + + if ($value < 0 || $value >= 10000) { + $this->form_validation->set_message('_check_decimal', 'Das Feld {field} muss zwischen 0 und 10000 liegen.'); + return false; + } + + return true; + } + public function _check_semesterstunden($value) + { + if ($value === null || $value === '') { + return true; + } + + if (!is_numeric($value)) + { + $this->form_validation->set_message( + '_check_semesterstunden', + 'Das Feld {field} muss eine Zahl sein.' + ); + return false; + } + + if ($value < 0) + { + $this->form_validation->set_message( + '_check_semesterstunden', + 'Das Feld {field} muss eine Zahl größer oder gleich 0 sein.' + ); + return false; + } + if ($value > 999.99) + { + $this->form_validation->set_message( + '_check_semesterstunden', + 'Das Feld {field} darf maximal 999,99 betragen.' + ); + return false; + } + + return true; + } + public function getLehrfunktionen() + { + $this->_ci->load->model('education/Lehrfunktion_model', 'LehrfunktionModel'); + $this->_ci->LehrfunktionModel->addOrder('lehrfunktion_kurzbz'); + $this->terminateWithSuccess(getData($this->_ci->LehrfunktionModel->load())); + } + + public function getLektoren() + { + $this->_ci->MitarbeiterModel->addSelect('uid, person_id, vorname, nachname'); + $this->_ci->MitarbeiterModel->addJoin('public.tbl_benutzer', 'uid = mitarbeiter_uid'); + $this->_ci->MitarbeiterModel->addJoin('public.tbl_person', 'person_id'); + $this->terminateWithSuccess(getData($this->_ci->MitarbeiterModel->loadWhere(array('public.tbl_benutzer.aktiv' => true)))); + } + + private function checkLehreinheit($lehreinheit_id) + { + if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $lehreinheit_result = $this->_ci->LehreinheitModel->load($lehreinheit_id); + + if (!hasData($lehreinheit_result) || isError($lehreinheit_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + return getData($lehreinheit_result)[0]; + + } + public function getLektorenByLE($lehreinheit_id = null) + { + $this->checkLehreinheit($lehreinheit_id); + $le_mitarbeiter_data = $this->_ci->LehreinheitmitarbeiterModel->getLektorenByLe($lehreinheit_id); + $this->terminateWithSuccess(hasData($le_mitarbeiter_data) ? getData($le_mitarbeiter_data) : array()); + } + + public function getLektorDaten($lehreinheit_id = null, $mitarbeiter_uid = null) + { + $lehreinheit = $this->checkLehreinheit($lehreinheit_id); + + if (is_null($mitarbeiter_uid)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid); + + if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $this->load->model('organisation/Studiensemester_model','StudiensemesterModel'); + $studiensemester_result = $this->_ci->StudiensemesterModel->loadWhere(array('studiensemester_kurzbz' => $lehreinheit->studiensemester_kurzbz)); + $studiensemester = getData($studiensemester_result)[0]; + + $defaultStundensatz = $this->_ci->StundensatzModel->getDefaultStundensatz($mitarbeiter_uid, $studiensemester->start, $studiensemester->ende, 'lehre'); + + $le_mitarbeiter_result = $this->_ci->LehreinheitmitarbeiterModel->getByLeLektor($lehreinheit_id, $mitarbeiter_uid); + + $le_mitarbeiter_data = array(); + if (hasData($le_mitarbeiter_result)) + { + $le_mitarbeiter_data = getData($le_mitarbeiter_result)[0]; + $le_mitarbeiter_data->default_stundensatz = $defaultStundensatz; + } + $vertrag = $this->getLektorVertrag($lehreinheit_id, $mitarbeiter_uid); + $le_mitarbeiter_data->vertrag = $vertrag; + $this->terminateWithSuccess($le_mitarbeiter_data); + } + + private function getLektorVertrag($lehreinheit_id = null, $mitarbeiter_uid = null) + { + $this->_ci->load->model('accounting/Vertrag_model', 'VertragModel'); + $vertrag = $this->_ci->VertragModel->getVertrag($mitarbeiter_uid, $lehreinheit_id); + return hasData($vertrag) ? getData($vertrag)[0] : null; + } + + private function checkLehrfachPermission($lehreinheit_id, $permissions) + { + $lehrfach_oe_kurzbz = $this->_ci->LehreinheitModel->getLehrfachOe($lehreinheit_id); + + if (isError($lehrfach_oe_kurzbz)) + $this->terminateWithError(getError($lehrfach_oe_kurzbz), self::ERROR_TYPE_GENERAL); + + $lehrfach_oe_kurzbz = array(''); + if (hasData($lehrfach_oe_kurzbz)) + $lehrfach_oe_kurzbz = array_column(getData($lehrfach_oe_kurzbz), 'oe_kurzbz'); + + + return $this->checkPermissionGenerel($permissions, $lehrfach_oe_kurzbz); + } + + private function checkPermissionGenerel($permissions, $oe_array) + { + $hasPermission = false; + foreach ($permissions as $permission) + { + if ($this->_ci->permissionlib->isBerechtigtMultipleOe($permission, $oe_array, 'suid')) + { + $hasPermission = true; + break; + } + } + + return $hasPermission; + } + + private function checkPermission($lehreinheit_id, $permissions) + { + $result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id); + + if (isError($result)) + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + $oe_array = []; + if (hasData($result)) + $oe_array = getData($result); + + return $this->checkPermissionGenerel($permissions, $oe_array); + } + public function cancelVertrag() + { + $vertrag_id = $this->input->post('vertrag_id'); + $lehreinheit_id = $this->input->post('lehreinheit_id'); + $mitarbeiter_uid = $this->input->post('mitarbeiter_uid'); + + $this->checkLehreinheit($lehreinheit_id); + $this->checkPermission($lehreinheit_id, array('admin', 'lehre/lehrauftrag_bestellen')); + + if (is_null($vertrag_id) || !ctype_digit((string)$vertrag_id)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $vertrag_result = $this->_ci->VertragModel->load($vertrag_id); + + if (!hasData($vertrag_result) || isError($vertrag_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + if (is_null($mitarbeiter_uid)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid); + + if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result)) + $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $result = $this->_ci->VertragModel->cancelVertrag($vertrag_id, $mitarbeiter_uid); + + if (isError($result)) + $this->terminateWithError(getError($result)); + + $this->terminateWithSuccess($result); + } + + public function deletePerson() + { + $lehreinheit_id = $this->input->post('lehreinheit_id'); + $mitarbeiter_uid = $this->input->post('mitarbeiter_uid'); + + $this->checkLehreinheit($lehreinheit_id); + $this->checkPermission($lehreinheit_id, array('admin', 'assistenz', 'lv-plan')); + + if (is_null($mitarbeiter_uid)) + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid); + + if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result)) + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $delete_result =$this->_ci->LehreinheitmitarbeiterModel->deleteLektorFromLe($lehreinheit_id, $mitarbeiter_uid); + + if (isError($delete_result)) + $this->terminateWithError(getError($delete_result)); + + $this->terminateWithSuccess($delete_result); + } + + public function deleteLVPlan() + { + $lehreinheit_id = $this->input->post('lehreinheit_id'); + $mitarbeiter_uid = $this->input->post('mitarbeiter_uid'); + + $this->checkLehreinheit($lehreinheit_id); + $this->checkPermission($lehreinheit_id, array('lv-plan/lektorentfernen')); + + if (is_null($mitarbeiter_uid)) + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid); + + if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result)) + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + + $delete_result = $this->_ci->StundenplandevModel->deleteLektorPlanning($lehreinheit_id, $mitarbeiter_uid); + + if (isError($delete_result)) + $this->terminateWithError(getError($delete_result)); + + $this->terminateWithSuccess($delete_result); + } + + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) + show_error('User authentification failed'); + } +} diff --git a/application/controllers/api/frontend/v1/lv/Setup.php b/application/controllers/api/frontend/v1/lv/Setup.php new file mode 100644 index 000000000..a2c167dd6 --- /dev/null +++ b/application/controllers/api/frontend/v1/lv/Setup.php @@ -0,0 +1,121 @@ +. + */ + +if (!defined('BASEPATH')) + exit('No direct script access allowed'); + +class Setup extends FHCAPI_Controller +{ + private $_ci; + private $_uid; + + public function __construct() + { + parent::__construct([ + 'getTabs' => ['admin:r', 'assistenz:r'], + 'getStudiensemester' => ['admin:r', 'assistenz:r'], + 'getSprache' => ['admin:r', 'assistenz:r'], + 'getRaumtyp' => ['admin:r', 'assistenz:r'], + 'getLehrform' => ['admin:r', 'assistenz:r'], + ]); + + $this->_ci = &get_instance(); + $this->_setAuthUID(); + + $this->_ci->load->model('education/Lehreinheit_model', 'LehreinheitModel'); + $this->_ci->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + + $this->_ci->load->library('VariableLib', ['uid' => $this->_uid]); + } + + public function getTabs() + { + $tabs['details'] = array ( + 'title' => 'Details', + 'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Details.js', + 'config' => [] + ); + $tabs['gruppen'] = array ( + 'title' => 'Gruppen', + 'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Gruppen.js', + 'config' => [] + ); + $tabs['lektor'] = array ( + 'title' => 'LektorInnenzuteilung', + 'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Lektor.js', + 'config' => [] + ); + $tabs['notiz'] = array ( + 'title' => 'Notizen', + 'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Notiz.js', + 'config' => [] + ); + $this->terminateWithSuccess($tabs); + } + + public function getStudiensemester() + { + $this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + $this->_ci->StudiensemesterModel->addOrder('start', 'DESC'); + $this->terminateWithSuccess(getData($this->_ci->StudiensemesterModel->load())); + } + public function getSprache() + { + $this->_ci->load->model('system/Sprache_model', 'SpracheModel'); + $this->terminateWithSuccess(getData($this->_ci->SpracheModel->load())); + } + + public function getRaumtyp() + { + $this->_ci->load->model('ressource/Raumtyp_model', 'RaumtypModel'); + $this->_ci->RaumtypModel->addOrder('raumtyp_kurzbz'); + $this->terminateWithSuccess(getData($this->_ci->RaumtypModel->loadWhere(array('aktiv' => true)))); + } + + public function getLehrform() + { + $language = $this->_getLanguageIndex(); + + $this->_ci->load->model('codex/lehrform_model', 'LehrformModel'); + + $this->_ci->LehrformModel->addSelect( + '*, + bezeichnung_kurz[('.$language.')] as bez_kurz, + bezeichnung_lang[('.$language.')] as bez + ' + ); + $this->terminateWithSuccess(getData($this->_ci->LehrformModel->load())); + } + + private function _getLanguageIndex() + { + $this->_ci->load->model('system/Sprache_model', 'SpracheModel'); + $this->_ci->SpracheModel->addSelect('index'); + $result = $this->_ci->SpracheModel->loadWhere(array('sprache' => getUserLanguage())); + + return hasData($result) ? getData($result)[0]->index : 1; + } + + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) + show_error('User authentification failed'); + } +} diff --git a/application/controllers/api/frontend/v1/lv/StgTree.php b/application/controllers/api/frontend/v1/lv/StgTree.php new file mode 100644 index 000000000..8272da978 --- /dev/null +++ b/application/controllers/api/frontend/v1/lv/StgTree.php @@ -0,0 +1,117 @@ +method] = ['admin:r', 'assistenz:r']; + parent::__construct($permissions); + + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + } + + public function _remap($method, $params = []) + { + if ($method == '' || $method == 'index') + return $this->getBase(); + + if (!$this->permissionlib->isBerechtigt('assistenz', 's', $method) + && !$this->permissionlib->isBerechtigt('admin', 's', $method) + ) { + return $this->_outputAuthError([$method => ['admin:r', 'assistenz:r']]); + } + + return $this->getStudiengang($method); + show_404(); + } + + protected function getBase() + { + $this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz'); + + $this->StudiengangModel->addDistinct(); + $this->StudiengangModel->addSelect("v.studiengang_kz AS link"); + $this->StudiengangModel->addSelect( + "CONCAT(kurzbzlang, ' (', UPPER(CONCAT(typ, kurzbz)), ') - ', tbl_studiengang.bezeichnung) AS name", + false + ); + $this->StudiengangModel->addSelect('erhalter_kz'); + $this->StudiengangModel->addSelect('typ'); + $this->StudiengangModel->addSelect('kurzbz'); + $this->StudiengangModel->addSelect('studiengang_kz'); + $this->StudiengangModel->addSelect('studiengang_kz AS stg_kz'); + + $this->StudiengangModel->addOrder('erhalter_kz'); + $this->StudiengangModel->addOrder('typ'); + $this->StudiengangModel->addOrder('kurzbz'); + + $stgs = $this->permissionlib->getSTG_isEntitledFor('admin') ?: []; + $stgs = array_merge($stgs, $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []); + + if (!$stgs) + $this->terminateWithSuccess([]); + + $this->StudiengangModel->db->where_in('studiengang_kz', $stgs); + + $result = $this->StudiengangModel->loadWhere(['v.aktiv' => true]); + + $list = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($list); + } + + protected function getStudiengang($studiengang_kz) + { + $link = $studiengang_kz . '/'; + + $this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz'); + + $this->StudiengangModel->addDistinct(); + $this->StudiengangModel->addSelect("CONCAT(" . $this->StudiengangModel->escape($link) . ", semester) AS link", false); + $this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester ORDER BY verband, gruppe LIMIT 1)) AS name", false); + $this->StudiengangModel->addSelect("TRUE AS leaf", false); + + $this->StudiengangModel->addSelect('semester'); + $this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false); + + $this->StudiengangModel->addOrder('semester'); + + $result = $this->StudiengangModel->loadWhere([ + 'v.studiengang_kz' => $studiengang_kz, + 'v.aktiv' => true + ]); + $list = $this->getDataOrTerminateWithError($result); + + $result = $this->StudiengangModel->load($studiengang_kz); + $result = $this->getDataOrTerminateWithError($result); + if ($result) + { + if (current($result)->mischform) + { + $this->load->model('organisation/Studienordnung_model', 'StudienordnungModel'); + + $this->StudienordnungModel->addDistinct(); + $this->StudienordnungModel->addSelect("CONCAT(studiengang_kz, '/', p.orgform_kurzbz) AS link"); + $this->StudienordnungModel->addSelect("p.orgform_kurzbz AS name"); + $this->StudienordnungModel->addSelect("TRUE as leaf", false); + + $this->StudienordnungModel->addJoin('lehre.tbl_studienplan p', 'studienordnung_id'); + + $result = $this->StudienordnungModel->loadWhere([ + 'aktiv' => true, + 'studiengang_kz' => $studiengang_kz, + 'p.orgform_kurzbz !=' => 'DDP' + ]); + $result = $this->getDataOrTerminateWithError($result); + + $list = array_merge($list, $result); + } + } + + $this->terminateWithSuccess($list); + } +} diff --git a/application/controllers/api/frontend/v1/lv/Tags.php b/application/controllers/api/frontend/v1/lv/Tags.php new file mode 100644 index 000000000..a22a4c82e --- /dev/null +++ b/application/controllers/api/frontend/v1/lv/Tags.php @@ -0,0 +1,50 @@ + self::BERECHTIGUNG_KURZBZ, + 'getTags' => self::BERECHTIGUNG_KURZBZ, + 'addTag' => self::BERECHTIGUNG_KURZBZ, + 'updateTag' => self::BERECHTIGUNG_KURZBZ, + 'doneTag' => self::BERECHTIGUNG_KURZBZ, + 'deleteTag' => self::BERECHTIGUNG_KURZBZ, + 'updateLehre' => self::BERECHTIGUNG_KURZBZ, + 'doneLehre' => self::BERECHTIGUNG_KURZBZ, + 'deleteLehre' => self::BERECHTIGUNG_KURZBZ, + ]); + + $this->config->load('lvverwaltung'); + } + public function getTag($readonly_tags = null) + { + parent::getTag($this->config->item('lvverwaltung_tags')); + } + public function getTags($tags = null) + { + parent::getTags($this->config->item('lvverwaltung_tags')); + } + public function addTag($withZuordnung = true, $updatable_tags = null) + { + parent::addTag(true, $this->config->item('lvverwaltung_tags')); + } + public function updateTag($updatable_tags = null) + { + parent::updateTag($this->config->item('lvverwaltung_tags')); + } + public function deleteTag($withZuordnung = true, $updatable_tags = null) + { + parent::deleteTag(true, $this->config->item('lvverwaltung_tags')); + } + public function doneTag($updatable_tags = null) + { + parent::doneTag($this->config->item('lvverwaltung_tags')); + } +} \ 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 new file mode 100644 index 000000000..f8e1f816b --- /dev/null +++ b/application/controllers/api/frontend/v1/notiz/NotizLehreinheit.php @@ -0,0 +1,21 @@ + ['admin:r', 'assistenz:r'], + 'getNotizen' => ['admin:r', 'assistenz:r'], + 'loadNotiz' => ['admin:r', 'assistenz:r'], + 'addNewNotiz' => ['admin:rw', 'assistenz:rw'], + 'updateNotiz' => ['admin:rw', 'assistenz:rw'], + 'deleteNotiz' => ['admin:rw', 'assistenz:rw'], + 'loadDokumente' => ['admin:r', 'assistenz:r'], + 'getMitarbeiter' => ['admin:r', 'assistenz:r'], + 'isBerechtigt' => ['admin:r', 'assistenz:r'], + ]); + } +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index 2fb436384..d52016943 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -184,7 +184,9 @@ class Config extends FHCAPI_Controller return $result; }); - $this->terminateWithSuccess($result); + $sortConfig = $this->config->item('student_tab_order'); + + $this->terminateWithSuccess($this->sortTabList($result, $sortConfig)); } public function students() @@ -231,7 +233,9 @@ class Config extends FHCAPI_Controller return $result; }); - $this->terminateWithSuccess($result); + $sortConfig = $this->config->item('students_tab_order'); + + $this->terminateWithSuccess($this->sortTabList($result, $sortConfig)); } protected function kontoColumns() @@ -507,4 +511,34 @@ class Config extends FHCAPI_Controller return $list; } + + /** + * Sort tab list + * + * @param array $input + * @param array $config + * + * @return array + */ + protected function sortTabList($input, $config) + { + // prepare config + if (!$config || !is_array($config)) + $config = []; + else + $config = array_flip($config); + + // fill missing items in config + foreach (array_keys($input) as $key) { + if (!isset($config[$key])) + $config[$key] = count($config); + } + + // do the sorting + uksort($input, function ($a, $b) use ($config) { + return $config[$a] - $config[$b]; + }); + + return $input; + } } diff --git a/application/controllers/api/frontend/v1/stv/Kontakt.php b/application/controllers/api/frontend/v1/stv/Kontakt.php index 9b713b5f9..3a8268775 100644 --- a/application/controllers/api/frontend/v1/stv/Kontakt.php +++ b/application/controllers/api/frontend/v1/stv/Kontakt.php @@ -434,7 +434,10 @@ class Kontakt extends FHCAPI_Controller $this->FirmaModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = st.firma_id)', 'LEFT'); $this->KontakttypModel->addJoin('public.tbl_kontakttyp kt', 'ON (public.tbl_kontakt.kontakttyp = kt.kontakttyp)'); $result = $this->KontaktModel->loadWhere( - array('person_id' => $person_id) + array( + 'person_id' => $person_id, + 'public.tbl_kontakt.kontakttyp !=' => 'hidden' + ) ); if (isError($result)) @@ -442,20 +445,18 @@ class Kontakt extends FHCAPI_Controller $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } $this->terminateWithSuccess((getData($result) ?: [])); + } public function getKontakttypen() { $this->load->model('person/Kontakttyp_model', 'KontakttypModel'); + $this->KontakttypModel->addOrder('beschreibung', 'ASC'); + $result = $this->KontakttypModel->loadWhere(array('kontakttyp !=' => 'hidden')); - $result = $this->KontakttypModel->load(); - if (isError($result)) { - $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } - else - { - $this->terminateWithSuccess(getData($result) ?: []); - } + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); } public function loadContact() diff --git a/application/controllers/api/frontend/v1/stv/Prestudent.php b/application/controllers/api/frontend/v1/stv/Prestudent.php index 4d0aa5fe1..7dc607d1a 100644 --- a/application/controllers/api/frontend/v1/stv/Prestudent.php +++ b/application/controllers/api/frontend/v1/stv/Prestudent.php @@ -138,13 +138,24 @@ class Prestudent extends FHCAPI_Controller { $val = $this->input->post($prop, true); - if ($val !== null || $prop === 'foerderrelevant') { + if ($val !== null) { + if(in_array($prop, ['dual', 'bismelden', 'foerderrelevant'])) + { + $val = boolval($val); + } + elseif ( + $val === '' + && in_array($prop, ['zgvnation', 'zgvmanation', 'zgvdoktornation', 'berufstaetigkeit_code', 'ausbildungcode']) + ) + { + $val = null; + } $update_prestudent[$prop] = $val; } // allowed to be null, but has to be in postparameter if ( - in_array($prop, ['zgvdatum', 'zgvmadatum', 'zgvdoktordatum', 'zgv_code', 'zgvmas_code', 'zgvdoktor_code']) + in_array($prop, ['foerderrelevant', 'zgvdatum', 'zgvmadatum', 'zgvdoktordatum', 'zgv_code', 'zgvmas_code', 'zgvdoktor_code']) && !isset($update_prestudent[$prop]) && array_key_exists($prop, $_POST) ) diff --git a/application/controllers/api/frontend/v1/stv/Status.php b/application/controllers/api/frontend/v1/stv/Status.php index 665fb620f..dc48a47ff 100644 --- a/application/controllers/api/frontend/v1/stv/Status.php +++ b/application/controllers/api/frontend/v1/stv/Status.php @@ -286,11 +286,11 @@ class Status extends FHCAPI_Controller ]); $this->form_validation->set_rules('_default', '', [ - ['meldestichtag_not_exceeded', function () use ($datum, $isBerechtigtNoStudstatusCheck) { + ['meldestichtag_not_exceeded', function () use ($datum_string, $isBerechtigtNoStudstatusCheck) { if ($isBerechtigtNoStudstatusCheck) return true; // Skip if access right says so - $result = $this->prestudentstatuschecklib->checkIfMeldestichtagErreicht($datum); + $result = $this->prestudentstatuschecklib->checkIfMeldestichtagErreicht($datum_string); return !$this->getDataOrTerminateWithError($result); }], @@ -733,8 +733,9 @@ class Status extends FHCAPI_Controller ); $result = $this->prestudentstatuschecklib->checkIfMeldestichtagErreicht($oldstatus->datum); + $isMeldestichtagErreicht = $this->getDataOrTerminateWithError($result); - if (!$this->getDataOrTerminateWithError($result)) + if ($isMeldestichtagErreicht) $this->terminateWithError( $this->p->t('lehre', 'error_dataVorMeldestichtag'), self::ERROR_TYPE_GENERAL, diff --git a/application/controllers/api/frontend/v1/stv/Student.php b/application/controllers/api/frontend/v1/stv/Student.php index 0cfd82c36..f2845572f 100644 --- a/application/controllers/api/frontend/v1/stv/Student.php +++ b/application/controllers/api/frontend/v1/stv/Student.php @@ -276,7 +276,17 @@ class Student extends FHCAPI_Controller $update_person = array(); foreach ($array_allowed_props_person as $prop) { $val = $this->input->post($prop); - if ($val !== null) { + if ($val === null) + { + continue; + } + if($prop == 'foto') + { + $fotoval = ($val == '') ? null : str_replace('data:image/jpeg;base64,', '', $val); + $update_person[$prop] = $fotoval; + } + else + { $update_person[$prop] = $val; } } diff --git a/application/controllers/api/frontend/v1/stv/Verband.php b/application/controllers/api/frontend/v1/stv/Verband.php index 4060704de..6487b6263 100644 --- a/application/controllers/api/frontend/v1/stv/Verband.php +++ b/application/controllers/api/frontend/v1/stv/Verband.php @@ -188,6 +188,7 @@ class Verband extends FHCAPI_Controller array_unshift($list, [ 'name' => 'PreStudent', 'link' => $link . 'prestudent', + 'stg_kz' => (int)$studiengang_kz, 'children' => $this->getStdSem($link . 'prestudent/', $studiengang_kz) ]); diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index 1fc49c72f..1a4f566e6 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -362,6 +362,8 @@ class InfoCenter extends Auth_Controller $data[self::ORIGIN_PAGE] = $origin_page; $data[self::PREV_FILTER_ID] = $this->input->get(self::PREV_FILTER_ID); + $data['studiensemester'] = $this->variablelib->getVar('infocenter_studiensemester'); + $this->load->view('system/infocenter/infocenterDetails.php', $data); } diff --git a/application/core/Notiz_Controller.php b/application/core/Notiz_Controller.php index c2bb03267..cfc54d5f5 100644 --- a/application/core/Notiz_Controller.php +++ b/application/core/Notiz_Controller.php @@ -393,10 +393,10 @@ abstract class Notiz_Controller extends FHCAPI_Controller foreach ($result as $doc) { $res = $this->dmslib->removeAll($doc->dms_id); - if (isError($result)) + if (isError($res)) { $this->db->trans_rollback(); - $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + $this->terminateWithError(getError($res), self::ERROR_TYPE_GENERAL); } } diff --git a/application/core/Tag_Controller.php b/application/core/Tag_Controller.php index 10e54780e..5b9bac6c5 100644 --- a/application/core/Tag_Controller.php +++ b/application/core/Tag_Controller.php @@ -29,13 +29,36 @@ class Tag_Controller extends FHCAPI_Controller $this->load->model('person/Notiz_model', 'NotizModel'); $this->load->model('system/Notiztyp_model', 'NotiztypModel'); $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + + $this->loadPhrases([ + 'ui' + ]); } - public function getTag() + public function getTag($readonly_tags = null) { $language = $this->_getLanguageIndex(); $id = $this->input->get('id'); + if (is_array($readonly_tags) && !isEmptyArray($readonly_tags)) + { + $readonly_tags = $this->_filterTag($readonly_tags, true); + + foreach ($readonly_tags as $key => $tag) + { + $readonly_tags[$key] = $this->NotizModel->db->escape($tag); + } + $tags = '(' . implode(',', $readonly_tags) . ')'; + + $this->NotizModel->addSelect(" + CASE + WHEN tbl_notiz_typ.typ_kurzbz IN $tags + THEN TRUE + ELSE FALSE + END as readonly + "); + } + $this->NotizModel->addSelect( "tbl_notiz.titel, tbl_notiz.text, @@ -54,7 +77,7 @@ class Tag_Controller extends FHCAPI_Controller $this->NotizModel->addJoin('public.tbl_benutzer verfasserbenutzer', 'tbl_notiz.verfasser_uid = verfasserbenutzer.uid', 'LEFT'); $this->NotizModel->addJoin('public.tbl_person verfasserperson', 'verfasserbenutzer.person_id = verfasserperson.person_id', 'LEFT'); - $this->NotizModel->addJoin('public.tbl_benutzer bearbeiterbenutzer', 'tbl_notiz.verfasser_uid = bearbeiterbenutzer.uid', 'LEFT'); + $this->NotizModel->addJoin('public.tbl_benutzer bearbeiterbenutzer', 'tbl_notiz.bearbeiter_uid = bearbeiterbenutzer.uid', 'LEFT'); $this->NotizModel->addJoin('public.tbl_person bearbeiterperson', 'bearbeiterbenutzer.person_id = bearbeiterperson.person_id', 'LEFT'); $notiz = $this->NotizModel->loadWhere(array('notiz_id' => $id)); @@ -62,7 +85,7 @@ class Tag_Controller extends FHCAPI_Controller $this->terminateWithSuccess(hasData($notiz) ? getData($notiz)[0] : array()); } - public function getTags() + public function getTags($tags = null) { $this->NotiztypModel->addSelect( 'typ_kurzbz as tag_typ_kurzbz, @@ -73,19 +96,36 @@ class Tag_Controller extends FHCAPI_Controller ' ); $this->NotiztypModel->addOrder('prioritaet'); + + if (is_array($tags) && !isEmptyArray($tags)) + { + $tags = $this->_filterTag($tags, false); + $this->NotiztypModel->db->where_in('typ_kurzbz', $tags); + } + $notiztypen = $this->NotiztypModel->loadWhere(array('aktiv' => true)); $this->terminateWithSuccess(hasData($notiztypen) ? getData($notiztypen) : array()); } - public function addTag($withZuordnung = true) + public function addTag($withZuordnung = true, $updatable_tags = null) { $postData = $this->getPostJson(); $checkTyp = $this->NotiztypModel->loadWhere(array('typ_kurzbz' => $postData->tag_typ_kurzbz)); - if (!hasData($checkTyp)) - $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + if (isError($checkTyp)) + $this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen')); + if (!hasData($checkTyp)) + $this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen')); + + if (is_array($updatable_tags) && !isEmptyArray($updatable_tags)) + { + $tags = $this->_filterTag($updatable_tags, false); + + if (!in_array($postData->tag_typ_kurzbz, $tags)) + $this->terminateWithError($this->p->t('ui', 'keineBerechtigung')); + } if ($withZuordnung) { @@ -125,48 +165,88 @@ class Tag_Controller extends FHCAPI_Controller } } - private function addNotiz($postData) - { - return $this->NotizModel->insert(array( - 'titel' => 'TAG', //TODO klären - 'text' => $postData->notiz, - 'verfasser_uid' => $this->_uid, - 'erledigt' => false, - 'insertamum' => date('Y-m-d H:i:s'), - 'insertvon' => $this->_uid, - 'typ' => $postData->tag_typ_kurzbz - )); - - } - public function updateTag() + public function updateTag($updatable_tags = null) { $postData = $this->getPostJson(); + $post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id)); + + if (isError($post_tag)) + $this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen')); + + if (!hasData($post_tag)) + $this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen')); + + if (is_array($updatable_tags) && !isEmptyArray($updatable_tags)) + { + $tags = $this->_filterTag($updatable_tags, false); + + $post_tag_typ = getData($post_tag)[0]->typ; + + if (!in_array($post_tag_typ, $tags)) + $this->terminateWithError($this->p->t('ui', 'keineBerechtigung')); + } + $updateData = $this->NotizModel->update(array('notiz_id' => $postData->id), array('text' => $postData->notiz, 'updateamum' => date('Y-m-d H:i:s'), 'updatevon' => $this->_uid, 'bearbeiter_uid' => $this->_uid, - ) + ) ); $this->terminateWithSuccess($updateData); } - public function doneTag() + public function doneTag($updatable_tags = null) { $postData = $this->getPostJson(); + $post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id)); + + if (isError($post_tag)) + $this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen')); + + if (!hasData($post_tag)) + $this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen')); + + if (is_array($updatable_tags) && !isEmptyArray($updatable_tags)) + { + $tags = $this->_filterTag($updatable_tags, false); + + $post_tag_typ = getData($post_tag)[0]->typ; + + if (!in_array($post_tag_typ, $tags)) + $this->terminateWithError($this->p->t('ui', 'keineBerechtigung')); + } + $updateData = $this->NotizModel->update(array('notiz_id' => $postData->id), array('erledigt' => !$postData->done, + 'text' => $postData->notiz, 'updateamum' => date('Y-m-d H:i:s'), 'updatevon' => $this->_uid, 'bearbeiter_uid' => $this->_uid, ) ); - $this->terminateWithSuccess($updateData); } - public function deleteTag($withZuordnung = true) + public function deleteTag($withZuordnung = true, $updatable_tags = null) { $postData = $this->getPostJson(); + $post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id)); + + if (isError($post_tag)) + $this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen')); + + if (!hasData($post_tag)) + $this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen')); + + if (is_array($updatable_tags) && !isEmptyArray($updatable_tags)) + { + $tags = $this->_filterTag($updatable_tags, false); + + $post_tag_typ = getData($post_tag)[0]->typ; + + if (!in_array($post_tag_typ, $tags)) + $this->terminateWithError($this->p->t('ui', 'keineBerechtigung')); + } $deleteNotiz = ""; if ($withZuordnung) @@ -208,5 +288,27 @@ class Tag_Controller extends FHCAPI_Controller return hasData($result) ? getData($result)[0]->index : 1; } + private function _filterTag($tags, $readonly = true) + { + $filtered_tags = array_filter($tags, function ($tag) use ($readonly) + { + return isset($tag['readonly']) && $tag['readonly'] === $readonly; + }); + + return array_keys($filtered_tags); + } + + private function addNotiz($postData) + { + return $this->NotizModel->insert(array( + 'titel' => 'TAG', //TODO klären + 'text' => $postData->notiz, + 'verfasser_uid' => $this->_uid, + 'erledigt' => false, + 'insertamum' => date('Y-m-d H:i:s'), + 'insertvon' => $this->_uid, + 'typ' => $postData->tag_typ_kurzbz + )); + } } \ No newline at end of file diff --git a/application/libraries/DmsLib.php b/application/libraries/DmsLib.php index 774ebdc79..c6c16a866 100644 --- a/application/libraries/DmsLib.php +++ b/application/libraries/DmsLib.php @@ -670,7 +670,7 @@ class DmsLib $fileObj = new stdClass(); $fileObj->filename = getData($result)[0]->filename; $fileObj->file = DMS_PATH.getData($result)[0]->filename; - $fileObj->name = DMS_PATH.getData($result)[0]->name; // original user filename + $fileObj->name = getData($result)[0]->name; // original user filename $fileObj->mimetype = getData($result)[0]->mimetype; return success($fileObj); diff --git a/application/libraries/LektorLib.php b/application/libraries/LektorLib.php new file mode 100644 index 000000000..e06e2b728 --- /dev/null +++ b/application/libraries/LektorLib.php @@ -0,0 +1,342 @@ +_ci =& get_instance(); + $this->_ci->load->model('education/lehreinheit_model', 'LehreinheitModel'); + $this->_ci->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); + $this->_ci->load->model('organisation/Studiensemester_model','StudiensemesterModel'); + $this->_ci->load->model('ressource/Stundensatz_model', 'StundensatzModel'); + $this->_ci->load->model('vertragsbestandteil/Dienstverhaeltnis_model','DienstverhaeltnisModel'); + $this->_ci->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); + $this->_ci->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel'); + $this->_ci->load->model('person/Benutzer_model', 'BenutzerModel'); + } + + public function addLektorToLehreinheit($lehreinheit_id, $mitarbeiter_uid) + { + $this->_ci->LehreinheitModel->addSelect('tbl_lehreinheit.*, tbl_lehrveranstaltung.studiengang_kz, semesterstunden'); + $this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id'); + $lehreinheit_result = $this->_ci->LehreinheitModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id)); + + if (isError($lehreinheit_result)) return $lehreinheit_result; + + if (!hasData($lehreinheit_result)) return error("Lehreinheit not found"); + + $lehreinheit = getData($lehreinheit_result)[0]; + + $already_assigned = $this->_ci->LehreinheitmitarbeiterModel->loadWhere(array('lehreinheit_id' => $lehreinheit->lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid)); + + if (isError($already_assigned)) return $already_assigned; + + if (hasData($already_assigned)) return error('Lektor already assigned'); + + $studiensemester_result = $this->_ci->StudiensemesterModel->loadWhere(array('studiensemester_kurzbz' => $lehreinheit->studiensemester_kurzbz)); + if (isError($studiensemester_result)) return $studiensemester_result; + $studiensemester = getData($studiensemester_result)[0]; + + $stundensatz = $this->_ci->StundensatzModel->getDefaultStundensatz($mitarbeiter_uid, $studiensemester->start, $studiensemester->ende, 'lehre'); + $echter_dv_result = $this->_ci->DienstverhaeltnisModel->existsDienstverhaeltnis($mitarbeiter_uid, $studiensemester->start, $studiensemester->ende, 'echterdv'); + + $echter_dv = false; + + if (hasData($echter_dv_result)) + { + $echter_dv = true; + } + + $maxstunden = $this->getMaxStunden($mitarbeiter_uid, $studiensemester->studiensemester_kurzbz, $lehreinheit->studiengang_kz, $echter_dv); + + $newData['semesterstunden'] = 0; + $newData['planstunden'] = 0; + if (!is_null($lehreinheit->semesterstunden)) + { + $newData['semesterstunden'] = min($lehreinheit->semesterstunden, $maxstunden); + $newData['planstunden'] = min($lehreinheit->semesterstunden, $maxstunden); + } + + $newData['lehreinheit_id'] = $lehreinheit->lehreinheit_id; + $newData['mitarbeiter_uid'] = $mitarbeiter_uid; + $newData['lehrfunktion_kurzbz'] = 'Lektor'; + $newData['bismelden'] = true; + $newData['insertvon'] = getAuthUID(); + $newData['insertamum'] = date('Y-m-d H:i:s'); + $newData['stundensatz'] = $stundensatz; + $result = $this->_ci->LehreinheitmitarbeiterModel->insert($newData); + + if (isError($result)) return $result; + + return success("Lektor added successfully"); + } + + public function updateLektorFromLehreinheit($lehreinheit_id, $mitarbeiter_uid, $new_data) + { + $this->_ci->LehreinheitmitarbeiterModel->addSelect('lehre.tbl_lehreinheitmitarbeiter.*, lehre.tbl_lehreinheit.studiensemester_kurzbz, tbl_lehrveranstaltung.studiengang_kz'); + $this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehreinheit', 'lehreinheit_id'); + $this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id'); + $lehreinheit_result = $this->_ci->LehreinheitmitarbeiterModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid)); + + if (isError($lehreinheit_result)) return $lehreinheit_result; + + if (!hasData($lehreinheit_result)) return error("Lehreinheit not found"); + + $lehreinheit = getData($lehreinheit_result)[0]; + + //TODO kollision check, wird vorerst nicht implementiert -> nur über das FAS möglich + if (isset($new_data['mitarbeiter_uid']) && $new_data['mitarbeiter_uid'] !== $mitarbeiter_uid) + { + $this->_ci->load->model('ressource/stundenplandev_model', 'StundenplandevModel'); + $this->_ci->StundenplandevModel->addGroupBy('stundenplandev_id'); + $this->_ci->StundenplandevModel->addGroupBy('mitarbeiter_uid'); + $this->_ci->StundenplandevModel->addGroupBy('mitarbeiter_uid'); + $verplant = $this->_ci->StundenplandevModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid)); + + if (hasData($verplant)) + return error('Wechsel vom Mitarbeiter nicht möglich da er bereits verplant ist!'); + } + $warning = ''; + if (isset($new_data['semesterstunden'])) + { + $studiengang_result = $this->_ci->StudiengangModel->loadWhere(array('studiengang_kz' => $lehreinheit->studiengang_kz)); + if (isError($studiengang_result)) return $studiengang_result; + if (!hasData($studiengang_result)) return error('Studiengang not found'); + $studiengang = getData($studiengang_result)[0]; + + $studiensemester_result = $this->_ci->StudiensemesterModel->loadWhere(array('studiensemester_kurzbz' => $lehreinheit->studiensemester_kurzbz)); + if (isError($studiensemester_result)) return $studiensemester_result; + $studiensemester = getData($studiensemester_result)[0]; + + $echter_dv_result = $this->_ci->DienstverhaeltnisModel->existsDienstverhaeltnis($mitarbeiter_uid, $studiensemester->start, $studiensemester->ende, 'echterdv'); + + $echter_dv = false; + + if (hasData($echter_dv_result)) + { + $echter_dv = true; + } + + $neue_stunden_eingerechnet = isset($new_data['bismelden']) ? $new_data['bismelden'] : $lehreinheit->bismelden; + $alte_stunden_eingerechnet = $lehreinheit->bismelden; + + if (($new_data['semesterstunden'] > $lehreinheit->semesterstunden) || $neue_stunden_eingerechnet) + { + $stundengrenze_result = $this->_ci->OrganisationseinheitModel->getStundengrenze($studiengang->oe_kurzbz, $echter_dv); + if (isError($stundengrenze_result)) return $stundengrenze_result; + + $stundengrenze = getData($stundengrenze_result)[0]; + + $oe_result = $this->_ci->OrganisationseinheitModel->getChilds($stundengrenze->oe_kurzbz); + $oe_array = hasData($oe_result) ? array_column(getData($oe_result), 'oe_kurzbz') : array(''); + + if ($alte_stunden_eingerechnet && $neue_stunden_eingerechnet) + $this->_ci->LehreinheitmitarbeiterModel->addSelect("(SUM(tbl_lehreinheitmitarbeiter.semesterstunden) - ($lehreinheit->semesterstunden) + {$this->_ci->LehreinheitmitarbeiterModel->db->escape($new_data['semesterstunden'])}) as summe"); + else if ($alte_stunden_eingerechnet && !$neue_stunden_eingerechnet) + $this->_ci->LehreinheitmitarbeiterModel->addSelect("(SUM(tbl_lehreinheitmitarbeiter.semesterstunden) - ($lehreinheit->semesterstunden)) as summe"); + else if (!$alte_stunden_eingerechnet && $neue_stunden_eingerechnet) + $this->_ci->LehreinheitmitarbeiterModel->addSelect("(SUM(tbl_lehreinheitmitarbeiter.semesterstunden) + ({$this->_ci->LehreinheitmitarbeiterModel->db->escape($new_data['semesterstunden'])})) as summe"); + else if (!$alte_stunden_eingerechnet && !$neue_stunden_eingerechnet) + $this->_ci->LehreinheitmitarbeiterModel->addSelect("(SUM(tbl_lehreinheitmitarbeiter.semesterstunden)) as summe"); + + $this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehreinheit', 'lehreinheit_id'); + $this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id'); + $this->_ci->LehreinheitmitarbeiterModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + + $this->_ci->LehreinheitmitarbeiterModel->db->where('mitarbeiter_uid', (isset($new_data['mitarbeiter_uid']) ? $new_data['mitarbeiter_uid'] : $mitarbeiter_uid)); + $this->_ci->LehreinheitmitarbeiterModel->db->where('studiensemester_kurzbz', $lehreinheit->studiensemester_kurzbz); + $this->_ci->LehreinheitmitarbeiterModel->db->where('bismelden', true); + $this->_ci->LehreinheitmitarbeiterModel->db->where('lower(mitarbeiter_uid) NOT LIKE', '_dummy%'); + + $this->_ci->LehreinheitmitarbeiterModel->db->where_in('tbl_studiengang.oe_kurzbz', $oe_array); + + + if(defined('FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE') + && is_array(FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE) + && count(FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE) > 0) + { + $this->_ci->LehreinheitmitarbeiterModel->db->where_not_in('tbl_studiengang.oe_kurzbz', FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE); + } + + $summe_result = $this->_ci->LehreinheitmitarbeiterModel->load(); + + if (isError($summe_result)) return $summe_result; + + if (!hasData($summe_result)) return error('Fehler beim Ermitteln der Gesamtstunden'); + + $summe = getData($summe_result)[0]->summe; + + if ($summe > $stundengrenze->stunden) + { + + if (!$echter_dv && (!$this->_ci->permissionlib->isBerechtigt('admin'))) + { + if (!$this->LehrauftragAufFirma(isset($formData['mitarbeiter_uid']) ? $formData['mitarbeiter_uid'] : $mitarbeiter_uid)) + return error("ACHTUNG: Die maximal erlaubte Semesterstundenanzahl des Lektors von $summe Stunden ($stundengrenze->stunden) wurde ueberschritten!\nDaten wurden NICHT gespeichert!\n\n"); + } + else + { + $warning .= "ACHTUNG: Die maximal erlaubte Semesterstundenanzahl des Lektors von $summe Stunden ($stundengrenze->stunden) wurde ueberschritten!\nDaten wurden gespeichert!\n\n"; + } + + $stunden_limit_result = $this->getStundenInstitut($mitarbeiter_uid, $lehreinheit->studiensemester_kurzbz, $oe_array); + + if (hasData($stunden_limit_result)) + { + $stunden_limit_array = getData($stunden_limit_result); + foreach ($stunden_limit_array as $stunden_limit) + { + $warning .= $stunden_limit->summe . ' Stunden ' . $stunden_limit->bezeichnung . "\n"; + } + } + } + } + } + + $benutzer_result = $this->_ci->BenutzerModel->load(array(isset($formData['mitarbeiter_uid']) ? $formData['mitarbeiter_uid'] : $mitarbeiter_uid)); + + if (isError($benutzer_result)) return $benutzer_result; + + if (!hasData($benutzer_result)) return error('Benutzer not found'); + + $benutzer_aktiv = getData($benutzer_result)[0]->aktiv; + + if (!$benutzer_aktiv) + $warning .= "Achtung: Der/Die Benutzer*in ist inaktiv!\nBitte informieren Sie die Personalbteilung.\nDaten wurden gespeichert.\n\n"; + + $updatableFields = array( + 'semesterstunden', + 'planstunden', + 'stundensatz', + 'faktor', + 'anmerkung', + 'lehrfunktion_kurzbz', + 'mitarbeiter_uid', + 'bismelden' + ); + + $updateData = array(); + foreach ($updatableFields as $field) + { + $value = isset($new_data[$field]) ? $new_data[$field] : null; + + if ($value !== null) + { + $updateData[$field] = $value; + } + } + $updateData['updatevon'] = getAuthUID(); + $updateData['updateamum'] = date('Y-m-d H:i:s'); + + $result = $this->_ci->LehreinheitmitarbeiterModel->update(array('lehreinheit_id' => $lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid), $updateData); + + if (isError($result)) return $result; + + if ($warning !== '') return success(['warning' => $warning]); + + return success('Erfolgreich geupdated'); + } + + private function getMaxStunden($mitarbeiter_uid, $studiensemester_kurzbz, $studiengang_kz, $echter_dv) + { + $maxstunden = 9999; + + $studiengang_result = $this->_ci->StudiengangModel->loadWhere(array('studiengang_kz' => $studiengang_kz)); + if (isError($studiengang_result)) return $studiengang_result; + + $studiengang = getData($studiengang_result)[0]; + + $stundengrenze_result = $this->_ci->OrganisationseinheitModel->getStundengrenze($studiengang->oe_kurzbz, $echter_dv); + if (isError($stundengrenze_result)) return $stundengrenze_result; + + $stundengrenze = getData($stundengrenze_result)[0]; + $maxstunden = $stundengrenze->stunden; + + $lehrauftrag_firma = $this->LehrauftragAufFirma($mitarbeiter_uid); + + if (!$echter_dv && !$lehrauftrag_firma) + { + $oe_result = $this->_ci->OrganisationseinheitModel->getChilds($stundengrenze->oe_kurzbz); + $oe_array = hasData($oe_result) ? array_column(getData($oe_result), 'oe_kurzbz') : array(''); + + $stunden_summe_result = $this->getSumSemesterstunden($mitarbeiter_uid, $studiensemester_kurzbz, $oe_array); + + $stunden_summe = hasData($stunden_summe_result) ? getData($stunden_summe_result)[0]->summe : 0; + + if ($stunden_summe >= $maxstunden && (!$this->_ci->permissionlib->isBerechtigt('admin'))) + { + $stunden_limit_result = $this->getStundenInstitut($mitarbeiter_uid, $studiensemester_kurzbz, $oe_array); + + $error = "ACHTUNG: Die maximal erlaubte Semesterstundenanzahl des Lektors von $maxstunden Stunden ($stundengrenze->oe_kurzbz) wurde ueberschritten!\n + Daten wurden NICHT gespeichert!\n\n"; + + if (hasData($stunden_limit_result)) + { + $stunden_limit_array = getData($stunden_limit_result); + + foreach ($stunden_limit_array as $stunden_limit) + { + $error .= $stunden_limit->summe . ' Stunden ' . $stunden_limit->bezeichnung . "\n"; + } + } + return error($error); + } + else + $maxstunden =- $stunden_summe; + } + return $maxstunden; + } + + private function LehrauftragAufFirma($mitarbeiter_uid) + { + $this->_ci->MitarbeiterModel->addJoin('tbl_benutzer', 'tbl_mitarbeiter.mitarbeiter_uid = tbl_benutzer.uid'); + $this->_ci->MitarbeiterModel->addJoin('tbl_person', 'person_id'); + $this->_ci->MitarbeiterModel->addJoin('tbl_adresse', 'person_id', 'LEFT'); + $this->_ci->MitarbeiterModel->addOrder('zustelladresse', 'DESC'); + $this->_ci->MitarbeiterModel->addOrder('firma_id'); + $this->_ci->MitarbeiterModel->addLimit(1); + $firma_result = $this->_ci->MitarbeiterModel->loadWhere(array('mitarbeiter_uid' => $mitarbeiter_uid)); + $firma = getData($firma_result)[0]->firma_id; + return !is_null($firma); + } + + private function getSumSemesterstunden($mitarbeiter_uid, $studiensemester_kurzbz, $oe_array = array()) + { + $this->_ci->LehreinheitmitarbeiterModel->addSelect('SUM(tbl_lehreinheitmitarbeiter.semesterstunden) as summe'); + $this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehreinheit', 'lehreinheit_id'); + $this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id'); + $this->_ci->LehreinheitmitarbeiterModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + $this->_ci->LehreinheitmitarbeiterModel->db->where('mitarbeiter_uid', $mitarbeiter_uid); + $this->_ci->LehreinheitmitarbeiterModel->db->where('studiensemester_kurzbz', $studiensemester_kurzbz); + $this->_ci->LehreinheitmitarbeiterModel->db->where('bismelden', true); + $this->_ci->LehreinheitmitarbeiterModel->db->where('lower(mitarbeiter_uid) NOT LIKE', '_dummy%'); + $this->_ci->LehreinheitmitarbeiterModel->db->where_in('tbl_studiengang.oe_kurzbz', $oe_array); + return $this->_ci->LehreinheitmitarbeiterModel->load(); + } + + private function getStundenInstitut($mitarbeiter_uid, $studiensemester_kurzbz, $oe_array = array()) + { + $this->_ci->LehreinheitmitarbeiterModel->addSelect('SUM(tbl_lehreinheitmitarbeiter.semesterstunden) as summe, tbl_studiengang.bezeichnung'); + $this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehreinheit', 'lehreinheit_id'); + $this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id'); + $this->_ci->LehreinheitmitarbeiterModel->addJoin('public.tbl_studiengang', 'studiengang_kz'); + $this->_ci->LehreinheitmitarbeiterModel->db->where('mitarbeiter_uid', $mitarbeiter_uid); + $this->_ci->LehreinheitmitarbeiterModel->db->where('studiensemester_kurzbz', $studiensemester_kurzbz); + $this->_ci->LehreinheitmitarbeiterModel->db->where('bismelden', true); + $this->_ci->LehreinheitmitarbeiterModel->db->where_in('tbl_studiengang.oe_kurzbz', $oe_array); + + if(defined('FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE') + && is_array(FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE) + && count(FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE) > 0) + { + $this->_ci->LehreinheitmitarbeiterModel->db->where_not_in('tbl_studiengang.oe_kurzbz', FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE); + } + + $this->_ci->LehreinheitmitarbeiterModel->addGroupBy('tbl_studiengang.bezeichnung'); + return $this->_ci->LehreinheitmitarbeiterModel->load(); + } +} diff --git a/application/libraries/ProfilLib.php b/application/libraries/ProfilLib.php index 2a130d263..6e93a0943 100644 --- a/application/libraries/ProfilLib.php +++ b/application/libraries/ProfilLib.php @@ -214,7 +214,7 @@ class ProfilLib{ * @param integer $uid the userID used to get the kontakt information * @return array all the kontakt information corresponding to a userID */ - private function getKontaktInfo($pid) + private function getKontaktInfo($pid, $includehidden=false) { $this->ci->load->model("person/Kontakt_model","KontaktModel"); $this->ci->KontaktModel->addSelect(['kontakttyp', 'kontakt_id', 'kontakt', 'tbl_kontakt.anmerkung', 'tbl_kontakt.zustellung']); @@ -222,7 +222,13 @@ class ProfilLib{ $this->ci->KontaktModel->addJoin('public.tbl_firma', 'firma_id', 'LEFT'); $this->ci->KontaktModel->addOrder('kontakttyp, kontakt, tbl_kontakt.updateamum, tbl_kontakt.insertamum'); - $kontakte_res = $this->ci->KontaktModel->loadWhere(['person_id' => $pid]); + $params = array('person_id' => $pid); + if(!$includehidden) + { + $params['kontakttyp <>'] = 'hidden'; + } + + $kontakte_res = $this->ci->KontaktModel->loadWhere($params); if(isError($kontakte_res)){ return error(getData($kontakte_res)); } @@ -303,10 +309,22 @@ class ProfilLib{ private function getBenutzerFunktion($uid) { $this->ci->load->model("person/Benutzerfunktion_model","BenutzerfunktionModel"); - $this->ci->BenutzerfunktionModel->addSelect(["tbl_benutzerfunktion.bezeichnung as Bezeichnung", "tbl_organisationseinheit.bezeichnung as Organisationseinheit", "datum_von as Gültig_von", "datum_bis as Gültig_bis", "wochenstunden as Wochenstunden"]); + $this->ci->BenutzerfunktionModel->addSelect([ + "CASE WHEN (tbl_benutzerfunktion.bezeichnung IS NOT NULL AND tbl_benutzerfunktion.bezeichnung <> '' AND tbl_benutzerfunktion.bezeichnung <> tbl_funktion.beschreibung) THEN tbl_funktion.beschreibung || ' - ' || tbl_benutzerfunktion.bezeichnung ELSE tbl_funktion.beschreibung END as \"Bezeichnung\"", + "tbl_organisationseinheit.bezeichnung as Organisationseinheit", + "datum_von as Gültig_von", + "datum_bis as Gültig_bis", + "COALESCE(wochenstunden, '0'::numeric(5,2)) AS \"Wochenstunden\"" + ]); + $this->ci->BenutzerfunktionModel->addJoin("tbl_funktion", "funktion_kurzbz"); $this->ci->BenutzerfunktionModel->addJoin("tbl_organisationseinheit", "oe_kurzbz"); - $benutzer_funktion_res = $this->ci->BenutzerfunktionModel->loadWhere(array('uid' => $uid)); + $benutzer_funktion_res = $this->ci->BenutzerfunktionModel->loadWhere( + array( + 'uid' => $uid, + 'NOW()::date BETWEEN COALESCE(datum_von, \'1970-01-01\'::date) AND COALESCE(datum_bis, \'2170-12-01\'::date)' => null + ) + ); if(isError($benutzer_funktion_res)){ return error(getData($benutzer_funktion_res)); } diff --git a/application/libraries/vertragsbestandteil/GehaltsbestandteilLib.php b/application/libraries/vertragsbestandteil/GehaltsbestandteilLib.php index 1aaafa471..c1238c13d 100644 --- a/application/libraries/vertragsbestandteil/GehaltsbestandteilLib.php +++ b/application/libraries/vertragsbestandteil/GehaltsbestandteilLib.php @@ -24,7 +24,6 @@ class GehaltsbestandteilLib $this->CI = get_instance(); $this->CI->load->model('vertragsbestandteil/Gehaltsbestandteil_model', 'GehaltsbestandteilModel'); - $this->CI->load->library('extensions/FHC-Core-Personalverwaltung/abrechnung/GehaltsLib'); $this->GehaltsbestandteilModel = $this->CI->GehaltsbestandteilModel; } @@ -121,10 +120,6 @@ class GehaltsbestandteilLib { $this->setUIDtoPGSQL(); - // delete Gehaltsabrechnung - $ret = $this->CI->gehaltslib->deleteAbrechnung($gehaltsbestandteil); - - // $ret = $this->GehaltsbestandteilModel->delete($gehaltsbestandteil->getGehaltsbestandteil_id()); if (isError($ret)) diff --git a/application/models/accounting/Vertrag_model.php b/application/models/accounting/Vertrag_model.php index abc2114a6..c17c676c7 100644 --- a/application/models/accounting/Vertrag_model.php +++ b/application/models/accounting/Vertrag_model.php @@ -384,6 +384,60 @@ class Vertrag_model extends DB_Model } } + public function getVertrag($mitarbeiter_uid, $lehreinheit_id) + { + $this->addSelect('tbl_lehreinheitmitarbeiter.*, tbl_vertrag.*, status.bezeichnung as vertragsstatus, status.vertragsstatus_kurzbz'); + $this->addJoin('lehre.tbl_lehreinheitmitarbeiter', 'vertrag_id'); + $this->addJoin('lehre.tbl_vertragstyp', 'vertragstyp_kurzbz', 'LEFT'); + $this->addJoin(' + ( + SELECT DISTINCT ON(vertrag_id) vertrag_id, + bezeichnung, + tbl_vertragsstatus.vertragsstatus_kurzbz + FROM lehre.tbl_vertrag_vertragsstatus + JOIN lehre.tbl_vertragsstatus USING(vertragsstatus_kurzbz) + ORDER BY vertrag_id, datum DESC + ) as status', 'status.vertrag_id = lehre.tbl_vertrag.vertrag_id', 'LEFT'); + + return $this->loadWhere(array('mitarbeiter_uid' => $mitarbeiter_uid, 'lehreinheit_id' => $lehreinheit_id)); + } + + public function cancelVertrag($vertrag_id, $mitarbeiter_uid) + { + $vertrag = $this->load($vertrag_id); + + if (!hasData($vertrag)) + return error("Contract not found"); + + $vertrag = getData($vertrag)[0]; + + $this->_updateVertragRelevant($vertrag->vertrag_id); + + return $this->VertragvertragsstatusModel->insert(array( + 'vertrag_id' => $vertrag->vertrag_id, + 'vertragsstatus_kurzbz' => 'storno', + 'uid' => $mitarbeiter_uid, + 'datum' => 'NOW()', + 'insertamum' => 'NOW()', + 'insertvon' => getAuthUID() + )); + } + + public function deleteVertrag($vertrag_id) + { + $vertrag = $this->load($vertrag_id); + + if (!hasData($vertrag)) + return error("Contract not found"); + + $vertrag = getData($vertrag)[0]; + + $this->_updateVertragRelevant($vertrag->vertrag_id); + + $this->VertragvertragsstatusModel->delete(array('vertrag_id' => $vertrag->vertrag_id)); + return $this->delete(array('vertrag_id' => $vertrag->vertrag_id)); + } + // ----------------------------------------------------------------------------------------------------------------- // Private methods @@ -415,4 +469,20 @@ class Vertrag_model extends DB_Model return $bezeichnung; } + + private function _updateVertragRelevant($vertrag_id) + { + $this->LehreinheitmitarbeiterModel->update( + array("vertrag_id" => $vertrag_id), + array( + 'vertrag_id' => null + ) + ); + $this->ProjektbetreuerModel->update( + array("vertrag_id" => $vertrag_id), + array( + 'vertrag_id' => null + ) + ); + } } diff --git a/application/models/education/Lehreinheit_model.php b/application/models/education/Lehreinheit_model.php index d4bc7a22f..e52af4cba 100644 --- a/application/models/education/Lehreinheit_model.php +++ b/application/models/education/Lehreinheit_model.php @@ -1,4 +1,6 @@ load->model('education/lehreinheitgruppe_model', 'LehreinheitgruppeModel'); $this->load->model('education/lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel'); $this->load->model('organisation/studiengang_model', 'StudiengangModel'); + $this->load->model('ressource/stundenplandev_model', 'StundenplandevModel'); + $this->load->model('ressource/stundenplan_model', 'StundenplanModel'); + $this->load->model('system/Log_model', 'LogModel'); } /** @@ -28,6 +33,11 @@ class Lehreinheit_model extends DB_Model { $lehreinheiten = array(); + $this->addSelect( + 'lehreinheit_id, lehrveranstaltung_id, studiensemester_kurzbz, lehrform_kurzbz, + stundenblockung, wochenrythmus, start_kw, raumtyp, raumtypalternativ, + sprache, lehre, unr, lvnr, lehrfach_id, gewicht' + ); $this->addOrder('lehreinheit_id'); $les = $this->loadWhere( array('lehrveranstaltung_id' => $lehrveranstaltung_id, @@ -303,4 +313,424 @@ EOSQL; return $this->execQuery($query, $params); } + + + public function getOes($lehreinheit_id) + { + $this->addSelect('tbl_lehrveranstaltung.studiengang_kz, + tbl_lehrveranstaltung.lehrveranstaltung_id'); + $this->addJoin('lehre.tbl_lehrveranstaltung', 'tbl_lehrveranstaltung.lehrveranstaltung_id = tbl_lehreinheit.lehrveranstaltung_id'); + $result = $this->loadWhere(array('lehreinheit_id' => $lehreinheit_id)); + + if (isError($result)) return $result; + + if (hasData($result)) + { + $lehrveranstaltung = getData($result)[0]; + $oe_result = $this->LehrveranstaltungModel->getAllOe($lehrveranstaltung->lehrveranstaltung_id); + return success(hasData($oe_result) ? array_column(getData($oe_result), 'oe_kurzbz') : array('')); + } + } + + public function getLehrfachOe($lehreinheit_id) + { + $this->addSelect('lehrfach.oe_kurzbz'); + $this->addJoin('lehre.tbl_lehrveranstaltung lehrfach', 'lehrfach.lehrveranstaltung_id = tbl_lehreinheit.lehrfach_id', 'LEFT'); + return $this->loadWhere(array('lehreinheit_id' => $lehreinheit_id)); + } + + + public function getByLvidStudiensemester($lv_id, $studiensemester_kurzbz, $mitarbeiter_uid = null, $fachbereich_kurzbz = null) + { + $qry = "WITH lehreinheiten AS ( + SELECT * + FROM lehre.tbl_lehreinheit + WHERE lehrveranstaltung_id = ? + AND studiensemester_kurzbz = ? + ), + ". $this->_getGruppenCTE() . ", + ". $this->_getLektorenCTE() . ", + ". $this->_getFachbereichCTE() . ", + ". $this->_getTagsCTE() . " + + SELECT lehreinheiten.*, + lehreinheiten.lehrform_kurzbz as lv_lehrform_kurzbz, + tbl_lehrveranstaltung.kurzbz as lv_kurzbz, + tbl_lehrveranstaltung.bezeichnung as lv_bezeichnung, + COALESCE(tag_data_agg.tags, '[]'::json) AS tags, + gruppen.gruppen, + mitarbeiter.lektoren, + mitarbeiter.le_planstunden, + mitarbeiter.vorname, + mitarbeiter.nachname, + mitarbeiter.semesterstunden, + fachbereich.bezeichnung as fachbereich, + UPPER(CONCAT(tbl_studiengang.typ,tbl_studiengang.kurzbz)) as studiengang, + semester + FROM lehreinheiten + LEFT JOIN lehre.tbl_lehrveranstaltung ON tbl_lehrveranstaltung.lehrveranstaltung_id = lehreinheiten.lehrfach_id + LEFT JOIN public.tbl_studiengang USING(studiengang_kz) + LEFT JOIN tag_data_agg ON tag_data_agg.lehreinheit_id = lehreinheiten.lehreinheit_id + LEFT JOIN mitarbeiter ON lehreinheiten.lehreinheit_id = mitarbeiter.lehreinheit_id + LEFT JOIN fachbereich ON lehreinheiten.lehreinheit_id = fachbereich.lehreinheit_id + LEFT JOIN gruppen ON lehreinheiten.lehreinheit_id = gruppen.lehreinheit_id + WHERE true + "; + + $params = array($lv_id, $studiensemester_kurzbz); + + if ($mitarbeiter_uid !== null) + { + $qry .= " AND lehreinheiten.lehreinheit_id IN ( SELECT lehreinheit_id FROM lehre.tbl_lehreinheitmitarbeiter WHERE mitarbeiter_uid = ?) "; + $params[] = $mitarbeiter_uid; + } + + if($fachbereich_kurzbz !== null) + { + $qry .= " AND EXISTS ( SELECT 1 FROM lehre.tbl_lehrveranstaltung JOIN public.tbl_fachbereich USING(oe_kurzbz) WHERE fachbereich_kurzbz= ? AND lehrveranstaltung_id=lehreinheiten.lehrfach_id)"; + $params[] = $fachbereich_kurzbz; + } + $qry .= " ORDER BY lehrveranstaltung_id;"; + + return $this->execReadOnlyQuery($qry, $params); + } + + private function getLVTmp($stg_kz = null) + { + $qry = "SELECT DISTINCT ON(lehrveranstaltung_id) *, + '' as stundenblockung, + '' as lehreinheit_id, + '' as wochenrythmus, + '' as raumtyp, + '' as raumtypalternativ, + '' as gruppen, + '' as studienplan_id, + '' as studienplan_beeichnung, + UPPER(CONCAT(vw_lehreinheit.stg_typ, vw_lehreinheit.stg_kurzbz)) as studiengang + FROM campus.vw_lehreinheit + WHERE mitarbeiter_uid = ? + AND studiensemester_kurzbz = ?"; + + if (!is_null($stg_kz)) { + $qry .= " AND lv_studiengang_kz = ?"; + } + + return $qry; + } + + public function getLvsByEmployee($mitarbeiter_uid, $studiensemester_kurzbz, $stg_kz = null) + { + $qry = "WITH lvs AS (" . $this->getLVTmp($stg_kz) . ") + SELECT lvs.* + FROM lvs + "; + + $params = array($mitarbeiter_uid, $studiensemester_kurzbz); + if (!is_null($stg_kz)) + { + $params[] = $stg_kz; + } + return $this->execReadOnlyQuery($qry, $params); + } + + public function deleteLehreinheit($lehreinheit_id) + { + $lehreinheit = $this->loadWhere(array('lehreinheit_id' => $lehreinheit_id)); + + if (isError($lehreinheit)) return $lehreinheit; + + if (!hasData($lehreinheit)) + return error("Lehreinheit not found!"); + + $errorReasons = []; + $addError = function ($reason = null) use (&$errorReasons) + { + if ($reason !== null) + { + $errorReasons[] = $reason; + } + }; + + $stundenplandev_result = $this->StundenplandevModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id)); + $stundenplan_result = $this->StundenplanModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id)); + + if (hasData($stundenplan_result) || hasData($stundenplandev_result)) + $addError('Dieser LV-Teil ist bereits im LV-Plan verplant und kann daher nicht geloescht werden!'); + + Events::trigger( + 'lehreinheit_delete_check', + $addError, + $lehreinheit_id + ); + + if (!empty($errorReasons)) return error($errorReasons); + + $this->db->trans_begin(); + + Events::trigger( + 'lehreinheit_delete', + $addError, + $lehreinheit_id + ); + + $undosql = ''; + + $lehreinheit_gruppe_result = $this->LehreinheitgruppeModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id)); + if (hasData($lehreinheit_gruppe_result)) + { + foreach (getData($lehreinheit_gruppe_result) as $row) + { + $values = [ + $this->db->escape($row->lehreinheitgruppe_id), + $this->db->escape($row->lehreinheit_id), + $this->db->escape($row->studiengang_kz), + $this->db->escape($row->semester), + $this->db->escape($row->verband), + $this->db->escape($row->gruppe), + $this->db->escape($row->gruppe_kurzbz), + $this->db->escape($row->updateamum), + $this->db->escape($row->updatevon), + $this->db->escape($row->insertamum), + $this->db->escape($row->insertvon) + ]; + + $undosql .= "INSERT INTO lehre.tbl_lehreinheitgruppe ( + lehreinheitgruppe_id, + lehreinheit_id, + studiengang_kz, + semester, + verband, + gruppe, + gruppe_kurzbz, + updateamum, + updatevon, + insertamum, + insertvon + ) VALUES (" . implode(', ', $values) . ");\n"; + } + + $lehreinheit_gruppe_delete_result = $this->LehreinheitgruppeModel->delete(array('lehreinheit_id' => $lehreinheit_id)); + + if (isError($lehreinheit_gruppe_delete_result)) + $addError(getError($lehreinheit_gruppe_delete_result)); + } + + $lehreinheit_mitarbeiter_result = $this->LehreinheitmitarbeiterModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id)); + if (hasData($lehreinheit_mitarbeiter_result)) + { + foreach (getData($lehreinheit_mitarbeiter_result) as $row) + { + $values = [ + $this->db->escape($row->lehreinheit_id), + $this->db->escape($row->mitarbeiter_uid), + $this->db->escape($row->lehrfunktion_kurzbz), + $this->db->escape($row->planstunden), + $this->db->escape($row->stundensatz), + $this->db->escape($row->faktor), + $this->db->escape($row->anmerkung), + $this->db->escape($row->bismelden), + $this->db->escape($row->updateamum), + $this->db->escape($row->updatevon), + $this->db->escape($row->insertamum), + $this->db->escape($row->insertvon), + $this->db->escape($row->semesterstunden) + ]; + + $undosql .= "INSERT INTO lehre.tbl_lehreinheitmitarbeiter ( + lehreinheit_id, + mitarbeiter_uid, + lehrfunktion_kurzbz, + planstunden, + stundensatz, + faktor, + anmerkung, + bismelden, + updateamum, + updatevon, + insertamum, + insertvon, + semesterstunden + ) VALUES (" . implode(', ', $values) . ");\n"; + } + + $lehreinheit_mitarbeiter_delete_result = $this->LehreinheitmitarbeiterModel->delete(array('lehreinheit_id' => $lehreinheit_id)); + if (isError($lehreinheit_mitarbeiter_delete_result)) + $addError(getError($lehreinheit_mitarbeiter_delete_result)); + } + + foreach (getData($lehreinheit) as $row) + { + $values = [ + $this->db->escape($row->lehreinheit_id), + $this->db->escape($row->lehrveranstaltung_id), + $this->db->escape($row->studiensemester_kurzbz), + $this->db->escape($row->lehrfach_id), + $this->db->escape($row->lehrform_kurzbz), + $this->db->escape($row->stundenblockung), + $this->db->escape($row->wochenrythmus), + $this->db->escape($row->start_kw), + $this->db->escape($row->raumtyp), + $this->db->escape($row->raumtypalternativ), + $this->db->escape($row->sprache), + $this->db->escape($row->lehre), + $this->db->escape($row->anmerkung), + $this->db->escape($row->unr), + $this->db->escape($row->lvnr), + $this->db->escape($row->updateamum), + $this->db->escape($row->updatevon), + $this->db->escape($row->insertamum), + $this->db->escape($row->insertvon), + ]; + + $undosql .= "INSERT INTO lehre.tbl_lehreinheit ( + lehreinheit_id, + lehrveranstaltung_id, + studiensemester_kurzbz, + lehrfach_id, + lehrform_kurzbz, + stundenblockung, + wochenrythmus, + start_kw, + raumtyp, + raumtypalternativ, + sprache, + lehre, + anmerkung, + unr, + lvnr, + updateamum, + updatevon, + insertamum, + insertvon + ) VALUES (" . implode(', ', $values) . ");\n"; + } + $lehreinheit_result = $this->delete($lehreinheit_id); + + $deleteSql = "DELETE FROM lehre.tbl_lehreinheitmitarbeiter WHERE lehreinheit_id = " . $this->db->escape($lehreinheit_id) ."; \n + DELETE FROM lehre.tbl_lehreinheitgruppe WHERE lehreinheit_id = " . $this->db->escape($lehreinheit_id) ."; \n + DELETE FROM lehre.tbl_lehreinheit WHERE lehreinheit_id = " . $this->db->escape($lehreinheit_id) .";"; + if (isError($lehreinheit_result)) + $addError($lehreinheit_result); + + $log_result = $this->LogModel->insert([ + 'sql' => $deleteSql, + 'sqlundo' => $undosql, + 'beschreibung' => 'Lehreinheit loeschen - ' . $lehreinheit_id, + 'mitarbeiter_uid' => getAuthUID(), + ]); + + if (isError($log_result)) + $addError($log_result); + + if (!empty($errorReasons)) + { + $this->db->trans_rollback(); + return error($errorReasons); + } + + $this->db->trans_commit(); + return success('Contract successfully updated.'); + } + + private function _getGruppenCTE() + { + return "gruppen AS ( + SELECT + lehreinheit_id, + STRING_AGG( + CASE + WHEN (tbl_lehreinheitgruppe.gruppe_kurzbz IS NULL OR tbl_lehreinheitgruppe.gruppe_kurzbz = '') + THEN + UPPER(tbl_studiengang.typ::varchar(1) || tbl_studiengang.kurzbz) || + COALESCE(TRIM(tbl_lehreinheitgruppe.semester::text), '') || + COALESCE(TRIM(tbl_lehreinheitgruppe.verband), '') || + COALESCE(TRIM(tbl_lehreinheitgruppe.gruppe), '') + ELSE + CASE + WHEN NOT tbl_gruppe.direktinskription THEN tbl_lehreinheitgruppe.gruppe_kurzbz + ELSE NULL + END + END, + ' ' + ) AS gruppen + FROM lehre.tbl_lehreinheitgruppe + LEFT JOIN public.tbl_studiengang USING (studiengang_kz) + LEFT JOIN public.tbl_gruppe USING (gruppe_kurzbz) + JOIN lehreinheiten USING(lehreinheit_id) + GROUP BY lehreinheit_id + )"; + } + private function _getLektorenCTE() + { + return "mitarbeiter AS ( + SELECT + tbl_lehreinheitmitarbeiter.lehreinheit_id, + STRING_AGG(m.kurzbz, ' ') AS lektoren, + STRING_AGG(tbl_person.vorname, ' ') AS vorname, + STRING_AGG(tbl_person.nachname, ' ') AS nachname, + STRING_AGG(tbl_lehreinheitmitarbeiter.semesterstunden::text, ' ') AS semesterstunden, + STRING_AGG(tbl_lehreinheitmitarbeiter.planstunden::text, ' ') AS le_planstunden + FROM lehre.tbl_lehreinheitmitarbeiter + JOIN public.tbl_mitarbeiter m USING (mitarbeiter_uid) + JOIN lehreinheiten USING(lehreinheit_id) + JOIN public.tbl_benutzer ON mitarbeiter_uid = uid + JOIN public.tbl_person ON tbl_benutzer.person_id = tbl_person.person_id + GROUP BY tbl_lehreinheitmitarbeiter.lehreinheit_id + )"; + } + + private function _getFachbereichCTE() + { + return "fachbereich AS ( + SELECT + CONCAT(tbl_organisationseinheit.bezeichnung, ' (', tbl_organisationseinheit.organisationseinheittyp_kurzbz, ')') as bezeichnung, + lehreinheiten.lehreinheit_id + FROM public.tbl_organisationseinheit + JOIN lehre.tbl_lehrveranstaltung AS lehrfach ON tbl_organisationseinheit.oe_kurzbz = lehrfach.oe_kurzbz + JOIN lehre.tbl_lehreinheit ON lehrfach.lehrveranstaltung_id = tbl_lehreinheit.lehrfach_id + JOIN lehreinheiten ON tbl_lehreinheit.lehreinheit_id = lehreinheiten.lehreinheit_id + )"; + } + + private function _getTagsCTE() + { + $this->load->config('lvverwaltung'); + $tags = $this->config->item('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 tbl_notiz_typ.typ_kurzbz IN (" . implode(",", $tags) . ")"; + } + + return "tag_data_agg AS ( + SELECT + lehreinheit_id, + COALESCE(json_agg(tag ORDER BY done), '[]'::json) AS tags + FROM ( + SELECT DISTINCT ON (public.tbl_notiz.notiz_id) + tbl_notiz.notiz_id AS id, + typ_kurzbz, + array_to_json(tbl_notiz_typ.bezeichnung_mehrsprachig)->>0 AS beschreibung, + text AS notiz, + style, + erledigt AS done, + lehreinheit_id + FROM public.tbl_notizzuordnung + JOIN public.tbl_notiz ON tbl_notizzuordnung.notiz_id = tbl_notiz.notiz_id + JOIN public.tbl_notiz_typ ON tbl_notiz.typ = tbl_notiz_typ.typ_kurzbz + WHERE lehreinheit_id IN (SELECT lehreinheit_id FROM lehreinheiten)" + . $whereTags. + ") AS tag + GROUP BY lehreinheit_id + )"; + } + } diff --git a/application/models/education/Lehreinheitgruppe_model.php b/application/models/education/Lehreinheitgruppe_model.php index 2a6f9571a..bca395f31 100644 --- a/application/models/education/Lehreinheitgruppe_model.php +++ b/application/models/education/Lehreinheitgruppe_model.php @@ -14,6 +14,7 @@ class Lehreinheitgruppe_model extends DB_Model $this->load->model('organisation/studiengang_model', 'StudiengangModel'); $this->load->model('organisation/gruppe_model', 'GruppeModel'); $this->load->model('person/benutzergruppe_model', 'BenutzergruppeModel'); + $this->load->model('ressource/stundenplandev_model', 'StundenplandevModel'); } /** @@ -23,7 +24,15 @@ class Lehreinheitgruppe_model extends DB_Model */ public function getDirectGroup($lehreinheit_id) { + $this->addSelect('tbl_lehreinheitgruppe.*'); + $this->addSelect('tbl_gruppe.*'); + $this->addSelect('uid'); + $this->addSelect('vorname'); + $this->addSelect('nachname'); $this->addJoin('public.tbl_gruppe', 'gruppe_kurzbz'); + $this->addJoin('public.tbl_benutzergruppe', 'gruppe_kurzbz', 'LEFT'); + $this->addJoin('public.tbl_benutzer', 'uid', 'LEFT'); + $this->addJoin('public.tbl_person', 'person_id', 'LEFT'); return $this->loadWhere( array( 'tbl_gruppe.direktinskription' => true, @@ -264,4 +273,209 @@ class Lehreinheitgruppe_model extends DB_Model } return $result; } + + public function addGroup($lehreinheit_id, $gid, $verband) + { + $lehreinheit = $this->LehreinheitModel->load($lehreinheit_id); + + if (!hasData($lehreinheit)) + return error ('No Lehreinheit found!'); + + if ($verband === false) + { + $gruppen_result = $this->GruppeModel->loadWhere(array('gid' => $gid)); + + if (!hasData($gruppen_result)) + return error('No group found for gid ' . $gid); + + $gruppen_array = getData($gruppen_result)[0]; + + if (!isEmptyString($gruppen_array->gruppe_kurzbz)) + { + $this->db->where('trim(gruppe_kurzbz)', $gruppen_array->gruppe_kurzbz); + } + else + { + $this->db->group_start(); + $this->db->where("trim(gruppe_kurzbz) = ''"); + $this->db->or_where("gruppe_kurzbz IS NULL"); + $this->db->group_end(); + } + } + else if ($verband === true) + { + $gruppen_result = $this->LehrverbandModel->loadWhere(array('gid' => $gid)); + + if (!hasData($gruppen_result)) + return error('No group found for gid ' . $gid); + + $gruppen_array = getData($gruppen_result)[0]; + + if (!isEmptyString($gruppen_array->verband)) + { + $this->db->where('verband', $gruppen_array->verband); + } + else + { + $this->db->group_start(); + $this->db->where("trim(verband) = ''"); + $this->db->or_where("verband IS NULL"); + $this->db->group_end(); + } + + if (!isEmptyString($gruppen_array->gruppe)) + { + $this->db->where('gruppe', $gruppen_array->gruppe); + } + else + { + $this->db->group_start(); + $this->db->where("trim(gruppe) = ''"); + $this->db->or_where("gruppe IS NULL"); + $this->db->group_end(); + } + } + else + return error('Wrong type of verband'); + + $this->db->where('lehreinheit_id', $lehreinheit_id); + $this->db->where('studiengang_kz', $gruppen_array->studiengang_kz); + + if (!isEmptyString($gruppen_array->semester)) + { + $this->db->where('semester', $gruppen_array->semester); + } + else + { + $this->db->group_start(); + $this->db->where("semester = ''"); + $this->db->or_where("semester IS NULL"); + $this->db->group_end(); + } + + $exist_result = $this->load(); + + if (!hasData($exist_result)) + { + $new_group_result = $this->insert(array( + 'lehreinheit_id' => $lehreinheit_id, + 'studiengang_kz' => $gruppen_array->studiengang_kz, + 'gruppe_kurzbz' => isset($gruppen_array->gruppe_kurzbz) ? $gruppen_array->gruppe_kurzbz : null, + 'semester' => $gruppen_array->semester, + 'verband' => isset($gruppen_array->verband) && !isEmptyString($gruppen_array->verband) ? $gruppen_array->verband : null, + 'gruppe' => isset($gruppen_array->gruppe) && !isEmptyString($gruppen_array->gruppe) ? $gruppen_array->gruppe : null, + 'insertamum' => date('Y-m-d H:i:s'), + 'insertvon' => getAuthUID() + )); + + if (isError($new_group_result)) + return error('Error when adding Group'); + + return success('Group assigned successfully to Lehreinheit'); + } + else + return error('Group already assigned'); + } + + public function deleteGroup($lehreinheit_id, $lehreinheitgruppe_id) + { + $lehreinheit = $this->LehreinheitModel->load($lehreinheit_id); + + if (!hasData($lehreinheit)) + return error ('No Lehreinheit found!'); + + $lehreinheitgruppe = $this->load($lehreinheitgruppe_id); + + if (!hasData($lehreinheitgruppe)) + return error ('No Lehreinheitgruppe found!'); + + $this->addSelect('stundenplandev_id'); + $this->addJoin('lehre.tbl_stundenplandev', + "tbl_stundenplandev.lehreinheit_id = tbl_lehreinheitgruppe.lehreinheit_id + AND tbl_stundenplandev.studiengang_kz = tbl_lehreinheitgruppe.studiengang_kz + AND tbl_stundenplandev.semester = tbl_lehreinheitgruppe.semester + AND trim(COALESCE(tbl_stundenplandev.verband, '')) = trim(COALESCE(tbl_lehreinheitgruppe.verband, '')) + AND trim(COALESCE(tbl_stundenplandev.gruppe, '')) = trim(COALESCE(tbl_lehreinheitgruppe.gruppe, '')) + AND trim(COALESCE(tbl_stundenplandev.gruppe_kurzbz, '')) = trim(COALESCE(tbl_lehreinheitgruppe.gruppe_kurzbz, ''))" + ); + $stundenplan_result = $this->loadWhere(array('tbl_lehreinheitgruppe.lehreinheitgruppe_id' => $lehreinheitgruppe_id)); + + if (hasData($stundenplan_result)) + return error('Gruppe already verplant'); + + $delete_result = $this->delete($lehreinheitgruppe_id); + + if (isError($delete_result)) + return error('Error deleting Group'); + + return success('Group deleted'); + } + + public function getByLehreinheit($lehreinheit_id) + { + $lehreinheit = $this->LehreinheitModel->load($lehreinheit_id); + + if (!hasData($lehreinheit)) + return error ('No Lehreinheit found!'); + + $this->addSelect('tbl_lehreinheitgruppe.*'); + $this->addSelect('tbl_gruppe.direktinskription'); + $this->addSelect('tbl_gruppe.gruppe_kurzbz'); + $this->addSelect("CASE + WHEN tbl_lehreinheitgruppe.gruppe_kurzbz IS NULL THEN + COALESCE ( + UPPER(tbl_studiengang.typ || tbl_studiengang.kurzbz) || + COALESCE(tbl_lehreinheitgruppe.semester::varchar, '') || + COALESCE(tbl_lehreinheitgruppe.verband::varchar, '') || + COALESCE(tbl_lehreinheitgruppe.gruppe, ''), + '') + ELSE tbl_lehreinheitgruppe.gruppe_kurzbz + END AS bezeichnung"); + $this->addSelect("CASE + WHEN tbl_lehreinheitgruppe.gruppe_kurzbz IS NULL THEN + ( + SELECT bezeichnung + FROM public.tbl_lehrverband + WHERE studiengang_kz = tbl_lehreinheitgruppe.studiengang_kz + AND semester = tbl_lehreinheitgruppe.semester + AND verband = tbl_lehreinheitgruppe.verband + AND gruppe = tbl_lehreinheitgruppe.gruppe + LIMIT 1 + ) + ELSE tbl_gruppe.beschreibung + END AS beschreibung"); + $this->addSelect("CASE + WHEN tbl_lehreinheitgruppe.gruppe_kurzbz IS NULL THEN + ( + SELECT EXISTS ( + SELECT 1 + FROM lehre.tbl_stundenplandev + WHERE lehreinheit_id = tbl_lehreinheitgruppe.lehreinheit_id + AND studiengang_kz = tbl_lehreinheitgruppe.studiengang_kz + AND semester = tbl_lehreinheitgruppe.semester + AND TRIM(COALESCE(verband, '')) = TRIM(tbl_lehreinheitgruppe.verband) + AND TRIM(COALESCE(gruppe, '')) = TRIM(tbl_lehreinheitgruppe.gruppe) + AND (gruppe_kurzbz IS NULL OR gruppe_kurzbz = '') + ) + ) + ELSE + ( + SELECT EXISTS ( + SELECT 1 + FROM lehre.tbl_stundenplandev + WHERE lehreinheit_id = tbl_lehreinheitgruppe.lehreinheit_id + AND gruppe_kurzbz = tbl_lehreinheitgruppe.gruppe_kurzbz + ) + ) + END AS verplant"); + $this->addJoin('tbl_studiengang', 'studiengang_kz', 'LEFT'); + $this->addJoin('public.tbl_gruppe', 'gruppe_kurzbz', 'LEFT'); + + $this->db->where('lehreinheit_id', $lehreinheit_id); + $this->db->group_start() + ->where('tbl_gruppe.direktinskription !=', true) + ->or_where('tbl_gruppe.direktinskription IS NULL') + ->group_end(); + return $this->load(); + } } diff --git a/application/models/education/Lehreinheitmitarbeiter_model.php b/application/models/education/Lehreinheitmitarbeiter_model.php index ae1ac55d2..efdb2e74d 100644 --- a/application/models/education/Lehreinheitmitarbeiter_model.php +++ b/application/models/education/Lehreinheitmitarbeiter_model.php @@ -10,6 +10,14 @@ class Lehreinheitmitarbeiter_model extends DB_Model parent::__construct(); $this->dbTable = 'lehre.tbl_lehreinheitmitarbeiter'; $this->pk = array('mitarbeiter_uid', 'lehreinheit_id'); + $this->hasSequence = false; + + $this->load->model('accounting/Vertrag_model', 'VertragModel'); + $this->load->model('ressource/stundenplandev_model', 'StundenplandevModel'); + $this->load->model('ressource/stundenplan_model', 'StundenplanModel'); + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); + $this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel'); } /** @@ -75,4 +83,67 @@ class Lehreinheitmitarbeiter_model extends DB_Model ]); } + public function getLektorenByLe($lehreinheit_id) + { + $this->addSelect('vorname, nachname, tbl_lehreinheitmitarbeiter.*, stundenplan.verplant'); + $this->addJoin('tbl_benutzer', 'uid = mitarbeiter_uid'); + $this->addJoin('tbl_person', 'person_id'); + + $this->addJoin('( + SELECT 1 as verplant, lehreinheit_id, mitarbeiter_uid + FROM lehre.tbl_stundenplandev + GROUP BY lehreinheit_id, mitarbeiter_uid + + ) stundenplan', 'stundenplan.mitarbeiter_uid = tbl_lehreinheitmitarbeiter.mitarbeiter_uid AND stundenplan.lehreinheit_id = tbl_lehreinheitmitarbeiter.lehreinheit_id', 'LEFT'); + + return $this->loadWhere(array('tbl_lehreinheitmitarbeiter.lehreinheit_id' => $lehreinheit_id)); + } + + public function getByLeLektor($lehreinheit_id, $mitarbeiter_uid) + { + $this->addSelect('vorname, nachname, tbl_lehreinheitmitarbeiter.*'); + $this->addJoin('tbl_benutzer', 'uid = mitarbeiter_uid'); + $this->addJoin('tbl_person', 'person_id'); + return $this->loadWhere(array('tbl_lehreinheitmitarbeiter.lehreinheit_id' => $lehreinheit_id, 'tbl_lehreinheitmitarbeiter.mitarbeiter_uid' => $mitarbeiter_uid)); + } + + public function deleteLektorFromLe($lehreinheit_id, $mitarbeiter_uid) + { + if (defined('FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN') && FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN) + { + $vertrag_result = $this->VertragModel->getVertrag($mitarbeiter_uid, $lehreinheit_id); + + if (hasData($vertrag_result)) + return error("Loeschen nur nach Stornierung des Vertrags möglich"); + } + + $stundenplandev_result = $this->StundenplandevModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid)); + $stundenplan_result = $this->StundenplanModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid)); + + if (hasData($stundenplandev_result) || hasData($stundenplan_result)) + return error("Diese/r LektorIn kann nicht gelöscht werden da er schon verplant ist"); + + $result = $this->loadWhere(array('lehreinheit_id' => $lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid)); + + if (hasData($result)) + { + $le_mitarbeiter_array = getData($result)[0]; + + if ($le_mitarbeiter_array->vertrag_id !== null) + { + $vertrag_result = $this->VertragModel->deleteVertrag($le_mitarbeiter_array->vertrag_id); + if (isError($vertrag_result)) + return $vertrag_result; + } + + $delete_result = $this->delete(array('lehreinheit_id' => $lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid)); + + if (isError($delete_result)) + return $delete_result; + + return success($delete_result); + } + } + + } diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index 3eb4d33a2..1b3b9e9d7 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -1019,4 +1019,240 @@ class Lehrveranstaltung_model extends DB_Model return $this->execQuery($qry, $params); } + + public function getLvsByOrganization($oe_kurzbz) + { + $qry=" + SELECT + distinct on (lehrveranstaltung_id) + tbl_lehrveranstaltung.studiengang_kz as lv_studiengang_kz, tbl_lehrveranstaltung.semester as lv_semester, + tbl_lehrveranstaltung.kurzbz as lv_kurzbz, tbl_lehrveranstaltung.bezeichnung as lv_bezeichnung, tbl_lehrveranstaltung.ects as lv_ects, + tbl_lehrveranstaltung.lehreverzeichnis as lv_lehreverzeichnis, tbl_lehrveranstaltung.planfaktor as lv_planfaktor, + tbl_lehrveranstaltung.planlektoren as lv_planlektoren, tbl_lehrveranstaltung.planpersonalkosten as lv_planpersonalkosten, + tbl_lehrveranstaltung.plankostenprolektor as lv_plankostenprolektor, tbl_lehrveranstaltung.orgform_kurzbz as lv_orgform_kurzbz, + tbl_lehrveranstaltung.lehrveranstaltung_id, + tbl_lehrveranstaltung.lehrform_kurzbz as lehrform_kurzbz, + tbl_lehrveranstaltung.lehrform_kurzbz as lv_lehrform_kurzbz, + tbl_lehrveranstaltung.bezeichnung_english as lv_bezeichnung_english, + tbl_lehrveranstaltung.studiengang_kz, tbl_lehrveranstaltung.semester, tbl_lehrveranstaltung.anmerkung, tbl_lehrveranstaltung.sprache, tbl_lehrveranstaltung.semesterstunden, + tbl_lehrveranstaltung.lehre, tbl_lehrveranstaltung.aktiv, + '' as studienplan_id, '' as studienplan_bezeichnung, tbl_lehrveranstaltung.lehrtyp_kurzbz + FROM + lehre.tbl_lehrveranstaltung + WHERE + tbl_lehrveranstaltung.oe_kurzbz= ? + AND tbl_lehrveranstaltung.aktiv + "; + + return $this->execReadOnlyQuery($qry, array($oe_kurzbz)); + } + + public function getLvsByFachbereich($fachbereich, $studiensemester_kurbz, $mitarbeiter_uid = null) + { + $qry = ""; + if (!is_null($mitarbeiter_uid)) + { + $qry = $this->getLvsFromStudienplanByEmp(); + $params = array($fachbereich, $studiensemester_kurbz); + } + + $qry .= "SELECT + distinct on(lehrveranstaltung_id) + lv_studiengang_kz, lv_semester, lv_kurzbz, lv_bezeichnung, lv_ects, + lv_lehreverzeichnis, lv_planfaktor, lv_planlektoren, lv_planpersonalkosten, + lv_plankostenprolektor, lv_orgform_kurzbz, lehrveranstaltung_id, + lehrform_kurzbz, lv_lehrform_kurzbz, lv_bezeichnung_english, studiengang_kz, semester, anmerkung, sprache, semesterstunden, + lehre, aktiv, + '' as studienplan_id, '' as studienplan_bezeichnung, + (SELECT lehrtyp_kurzbz FROM lehre.tbl_lehrveranstaltung WHERE lehrveranstaltung_id=vw_lehreinheit.lehrveranstaltung_id) as lehrtyp_kurzbz + FROM + campus.vw_lehreinheit + WHERE studiensemester_kurzbz = ? + AND fachbereich_kurzbz = ?"; + + $params[] = array($studiensemester_kurbz, $fachbereich); + + if (!is_null($mitarbeiter_uid)) + { + $qry .= " AND mitarbeiter_uid = ?"; + $params[] = $mitarbeiter_uid; + } + else + { + $qry.=" AND lehrveranstaltung_id NOT IN (SELECT lehrveranstaltung_id + FROM + lehre.tbl_lehrveranstaltung + JOIN lehre.tbl_studienplan_lehrveranstaltung USING(lehrveranstaltung_id) + JOIN lehre.tbl_studienplan USING(studienplan_id) + JOIN lehre.tbl_studienordnung USING(studienordnung_id) + JOIN lehre.tbl_studienplan_semester USING(studienplan_id) + WHERE + tbl_lehrveranstaltung.oe_kurzbz=(Select oe_kurzbz from public.tbl_fachbereich where fachbereich_kurzbz= ?) + AND tbl_studienplan_semester.studiensemester_kurzbz= ?"; + + $params[] = array($fachbereich, $studiensemester_kurbz); + } + + return $this->execReadOnlyQuery($qry, $params); + } + + private function getLvsFromStudienplanByEmp() + { + return " + SELECT + distinct on (lehrveranstaltung_id) + tbl_lehrveranstaltung.studiengang_kz as lv_studiengang_kz, + tbl_lehrveranstaltung.semester as lv_semester, + tbl_lehrveranstaltung.kurzbz as lv_kurzbz, + tbl_lehrveranstaltung.bezeichnung as lv_bezeichnung, + tbl_lehrveranstaltung.ects as lv_ects, + tbl_lehrveranstaltung.lehreverzeichnis as lv_lehreverzeichnis, + tbl_lehrveranstaltung.planfaktor as lv_planfaktor, + tbl_lehrveranstaltung.planlektoren as lv_planlektoren, + tbl_lehrveranstaltung.planpersonalkosten as lv_planpersonalkosten, + tbl_lehrveranstaltung.plankostenprolektor as lv_plankostenprolektor, + tbl_lehrveranstaltung.orgform_kurzbz as lv_orgform_kurzbz, + tbl_lehrveranstaltung.lehrveranstaltung_id, + tbl_lehrveranstaltung.lehrform_kurzbz as lehrform_kurzbz, + tbl_lehrveranstaltung.lehrform_kurzbz as lv_lehrform_kurzbz, + tbl_lehrveranstaltung.bezeichnung_english as lv_bezeichnung_english, + tbl_lehrveranstaltung.studiengang_kz, + tbl_studienplan_lehrveranstaltung.semester, + tbl_lehrveranstaltung.anmerkung, + tbl_lehrveranstaltung.sprache, + tbl_lehrveranstaltung.semesterstunden, + tbl_lehrveranstaltung.lehre, + tbl_lehrveranstaltung.aktiv, + tbl_studienplan.studienplan_id::text, + tbl_studienplan.bezeichnung as studienplan_bezeichnung, + tbl_lehrveranstaltung.lehrtyp_kurzbz + FROM + lehre.tbl_lehrveranstaltung + JOIN lehre.tbl_studienplan_lehrveranstaltung USING(lehrveranstaltung_id) + JOIN lehre.tbl_studienplan USING(studienplan_id) + JOIN lehre.tbl_studienordnung USING(studienordnung_id) + JOIN lehre.tbl_studienplan_semester USING(studienplan_id) + WHERE + tbl_lehrveranstaltung.oe_kurzbz=(Select oe_kurzbz from public.tbl_fachbereich where fachbereich_kurzbz= ?) + AND tbl_studienplan_semester.studiensemester_kurzbz = ? + AND tbl_lehrveranstaltung.aktiv + UNION + "; + } + + public function getLvsByStudiengang($studienplan_ids, $placeholders, $only_ids, $studiengang_kz, $studiensemester_kurzbz, $semester = null, $verband = null) + { + $qry = ""; + $params = array(); + + if (!empty($studienplan_ids)) + { + $qry = $this->getLvsFromStudienplanByStudienplanID($placeholders); + $params = $studienplan_ids; + } + + $qry .= " + SELECT DISTINCT on(lehrveranstaltung_id) lehrveranstaltung_id, + tbl_lehrveranstaltung.kurzbz as lv_kurzbz, + tbl_lehrveranstaltung.bezeichnung as lv_bezeichnung, + tbl_lehrveranstaltung.bezeichnung_english as lv_bezeichnung_english, + studiengang_kz, + semester, + tbl_lehrveranstaltung.sprache, + ects as lv_ects, + semesterstunden, + tbl_lehrveranstaltung.anmerkung, + tbl_lehrveranstaltung.lehre, + lehreverzeichnis as lv_lehreverzeichnis, + tbl_lehrveranstaltung.aktiv, + planfaktor as lv_planfaktor, + planlektoren as lv_planlektoren, + planpersonalkosten as lv_planpersonalkosten, + plankostenprolektor as lv_plankostenprolektor, + tbl_lehrveranstaltung.lehrform_kurzbz as lv_lehrform_kurzbz, + tbl_lehrveranstaltung.orgform_kurzbz, + ''::text as studienplan_id, + '' as studienplan_bezeichnung, + '' as studienplan_lehrveranstaltung_id_parent, + tbl_lehrveranstaltung.lehrtyp_kurzbz, + UPPER(CONCAT(tbl_studiengang.typ,tbl_studiengang.kurzbz)) as studiengang + FROM lehre.tbl_lehrveranstaltung + JOIN lehre.tbl_lehreinheit USING (lehrveranstaltung_id) + JOIN public.tbl_studiengang USING(studiengang_kz) + WHERE studiengang_kz = ? + AND studiensemester_kurzbz = ? + "; + + $params[] = $studiengang_kz; + $params[] = $studiensemester_kurzbz; + if (!is_null($semester)) + { + $qry .= ' AND semester = ?'; + $params[] = $semester; + } + if (!is_null($verband)) + { + $qry .= ' AND (tbl_lehrveranstaltung.orgform_kurzbz = ? OR tbl_lehrveranstaltung.orgform_kurzbz IS NULL)'; + $params[] = $verband; + } + + if (!empty($only_ids)) + { + + $qry .= ' AND NOT EXISTS (SELECT 1 FROM lehre.tbl_studienplan_lehrveranstaltung where studienplan_id IN ? + AND lehrveranstaltung_id = tbl_lehrveranstaltung.lehrveranstaltung_id AND tbl_lehrveranstaltung.aktiv)'; + + $params[] = $only_ids; + } + + return $this->execReadOnlyQuery($qry, $params); + } + private function getLvsFromStudienplanByStudienplanID($placeholders) + { + return " + SELECT + lehrveranstaltung_id, tbl_lehrveranstaltung.kurzbz as lv_kurzbz, tbl_lehrveranstaltung.bezeichnung as lv_bezeichnung, bezeichnung_english as lv_bezeichnung_english, studiengang_kz, + tbl_studienplan_lehrveranstaltung.semester, tbl_lehrveranstaltung.sprache, + ects as lv_ects, semesterstunden, anmerkung, lehre, lehreverzeichnis as lv_lehreverzeichnis, tbl_lehrveranstaltung.aktiv, + planfaktor as lv_planfaktor, planlektoren as lv_planlektoren, planpersonalkosten as lv_planpersonalkosten, + plankostenprolektor as lv_plankostenprolektor, lehrform_kurzbz as lv_lehrform_kurzbz, tbl_lehrveranstaltung.orgform_kurzbz, + tbl_studienplan_lehrveranstaltung.studienplan_id::text as studienplan_id, tbl_studienplan.bezeichnung as studienplan_bezeichnung, tbl_studienplan_lehrveranstaltung.studienplan_lehrveranstaltung_id_parent::text, + tbl_lehrveranstaltung.lehrtyp_kurzbz, UPPER(CONCAT(tbl_studiengang.typ,tbl_studiengang.kurzbz)) as studiengang + FROM + lehre.tbl_lehrveranstaltung + JOIN lehre.tbl_studienplan_lehrveranstaltung USING(lehrveranstaltung_id) + JOIN lehre.tbl_studienplan USING(studienplan_id) + JOIN tbl_studiengang USING(studiengang_kz) + WHERE + tbl_lehrveranstaltung.aktiv AND ((studienplan_id, tbl_studienplan_lehrveranstaltung.semester) IN ( " . implode(',', $placeholders) . ")) + UNION + "; + } + + public function getAllOe($lv_id) + { + $qry = "SELECT DISTINCT oe_kurzbz + FROM lehre.tbl_studienplan_lehrveranstaltung + JOIN lehre.tbl_studienplan USING(studienplan_id) + JOIN lehre.tbl_studienordnung USING(studienordnung_id) + JOIN public.tbl_studiengang USING(studiengang_kz) + WHERE lehrveranstaltung_id = ? + + UNION + + ( + SELECT oe_kurzbz + FROM public.tbl_studiengang + WHERE studiengang_kz = ( + SELECT tbl_lehrveranstaltung.studiengang_kz + FROM lehre.tbl_lehrveranstaltung + WHERE lehrveranstaltung_id = ? + ) + ) + "; + + $params = array($lv_id, $lv_id); + + return $this->execReadOnlyQuery($qry, $params); + } } diff --git a/application/models/organisation/Organisationseinheit_model.php b/application/models/organisation/Organisationseinheit_model.php index ba91964f6..db56c1930 100644 --- a/application/models/organisation/Organisationseinheit_model.php +++ b/application/models/organisation/Organisationseinheit_model.php @@ -213,4 +213,34 @@ class Organisationseinheit_model extends DB_Model return $result; } + + /** + * Ermittelt die Stundenobergrenze fuer Lektoren + * Dabei wird im OE Baum nach oben nach Stundengrenzen gesucht und die niedrigste Stundengrenze ermittelt + * @param $oe_kurzbz Organisationseinheit + * @param $fixangestellt boolean legt fest ob die Grenze + * fuer Freie oder Fixangestellte Lektoren ermittelt werden soll + + */ + public function getStundengrenze($oe_kurzbz, $fixangestellt = true) + { + $fixfrei = $fixangestellt ? 'fix' : 'frei'; + + $qry = " + WITH RECURSIVE oes(oe_kurzbz, oe_parent_kurzbz) as + ( + SELECT oe_kurzbz, oe_parent_kurzbz FROM public.tbl_organisationseinheit + WHERE oe_kurzbz= ? + UNION ALL + SELECT o.oe_kurzbz, o.oe_parent_kurzbz FROM public.tbl_organisationseinheit o, oes + WHERE o.oe_kurzbz=oes.oe_parent_kurzbz + ) + SELECT oe_kurzbz, warn_semesterstunden_{$fixfrei} AS stunden + FROM oes + JOIN public.tbl_organisationseinheit USING (oe_kurzbz) + ORDER BY warn_semesterstunden_{$fixfrei} ASC + LIMIT 1"; + + return $this->execReadOnlyQuery($qry, array($oe_kurzbz)); + } } diff --git a/application/models/organisation/Studienplan_model.php b/application/models/organisation/Studienplan_model.php index 569aebd0b..481a0564c 100644 --- a/application/models/organisation/Studienplan_model.php +++ b/application/models/organisation/Studienplan_model.php @@ -107,6 +107,8 @@ class Studienplan_model extends DB_Model )); } + // Deprecated + // im Lehrveranstaltung_model vorhanden public function getAllOesForLv($lehrveranstaltung_id) { $this->addDistinct('oe_kurzbz'); @@ -135,6 +137,27 @@ class Studienplan_model extends DB_Model ]); } + public function loadStudienplanLehrveranstaltung($lv_id) + { + $qry = "SELECT studienplan_lehrveranstaltung_id, + semester, + pflicht, + studienplan_id, + koordinator, + studienplan_lehrveranstaltung_id_parent, + lehrveranstaltung_id, + insertamum, + insertvon, + updateamum, + updatevon, + sort, + curriculum, + export + FROM lehre.tbl_studienplan_lehrveranstaltung WHERE studienplan_lehrveranstaltung_id = ? "; + return $this->execReadOnlyQuery($qry, array($lv_id)); + } + + public function getStudienplaeneForPerson($person_id) { $this->addDistinct(); diff --git a/application/models/person/Notiz_model.php b/application/models/person/Notiz_model.php index 1835296fe..bc4494f57 100644 --- a/application/models/person/Notiz_model.php +++ b/application/models/person/Notiz_model.php @@ -151,7 +151,7 @@ class Notiz_model extends DB_Model * bestellung_id, lehreinheit_id, anrechnung_id, uid) * @param $id the corresponding id, part of public.tbl_notizzuordnung */ - public function getNotizWithDocEntries($id, $type) + public function getNotizWithDocEntries($id, $type, $withoutTags = true) { $qry = " SELECT @@ -195,8 +195,12 @@ class Notiz_model extends DB_Model LEFT JOIN public.tbl_person person_bearbeiter ON (person_bearbeiter.person_id = p_bearbeiter.person_id) WHERE - z.$type = ? - GROUP BY + z.$type = ?"; + + if ($withoutTags) + $qry .= " AND n.typ IS NULL "; + + $qry .= "GROUP BY notiz_id, z.notizzuordnung_id, person_verfasser.vorname, person_verfasser.nachname, person_bearbeiter.vorname, person_bearbeiter.nachname diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 997048972..3947378cf 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -307,72 +307,60 @@ class Person_model extends DB_Model public function checkDuplicate($person_id) { - $qry = "SELECT person_id - FROM public.tbl_prestudent p - JOIN - ( - SELECT DISTINCT ON(prestudent_id) * - FROM public.tbl_prestudentstatus - WHERE prestudent_id IN - ( - SELECT prestudent_id - FROM public.tbl_prestudent - WHERE person_id IN - ( - SELECT p2.person_id - FROM public.tbl_person p - JOIN public.tbl_person p2 - ON lower(p.vorname) = lower(p2.vorname) - AND lower(p.nachname) = lower(p2.nachname) - AND p.gebdatum = p2.gebdatum - AND p.person_id = ? - ) - ) - ORDER BY prestudent_id, datum DESC, insertamum DESC - ) ps USING(prestudent_id) - JOIN public.tbl_status USING(status_kurzbz) + $qry = " + WITH person AS ( + SELECT * + FROM public.tbl_person + WHERE person_id = ? + ), + allePersonen AS ( + SELECT p.person_id + FROM public.tbl_person p + JOIN person + ON lower(p.vorname) = lower(person.vorname) + AND lower(p.nachname) = lower(person.nachname) + AND p.gebdatum = person.gebdatum + ), + lastStatus AS ( + SELECT DISTINCT ON (tbl_prestudentstatus.prestudent_id) + tbl_prestudentstatus.prestudent_id, + tbl_prestudentstatus.status_kurzbz, + tbl_prestudent.studiengang_kz, + tbl_prestudent.person_id + FROM public.tbl_prestudentstatus + JOIN public.tbl_prestudent USING (prestudent_id) + WHERE tbl_prestudent.person_id IN (SELECT person_id FROM allePersonen) + ORDER BY tbl_prestudentstatus.prestudent_id, tbl_prestudentstatus.datum DESC, tbl_prestudentstatus.insertamum DESC + ), + interessenten AS ( + SELECT * + FROM lastStatus WHERE status_kurzbz = 'Interessent' - AND studiengang_kz IN - ( - SELECT studiengang_kz - FROM public.tbl_prestudent p - JOIN - ( - SELECT DISTINCT ON(prestudent_id) * - FROM public.tbl_prestudentstatus - WHERE prestudent_id IN - ( - SELECT prestudent_id - FROM public.tbl_prestudent - WHERE person_id IN - ( - SELECT p2.person_id - FROM public.tbl_person p - JOIN public.tbl_person p2 - ON lower(p.vorname) = lower(p2.vorname) - AND lower(p.nachname) = lower(p2.nachname) - AND p.gebdatum = p2.gebdatum - AND p.person_id = ? - ) - ) - ORDER BY prestudent_id, datum DESC, insertamum DESC - ) ps USING(prestudent_id) - JOIN public.tbl_status USING(status_kurzbz) - WHERE status_kurzbz = 'Abbrecher' - ) - - UNION - + ), + keineInteressenten AS ( + SELECT * + FROM lastStatus + WHERE status_kurzbz != 'Interessent' + ), + doppeltePerson AS ( SELECT p2.person_id - FROM tbl_person p1 - JOIN tbl_prestudent ps ON p1.person_id = ps.person_id - INNER JOIN ( - SELECT vorname, nachname, gebdatum, person.person_id - FROM tbl_person person - JOIN tbl_prestudent sps ON person.person_id = sps.person_id - ) p2 - ON (lower(p1.vorname) = lower(p2.vorname) AND lower(p1.nachname) = lower(p2.nachname) AND p1.gebdatum = p2.gebdatum) - WHERE p1.person_id != p2.person_id AND (p1.person_id = ?)"; + FROM public.tbl_person p1 + JOIN public.tbl_prestudent ps1 ON ps1.person_id = p1.person_id + JOIN public.tbl_person p2 + ON lower(p1.vorname) = lower(p2.vorname) + AND lower(p1.nachname) = lower(p2.nachname) + AND p1.gebdatum = p2.gebdatum + WHERE p1.person_id = ? + AND p1.person_id <> p2.person_id + ) + SELECT DISTINCT(interessenten.person_id) + FROM interessenten + JOIN keineInteressenten + ON interessenten.studiengang_kz = keineInteressenten.studiengang_kz + WHERE interessenten.person_id = ? + UNION + SELECT DISTINCT person_id + FROM doppeltePerson"; return $this->execQuery($qry, array($person_id, $person_id, $person_id)); } diff --git a/application/models/ressource/Mitarbeiter_model.php b/application/models/ressource/Mitarbeiter_model.php index bf4672070..f6cdc74b8 100644 --- a/application/models/ressource/Mitarbeiter_model.php +++ b/application/models/ressource/Mitarbeiter_model.php @@ -430,4 +430,18 @@ class Mitarbeiter_model extends DB_Model return $this->execQuery($qry, $parametersArray); } + + public function isLehrauftragFirma($mitarbeiter_uid) + { + $this->addSelect('firma_id'); + $this->addJoin('public.tbl_benutzer', 'uid = mitarbeiter_uid'); + $this->addJoin('public.tbl_person', 'person_id'); + $this->addJoin('public.tbl_adresse', 'person_id', 'LEFT'); + $this->addOrder('zustelladresse', 'DESC'); + $this->addOrder('firma_id'); + $this->addLimit(1); + $firma_result = $this->loadWhere(array('mitarbeiter_uid' => $mitarbeiter_uid)); + $firma = getData($firma_result)[0]->firma_id; + return !is_null($firma); + } } diff --git a/application/models/ressource/Stundenplandev_model.php b/application/models/ressource/Stundenplandev_model.php index 800540d60..e718ba073 100644 --- a/application/models/ressource/Stundenplandev_model.php +++ b/application/models/ressource/Stundenplandev_model.php @@ -10,6 +10,9 @@ class Stundenplandev_model extends DB_Model parent::__construct(); $this->dbTable = 'lehre.tbl_stundenplandev'; $this->pk = 'stundenplandev_id'; + + $this->load->model('education/lehreinheit_model', 'LehreinheitModel'); + $this->load->model('education/Lehreinheitgruppe_model', 'LehreinheitgruppeModel'); } @@ -157,4 +160,85 @@ class Stundenplandev_model extends DB_Model return $this->execQuery($qry, $params); } + public function deleteGroupPlanning($lehreinheit_id, $lehreinheitgruppe_id) + { + $lehreinheit = $this->LehreinheitModel->load($lehreinheit_id); + + if (!hasData($lehreinheit)) + return error ('No Lehreinheit found!'); + + $lehreinheitgruppe = $this->LehreinheitgruppeModel->load($lehreinheitgruppe_id); + + if (!hasData($lehreinheitgruppe)) + return error ('No Lehreinheitgruppe found!'); + + $this->addJoin('lehre.tbl_stundenplan_betriebsmittel', 'stundenplandev_id'); + $this->addJoin('lehre.tbl_lehreinheitgruppe', 'lehreinheit_id'); + $this->db->where('tbl_lehreinheitgruppe.lehreinheitgruppe_id', $lehreinheitgruppe_id); + + $this->db->group_start(); + $this->db->group_start(); + $this->db->where('tbl_lehreinheitgruppe.gruppe_kurzbz IS NOT NULL', null, false); + $this->db->where('tbl_lehreinheitgruppe.gruppe_kurzbz = tbl_stundenplandev.gruppe_kurzbz', null, false); + $this->db->group_end(); + $this->db->or_group_start(); + $this->db->where('tbl_lehreinheitgruppe.gruppe_kurzbz IS NULL', null, false); + $this->db->where('tbl_lehreinheitgruppe.studiengang_kz = tbl_stundenplandev.studiengang_kz', null, false); + $this->db->where('tbl_lehreinheitgruppe.semester = tbl_stundenplandev.semester', null, false); + $this->db->where('tbl_lehreinheitgruppe.verband = tbl_stundenplandev.verband', null, false); + $this->db->where('tbl_lehreinheitgruppe.gruppe = tbl_stundenplandev.gruppe', null, false); + $this->db->group_end(); + $this->db->group_end(); + + $betriebsmittel_result = $this->load(); + $betriebsmittel_array = hasData($betriebsmittel_result) ? getData($betriebsmittel_result) : array(); + if (sizeof($betriebsmittel_array) > 0) + { + return error ('Gruppe kann nicht entfernt werden da bereits Ressourcen zugeordnet wurden'); + } + + $this->addSelect('stundenplandev_id'); + $this->addJoin('lehre.tbl_lehreinheitgruppe', + "tbl_stundenplandev.lehreinheit_id = tbl_lehreinheitgruppe.lehreinheit_id + AND tbl_stundenplandev.studiengang_kz = tbl_lehreinheitgruppe.studiengang_kz + AND tbl_stundenplandev.semester = tbl_lehreinheitgruppe.semester + AND trim(COALESCE(tbl_stundenplandev.verband, '')) = trim(COALESCE(tbl_lehreinheitgruppe.verband, '')) + AND trim(COALESCE(tbl_stundenplandev.gruppe, '')) = trim(COALESCE(tbl_lehreinheitgruppe.gruppe, '')) + AND trim(COALESCE(tbl_stundenplandev.gruppe_kurzbz, '')) = trim(COALESCE(tbl_lehreinheitgruppe.gruppe_kurzbz, ''))" + ); + $stundenplan_result = $this->loadWhere(array('tbl_lehreinheitgruppe.lehreinheitgruppe_id' => $lehreinheitgruppe_id)); + + if (hasData($stundenplan_result)) + { + $stundenplan_ids = array_column(getData($stundenplan_result), 'stundenplandev_id'); + $this->db->where_in('stundenplandev_id', $stundenplan_ids); + $delete_result = $this->db->delete('lehre.tbl_stundenplandev'); + + if ($delete_result) + return success('Group deleted successfully from Stundenplandev'); + else + return error('Error deleting Group from Stundenplandev'); + } + } + + public function deleteLektorPlanning($lehreinheit_id, $mitarbeiter_uid) + { + //TODO (david) prüfen ob der check notwendig ist + /*$this->addDistinct('mitarbeiter_uid'); + $this->addSelect('mitarbeiter_uid'); + $stundenplan_result = $this->loadWhere(array('lehreinheit_id' => $lehreinheit_id)); + $stundenplan_array = hasData($stundenplan_result) ? (getData($stundenplan_result)) : array(); + + if (sizeof($stundenplan_array) <= 1) + return error('Diese/r LektorIn kann nicht aus dem LVPlan entfernt werden da dies der/die letzte verplante LektorIn ist');*/ + + $this->addJoin('lehre.tbl_stundenplan_betriebsmittel', 'stundenplandev_id'); + $betriebsmittel_result = $this->loadWhere(array('lehreinheit_id' => $lehreinheit_id, 'tbl_stundenplandev.mitarbeiter_uid' => $mitarbeiter_uid)); + $betriebsmittel_array = hasData($betriebsmittel_result) ? getData($betriebsmittel_result) : array(); + + if (sizeof($betriebsmittel_array) > 0) + return error('Gruppe kann nicht entfernt werden da bereits Ressourcen zugeordnet wurden'); + + return $this->delete(array('lehreinheit_id' => $lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid)); + } } diff --git a/application/models/ressource/Stundensatz_model.php b/application/models/ressource/Stundensatz_model.php index 10f5a6aa1..f34ad07ed 100644 --- a/application/models/ressource/Stundensatz_model.php +++ b/application/models/ressource/Stundensatz_model.php @@ -42,4 +42,20 @@ class Stundensatz_model extends DB_Model return $this->execQuery($qry, $params); } + + public function getDefaultStundensatz($mitarbeiter_uid, $beginn, $ende = null, $typ = null) + { + $stundensatz_result = $this->getStundensatzByDatum($mitarbeiter_uid, $beginn, $ende, $typ); + $default_stundensatz = hasData($stundensatz_result) ? getData($stundensatz_result)[0]->stundensatz : null; + if (defined('FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ') && !FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ) + { + $this->load->model('vertragsbestandteil/Dienstverhaeltnis_model','DienstverhaeltnisModel'); + $echterdv_result = $this->DienstverhaeltnisModel->existsDienstverhaeltnis($mitarbeiter_uid, $beginn, $ende, 'echterdv'); + if (hasData($echterdv_result)) + { + $default_stundensatz = null; + } + } + return $default_stundensatz; + } } \ No newline at end of file diff --git a/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php b/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php index f81a2d518..b055ee954 100644 --- a/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php +++ b/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php @@ -253,4 +253,25 @@ EOSQL; } return $dvs; } + + public function existsDienstverhaeltnis($mitarbeiter_uid, $start, $ende = null, $vertragsart_kurzbz = null) + { + $this->addOrder('von', 'DESC'); + $this->db->where('mitarbeiter_uid', $mitarbeiter_uid); + if (!is_null($vertragsart_kurzbz)) + $this->db->where('vertragsart_kurzbz', $this->escape($vertragsart_kurzbz)); + + $this->db->where('von <=', $ende); + + if (!is_null($ende)) + { + $this->db->group_start(); + $this->db->where('bis >=', $start); + $this->db->or_where('bis IS NULL', null, false); + $this->db->group_end(); + } + + $this->addLimit(1); + return $this->load(); + } } diff --git a/application/views/LVVerwaltung.php b/application/views/LVVerwaltung.php new file mode 100644 index 000000000..4cebae839 --- /dev/null +++ b/application/views/LVVerwaltung.php @@ -0,0 +1,39 @@ + 'LVVerwaltung', + 'axios027' => true, + 'bootstrap5' => true, + 'fontawesome6' => true, + 'vue3' => true, + 'primevue3' => true, + 'tabulator6' => true, + 'tinymce5' => true, + 'tags' => true, + + 'customCSSs' => [ + 'public/css/components/vue-datepicker.css', + 'public/css/components/primevue.css', + 'public/css/Studentenverwaltung.css', + 'public/css/Lvverwaltung.css' + + ], + 'customJSModules' => [ + 'public/js/apps/LVVerwaltung.js' + ] + ); + + $this->load->view('templates/FHC-Header', $includesArray); + +?> +
+ + + +
+load->view('templates/FHC-Footer', $includesArray); ?> + diff --git a/application/views/system/infocenter/anmerkungenZurBewerbung.php b/application/views/system/infocenter/anmerkungenZurBewerbung.php index ca012ff3e..3ffe5f9a2 100644 --- a/application/views/system/infocenter/anmerkungenZurBewerbung.php +++ b/application/views/system/infocenter/anmerkungenZurBewerbung.php @@ -18,6 +18,9 @@ kurzbzlang)) ?: print_r('(' . nl2br($notiz->kurzbzlang) . ') - ') ?> text) ?> + + + diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 51b913b6c..fb023c5fd 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -57,7 +57,7 @@
diff --git a/cis/private/tools/zeitaufzeichnung.php b/cis/private/tools/zeitaufzeichnung.php index 1ae315f7a..4dcb63b31 100644 --- a/cis/private/tools/zeitaufzeichnung.php +++ b/cis/private/tools/zeitaufzeichnung.php @@ -45,6 +45,7 @@ require_once('../../../include/benutzerberechtigung.class.php'); require_once('../../../include/zeitaufzeichnung_import_csv.class.php'); require_once('../../../include/zeitaufzeichnung_import_post.class.php'); require_once('../../../include/vertragsbestandteil.class.php'); +require_once('../../../include/benutzerfunktion.class.php'); $sprache = getSprache(); $p=new phrasen($sprache); @@ -112,6 +113,13 @@ else $activities = array('Admin', 'FuE','FuEallg','Lehre', 'Pause', 'Arztbesuch', 'DienstreiseMT', 'Behoerde', 'Ersatzruhe', 'Weiterbildung', 'LVEntwicklung'); } +// Wenn die Funktion Lehrling zugeteilt ist, kann zusaetzlich Berufsschule als Aktivitaet gewaehlt werden +$benutzerfunktion = new benutzerfunktion(); +if ($benutzerfunktion->benutzerfunktion_exists($user, 'lehrling', true)) +{ + $activities[] = 'Berufsschule'; +} + $activities_str = "'".implode("','", $activities)."'"; // definiert bis zu welchem Datum die Eintragung nicht mehr möglich ist @@ -690,7 +698,7 @@ echo ' function checkPausenblock() { var sel = $("#aktivitaet").val(); - var activities = ["Admin", "Lehre", "FuE", "Operativ", "Betrieb", "Design", "LVEntwicklung", "Weiterbildung", "FuEallg"]; + var activities = ["Admin", "Lehre", "FuE", "Operativ", "Betrieb", "Design", "LVEntwicklung", "Weiterbildung", "FuEallg", "Berufsschule"]; if (activities.includes(sel)) showPausenblock(); else diff --git a/public/css/Lvverwaltung.css b/public/css/Lvverwaltung.css new file mode 100644 index 000000000..6e0f4c760 --- /dev/null +++ b/public/css/Lvverwaltung.css @@ -0,0 +1,40 @@ +textarea[name="anmerkung"] { + position: absolute; + max-height: 300px; +} + +.lv_table_icon::before +{ + font-family: 'Font Awesome 6 Free'; + font-weight: 900; + margin-left: 5px; + display: inline-block; +} + +.lv_table_icon.icon-modul::before +{ + content: '\f468'; + color: #4e4ed2; +} + +.lv_table_icon.icon-lv::before +{ + content: '\f466'; + color: black; +} + +.lv_table_icon.icon-::before +{ + content: '\f073'; + color: #f3c541; +} + + +.modal-dialog.modal-xxl { + max-width: 95% !important; +} + +.tabulator-menu .tabulator-menu-item.tabulator-menu-item-submenu:after +{ + border-color: black; +} diff --git a/public/css/Tabulator6.css b/public/css/Tabulator6.css index 8be726544..7a66dd2f6 100644 --- a/public/css/Tabulator6.css +++ b/public/css/Tabulator6.css @@ -1 +1,153 @@ -@import '../../vendor/olifolkerd/tabulator6/dist/css/tabulator_simple.min.css'; \ No newline at end of file +@import '../../vendor/olifolkerd/tabulator6/dist/css/tabulator_simple.min.css'; +.tabulator-row { + border-bottom: none; +} +.tabulator-row .tabulator-frozen, +.tabulator-row .tabulator-cell { + border-bottom: 1px solid #dee2e6; +} +.tabulator-row.tabulator-row-even { + background-color: transparent; +} +.tabulator-headers .tabulator-frozen, +.tabulator-row.tabulator-row-odd .tabulator-frozen, +.tabulator-row.tabulator-row-odd .tabulator-cell { + background-color: #fff; +} +.tabulator-row.tabulator-row-even .tabulator-frozen, +.tabulator-row.tabulator-row-even .tabulator-cell { + background-color: #f2f2f2; +} +.tabulator-row.tabulator-selectable:hover .tabulator-frozen, +.tabulator-row.tabulator-selectable:hover .tabulator-cell { + background-color: #ececec; +} +.tabulator-row.tabulator-selected .tabulator-frozen, +.tabulator-row.tabulator-selected .tabulator-cell { + background-color: #9abcea; +} +.tabulator-row.tabulator-selected:hover .tabulator-frozen, +.tabulator-row.tabulator-selected:hover .tabulator-cell { + background-color: #769bcc; +} +.tabulator .tabulator-col-resize-handle:last-of-type { + z-index: 999999; +} + +/* classes for rows that are not selectable in the tabulator, except for rows that are used for calculation */ +.tabulator-row.tabulator-unselectable:not(.tabulator-calcs) { + color: #adb5bd !important; + pointer-events: none !important; +} + +.tabulator-row.tabulator-unselectable a { + pointer-events: auto !important; +} + +/* using bootstrap background classes to style the background color of tabulator rows */ +/* bg-warning */ +/* odd-rows */ +.tabulator-headers .tabulator-frozen.bg-warning, +.tabulator-row.tabulator-row-odd .tabulator-frozen.bg-warning, +.tabulator-row.tabulator-row-odd .tabulator-cell.bg-warning { + background-color: #fcf8e3; + +} +/* even-rows */ +.tabulator-headers .tabulator-frozen.bg-warning, +.tabulator-row.tabulator-row-even .tabulator-frozen.bg-warning, +.tabulator-row.tabulator-row-even .tabulator-cell.bg-warning { + background-color: #fcf8e3; + +} + +/* bg-success */ +/* odd-rows */ +.tabulator-headers .tabulator-frozen.bg-success, +.tabulator-row.tabulator-row-odd .tabulator-frozen.bg-success, +.tabulator-row.tabulator-row-odd .tabulator-cell.bg-success { + background-color: #dff0d8; + +} +/* even-rows */ +.tabulator-headers .tabulator-frozen.bg-success, +.tabulator-row.tabulator-row-even .tabulator-frozen.bg-success, +.tabulator-row.tabulator-row-even .tabulator-cell.bg-success { + background-color: #dff0d8; + +} + +/* bg-info */ +/* odd-rows */ +.tabulator-headers .tabulator-frozen.bg-info, +.tabulator-row.tabulator-row-odd .tabulator-frozen.bg-info, +.tabulator-row.tabulator-row-odd .tabulator-cell.bg-info { + background-color: #d9edf7; + +} +/* even-rows */ +.tabulator-headers .tabulator-frozen.bg-info, +.tabulator-row.tabulator-row-even .tabulator-frozen.bg-info, +.tabulator-row.tabulator-row-even .tabulator-cell.bg-info { + background-color: #d9edf7; + +} + +/* special bootstrap5 styling for tableWidget and their accordion-item ::after content */ +.accordion-button::after{ + content:none !important; +} + + +.tabulator { + font-size: 1rem; +} + +.tabulator-initialfontsize .tabulator { + font-size: 14px; +} + +.tabulator-row.tabulator-unselectable .tabulator-cell { + pointer-events: all; +} + +.tabulator-tooltip { + color: #fff; + background-color: #000; +} + +.tabulator-row.tabulator-unselectable:not(.tabulator-calcs) { + color: #777 !important; +} + +.tabulator-cell .btn { + padding: 0 .375rem; + font-size: calc(1rem - 2px / 1.5); /* substract border (2 x 1px) modified by the line-height (1.5) */ + border-radius: .2rem; + vertical-align: baseline; +} + +.tabulator-row.tabulator-selectable:focus { + box-shadow: 0 0 0 .24rem rgba(13,110,253,.25); + z-index: 1; + outline: 0; +} + +.btn-select-col-selected +{ + background-color: #e6e6e6; +} + +.accordion-item-dark, .accordion-item-dark:focus{ + background-color:#CED4DA !important; + border-color:#ADB5BD !important; + box-shadow: none !important; +} + +/** + * Make keyboard-focused list items look like the mouse-hovered list items + */ +.tabulator-edit-list .tabulator-edit-list-item.focused { + color: #fff; + background: #1d68cd; +} diff --git a/public/css/components/dashboard.css b/public/css/components/dashboard.css index 8dc19128d..88d136b55 100644 --- a/public/css/components/dashboard.css +++ b/public/css/components/dashboard.css @@ -203,3 +203,14 @@ } } + +.hiddenWidget{ + background: var(--fhc-disabled-background); + opacity: 40%; +} + +.hiddenWidget .card, +.hiddenWidget .card-body, +.hiddenWidget .card-body *{ + background: inherit !important; +} diff --git a/public/css/theme/default.css b/public/css/theme/default.css index ba6493542..a0f366174 100644 --- a/public/css/theme/default.css +++ b/public/css/theme/default.css @@ -89,7 +89,8 @@ --fhc-link: var(--fhc-blue-10); /* disabled */ - --fhc-disabled: var(--fhc-gray-10); + --fhc-disabled: var(--fhc-gray-90); + --fhc-disabled-background: var(--fhc-gray-30); /* status colors */ --fhc-danger: var(--fhc-red-10); @@ -135,6 +136,7 @@ /* disabled */ --fhc-disabled: var(--fhc-gray-10); + --fhc-disabled-background: var(--fhc-gray-120); /* status colors */ --fhc-danger: var(--fhc-red-10); diff --git a/public/js/api/factory/notiz.js b/public/js/api/factory/notiz.js index 074d4b6a5..ce14269d6 100644 --- a/public/js/api/factory/notiz.js +++ b/public/js/api/factory/notiz.js @@ -16,7 +16,10 @@ */ import person from "./notiz/person.js"; +import lehreinheit from "./notiz/lehreinheit.js"; + export default { - person + person, + lehreinheit }; diff --git a/public/js/api/factory/notiz/lehreinheit.js b/public/js/api/factory/notiz/lehreinheit.js new file mode 100644 index 000000000..d93bb50f9 --- /dev/null +++ b/public/js/api/factory/notiz/lehreinheit.js @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import Person from './person.js'; + +export default { + + ...Person, + getNotizen(id, type) { + return { + method: 'get', + url: 'api/frontend/v1/notiz/notizLehreinheit/getNotizen/' + encodeURIComponent(id) + '/' + encodeURIComponent(type) + }; + }, +}; diff --git a/public/js/api/factory/profilUpdate.js b/public/js/api/factory/profilUpdate.js index dfef399bf..553522d30 100644 --- a/public/js/api/factory/profilUpdate.js +++ b/public/js/api/factory/profilUpdate.js @@ -68,6 +68,13 @@ export default { params: dms }; }, + getProfilUpdateWithPermission(filter) { + const url_filter = (filter !== '') ? '/' + encodeURIComponent(filter) : ''; + return { + method: 'get', + url: '/api/frontend/v1/ProfilUpdate/getProfilUpdateWithPermission' + url_filter + }; + }, getProfilRequestFiles(requestID) { return { method: 'get', diff --git a/public/js/api/lehrveranstaltung.js b/public/js/api/lehrveranstaltung.js new file mode 100644 index 000000000..8aa6becaf --- /dev/null +++ b/public/js/api/lehrveranstaltung.js @@ -0,0 +1,36 @@ +export default { + + getByLV(lehrveranstaltung_id) + { + return { + method: 'get', + url: '/api/frontend/v1/Lehrveranstaltung/loadByLV/' + encodeURIComponent(lehrveranstaltung_id) + }; + }, + getByStg(studiensemester_kurzbz, studiengang_kz, semester = null) + { + let path = "/api/frontend/v1/Lehrveranstaltung/getByStg/" + encodeURIComponent(studiensemester_kurzbz) + "/" + encodeURIComponent(studiengang_kz); + + if (semester) + path += "/" + encodeURIComponent(semester); + + return path; + }, + getByEmp(studiensemester_kurzbz, mitarbeiter_uid, stg = null) + { + let path = "/api/frontend/v1/Lehrveranstaltung/getByEmp/" + encodeURIComponent(studiensemester_kurzbz) + "/" + encodeURIComponent(mitarbeiter_uid); + + if (stg) + path += "/" + encodeURIComponent(stg); + + return path; + }, + getTable(url) + { + return { + method: 'get', + url: url + }; + }, + +} \ No newline at end of file diff --git a/public/js/api/lehrveranstaltung/details.js b/public/js/api/lehrveranstaltung/details.js new file mode 100644 index 000000000..db251330a --- /dev/null +++ b/public/js/api/lehrveranstaltung/details.js @@ -0,0 +1,30 @@ +export default { + getStudiensemester() + { + return { + method: 'get', + url: '/api/frontend/v1/lv/setup/getStudiensemester/' + }; + }, + getSprache() + { + return { + method: 'get', + url: '/api/frontend/v1/lv/setup/getSprache/' + }; + }, + getLehrform() + { + return { + method: 'get', + url: '/api/frontend/v1/lv/setup/getLehrform/' + }; + }, + getRaumtyp() + { + return { + method: 'get', + url: '/api/frontend/v1/lv/setup/getRaumtyp/' + }; + }, +} diff --git a/public/js/api/lehrveranstaltung/direktgruppe.js b/public/js/api/lehrveranstaltung/direktgruppe.js new file mode 100644 index 000000000..9cd72fcc7 --- /dev/null +++ b/public/js/api/lehrveranstaltung/direktgruppe.js @@ -0,0 +1,26 @@ +export default { + add(newData) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/DirektGruppe/add/', + params: newData + }; + }, + delete(deleteData) + { + + return { + method: 'post', + url: '/api/frontend/v1/lv/DirektGruppe/delete/', + params: deleteData + }; + }, + getByLehreinheit(lehreinheit_id) + { + return { + method: 'get', + url: '/api/frontend/v1/lv/DirektGruppe/getByLehreinheit/' + encodeURIComponent(lehreinheit_id) + }; + }, +} diff --git a/public/js/api/lehrveranstaltung/gruppe.js b/public/js/api/lehrveranstaltung/gruppe.js new file mode 100644 index 000000000..e22fdd847 --- /dev/null +++ b/public/js/api/lehrveranstaltung/gruppe.js @@ -0,0 +1,56 @@ +export default { + + delete(deleteData) + { + + return { + method: 'post', + url: '/api/frontend/v1/lv/gruppe/delete/', + params: deleteData + }; + }, + + add(newData) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/gruppe/add/', + params: newData + }; + }, + getByLehreinheit(lehreinheit_id) + { + return { + method: 'get', + url: '/api/frontend/v1/lv/gruppe/getByLehreinheit/' + encodeURIComponent(lehreinheit_id) + }; + }, + + deleteFromLVPlan(deleteData) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/gruppe/deleteFromLVPlan/', + params: deleteData + }; + }, + + +/*------------- details -------- */ + getAll() + { + return { + method: 'get', + url: '/api/frontend/v1/lv/gruppe/getAll/' + }; + }, + + getBenutzer() + { + return { + method: 'get', + url: '/api/frontend/v1/lv/gruppe/getBenutzer/' + }; + } + +} diff --git a/public/js/api/lehrveranstaltung/lehreinheit.js b/public/js/api/lehrveranstaltung/lehreinheit.js new file mode 100644 index 000000000..d8f12e27a --- /dev/null +++ b/public/js/api/lehrveranstaltung/lehreinheit.js @@ -0,0 +1,41 @@ +export default { + copy(data) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/lehreinheit/copy/', + params: data + }; + }, + delete(data) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/lehreinheit/delete/', + params: data + }; + }, + add(newData) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/lehreinheit/add/', + params: newData + }; + }, + get(lehreinheit) + { + return { + method: 'get', + url: '/api/frontend/v1/lv/lehreinheit/get/' + encodeURIComponent(lehreinheit) + }; + }, + update(updatedData) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/lehreinheit/update/', + params: updatedData + }; + }, +} diff --git a/public/js/api/lehrveranstaltung/lektor.js b/public/js/api/lehrveranstaltung/lektor.js new file mode 100644 index 000000000..e8c2fb673 --- /dev/null +++ b/public/js/api/lehrveranstaltung/lektor.js @@ -0,0 +1,78 @@ +export default { + + getLehrfunktionen() + { + return { + method: 'get', + url: '/api/frontend/v1/lv/lektor/getLehrfunktionen/' + }; + }, + + + getLektoren() + { + return { + method: 'get', + url: '/api/frontend/v1/lv/lektor/getLektoren/' + }; + }, + + + getByLehreinheit(lehreinheit_id) + { + return { + method: 'get', + url: '/api/frontend/v1/lv/lektor/getLektorenByLE/' + encodeURIComponent(lehreinheit_id) + }; + }, + + + add(newData) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/lektor/add/', + params: newData + }; + }, + + update(updatedData) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/lektor/update/', + params: updatedData + }; + }, + + + deletePerson(deleteData) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/lektor/deletePerson/', + params: deleteData + }; + }, + deleteFromLVPlan(deleteData) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/lektor/deleteLVPlan/', + params: deleteData + }; + }, + getLektorDaten(lehreinheit_id, mitarbeiter_uid) + { + return { + method: 'get', + url: '/api/frontend/v1/lv/lektor/getLektorDaten/' + encodeURIComponent(lehreinheit_id) + '/' + encodeURIComponent(mitarbeiter_uid) + }; + }, + + + + + + +} diff --git a/public/js/api/lehrveranstaltung/setup.js b/public/js/api/lehrveranstaltung/setup.js new file mode 100644 index 000000000..78f78b05b --- /dev/null +++ b/public/js/api/lehrveranstaltung/setup.js @@ -0,0 +1,9 @@ +export default { + getTabs() + { + return { + method: 'get', + url: '/api/frontend/v1/lv/setup/getTabs/' + }; + }, +} diff --git a/public/js/api/lehrveranstaltung/studiengangtree.js b/public/js/api/lehrveranstaltung/studiengangtree.js new file mode 100644 index 000000000..fb63db729 --- /dev/null +++ b/public/js/api/lehrveranstaltung/studiengangtree.js @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + get(path) { + let url = 'api/frontend/v1/lv/StgTree'; + if (path) + url += '/' + path; + return { + method: 'get', + url + }; + }, + favorites: { + get() { + return { + method: 'get', + url: 'api/frontend/v1/lv/favorites' + }; + }, + set(favorites) { + return { + method: 'post', + url: 'api/frontend/v1/lv/favorites/set', + params: { favorites } + }; + } + } +}; \ No newline at end of file diff --git a/public/js/api/lehrveranstaltung/tag.js b/public/js/api/lehrveranstaltung/tag.js new file mode 100644 index 000000000..3d5a5f2ea --- /dev/null +++ b/public/js/api/lehrveranstaltung/tag.js @@ -0,0 +1,54 @@ +export default { + + getTag(data) + { + return { + method: 'get', + url: 'api/frontend/v1/lv/Tags/getTag', + params: data + }; + }, + + getTags(data) + { + return { + method: 'get', + url: 'api/frontend/v1/lv/Tags/getTags' + }; + }, + + addTag(data) + { + return { + method: 'post', + url: 'api/frontend/v1/lv/Tags/addTag', + params: data + }; + }, + + updateTag(data) + { + return { + method: 'post', + url: 'api/frontend/v1/lv/Tags/updateTag', + params: data + }; + }, + doneTag(data) + { + return { + method: 'post', + url: 'api/frontend/v1/lv/Tags/doneTag', + params: data + }; + }, + + deleteTag(data) + { + return { + method: 'post', + url: 'api/frontend/v1/lv/Tags/deleteTag', + params: data + }; + }, +}; \ No newline at end of file diff --git a/public/js/api/lehrveranstaltung/vertrag.js b/public/js/api/lehrveranstaltung/vertrag.js new file mode 100644 index 000000000..601f4b7e3 --- /dev/null +++ b/public/js/api/lehrveranstaltung/vertrag.js @@ -0,0 +1,22 @@ +export default { + + getByLeEmp(lehreinheit_id, mitarbeiter_uid) + { + return { + method: 'get', + url: '/api/frontend/v1/lv/lektor/getLektorDaten/' + encodeURIComponent(lehreinheit_id) + '/' + encodeURIComponent(mitarbeiter_uid), + }; + }, + + cancelByLeEmp(needUpdate) + { + return { + method: 'post', + url: '/api/frontend/v1/lv/lektor/cancelVertrag/', + params: needUpdate + }; + }, + + + +} diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index 870d9d1d6..093ad815b 100644 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -139,10 +139,10 @@ const router = VueRouter.createRouter({ props: true }, { - path: `/Cis/MyLv`, + path: `/Cis/MyLv/:studiensemester?`, name: 'MyLv', component: MylvStudent, - props: true + props: true, }, { path: `/Cis/MyLv/Info/:studien_semester/:lehrveranstaltung_id`, diff --git a/public/js/apps/LVVerwaltung.js b/public/js/apps/LVVerwaltung.js new file mode 100644 index 000000000..f365b74a8 --- /dev/null +++ b/public/js/apps/LVVerwaltung.js @@ -0,0 +1,102 @@ +import LVVerwaltung from "../components/LVVerwaltung/LVVerwaltung.js"; +import Phrasen from "../plugins/Phrasen.js"; + +const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router; + +const router = VueRouter.createRouter({ + history: VueRouter.createWebHistory(`/${ciPath}/LVVerwaltung`), + routes: [ + { + name: 'index', + path: `/`, + component: LVVerwaltung + }, + { + name: `byEmp`, + path: `/emp/:studiensemester_kurzbz/:emp/:stg?/:semester?`, + component: LVVerwaltung, + props: route => { + let {emp, stg, semester, studiensemester_kurzbz} = route.params; + + if (emp === '') + emp = undefined; + + if (stg === '') + stg = undefined; + + if (studiensemester_kurzbz === '') + studiensemester_kurzbz = undefined; + + return { + studiensemester_kurzbz: studiensemester_kurzbz, + emp: emp, + stg: stg, + semester: semester + }; + }, + beforeEnter: (to, from, next) => { + const { studiensemester_kurzbz } = to.params; + const isSemester = /^(SS|WS)\d{4}$/.test(studiensemester_kurzbz); + + if (!isSemester) + return next({ path: '/' }); + else + next(); + } + }, + /*{ + name: `byFachbereich`, + path: `/fachbereich/:fachbereich/:emp?`, + component: LVVerwaltung + },*/ + { + name: `byStg`, + path: '/stg/:studiensemester_kurzbz/:stg?/:semester?/', + component: LVVerwaltung, + props: route => { + let { studiensemester_kurzbz, stg, semester } = route.params; + + if (semester === '') + semester = undefined; + + if (studiensemester_kurzbz === '') + studiensemester_kurzbz = undefined; + + if (stg === '') + stg = undefined; + + return { + studiensemester_kurzbz: studiensemester_kurzbz, + stg: stg, + semester: semester, + }; + }, + beforeEnter: (to, from, next) => { + const studiensemester_kurzbz = to.params?.studiensemester_kurzbz + const isSemester = /^(SS|WS)\d{4}$/.test(studiensemester_kurzbz); + + if (!isSemester) + return next({ path: '/' }); + else + next(); + } + }, + { + path: '/:pathMatch(.*)*', + redirect: '/' + }, + + ] +}); + +const app = Vue.createApp(); + +app + .use(router) + .use(primevue.config.default, { + zIndex: { + overlay: 1100 + } + }) + .use(Phrasen) + .mount('#main'); diff --git a/public/js/components/Cis/Cms/Content.js b/public/js/components/Cis/Cms/Content.js index 470a0fa62..355add08a 100644 --- a/public/js/components/Cis/Cms/Content.js +++ b/public/js/components/Cis/Cms/Content.js @@ -2,6 +2,8 @@ import raum_contentmittitel from './Content_types/Raum_contentmittitel.js' import general from './Content_types/General.js' import BsConfirm from "../../Bootstrap/Confirm.js"; import news_content from './Content_types/News_content.js'; +import iframe_content from './Content_types/Iframe_content.js'; + import ApiCms from '../../../api/factory/cms.js'; export default { @@ -24,42 +26,23 @@ export default { raum_contentmittitel, news_content, general, + iframe_content }, data() { return { + content_type: null, content: null, content_id_internal: this.content_id }; }, methods: { fetchContent(){ - return this.$api + this.$api .call(ApiCms.content(this.content_id_internal, this.version, this.sprache, this.sichtbar)) .then(res => { - this.content = res.data.content; - this.content_type = res.data.type; - - document.querySelectorAll("#cms [data-confirm]").forEach((el) => { - el.addEventListener("click", (evt) => { - evt.preventDefault(); - BsConfirm.popup(el.dataset.confirm) - .then(() => { - Axios.get(el.href) - .then((res) => { - // TODO(chris): check for success then show message and/or reload - location = location; - }) - .catch((err) => console.error("ERROR:", err)); - }) - .catch(() => { - }); - }); - }); - document.querySelectorAll("#cms [data-href]").forEach((el) => { - el.href = el.dataset.href.replace( - /^ROOT\//, - FHC_JS_DATA_STORAGE_OBJECT.app_root - ); + this.$nextTick(function() { + this.content = res.data.content; + this.content_type = res.data.type; }); }); } @@ -83,6 +66,8 @@ export default { return "raum_contentmittitel"; case "news": return "news_content"; + case "iframe": + return "iframe_content"; default: return "general"; }; @@ -91,8 +76,6 @@ export default { created() { this.fetchContent(); }, - mounted() { - }, template: /*html*/ `
diff --git a/public/js/components/Cis/Cms/Content_types/General.js b/public/js/components/Cis/Cms/Content_types/General.js index c57ccd8ca..cbc4224f9 100644 --- a/public/js/components/Cis/Cms/Content_types/General.js +++ b/public/js/components/Cis/Cms/Content_types/General.js @@ -57,65 +57,70 @@ export default { p.style.setProperty('white-space', 'normal'); p.style.setProperty('max-width', '400px'); }) + }, + prepareContent() { + // replaces the tablesorter with the tabulator + let tables = Array.from(document.getElementsByClassName("tablesorter")); + + tables.forEach((table, index) => { + this.sanitizeLegacyTables(table) + + new Tabulator(table, { + index: index, + layout: "fitDataFill", + + columnDefaults: { + formatter: "html", + resizable: true, + minWidth: "100px" + } + }) + }) + + document.querySelectorAll("#cms [data-confirm]").forEach((el) => { + el.addEventListener("click", (evt) => { + evt.preventDefault(); + BsConfirm.popup(el.dataset.confirm) + .then(() => { + Axios.get(el.href) + .then((res) => { + // TODO(chris): check for success then show message and/or reload + location = location; + }) + .catch((err) => console.error("ERROR:", err)); + }) + .catch(() => {}); + }); + }); + document.querySelectorAll("#cms [data-href]").forEach((el) => { + el.href = el.dataset.href.replace( + /^ROOT\//, + FHC_JS_DATA_STORAGE_OBJECT.app_root + ); + }); + + document.querySelectorAll("[href]").forEach((element) => { + let orignal_href = element.getAttribute("href"); + let new_href = replaceRelativeLegacyLink(orignal_href); + element.href = new_href; + }); + + document.querySelectorAll("[style*=background-color]").forEach((element) => { + if (element.style.backgroundColor == "rgb(255, 255, 255)"){ + element.style.backgroundColor = "var(--fhc-background)"; + } + if(element.querySelector("*[style*=background-color]")){ + element.style.backgroundColor = "var(--fhc-tertiary)"; + } + }); } }, - mounted(){ - // replaces the tablesorter with the tabulator - let tables = Array.from(document.getElementsByClassName("tablesorter")); - - tables.forEach((table, index) => { - this.sanitizeLegacyTables(table) - - new Tabulator(table, { - index: index, - layout: "fitDataFill", - - columnDefaults: { - formatter: "html", - resizable: true, - minWidth: "100px" - } - }) - }) - - document.querySelectorAll("#cms [data-confirm]").forEach((el) => { - el.addEventListener("click", (evt) => { - evt.preventDefault(); - BsConfirm.popup(el.dataset.confirm) - .then(() => { - Axios.get(el.href) - .then((res) => { - // TODO(chris): check for success then show message and/or reload - location = location; - }) - .catch((err) => console.error("ERROR:", err)); - }) - .catch(() => {}); - }); - }); - document.querySelectorAll("#cms [data-href]").forEach((el) => { - el.href = el.dataset.href.replace( - /^ROOT\//, - FHC_JS_DATA_STORAGE_OBJECT.app_root - ); - }); - - document.querySelectorAll("[href]").forEach((element) => { - let orignal_href = element.getAttribute("href"); - let new_href = replaceRelativeLegacyLink(orignal_href); - element.href = new_href; - }); - - document.querySelectorAll("[style*=background-color]").forEach((element) => { - if (element.style.backgroundColor == "rgb(255, 255, 255)"){ - element.style.backgroundColor = "var(--fhc-background)"; - } - if(element.querySelector("*[style*=background-color]")){ - element.style.backgroundColor = "var(--fhc-tertiary)"; - } - }); - - }, + updated() { + this.prepareContent(); + }, + mounted(){ + this.prepareContent(); + }, template: /*html*/ `
diff --git a/public/js/components/Cis/Cms/Content_types/Iframe_content.js b/public/js/components/Cis/Cms/Content_types/Iframe_content.js new file mode 100644 index 000000000..568cfaf03 --- /dev/null +++ b/public/js/components/Cis/Cms/Content_types/Iframe_content.js @@ -0,0 +1,31 @@ +import { replaceRelativeLegacyLink } from "../../../../helpers/LegacyLinkReplaceHelper.js"; + +export default { + name: "iframe_content", + props: { + content: { type: String, required: true } + }, + computed: { + srcUrl() { + const parser = new DOMParser() + const doc = parser.parseFromString(`
${this.content}
`, "text/html"); + const iframe = doc.querySelector("iframe[src]"); + + if (!iframe) + return ""; + + let url = iframe.getAttribute("src") || ""; + return replaceRelativeLegacyLink(url); + } + }, + template: ` +
+ +
Keine URL gefunden.
+
+ ` +}; diff --git a/public/js/components/Cis/Cms/Content_types/News_content.js b/public/js/components/Cis/Cms/Content_types/News_content.js index a4eacd332..a17e8592a 100644 --- a/public/js/components/Cis/Cms/Content_types/News_content.js +++ b/public/js/components/Cis/Cms/Content_types/News_content.js @@ -1,6 +1,6 @@ import { replaceRelativeLegacyLink } from "../../../../helpers/LegacyLinkReplaceHelper.js" export default { - name: "GeneralComponent", + name: "NewsContentType", props:{ content:{ type:String, diff --git a/public/js/components/Cis/Mylv/Student.js b/public/js/components/Cis/Mylv/Student.js index 508acb883..4cc45b85f 100644 --- a/public/js/components/Cis/Mylv/Student.js +++ b/public/js/components/Cis/Mylv/Student.js @@ -75,21 +75,26 @@ export default { this.$refs.studiensemester.selectedIndex++; this.$refs.studiensemester.dispatchEvent(new Event('change', { bubbles: true })); }, - setHash(val) { - // TODO: make this a router param to enable history - location.hash = val; + updateRouter(val) { + this.$router.push(`/Cis/MyLv/${val}`); } }, created() { axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/Cis/Mylv/Studiensemester').then(res => { this.studiensemester = res.data.retval || []; - const hash = location.hash.substring(1); - if (hash && this.studiensemester.filter(s => s.studiensemester_kurzbz == hash).length) - this.currentSemester = hash; + const routerStudiensemester = this.$route.params.studiensemester; + if (routerStudiensemester && this.studiensemester.filter(s => s.studiensemester_kurzbz == routerStudiensemester).length) + this.currentSemester = routerStudiensemester; else this.currentSemester = this.nearestSem; }); }, + beforeRouteUpdate(to, from, next){ + if (to.params.studiensemester && this.studiensemester.filter(s => s.studiensemester_kurzbz == to.params.studiensemester).length && to.params.studiensemester != this.currentSemester) + this.currentSemester = to.params.studiensemester; + next(); + + }, template: `

{{$p.t('lehre/myLV')}}

@@ -104,7 +109,7 @@ export default { -
- - - +
+
+
{{$p.t('profilUpdate','meldebestaetigung')}}*
+ +
+
+
 
+ +
+
`, diff --git a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/ImageUpload.js b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/ImageUpload.js index 672b4ce4a..2d2efb0fe 100644 --- a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/ImageUpload.js +++ b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/ImageUpload.js @@ -16,7 +16,7 @@ export default { mixins: [BsModal], props: { titel: { - type: Object, + type: String, }, files: { type: Array, @@ -57,7 +57,7 @@ export default { }, template: /*html*/` - + diff --git a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/Status.js b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/Status.js index a0492a2da..d8c7637b3 100644 --- a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/Status.js +++ b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/Status.js @@ -112,14 +112,17 @@ export default {
{{topic}}
{{data.value}}
-
+ +
+
{{$p.t('profilUpdate','nachweisdokumente')}}
+ +
`, }; diff --git a/public/js/components/Cis/Profil/StudentProfil.js b/public/js/components/Cis/Profil/StudentProfil.js index 88437a0f1..3f8e8380d 100644 --- a/public/js/components/Cis/Profil/StudentProfil.js +++ b/public/js/components/Cis/Profil/StudentProfil.js @@ -11,6 +11,7 @@ import FetchProfilUpdates from "./ProfilComponents/FetchProfilUpdates.js"; import EditProfil from "./ProfilModal/EditProfil.js"; import ApiProfilUpdate from '../../../api/factory/profilUpdate.js'; +import { dateFilter } from '../../../tabulator/filters/Dates.js'; export default { components: { @@ -39,7 +40,7 @@ export default { persistence: { columns: false }, - height: 200, + minHeight: 200, layout: "fitColumns", columns: [{ title: Vue.computed(() => this.preloadedPhrasen.zutrittsGruppenPhrase), @@ -51,7 +52,7 @@ export default { persistence: { columns: false }, - height: 300, + minHeight: 300, layout: "fitColumns", responsiveLayout: "collapse", responsiveLayoutCollapseUseFormatters: false, @@ -85,9 +86,12 @@ export default { { title: Vue.computed(() =>this.preloadedPhrasen.ausgabedatum) , field: "Ausgegeben_am", - headerFilter: true, + headerFilterFunc: 'dates', + headerFilter: dateFilter, minWidth: 200, - visible: true + visible: true, + formatter:"datetime", + formatterParams: this.datetimeFormatterParams() }, ], }, @@ -133,11 +137,11 @@ export default { this.$api .call(ApiProfilUpdate.selectProfilRequest()) .then((request) => { - if (!request.error && res) { + if (!request.error && request.data) { this.data.profilUpdates = request.data; this.data.profilUpdates.sort(this.sortProfilUpdates); } else { - console.error("Error when fetching profile updates: " + res.data); + console.error("Error when fetching profile updates: " + request); } }) .catch((err) => { @@ -160,6 +164,15 @@ export default { this.$refs.editModal.show(); }); }, + datetimeFormatterParams: function() { + const params = { + inputFormat:"yyyy-MM-dd", + outputFormat:"dd.MM.yyyy", + invalidPlaceholder:"(invalid date)", + timezone:FHC_JS_DATA_STORAGE_OBJECT.timezone + }; + return params; + } }, computed: { diff --git a/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js b/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js index d9495f073..d23dcb1b8 100644 --- a/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js +++ b/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js @@ -188,16 +188,21 @@ export default { {{data.requested_change.value}}
-
- - {{file.name}} -
+ + +
+
{{$p.t('profilUpdate','nachweisdokumente')}}
+
+ {{file.name}} +
+
+ diff --git a/public/js/components/Cis/ProfilUpdate/ProfilUpdateView.js b/public/js/components/Cis/ProfilUpdate/ProfilUpdateView.js index 483a4665c..3b056b042 100644 --- a/public/js/components/Cis/ProfilUpdate/ProfilUpdateView.js +++ b/public/js/components/Cis/ProfilUpdate/ProfilUpdateView.js @@ -31,10 +31,10 @@ export default { Loading, AcceptDenyUpdate, }, - inject: ["profilUpdateTopic", "profilUpdateStates"], + inject: ["profilUpdateStates"], props: { id: { - type: Number, + type: String, }, }, data() { @@ -44,51 +44,53 @@ export default { modalData: null, loading: false, filter: "Pending", - events: [], profil_update_id: Number(this.id), }; }, - computed:{ - profilUpdateOptions: function(){ - return { - ajaxURL: - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - `/Cis/ProfilUpdate/`, - - ajaxURLGenerator: (url, config, params) => { - //? this function needs to be an array function in order to access the this properties of the Vue component - - switch (this.filter) { - case this.profilUpdateStates["Pending"]: - return ( - url + - `getProfilUpdateWithPermission/${this.profilUpdateStates["Pending"]}` - ); - case this.profilUpdateStates["Accepted"]: - return ( - url + - `getProfilUpdateWithPermission/${this.profilUpdateStates["Accepted"]}` - ); - case this.profilUpdateStates["Rejected"]: - return ( - url + - `getProfilUpdateWithPermission/${this.profilUpdateStates["Rejected"]}` - ); - default: - return url + `getProfilUpdateWithPermission`; - } - }, + computed: { + profilUpdateEvents: function () { + return [ + { + "event": "dataProcessed", + "handler": this.handleDataProcessed + } + ]; + }, + profilUpdateOptions: function () { + return { + ajaxURL: 'dummy', + ajaxRequestFunc: (url, config, params) => { + return this.$api.call(ApiProfilUpdate.getProfilUpdateWithPermission(params.filter)); + }, + ajaxParams: () => { + let filter = ''; + switch (this.filter) { + case this.profilUpdateStates["Pending"]: + filter = this.profilUpdateStates["Pending"]; + break; + case this.profilUpdateStates["Accepted"]: + filter = this.profilUpdateStates["Accepted"]; + break; + case this.profilUpdateStates["Rejected"]: + filter = this.profilUpdateStates["Rejected"]; + break; + default: + filter = ''; + } + return { + "filter": filter + }; + }, ajaxResponse: (url, params, response) => { //url - the URL of the request //params - the parameters passed with the request //response - the JSON object returned in the body of the response. //? sorts the response data from the backend - if (response) - response.sort((ele1, ele2) => sortProfilUpdates(ele1, ele2, this)); + if (response?.data) + response.data.sort((ele1, ele2) => sortProfilUpdates(ele1, ele2, this)); - return response; + return response.data; }, //? adds tooltip with the status message of a profil update request if its status is not pending columnDefaults: { @@ -356,7 +358,19 @@ export default { this.$refs.UpdatesTable.tabulator.setData(); //? store the selected view in the session storage of the browser sessionStorage.setItem("filter", event.target.value); - }, + }, + handleDataProcessed: function () { + if (this.profil_update_id) { + const arrayRowData = this.$refs.UpdatesTable.tabulator + .getData() + .filter((row) => { + return row.profil_update_id === this.profil_update_id; + }); + if (arrayRowData.length) { + this.showAcceptDenyModal(arrayRowData[0]); + } + } + } }, watch: { loading: function (newValue, oldValue) { @@ -374,20 +388,7 @@ export default { }, mounted() { - //? opens the AcceptDenyUpdate Modal if a preselected profil_update_id was passed to the component (used for email links) - if (this.profil_update_id) { - this.$refs.UpdatesTable.tabulator.on("dataProcessed", () => { - const arrayRowData = this.$refs.UpdatesTable.tabulator - .getData() - .filter((row) => { - return row.profil_update_id === this.profil_update_id; - }); - if (arrayRowData.length) { - this.showAcceptDenyModal(arrayRowData[0]); - } - }); - } - + //? opens the AcceptDenyUpdate Modal if a preselected profil_update_id was passed to the component (used for email links) if (sessionStorage.getItem("filter")) { this.filter = sessionStorage.getItem("filter"); } @@ -409,7 +410,7 @@ export default { - + `, }; diff --git a/public/js/components/Dashboard/Item.js b/public/js/components/Dashboard/Item.js index eccc8242e..d2ad4ae75 100644 --- a/public/js/components/Dashboard/Item.js +++ b/public/js/components/Dashboard/Item.js @@ -156,7 +156,7 @@ export default { -
+
diff --git a/public/js/components/DashboardWidget/Url.js b/public/js/components/DashboardWidget/Url.js index 2763862a9..16eacab90 100644 --- a/public/js/components/DashboardWidget/Url.js +++ b/public/js/components/DashboardWidget/Url.js @@ -159,7 +159,7 @@ export default { // this.$emit('setConfig', true); -> use this to enable widget config mode if needed }, template: /*html*/ ` -
+
diff --git a/public/js/components/DetailHeader/DetailHeader.js b/public/js/components/DetailHeader/DetailHeader.js index 5c1573753..1088e3f63 100644 --- a/public/js/components/DetailHeader/DetailHeader.js +++ b/public/js/components/DetailHeader/DetailHeader.js @@ -102,6 +102,13 @@ export default { redirectToLeitung(){ this.$emit('redirectToLeitung', { person_id: this.leitungData.person_id}); + }, + getFotoSrc(foto) { + if(foto === null) { + return FHC_JS_DATA_STORAGE_OBJECT.app_root + 'skin/images/profilbild_dummy.jpg'; + } else { + return 'data:image/jpeg;base64,' + foto; + } } }, template: ` @@ -116,7 +123,7 @@ export default { Profilbild -