From e71f782a835f200d4a89eb25aff72269821cafe1 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Sat, 16 Dec 2023 11:42:56 +0100 Subject: [PATCH] fixed success and error messages --- application/controllers/Hrdlog.php | 58 +++++++++++++++-------------- application/controllers/Qrz.php | 4 +- application/views/adif/import.php | 2 +- application/views/hrdlog/export.php | 2 +- application/views/qrz/export.php | 2 +- assets/js/sections/hrdlog.js | 29 ++++++++------- assets/js/sections/qrzlogbook.js | 28 +++++++------- assets/js/sections/webadif.js | 26 +++++++------ 8 files changed, 81 insertions(+), 70 deletions(-) diff --git a/application/controllers/Hrdlog.php b/application/controllers/Hrdlog.php index 78e449ad..5bbbfdc4 100644 --- a/application/controllers/Hrdlog.php +++ b/application/controllers/Hrdlog.php @@ -1,4 +1,4 @@ -hrdlog_username; $hrdlog_code = $station->hrdlog_code; - if($this->mass_upload_qsos($station->station_id, $hrdlog_username, $hrdlog_code)) { + if ($this->mass_upload_qsos($station->station_id, $hrdlog_username, $hrdlog_code)) { echo "QSOs have been uploaded to hrdlog.net."; log_message('info', 'QSOs have been uploaded to hrdlog.net.'); - } else{ + } else { echo "No QSOs found for upload."; log_message('info', 'No QSOs found for upload.'); } @@ -52,9 +52,9 @@ class Hrdlog extends CI_Controller { function mass_upload_qsos($station_id, $hrdlog_username, $hrdlog_code) { $i = 0; $data['qsos'] = $this->logbook_model->get_hrdlog_qsos($station_id); - $errormessages=array(); + $errormessages = array(); - $CI =& get_instance(); + $CI = &get_instance(); $CI->load->library('AdifHelper'); if ($data['qsos']) { @@ -67,25 +67,27 @@ class Hrdlog extends CI_Controller { $result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif); } - if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') || ($result['status'] == 'duplicate')) ){ + if (($result['status'] == 'OK') || (($result['status'] == 'error') || ($result['status'] == 'duplicate'))) { $this->markqso($qso->COL_PRIMARY_KEY); $i++; - } elseif ((substr($result['status'],0,11) == 'auth_error')) { + $result['status'] = 'OK'; + } elseif ((substr($result['status'], 0, 11) == 'auth_error')) { log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); - log_message('error', 'hrdlog upload failed with the following message: ' .$result['message']); - log_message('error', 'hrdlog upload stopped for Station_ID: ' .$station_id); + log_message('error', 'hrdlog upload failed with the following message: ' . $result['message']); + log_message('error', 'hrdlog upload stopped for Station_ID: ' . $station_id); $errormessages[] = $result['message'] . 'Invalid HRDLog-Code, stopped at Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; - break; /* If key is invalid, immediate stop syncing for more QSOs of this station */ + $result['status'] = 'Error'; + break; /* If key is invalid, immediate stop syncing for more QSOs of this station */ } else { log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); - log_message('error', 'hrdlog upload failed with the following message: ' .$result['message']); + log_message('error', 'hrdlog upload failed with the following message: ' . $result['message']); + $result['status'] = 'Error'; $errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; } } - $result['status'] = 'OK'; $result['count'] = $i; $result['errormessages'] = $errormessages; - return $result; + return $result; } else { $result['status'] = 'Error'; $result['count'] = $i; @@ -109,7 +111,7 @@ class Hrdlog extends CI_Controller { $data['page_title'] = "HRDlog.net Logbook"; - $data['station_profiles'] = $this->stations->all_of_user(); + $data['station_profiles'] = $this->stations->all_of_user(); $data['station_profile'] = $this->stations->stations_with_hrdlog_code(); $this->load->view('interface_assets/header', $data); @@ -149,25 +151,25 @@ class Hrdlog extends CI_Controller { } } - public function mark_hrdlog() { - // Set memory limit to unlimited to allow heavy usage - ini_set('memory_limit', '-1'); + public function mark_hrdlog() { + // Set memory limit to unlimited to allow heavy usage + ini_set('memory_limit', '-1'); - $station_id = $this->security->xss_clean($this->input->post('station_profile')); + $station_id = $this->security->xss_clean($this->input->post('station_profile')); - $this->load->model('adif_data'); + $this->load->model('adif_data'); - $data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id); + $data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id); - $this->load->model('logbook_model'); + $this->load->model('logbook_model'); - foreach ($data['qsos']->result() as $qso) + foreach ($data['qsos']->result() as $qso) { - $this->logbook_model->mark_hrdlog_qsos_sent($qso->COL_PRIMARY_KEY); - } + $this->logbook_model->mark_hrdlog_qsos_sent($qso->COL_PRIMARY_KEY); + } - $this->load->view('interface_assets/header', $data); - $this->load->view('hrdlog/mark_hrdlog', $data); - $this->load->view('interface_assets/footer'); - } + $this->load->view('interface_assets/header', $data); + $this->load->view('hrdlog/mark_hrdlog', $data); + $this->load->view('interface_assets/footer'); + } } diff --git a/application/controllers/Qrz.php b/application/controllers/Qrz.php index 89647626..efc8449e 100644 --- a/application/controllers/Qrz.php +++ b/application/controllers/Qrz.php @@ -74,19 +74,21 @@ class Qrz extends CI_Controller { if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') && ($result['message'] == 'STATUS=FAIL&REASON=Unable to add QSO to database: duplicate&EXTENDED=')) ){ $this->markqso($qso->COL_PRIMARY_KEY); $i++; + $result['status'] = 'OK'; } elseif ( ($result['status']=='error') && (substr($result['message'],0,11) == 'STATUS=AUTH')) { log_message('error', 'QRZ upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); log_message('error', 'QRZ upload failed with the following message: ' .$result['message']); log_message('error', 'QRZ upload stopped for Station_ID: ' .$station_id); $errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; + $result['status'] = 'Error'; break; /* If key is invalid, immediate stop syncing for more QSOs of this station */ } else { log_message('error', 'QRZ upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); log_message('error', 'QRZ upload failed with the following message: ' .$result['message']); $errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; + $result['status'] = 'Error'; } } - $result['status'] = 'OK'; $result['count'] = $i; $result['errormessages'] = $errormessages; return $result; diff --git a/application/views/adif/import.php b/application/views/adif/import.php index 9375649b..2de27165 100644 --- a/application/views/adif/import.php +++ b/application/views/adif/import.php @@ -1,4 +1,4 @@ -
+

+

diff --git a/application/views/qrz/export.php b/application/views/qrz/export.php index 6d64af5b..4c65be05 100644 --- a/application/views/qrz/export.php +++ b/application/views/qrz/export.php @@ -1,5 +1,5 @@ -
+

diff --git a/assets/js/sections/hrdlog.js b/assets/js/sections/hrdlog.js index 9b3ce0e3..67153685 100644 --- a/assets/js/sections/hrdlog.js +++ b/assets/js/sections/hrdlog.js @@ -21,27 +21,30 @@ function ExportHrd(station_id) { $('#notcount'+value.station_id).html(value.notcount); $('#totcount'+value.station_id).html(value.totcount); }); - $(".card-body").append(''); + $(".card-body").append(''); } else { - $(".card-body").append(''); + $(".card-body").append(''); } if (data.errormessages.length > 0) { - $(".card-body").append('' + - '

\n' + - ' \n' + - '

\n' + - '
\n' + - '
\n' + - '
\n' + - '
'); - $.each(data.errormessages, function(index, value) { + $("#hrdlog_export").append( + '
\n' + + '
\n' + + '
\n' + + ' Error Message\n' + + '
\n' + + '
\n' + + '
\n' + + '
\n' + + '
\n' + + '
' + ); + $.each(data.errormessages, function (index, value) { $(".errors").append('
  • ' + value); }); } + } }); } diff --git a/assets/js/sections/qrzlogbook.js b/assets/js/sections/qrzlogbook.js index 84cb9268..c7563046 100644 --- a/assets/js/sections/qrzlogbook.js +++ b/assets/js/sections/qrzlogbook.js @@ -21,24 +21,26 @@ function ExportQrz(station_id) { $('#notcount'+value.station_id).html(value.notcount); $('#totcount'+value.station_id).html(value.totcount); }); - $(".card-body").append(''); + $(".card-body").append(''); } else { - $(".card-body").append(''); + $(".card-body").append(''); } if (data.errormessages.length > 0) { - $(".card-body").append('' + - '

    \n' + - ' \n' + - '

    \n' + - '
    \n' + - '
    \n' + - '
    \n' + - '
    '); - $.each(data.errormessages, function(index, value) { + $("#qrz_export").append( + '
    \n' + + '
    \n' + + '
    \n' + + ' Error Message\n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    ' + ); + $.each(data.errormessages, function (index, value) { $(".errors").append('
  • ' + value); }); } diff --git a/assets/js/sections/webadif.js b/assets/js/sections/webadif.js index 6203b866..196d5f58 100644 --- a/assets/js/sections/webadif.js +++ b/assets/js/sections/webadif.js @@ -35,21 +35,23 @@ function ExportWebADIF(station_id) { $(".card-body").append(''); } else { - $(".card-body").append(''); + $(".card-body").append(''); } if (data.errormessages.length > 0) { - $(".card-body").append('' + - '

    \n' + - ' \n' + - '

    \n' + - '
    \n' + - '
    \n' + - '
    \n' + - '
    '); - $.each(data.errormessages, function(index, value) { + $("#adif_import").append( + '
    \n' + + '
    \n' + + '
    \n' + + ' Error Message\n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    ' + ); + $.each(data.errormessages, function (index, value) { $(".errors").append('
  • ' + value); }); }