renamed unrulyPerson api to checkPerson; built in logic into infoCenterDetails to trigger a number of checks about any changed data in the info center (in this case unruly) and update the page accordingly; Also fixed a bug when saving stammdaten without kontakt entries;

This commit is contained in:
Johann Hoffmann
2024-09-17 14:09:49 +02:00
parent 27c312d7d3
commit 79ea8c4521
12 changed files with 235 additions and 115 deletions
@@ -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))
@@ -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'));
}
}
}
}
+7 -7
View File
@@ -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
@@ -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);
?>
<script>
// Embed PHP data into JS as JSON to access from script files
const viewData = {
checkPerson: <?php echo json_encode(array('unruly' => $unruly, 'duplicate' => $duplicate)); ?>,
};
</script>
<div id="wrapper">
<?php echo $this->widgetlib->widget('NavigationWidget'); ?>
@@ -74,38 +83,8 @@
</div>
</div>
</div>
<?php if (!is_null($unruly)): ?>
<div class="row alert-info">
<h3 class="header col-lg-12">
<?php echo $this->p->t('infocenter', 'unrulyPersonFound') . ':'; ?>
</h3>
<div class="text-left col-lg-12">
<?php
foreach ($unruly as $unruled)
{
echo 'Person ID: ' . $unruled->person_id . '<br />';
}
?>
</div>
</div>
<?php endif; ?>
<?php if (!is_null($duplicated)): ?>
<div class="row alert-warning">
<h3 class="header col-lg-12">
<?php echo $this->p->t('global', 'bewerberVorhanden') . ':'; ?>
</h3>
<div class="text-left col-lg-12">
<?php
foreach ($duplicated as $duplicate)
{
echo 'Person ID: ' . $duplicate->person_id . '<br />';
}
?>
</div>
</div>
<?php endif; ?>
<br/>
<?php $this->load->view('system/infocenter/personCheck.php', array('unruly' => $unruly, 'duplicate' => $duplicate)); ?>
<br/>
<section>
<div class="row">
@@ -0,0 +1,34 @@
<div class="row alert-info" id="unruly" style="display: none;">
<h3 class="header col-lg-12">
<?php echo $this->p->t('infocenter', 'unrulyPersonFound') . ':'; ?>
</h3>
<div class="text-left col-lg-12" id="unrulylist">
<?php
if($unruly) {
foreach ($unruly as $unruled)
{
echo '<a>Person ID: ' . $unruled->person_id . '<a/><br />';
}
}
?>
</div>
</div>
<div class="row alert-warning" id="duplicate" style="display: none;">
<h3 class="header col-lg-12">
<?php echo $this->p->t('global', 'bewerberVorhanden') . ':'; ?>
</h3>
<div class="text-left col-lg-12" id="duplicatelist">
<?php
if($duplicate) {
foreach ($duplicate as $dupe)
{
echo '<a>Person ID: ' . $dupe->person_id . '<a/><br />';
}
}
?>
</div>
</div>
@@ -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) {
+2 -2
View File
@@ -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
};
@@ -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'))
+1 -1
View File
@@ -847,4 +847,4 @@ var InfocenterDetails = {
{
return elementid.substr(elementid.indexOf("_") + 1);
}
};
};
+71
View File
@@ -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;')
}
},
}
+6 -3
View File
@@ -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();
+6 -6
View File
@@ -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. <u><strong>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'
),