From c40eb37f4095ceaae167892ec120dc8606179bda Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 12 Feb 2016 16:31:29 +0000 Subject: [PATCH] more changes --- application/config/mimes.php | 2 + application/controllers/adif.php | 4 +- application/controllers/awards.php | 13 +- application/controllers/logbook.php | 3 +- application/controllers/qso.php | 6 +- application/controllers/search.php | 22 +-- application/models/dxcc.php | 37 +++++ application/models/logbook_model.php | 151 +++++++++++---------- application/views/qso/index.php | 21 ++- application/views/qso/manual.php | 15 +- application/views/search/main.php | 66 ++++----- application/views/search/result_search.php | 26 +++- application/views/view_log/index.php | 68 +--------- 13 files changed, 235 insertions(+), 199 deletions(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index 856a7b8d..d8451a58 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -100,7 +100,9 @@ $mimes = array( 'hqx' => 'application/mac-binhex40', 'eml' => 'message/rfc822', 'json' => array('application/json', 'text/json'), 'adi' => 'application/octet-stream', + 'adif' => 'application/octet-stream', 'ADI' => 'application/octet-stream', + 'ADIF' => 'application/octet-stream', 'tq8' => 'application/octet-stream', 'TQ8' => 'application/octet-stream', ); diff --git a/application/controllers/adif.php b/application/controllers/adif.php index 960a0102..686ff9d1 100644 --- a/application/controllers/adif.php +++ b/application/controllers/adif.php @@ -71,12 +71,14 @@ class adif extends CI_Controller { $data['page_title'] = "ADIF Import"; $config['upload_path'] = 'uploads/'; - $config['allowed_types'] = 'adi|ADI'; + $config['allowed_types'] = 'adi|ADI|adif|ADIF'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload()) { + //print $this->upload->display_errors(); + //exit(0); $data['error'] = $this->upload->display_errors(); $this->load->view('layout/header', $data); diff --git a/application/controllers/awards.php b/application/controllers/awards.php index f4e85f2a..4e2e1222 100644 --- a/application/controllers/awards.php +++ b/application/controllers/awards.php @@ -19,7 +19,16 @@ class Awards extends CI_Controller { public function dxcc () { - echo "Needs Developed"; + //echo "Needs Developed"; + $this->load->model('dxcc'); + $data['dxcc'] = $this->dxcc->show_stats(); + + // Render Page + $data['page_title'] = "Awards - DXCC"; + $this->load->view('layout/header', $data); + $this->load->view('awards/dxcc/index'); + $this->load->view('layout/footer'); + } /* @@ -73,4 +82,4 @@ class Awards extends CI_Controller { $this->load->view('layout/footer'); } -} \ No newline at end of file +} diff --git a/application/controllers/logbook.php b/application/controllers/logbook.php index b9392516..babab64b 100644 --- a/application/controllers/logbook.php +++ b/application/controllers/logbook.php @@ -347,7 +347,8 @@ class Logbook extends CI_Controller { $json = file_get_contents($url); $data = json_decode($json, TRUE); - echo ucfirst(strtolower($data['Name'])); + // echo ucfirst(strtolower($data['Name'])); + echo $json; } /* return station bearing */ diff --git a/application/controllers/qso.php b/application/controllers/qso.php index 3d13ef41..13c0d13f 100644 --- a/application/controllers/qso.php +++ b/application/controllers/qso.php @@ -40,7 +40,9 @@ class QSO extends CI_Controller { else { // Add QSO - $this->logbook_model->add(); + // $this->logbook_model->add(); + //change to create_qso function as add and create_qso duplicate functionality + $this->logbook_model->create_qso(); // Store Basic QSO Info for reuse // Put data in an array first, then call set_userdata once. @@ -49,7 +51,7 @@ class QSO extends CI_Controller { // For more info, see http://bizhole.com/codeigniter-nginx-error-502-bad-gateway/ // $qso_data = [ // 18-Jan-2016 - make php v5.3 friendly! - $sqo_data = array( + $qso_data = array( 'band' => $this->input->post('band'), 'freq' => $this->input->post('freq'), 'mode' => $this->input->post('mode'), diff --git a/application/controllers/search.php b/application/controllers/search.php index a157c4fb..bbbed4b7 100644 --- a/application/controllers/search.php +++ b/application/controllers/search.php @@ -4,20 +4,20 @@ class Search extends CI_Controller { public function index() { - // Auth check - $this->load->model('user_model'); - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { - if($this->user_model->validate_session()) { - $this->user_model->clear_session(); - show_error('Access denied

Click here to log in as another user', 403); - } else { - redirect('user/login'); - } - } + // Auth check + $this->load->model('user_model'); + if(!$this->user_model->authorize($this->config->item('auth_mode'))) { + if($this->user_model->validate_session()) { + $this->user_model->clear_session(); + show_error('Access denied

Click here to log in as another user', 403); + } else { + redirect('user/login'); + } + } $data['page_title'] = "Search"; - $this->load->view('layout/header', $data); + $this->load->view('layout/header', $data); $this->load->view('search/main'); $this->load->view('layout/footer'); } diff --git a/application/models/dxcc.php b/application/models/dxcc.php index d6485d1a..967b3832 100644 --- a/application/models/dxcc.php +++ b/application/models/dxcc.php @@ -7,6 +7,43 @@ class DXCC extends CI_Model { // Call the Model constructor parent::__construct(); } + + function show_stats(){ + + $data = $this->db->query( + "select COL_COUNTRY, COL_MODE, lcase(COL_BAND) as COL_BAND, count(COL_COUNTRY) as cnt + from TABLE_HRD_CONTACTS_V01 + group by COL_COUNTRY, COL_MODE, COL_BAND" + ); + + $results = array(); + $last_country = ""; + foreach($data->result() as $row){ + if ($last_country != $row->COL_COUNTRY){ + // new row + $results[$row->COL_COUNTRY] = array("160m"=>0, + "80m"=>0, + "40m"=>0, + "30m"=>0, + "20m"=>0, + "17m"=>0, + "15m"=>0, + "12m"=>0, + "10m"=>0, + "6m"=>0, + "2m"=>0); + $last_country = $row->COL_COUNTRY; + } + + // update stats + $results[$row->COL_COUNTRY][$row->COL_BAND] = $row->cnt; + } + + //print_r($results); + + return $results; + } + /** * Function: mostactive * Information: Returns the most active band diff --git a/application/models/logbook_model.php b/application/models/logbook_model.php index 76307661..feb9df6a 100644 --- a/application/models/logbook_model.php +++ b/application/models/logbook_model.php @@ -2,11 +2,11 @@ class Logbook_model extends CI_Model { - function __construct() - { - // Call the Model constructor - parent::__construct(); - } + function __construct() + { + // Call the Model constructor + parent::__construct(); + } /* Add QSO to Logbook */ function add() { @@ -79,84 +79,87 @@ class Logbook_model extends CI_Model { 'COL_RX_PWR' => null, 'COL_LAT' => null, 'COL_LON' => null, + 'COL_DXCC' => $this->input->post('dxcc_id'), + 'COL_CQZ' => $this->input->post('cqz'), ); $this->add_qso($data); } /* Add QSO to Logbook */ - function create_qso() { - // Join date+time - $datetime = date("Y-m-d",strtotime($this->input->post('start_date')))." ". $this->input->post('start_time'); - if ($this->input->post('prop_mode') != null) { - $prop_mode = $this->input->post('prop_mode'); - } else { - $prop_mode = ""; - } + function create_qso() { + // Join date+time + $datetime = date("Y-m-d",strtotime($this->input->post('start_date')))." ". $this->input->post('start_time'); + if ($this->input->post('prop_mode') != null) { + $prop_mode = $this->input->post('prop_mode'); + } else { + $prop_mode = ""; + } - if($this->input->post('sat_name')) { - $prop_mode = "SAT"; - } + if($this->input->post('sat_name')) { + $prop_mode = "SAT"; + } - if($this->session->userdata('user_locator')){ - $locator = $this->session->userdata('user_locator'); - } else { - $locator = $this->config->item('locator'); - } + if($this->session->userdata('user_locator')){ + $locator = $this->session->userdata('user_locator'); + } else { + $locator = $this->config->item('locator'); + } - // Create array with QSO Data + // Create array with QSO Data + $data = array( + 'COL_TIME_ON' => $datetime, + 'COL_TIME_OFF' => $datetime, + 'COL_CALL' => strtoupper(trim($this->input->post('callsign'))), + 'COL_BAND' => $this->input->post('band'), + 'COL_FREQ' => $this->input->post('freq_display'), + 'COL_MODE' => $this->input->post('mode'), + 'COL_RST_RCVD' => $this->input->post('rst_recv'), + 'COL_RST_SENT' => $this->input->post('rst_sent'), + 'COL_NAME' => $this->input->post('name'), + 'COL_COMMENT' => $this->input->post('comment'), + 'COL_SAT_NAME' => strtoupper($this->input->post('sat_name')), + 'COL_SAT_MODE' => strtoupper($this->input->post('sat_mode')), + 'COL_GRIDSQUARE' => strtoupper(trim($this->input->post('locator'))), + 'COL_COUNTRY' => $this->input->post('country'), + 'COL_MY_RIG' => $this->input->post('equipment'), + 'COL_QSLSDATE' => date('Y-m-d'), + 'COL_QSLRDATE' => date('Y-m-d'), + 'COL_QSL_SENT' => $this->input->post('qsl_sent'), + 'COL_QSL_RCVD' => $this->input->post('qsl_recv'), + 'COL_QSL_SENT_VIA' => $this->input->post('qsl_sent_method'), + 'COL_QSL_RCVD_VIA' => $this->input->post('qsl_recv_method'), + 'COL_QSL_VIA' => $this->input->post('qsl_via'), + 'COL_OPERATOR' => $this->session->userdata('user_callsign'), + 'COL_QTH' => $this->input->post('qth'), + 'COL_PROP_MODE' => $prop_mode, + 'COL_IOTA' => trim($this->input->post('iota_ref')), + 'COL_MY_GRIDSQUARE' => $locator, + 'COL_DISTANCE' => "0", + 'COL_FREQ_RX' => 0, + 'COL_BAND_RX' => null, + 'COL_ANT_AZ' => null, + 'COL_ANT_EL' => null, + 'COL_A_INDEX' => null, + 'COL_AGE' => null, + 'COL_TEN_TEN' => null, + 'COL_TX_PWR' => null, + 'COL_STX' => null, + 'COL_SRX' => null, + 'COL_NR_BURSTS' => null, + 'COL_NR_PINGS' => null, + 'COL_MAX_BURSTS' => null, + 'COL_K_INDEX' => null, + 'COL_SFI' => null, + 'COL_RX_PWR' => null, + 'COL_LAT' => null, + 'COL_LON' => null, + 'COL_DXCC' => $this->input->post('dxcc_id'), + 'COL_CQZ' => $this->input->post('cqz'), + ); - $data = array( - 'COL_TIME_ON' => $datetime, - 'COL_TIME_OFF' => $datetime, - 'COL_CALL' => strtoupper(trim($this->input->post('callsign'))), - 'COL_BAND' => $this->input->post('band'), - 'COL_FREQ' => $this->input->post('freq_display'), - 'COL_MODE' => $this->input->post('mode'), - 'COL_RST_RCVD' => $this->input->post('rst_recv'), - 'COL_RST_SENT' => $this->input->post('rst_sent'), - 'COL_NAME' => $this->input->post('name'), - 'COL_COMMENT' => $this->input->post('comment'), - 'COL_SAT_NAME' => strtoupper($this->input->post('sat_name')), - 'COL_SAT_MODE' => strtoupper($this->input->post('sat_mode')), - 'COL_GRIDSQUARE' => strtoupper(trim($this->input->post('locator'))), - 'COL_COUNTRY' => $this->input->post('country'), - 'COL_MY_RIG' => $this->input->post('equipment'), - 'COL_QSLSDATE' => date('Y-m-d'), - 'COL_QSLRDATE' => date('Y-m-d'), - 'COL_QSL_SENT' => $this->input->post('qsl_sent'), - 'COL_QSL_RCVD' => $this->input->post('qsl_recv'), - 'COL_QSL_SENT_VIA' => $this->input->post('qsl_sent_method'), - 'COL_QSL_RCVD_VIA' => $this->input->post('qsl_recv_method'), - 'COL_QSL_VIA' => $this->input->post('qsl_via'), - 'COL_OPERATOR' => $this->session->userdata('user_callsign'), - 'COL_QTH' => $this->input->post('qth'), - 'COL_PROP_MODE' => $prop_mode, - 'COL_IOTA' => trim($this->input->post('iota_ref')), - 'COL_MY_GRIDSQUARE' => $locator, - 'COL_DISTANCE' => "0", - 'COL_FREQ_RX' => 0, - 'COL_BAND_RX' => null, - 'COL_ANT_AZ' => null, - 'COL_ANT_EL' => null, - 'COL_A_INDEX' => null, - 'COL_AGE' => null, - 'COL_TEN_TEN' => null, - 'COL_TX_PWR' => null, - 'COL_STX' => null, - 'COL_SRX' => null, - 'COL_NR_BURSTS' => null, - 'COL_NR_PINGS' => null, - 'COL_MAX_BURSTS' => null, - 'COL_K_INDEX' => null, - 'COL_SFI' => null, - 'COL_RX_PWR' => null, - 'COL_LAT' => null, - 'COL_LON' => null, - ); - - $this->add_qso($data); - } + $this->add_qso($data); + } function add_qso($data) { // Add QSO to database @@ -273,7 +276,7 @@ class Logbook_model extends CI_Model { function get_qsos($num, $offset) { - $this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_GRIDSQUARE, COL_QSL_RCVD, COL_QSL_SENT, COL_STX_STRING, COL_SRX_STRING, COL_OPERATOR, COL_STATION_CALLSIGN'); + $this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_GRIDSQUARE, COL_QSL_RCVD, COL_EQSL_QSL_RCVD, COL_EQSL_QSL_SENT, COL_QSL_SENT, COL_STX_STRING, COL_SRX_STRING, COL_OPERATOR, COL_STATION_CALLSIGN'); $this->db->order_by("COL_TIME_ON", "desc"); $query = $this->db->get($this->config->item('table_name'), $num, $offset); diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 3623fe6c..dc80f3e9 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -51,6 +51,8 @@

Add QSO

+ + @@ -392,7 +394,12 @@ /* Find and populate DXCC */ $.get('logbook/find_dxcc/' + $(this).val(), function(result) { - $('#country').val(result); + //$('#country').val(result); + obj = JSON.parse(result); + $('#country').val(convert_case(obj.Name)); + $('#dxcc_id').val(obj.DXCC); + $('#cqz').val(obj.CQZ); + }); /* Find Locator if the field is empty */ @@ -440,5 +447,17 @@ $('#rst_recv').val('59'); } }); + + }); + + + function convert_case(str) { + var lower = str.toLowerCase(); + return lower.replace(/(^| )(\w)/g, function(x) { + return x.toUpperCase(); + }); + } + + \ No newline at end of file diff --git a/application/views/qso/manual.php b/application/views/qso/manual.php index c406814e..65f04999 100644 --- a/application/views/qso/manual.php +++ b/application/views/qso/manual.php @@ -41,6 +41,8 @@

Manual QSO

+ +
@@ -482,7 +484,11 @@ /* Find and populate DXCC */ $.get('/' + $(this).val(), function(result) { - $('#country').val(result); + //$('#country').val(result); + obj = JSON.parse(result); + $('#country').val(convert_case(obj.Name)); + $('#dxcc_id').val(obj.DXCC); + $('#cqz').val(obj.CQZ); }); /* Find Locator if the field is empty */ @@ -510,4 +516,11 @@ } }); }); + + function convert_case(str) { + var lower = str.toLowerCase(); + return lower.replace(/(^| )(\w)/g, function(x) { + return x.toUpperCase(); + }); + } \ No newline at end of file diff --git a/application/views/search/main.php b/application/views/search/main.php index 4d22625c..ebee83f6 100644 --- a/application/views/search/main.php +++ b/application/views/search/main.php @@ -17,6 +17,15 @@ $(document).ready(function(){ $('#partial_view').load("logbook/search_result/input->post('callsign'); ?>", function() { // after load trigger your fancybox + $(".qsobox").fancybox({ + 'autoDimensions' : false, + 'width' : 700, + 'height' : 300, + 'transitionIn' : 'fade', + 'transitionOut' : 'fade', + 'type' : 'iframe' + }); + $(".editbox").fancybox({ 'autoDimensions' : false, 'width' : 450, @@ -30,18 +39,26 @@ $(document).ready(function(){ $("#callsign").keyup(function(){ if ($(this).val()) { - $('#partial_view').load("logbook/search_result/" + $(this).val(), function() { - // after load trigger your fancybox - $(".editbox").fancybox({ - 'autoDimensions' : false, - 'width' : 450, - 'height' : 550, - 'transitionIn' : 'fade', - 'transitionOut' : 'fade', - 'type' : 'iframe', - }); - }); - + $('#partial_view').load("logbook/search_result/" + $(this).val(), function() { + $(".qsobox").fancybox({ + 'autoDimensions' : false, + 'width' : 700, + 'height' : 300, + 'transitionIn' : 'fade', + 'transitionOut' : 'fade', + 'type' : 'iframe' + }); + + // after load trigger your fancybox + $(".editbox").fancybox({ + 'autoDimensions' : false, + 'width' : 450, + 'height' : 550, + 'transitionIn' : 'fade', + 'transitionOut' : 'fade', + 'type' : 'iframe', + }); + }); } }); @@ -54,28 +71,3 @@ $(document).ready(function(){ - \ No newline at end of file diff --git a/application/views/search/result_search.php b/application/views/search/result_search.php index cbf341d8..7f7ba641 100644 --- a/application/views/search/result_search.php +++ b/application/views/search/result_search.php @@ -9,7 +9,8 @@ config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { ?> - + + @@ -45,10 +46,31 @@ QSL Cards sent + -
Band Country QSLeQSL
+ COL_EQSL_QSL_SENT != ''){ ?> + + + + Edit
\ No newline at end of file + +