diff --git a/application/controllers/Qsl.php b/application/controllers/Qsl.php index 59177e8ad..e0b27404d 100644 --- a/application/controllers/Qsl.php +++ b/application/controllers/Qsl.php @@ -10,7 +10,7 @@ class Qsl extends CI_Controller { parent::__construct(); $this->load->model('user_model'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); } - if(($this->config->item('disable_qsl') ?? false)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); exit; } + if(($this->config->item('disable_qsl') ?? false)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); exit; } } // Default view when loading controller. @@ -25,11 +25,39 @@ class Qsl extends CI_Controller { $data['page_title'] = __("QSL Cards"); $data['qslarray'] = $this->qsl_model->getQsoWithQslList(); + $footerData = []; + $footerData['scripts'] = [ + 'assets/js/sections/qsl.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/qsl.js")), + ]; + $this->load->view('interface_assets/header', $data); $this->load->view('qslcard/index'); - $this->load->view('interface_assets/footer'); + $this->load->view('interface_assets/footer', $footerData); } + // View for filtering and showing confirmations on LoTW/QSL/eQSL/QRZ/HRDLog/Clublog + public function confirmations() { + // Render Page + $data['page_title'] = __("Confirmations"); + + $footerData = []; + $footerData['scripts'] = [ + 'assets/js/bootstrap-multiselect.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/bootstrap-multiselect.js")), + 'assets/js/sections/qsl.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/qsl.js")), + ]; + + $this->load->view('interface_assets/header', $data); + $this->load->view('qslcard/confirmations'); + $this->load->view('interface_assets/footer', $footerData); + } + + public function searchConfirmations() { + $this->load->model('qsl_model'); + $confirmationtype = xss_clean($this->input->post('type')); + $data['result'] = $this->qsl_model->getConfirmations($confirmationtype); + $this->load->view('qslcard/confirmationresult', $data); + } + public function upload() { // Render Page $data['page_title'] = __("Upload QSL Cards"); diff --git a/application/models/Qsl_model.php b/application/models/Qsl_model.php index 38f4b3264..b6b24e3ef 100644 --- a/application/models/Qsl_model.php +++ b/application/models/Qsl_model.php @@ -141,7 +141,7 @@ class Qsl_model extends CI_Model { return $this->db->insert_id(); } - // return path of qsl file : u=url / p=real path + // return path of qsl file : u=url / p=real path function get_imagePath($pathorurl='u', $user_id=null) { // test if new folder directory option is enabled @@ -178,4 +178,66 @@ class Qsl_model extends CI_Model { return 'assets/qslcard'; } } + + function getConfirmations($confirmationtype) { + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + if (!$logbooks_locations_array) { + return null; + } + + $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $table = $this->config->item('table_name'); + $sql_parts = array(); + + if (in_array('qsl', $confirmationtype)) { + $sql_parts[] = " + SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_sat_name, col_qslrdate AS rxdate, 'QSL Card' AS type, + EXISTS (SELECT 1 FROM qsl_images WHERE qsoid = $table.COL_PRIMARY_KEY) AS qslcount + FROM $table + WHERE station_id IN ($location_list) AND col_qslrdate IS NOT NULL AND coalesce(col_qslrdate, '') <> '' AND col_qsl_rcvd = 'Y' + "; + } + if (in_array('lotw', $confirmationtype)) { + $sql_parts[] = " + SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_sat_name, col_lotw_qslrdate AS rxdate, 'LoTW' AS type, 0 as qslcount + FROM $table + WHERE station_id IN ($location_list) AND col_lotw_qslrdate IS NOT NULL AND coalesce(col_lotw_qslrdate, '') <> '' AND col_lotw_qsl_rcvd = 'Y' + "; + } + if (in_array('eqsl', $confirmationtype)) { + $sql_parts[] = " + SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_sat_name, col_eqsl_qslrdate AS rxdate, 'eQSL' AS type, 0 as qslcount + FROM $table + WHERE station_id IN ($location_list) AND col_eqsl_qslrdate IS NOT NULL AND coalesce(col_eqsl_qslrdate, '') <> '' AND col_eqsl_qsl_rcvd = 'Y' + "; + } + if (in_array('qrz', $confirmationtype)) { + $sql_parts[] = " + SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_sat_name, col_qrzcom_qso_download_date AS rxdate, 'QRZ.com' AS type, 0 as qslcount + FROM $table + WHERE station_id IN ($location_list) AND col_qrzcom_qso_download_date IS NOT NULL AND coalesce(col_qrzcom_qso_download_date, '') <> '' AND col_qrzcom_qso_download_status = 'Y' + "; + } + if (in_array('clublog', $confirmationtype)) { + $sql_parts[] = " + SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_sat_name, col_clublog_qso_download_date AS rxdate, 'Clublog' AS type, 0 as qslcount + FROM $table + WHERE station_id IN ($location_list) AND col_clublog_qso_download_date IS NOT NULL AND coalesce(col_clublog_qso_download_date, '') <> '' AND col_clublog_qso_download_status = 'Y' + "; + } + + if (count($sql_parts) == 0) { + return array(); + } + + $sql = implode(" UNION ALL ", $sql_parts); + $sql = "SELECT * FROM ( $sql ) AS unioned_results ORDER BY rxdate DESC LIMIT 1000"; + + $query = $this->db->query($sql); + + return $query->result(); + } } + diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index f8b3db338..af3394568 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2839,17 +2839,6 @@ function viewEqsl(picture, callsign) { }); } - function searchAdditionalQsos(filename) { - $.ajax({ - url: base_url + 'index.php/qsl/searchQsos', - type: 'post', - data: {'callsign': $('#callsign').val(), 'filename': filename}, - success: function(html) { - $('#searchresult').empty(); - $('#searchresult').append(html); - } - }); - } uri->segment(1) == "contesting" && ($this->uri->segment(2) != "add" && $this->uri->segment(2) != "edit")) { ?>