refactor Tab Kontakt api Controller, Phrases alerts

This commit is contained in:
ma0068
2024-04-02 09:12:26 +02:00
parent 3023cd2e94
commit 2d88ee031c
6 changed files with 975 additions and 272 deletions
@@ -0,0 +1,710 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \DateTime as DateTime;
class Kontakt extends FHCAPI_Controller
{
public function __construct()
{
parent::__construct([
'getAdressen' => ['admin:r', 'assistenz:r'],
'addNewAddress' => ['admin:r', 'assistenz:r'],
'addNewContact' => ['admin:r', 'assistenz:r'],
'addNewBankverbindung' => ['admin:r', 'assistenz:r'],
'updateAddress' => ['admin:r', 'assistenz:r'],
'updateContact' => ['admin:r', 'assistenz:r'],
'updateBankverbindung' => ['admin:r', 'assistenz:r'],
'loadAddress' => ['admin:r', 'assistenz:r'],
'loadContact' => ['admin:r', 'assistenz:r'],
'loadBankverbindung' => ['admin:r', 'assistenz:r'],
'deleteAddress' => ['admin:r', 'assistenz:r'],
'deleteContact' => ['admin:r','assistenz:r'],
'deleteBankverbindung' => ['admin:r','assistenz:r'],
'getAdressentypen' => ['admin:r', 'assistenz:r'],
'getKontakttypen' => ['admin:r', 'assistenz:r'],
'getFirmen' => ['admin:r', 'assistenz:r'],
'getStandorte' => ['admin:r', 'assistenz:r'],
'getKontakte' => ['admin:r', 'assistenz:r'],
'getBankverbindung' => ['admin:r', 'assistenz:r'],
]);
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
$this->load->library('form_validation');
// Load language phrases
$this->loadPhrases([
'ui'
]);
}
public function getAdressen($person_id)
{
$this->load->model('person/Adresse_model', 'AdresseModel');
$this->AdresseModel->addSelect('public.tbl_adresse.*');
$this->AdresseModel->addSelect('t.*');
$this->AdresseModel->addSelect('f.firma_id');
$this->AdresseModel->addSelect('f.name as firmenname');
$this->AdresseModel->addJoin('public.tbl_adressentyp t', 'ON (t.adressentyp_kurzbz = public.tbl_adresse.typ)');
$this->AdresseModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = public.tbl_adresse.firma_id)', 'LEFT');
$result = $this->AdresseModel->loadWhere(
array('person_id' => $person_id)
);
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function addNewAddress($person_id)
{
$_POST = json_decode($this->input->raw_input_stream, true);
$this->form_validation->set_rules('plz', 'PLZ', 'required|numeric', [
'required' => $this->p->t('ui','error_fieldRequired',['field' => 'PLZ']),
'numeric' => $this->p->t('ui','error_fieldNotNumeric',['field' => 'PLZ'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$this->load->model('person/Adresse_model', 'AdresseModel');
$uid = getAuthUID();
$co_name = isset($_POST['co_name']) ? $_POST['co_name'] : null;
$strasse = isset($_POST['strasse']) ? $_POST['strasse'] : null;
$ort = isset($_POST['ort']) ? $_POST['ort'] : null;
$gemeinde = isset($_POST['gemeinde']) ? $_POST['gemeinde'] : null;
$nation = isset($_POST['nation']) ? $_POST['nation'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
$typ = isset($_POST['typ']) ? $_POST['typ'] : null;
$anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null;
if(isset($_POST['firma']))
{
$firma_id = $_POST['firma']['firma_id'];
}
else
$firma_id = null;
$result = $this->AdresseModel->insert(
[
'person_id' => $person_id,
'strasse' => $strasse,
'insertvon' => $uid,
'insertamum' => date('c'),
'plz' => $_POST['plz'],
'ort' => $ort,
'gemeinde' => $gemeinde,
'nation' => $nation,
'heimatadresse' => $_POST['heimatadresse'],
'zustelladresse' => $_POST['zustelladresse'],
'co_name' => $co_name,
'typ' => $typ,
'firma_id' => $firma_id,
'name' => $name,
'rechnungsadresse' => $_POST['rechnungsadresse'],
'anmerkung' => $anmerkung
]
);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function updateAddress($address_id)
{
$uid = getAuthUID();
$_POST = json_decode($this->input->raw_input_stream, true);
$this->form_validation->set_rules('plz', 'PLZ', 'required|numeric', [
'required' => $this->p->t('ui','error_fieldRequired',['field' => 'PLZ']),
'numeric' => $this->p->t('ui','error_fieldNotNumeric',['field' => 'PLZ'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$this->load->model('person/Adresse_model', 'AdresseModel');
if(!$address_id)
{
return $this->terminateWithError($this->p->t('ui','error_missingId',['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL);
}
if(isset($_POST['firma']))
{
$firma_id = $_POST['firma']['firma_id'];
}
else
$firma_id = null;
$person_id = isset($_POST['person_id']) ? $_POST['person_id'] : null;
$co_name = isset($_POST['co_name']) ? $_POST['co_name'] : null;
$strasse = isset($_POST['strasse']) ? $_POST['strasse'] : null;
$ort = isset($_POST['ort']) ? $_POST['ort'] : null;
$gemeinde = isset($_POST['gemeinde']) ? $_POST['gemeinde'] : null;
$nation = isset($_POST['nation']) ? $_POST['nation'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
$typ = isset($_POST['typ']) ? $_POST['typ'] : null;
$anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null;
$result = $this->AdresseModel->update(
[
'adresse_id' => $address_id
],
[ 'person_id' => $person_id,
'strasse' => $strasse,
'updatevon' => $uid,
'updateamum' => date('c'),
'plz' => $_POST['plz'],
'ort' => $ort,
'gemeinde' => $gemeinde,
'nation' => $nation,
'heimatadresse' => $_POST['heimatadresse'],
'zustelladresse' => $_POST['zustelladresse'],
'co_name' => $co_name,
'typ' => $typ,
'firma_id' => $firma_id,
'name' => $name,
'rechnungsadresse' => $_POST['rechnungsadresse'],
'anmerkung' => $anmerkung
]
);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function loadAddress($adresse_id)
{
$this->load->model('person/Adresse_model', 'AdresseModel');
$this->AdresseModel->addSelect('public.tbl_adresse.*');
$this->AdresseModel->addSelect('t.*');
$this->AdresseModel->addSelect('f.firma_id');
$this->AdresseModel->addSelect('f.name as firmenname');
$this->AdresseModel->addJoin('public.tbl_adressentyp t', 'ON (t.adressentyp_kurzbz = public.tbl_adresse.typ)');
$this->AdresseModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = public.tbl_adresse.firma_id)', 'LEFT');
$this->AdresseModel->addLimit(1);
$result = $this->AdresseModel->loadWhere(
array('adresse_id' => $adresse_id)
);
if (isError($result)) {
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if (!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId',['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess(current(getData($result)) ? : null);
}
public function deleteAddress($adresse_id)
{
$this->load->model('person/Adresse_model', 'AdresseModel');
$result = $this->AdresseModel->delete(
array('adresse_id' => $adresse_id)
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if (!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId',['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL);
}
//return $this->outputJsonSuccess(current(getData($result)));
return $this->terminateWithSuccess(current(getData($result)) ? : null);
}
public function getAdressentypen()
{
$this->load->model('person/Adressentyp_model', 'AdressentypModel');
$result = $this->AdressentypModel->load();
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess(getData($result) ?: []);
}
public function getFirmen($searchString)
{
$this->load->model('ressource/firma_model', 'FirmaModel');
$result = $this->FirmaModel->searchFirmen($searchString);
if (isError($result)) {
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess($result ?: []);
}
public function getStandorte($searchString)
{
$this->load->model('organisation/standort_model', 'StandortModel');
$result = $this->StandortModel->searchStandorte($searchString);
if (isError($result)) {
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess($result ?: []);
}
public function getKontakte($person_id)
{
$this->load->model('person/Kontakt_model', 'KontaktModel');
$this->load->model('organisation/standort_model', 'StandortModel');
$this->KontaktModel->addSelect("*,
TO_CHAR (CASE
WHEN public.tbl_kontakt.updateamum >= public.tbl_kontakt.insertamum
THEN public.tbl_kontakt.updateamum
ELSE public.tbl_kontakt.insertamum
END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate");
$this->StandortModel->addJoin('public.tbl_standort st', 'ON (public.tbl_kontakt.standort_id = st.standort_id)', 'LEFT');
$result = $this->KontaktModel->loadWhere(
array('person_id' => $person_id)
);
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function getKontakttypen()
{
$this->load->model('person/Kontakttyp_model', 'KontakttypModel');
$result = $this->KontakttypModel->load();
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
} else {
$this->terminateWithSuccess(getData($result) ?: []);
}
}
public function loadContact($kontakt_id)
{
$this->load->model('person/Kontakt_model', 'KontaktModel');
$this->KontaktModel->addSelect('public.tbl_kontakt.*');
$this->KontaktModel->addSelect('st.kurzbz');
$this->KontaktModel->addJoin('public.tbl_standort st', 'ON (public.tbl_kontakt.standort_id = st.standort_id)', 'LEFT');
$this->KontaktModel->addLimit(1);
$result = $this->KontaktModel->loadWhere(
array('kontakt_id' => $kontakt_id)
);
if (isError($result)) {
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if (!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId',['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL);
}
// $this->outputJsonSuccess(current(getData($result)));
$this->terminateWithSuccess(current(getData($result)));
}
public function addNewContact($person_id)
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
if(($_POST['kontakttyp'] == 'email' && isset($_POST['kontakt'])))
$this->form_validation->set_rules('kontakt', 'Kontakt', 'valid_email', [
'valid_email' => $this->p->t('ui','error_fieldNoValidEmail',['field' => 'Kontakt'])
]);
else
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required', [
'required' => $this->p->t('ui','error_fieldRequired',['field' => 'Kontakt'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$this->load->model('person/Kontakt_model', 'KontaktModel');
if(isset($_POST['standort']))
{
$standort_id = $_POST['standort']['standort_id'];
}
else
$standort_id = null;
$uid = getAuthUID();
$kontakttyp = $this->input->post('kontakttyp');
$anmerkung = $this->input->post('anmerkung');
$kontakt = $this->input->post('kontakt');
$ext_id = $this->input->post('ext_id');
$result = $this->KontaktModel->insert(
[
'person_id' => $person_id,
'kontakttyp' => $kontakttyp,
'anmerkung' => $anmerkung,
'kontakt' => $kontakt,
'zustellung' => $_POST['zustellung'],
'insertvon' => $uid,
'insertamum' => date('c'),
'standort_id' => $standort_id,
'ext_id' => $ext_id
]
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function updateContact($kontakt_id)
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$this->load->model('person/Kontakt_model', 'KontaktModel');
if(!$kontakt_id)
{
return $this->terminateWithError($this->p->t('ui','error_missingId',['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL);
}
if(($_POST['kontakttyp'] == 'email' && isset($_POST['kontakt'])))
$this->form_validation->set_rules('kontakt', 'Kontakt', 'valid_email', [
'valid_email' => $this->p->t('ui','error_fieldNoValidEmail',['field' => 'Kontakt'])
]);
else
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required', [
'required' => $this->p->t('ui','error_fieldRequired',['field' => 'Kontakt'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
if(isset($_POST['standort']))
{
$standort_id = $_POST['standort']['standort_id'];
}
else
$standort_id = null;
$uid = getAuthUID();
$kontakttyp = $this->input->post('kontakttyp');
$anmerkung = $this->input->post('anmerkung');
$kontakt = $this->input->post('kontakt');
$ext_id = $this->input->post('ext_id');
$person_id = $this->input->post('person_id');
$result = $this->KontaktModel->update(
[
'kontakt_id' => $kontakt_id
],
[
'person_id' => $person_id,
'kontakttyp' => $kontakttyp,
'anmerkung' => $anmerkung,
'kontakt' => $kontakt,
'zustellung' => $_POST['zustellung'],
'insertvon' => $uid,
'insertamum' => date('c'),
'standort_id' => $standort_id,
'ext_id' => $ext_id
]
);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function deleteContact($kontakt_id)
{
$this->load->model('person/Kontakt_model', 'KontaktModel');
$result = $this->KontaktModel->delete(
array('kontakt_id' => $kontakt_id)
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId',['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(current(getData($result)) ? : null);
}
public function getBankverbindung($person_id)
{
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
$this->BankverbindungModel->addSelect('*');
$result = $this->BankverbindungModel->loadWhere(
array('person_id' => $person_id)
);
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function addNewBankverbindung($person_id)
{
$this->load->library('form_validation');
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$this->form_validation->set_rules('iban', 'IBAN', 'required', [
'required' => $this->p->t('ui','error_fieldRequired',['field' => 'IBAN'])
]);
$this->form_validation->set_rules('typ', 'TYP', 'required', [
'required' => $this->p->t('ui','error_fieldRequired',['field' => 'TYP'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
$ext_id = $this->input->post('ext_id');
$oe_kurzbz = $this->input->post('oe_kurzbz');
$orgform_kurzbz = $this->input->post('orgform_kurzbz');
$name = $this->input->post('name');
$anschrift = $this->input->post('anschrift');
$bic = $this->input->post('bic');
$blz = $this->input->post('blz ');
$kontonr = $this->input->post('kontonr');
$result = $this->BankverbindungModel->insert(
[
'person_id' => $person_id,
'name' => $name,
'anschrift' => $anschrift,
'bic' => $bic,
'iban' => $_POST['iban'],
'blz' => $blz,
'kontonr' => $kontonr,
'insertvon' => 'uid',
'insertamum' => date('c'),
'typ' => $_POST['typ'],
'verrechnung' => $_POST['verrechnung'],
'ext_id' => $ext_id,
'oe_kurzbz' => $oe_kurzbz,
'orgform_kurzbz' => $orgform_kurzbz
]
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function loadBankverbindung($bankverbindung_id)
{
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
$this->BankverbindungModel->addSelect('*');
$this->BankverbindungModel->addLimit(1);
$result = $this->BankverbindungModel->loadWhere(
array('bankverbindung_id' => $bankverbindung_id)
);
if (isError($result))
{
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if (!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId',['id'=> 'Bankverbindung_id']), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess(current(getData($result)));
}
public function updateBankverbindung($bankverbindung_id)
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$this->form_validation->set_rules('iban', 'IBAN', 'required', [
'required' => $this->p->t('ui','error_fieldRequired',['field' => 'IBAN'])
]);
$this->form_validation->set_rules('typ', 'TYP', 'required', [
'required' => $this->p->t('ui','error_fieldRequired',['field' => 'TYP'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
if(!$bankverbindung_id)
{
return $this->terminateWithError($this->p->t('ui','error_missingId',['id'=> 'Bankverbindung_id']), self::ERROR_TYPE_GENERAL);
}
$uid = getAuthUID();
$result = $this->BankverbindungModel->update(
[
'bankverbindung_id' => $bankverbindung_id
],
[
'person_id' => $_POST['person_id'],
'name' => $_POST['name'],
'anschrift' => $_POST['anschrift'],
'bic' => $_POST['bic'],
'iban' => $_POST['iban'],
'blz' => $_POST['blz'],
'kontonr' => $_POST['kontonr'],
'updatevon' => $uid,
'updateamum' => date('c'),
'typ' => $_POST['typ'],
'verrechnung' => $_POST['verrechnung'],
'ext_id' => $_POST['ext_id'],
'oe_kurzbz' => $_POST['oe_kurzbz'],
'orgform_kurzbz' => $_POST['orgform_kurzbz']
]
);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function deleteBankverbindung($bankverbindung_id)
{
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
$result = $this->BankverbindungModel->delete(
array('bankverbindung_id' => $bankverbindung_id)
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if (!hasData($result))
{
$this->outputJson($result);
}
return $this->terminateWithSuccess(current(getData($result)) ? : null);
}
/* public function plz_required($value)
{
if (empty($value)) {
$this->form_validation->set_message('plz_required', $this->p->t('ui','error_fieldRequired',['field' => 'PLZ']));
return false;
}
else
{
return true;
}
}*/
/* public function kontakt_required($value)
{
if (empty($value)) {
$this->form_validation->set_message('kontakt_required', $this->p->t('ui','error_fieldRequired',['field' => 'Kontakt']));
return false;
}
else
{
return true;
}
}
public function iban_required($value)
{
if (empty($value)) {
$this->form_validation->set_message('iban_required', $this->p->t('ui','error_fieldRequired',['field' => 'IBANoff']));
return false;
}
else
{
return true;
}
}
public function typ_required($value)
{
if (empty($value)) {
$this->form_validation->set_message('typ_required', $this->p->t('ui','error_fieldRequired',['field' => 'Typ']));
return false;
}
else
{
return true;
}
}*/
/* public function plz_numeric($value)
{
if (!is_numeric($value)) {
$this->form_validation->set_message('plz_numeric', $this->p->t('ui','error_fieldNotNumeric',['field' => 'PLZ']));
return false;
}
else
{
return true;
}
}*/
public function kontakt_valid_email($email)
{
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$this->form_validation->set_message('kontakt_valid_email', $this->p->t('ui','error_fieldNoValidEmail',['field' => 'Kontakt']));
return false;
}
else
{
return true;
}
}
}
@@ -2,8 +2,6 @@ import AddressList from "./Kontakt/Address.js";
import ContactList from "./Kontakt/Contact.js";
import BankaccountList from "./Kontakt/Bankaccount.js";
import PvToast from "../../../../../../index.ci.php/public/js/components/primevue/toast/toast.esm.min.js";
import PvAutoComplete from "../../../../../../index.ci.php/public/js/components/primevue/autocomplete/autocomplete.esm.min.js";
export default {
components: {
AddressList,
@@ -17,7 +17,9 @@ export default{
data() {
return{
tabulatorOptions: {
ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Kontakt/getAdressen/' + this.uid),
ajaxURL: 'api/frontend/v1/stv/Kontakt/getAdressen/' + this.uid,
ajaxRequestFunc: this.$fhcApi.get,
ajaxResponse: (url, params, response) => response.data,
//autoColumns: true,
columns:[
{title:"Typ", field:"bezeichnung"},
@@ -80,7 +82,55 @@ export default{
selectable: true,
index: 'adresse_id',
},
tabulatorEvents: [],
tabulatorEvents: [
{
event: 'tableBuilt',
handler: async () => {
await this.$p.loadCategory(['notiz','global','person']);
let cm = this.$refs.table.tabulator.columnManager;
cm.getColumnByField('bezeichnung').component.updateDefinition({
title: this.$p.t('global', 'typ')
});
cm.getColumnByField('strasse').component.updateDefinition({
title: this.$p.t('person', 'strasse')
});
cm.getColumnByField('plz').component.updateDefinition({
title: this.$p.t('person', 'plz')
});
cm.getColumnByField('ort').component.updateDefinition({
title: this.$p.t('person', 'ort')
});
cm.getColumnByField('gemeinde').component.updateDefinition({
title: this.$p.t('person', 'gemeinde')
});
cm.getColumnByField('nation').component.updateDefinition({
title: this.$p.t('person', 'nation')
});
cm.getColumnByField('heimatadresse').component.updateDefinition({
title: this.$p.t('person', 'heimatadresse')
});
cm.getColumnByField('co_name').component.updateDefinition({
title: this.$p.t('person', 'co_name')
});
cm.getColumnByField('name').component.updateDefinition({
title: this.$p.t('person', 'firma_zusatz')
});
cm.getColumnByField('firmenname').component.updateDefinition({
title: this.$p.t('person', 'firma')
});
cm.getColumnByField('updateamum').component.updateDefinition({
title: this.$p.t('notiz', 'letzte_aenderung')
});
cm.getColumnByField('rechnungsadresse').component.updateDefinition({
title: this.$p.t('person', 'rechnungsadresse')
});
cm.getColumnByField('anmerkung').component.updateDefinition({
title: this.$p.t('notiz', 'document')
});
}
}
],
addressData: {
zustelladresse: true,
heimatadresse: true,
@@ -132,29 +182,20 @@ export default{
this.loadAdress(adress_id).then(() => {
if(this.addressData.adresse_id)
if(this.addressData.heimatadresse)
this.$fhcAlert.alertError("Heimatadressen dürfen nicht gelöscht werden, da diese für die BIS-Meldung relevant sind. Um die Adresse dennoch zu löschen, entfernen sie das Häkchen bei Heimatadresse!");
this.$fhcAlert.alertError(this.$p.t('person', 'error_deleteHomeAdress'));
else
this.$refs.deleteAdressModal.show();
});
},
addNewAddress(addressData) {
CoreRESTClient.post('components/stv/Kontakt/addNewAddress/' + this.uid,
this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewAddress/' + this.uid,
this.addressData
).then(response => {
if (!response.data.error) {
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal('newAdressModal');
this.resetModal();
} else {
const errorData = response.data.retval;
Object.entries(errorData).forEach(entry => {
const [key, value] = entry;
this.$fhcAlert.alertError(value);
});
}
}).catch(error => {
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
}).finally(() => {
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
window.scrollTo(0, 0);
this.reload();
});
@@ -163,60 +204,38 @@ export default{
this.$refs.table.reloadTable();
},
loadAdress(adress_id){
return CoreRESTClient.get('components/stv/Kontakt/loadAddress/' + adress_id)
.then(
result => {
if(result.data.retval)
this.addressData = result.data.retval;
else
{
this.addressData = {};
this.$fhcAlert.alertError('Keine Adresse mit Id ' + adress_id + ' gefunden');
}
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadAddress/' + adress_id)
.then(result => {
this.addressData = result.data;
return result;
}
);
})
.catch(this.$fhcAlert.handleSystemError);
},
updateAddress(adress_id){
CoreRESTClient.post('components/stv/Kontakt/updateAddress/' + adress_id,
this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateAddress/' + adress_id,
this.addressData
).then(response => {
if (!response.data.error) {
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal('editAdressModal');
this.resetModal();
} else {
const errorData = response.data.retval;
Object.entries(errorData).forEach(entry => {
const [key, value] = entry;
this.$fhcAlert.alertError(value);
});
}
}).catch(error => {
this.statusMsg = 'Error in Catch';
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
}).finally(() => {
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
window.scrollTo(0, 0);
this.reload();
});
},
deleteAddress(adress_id){
CoreRESTClient.post('components/stv/Kontakt/deleteAddress/' + adress_id)
this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteAddress/' + adress_id)
.then(response => {
if (!response.data.error) {
this.$fhcAlert.alertSuccess('Löschen erfolgreich');
} else {
this.$fhcAlert.alertError('Keine Adresse mit Id ' + adress_id + ' gefunden');
}
}).catch(error => {
this.$fhcAlert.alertError('Fehler bei Löschroutine aufgetreten');
}).finally(()=> {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
}).catch(this.$fhcAlert.handleSystemError)
.finally(()=> {
window.scrollTo(0, 0);
this.hideModal('deleteAdressModal');
this.reload();
});
},
loadPlaces() {
loadPlaces() { //TODO(manu) Refactor API-controller
if (this.abortController.places)
this.abortController.places.abort();
if (this.addressData.nation != 'A' || !this.addressData.plz)
@@ -241,10 +260,10 @@ export default{
});*/
},
search(event) {
return CoreRESTClient
.get('components/stv/Kontakt/getFirmen/' + event.query)
return this.$fhcApi
.get('api/frontend/v1/stv/kontakt/getFirmen/' + event.query)
.then(result => {
this.filteredFirmen = CoreRESTClient.getData(result.data);
this.filteredFirmen = result.data.retval;
});
},
reload(){
@@ -266,59 +285,12 @@ export default{
this.nations = result;
})
.catch(this.$fhcAlert.handleSystemError);
CoreRESTClient
.get('components/stv/Kontakt/getAdressentypen')
this.$fhcApi
.get('api/frontend/v1/stv/kontakt/getAdressentypen')
.then(result => {
this.adressentypen = result.data;
})
.catch(err => {
console.error(err.response.data || err.message);
});
},
async mounted() {
await this.$p.loadCategory(['notiz','global','person']);
let cm = this.$refs.table.tabulator.columnManager;
cm.getColumnByField('bezeichnung').component.updateDefinition({
title: this.$p.t('global', 'typ')
});
cm.getColumnByField('strasse').component.updateDefinition({
title: this.$p.t('person', 'strasse')
});
cm.getColumnByField('plz').component.updateDefinition({
title: this.$p.t('person', 'plz')
});
cm.getColumnByField('ort').component.updateDefinition({
title: this.$p.t('person', 'ort')
});
cm.getColumnByField('gemeinde').component.updateDefinition({
title: this.$p.t('person', 'gemeinde')
});
cm.getColumnByField('nation').component.updateDefinition({
title: this.$p.t('person', 'nation')
});
cm.getColumnByField('heimatadresse').component.updateDefinition({
title: this.$p.t('person', 'heimatadresse')
});
cm.getColumnByField('co_name').component.updateDefinition({
title: this.$p.t('person', 'co_name')
});
cm.getColumnByField('name').component.updateDefinition({
title: this.$p.t('person', 'firma_zusatz')
});
cm.getColumnByField('firmenname').component.updateDefinition({
title: this.$p.t('person', 'firma')
});
cm.getColumnByField('updateamum').component.updateDefinition({
title: this.$p.t('notiz', 'letzte_aenderung')
});
cm.getColumnByField('rechnungsadresse').component.updateDefinition({
title: this.$p.t('person', 'rechnungsadresse')
});
cm.getColumnByField('anmerkung').component.updateDefinition({
title: this.$p.t('notiz', 'document')
});
.catch(this.$fhcAlert.handleSystemError)
},
template: `
<div class="stv-list h-100 pt-3">
@@ -590,7 +562,7 @@ export default{
:side-menu="false"
reload
new-btn-show
new-btn-label="Neu"
new-btn-label="Adresse"
@click:new="actionNewAdress"
>
<button v-if="reload" class="btn btn-outline-warning" aria-label="Reload">
@@ -1,5 +1,4 @@
import {CoreFilterCmpt} from "../../../../filter/Filter.js";
import {CoreRESTClient} from "../../../../../RESTClient";
import BsModal from "../../../../Bootstrap/Modal.js";
export default{
@@ -13,7 +12,9 @@ export default{
data() {
return{
tabulatorOptions: {
ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Kontakt/getBankverbindung/' + this.uid),
ajaxURL: 'api/frontend/v1/stv/Kontakt/getBankverbindung/' + this.uid,
ajaxRequestFunc: this.$fhcApi.get,
ajaxResponse: (url, params, response) => response.data,
columns:[
{title:"Name", field:"name"},
{title:"Anschrift", field:"anschrift", visible:false},
@@ -76,7 +77,32 @@ export default{
selectable: true,
index: 'bankverbindung_id',
},
tabulatorEvents: [],
tabulatorEvents: [
{
event: 'tableBuilt',
handler: async() => {
await this.$p.loadCategory(['global','person']);
let cm = this.$refs.table.tabulator.columnManager;
cm.getColumnByField('anschrift').component.updateDefinition({
title: this.$p.t('person', 'anschrift')
});
cm.getColumnByField('kontonr').component.updateDefinition({
title: this.$p.t('person', 'kontonr')
});
cm.getColumnByField('blz').component.updateDefinition({
title: this.$p.t('person', 'blz')
});
cm.getColumnByField('typ').component.updateDefinition({
title: this.$p.t('global', 'typ')
});
cm.getColumnByField('verrechnung').component.updateDefinition({
title: this.$p.t('person', 'verrechnung')
});
}
}
],
lastSelected: null,
bankverbindungData: {
verrechnung: true,
@@ -105,80 +131,46 @@ export default{
});
},
addNewBankverbindung(bankverbindungData) {
CoreRESTClient.post('components/stv/Kontakt/addNewBankverbindung/' + this.uid,
this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewBankverbindung/' + this.uid,
this.bankverbindungData
).then(response => {
if (!response.data.error) {
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
/* this.$refs.newBankverbindungModal.hide();*/
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal('newBankverbindungModal');
this.resetModal();
} else {
const errorData = response.data.retval;
Object.entries(errorData).forEach(entry => {
const [key, value] = entry;
this.$fhcAlert.alertError('Das Feld ' + key + ' ist erforderlich');
});
this.statusCode = 0;
this.statusMsg = response.data;
}
}).catch(error => {
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
}).finally(() => {
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
window.scrollTo(0, 0);
this.reload();
});
},
loadBankverbindung(bankverbindung_id){
return CoreRESTClient.get('components/stv/Kontakt/loadBankverbindung/' + bankverbindung_id)
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadBankverbindung/' + bankverbindung_id)
.then(
result => {
if(!result.data.retval || result.data.retval.length < 1)
{
this.bankverbindungData = {};
this.$fhcAlert.alertError('Keine Bankverbindung mit Id ' + bankverbindung_id + ' gefunden');
}
else
{
this.bankverbindungData = result.data.retval;
}
this.bankverbindungData = result.data;
return result;
}
);
})
.catch(this.$fhcAlert.handleSystemError);
},
updateBankverbindung(bankverbindung_id){
CoreRESTClient.post('components/stv/Kontakt/updateBankverbindung/' + bankverbindung_id,
this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateBankverbindung/' + bankverbindung_id,
this.bankverbindungData)
.then(response => {
if (!response.data.error) {
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
this.hideModal('editBankverbindungModal');
this.resetModal();
} else {
const errorData = response.data.retval;
Object.entries(errorData).forEach(entry => {
const [key, value] = entry;
this.$fhcAlert.alertError('Das Feld ' + key + ' ist erforderlich');
});
}
}).catch(error => {
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
}).finally(() => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal('editBankverbindungModal');
this.resetModal();
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
window.scrollTo(0, 0);
this.reload();
});
},
deleteBankverbindung(bankverbindung_id){
CoreRESTClient.post('components/stv/Kontakt/deleteBankverbindung/' + bankverbindung_id)
this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteBankverbindung/' + bankverbindung_id)
.then(response => {
if (!response.data.error || response.data === []) {
this.$fhcAlert.alertSuccess('Löschen erfolgreich');
} else {
this.$fhcAlert.alertError('Keine Adresse mit Id ' + bankverbindung_id + ' gefunden');
}
}).catch(error => {
this.$fhcAlert.alertError('Fehler bei Löschroutine aufgetreten');
}).finally(()=> {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
}).catch(this.$fhcAlert.handleSystemError)
.finally(()=> {
window.scrollTo(0, 0);
this.hideModal('deleteBankverbindungModal');
this.resetModal();
@@ -196,27 +188,6 @@ export default{
this.bankverbindungData = this.initData;
},
},
async mounted() {
await this.$p.loadCategory(['global','person']);
let cm = this.$refs.table.tabulator.columnManager;
cm.getColumnByField('anschrift').component.updateDefinition({
title: this.$p.t('person', 'anschrift')
});
cm.getColumnByField('kontonr').component.updateDefinition({
title: this.$p.t('person', 'kontonr')
});
cm.getColumnByField('blz').component.updateDefinition({
title: this.$p.t('person', 'blz')
});
cm.getColumnByField('typ').component.updateDefinition({
title: this.$p.t('global', 'typ')
});
cm.getColumnByField('verrechnung').component.updateDefinition({
title: this.$p.t('person', 'verrechnung')
});
},
template: `
<div class="stv-list h-100 pt-3">
@@ -370,7 +341,7 @@ export default{
:side-menu="false"
reload
new-btn-show
new-btn-label="Neu"
new-btn-label="Bankverbindung"
@click:new="actionNewBankverbindung"
>
</core-filter-cmpt>
@@ -16,7 +16,9 @@ export default{
data() {
return{
tabulatorOptions: {
ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Kontakt/getKontakte/' + this.uid),
ajaxURL: 'api/frontend/v1/stv/Kontakt/getKontakte/' + this.uid,
ajaxRequestFunc: this.$fhcApi.get,
ajaxResponse: (url, params, response) => response.data,
columns:[
{title:"Typ", field:"kontakttyp"},
{title:"Kontakt", field:"kontakt"},
@@ -65,7 +67,35 @@ export default{
selectable: true,
index: 'kontakt_id'
},
tabulatorEvents: [],
tabulatorEvents: [
{
event: 'tableBuilt',
handler: async() => {
await this.$p.loadCategory(['notiz','global','person']);
let cm = this.$refs.table.tabulator.columnManager;
cm.getColumnByField('kontakttyp').component.updateDefinition({
title: this.$p.t('global', 'typ')
});
cm.getColumnByField('kontakt').component.updateDefinition({
title: this.$p.t('global', 'kontakt')
});
cm.getColumnByField('zustellung').component.updateDefinition({
title: this.$p.t('person', 'zustellung')
});
cm.getColumnByField('anmerkung').component.updateDefinition({
title: this.$p.t('global', 'anmerkung')
});
cm.getColumnByField('kurzbz').component.updateDefinition({
title: this.$p.t('person', 'firma')
});
cm.getColumnByField('lastupdate').component.updateDefinition({
title: this.$p.t('notiz', 'letzte_aenderung')
});
}
}
],
lastSelected: null,
contactData: {
zustellung: true,
@@ -94,79 +124,50 @@ export default{
this.$refs.deleteContactModal.show();
},
addNewContact(formData) {
CoreRESTClient.post('components/stv/Kontakt/addNewContact/' + this.uid,
this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewContact/' + this.uid,
this.contactData)
.then(response => {
if (!response.data.error) {
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal("newContactModal");
this.resetModal();
} else {
const errorData = response.data.retval;
Object.entries(errorData).forEach(entry => {
const [key, value] = entry;
this.$fhcAlert.alertError(value);
});
}
}).catch(error => {
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
}).finally(() => {
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
window.scrollTo(0, 0);
this.reload();
});
},
loadContact(contact_id){
return CoreRESTClient.get('components/stv/Kontakt/loadContact/' + contact_id)
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadContact/' + contact_id)
.then(
result => {
if(result.data.retval)
this.contactData = result.data.retval;
else
{
this.contactData = {};
this.$fhcAlert.alertError('Kein Kontakt mit Id ' + contact_id + ' gefunden');
}
this.contactData = result.data;
return result;
}
);
})
.catch(this.$fhcAlert.handleSystemError);
},
deleteContact(kontakt_id){
CoreRESTClient.post('components/stv/Kontakt/deleteContact/' + kontakt_id)
this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteContact/' + kontakt_id)
.then(response => {
if (!response.data.error) {
this.$fhcAlert.alertSuccess('Löschen erfolgreich');
} else {
this.$fhcAlert.alertError('Keine Adresse mit Id ' + kontakt_id + ' gefunden');
}
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
})
.catch(error => {
this.$fhcAlert.alertError('Fehler bei Löschroutine aufgetreten');
}).finally(()=> {
window.scrollTo(0, 0);
this.hideModal('deleteContactModal');
this.resetModal();
this.reload();
.catch(this.$fhcAlert.handleSystemError)
.finally(()=> {
window.scrollTo(0, 0);
this.hideModal('deleteContactModal');
this.resetModal();
this.reload();
});
},
updateContact(kontakt_id){
CoreRESTClient.post('components/stv/Kontakt/updateContact/' + kontakt_id,
this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateContact/' + kontakt_id,
this.contactData).
then(response => {
if (!response.data.error) {
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
this.hideModal('editContactModal');
this.resetModal();
this.reload();
} else {
const errorData = response.data.retval;
Object.entries(errorData).forEach(entry => {
const [key, value] = entry;
this.$fhcAlert.alertError(value);
});
}
}).catch(error => {
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
}).finally(() => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal('editContactModal');
this.resetModal();
this.reload();
}).catch(this.$fhcAlert.handleSystemError)
.finally(()=> {
window.scrollTo(0, 0);
this.reload();
});
@@ -178,10 +179,10 @@ export default{
this.$refs.table.reloadTable();
},
search(event) {
return CoreRESTClient
.get('components/stv/Kontakt/getStandorte/' + event.query)
return this.$fhcApi
.get('api/frontend/v1/stv/kontakt/getStandorte/' + event.query)
.then(result => {
this.filteredStandorte = CoreRESTClient.getData(result.data);
this.filteredStandorte = result.data.retval;
});
},
resetModal(){
@@ -190,38 +191,12 @@ export default{
},
},
created(){
CoreRESTClient
.get('components/stv/Kontakt/getKontakttypen')
this.$fhcApi
.get('api/frontend/v1/stv/kontakt/getKontakttypen')
.then(result => {
this.kontakttypen = result.data;
})
.catch(err => {
console.error(err.response.data || err.message);
});
},
async mounted() {
await this.$p.loadCategory(['notiz','global','person']);
let cm = this.$refs.table.tabulator.columnManager;
cm.getColumnByField('kontakttyp').component.updateDefinition({
title: this.$p.t('global', 'typ')
});
cm.getColumnByField('kontakt').component.updateDefinition({
title: this.$p.t('global', 'kontakt')
});
cm.getColumnByField('zustellung').component.updateDefinition({
title: this.$p.t('person', 'zustellung')
});
cm.getColumnByField('anmerkung').component.updateDefinition({
title: this.$p.t('global', 'anmerkung')
});
cm.getColumnByField('kurzbz').component.updateDefinition({
title: this.$p.t('person', 'firma')
});
cm.getColumnByField('lastupdate').component.updateDefinition({
title: this.$p.t('notiz', 'letzte_aenderung')
});
.catch(this.$fhcAlert.handleSystemError);
},
template: `
<div class="stv-list h-100 pt-3">
@@ -348,7 +323,7 @@ export default{
:side-menu="false"
reload
new-btn-show
new-btn-label="Neu"
new-btn-label="Kontakt"
@click:new="actionNewContact"
>
</core-filter-cmpt>
+77
View File
@@ -26171,6 +26171,83 @@ array(
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'error_missingId',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Id {id} nicht gefunden',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Missing Id {id}',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'person',
'phrase' => 'error_deleteHomeAdress',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Heimatadressen dürfen nicht gelöscht werden, da diese für die BIS-Meldung relevant sind. Um die Adresse dennoch zu löschen, entfernen sie das Häkchen bei Heimatadresse!',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Home addresses may not be deleted as they are relevant for the BIS report. To delete the address anyway, uncheck the home address box!',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'successSave',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Speichern erfolgreich',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Successfully saved',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'successDelete',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Löschen erfolgreich',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Delete successful',
'description' => '',
'insertvon' => 'system'
)
)
),
);