diff --git a/application/config/navigation.php b/application/config/navigation.php index 11fd1a3a6..f7ba8dca3 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -336,3 +336,24 @@ $config['navigation_menu']['system/issues/Issues/*'] = array( 'requiredPermissions' => array('admin:rw') ), ); + +$config['navigation_menu']['apps'] = [ + 'stv' => [ + 'link' => site_url('studentenverwaltung'), + 'description' => 'Studierendenverwaltung', + #'icon' => 'users', + 'requiredPermissions' => array('admin:r', 'assistenz:r') + ], + 'lvv' => [ + 'link' => site_url('lVVerwaltung'), + 'description' => 'LV Verwaltung', + #'icon' => 'person-chalkboard', + 'requiredPermissions' => array('admin:r', 'assistenz:r') + ], + 'lav' => [ + 'link' => site_url('lehre/lehrauftrag/Lehrauftrag/Dashboard'), + 'description' => 'Lehraufträge', + #'icon' => 'person-chalkboard', + 'requiredPermissions' => array('lehre/lehrauftrag_bestellen:r', 'lehre/lehrauftrag_erteilen:r') + ] +]; diff --git a/application/config/routes.php b/application/config/routes.php index de8e6e098..eba6688ff 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -1,6 +1,6 @@ my_controller/my_method */ $route['default_controller'] = defined('CIS4') && CIS4 ? 'Cis4' : 'Vilesci'; -$route['translate_uri_dashes'] = FALSE; +$route['translate_uri_dashes'] = false; // Class name conflicts $route['api/v1/organisation/[S|s]tudiengang/(:any)'] = 'api/v1/organisation/studiengang2/$1'; @@ -71,9 +71,9 @@ $route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})'] = 'api/frontend/v1/stv // (studiensemester_kurzbz)/inout[/(incoming|outgoing|gemeinsamestudien)] $route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/inout'] = 'api/frontend/v1/stv/Students/index'; -$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/inout/incoming'] = 'api/frontend/v1/stv/Students/getIncoming'; -$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/inout/outgoing'] = 'api/frontend/v1/stv/Students/getOutgoing'; -$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/inout/gemeinsamestudien'] = 'api/frontend/v1/stv/Students/getGemeinsamestudien'; +$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/inout/incoming'] = 'api/frontend/v1/stv/Students/getIncoming/$1'; +$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/inout/outgoing'] = 'api/frontend/v1/stv/Students/getOutgoing/$1'; +$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/inout/gemeinsamestudien'] = 'api/frontend/v1/stv/Students/getGemeinsamestudien/$1'; // (studiengang_kz)/prestudent[/(studiensemester_kurzbz)[/(filter)[/(otherfilter)]]] $route['api/frontend/v1/stv/[sS]tudents/(-?[0-9]+)/prestudent'] = 'api/frontend/v1/stv/Students/getPrestudents/$1'; diff --git a/application/config/searchfunctions.php b/application/config/searchfunctions.php index 276652997..ddf7692d5 100644 --- a/application/config/searchfunctions.php +++ b/application/config/searchfunctions.php @@ -29,7 +29,7 @@ $config['similar'] = [ $config['vector'] = [ 'priority' => 1, - 'rank' => "ts_rank({field}, to_tsquery('simple', {word}))", - 'compare' => "to_tsquery('simple', {word}) @@ {field}" + 'rank' => "ts_rank({field}, plainto_tsquery('simple', {word}))", + 'compare' => "plainto_tsquery('simple', {word}) @@ {field}" ]; diff --git a/application/config/searchstv.php b/application/config/searchstv.php index 96c118ac8..d507f7250 100644 --- a/application/config/searchstv.php +++ b/application/config/searchstv.php @@ -7,5 +7,43 @@ $CI =& get_instance(); $config['student'] = $CI->config->item('student', 'search'); +$config['student']['searchfields']['pkz'] = [ + 'alias' => ['personenkennzeichen', 'personalid'], + 'comparison' => 'equals', + 'field' => 'matrikelnr' +]; +$config['student']['searchfields']['matrnr'] = [ + 'alias' => ['matrikelnr', 'matrikelnummer', 'matrno', 'matriculationno', 'matriculationnumber', 'studno', 'studentno', 'studentnumber'], + 'comparison' => 'equals', + 'field' => 'matr_nr', + 'join' => [ + [ + 'table' => "public.tbl_prestudent", + 'using' => "prestudent_id" + ], + [ + 'table' => "public.tbl_person", + 'using' => "person_id" + ] + ] +]; $config['prestudent'] = $CI->config->item('prestudent', 'search'); +$config['prestudent']['searchfields']['pkz'] = [ + 'alias' => ['personenkennzeichen', 'personalid'], + 'comparison' => 'equals', + 'field' => 'matrikelnr', + 'join' => [ + 'table' => "public.tbl_student", + 'using' => "prestudent_id" + ] +]; +$config['prestudent']['searchfields']['matrnr'] = [ + 'alias' => ['matrikelnr', 'matrikelnummer', 'matrno', 'matriculationno', 'matriculationnumber', 'studno', 'studentno', 'studentnumber'], + 'comparison' => 'equals', + 'field' => 'matr_nr', + 'join' => [ + 'table' => "public.tbl_person", + 'using' => "person_id" + ] +]; diff --git a/application/config/stv.php b/application/config/stv.php index 42afc318c..8942c35e6 100644 --- a/application/config/stv.php +++ b/application/config/stv.php @@ -61,9 +61,13 @@ $config['tabs'] = 'notes' => [ //if true, the count of Messages will be shown in the header of the Tab Messages 'showCountNotes' => true - ] + ], + 'combinePeople' => [ + //multitab should only be shown with this length of selection + 'validCountMulti' => 2, + ], ]; - + // List of fields to show when ZGV_DOKTOR_ANZEIGEN is defined $fieldsZgvDoktor = ['zgvdoktorort', 'zgvdoktordatum', 'zgvdoktornation', 'zgvdoktor_erfuellt', 'zgvdoktor_code']; @@ -84,6 +88,16 @@ if (!defined('ZGV_DOKTOR_ANZEIGEN') || !ZGV_DOKTOR_ANZEIGEN) { ); } +$config['tabs']['projektarbeit']['defaultProjektbetreuerStunden'] = + defined('FAS_STUDIERENDE_PROJEKTARBEIT_DEFAULT_BETREUER_STUNDEN_BACHELOR') + ? FAS_STUDIERENDE_PROJEKTARBEIT_DEFAULT_BETREUER_STUNDEN_BACHELOR + : '0.0'; +$config['tabs']['projektarbeit']['defaultProjektbetreuerStundenDiplom'] = + defined('FAS_STUDIERENDE_PROJEKTARBEIT_DEFAULT_BETREUER_STUNDEN_MASTER') + ? FAS_STUDIERENDE_PROJEKTARBEIT_DEFAULT_BETREUER_STUNDEN_MASTER + : '0.0'; +$config['tabs']['projektarbeit']['defaultProjektbetreuerStundensatz'] = '80.0'; + $config['student_tab_order'] = [ 'details', 'notes', @@ -97,6 +111,7 @@ $config['student_tab_order'] = [ 'grades', 'exam', 'exemptions', + 'projektarbeit', 'finalexam', 'mobility', 'jointstudies', @@ -109,7 +124,9 @@ $config['student_tab_order'] = [ $config['students_tab_order'] = [ 'banking', 'status', + 'messages', 'groups', 'finalexam', + 'combinePeople', 'archive', ]; diff --git a/application/controllers/Cis/Documents.php b/application/controllers/Cis/Documents.php index c5a6684d3..0b8d08a56 100644 --- a/application/controllers/Cis/Documents.php +++ b/application/controllers/Cis/Documents.php @@ -72,7 +72,7 @@ class Documents extends Auth_Controller $stgs = []; $stsemArray = []; - $buchungstypen = implode('\',\'', defined("CIS_DOKUMENTE_STUDIENBEITRAG_TYPEN") ? unserialize(CIS_DOKUMENTE_STUDIENBEITRAG_TYPEN) : []); + $buchungstypen = defined("CIS_DOKUMENTE_STUDIENBEITRAG_TYPEN") ? unserialize(CIS_DOKUMENTE_STUDIENBEITRAG_TYPEN) : []; $person_ids = []; foreach ($stati as $status) { $person_ids[] = $status->person_id; diff --git a/application/controllers/Cis/ProfilUpdate.php b/application/controllers/Cis/ProfilUpdate.php index 74641d748..698b091d1 100644 --- a/application/controllers/Cis/ProfilUpdate.php +++ b/application/controllers/Cis/ProfilUpdate.php @@ -13,7 +13,7 @@ class ProfilUpdate extends Auth_Controller { parent::__construct([ 'index' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r'], - 'show' => ['basis/cis:r'], + 'show' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r', 'basis/cis:r'], 'id' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r'] ]); diff --git a/application/controllers/Cis/Pub.php b/application/controllers/Cis/Pub.php index bebc844ab..de456145b 100644 --- a/application/controllers/Cis/Pub.php +++ b/application/controllers/Cis/Pub.php @@ -14,7 +14,7 @@ class Pub extends Auth_Controller { parent::__construct( array( - 'bild' => ['basis/cis:r'] + 'bild' => ['basis/cis:r', 'assistenz:r'] ) ); } diff --git a/application/controllers/NeueNachricht.php b/application/controllers/NeueNachricht.php index 9b61b78ef..b0ff5c554 100644 --- a/application/controllers/NeueNachricht.php +++ b/application/controllers/NeueNachricht.php @@ -20,11 +20,18 @@ class NeueNachricht extends Auth_Controller */ public function _remap() { + $typeid = $this->input->post('typeid'); + $ids = ($this->input->post('ids') && strpos($this->input->post('ids'), ',')) + ? explode(',', $this->input->post('ids')) + : $this->input->post('ids'); + //now working $this->load->view('Nachrichten', [ 'permissions' => [ 'assistenz_schreibrechte' => $this->permissionlib->isBerechtigt('assistenz','suid'), - ] + ], + 'ids' => $ids, + 'typeid' => $typeid ]); } } diff --git a/application/controllers/Studentenverwaltung.php b/application/controllers/Studentenverwaltung.php index 2ce19c58a..3fba97e91 100644 --- a/application/controllers/Studentenverwaltung.php +++ b/application/controllers/Studentenverwaltung.php @@ -32,6 +32,10 @@ class Studentenverwaltung extends Auth_Controller 'student/keine_studstatuspruefung' => $this->permissionlib->isBerechtigt('student/keine_studstatuspruefung'), 'lehre/reihungstestAufsicht' => $this->permissionlib->isBerechtigt('lehre/reihungstestAufsicht'), 'system/change_outputformat' => $this->permissionlib->getOE_isEntitledFor('system/change_outputformat'), + 'student/editBakkZgv' => $this->permissionlib->isBerechtigt('student/editBakkZgv'), + 'student/editMakkZgv' => $this->permissionlib->isBerechtigt('student/editMakkZgv'), + 'student/editDokZgv' => $this->permissionlib->isBerechtigt('student/editDokZgv'), + 'student/editBismelden' => $this->permissionlib->isBerechtigt('student/editBismelden') ], 'variables' => [ 'semester_aktuell' => $this->variablelib->getVar('semester_aktuell') diff --git a/application/controllers/api/frontend/v1/Documents.php b/application/controllers/api/frontend/v1/Documents.php index 2d2c410cf..7b2fc4a15 100644 --- a/application/controllers/api/frontend/v1/Documents.php +++ b/application/controllers/api/frontend/v1/Documents.php @@ -442,6 +442,10 @@ class Documents extends FHCAPI_Controller 'betreuerart_kurzbz', 'studiensemester_kurzbz' ] as $key) { + if (in_array($xsl, array('Ausbildungsver', 'AusbVerEng')) && $key === 'uid') + { + continue; + } $value = $this->input->post_get($key); if ($value !== null) $params .= '&' . $key . '=' . urlencode($value); diff --git a/application/controllers/api/frontend/v1/Lehrveranstaltung.php b/application/controllers/api/frontend/v1/Lehrveranstaltung.php index 2e254bfc8..935602391 100644 --- a/application/controllers/api/frontend/v1/Lehrveranstaltung.php +++ b/application/controllers/api/frontend/v1/Lehrveranstaltung.php @@ -119,7 +119,19 @@ class Lehrveranstaltung extends FHCAPI_Controller if (hasData($lehreinheiten_data)) { $lehreinheiten = getData($lehreinheiten_data); - $rowData->_children = $lehreinheiten; + + if (!isset($row->_children)) + { + $row->_children = $lehreinheiten; + } + else + { + if (!is_array($row->_children)) + { + $row->_children = [$row->_children]; + } + $row->_children = array_merge($row->_children, $lehreinheiten); + } } if (!isEmptyString($row->studienplan_lehrveranstaltung_id_parent)) diff --git a/application/controllers/api/frontend/v1/ProfilUpdate.php b/application/controllers/api/frontend/v1/ProfilUpdate.php index e5129b678..f97546288 100644 --- a/application/controllers/api/frontend/v1/ProfilUpdate.php +++ b/application/controllers/api/frontend/v1/ProfilUpdate.php @@ -637,7 +637,7 @@ class ProfilUpdate extends FHCAPI_Controller //? 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_prestudent", "public.tbl_benutzer.person_id = public.tbl_prestudent.person_id and public.tbl_student.studiengang_kz = public.tbl_prestudent.studiengang_kz"); $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"]); @@ -706,7 +706,13 @@ class ProfilUpdate extends FHCAPI_Controller private function setStatusOnUpdateRequest($id, $status, $status_message) { - return $this->ProfilUpdateModel->update([$id], ["status" => $status, "status_timestamp" => "NOW()", "status_message" => $status_message]); + return $this->ProfilUpdateModel->update([$id], [ + "status" => $status, + "status_timestamp" => "NOW()", + "status_message" => $status_message, + "updateamum" => "NOW()", + "updatevon" => getAuthUID() + ]); } private function updateRequestedChange($id, $requested_change) @@ -716,13 +722,12 @@ class ProfilUpdate extends FHCAPI_Controller private function deleteOldVersionFile($dms_id) { + if (!isset($dms_id)) { + return true; + } + // starting the transaction $this->db->trans_start(); - - - if (!isset($dms_id)) { - return; - } //? delete the file from the profilUpdate first $profilUpdateFileDelete = $this->ProfilUpdateModel->removeFileFromProfilUpdate($dms_id); @@ -777,13 +782,8 @@ class ProfilUpdate extends FHCAPI_Controller $res = $this->StudentModel->execReadOnlyQuery($query, [$student_uid]); $res = $this->getDataOrTerminateWithError($res, $this->p->t('profilUpdate', 'profilUpdate_loadingOE_error')); - $res = array_map( - function ($item) { - return $item->oe_kurzbz; - }, - $res - ); - return $res; + $oe = ($res[0])->oe_kurzbz; + return $oe; } private function handleAdresse($requested_change, $personID) diff --git a/application/controllers/api/frontend/v1/lv/Gruppe.php b/application/controllers/api/frontend/v1/lv/Gruppe.php index 83a4fb696..daebe8a61 100644 --- a/application/controllers/api/frontend/v1/lv/Gruppe.php +++ b/application/controllers/api/frontend/v1/lv/Gruppe.php @@ -12,8 +12,8 @@ class Gruppe extends FHCAPI_Controller 'add' => ['admin:rw', 'assistenz:rw'], 'delete' => ['admin:rw', 'assistenz:rw'], 'deleteFromLVPlan' => ['admin:rw', 'assistenz:rw'], - 'getBenutzer' => ['admin:r', 'assistenz:r'], - 'getAll' => ['admin:r', 'assistenz:r'], + 'getBenutzerSearch' => ['admin:r', 'assistenz:r'], + 'getAllSearch' => ['admin:r', 'assistenz:r'], 'getByLehreinheit' => ['admin:r', 'assistenz:r'], ]); @@ -22,7 +22,8 @@ class Gruppe extends FHCAPI_Controller $this->_ci->load->library('PhrasesLib'); $this->loadPhrases( array( - 'ui' + 'ui', + 'lehre' ) ); @@ -91,11 +92,11 @@ class Gruppe extends FHCAPI_Controller $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); + $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->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); $this->checkPermission($lehreinheit_id); @@ -108,15 +109,33 @@ class Gruppe extends FHCAPI_Controller } - public function getAll() + public function getAllSearch() { + $query = $this->input->get('query'); + + if (is_null($query)) + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $query_words = explode(' ', $query); + $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)); + $this->_ci->GruppeModel->db->where(array('sichtbar' => true, 'aktiv' => true, 'lehre' => true, 'direktinskription' => false, 'semester IS NOT NULL' => null)); + $this->_ci->GruppeModel->db->group_start(); + foreach ($query_words as $word) + { + $this->_ci->GruppeModel->db->group_start(); + $this->_ci->GruppeModel->db->where('gruppe_kurzbz ILIKE', "%" . $word . "%"); + $this->_ci->GruppeModel->db->or_where('bezeichnung ILIKE', "%" . $word . "%"); + $this->_ci->GruppeModel->db->group_end(); + } + $this->_ci->GruppeModel->db->group_end(); + + $gruppen_result = $this->_ci->GruppeModel->load(); $gruppen_array = array(); @@ -135,7 +154,18 @@ class Gruppe extends FHCAPI_Controller $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)); + $this->_ci->LehrverbandModel->db->where(array('tbl_lehrverband.aktiv' => true)); + + $this->_ci->LehrverbandModel->db->group_start(); + foreach ($query_words as $word) + { + $this->_ci->LehrverbandModel->db->group_start(); + $this->_ci->LehrverbandModel->db->where('CONCAT(CONCAT(typ, kurzbz), \'\', semester, verband, COALESCE(gruppe,\'\')) ILIKE', "%" . $word . "%"); + $this->_ci->LehrverbandModel->db->or_where('tbl_lehrverband.bezeichnung ILIKE', "%" . $word . "%"); + $this->_ci->LehrverbandModel->db->group_end(); + } + $this->_ci->LehrverbandModel->db->group_end(); + $lehrverband_result = $this->_ci->LehrverbandModel->load(); $lehrverband_array = array(); @@ -150,15 +180,40 @@ class Gruppe extends FHCAPI_Controller $this->terminateWithSuccess($all_gruppen); } - public function getBenutzer() + public function getBenutzerSearch() { + $query = $this->input->get('query'); + + if (is_null($query)) + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $query_words = explode(' ', $query); + $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->_ci->PersonModel->db->where(array('tbl_benutzer.aktiv' => true)); + + $this->_ci->PersonModel->db->group_start(); + foreach ($query_words as $word) + { + $this->_ci->PersonModel->db->group_start(); + $this->_ci->PersonModel->db->where('tbl_person.vorname ILIKE', "%" . $word . "%"); + $this->_ci->PersonModel->db->or_where('tbl_person.nachname ILIKE', "%" . $word . "%"); + $this->_ci->PersonModel->db->or_where('uid ILIKE', "%" . $word . "%"); + $this->_ci->PersonModel->db->or_where('CONCAT(tbl_studiengang.typ, tbl_studiengang.kurzbz) ILIKE', "%" . $word . "%"); + + if (is_numeric($word)) + { + $this->_ci->PersonModel->db->or_where('semester', $word); + } + $this->_ci->PersonModel->db->group_end(); + } + $this->_ci->PersonModel->db->group_end(); + $personen = $this->_ci->PersonModel->load(); $this->terminateWithSuccess(hasData($personen) ? getData($personen) : array()); } diff --git a/application/controllers/api/frontend/v1/lv/Lehreinheit.php b/application/controllers/api/frontend/v1/lv/Lehreinheit.php index 958007901..6329d30ac 100644 --- a/application/controllers/api/frontend/v1/lv/Lehreinheit.php +++ b/application/controllers/api/frontend/v1/lv/Lehreinheit.php @@ -169,6 +169,10 @@ class Lehreinheit extends FHCAPI_Controller { $value = $this->input->post($field); + if ($field === 'lehre') + { + $value = (bool)$value; + } if ($value !== null) { $updateData[$field] = $value; @@ -281,15 +285,43 @@ class Lehreinheit extends FHCAPI_Controller 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); + $errors = array(); + if (is_array($lehreinheit_id)) + { + foreach ($lehreinheit_id as $le_id) + { + $lehreinheit = $this->checkLehreinheit($le_id); + $this->checkPermission($lehreinheit->lehreinheit_id); - if (isError($result)) - $this->terminateWithValidationErrors(getError($result)); + $result = $this->_ci->LehreinheitModel->deleteLehreinheit($lehreinheit->lehreinheit_id); - $this->terminateWithSuccess('Erfolgreich geloescht'); + if (isError($result)) + { + $errors[] = getError($result); + } + } + } + else + { + $lehreinheit = $this->checkLehreinheit($lehreinheit_id); + $this->checkPermission($lehreinheit->lehreinheit_id); + + $result = $this->_ci->LehreinheitModel->deleteLehreinheit($lehreinheit->lehreinheit_id); + + if (isError($result)) + $this->terminateWithError(getError($result)); + } + + if (!isEmptyArray($errors)) + { + if (count($errors) !== count($lehreinheit_id)) + $this->terminateWithSuccess(array('errors' => $errors)); + else + $this->terminateWithError($errors); + } + else + $this->terminateWithSuccess('Erfolgreich geloescht'); } public function update() diff --git a/application/controllers/api/frontend/v1/lv/Lektor.php b/application/controllers/api/frontend/v1/lv/Lektor.php index 68bec1bc4..cce7f6e8b 100644 --- a/application/controllers/api/frontend/v1/lv/Lektor.php +++ b/application/controllers/api/frontend/v1/lv/Lektor.php @@ -15,7 +15,7 @@ class Lektor extends FHCAPI_Controller 'deleteLVPlan' => ['admin:rw', 'assistenz:rw'], 'deletePerson' => ['admin:rw', 'assistenz:rw'], 'getLehrfunktionen' => ['admin:r', 'assistenz:r'], - 'getLektoren' => ['admin:r', 'assistenz:r'], + 'getLektorenSearch' => ['admin:r', 'assistenz:r'], 'getLektorenByLE' => ['admin:r', 'assistenz:r'], 'getLektorDaten' => ['admin:r', 'assistenz:r'], 'getLektorVertrag' => ['admin:r', 'assistenz:r'], @@ -208,12 +208,35 @@ class Lektor extends FHCAPI_Controller $this->terminateWithSuccess(getData($this->_ci->LehrfunktionModel->load())); } - public function getLektoren() + public function getLektorenSearch() { + $query = $this->input->get('query'); + + if (is_null($query)) + $this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); + + $query_words = explode(' ', $query); + $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)))); + + $this->_ci->MitarbeiterModel->db->where('public.tbl_benutzer.aktiv', true); + + $this->_ci->MitarbeiterModel->db->group_start(); + foreach ($query_words as $word) + { + $this->_ci->MitarbeiterModel->db->group_start(); + $this->_ci->MitarbeiterModel->db->where('tbl_person.vorname ILIKE', "%" . $word . "%"); + $this->_ci->MitarbeiterModel->db->or_where('tbl_person.nachname ILIKE', "%" . $word . "%"); + $this->_ci->MitarbeiterModel->db->or_where('uid ILIKE', "%" . $word . "%"); + $this->_ci->MitarbeiterModel->db->group_end(); + } + $this->_ci->MitarbeiterModel->db->group_end(); + $this->_ci->MitarbeiterModel->addOrder('nachname'); + $this->_ci->MitarbeiterModel->addOrder('vorname'); + $result = $this->_ci->MitarbeiterModel->load(); + $this->terminateWithSuccess(hasData($result) ? getData($result) : array()); } private function checkLehreinheit($lehreinheit_id) diff --git a/application/controllers/api/frontend/v1/lv/Tags.php b/application/controllers/api/frontend/v1/lv/Tags.php index a22a4c82e..34c42bc32 100644 --- a/application/controllers/api/frontend/v1/lv/Tags.php +++ b/application/controllers/api/frontend/v1/lv/Tags.php @@ -5,7 +5,7 @@ if (!defined('BASEPATH')) class Tags extends Tag_Controller { - const BERECHTIGUNG_KURZBZ = ['admin:rw', 'assistenz:rw']; + const BERECHTIGUNG_KURZBZ = ['admin:rw', 'assistenz:r']; public function __construct() { diff --git a/application/controllers/api/frontend/v1/messages/Messages.php b/application/controllers/api/frontend/v1/messages/Messages.php index fa6748f6a..3035e532d 100644 --- a/application/controllers/api/frontend/v1/messages/Messages.php +++ b/application/controllers/api/frontend/v1/messages/Messages.php @@ -1,6 +1,5 @@ ['admin:r', 'assistenz:r'], 'getMsgVarsLoggedInUser' => ['admin:r', 'assistenz:r'], 'getNameOfDefaultRecipient' => ['admin:r', 'assistenz:r'], + 'getNameOfDefaultRecipients' => ['admin:r', 'assistenz:r'], 'sendMessage' => ['admin:r', 'assistenz:r'], 'deleteMessage' => ['admin:r', 'assistenz:r'], - 'getVorlagentext' => ['admin:r', 'assistenz:r'], + 'getDataVorlage' => ['admin:r', 'assistenz:r'], 'getPreviewText' => ['admin:r', 'assistenz:r'], 'getReplyData' => ['admin:r', 'assistenz:r'], 'getPersonId' => ['admin:r', 'assistenz:r'], 'getUid' => ['admin:r', 'assistenz:r'], + 'getUids' => ['admin:r', 'assistenz:r'], ]); //Load Models @@ -37,7 +38,7 @@ class Messages extends FHCAPI_Controller // Load language phrases $this->loadPhrases([ - 'ui' + 'ui', 'messages' ]); } @@ -52,11 +53,14 @@ class Messages extends FHCAPI_Controller $result = $this->MessageModel->getMessagesForTable($id, $offset, $limit); - $data = $this->getDataOrTerminateWithError($result); + if (hasData($result)) + { + $data = getData($result); + $this->addMeta('count', $data['count']); + $this->terminateWithSuccess($data['data']); + } - $this->addMeta('count', $data['count']); - - $this->terminateWithSuccess($data['data']); + $this->terminateWithSuccess(array()); } public function getVorlagen() @@ -66,33 +70,23 @@ class Messages extends FHCAPI_Controller $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); $result = $this->BenutzerfunktionModel->getBenutzerfunktionByUid($uid, 'oezuordnung'); - $data = $this->getDataOrTerminateWithError($result); - $oe_kurzbz = current($data); + if (hasData($result)) + { + $this->load->model('system/Vorlage_model', 'VorlageModel'); - $this->load->model('system/Vorlage_model', 'VorlageModel'); + $data = getData($result); - $result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz->oe_kurzbz); - $data = $this->getDataOrTerminateWithError($result); + $oe_kurzbz = array_column($data, 'oe_kurzbz'); + $result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz); - $this->terminateWithSuccess($data); + $this->terminateWithSuccess(hasData($result) ? getData($result) : array()); + } - //If admin - $this->VorlageModel->addOrder('vorlage_kurzbz', 'ASC'); - $result = $this->VorlageModel->loadWhere( - array( - 'mimetype' => 'text/html' - )); - - - $data = $this->getDataOrTerminateWithError($result); - - $this->terminateWithSuccess($data); + $this->terminateWithSuccess(array()); } - public function getVorlagentext($vorlage_kurzbz) + public function getDataVorlage($vorlage_kurzbz) { - //$this->terminateWithError("vor " . $vorlage_kurzbz, self::ERROR_TYPE_GENERAL); - //$studiengang_kz = 227; //TODO(Manu) dynamisieren NULL $studiengang_kz = 0; $this->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel'); $this->VorlagestudiengangModel->addOrder('version', 'DESC'); @@ -104,30 +98,53 @@ class Messages extends FHCAPI_Controller ]); $data = $this->getDataOrTerminateWithError($result); - - //not correct with Vorlage $vorlage = current($data); - - //$this->terminateWithSuccess($data); - $this->terminateWithSuccess($vorlage->text); + $this->terminateWithSuccess($vorlage); } - public function getMessageVarsPerson($id, $typeId) + public function getMessageVarsPerson($typeId) { - $person_id = ($typeId == 'mitarbeiter_uid') ? $this->_getPersonId($id, $typeId) : $id; - $result = $this->MessageModel->getMsgVarsDataByPersonId($person_id); - $data = $this->getDataOrTerminateWithError($result); + $ids = $this->input->post('ids'); + $messageVarsPerson = []; - $this->terminateWithSuccess($data); + foreach ($ids as $id) + { + $person_id = ($typeId == 'mitarbeiter_uid') ? $this->_getPersonId($id, $typeId) : $id; + $result = $this->MessageModel->getMsgVarsDataByPersonId($person_id); + $data = $this->getDataOrTerminateWithError($result); + $messageVarsPerson[] = current($data); + } + + $this->terminateWithSuccess($messageVarsPerson); } - public function getMsgVarsPrestudent($id, $typeId) + public function getMsgVarsPrestudent($typeId) { - $prestudent_id = ($typeId == 'uid') ? $this->_getPrestudentIdFromUid($id) : $id; - $result = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); - $data = $this->getDataOrTerminateWithError($result); + $ids = $this->input->post('ids'); + if(!is_array($ids)) { + $ids = array($ids); + } + $messageVarsPrestudent = []; - $this->terminateWithSuccess($data); + if($typeId == 'uid') + { + $prestudent_ids = []; + foreach ($ids as $id) + { + $prestudent_ids[] = $this->_getPrestudentIdFromUid($id); + } + } + else + $prestudent_ids = $ids; + + foreach ($prestudent_ids as $prestudent_id) + { + $result = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); + $data = $this->getDataOrTerminateWithError($result); + $messageVarsPrestudent[] = current($data); + } + + $this->terminateWithSuccess($messageVarsPrestudent); } public function getMsgVarsLoggedInUser() @@ -138,27 +155,45 @@ class Messages extends FHCAPI_Controller $this->terminateWithSuccess($data); } - public function getNameOfDefaultRecipient($id, $type_id) + public function getNameOfDefaultRecipients($type_id) { - $id = ($type_id != 'person_id') ? $this->_getPersonId($id, $type_id) : $id; + $ids = $this->input->post('ids'); + if(!is_array($ids)) { + $ids = array($ids); + } + $recipients = []; + + if (empty($ids)) { + + throw new InvalidArgumentException($this->p->t('ui', 'errorMissingOrInvalidParameters', ['parameter'=> 'Id(s)']), self::ERROR_TYPE_GENERAL); + } $this->load->model('person/Person_model', 'PersonModel'); + if($type_id != 'person_id'){ + foreach ($ids as $id) + { + $person_id = $this->_getPersonId($id, $type_id); + $result = $this->PersonModel->load($person_id); + $data = $this->getDataOrTerminateWithError($result); + $name = current($data); + $recipients[$id] = $name->vorname . " " . $name->nachname; + } + } + else { + foreach ($ids as $id) { + $result = $this->PersonModel->load($id); + $data = $this->getDataOrTerminateWithError($result); + $name = current($data); + $recipients[$id] = $name->vorname . " " . $name->nachname; + } + } - $result = $this->PersonModel->load($id); - $data = $this->getDataOrTerminateWithError($result); - $name = current($data); - - $this->terminateWithSuccess($name->vorname . " " . $name->nachname ); + $this->terminateWithSuccess($recipients); } - public function sendMessage($recipient_id) + public function sendMessage($typeId) { - //has to be uid - // $this->terminateWithError("uid", $recipient_id, self::ERROR_TYPE_GENERAL); - - //default setting - $receiversPersonId = $this->_getPersonId($recipient_id, 'uid'); - + $resultReturn = []; $uid = getAuthUID(); $this->load->model('person/Benutzer_model', 'BenutzerModel'); $result = $this->BenutzerModel->loadWhere( @@ -196,49 +231,61 @@ class Messages extends FHCAPI_Controller $body = $this->input->post('body'); $relationmessage_id = $this->input->post('relationmessage_id'); - $typeId = $this->input->post('type_id'); - $id = $this->input->post('id'); - - if($typeId == 'uid') + if (isset($_POST['ids'])) { - $prestudent_id = $this-> _getPrestudentIdFromUid($id); - - //parseMessagetext for variables Prestudent - $result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $body); - $bodyParsed = $this->getDataOrTerminateWithError($result); - } - if($typeId == 'mitarbeiter_uid') - { - $person_id = $this->_getPersonId($id, $typeId); - - $result = $this->MessagesModel->parseMessageTextPerson($person_id, $body); - $bodyParsed = $this->getDataOrTerminateWithError($result); - $this->terminateWithError($bodyParsed, self::ERROR_TYPE_GENERAL); - - } - elseif($typeId == 'person_id') - { - $result = $this->MessagesModel->parseMessageTextPerson($id, $body); - $bodyParsed = $this->getDataOrTerminateWithError($result); - } - elseif($typeId == 'prestudent_id') - { - // $this->terminateWithError("prestudent_id ", self::ERROR_TYPE_GENERAL); - - $result = $this->MessagesModel->parseMessageTextPrestudent($id, $body); - $bodyParsed = $this->getDataOrTerminateWithError($result); - } - else - { - $this->terminateWithError("type_id " . $typeId . " not valid", self::ERROR_TYPE_GENERAL); + $ids = json_decode($_POST['ids']); + unset($_POST['ids']); + foreach ($data as $k => $v) { + $_POST[$k] = $v; + } } - $result = $this->messagelib->sendMessageUser($receiversPersonId, $subject, $bodyParsed, $benutzer->person_id, null, $relationmessage_id); + if (!is_array($ids)) { + $ids = [$ids]; + } - $this->terminateWithSuccess($result); + foreach ($ids as $id) + { + $receiversPersonId = $typeId == "person_id" ? $id : $this->_getPersonId($id, $typeId); + + if($typeId == 'uid') + { + $prestudent_id = $this-> _getPrestudentIdFromUid($id); + + $result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $body); + $bodyParsed = $this->getDataOrTerminateWithError($result); + } + if($typeId == 'mitarbeiter_uid') + { + $person_id = $this->_getPersonId($id, $typeId); + + $result = $this->MessagesModel->parseMessageTextPerson($person_id, $body); + $bodyParsed = $this->getDataOrTerminateWithError($result); + } + elseif($typeId == 'person_id') + { + $result = $this->MessagesModel->parseMessageTextPerson($id, $body); + $bodyParsed = $this->getDataOrTerminateWithError($result); + } + elseif($typeId == 'prestudent_id') + { + $result = $this->MessagesModel->parseMessageTextPrestudent($id, $body); + $bodyParsed = $this->getDataOrTerminateWithError($result); + } + else + { + $this->terminateWithError($this->p->t('messages', 'error_missingLogic', ['type'=> $typeId]), self::ERROR_TYPE_GENERAL); + } + + $result =$this->messagelib->sendMessageUser($receiversPersonId, $subject, $bodyParsed, $benutzer->person_id, null, $relationmessage_id); + $data = $this->getDataOrTerminateWithError($result); + $resultReturn[] = current($data); + + } + $this->terminateWithSuccess($resultReturn); } - public function getPreviewText($id, $type_id) + public function getPreviewText($type_id) { if (isset($_POST['data'])) { @@ -246,39 +293,60 @@ class Messages extends FHCAPI_Controller unset($_POST['data']); } else - $this->terminateWithError("Textbody missing ", self::ERROR_TYPE_GENERAL); + $this->terminateWithError($this->p->t('messages', 'errorMissingOrInvalidParameters', ['parameter'=> "Textbody"]), self::ERROR_TYPE_GENERAL); - switch($type_id) + if (isset($_POST['ids'])) { - case 'uid': - $prestudent_id = $this->_getPrestudentIdFromUid($id); - $result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $data); - break; - case 'prestudent_id': - $result = $this->MessagesModel->parseMessageTextPrestudent($id, $data); - break; - case 'person_id': - $result = $this->MessagesModel->parseMessageTextPerson($id, $data); - break; - case 'mitarbeiter_uid': - { - $person_id = $this->_getPersonId($id, $type_id); - $result = $this->MessagesModel->parseMessageTextPerson($person_id, $data); - } - break; - default: - $this->terminateWithError("MESSAGES::getPreviewText logic for type_id " . $type_id . " not defined yet", self::ERROR_TYPE_GENERAL); - break; + $ids = json_decode($_POST['ids']); + if(!is_array($ids)) + { + $ids = array($ids); + } + unset($_POST['ids']); } + else + $this->terminateWithError($this->p->t('ui', 'errorMissingOrInvalidParameters', ['parameter'=> 'Id(s)']), self::ERROR_TYPE_GENERAL); - $bodyParsed = $this->getDataOrTerminateWithError($result); + $bodyParsed = []; + + foreach ($ids as $id) + { + switch($type_id) + { + case 'uid': + $prestudent_id = $this->_getPrestudentIdFromUid($id); + $result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $data); + $bodyParsed[$id] = $this->getDataOrTerminateWithError($result); + break; + case 'prestudent_id': + $result = $this->MessagesModel->parseMessageTextPrestudent($id, $data); + $bodyParsed[$id] = $this->getDataOrTerminateWithError($result); + break; + case 'person_id': + $result = $this->MessagesModel->parseMessageTextPerson($id, $data); + $bodyParsed[$id] = $this->getDataOrTerminateWithError($result); + break; + case 'mitarbeiter_uid': + { + $person_id = $this->_getPersonId($id, $type_id); + $result = $this->MessagesModel->parseMessageTextPerson($person_id, $data); + $bodyParsed[$id] = $this->getDataOrTerminateWithError($result); + } + break; + default: + $this->terminateWithError($this->p->t('messages', 'error_missingLogic', ['type'=> $type_id]), self::ERROR_TYPE_GENERAL); + break; + } + } $this->terminateWithSuccess($bodyParsed); } public function getReplyData($messageId) { - //TODO(Manu) validation of messageId: if number + if (!is_numeric($messageId)) { + $this->terminateWithError($this->p->t('ui', 'error_valueNotNumeric', ['value'=> 'Message ID']), self::ERROR_TYPE_GENERAL); + } $this->MessageModel->addSelect('public.tbl_msg_message.*'); $this->MessageModel->addSelect('r.*'); @@ -301,7 +369,6 @@ class Messages extends FHCAPI_Controller $replyBody = $this->_getReplyBody($body, $dataMessage[0]->nachname, $dataMessage[0]->vorname, $dataMessage[0]->insertamum); $dataMessage[0]->replyBody = $replyBody; - $dataMessage[0]->rest = "Help Manu"; $dataMessage[0]->replySubject = $prefix . $subject; $this->terminateWithSuccess($dataMessage); @@ -349,6 +416,11 @@ class Messages extends FHCAPI_Controller ['prestudent_id' => $id] ); } + else + { + $this->terminateWithError($this->p->t('messages', 'error_missingLogic', ['type'=> $typeId]), self::ERROR_TYPE_GENERAL); + } + $data = $this->getDataOrTerminateWithError($result); $person = current($data); @@ -356,8 +428,11 @@ class Messages extends FHCAPI_Controller $this->terminateWithSuccess($person->person_id); } - public function getUid($id, $typeId) + public function getUids($typeId) { + $ids = $this->input->post('ids'); + $benutzerIds = []; + if (!$typeId) { $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Type ID']), self::ERROR_TYPE_GENERAL); @@ -365,39 +440,50 @@ class Messages extends FHCAPI_Controller elseif ($typeId == 'person_id') { $this->load->model('person/Benutzer_model', 'BenutzerModel'); - $result = $this->BenutzerModel->loadWhere( - ['person_id' => $id] - ); + foreach ($ids as $id) + { + $result = $this->BenutzerModel->loadWhere( + ['person_id' => $id] + ); + $data = $this->getDataOrTerminateWithError($result); + $benutzer = current($data); + + $benutzerIds[$id] = $benutzer->uid; + } } elseif($typeId == 'prestudent_id') { $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $result = $this->PrestudentModel->loadWhere( - ['prestudent_id' => $id] - ); + foreach ($ids as $id) + { + $result = $this->PrestudentModel->loadWhere( + ['prestudent_id' => $id] + ); - $data = $this->getDataOrTerminateWithError($result); - $person = current($data); - $person_id = $person->person_id; + $data = $this->getDataOrTerminateWithError($result); + $person = current($data); + $person_id = $person->person_id; - $this->load->model('person/Benutzer_model', 'BenutzerModel'); - $result = $this->BenutzerModel->loadWhere( - ['person_id' => $person_id] - ); + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $result = $this->BenutzerModel->loadWhere( + ['person_id' => $person_id] + ); + $data = $this->getDataOrTerminateWithError($result); + $benutzer = current($data); + + $benutzerIds[$id] = $benutzer->uid; + } } elseif($typeId == 'uid' || $typeId == 'mitarbeiter_uid') { - $this->terminateWithSuccess($id); + $this->terminateWithSuccess($ids); } else { - $this->terminateWithError("MESSAGES::getUID logic for type_id " . $typeId . " not defined yet", self::ERROR_TYPE_GENERAL); + $this->terminateWithError($this->p->t('messages', 'error_missingLogic', ['type'=> $typeId]), self::ERROR_TYPE_GENERAL); } - $data = $this->getDataOrTerminateWithError($result); - $benutzer = current($data); - - $this->terminateWithSuccess($benutzer->uid); + $this->terminateWithSuccess($benutzerIds); } private function _getPersonId($id, $typeId) @@ -416,11 +502,16 @@ class Messages extends FHCAPI_Controller ['prestudent_id' => $id] ); } + else + { + $this->terminateWithError($this->p->t('messages', 'error_missingLogic', ['type'=> $typeId]), self::ERROR_TYPE_GENERAL); + } + $data = $this->getDataOrTerminateWithError($result); if (count($data) < 1) { - $this->terminateWithError('Error: Messages API no person_id found.'); + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person ID']), self::ERROR_TYPE_GENERAL); } $person = current($data); @@ -429,7 +520,6 @@ class Messages extends FHCAPI_Controller private function _getPrestudentIdFromUid($uid) { - // $this->terminateWithError($uid, self::ERROR_TYPE_GENERAL); $this->load->model('crm/Student_model', 'StudentModel'); $result = $this->StudentModel->loadWhere( ['student_uid' => $uid] @@ -438,7 +528,7 @@ class Messages extends FHCAPI_Controller $data = $this->getDataOrTerminateWithError($result); if (count($data) < 1) { - $this->terminateWithError('Error: Messages API no prestudent_id found.'); + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL); } $student = current($data); @@ -463,4 +553,4 @@ class Messages extends FHCAPI_Controller date_format(date_create($sentDate), 'd.m.Y H:i'), $receiverName, $receiverSurname, $body ); } -} \ No newline at end of file +} diff --git a/application/controllers/api/frontend/v1/organisation/Studienplan.php b/application/controllers/api/frontend/v1/organisation/Studienplan.php new file mode 100644 index 000000000..c5a69fdee --- /dev/null +++ b/application/controllers/api/frontend/v1/organisation/Studienplan.php @@ -0,0 +1,69 @@ + self::PERM_LOGGED + ]); + } + + public function getBySemester() + { + $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + + $studiengang_kz = $this->input->get('studiengang_kz'); + $studiensemester_kurzbz = $this->input->get('studiensemester_kurzbz'); + $ausbildungssemester = $this->input->get('ausbildungssemester') ?: null; + $orgform_kurzbz = $this->input->get('orgform_kurzbz') ?: null; + + if (!$studiengang_kz || !is_numeric($studiengang_kz)) + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Studiengangskennzahl']), self::ERROR_TYPE_GENERAL); + + if (!$studiensemester_kurzbz) + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Studiensemester']), self::ERROR_TYPE_GENERAL); + + if (isset($ausbildungssemester) && !is_numeric($ausbildungssemester)) + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Ausbildungssemester']), self::ERROR_TYPE_GENERAL); + + + //~ $this->load->library('form_validation'); + + //~ $this->form_validation->set_rules('studiengang_kz', 'StudiengangKz', 'required|numeric'); + //~ $this->form_validation->set_rules('studiensemester_kurzbz', 'StudiensemesterKurbz', 'required'); + //~ $this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'numeric'); + + //~ if (!$this->form_validation->run()) + //~ { + //~ $this->addMeta('fail2', 'fail2'); + //~ return $this->terminateWithValidationErrors($this->form_validation->error_array()); + //~ } + + + $this->addMeta('stg_kz', $studiengang_kz); + $this->addMeta('sem', $studiensemester_kurzbz); + $this->addMeta('sem2', $ausbildungssemester); + $this->addMeta('org', $orgform_kurzbz); + + $result = $this->StudienplanModel->getStudienplaeneBySemester($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester, $orgform_kurzbz); + if (isError($result)) $this->terminateWithError(getError($result), self::ERROR_TYPE_DB); + + $this->terminateWithSuccess(hasData($result) ? getData($result) : []); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Abschlusspruefung.php b/application/controllers/api/frontend/v1/stv/Abschlusspruefung.php index d8bc067f9..def4f6502 100644 --- a/application/controllers/api/frontend/v1/stv/Abschlusspruefung.php +++ b/application/controllers/api/frontend/v1/stv/Abschlusspruefung.php @@ -20,8 +20,6 @@ class Abschlusspruefung extends FHCAPI_Controller 'getBeurteilungen' => ['admin:rw', 'assistenz:rw'], 'getAkadGrade' => ['admin:rw', 'assistenz:rw'], 'getMitarbeiter' => ['admin:rw', 'assistenz:rw'], - 'getAllMitarbeiter' => ['admin:rw', 'assistenz:rw'], - 'getAllPersons' => ['admin:rw', 'assistenz:rw'], 'getPruefer' => ['admin:rw', 'assistenz:rw'], 'getTypStudiengang' => ['admin:rw', 'assistenz:rw'], 'checkForExistingExams' => ['admin:rw', 'assistenz:rw'], @@ -102,35 +100,45 @@ class Abschlusspruefung extends FHCAPI_Controller { $abschlusspruefung_id = $this->input->post('id'); - $this->AbschlusspruefungModel->addSelect('lehre.tbl_abschlusspruefung.*'); - $this->AbschlusspruefungModel->addSelect(" - CASE - WHEN pruefer1 IS NOT NULL - THEN CONCAT(p1.nachname, ' ', p1.vorname, COALESCE(' ' || p1.titelpre, '')) - ELSE NULL - END AS p1 - "); - $this->AbschlusspruefungModel->addSelect(" - CASE - WHEN pruefer2 IS NOT NULL - THEN CONCAT(p2.nachname, ' ', p2.vorname, COALESCE(' ' || p2.titelpre, '')) - ELSE NULL - END AS p2 - "); - $this->AbschlusspruefungModel->addSelect(" - CASE - WHEN pruefer3 IS NOT NULL - THEN CONCAT(p3.nachname, ' ', p3.vorname, COALESCE(' ' || p3.titelpre, '')) - ELSE NULL - END AS p3 - "); - $this->AbschlusspruefungModel->addSelect(" - CASE - WHEN vorsitz IS NOT NULL - THEN CONCAT(pv.nachname, ' ', pv.vorname, COALESCE(' ' || pv.titelpre, ''), ' (', ben.uid , ')' ) - ELSE NULL - END AS pv - "); + $this->AbschlusspruefungModel->addSelect( + 'lehre.tbl_abschlusspruefung.*, + p1.person_id AS p1_person_id, p1.vorname AS p1_vorname, p1.nachname AS p1_nachname, + p1.titelpre AS p1_titelpre, p1.titelpost AS p1_titelpost, + p2.person_id AS p2_person_id, p2.vorname AS p2_vorname, p2.nachname AS p2_nachname, + p2.titelpre AS p2_titelpre, p2.titelpost AS p2_titelpost, + p3.person_id AS p3_person_id, p3.vorname AS p3_vorname, p3.nachname AS p3_nachname, + p3.titelpre AS p3_titelpre, p3.titelpost AS p3_titelpost, + pv.person_id AS pv_person_id, pv.vorname AS pv_vorname, pv.nachname AS pv_nachname, + pv.titelpre AS pv_titelpre, pv.titelpost AS pv_titelpost, ben.uid AS pv_uid' + ); + //~ $this->AbschlusspruefungModel->addSelect(" + //~ CASE + //~ WHEN pruefer1 IS NOT NULL + //~ THEN CONCAT(p1.nachname, ' ', p1.vorname, COALESCE(' ' || p1.titelpre, '')) + //~ ELSE NULL + //~ END AS p1 + //~ "); + //~ $this->AbschlusspruefungModel->addSelect(" + //~ CASE + //~ WHEN pruefer2 IS NOT NULL + //~ THEN CONCAT(p2.nachname, ' ', p2.vorname, COALESCE(' ' || p2.titelpre, '')) + //~ ELSE NULL + //~ END AS p2 + //~ "); + //~ $this->AbschlusspruefungModel->addSelect(" + //~ CASE + //~ WHEN pruefer3 IS NOT NULL + //~ THEN CONCAT(p3.nachname, ' ', p3.vorname, COALESCE(' ' || p3.titelpre, '')) + //~ ELSE NULL + //~ END AS p3 + //~ "); + //~ $this->AbschlusspruefungModel->addSelect(" + //~ CASE + //~ WHEN vorsitz IS NOT NULL + //~ THEN CONCAT(pv.nachname, ' ', pv.vorname, COALESCE(' ' || pv.titelpre, ''), ' (', ben.uid , ')' ) + //~ ELSE NULL + //~ END AS pv + //~ "); $this->AbschlusspruefungModel->addJoin('public.tbl_benutzer ben', 'ON (ben.uid = lehre.tbl_abschlusspruefung.vorsitz)', 'LEFT'); $this->AbschlusspruefungModel->addJoin('public.tbl_person pv', 'ON (pv.person_id = ben.person_id)', 'LEFT'); $this->AbschlusspruefungModel->addJoin('public.tbl_person p1', 'ON (p1.person_id = lehre.tbl_abschlusspruefung.pruefer1)', 'LEFT'); @@ -220,8 +228,10 @@ class Abschlusspruefung extends FHCAPI_Controller $this->terminateWithSuccess($typStudiengang); } - public function getMitarbeiter($searchString) + public function getMitarbeiter() { + $searchString = $this->input->get('searchString') ?? ''; + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); $result = $this->MitarbeiterModel->searchMitarbeiter($searchString, 'mitAkadGrad'); @@ -232,8 +242,10 @@ class Abschlusspruefung extends FHCAPI_Controller $this->terminateWithSuccess($result ?: []); } - public function getPruefer($searchString) + public function getPruefer() { + $searchString = $this->input->get('searchString') ?? ''; + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); $result = $this->MitarbeiterModel->searchMitarbeiter($searchString, 'ohneMaUid'); @@ -444,58 +456,4 @@ class Abschlusspruefung extends FHCAPI_Controller } $this->terminateWithSuccess('step3'); } - - /* - * returns list of all Mitarbeiter - * as key value list to be used in select or autocomplete - */ - public function getAllMitarbeiter() - { - $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); - - $sql = " - SELECT - ma.mitarbeiter_uid as mitarbeiter_uid, - CONCAT(p.nachname, ' ', p.vorname, ' (', ma.mitarbeiter_uid, ')') as label - FROM - public.tbl_mitarbeiter ma - JOIN public.tbl_benutzer bn ON (bn.uid = ma.mitarbeiter_uid) - JOIN public.tbl_person p ON (p.person_id = bn.person_id) - ORDER BY - p.nachname ASC - "; - - $result = $this->MitarbeiterModel->execReadOnlyQuery($sql); - $data = $this->getDataOrTerminateWithError($result); - - $this->terminateWithSuccess($data); - } - - /* - * returns list of all Persons - * as key value list to be used in select or autocomplete - */ - public function getAllPersons() - { - $this->load->model('person/Person_model', 'PersonModel'); - - $sql = " - SELECT - p.vorname, p.nachname, p.person_id, - CONCAT(p.nachname, ' ', p.vorname) as label - FROM - public.tbl_person p - -- JOIN public.tbl_benutzer bn ON (p.person_id = bn.person_id) - -- and bn.aktiv = 'true' - ORDER BY - p.nachname ASC - "; - - //TODO(manu) check if filter active benutzer - - $result = $this->PersonModel->execReadOnlyQuery($sql); - $data = $this->getDataOrTerminateWithError($result); - - $this->terminateWithSuccess($data); - } } diff --git a/application/controllers/api/frontend/v1/stv/Archiv.php b/application/controllers/api/frontend/v1/stv/Archiv.php index cc636951d..6b8388fbb 100644 --- a/application/controllers/api/frontend/v1/stv/Archiv.php +++ b/application/controllers/api/frontend/v1/stv/Archiv.php @@ -39,7 +39,7 @@ class Archiv extends FHCAPI_Controller 'archive' => ['admin:w', 'assistenz:w'], 'download' => ['admin:w', 'assistenz:w'], 'update' => ['admin:w'], - 'delete' => ['admin:w', 'assistenz:w'] + 'delete' => ['admin:w', 'assistenz:w'], ]); // Load models @@ -107,13 +107,9 @@ class Archiv extends FHCAPI_Controller $result = $this->AkteModel->load($akte_id); - if (!hasData($result)) $this->terminateWithError('Akte not found'); - $data = $this->getDataOrTerminateWithError($result); - $data = getData($result)[0]; - //$this->addMeta("daa", $data->inhalt); $fileObj = new stdClass(); if (isset($data->inhalt) && $data->inhalt != '') @@ -133,12 +129,7 @@ class Archiv extends FHCAPI_Controller //header("Content-type: $data->mimetype"); header('Content-Disposition: attachment; filename="'.$data->titel.'"'); readfile($filename); - //echo base64_decode($data->inhalt); die(); - //~ $fileObj->file = $data->inhalt; - //~ $fileObj->name = $data->titel; - //~ $fileObj->mimetype = $data->mimetype; - //~ $fileObj->disposition = 'attachment'; } else { @@ -146,12 +137,6 @@ class Archiv extends FHCAPI_Controller $result = $this->aktelib->get($akte_id); } - - /* $fileObj->filename - * $fileObj->file - * $fileObj->name - * $fileObj->mimetype - * $fileObj->disposition*/ } /** diff --git a/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php b/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php index 86b739c90..26033908d 100644 --- a/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php +++ b/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php @@ -298,7 +298,7 @@ class Aufnahmetermine extends FHCAPI_Controller $reihungstestangetreten = (isset($formData['reihungstestangetreten']) && !empty($formData['reihungstestangetreten'])) ? $formData['reihungstestangetreten'] - : null; + : false; $aufnahmegruppe_kurzbz = (isset($formData['aufnahmegruppe_kurzbz']) && !empty($formData['aufnahmegruppe_kurzbz'])) ? $formData['aufnahmegruppe_kurzbz'] diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index d52016943..17b360f8c 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -33,6 +33,9 @@ class Config extends FHCAPI_Controller { // TODO(chris): permissions parent::__construct([ + 'get' => ['admin:r', 'assistenz:r'], + 'set' => ['admin:r', 'assistenz:r'], + 'filter' => ['admin:r', 'assistenz:r'], 'student' => ['admin:r', 'assistenz:r'], 'students' => ['admin:r', 'assistenz:r'] ]); @@ -45,13 +48,255 @@ class Config extends FHCAPI_Controller 'lehre', 'stv', 'konto', - 'abschlusspruefung' + 'abschlusspruefung', + 'projektarbeit' ]); // Load Config $this->load->config('stv'); } + /** + * get App config + */ + public function get() + { + $this->load->model('system/Variable_model', 'VariableModel'); + $this->load->config('stv'); + + $config = []; + + #number_displayed_past_studiensemester + $result = $this->VariableModel->getVariables(getAuthUID(), ['number_displayed_past_studiensemester']); + $data = $this->getDataOrTerminateWithError($result); + + $number_displayed_past_studiensemester_default = $this->config->item('number_displayed_past_studiensemester_default'); + + $config['number_displayed_past_studiensemester'] = [ + "type" => "number", + "label" => $this->p->t('stv', 'settings_no_displayed_past_sem'), + "value" => $data['number_displayed_past_studiensemester'] + ?? $number_displayed_past_studiensemester_default + ]; + + #font_size + $result = $this->VariableModel->getVariables(getAuthUID(), ['stv_font_size']); + $data = $this->getDataOrTerminateWithError($result); + $config['font_size'] = [ + "type" => "select", + "label" => $this->p->t('stv', 'settings_fontsize'), + "value" => $data['stv_font_size'] ?? "fs_normal", + "options" => [ + "fs_xx-small" => $this->p->t('stv', 'settings_fontsize_xx-small'), + "fs_x-small" => $this->p->t('stv', 'settings_fontsize_x-small'), + "fs_small" => $this->p->t('stv', 'settings_fontsize_small'), + "fs_normal" => $this->p->t('stv', 'settings_fontsize_normal'), + "fs_big" => $this->p->t('stv', 'settings_fontsize_big'), + "fs_huge" => $this->p->t('stv', 'settings_fontsize_huge') + ] + ]; + + #others + Events::trigger('stv_config_get', function & () use (&$config) { + return $config; + }); + + $this->terminateWithSuccess($config); + } + + /** + * set App config + */ + public function set() + { + $this->load->model('system/Variable_model', 'VariableModel'); + $this->load->library('form_validation'); + + $this->form_validation->set_rules( + 'number_displayed_past_studiensemester', + $this->p->t('stv', 'settings_no_displayed_past_sem'), + 'required|integer' + ); + $this->form_validation->set_rules( + 'font_size', + $this->p->t('stv', 'settings_fontsize'), + 'required|in_list[fs_xx-small,fs_x-small,fs_small,fs_normal,fs_big,fs_huge]' + ); + + Events::trigger('stv_config_validation', $this->form_validation); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + + $this->VariableModel->setVariable( + getAuthUID(), + 'number_displayed_past_studiensemester', + $this->input->post('number_displayed_past_studiensemester') + ); + $this->VariableModel->setVariable( + getAuthUID(), + 'stv_font_size', + $this->input->post('font_size') + ); + + Events::trigger('stv_config_set', $this->input); + + $this->terminateWithSuccess(); + } + + /* + * Get the config for the student filters + * + * @return void + */ + public function filter() + { + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + $this->load->model('crm/Buchungstyp_model', 'BuchungstypModel'); + + $this->BuchungstypModel->addOrder('beschreibung'); + + $result = $this->BuchungstypModel->load(); + + $buchungstyp_kurzbz = $this->getDataOrTerminateWithError($result); + $buchungstyp_kurzbz_plus_all = array_merge([[ + 'buchungstyp_kurzbz' => 'all', + 'beschreibung' => $this->p->t('stv', 'konto_all_types') + ]], $buchungstyp_kurzbz); + + $this->load->model('crm/Statusgrund_model', 'StatusgrundModel'); + + $result = $this->StatusgrundModel->getAktiveGruende(); + + $statusgruende = $this->getDataOrTerminateWithError($result); + + $result = []; + + $result[] = [ + 'id' => 'filter_konto_count_0', + 'label' => $this->p->t('stv', 'filter_konto_count_0'), + 'type' => 'konto', + 'fixed' => [ + 'missing' => true, + 'usestdsem' => true + ], + 'dynamic' => [ + 'buchungstyp_kurzbz' => [ + 'type' => 'select', + 'values' => $buchungstyp_kurzbz, + 'value_key' => 'buchungstyp_kurzbz', + 'label_key' => 'beschreibung' + ] + ] + ]; + $result[] = [ + 'id' => 'filter_konto_missing_counter', + 'label' => $this->p->t('stv', 'filter_konto_missing_counter'), + 'type' => 'konto_counter', + 'dynamic' => [ + 'buchungstyp_kurzbz' => [ + 'type' => 'select', + 'values' => $buchungstyp_kurzbz_plus_all, + 'value_key' => 'buchungstyp_kurzbz', + 'label_key' => 'beschreibung' + ], + 'samestg' => [ + 'type' => 'bool', + 'label' => $this->p->t('stv', 'filter_konto_samestg'), + 'default' => $this->variablelib->getVar('kontofilterstg') == 'true' + ] + ] + ]; + $result[] = [ + 'id' => 'filter_documents', + 'label' => $this->p->t('stv', 'filter_documents'), + 'type' => 'documents' + ]; + $result[] = [ + 'id' => 'filter_konto_missing_counter_past', + 'label' => $this->p->t('stv', 'filter_konto_missing_counter_past'), + 'type' => 'konto_counter', + 'fixed' => [ + 'past' => true + ], + 'dynamic' => [ + 'buchungstyp_kurzbz' => [ + 'type' => 'select', + 'values' => $buchungstyp_kurzbz_plus_all, + 'value_key' => 'buchungstyp_kurzbz', + 'label_key' => 'beschreibung' + ], + 'samestg' => [ + 'type' => 'bool', + 'label' => $this->p->t('stv', 'filter_konto_samestg'), + 'default' => $this->variablelib->getVar('kontofilterstg') == 'true' + ] + ] + ]; + $result[] = [ + 'id' => 'filter_konto_missing_studiengebuehr', + 'label' => $this->p->t('stv', 'filter_konto_missing_studiengebuehr'), + 'type' => 'konto', + 'fixed' => [ + 'missing' => true, + 'usestdsem' => true + ], + 'dynamic' => [ + 'buchungstyp_kurzbz' => [ + 'type' => 'select', + 'values' => $buchungstyp_kurzbz, + 'value_key' => 'buchungstyp_kurzbz', + 'label_key' => 'beschreibung' + ] + ] + ]; + $result[] = [ + 'id' => 'filter_konto_studiengebuehrerhoeht', + 'label' => $this->p->t('stv', 'filter_konto_studiengebuehrerhoeht'), + 'type' => 'konto', + 'fixed' => [ + 'usestdsem' => true + ], + 'dynamic' => [ + 'buchungstyp_kurzbz' => [ + 'type' => 'select', + 'values' => $buchungstyp_kurzbz, + 'value_key' => 'buchungstyp_kurzbz', + 'label_key' => 'beschreibung' + ] + ] + ]; + $result[] = [ + 'id' => 'filter_zgv_without_date', + 'label' => $this->p->t('stv', 'filter_zgv_without_date'), + 'type' => 'zgv' + ]; + $result[] = [ + 'id' => 'filter_statusgrund', + 'label' => $this->p->t('stv', 'filter_statusgrund'), + 'type' => 'statusgrund', + 'fixed' => [ + 'usestdsem' => true + ], + 'dynamic' => [ + 'statusgrund_id' => [ + 'type' => 'select', + 'values' => $statusgruende, + 'value_key' => 'statusgrund_id', + 'label_key' => 'bezeichnung' + ] + ] + ]; + + Events::trigger('stv_conf_filter', function & () use (&$result) { + return $result; + }); + + $this->terminateWithSuccess($result); + } + public function student() { $result = []; @@ -59,21 +304,21 @@ class Config extends FHCAPI_Controller $result['details'] = [ 'title' => $this->p->t('stv', 'tab_details'), - 'component' => './Stv/Studentenverwaltung/Details/Details.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Details.js'), 'config' => $config['details'] ]; $result['notes'] = [ 'title' => $this->p->t('stv', 'tab_notes'), - 'component' => './Stv/Studentenverwaltung/Details/Notizen.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Notizen.js'), 'config' => $config['notes'], 'showSuffix' => ($config['notes']['showCountNotes'] ?? false), - 'suffixhelper' => APP_ROOT . 'public/js/helpers/Stv/Studentenverwaltung/Details/Notizen/NotizenSuffixHelper.js' + 'suffixhelper' => absoluteJsImportUrl('public/js/helpers/Stv/Studentenverwaltung/Details/Notizen/NotizenSuffixHelper.js') ]; $result['contact'] = [ 'title' => $this->p->t('stv', 'tab_contact'), - 'component' => './Stv/Studentenverwaltung/Details/Kontakt.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Kontakt.js'), 'config' => [ 'showBankaccount' => $this->permissionlib->isBerechtigt('mitarbeiter/bankdaten') || $this->permissionlib->isBerechtigt('student/bankdaten') @@ -81,20 +326,23 @@ class Config extends FHCAPI_Controller ]; $result['prestudent'] = [ 'title' => $this->p->t('stv', 'tab_prestudent'), - 'component' => './Stv/Studentenverwaltung/Details/Prestudent.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Prestudent.js'), 'config' => $config['prestudent'] ]; $result['status'] = [ 'title' => 'Status', - 'component' => './Stv/Studentenverwaltung/Details/MultiStatus.js' + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/MultiStatus.js'), + 'config' => [ + 'showStatusVorruecken' => defined('STATUS_VORRUECKEN_ANZEIGEN') ? STATUS_VORRUECKEN_ANZEIGEN : true, + ] ]; $result['documents'] = [ 'title' => $this->p->t('stv', 'tab_documents'), - 'component' => './Stv/Studentenverwaltung/Details/Dokumente.js' + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Dokumente.js') ]; $result['banking'] = [ 'title' => $this->p->t('stv', 'tab_banking'), - 'component' => './Stv/Studentenverwaltung/Details/Konto.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Konto.js'), 'config' => [ 'showZahlungsbestaetigung' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN), 'showBuchungsnr' => $this->permissionlib->isBerechtigt('admin'), @@ -106,20 +354,22 @@ class Config extends FHCAPI_Controller ]; $result['resources'] = [ 'title' => $this->p->t('stv', 'tab_resources'), - 'component' => './Stv/Studentenverwaltung/Details/Betriebsmittel.js' + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Betriebsmittel.js'), + 'showOnlyWithUid' => true ]; $result['groups'] = [ 'title' => $this->p->t('stv', 'tab_groups'), - 'component' => './Stv/Studentenverwaltung/Details/Gruppen.js' + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Groups.js'), + 'showOnlyWithUid' => true ]; $result['messages'] = [ 'title' => $this->p->t('stv', 'tab_messages'), - 'component' => './Stv/Studentenverwaltung/Details/Messages.js' + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Messages.js'), ]; $result['grades'] = [ 'title' => $this->p->t('stv', 'tab_grades'), - 'component' => './Stv/Studentenverwaltung/Details/Noten.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Noten.js'), 'showOnlyWithUid' => true, 'config' => [ 'usePoints' => defined('CIS_GESAMTNOTE_PUNKTE') && CIS_GESAMTNOTE_PUNKTE, @@ -132,29 +382,42 @@ class Config extends FHCAPI_Controller $result['exam'] = [ 'title' => $this->p->t('stv', 'tab_exam'), - 'component' => './Stv/Studentenverwaltung/Details/Pruefung.js' + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Pruefung.js'), + 'showOnlyWithUid' => true ]; $result['exemptions'] = [ 'title' => $this->p->t('lehre', 'anrechnungen'), - 'component' => './Stv/Studentenverwaltung/Details/Anrechnungen.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Anrechnungen.js'), 'config' => $config['exemptions'] ]; $result['finalexam'] = [ 'title' => $this->p->t('stv', 'tab_finalexam'), - 'component' => './Stv/Studentenverwaltung/Details/Abschlusspruefung.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Abschlusspruefung.js'), + 'showOnlyWithUid' => true, 'config' => $config['finalexam'] ]; + $result['projektarbeit'] = [ + 'title' => $this->p->t('stv', 'tab_projektarbeit'), + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Projektarbeit.js'), + 'config' => array_merge( + $config['projektarbeit'], + ['showVertragsdetails' => + defined('FAS_STUDIERENDE_PROJEKTARBEIT_VERTRAGSDETAILS_ANZEIGEN') && FAS_STUDIERENDE_PROJEKTARBEIT_VERTRAGSDETAILS_ANZEIGEN] + ) + ]; + $result['mobility'] = [ 'title' => $this->p->t('stv', 'tab_mobility'), - 'component' => './Stv/Studentenverwaltung/Details/Mobility.js' + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Mobility.js'), + 'showOnlyWithUid' => true ]; $result['archive'] = [ 'title' => $this->p->t('stv', 'tab_archive'), - 'component' => './Stv/Studentenverwaltung/Details/Archiv.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Archiv.js'), 'config' => [ 'showEdit' => $this->permissionlib->isBerechtigt('admin') ] @@ -162,22 +425,24 @@ class Config extends FHCAPI_Controller $result['jointstudies'] = [ 'title' => $this->p->t('stv', 'tab_jointstudies'), - 'component' => './Stv/Studentenverwaltung/Details/JointStudies.js' + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/JointStudies.js'), + 'showOnlyWithUid' => true ]; $result['coursedates'] = [ 'title' => $this->p->t('stv', 'tab_courseDates'), - 'component' => './Stv/Studentenverwaltung/Details/Lehrveranstaltungstermine.js' + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Lehrveranstaltungstermine.js') ]; $result['admissionDates'] = [ 'title' => $this->p->t('stv', 'tab_admissionDates'), - 'component' => './Stv/Studentenverwaltung/Details/Aufnahmetermine.js' + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Aufnahmetermine.js') ]; $result['functions'] = [ 'title' => $this->p->t('stv', 'tab_functions'), - 'component' => './Stv/Studentenverwaltung/Details/Funktionen.js' + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Funktionen.js'), + 'showOnlyWithUid' => true ]; Events::trigger('stv_conf_student', function & () use (&$result) { @@ -195,7 +460,7 @@ class Config extends FHCAPI_Controller $config = $this->config->item('tabs'); $result['banking'] = [ 'title' => $this->p->t('stv', 'tab_banking'), - 'component' => './Stv/Studentenverwaltung/Details/Konto.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Konto.js'), 'config' => [ 'showZahlungsbestaetigung' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN), 'showBuchungsnr' => $this->permissionlib->isBerechtigt('admin'), @@ -205,9 +470,14 @@ class Config extends FHCAPI_Controller 'additionalCols' => [] ] ]; + $result['groups'] = [ + 'title' => $this->p->t('stv', 'tab_groups'), + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Groups.js'), + 'showOnlyWithUid' => true + ]; $result['status'] = [ 'title' => 'Status', - 'component' => './Stv/Studentenverwaltung/Details/MultiStatus.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/MultiStatus.js'), 'config' => [ 'changeStatusToAbbrecherStgl' => $this->permissionlib->isBerechtigt('admin'), 'changeStatusToAbbrecherStud' => $this->permissionlib->isBerechtigt('admin'), @@ -218,17 +488,37 @@ class Config extends FHCAPI_Controller ]; $result['finalexam'] = [ 'title' => $this->p->t('stv', 'tab_finalexam'), - 'component' => './Stv/Studentenverwaltung/Details/Abschlusspruefung.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Abschlusspruefung.js'), + 'showOnlyWithUid' => true, 'config' => $config['finalexam'] ]; $result['archive'] = [ 'title' => $this->p->t('stv', 'tab_archive'), - 'component' => './Stv/Studentenverwaltung/Details/Archiv.js', + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Archiv.js'), 'config' => [ 'showEdit' => $this->permissionlib->isBerechtigt('admin') ] ]; + if($this->permissionlib->isBerechtigt('basis/person')) + { + $result['combinePeople'] = [ + 'title' => $this->p->t('stv', 'tab_combine_people'), + 'component' => './Stv/Studentenverwaltung/Details/CombinePeople.js', + 'config' => $config['combinePeople'] + ]; + } + + $result['kontaktieren'] = [ + 'title' => $this->p->t('stv', 'tab_kontaktieren'), + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Kontaktieren.js'), + ]; + + $result['messages'] = [ + 'title' => $this->p->t('stv', 'tab_messages'), + 'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Messages.js'), + ]; + Events::trigger('stv_conf_students', function & () use (&$result) { return $result; }); diff --git a/application/controllers/api/frontend/v1/stv/Dokumente.php b/application/controllers/api/frontend/v1/stv/Dokumente.php index 18c976eb6..8a69d28ab 100644 --- a/application/controllers/api/frontend/v1/stv/Dokumente.php +++ b/application/controllers/api/frontend/v1/stv/Dokumente.php @@ -2,6 +2,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +use \CI3_Events as Events; use \DateTime as DateTime; class Dokumente extends FHCAPI_Controller @@ -19,6 +20,8 @@ class Dokumente extends FHCAPI_Controller 'getDoktypen' => ['admin:r', 'assistenz:r'], 'uploadDokument' => ['admin:rw', 'assistenz:rw'], 'download' => ['admin:rw', 'assistenz:rw'], + 'getDocumentDropDown' => ['admin:rw', 'assistenz:rw'], + 'getDocumentDropDownMulti' => ['admin:rw', 'assistenz:rw'], ]); // Load Libraries @@ -566,4 +569,422 @@ class Dokumente extends FHCAPI_Controller return false; } } + + public function getDocumentDropDown($prestudent_id, $studiensemester_kurzbz, $studiengang_kz) + { + $this->load->helper('hlp_common'); + //permission to create also odt, and doc outputs of certain documents(menu abschlusspruefung) + $hasPermissionOutputformat = $this->permissionlib->isBerechtigt('system/change_outputformat', 's'); + + if (!$prestudent_id) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Prestudent_id']), self::ERROR_TYPE_GENERAL); + if (!$studiensemester_kurzbz) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Studiensemester']), self::ERROR_TYPE_GENERAL); + if(!$studiengang_kz) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Studiengang_kz']), self::ERROR_TYPE_GENERAL); + + + $uid = $this->_loadUIDFromPrestudent($prestudent_id); + $semArray = $this->_getEntriesStudiensemester(); + $stgTyp = $this->_getStudiengangstyp($studiengang_kz); + + $documents = [ + buildDropdownEntryPrintArray("accountinfo", "Accountinfoblatt", "xml=accountinfoblatt.xml.php&xsl=AccountInfo&output=pdf", $uid, 10, null), + buildDropdownEntryPrintArray("ausbildungsvertrag", "Ausbildungsvertrag", "xml=ausbildungsvertrag.xml.php&xsl=Ausbildungsver&output=pdf&prestudent_id=$prestudent_id", null,20, null), + buildDropdownEntryPrintArray("ausbildungsvertrag_en", "Ausbildungsvertrag Zweisprachig", "xml=ausbildungsvertrag.xml.php&xsl=AusbVerEng&output=pdf&prestudent_id=$prestudent_id", null,21, null), + + buildDropdownEntryPrintArray("bescheid", "Bescheid (nur Voransicht)", "xml=abschlusspruefung.rdf.php&xsl_stg_kz=$studiengang_kz&xsl=Bescheid&output=pdf", $uid, 25, null), + buildDropdownEntryPrintArray("diplomasupp", "Diploma Supplement (nur Voransicht)", "xml=diplomasupplement.xml.php&xsl_stg_kz=$studiengang_kz&xsl=DiplSupplement&output=pdf", $uid, 26, null), + + buildDropdownEntryPrintArray("studienbestaetigung", "Studienbestätigung", "xml=student.rdf.php&xsl=Inskription&output=pdf", $uid, 50, null), + buildDropdownEntryPrintArray("studienbestaetigung_en", "Studienbestätigung Englisch", "xml=student.rdf.php&xsl=InskriptionEng&output=pdf", $uid, 51, null), + buildDropdownEntryPrintArray("zutrittskarte", "Zutrittskarte", "xsl=ZutrittskarteStud&output=pdf&data=$uid", $uid,200, "zutrittskarte.php"), + buildDropdownEntryPrintArray("studienblatt", "Studienblatt", "xml=studienblatt.xml.php&xsl=Studienblatt&output=pdf&ss=$studiensemester_kurzbz", $uid, 60, null), + buildDropdownEntryPrintArray("studienblatt_eng", "Studienblatt Englisch", "xml=studienblatt.xml.php&xsl=StudienblattEng&output=pdf&ss=$studiensemester_kurzbz", $uid, 61, null), + + $this->buildStudienerfolgSubmenu("de", $uid, $semArray, $studiensemester_kurzbz), + $this->buildStudienerfolgSubmenu("en", $uid, $semArray, $studiensemester_kurzbz), + $this->buildStudienerfolgSubmenu("de", $uid, $semArray, $studiensemester_kurzbz, true), + $this->buildStudienerfolgSubmenu("en", $uid, $semArray, $studiensemester_kurzbz, true), + + [ + "id" => "submenu_studstatus", + "type" => "submenu", + "name" => "Verwaltung des StudierendenStatus", + "order" => 110, + "data" => [ + buildDropdownEntryPrintArray("Abmeldung", "Abmeldung", "xml=AntragAbmeldung.xml.php&xsl=AntragAbmeldung&prestudent_id=$prestudent_id&output=pdf", $uid, null, null), + buildDropdownEntryPrintArray("Abmeldung durch Stgl", "AntragAbmeldungStgl", "xml=AntragAbmeldungStgl.xml.php&xsl=AntragAbmeldungStgl&prestudent_id=$prestudent_id&output=pdf", $uid, null, null), + buildDropdownEntryPrintArray("Unterbrechung", "Unterbrechung", "xml=AntragUnterbrechung.xml.php&xsl=AntragUnterbrechung&prestudent_id=$prestudent_id&output=pdf", $uid, null, null), + buildDropdownEntryPrintArray("Wiederholung", "Abmeldung durch Ablauf der Wiederholungsfrist", "xml=AntragWiederholung.xml.php&xsl=AntragWiederholung&prestudent_id=$prestudent_id&output=pdf", $uid, null, null), + ] + ], + + //Bakkzeugnis bzw. Diplomzeugnis is just shown in tab final_exam + buildDropdownEntryPrintArray("zeugnis", "Zeugnis", "xml=zeugnis.rdf.php&xsl=Zeugnis&output=pdf&xsl_stg_kz=$studiengang_kz&ss=$studiensemester_kurzbz", $uid, 121, null), + buildDropdownEntryPrintArray("zeugnis_en", "Zeugnis Englisch", "xml=zeugnis.rdf.php&xsl=ZeugnisEng&output=pdf&xsl_stg_kz=$studiengang_kz&ss=$studiensemester_kurzbz", $uid, 122, null), + + + ]; + + Events::trigger('DocumentGenerationDropDown', + // passing $menu per reference + function & () use (&$documents) { + return $documents; + }, + $prestudent_id, + $studiensemester_kurzbz, + $studiengang_kz + ); + + $extraEntries = $this->loadDropDownEntriesBakkOrDipl($stgTyp, $uid); + + $documents = array_merge($documents, $extraEntries); + + usort($documents, function ($a, $b) { + $orderA = isset($a['order']) ? (int)$a['order'] : PHP_INT_MAX; + $orderB = isset($b['order']) ? (int)$b['order'] : PHP_INT_MAX; + return $orderA <=> $orderB; + }); + + $this->terminateWithSuccess($documents); + //return $documents || null; + } + + public function getDocumentDropDownMulti($studiensemester_kurzbz,$studiengang_kz) + { + //permission to create also odt, and doc outputs of certain documents (menu abschlusspruefung) + $hasPermissionOutputformat = $this->permissionlib->isBerechtigt('system/change_outputformat', 's'); + + $studentUids = $this->input->get('studentUids'); + $prestudentIds = []; + + if (is_array($studentUids) && !empty($studentUids)) { + foreach ($studentUids as $uid) { + $prestudent_id = $this-> _loadPrestudentFromUid($uid); + $prestudentIds[] = $prestudent_id; + } + } + else + { + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Array StudentUIDs']), self::ERROR_TYPE_GENERAL); + } + + if (!$studiensemester_kurzbz) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Studiensemester']), self::ERROR_TYPE_GENERAL); + if(!$studiengang_kz) + $this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Studiengang_kz']), self::ERROR_TYPE_GENERAL); + + + $uidString = implode(";", $studentUids); + $prestudentIdsString = implode(";", $prestudentIds); + + $semArray = $this->_getEntriesStudiensemester(); + $stgTyp = $this->_getStudiengangstyp($studiengang_kz); + + $documents = [ + buildDropdownEntryPrintArray("accountinfo", "Accountinfoblatt", "xml=accountinfoblatt.xml.php&xsl=AccountInfo&output=pdf", $uidString, 10, null), + buildDropdownEntryPrintArray("ausbildungsvertrag", "Ausbildungsvertrag", "xml=ausbildungsvertrag.xml.php&xsl=Ausbildungsver&output=pdf", $uidString, 20, null), + buildDropdownEntryPrintArray("ausbildungsvertrag_en", "Ausbildungsvertrag Englisch", "xml=ausbildungsvertrag.xml.php&xsl=AusbVerEng&output=pdf", $uidString, 21, null), + buildDropdownEntryPrintArray("studienbestaetigung", "Studienbestätigung", "xml=student.rdf.php&xsl=Inskription&output=pdf", $uidString, 50, null), + buildDropdownEntryPrintArray("studienbestaetigung_en", "Studienbestätigung Englisch", "xml=student.rdf.php&xsl=InskriptionEng&output=pdf", $uidString, 51, null), + buildDropdownEntryPrintArray("zutrittskarte", "Zutrittskarte", "xsl=ZutrittskarteStud&output=pdf&data=$uidString", $uidString,200, "zutrittskarte.php"), + buildDropdownEntryPrintArray("studienblatt", "Studienblatt", "xml=studienblatt.xml.php&xsl=Studienblatt&output=pdf&ss=$studiensemester_kurzbz", $uidString, 60, null), + buildDropdownEntryPrintArray("studienblatt_eng", "Studienblatt Englisch", "xml=studienblatt.xml.php&xsl=StudienblattEng&output=pdf&ss=$studiensemester_kurzbz", $uidString, 61, null), + + // Studienerfolg Menüs automatisch + $this->buildStudienerfolgSubmenu("de", $uidString, $semArray, $studiensemester_kurzbz), + $this->buildStudienerfolgSubmenu("en", $uidString, $semArray, $studiensemester_kurzbz), + $this->buildStudienerfolgSubmenu("de", $uidString, $semArray, $studiensemester_kurzbz, true), + $this->buildStudienerfolgSubmenu("en", $uidString, $semArray, $studiensemester_kurzbz, true), + + [ + "id" => "submenu_studstatus", + "type" => "submenu", + "name" => "Verwaltung des StudierendenStatus", + "order" => 110, + "data" => [ + buildDropdownEntryPrintArray("Abmeldung", "Abmeldung", "xml=AntragAbmeldung.xml.php&xsl=AntragAbmeldung&prestudent_id=$prestudentIdsString&output=pdf", $uidString, null, null), + buildDropdownEntryPrintArray("Abmeldung durch Stgl", "AntragAbmeldungStgl", "xml=AntragAbmeldungStgl.xml.php&xsl=AntragAbmeldungStgl&prestudent_id=$prestudentIdsString&output=pdf", $uidString, null, null), + buildDropdownEntryPrintArray("Unterbrechung", "Unterbrechung", "xml=AntragUnterbrechung.xml.php&xsl=AntragUnterbrechung&prestudent_id=$prestudentIdsString&output=pdf", $uidString, null, null), + buildDropdownEntryPrintArray("Wiederholung", "Abmeldung durch Ablauf der Wiederholungsfrist", "xml=AntragWiederholung.xml.php&xsl=AntragWiederholung&prestudent_id=$prestudentIdsString&output=pdf", $uidString, null, null), + ] + ], + + buildDropdownEntryPrintArray("diplomasupp", "Diploma Supplement (nur Voransicht)", "xml=diplomasupplement.xml.php&xsl_stg_kz=$studiengang_kz&xsl=DiplSupplement&output=pdf", $uidString, 35, null), + buildDropdownEntryPrintArray("zeugnis", "Zeugnis", "xml=zeugnis.rdf.php&xsl=Zeugnis&output=pdf&xsl_stg_kz=$studiengang_kz&ss=$studiensemester_kurzbz", $uidString, 121, null), + buildDropdownEntryPrintArray("zeugnis_en", "Zeugnis Englisch", "xml=zeugnis.rdf.php&xsl=ZeugnisEng&output=pdf&xsl_stg_kz=$studiengang_kz&ss=$studiensemester_kurzbz", $uidString, 122, null), + ]; + + Events::trigger('DocumentGenerationDropDownMulti', + // passing $menu per reference + function & () use (&$documents) { + return $documents; + }, + $studentUids, + $studiensemester_kurzbz, + $studiengang_kz + ); + + $extraEntries = $this->loadDropDownEntriesBakkOrDipl($stgTyp, $uidString); + + $documents = array_merge($documents, $extraEntries); + + usort($documents, function ($a, $b) { + $orderA = isset($a['order']) ? (int)$a['order'] : PHP_INT_MAX; + $orderB = isset($b['order']) ? (int)$b['order'] : PHP_INT_MAX; + return $orderA <=> $orderB; + }); + + + $this->terminateWithSuccess($documents); + + return $documents || null; + } + + private function _loadUIDFromPrestudent($prestudent_id) + { + if(!$prestudent_id){ + return $this->terminateWithError("no prestudent ID received."); + } + $this->load->model('crm/Student_model', 'StudentModel'); + $result = $this->StudentModel->loadWhere( + ['prestudent_id' => $prestudent_id] + ); + + $data = $this->getDataOrTerminateWithError($result); + $student = current($data); + + return $student->student_uid; + } + + private function _loadPrestudentFromUid($studentUid) + { + + $this->load->model('crm/Student_model', 'StudentModel'); + $result = $this->StudentModel->loadWhere( + ['student_uid' => $studentUid] + ); + + $data = $this->getDataOrTerminateWithError($result); + $student = current($data); + + + return $student->prestudent_id; + } + + /** + * is building an array with studiensemesterkurzb + * actual studiensemester plus the 5 studiensemester in the past + + * @return Array Studiensemester_kurzbz + */ + private function _getEntriesStudiensemester(){ + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->StudiensemesterModel->addPlusMinus(1, 5); + $this->StudiensemesterModel->addOrder('ende', 'DESC'); + $result = $this->StudiensemesterModel->load(); + $data = $this->getDataOrTerminateWithError($result); + + foreach($data as $sem) + { + $semArray[] = $sem->studiensemester_kurzbz; + } + + array_shift($semArray); + + return $semArray; + } + /** + * is returning the typ of Studiengang (Bakk oder Master) + + * @return character eg. 'b' or 'm' + */ + private function _getStudiengangstyp($studiengang_kz) + { + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + + $result = $this->StudiengangModel->loadWhere( + array('studiengang_kz' => $studiengang_kz) + ); + $data = $this->getDataOrTerminateWithError($result); + + $typStudiengang = current($data)->typ; + + return $typStudiengang; + } + + /** + * helper function to create ArrayStructure + * actual studiensemester plus the 5 studiensemester in the past + + * @return Array Studiensemester_kurzbz + */ + private function buildStudienerfolgSubmenu($lang, $uid, $semArray, $studiensemester_kurzbz, $fa = false) + { + $entries = []; + + $xsl = $lang === "de" ? "Studienerfolg" : "StudienerfolgEng"; + $idPrefix = "submenu_studienerfolg_" . $lang . ($fa ? "_fa" : ""); + + $entries[] = buildDropdownEntryPrintArray( + $idPrefix . "_aktuell", + "ausgewähltes Semester", + "xml=studienerfolg.rdf.php&xsl=$xsl&ss=$studiensemester_kurzbz" . ($fa ? "&typ=finanzamt" : ""), + $uid + ); + + //all semester + $entries[] = buildDropdownEntryPrintArray( + $idPrefix . "_all", + "alle Semester", + "xml=studienerfolg.rdf.php&xsl=$xsl&ss=$studiensemester_kurzbz&all=true" . ($fa ? "&typ=finanzamt" : ""), + $uid + ); + + //sem from array + foreach ($semArray as $i => $sem) { + $entries[] = buildDropdownEntryPrintArray( + $idPrefix . ($i === 0 ? "_akt" : "_minus" . $i), + $sem, + "xml=studienerfolg.rdf.php&xsl=$xsl&ss=$sem" . ($fa ? "&typ=finanzamt" : ""), + $uid + ); + + } + $order = 0; + if ($lang === "de" && !$fa) $order = 75; // Studienerfolg + if ($lang === "en" && !$fa) $order = 76; // Studienerfolg Englisch + if ($lang === "de" && $fa) $order = 77; // Studienerfolg Finanzamt + if ($lang === "en" && $fa) $order = 78; // Studienerfolg Finanzamt Englisch + + return [ + "id" => $idPrefix, + "type" => "submenu", + "name" => "Studienerfolg " . ($fa ? " Finanzamt" : "") . ($lang === "de" ? "" : "Englisch") , + "order" => $order, + "data" => $entries, + ]; + } + + private function loadDropDownEntriesFinalExam($hasPermissionOutputformat, $stgTyp, $uid) + { + if ($stgTyp == 'b') + $postfix = 'Bakk'; + else if ($stgTyp == 'm' || $stgTyp == 'd') + $postfix = 'Master'; + else + return []; + + $arrayFinalExam = [ + 'pruefungsprotokoll' => [ + 'de' => [ + 'Bakk' => 'PrProtBA', + 'Master' => 'PrProtMA', + ], + 'en' => [ + 'Bakk' => 'PrProtBAEng', + 'Master' => 'PrProtMAEng', + ], + ], + 'pruefungszeugnis' => [ + 'de' => [ + 'Bakk' => 'Bakkzeugnis', + 'Master' => 'Diplomzeugnis', + ], + 'en' => [ + 'Bakk' => 'BakkzeugnisEng', + 'Master' => 'DiplomzeugnisEng', + ], + ], + 'urkunde' => [ + 'de' => [ + 'Bakk' => 'Bakkurkunde', + 'Master' => 'Diplomurkunde', + ], + 'en' => [ + 'Bakk' => 'BakkurkundeEng', + 'Master' => 'DiplomurkundeEng', + ], + ], + ]; + + $langLabels = [ + "de" => "Deutsch", + "en" => "Englisch" + ]; + + $docLabels = [ + "pruefungsprotokoll" => "Prüfungsprotokoll", + "pruefungszeugnis" => "Zeugnis", + "urkunde" => "Urkunde" + ]; + + $submenuData = []; + if ($hasPermissionOutputformat) { + foreach ($arrayFinalExam as $docType => $langs) { + foreach ($langs as $lang => $types) { + $xsl = $types[$postfix]; + $idPrefix = $docType . "_" . $lang; + + $baseName = $docLabels[$docType] . " " . $langLabels[$lang]; + $baseUrl = "xml=abschlusspruefung.rdf.php&xsl={$xsl}"; + + //3 outputformates + foreach (["pdf", "odt", "docx"] as $format) { + $submenuData[] = buildDropdownEntryPrintArray( + $idPrefix . "_" . $format, + $baseName . " (" . strtoupper($format) . ")", + $baseUrl . "&output=" . $format, + $uid + ); + } + } + } + } + else + { + foreach ($arrayFinalExam as $docType => $langs) { + foreach ($langs as $lang => $types) { + $xsl = $types[$postfix]; // Auswahl Bakk/Master für jeweilige Sprache + $id = $docType . "_" . $lang; + + $name = $docLabels[$docType] . " " . $langLabels[$lang]; + + $url = "xml=abschlusspruefung.rdf.php&xsl=" . $xsl . "&output=pdf"; + + $submenuData[] = buildDropdownEntryPrintArray($id, $name, $url, $uid); + } + } + } + return [ + "id" => "submenu_finalexam", + "type" => "submenu", + "name" => "Abschlussprüfung", + "data" => $submenuData, + "order" => null, + "order" => 80, + ]; + } + + private function loadDropDownEntriesBakkOrDipl($stgTyp, $uid) + { + $entries = []; + + if ($stgTyp == 'b') + { + $entries[] = buildDropdownEntryPrintArray("bakkurkunde", "Bakkurkunde", "xml=abschlusspruefung.rdf.php&xsl=Bakkurkunde&output=pdf", $uid, 22, null); + $entries[] = buildDropdownEntryPrintArray("bakkurkundeEng", "Bakkurkunde Englisch", "xml=abschlusspruefung.rdf.php&xsl=BakkurkundeEng&output=pdf", $uid, 23, null); + } + + if ($stgTyp == 'm' || $stgTyp == 'd') + { + $entries[] = buildDropdownEntryPrintArray("diplomurkunde", "Diplomurkunde", "xml=abschlusspruefung.rdf.php&xsl=Diplomurkunde&output=pdf", $uid, 27, null); + $entries[] = buildDropdownEntryPrintArray("diplomurkundeEng", "Diplomurkunde Englisch", "xml=abschlusspruefung.rdf.php&xsl=DiplomurkundeEng&output=pdf", $uid, 28, null); + } + + return $entries; + } + } diff --git a/application/controllers/api/frontend/v1/stv/GemeinsameStudien.php b/application/controllers/api/frontend/v1/stv/GemeinsameStudien.php index 97dad48fd..8f3d6419a 100644 --- a/application/controllers/api/frontend/v1/stv/GemeinsameStudien.php +++ b/application/controllers/api/frontend/v1/stv/GemeinsameStudien.php @@ -83,7 +83,7 @@ class GemeinsameStudien extends FHCAPI_Controller { $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); - $this->StudiensemesterModel->addOrder('studienjahr_kurzbz', 'DESC'); + $this->StudiensemesterModel->addOrder('start', 'DESC'); $result = $this->StudiensemesterModel->load(); $data = $this->getDataOrTerminateWithError($result); $this->terminateWithSuccess($data); diff --git a/application/controllers/api/frontend/v1/stv/Grades.php b/application/controllers/api/frontend/v1/stv/Grades.php index dd8f53a27..128316d2b 100644 --- a/application/controllers/api/frontend/v1/stv/Grades.php +++ b/application/controllers/api/frontend/v1/stv/Grades.php @@ -60,7 +60,8 @@ class Grades extends FHCAPI_Controller { $this->load->model('codex/Note_model', 'NoteModel'); - $this->NoteModel->addOrder('note'); + $this->NoteModel->addOrder('notenwert', 'ASC'); + $this->NoteModel->addOrder('bezeichnung', 'ASC'); $result = $this->NoteModel->load(); diff --git a/application/controllers/api/frontend/v1/stv/Gruppen.php b/application/controllers/api/frontend/v1/stv/Gruppen.php index c30816f2a..b10cfb328 100644 --- a/application/controllers/api/frontend/v1/stv/Gruppen.php +++ b/application/controllers/api/frontend/v1/stv/Gruppen.php @@ -9,6 +9,8 @@ class Gruppen extends FHCAPI_Controller public function __construct() { parent::__construct([ + 'add' => ['admin:rw', 'assistenz:rw'], + 'search' => ['admin:r', 'assistenz:r'], 'getGruppen' => ['admin:r', 'assistenz:r'], 'deleteGruppe' => ['admin:rw', 'assistenz:rw'], ]); @@ -18,7 +20,9 @@ class Gruppen extends FHCAPI_Controller // Load language phrases $this->loadPhrases([ - 'ui', 'gruppenmanagement' + 'ui', + 'gruppenmanagement', + 'lehre' ]); // Load models @@ -26,15 +30,141 @@ class Gruppen extends FHCAPI_Controller $this->load->model('organisation/Gruppe_model', 'GruppeModel'); } + public function add() + { + $this->load->library("form_validation"); + + $this->form_validation->set_rules( + 'gruppe_kurzbz', + $this->p->t('gruppenmanagement', 'gruppe'), + 'required|is_in_db[organisation/Gruppe_model]', + [ + 'required' => $this->p->t('ui', 'error_fieldRequired'), + 'is_in_db' => $this->p->t('ui', 'error_fieldNotFound') + ] + ); + $this->form_validation->set_rules( + 'uid', + $this->p->t('ui', 'student_uid'), + 'required|is_in_db[crm/Student_model:student_uid]', + [ + 'required' => $this->p->t('ui', 'error_fieldRequired'), + 'is_in_db' => $this->p->t('ui', 'error_fieldNotFound') + ] + ); + $this->form_validation->set_rules( + 'studiensemester_kurzbz', + $this->p->t('lehre', 'studiensemester'), + 'required|is_in_db[organisation/Studiensemester_model]', + [ + 'required' => $this->p->t('ui', 'error_fieldRequired'), + 'is_in_db' => $this->p->t('ui', 'error_fieldNotFound') + ] + ); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $gruppe_kurzbz = $this->input->post('gruppe_kurzbz'); + $uid = $this->input->post('uid'); + $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); + + $result = $this->BenutzergruppeModel->load([ + $gruppe_kurzbz, + $uid + ]); + $benutzergruppe = $this->getDataOrTerminateWithError($result); + + if ($benutzergruppe) { + $this->terminateWithError( + $this->p->t('gruppenmanagement', 'error_alreadyInGroup', [ + 'uid' => $uid, + 'studiensemester_kurzbz' => current($benutzergruppe)->studiensemester_kurzbz + ]), + self::ERROR_TYPE_GENERAL + ); + } + + $result = $this->BenutzergruppeModel->insert([ + 'uid' => $uid, + 'gruppe_kurzbz' => $gruppe_kurzbz, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'insertamum' => date('c'), + 'insertvon' => getAuthUID() + ]); + + $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(); + } + + public function search() + { + $query = $this->input->post('query'); + if (!$query) + $this->terminateWithSuccess([]); + + // add query to where clause + $query = strtoupper($query); + $query = $this->GruppeModel->db->escape_like_str($query); + $query = '%' . str_replace(' ', '%', $query) . '%'; + + $this->GruppeModel->db->group_start(); + $this->GruppeModel->db->or_like('UPPER(gruppe_kurzbz)', $query, 'none', false); + $this->GruppeModel->db->or_like('UPPER(bezeichnung)', $query, 'none', false); + $this->GruppeModel->db->or_like('UPPER(beschreibung)', $query, 'none', false); + $this->GruppeModel->db->group_end(); + + // add stg sorting 1 + $studiengang_kz = $this->input->post('studiengang_kz'); + $sort_stg = $studiengang_kz ? "WHEN studiengang_kz = " . $this->GruppeModel->escape($studiengang_kz) . " THEN 0" : ""; + + // add stg sorting 2 + $studiengang_kzs = []; + $result = $this->permissionlib->getSTG_isEntitledFor('admin'); + if ($result) + $studiengang_kzs = array_merge($studiengang_kzs, $result); + $result = $this->permissionlib->getSTG_isEntitledFor('assistenz'); + if ($result) + $studiengang_kzs = array_merge($studiengang_kzs, $result); + + // selects + $this->GruppeModel->addSelect("*"); + $this->GruppeModel->addSelect("CASE + " . $sort_stg . " + WHEN studiengang_kz IN (" . implode(",", $this->GruppeModel->db->escape($studiengang_kzs)) . ") + THEN 1 + ELSE 2 + END AS sort_stg"); + + // ordering + $this->GruppeModel->addOrder("sort_stg"); + $this->GruppeModel->addOrder("sort"); + $this->GruppeModel->addOrder("gruppe_kurzbz"); + + // default where clause & execute + $result = $this->GruppeModel->loadWhere([ + 'lehre' => true, + 'sichtbar' => true, + 'aktiv' => true, + 'direktinskription' => false, + 'generiert' => false + ]); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + public function getGruppen($student_uid) { - $this->BenutzergruppeModel ->addSelect('gruppe_kurzbz'); - $this->BenutzergruppeModel ->addSelect('bezeichnung'); - $this->BenutzergruppeModel ->addSelect('generiert'); - $this->BenutzergruppeModel ->addSelect('uid'); - $this->BenutzergruppeModel ->addSelect('studiensemester_kurzbz'); - $this->BenutzergruppeModel ->addJoin('public.tbl_gruppe', 'gruppe_kurzbz'); - $this->BenutzergruppeModel-> addOrder('bezeichnung', 'ASC'); + $this->BenutzergruppeModel->addSelect('gruppe_kurzbz'); + $this->BenutzergruppeModel->addSelect('bezeichnung'); + $this->BenutzergruppeModel->addSelect('generiert'); + $this->BenutzergruppeModel->addSelect('uid'); + $this->BenutzergruppeModel->addSelect('studiensemester_kurzbz'); + $this->BenutzergruppeModel->addJoin('public.tbl_gruppe', 'gruppe_kurzbz'); + $this->BenutzergruppeModel->addOrder('bezeichnung', 'ASC'); $result = $this->BenutzergruppeModel->loadWhere( array( @@ -49,29 +179,48 @@ class Gruppen extends FHCAPI_Controller public function deleteGruppe() { - $student_uid = $this->input->post('id'); + $this->load->library("form_validation"); + + $this->form_validation->set_rules( + 'uid', + $this->p->t('person', 'UID'), + 'required', + [ + 'required' => $this->p->t('ui', 'error_fieldRequired') + ] + ); + + $this->form_validation->set_rules( + 'gruppe_kurzbz', + $this->p->t('gruppenmanagement', 'gruppe'), + 'required', + [ + 'required' => $this->p->t('ui', 'error_fieldRequired') + ] + ); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $uid = $this->input->post('uid'); $gruppe_kurzbz = $this->input->post('gruppe_kurzbz'); - //Validate if automatic group generation - $result = $this->GruppeModel-> loadWhere( - array( - 'gruppe_kurzbz' => $gruppe_kurzbz - ) - ); + // Validate if automatic group generation + $result = $this->GruppeModel->loadWhere([ + 'gruppe_kurzbz' => $gruppe_kurzbz + ]); $data = $this->getDataOrTerminateWithError($result); $generation = current($data); - if($generation->generiert) + if ($generation->generiert) { $this->terminateWithError($this->p->t('gruppenmanagement', 'error_deleteGeneratedGroups'), self::ERROR_TYPE_GENERAL); } - $result = $this->BenutzergruppeModel->delete( - array( - 'gruppe_kurzbz' => $gruppe_kurzbz, - 'uid' => $student_uid - ) - ); + $result = $this->BenutzergruppeModel->delete([ + 'gruppe_kurzbz' => $gruppe_kurzbz, + 'uid' => $uid + ]); $data = $this->getDataOrTerminateWithError($result); diff --git a/application/controllers/api/frontend/v1/stv/Kontakt.php b/application/controllers/api/frontend/v1/stv/Kontakt.php index 3a8268775..d246a04d9 100644 --- a/application/controllers/api/frontend/v1/stv/Kontakt.php +++ b/application/controllers/api/frontend/v1/stv/Kontakt.php @@ -52,6 +52,7 @@ class Kontakt extends FHCAPI_Controller // Extra Permissionchecks $permsMa = []; $permsStud = []; + $permsDefault = null; switch ($this->router->method) { case 'getBankverbindung': case 'loadBankverbindung': @@ -68,7 +69,7 @@ class Kontakt extends FHCAPI_Controller case 'getKontakte': case 'loadAddress': case 'loadContact': - $permsMa = $permsStud = ['admin:r', 'assistenz:r']; + $permsMa = $permsStud = $permsDefault = ['admin:r', 'assistenz:r']; break; case 'addNewAddress': case 'addNewContact': @@ -76,7 +77,7 @@ class Kontakt extends FHCAPI_Controller case 'updateContact': case 'deleteAddress': case 'deleteContact': - $permsMa = $permsStud = ['admin:rw', 'assistenz:rw']; + $permsMa = $permsStud = $permsDefault = ['admin:rw', 'assistenz:rw']; break; } if ($this->router->method == 'getAdressen' @@ -91,7 +92,7 @@ class Kontakt extends FHCAPI_Controller if (is_null($person_id) || !ctype_digit((string)$person_id)) $this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL); - $this->checkPermissionsForPerson($person_id, $permsMa, $permsStud); + $this->checkPermissionsForPerson($person_id, $permsMa, $permsStud, $permsDefault); } elseif ($this->router->method == 'loadAddress' || $this->router->method == 'loadContact' || $this->router->method == 'loadBankverbindung' @@ -135,7 +136,7 @@ class Kontakt extends FHCAPI_Controller $person_id = current($data)->person_id; - $this->checkPermissionsForPerson($person_id, $permsMa, $permsStud); + $this->checkPermissionsForPerson($person_id, $permsMa, $permsStud, $permsDefault); } } public function getAdressen($person_id) diff --git a/application/controllers/api/frontend/v1/stv/Konto.php b/application/controllers/api/frontend/v1/stv/Konto.php index a33680ea0..384452f3e 100644 --- a/application/controllers/api/frontend/v1/stv/Konto.php +++ b/application/controllers/api/frontend/v1/stv/Konto.php @@ -352,7 +352,7 @@ class Konto extends FHCAPI_Controller continue; } - + $result = $this->KontoModel->insert([ 'person_id' => $buchung['person_id'], 'studiengang_kz' => $buchung['studiengang_kz'], @@ -361,7 +361,7 @@ class Konto extends FHCAPI_Controller 'buchungstyp_kurzbz' => $buchung['buchungstyp_kurzbz'], 'credit_points' => $buchung['credit_points'], 'zahlungsreferenz' => $buchung['zahlungsreferenz'], - 'betrag' => $betrag, + 'betrag' => number_format($betrag, 2, '.', ''), 'buchungsdatum' => $buchungsdatum, 'mahnspanne' => '0', 'buchungsnr_verweis' => $buchung['buchungsnr'], diff --git a/application/controllers/api/frontend/v1/stv/Lehrverband.php b/application/controllers/api/frontend/v1/stv/Lehrverband.php new file mode 100644 index 000000000..72610dd63 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Lehrverband.php @@ -0,0 +1,63 @@ + ['admin:r', 'assistenz:r'], + 'getTree' => ['admin:r', 'assistenz:r'], + 'getSpecialgroups' => ['admin:r', 'assistenz:r'] + ]); + } + + public function hasOrgforms($studiengang_kz) + { + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + + $result = $this->StudiengangModel->load($studiengang_kz); + + $data = $this->getDataOrTerminateWithError($result); + if ($data) { + $data = current($data)->mischform; + } + + $this->terminateWithSuccess($data); + } + + public function getTree($studiengang_kz) + { + $this->load->model('organisation/Lehrverband_model', 'LehrverbandModel'); + + $result = $this->LehrverbandModel->loadWhere([ + 'studiengang_kz' => $studiengang_kz, + 'aktiv' => true + ]); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getSpecialgroups($studiengang_kz) + { + $this->load->model('organisation/Gruppe_model', 'GruppeModel'); + + $where = [ + 'studiengang_kz' => $studiengang_kz, + 'lehre' => true, + 'sichtbar' => true, + 'aktiv' => true, + 'direktinskription' => false + ]; + + $result = $this->GruppeModel->loadWhere($where); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Projektarbeit.php b/application/controllers/api/frontend/v1/stv/Projektarbeit.php new file mode 100644 index 000000000..db7d99752 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Projektarbeit.php @@ -0,0 +1,410 @@ + ['admin:r', 'assistenz:r'], + 'loadProjektarbeit' => ['admin:r', 'assistenz:r'], + 'insertProjektarbeit' => ['admin:rw', 'assistenz:rw'], + 'updateProjektarbeit' => ['admin:rw', 'assistenz:rw'], + 'deleteProjektarbeit' => ['admin:rw', 'assistenz:rw'], + 'getTypenProjektarbeit' => ['admin:r', 'assistenz:r'], + 'getFirmen' => ['admin:r', 'assistenz:r'], + 'getLehrveranstaltungen' => ['admin:r', 'assistenz:r'], + 'getNoten' => ['admin:r', 'assistenz:r'], + 'getStudiensemester' => ['admin:r', 'assistenz:r'] + ]); + + // Load Libraries + $this->load->library('form_validation'); + + // Load language phrases + $this->loadPhrases([ + 'ui', + 'person', + 'projektarbeit' + ]); + + // Load models + $this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel'); + $this->load->model('education/Projekttyp_model', 'ProjekttypModel'); + $this->load->model('education/Paabgabe_model', 'PaabgabeModel'); + $this->load->model('ressource/Firma_model', 'FirmaModel'); + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $this->load->model('education/Lehreinheit_model', 'LehreinheitModel'); + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); + $this->load->model('education/Note_model', 'NoteModel'); + $this->load->model('education/Projektbetreuer_model', 'BetreuerModel'); + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + // load libraries + $this->load->library('PermissionLib'); + } + + /** + * Get projekt works for a uid. + */ + public function getProjektarbeit() + { + $student_uid = $this->input->get('uid'); + + if (!isset($student_uid)) $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Student UID']), self::ERROR_TYPE_GENERAL); + + $result = $this->ProjektarbeitModel->getProjektarbeit($student_uid); + + if (isError($result)) $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + if (!hasData($result)) $this->terminateWithSuccess([]); + + $projektarbeiten = getData($result); + + foreach ($projektarbeiten as $projektarbeit) + { + $projektarbeit_id = $projektarbeit->projektarbeit_id; + $abgabeRes = $this->PaabgabeModel->getEndabgabe($projektarbeit_id); + + if (isError($abgabeRes)) $this->terminateWithError(getError($abgabeRes), self::ERROR_TYPE_GENERAL); + + if (hasData($abgabeRes)) + { + $paabgabe = getData($abgabeRes)[0]; + $projektarbeit->abgabedatum = $paabgabe->abgabedatum; + } + } + + $this->terminateWithSuccess($projektarbeiten); + } + + /** + * Load a single Projektarbeit by id. + */ + public function loadProjektarbeit() + { + $projektarbeit_id = $this->input->get('projektarbeit_id'); + + if (!isset($projektarbeit_id) || !is_numeric($projektarbeit_id)) return $this->terminateWithError('Projektarbeit Id missing', self::ERROR_TYPE_GENERAL); + + $this->ProjektarbeitModel->addSelect( + 'lehre.tbl_projektarbeit.projektarbeit_id, titel, titel_english, themenbereich, projekttyp_kurzbz, lehrveranstaltung_id, lehreinheit_id, + firma_id, beginn, ende, gesperrtbis, note, final, freigegeben, tbl_projektarbeit.anmerkung, fa.name AS firma_name' + ); + $this->ProjektarbeitModel->addJoin('lehre.tbl_lehreinheit le', 'lehreinheit_id'); + $this->ProjektarbeitModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'lehrveranstaltung_id'); + $this->ProjektarbeitModel->addJoin('public.tbl_firma fa', 'firma_id', 'LEFT'); + $result = $this->ProjektarbeitModel->loadWhere( + array('projektarbeit_id' => $projektarbeit_id) + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(current($data)); + } + + /** + * Inwert a Projektarbeit. + */ + public function insertProjektarbeit() + { + $student_uid = $this->input->post('uid'); + + if (!$student_uid) return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Student UID']), self::ERROR_TYPE_GENERAL); + + if (!$this->_hasBerechtigungForStudent($student_uid)) + return $this->_outputAuthError([$this->router->method => ['admin:rw', 'assistenz:rw']]); + + $formData = $this->input->post('formData'); + + if ($this->_validate($formData) == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $projektarbeit = $this->_getProjektarbeitArr($formData); + + $result = $this->ProjektarbeitModel->insert( + array_merge($projektarbeit, ['insertamum' => date('c'), 'insertvon' => getAuthUID(), 'student_uid' => $student_uid]) + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * Update a Projektarbeit by ID. + */ + public function updateProjektarbeit() + { + $projektarbeit_id = $this->input->post('projektarbeit_id'); + + if (!$projektarbeit_id || !is_numeric($projektarbeit_id)) + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Projektarbeit ID']), self::ERROR_TYPE_GENERAL); + + if (!$this->ProjektarbeitModel->hasBerechtigungForProjektarbeit($projektarbeit_id)) + return $this->_outputAuthError([$this->router->method => ['admin:rw', 'assistenz:rw']]); + + $formData = $this->input->post('formData'); + + if ($this->_validate($formData) == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $projektarbeit = $this->_getProjektarbeitArr($formData); + + $result = $this->ProjektarbeitModel->update( + $projektarbeit_id, + array_merge($projektarbeit, ['updateamum' => date('c'), 'updatevon' => getAuthUID()]) + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * Delete Projektarbeit by ID after validation. + */ + public function deleteProjektarbeit() + { + $projektarbeit_id = $this->input->post('projektarbeit_id'); + + if (!isset($projektarbeit_id) || !is_numeric($projektarbeit_id)) + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Projektarbeit ID'], self::ERROR_TYPE_GENERAL)); + + if (!$this->ProjektarbeitModel->hasBerechtigungForProjektarbeit($projektarbeit_id)) + return $this->_outputAuthError([$this->router->method => ['admin:rw', 'assistenz:rw']]); + + $validate = $this->_validateDelete($projektarbeit_id); + + if (isError($validate)) return $this->terminateWithError(getError($validate), self::ERROR_TYPE_GENERAL); + + $result = $this->ProjektarbeitModel->delete( + ['projektarbeit_id' => $projektarbeit_id] + ); + + if (isError($result)) return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + if (!hasData($result)) + { + $this->outputJson($result); + } + + return $this->terminateWithSuccess(current(getData($result)) ? : null); + } + + /** + * Get all active projekt work types. + */ + public function getTypenProjektarbeit() + { + $result = $this->ProjekttypModel->loadWhere(['aktiv' => true]); + + if (isError($result)) return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + return $this->terminateWithSuccess(hasData($result) ? getData($result) : []); + } + + /** + * Gets companies by search string. + */ + public function getFirmen() + { + $searchString = $this->input->get('searchString'); + + if (!isset($searchString)) + $this->terminateWithError($this->p->t('ui', 'error_fieldRequired', ['field' => 'Search term']), self::ERROR_TYPE_GENERAL); + + $result = $this->FirmaModel->searchFirmen($searchString, $aktiv = true); + + if (isError($result)) return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + return $this->terminateWithSuccess(hasData($result) ? getData($result) : []); + } + + /** + * Get Lehrveranstaltungen by params, incling lehreinheiten for a specific Studiensemester.. + */ + public function getLehrveranstaltungen() + { + $student_uid = $this->input->get('student_uid'); + $studiengang_kz = $this->input->get('studiengang_kz'); + $studiensemester_kurzbz = $this->input->get('studiensemester_kurzbz'); + $additional_lehrveranstaltung_id = $this->input->get('additional_lehrveranstaltung_id'); + + if (!isset($student_uid)) $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Student UID']), self::ERROR_TYPE_GENERAL); + if (!isset($studiensemester_kurzbz)) $this->terminateWithError('Studiensemster missing', self::ERROR_TYPE_GENERAL); + + // get Lvs + $lvsResult = $this->LehrveranstaltungModel->getLvsForProjektarbeit($student_uid, $studiengang_kz, $additional_lehrveranstaltung_id); + + if (isError($lvsResult)) return $this->terminateWithError($lvsResult, self::ERROR_TYPE_GENERAL); + + $lvs = hasData($lvsResult) ? getData($lvsResult) : []; + + foreach ($lvs as $lv) + { + // add Lehreinheiten for each Lv for the semester + $lehreinheiten = $this->LehreinheitModel->getLesForLv( + $lv->lehrveranstaltung_id, $studiensemester_kurzbz + ); + + foreach ($lehreinheiten as $lehreinheit) + { + if (!isEmptyArray($lehreinheit->lektoren)) + { + $this->MitarbeiterModel->addSelect('kurzbz'); + $this->MitarbeiterModel->db->where_in('tbl_mitarbeiter.mitarbeiter_uid', $lehreinheit->lektoren); + $maResult = $this->MitarbeiterModel->load(); + + if (isError($maResult)) return $this->terminateWithError($lvsResult, self::ERROR_TYPE_GENERAL); + + $lehreinheit->lektoren = array_column(getData($maResult), 'kurzbz'); + } + } + + $lv->lehreinheiten = $lehreinheiten; + } + + return $this->terminateWithSuccess($lvs); + } + + /** + * Get all noten. + */ + public function getNoten() + { + $result = $this->NoteModel->load(); + + if (isError($result)) return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + return $this->terminateWithSuccess(hasData($result) ? getData($result) : []); + } + + /** + * Get all Studiensemester, sorted. + */ + public function getStudiensemester() + { + $this->StudiensemesterModel->addOrder('start', 'DESC'); + $result = $this->StudiensemesterModel->load(); + + if (isError($result)) return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + return $this->terminateWithSuccess(hasData($result) ? getData($result) : []); + } + + /** + * Validate Projektarbeit data. + * @param formData + * @return bool true if data valid + */ + private function _validate($formData) + { + $this->form_validation->set_data($formData); + + $this->form_validation->set_rules('projekttyp_kurzbz', 'Projekttyp', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Projekttyp']) + ]); + + $this->form_validation->set_rules('lehreinheit_id', 'Lehreinheit', 'required|is_natural', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehreinheit']), + 'is_natural' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Lehreinheit']) + ]); + + $this->form_validation->set_rules('beginn', 'Beginn', 'is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Beginn']) + ]); + + $this->form_validation->set_rules('ende', 'Ende', 'is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Ende']) + ]); + + $this->form_validation->set_rules('gesperrtbis', 'Ende', 'is_valid_date', [ + 'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Gesperrt bis']) + ]); + + return $this->form_validation->run(); + } + + /** + * Extract Projektarbeit data from passed form data. + * @param formData + * @return array + */ + private function _getProjektarbeitArr($formData) + { + return [ + 'titel' => $formData['titel'], + 'titel_english' => $formData['titel_english'] ?? null, + 'themenbereich' => $formData['themenbereich'] ?? null, + 'projekttyp_kurzbz' => $formData['projekttyp_kurzbz'], + 'firma_id' => $formData['firma_id'] ?? null, + 'lehreinheit_id' => $formData['lehreinheit_id'], + 'beginn' => isset($formData['beginn']) && !isEmptyString($formData['beginn']) ? $formData['beginn'] : null, + 'ende' => isset($formData['ende']) && !isEmptyString($formData['ende']) ? $formData['ende'] : null, + 'note' => $formData['note'] ?? null, + 'final' => $formData['final'] ?? null, + 'freigegeben' => $formData['freigegeben'] ?? null, + 'anmerkung' => $formData['anmerkung'] ?? null, + 'gesperrtbis' => isset($formData['gesperrtbis']) && !isEmptyString($formData['gesperrtbis']) ? $formData['gesperrtbis'] : null + ]; + } + + /** + * Check if deletion of a Projektarbeit is possible. + * @param $projektarbeit_id + * @return object success if deletion possible, error otherwise. + */ + private function _validateDelete($projektarbeit_id) + { + $this->BetreuerModel->addSelect('1'); + $result = $this->BetreuerModel->loadWhere(['projektarbeit_id' => $projektarbeit_id]); + + if (isError($result)) return $result; + + if (hasData($result)) return error($this->p->t('projektarbeit', 'error_betreuerNichtGeloescht')); + + $this->PaabgabeModel->addSelect('1'); + $result = $this->PaabgabeModel->loadWhere(['projektarbeit_id' => $projektarbeit_id]); + + if (isError($result)) return $result; + + if (hasData($result)) return error($this->p->t('projektarbeit', 'error_paabgabeNichtGeloescht')); + + return success(); + } + + /** + * Checks permissions for a student. + * @param $student_uid + * @return bool true if authorized + */ + private function _hasBerechtigungForStudent($student_uid) + { + if (!$student_uid) + return false; + + $this->load->model('crm/Student_model', 'StudentModel'); + + $this->StudentModel->addSelect('studiengang_kz'); + $result = $this->StudentModel->load([$student_uid]); + if (isError($result) || !hasData($result)) + return false; + + $studiengang_kz = getData($result)[0]->studiengang_kz; + + if ($this->permissionlib->isBerechtigt('admin', 'suid', $studiengang_kz)) + return true; + if ($this->permissionlib->isBerechtigt('assistenz', 'suid', $studiengang_kz)) + return true; + + return false; + } +} diff --git a/application/controllers/api/frontend/v1/stv/Projektbetreuer.php b/application/controllers/api/frontend/v1/stv/Projektbetreuer.php new file mode 100644 index 000000000..904fa6167 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Projektbetreuer.php @@ -0,0 +1,435 @@ + ['admin:r', 'assistenz:r'], + 'saveProjektbetreuer' => ['admin:rw', 'assistenz:rw'], + 'deleteProjektbetreuer' => ['admin:rw', 'assistenz:rw'], + 'getBetreuerarten' => ['admin:r', 'assistenz:r'], + 'getNoten' => ['admin:r', 'assistenz:r'], + 'getDefaultStundensaetze' => ['admin:r', 'assistenz:r'], + 'getProjektbetreuerBySearchQuery' => ['admin:r', 'assistenz:r'], + 'getPerson' => ['admin:r', 'assistenz:r'], + 'validateProjektbetreuer' => ['admin:r', 'assistenz:r'] + ]); + + // Load Libraries + $this->load->library('form_validation'); + + // Load language phrases + $this->loadPhrases([ + 'ui', + 'person', + 'projektarbeit' + ]); + + // Load models + $this->load->model('education/Projektbetreuer_model', 'ProjektbetreuerModel'); + $this->load->model('education/Betreuerart_model', 'BetreuerartModel'); + $this->load->model('ressource/Stundensatz_model', 'StundensatzModel'); + $this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel'); + $this->load->model('education/Note_model', 'NoteModel'); + $this->load->model('person/Person_model', 'PersonModel'); + + // load libraries + $this->load->library('PermissionLib'); + } + + /** + * Gets Projektbetreuer data for a Projektarbeit. + */ + public function getProjektbetreuer() + { + $projektarbeit_id = $this->input->get('projektarbeit_id'); + + if (!isset($projektarbeit_id)) + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Projektarbeit ID']), self::ERROR_TYPE_GENERAL); + + $qry = " + SELECT * FROM ( + SELECT + projektarbeit_id, person_id, nachname, vorname, note, punkte, round(stunden, 1) AS stunden, + stundensatz, betreuerart_kurzbz, vertrag_id, titelpre, titelpost, + CASE + WHEN EXISTS + (SELECT 1 FROM public.tbl_benutzer JOIN public.tbl_mitarbeiter ON(uid=mitarbeiter_uid) WHERE person_id=pers.person_id) + THEN 'Mitarbeiter' + WHEN EXISTS + (SELECT 1 FROM public.tbl_benutzer JOIN public.tbl_student ON(uid=student_uid) WHERE person_id=pers.person_id) + THEN 'Student' + ELSE 'Person' + END AS status + FROM + lehre.tbl_projektbetreuer + JOIN public.tbl_person pers USING (person_id) + WHERE + projektarbeit_id = ? + ) betreuer + ORDER BY + CASE WHEN status = 'Mitarbeiter' THEN 0 WHEN status = 'Person' THEN 1 ELSE 2 END"; + + $result = $this->ProjektbetreuerModel->execReadOnlyQuery($qry, [$projektarbeit_id]); + + if (isError($result)) $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + if (!hasData($result)) $this->terminateWithSuccess([]); + + $projektbetreuer = getData($result); + + //~ foreach ($projektbetreuer as $projektarbeit) + //~ { + //~ $projektarbeit_id = $projektarbeit->projektarbeit_id; + //~ $abgabeRes = $this->PaabgabeModel->getEndabgabe($projektarbeit_id); + + //~ if (isError($abgabeRes)) $this->terminateWithError(getError($abgabeRes), self::ERROR_TYPE_GENERAL); + + //~ if (hasData($abgabeRes)) + //~ { + //~ $paabgabe = getData($abgabeRes)[0]; + //~ $projektarbeit->abgabedatum = $paabgabe->abgabedatum; + //~ } + //~ } + + // add thesis download link (from external extension) + foreach ($projektbetreuer as $pb) + { + $downloadLink = null; + Events::trigger( + 'projektbeurteilung_download_link', + $pb->projektarbeit_id, + $pb->betreuerart_kurzbz, + $pb->person_id, + function ($value) use (&$downloadLink) { + $downloadLink = $value; + } + ); + $pb->beurteilungDownloadLink = $downloadLink; + } + + $this->terminateWithSuccess($this->_addFullNameToBetreuer($projektbetreuer)); + } + + /** + * Saves (adds or updates) a single Projektbetreuer for a Projektarbeit. + */ + public function saveProjektbetreuer() + { + $projektarbeit_id = $this->input->post('projektarbeit_id'); + + if (!isset($projektarbeit_id) || !is_numeric($projektarbeit_id)) + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Projektarbeit ID']), self::ERROR_TYPE_GENERAL); + + if (!$this->ProjektarbeitModel->hasBerechtigungForProjektarbeit($projektarbeit_id)) + return $this->_outputAuthError([$this->router->method => ['admin:rw', 'assistenz:rw']]); + + $projektbetreuer = $this->input->post('projektbetreuer'); + + if ($this->_validate($projektbetreuer) == false) $this->terminateWithValidationErrors($this->form_validation->error_array()); + + // check if assessor has already been assigned + if (isset($projektbetreuer['person_id'])) + { + $this->ProjektbetreuerModel->addSelect('1'); + $betreuerRes = $this->ProjektbetreuerModel->loadWhere( + [ + 'person_id' => $projektbetreuer['person_id'], + 'projektarbeit_id' => $projektbetreuer['projektarbeit_id'], + 'betreuerart_kurzbz' => $projektbetreuer['betreuerart_kurzbz'] + ] + ); + + if (hasData($betreuerRes) + && (!isset($projektbetreuer['person_id_old']) || $projektbetreuer['person_id'] != $projektbetreuer['person_id_old'])) { + return $this->terminateWithError($this->p->t('projektarbeit', 'betreuerZugewiesen'), self::ERROR_TYPE_GENERAL); + } + } + + $result = null; + + $stunden = isset($projektbetreuer['stunden']) && !isEmptyString($projektbetreuer['stunden']) ? $projektbetreuer['stunden'] : null; + $stundensatz = + isset($projektbetreuer['stundensatz']) && !isEmptyString($projektbetreuer['stundensatz']) ? $projektbetreuer['stundensatz'] : null; + + $betreuer = [ + 'projektarbeit_id' => $projektarbeit_id, + 'person_id' => $projektbetreuer['person_id'], + 'note' => $projektbetreuer['note'], + 'stunden' => $stunden, + 'stundensatz' => $stundensatz, + 'betreuerart_kurzbz' => $projektbetreuer['betreuerart_kurzbz'] + ]; + + if (isset($projektbetreuer['person_id_old']) && isset($projektbetreuer['betreuerart_kurzbz_old'])) + { + $result = $this->ProjektbetreuerModel->update( + [ + 'projektarbeit_id' => $projektarbeit_id, + 'person_id' => $projektbetreuer['person_id_old'], + 'betreuerart_kurzbz' => $projektbetreuer['betreuerart_kurzbz_old'] + ], + array_merge($betreuer, ['updateamum' => date('c'), 'updatevon' => getAuthUID()]) + ); + } + else + { + $result = $this->ProjektbetreuerModel->insert( + array_merge($betreuer, ['insertamum' => date('c'), 'insertvon' => getAuthUID()]) + ); + } + + if (isError($result)) $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + $this->terminateWithSuccess(hasData($result) ? getData($result) : []); + } + + /** + * Delete a Projektbetreuer assignment to a Projektarbeit. + */ + public function deleteProjektbetreuer() + { + $projektarbeit_id = $this->input->post('projektarbeit_id'); + $person_id = $this->input->post('person_id'); + $betreuerart_kurzbz = $this->input->post('betreuerart_kurzbz'); + + if (!isset($projektarbeit_id) || !is_numeric($projektarbeit_id)) + { + return $this->terminateWithError( + $this->p->t('ui', 'error_missingId', ['id'=> $this->p->t('projektarbeit', 'projektarbeit').' ID'], self::ERROR_TYPE_GENERAL) + ); + } + + if (!isset($person_id) || !is_numeric($person_id)) + return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person ID'], self::ERROR_TYPE_GENERAL)); + + if (!isset($betreuerart_kurzbz)) + { + return $this->terminateWithError( + $this->p->t('ui', 'error_missingId', ['id'=> $this->p->t('projektarbeit', 'betreuerart')], self::ERROR_TYPE_GENERAL) + ); + } + + // check permission + if (!$this->ProjektarbeitModel->hasBerechtigungForProjektarbeit($projektarbeit_id)) + return $this->_outputAuthError([$this->router->method => ['admin:rw', 'assistenz:rw']]); + + $validate = $this->_validateDelete($projektarbeit_id, $person_id, $betreuerart_kurzbz); + + if (isError($validate)) return $this->terminateWithError(getError($validate), self::ERROR_TYPE_GENERAL); + + // check if there is a Projektarbeitsbeurteilung - if yes, it is handled (possibly deleted) by external extension. + $beurteilungDeleteSuccess = true; + + Events::trigger( + 'projektarbeitsbeurteilung_delete', + $projektarbeit_id, + function ($value) use (&$beurteilungDeleteSuccess) { + $beurteilungDeleteSuccess = $value; + } + ); + + // if there is still a Beurteilung, Projektarbeit cannot be deleted - return with error + if (!$beurteilungDeleteSuccess) return $this->terminateWithError($this->p->t('projektarbeit', 'error_paarbeitHatBeurteilung')); + + $result = $this->ProjektbetreuerModel->delete( + ['projektarbeit_id' => $projektarbeit_id, 'person_id' => $person_id, 'betreuerart_kurzbz' => $betreuerart_kurzbz] + ); + + if (isError($result)) return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + if (!hasData($result)) + { + $this->outputJson($result); + } + + return $this->terminateWithSuccess(getData($result)); + } + + /** + * Get all active Betreuerarten. + */ + public function getBetreuerarten() + { + $result = $this->BetreuerartModel->loadWhere(['aktiv' => true]); + + if (isError($result)) return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + return $this->terminateWithSuccess(hasData($result) ? getData($result) : []); + } + + /** + * Get all Noten. + */ + public function getNoten() + { + $result = $this->NoteModel->load(); + + if (isError($result)) return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + return $this->terminateWithSuccess(hasData($result) ? getData($result) : []); + } + + /** + * Get default Stundensätze for an employee in a semester. + */ + public function getDefaultStundensaetze() + { + $person_id = $this->input->get('person_id'); + $studiensemester_kurzbz = $this->input->get('studiensemester_kurzbz'); + + $result = $this->StundensatzModel->getStundensatzForMitarbeiter($person_id, $studiensemester_kurzbz); + + return $this->terminateWithSuccess($result); + } + + /** + * Get all Projektbetreuer by search string. + */ + public function getProjektbetreuerBySearchQuery() + { + $searchString = $this->input->get('searchString'); + + if (!isset($searchString)) + $this->terminateWithError($this->p->t('ui', 'error_fieldRequired', ['field' => 'Search term']), self::ERROR_TYPE_GENERAL); + + $result = $this->PersonModel->searchPerson($searchString); + + if (isError($result)) return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + if (!hasData($result)) $this->terminateWithSuccess([]); + + $persons = $this->_addFullNameToBetreuer(getData($result)); + + // sort persons by type (employees first) + usort($persons, function ($a, $b) { + $statusRanks = ['Mitarbeiter' => 0, 'Person' => 1, 'Student' => 2]; + return (isset($statusRanks[$a->status]) ? $statusRanks[$a->status] : count($statusRanks) + 1) + - (isset($statusRanks[$b->status]) ? $statusRanks[$b->status] : count($statusRanks) + 1); + }); + + return $this->terminateWithSuccess($persons); + } + + /** + * Get person info by Id. + */ + public function getPerson() + { + $person_id = $this->input->get('person_id'); + + if (!isset($person_id)) + $this->terminateWithError($this->p->t('ui', 'error_fieldRequired', ['field' => 'Person']), self::ERROR_TYPE_GENERAL); + + $this->PersonModel->addSelect("CASE + WHEN EXISTS + (SELECT 1 FROM public.tbl_benutzer JOIN public.tbl_mitarbeiter ON(uid=mitarbeiter_uid) WHERE person_id=tbl_person.person_id) + THEN 'Mitarbeiter' + WHEN EXISTS + (SELECT 1 FROM public.tbl_benutzer JOIN public.tbl_student ON(uid=student_uid) WHERE person_id=tbl_person.person_id) + THEN 'Student' + ELSE 'Person' + END AS status"); + $result = $this->PersonModel->addSelect('titelpre, titelpost, vorname, nachname, person_id'); + $result = $this->PersonModel->load($person_id); + + if (isError($result)) return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + return $this->terminateWithSuccess(hasData($result) ? $this->_addFullNameToBetreuer(getData($result))[0] : []); + } + + /** + * Validate list of Projektbetreuer. + */ + public function validateProjektbetreuer() + { + $projektbetreuerArr = $this->input->post('projektbetreuer'); + + if (!is_array($projektbetreuerArr)) $projektbetreuerArr = [$projektbetreuerArr]; + + foreach ($projektbetreuerArr as $pb) + { + if ($this->_validate($pb) == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + } + + $this->terminateWithSuccess([]); + } + + /** + * Validation funciton for checking Projektbetreuer input. + * @param $formData Betreuer data + * @return bool true when data is valid + */ + private function _validate($formData) + { + $this->form_validation->set_data($formData); + + $this->form_validation->set_rules('betreuerart_kurzbz', 'Betreuerart', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('projektarbeit', 'betreuerart')]) + ]); + + $this->form_validation->set_rules('person_id', 'Person', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('projektarbeit', 'betreuer')]) + ]); + + $this->form_validation->set_rules('stunden', 'Stunden', 'numeric', [ + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => $this->p->t('projektarbeit', 'stunden')]) + ]); + + $this->form_validation->set_rules('stundensatz', 'Stundensatz', 'numeric', [ + 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => $this->p->t('projektarbeit', 'stundensatz')]) + ]); + + + return $this->form_validation->run(); + } + + /** + * Check possibility of deletion of a Projektbetreuer. + * @param projektarbeit_id + * @param person_id + * @param betreuerart_kurzbz + * @return object success when delete possible, error otherwise + */ + private function _validateDelete($projektarbeit_id, $person_id, $betreuerart_kurzbz) + { + // check if contract exists + $this->ProjektbetreuerModel->addSelect('vertrag_id'); + $result = $this->ProjektbetreuerModel->loadWhere( + ['projektarbeit_id' => $projektarbeit_id, 'person_id' => $person_id, 'betreuerart_kurzbz' => $betreuerart_kurzbz] + ); + + if (isError($result)) return $result; + + // if contract exists, no deletion is possible + if (hasData($result) && getData($result)[0]->vertrag_id != null) return error($this->p->t('projektarbeit', 'error_betreuerHatVertrag')); + + return success(); + } + + /** + * Add full name to array with Betreuer. + * @param $betreuerArr + * @return array including Betreuer with their full names + */ + private function _addFullNameToBetreuer($betreuerArr) + { + foreach ($betreuerArr as $betreuer) + { + $betreuer->name = ($betreuer->titelpre ? $betreuer->titelpre . ' ' : '') . + $betreuer->nachname . ' ' . $betreuer->vorname . ($betreuer->titelpost ? ' ' . $betreuer->titelpre : ''). + ' (' . $betreuer->status . ')'; + } + + return $betreuerArr; + } +} diff --git a/application/controllers/api/frontend/v1/stv/Pruefung.php b/application/controllers/api/frontend/v1/stv/Pruefung.php index e205c85b8..4521c2033 100644 --- a/application/controllers/api/frontend/v1/stv/Pruefung.php +++ b/application/controllers/api/frontend/v1/stv/Pruefung.php @@ -18,6 +18,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +use \DateTime as DateTime; + /** * This controller operates between (interface) the JS (GUI) and the back-end * Provides data to the ajax get calls about addresses @@ -111,7 +113,7 @@ class Pruefung extends FHCAPI_Controller // Load language phrases $this->loadPhrases([ - 'global', 'ui','lehre' + 'global', 'ui', 'lehre', 'exam' ]); } @@ -172,174 +174,11 @@ class Pruefung extends FHCAPI_Controller * * @param lehrveranstaltung_id, student_uid, lehreinheit_id * - * @return values on success - * retval 0: pruefung inserted - * reval 1: pruefung and zeugnisnote inserted - * retval 2: pruefung inserted, no insert Zeugnisnote - * (change after date of examination) - * retval 3: pruefung of type Termin2 inserted - * and pruefung of type Termin1 as well - * retval 5: prueufungen Termin 2 and 1 inserted - * and no insert Zeugnisnote (change after date of examination) + * @return void */ public function insertPruefung() { - $authUID = getAuthUID(); - - $this->load->library('form_validation'); - - $this->form_validation->set_rules('lehrveranstaltung_id', $this->p->t('lehre', 'lehrveranstaltung'), 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('lehre', 'lehrveranstaltung')]), - ]); - $this->form_validation->set_rules('lehreinheit_id', $this->p->t('lehre', 'lehreinheit'), 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('lehre', 'lehreinheit')]), - ]); - $this->form_validation->set_rules('pruefungstyp_kurzbz', $this->p->t('lehre', 'pruefung'), 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('global', 'typ')]), - ]); - $this->form_validation->set_rules( - 'datum', - $this->p->t('global', 'datum'), - ['is_valid_date'] - ); - - if ($this->form_validation->run() == false) - { - $this->terminateWithValidationErrors($this->form_validation->error_array()); - } - - //calculate studiensemester_kurzbz this from lehreinheit (case newPruefung) - $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); - if (!$studiensemester_kurzbz) - { - $this->load->model('education/Lehreinheit_model', 'LehreinheitModel'); - - $result = $this->LehreinheitModel->load($this->input->post('lehreinheit_id')); - - $lehreinheit = $this->getDataOrTerminateWithError($result); - $studiensemester_kurzbz = current($lehreinheit)->studiensemester_kurzbz; - - if (isError($result)) - { - $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } - } - - $result = $this->PruefungModel->insert([ - 'lehreinheit_id' => $this->input->post('lehreinheit_id'), - 'student_uid' => $this->input->post('student_uid'), - 'mitarbeiter_uid' => $this->input->post('mitarbeiter_uid'), - 'datum' => $this->input->post('datum'), - 'pruefungstyp_kurzbz' => $this->input->post('pruefungstyp_kurzbz'), - 'note' => $this->input->post('note'), - 'anmerkung' => $this->input->post('anmerkung'), - 'insertamum' => date('c'), - 'insertvon' => $authUID, - ]); - - $this->getDataOrTerminateWithError($result); - - //check if existing zeugnisnote - $this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel'); - - $result = $this->ZeugnisnoteModel->loadWhere(array( - 'lehrveranstaltung_id' => $this->input->post('lehrveranstaltung_id'), - 'student_uid' => $this->input->post('student_uid'), - 'studiensemester_kurzbz' => $studiensemester_kurzbz)); - - if (isError($result)) - { - $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } - - if (!hasData($result)) - { - //insert zeugnisnote, if not existing - $result = $this->ZeugnisnoteModel->insert(array( - 'lehrveranstaltung_id' => $this->input->post('lehrveranstaltung_id'), - 'student_uid' => $this->input->post('student_uid'), - 'studiensemester_kurzbz' => $studiensemester_kurzbz, - 'note' => $this->input->post('note'), - 'uebernahmedatum' => date('c'), - 'benotungsdatum' => $this->input->post('datum'), - 'insertamum' => date('c'), - 'insertvon' => $authUID - )); - - if (isError($result)) - { - $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } - $this->terminateWithSuccess(1); - } - - $return_code = 0; - - //handling Termin1 if not existing - if($this->input->post('pruefungstyp_kurzbz') == "Termin2") - { - $resultP = $this->PruefungModel->loadWhere(array( - 'lehreinheit_id' => $this->input->post('lehreinheit_id'), - 'student_uid' => $this->input->post('student_uid'), - 'pruefungstyp_kurzbz' => 'Termin1')); - - if (isError($resultP)) - { - $this->terminateWithError(getError($resultP), self::ERROR_TYPE_GENERAL); - } - if(!hasData($resultP)) - { - //check if existing Zeugnisnote - $this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel'); - $this->ZeugnisnoteModel->addJoin('lehre.tbl_lehreinheit', 'lehrveranstaltung_id'); - - $resultP = $this->ZeugnisnoteModel->loadWhere(array( - 'lehrveranstaltung_id' => $this->input->post('lehrveranstaltung_id'), - 'student_uid' => $this->input->input->post('student_uid'), - 'lehre.tbl_zeugnisnote.studiensemester_kurzbz' => $studiensemester_kurzbz)); - if (isError($resultP)) - { - $this->terminateWithError(getError($resultP), self::ERROR_TYPE_GENERAL); - } - if (!hasData($resultP)) - { - $this->terminateWithError("Zeugnisnote existiert nicht", self::ERROR_TYPE_GENERAL); - } - $dataNote = current(getData($resultP)); - - $resultN = $this->PruefungModel->insert([ - 'lehreinheit_id' => $this->input->post('lehreinheit_id'), - 'student_uid' => $this->input->post('student_uid'), - 'mitarbeiter_uid' => $this->input->post('mitarbeiter_uid'), - 'datum' => $dataNote->benotungsdatum, - 'pruefungstyp_kurzbz' => 'Termin1', - 'note' => $dataNote->note, - 'punkte' => $dataNote->punkte, - 'anmerkung' => 'automatisiert aus Zeugnisnote erstellt', - 'insertamum' => date('c'), - 'insertvon' => $authUID, - ]); - - if (isError($resultN)) { - $this->terminateWithError(getError($resultN), self::ERROR_TYPE_GENERAL); - } - $return_code = 3; - } - } - - $note = current(getData($result)); - $uebernahmedatum = new DateTime($note->uebernahmedatum); - $benotungsdatum = new DateTime($note->benotungsdatum); - - $checkDate = $uebernahmedatum === '' || $benotungsdatum > $uebernahmedatum - ? $benotungsdatum - : $uebernahmedatum; - - if ($checkDate >= $this->input->post('datum') && $note !== $note->note) - { - $this->terminateWithSuccess($return_code + 2); - } - $this->terminateWithSuccess($return_code + 2); + $this->insertOrUpdatePruefung(); } /** @@ -348,8 +187,6 @@ class Pruefung extends FHCAPI_Controller * @param pruefung_id * * @return success or error - * - * no impact on lehre.tbl_zeugnisnote */ public function updatePruefung($pruefung_id) { @@ -359,48 +196,7 @@ class Pruefung extends FHCAPI_Controller if (!$oldpruefung) show_404(); // Pruefung that should be updated does not exist - $authUID = getAuthUID(); - - $this->load->library('form_validation'); - - $this->form_validation->set_rules('lehrveranstaltung_id', $this->p->t('lehre', 'lehrveranstaltung'), 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('lehre', 'lehrveranstaltung')]), - ]); - $this->form_validation->set_rules('lehreinheit_id', $this->p->t('lehre', 'lehreinheit'), 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('lehre', 'lehreinheit')]), - ]); - $this->form_validation->set_rules('pruefungstyp_kurzbz', $this->p->t('lehre', 'pruefung'), 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('global', 'typ')]), - ]); - $this->form_validation->set_rules( - 'datum', - $this->p->t('global', 'datum'), - ['is_valid_date'] - ); - - if ($this->form_validation->run() == false) - { - $this->terminateWithValidationErrors($this->form_validation->error_array()); - } - - $result = $this->PruefungModel->update( - [ - 'pruefung_id' => $pruefung_id - ], - [ 'lehreinheit_id' => $this->input->post('lehreinheit_id'), - 'student_uid' => $this->input->post('student_uid'), - 'mitarbeiter_uid' => $this->input->post('mitarbeiter_uid'), - 'note' => $this->input->post('note'), - 'pruefungstyp_kurzbz' => $this->input->post('pruefungstyp_kurzbz'), - 'datum' => $this->input->post('datum'), - 'anmerkung' => $this->input->post('anmerkung'), - 'updatevon' => $authUID, - 'updateamum' => date('c'), - ] - ); - $this->getDataOrTerminateWithError($result); - - return $this->outputJsonSuccess(true); + $this->insertOrUpdatePruefung($pruefung_id); } /** @@ -574,4 +370,198 @@ class Pruefung extends FHCAPI_Controller return $this->terminateWithSuccess($data); } + + protected function insertOrUpdatePruefung($pruefung_id=null) + { + $authUID = getAuthUID(); + + $this->load->library('form_validation'); + + $this->form_validation->set_rules('lehreinheit_id', $this->p->t('lehre', 'lehreinheit'), 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('lehre', 'lehreinheit')]), + ]); + $this->form_validation->set_rules('pruefungstyp_kurzbz', $this->p->t('lehre', 'pruefung'), 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('global', 'typ')]), + ]); + $this->form_validation->set_rules( + 'datum', + $this->p->t('global', 'datum'), + ['is_valid_date'] + ); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel'); + + $this->PruefungModel->db->trans_start(); + + if ($this->input->post('pruefungstyp_kurzbz') == "Termin2") + { + //Wenn ein 2. Termin angelegt wird, und kein 1. Termin vorhanden ist, + //dann wird auch ein 1. Termin angelegt mit der derzeitigen Zeugnisnote + $resultP = $this->PruefungModel->loadWhere(array( + 'lehreinheit_id' => $this->input->post('lehreinheit_id'), + 'student_uid' => $this->input->post('student_uid'), + 'pruefungstyp_kurzbz' => 'Termin1')); + + $termin1 = $this->getDataOrTerminateWithError($resultP); + if (!$termin1) + { + //check if existing Zeugnisnote + $this->ZeugnisnoteModel->addJoin('lehre.tbl_lehreinheit', 'lehrveranstaltung_id'); + + $this->ZeugnisnoteModel->db->where( + 'lehre.tbl_zeugnisnote.studiensemester_kurzbz', + 'lehre.tbl_lehreinheit.studiensemester_kurzbz', + false + ); + $resultP = $this->ZeugnisnoteModel->loadWhere(array( + 'lehrveranstaltung_id' => $this->input->post('lehrveranstaltung_id'), + 'student_uid' => $this->input->post('student_uid') + )); + + $zeugnisnoten = $this->getDataOrTerminateWithError($resultP); + if ($zeugnisnoten) + { + $zeugnisnote = current($zeugnisnoten); + + $resultN = $this->PruefungModel->insert([ + 'lehreinheit_id' => $this->input->post('lehreinheit_id'), + 'student_uid' => $this->input->post('student_uid'), + 'mitarbeiter_uid' => $this->input->post('mitarbeiter_uid'), + 'datum' => $zeugnisnote->benotungsdatum, + 'pruefungstyp_kurzbz' => 'Termin1', + 'note' => $zeugnisnote->note, + 'punkte' => $zeugnisnote->punkte, + 'anmerkung' => 'automatisiert aus Zeugnisnote erstellt', + 'insertamum' => date('c'), + 'insertvon' => $authUID, + ]); + + $this->getDataOrTerminateWithError($resultN); + } + //Wenn keine Zeugnisnote vorhanden ist, dann wird kein + //1.Termin angelegt + } + } + + if(intval($pruefung_id) > 0) + { + $result = $this->PruefungModel->update( + [ + 'pruefung_id' => $pruefung_id + ], + [ 'lehreinheit_id' => $this->input->post('lehreinheit_id'), + 'student_uid' => $this->input->post('student_uid'), + 'mitarbeiter_uid' => $this->input->post('mitarbeiter_uid'), + 'note' => $this->input->post('note'), + 'pruefungstyp_kurzbz' => $this->input->post('pruefungstyp_kurzbz'), + 'datum' => $this->input->post('datum'), + 'anmerkung' => $this->input->post('anmerkung'), + 'updatevon' => $authUID, + 'updateamum' => date('c'), + ] + ); + } + else + { + $result = $this->PruefungModel->insert([ + 'lehreinheit_id' => $this->input->post('lehreinheit_id'), + 'student_uid' => $this->input->post('student_uid'), + 'mitarbeiter_uid' => $this->input->post('mitarbeiter_uid'), + 'datum' => $this->input->post('datum'), + 'pruefungstyp_kurzbz' => $this->input->post('pruefungstyp_kurzbz'), + 'note' => $this->input->post('note'), + 'anmerkung' => $this->input->post('anmerkung'), + 'insertamum' => date('c'), + 'insertvon' => $authUID, + 'punkte' => $this->input->post('punkte') ? str_replace(',', '.', $this->input->post('punkte')) : null + ]); + } + + $this->getDataOrTerminateWithError($result); + + //get studiensemester_kurzbz and lehreveranstaltung_id from lehreinheit + $this->load->model('education/Lehreinheit_model', 'LehreinheitModel'); + + $result = $this->LehreinheitModel->load($this->input->post('lehreinheit_id')); + + $lehreinheiten = $this->getDataOrTerminateWithError($result); + + if (!$lehreinheiten) { + $this->terminateWithValidationErrors([ + 'lehreinheit_id' => $this->p->t('ui', 'error_fieldNotFound', [ + 'field' => $this->p->t('lehre', 'lehreinheit') + ]) + ]); + } + $lehreinheit = current($lehreinheiten); + $studiensemester_kurzbz = $lehreinheit->studiensemester_kurzbz; + $lehrveranstaltung_id = $lehreinheit->lehrveranstaltung_id; + + //check if existing zeugnisnote + $result = $this->ZeugnisnoteModel->loadWhere(array( + 'lehrveranstaltung_id' => $lehrveranstaltung_id, + 'student_uid' => $this->input->post('student_uid'), + 'studiensemester_kurzbz' => $studiensemester_kurzbz + )); + + $zeugnisnoten = $this->getDataOrTerminateWithError($result); + + if (!$zeugnisnoten) + { + //insert zeugnisnote, if not existing + $result = $this->ZeugnisnoteModel->insert(array( + 'lehrveranstaltung_id' => $lehrveranstaltung_id, + 'student_uid' => $this->input->post('student_uid'), + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'note' => $this->input->post('note'), + 'uebernahmedatum' => date('c'), + 'benotungsdatum' => $this->input->post('datum'), + 'insertamum' => date('c'), + 'insertvon' => $authUID, + 'punkte' => $this->input->post('punkte') ? str_replace(',', '.', $this->input->post('punkte')) : null + )); + + $this->getDataOrTerminateWithError($result); + + $this->PruefungModel->db->trans_complete(); + $this->terminateWithSuccess(); + } + + $note = current($zeugnisnoten); + $uebernahmedatum = new DateTime($note->uebernahmedatum); + $benotungsdatum = new DateTime($note->benotungsdatum); + $pruefungsdatum = new DateTime($this->input->post('datum')); + + $checkDate = $note->uebernahmedatum === '' || $benotungsdatum > $uebernahmedatum + ? $benotungsdatum + : $uebernahmedatum; + + if ($checkDate > $pruefungsdatum && $this->input->post('note') !== $note->note) + { + $this->PruefungModel->db->trans_complete(); + $this->terminateWithSuccess($this->p->t('exam', 'hinweis_changeAfterExamDate')); + } + + //update zeugnisnote, if existing and valid datum + $result = $this->ZeugnisnoteModel->update([ + 'lehrveranstaltung_id' => $lehrveranstaltung_id, + 'student_uid' => $this->input->post('student_uid'), + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ], [ + 'note' => $this->input->post('note'), + 'uebernahmedatum' => date('c'), + 'benotungsdatum' => $this->input->post('datum'), + 'updateamum' => date('c'), + 'updatevon' => $authUID, + 'punkte' => $this->input->post('punkte') ? str_replace(',', '.', $this->input->post('punkte')) : null + ]); + + $this->PruefungModel->db->trans_complete(); + $this->terminateWithSuccess(); + } } diff --git a/application/controllers/api/frontend/v1/stv/Status.php b/application/controllers/api/frontend/v1/stv/Status.php index dc48a47ff..36d445fc6 100644 --- a/application/controllers/api/frontend/v1/stv/Status.php +++ b/application/controllers/api/frontend/v1/stv/Status.php @@ -114,9 +114,8 @@ class Status extends FHCAPI_Controller $this->load->model('codex/Bismeldestichtag_model', 'BismeldestichtagModel'); $result = $this->BismeldestichtagModel->getLastReachedMeldestichtag(); - $data = $this->getDataOrTerminateWithError($result); - $this->terminateWithSuccess($data); + $this->terminateWithSuccess(hasData($result) ? getData($result) : array()); } public function isLastStatus($prestudent_id) @@ -296,7 +295,7 @@ class Status extends FHCAPI_Controller }], //Check if Rolle already exists ['rolle_doesnt_exist', function () use ($prestudent_id, $status_kurzbz, $studiensemester_kurzbz, $ausbildungssemester) { - if (!$status_kurzbz || !$studiensemester_kurzbz || !$ausbildungssemester) + if (!$status_kurzbz || !$studiensemester_kurzbz || !isset($ausbildungssemester) || $ausbildungssemester === '') return true; // Error will be handled by the required statements above $result = $this->PrestudentstatusModel->load([$ausbildungssemester, $studiensemester_kurzbz, $status_kurzbz, $prestudent_id]); @@ -903,7 +902,7 @@ class Status extends FHCAPI_Controller $this->form_validation->set_rules('_default', '', [ ['rolle_doesnt_exist', function () use ($prestudent_id, $status_kurzbz, $studiensemester_kurzbz, $ausbildungssemester) { - if (!$status_kurzbz || !$studiensemester_kurzbz || !$ausbildungssemester) + if (!$status_kurzbz || !$studiensemester_kurzbz || !isset($ausbildungssemester) || $ausbildungssemester === '') return true; // Error will be handled by the required statements above $result = $this->PrestudentstatusModel->load([$ausbildungssemester, $studiensemester_kurzbz, $status_kurzbz, $prestudent_id]); @@ -920,7 +919,7 @@ class Status extends FHCAPI_Controller ) { if ($isBerechtigtNoStudstatusCheck) return true; // Skip if access right says so - if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !$ausbildungssemester) + if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !isset($ausbildungssemester) || $ausbildungssemester === '') return true; // Error will be handled by the required statements above $result = $this->prestudentstatuschecklib->checkStatusHistoryTimesequence( @@ -945,7 +944,7 @@ class Status extends FHCAPI_Controller ) { if ($isBerechtigtNoStudstatusCheck) return true; // Skip if access right says so - if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !$ausbildungssemester) + if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !isset($ausbildungssemester) || $ausbildungssemester === '') return true; // Error will be handled by the required statements above $result = $this->prestudentstatuschecklib->checkStatusHistoryLaststatus( @@ -970,7 +969,7 @@ class Status extends FHCAPI_Controller ) { if ($isBerechtigtNoStudstatusCheck) return true; // Skip if access right says so - if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !$ausbildungssemester) + if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !isset($ausbildungssemester) || $ausbildungssemester === '') return true; // Error will be handled by the required statements above $result = $this->prestudentstatuschecklib->checkStatusHistoryUnterbrechersemester( @@ -995,7 +994,7 @@ class Status extends FHCAPI_Controller ) { if ($isBerechtigtNoStudstatusCheck) return true; // Skip if access right says so - if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !$ausbildungssemester) + if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !isset($ausbildungssemester) || $ausbildungssemester === '') return true; // Error will be handled by the required statements above $result = $this->prestudentstatuschecklib->checkStatusHistoryAbbrechersemester( @@ -1020,7 +1019,7 @@ class Status extends FHCAPI_Controller ) { if ($isBerechtigtNoStudstatusCheck) return true; // Skip if access right says so - if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !$ausbildungssemester) + if (!$status_kurzbz || !$datum || !$studiensemester_kurzbz || !isset($ausbildungssemester) || $ausbildungssemester === '') return true; // Error will be handled by the required statements above $result = $this->prestudentstatuschecklib->checkStatusHistoryDiplomant( @@ -1342,6 +1341,7 @@ class Status extends FHCAPI_Controller 'updateamum' => date('c'), 'updatevon' => $authUID ]; + $nullableFields = ['statusgrund_id', 'anmerkung', 'rt_stufe']; foreach ([ 'orgform_kurzbz', 'anmerkung', @@ -1350,8 +1350,17 @@ class Status extends FHCAPI_Controller 'rt_stufe', 'statusgrund_id' ] as $key) - if ($this->input->post($key)) + { + if (in_array($key, $nullableFields)) + { + $updateData[$key] = ($this->input->post($key) === '') ? null : $this->input->post($key); + } + else if ($this->input->post($key)) + { $updateData[$key] = $this->input->post($key); + } + } + if ($this->input->post('bestaetigtam')) { $updateData['bestaetigtam'] = $this->input->post('bestaetigtam'); diff --git a/application/controllers/api/frontend/v1/stv/Student.php b/application/controllers/api/frontend/v1/stv/Student.php index f2845572f..ad6883f94 100644 --- a/application/controllers/api/frontend/v1/stv/Student.php +++ b/application/controllers/api/frontend/v1/stv/Student.php @@ -36,7 +36,8 @@ class Student extends FHCAPI_Controller parent::__construct([ 'get' => ['admin:r', 'assistenz:r'], 'save' => ['admin:rw', 'assistenz:rw'], - 'check' => ['admin:rw', 'assistenz:rw'], + 'saveStudent' => ['admin:rw', 'assistenz:rw'], + 'getPerson' => ['admin:rw', 'assistenz:rw'], 'add' => ['admin:rw', 'assistenz:rw'] // TODO(chris): extra permissions ]); @@ -55,7 +56,7 @@ class Student extends FHCAPI_Controller // Load language phrases $this->loadPhrases([ - 'ui', 'lehre' + 'ui', 'lehre', 'person' ]); } @@ -111,16 +112,28 @@ class Student extends FHCAPI_Controller if (defined('ACTIVE_ADDONS') && strpos(ACTIVE_ADDONS, 'bewerbung') !== false) { $this->PrestudentModel->addSelect( "( - SELECT kontakt - FROM public.tbl_kontakt - WHERE kontakttyp='email' - AND person_id=p.person_id - AND zustellung - ORDER BY kontakt_id + SELECT kontakt + FROM public.tbl_kontakt + WHERE kontakttyp='email' + AND person_id=p.person_id + AND zustellung + ORDER BY kontakt_id DESC LIMIT 1 ) AS email_privat", false ); + $this->PrestudentModel->addSelect( + "( + SELECT kontakt + FROM public.tbl_kontakt + WHERE kontakttyp='email_unverifiziert' + AND person_id=p.person_id + AND zustellung + ORDER BY kontakt_id DESC + LIMIT 1 + ) AS email_privat_unverified", + false + ); } $this->PrestudentModel->addSelect( "( @@ -146,9 +159,9 @@ class Student extends FHCAPI_Controller 'LEFT');*/ $result = $this->PrestudentModel->loadWhere(['tbl_prestudent.prestudent_id' => $prestudent_id]); - + $student = $this->getDataOrTerminateWithError($result); - + if (!$student) return show_404(); @@ -208,7 +221,7 @@ class Student extends FHCAPI_Controller ]); $this->load->library('UDFLib'); - + $result = $this->udflib->getCiValidations($this->PersonModel, $this->input->post()); $udf_field_validations = $this->getDataOrTerminateWithError($result); @@ -219,7 +232,7 @@ class Student extends FHCAPI_Controller $this->terminateWithValidationErrors($this->form_validation->error_array()); $result = $this->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]); - + $student = $this->getDataOrTerminateWithError($result); $uid = $student ? current($student)->student_uid : null; @@ -232,7 +245,6 @@ class Student extends FHCAPI_Controller $person_id = $person ? current($person)->person_id : null; - $array_allowed_props_lehrverband = ['verband', 'semester', 'gruppe']; $update_lehrverband = array(); foreach ($array_allowed_props_lehrverband as $prop) { @@ -292,7 +304,7 @@ class Student extends FHCAPI_Controller } $array_allowed_props_student = ['matrikelnr']; - if($this->isLaufendesSemester($studiensemester_kurzbz)) + if($this->isLaufendesSemester($studiensemester_kurzbz)) { $array_allowed_props_student = ['matrikelnr', 'verband', 'semester', 'gruppe']; } @@ -424,7 +436,32 @@ class Student extends FHCAPI_Controller ), '')); } - public function check() + /** + * Saves data to a prestudent using their student_uid + * + * @param string $student_uid + * @param string $studiensemester_kurzbz + * @return void + */ + public function saveStudent($student_uid, $studiensemester_kurzbz) + { + $this->load->model('crm/Student_model', 'StudentModel'); + + $result = $this->StudentModel->load([$student_uid]); + + $data = $this->getDataOrTerminateWithError($result); + + if (!$data) + show_404(); // No Student with that ID + + $student = current($data); + + $this->checkPermissionsForPrestudent($student->prestudent_id, ['admin:rw', 'assistenz:rw']); + + return $this->save($student->prestudent_id, $studiensemester_kurzbz); + } + + public function getPerson() { $this->load->library('form_validation'); @@ -442,21 +479,55 @@ class Student extends FHCAPI_Controller $this->load->model('person/Person_model', 'PersonModel'); + $this->PersonModel->addSelect( + 'person_id, vorname, nachname, vornamen, wahlname, gebdatum, staatsbuergerschaft, geburtsnation, sprache, anrede, + titelpost, titelpre, gebort, gebzeit, homepage, geschlecht, matr_nr, + aktiv, unruly, tbl_geschlecht.bezeichnung_mehrsprachig AS geschlecht_bezeichnung' + ); + $this->PersonModel->addJoin('public.tbl_geschlecht', 'geschlecht'); + if ($gebdatum) $this->PersonModel->db->where('gebdatum', (new DateTime($gebdatum))->format('Y-m-d')); if ($vorname && $nachname) { $this->PersonModel->db->or_group_start(); - $this->PersonModel->db->where('LOWER(nachname)', 'LOWER(' . $this->PersonModel->db->escape($nachname) . ')', false); - $this->PersonModel->db->where('LOWER(vorname)', 'LOWER(' . $this->PersonModel->db->escape($vorname) . ')', false); + $this->PersonModel->db->where('LOWER(nachname)', 'LOWER(' . $this->PersonModel->db->escape(trim($nachname)) . ')', false); + $this->PersonModel->db->where('LOWER(vorname)', 'LOWER(' . $this->PersonModel->db->escape(trim($vorname)) . ')', false); $this->PersonModel->db->group_end(); } elseif ($nachname) { - $this->PersonModel->db->or_where('LOWER(nachname)', 'LOWER(' . $this->PersonModel->escape($nachname) . ')', false); + $this->PersonModel->db->or_where('LOWER(nachname)', 'LOWER(' . $this->PersonModel->escape(trim($nachname)) . ')', false); } $result = $this->PersonModel->load(); $data = $this->getDataOrTerminateWithError($result); + $this->load->model('person/Adresse_model', 'AdresseModel'); + $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + + foreach ($data as $person) + { + // get adresses + $langIdx = $this->_getLanguageIndex() - 1; + $person->geschlecht_bezeichnung = isset($person->geschlecht_bezeichnung[$langIdx]) ? $person->geschlecht_bezeichnung[$langIdx] : ''; + + // get Adresse + $this->AdresseModel->addOrder('heimatadresse', 'DESC'); + $this->AdresseModel->addOrder('zustelladresse', 'DESC'); + $this->AdresseModel->addOrder('adresse_id', 'DESC'); + $result = $this->AdresseModel->loadWhere(['person_id' => $person->person_id]); + + $adressen = $this->getDataOrTerminateWithError($result); + + $person->adressen = $adressen; + + // get status + $result = $this->PrestudentstatusModel->getLastStatusPerson($person->person_id); + + $status = $this->getDataOrTerminateWithError($result); + + $person->status = $status; + } + $this->terminateWithSuccess($data); } @@ -465,69 +536,57 @@ class Student extends FHCAPI_Controller if (!$this->input->post('person_id')) { if (!isset($_POST['address']) || !is_array($_POST['address'])) $_POST['address'] = []; - $_POST['address']['func'] = 1; } if ($this->input->post('incoming')) { $_POST['ausbildungssemester'] = 0; } - $this->load->library('form_validation'); + $this->_validate(); - $this->form_validation->set_rules('nachname', 'Nachname', 'callback_requiredIfNotPersonId', [ - 'requiredIfNotPersonId' => $this->p->t('ui', 'error_required') - ]); - $this->form_validation->set_rules('geschlecht', 'Geschlecht', 'callback_requiredIfNotPersonId', [ - 'requiredIfNotPersonId' => $this->p->t('ui', 'error_required') - ]); - $this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'callback_isValidDate', [ - 'isValidDate' => $this->p->t('ui', 'error_invalid_date') - ]); - $this->form_validation->set_rules('address[func]', 'Address', 'required|integer|less_than[2]|greater_than[-2]'); - $this->form_validation->set_rules('address[plz]', 'PLZ', 'callback_requiredIfAddressFunc', [ - 'requiredIfAddressFunc' => $this->p->t('ui', 'error_required') - ]); - $this->form_validation->set_rules('address[gemeinde]', 'Gemeinde', 'callback_requiredIfAddressFunc', [ - 'requiredIfAddressFunc' => $this->p->t('ui', 'error_required') - ]); - $this->form_validation->set_rules('address[ort]', 'Ort', 'callback_requiredIfAddressFunc', [ - 'requiredIfAddressFunc' => $this->p->t('ui', 'error_required') - ]); - $this->form_validation->set_rules('address[address]', 'Adresse', 'callback_requiredIfAddressFunc', [ - 'requiredIfAddressFunc' => $this->p->t('ui', 'error_required') - ]); - $this->form_validation->set_rules('email', 'E-Mail', 'valid_email'); - $this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required'); - $this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required'); - $this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'required|integer|less_than[9]|greater_than[-1]'); - // TODO(chris): validate studienplan with studiengang, semester and orgform? - // TODO(chris): validate person_id, studiengang_kz, studiensemester_kurzbz, orgform_kurzbz, nation, gemeinde, ort, geschlecht? - - if (!$this->form_validation->run()) - $this->terminateWithValidationErrors($this->form_validation->error_array()); - - // TODO(chris): This should be in a library + $this->load->model('crm/Student_model', 'StudentModel'); $this->load->model('crm/Prestudent_model', 'PrestudentModel'); $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); + $this->load->model('organisation/Lehrverband_model', 'LehrverbandModel'); + $this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel'); - $this->db->trans_start(); + $this->load->library('PrestudentLib'); - $result = $this->addInteressent(); + $errors = []; + $person_id = null; - $this->db->trans_complete(); + $this->db->trans_begin(); - if ($this->db->trans_status() === FALSE) - $this->terminateWithError('TODO(chris): TEXT', self::ERROR_TYPE_GENERAL); + $result = $this->_addPerson(); + if (isError($result)) $errors[] = getError($result); - $this->terminateWithSuccess($result); + if (hasData($result)) + { + $person_id = getData($result); + $result = $this->_addAdresse($person_id); + if (isError($result)) $errors[] = getError($result); + $result = $this->_addKontakt($person_id); + if (isError($result)) $errors[] = getError($result); + if (!$this->input->post('personOnly')) $result = $this->_addFirstPrestudentstatus($person_id); + if (isError($result)) $errors[] = getError($result); + } + + if ($this->db->trans_status() === FALSE || !isEmptyArray($errors)) + { + $this->db->trans_rollback(); + $this->terminateWithError(isEmptyArray($errors) ? $this->p->t('stv', 'error_add_student') : $errors); + } + $this->db->trans_commit(); + + $this->terminateWithSuccess($person_id); } - protected function addInteressent() + private function _addPerson() { // Person anlegen wenn nötig $person_id = $this->input->post('person_id'); if (!$person_id) { $this->load->model('person/Person_model', 'PersonModel'); - + $data = [ 'nachname' => $this->input->post('nachname'), 'insertamum' => date('c'), @@ -550,19 +609,25 @@ class Student extends FHCAPI_Controller if ($this->input->post('geschlecht')) $data['geschlecht'] = $this->input->post('geschlecht'); if ($this->input->post('gebdatum')) - $data['gebdatum'] = (new DateTime($this->input->post('datum_obj')))->format('Y-m-d'); + $data['gebdatum'] = (new DateTime($this->input->post('gebdatum')))->format('Y-m-d'); if ($this->input->post('geburtsnation')) $data['geburtsnation'] = $this->input->post('geburtsnation'); if ($this->input->post('staatsbuergerschaft')) $data['staatsbuergerschaft'] = $this->input->post('staatsbuergerschaft'); - $result = $this->PersonModel->insert($data); - $person_id = $this->getDataOrTerminateWithError($result); + return $this->PersonModel->insert($data); } - // Addresse anlegen - $anlegen = $this->input->post('address[func]'); - if ($anlegen) { + return success($person_id); + } + + private function _addAdresse($person_id) + { + // Addresse anlegen? + $anlegen = $this->input->post('address[checked]'); + if ($anlegen === true) + { + // Adresse laden $this->load->model('person/Adresse_model', 'AdresseModel'); $data = [ @@ -574,50 +639,45 @@ class Student extends FHCAPI_Controller 'typ' => 'h', 'zustelladresse' => true, ]; - if ($anlegen < 0) { // Überschreiben - $this->AdresseModel->addOrder('zustelladresse', 'DESC'); - $this->AdresseModel->addOrder('sort'); + + $this->AdresseModel->addSelect('adresse_id'); $result = $this->AdresseModel->loadWhere([ 'person_id' => $person_id ]); - $address = $this->getDataOrTerminateWithError($result); - if ($address) { - $address = current($address); - $data['updateamum'] = date('c'); - $data['updatevon'] = getAuthUID(); + if (isError($result)) return $result; + + // wenn neue Adresse, heimatadresse setzen + if (!hasData($result)) $data['heimatadresse'] = true; - $result = $this->AdresseModel->update($address->adresse_id, $data); - $this->getDataOrTerminateWithError($result); - } else { - //Wenn keine Adrese vorhanden ist dann eine neue Anlegen - $anlegen = 1; - $data['heimatadresse'] = true; - } - } - if ($anlegen > 0) { $data['person_id'] = $person_id; $data['insertamum'] = date('c'); $data['insertvon'] = getAuthUID(); - if (!isset($data['heimatadresse'])) - $data['heimatadresse'] = !$this->input->post('person_id'); - - $result = $this->AdresseModel->insert($data); - $this->getDataOrTerminateWithError($result); - } + + return $this->AdresseModel->insert($data); } - + + return success(null); + } + + private function _addKontakt($person_id) + { // Kontaktdaten $kontaktdaten = []; - foreach (['email', 'telefon', 'mobil'] as $k) { + + foreach (['email', 'telefon', 'mobil'] as $k) + { $v = $this->input->post($k); if ($v) $kontaktdaten[$k] = $v; } - if (count($kontaktdaten)) { + + if (count($kontaktdaten)) + { $this->load->model('person/Kontakt_model', 'KontaktModel'); - foreach ($kontaktdaten as $typ => $kontakt) { + foreach ($kontaktdaten as $typ => $kontakt) + { $data = [ 'person_id' => $person_id, 'kontakttyp' => $typ, @@ -627,83 +687,70 @@ class Student extends FHCAPI_Controller 'insertvon' => getAuthUID() ]; $result = $this->KontaktModel->insert($data); - $this->getDataOrTerminateWithError($result); + if (isError($result)) return $result; } } + return success(null); + } + private function _addFirstPrestudentstatus($person_id) + { // Prestudent anlegen - $data = [ - 'aufmerksamdurch_kurzbz' => 'k.A.', - 'person_id' => $person_id, - 'studiengang_kz' => $this->input->post('studiengang_kz'), - 'ausbildungcode' => $this->input->post('letzteausbildung'), - 'anmerkung' => $this->input->post('anmerkungen'), - 'reihungstestangetreten' => false, - 'bismelden' => true - ]; + + // Anmerkung with Ausbildungsart + $studiengang_kz = $this->input->post('studiengang_kz'); + $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); $ausbildungsart = $this->input->post('ausbildungsart'); + $anmerkung = $this->input->post('anmerkungen'); + $foerderrelevant = null; if ($ausbildungsart) - $data['anmerkung'] .= ' Ausbildungsart:' . $ausbildungsart; + $anmerkung .= ' Ausbildungsart:' . $ausbildungsart; + // Incomings und ausserordentliche sind bei Meldung nicht förderrelevant $incoming = $this->input->post('incoming'); - if ($incoming || substr($data['studiengang_kz'], 0, 1) == '9') - $data['foerderrelevant'] = false; - // Wenn die Person schon im System erfasst ist, dann die ZGV des Datensatzes uebernehmen - $this->PrestudentModel->addOrder('zgvmas_code'); - $this->PrestudentModel->addOrder('zgv_code', 'DESC'); - $this->PrestudentModel->addLimit(1); - $result = $this->PrestudentModel->loadWhere([ - 'person_id' => $person_id - ]); - $prestudent = $this->getDataOrTerminateWithError($result); - if ($prestudent) { - $prestudent = current($prestudent); - if ($prestudent->zgv_code) { - $data['zgv_code'] = $prestudent->zgv_code; - $data['zgvort'] = $prestudent->zgvort; - $data['zgvdatum'] = $prestudent->zgvdatum; + if ($incoming || substr($studiengang_kz, 0, 1) == '9') + $foerderrelevant = false; - $data['zgvmas_code'] = $prestudent->zgvmas_code; - $data['zgvmaort'] = $prestudent->zgvmaort; - $data['zgvmadatum'] = $prestudent->zgvmadatum; - } - } // Prestudent speichern - $result = $this->PrestudentModel->insert($data); - $prestudent_id = $this->getDataOrTerminateWithError($result); + $result = $this->prestudentlib->setPrestudent( + $person_id, + $studiengang_kz, + $this->input->post('letzteausbildung'), + $anmerkung, + $foerderrelevant + ); + if (isError($result)) return $result; + if (!hasData($result)) return error('Error when adding prestudent'); - // Prestudent Rolle Anlegen - $data = [ - 'prestudent_id' => $prestudent_id, - 'status_kurzbz' => $incoming ? 'Incoming' : 'Interessent', - 'studiensemester_kurzbz' => $this->input->post('studiensemester_kurzbz'), - 'ausbildungssemester' => $this->input->post('ausbildungssemester') ?: 0, - 'orgform_kurzbz' => $this->input->post('orgform_kurzbz') ?: null, - 'studienplan_id' => $this->input->post('studienplan_id') ?: null, - 'datum' => date('Y-m-d'), - 'insertamum' => date('c'), - 'insertvon' => getAuthUID() - ]; - $result = $this->PrestudentstatusModel->insert($data); - $this->getDataOrTerminateWithError($result); + $prestudent_id = getData($result); - if ($incoming) { - // TODO(chris): IMPLEMENT! - //Matrikelnummer und UID generieren - //Benutzerdatensatz anlegen - //Studentendatensatz anlegen - //StudentLehrverband anlegen + // wenn Incoming, Incoming Daten hinzufügen + if ($incoming) + { + $statusResult = $this->prestudentlib->setFirstIncoming( + $prestudent_id, + $studiengang_kz, + $studiensemester_kurzbz, + $this->input->post('orgform_kurzbz'), + $this->input->post('studienplan_id') + ); } + else + { + // Prestudent Rolle Anlegen + $statusResult = $this->prestudentlib->setFirstStatus( + $prestudent_id, + $this->PrestudentstatusModel::STATUS_INTERESSENT, + $studiensemester_kurzbz, + $this->input->post('ausbildungssemester'), + $this->input->post('orgform_kurzbz'), + $this->input->post('studienplan_id') + ); + } + if (!hasData($statusResult)) return error('error when adding status'); + if (isError($statusResult)) return $statusResult; - // TODO(chris): DEBUG - /*$result = $this->PrestudentModel->loadWhere([ - 'pestudent_id' => 1 - ]); - if (isError($result)) { - return $result; - }*/ - - return success(true); + return success($prestudent_id); } public function requiredIfNotPersonId($value) @@ -715,13 +762,84 @@ class Student extends FHCAPI_Controller public function requiredIfAddressFunc($value) { - if (!$_POST['address']['func']) + if (!isset($_POST['address']['checked']) || !$_POST['address']['checked']) return true; return !!$value; } - public function isValidDate($value) + public function requiredIfStudentFunc($value) { - return isValidDate($value); + if (isset($_POST['personOnly']) && $_POST['personOnly']) + return true; + return !!$value; + } + + public function requiredIfStudentAndNotIncomingFunc($value) + { + if ((isset($_POST['incoming']) && $_POST['incoming']) || $this->requiredIfStudentFunc($value)) + return true; + return !!$value; + } + + /** + * Validates input data. Terminates with validation errors, if invalid. + */ + private function _validate() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('nachname', 'Nachname', 'callback_requiredIfNotPersonId', [ + 'requiredIfNotPersonId' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('person', 'nachname')]) + ]); + $this->form_validation->set_rules('geschlecht', 'Geschlecht', 'callback_requiredIfNotPersonId', [ + 'requiredIfNotPersonId' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('person', 'geschlecht')]) + ]); + $this->form_validation->set_rules('gebdatum', 'Geburtsdatum', ['isValidDate', function($value) { return isValidDate($value); }], [ + 'isValidDate' => $this->p->t('ui', 'error_invalid_date') + ]); + //$this->form_validation->set_rules('address[checked]', 'Address', 'required'); + $this->form_validation->set_rules('address[plz]', 'PLZ', 'callback_requiredIfAddressFunc', [ + 'requiredIfAddressFunc' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('person', 'plz')]) + ]); + $this->form_validation->set_rules('address[gemeinde]', 'Gemeinde', 'callback_requiredIfAddressFunc', [ + 'requiredIfAddressFunc' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('person', 'gemeinde')]) + ]); + $this->form_validation->set_rules('address[ort]', 'Ort', 'callback_requiredIfAddressFunc', [ + 'requiredIfAddressFunc' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('person', 'ort')]) + ]); + $this->form_validation->set_rules('address[address]', 'Adresse', 'callback_requiredIfAddressFunc', [ + 'requiredIfAddressFunc' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('person', 'adresse')]) + ]); + $this->form_validation->set_rules('email', 'E-Mail', 'valid_email'); + $this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'callback_requiredIfStudentFunc', [ + 'requiredIfStudentFunc' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('lehre', 'studiengang')]) + ]); + $this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'callback_requiredIfStudentFunc', [ + 'requiredIfStudentFunc' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('lehre', 'studiensemester')]) + ]); + $this->form_validation->set_rules( + 'ausbildungssemester', + 'Ausbildungssemester', + 'callback_requiredIfStudentAndNotIncomingFunc|integer|less_than[9]|greater_than[-1]', + [ + 'requiredIfStudentAndNotIncomingFunc' => + $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('lehre', 'ausbildungssemester')]), + ] + ); + // TODO(chris): validate studienplan with studiengang, semester and orgform? + // TODO(chris): validate person_id, studiengang_kz, studiensemester_kurzbz, orgform_kurzbz, nation, gemeinde, ort, geschlecht? + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + private function _getLanguageIndex() + { + $this->load->model('system/Sprache_model', 'SpracheModel'); + $this->SpracheModel->addSelect('index'); + $result = $this->SpracheModel->loadWhere(array('sprache' => getUserLanguage())); + $this->addMeta('lang', getUserLanguage()); + + return hasData($result) ? getData($result)[0]->index : 1; } } diff --git a/application/controllers/api/frontend/v1/stv/Students.php b/application/controllers/api/frontend/v1/stv/Students.php index 9de0c29b1..9dbea65f2 100644 --- a/application/controllers/api/frontend/v1/stv/Students.php +++ b/application/controllers/api/frontend/v1/stv/Students.php @@ -44,14 +44,12 @@ class Students extends FHCAPI_Controller } // Load Libraries - $this->load->library('VariableLib', ['uid' => getAuthUID()]); $this->load->library('PhrasesLib'); $this->loadPhrases( array( 'lehre' ) ); - } /** @@ -75,7 +73,7 @@ class Students extends FHCAPI_Controller * /(studiengang_kz)/(orgform)/prestudent/(studiensemester_kurzbz)/(filter) => getPrestudentsOrgform * /(studiengang_kz)/(orgform)/prestudent/(studiensemester_kurzbz)/(filter)/(otherfilter) => getPrestudentsOrgform * - * /(studiensemester_kurzbz)/(studiengang_kz)/(semester)/grp/(gruppe) => getStudentsSpezialguppe + * /(studiensemester_kurzbz)/(studiengang_kz)/(semester)/grp/(gruppe) => getStudentsSpezialgruppe * * /(studiensemester_kurzbz)/(studiengang_kz) => getStudents * /(studiensemester_kurzbz)/(studiengang_kz)/(semester) => getStudents @@ -101,39 +99,183 @@ class Students extends FHCAPI_Controller } /** + * @param string $studiensemester_kurzbz + * * @return void */ - public function getIncoming() + public function getIncoming($studiensemester_kurzbz) { $this->addMeta('ci_method', __FUNCTION__); - // TODO(chris): IMPLEMENT! - $this->terminateWithSuccess([]); + $this->addMeta('ci_params', [ + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ]); + + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + + $this->PrestudentModel->addJoin( + "( + SELECT prestudent_id + FROM public.tbl_prestudentstatus + WHERE status_kurzbz = 'Incoming' + AND studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " + ) test", + "prestudent_id" + ); + + + $this->prepareQuery($studiensemester_kurzbz); + + $this->PrestudentModel->addSelect("COALESCE( + v.semester::text, + CASE + WHEN pls.status_kurzbz IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') + THEN pls.ausbildungssemester::text + ELSE ''::text + END + ) AS semester", false); + $this->PrestudentModel->addSelect("COALESCE(v.verband::text, ''::text)"); + $this->PrestudentModel->addSelect("COALESCE(v.gruppe::text, ''::text)"); + + $this->addSelectPrioRel(); + + $this->addFilter($studiensemester_kurzbz); + + + $result = $this->PrestudentModel->load(); + + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); } /** + * @param string $studiensemester_kurzbz + * * @return void */ - public function getOutgoing() + public function getOutgoing($studiensemester_kurzbz) { $this->addMeta('ci_method', __FUNCTION__); - // TODO(chris): IMPLEMENT! - $this->terminateWithSuccess([]); + $this->addMeta('ci_params', [ + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ]); + + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + + $this->PrestudentModel->addJoin( + "( + SELECT prestudent_id + FROM bis.tbl_bisio bis + JOIN public.tbl_student USING (student_uid) + JOIN public.tbl_studiensemester stdsem ON ( + (bis.von >= stdsem.start AND bis.von <= stdsem.ende) + OR + (bis.bis >= stdsem.start AND bis.bis <= stdsem.ende) + OR + (bis.von <= stdsem.start AND bis.bis >= stdsem.ende) + ) + WHERE NOT EXISTS ( + SELECT 1 + FROM public.tbl_prestudentstatus + WHERE status_kurzbz = 'Incoming' + AND prestudent_id = tbl_student.prestudent_id + ) AND stdsem.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " + GROUP BY prestudent_id + ) test", + "prestudent_id" + ); + + + $this->prepareQuery($studiensemester_kurzbz); + + + $this->PrestudentModel->addSelect("COALESCE( + v.semester::text, + CASE + WHEN pls.status_kurzbz IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') + THEN pls.ausbildungssemester::text + ELSE ''::text + END + ) AS semester", false); + $this->PrestudentModel->addSelect("COALESCE(v.verband::text, ''::text)"); + $this->PrestudentModel->addSelect("COALESCE(v.gruppe::text, ''::text)"); + + $this->addSelectPrioRel(); + + $this->addFilter($studiensemester_kurzbz); + + + $result = $this->PrestudentModel->load(); + + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); } /** + * @param string $studiensemester_kurzbz + * * @return void */ - public function getGemeinsamestudien() + public function getGemeinsamestudien($studiensemester_kurzbz) { $this->addMeta('ci_method', __FUNCTION__); - // TODO(chris): IMPLEMENT! - $this->terminateWithSuccess([]); + $this->addMeta('ci_params', [ + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ]); + + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + + $this->PrestudentModel->addJoin( + "( + SELECT prestudent_id + FROM bis.tbl_mobilitaet + WHERE studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " + ) bis", + "prestudent_id" + ); + + + $this->prepareQuery($studiensemester_kurzbz); + + + $this->PrestudentModel->addSelect("COALESCE( + v.semester::text, + CASE + WHEN pls.status_kurzbz IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') + THEN pls.ausbildungssemester::text + ELSE ''::text + END + ) AS semester", false); + $this->PrestudentModel->addSelect("COALESCE(v.verband::text, ''::text)"); + $this->PrestudentModel->addSelect("COALESCE(v.gruppe::text, ''::text)"); + + $this->addSelectPrioRel(); + + $this->addFilter($studiensemester_kurzbz); + + + $result = $this->PrestudentModel->load(); + + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); } - public function getPrestudents($studiengang_kz, - $studiensemester_kurzbz = null, $filter = null - ) - { + public function getPrestudents( + $studiengang_kz, + $studiensemester_kurzbz = null, + $filter = null + ) { $this->addMeta('ci_method', __FUNCTION__); $this->addMeta('ci_params', array( 'studiengang_kz' => $studiengang_kz, @@ -144,10 +286,12 @@ class Students extends FHCAPI_Controller $this->fetchPrestudents($studiengang_kz, $studiensemester_kurzbz, $filter); } - public function getPrestudentsOrgform($studiengang_kz, $orgform_kurzbz, - $studiensemester_kurzbz = null, $filter = null - ) - { + public function getPrestudentsOrgform( + $studiengang_kz, + $orgform_kurzbz, + $studiensemester_kurzbz = null, + $filter = null + ) { $this->addMeta('ci_method', __FUNCTION__); $this->addMeta('ci_params', array( 'studiengang_kz' => $studiengang_kz, @@ -227,7 +371,7 @@ class Students extends FHCAPI_Controller $stg = $this->getDataOrTerminateWithError($result); if (!$stg) - $this->terminateWithValidationErrors(['' => 'Studiengang does not exist']); // TODO(chris): phrase + $this->terminateWithSuccess([]); $stg = current($stg); $where['ps.status_kurzbz'] = 'Interessent'; @@ -296,7 +440,10 @@ class Students extends FHCAPI_Controller break; default: if (!$studiensemester_kurzbz) { - // TODO(chris): this does not work with $orgform_kurzbz != null + /** NOTE(chris): + * show all prestudents in this stg who don't have a status + * $orgform_kurzbz does not change the results since orgform is stored in the status table + */ $where['ps.status_kurzbz'] = null; } else { $this->PrestudentModel->db->where_in('ps.status_kurzbz', [ @@ -310,42 +457,18 @@ class Students extends FHCAPI_Controller break; } - /* - $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); - $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); - $this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', ' - pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) - AND pls.prestudent_id=tbl_prestudent.prestudent_id - AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL) - AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT'); - $this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT'); - $this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', ' - ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') - AND ps.prestudent_id=tbl_prestudent.prestudent_id - AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') - AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')', 'LEFT');*/ $this->prepareQuery($studiensemester_kurzbz); $this->PrestudentModel->addSelect(" - CASE WHEN ps.status_kurzbz IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') - THEN ps.ausbildungssemester::text - ELSE ''::text END AS semester", false); + CASE + WHEN pls.status_kurzbz IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') + THEN ps.ausbildungssemester::text + ELSE ''::text + END AS semester", false); $this->PrestudentModel->addSelect("'' AS verband"); $this->PrestudentModel->addSelect("'' AS gruppe"); $this->addSelectPrioRel(); - //add status per semester - $this->PrestudentModel->addSelect( - "( - SELECT status_kurzbz - FROM public.tbl_prestudentstatus pss - WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id - AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " - ORDER BY GREATEST(pss.datum, '0001-01-01') DESC - LIMIT 1 - ) AS statusofsemester" - ); - $this->addFilter($studiensemester_kurzbz); $result = $this->PrestudentModel->loadWhere($where); @@ -355,10 +478,13 @@ class Students extends FHCAPI_Controller $this->terminateWithSuccess($data); } - public function getStudents($studiensemester_kurzbz, - $studiengang_kz, $semester = null, $verband = null, $gruppe = null - ) - { + public function getStudents( + $studiensemester_kurzbz, + $studiengang_kz, + $semester = null, + $verband = null, + $gruppe = null + ) { $this->addMeta('ci_method', __FUNCTION__); $this->addMeta('ci_params', array( 'studiensemester_kurzbz' => $studiensemester_kurzbz, @@ -371,10 +497,14 @@ class Students extends FHCAPI_Controller $this->fetchStudents($studiensemester_kurzbz, $studiengang_kz, $semester, $verband, $gruppe, null, null); } - public function getStudentsOrgform($studiensemester_kurzbz, - $studiengang_kz, $orgform_kurzbz, $semester = null, $verband = null, $gruppe = null - ) - { + public function getStudentsOrgform( + $studiensemester_kurzbz, + $studiengang_kz, + $orgform_kurzbz, + $semester = null, + $verband = null, + $gruppe = null + ) { $this->addMeta('ci_method', __FUNCTION__); $this->addMeta('ci_params', array( 'studiensemester_kurzbz' => $studiensemester_kurzbz, @@ -388,10 +518,12 @@ class Students extends FHCAPI_Controller $this->fetchStudents($studiensemester_kurzbz, $studiengang_kz, $semester, $verband, $gruppe, null, $orgform_kurzbz); } - public function getStudentsSpezialgruppe($studiensemester_kurzbz, - $studiengang_kz, $semester, $gruppe_kurzbz, - $orgform_kurzbz = null) - { + public function getStudentsSpezialgruppe( + $studiensemester_kurzbz, + $studiengang_kz, + $semester, + $gruppe_kurzbz + ) { $this->addMeta('ci_method', __FUNCTION__); $this->addMeta('ci_params', array( 'studiensemester_kurzbz' => $studiensemester_kurzbz, @@ -403,10 +535,13 @@ class Students extends FHCAPI_Controller $this->fetchStudents($studiensemester_kurzbz, $studiengang_kz, $semester, null, null, $gruppe_kurzbz, null); } - public function getStudentsOrgformSpezialgruppe($studiensemester_kurzbz, - $orgform_kurzbz, $studiengang_kz, $semester, $gruppe_kurzbz - ) - { + public function getStudentsOrgformSpezialgruppe( + $studiensemester_kurzbz, + $orgform_kurzbz, + $studiengang_kz, + $semester, + $gruppe_kurzbz + ) { $this->addMeta('ci_method', __FUNCTION__); $this->addMeta('ci_params', array( 'studiensemester_kurzbz' => $studiensemester_kurzbz, @@ -430,8 +565,15 @@ class Students extends FHCAPI_Controller * * @return void */ - protected function fetchStudents($studiensemester_kurzbz, $studiengang_kz, $semester = null, $verband = null, $gruppe = null, $gruppe_kurzbz = null, $orgform_kurzbz = null) - { + protected function fetchStudents( + $studiensemester_kurzbz, + $studiengang_kz, + $semester = null, + $verband = null, + $gruppe = null, + $gruppe_kurzbz = null, + $orgform_kurzbz = null + ) { $this->load->model('crm/Prestudent_model', 'PrestudentModel'); $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); @@ -440,21 +582,6 @@ class Students extends FHCAPI_Controller $this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester')); } - /* - $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); - $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); - $this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id'); - $this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', ' - pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) - AND pls.prestudent_id=tbl_prestudent.prestudent_id - AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL) - AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT'); - $this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT'); - $this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid'); - $this->PrestudentModel->addJoin( - 'public.tbl_studentlehrverband v', - 'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz) - );*/ $this->prepareQuery($studiensemester_kurzbz, ''); $this->PrestudentModel->addSelect('v.semester'); @@ -462,18 +589,6 @@ class Students extends FHCAPI_Controller $this->PrestudentModel->addSelect('v.gruppe'); $this->PrestudentModel->addSelect("'' AS priorisierung_relativ"); - //add status per semester - $this->PrestudentModel->addSelect( - "( - SELECT status_kurzbz - FROM public.tbl_prestudentstatus pss - WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id - AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " - ORDER BY GREATEST(pss.datum, '0001-01-01') DESC - LIMIT 1 - ) AS statusofsemester" - ); - $where = []; @@ -506,7 +621,6 @@ class Students extends FHCAPI_Controller false ); } - } $this->addFilter($studiensemester_kurzbz); @@ -540,39 +654,18 @@ class Students extends FHCAPI_Controller $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - /* - $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); - $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); - $this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT'); - $this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', ' - pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) - AND pls.prestudent_id=tbl_prestudent.prestudent_id - AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL) - AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT'); - $this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT'); - $this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid', 'LEFT'); - $this->PrestudentModel->addJoin( - 'public.tbl_studentlehrverband v', - 'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz), - 'LEFT' - );*/ $this->prepareQuery($studiensemester_kurzbz); - $this->PrestudentModel->addSelect("COALESCE(v.semester::text, CASE WHEN public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') THEN public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)::text ELSE ''::text END) AS semester", false); - $this->PrestudentModel->addSelect('v.verband'); - $this->PrestudentModel->addSelect('v.gruppe'); - - //add status per semester - $this->PrestudentModel->addSelect( - "( - SELECT status_kurzbz - FROM public.tbl_prestudentstatus pss - WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id - AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " - ORDER BY GREATEST(pss.datum, '0001-01-01') DESC - LIMIT 1 - ) AS statusofsemester" - ); + $this->PrestudentModel->addSelect("COALESCE( + v.semester::text, + CASE + WHEN pls.status_kurzbz IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') + THEN pls.ausbildungssemester::text + ELSE ''::text + END + ) AS semester", false); + $this->PrestudentModel->addSelect("COALESCE(v.verband::text, ''::text)"); + $this->PrestudentModel->addSelect("COALESCE(v.gruppe::text, ''::text)"); $this->addSelectPrioRel(); @@ -609,40 +702,12 @@ class Students extends FHCAPI_Controller $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - /* - $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); - $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); - $this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id'); - $this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', ' - pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) - AND pls.prestudent_id=tbl_prestudent.prestudent_id - AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL) - AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT'); - $this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT'); - $this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid'); - $this->PrestudentModel->addJoin( - 'public.tbl_studentlehrverband v', - 'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz), - 'LEFT' - );*/ $this->prepareQuery($studiensemester_kurzbz); $this->PrestudentModel->addSelect('v.semester'); $this->PrestudentModel->addSelect('v.verband'); $this->PrestudentModel->addSelect('v.gruppe'); - //add status per semester - $this->PrestudentModel->addSelect( - "( - SELECT status_kurzbz - FROM public.tbl_prestudentstatus pss - WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id - AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " - ORDER BY GREATEST(pss.datum, '0001-01-01') DESC - LIMIT 1 - ) AS statusofsemester" - ); - $this->addSelectPrioRel(); @@ -681,21 +746,59 @@ class Students extends FHCAPI_Controller $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - /* - $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); - $this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id'); - $this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid'); - $this->PrestudentModel->addJoin( - 'public.tbl_studentlehrverband v', - 'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz), - 'LEFT' - );*/ $this->prepareQuery($studiensemester_kurzbz); $this->PrestudentModel->addSelect('v.semester'); $this->PrestudentModel->addSelect('v.verband'); $this->PrestudentModel->addSelect('v.gruppe'); + $this->addSelectPrioRel(); + + $this->addFilter($studiensemester_kurzbz); + + $result = $this->PrestudentModel->loadWhere([ + 'p.person_id' => $person_id + ]); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + /** + * @param string $studiensemester_kurzbz + * + * @return void + */ + public function search($studiensemester_kurzbz) + { + $this->addMeta('ci_method', __FUNCTION__); + $this->addMeta('ci_params', array( + 'studiensemester_kurzbz' => $studiensemester_kurzbz + )); + + $this->load->library('SearchLib', [ 'config' => 'searchstv' ]); + $this->load->library('form_validation'); + + $this->form_validation->set_rules('searchstr', 'searchstr', 'required'); + $this->form_validation->set_rules('types[]', 'types', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $result = $this->searchlib->search($this->input->post('searchstr'), $this->input->post('types')); + + $data = $this->getDataOrTerminateWithError($result); + + + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $this->prepareQuery($studiensemester_kurzbz); + + $this->PrestudentModel->addSelect("COALESCE(v.semester::text, CASE WHEN public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') THEN public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)::text ELSE ''::text END) AS semester", false); + $this->PrestudentModel->addSelect('v.verband'); + $this->PrestudentModel->addSelect('v.gruppe'); + //add status per semester $this->PrestudentModel->addSelect( "( @@ -712,10 +815,31 @@ class Students extends FHCAPI_Controller $this->addFilter($studiensemester_kurzbz); - $result = $this->PrestudentModel->loadWhere([ - 'p.person_id' => $person_id - ]); - + $prestudent_ids = []; + $student_uids = []; + $this->addMeta('data', $data); + foreach ($data as $row) { + $dataset = json_decode($row->data); + if ($row->type == 'prestudent') { + $prestudent_ids[] = $dataset->prestudent_id; + } elseif ($row->type == 'student') { + $student_uids[] = $dataset->uid; + } + } + + if ($prestudent_ids && $student_uids) { + $this->PrestudentModel->db->where_in('tbl_prestudent.prestudent_id', $prestudent_ids); + $this->PrestudentModel->db->or_where_in('s.student_uid', $student_uids); + } elseif ($prestudent_ids) { + $this->PrestudentModel->db->where_in('tbl_prestudent.prestudent_id', $prestudent_ids); + } elseif ($student_uids) { + $this->PrestudentModel->db->where_in('s.student_uid', $student_uids); + } else { + $this->terminateWithSuccess([]); + } + + $result = $this->PrestudentModel->load(); + $data = $this->getDataOrTerminateWithError($result); $this->terminateWithSuccess($data); @@ -771,6 +895,18 @@ class Students extends FHCAPI_Controller // verband // gruppe + //add status per semester + $this->PrestudentModel->addSelect( + "( + SELECT status_kurzbz + FROM public.tbl_prestudentstatus pss + WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id + AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . " + ORDER BY GREATEST(pss.datum, '0001-01-01') DESC + LIMIT 1 + ) AS statusofsemester" + ); + $this->PrestudentModel->addSelect('UPPER(stg.typ || stg.kurzbz) AS studiengang'); $this->PrestudentModel->addSelect('tbl_prestudent.studiengang_kz'); $this->PrestudentModel->addSelect('stg.bezeichnung AS stg_bezeichnung'); @@ -806,13 +942,6 @@ class Students extends FHCAPI_Controller $this->PrestudentModel->addSelect('mentor'); $this->PrestudentModel->addSelect('b.aktiv AS bnaktiv'); - /*$this->PrestudentModel->addSelect('tbl_prestudent.reihungstest_id'); - $this->PrestudentModel->addSelect('tbl_prestudent.anmeldungreihungstest'); - $this->PrestudentModel->addSelect('tbl_prestudent.gsstudientyp_kurzbz'); - $this->PrestudentModel->addSelect('tbl_prestudent.priorisierung'); - $this->PrestudentModel->addSelect('p.zugangscode'); - $this->PrestudentModel->addSelect('p.bpk');*/ - $this->PrestudentModel->db->where_in('tbl_prestudent.studiengang_kz', $this->allowedStgs); $this->PrestudentModel->addOrder('nachname'); @@ -827,13 +956,13 @@ class Students extends FHCAPI_Controller $this->PrestudentModel->addSelect("( SELECT count(*) FROM ( - SELECT *, public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) AS laststatus - FROM PUBLIC.tbl_prestudent pss - JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id) + SELECT *, public.get_rolle_prestudent(pss.prestudent_id, NULL) AS laststatus + FROM public.tbl_prestudent pss + JOIN public.tbl_prestudentstatus USING (prestudent_id) WHERE person_id = p.person_id AND studiensemester_kurzbz = ( SELECT studiensemester_kurzbz - FROM PUBLIC.tbl_prestudentstatus + FROM public.tbl_prestudentstatus WHERE prestudent_id = tbl_prestudent.prestudent_id AND status_kurzbz = 'Interessent' LIMIT 1 @@ -842,7 +971,7 @@ class Students extends FHCAPI_Controller ) prest WHERE laststatus NOT IN ('Abbrecher', 'Abgewiesener', 'Absolvent') AND priorisierung <= tbl_prestudent.priorisierung - ) || ' (' || tbl_prestudent.priorisierung || ')' AS priorisierung_relativ", false); + ) || ' (' || COALESCE(tbl_prestudent.priorisierung::text, ' '::text) || ')' AS priorisierung_relativ", false); } /** @@ -854,40 +983,20 @@ class Students extends FHCAPI_Controller */ protected function addFilter($studiensemester_kurzbz) { - $filter = json_decode($this->input->get('filter'), true); + $filter = $this->input->post('filter'); + if (!is_array($filter)) { - $this->addMeta('addfilter', 'invalid filter: ' . $this->input->get('filter')); + $this->addMeta('addfilter', 'invalid filter: ' . json_encode($this->input->post('filter'))); return; } - if (isset($filter['konto_count_0'])) { - $bt = $this->PrestudentModel->escape($filter['konto_count_0']); - $stdsem = $this->PrestudentModel->escape($studiensemester_kurzbz); - - $this->PrestudentModel->db->where('( - SELECT count(*) - FROM public.tbl_konto - WHERE person_id=tbl_prestudent.person_id - AND buchungstyp_kurzbz=' . $bt . ' - AND studiensemester_kurzbz=' . $stdsem . ' - ) =', 0); - $this->PrestudentModel->db->where('get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) !=', 'Incoming'); - } - if (isset($filter['konto_missing_counter'])) { - $bt = $this->PrestudentModel->escape($filter['konto_missing_counter']); - $stg = ''; - if ($this->variablelib->getVar('kontofilterstg') == 'true') - $stg = ' AND studiengang_kz=tbl_prestudent.studiengang_kz'; - - $bt = $bt == 'alle' ? '' : ' AND buchungstyp_kurzbz=' . $bt; - - $this->PrestudentModel->db->where('( - SELECT sum(betrag) - FROM public.tbl_konto - WHERE person_id=tbl_prestudent.person_id' . - $bt . - $stg . ' - ) !=', 0); + foreach ($filter as $item) { + if (isset($item['usestdsem']) && $item['usestdsem']) + $item['studiensemester_kurzbz'] = $studiensemester_kurzbz; + if (!$this->PrestudentModel->addFilter($item)) { + $this->addMeta('addfilter', 'invalid filter: ' . json_encode($item)); + return; + } } } } diff --git a/application/controllers/api/frontend/v1/stv/Verband.php b/application/controllers/api/frontend/v1/stv/Verband.php index 6487b6263..32ef30a45 100644 --- a/application/controllers/api/frontend/v1/stv/Verband.php +++ b/application/controllers/api/frontend/v1/stv/Verband.php @@ -165,7 +165,17 @@ class Verband extends FHCAPI_Controller $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("CONCAT( + UPPER(CONCAT(typ, kurzbz)), + '-', + semester, + ( + SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END + FROM public.tbl_lehrverband + WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester + ORDER BY verband, gruppe LIMIT 1 + ) + ) AS name", false); $this->StudiengangModel->addSelect('semester'); $this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false); @@ -173,6 +183,7 @@ class Verband extends FHCAPI_Controller $this->StudiengangModel->addOrder('semester'); if ($org_form !== null) { + $this->StudiengangModel->addSelect("v.orgform_kurzbz"); $this->StudiengangModel->db->group_start(); $this->StudiengangModel->db->where('v.semester', 0); $this->StudiengangModel->db->or_where('v.orgform_kurzbz', $org_form); @@ -188,6 +199,7 @@ class Verband extends FHCAPI_Controller array_unshift($list, [ 'name' => 'PreStudent', 'link' => $link . 'prestudent', + 'no_sem_reload' => true, 'stg_kz' => (int)$studiengang_kz, 'children' => $this->getStdSem($link . 'prestudent/', $studiengang_kz) ]); @@ -203,6 +215,7 @@ class Verband extends FHCAPI_Controller $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("studiengang_kz AS stg_kz"); $this->StudienordnungModel->addJoin('lehre.tbl_studienplan p', 'studienordnung_id'); @@ -216,7 +229,6 @@ class Verband extends FHCAPI_Controller $list = array_merge($list, $result); } } - } $this->terminateWithSuccess($list); } @@ -272,6 +284,7 @@ class Verband extends FHCAPI_Controller $this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband ORDER BY gruppe LIMIT 1)) AS name", false); $this->StudiengangModel->addSelect("CASE WHEN MAX(gruppe)='' OR MAX(gruppe)=' ' THEN TRUE ELSE FALSE END AS leaf"); + $this->StudiengangModel->addSelect($this->StudiengangModel->escape($semester) . ' AS semester'); $this->StudiengangModel->addSelect('verband'); $this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false); @@ -320,6 +333,8 @@ class Verband extends FHCAPI_Controller $this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, gruppe, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband AND gruppe=v.gruppe ORDER BY gruppe LIMIT 1)) AS name", false); $this->StudiengangModel->addSelect("TRUE AS leaf", false); + $this->StudiengangModel->addSelect('v.semester'); + $this->StudiengangModel->addSelect('v.verband'); $this->StudiengangModel->addSelect('gruppe'); $this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false); diff --git a/application/controllers/api/frontend/v1/stv/Vertrag.php b/application/controllers/api/frontend/v1/stv/Vertrag.php new file mode 100644 index 000000000..f94fe795e --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Vertrag.php @@ -0,0 +1,104 @@ + ['admin:r', 'assistenz:r'], + 'cancelVertrag' => ['admin:r', 'assistenz:r'] + ]); + + // Load Libraries + $this->load->library('form_validation'); + + // Load language phrases + $this->loadPhrases([ + 'ui', + 'person', + 'projektarbeit' + ]); + + // Load models + $this->load->model('accounting/Vertrag_model', 'VertragModel'); + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + + // load libraries + $this->load->library('PermissionLib'); + } + + public function getVertrag() + { + $vertrag_id = $this->input->get('vertrag_id'); + + if (!isset($vertrag_id) || !is_numeric($vertrag_id)) + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Vertrag ID']), self::ERROR_TYPE_GENERAL); + + $result = $this->VertragModel->getVertragById($vertrag_id); + + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + if (!hasData($result)) $this->terminateWithSuccess([]); + + $vertrag = getData($result)[0]; + + $this->terminateWithSuccess($vertrag); + } + + public function cancelVertrag() + { + $vertrag_id = $this->input->post('vertrag_id'); + $person_id = $this->input->post('person_id'); + + if (!isset($vertrag_id) || !is_numeric($vertrag_id)) + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Vertrag ID']), self::ERROR_TYPE_GENERAL); + if (!isset($person_id) || !is_numeric($person_id)) + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person ID']), self::ERROR_TYPE_GENERAL); + + // * first find lehrveranstaltung_id of the contracts lehrveranstaltung + $this->VertragModel->addSelect('lehrveranstaltung_id'); + $this->VertragModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id', 'LEFT'); + $result = $this->VertragModel->loadWhere(['vertrag_id' => $vertrag_id]); + + if (isError($result)) $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + if (!hasData($result)) $this->terminateWithSuccess([]); + + $lehrveranstaltung_id = getData($result)[0]->lehrveranstaltung_id; + + $allOe = $this->LehrveranstaltungModel->getAllOe($lehrveranstaltung_id); + + if (isError($allOe)) $this->terminateWithError(getError($allOe), self::ERROR_TYPE_GENERAL); + + $allOe = hasData($allOe) ? getData($allOe) : []; + + $this->addMeta('oe', $allOe); + + // * then check if the user has permissions to cancel the corresponding lv-organisational units + if (!$this->permissionlib->isBerechtigtMultipleOe('admin', $allOe, 'suid') && + !$this->permissionlib->isBerechtigtMultipleOe('lehre/lehrauftrag_bestellen', $allOe, 'suid')) + { + return $this->_outputAuthError([$this->router->method => ['admin:rw', 'lehrauftrag_bestellen:rw']]); + } + + $uidResult = $this->BenutzerModel->getFromPersonId($person_id); + + if (isError($uidResult)) $this->terminateWithError(getError($uidResult), self::ERROR_TYPE_GENERAL); + + if (!hasData($uidResult)) $this->terminateWithError("no user found", self::ERROR_TYPE_GENERAL); + + $mitarbeiter_uid = getData($uidResult)[0]->uid; + + $result = $this->VertragModel->cancelVertrag($vertrag_id, $mitarbeiter_uid); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/api/frontend/v1/vorlagen/Vorlagen.php b/application/controllers/api/frontend/v1/vorlagen/Vorlagen.php index 01edb33d1..cf76746ef 100644 --- a/application/controllers/api/frontend/v1/vorlagen/Vorlagen.php +++ b/application/controllers/api/frontend/v1/vorlagen/Vorlagen.php @@ -51,13 +51,17 @@ class Vorlagen extends FHCAPI_Controller $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); $result = $this->BenutzerfunktionModel->getBenutzerfunktionByUid($uid, 'oezuordnung'); - $data = $this->getDataOrTerminateWithError($result); - $oe_kurzbz = current($data); + if (hasData($result)) + { + $data = getData($result); - $result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz->oe_kurzbz); - $data = $this->getDataOrTerminateWithError($result); + $oe_kurzbz = array_column($data, 'oe_kurzbz'); + $result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz); + + $this->terminateWithSuccess(hasData($result) ? getData($result) : array()); + } + $this->terminateWithSuccess(array()); - $this->terminateWithSuccess($data); } } \ No newline at end of file diff --git a/application/controllers/api/v1/person/Person.php b/application/controllers/api/v1/person/Person.php index 6a373137f..935fbae62 100644 --- a/application/controllers/api/v1/person/Person.php +++ b/application/controllers/api/v1/person/Person.php @@ -233,10 +233,10 @@ class Person extends API_Controller //Quersumme bilden for ($i = 0; $i < 10; $i++) { - $erg += $gewichtung[$i] * $tmpSvnr{$i}; + $erg += $gewichtung[$i] * $tmpSvnr[$i]; } - if ($tmpSvnr{3} != ($erg % 11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11 + if ($tmpSvnr[3] != ($erg % 11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11 { return error('SVNR ist ungueltig'); } @@ -244,7 +244,7 @@ class Person extends API_Controller if (mb_strlen($person['svnr']) == 12) { $last = substr($person['svnr'], 10, 12); - if ($last{0} != 'v' || !is_numeric($last{1})) + if ($last[0] != 'v' || !is_numeric($last[1])) { return error('SVNR ist ungueltig'); } diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index 1a4f566e6..eaa207ff1 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -22,6 +22,7 @@ class InfoCenter extends Auth_Controller const REIHUNGSTESTABSOLVIERT_PAGE = 'reihungstestAbsolviert'; const ABGEWIESEN_PAGE = 'abgewiesen'; const AUFGENOMMEN_PAGE = 'aufgenommen'; + const ONBOARDING_PAGE = 'onboarding'; const SHOW_DETAILS_PAGE = 'showDetails'; const SHOW_ZGV_DETAILS_PAGE = 'showZGVDetails'; const ZGV_UBERPRUEFUNG_PAGE = 'ZGVUeberpruefung'; @@ -116,6 +117,7 @@ class InfoCenter extends Auth_Controller 'index' => 'infocenter:r', 'freigegeben' => 'infocenter:r', 'abgewiesen' => 'infocenter:r', + 'onboarding' => 'infocenter:r', 'aufgenommen' => 'infocenter:r', 'reihungstestAbsolviert' => 'infocenter:r', 'showDetails' => 'infocenter:r', @@ -230,6 +232,13 @@ class InfoCenter extends Auth_Controller $this->load->view('system/infocenter/infocenterAbgewiesen.php'); } + + public function onboarding() + { + $this->_setNavigationMenu(self::ONBOARDING_PAGE); // define the navigation menu for this page + + $this->load->view('system/infocenter/onboarding.php'); + } /** * Aufgenommene page of the InfoCenter tool @@ -1553,6 +1562,7 @@ class InfoCenter extends Auth_Controller $reihungstestAbsolviertLink = site_url(self::INFOCENTER_URI.'/'.self::REIHUNGSTESTABSOLVIERT_PAGE); $abgewiesenLink = site_url(self::INFOCENTER_URI.'/'.self::ABGEWIESEN_PAGE); $aufgenommenLink = site_url(self::INFOCENTER_URI.'/'.self::AUFGENOMMEN_PAGE); + $onboardingLink = site_url(self::INFOCENTER_URI.'/'.self::ONBOARDING_PAGE); $currentFilterId = $this->input->get(self::FILTER_ID); if (isset($currentFilterId)) @@ -1561,6 +1571,7 @@ class InfoCenter extends Auth_Controller $reihungstestAbsolviertLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId; $abgewiesenLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId; $aufgenommenLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId; + $onboardingLink .= '?'.self::PREV_FILTER_ID.'='.$currentFilterId; } $this->navigationlib->setSessionMenu( @@ -1624,6 +1635,18 @@ class InfoCenter extends Auth_Controller '', // target 40 // sort ), + 'ohnePrestudent' => $this->navigationlib->oneLevel( + 'Electronic Onboarding', // description + $onboardingLink, // link + null, // children + 'users', // icon + null, // subscriptDescription + false, // expand + null, // subscriptLinkClass + null, // subscriptLinkValue + '', // target + 50 // sort + ), ) ); } @@ -1650,6 +1673,8 @@ class InfoCenter extends Auth_Controller $link = site_url(self::ZGV_UEBERPRUEFUNG_URI); if ($origin_page === self::ABGEWIESEN_PAGE) $link = site_url(self::INFOCENTER_URI.'/'.self::ABGEWIESEN_PAGE); + if ($origin_page === self::ONBOARDING_PAGE) + $link = site_url(self::INFOCENTER_URI.'/'.self::ONBOARDING_PAGE); if ($origin_page === self::AUFGENOMMEN_PAGE) $link = site_url(self::INFOCENTER_URI.'/'.self::AUFGENOMMEN_PAGE); @@ -1691,6 +1716,7 @@ class InfoCenter extends Auth_Controller $freigegebenLink = site_url(self::INFOCENTER_URI.'/'.self::FREIGEGEBEN_PAGE); $absolviertLink = site_url(self::INFOCENTER_URI.'/'.self::REIHUNGSTESTABSOLVIERT_PAGE); $abgewiesenLink = site_url(self::INFOCENTER_URI.'/'.self::ABGEWIESEN_PAGE); + $onboardingLink = site_url(self::INFOCENTER_URI.'/'.self::ONBOARDING_PAGE); $prevFilterId = $this->input->get(self::PREV_FILTER_ID); if (isset($prevFilterId)) { @@ -1767,6 +1793,24 @@ class InfoCenter extends Auth_Controller ) ); } + if($page == self::ONBOARDING_PAGE) + { + $this->navigationlib->setSessionElementMenu( + 'onboarding', + $this->navigationlib->oneLevel( + 'Electronic Onboarding', // description + $onboardingLink, // link + null, // children + 'users', // icon + null, // subscriptDescription + false, // expand + null, // subscriptLinkClass + null, // subscriptLinkValue + '', // target + 50 // sort + ) + ); + } } /** diff --git a/application/core/Auth_Controller.php b/application/core/Auth_Controller.php index 466627fe3..d6c89be57 100644 --- a/application/core/Auth_Controller.php +++ b/application/core/Auth_Controller.php @@ -70,20 +70,22 @@ abstract class Auth_Controller extends FHC_Controller /** * Checks for Permissions depending if the given person is a * Mitarbeiter and/or Student + * If neither Student nor Mitarbeiter, default permissions are checked * and exits/outputs an error if they are not met. * * @param integer $person_id * @param array $permMa Perms if the person is a Mitarbeiter * @param array $permStud Perms if the person is a Student + * @param array $permDefault Perms if the person is neither a Student nor a Mitarbeiter * * @return void */ - protected function checkPermissionsForPerson($person_id, $permMa, $permStud) + protected function checkPermissionsForPerson($person_id, $permMa, $permStud, $permDefault = null) { - $res = $this->hasPermissionsForPerson($person_id, $permMa, $permStud); - + $res = $this->hasPermissionsForPerson($person_id, $permMa, $permStud, $permDefault); + if ($res) { - $perm = array_keys(array_flip(array_merge($res|1 ? $permMa : [], $res|2 ? $permStud : []))); + $perm = array_keys(array_flip(array_merge($res&1 ? $permMa : [], $res&2 ? $permStud : [], $res&4 ? $permDefault : []))); $this->_outputAuthError([$this->router->method => $perm]); } } @@ -108,16 +110,19 @@ abstract class Auth_Controller extends FHC_Controller * Checks for Permissions depending if the given person is a * Mitarbeiter and/or Student * and returns the result. - * + * If neither Student nor Mitarbeiter, default permissions are checked + * * @param integer $person_id * @param array $permMa Perms if the person is a Mitarbeiter * @param array $permStud Perms if the person is a Student - * + * @param array $permDefault Perms if the person is neither a Student nor a Mitarbeiter * @return integer 0 if permission is granted */ - protected function hasPermissionsForPerson($person_id, $permMa, $permStud) + protected function hasPermissionsForPerson($person_id, $permMa, $permStud, $permDefault) { - $res = 3; + $res = 8; + $isMitarbeiter = false; + $isStudent = false; $this->load->model('person/Person_model', 'PersonModel'); $this->PersonModel->addJoin('public.tbl_benutzer', 'person_id'); $this->PersonModel->addJoin('public.tbl_mitarbeiter', 'uid = mitarbeiter_uid'); @@ -125,7 +130,8 @@ abstract class Auth_Controller extends FHC_Controller if (hasData($result)) { if ($this->permissionlib->isEntitled(['a' => $permMa], 'a')) return 0; - $res = 1; + $isMitarbeiter = true; + $res += 1; } $this->PersonModel->addJoin('public.tbl_prestudent', 'person_id'); $result = $this->PersonModel->load($person_id); @@ -140,8 +146,15 @@ abstract class Auth_Controller extends FHC_Controller return 0; } } + $isStudent = true; $res += 2; } + if (isset($permDefault) && !$isMitarbeiter && !$isStudent) + { + if ($this->permissionlib->isEntitled(['a' => $permDefault], 'a')) + return 0; + $res += 4; + } return $res; } diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index 00c0a1b93..b13d9d44d 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -515,3 +515,73 @@ function has_permissions_for_stg($studiengang_kz, $permissions = '') return false; } + +/** + * check if an entry exists in the database + */ +function is_in_db($key, $model = '') +{ + if (!$model) + return false; + + $field = strstr($model, ":"); + if ($field) { + $model = strstr($model, ":", true); + $field = substr($field, 1); + } + + $CI =& get_instance(); + $CI->load->model($model, $model); + + if ($field) { + $result = $CI->$model->loadWhere([ + $field => $key + ]); + } else { + $result = $CI->$model->load($key); + } + + return (isSuccess($result) && hasData($result)); +} + +/** + * is building an array for Dropdown Entry in Print Dropdown + * @param $id id for the Document to add to the Document Array + * @param $name title of the dropdownEntry + * @param $parameterUrl url of parameters xml, xsl, format etc as needed + * WITHOUT BASEURL eg. "xml=abschlusspruefung.rdf.php&xsl_stg_kz=$studiengang_kz&xsl=Bescheid&output=pdf" + * @param $uid default parameter, if null only parameterurl will be added + * additional needed parameter: put in the parameterUrl + * @param $alternativeBaseUrl: if baseUrl not pdfExport.php, put here alternative without ? char, eg. "zutrittskarte.php" + * + * @return Array + */ +function buildDropdownEntryPrintArray($id, $name, $parameterurl, $uid=null, $order=null, $alternativeBaseUrl=null) +{ + //DEFAULT BASEURL + $baseurl = "pdfExport.php?"; + + $uidString = $uid ? "&uid=" . $uid : ""; + + + + if($alternativeBaseUrl) + { + return [ + "id" => $id, + "type" => "documenturl", + "name" => $name, + "url" => $alternativeBaseUrl . "?" . $parameterurl . $uidString, + "order" => $order + ]; + } + else + return [ + "id" => $id, + "type" => "documenturl", + "name" => $name, + "url" => $baseurl . $parameterurl . "&uid=" . $uid, + "order" => $order + ]; + +} diff --git a/application/helpers/hlp_header_helper.php b/application/helpers/hlp_header_helper.php index 24c02eac5..309bdedbd 100644 --- a/application/helpers/hlp_header_helper.php +++ b/application/helpers/hlp_header_helper.php @@ -246,3 +246,10 @@ function generateSkipLink($skipID) $toPrint.='" class="fhcSkipLink" aria-label="Skip to main content">'; echo $toPrint; } + +function absoluteJsImportUrl($relurl) +{ + $ci =& get_instance(); + $url = base_url($relurl) . '?'. $ci->config->item('fhcomplete_build_version'); + return $url; +} \ No newline at end of file diff --git a/application/language/english/form_validation_lang.php b/application/language/english/form_validation_lang.php index b8918a721..2777cd05e 100644 --- a/application/language/english/form_validation_lang.php +++ b/application/language/english/form_validation_lang.php @@ -41,3 +41,4 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); $lang['form_validation_has_write_permissions'] = 'You have no rights to edit {field} field.'; $lang['form_validation_is_valid_date'] = 'The date format is invalid or out of range.'; $lang['form_validation_has_permissions_for_stg'] = 'You have no rights for stg {field}.'; +$lang['form_validation_is_in_db'] = '{field} does not exist.'; diff --git a/application/libraries/LektorLib.php b/application/libraries/LektorLib.php index e06e2b728..bbe630eaf 100644 --- a/application/libraries/LektorLib.php +++ b/application/libraries/LektorLib.php @@ -17,6 +17,7 @@ class LektorLib $this->_ci->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); $this->_ci->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel'); $this->_ci->load->model('person/Benutzer_model', 'BenutzerModel'); + $this->_ci->load->library('PhrasesLib', array('lehre')); } public function addLektorToLehreinheit($lehreinheit_id, $mitarbeiter_uid) @@ -35,7 +36,7 @@ class LektorLib if (isError($already_assigned)) return $already_assigned; - if (hasData($already_assigned)) return error('Lektor already assigned'); + if (hasData($already_assigned)) return error($this->_ci->phraseslib->t("lehre", "bereitzugeteilt")); $studiensemester_result = $this->_ci->StudiensemesterModel->loadWhere(array('studiensemester_kurzbz' => $lehreinheit->studiensemester_kurzbz)); if (isError($studiensemester_result)) return $studiensemester_result; @@ -88,6 +89,7 @@ class LektorLib $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) { @@ -98,7 +100,13 @@ class LektorLib $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!'); + return error($this->_ci->phraseslib->t("lehre", "lektorbereitsverplant")); + + $lehreinheit_data = $this->_ci->LehreinheitmitarbeiterModel->loadWhere(array('mitarbeiter_uid' => $new_data['mitarbeiter_uid'], 'lehreinheit_id' => $lehreinheit_id)); + + if (hasData($lehreinheit_data)) + return error($this->_ci->phraseslib->t("lehre", "bereitzugeteilt")); + } $warning = ''; if (isset($new_data['semesterstunden'])) diff --git a/application/libraries/PrestudentLib.php b/application/libraries/PrestudentLib.php index 2d795369f..28879fb47 100644 --- a/application/libraries/PrestudentLib.php +++ b/application/libraries/PrestudentLib.php @@ -35,6 +35,89 @@ class PrestudentLib $this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel'); } + /** + * Sets initial prestudent entry, no status yet. + * @return object success or error + */ + public function setPrestudent( + $person_id, + $studiengang_kz, + $ausbildungscode, + $anmerkung, + $foerderrelevant + ) + { + // Prestudent anlegen + $data = [ + 'aufmerksamdurch_kurzbz' => 'k.A.', + 'person_id' => $person_id, + 'studiengang_kz' => $studiengang_kz, + 'ausbildungcode' => $ausbildungscode, + 'anmerkung' => $anmerkung, + 'reihungstestangetreten' => false, + 'bismelden' => true, + 'foerderrelevant' => $foerderrelevant, + 'insertamum' => date('c'), + 'insertvon' => getAuthUID() + ]; + + // Wenn die Person schon im System erfasst ist, dann die ZGV des Datensatzes uebernehmen + $this->_ci->PrestudentModel->addSelect('public.tbl_prestudent.*, public.tbl_person.vorname, public.tbl_person.nachname'); + $this->_ci->PrestudentModel->addJoin('public.tbl_person', 'person_id'); + $this->_ci->PrestudentModel->addOrder('zgvmas_code'); + $this->_ci->PrestudentModel->addOrder('zgv_code', 'DESC'); + $this->_ci->PrestudentModel->addLimit(1); + $result = $this->_ci->PrestudentModel->loadWhere([ + 'person_id' => $person_id + ]); + + if (isError($result)) return $result; + + if (hasData($result)) { + $prestudent = getData($result)[0]; + if ($prestudent->zgv_code) { + $data['zgv_code'] = $prestudent->zgv_code; + $data['zgvort'] = $prestudent->zgvort; + $data['zgvdatum'] = $prestudent->zgvdatum; + + $data['zgvmas_code'] = $prestudent->zgvmas_code; + $data['zgvmaort'] = $prestudent->zgvmaort; + $data['zgvmadatum'] = $prestudent->zgvmadatum; + } + } + // Prestudent speichern + return $this->_ci->PrestudentModel->insert($data); + } + + /** + * Sets first status of a prestudent.! + * @return object success or error + */ + public function setFirstStatus( + $prestudent_id, + $status_kurzbz, + $studiensemester_kurzbz, + $ausbildungssemester = null, + $orgform_kurzbz = null, + $studienplan_id = null + ) + { + // Prestudent Rolle Anlegen + $data = [ + 'prestudent_id' => $prestudent_id, + 'status_kurzbz' => $status_kurzbz, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'ausbildungssemester' => $ausbildungssemester ?: 0, + 'orgform_kurzbz' => $orgform_kurzbz ?: null, + 'studienplan_id' => $studienplan_id ?: null, + 'datum' => date('Y-m-d'), + 'insertamum' => date('c'), + 'insertvon' => getAuthUID() + ]; + + return $this->_ci->PrestudentstatusModel->insert($data); + } + public function setAbbrecher( $prestudent_id, $studiensemester_kurzbz, @@ -889,6 +972,155 @@ class PrestudentLib ); } + /** + * Creates an incoming, saves necessary data for an incoming. + * @param $prestudent_id existing prestudent, for which incoming entry is created + * @param $studiengang_kz Studiengang assigned to incoming + * @param $studiensemester_kurzbz start semester for incoming + * @return object success if incoming successfully saved, or error + */ + public function setFirstIncoming($prestudent_id, $studiengang_kz, $studiensemester_kurzbz, $orgform_kurzbz, $studienplan_id) + { + // Verband and Ausbildungssemester for incoming + $authUID = getAuthUID(); + $incomingVerband = 'I'; + $incomingAusbildungssemester = '0'; + + // get prestudent + $this->_ci->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); + $this->_ci->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz'); + $result = $this->_ci->PrestudentModel->load($prestudent_id); + + if (isError($result)) return $result; + if (!hasData($result)) return error('No prestudent'); + + $student_data = getData($result)[0]; + + $result = $this->setFirstStatus( + $prestudent_id, + $this->_ci->PrestudentstatusModel::STATUS_INCOMING, + $studiensemester_kurzbz, + $incomingAusbildungssemester, + $orgform_kurzbz, + $studienplan_id + ); + if (isError($result)) return $result; + if (!hasData($result)) return error('Error when adding prestudentstatus'); + + // generate Personenkennzeichen + $result = $this->_ci->StudentModel->generateMatrikelnummer2($studiengang_kz, $studiensemester_kurzbz); + if (isError($result)) return $result; + if (!hasData($result)) return error('No personenkennzeichen could be generated'); + + $personenkennzeichen = getData($result); + + $jahr = mb_substr($personenkennzeichen, 0, 2); + $stg = mb_substr($personenkennzeichen, 3, 4); + + $nachname_clean = mb_strtolower(sanitizeProblemChars($student_data->nachname)); + $vorname_clean = mb_strtolower(sanitizeProblemChars($student_data->vorname)); + $nachname_clean = str_replace(' ','_', $nachname_clean); + $vorname_clean = str_replace(' ','_', $vorname_clean); + + // get Studiengang data + $result = $this->_ci->StudiengangModel->load(ltrim($stg, '0')); + if (isError($result)) return $result; + if (!hasData($result)) return error('No Studiengang'); + + $stgObj = getData($result)[0]; + + // gernerate uid + $result = $this->_ci->StudentModel->generateUID($stgObj->kurzbz, $jahr, $stgObj->typ, $personenkennzeichen, $vorname_clean, $nachname_clean); + if (isError($result)) return $result; + if (!hasData($result)) return error("UID could not be generated"); + $uid = getData($result); + + //Benutzerdatensatz anlegen + $benutzer = [ + 'uid' => $uid, + 'person_id' => $student_data->person_id, + 'aktiv' => true, + 'aktivierungscode' => $this->_ci->BenutzerModel->generateActivationkey() + ]; + + // Generate Alias + $alias = ''; + if (!defined('GENERATE_ALIAS_STUDENT') || GENERATE_ALIAS_STUDENT === true) + { + $result = $this->_ci->BenutzerModel->generateAliasFromName($student_data->vorname, $student_data->nachname); + if (isError($result)) + return $result; + $alias = getData($result); + } + + $benutzer['alias'] = $alias; + $benutzer['insertamum'] = date('Y-m-d H:i:s'); + $benutzer['insertvon'] = $authUID; + + $result = $this->_ci->BenutzerModel->insert($benutzer); + + if (isError($result)) return $result; + + // Studentendatensatz anlegen + $student = [ + 'student_uid' => $uid, + 'matrikelnr' => $personenkennzeichen, + 'prestudent_id' => $prestudent_id, + 'studiengang_kz' => $studiengang_kz, + 'semester' => $incomingAusbildungssemester, + 'verband' => $incomingVerband, + 'gruppe' => ' ' + ]; + + $result = $this->_ci->LehrverbandModel->loadWhere([ + 'studiengang_kz' => $student['studiengang_kz'], + 'semester' => $student['semester'], + 'verband' => $student['verband'], + 'gruppe' => $student['gruppe'] + ]); + + if (isError($result)) return $result; + + if (!hasData($result)) + { + // Add Lehrverband if it does not exist + $result = $this->_ci->LehrverbandModel->insert([ + 'studiengang_kz' => $student_data->studiengang_kz, + 'semester' => $student['semester'], + 'verband' => $student['verband'], + 'gruppe' => $student['gruppe'], + 'bezeichnung' => 'Incoming', + 'aktiv' => true + ]); + + if (isError($result)) return $result; + } + + // add student + $student['insertamum'] = date('Y-m-d H:i:s'); + $student['insertvon'] = $authUID; + + $result = $this->_ci->StudentModel->insert($student); + if (isError($result)) return $result; + + // Add Studentlehrverband + $result = $this->_ci->StudentlehrverbandModel->insert([ + 'student_uid' => $uid, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'studiengang_kz' => $student_data->studiengang_kz, + 'semester' => $incomingAusbildungssemester, + 'verband' => $incomingVerband, + 'gruppe' => ' ', + 'insertamum' => date('Y-m-d H:i:s'), + 'insertvon' => $authUID + ]); + + if (isError($result)) + return $result; + + return success($prestudent_id); + } + protected function setBasic($authUID, $now, $status_kurzbz, $prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id = null) { $result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id); diff --git a/application/models/accounting/Vertrag_model.php b/application/models/accounting/Vertrag_model.php index c17c676c7..4c036369b 100644 --- a/application/models/accounting/Vertrag_model.php +++ b/application/models/accounting/Vertrag_model.php @@ -402,6 +402,26 @@ class Vertrag_model extends DB_Model return $this->loadWhere(array('mitarbeiter_uid' => $mitarbeiter_uid, 'lehreinheit_id' => $lehreinheit_id)); } + public function getVertragById($vertrag_id) + { + $this->addSelect( + 'tbl_vertrag.vertrag_id, vertragstyp_kurzbz, vertragsstunden, vertragsstunden_studiensemester_kurzbz, status.vertragsstatus_kurzbz, + status.bezeichnung AS vertragsstatus, tbl_vertrag.betrag, lema.semesterstunden, lema.stundensatz' + ); + $this->addJoin('lehre.tbl_lehreinheitmitarbeiter lema', 'tbl_vertrag.vertrag_id = lema.vertrag_id', 'LEFT'); + $this->addJoin(' + ( + SELECT DISTINCT ON(vst.vertrag_id) vst.vertrag_id, + bezeichnung, + tbl_vertragsstatus.vertragsstatus_kurzbz + FROM lehre.tbl_vertrag_vertragsstatus vst + JOIN lehre.tbl_vertragsstatus USING(vertragsstatus_kurzbz) + ORDER BY vst.vertrag_id, datum DESC + ) as status', 'status.vertrag_id = lehre.tbl_vertrag.vertrag_id', 'LEFT'); + + return $this->loadWhere(['tbl_vertrag.vertrag_id' => $vertrag_id]); + } + public function cancelVertrag($vertrag_id, $mitarbeiter_uid) { $vertrag = $this->load($vertrag_id); diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index ff56c3268..ad5c3e141 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -1,5 +1,7 @@ execQuery($query, array($person_id)); } + + /** + * Adds a filter to the query builder + * + * @param array $filter + * @return boolean + */ + public function addFilter($filter) + { + if (!isset($filter['type'])) + return false; + + switch ($filter['type']) { + case 'konto': + $bt = ''; + $stdsem = ''; + $comp = '!='; + + if (isset($filter['buchungstyp_kurzbz']) && $filter['buchungstyp_kurzbz'] != 'all') + $bt = ' AND buchungstyp_kurzbz=' . $this->escape($filter['buchungstyp_kurzbz']); + + if (isset($filter['studiensemester_kurzbz'])) + $stdsem = ' AND studiensemester_kurzbz=' . $this->escape($filter['studiensemester_kurzbz']); + + if (isset($filter['missing']) && $filter['missing']) { + $comp = '='; + $this->db->where('get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) !=', 'Incoming'); + } + + $this->db->where('( + SELECT count(*) + FROM public.tbl_konto + WHERE person_id=tbl_prestudent.person_id + ' . $bt . ' + ' . $stdsem . ' + ) ' . $comp, 0); + break; + + case 'konto_counter': + $bt = ''; + $samestg = ''; + $past = ''; + + if (isset($filter['buchungstyp_kurzbz']) && $filter['buchungstyp_kurzbz'] != 'all') + $bt = ' AND buchungstyp_kurzbz = ' . $this->escape($filter['buchungstyp_kurzbz']); + + if (isset($filter['samestg']) && $filter['samestg']) + $samestg = ' AND studiengang_kz = tbl_prestudent.studiengang_kz'; + + if (isset($filter['past']) && $filter['past']) + $past = ' AND buchungsdatum < NOW()'; + + $this->db->where('( + SELECT sum(betrag) + FROM public.tbl_konto + WHERE person_id = tbl_prestudent.person_id + ' . $bt . ' + ' . $samestg . ' + ' . $past . ' + ) !=', 0); + break; + + case 'zgv': + $this->db + ->group_start() + ->group_start() + ->where('zgv_code IS NOT NULL') + ->where('zgvdatum IS NULL') + ->group_end() + ->or_group_start() + ->where('zgvmas_code IS NOT NULL') + ->where('zgvmadatum IS NULL') + ->group_end() + ->or_group_start() + ->where('zgvdoktor_code IS NOT NULL') + ->where('zgvdoktordatum IS NULL') + ->group_end() + ->group_end(); + break; + + case 'documents': + $this->db->where('( + SELECT count(*) + FROM public.tbl_dokumentstudiengang + WHERE dokument_kurzbz NOT IN ( + SELECT dokument_kurzbz + FROM tbl_dokumentprestudent + WHERE prestudent_id=tbl_prestudent.prestudent_id + ) + AND studiengang_kz=tbl_prestudent.studiengang_kz + ) !=', 0); + break; + + case 'statusgrund': + if (!isset($filter['statusgrund_id'])) + return false; + + if (isset($filter['studiensemester_kurzbz'])) + $stdsem = ' AND studiensemester_kurzbz=' . $this->escape($filter['studiensemester_kurzbz']); + + $this->db->where('( + SELECT count(*) + FROM public.tbl_prestudentstatus + WHERE prestudent_id = tbl_prestudent.prestudent_id + AND statusgrund_id = ' . $this->escape($filter['statusgrund_id']) . ' + ' . $stdsem . ' + ) !=', 0); + break; + } + + Events::trigger('prestudent_add_filter', $filter); + + return true; + } } diff --git a/application/models/crm/Prestudentstatus_model.php b/application/models/crm/Prestudentstatus_model.php index de91319b9..c0ed8595e 100644 --- a/application/models/crm/Prestudentstatus_model.php +++ b/application/models/crm/Prestudentstatus_model.php @@ -290,7 +290,11 @@ class Prestudentstatus_model extends DB_Model */ public function getLastStatusPerson($person_id, $studiensemester_kurzbz = null) { - $query = 'SELECT * + $query = 'SELECT p.*, ps.*, s.*, + stg.kurzbz AS studiengang_kurzbz, stg.kurzbzlang AS studiengang_kurzbzlang, + UPPER(typ::varchar(1) || kurzbz) AS studiengang_kuerzel, + stg.typ AS studiengang_typ, stg.bezeichnung AS studiengang_bezeichnung, stg.english AS studiengang_bezeichnung_english, + stg.orgform_kurzbz AS studiengang_orgform FROM public.tbl_prestudent p JOIN ( SELECT DISTINCT ON(prestudent_id) * @@ -298,7 +302,8 @@ class Prestudentstatus_model extends DB_Model WHERE prestudent_id IN (SELECT prestudent_id FROM public.tbl_prestudent WHERE person_id = ?) ORDER BY prestudent_id, datum desc, insertamum desc ) ps USING(prestudent_id) - JOIN public.tbl_status USING(status_kurzbz)'; + JOIN public.tbl_status s USING(status_kurzbz) + JOIN public.tbl_studiengang stg USING (studiengang_kz)'; $parametersArray = array($person_id); diff --git a/application/models/crm/Student_model.php b/application/models/crm/Student_model.php index 539c3cf56..6f2404cbd 100644 --- a/application/models/crm/Student_model.php +++ b/application/models/crm/Student_model.php @@ -27,7 +27,7 @@ class Student_model extends DB_Model $this->addSelect('1'); $result = $this->loadWhere(array('student_uid' => $uid)); - + if(hasData($result)) { @@ -169,7 +169,7 @@ class Student_model extends DB_Model $max = 0; if ($matrikelnrres && hasData($matrikelnrres)) { - $max = mb_substr($matrikelnrres->retval[0]->matrikelnr, 7); + $max = mb_substr(getData($matrikelnrres)[0]->matrikelnr, 7); if (!is_numeric($max)) { $max = (int)$max; } diff --git a/application/models/education/Lehreinheit_model.php b/application/models/education/Lehreinheit_model.php index e52af4cba..2f955c295 100644 --- a/application/models/education/Lehreinheit_model.php +++ b/application/models/education/Lehreinheit_model.php @@ -651,7 +651,13 @@ EOSQL; ELSE NULL END END, - ' ' + ' ' + ORDER BY + 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), ''), + COALESCE(tbl_lehreinheitgruppe.gruppe_kurzbz, '') ) AS gruppen FROM lehre.tbl_lehreinheitgruppe LEFT JOIN public.tbl_studiengang USING (studiengang_kz) diff --git a/application/models/education/Lehreinheitgruppe_model.php b/application/models/education/Lehreinheitgruppe_model.php index bca395f31..dee8bbfe1 100644 --- a/application/models/education/Lehreinheitgruppe_model.php +++ b/application/models/education/Lehreinheitgruppe_model.php @@ -374,7 +374,7 @@ class Lehreinheitgruppe_model extends DB_Model return success('Group assigned successfully to Lehreinheit'); } else - return error('Group already assigned'); + return error($this->p->t('lehre', 'grpbereitszugeteilt')); } public function deleteGroup($lehreinheit_id, $lehreinheitgruppe_id) @@ -401,7 +401,7 @@ class Lehreinheitgruppe_model extends DB_Model $stundenplan_result = $this->loadWhere(array('tbl_lehreinheitgruppe.lehreinheitgruppe_id' => $lehreinheitgruppe_id)); if (hasData($stundenplan_result)) - return error('Gruppe already verplant'); + return error($this->p->t('lehre', 'grpbereitsverplant')); $delete_result = $this->delete($lehreinheitgruppe_id); diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index 1b3b9e9d7..7347cf2ca 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -1255,4 +1255,61 @@ class Lehrveranstaltung_model extends DB_Model return $this->execReadOnlyQuery($qry, $params); } + + /** + * Gets Lehrveranstaltungen for a student, as needed for a Projektarbeit. + * @param student_uid + * @param studiengang_kz optional, all Lvs of this Studiengang will be included + * @param additional_lehrveranstaltung_id optional, this lv will be added to result + * @return object success or error + */ + public function getLvsForProjektarbeit($student_uid, $studiengang_kz = null, $additional_lehrveranstaltung_id = null) + { + $params = array($student_uid, $student_uid); + + $qry = " + SELECT * + FROM + lehre.tbl_lehrveranstaltung + WHERE + ( + lehrveranstaltung_id IN ( + + SELECT + lehrveranstaltung_id + FROM + campus.vw_student_lehrveranstaltung + WHERE + uid=? + + UNION + + SELECT + lehrveranstaltung_id + FROM + lehre.tbl_zeugnisnote + WHERE + student_uid=? + )"; + + if (isset($studiengang_kz)) + { + $params[] = $studiengang_kz; + $qry .= " OR (studiengang_kz = ? AND semester IS NOT NULL)"; + } + + if (isset($additional_lehrveranstaltung_id)) + { + $params[] = $additional_lehrveranstaltung_id; + $qry .= " OR lehrveranstaltung_id = ?"; + } + + $qry .= " + ) + AND projektarbeit = TRUE + ORDER BY + semester, bezeichnung"; + + return $this->execQuery($qry, $params); + } } diff --git a/application/models/education/Projektarbeit_model.php b/application/models/education/Projektarbeit_model.php index 4083dbf6e..414d1d1be 100644 --- a/application/models/education/Projektarbeit_model.php +++ b/application/models/education/Projektarbeit_model.php @@ -24,16 +24,28 @@ class Projektarbeit_model extends DB_Model public function getProjektarbeit($student_uid, $studiengang_kz = null, $studiensemester_kurzbz = null, $projekttyp = null, $final = null) { $qry = "SELECT - tbl_projektarbeit.* , tbl_projekttyp.bezeichnung + pa.*, tbl_projekttyp.bezeichnung, + tbl_lehreinheit.studiensemester_kurzbz, tbl_lehrveranstaltung.lehrveranstaltung_id, + tbl_firma.name AS firma_name, + ( + SELECT + STRING_AGG(trim(COALESCE(titelpre,'')||' '||COALESCE(vorname,'')||' '||COALESCE(nachname,'')||' '||COALESCE(titelpost,'')), ', ') + FROM + lehre.tbl_projektbetreuer + JOIN public.tbl_person USING (person_id) + WHERE + projektarbeit_id = pa.projektarbeit_id + AND student_uid = pa.student_uid + GROUP BY projektarbeit_id + ) AS projektbetreuer FROM - lehre.tbl_projektarbeit - JOIN - lehre.tbl_projekttyp USING (projekttyp_kurzbz), lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung - + lehre.tbl_projektarbeit pa + JOIN lehre.tbl_projekttyp USING (projekttyp_kurzbz) + JOIN lehre.tbl_lehreinheit USING (lehreinheit_id) + JOIN lehre.tbl_lehrveranstaltung USING (lehrveranstaltung_id) + LEFT JOIN public.tbl_firma USING (firma_id) WHERE - tbl_projektarbeit.lehreinheit_id=tbl_lehreinheit.lehreinheit_id AND - tbl_lehreinheit.lehrveranstaltung_id = tbl_lehrveranstaltung.lehrveranstaltung_id AND - tbl_projektarbeit.student_uid = ?"; + pa.student_uid = ?"; $params = array($student_uid); @@ -261,4 +273,30 @@ class Projektarbeit_model extends DB_Model return $this->execReadOnlyQuery($qry, array($projektarbeit_id)); } + + /** + * + * @param + * @return object success or error + */ + public function hasBerechtigungForProjektarbeit($projektarbeit_id) + { + if (!$projektarbeit_id || !is_numeric($projektarbeit_id)) + return false; + + $this->ProjektarbeitModel->addSelect('studiengang_kz'); + $this->ProjektarbeitModel->addJoin('public.tbl_student', 'student_uid'); + $result = $this->ProjektarbeitModel->load($projektarbeit_id); + if (isError($result) || !hasData($result)) + return false; + + $studiengang_kz = getData($result)[0]->studiengang_kz; + + if ($this->permissionlib->isBerechtigt('admin', 'suid', $studiengang_kz)) + return true; + if ($this->permissionlib->isBerechtigt('assistenz', 'suid', $studiengang_kz)) + return true; + + return false; + } } diff --git a/application/models/education/Projektbetreuer_model.php b/application/models/education/Projektbetreuer_model.php index 95950bf95..02368ae21 100644 --- a/application/models/education/Projektbetreuer_model.php +++ b/application/models/education/Projektbetreuer_model.php @@ -10,6 +10,7 @@ class Projektbetreuer_model extends DB_Model parent::__construct(); $this->dbTable = 'lehre.tbl_projektbetreuer'; $this->pk = array('betreuerart_kurzbz', 'projektarbeit_id', 'person_id'); + $this->hasSequence = false; } /** diff --git a/application/models/organisation/Studienplan_model.php b/application/models/organisation/Studienplan_model.php index 481a0564c..4a5f87832 100644 --- a/application/models/organisation/Studienplan_model.php +++ b/application/models/organisation/Studienplan_model.php @@ -157,7 +157,6 @@ class Studienplan_model extends DB_Model 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 bc4494f57..64fce8944 100644 --- a/application/models/person/Notiz_model.php +++ b/application/models/person/Notiz_model.php @@ -207,7 +207,6 @@ class Notiz_model extends DB_Model "; return $this->execQuery($qry, array($type, $id)); - } diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 3947378cf..233cfc751 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -151,12 +151,21 @@ class Person_model extends DB_Model */ public function searchPerson($filter) { - $this->addSelect('vorname, nachname, gebdatum, person_id'); + $this->addSelect('vorname, nachname, gebdatum, person_id, titelpre, titelpost'); + $this->addSelect("CASE + WHEN EXISTS + (SELECT 1 FROM public.tbl_benutzer JOIN public.tbl_mitarbeiter ON(uid=mitarbeiter_uid) WHERE person_id=tbl_person.person_id) + THEN 'Mitarbeiter' + WHEN EXISTS + (SELECT 1 FROM public.tbl_benutzer JOIN public.tbl_student ON(uid=student_uid) WHERE person_id=tbl_person.person_id) + THEN 'Student' + ELSE 'Person' + END AS status"); $result = $this->loadWhere( - 'lower(nachname) like '.$this->db->escape('%'.$filter.'%')." + 'lower(nachname) like '.$this->db->escape('%'.mb_strtolower($filter).'%')." OR lower(vorname) like ".$this->db->escape('%'.$filter.'%')." - OR lower(nachname || ' ' || vorname) like ".$this->db->escape('%'.$filter.'%')." - OR lower(vorname || ' ' || nachname) like ".$this->db->escape('%'.$filter.'%') + OR lower(nachname || ' ' || vorname) like ".$this->db->escape('%'.mb_strtolower($filter).'%')." + OR lower(vorname || ' ' || nachname) like ".$this->db->escape('%'.mb_strtolower($filter).'%') ); return $result; @@ -411,4 +420,4 @@ class Person_model extends DB_Model return success($result); } } -} \ No newline at end of file +} diff --git a/application/models/person/Profil_update_model.php b/application/models/person/Profil_update_model.php index 36f53ff75..31005c4b7 100644 --- a/application/models/person/Profil_update_model.php +++ b/application/models/person/Profil_update_model.php @@ -235,8 +235,11 @@ class Profil_update_model extends DB_Model private function formatProfilRequest($request) { $request->requested_change = json_decode($request->requested_change); + $request->insertamum_iso = !is_null($request->insertamum) ? date_create($request->insertamum)->format('Y-m-d') : null; $request->insertamum = !is_null($request->insertamum) ? date_create($request->insertamum)->format('d.m.Y') : null; + $request->updateamum_iso = !is_null($request->updateamum) ? date_create($request->updateamum)->format('Y-m-d') : null; $request->updateamum = !is_null($request->updateamum) ? date_create($request->updateamum)->format('d.m.Y') : null; + $request->status_timestamp_iso = !is_null($request->status_timestamp) ? date_create($request->status_timestamp)->format('Y-m-d') : null; $request->status_timestamp = !is_null($request->status_timestamp) ? date_create($request->status_timestamp)->format('d.m.Y') : null; } diff --git a/application/models/ressource/Firma_model.php b/application/models/ressource/Firma_model.php index 431f0815f..5ae53eeaf 100644 --- a/application/models/ressource/Firma_model.php +++ b/application/models/ressource/Firma_model.php @@ -12,17 +12,24 @@ class Firma_model extends DB_Model $this->pk = 'firma_id'; } - public function searchFirmen($filter) + public function searchFirmen($filter, $aktiv = null) { + $params = []; $filter = strtoLower($filter); $qry = " - SELECT + SELECT f.name, f.firma_id - FROM - public.tbl_firma f - WHERE - lower (f.name) LIKE '%". $this->db->escape_like_str($filter)."%'"; + FROM + public.tbl_firma f + WHERE + lower (f.name) LIKE '%". $this->db->escape_like_str($filter)."%'"; - return $this->execQuery($qry); + if (isset($aktiv) && is_bool($aktiv)) + { + $params[] = $aktiv; + $qry .= " AND aktiv = ?"; + } + + return $this->execQuery($qry, $params); } } diff --git a/application/models/ressource/Mitarbeiter_model.php b/application/models/ressource/Mitarbeiter_model.php index f6cdc74b8..a650643f1 100644 --- a/application/models/ressource/Mitarbeiter_model.php +++ b/application/models/ressource/Mitarbeiter_model.php @@ -353,12 +353,14 @@ class Mitarbeiter_model extends DB_Model { $filter = strtoLower($filter); + $returnwert = "p.person_id, p.nachname, p.vorname, p.titelpost, p.titelpre"; + if ($mode == "mitAkadGrad") - $returnwert = "ma.mitarbeiter_uid, CONCAT(p.nachname, ' ', p.vorname, ' ', p.titelpost, ' ', p.titelpre, ' (', ma.mitarbeiter_uid , ')') as mitarbeiter"; + $returnwert .= ", ma.mitarbeiter_uid, CONCAT(p.nachname, ' ', p.vorname, ' ', p.titelpost, ' ', p.titelpre, ' (', ma.mitarbeiter_uid , ')') as mitarbeiter"; elseif ($mode == "ohneMaUid") - $returnwert = "p.person_id, CONCAT(p.nachname, ' ', p.vorname, ' ', p.titelpost, ' ', p.titelpre) as mitarbeiter"; + $returnwert .= ", CONCAT(p.nachname, ' ', p.vorname, ' ', p.titelpost, ' ', p.titelpre) as mitarbeiter"; else - $returnwert = "ma.mitarbeiter_uid, CONCAT(p.nachname, ' ', p.vorname, ' (', ma.mitarbeiter_uid , ')') as mitarbeiter"; + $returnwert .= ", ma.mitarbeiter_uid, CONCAT(p.nachname, ' ', p.vorname, ' (', ma.mitarbeiter_uid , ')') as mitarbeiter"; $qry = " SELECT " . $returnwert . " @@ -373,7 +375,11 @@ class Mitarbeiter_model extends DB_Model OR lower (p.vorname) LIKE '%". $this->db->escape_like_str($filter)."%' OR - (ma.mitarbeiter_uid) LIKE '%". $this->db->escape_like_str($filter)."%'"; + (ma.mitarbeiter_uid) LIKE '%". $this->db->escape_like_str($filter)."%' + OR + lower(vorname || ' ' || nachname || ' ' || vorname) like ".$this->db->escape('%'.mb_strtolower($filter).'%')." + ORDER BY + p.nachname, p.vorname, b.uid, p.person_id"; return $this->execQuery($qry); } diff --git a/application/models/ressource/Stundensatz_model.php b/application/models/ressource/Stundensatz_model.php index f34ad07ed..2a7418924 100644 --- a/application/models/ressource/Stundensatz_model.php +++ b/application/models/ressource/Stundensatz_model.php @@ -2,7 +2,7 @@ class Stundensatz_model extends DB_Model { - + /** * Constructor */ @@ -43,6 +43,107 @@ class Stundensatz_model extends DB_Model return $this->execQuery($qry, $params); } + public function getStundensatzForMitarbeiter($person_id, $studiensemester_kurzbz) + { + $this->load->config('stv'); + + $defaultStundensatz = $this->config->item('tabs')['projektarbeit']['defaultProjektbetreuerStundensatz']; + + $stundensatz = ''; + + if(isset($person_id) && isset($studiensemester_kurzbz)) + { + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->StudiensemesterModel->addSelect('start, ende'); + $result = $this->StudiensemesterModel->load($studiensemester_kurzbz); + + if (hasData($result)) + { + $studiensemester = getData($result)[0]; + + if (defined('FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ') && !FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ) + { + // load Mitarbeiter + $params = [$person_id]; + $qry = " + SELECT + mitarbeiter_uid, fixangestellt + FROM + public.tbl_mitarbeiter + JOIN public.tbl_benutzer ON(tbl_benutzer.uid=tbl_mitarbeiter.mitarbeiter_uid) + WHERE + person_id=? + ORDER BY + tbl_mitarbeiter.insertamum DESC NULLS LAST + LIMIT 1"; + + $result = $this->execQuery($qry, $params); + + if (hasData($result)) + { + $ma = getData($result)[0]; + + $this->load->model('vertragsbestandteil/Dienstverhaeltnis_model','DienstverhaeltnisModel'); + $echterdv_result = $this->DienstverhaeltnisModel->existsDienstverhaeltnis( + $ma->mitarbeiter_uid, + $studiensemester->start, + $studiensemester->ende, + 'echterdv' + ); + + if (hasData($echterdv_result)) + { + $stundensatz = null; + } + else + { + $stundensatzRes = $this->getStundensatzByDatum( + $ma->mitarbeiter_uid, $studiensemester->start, $studiensemester->ende, 'lehre' + ); + + if (hasData($stundensatzRes)) + $stundensatz = getData($stundensatzRes)[0]->stundensatz; + else + $stundensatz = '0.00'; + } + } + else + { + $stundensatz = '0.00'; + } + + } + else + { + $params = [$person_id, $studiensemester->ende, $studiensemester->start]; + $qry = "SELECT ss.stundensatz + FROM hr.tbl_stundensatz ss + JOIN public.tbl_mitarbeiter ON ss.uid = tbl_mitarbeiter.mitarbeiter_uid + JOIN public.tbl_benutzer ON(tbl_benutzer.uid=tbl_mitarbeiter.mitarbeiter_uid) + WHERE person_id=? + AND stundensatztyp = 'lehre' + AND gueltig_von <= ? + AND (gueltig_bis >= ? OR gueltig_bis IS NULL) + ORDER BY gueltig_bis DESC NULLS FIRST, gueltig_von DESC NULLS LAST LIMIT 1"; + + $result = $this->execQuery($qry, $params); + + if (hasData($result)) + { + $stundensatz = getData($result)[0]->stundensatz; + } + else + { + $stundensatz = $defaultStundensatz; + } + } + } + } + + return $stundensatz; + } + public function getDefaultStundensatz($mitarbeiter_uid, $beginn, $ende = null, $typ = null) { $stundensatz_result = $this->getStundensatzByDatum($mitarbeiter_uid, $beginn, $ende, $typ); @@ -58,4 +159,4 @@ class Stundensatz_model extends DB_Model } 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 b055ee954..1143398ca 100644 --- a/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php +++ b/application/models/vertragsbestandteil/Dienstverhaeltnis_model.php @@ -254,22 +254,16 @@ EOSQL; return $dvs; } - public function existsDienstverhaeltnis($mitarbeiter_uid, $start, $ende = null, $vertragsart_kurzbz = null) + public function existsDienstverhaeltnis($mitarbeiter_uid, $start, $ende, $vertragsart_kurzbz) { $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('vertragsart_kurzbz', $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->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/Cis/ProfilUpdate.php b/application/views/Cis/ProfilUpdate.php index e797d436f..2e69208c7 100644 --- a/application/views/Cis/ProfilUpdate.php +++ b/application/views/Cis/ProfilUpdate.php @@ -2,10 +2,14 @@ $includesArray = array( 'title' => 'Profil Änderungen', 'vue3' => true, + 'primevue3' => true, 'bootstrap5' => true, 'fontawesome6'=> true, 'axios027' => true, 'tabulator5' => true, + 'customJSs' => array( + 'vendor/moment/luxonjs/luxon.min.js' + ), 'customJSModules' => array( 'public/js/apps/Cis/ProfilUpdateRequests.js' ), diff --git a/application/views/Nachrichten.php b/application/views/Nachrichten.php index cf34bfd53..0d0e8e707 100644 --- a/application/views/Nachrichten.php +++ b/application/views/Nachrichten.php @@ -40,6 +40,10 @@ $configArray = [ cis-root="= CIS_ROOT; ?>" :permissions="= htmlspecialchars(json_encode($permissions)); ?>" :config="= htmlspecialchars(json_encode($configArray)); ?>" + + :id ="= htmlspecialchars(json_encode($ids)); ?>" + type-id ="= htmlspecialchars($typeid); ?>" + > diff --git a/application/views/Studentenverwaltung.php b/application/views/Studentenverwaltung.php index 01e611657..1cd28d735 100644 --- a/application/views/Studentenverwaltung.php +++ b/application/views/Studentenverwaltung.php @@ -22,7 +22,8 @@ 'public/css/components/function.css' ], 'customJSs' => [ - 'vendor/vuejs/vuedatepicker_js/vue-datepicker.iife.js' + 'vendor/vuejs/vuedatepicker_js/vue-datepicker.iife.js', + 'vendor/moment/luxonjs/luxon.min.js' #'vendor/npm-asset/primevue/tree/tree.min.js', #'vendor/npm-asset/primevue/toast/toast.min.js' ], @@ -53,6 +54,8 @@ $configArray = [ active-addons="= defined('ACTIVE_ADDONS') ? ACTIVE_ADDONS : ''; ?>" stv-root="= site_url('Studentenverwaltung'); ?>" cis-root="= CIS_ROOT; ?>" + avatar-url="= site_url('Cis/Pub/bild/person/' . getAuthPersonId()); ?>" + logout-url="= site_url('Cis/Auth/logout'); ?>" :permissions="= htmlspecialchars(json_encode($permissions)); ?>" :config="= htmlspecialchars(json_encode($configArray)); ?>" > diff --git a/application/views/system/infocenter/onboarding.php b/application/views/system/infocenter/onboarding.php new file mode 100644 index 000000000..1f5bae847 --- /dev/null +++ b/application/views/system/infocenter/onboarding.php @@ -0,0 +1,47 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Info Center', + 'jquery3' => true, + 'jqueryui1' => true, + 'jquerycheckboxes1' => true, + 'bootstrap3' => true, + 'fontawesome4' => true, + 'sbadmintemplate3' => true, + 'tablesorter2' => true, + 'ajaxlib' => true, + 'filterwidget' => true, + 'navigationwidget' => true, + 'dialoglib' => true, + 'phrases' => array( + 'person' => array('vorname', 'nachname'), + 'ui' => array('bitteEintragWaehlen') + ), + 'customCSSs' => array('public/css/sbadmin2/tablesort_bootstrap.css', 'public/css/infocenter/infocenterPersonDataset.css'), + 'customJSs' => array('public/js/bootstrapper.js', 'public/js/infocenter/rueckstellung.js', 'public/js/infocenter/infocenterPersonDataset.js') + ) + ); +?> + +
';
}
}
-
}
/* else
{
diff --git a/config/global.config-default.inc.php b/config/global.config-default.inc.php
index f24a302cc..37bedbdcb 100644
--- a/config/global.config-default.inc.php
+++ b/config/global.config-default.inc.php
@@ -360,4 +360,8 @@ define('SANCHO_MAIL_HEADER_IMG', 'sancho_header_DEFAULT.jpg');
// footer image for eigene Mails
define('SANCHO_MAIL_FOOTER_IMG', 'sancho_footer_DEFAULT.jpg');
+
+// Gibt an, ob in der StudVW der Status vorgerueckt werden kann
+define('STATUS_VORRUECKEN_ANZEIGEN', true);
+
?>
diff --git a/content/statistik/notenspiegel.php b/content/statistik/notenspiegel.php
index 1a7651296..0901b834f 100644
--- a/content/statistik/notenspiegel.php
+++ b/content/statistik/notenspiegel.php
@@ -62,6 +62,11 @@ if(!$rechte->isBerechtigt('student/noten',$studiengang_kz, 's'))
$semester = isset($_GET['semester'])?$_GET['semester']:'';
$typ = isset($_GET['typ'])?$_GET['typ']:'';
+if(isset($_GET['studiensemester']) && preg_match('/[WS]S[0-9]{4}/', $_GET['studiensemester']))
+{
+ $semester_aktuell = $_GET['studiensemester'];
+}
+
if($semester=='')
die('Bitte ein Semester auswaehlen');
diff --git a/content/statistik/notenspiegel_erweitert.php b/content/statistik/notenspiegel_erweitert.php
index 2849a1895..67097ed22 100644
--- a/content/statistik/notenspiegel_erweitert.php
+++ b/content/statistik/notenspiegel_erweitert.php
@@ -64,6 +64,11 @@ if (!$rechte->isBerechtigt('student/noten', $studiengang_kz, 's'))
$semester = isset($_GET['semester']) ? $_GET['semester'] : '';
$typ = isset($_GET['typ']) ? $_GET['typ'] : '';
+if(isset($_GET['studiensemester']) && preg_match('/[WS]S[0-9]{4}/', $_GET['studiensemester']))
+{
+ $semester_aktuell = $_GET['studiensemester'];
+}
+
if ($semester == '')
die('Bitte ein Semester auswaehlen');
diff --git a/include/File/CSV.php b/include/File/CSV.php
index c4c4d44ad..ea67181f1 100644
--- a/include/File/CSV.php
+++ b/include/File/CSV.php
@@ -178,7 +178,7 @@ class File_CSV
return $field;
}
- if ($quote && $field{0} == $quote && $field{strlen($field)-1} == $quote) {
+ if ($quote && $field[0] == $quote && $field[strlen($field) - 1] == $quote) {
return substr($field, 1, -1);
}
return $field;
@@ -230,7 +230,7 @@ class File_CSV
} elseif ($c == "\n" || $c == "\r") {
$sub = ($prev == "\r") ? 2 : 1;
if ((strlen($buff) >= $sub) &&
- ($buff{strlen($buff) - $sub} == $quote))
+ ($buff[strlen($buff) - $sub] == $quote))
{
$in_quote = false;
}
@@ -312,9 +312,9 @@ class File_CSV
$last =& $fields[count($fields) - 1];
// Fallback to read the line with readQuoted when guess
// that the simple explode won't work right
- if (($last{strlen($last) - 1} == "\n"
- && $last{0} == $conf['quote']
- && $last{strlen(rtrim($last)) - 1} != $conf['quote'])
+ if (($last[strlen($last) - 1] == "\n"
+ && $last[0] == $conf['quote']
+ && $last[strlen(rtrim($last)) - 1] != $conf['quote'])
||
(count($fields) != $conf['fields'])
// XXX perhaps there is a separator inside a quoted field
@@ -511,4 +511,4 @@ class File_CSV
return true;
}
}
-?>
\ No newline at end of file
+?>
diff --git a/include/File/Util.php b/include/File/Util.php
index 941c61441..5474bc2a7 100644
--- a/include/File/Util.php
+++ b/include/File/Util.php
@@ -96,7 +96,7 @@ class File_Util
{
if (File_Util::isAbsolute($path)) {
if (FILE_WIN32) {
- return substr($path, $path{3} == '\\' ? 4 : 3);
+ return substr($path, $path[3] == '\\' ? 4 : 3);
}
return ltrim($path, '/');
}
@@ -182,7 +182,7 @@ class File_Util
if (FILE_WIN32) {
return preg_match('/^[a-zA-Z]:(\\\|\/)/', $path);
}
- return ($path{0} == '/') || ($path{0} == '~');
+ return ($path[0] == '/') || ($path[0] == '~');
}
/**
@@ -244,11 +244,11 @@ class File_Util
} else {
$cwd = getcwd();
$drive = substr($cwd, 0, 2);
- if ($path{0} !== $separator{0}) {
+ if ($path[0] !== $separator[0]) {
$path = substr($cwd, 3) . $separator . $path;
}
}
- } elseif ($path{0} !== $separator) {
+ } elseif ($path[0] !== $separator) {
$path = getcwd() . $separator . $path;
}
@@ -323,7 +323,7 @@ class File_Util
$entries = array();
for ($dir = dir($path); false !== $entry = $dir->read(); ) {
- if ($list & FILE_LIST_DOTS || $entry{0} !== '.') {
+ if ($list & FILE_LIST_DOTS || $entry[0] !== '.') {
$isRef = ($entry === '.' || $entry === '..');
$isDir = $isRef || is_dir($path .'/'. $entry);
if ( ((!$isDir && $list & FILE_LIST_FILES) ||
diff --git a/include/filter.class.php b/include/filter.class.php
index c3d1d6ac1..7100e6562 100644
--- a/include/filter.class.php
+++ b/include/filter.class.php
@@ -240,7 +240,7 @@ class filter extends basis_db
{
//$value->value = preg_replace('/(.*?)selected=.selected./', '$1', $value->value);
//$value->value = preg_replace('/(.*?)\s*[selected=?selected?]/', '$1', $value->value);
- //$value->value = preg_replace('/(.*?)\s*selected="selected"\s*/', '${1}', $value->value);
+ //$value->value = preg_replace('/(.*?)\s*selected="selected"\s*/', '$[1]', $value->value);
//$value->value = preg_replace('/^\s*selected=.*?selected.*?\s*/', ' ', $value->value);
//$value->value = str_replace('selected=', '', $value->value);
diff --git a/include/securimage/WavFile.php b/include/securimage/WavFile.php
index 6d84fc725..d56dbd942 100644
--- a/include/securimage/WavFile.php
+++ b/include/securimage/WavFile.php
@@ -1532,7 +1532,7 @@ class WavFile
} else {
// replace
for ($i = 0; $i < $sampleBytes; ++$i) {
- $this->_samples{$offset + $i} = $sampleBinary{$i};
+ $this->_samples[$offset + $i] = $sampleBinary[$i];
}
}
diff --git a/include/securimage/securimage.php b/include/securimage/securimage.php
index 51d876672..820e8b92f 100644
--- a/include/securimage/securimage.php
+++ b/include/securimage/securimage.php
@@ -1435,7 +1435,7 @@ class Securimage
$length = strlen($code['display']);
for($i = 0; $i < $length; ++$i) {
- $letter = $code['display']{$i};
+ $letter = $code['display'][$i];
$letters[] = $letter;
}
}
diff --git a/public/css/Cis4/Cis.css b/public/css/Cis4/Cis.css
index ff1b181dd..2bb467048 100644
--- a/public/css/Cis4/Cis.css
+++ b/public/css/Cis4/Cis.css
@@ -407,6 +407,7 @@ html {
background-color: var(--fhc-background);
border-color: var(--fhc-border);
padding: var(--fhc-cis-main-py) var(--fhc-cis-main-px);
+ min-width: 0; /* fix flex-grow with tabulator exceeding width */
}
#cis-main .fa-arrow-up-right-from-square {
@@ -854,4 +855,4 @@ html {
#cis-main .modal-footer {
background-color: var(--fhc-secondary);
-}
\ No newline at end of file
+}
diff --git a/public/css/Studentenverwaltung.css b/public/css/Studentenverwaltung.css
index bb2588926..eb6becc15 100644
--- a/public/css/Studentenverwaltung.css
+++ b/public/css/Studentenverwaltung.css
@@ -1,14 +1,38 @@
@import './Fhc.css';
+@import './SvgIcons.css';
@import './components/searchbar/searchbar.css';
@import './components/verticalsplit.css';
@import './components/FilterComponent.css';
@import './components/Tabs.css';
@import './components/Notiz.css';
@import './components/Messages.css';
+@import './components/AppMenu.css';
html {
font-size: .875em;
}
+html.fs_xx-small {
+ font-size: .5em;
+}
+html.fs_x-small {
+ font-size: .625em;
+}
+html.fs_small {
+ font-size: .75em;
+}
+html.fs_normal {
+ font-size: .875em;
+}
+html.fs_big {
+ font-size: 1em;
+}
+html.fs_huge {
+ font-size: 1.125em;
+}
+
+#appMenu {
+ width: 300px;
+}
.navbar-dark .navbar-brand:focus {
box-shadow: 0 0 0 .25rem rgba(13,110,253,.25);
@@ -37,8 +61,10 @@ html {
flex: 1 1 auto;
}
-#sidebarMenu {
- width: 0%;
+#nav-user-btn img {
+ object-fit: contain;
+ height: 2.5rem;
+ width: 2.5rem;
}
.tabulator-row.disabled.tabulator-row-odd .tabulator-cell {
@@ -158,4 +184,4 @@ html {
.tiny-90 div.tox.tox-tinymce {
height: 90% !important;
-}
\ No newline at end of file
+}
diff --git a/public/css/SvgIcons.css b/public/css/SvgIcons.css
new file mode 100644
index 000000000..f25d842a4
--- /dev/null
+++ b/public/css/SvgIcons.css
@@ -0,0 +1,28 @@
+/* Themable Variables */
+:root {
+ --svg-icon-apps: var(--fhc-icon-apps, url('data:image/svg+xml,\
+ '));
+}
+.svg-icon {
+ display: inline-block;
+ width: 1rem;
+ line-height: 1;
+ background-color: currentColor;
+}
+.svg-icon:before {
+ content: "\00a0";
+}
+.svg-icon.svg-icon-apps {
+ -webkit-mask-image: var(--svg-icon-apps);
+ mask-image: var(--svg-icon-apps);
+}
diff --git a/public/css/components/AppMenu.css b/public/css/components/AppMenu.css
new file mode 100644
index 000000000..e142858f8
--- /dev/null
+++ b/public/css/components/AppMenu.css
@@ -0,0 +1,30 @@
+.fhc-app-menu {
+ display: flex;
+ flex-direction: column;
+ padding-left: 0;
+ margin: calc(var(--bs-offcanvas-padding-y) * -1) calc(var(--bs-offcanvas-padding-x) * -1);
+}
+.fhc-app-menu li {
+ display: block;
+ border: var(--bs-border-width) solid var(--bs-border-color);
+}
+.fhc-app-menu li + li {
+ border-top-width: 0;
+}
+.fhc-app-menu li a {
+ display: block;
+ padding: .5rem 1rem;
+ text-decoration: none;
+}
+.fhc-app-menu li a.disabled {
+ --bs-link-opacity: .5;
+}
+.fhc-app-menu li a.active,
+.fhc-app-menu li a:hover {
+ --bs-link-color-rgb: var(--bs-link-hover-color-rgb);
+ background: var(--surface-hover);
+}
+.fhc-app-menu li a.disabled,
+.fhc-app-menu li a.active {
+ pointer-events: none;
+}
diff --git a/public/css/components/primevue.css b/public/css/components/primevue.css
index 5949d6ecc..ac1950334 100644
--- a/public/css/components/primevue.css
+++ b/public/css/components/primevue.css
@@ -5690,3 +5690,32 @@
outline: 0;
box-shadow: 0 0 0 .25rem rgba(13,110,253,.25);
}
+
+/* input-group */
+/* autocomplete */
+.input-group:not(.has-validation) > .dropdown-toggle:nth-last-child(n+3) > .p-autocomplete-input,
+.input-group:not(.has-validation) > .form-floating:not(:last-child) > .form-control > .p-autocomplete-input,
+.input-group:not(.has-validation) > .form-floating:not(:last-child) > .form-select > .p-autocomplete-input,
+.input-group:not(.has-validation) > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating) > .p-autocomplete-input,
+.input-group:not(.has-validation) > .dropdown-toggle:nth-last-child(n+3) > .p-autocomplete > .p-autocomplete-input,
+.input-group:not(.has-validation) > .form-floating:not(:last-child) > .form-control > .p-autocomplete > .p-autocomplete-input,
+.input-group:not(.has-validation) > .form-floating:not(:last-child) > .form-select > .p-autocomplete > .p-autocomplete-input,
+.input-group:not(.has-validation) > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating) > .p-autocomplete > .p-autocomplete-input {
+ border-top-right-radius: 0;
+ border-bottom-right-radius: 0;
+}
+.input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) > .p-autocomplete-input,
+.input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) > .p-autocomplete > .p-autocomplete-input {
+ margin-left: calc(var(--bs-border-width) * -1);
+ border-top-left-radius: 0;
+ border-bottom-left-radius: 0;
+}
+
+.p-inputtext.is-invalid:enabled:hover {
+ border-color: var(--bs-form-invalid-border-color);
+}
+.p-inputtext.is-invalid:enabled:focus,
+.was-validated .p-inputtext:invalid:focus {
+ border-color: var(--bs-form-invalid-border-color);
+ box-shadow: 0 0 0 .25rem rgba(var(--bs-danger-rgb),.25);
+}
diff --git a/public/css/tags.css b/public/css/tags.css
index 8cf306626..9e0d7ee4b 100644
--- a/public/css/tags.css
+++ b/public/css/tags.css
@@ -95,6 +95,12 @@
.modificationdate {
font-style: italic;
- font-size: 0.7em;
+ font-size: 1em;
text-align: left;
}
+
+
+.copy-btn {
+ float: right;
+ margin-top: 3px;
+}
\ No newline at end of file
diff --git a/public/js/api/factory/messages/messages.js b/public/js/api/factory/messages/messages.js
index cec34ad8b..b7b21dd8a 100644
--- a/public/js/api/factory/messages/messages.js
+++ b/public/js/api/factory/messages/messages.js
@@ -38,16 +38,18 @@ export default {
url: 'api/frontend/v1/messages/messages/getMsgVarsLoggedInUser/'
};
},
- getMessageVarsPerson(userParams){
+ getMessageVarsPerson(ids, type_id){
return {
method: 'post',
- url: 'api/frontend/v1/messages/messages/getMessageVarsPerson/' + userParams.id + '/' + userParams.type_id
+ url: 'api/frontend/v1/messages/messages/getMessageVarsPerson/' + type_id,
+ params: {ids}
};
},
- getMsgVarsPrestudent(userParams){
+ getMsgVarsPrestudent(ids, type_id){
return {
method: 'post',
- url: 'api/frontend/v1/messages/messages/getMsgVarsPrestudent/' + userParams.id + '/' + userParams.type_id
+ url: 'api/frontend/v1/messages/messages/getMsgVarsPrestudent/' + type_id,
+ params: {ids}
};
},
getPersonId(params){
@@ -56,28 +58,23 @@ export default {
url: 'api/frontend/v1/messages/messages/getPersonId/' + params.id + '/' + params.type_id
};
},
- getUid(userParams){
+ getDataVorlage(vorlage_kurzbz){
return {
method: 'get',
- url: 'api/frontend/v1/messages/messages/getUid/' + userParams.id + '/' + userParams.type_id
+ url: 'api/frontend/v1/messages/messages/getDataVorlage/' + vorlage_kurzbz
};
},
- getVorlagentext(vorlage_kurzbz){
- return {
- method: 'get',
- url: 'api/frontend/v1/messages/messages/getVorlagentext/' + vorlage_kurzbz
- };
- },
- getNameOfDefaultRecipient(params){
- return {
- method: 'get',
- url: 'api/frontend/v1/messages/messages/getNameOfDefaultRecipient/' + params.id + '/' + params.type_id
- };
- },
- getPreviewText(userParams, params){
+ getNameOfDefaultRecipients(ids, type_id){
return {
method: 'post',
- url: 'api/frontend/v1/messages/messages/getPreviewText/' + userParams.id + '/' + userParams.type_id,
+ url: 'api/frontend/v1/messages/messages/getNameOfDefaultRecipients/' + type_id,
+ params: {ids}
+ };
+ },
+ getPreviewText(type_id, params){
+ return {
+ method: 'post',
+ url: 'api/frontend/v1/messages/messages/getPreviewText/' + type_id,
params
};
},
@@ -87,17 +84,10 @@ export default {
url: 'api/frontend/v1/messages/messages/getReplyData/' + messageId
};
},
- sendMessageFromModalContext(id, params) {
+ sendMessage(type_id, params) {
return {
method: 'post',
- url: 'api/frontend/v1/messages/messages/sendMessage/' + id,
- params
- };
- },
- sendMessage(id, params) {
- return {
- method: 'post',
- url: 'api/frontend/v1/messages/messages/sendMessage/' + id,
+ url: 'api/frontend/v1/messages/messages/sendMessage/' + type_id,
params
};
},
diff --git a/public/js/api/factory/studienplan.js b/public/js/api/factory/studienplan.js
new file mode 100644
index 000000000..550a5211c
--- /dev/null
+++ b/public/js/api/factory/studienplan.js
@@ -0,0 +1,11 @@
+export default {
+
+ getStudienplaeneBySemester(studiengang_kz, studiensemester_kurzbz, ausbildungssemester, orgform_kurzbz)
+ {
+ return {
+ method: 'get',
+ url: 'api/frontend/v1/organisation/studienplan/getBySemester',
+ params: { studiengang_kz, studiensemester_kurzbz, ausbildungssemester, orgform_kurzbz },
+ };
+ }
+}
\ No newline at end of file
diff --git a/public/js/api/factory/studiensemester.js b/public/js/api/factory/studiensemester.js
new file mode 100644
index 000000000..367ec9558
--- /dev/null
+++ b/public/js/api/factory/studiensemester.js
@@ -0,0 +1,11 @@
+export default {
+
+ getAll(order = null, start = null)
+ {
+ return {
+ method: 'get',
+ url: 'api/frontend/v1/organisation/studiensemester/getAll',
+ params: { order, start }
+ };
+ }
+}
\ No newline at end of file
diff --git a/public/js/api/factory/studstatus/leitung.js b/public/js/api/factory/studstatus/leitung.js
index cc6b87d25..7f6bc9f54 100644
--- a/public/js/api/factory/studstatus/leitung.js
+++ b/public/js/api/factory/studstatus/leitung.js
@@ -34,7 +34,7 @@ export default {
url: '/api/frontend/v1/studstatus/leitung/getHistory/' + antrag_id
};
},
- getPrestudents(query, signal) {
+ getPrestudents(query) {
return {
method: 'post',
url: '/api/frontend/v1/studstatus/leitung/getPrestudents',
diff --git a/public/js/api/factory/stv/abschlusspruefung.js b/public/js/api/factory/stv/abschlusspruefung.js
index db8403b48..dcba61887 100644
--- a/public/js/api/factory/stv/abschlusspruefung.js
+++ b/public/js/api/factory/stv/abschlusspruefung.js
@@ -86,13 +86,15 @@ export default {
getMitarbeiter(searchString) {
return {
method: 'get',
- url: 'api/frontend/v1/stv/abschlusspruefung/getMitarbeiter/' + searchString
+ url: 'api/frontend/v1/stv/abschlusspruefung/getMitarbeiter',
+ params: { searchString }
};
},
getPruefer(searchString) {
return {
method: 'get',
- url: 'api/frontend/v1/stv/abschlusspruefung/getPruefer/' + searchString
+ url: 'api/frontend/v1/stv/abschlusspruefung/getPruefer',
+ params: { searchString }
};
},
getNoten() {
@@ -108,16 +110,11 @@ export default {
params: { uids }
};
},
- getAllMitarbeiter(){
+ searchPerson(searchString) {
return {
method: 'get',
- url: 'api/frontend/v1/stv/abschlusspruefung/getAllMitarbeiter/'
+ url: 'api/frontend/v1/stv/abschlusspruefung/searchPerson/',
+ params: { id }
};
},
- getAllPersons(){
- return {
- method: 'get',
- url: 'api/frontend/v1/stv/abschlusspruefung/getAllPersons/'
- };
- }
-};
\ No newline at end of file
+};
diff --git a/public/js/api/factory/stv/app.js b/public/js/api/factory/stv/app.js
index 6fcf46700..d75207c26 100644
--- a/public/js/api/factory/stv/app.js
+++ b/public/js/api/factory/stv/app.js
@@ -16,6 +16,12 @@
*/
export default {
+ configFilter() {
+ return {
+ method: 'get',
+ url: 'api/frontend/v1/stv/config/filter'
+ };
+ },
configStudent() {
return {
method: 'get',
diff --git a/public/js/api/factory/stv/archiv.js b/public/js/api/factory/stv/archiv.js
index ca8f25116..cf380b25d 100644
--- a/public/js/api/factory/stv/archiv.js
+++ b/public/js/api/factory/stv/archiv.js
@@ -39,5 +39,5 @@ export default {
url: 'api/frontend/v1/stv/archiv/delete',
params: {akte_id, studiengang_kz}
};
- }
+ },
};
diff --git a/public/js/api/factory/stv/config.js b/public/js/api/factory/stv/config.js
new file mode 100644
index 000000000..c54b2f8b2
--- /dev/null
+++ b/public/js/api/factory/stv/config.js
@@ -0,0 +1,32 @@
+/**
+ * Copyright (C) 2025 fhcomplete.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see