diff --git a/.htaccess.sample b/.htaccess.sample index 435eea60..f766ea9f 100644 --- a/.htaccess.sample +++ b/.htaccess.sample @@ -10,3 +10,5 @@ RewriteRule ^(.*)$ /index.php?/$1 "[L,QSA,B= ?,BNP]" RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?/$1 "[L,QSA,B= ?,BNP]" + +RedirectMatch 404 ^/\.git diff --git a/application/config/migration.php b/application/config/migration.php index 55613c99..ceb663f7 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 124; +$config['migration_version'] = 125; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Eqsl.php b/application/controllers/Eqsl.php index d329d2dc..642e6fa5 100644 --- a/application/controllers/Eqsl.php +++ b/application/controllers/Eqsl.php @@ -501,7 +501,7 @@ class eqsl extends CI_Controller { $query = $this->user_model->get_by_id($this->session->userdata('user_id')); $q = $query->row(); - $username = $q->user_eqsl_name; + $username = $qso->COL_STATION_CALLSIGN; $password = $q->user_eqsl_password; $image_url = $this->electronicqsl->card_image($username, urlencode($password), $callsign, $band, $mode, $year, $month, $day, $hour, $minute); @@ -559,7 +559,7 @@ class eqsl extends CI_Controller { $query = $this->user_model->get_by_id($this->session->userdata('user_id')); $q = $query->row(); - $username = $q->user_eqsl_name; + $username = $qso->COL_STATION_CALLSIGN; $password = $q->user_eqsl_password; $error = ''; diff --git a/application/controllers/Gridmap.php b/application/controllers/Gridmap.php index d4e32e6a..7594b98d 100644 --- a/application/controllers/Gridmap.php +++ b/application/controllers/Gridmap.php @@ -11,6 +11,9 @@ class Gridmap extends CI_Controller { $this->load->model('bands'); $this->load->model('gridmap_model'); + $this->load->model('stations'); + + $data['homegrid'] = explode(',', $this->stations->find_gridsquare()); $data['modes'] = $this->gridmap_model->get_worked_modes(); $data['bands'] = $this->bands->get_worked_bands(); @@ -27,6 +30,7 @@ class Gridmap extends CI_Controller { $footerData = []; $footerData['scripts'] = [ + 'assets/js/leaflet/geocoding.js', 'assets/js/leaflet/L.MaidenheadColouredGridMap.js', 'assets/js/sections/gridmap.js?' ]; diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 628b4dcd..9b813de0 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -87,22 +87,27 @@ class Labels extends CI_Controller { } + public function printids() { + $ids = xss_clean(json_decode($this->input->post('id'))); + $this->load->model('labels_model'); + $result = $this->labels_model->export_printrequestedids($ids); + + $this->prepareLabel($result, true); + } + public function print($station_id) { $clean_id = xss_clean($station_id); $this->load->model('labels_model'); $result = $this->labels_model->export_printrequested($clean_id); + $this->prepareLabel($result); + } + + function prepareLabel($qsos, $jscall = false) { + $this->load->model('labels_model'); $label = $this->labels_model->getDefaultLabel(); - - // require_once('fpdf.php'); - // require('PDF_Label.php'); - // require_once APPPATH."/src/Label/PDF_Label.php"; - // require_once APPPATH."/src/Label/fpdf.php"; - - // Example of custom format - // $pdf = new PDF_Label(array('paper-size'=>'A4', 'metric'=>'mm', 'marginLeft'=>1, 'marginTop'=>1, 'NX'=>2, 'NY'=>7, 'SpaceX'=>0, 'SpaceY'=>0, 'width'=>99, 'height'=>38, 'font-size'=>14)); - + try { if ($label) { $pdf = new PDF_Label(array( @@ -119,17 +124,29 @@ class Labels extends CI_Controller { 'font-size' => $label->font_size )); } else { - $this->session->set_flashdata('error', 'You need to create a label and set it to be used for print.'); - redirect('labels'); + if ($jscall) { + header('Content-Type: application/json'); + echo json_encode(array('message' => 'You need to create a label and set it to be used for print.')); + return; + } else { + $this->session->set_flashdata('error', 'You need to create a label and set it to be used for print.'); + redirect('labels'); + } } } catch (\Throwable $th) { - $this->session->set_flashdata('error', 'Something went wrong! The label could not be generated. Check label size and font size.'); - redirect('labels'); + if ($jscall) { + header('Content-Type: application/json'); + echo json_encode(array('message' => 'Something went wrong! The label could not be generated. Check label size and font size.')); + return; + } else { + $this->session->set_flashdata('error', 'Something went wrong! The label could not be generated. Check label size and font size.'); + redirect('labels'); + } } define('FPDF_FONTPATH', './src/Label/font/'); - + $pdf->AddPage(); - + if ($label->font == 'DejaVuSans') { $pdf->AddFont($label->font,'','DejaVuSansMono.ttf',true); $pdf->SetFont($label->font); @@ -137,13 +154,12 @@ class Labels extends CI_Controller { $pdf->AddFont($label->font); $pdf->SetFont($label->font); } - - - if ($result->num_rows() > 0) { + + if ($qsos->num_rows() > 0) { if ($label->qsos == 1) { - $this->makeOneQsoLabel($result->result(), $pdf); + $this->makeOneQsoLabel($qsos->result(), $pdf); } else { - $this->makeMultiQsoLabel($result->result(), $pdf, $label->qsos); + $this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos); } } else { $this->session->set_flashdata('message', '0 QSOs found for print!'); diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index d1d797e2..6c5d7675 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -772,7 +772,7 @@ class Logbook extends CI_Controller { function querydb($id) { $this->db->from($this->config->item('table_name')); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); - $this->db->join('dxcc_entities', 'dxcc_entities.adif = '.$this->config->item('table_name').'.COL_DXCC'); + $this->db->join('dxcc_entities', 'dxcc_entities.adif = '.$this->config->item('table_name').'.COL_DXCC', 'left outer'); $this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer'); $this->db->group_start(); $this->db->like(''.$this->config->item('table_name').'.COL_CALL', $id); diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php index 19daff37..736fc077 100644 --- a/application/controllers/Logbookadvanced.php +++ b/application/controllers/Logbookadvanced.php @@ -106,6 +106,10 @@ class Logbookadvanced extends CI_Controller { 'state' => xss_clean($this->input->post('state')), 'qsoresults' => xss_clean($this->input->post('qsoresults')), 'sats' => xss_clean($this->input->post('sats')), + 'lotwSent' => xss_clean($this->input->post('lotwSent')), + 'lotwReceived' => xss_clean($this->input->post('lotwReceived')), + 'eqslSent' => xss_clean($this->input->post('eqslSent')), + 'eqslReceived' => xss_clean($this->input->post('eqslReceived')), ); $qsos = []; @@ -184,4 +188,32 @@ class Logbookadvanced extends CI_Controller { header("Content-Type: application/json"); print json_encode($q); } + + function update_qsl_received() { + $this->load->model('logbookadvanced_model'); + + $ids = xss_clean($this->input->post('id')); + $user_id = (int)$this->session->userdata('user_id'); + $method = xss_clean($this->input->post('method')); + $sent = xss_clean($this->input->post('sent')); + + $status = $this->logbookadvanced_model->updateQslReceived($ids, $user_id, $method, $sent); + + $data = $this->logbookadvanced_model->getQsosForAdif($ids, $user_id); + + $results = $data->result('array'); + + $qsos = []; + foreach ($results as $data) { + $qsos[] = new QSO($data); + } + + $q = []; + foreach ($qsos as $qso) { + $q[] = $qso->toArray(); + } + + header("Content-Type: application/json"); + print json_encode($q); + } } \ No newline at end of file diff --git a/application/controllers/Qsl.php b/application/controllers/Qsl.php index 2602fa78..89df8947 100644 --- a/application/controllers/Qsl.php +++ b/application/controllers/Qsl.php @@ -66,11 +66,15 @@ class Qsl extends CI_Controller { if (isset($_FILES['qslcardfront']) && $_FILES['qslcardfront']['name'] != "" && $_FILES['qslcardfront']['error'] == 0) { $result['front'] = $this->uploadQslCardFront($qsoid); + } else { + $result['front']['status'] = ''; } if (isset($_FILES['qslcardback']) && $_FILES['qslcardback']['name'] != "" && $_FILES['qslcardback']['error'] == 0) { $result['back'] = $this->uploadQslCardBack($qsoid); + } else { + $result['back']['status'] = ''; } header("Content-type: application/json"); @@ -170,6 +174,13 @@ class Qsl extends CI_Controller { echo json_encode($result); } + function viewQsl() { + $cleanid = $this->security->xss_clean($this->input->post('id')); + $this->load->model('Qsl_model'); + $data['qslimages'] = $this->Qsl_model->getQslForQsoId($cleanid); + $this->load->view('qslcard/qslcarousel', $data); + } + } // Functions for storage, these need shifted to a libary to use across Cloudlog diff --git a/application/language/english/general_words_lang.php b/application/language/english/general_words_lang.php index 6dc3b456..2b15e688 100644 --- a/application/language/english/general_words_lang.php +++ b/application/language/english/general_words_lang.php @@ -55,6 +55,7 @@ $lang['general_word_lotw'] = 'Logbook of the World'; $lang['general_edit_qso'] = 'Edit QSO'; $lang['general_mark_qsl_rx_bureau'] = 'Mark QSL Received (Bureau)'; $lang['general_mark_qsl_rx_direct'] = 'Mark QSL Received (Direct)'; +$lang['general_mark_qsl_rx_electronic'] = 'Mark QSL Received (Electronic)'; $lang['general_mark_qsl_tx_bureau'] = 'Mark QSL Sent (Bureau)'; $lang['general_mark_qsl_tx_direct'] = 'Mark QSL Sent (Direct)'; @@ -138,4 +139,4 @@ $lang['northamerica'] = 'North America'; $lang['oceania'] = 'Oceania'; $lang['southamerica'] = 'South America'; -$lang['gen_band_selection'] = 'Band selection'; \ No newline at end of file +$lang['gen_band_selection'] = 'Band selection'; diff --git a/application/language/english/menu_lang.php b/application/language/english/menu_lang.php index eb3911e7..30972966 100644 --- a/application/language/english/menu_lang.php +++ b/application/language/english/menu_lang.php @@ -21,7 +21,7 @@ $lang['menu_notes'] = 'Notes'; $lang['menu_analytics'] = 'Analytics'; $lang['menu_statistics'] = 'Statistics'; $lang['menu_gridsquares'] = 'Gridsquares'; -$lang['menu_gridmap'] = 'Gridmap'; +$lang['menu_gridmap'] = 'Gridsquare Map'; $lang['menu_activated_gridsquares'] = 'Activated Gridsquares'; $lang['menu_gridsquare_activators'] = 'Gridsquare Activators'; $lang['menu_distances_worked'] = 'Distances Worked'; diff --git a/application/language/german/general_words_lang.php b/application/language/german/general_words_lang.php index 61865b04..8930dddf 100644 --- a/application/language/german/general_words_lang.php +++ b/application/language/german/general_words_lang.php @@ -55,6 +55,7 @@ $lang['general_word_lotw'] = 'Logbook of the World'; $lang['general_edit_qso'] = 'QSO bearbeiten'; $lang['general_mark_qsl_rx_bureau'] = 'Markiere QSL erhalten (Büro)'; $lang['general_mark_qsl_rx_direct'] = 'Markiere QSL erhalten (Direkt)'; +$lang['general_mark_qsl_rx_electronic'] = 'Markiere QSL erhalten (Elektronisch)'; $lang['general_mark_qsl_tx_bureau'] = 'Markiere QSL gesendet (Büro)'; $lang['general_mark_qsl_tx_direct'] = 'Markiere QSL gesendet (Direkt)'; diff --git a/application/migrations/125_lotw_enddates.php b/application/migrations/125_lotw_enddates.php new file mode 100644 index 00000000..e09e26d3 --- /dev/null +++ b/application/migrations/125_lotw_enddates.php @@ -0,0 +1,21 @@ +db->table_exists('lotw_certs')) { + $sql = 'UPDATE lotw_certs SET qso_end_date = DATE_ADD(qso_end_date, INTERVAL 24*60*60 -1 SECOND) WHERE TIME(qso_end_date) = "00:00:00";'; + $this->db->query($sql); + } + } + + public function down() + { + if ($this->db->table_exists('lotw_certs')) { + $sql = 'UPDATE lotw_certs SET qso_end_date = DATE_SUB(qso_end_date, INTERVAL 24*60*60 -1 SECOND) WHERE TIME(qso_end_date) = "23:59:59";'; + $this->db->query($sql); + } + } +} diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index 91c62027..c0c50494 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -127,4 +127,16 @@ class Labels_model extends CI_Model { return $query; } + + function export_printrequestedids($ids) { + $this->db->select($this->config->item('table_name').'.*, station_profile.*, dxcc_entities.name as station_country'); + $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); + $this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif'); + $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); + $this->db->where_in('COL_PRIMARY_KEY', $ids); + $this->db->order_by("COL_DXCC", "ASC"); + $query = $this->db->get($this->config->item('table_name')); + + return $query; + } } \ No newline at end of file diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 71e7ac28..7900a6ca 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -694,10 +694,10 @@ class Logbook_model extends CI_Model { $sat_name = ''; if ($data['COL_SAT_NAME'] == 'AO-7') { if ($data['COL_BAND'] == '2m' && $data['COL_BAND_RX'] == '10m') { - $sat_name = '[A]_AO-7'; + $sat_name = 'AO-7[A]'; } if ($data['COL_BAND'] == '70cm' && $data['COL_BAND_RX'] == '2m') { - $sat_name = '[B]_AO-7'; + $sat_name = 'AO-7[B]'; } } else if ($data['COL_SAT_NAME'] == 'QO-100') { $sat_name = 'QO-100_NB'; diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index f0571352..cc361181 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -56,6 +56,24 @@ class Logbookadvanced_model extends CI_Model { $binding[] = $searchCriteria['qslReceived']; } + if ($searchCriteria['lotwSent'] !== '') { + $conditions[] = "COL_LOTW_QSL_SENT = ?"; + $binding[] = $searchCriteria['lotwSent']; + } + if ($searchCriteria['lotwReceived'] !== '') { + $conditions[] = "COL_LOTW_QSL_RCVD = ?"; + $binding[] = $searchCriteria['lotwReceived']; + } + + if ($searchCriteria['eqslSent'] !== '') { + $conditions[] = "COL_EQSL_QSL_SENT = ?"; + $binding[] = $searchCriteria['eqslSent']; + } + if ($searchCriteria['eqslReceived'] !== '') { + $conditions[] = "COL_EQSL_QSL_RCVD = ?"; + $binding[] = $searchCriteria['eqslReceived']; + } + if ($searchCriteria['iota'] !== '') { $conditions[] = "COL_IOTA = ?"; $binding[] = $searchCriteria['iota']; @@ -101,6 +119,11 @@ class Logbookadvanced_model extends CI_Model { INNER JOIN station_profile ON qsos.station_id=station_profile.station_id LEFT OUTER JOIN dxcc_entities ON qsos.col_dxcc=dxcc_entities.adif LEFT OUTER JOIN lotw_users ON qsos.col_call=lotw_users.callsign + LEFT OUTER JOIN ( + select count(*) as qslcount, qsoid + from qsl_images + group by qsoid + ) x on qsos.COL_PRIMARY_KEY = x.qsoid WHERE station_profile.user_id = ? $where ORDER BY qsos.COL_TIME_ON desc, qsos.COL_PRIMARY_KEY desc @@ -132,10 +155,17 @@ class Logbookadvanced_model extends CI_Model { $order = $this->getSortorder($sortorder); $sql = " - SELECT *, dxcc_entities.name AS station_country + SELECT qsos.*, d2.*, lotw_users.*, station_profile.*, x.qslcount, dxcc_entities.name AS station_country FROM " . $this->config->item('table_name') . " qsos INNER JOIN station_profile ON qsos.station_id = station_profile.station_id LEFT OUTER JOIN dxcc_entities ON qsos.COL_MY_DXCC = dxcc_entities.adif + LEFT OUTER JOIN dxcc_entities d2 ON qsos.COL_DXCC = d2.adif + LEFT OUTER JOIN lotw_users ON qsos.col_call=lotw_users.callsign + LEFT OUTER JOIN ( + select count(*) as qslcount, qsoid + from qsl_images + group by qsoid + ) x on qsos.COL_PRIMARY_KEY = x.qsoid WHERE station_profile.user_id = ? $where $order @@ -215,6 +245,24 @@ class Logbookadvanced_model extends CI_Model { } } + public function updateQslReceived($ids, $user_id, $method, $sent) { + $this->load->model('user_model'); + + if(!$this->user_model->authorize(2)) { + return array('message' => 'Error'); + } else { + $data = array( + 'COL_QSLRDATE' => date('Y-m-d H:i:s'), + 'COL_QSL_RCVD' => $sent, + 'COL_QSL_RCVD_VIA' => $method + ); + $this->db->where_in('COL_PRIMARY_KEY', json_decode($ids, true)); + $this->db->update($this->config->item('table_name'), $data); + + return array('message' => 'OK'); + } + } + public function updateQsoWithCallbookInfo($qsoID, $qso, $callbook) { $updatedData = array(); if (!empty($callbook['name']) && empty($qso['COL_NAME'])) { diff --git a/application/models/LotwCert.php b/application/models/LotwCert.php index 1d1fd03d..1dab4515 100644 --- a/application/models/LotwCert.php +++ b/application/models/LotwCert.php @@ -6,7 +6,7 @@ class LotwCert extends CI_Model { |-------------------------------------------------------------------------- | Function: lotw_certs |-------------------------------------------------------------------------- - | + | | Returns all lotw_certs for a selected user via the $user_id parameter | */ @@ -17,7 +17,7 @@ class LotwCert extends CI_Model { $this->db->join('dxcc_entities','lotw_certs.cert_dxcc_id = dxcc_entities.adif','left'); $this->db->order_by('cert_dxcc', 'ASC'); $query = $this->db->get('lotw_certs'); - + return $query; } @@ -46,7 +46,7 @@ class LotwCert extends CI_Model { 'date_created' => $date_created, 'date_expires' => $date_expires, 'qso_start_date' => $qso_start_date, - 'qso_end_date' => $qso_end_date, + 'qso_end_date' => $qso_end_date . ' 23:59:59', 'cert_key' => $cert_key, 'cert' => $general_cert, ); @@ -60,7 +60,7 @@ class LotwCert extends CI_Model { 'date_created' => $date_created, 'date_expires' => $date_expires, 'qso_start_date' => $qso_start_date, - 'qso_end_date' => $qso_end_date, + 'qso_end_date' => $qso_end_date . ' 23:59:59', 'cert_key' => $cert_key, 'cert' => $general_cert ); @@ -90,9 +90,9 @@ class LotwCert extends CI_Model { return "Updated"; } - + function empty_table($table) { - $this->db->empty_table($table); + $this->db->empty_table($table); } function lotw_cert_expired($user_id, $date) { diff --git a/application/models/Pota.php b/application/models/Pota.php index 117a8c42..1c5c8a40 100644 --- a/application/models/Pota.php +++ b/application/models/Pota.php @@ -15,6 +15,8 @@ class Pota extends CI_Model { $bandslots = $this->bands->get_worked_bands('pota'); + if(!$bandslots) return null; + $this->db->where_in("station_id", $logbooks_locations_array); $this->db->where_in("col_band", $bandslots); $this->db->order_by("COL_POTA_REF", "ASC"); diff --git a/application/models/Sota.php b/application/models/Sota.php index 6d47334e..46d7e5f5 100644 --- a/application/models/Sota.php +++ b/application/models/Sota.php @@ -15,6 +15,8 @@ class Sota extends CI_Model { $bandslots = $this->bands->get_worked_bands('sota'); + if(!$bandslots) return null; + $this->db->where_in("station_id", $logbooks_locations_array); $this->db->where_in("col_band", $bandslots); $this->db->order_by("COL_SOTA_REF", "ASC"); diff --git a/application/models/Stations.php b/application/models/Stations.php index 7d9e8823..dca8cd88 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -372,14 +372,14 @@ class Stations extends CI_Model { $sql=" SELECT station_profile.station_id, station_profile.station_profile_name, station_profile.station_callsign, notc.c notcount, totc.c totcount FROM station_profile - INNER JOIN ( + LEFT OUTER JOIN ( SELECT qsos.station_id, COUNT(qsos.COL_PRIMARY_KEY) c FROM %s qsos LEFT JOIN webadif ON qsos.COL_PRIMARY_KEY = webadif.qso_id WHERE webadif.qso_id IS NULL AND qsos.COL_SAT_NAME = 'QO-100' GROUP BY qsos.station_id ) notc ON station_profile.station_id = notc.station_id - INNER JOIN ( + LEFT JOIN ( SELECT qsos.station_id, COUNT(qsos.COL_PRIMARY_KEY) c FROM %s qsos WHERE qsos.COL_SAT_NAME = 'QO-100' diff --git a/application/models/Wwff.php b/application/models/Wwff.php index 93908d7e..e15584c3 100644 --- a/application/models/Wwff.php +++ b/application/models/Wwff.php @@ -15,6 +15,8 @@ class Wwff extends CI_Model { $bandslots = $this->bands->get_worked_bands('wwff'); + if(!$bandslots) return null; + $this->db->where_in("station_id", $logbooks_locations_array); $this->db->where_in("col_band", $bandslots); $this->db->order_by("COL_WWFF_REF", "ASC"); diff --git a/application/views/gridmap/index.php b/application/views/gridmap/index.php index 93a2cdeb..2b9e59ef 100644 --- a/application/views/gridmap/index.php +++ b/application/views/gridmap/index.php @@ -6,9 +6,9 @@ padding: 6px 8px; font: 14px Arial, Helvetica, sans-serif; background: white; - background: rgba(255, 255, 255, 0.8); line-height: 24px; color: #555; + border-radius: 10px; } .legend h4 { text-align: center; @@ -25,7 +25,19 @@ height: 18px; float: left; margin: 0 8px 0 0; - opacity: 0.7; +} +.coordinates { + justify-content: center; + align-items: stretch; +} +.cohidden { + display:none; +} +#latDeg, #lngDeg { + width: 170px; +} +#locator, #distance, #bearing { + width: 120px; }