mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-18 12:39:29 +00:00
Autocomplete, überarbeitung Modal
This commit is contained in:
@@ -24,13 +24,14 @@ class Kontakt extends FHC_Controller
|
||||
public function getAdressen($person_id)
|
||||
{
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
//TODO(manu) check select: für Anzeige alle Tabellen nötig
|
||||
$this->AdresseModel->addSelect('*');
|
||||
//TODO(manu) check name: in Adresse und firma
|
||||
$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->addJoin('public.tbl_firmentyp ft', 'ON (f.firma_id = ft.firmentyp.firma_id)', 'LEFT');
|
||||
|
||||
$result = $this->AdresseModel->loadWhere(
|
||||
array('person_id' => $person_id)
|
||||
);
|
||||
@@ -44,41 +45,52 @@ class Kontakt extends FHC_Controller
|
||||
|
||||
public function addNewAddress($person_id)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
$this->form_validation->set_rules('plz', 'PLZ', 'required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('AuthLib');
|
||||
$this->load->library('VariableLib', ['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;
|
||||
|
||||
$firma_id = '';
|
||||
if (isset($_POST['firma_id']))
|
||||
$firma_id = $_POST('firma_id');
|
||||
|
||||
$co_name = '';
|
||||
if (isset($_POST['co_name']))
|
||||
$co_name = $_POST('co_name');
|
||||
if(isset($_POST['firma']))
|
||||
{
|
||||
$firma_id = $_POST['firma']['firma_id'];
|
||||
}
|
||||
else
|
||||
$firma_id = null;
|
||||
|
||||
$result = $this->AdresseModel->insert(
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
'strasse' => $_POST['strasse'],
|
||||
'strasse' => $strasse,
|
||||
'insertvon' => 'uid',
|
||||
'insertamum' => date('c'),
|
||||
'plz' => $_POST['plz'],
|
||||
'ort' => $_POST['ort'],
|
||||
'gemeinde' => $_POST['gemeinde'],
|
||||
'nation' => $_POST['nation'],
|
||||
'ort' => $ort,
|
||||
'gemeinde' => $gemeinde,
|
||||
'nation' => $nation,
|
||||
'heimatadresse' => $_POST['heimatadresse'],
|
||||
'zustelladresse' => $_POST['zustelladresse'],
|
||||
'co_name' => $co_name,
|
||||
'typ' => $_POST['typ'],
|
||||
'typ' => $typ,
|
||||
'firma_id' => $firma_id,
|
||||
'name' => $_POST['name'],
|
||||
'name' => $name,
|
||||
'rechnungsadresse' => $_POST['rechnungsadresse'],
|
||||
'anmerkung' => $_POST['anmerkung']
|
||||
|
||||
'anmerkung' => $anmerkung
|
||||
|
||||
]
|
||||
);
|
||||
@@ -92,20 +104,31 @@ class Kontakt extends FHC_Controller
|
||||
}
|
||||
|
||||
public function updateAddress($address_id)
|
||||
//Todo(manu) update Firma
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
$this->form_validation->set_rules('plz', 'PLZ', 'required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
// Load Libraries
|
||||
$this->load->library('AuthLib');
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
|
||||
if(!$address_id)
|
||||
{
|
||||
return $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
if(isset($_POST['firma']))
|
||||
{
|
||||
$firma_id = $_POST['firma']['firma_id'];
|
||||
}
|
||||
else
|
||||
$firma_id = $_POST['firma_id'];
|
||||
|
||||
$result = $this->AdresseModel->update([
|
||||
'adresse_id' => $address_id
|
||||
],
|
||||
@@ -120,7 +143,11 @@ class Kontakt extends FHC_Controller
|
||||
'heimatadresse' => $_POST['heimatadresse'],
|
||||
'zustelladresse' => $_POST['zustelladresse'],
|
||||
'co_name' => $_POST['co_name'],
|
||||
'typ' => $_POST['typ']
|
||||
'typ' => $_POST['typ'],
|
||||
'firma_id' => $firma_id,
|
||||
'name' => $_POST['name'],
|
||||
'rechnungsadresse' => $_POST['rechnungsadresse'],
|
||||
'anmerkung' => $_POST['anmerkung']
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
@@ -135,7 +162,10 @@ class Kontakt extends FHC_Controller
|
||||
{
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
|
||||
$this->AdresseModel->addSelect('*');
|
||||
$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');
|
||||
|
||||
@@ -151,7 +181,6 @@ class Kontakt extends FHC_Controller
|
||||
|
||||
elseif (!hasData($result)) {
|
||||
$this->outputJson($result); //success mit Wert null
|
||||
// $this->outputJson(getData($result) ?: []);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -191,7 +220,6 @@ class Kontakt extends FHC_Controller
|
||||
}
|
||||
}
|
||||
|
||||
//TODO(Manu) Liste zu lang - besser nachladen
|
||||
public function getFirmen($searchString)
|
||||
{
|
||||
$this->load->model('ressource/firma_model', 'FirmaModel');
|
||||
@@ -199,27 +227,22 @@ class Kontakt extends FHC_Controller
|
||||
$result = $this->FirmaModel->searchFirmen($searchString);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
$this->outputJson(getError($result));
|
||||
} else {
|
||||
$this->outputJson(getData($result) ?: []);
|
||||
}
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
//TODO(Manu) Autocomplete?
|
||||
public function getStandorte($searchString)
|
||||
{
|
||||
$this->load->model('organisation/Standort_model', 'StandortModel');
|
||||
$this->load->model('organisation/standort_model', 'StandortModel');
|
||||
|
||||
$result = $this->StandortModel->load();
|
||||
$result = $this->StandortModel->searchStandorte($searchString);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
$this->outputJson(getError($result));
|
||||
} else {
|
||||
$this->outputJson(getData($result) ?: []);
|
||||
}
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
public function getFirmenliste($searchString)
|
||||
public function getFirmenliste($searchString) //TODO (manu) DEPRECATED
|
||||
{
|
||||
$this->load->model('ressource/firma_model', 'FirmaModel');
|
||||
|
||||
@@ -290,11 +313,9 @@ class Kontakt extends FHC_Controller
|
||||
{
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
$this->load->model('organisation/standort_model', 'StandortModel');
|
||||
$this->load->model('ressource/firma_model', 'FirmaModel');
|
||||
|
||||
$this->KontaktModel->addSelect('*');
|
||||
$this->StandortModel->addJoin('public.tbl_standort st', 'ON (public.tbl_kontakt.standort_id = st.standort_id)', 'LEFT');
|
||||
$this->StandortModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = st.firma_id)', 'LEFT');
|
||||
|
||||
$result = $this->KontaktModel->loadWhere(
|
||||
array('person_id' => $person_id)
|
||||
@@ -325,9 +346,9 @@ class Kontakt extends FHC_Controller
|
||||
{
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
$this->KontaktModel->addSelect('*');
|
||||
$this->AdresseModel->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->addJoin('public.tbl_firma f', 'ON (f.firma_id = st.firma_id)', 'LEFT');
|
||||
|
||||
$this->KontaktModel->addLimit(1);
|
||||
|
||||
@@ -351,25 +372,46 @@ class Kontakt extends FHC_Controller
|
||||
|
||||
public function addNewContact($person_id)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_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');
|
||||
else
|
||||
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
$firma_id = '';
|
||||
if (isset($_POST['firma_id']))
|
||||
$firma_id = $_POST('firma_id');
|
||||
if(isset($_POST['standort']))
|
||||
{
|
||||
$standort_id = $_POST['standort']['standort_id'];
|
||||
}
|
||||
else
|
||||
$standort_id = null;
|
||||
|
||||
$kontakttyp = isset($_POST['kontakttyp']) ? $_POST['kontakttyp'] : null;
|
||||
$anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null;
|
||||
$kontakt = isset($_POST['kontakt']) ? $_POST['kontakt'] : null;
|
||||
$ext_id = isset($_POST['ext_id']) ? $_POST['ext_id'] : null;
|
||||
|
||||
$result = $this->KontaktModel->insert(
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
'kontakttyp' => $_POST['kontakttyp'],
|
||||
'anmerkung' => $_POST['anmerkung'],
|
||||
'kontakt' => $_POST['kontakt'],
|
||||
'kontakttyp' => $kontakttyp,
|
||||
'anmerkung' => $anmerkung,
|
||||
'kontakt' => $kontakt,
|
||||
'zustellung' => $_POST['zustellung'],
|
||||
'insertvon' => 'uid',
|
||||
'insertamum' => date('c'),
|
||||
'standort_id' => $_POST['standort_id'],
|
||||
'ext_id' => $_POST['ext_id']
|
||||
'standort_id' => $standort_id,
|
||||
'ext_id' => $ext_id
|
||||
]
|
||||
);
|
||||
|
||||
@@ -392,19 +434,32 @@ class Kontakt extends FHC_Controller
|
||||
return $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
if(isset($_POST['standort']))
|
||||
{
|
||||
$standort_id = $_POST['standort']['standort_id'];
|
||||
}
|
||||
else
|
||||
$standort_id = $_POST['standort_id'];
|
||||
|
||||
$kontakttyp = isset($_POST['kontakttyp']) ? $_POST['kontakttyp'] : null;
|
||||
$anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null;
|
||||
$kontakt = isset($_POST['kontakt']) ? $_POST['kontakt'] : null;
|
||||
$ext_id = isset($_POST['ext_id']) ? $_POST['ext_id'] : null;
|
||||
$person_id = isset($_POST['person_id']) ? $_POST['person_id'] : null;
|
||||
|
||||
$result = $this->KontaktModel->update([
|
||||
'kontakt_id' => $kontakt_id
|
||||
],
|
||||
[
|
||||
'person_id' => $_POST['person_id'],
|
||||
'kontakttyp' => $_POST['kontakttyp'],
|
||||
'anmerkung' => $_POST['anmerkung'],
|
||||
'kontakt' => $_POST['kontakt'],
|
||||
'person_id' => $person_id,
|
||||
'kontakttyp' => $kontakttyp,
|
||||
'anmerkung' => $anmerkung,
|
||||
'kontakt' => $kontakt,
|
||||
'zustellung' => $_POST['zustellung'],
|
||||
'updatevon' => 'uid',
|
||||
'updateamum' => date('c'),
|
||||
'standort_id' => $_POST['standort_id'],
|
||||
'ext_id' => $_POST['ext_id']
|
||||
'insertvon' => 'uid',
|
||||
'insertamum' => date('c'),
|
||||
'standort_id' => $standort_id,
|
||||
'ext_id' => $ext_id
|
||||
]);
|
||||
|
||||
if (isError($result))
|
||||
|
||||
@@ -11,4 +11,18 @@ class Standort_model extends DB_Model
|
||||
$this->dbTable = 'public.tbl_standort';
|
||||
$this->pk = 'standort_id';
|
||||
}
|
||||
|
||||
public function searchStandorte($filter)
|
||||
{
|
||||
$qry = "
|
||||
SELECT
|
||||
s.kurzbz, s.standort_id
|
||||
FROM
|
||||
public.tbl_standort s
|
||||
WHERE
|
||||
lower (s.kurzbz) LIKE '%". $this->db->escape_like_str($filter)."%'";
|
||||
|
||||
return $this->execQuery($qry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,3 +70,5 @@ class Adresse_model extends DB_Model
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,4 +11,17 @@ class Firma_model extends DB_Model
|
||||
$this->dbTable = 'public.tbl_firma';
|
||||
$this->pk = 'firma_id';
|
||||
}
|
||||
|
||||
public function searchFirmen($filter)
|
||||
{
|
||||
$qry = "
|
||||
SELECT
|
||||
f.name, f.firma_id
|
||||
FROM
|
||||
public.tbl_firma f
|
||||
WHERE
|
||||
lower (f.name) LIKE '%". $this->db->escape_like_str($filter)."%'";
|
||||
|
||||
return $this->execQuery($qry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,16 @@ import {CoreRESTClient} from '../../../../RESTClient.js';
|
||||
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,
|
||||
ContactList,
|
||||
BankaccountList,
|
||||
PvToast
|
||||
PvToast,
|
||||
PvAutoComplete
|
||||
},
|
||||
props: {
|
||||
student: Object
|
||||
@@ -22,7 +25,7 @@ export default {
|
||||
},
|
||||
created(){
|
||||
CoreRESTClient
|
||||
.get('components/stv/Student/getAdressen/' + this.student.person_id)
|
||||
.get('components/stv/Kontakt/getAdressen/' + this.student.person_id)
|
||||
.then(result => {
|
||||
this.adressen = result.data;
|
||||
})
|
||||
@@ -30,7 +33,7 @@ export default {
|
||||
console.error(err.response.data || err.message);
|
||||
});
|
||||
/* CoreRESTClient
|
||||
.get('components/stv/Student/getKontakte/' + this.student.person_id)
|
||||
.get('components/stv/Kontakt/getKontakte/' + this.student.person_id)
|
||||
.then(result => {
|
||||
this.kontakte = result.data;
|
||||
})
|
||||
@@ -38,7 +41,7 @@ export default {
|
||||
console.error(err.response.data || err.message);
|
||||
});
|
||||
CoreRESTClient
|
||||
.get('components/stv/Student/getBankverbindung/' + this.student.person_id)
|
||||
.get('components/stv/Kontakt/getBankverbindung/' + this.student.person_id)
|
||||
.then(result => {
|
||||
this.bankverbindungen = result.data;
|
||||
})
|
||||
@@ -49,15 +52,25 @@ export default {
|
||||
template: `
|
||||
<div class="stv-details-details h-100 pb-3">
|
||||
<fieldset class="overflow-hidden">
|
||||
|
||||
|
||||
|
||||
<legend>Adressen</legend>
|
||||
<!-- {{this.adressen}}-->
|
||||
<!-- {{this.adressen}}-->
|
||||
|
||||
<!--props notwendig, um auf Funktion in child zuzugreifen-->
|
||||
<!-- <button type="button" class="btn btn btn-outline-warning" @click="actionNewAdress()">new Adress</button>
|
||||
<button type="button" class="btn btn btn-outline-warning" @click="actionEditAdress(111444)">edit 111444</button>-->
|
||||
|
||||
<address-list ref="adressList" :uid="student.person_id"></address-list>
|
||||
</fieldset>
|
||||
<br>
|
||||
<fieldset class="overflow-hidden">
|
||||
<legend>Kontakt</legend>
|
||||
<!-- {{this.kontakte}}-->
|
||||
<contact-list ref="contactList" :uid="student.person_id"></contact-list>
|
||||
</fieldset>
|
||||
<br>
|
||||
<fieldset class="overflow-hidden">
|
||||
<legend>Bankverbindungen</legend>
|
||||
<!-- {{this.bankverbindungen}}-->
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import {CoreFilterCmpt} from "../../../../filter/Filter.js";
|
||||
import {CoreRESTClient} from "../../../../../RESTClient";
|
||||
import PvAutoComplete from "../../../../../../../index.ci.php/public/js/components/primevue/autocomplete/autocomplete.esm.min.js";
|
||||
/*import PvToast from "../../../../../../index.ci.php/public/js/components/primevue/toast/toast.esm.min.js";*/
|
||||
|
||||
|
||||
var editIcon = function(cell, formatterParams){ //plain text value
|
||||
@@ -12,7 +14,8 @@ var deleteIcon = function(cell, formatterParams){ //plain text value
|
||||
|
||||
export default{
|
||||
components: {
|
||||
CoreFilterCmpt
|
||||
CoreFilterCmpt,
|
||||
PvAutoComplete
|
||||
},
|
||||
props: {
|
||||
uid: String
|
||||
@@ -23,10 +26,10 @@ export default{
|
||||
data() {
|
||||
return{
|
||||
tabulatorOptions: {
|
||||
ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Student/getAdressen/' + this.uid),
|
||||
ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Kontakt/getAdressen/' + this.uid),
|
||||
//autoColumns: true,
|
||||
columns:[
|
||||
{title:"Typ", field:"bezeichnung"}, //TODO(manu) mix ok?
|
||||
{title:"Typ", field:"bezeichnung"},
|
||||
{title:"Strasse", field:"strasse"},
|
||||
{title:"Plz", field:"plz"},
|
||||
{title:"Ort", field:"ort"},
|
||||
@@ -38,7 +41,8 @@ export default{
|
||||
return output;}
|
||||
},
|
||||
{title:"Abweich.Empf", field:"co_name"},
|
||||
{title:"Firma", field:"name"}, //TODO(manu) check in DB
|
||||
{title:"Name", field:"name"},
|
||||
{title:"Firma", field:"firmenname"}, //TODO(manu) check in DB
|
||||
{title:"Firma_id", field:"firma_id", visible:false},
|
||||
{title:"Adresse_id", field:"adresse_id", visible:false},
|
||||
{title:"Person_id", field:"person_id", visible:false},
|
||||
@@ -50,8 +54,18 @@ export default{
|
||||
return output;}
|
||||
},
|
||||
{title:"Anmerkung", field:"anmerkung", visible:false},
|
||||
{formatter:editIcon, width:40, align:"center", cellClick:function(e, cell){alert("Edit data for adresse_id: " + cell.getRow().getIndex())}},
|
||||
{formatter:deleteIcon, width:40, align:"center", cellClick:function(e, cell){alert("Delete data for adresse_id " + cell.getRow().getIndex())}},
|
||||
{title: "Actions",
|
||||
columns:[
|
||||
{formatter:editIcon, width:40, align:"center", cellClick: (e, cell) => {
|
||||
this.actionEditAdress(cell.getData().adresse_id);
|
||||
console.log(cell.getRow().getIndex(), cell.getData(), this);
|
||||
}, width:50, headerSort:false},
|
||||
{formatter:deleteIcon, width:40, align:"center", cellClick: (e, cell) => {
|
||||
this.actionDeleteAdress(cell.getData().adresse_id);
|
||||
console.log(cell.getRow().getIndex(), cell.getData(), this);
|
||||
}, width:50, headerSort:false },
|
||||
],
|
||||
},
|
||||
],
|
||||
layout: 'fitDataFill',
|
||||
layoutColumnsOnNewData: false,
|
||||
@@ -62,44 +76,58 @@ export default{
|
||||
tabulatorEvents: [
|
||||
|
||||
],
|
||||
lastSelected: null,
|
||||
modalRefVis: false,
|
||||
addressData: [],
|
||||
addressData: {},
|
||||
formData: {
|
||||
zustelladresse: false,
|
||||
heimatadresse: false
|
||||
zustelladresse: true,
|
||||
heimatadresse: true,
|
||||
rechnungsadresse: false,
|
||||
typ: 'h',
|
||||
nation: 'A'
|
||||
},
|
||||
nations: [],
|
||||
adressentypen: []
|
||||
adressentypen: [],
|
||||
firmen: [],
|
||||
ortschaften: [],
|
||||
gemeinden: [],
|
||||
filteredFirmen: []
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
|
||||
},
|
||||
methods:{
|
||||
actionNewAdress(){
|
||||
|
||||
console.log("Neue Adresse anlegen");
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs.newAdressModal).show();
|
||||
},
|
||||
deleteAdressData(){
|
||||
return this.formData = null;
|
||||
actionEditAdress(adress_id){
|
||||
this.loadAdress(adress_id).then(() => {
|
||||
if(this.addressData.adresse_id)
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs.editAdressModal).show();
|
||||
});
|
||||
},
|
||||
hideModal(){
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs.newAdressModal).hide();
|
||||
actionDeleteAdress(adress_id){
|
||||
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!");
|
||||
else
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs.deleteAdressModal).show();
|
||||
});
|
||||
},
|
||||
addNewAddress(formData) {
|
||||
CoreRESTClient.post('components/stv/Student/addNewAddress/' + this.uid,
|
||||
this.formData
|
||||
).then(response => {
|
||||
console.log(response);
|
||||
CoreRESTClient.post('components/stv/Kontakt/addNewAddress/' + this.uid,
|
||||
this.formData
|
||||
).then(response => {
|
||||
if (!response.data.error) {
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'success';
|
||||
console.log('Speichern erfolgreich: ' + this.statusMsg);
|
||||
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
|
||||
this.hideModal('newAdressModal');
|
||||
} else {
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'Error';
|
||||
console.log('Speichern nicht erfolgreich: ' + this.statusMsg);
|
||||
this.$fhcAlert.alertError('Speichern nicht erfolgreich');
|
||||
const errorData = response.data.retval;
|
||||
Object.entries(errorData).forEach(entry => {
|
||||
const [key, value] = entry;
|
||||
console.log(key, value);
|
||||
this.$fhcAlert.alertError(value);
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
@@ -109,26 +137,127 @@ export default{
|
||||
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
|
||||
}).finally(() => {
|
||||
window.scrollTo(0, 0);
|
||||
hideModal();
|
||||
this.reload();
|
||||
});
|
||||
|
||||
//this.formData = [];
|
||||
},
|
||||
reload(){
|
||||
this.$refs.table.reloadTable();
|
||||
},
|
||||
loadAdress(adress_id){
|
||||
return CoreRESTClient.get('components/stv/Kontakt/loadAddress/' + adress_id
|
||||
).then(
|
||||
result => {
|
||||
console.log(this.addressData, result);
|
||||
if(result.data.retval)
|
||||
this.addressData = result.data.retval;
|
||||
else
|
||||
{
|
||||
this.addressData = {};
|
||||
this.$fhcAlert.alertError('Keine Adresse mit Id ' + adress_id + ' gefunden');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
);
|
||||
},
|
||||
updateAddress(adress_id){
|
||||
CoreRESTClient.post('components/stv/Kontakt/updateAddress/' + adress_id,
|
||||
this.addressData
|
||||
).then(response => {
|
||||
if (!response.data.error) {
|
||||
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
|
||||
this.hideModal('editAdressModal');
|
||||
} else {
|
||||
const errorData = response.data.retval;
|
||||
Object.entries(errorData).forEach(entry => {
|
||||
const [key, value] = entry;
|
||||
console.log(key, value);
|
||||
this.$fhcAlert.alertError(value);
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
this.statusMsg = 'Error in Catch';
|
||||
console.log('Speichern nicht erfolgreich ' + this.statusMsg);
|
||||
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
|
||||
}).finally(() => {
|
||||
window.scrollTo(0, 0);
|
||||
//hideModal();
|
||||
this.reload();
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/* showModalRef(){
|
||||
|
||||
modalRef = true;
|
||||
}*/
|
||||
/* updateUrl(url, first) {
|
||||
this.lastSelected = first ? undefined : this.selected;
|
||||
if (url)
|
||||
url = CoreRESTClient._generateRouterURI(url);
|
||||
if (!this.$refs.table.tableBuilt)
|
||||
this.$refs.table.tabulator.on("tableBuilt", () => {
|
||||
this.$refs.table.tabulator.setData(url);
|
||||
});
|
||||
deleteAddress(adress_id){
|
||||
CoreRESTClient.post('components/stv/Kontakt/deleteAddress/' + adress_id)
|
||||
.then(response => {
|
||||
console.log(response);
|
||||
if (!response.data.error) {
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'success';
|
||||
console.log('Löschen erfolgreich: ' + this.statusMsg);
|
||||
this.$fhcAlert.alertSuccess('Löschen erfolgreich');
|
||||
} else {
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'Error';
|
||||
console.log('Löschen nicht erfolgreich: ' + this.statusMsg);
|
||||
this.$fhcAlert.alertError('Keine Adresse mit Id ' + adress_id + ' gefunden');
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'Error in Catch';
|
||||
console.log('Löschen nicht erfolgreich ' + this.statusMsg);
|
||||
this.$fhcAlert.alertError('Fehler bei Löschroutine aufgetreten');
|
||||
}).finally(()=> {
|
||||
window.scrollTo(0, 0);
|
||||
this.hideModal('deleteAdressModal');
|
||||
this.reload();
|
||||
});
|
||||
},
|
||||
getGemeinden(searchString){
|
||||
return CoreRESTClient.get('components/stv/Kontakt/getGemeinden/' + searchString
|
||||
).then(
|
||||
result => {
|
||||
if(result.data.retval)
|
||||
this.gemeinden = result.data.retval;
|
||||
else
|
||||
this.$refs.table.tabulator.setData(url);
|
||||
}*/
|
||||
{
|
||||
this.gemeinden = {};
|
||||
this.$fhcAlert.alertError('Keine Gemeinde mit PLZ ' + plz + ' gefunden');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
);
|
||||
},
|
||||
getOrtschaften(searchString){
|
||||
return CoreRESTClient.get('components/stv/Kontakt/getOrtschaften/' + searchString
|
||||
).then(
|
||||
result => {
|
||||
if(result.data.retval)
|
||||
this.ortschaften = result.data.retval;
|
||||
else
|
||||
{
|
||||
this.ortschaften = {};
|
||||
//this.$fhcAlert.alertError('Keine Ortschaft mit PLZ ' + plz + ' gefunden');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
);
|
||||
},
|
||||
search(event) {
|
||||
//console.log(event.query);
|
||||
return CoreRESTClient
|
||||
.get('components/stv/Kontakt/getFirmen/' + event.query)
|
||||
.then(result => {
|
||||
this.filteredFirmen = CoreRESTClient.getData(result.data);
|
||||
//return firma.name.toLowerCase().startsWith(event.query.toLowerCase());
|
||||
});
|
||||
},
|
||||
reload(){
|
||||
this.$refs.table.reloadTable();
|
||||
},
|
||||
hideModal(modalRef){
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs[modalRef]).hide();
|
||||
},
|
||||
},
|
||||
created(){
|
||||
CoreRESTClient
|
||||
@@ -140,7 +269,7 @@ export default{
|
||||
console.error(err.response.data || err.message);
|
||||
});
|
||||
CoreRESTClient
|
||||
.get('components/stv/Student/getAdressentypen')
|
||||
.get('components/stv/Kontakt/getAdressentypen')
|
||||
.then(result => {
|
||||
this.adressentypen = result.data;
|
||||
})
|
||||
@@ -148,83 +277,145 @@ export default{
|
||||
console.error(err.response.data || err.message);
|
||||
});
|
||||
},
|
||||
template: `
|
||||
|
||||
template: `
|
||||
<div class="stv-list h-100 pt-3">
|
||||
|
||||
<!-- <Modal>
|
||||
TODO(MANU) use BSModal, Validierungen
|
||||
-->
|
||||
|
||||
<div ref="newAdressModal" class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<!-- <Modal>
|
||||
TODO(MANU) use BSModal, Validierungen
|
||||
-->
|
||||
|
||||
<div ref="newAdressModal" class="modal fade" id="newAddressModal" tabindex="-1" aria-labelledby="newAddressModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Details Adresse</h5>
|
||||
<h5 class="modal-title" id="newAddressModalLabel">Neue Adresse anlegen</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form ref="formData">{{formData}}
|
||||
|
||||
<div class="col-sm-3">
|
||||
<label for="adressentyp" class="form-label required">Typ</label>
|
||||
<form ref="formData">
|
||||
<div class="row mb-3">
|
||||
<label for="adressentyp" class="form-label col-sm-4">Typ</label>
|
||||
<div class="col-sm-5">
|
||||
<select id="adressentyp" class="form-control" v-model="formData.typ">
|
||||
<option value="">-- keine Auswahl --</option>
|
||||
<option v-for="typ in adressentypen" :key="typ.adressentyp_kurzbz" :value="typ.adressentyp_kurzbz" >{{typ.bezeichnung}}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="strasse" class="form-label col-sm-4">Strasse</label>
|
||||
<div class="col-sm-3">
|
||||
<label for="strasse" class="form-label">Strasse</label>
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="strasse" v-model="formData['strasse']" maxlength="256">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="strasse" v-model="formData['strasse']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<label for="nation" class="form-label">Nation</label>
|
||||
<div class="row mb-3">
|
||||
<label for="nation" class="form-label col-sm-4">Nation</label>
|
||||
<div class="col-sm-5">
|
||||
<select id="nation" class="form-control" v-model="formData.nation">
|
||||
<option value="">-- keine Auswahl --</option>
|
||||
<option v-for="nation in nations" :key="nation.nation_code" :value="nation.nation_code" :disabled="nation.sperre">{{nation.kurztext}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="plz" class="required form-label col-sm-4" >PLZ</label>
|
||||
<div class="col-sm-3">
|
||||
<label for="plz" class="required form-label" >PLZ</label>
|
||||
<input type="text" required v-model="formData['plz']" >
|
||||
<input type="text" class="form-control-sm" required v-model="formData['plz']" >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="gemeinde" class="form-label col-sm-4">Gemeinde</label>
|
||||
<div v-if="formData.plz && formData.nation === 'A'" class="col-sm-5">
|
||||
<select id="gemeinde" class="form-control" v-model="formData['gemeinde']" @click="getGemeinden(formData.plz)">
|
||||
<option value="">-- keine Auswahl --</option>
|
||||
<option v-for="gemeinde in gemeinden" :value="gemeinde.name" >{{gemeinde.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-else class="col-sm-3">
|
||||
<div class="col-sm-3">
|
||||
<input id="ort" type="text" class="form-control-sm" v-model="formData['gemeinde']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<label for="gemeinde" class="form-label">Gemeinde</label>
|
||||
<input class="form-control-sm" id="gemeinde" v-model="formData['gemeinde']"maxlength="256">
|
||||
<div class="row mb-3">
|
||||
<label for="ort" class="form-label col-sm-4">Ortschaft</label>
|
||||
<div v-if="formData.plz && formData.nation === 'A' && formData.gemeinde" class="col-sm-5">
|
||||
<select id="ort" class="form-control" v-model="formData['ort']" @click="getOrtschaften(formData.plz + '/' + formData.gemeinde)">
|
||||
<option value="">-- keine Auswahl --</option>
|
||||
<option v-for="ort in ortschaften" :value="ort.ortschaftsname" >{{ort.ortschaftsname}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-else-if="formData.plz && formData.nation === 'A'" class="col-sm-5">
|
||||
<select id="ort" class="form-control" v-model="formData['ort']" @click="getOrtschaften(formData.plz)">
|
||||
<option value="">-- keine Auswahl --</option>
|
||||
<option v-for="ort in ortschaften" :value="ort.ortschaftsname" >{{ort.ortschaftsname}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-else class="col-sm-3">
|
||||
<div class="col-sm-3">
|
||||
<input id="ort" type="text" class="form-control-sm" v-model="formData['ort']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<label for="ort" class="required form-label">Ortschaft</label>
|
||||
<input type="text" required v-model="formData['ort']">
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="heimatadresse" class="form-label col-sm-4">Heimatadresse</label>
|
||||
<div class="col-sm-3 align-self-center">
|
||||
<label for="heimatadresse" class="form-label">Heimatadresse</label>
|
||||
<div class="form-check">
|
||||
<input id="heimatadresse" type="checkbox" class="form-check-input" value="1" v-model="formData['heimatadresse']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="zustelladresse" class="form-label col-sm-4">Zustelladresse</label>
|
||||
<div class="col-sm-3 align-self-center">
|
||||
<label for="zustelladresse" class="form-label">Zustelladresse</label>
|
||||
<div class="form-check">
|
||||
<input id="zustelladresse" type="checkbox" class="form-check-input" value="1" v-model="formData['zustelladresse']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-6">
|
||||
<label for="co_name" class="form-label">Abweich.Empfänger. (c/o)</label>
|
||||
<input type="text" v-model="formData['co_name']">
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="co_name" class="form-label col-sm-4">Abweich.Empfänger. (c/o)</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" id="co_name" class="form-control-sm" v-model="formData['co_name']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="rechnungsadresse" class="form-label col-sm-4">Rechnungsadresse</label>
|
||||
<div class="col-sm-3 align-self-center">
|
||||
<div class="form-check">
|
||||
<input id="rechnungsadresse" type="checkbox" class="form-check-input" v-model="formData['rechnungsadresse']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="firma_name" class="form-label col-sm-4">Firma</label>
|
||||
<div class="col-sm-3">
|
||||
<PvAutoComplete v-model="formData['firma']" optionLabel="name" :suggestions="filteredFirmen" @complete="search" minLength="3"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="name" class="form-label col-sm-4">Name</label>
|
||||
<div class="col-sm-2">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="name" v-model="formData['name']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="anmerkung" class="form-label col-sm-4">Anmerkung</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="anmerkung" v-model="formData['anmerkung']">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
@@ -233,21 +424,199 @@ export default{
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<core-filter-cmpt
|
||||
ref="table"
|
||||
:tabulator-options="tabulatorOptions"
|
||||
:tabulator-events="tabulatorEvents"
|
||||
table-only
|
||||
:side-menu="false"
|
||||
reload
|
||||
new-btn-show
|
||||
new-btn-label="Neu"
|
||||
@click:new="actionNewAdress"
|
||||
|
||||
|
||||
<div ref="editAdressModal" class="modal fade" id="editAdressModal" tabindex="-1" aria-labelledby="editAdressModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editAdressModalLabel">Adresse bearbeiten</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form ref="addressData">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="adressentyp" class="form-label col-sm-4">Typ</label>
|
||||
<div class="col-sm-5">
|
||||
<select id="adressentyp" class="form-control" v-model="addressData.typ">
|
||||
<option v-for="typ in adressentypen" :key="typ.adressentyp_kurzbz" :value="typ.adressentyp_kurzbz" >{{typ.bezeichnung}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="strasse" class="form-label col-sm-4">Strasse</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="strasse" v-model="addressData.strasse">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="nation" class="form-label col-sm-4">Nation</label>
|
||||
<div class="col-sm-5">
|
||||
<select id="nation" class="form-control" v-model="addressData.nation">
|
||||
<option v-for="nation in nations" :key="nation.nation_code" :value="nation.nation_code" :disabled="nation.sperre">{{nation.kurztext}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="plz" class="required form-label col-sm-4" >PLZ</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" class="form-control-sm" required v-model="addressData.plz" >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="gemeinde" class="form-label col-sm-4">Gemeinde</label>
|
||||
<div v-if="addressData.gemeinde" class="col-sm-3" >
|
||||
<input id="ort" type="text" class="form-control-sm" v-model="addressData['gemeinde']">
|
||||
</div>
|
||||
<div v-else-if="addressData.plz && addressData.nation === 'A'" class="col-sm-5">
|
||||
<select id="gemeinde" class="form-control" v-model="addressData['gemeinde']" @click="getGemeinden(addressData.plz)">
|
||||
<option value="">-- keine Auswahl --</option>
|
||||
<option v-for="gemeinde in gemeinden" :value="gemeinde.name" >{{gemeinde.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-else class="col-sm-3">
|
||||
<div class="col-sm-3">
|
||||
<input id="ort" type="text" class="form-control-sm" v-model="addressData['gemeinde']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="ort" class="form-label col-sm-4">Ortschaft</label>
|
||||
<div v-if="addressData.ort" class="col-sm-3">
|
||||
<div class="col-sm-3">
|
||||
<input id="ort" type="text" class="form-control-sm" v-model="addressData['ort']">
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="addressData.plz && addressData.nation === 'A' && addressData.gemeinde" class="col-sm-5">
|
||||
<select id="ort" class="form-control" v-model="addressData['ort']" @click="getOrtschaften(addressData.plz + '/' + addressData.gemeinde)">
|
||||
<option value="">-- keine Auswahl --</option>
|
||||
<option v-for="ort in ortschaften" :value="ort.ortschaftsname" >{{ort.ortschaftsname}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-else-if="addressData.plz && addressData.nation === 'A'" class="col-sm-5">
|
||||
<select id="ort" class="form-control" v-model="addressData['ort']" @click="getOrtschaften(addressData.plz)">
|
||||
<option value="">-- keine Auswahl --</option>
|
||||
<option v-for="ort in ortschaften" :value="ort.ortschaftsname" >{{ort.ortschaftsname}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-else class="col-sm-3">
|
||||
<div class="col-sm-3">
|
||||
<input id="ort" type="text" class="form-control-sm" v-model="addressData['ort']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="heimatadresse" class="form-label col-sm-4">Heimatadresse</label>
|
||||
<div class="col-sm-3 align-self-center">
|
||||
<div class="form-check">
|
||||
<input id="heimatadresse" type="checkbox" class="form-check-input" value="1" v-model="addressData['heimatadresse']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="zustelladresse" class="form-label col-sm-4">Zustelladresse</label>
|
||||
<div class="col-sm-3 align-self-center">
|
||||
<div class="form-check">
|
||||
<input id="zustelladresse" type="checkbox" class="form-check-input" value="1" v-model="addressData['zustelladresse']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="co_name" class="form-label col-sm-4">Abweich.Empfänger. (c/o)</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" id="co_name" class="form-control-sm" v-model="addressData['co_name']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="rechnungsadresse" class="form-label col-sm-4">Rechnungsadresse</label>
|
||||
<div class="col-sm-3 align-self-center">
|
||||
<div class="form-check">
|
||||
<input id="rechnungsadresse" type="checkbox" class="form-check-input" v-model="addressData['rechnungsadresse']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="firma_name" class="form-label col-sm-4">Firma</label>
|
||||
<div v-if="addressData.firmenname" class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="name" v-model="addressData.firmenname">
|
||||
</div>
|
||||
<div v-else class="col-sm-3">
|
||||
<PvAutoComplete v-model="addressData['firma']" optionLabel="name" :suggestions="filteredFirmen" @complete="search" minLength="3"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<input type="hidden" :readonly="readonly" class="form-control-sm" id="firma_id" v-model="addressData.firma_id">
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="name" class="form-label col-sm-4">Name</label>
|
||||
<div class="col-sm-2">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="name" v-model="addressData['name']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="anmerkung" class="form-label col-sm-4">Anmerkung</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="anmerkung" v-model="addressData['anmerkung']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<button ref="Close" type="button" class="btn btn-primary" @click="updateAddress(addressData.adresse_id)">OK</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ref="deleteAdressModal" class="modal fade" id="deleteAdressModal" tabindex="-1" aria-labelledby="deleteAdressModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteAdressModalLabel">Adresse löschen</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Adresse {{addressData.adresse_id}} wirklich löschen?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<button type="button" class="btn btn-primary" @click="deleteAddress(addressData.adresse_id)">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<core-filter-cmpt
|
||||
ref="table"
|
||||
:tabulator-options="tabulatorOptions"
|
||||
:tabulator-events="tabulatorEvents"
|
||||
table-only
|
||||
:side-menu="false"
|
||||
reload
|
||||
new-btn-show
|
||||
new-btn-label="Neu"
|
||||
@click:new="actionNewAdress"
|
||||
>
|
||||
<button v-if="reload" class="btn btn-outline-warning" aria-label="Reload" @click="editTable">
|
||||
<span class="fa-solid fa-rotate-right" aria-hidden="true"></span>
|
||||
<button v-if="reload" class="btn btn-outline-warning" aria-label="Reload">
|
||||
<span class="fa-solid fa-rotate-right" aria-hidden="true"></span>
|
||||
</button>
|
||||
</core-filter-cmpt>
|
||||
</div>`
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import {CoreFilterCmpt} from "../../../../filter/Filter.js";
|
||||
import {CoreRESTClient} from "../../../../../RESTClient";
|
||||
|
||||
var editIcon = function(cell, formatterParams){ //plain text value
|
||||
return "<i class='fa fa-edit'></i>";
|
||||
};
|
||||
var deleteIcon = function(cell, formatterParams) { //plain text value
|
||||
return "<i class='fa fa-remove'></i>";
|
||||
};
|
||||
|
||||
export default{
|
||||
components: {
|
||||
CoreFilterCmpt
|
||||
@@ -14,7 +21,7 @@ export default{
|
||||
data() {
|
||||
return{
|
||||
tabulatorOptions: {
|
||||
ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Student/getBankverbindung/' + this.uid),
|
||||
ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Kontakt/getBankverbindung/' + this.uid),
|
||||
columns:[
|
||||
{title:"Name", field:"name"},
|
||||
{title:"Anschrift", field:"anschrift", visible:false},
|
||||
@@ -44,6 +51,18 @@ export default{
|
||||
},
|
||||
{title:"Person_id", field:"person_id", visible:false},
|
||||
{title:"Bankverbindung_id", field:"bankverbindung_id", visible:false},
|
||||
{title: "Actions",
|
||||
columns:[
|
||||
{formatter:editIcon, width:40, align:"center", cellClick: (e, cell) => {
|
||||
this.actionEditBankverbindung(cell.getData().bankverbindung_id);
|
||||
console.log(cell.getRow().getIndex(), cell.getData(), this);
|
||||
}, width:50, headerSort:false},
|
||||
{formatter:deleteIcon, width:40, align:"center", cellClick: (e, cell) => {
|
||||
this.actionDeleteBankverbindung(cell.getData().bankverbindung_id);
|
||||
console.log(cell.getRow().getIndex(), cell.getData(), this);
|
||||
}, width:50, headerSort:false },
|
||||
],
|
||||
},
|
||||
],
|
||||
layout: 'fitDataFill',
|
||||
layoutColumnsOnNewData: false,
|
||||
@@ -51,37 +70,310 @@ export default{
|
||||
selectable: true,
|
||||
index: 'bankverbindung_id',
|
||||
},
|
||||
tabulatorEvents: [
|
||||
/* {
|
||||
event: 'rowSelectionChanged',
|
||||
handler: this.rowSelectionChanged
|
||||
},
|
||||
{
|
||||
event: 'dataProcessed',
|
||||
handler: this.autoSelectRows
|
||||
}*/
|
||||
],
|
||||
lastSelected: null
|
||||
tabulatorEvents: [],
|
||||
lastSelected: null,
|
||||
bankverbindungData: {
|
||||
verrechnung: true
|
||||
}
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
actionNewAdress(){
|
||||
console.log("Neuen Kontakt anlegen");
|
||||
actionNewBankverbindung(){
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs.newBankverbindungModal).show();
|
||||
},
|
||||
updateUrl(url, first) {
|
||||
this.lastSelected = first ? undefined : this.selected;
|
||||
if (url)
|
||||
url = CoreRESTClient._generateRouterURI(url);
|
||||
if (!this.$refs.table.tableBuilt)
|
||||
this.$refs.table.tabulator.on("tableBuilt", () => {
|
||||
this.$refs.table.tabulator.setData(url);
|
||||
});
|
||||
else
|
||||
this.$refs.table.tabulator.setData(url);
|
||||
actionEditBankverbindung(bankverbindung_id){
|
||||
this.loadBankverbindung(bankverbindung_id).then(() => {
|
||||
if(this.bankverbindungData.bankverbindung_id)
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs.editBankverbindungModal).show();
|
||||
});
|
||||
},
|
||||
actionDeleteBankverbindung(bankverbindung_id){
|
||||
this.loadBankverbindung(bankverbindung_id).then(() => {
|
||||
if(this.bankverbindungData.bankverbindung_id) //Todo(Manu) not optimal
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs.deleteBankverbindungModal).show();
|
||||
});
|
||||
},
|
||||
addNewBankverbindung(bankverbindungData) {
|
||||
CoreRESTClient.post('components/stv/Kontakt/addNewBankverbindung/' + this.uid,
|
||||
this.bankverbindungData
|
||||
).then(response => {
|
||||
if (!response.data.error) {
|
||||
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
|
||||
this.hideModal('newBankverbindungModal');
|
||||
this.reload();
|
||||
} else {
|
||||
//console.log(response.data.retval);
|
||||
const errorData = response.data.retval;
|
||||
Object.entries(errorData).forEach(entry => {
|
||||
const [key, value] = entry;
|
||||
console.log(key, value);
|
||||
this.$fhcAlert.alertError('Das Feld ' + key + ' ist erforderlich');
|
||||
});
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = response.data;
|
||||
//console.log('Speichern nicht erfolgreich: ' + this.statusMsg);
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'Error in Catch';
|
||||
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
|
||||
}).finally(() => {
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
},
|
||||
loadBankverbindung(bankverbindung_id){
|
||||
return CoreRESTClient.get('components/stv/Kontakt/loadBankverbindung/' + bankverbindung_id
|
||||
).then(
|
||||
result => {
|
||||
console.log(this.bankverbindungData, 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;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
);
|
||||
},
|
||||
updateBankverbindung(bankverbindung_id){
|
||||
CoreRESTClient.post('components/stv/Kontakt/updateBankverbindung/' + bankverbindung_id,
|
||||
this.bankverbindungData
|
||||
).then(response => {
|
||||
console.log(response);
|
||||
if (!response.data.error) {
|
||||
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
|
||||
this.hideModal('editBankverbindungModal');
|
||||
this.reload();
|
||||
} else {
|
||||
const errorData = response.data.retval;
|
||||
console.log(errorData);
|
||||
Object.entries(errorData).forEach(entry => {
|
||||
const [key, value] = entry;
|
||||
this.$fhcAlert.alertError('Das Feld ' + key + ' ist erforderlich');
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
this.statusMsg = 'Error in Catch';
|
||||
console.log('Speichern nicht erfolgreich ' + this.statusMsg);
|
||||
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
|
||||
}).finally(() => {
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
},
|
||||
deleteBankverbindung(bankverbindung_id){
|
||||
CoreRESTClient.post('components/stv/Kontakt/deleteBankverbindung/' + bankverbindung_id)
|
||||
.then(response => {
|
||||
console.log(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(()=> {
|
||||
window.scrollTo(0, 0);
|
||||
this.hideModal('deleteBankverbindungModal');
|
||||
this.reload();
|
||||
});
|
||||
},
|
||||
hideModal(modalRef){
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs[modalRef]).hide();
|
||||
},
|
||||
reload(){
|
||||
this.$refs.table.reloadTable();
|
||||
},
|
||||
resetData(){ //Todo(manu) check
|
||||
bankverbindungData: [];
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="stv-list h-100 pt-3">
|
||||
|
||||
<!-- <button type="button" class="btn btn btn-outline-warning" class="col-sm-2" @click="actionDeleteBankverbindung(8796)">delete 8796</button>
|
||||
<button type="button" class="btn btn btn-outline-warning" class="col-sm-2" @click="actionEditBankverbindung(8796)">edit 8796</button>
|
||||
<button type="button" class="btn btn btn-outline-warning" class="col-sm-2" @click="reload">reload</button>-->
|
||||
|
||||
<!--Modal: new Bankverbindung-->
|
||||
<div ref="newBankverbindungModal" class="modal fade" id="newBankverbindungModal" tabindex="-1" aria-labelledby="newBankverbindungModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="newBankverbindungModalLabel">Bankverbindung anlegen</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form ref="bankverbindungData">
|
||||
<!-- {{bankverbindungData}} -->
|
||||
<div class="row mb-3">
|
||||
<label for="name" class="form-label col-sm-4">Name</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="name" v-model="bankverbindungData['name']">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="anschrift" class="form-label col-sm-4">Anschrift</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="anschrift" v-model="bankverbindungData['anschrift']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="iban" class="form-label col-sm-4">IBAN</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" required class="form-control-sm" id="iban" v-model="bankverbindungData['iban']">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="bic" class="form-label col-sm-4">BIC</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="bic" v-model="bankverbindungData['bic']">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="kontonr" class="form-label col-sm-4">Kontonummer</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="kontonr" v-model="bankverbindungData['kontonr']">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="blz" class="form-label col-sm-4">BLZ</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="blz" v-model="bankverbindungData['blz']">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="typ" class="form-label col-sm-4">Typ</label>
|
||||
<div class="col-sm-5">
|
||||
<select id="typ" class="form-control" required v-model="bankverbindungData['typ']">
|
||||
<option value="p">Privatkonto</option>
|
||||
<option value="f">Firmenkonto</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="verrechnung" class="form-label col-sm-4">Verrechnung</label>
|
||||
<div class="col-sm-3 align-self-center">
|
||||
<div class="form-check">
|
||||
<input id="verrechnung" type="checkbox" class="form-check-input" value="1" v-model="bankverbindungData['verrechnung']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<button type="button" class="btn btn-primary" @click="addNewBankverbindung()">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Modal: Edit Bankverbindung-->
|
||||
<div ref="editBankverbindungModal" class="modal fade" id="editBankverbindungModal" tabindex="-1" aria-labelledby="editBankverbindungModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editBankverbindungModalLabel">Bankverbindung bearbeiten</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form ref="bankverbindungData">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="name" class="form-label col-sm-4">Name</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="name" v-model="bankverbindungData['name']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="anschrift" class="form-label col-sm-4">Anschrift</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="anschrift" v-model="bankverbindungData['anschrift']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="iban" class="form-label col-sm-4">IBAN</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" required class="form-control-sm" id="iban" v-model="bankverbindungData['iban']">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="bic" class="form-label col-sm-4">BIC</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="bic" v-model="bankverbindungData['bic']">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="kontonr" class="form-label col-sm-4">Kontonummer</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="kontonr" v-model="bankverbindungData['kontonr']">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="blz" class="form-label col-sm-4">BLZ</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="blz" v-model="bankverbindungData['blz']">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="typ" class="form-label col-sm-4">Typ</label>
|
||||
<div class="col-sm-5">
|
||||
<select id="typ" class="form-control" required v-model="bankverbindungData['typ']">
|
||||
<option value="p">Privatkonto</option>
|
||||
<option value="f">Firmenkonto</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="verrechnung" class="form-label col-sm-4">Verrechnung</label>
|
||||
<div class="col-sm-3 align-self-center">
|
||||
<div class="form-check">
|
||||
<input id="verrechnung" type="checkbox" class="form-check-input" value="1" v-model="bankverbindungData['verrechnung']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<button ref="Close" type="button" class="btn btn-primary" @click="updateBankverbindung(bankverbindungData.bankverbindung_id)">OK</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal: Delete Bankverbindung-->
|
||||
<div ref="deleteBankverbindungModal" class="modal fade" id="deleteBankverbindungModal" tabindex="-1" aria-labelledby="deleteBankverbindungModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteBankverbindungModalLabel">Kontakt löschen</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Bankverbindung wirklich löschen?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<button type="button" class="btn btn-primary" @click="deleteBankverbindung(bankverbindungData.bankverbindung_id)">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<core-filter-cmpt
|
||||
ref="table"
|
||||
:tabulator-options="tabulatorOptions"
|
||||
@@ -91,7 +383,7 @@ export default{
|
||||
reload
|
||||
new-btn-show
|
||||
new-btn-label="Neu"
|
||||
@click:new="actionNewContact"
|
||||
@click:new="actionNewBankverbindung"
|
||||
>
|
||||
</core-filter-cmpt>
|
||||
</div>`
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import {CoreFilterCmpt} from "../../../../filter/Filter.js";
|
||||
import {CoreRESTClient} from "../../../../../RESTClient";
|
||||
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";
|
||||
|
||||
var editIcon = function(cell, formatterParams){ //plain text value
|
||||
return "<i class='fa fa-edit'></i>";
|
||||
@@ -10,7 +12,9 @@ var deleteIcon = function(cell, formatterParams){ //plain text value
|
||||
|
||||
export default{
|
||||
components: {
|
||||
CoreFilterCmpt
|
||||
CoreFilterCmpt,
|
||||
PvAutoComplete,
|
||||
PvToast
|
||||
},
|
||||
props: {
|
||||
uid: String
|
||||
@@ -21,7 +25,7 @@ export default{
|
||||
data() {
|
||||
return{
|
||||
tabulatorOptions: {
|
||||
ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Student/getKontakte/' + this.uid),
|
||||
ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Kontakt/getKontakte/' + this.uid),
|
||||
columns:[
|
||||
{title:"Typ", field:"kontakttyp"}, //TODO(manu) mix ok?
|
||||
{title:"Kontakt", field:"kontakt"},
|
||||
@@ -31,51 +35,343 @@ export default{
|
||||
return output;}
|
||||
},
|
||||
{title:"Anmerkung", field:"anmerkung"},
|
||||
//{title:"Firma", field:"adress_id"},
|
||||
{title:"Firma", field:"kurzbz", visible:false},
|
||||
{title:"Firma_id", field:"firma_id", visible:false},
|
||||
{title:"Person_id", field:"person_id", visible:false},
|
||||
{title:"Kontakt_id", field:"kontakt_id", visible:false},
|
||||
{title:"Standort_id", field:"standort_id", visible:false},
|
||||
{title:"letzte Änderung", field:"updateamum", visible:false},
|
||||
{formatter:editIcon, width:40, align:"center", cellClick:function(e, cell){alert("Edit data for kontakt_id: " + cell.getRow().getIndex())}},
|
||||
{formatter:deleteIcon, width:40, align:"center", cellClick:function(e, cell){alert("Delete data for kontakt_id " + cell.getRow().getIndex())}},
|
||||
{title: "Actions",
|
||||
columns:[
|
||||
{formatter:editIcon, cellClick: (e, cell) => {
|
||||
this.actionEditContact(cell.getData().kontakt_id);
|
||||
console.log(cell.getRow().getIndex(), cell.getData(), this);
|
||||
}, width:50, headerSort:false, headerVisible:false},
|
||||
{formatter:deleteIcon, cellClick: (e, cell) => {
|
||||
this.actionDeleteContact(cell.getData().kontakt_id);
|
||||
console.log(cell.getRow().getIndex(), cell.getData(), this);
|
||||
}, width:50, headerSort:false, headerVisible:false },
|
||||
],
|
||||
},
|
||||
],
|
||||
layout: 'fitDataFill',
|
||||
layoutColumnsOnNewData: false,
|
||||
height: 'auto',
|
||||
selectable: true,
|
||||
index: 'kontakt_id',
|
||||
index: 'kontakt_id'
|
||||
},
|
||||
tabulatorEvents: [
|
||||
/* {
|
||||
event: 'rowSelectionChanged',
|
||||
handler: this.rowSelectionChanged
|
||||
},
|
||||
{
|
||||
event: 'dataProcessed',
|
||||
handler: this.autoSelectRows
|
||||
}*/
|
||||
],
|
||||
lastSelected: null
|
||||
lastSelected: null,
|
||||
contactData: {
|
||||
zustellung: true,
|
||||
kontakttyp: 'email'
|
||||
},
|
||||
kontakttypen: [],
|
||||
standorte: [],
|
||||
selectedStandort: null,
|
||||
filteredStandorte: null
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
actionNewAdress(){
|
||||
actionNewContact(){
|
||||
console.log("Neuen Kontakt anlegen");
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs.newContactModal).show();
|
||||
},
|
||||
updateUrl(url, first) {
|
||||
this.lastSelected = first ? undefined : this.selected;
|
||||
if (url)
|
||||
url = CoreRESTClient._generateRouterURI(url);
|
||||
if (!this.$refs.table.tableBuilt)
|
||||
this.$refs.table.tabulator.on("tableBuilt", () => {
|
||||
this.$refs.table.tabulator.setData(url);
|
||||
actionEditContact(contact_id){
|
||||
console.log("Edit Contact mit contact_id " + contact_id);
|
||||
this.loadContact(contact_id);
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs.editContactModal).show();
|
||||
|
||||
},
|
||||
actionDeleteContact(contact_id){
|
||||
console.log("Delete Contact " + contact_id);
|
||||
this.loadContact(contact_id);
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs.deleteContactModal).show();
|
||||
},
|
||||
addNewContact(formData) {
|
||||
CoreRESTClient.post('components/stv/Kontakt/addNewContact/' + this.uid,
|
||||
this.contactData
|
||||
).then(response => {
|
||||
console.log(response);
|
||||
if (!response.data.error) {
|
||||
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
|
||||
this.hideModal("newContactModal");
|
||||
} else {
|
||||
const errorData = response.data.retval;
|
||||
Object.entries(errorData).forEach(entry => {
|
||||
const [key, value] = entry;
|
||||
console.log(key, value);
|
||||
this.$fhcAlert.alertError(value);
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'Error in Catch';
|
||||
console.log('Speichern nicht erfolgreich ' + this.statusMsg);
|
||||
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
|
||||
}).finally(() => {
|
||||
window.scrollTo(0, 0);
|
||||
this.reload();
|
||||
});
|
||||
},
|
||||
loadContact(contact_id){
|
||||
return CoreRESTClient.get('components/stv/Kontakt/loadContact/' + contact_id
|
||||
).then(
|
||||
result => {
|
||||
console.log(this.contactData, result);
|
||||
if(result.data.retval)
|
||||
this.contactData = result.data.retval;
|
||||
else
|
||||
{
|
||||
this.contactData = {};
|
||||
this.$fhcAlert.alertError('Kein Kontakt mit Id ' + contact_id + ' gefunden');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
);
|
||||
},
|
||||
deleteContact(kontakt_id){
|
||||
CoreRESTClient.post('components/stv/Kontakt/deleteContact/' + kontakt_id)
|
||||
.then(response => {
|
||||
console.log(response);
|
||||
if (!response.data.error) {
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'success';
|
||||
console.log('Löschen erfolgreich: ' + this.statusMsg);
|
||||
this.$fhcAlert.alertSuccess('Löschen erfolgreich');
|
||||
} else {
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'Error';
|
||||
console.log('Löschen nicht erfolgreich: ' + this.statusMsg);
|
||||
this.$fhcAlert.alertError('Keine Adresse mit Id ' + kontakt_id + ' gefunden');
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'Error in Catch';
|
||||
console.log('Löschen nicht erfolgreich ' + this.statusMsg);
|
||||
this.$fhcAlert.alertError('Fehler bei Löschroutine aufgetreten');
|
||||
}).finally(()=> {
|
||||
window.scrollTo(0, 0);
|
||||
this.hideModal('deleteContactModal');
|
||||
this.reload();
|
||||
});
|
||||
},
|
||||
updateContact(kontakt_id){
|
||||
CoreRESTClient.post('components/stv/Kontakt/updateContact/' + kontakt_id,
|
||||
this.contactData
|
||||
).then(response => {
|
||||
console.log(response);
|
||||
if (!response.data.error) {
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'success';
|
||||
console.log('Speichern erfolgreich: ' + this.statusMsg);
|
||||
this.$fhcAlert.alertSuccess('Speichern erfolgreich');
|
||||
this.hideModal('editContactModal');
|
||||
this.reload();
|
||||
} else {
|
||||
const errorData = response.data.retval;
|
||||
Object.entries(errorData).forEach(entry => {
|
||||
const [key, value] = entry;
|
||||
console.log(key, value);
|
||||
this.$fhcAlert.alertError(value);
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
this.statusCode = 0;
|
||||
this.statusMsg = 'Error in Catch';
|
||||
console.log('Speichern nicht erfolgreich ' + this.statusMsg);
|
||||
this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten');
|
||||
}).finally(() => {
|
||||
window.scrollTo(0, 0);
|
||||
//hideModal();
|
||||
this.reload();
|
||||
});
|
||||
},
|
||||
hideModal(modalRef){
|
||||
bootstrap.Modal.getOrCreateInstance(this.$refs[modalRef]).hide();
|
||||
},
|
||||
reload(){
|
||||
this.$refs.table.reloadTable();
|
||||
},
|
||||
search(event) {
|
||||
return CoreRESTClient
|
||||
.get('components/stv/Kontakt/getStandorte/' + event.query)
|
||||
.then(result => {
|
||||
this.filteredStandorte = CoreRESTClient.getData(result.data);
|
||||
});
|
||||
else
|
||||
this.$refs.table.tabulator.setData(url);
|
||||
}
|
||||
},
|
||||
},
|
||||
created(){
|
||||
CoreRESTClient
|
||||
.get('components/stv/Kontakt/getKontakttypen')
|
||||
.then(result => {
|
||||
this.kontakttypen = result.data;
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err.response.data || err.message);
|
||||
});
|
||||
},
|
||||
template: `
|
||||
<div class="stv-list h-100 pt-3">
|
||||
|
||||
<!--Modal: new Contact-->
|
||||
<div ref="newContactModal" class="modal fade" id="newAContactModal" tabindex="-1" aria-labelledby="newAContactModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="newContactModalLabel">Details</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form ref="contactData">
|
||||
{{contactData}}
|
||||
<div class="row mb-3">
|
||||
<label for="kontakttyp" class="form-label col-sm-4">Typ</label>
|
||||
<div class="col-sm-5">
|
||||
<select id="kontakttyp" class="form-control" v-model="contactData.kontakttyp">
|
||||
<option value="">-- keine Auswahl --</option>
|
||||
<option v-for="typ in kontakttypen" :key="typ.kontakttyp_kurzbz" :value="typ.kontakttyp" >{{typ.kontakttyp}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="kontakt" class="form-label col-sm-4">Kontakt</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="kontakt" v-model="contactData['kontakt']">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="anmerkung" class="form-label col-sm-4">Anmerkung</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="anmerkung" v-model="contactData['anmerkung']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="zustellung" class="form-label col-sm-4">Zustellung</label>
|
||||
<div class="col-sm-3 align-self-center">
|
||||
<div class="form-check">
|
||||
<input id="zustellung" type="checkbox" class="form-check-input" value="1" v-model="contactData['zustellung']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="firma_name" class="form-label col-sm-4">Firma / Standort</label>
|
||||
<div class="col-sm-3">
|
||||
<PvAutoComplete v-model="contactData['standort']" optionLabel="kurzbz" :suggestions="filteredStandorte" @complete="search" minLength="3"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<button type="button" class="btn btn-primary" @click="addNewContact()">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Modal: Edit Contact-->
|
||||
<div ref="editContactModal" class="modal fade" id="editContactModal" tabindex="-1" aria-labelledby="editContactModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editContactModalLabel">Kontakt bearbeiten</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form ref="contactData">{{contactData}}
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="kontakttyp" class="form-label col-sm-4">Typ</label>
|
||||
<div class="col-sm-5">
|
||||
<select id="kontakttyp" class="form-control" v-model="contactData.kontakttyp">
|
||||
<option value="">-- keine Auswahl --</option>
|
||||
<option v-for="typ in kontakttypen" :key="typ.kontakttyp_kurzbz" :value="typ.kontakttyp" >{{typ.kontakttyp}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="kontakt" class="form-label col-sm-4">Kontakt</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="kontakt" v-model="contactData['kontakt']">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="anmerkung" class="form-label col-sm-4">Anmerkung</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="anmerkung" v-model="contactData['anmerkung']">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="zustellung" class="form-label col-sm-4">Zustellung</label>
|
||||
<div class="col-sm-3 align-self-center">
|
||||
<div class="form-check">
|
||||
<input id="zustellung" type="checkbox" class="form-check-input" value="1" v-model="contactData['zustellung']">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="standort_id" v-model="contactData.standort_id">
|
||||
</div>
|
||||
|
||||
<!-- <div class="row mb-3">
|
||||
<label for="name" class="form-label col-sm-4">Firma/Standort</label>
|
||||
<div class="col-sm-2">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="name" v-model="addressData['name']">
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="row mb-3">
|
||||
<label for="standort" class="form-label col-sm-4">Firma / Standort</label>
|
||||
<div v-if="contactData.kurzbz" class="col-sm-3">
|
||||
<input type="text" :readonly="readonly" class="form-control-sm" id="name" v-model="contactData.kurzbz">
|
||||
</div>
|
||||
<div v-else class="col-sm-3">
|
||||
<PvAutoComplete v-model="contactData['standort']" optionLabel="kurzbz" :suggestions="filteredStandorte" @complete="search" minLength="3"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<button ref="Close" type="button" class="btn btn-primary" @click="updateContact(contactData.kontakt_id)">OK</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal: Delete Contact-->
|
||||
<div ref="deleteContactModal" class="modal fade" id="deleteContactModal" tabindex="-1" aria-labelledby="deleteContactModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteContactModalLabel">Kontakt löschen</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Kontakt {{contactData.kontakt_id}} wirklich löschen?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<button type="button" class="btn btn-primary" @click="deleteContact(contactData.kontakt_id)">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<core-filter-cmpt
|
||||
ref="table"
|
||||
:tabulator-options="tabulatorOptions"
|
||||
|
||||
Reference in New Issue
Block a user