Konto delete

This commit is contained in:
cgfhtw
2024-04-16 14:34:45 +02:00
parent e15f4981fb
commit 006a763436
4 changed files with 93 additions and 8 deletions
@@ -39,7 +39,8 @@ class Konto extends FHCAPI_Controller
'getBuchungstypen' => 'student/stammdaten:r', // alle?
'checkDoubles' => ['admin:r', 'assistenz:r'],
'insert' => ['admin:w', 'assistenz:w'],
'update' => ['admin:w', 'assistenz:w']
'update' => ['admin:w', 'assistenz:w'],
'delete' => ['admin:w', 'assistenz:w']
]);
// Load models
@@ -64,11 +65,12 @@ class Konto extends FHCAPI_Controller
$this->load->library('form_validation');
$person_id = $this->input->post('person_id');
if (!$person_id || !is_array($person_id))
if (!$person_id || !is_array($person_id)) {
$this->form_validation->set_rules('person_id', 'Person ID', 'required');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$studiengang_kz = $this->input->post('studiengang_kz');
@@ -251,14 +253,14 @@ class Konto extends FHCAPI_Controller
$result = [];
foreach ($person_ids as $person_id) {
$id = $this->KontoModel->insert(array_merge($data, ['person_id' => $person_id]));
if (isError($id))
if (isError($id)) {
$this->addError(getError($id), self::ERROR_TYPE_GENERAL);
else {
} else {
$data = $this->KontoModel->withAdditionalInfo()->load(getData($id));
if (isError($data))
$this->addError(getError($data), self::ERROR_TYPE_GENERAL);
else
$result[] = getData($data);
$result[] = current(getData($data));
}
}
@@ -327,4 +329,50 @@ class Konto extends FHCAPI_Controller
$this->terminateWithSuccess($result);
}
/**
* Delete Buchung
*
* @return void
*/
public function delete()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('buchungsnr', 'Buchungsnr', 'required');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$buchungsnr = $this->input->post('buchungsnr');
$result = $this->KontoModel->load($buchungsnr);
#$result = $this->getDataOrTerminateWithError($result);
if (isError($result))
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$result = $result->retval;
if (!$result)
$this->terminateWithError('buchung not found', self::ERROR_TYPE_GENERAL);
$_POST['studiengang_kz'] = current($result)->studiengang_kz;
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'has_permissions_for_stg[admin:rw,assistenz:rw]');
Events::trigger('konto_delete_validation', $this->form_validation);
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
Events::trigger('konto_delete', $buchungsnr);
$result = $this->KontoModel->delete($buchungsnr);
#$this->getDataOrTerminateWithError($result);
if (isError($result))
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$this->terminateWithSuccess();
}
}
+3
View File
@@ -25,6 +25,9 @@ export default {
edit(data) {
return this.$fhcApi.post('api/frontend/v1/stv/konto/update', data);
},
delete(buchungsnr) {
return this.$fhcApi.post('api/frontend/v1/stv/konto/delete', {buchungsnr});
},
getBuchungstypen() {
return this.$fhcApi.get('api/frontend/v1/stv/konto/getBuchungstypen');
}
@@ -154,6 +154,19 @@ export default {
);
container.append(button);
button = document.createElement('button');
button.className = 'btn btn-outline-secondary';
button.innerHTML = '<i class="fa fa-trash"></i>';
button.addEventListener('click', () =>
this.$fhcAlert
.confirmDelete()
.then(result => result ? cell.getData().buchungsnr : Promise.reject({handled:true}))
.then(this.$fhcApi.factory.stv.konto.delete)
.then(() => cell.getRow().delete())
.catch(this.$fhcAlert.handleSystemError)
);
container.append(button);
return container;
},
frozen: true
@@ -182,7 +195,7 @@ export default {
updateData(data) {
if (!data)
return this.reload();
this.$refs.table.tabulator.updateData(data);
this.$refs.table.tabulator.updateOrAddData(data);
},
actionNew() {
this.$refs.new.open();
@@ -221,6 +234,7 @@ export default {
table-only
:side-menu="false"
:tabulator-options="tabulatorOptions"
reload
new-btn-show
new-btn-label="Buchung"
:new-btn-disabled="stg_kz === ''"
+20
View File
@@ -26573,6 +26573,26 @@ array(
)
)
),
array(
'app' => 'core',
'category' => 'sap',
'phrase' => 'msg_buchung_deleted',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Buchungszuordnung SAP geloescht: SalesOrder: {sap_sales_order_id}',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Buchungszuordnung SAP deleted: SalesOrder: {sap_sales_order_id}',
'description' => '',
'insertvon' => 'system'
)
)
),
);