Added return-values with details on failed save-attempt

This commit is contained in:
int2001
2025-02-15 07:51:05 +00:00
parent ebe56b23cd
commit aeca52bfe8
3 changed files with 17 additions and 9 deletions

View File

@@ -304,11 +304,14 @@ class QSO extends CI_Controller {
$this->form_validation->set_rules('time_off', 'End Date', 'required');
$this->form_validation->set_rules('id', 'qso ID', 'required');
$edit_result=array();
$edit_result['success']=false;
if ($this->form_validation->run()) {
$edit_result=$this->logbook_model->edit();
} else {
$edit_result['success']=false;
}
header('Content-Type: application/json; charset=utf-8');
header('Content-Type: application/json');
echo json_encode($edit_result);
}

View File

@@ -1198,6 +1198,8 @@ class Logbook_model extends CI_Model {
/* Edit QSO */
function edit() {
$retvals=[];
$retvals['success']=false;
$qso = $this->get_qso($this->input->post('id'))->row();
$entity = $this->get_entity($this->input->post('dxcc_id'));
@@ -1207,11 +1209,13 @@ class Logbook_model extends CI_Model {
// be sure that station belongs to user
$this->load->model('stations');
if (!$this->stations->check_station_is_accessible($stationId)) {
return;
$retvals['detail']='Station ID not allowed';
return $retvals;
}
if (trim($this->input->post('callsign')) == '') {
return;
$retvals['detail']='No Call given';
return $retvals;
}
$station_profile = $this->stations->profile_clean($stationId);
@@ -1528,7 +1532,6 @@ class Logbook_model extends CI_Model {
}
$this->db->where('COL_PRIMARY_KEY', $this->input->post('id'));
$retvals=[];
try {
$this->db->update($this->config->item('table_name'), $data);
$retvals['success']=true;

View File

@@ -541,11 +541,13 @@ function qso_save() {
contentType: false,
type: 'POST',
success: function (dataofconfirm) {
$(".edit-dialog").modal('hide');
$(".qso-dialog").modal('hide');
if (reload_after_qso_safe == true) {
location.reload();
}
if (dataofconfirm.success) {
$(".edit-dialog").modal('hide');
$(".qso-dialog").modal('hide');
if (reload_after_qso_safe == true) {
location.reload();
}
}
},
error: function(xhr, status, error) {
console.log(xhr.responseText);