mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
use factories in Address.js, Bankaccount.js, Contact.js
This commit is contained in:
@@ -45,8 +45,12 @@ class Address extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getPlaces($plz)
|
||||
public function getPlaces($plz = null)
|
||||
{
|
||||
//TODO(Manu) check with Chris
|
||||
if (!$plz){
|
||||
$plz = $this->input->post('plz');
|
||||
}
|
||||
$this->load->model('codex/Gemeinde_model', 'GemeindeModel');
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
@@ -97,7 +97,22 @@ class Kontakt extends FHCAPI_Controller
|
||||
|| $this->router->method == 'deleteContact'
|
||||
|| $this->router->method == 'deleteBankverbindung'
|
||||
) {
|
||||
$id = current(array_slice($this->uri->rsegments, 2));
|
||||
|
||||
//TODO(manu) build all new with postparamater
|
||||
|
||||
if($this->input->post('address_id'))
|
||||
$id = $this->input->post('address_id');
|
||||
if($this->input->post('adresse_id'))
|
||||
$id = $this->input->post('adresse_id');
|
||||
if($this->input->post('bankverbindung_id'))
|
||||
$id = $this->input->post('bankverbindung_id');
|
||||
if($this->input->post('kontakt_id'))
|
||||
$id = $this->input->post('kontakt_id');
|
||||
|
||||
//$id = current(array_slice($this->uri->rsegments, 2));
|
||||
// $id = $this->input->post('address_id') || $this->input->post('adresse_id');
|
||||
//$id: no more uri parameter
|
||||
// $this->terminateWithError($this->router->method, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$model = 'person/Adresse_model';
|
||||
if ($this->router->method == 'loadContact'
|
||||
@@ -203,8 +218,11 @@ class Kontakt extends FHCAPI_Controller
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function updateAddress($address_id)
|
||||
public function updateAddress()
|
||||
{
|
||||
//TODO(Manu) rename all to same
|
||||
$address_id = $this->input->post('adresse_id');
|
||||
|
||||
$uid = getAuthUID();
|
||||
$this->form_validation->set_rules('plz', 'PLZ', 'required|numeric', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'PLZ']),
|
||||
@@ -279,8 +297,10 @@ class Kontakt extends FHCAPI_Controller
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function loadAddress($adresse_id)
|
||||
public function loadAddress()
|
||||
{
|
||||
$adresse_id = $this->input->post('address_id');
|
||||
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
|
||||
$this->AdresseModel->addSelect('public.tbl_adresse.*');
|
||||
@@ -306,8 +326,12 @@ class Kontakt extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess(current(getData($result)) ? : null);
|
||||
}
|
||||
|
||||
public function deleteAddress($adresse_id)
|
||||
public function deleteAddress()
|
||||
{
|
||||
//TODO(Manu) rename all to same
|
||||
$adresse_id = $this->input->post('address_id');
|
||||
// return $this->terminateWithError($adresse_id, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
$result = $this->AdresseModel->load([
|
||||
'adresse_id'=> $adresse_id,
|
||||
@@ -418,8 +442,9 @@ class Kontakt extends FHCAPI_Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function loadContact($kontakt_id)
|
||||
public function loadContact()
|
||||
{
|
||||
$kontakt_id = $this->input->post('kontakt_id');
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
$this->KontaktModel->addSelect('*, public.tbl_kontakt.*');
|
||||
@@ -494,8 +519,9 @@ class Kontakt extends FHCAPI_Controller
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function updateContact($kontakt_id)
|
||||
public function updateContact()
|
||||
{
|
||||
$kontakt_id = $this->input->post('kontakt_id');
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
if(!$kontakt_id)
|
||||
@@ -554,8 +580,9 @@ class Kontakt extends FHCAPI_Controller
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function deleteContact($kontakt_id)
|
||||
public function deleteContact()
|
||||
{
|
||||
$kontakt_id = $this->input->post('kontakt_id');
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
$result = $this->KontaktModel->delete(
|
||||
@@ -640,8 +667,10 @@ class Kontakt extends FHCAPI_Controller
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function loadBankverbindung($bankverbindung_id)
|
||||
public function loadBankverbindung()
|
||||
{
|
||||
$bankverbindung_id = $this->input->post('bankverbindung_id');
|
||||
|
||||
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
|
||||
|
||||
$this->BankverbindungModel->addSelect('*');
|
||||
@@ -716,8 +745,10 @@ class Kontakt extends FHCAPI_Controller
|
||||
return $this->outputJsonSuccess(true);
|
||||
}
|
||||
|
||||
public function deleteBankverbindung($bankverbindung_id)
|
||||
public function deleteBankverbindung()
|
||||
{
|
||||
$bankverbindung_id = $this->input->post('bankverbindung_id');
|
||||
|
||||
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
|
||||
|
||||
$result = $this->BankverbindungModel->delete(
|
||||
|
||||
@@ -2,12 +2,14 @@ import verband from './stv/verband.js';
|
||||
import students from './stv/students.js';
|
||||
import filter from './stv/filter.js';
|
||||
import konto from './stv/konto.js';
|
||||
import kontakt from './stv/kontakt.js';
|
||||
|
||||
export default {
|
||||
verband,
|
||||
students,
|
||||
filter,
|
||||
konto,
|
||||
kontakt,
|
||||
configStudent() {
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/config/student');
|
||||
},
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
export default {
|
||||
//TODO(Manu) check if tabulatorConfig use here like in konto.js
|
||||
getAdressen (url, config, params){
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getAdressen/' + params.id);
|
||||
},
|
||||
addNewAddress(id, data) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewAddress/' + id,
|
||||
data
|
||||
);
|
||||
},
|
||||
loadAddress(address_id){
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/loadAddress/', {address_id});
|
||||
},
|
||||
updateAddress(address_id, data) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateAddress/' + address_id,
|
||||
data
|
||||
);
|
||||
},
|
||||
deleteAddress(address_id) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteAddress/', {address_id});
|
||||
},
|
||||
getPlaces(plz) {
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/address/getPlaces/' + plz);
|
||||
},
|
||||
getFirmen(searchString) {
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getFirmen/' + searchString);
|
||||
},
|
||||
getNations() {
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/address/getNations/');
|
||||
},
|
||||
getAdressentypen() {
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getAdressentypen/');
|
||||
},
|
||||
getBankverbindung (url, config, params){
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getBankverbindung/' + params.id);
|
||||
},
|
||||
addNewBankverbindung(id, data) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewBankverbindung/' + id,
|
||||
data
|
||||
);
|
||||
},
|
||||
loadBankverbindung(bankverbindung_id){
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/loadBankverbindung/', {bankverbindung_id});
|
||||
},
|
||||
updateBankverbindung(bankverbindung_id, data) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateBankverbindung/' + bankverbindung_id,
|
||||
data
|
||||
);
|
||||
},
|
||||
deleteBankverbindung(bankverbindung_id) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteBankverbindung/', {bankverbindung_id});
|
||||
},
|
||||
getKontakte (url, config, params){
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getKontakte/' + params.id);
|
||||
},
|
||||
addNewContact(id, data) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewContact/' + id,
|
||||
data
|
||||
);
|
||||
},
|
||||
loadContact(kontakt_id){
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/loadContact/', {kontakt_id});
|
||||
},
|
||||
updateContact(kontakt_id, data) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateContact/' + kontakt_id,
|
||||
data
|
||||
);
|
||||
},
|
||||
deleteContact(kontakt_id) {
|
||||
return this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteContact/', {kontakt_id});
|
||||
},
|
||||
getStandorteByFirma(searchString){
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getStandorteByFirma/' + searchString);
|
||||
},
|
||||
getKontakttypen(){
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getKontakttypen/');
|
||||
}
|
||||
};
|
||||
@@ -18,10 +18,15 @@ export default{
|
||||
uid: Number
|
||||
},
|
||||
data() {
|
||||
return{
|
||||
return {
|
||||
tabulatorOptions: {
|
||||
ajaxURL: 'api/frontend/v1/stv/kontakt/getAdressen/' + this.uid,
|
||||
ajaxRequestFunc: this.$fhcApi.get,
|
||||
ajaxURL: 'dummy',
|
||||
ajaxRequestFunc: this.$fhcApi.factory.stv.kontakt.getAdressen,
|
||||
ajaxParams: () => {
|
||||
return {
|
||||
id: this.uid
|
||||
};
|
||||
},
|
||||
ajaxResponse: (url, params, response) => response.data,
|
||||
//autoColumns: true,
|
||||
columns:[
|
||||
@@ -219,9 +224,8 @@ export default{
|
||||
});
|
||||
},
|
||||
addNewAddress(addressData) {
|
||||
this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewAddress/' + this.uid,
|
||||
this.addressData
|
||||
).then(response => {
|
||||
return this.$fhcApi.factory.stv.kontakt.addNewAddress(this.uid, this.addressData)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
|
||||
this.hideModal('adressModal');
|
||||
this.resetModal();
|
||||
@@ -236,7 +240,7 @@ export default{
|
||||
},
|
||||
loadAdress(adress_id) {
|
||||
this.statusNew = false;
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadAddress/' + adress_id)
|
||||
return this.$fhcApi.factory.stv.kontakt.loadAddress(adress_id)
|
||||
.then(result => {
|
||||
this.addressData = result.data;
|
||||
return result;
|
||||
@@ -244,7 +248,7 @@ export default{
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
updateAddress(adress_id) {
|
||||
this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateAddress/' + adress_id,
|
||||
return this.$fhcApi.factory.stv.kontakt.updateAddress(adress_id,
|
||||
this.addressData
|
||||
).then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
|
||||
@@ -257,7 +261,7 @@ export default{
|
||||
});
|
||||
},
|
||||
deleteAddress(adress_id) {
|
||||
this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteAddress/' + adress_id)
|
||||
return this.$fhcApi.factory.stv.kontakt.deleteAddress(adress_id)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
|
||||
}).catch(this.$fhcAlert.handleSystemError)
|
||||
@@ -267,16 +271,14 @@ export default{
|
||||
});
|
||||
},
|
||||
loadPlaces() {
|
||||
if (this.abortController.places)
|
||||
this.abortController.places.abort();
|
||||
//TODO(Manu) check with chris if its okay without abortion controller
|
||||
/* if (this.abortController.places)
|
||||
this.abortController.places.abort();*/
|
||||
if (this.addressData.nation != 'A' || !this.addressData.plz)
|
||||
return;
|
||||
|
||||
this.abortController.places = new AbortController();
|
||||
this.$fhcApi
|
||||
.get('api/frontend/v1/stv/address/getPlaces/' + this.addressData.plz, undefined, {
|
||||
signal: this.abortController.places.signal
|
||||
})
|
||||
//this.abortController.places = new AbortController();
|
||||
return this.$fhcApi.factory.stv.kontakt.getPlaces(this.addressData.plz)
|
||||
.then(result => {
|
||||
this.places = result.data;
|
||||
});
|
||||
@@ -288,8 +290,7 @@ export default{
|
||||
});*/
|
||||
},
|
||||
search(event) {
|
||||
return this.$fhcApi
|
||||
.get('api/frontend/v1/stv/kontakt/getFirmen/' + event.query)
|
||||
return this.$fhcApi.factory.stv.kontakt.getFirmen(event.query)
|
||||
.then(result => {
|
||||
this.filteredFirmen = result.data.retval;
|
||||
});
|
||||
@@ -316,18 +317,17 @@ export default{
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.$fhcApi
|
||||
.get('api/frontend/v1/stv/address/getNations')
|
||||
this.$fhcApi.factory.stv.kontakt.getNations()
|
||||
.then(result => {
|
||||
this.nations = result.data;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
this.$fhcApi
|
||||
.get('api/frontend/v1/stv/kontakt/getAdressentypen')
|
||||
|
||||
this.$fhcApi.factory.stv.kontakt.getAdressentypen()
|
||||
.then(result => {
|
||||
this.adressentypen = result.data;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError)
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
template: `
|
||||
<div class="stv-details-kontakt-address h-100 pt-3">
|
||||
|
||||
@@ -16,8 +16,13 @@ export default{
|
||||
data() {
|
||||
return{
|
||||
tabulatorOptions: {
|
||||
ajaxURL: 'api/frontend/v1/stv/Kontakt/getBankverbindung/' + this.uid,
|
||||
ajaxRequestFunc: this.$fhcApi.get,
|
||||
ajaxURL: 'dummy',
|
||||
ajaxRequestFunc: this.$fhcApi.factory.stv.kontakt.getBankverbindung,
|
||||
ajaxParams: () => {
|
||||
return {
|
||||
id: this.uid
|
||||
};
|
||||
},
|
||||
ajaxResponse: (url, params, response) => response.data,
|
||||
columns:[
|
||||
{title:"Name", field:"name"},
|
||||
@@ -159,9 +164,8 @@ export default{
|
||||
});
|
||||
},
|
||||
addNewBankverbindung(bankverbindungData) {
|
||||
this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewBankverbindung/' + this.uid,
|
||||
this.bankverbindungData
|
||||
).then(response => {
|
||||
return this.$fhcApi.factory.stv.kontakt.addNewBankverbindung(this.uid, this.bankverbindungData)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
|
||||
this.hideModal('bankverbindungModal');
|
||||
this.resetModal();
|
||||
@@ -173,7 +177,7 @@ export default{
|
||||
},
|
||||
loadBankverbindung(bankverbindung_id){
|
||||
this.statusNew = false;
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadBankverbindung/' + bankverbindung_id)
|
||||
return this.$fhcApi.factory.stv.kontakt.loadBankverbindung(bankverbindung_id)
|
||||
.then(
|
||||
result => {
|
||||
this.bankverbindungData = result.data;
|
||||
@@ -182,7 +186,7 @@ export default{
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
updateBankverbindung(bankverbindung_id){
|
||||
this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateBankverbindung/' + bankverbindung_id,
|
||||
return this.$fhcApi.factory.stv.kontakt.updateBankverbindung(bankverbindung_id,
|
||||
this.bankverbindungData)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
|
||||
@@ -195,7 +199,7 @@ export default{
|
||||
});
|
||||
},
|
||||
deleteBankverbindung(bankverbindung_id){
|
||||
this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteBankverbindung/' + bankverbindung_id)
|
||||
return this.$fhcApi.factory.stv.kontakt.deleteBankverbindung(bankverbindung_id)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
|
||||
}).catch(this.$fhcAlert.handleSystemError)
|
||||
|
||||
@@ -18,8 +18,13 @@ export default{
|
||||
data() {
|
||||
return{
|
||||
tabulatorOptions: {
|
||||
ajaxURL: 'api/frontend/v1/stv/Kontakt/getKontakte/' + this.uid,
|
||||
ajaxRequestFunc: this.$fhcApi.get,
|
||||
ajaxURL: 'dummy',
|
||||
ajaxRequestFunc: this.$fhcApi.factory.stv.kontakt.getKontakte,
|
||||
ajaxParams: () => {
|
||||
return {
|
||||
id: this.uid
|
||||
};
|
||||
},
|
||||
ajaxResponse: (url, params, response) => response.data,
|
||||
columns:[
|
||||
{title:"Typ", field:"kontakttyp"},
|
||||
@@ -158,8 +163,7 @@ export default{
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
addNewContact(formData) {
|
||||
this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewContact/' + this.uid,
|
||||
this.contactData)
|
||||
return this.$fhcApi.factory.stv.kontakt.addNewContact(this.uid, this.contactData)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
|
||||
this.hideModal("contactModal");
|
||||
@@ -170,11 +174,11 @@ export default{
|
||||
this.reload();
|
||||
});
|
||||
},
|
||||
loadContact(contact_id){
|
||||
loadContact(kontakt_id){
|
||||
this.statusNew = false;
|
||||
if(this.contactData.firma_id)
|
||||
this.loadStandorte(this.contactData.firma_id);
|
||||
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadContact/' + contact_id)
|
||||
return this.$fhcApi.factory.stv.kontakt.loadContact(kontakt_id)
|
||||
.then(
|
||||
result => {
|
||||
this.contactData = result.data;
|
||||
@@ -183,7 +187,7 @@ export default{
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
deleteContact(kontakt_id){
|
||||
this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteContact/' + kontakt_id)
|
||||
return this.$fhcApi.factory.stv.kontakt.deleteContact(kontakt_id)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
|
||||
})
|
||||
@@ -195,9 +199,9 @@ export default{
|
||||
});
|
||||
},
|
||||
updateContact(kontakt_id){
|
||||
this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateContact/' + kontakt_id,
|
||||
this.contactData).
|
||||
then(response => {
|
||||
return this.$fhcApi.factory.stv.kontakt.updateContact(kontakt_id,
|
||||
this.contactData)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
|
||||
this.hideModal('contactModal');
|
||||
this.resetModal();
|
||||
@@ -223,8 +227,7 @@ export default{
|
||||
});
|
||||
},
|
||||
loadStandorte(firmen_id) {
|
||||
return this.$fhcApi
|
||||
.get('api/frontend/v1/stv/kontakt/getStandorteByFirma/' + firmen_id)
|
||||
return this.$fhcApi.factory.stv.kontakt.getStandorteByFirma(firmen_id)
|
||||
.then(result => {
|
||||
this.filteredOrte = result.data;
|
||||
});
|
||||
@@ -244,8 +247,7 @@ export default{
|
||||
},
|
||||
},
|
||||
created(){
|
||||
this.$fhcApi
|
||||
.get('api/frontend/v1/stv/kontakt/getKontakttypen')
|
||||
this.$fhcApi.factory.stv.kontakt.getKontakttypen()
|
||||
.then(result => {
|
||||
this.kontakttypen = result.data;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user