API Refactoring, some other minor fixes

This commit is contained in:
ma0068
2025-06-10 11:57:43 +02:00
parent 7d2da9e7f6
commit 6f60d7c99e
9 changed files with 246 additions and 80 deletions
@@ -47,6 +47,7 @@ class Config extends FHCAPI_Controller
$params
);
//TODO(Manu) check warning
$this->terminateWithSuccess($menu[0]);
}
}
@@ -467,7 +467,7 @@ class Vertraege extends FHCAPI_Controller
return $this->terminateWithSuccess(current(getData($result)));
}
public function insertContractStatus($vertrag_id)
public function insertContractStatus()
{
$this->load->library('form_validation');
@@ -486,7 +486,7 @@ class Vertraege extends FHCAPI_Controller
$result = $this->VertragvertragsstatusModel->loadWhere(
array(
'vertrag_id' => $vertrag_id,
'vertrag_id' => $this->input->post('vertrag_id'),
'vertragsstatus_kurzbz' => $this->input->post('vertragsstatus_kurzbz')
)
);
@@ -497,7 +497,7 @@ class Vertraege extends FHCAPI_Controller
}
$status_result = $this->VertragvertragsstatusModel->insert([
'vertrag_id' => $vertrag_id,
'vertrag_id' => $this->input->post('vertrag_id'),
'uid' => getAuthUID(),
'vertragsstatus_kurzbz' => $this->input->post('vertragsstatus_kurzbz'),
'insertamum' => date('c'),
@@ -512,9 +512,10 @@ class Vertraege extends FHCAPI_Controller
return $this->terminateWithSuccess(current(getData($status_result)));
}
public function deleteContractStatus($vertrag_id)
public function deleteContractStatus()
{
$status = $this->input->post('vertragsstatus_kurzbz');
$vertrag_id = $this->input->post('vertrag_id');
$result = $this->VertragvertragsstatusModel->delete(
array(
@@ -534,9 +535,10 @@ class Vertraege extends FHCAPI_Controller
return $this->terminateWithSuccess(current(getData($result)));
}
public function loadContractStatus($vertrag_id)
public function loadContractStatus()
{
$status = $this->input->post('vertragsstatus_kurzbz');
$status = $this->input->get('vertragsstatus_kurzbz');
$vertrag_id = $this->input->get('vertrag_id');
$result = $this->VertragvertragsstatusModel->loadWhere(
array(
@@ -550,7 +552,7 @@ class Vertraege extends FHCAPI_Controller
return $this->terminateWithSuccess(current(getData($result)));
}
public function updateContractStatus($vertrag_id)
public function updateContractStatus()
{
$this->load->library('form_validation');
@@ -569,7 +571,7 @@ class Vertraege extends FHCAPI_Controller
$status_result = $this->VertragvertragsstatusModel->update(
[
'vertrag_id' => $vertrag_id,
'vertrag_id' => $this->input->post('vertrag_id'),
'vertragsstatus_kurzbz' => $this->input->post('vertragsstatus_kurzbz')],
[
'uid' => getAuthUID(),
@@ -586,10 +588,11 @@ class Vertraege extends FHCAPI_Controller
return $this->terminateWithSuccess(current(getData($status_result)));
}
public function deleteLehrauftrag($vertrag_id)
public function deleteLehrauftrag()
{
$lehreinheit_id = $this->input->post('lehreinheit_id');
$mitarbeiter_uid = $this->input->post('mitarbeiter_uid');
$vertrag_id = $this->input->post('vertrag_id ');
$this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel');
@@ -616,11 +619,12 @@ class Vertraege extends FHCAPI_Controller
return $this->terminateWithSuccess(current(getData($result)));
}
public function deleteBetreuung($vertrag_id)
public function deleteBetreuung()
{
$person_id= $this->input->post('person_id');
$projektarbeit_id = $this->input->post('projektarbeit_id');
$betreuerart_kurzbz = $this->input->post('betreuerart_kurzbz');
$vertrag_id = $this->input->post('vertrag_id ');
$this->load->model('education/Projektbetreuer_model', 'Projektbetreuermodel');
@@ -0,0 +1,158 @@
/**
* Copyright (C) 2025 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export default {
getAllVertraege(person_id) {
return {
method: 'get',
url: 'api/frontend/v1/vertraege/Vertraege/getAllVertraege/' + person_id
};
},
/* getAllContractsNotAssigned2(person_id) {
return {
method: 'get',
url: 'api/frontend/v1/vertraege/Vertraege/getAllContractsNotAssigned/' + person_id
};
},*/
getAllContractsNotAssigned(person_id) {
return {
method: 'get',
url: 'api/frontend/v1/vertraege/Vertraege/getAllContractsNotAssigned/' + person_id
};
},
getAllContractsAssigned(person_id, vertrag_id) {
return {
method: 'get',
url: 'api/frontend/v1/vertraege/Vertraege/getAllContractsAssigned/' + person_id + '/' + vertrag_id + ''
};
},
getAllContractTypes() {
return {
method: 'get',
url: 'api/frontend/v1/vertraege/Vertraege/getAllContractTypes/'
};
},
getStatiOfContract(vertrag_id){
return {
method: 'get',
url: 'api/frontend/v1/vertraege/Vertraege/getStatiOfContract/' + vertrag_id
};
},
configPrintDocument() {
return {
method: 'get',
url: 'api/frontend/v1/vertraege/Config/printDocument/'
};
},
getAllContractStati() {
return {
method: 'get',
url: 'api/frontend/v1/vertraege/vertraege/getAllContractStati/'
};
},
deleteContract(vertrag_id) {
return {
method: 'post',
url: 'api/frontend/v1/vertraege/vertraege/deleteContract/' + vertrag_id
};
},
addNewContract(params) {
return {
method: 'post',
url: 'api/frontend/v1/vertraege/vertraege/addNewContract/',
params
};
},
loadContract(vertrag_id){
return {
method: 'get',
url: 'api/frontend/v1/vertraege/vertraege/loadContract/' + vertrag_id
};
},
updateContract(params) {
return {
method: 'post',
url: 'api/frontend/v1/vertraege/vertraege/updateContract/',
params
};
},
loadContractStatus(params){
return {
method: 'get',
url: 'api/frontend/v1/vertraege/vertraege/loadContractStatus/',
params
};
},
insertContractStatus(params) {
return {
method: 'post',
url: 'api/frontend/v1/vertraege/vertraege/insertContractStatus/',
params
};
},
updateContractStatus(params) {
return {
method: 'post',
url: 'api/frontend/v1/vertraege/vertraege/updateContractStatus/',
params
};
},
deleteContractStatus(params) {
return {
method: 'post',
url: 'api/frontend/v1/vertraege/vertraege/deleteContractStatus/',
params
};
},
deleteLehrauftrag(params) {
return {
method: 'post',
url: 'api/frontend/v1/vertraege/vertraege/deleteLehrauftrag/',
params
};
},
deleteBetreuung(params) {
return {
method: 'post',
url: 'api/frontend/v1/vertraege/vertraege/deleteBetreuung/',
params
};
},
getMitarbeiter(){
return {
method: 'post',
url: 'api/frontend/v1/vertraege/vertraege/getMitarbeiter/',
};
//return this.$fhcApi.post('api/frontend/v1/vertraege/vertraege/getMitarbeiter/');
},
getHeader(person_id){
return this.$fhcApi.post('api/frontend/v1/vertraege/vertraege/getHeader/' + person_id);
},
getPersonAbteilung(person_id){
return this.$fhcApi.post('api/frontend/v1/vertraege/vertraege/getPersonAbteilung/' + person_id);
},
getLeitungOrg(oekurzbz){
return this.$fhcApi.post('api/frontend/v1/vertraege/vertraege/getLeitungOrg/' + oekurzbz);
},
getMitarbeiterUid(person_id){
return {
method: 'get',
url: 'api/frontend/v1/vertraege/vertraege/getMitarbeiterUid/' + person_id
};
// return this.$fhcApi.get('api/frontend/v1/vertraege/vertraege/getMitarbeiterUid/' + person_id);
},
};
@@ -26,19 +26,19 @@ export default {
type: [Number],
required: true
},
endpoint: {
type: Object,
required: true
},
},
data() {
return {
//tableData: [],
tabulatorOptions: {
ajaxURL: 'dummy',
ajaxRequestFunc: this.$fhcApi.factory.vertraege.person.getAllContractsAssigned,
ajaxParams: () => {
return {
person_id: this.person_id,
vertrag_id: this.vertrag_id
};
},
ajaxRequestFunc: () => this.$api.call(
this.endpoint.getAllContractsAssigned(this.person_id, this.vertrag_id)
),
ajaxResponse: (url, params, response) => response.data,
columns: [
{title: "Typ", field: "type"},
@@ -29,18 +29,19 @@ export default {
formDataParent: {
type: Object,
required: true
}
},
endpoint: {
type: Object,
required: true
},
},
data() {
return {
tabulatorOptions: {
ajaxURL: 'dummy',
ajaxRequestFunc: this.$fhcApi.factory.vertraege.person.getStatiOfContract,
ajaxParams: () => {
return {
vertrag_id: this.vertrag_id
};
},
ajaxRequestFunc: () => this.$api.call(
this.endpoint.getStatiOfContract(this.vertrag_id)
),
ajaxResponse: (url, params, response) => response.data,
columns: [
{title: "Status", field: "bezeichnung"},
@@ -25,12 +25,9 @@ export default {
return {
tabulatorOptions: {
ajaxURL: 'dummy',
ajaxRequestFunc: this.$fhcApi.factory.vertraege.person.getAllContractsNotAssigned,
ajaxParams: () => {
return {
person_id: this.person_id
};
},
ajaxRequestFunc: () => this.$api.call(
this.endpoint.getAllContractsNotAssigned(this.person_id)
),
ajaxResponse: (url, params, response) => response.data,
columns: [
{title: "Typ", field: "type", width: 100},
@@ -6,15 +6,19 @@ export default {
CoreFilterCmpt,
FormInput
},
inject: {
/* inject: {
cisRoot: {
from: 'cisRoot'
},
},
},*/
emits: [
"selectedPerson"
],
props: {
endpoint: {
type: Object,
required: true
},
// maybe later nur fixe oder alle Mitarbeiter: gleich funktionsaufruf
//oder Mitarbeiter mit Verträgen
/* filterMa: {
@@ -41,12 +45,9 @@ export default {
return {
tabulatorOptions: {
ajaxURL: 'dummy',
ajaxRequestFunc: this.$fhcApi.factory.vertraege.person.getMitarbeiter,
ajaxParams: () => {
return {
fix: this.filterMa
};
},
ajaxRequestFunc: () => this.$api.call(
this.endpoint.getMitarbeiter()
),
ajaxResponse: (url, params, response) => response.data,
columns: [
{title: "UID", field: "uid", headerFilter:"input"},
@@ -148,6 +149,7 @@ export default {
<div class="core-mitarbeiter-header">
<h4>{{$p.t('vertrag', 'vertragsverwaltung')}}</h4>
<!-- filter: show only active employees-->
<div class="justify-content-end py-3">
<form-input
+39 -39
View File
@@ -7,6 +7,7 @@ import ListUnassigned from './List/Unassigned.js';
import ContractDetails from './List/Details.js';
import ContractStati from './List/Status.js';
export default {
components: {
CoreFilterCmpt,
@@ -18,9 +19,9 @@ export default {
ContractStati
},
inject: {
cisRoot: {
/* cisRoot: {
from: 'cisRoot'
},
},*/
hasSchreibrechte: {
from: 'hasSchreibrechte',
default: false
@@ -45,12 +46,9 @@ export default {
return {
tabulatorOptions: {
ajaxURL: 'dummy',
ajaxRequestFunc: this.$fhcApi.factory.vertraege.person.getAllVertraege,
ajaxParams: () => {
return {
person_id: this.person_id
};
},
ajaxRequestFunc: () => this.$api.call(
this.endpoint.getAllVertraege(this.person_id)
),
ajaxResponse: (url, params, response) => response.data,
columns: [
{title: "Bezeichnung", field: "bezeichnung", width: 150},
@@ -176,9 +174,9 @@ export default {
cm.getColumnByField('isabgerechnet').component.updateDefinition({
title: this.$p.t('vertrag', 'abgerechnet')
});
cm.getColumnByField('actions').component.updateDefinition({
/* cm.getColumnByField('actions').component.updateDefinition({
title: this.$p.t('global', 'aktionen')
});
});*/
}
},
{
@@ -242,7 +240,9 @@ export default {
.then(result => result
? vertrag_id
: Promise.reject({handled: true}))
.then(this.endpoint.deleteContract)
.then(vertrag_id => this.$api.call(
this.endpoint.deleteContract(vertrag_id))
)
.then(result => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
//window.scrollTo(0, 0);
@@ -258,9 +258,8 @@ export default {
formData: this.formData,
clickedRows: this.childData, //all data needed, maybe smaller array?
};
return this.endpoint
.addNewContract(this.$refs.contractData, dataToSend)
return this.$refs.contractData
.call(this.endpoint.addNewContract(dataToSend))
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.$refs.contractModal.hide();
@@ -280,9 +279,8 @@ export default {
formData: this.formData,
clickedRows: this.childData,
};
return this.endpoint
.updateContract(this.$refs.contractData, dataToSend)
return this.$refs.contractData
.call(this.endpoint.updateContract(dataToSend))
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.$refs.contractModal.hide();
@@ -296,8 +294,8 @@ export default {
loadContract(vertrag_id) {
this.resetModal();
this.statusNew = false;
return this.endpoint
.loadContract(vertrag_id)
return this.$api
.call(this.endpoint.loadContract(vertrag_id))
.then(result => {
this.formData = result.data;
})
@@ -322,8 +320,8 @@ export default {
datum: formattedDate
};
return this.endpoint
.insertContractStatus(this.$refs.contractstati.$refs.statusData, params)
return this.$refs.contractstati.$refs.statusData
.call(this.endpoint.insertContractStatus(params))
.then(response => {
//this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
@@ -338,8 +336,8 @@ export default {
vertrag_id : vertrag_id,
vertragsstatus_kurzbz: status
};
return this.endpoint
.deleteContractStatus(params)
return this.$api
.call(this.endpoint.deleteContractStatus(params))
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
@@ -364,8 +362,8 @@ export default {
datum : formattedDate,
vertragsstatus_kurzbz: status
};
return this.endpoint
.updateContractStatus(this.$refs.contractstati.$refs.statusData, params)
return this.$refs.contractstati.$refs.statusData
.call(this.endpoint.updateContractStatus(params))
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.$refs.contractstati.closeModal();
@@ -379,8 +377,8 @@ export default {
vertrag_id : vertrag_id,
vertragsstatus_kurzbz: status
};
return this.endpoint
.loadContractStatus(params)
return this.$api
.call(this.endpoint.loadContractStatus(params))
.then(response => {
this.contractFormData = response.data;
this.$refs.contractstati.openModal();
@@ -394,8 +392,8 @@ export default {
lehreinheit_id: lehreinheit_id,
mitarbeiter_uid: mitarbeiter_uid
};
return this.endpoint
.deleteLehrauftrag(params)
return this.$api
.call(this.endpoint.deleteLehrauftrag(params))
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
this.resetModal();
@@ -411,8 +409,8 @@ export default {
projektarbeit_id: projektarbeit_id,
betreuerart_kurzbz: betreuerart_kurzbz
};
return this.endpoint
.deleteBetreuung(params)
return this.$api
.call(this.endpoint.deleteBetreuung(params))
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
this.$refs.contractdetails.reload();
@@ -437,7 +435,7 @@ export default {
this.statusNew = true;
//this.childData = {};
//gefährlich, immer null??
//always null??
//TODO(Manu) check if this.childData = {},
},
updateBetrag(sumBetrag){
@@ -488,8 +486,8 @@ export default {
});
},
getMitarbeiterUid(){
return this.endpoint
.getMitarbeiterUid(this.person_id)
return this.$api
.call(this.endpoint.getMitarbeiterUid(this.person_id))
.then(response => {
this.ma_uid = response.data;
})
@@ -511,10 +509,10 @@ export default {
},
created() {
Promise.all([
this.endpoint.getAllContractTypes(),
this.endpoint.getAllContractsNotAssigned2(this.person_id),
this.endpoint.getAllContractStati(),
this.$fhcApi.factory.vertraege.configPrintDocument()
this.$api.call(this.endpoint.getAllContractTypes()),
this.$api.call(this.endpoint.getAllContractsNotAssigned(this.person_id)),
this.$api.call(this.endpoint.getAllContractStati()),
this.$api.call(this.endpoint.configPrintDocument())
])
.then(([result1, result2, result3, result4]) => {
this.listContractTypes = result1.data;
@@ -591,6 +589,7 @@ export default {
<contract-details
:person_id="person_id"
:vertrag_id="contractSelected.vertrag_id"
:endpoint="endpoint"
@deleteLehrauftrag="deleteLehrauftrag"
@deleteBetreuung="deleteBetreuung"
ref="contractdetails"
@@ -604,6 +603,7 @@ export default {
:vertrag_id="contractSelected.vertrag_id"
:listContractStati="listContractStati"
:formDataParent="contractFormData"
:endpoint="endpoint"
@setContractStatus="addNewContractStatus"
@deleteContractStatus="deleteContractStatus"
@updateContractStatus="updateContractStatus"
@@ -622,8 +622,8 @@ export default {
</template>
<list-unassigned
:endpoint="$fhcApi.factory.vertraege.person"
:person_id="person_id"
:endpoint="endpoint"
ref="unassignedLehrauftraege"
@saveClickedRows="saveClickedRows"
@sum-updated="updateBetrag"
@@ -2,6 +2,8 @@ import MitarbeiterHeader from "./MitarbeiterHeader.js";
import MitarbeiterDetails from "./MitarbeiterDetails.js";
import VertraegeMitarbeiter from "./Vertraege.js";
import VerticalSplit from "../verticalsplit/verticalsplit.js";
import ApiCoreVertraege from '../../api/factory/vertraege/vertraege.js';
export default {
components: {
@@ -23,6 +25,7 @@ export default {
data() {
return {
person_id: null,
endpoint: ApiCoreVertraege
}
},
methods: {
@@ -37,15 +40,15 @@ export default {
<vertical-split ref="vsplit">
<template #top>
<div class="d-flex flex-column" style="height: 100%;">
<mitarbeiter-header :filterMa="filterMa" :vertragsarten="vertragsarten" @selectedPerson="selectPerson" />
<mitarbeiter-header :endpoint="endpoint" @selectedPerson="selectPerson" />
</div>
</template>
<template #bottom>
<div class="col" v-if="person_id!=null">
<mitarbeiter-details :person_id="person_id"></mitarbeiter-details>
<vertraege-mitarbeiter :endpoint="$fhcApi.factory.vertraege.person" :person_id="this.person_id"/>
<vertraege-mitarbeiter :endpoint="endpoint" :person_id="this.person_id"/>
</div>
<template>
</template>
</vertical-split>
</main>
</div>