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); ?> + + +
widgetlib->widget('NavigationWidget'); ?> @@ -74,38 +83,8 @@
- -
-

- p->t('infocenter', 'unrulyPersonFound') . ':'; ?> -

-
- person_id . '
'; - } - ?> -
- -
- - -
-

- p->t('global', 'bewerberVorhanden') . ':'; ?> -

-
- person_id . '
'; - } - ?> -
- -
- +
+ load->view('system/infocenter/personCheck.php', array('unruly' => $unruly, 'duplicate' => $duplicate)); ?>
diff --git a/application/views/system/infocenter/personCheck.php b/application/views/system/infocenter/personCheck.php new file mode 100644 index 000000000..c43a11bed --- /dev/null +++ b/application/views/system/infocenter/personCheck.php @@ -0,0 +1,34 @@ + + + + \ No newline at end of file diff --git a/public/js/api/unrulyperson.js b/public/js/api/checkperson.js similarity index 70% rename from public/js/api/unrulyperson.js rename to public/js/api/checkperson.js index 9e7d16e9f..9cd85840a 100644 --- a/public/js/api/unrulyperson.js +++ b/public/js/api/checkperson.js @@ -3,7 +3,7 @@ export default { try { const payload = {person_id, unruly: unrulyParam} - const url = '/api/frontend/v1/unrulyperson/UnrulyPerson/updatePersonUnrulyStatus'; + const url = '/api/frontend/v1/checkperson/CheckPerson/updatePersonUnrulyStatus'; return this.$fhcApi.post(url, payload, null); } catch (error) { throw error; @@ -13,7 +13,7 @@ export default { filterPerson(payload, base = ''){ try { - const url = base + '/api/frontend/v1/unrulyperson/UnrulyPerson/filterPerson'; + const url = base + '/api/frontend/v1/checkperson/CheckPerson/filterPerson'; return axios.post(url, payload) // return this.$fhcApi.post(url, payload, null); } catch (error) { diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index 214076616..e30772ca7 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -23,7 +23,7 @@ import studstatus from "./studstatus.js"; import stv from "./stv.js"; import notiz from "./notiz.js"; import betriebsmittel from "./betriebsmittel.js"; -import unrulyperson from "./unrulyperson.js"; +import checkperson from "./checkperson.js"; export default { search, @@ -34,5 +34,5 @@ export default { stv, notiz, betriebsmittel, - unrulyperson + checkperson }; \ No newline at end of file diff --git a/public/js/components/Studierendenantrag/Form/AbmeldungStgl.js b/public/js/components/Studierendenantrag/Form/AbmeldungStgl.js index ccb25a632..ca3bb9fbc 100644 --- a/public/js/components/Studierendenantrag/Form/AbmeldungStgl.js +++ b/public/js/components/Studierendenantrag/Form/AbmeldungStgl.js @@ -81,7 +81,7 @@ export default { .then(result => { if(this.unrulyInternal) { - this.$fhcApi.factory.unrulyperson.updatePersonUnrulyStatus(this.data.person_id, true).then( + this.$fhcApi.factory.checkperson.updatePersonUnrulyStatus(this.data.person_id, true).then( (res)=> { if(res?.meta?.status === "success") { this.$fhcAlert.alertSuccess(this.$p.t('studierendenantrag', 'antrag_unruly_updated')) diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js index 186479a8f..35da8f584 100644 --- a/public/js/infocenter/infocenterDetails.js +++ b/public/js/infocenter/infocenterDetails.js @@ -847,4 +847,4 @@ var InfocenterDetails = { { return elementid.substr(elementid.indexOf("_") + 1); } -}; +}; \ No newline at end of file diff --git a/public/js/infocenter/personcheck.js b/public/js/infocenter/personcheck.js new file mode 100644 index 000000000..55ada0b11 --- /dev/null +++ b/public/js/infocenter/personcheck.js @@ -0,0 +1,71 @@ +$(document).ready(function () +{ + if(viewData?.checkPerson?.unruly?.length) { + const unruly = document.getElementById('unruly') + unruly.setAttribute('style', 'display: block;') + } + + if(viewData?.checkPerson?.duplicate?.length) { + const duplicate = document.getElementById('duplicate') + duplicate.setAttribute('style', 'display: block;') + } + + +}); + +var PersonCheck = { + update: function(data) + { + // format date according to db + if(data.gebdatum) { + const [day, month, year] = data.gebdatum.split('.'); + data.gebdatum = year + '-' + month + '-' + day + } + + FHC_AjaxClient.ajaxCallPost( + 'api/frontend/v1/checkperson/CheckPerson/checkUnruly', + data, + { + successCallback: function(response, textStatus, jqXHR) { + if (response?.meta?.status === 'success') + { + PersonCheck._updatedUnruly(response); + } + else + { + FHC_DialogLib.alertError('unruly error'); + } + }, + errorCallback: function() { + FHC_DialogLib.alertWarning("Fehler beim Speichern!"); + } + } + ); + + }, + + _updatedUnruly: function(response) + { + const unruly = document.getElementById('unruly') + + if(response?.data?.retval?.length) { + viewData.checkPerson.unruly = response?.data?.retval + + // replace existing elements + const unrulylist = document.getElementById('unrulylist') + const newUnrulyPeople = [] + viewData.checkPerson.unruly.forEach(u => { + newUnrulyPeople.push(document.createTextNode("Person ID: " + u.person_id)) + newUnrulyPeople.push(document.createElement('br')) + }) + unrulylist.replaceChildren(...newUnrulyPeople) + + // and show it all + unruly.setAttribute('style', 'display: block;') + } else { + // just hide everything + unruly.setAttribute('style', 'display: none;') + } + + }, +} \ No newline at end of file diff --git a/public/js/infocenter/stammdaten.js b/public/js/infocenter/stammdaten.js index d83690b04..c7600f677 100644 --- a/public/js/infocenter/stammdaten.js +++ b/public/js/infocenter/stammdaten.js @@ -14,6 +14,7 @@ $(document).ready(function () $('.saveStammdaten').click(function() { + var kontakt = []; $('.kontakt_input').each(function(){ kontakt.push({ @@ -62,15 +63,16 @@ var Stammdaten = { CALLED_PATH + "/updateStammdaten/", data, { - successCallback: function(data, textStatus, jqXHR) { - if (FHC_AjaxClient.isSuccess(data)) + successCallback: function(response, textStatus, jqXHR) { + if (FHC_AjaxClient.isSuccess(response)) { FHC_DialogLib.alertSuccess("Done!"); Stammdaten._updated(); + PersonCheck.update(data) } else { - FHC_DialogLib.alertError(FHC_AjaxClient.getError(data)); + FHC_DialogLib.alertError(FHC_AjaxClient.getError(response)); } }, errorCallback: function() { @@ -149,6 +151,7 @@ var Stammdaten = { _updated: function() { + $('.kontakt_input').each(function() { var span = $(this).parent('td').children('span'); var value = $(this).val(); diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 27458209a..da7d109dc 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -2670,7 +2670,7 @@ $phrases = array( 'phrases' => array( array( 'sprache' => 'German', - 'text' => 'Unerwünscht', + 'text' => 'Unruly', 'description' => '', 'insertvon' => 'system' ), @@ -5349,7 +5349,7 @@ The invoice will be sent to you again. The amount is only to be trans 'phrases' => array( array( 'sprache' => 'German', - 'text' => 'Unerwünschte Person wurde gefunden', + 'text' => 'Unruly Person wurde gefunden', 'description' => '', 'insertvon' => 'system' ), @@ -20838,7 +20838,7 @@ array( 'phrases' => array( array( 'sprache' => 'German', - 'text' => 'Unerwünscht', + 'text' => 'Unruly', 'description' => '', 'insertvon' => 'system' ), @@ -20858,7 +20858,7 @@ array( 'phrases' => array( array( 'sprache' => 'German', - 'text' => 'Unerwünschte Person Status wurde aktualisiert.', + 'text' => 'Unruly Person Status wurde aktualisiert.', 'description' => '', 'insertvon' => 'system' ), @@ -23219,7 +23219,7 @@ array( 'phrases' => array( array( 'sprache' => 'German', - 'text' => 'Person ist unerwünscht', + 'text' => 'Person ist unruly', 'description' => '', 'insertvon' => 'system' ), @@ -23419,7 +23419,7 @@ array( 'phrases' => array( array( 'sprache' => 'German', - 'text' => 'Person ist unerwünscht', + 'text' => 'Person ist unruly.', 'description' => '', 'insertvon' => 'system' ),