diff --git a/application/controllers/api/frontend/v1/checkperson/CheckPerson.php b/application/controllers/api/frontend/v1/checkperson/CheckPerson.php new file mode 100644 index 000000000..321893610 --- /dev/null +++ b/application/controllers/api/frontend/v1/checkperson/CheckPerson.php @@ -0,0 +1,141 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +class CheckPerson extends FHCAPI_Controller +{ + public function __construct() + { + parent::__construct([ + 'updatePersonUnrulyStatus' => array('basis/mitarbeiter:rw', 'student/antragfreigabe:rw', 'student/studierendenantrag:rw'), + 'filterPerson' => array('basis/mitarbeiter:rw', 'student/antragfreigabe:rw', 'student/studierendenantrag:rw'), + 'checkUnruly' => array('basis/mitarbeiter:r', 'student/antragfreigabe:r', 'student/studierendenantrag:r', 'infocenter:r'), + 'checkDuplicate' => array('infocenter:r'), + ]); + + $this->_ci =& get_instance(); + $this->_ci->load->model('person/Person_model', 'PersonModel'); + } + + public function updatePersonUnrulyStatus() + { + $data = json_decode($this->input->raw_input_stream, true); + + $person_id = $data['person_id']; + $unruly = $data['unruly']; + + $result = $this->_ci->PersonModel->updateUnruly($person_id, $unruly); + + if(isError($result)) { + $this->terminateWithError($result); + } else if (isSuccess($result)) { + $this->terminateWithSuccess($result); + } + + } + + public function checkDuplicate() { + + $person_id = $this->input->post('person_id'); + + $result = $this->_ci->PersonModel->checkDuplicate($person_id); + + if (isSuccess($result)) + $this->terminateWithSuccess($result); + else + $this->terminateWithError('Error when searching for person'); + + } + + // performs strict check over vorname, nachname, gebdatum + public function checkUnruly() { + + $vorname = $this->input->post('vorname'); + $nachname = $this->input->post('nachname'); + $gebdatum = $this->input->post('gebdatum'); + + $result = $this->_ci->PersonModel->checkUnruly($vorname, $nachname, $gebdatum); + + if (isSuccess($result)) + $this->terminateWithSuccess($result); + else + $this->terminateWithError('Error when searching for person'); + } + + // filters nachname on similarity and vorname/gebdatum are optional + public function filterPerson() { + $payload = json_decode($this->input->raw_input_stream, TRUE); + + $nachnameString = ''; + $vornameString = ''; + $filterUnruly = true; + $birthdateString = ''; + + if(array_key_exists( 'nachname', $payload) ) { + $nachnameString = $payload['nachname']; + } + + if(array_key_exists('vorname', $payload)) { + $vornameString = $payload['vorname']; + } + + if(array_key_exists('unruly', $payload)){ + $filterUnruly = $payload['unruly']; + } + + if(array_key_exists('gebdatum', $payload)) { + // TODO: enable if gebdatum filter for unrulys is desired +// $birthdateString = $payload['gebdatum']; + } + + $parametersArray = array($nachnameString); + $where ="p.nachname~* ? "; + if (mb_strlen($nachnameString) == 2) + { + $where = "p.nachname=? "; + } + + if(isset($vornameString) && $vornameString != '') + { + $where.= " AND p.vorname~*?"; + $parametersArray[] = $vornameString; + } + + if(isset($birthdateString) && $birthdateString != '') + { + $where.=" AND p.gebdatum=?"; + $parametersArray[] = $birthdateString; + } + + if(isset($filterUnruly)) + { + $where.=" AND p.unruly=?"; + $parametersArray[] = $filterUnruly; + } + + $result = $this->_ci->PersonModel->checkUnrulyWhere($where, $parametersArray); + + if (isSuccess($result)) + $this->terminateWithSuccess($result); + else + $this->terminateWithError('Error when searching for person'); + + + } +} \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/studstatus/Abmeldung.php b/application/controllers/api/frontend/v1/studstatus/Abmeldung.php index 875b6484c..aada1f436 100644 --- a/application/controllers/api/frontend/v1/studstatus/Abmeldung.php +++ b/application/controllers/api/frontend/v1/studstatus/Abmeldung.php @@ -184,4 +184,4 @@ class Abmeldung extends FHCAPI_Controller $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 a686f6060..6a373137f 100644 --- a/application/controllers/api/v1/person/Person.php +++ b/application/controllers/api/v1/person/Person.php @@ -264,4 +264,4 @@ class Person extends API_Controller return success('Input data are valid'); } -} +} \ No newline at end of file diff --git a/application/controllers/lehre/Studierendenantrag.php b/application/controllers/lehre/Studierendenantrag.php index d6d6b2c50..107c9af96 100644 --- a/application/controllers/lehre/Studierendenantrag.php +++ b/application/controllers/lehre/Studierendenantrag.php @@ -21,6 +21,7 @@ class Studierendenantrag extends FHC_Controller // Load Models $this->load->model('education/Studierendenantrag_model', 'StudierendenantragModel'); + $this->load->model('person/Person_model', 'PersonModel'); // Load language phrases $this->loadPhrases([ @@ -102,6 +103,7 @@ class Studierendenantrag extends FHC_Controller public function abmeldungstgl($prestudent_id, $studierendenantrag_id = null) { + $this->load->view('lehre/Antrag/Create', [ 'prestudent_id' => $prestudent_id, 'studierendenantrag_id' => $studierendenantrag_id, @@ -185,4 +187,4 @@ class Studierendenantrag extends FHC_Controller return $strRequiredPermissions; } -} +} \ No newline at end of file diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index cf0c6755a..f6e41d2e6 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -337,10 +337,13 @@ class InfoCenter extends Auth_Controller $persondata = $this->_loadPersonData($person_id); $checkPerson = $this->PersonModel->checkDuplicate($person_id); - if (isError($checkPerson)) show_error(getError($checkPerson)); - $duplicate = array('duplicated' => getData($checkPerson)); + $checkUnruly = $this->PersonModel->checkUnruly($persondata['stammdaten']->vorname, $persondata['stammdaten']->nachname, $persondata['stammdaten']->gebdatum); + if (isError($checkUnruly)) show_error(getError($checkUnruly)); + + $duplicate = array('duplicate' => getData($checkPerson)); + $unruly = array('unruly' => getData($checkUnruly)); $prestudentdata = $this->_loadPrestudentData($person_id); @@ -351,7 +354,8 @@ class InfoCenter extends Auth_Controller $persondata, $prestudentdata, $dokumentdata, - $duplicate + $duplicate, + $unruly ); $data[self::FHC_CONTROLLER_ID] = $this->getControllerId(); @@ -1285,67 +1289,28 @@ class InfoCenter extends Auth_Controller $this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern')); $kontakte = $this->input->post('kontakt'); - foreach ($kontakte as $kontakt) - { - $kontaktExists = $this->KontaktModel->loadWhere(array( - 'kontakt_id' => $kontakt['id'], - 'person_id' => $person_id, - )); + if($kontakte) { - if (hasData($kontaktExists)) - { - $kontaktExists = getData($kontaktExists)[0]; + foreach ($kontakte as $kontakt) { + $kontaktExists = $this->KontaktModel->loadWhere(array( + 'kontakt_id' => $kontakt['id'], + 'person_id' => $person_id, + )); - if ($kontaktExists->kontakt === $kontakt['value']) - continue; + if (hasData($kontaktExists)) { + $kontaktExists = getData($kontaktExists)[0]; - $update = $this->KontaktModel->update( - array - ( - 'kontakt_id' => $kontakt['id'] - ), - array - ( - 'kontakt' => isEmptyString($kontakt['value']) ? null : $kontakt['value'], - 'updateamum' => date('Y-m-d H:i:s'), - 'updatevon' => $this->_uid - ) - ); + if ($kontaktExists->kontakt === $kontakt['value']) + continue; - if (isError($update)) - $this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern')); - } - } - - $adressen = $this->input->post('adresse'); - - foreach ($adressen as $adresse) - { - $adresseExists = $this->AdresseModel->loadWhere(array( - 'adresse_id' => $adresse['id'], - 'person_id' => $person_id, - )); - - if (hasData($adresseExists)) - { - $adresse = $adresse['value']; - $adresseExists = getData($adresseExists)[0]; - if ($adresseExists->strasse !== $adresse['strasse'] || - $adresseExists->plz !== $adresse['plz'] || - $adresseExists->ort !== $adresse['ort'] || - $adresseExists->nation !== $adresse['nation']) - { - $update = $this->AdresseModel->update( + $update = $this->KontaktModel->update( array ( - 'adresse_id' => $adresseExists->adresse_id + 'kontakt_id' => $kontakt['id'] ), array ( - 'strasse' => isEmptyString($adresse['strasse']) ? null : $adresse['strasse'], - 'plz' => isEmptyString($adresse['plz']) ? null : $adresse['plz'], - 'ort' => isEmptyString($adresse['ort']) ? null : $adresse['ort'], - 'nation' => isEmptyString($adresse['nation']) ? null : $adresse['nation'], + 'kontakt' => isEmptyString($kontakt['value']) ? null : $kontakt['value'], 'updateamum' => date('Y-m-d H:i:s'), 'updatevon' => $this->_uid ) @@ -1354,7 +1319,48 @@ class InfoCenter extends Auth_Controller if (isError($update)) $this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern')); } + } + } + + $adressen = $this->input->post('adresse'); + + if($adressen) { + + foreach ($adressen as $adresse) { + $adresseExists = $this->AdresseModel->loadWhere(array( + 'adresse_id' => $adresse['id'], + 'person_id' => $person_id, + )); + + if (hasData($adresseExists)) { + $adresse = $adresse['value']; + $adresseExists = getData($adresseExists)[0]; + if ($adresseExists->strasse !== $adresse['strasse'] || + $adresseExists->plz !== $adresse['plz'] || + $adresseExists->ort !== $adresse['ort'] || + $adresseExists->nation !== $adresse['nation']) { + $update = $this->AdresseModel->update( + array + ( + 'adresse_id' => $adresseExists->adresse_id + ), + array + ( + 'strasse' => isEmptyString($adresse['strasse']) ? null : $adresse['strasse'], + 'plz' => isEmptyString($adresse['plz']) ? null : $adresse['plz'], + 'ort' => isEmptyString($adresse['ort']) ? null : $adresse['ort'], + 'nation' => isEmptyString($adresse['nation']) ? null : $adresse['nation'], + 'updateamum' => date('Y-m-d H:i:s'), + 'updatevon' => $this->_uid + ) + ); + + if (isError($update)) + $this->terminateWithJsonError($this->p->t('ui', 'fehlerBeimSpeichern')); + } + + } } } @@ -2383,4 +2389,4 @@ class InfoCenter extends Auth_Controller $this->outputJsonSuccess("Success"); } -} +} \ No newline at end of file diff --git a/application/libraries/AntragLib.php b/application/libraries/AntragLib.php index e45c4ad34..885acac90 100644 --- a/application/libraries/AntragLib.php +++ b/application/libraries/AntragLib.php @@ -930,7 +930,7 @@ class AntragLib public function createWiederholung($prestudent_id, $studiensemester_kurzbz, $insertvon, $repeat) { $result = $this->_ci->StudierendenantragModel->loadIdAndStatusWhere([ - 'prestudent_id' => $prestudent_id, + 'tbl_studierendenantrag.prestudent_id' => $prestudent_id, 'studiensemester_kurzbz'=> $studiensemester_kurzbz, 'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG ]); @@ -1360,7 +1360,7 @@ class AntragLib if (!in_array($result->status_kurzbz, $this->_ci->config->item('antrag_prestudentstatus_whitelist_abmeldung'))) { $result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([ - 'prestudent_id' => $prestudent_id, + 'tbl_studierendenantrag.prestudent_id' => $prestudent_id, 's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_APPROVED ], [ Studierendenantrag_model::TYP_ABMELDUNG, @@ -1372,7 +1372,7 @@ class AntragLib return success(-1); $result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([ - 'prestudent_id' => $prestudent_id, + 'tbl_studierendenantrag.prestudent_id' => $prestudent_id, 's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_PAUSE ], [ Studierendenantrag_model::TYP_ABMELDUNG, @@ -1386,7 +1386,7 @@ class AntragLib return success(0); } - $result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['prestudent_id' => $prestudent_id]); + $result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['tbl_studierendenantrag.prestudent_id' => $prestudent_id]); if (isError($result)) return $result; if (!hasData($result)) @@ -1447,7 +1447,7 @@ class AntragLib && $result->status_kurzbz != 'Unterbrecher') { return success(0); } - $result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['prestudent_id' => $prestudent_id]); + $result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['tbl_studierendenantrag.prestudent_id' => $prestudent_id]); if (isError($result)) return $result; if (!hasData($result)) @@ -1523,7 +1523,7 @@ class AntragLib $datumStatus = $result->datum; if (!in_array($result->status_kurzbz, $this->_ci->config->item('antrag_prestudentstatus_whitelist'))) { $result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([ - 'prestudent_id' => $prestudent_id, + 'tbl_studierendenantrag.prestudent_id' => $prestudent_id, 'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG, 's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_APPROVED ]); @@ -1533,7 +1533,7 @@ class AntragLib return success(-1); $result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([ - 'prestudent_id' => $prestudent_id, + 'tbl_studierendenantrag.prestudent_id' => $prestudent_id, 'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG, 's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_DEREGISTERED ]); @@ -1543,7 +1543,7 @@ class AntragLib return success(-1); $result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([ - 'prestudent_id' => $prestudent_id, + 'tbl_studierendenantrag.prestudent_id' => $prestudent_id, 'typ' => Studierendenantrag_model::TYP_WIEDERHOLUNG, 's.studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_PAUSE ]); @@ -1554,7 +1554,7 @@ class AntragLib return success(0); } - $result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['prestudent_id' => $prestudent_id]); + $result = $this->_ci->StudierendenantragModel->loadWithStatusWhere(['tbl_studierendenantrag.prestudent_id' => $prestudent_id]); if (isError($result)) return $result; if (!hasData($result)) @@ -1607,7 +1607,7 @@ class AntragLib public function getDetailsForLastAntrag($prestudent_id, $typ = null) { $where = [ - 'prestudent_id' => $prestudent_id + 'tbl_studierendenantrag.prestudent_id' => $prestudent_id ]; $types = null; if ($typ) { @@ -2193,4 +2193,4 @@ class AntragLib $result = $this->_ci->StudierendenantraglehrveranstaltungModel->getLvsForPrestudent($prestudent_id, $studiensemester_kurzbz); return $result; } -} +} \ No newline at end of file diff --git a/application/models/crm/Prestudentstatus_model.php b/application/models/crm/Prestudentstatus_model.php index 6405569db..5f0b5876c 100644 --- a/application/models/crm/Prestudentstatus_model.php +++ b/application/models/crm/Prestudentstatus_model.php @@ -289,6 +289,7 @@ class Prestudentstatus_model extends DB_Model $this->addSelect('ss.studienjahr_kurzbz'); $this->addSelect('pers.vorname'); $this->addSelect('pers.nachname'); + $this->addSelect('pers.unruly'); $this->addSelect('TRIM(CONCAT(pers.vorname, \' \', pers.nachname)) AS name'); $this->addSelect('pers.person_id'); $this->addSelect('g.studiengang_kz'); @@ -571,12 +572,12 @@ class Prestudentstatus_model extends DB_Model $this->addOrder('tbl_prestudentstatus.datum', 'DESC'); $this->addOrder('tbl_prestudentstatus.insertamum', 'DESC'); $this->addOrder('tbl_prestudentstatus.ext_id', 'DESC'); - + $this->addLimit(1); $this->db->where('prestudent_id', $prestudent_id); $this->db->where('status_kurzbz', self::STATUS_STUDENT); - + $sql = $this->db->get_compiled_select($this->dbTable); $this->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT'); @@ -587,4 +588,4 @@ class Prestudentstatus_model extends DB_Model 'status_kurzbz' => self::STATUS_BEWERBER ]); } -} +} \ No newline at end of file diff --git a/application/models/education/Studierendenantrag_model.php b/application/models/education/Studierendenantrag_model.php index b7c0667cb..80804f49a 100644 --- a/application/models/education/Studierendenantrag_model.php +++ b/application/models/education/Studierendenantrag_model.php @@ -38,6 +38,7 @@ class Studierendenantrag_model extends DB_Model $this->addSelect('studienjahr_kurzbz'); $this->addSelect('vorname'); $this->addSelect('nachname'); + $this->addSelect('unruly'); $this->addSelect('p.prestudent_id'); $this->addSelect('p.studiengang_kz'); $this->addSelect('semester'); @@ -149,6 +150,7 @@ class Studierendenantrag_model extends DB_Model $this->addSelect('s.studierendenantrag_statustyp_kurzbz status'); $this->addSelect('s.insertvon status_insertvon'); $this->addSelect('t.bezeichnung[(' . $lang . ')] statustyp'); + $this->addSelect('p.unruly AS unruly'); $this->addJoin( 'campus.tbl_studierendenantrag_status s', @@ -158,6 +160,18 @@ class Studierendenantrag_model extends DB_Model 'campus.tbl_studierendenantrag_statustyp t', 's.studierendenantrag_statustyp_kurzbz=t.studierendenantrag_statustyp_kurzbz' ); + $this->addJoin( + 'public.tbl_student st', + 'st.prestudent_id=tbl_studierendenantrag.prestudent_id' + ); + $this->addJoin( + 'public.tbl_benutzer b', + 'st.student_uid=b.uid' + ); + $this->addJoin( + 'public.tbl_person p', + 'b.person_id=p.person_id' + ); if ($types && is_array($types)) { $this->db->where_in('typ', $types); @@ -475,4 +489,4 @@ class Studierendenantrag_model extends DB_Model return hasData($this->load()); } -} +} \ No newline at end of file diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 88813220e..dc925a171 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -294,15 +294,15 @@ class Person_model extends DB_Model { $qry = "SELECT person_id FROM public.tbl_prestudent p - JOIN + JOIN ( SELECT DISTINCT ON(prestudent_id) * FROM public.tbl_prestudentstatus - WHERE prestudent_id IN + WHERE prestudent_id IN ( - SELECT prestudent_id - FROM public.tbl_prestudent - WHERE person_id IN + SELECT prestudent_id + FROM public.tbl_prestudent + WHERE person_id IN ( SELECT p2.person_id FROM public.tbl_person p @@ -316,8 +316,8 @@ class Person_model extends DB_Model ORDER BY prestudent_id, datum DESC, insertamum DESC ) ps USING(prestudent_id) JOIN public.tbl_status USING(status_kurzbz) - WHERE status_kurzbz = 'Interessent' - AND studiengang_kz IN + WHERE status_kurzbz = 'Interessent' + AND studiengang_kz IN ( SELECT studiengang_kz FROM public.tbl_prestudent p @@ -374,5 +374,38 @@ class Person_model extends DB_Model 'prestudent_id' => $prestudent_id ]); } -} + public function checkUnruly($vorname, $nachname, $gebdatum) + { + $qry = "SELECT person_id, vorname, nachname, gebdatum, unruly + FROM tbl_person + WHERE tbl_person.vorname = ? + AND tbl_person.nachname = ? + AND tbl_person.gebdatum = ? + AND tbl_person.unruly = TRUE;"; + + return $this->execQuery($qry, [$vorname, $nachname, $gebdatum]); + } + + public function checkUnrulyWhere($where, $paramsArray) + { + $qry = 'SELECT * + FROM tbl_person p + WHERE '.$where.';'; + + return $this->execQuery($qry, $paramsArray); + } + + public function updateUnruly($person_id, $unruly) + { + $result = $this->update($person_id, array( + 'unruly' => $unruly + )); + + if (isError($result)) { + return error($result->msg, EXIT_ERROR); + } else if (isSuccess($result) && hasData($result)) { + return success($result); + } + } +} \ No newline at end of file diff --git a/application/views/lehre/Antrag/Create.php b/application/views/lehre/Antrag/Create.php index 91b20c9b7..7e8bda874 100644 --- a/application/views/lehre/Antrag/Create.php +++ b/application/views/lehre/Antrag/Create.php @@ -52,4 +52,4 @@ $this->load->view( $this->load->view( 'templates/FHC-Footer', $sitesettings -); +); \ No newline at end of file diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index a8e6e3e13..51b913b6c 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -27,7 +27,8 @@ 'public/js/infocenter/rueckstellung.js', 'public/js/infocenter/zgvUeberpruefung.js', 'public/js/infocenter/docUeberpruefung.js', - 'public/js/infocenter/stammdaten.js' + 'public/js/infocenter/stammdaten.js', + 'public/js/infocenter/personcheck.js' ), 'phrases' => array( 'infocenter', @@ -38,6 +39,14 @@ $this->load->view('templates/FHC-Header', $includesArray); ?> + + +