mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
Interessent anlegen: bugfix Geburtsdatum save, when searching for existing persons, more fields are displayed, form is emptied each time it is opened, adress can only be added, but not overwritten
This commit is contained in:
@@ -441,6 +441,13 @@ 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) {
|
||||
@@ -456,6 +463,33 @@ class Student extends FHCAPI_Controller
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
@@ -471,7 +505,6 @@ class Student extends FHCAPI_Controller
|
||||
|
||||
$this->_validate();
|
||||
|
||||
// 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');
|
||||
@@ -486,6 +519,8 @@ class Student extends FHCAPI_Controller
|
||||
$this->db->trans_begin();
|
||||
|
||||
$result = $this->_addPerson();
|
||||
if (isError($result)) $errors[] = getError($result);
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$person_id = getData($result);
|
||||
@@ -536,7 +571,7 @@ 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'))
|
||||
@@ -551,8 +586,8 @@ class Student extends FHCAPI_Controller
|
||||
private function _addAdresse($person_id)
|
||||
{
|
||||
// Addresse anlegen?
|
||||
$anlegen = $this->input->post('address[func]');
|
||||
if ($anlegen)
|
||||
$anlegen = $this->input->post('address[checked]');
|
||||
if ($anlegen === true)
|
||||
{
|
||||
// Adresse laden
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
@@ -567,46 +602,21 @@ class Student extends FHCAPI_Controller
|
||||
'zustelladresse' => true,
|
||||
];
|
||||
|
||||
if ($anlegen < 0) // Adresse überschreiben
|
||||
{
|
||||
$this->AdresseModel->addSelect('adresse_id');
|
||||
$this->AdresseModel->addJoin('public.tbl_adressentyp', 'typ = adressentyp_kurzbz');
|
||||
$this->AdresseModel->addOrder('zustelladresse', 'DESC');
|
||||
$this->AdresseModel->addOrder('sort');
|
||||
$result = $this->AdresseModel->loadWhere([
|
||||
'person_id' => $person_id
|
||||
]);
|
||||
|
||||
if (isError($result)) return $result;
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$address = getData($result)[0];
|
||||
// wenn neue Adresse, heimatadresse setzen
|
||||
if (!hasData($result)) $data['heimatadresse'] = true;
|
||||
|
||||
$data['updateamum'] = date('c');
|
||||
$data['updatevon'] = getAuthUID();
|
||||
|
||||
return $this->AdresseModel->update($address->adresse_id, $data);
|
||||
}
|
||||
else {
|
||||
//Wenn keine Adrese vorhanden ist dann eine neue Anlegen
|
||||
$anlegen = 1;
|
||||
$data['heimatadresse'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($anlegen > 0) // Adresse hinzufügen
|
||||
{
|
||||
$data['person_id'] = $person_id;
|
||||
$data['insertamum'] = date('c');
|
||||
$data['insertvon'] = getAuthUID();
|
||||
|
||||
// Wenn die Person neu angelegt wird, dann ist die neue Adresse die Heimatadresse
|
||||
if (!isset($data['heimatadresse']))
|
||||
$data['heimatadresse'] = !$this->input->post('person_id');
|
||||
|
||||
return $this->AdresseModel->insert($data);
|
||||
}
|
||||
}
|
||||
|
||||
return success(null);
|
||||
@@ -714,7 +724,7 @@ class Student extends FHCAPI_Controller
|
||||
|
||||
public function requiredIfAddressFunc($value)
|
||||
{
|
||||
if (!$_POST['address']['func'] || $_POST['address']['func'] == 0)
|
||||
if (!isset($_POST['address']['checked']) || !$_POST['address']['checked'])
|
||||
return true;
|
||||
return !!$value;
|
||||
}
|
||||
@@ -733,11 +743,6 @@ class Student extends FHCAPI_Controller
|
||||
return !!$value;
|
||||
}
|
||||
|
||||
public function isValidDate($value)
|
||||
{
|
||||
return isValidDate($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates input data. Terminates with validation errors, if invalid.
|
||||
*/
|
||||
@@ -754,7 +759,7 @@ class Student extends FHCAPI_Controller
|
||||
$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[func]', 'Address', 'required|integer|less_than[2]|greater_than[-2]');
|
||||
//$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')])
|
||||
]);
|
||||
@@ -789,4 +794,14 @@ class Student extends FHCAPI_Controller
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -381,7 +381,6 @@ export default {
|
||||
return false;
|
||||
},
|
||||
actionNewPerson() {
|
||||
this.$refs.newPersonModal.reset();
|
||||
this.$refs.newPersonModal.open();
|
||||
},
|
||||
actionKontaktdatenBearbeiten() {
|
||||
|
||||
@@ -13,9 +13,11 @@ import ApiStudienplan from '../../../../api/factory/studienplan.js';
|
||||
var _uuid = 0;
|
||||
const FORMDATA_DEFAULT = {
|
||||
address: {
|
||||
func: 1,
|
||||
checked: true,
|
||||
nation: 'A'
|
||||
},
|
||||
vorname: '',
|
||||
nachname: '',
|
||||
geburtsnation: 'A',
|
||||
staatsbuergerschaft: 'A',
|
||||
ausbildungssemester: 1,
|
||||
@@ -45,7 +47,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
places: [],
|
||||
formData: FORMDATA_DEFAULT,
|
||||
formData: null,
|
||||
suggestions: {},
|
||||
person: null,
|
||||
semester: [],
|
||||
@@ -63,7 +65,7 @@ export default {
|
||||
return this.formData;
|
||||
},
|
||||
orte() {
|
||||
return this.places.filter(ort => ort.name == this.formData.address.gemeinde);
|
||||
return this.places.filter(ort => ort.name == this.formData?.address.gemeinde);
|
||||
},
|
||||
gemeinden() {
|
||||
return Object.values(this.places.reduce((res,place) => {
|
||||
@@ -73,7 +75,7 @@ export default {
|
||||
},
|
||||
formDataStg: {
|
||||
get() {
|
||||
return this.formData.studiengang_kz !== undefined ? this.formData.studiengang_kz : this.studiengangKz;
|
||||
return this.formData?.studiengang_kz !== undefined ? this.formData?.studiengang_kz : this.studiengangKz;
|
||||
},
|
||||
set(v) {
|
||||
this.formData.studiengang_kz = v;
|
||||
@@ -81,7 +83,7 @@ export default {
|
||||
},
|
||||
formDataSem: {
|
||||
get() {
|
||||
return this.formData.studiensemester_kurzbz !== undefined ? this.formData.studiensemester_kurzbz : this.studiensemesterKurzbz;
|
||||
return this.formData?.studiensemester_kurzbz !== undefined ? this.formData?.studiensemester_kurzbz : this.studiensemesterKurzbz;
|
||||
},
|
||||
set(v) {
|
||||
this.formData.studiensemester_kurzbz = v;
|
||||
@@ -101,10 +103,10 @@ export default {
|
||||
this.$refs.modal.show();
|
||||
},
|
||||
reset() {
|
||||
this.formData = FORMDATA_DEFAULT;
|
||||
this.formData = JSON.parse(JSON.stringify(FORMDATA_DEFAULT));
|
||||
this.person = null;
|
||||
this.suggestions = [];
|
||||
this.$refs.form.clearValidation();
|
||||
if (this.$refs.form) this.$refs.form.clearValidation();
|
||||
},
|
||||
loadSuggestions() {
|
||||
if (this.abortController.suggestions)
|
||||
@@ -116,9 +118,9 @@ export default {
|
||||
|
||||
this.$api
|
||||
.call(ApiStvStudents.getPerson({
|
||||
vorname: this.formData.vorname,
|
||||
nachname: this.formData.nachname,
|
||||
gebdatum: this.formData.gebdatum
|
||||
vorname: this.formData?.vorname,
|
||||
nachname: this.formData?.nachname,
|
||||
gebdatum: this.formData?.gebdatum
|
||||
}), {
|
||||
signal: this.abortController.suggestions.signal
|
||||
})
|
||||
@@ -137,12 +139,12 @@ export default {
|
||||
loadPlaces() {
|
||||
if (this.abortController.places)
|
||||
this.abortController.places.abort();
|
||||
if (this.formData.address.nation != 'A' || !this.formData.address.plz)
|
||||
if (this.formData?.address?.nation != 'A' || !this?.formData?.address?.plz)
|
||||
return;
|
||||
|
||||
this.abortController.places = new AbortController();
|
||||
this.$refs.form.call(
|
||||
ApiStvAddress.getPlaces(this.formData.address.plz)
|
||||
ApiStvAddress.getPlaces(this.formData?.address.plz)
|
||||
//~ undefined,
|
||||
//~ {
|
||||
//~ signal: this.abortController.places.signal
|
||||
@@ -164,13 +166,13 @@ export default {
|
||||
.call(ApiStudienplan.getStudienplaeneBySemester(
|
||||
this.formDataStg,
|
||||
this.formDataSem,
|
||||
this.formData.ausbildungssemester,
|
||||
this.formData.orgform_kurzbz
|
||||
this.formData?.ausbildungssemester,
|
||||
this.formData?.orgform_kurzbz
|
||||
))
|
||||
.then(result => result.data || [])
|
||||
.then(result => {
|
||||
this.studienplaene = result;
|
||||
if (this.formData.studienplan_id !== '' && !this.studienplaene.filter(plan => plan.studienplan_id == this.formData.studienplan_id).length)
|
||||
if (this.formData?.studienplan_id !== '' && !this.studienplaene.filter(plan => plan.studienplan_id == this.formData?.studienplan_id).length)
|
||||
this.formData.studienplan_id = '';
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -184,10 +186,10 @@ export default {
|
||||
}
|
||||
},
|
||||
changeAddressNation(e) {
|
||||
if (this.formData['geburtsnation'] == this.formData['address']['nation'])
|
||||
this.formData['geburtsnation'] = e.target.value;
|
||||
if (this.formData['staatsbuergerschaft'] == this.formData['address']['nation'])
|
||||
this.formData['staatsbuergerschaft'] = e.target.value;
|
||||
if (this.formData.geburtsnation == this.formData?.address.nation)
|
||||
this.formData.geburtsnation = e.target.value;
|
||||
if (this.formData.staatsbuergerschaft == this.formData?.address.nation)
|
||||
this.formData.staatsbuergerschaft = e.target.value;
|
||||
this.loadPlaces();
|
||||
},
|
||||
send(e) {
|
||||
@@ -216,11 +218,23 @@ export default {
|
||||
setPerson(suggestion)
|
||||
{
|
||||
this.person = suggestion;
|
||||
this.formData.address.func = -1;
|
||||
this.formData.address.checked = false;
|
||||
},
|
||||
dateFormatter(val)
|
||||
{
|
||||
if (!val)
|
||||
return '';
|
||||
let date = new Date(val);
|
||||
return date.toLocaleDateString('de-AT', {
|
||||
"day": "2-digit",
|
||||
"month": "2-digit",
|
||||
"year": "numeric"
|
||||
});
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.uuid = _uuid++;
|
||||
this.reset();
|
||||
this.$api.call(ApiStudiensemester.getAll())
|
||||
.then(result => result.data || [])
|
||||
.then(result => {
|
||||
@@ -282,9 +296,17 @@ export default {
|
||||
</form-input>
|
||||
</div>
|
||||
</div>
|
||||
<!-- TODO(chris): more details -->
|
||||
<table class="table caption-top table-striped table-hover">
|
||||
<table class="table caption-top table-striped table-hover" >
|
||||
<caption>{{ $p.t('person', 'personExistiertPruefung') }}</caption>
|
||||
<thead v-if="suggestions?.length">
|
||||
<th>{{ $p.t('person', 'nachname') }}</th>
|
||||
<th>{{ $p.t('person', 'vorname') }}</th>
|
||||
<th>{{ $p.t('person', 'weitereVornamen') }}</th>
|
||||
<th>{{ $p.t('person', 'geburtsdatum') }}</th>
|
||||
<th>{{ $p.t('person', 'geschlecht') }}</th>
|
||||
<th>{{ $p.t('person', 'adresse') }}</th>
|
||||
<th>Status</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(suggestion, index) in suggestions"
|
||||
@@ -293,8 +315,21 @@ export default {
|
||||
@click="(index == 2) ? suggestions.shift() : setPerson(suggestion)"
|
||||
v-accessibility:tab.vertical
|
||||
>
|
||||
<td>{{suggestion.vorname + ' ' + suggestion.nachname}}</td>
|
||||
<td></td>
|
||||
<td>{{ suggestion.nachname }}</td>
|
||||
<td>{{ suggestion.vorname }}</td>
|
||||
<td>{{ suggestion.vornamen }}</td>
|
||||
<td>{{ dateFormatter(suggestion.gebdatum) }}</td>
|
||||
<td>{{ suggestion.geschlecht_bezeichnung }}</td>
|
||||
<td>
|
||||
<div v-for="adresse in suggestion.adressen">
|
||||
{{ (adresse.plz ?? '') + (adresse.plz && adresse.ort ? ' ' : '') + (adresse.ort ?? '') + (adresse.ort && adresse.strasse ? ', ' : '') + (adresse.strasse ?? '') }}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div v-for="status in suggestion.status">
|
||||
{{ status.status_kurzbz + " " + status.studiengang_kuerzel }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -422,19 +457,18 @@ export default {
|
||||
<div class="row">
|
||||
<div class="col-sm-6 mb-3">
|
||||
<form-input
|
||||
type="select"
|
||||
id="stv-list-new-address-func"
|
||||
name="address[func]"
|
||||
v-model="formData['address']['func']"
|
||||
:label="$p.t('person', 'adresseHinzufuegen')"
|
||||
type="checkbox"
|
||||
id="stv-new-adresse"
|
||||
name="adresseChecked"
|
||||
v-model="formData['address']['checked']"
|
||||
value="true"
|
||||
>
|
||||
<option value="-1" v-if="person">{{ $p.t('person', 'bestehendeAdresseUeberschreiben') }}</option>
|
||||
<option value="1">{{ $p.t('person', 'adresseHinzufuegen') }}</option>
|
||||
<option value="0">{{ $p.t('person', 'adresseNichtAnlegen') }}</option>
|
||||
</form-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<fieldset v-if="formData['address']['func'] != 0">
|
||||
<fieldset v-if="formData['address']['checked']">
|
||||
<hr>
|
||||
<legend>Adresse</legend>
|
||||
<div class="row">
|
||||
<div class="col-sm-4 mb-3">
|
||||
@@ -519,6 +553,7 @@ export default {
|
||||
</form-input>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
</fieldset>
|
||||
|
||||
<div class="row">
|
||||
@@ -679,7 +714,7 @@ export default {
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-10 mb-3">
|
||||
<div class="form-check">
|
||||
<div>
|
||||
<form-input
|
||||
label="Incoming"
|
||||
type="checkbox"
|
||||
@@ -696,7 +731,7 @@ export default {
|
||||
</template>
|
||||
</template>
|
||||
<template #footer>
|
||||
<button v-if="person !== null" type="button" class="btn btn-secondary" @click="person = null; formData.address.func = 1;"><i class="fa fa-chevron-left"></i>{{ $p.t('ui', 'zurueck') }}</button>
|
||||
<button v-if="person !== null" type="button" class="btn btn-secondary" @click="person = null; formData.address.checked = true;"><i class="fa fa-chevron-left"></i>{{ $p.t('ui', 'zurueck') }}</button>
|
||||
<button type="submit" class="btn btn-primary">{{ person === null || personOnly ? $p.t('person', 'personAnlegen') : $p.t('lehre', 'interessentAnlegen') }}</button>
|
||||
</template>
|
||||
</bs-modal>
|
||||
|
||||
Reference in New Issue
Block a user