change backend

This commit is contained in:
DB4SCW
2025-09-09 09:59:15 +00:00
parent 5b1664c7c9
commit 4f2afb98f5
2 changed files with 25 additions and 4 deletions

View File

@@ -60,12 +60,31 @@ class Hrdlog extends CI_Controller {
$postData = $this->input->post();
$this->load->model('logbook_model');
//checks for credentials. Returns "false" if credentials are there, but upload was disabled
$result = $this->logbook_model->exists_hrdlog_credentials($postData['station_id']);
//check for credential errors before accessing them
if($result == false){
$data['status'] = 'Credential_Error';
$data['infomessage'] = __("HRD Log upload for this station is disabled or credentials not filled in completely.");
$data['errormessages'] = array(__("HRD Log upload for this station is disabled or credentials not filled in completely."));
echo json_encode($data);
return;
}
//read hrd credentials
$hrdlog_username = $result->hrdlog_username;
$hrdlog_code = $result->hrdlog_code;
header('Content-type: application/json');
$result = $this->Hrdlog_model->mass_upload_qsos($postData['station_id'], $hrdlog_username, $hrdlog_code);
if ($result['status'] == 'OK') {
//set header
header('Content-type: application/json');
//perform upload
$result = $this->Hrdlog_model->mass_upload_qsos($postData['station_id'], $hrdlog_username, $hrdlog_code);
//return success
if ($result['status'] == 'OK') {
$stationinfo = $this->stations->stations_with_hrdlog_code();
$info = $stationinfo->result();

View File

@@ -938,8 +938,10 @@ class Logbook_model extends CI_Model {
* Function checks if a HRDLog Code and Username exists in the table with the given station id
*/
function exists_hrdlog_credentials($station_id) {
//checks disabled state AND content of hrdlog_username and hrdlog_code
$sql = 'select hrdlog_username, hrdlog_code, hrdlogrealtime from station_profile
where station_id = ? and hrdlogrealtime>=0';
where station_id = ? and hrdlogrealtime >= 0 and COALESCE(hrdlog_username, "") != "" AND COALESCE(hrdlog_code, "") != "";';
$query = $this->db->query($sql, $station_id);