diff --git a/application/controllers/api/frontend/v1/unrulyperson/UnrulyPerson.php b/application/controllers/api/frontend/v1/checkperson/CheckPerson.php similarity index 67% rename from application/controllers/api/frontend/v1/unrulyperson/UnrulyPerson.php rename to application/controllers/api/frontend/v1/checkperson/CheckPerson.php index d1dbea7d8..321893610 100644 --- a/application/controllers/api/frontend/v1/unrulyperson/UnrulyPerson.php +++ b/application/controllers/api/frontend/v1/checkperson/CheckPerson.php @@ -18,13 +18,15 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -class UnrulyPerson extends FHCAPI_Controller +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') + '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(); @@ -48,13 +50,42 @@ class UnrulyPerson extends FHCAPI_Controller } + 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 = null; + $birthdateString = ''; if(array_key_exists( 'nachname', $payload) ) { $nachnameString = $payload['nachname']; @@ -80,16 +111,16 @@ class UnrulyPerson extends FHCAPI_Controller $where = "p.nachname=? "; } - if(isset($vorname) && $vorname != '') + if(isset($vornameString) && $vornameString != '') { $where.= " AND p.vorname~*?"; - $parametersArray[] = $vorname; + $parametersArray[] = $vornameString; } - if(isset($birthdate) && $birthdate != '') + if(isset($birthdateString) && $birthdateString != '') { $where.=" AND p.gebdatum=?"; - $parametersArray[] = $birthdate; + $parametersArray[] = $birthdateString; } if(isset($filterUnruly)) diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index d5cb50a00..f6e41d2e6 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -342,7 +342,7 @@ class InfoCenter extends Auth_Controller $checkUnruly = $this->PersonModel->checkUnruly($persondata['stammdaten']->vorname, $persondata['stammdaten']->nachname, $persondata['stammdaten']->gebdatum); if (isError($checkUnruly)) show_error(getError($checkUnruly)); - $duplicate = array('duplicated' => getData($checkPerson)); + $duplicate = array('duplicate' => getData($checkPerson)); $unruly = array('unruly' => getData($checkUnruly)); $prestudentdata = $this->_loadPrestudentData($person_id); @@ -1289,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 ) @@ -1358,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')); + } + + } } } diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 9f10599fb..42a3b1431 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 diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 53fbda8b5..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); ?> + + +