diff --git a/application/config/migration.php b/application/config/migration.php index 5b216f92..227bc690 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'] = 70; +$config['migration_version'] = 71; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Search.php b/application/controllers/Search.php index 2a0fc3cc..6ee1a4d5 100644 --- a/application/controllers/Search.php +++ b/application/controllers/Search.php @@ -32,6 +32,7 @@ class Search extends CI_Controller { $this->load->model('Search_filter'); $data['get_table_names'] = $this->Search_filter->get_table_columns(); + $data['stored_queries'] = $this->Search_filter->get_stored_queries(); //print_r($this->Search_filter->get_table_columns()); @@ -51,24 +52,85 @@ class Search extends CI_Controller { function json_result() { if(isset($_POST['search'])) { - $result = $this->fetchQueryResult($_POST['search']); + $result = $this->fetchQueryResult($_POST['search'], false); echo json_encode($result->result_array()); - } else { - echo "Noooooooob"; - } + } } - function export_to_adif() { - if(isset($_POST['search'])) { - $data['qsos'] = $this->fetchQueryResult($_POST['search']); + function get_stored_queries() { + $this->load->model('Search_filter'); + $data['result'] = $this->Search_filter->get_stored_queries(); + $this->load->view('search/stored_queries', $data); + } - $this->load->view('adif/data/exportall', $data); - } else { - echo "Noooooooob"; + function search_result() { + if(isset($_POST['search'])) { + $data['results'] = $this->fetchQueryResult($_POST['search'], false); + $this->load->view('search/search_result_ajax', $data); } } - function fetchQueryResult($json) { + function export_to_adif() { + if(isset($_POST['search'])) { + $data['qsos'] = $this->fetchQueryResult($_POST['search'], false); + $this->load->view('adif/data/exportall', $data); + } + } + + function export_stored_query_to_adif() { + $this->db->where('id', xss_clean($this->input->post('id'))); + $sql = $this->db->get('queries')->result(); + + $data['qsos'] = $this->db->query($sql[0]->query); + $this->load->view('adif/data/exportall', $data); + } + + function run_query() { + $this->db->where('id', xss_clean($this->input->post('id'))); + $sql = $this->db->get('queries')->result(); + $sql = $sql[0]->query; + + if (stristr($sql, 'select', ) && !stristr($sql, 'delete') && !stristr($sql, 'update')) { + $data['results'] = $this->db->query($sql); + + $this->load->view('search/search_result_ajax', $data); + } + } + + function save_query() { + if(isset($_POST['search'])) { + $query = $this->fetchQueryResult($_POST['search'], true); + + $data = array( + 'userid' => xss_clean($this->session->userdata('user_id')), + 'query' => $query, + 'description' => xss_clean($_POST['description']) + ); + + $this->db->insert('queries', $data); + $last_id = $this->db->insert_id(); + header('Content-Type: application/json'); + echo json_encode(array('id' => $last_id, 'description' => xss_clean($_POST['description']))); + } + } + + function delete_query() { + $id = xss_clean($this->input->post('id')); + $this->load->model('search_filter'); + $this->search_filter->delete_query($id); + } + + function save_edited_query() { + $data = array( + 'description' => xss_clean($this->input->post('description')), + ); + + $this->db->where('id', xss_clean($this->input->post('id'))); + $this->db->where('userid', $this->session->userdata['user_id']); + $this->db->update('queries', $data); + } + + function fetchQueryResult($json, $returnquery) { $search_items = json_decode($json, true); @@ -316,9 +378,15 @@ class Search extends CI_Controller { } } } + $this->db->order_by('COL_TIME_ON', 'DESC'); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); - $query = $this->db->get($this->config->item('table_name')); + + if ($returnquery) { + $query = $this->db->get_compiled_select($this->config->item('table_name')); + } else { + $query = $this->db->get($this->config->item('table_name')); + } return $query; } } diff --git a/application/migrations/071_add_queries_table.php b/application/migrations/071_add_queries_table.php new file mode 100644 index 00000000..a1f90889 --- /dev/null +++ b/application/migrations/071_add_queries_table.php @@ -0,0 +1,14 @@ +db->query("create table if not exists queries (id integer not null auto_increment, query text, description text, userid integer not null, primary key (id)) ENGINE=myisam DEFAULT CHARSET=utf8;"); + } + + public function down() + { + $this->db->query(""); + } +} diff --git a/application/models/Search_filter.php b/application/models/Search_filter.php index c215c780..d6d4c835 100644 --- a/application/models/Search_filter.php +++ b/application/models/Search_filter.php @@ -13,6 +13,15 @@ class Search_filter extends CI_Model { return $query; } + function get_stored_queries() { + $this->db->where('userid', $this->session->userdata('user_id')); + return $this->db->get('queries')->result(); + } + + function delete_query($id) { + $this->db->delete('queries', array('id' => xss_clean($id), 'userid' =>$this->session->userdata('user_id'))); + } + } -?> \ No newline at end of file +?> diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index c92eba98..ad80d4b1 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -52,122 +52,320 @@ function load_was_map() { uri->segment(1) == "search" && $this->uri->segment(2) == "filter") { ?> - + diff --git a/application/views/search/filter.php b/application/views/search/filter.php index 7601414d..9b654175 100644 --- a/application/views/search/filter.php +++ b/application/views/search/filter.php @@ -24,19 +24,41 @@ -
+

- + - - - +

+

+ - Info You can find out how to use the search filter functions in the wiki. + +

+ + +
+ +
+ +
+ +
+ + + +
Info You can find out how to use the search filter functions in the wiki.

@@ -47,24 +69,9 @@
- Search Results + Search Results:
-
- -
- - - - - - - - - - - -
Date/TimeCallModeSentRecv'dBandCountry
-
+
diff --git a/application/views/search/search_result_ajax.php b/application/views/search/search_result_ajax.php new file mode 100644 index 00000000..1d20cc77 --- /dev/null +++ b/application/views/search/search_result_ajax.php @@ -0,0 +1,282 @@ +
+ + + + + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> + + + +'; + switch($this->session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')) { + case 'Mode': echo $this->lang->line('gen_hamradio_mode'); break; + case 'RSTS': echo $this->lang->line('gen_hamradio_rsts'); break; + case 'RSTR': echo $this->lang->line('gen_hamradio_rstr'); break; + case 'Country': echo $this->lang->line('general_word_country'); break; + case 'IOTA': echo $this->lang->line('gen_hamradio_iota'); break; + case 'SOTA': echo $this->lang->line('gen_hamradio_sota'); break; + case 'State': echo $this->lang->line('gen_hamradio_state'); break; + case 'Grid': echo $this->lang->line('gen_hamradio_gridsquare'); break; + case 'Band': echo $this->lang->line('gen_hamradio_band'); break; + } + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + if(($this->config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { ?> + + session->userdata('user_eqsl_name') != "") { ?> + + + session->userdata('user_lotw_name') != "") { ?> + + + + + config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { ?> + + + + + + result() as $row) { ?> + + session->userdata('user_date_format')) { + // If Logged in and session exists + $custom_date_format = $this->session->userdata('user_date_format'); + } else { + // Get Default date format from /config/cloudlog.php + $custom_date_format = $this->config->item('qso_date_format'); + } + ?> + COL_PRIMARY_KEY .'">'; ?> + + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> + + + + session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')) { + case 'Mode': echo ''; + switch($this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')) { + case 'Mode': echo ''; + + switch($this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')) { + case 'Mode': echo ''; + switch($this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')) { + case 'Mode': echo ''; + switch($this->session->userdata('user_column5')==""?'Country':$this->session->userdata('user_column5')) { + case 'Mode': echo ''; + if(($this->config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { ?> + + + session->userdata('user_eqsl_name') != ""){ ?> + + + + session->userdata('user_lotw_name') != "") { ?> + + + + + + station_callsign)) { ?> + + + + config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { ?> + + + + + +
lang->line('general_word_date'); ?>lang->line('general_word_time'); ?>lang->line('gen_hamradio_call'); ?>'; + switch($this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')) { + case 'Mode': echo $this->lang->line('gen_hamradio_mode'); break; + case 'RSTS': echo $this->lang->line('gen_hamradio_rsts'); break; + case 'RSTR': echo $this->lang->line('gen_hamradio_rstr'); break; + case 'Country': echo $this->lang->line('general_word_country'); break; + case 'IOTA': echo $this->lang->line('gen_hamradio_iota'); break; + case 'State': echo $this->lang->line('gen_hamradio_state'); break; + case 'SOTA': echo $this->lang->line('gen_hamradio_sota'); break; + case 'Grid': echo $this->lang->line('gen_hamradio_gridsquare'); break; + case 'Band': echo $this->lang->line('gen_hamradio_band'); break; + } + echo ''; + switch($this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')) { + case 'Mode': echo $this->lang->line('gen_hamradio_mode'); break; + case 'RSTS': echo $this->lang->line('gen_hamradio_rsts'); break; + case 'RSTR': echo $this->lang->line('gen_hamradio_rstr'); break; + case 'Country': echo $this->lang->line('general_word_country'); break; + case 'IOTA': echo $this->lang->line('gen_hamradio_iota'); break; + case 'SOTA': echo $this->lang->line('gen_hamradio_sota'); break; + case 'State': echo $this->lang->line('gen_hamradio_state'); break; + case 'Grid': echo $this->lang->line('gen_hamradio_gridsquare'); break; + case 'Band': echo $this->lang->line('gen_hamradio_band'); break; + } + echo ''; + switch($this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')) { + case 'Mode': echo $this->lang->line('gen_hamradio_mode'); break; + case 'RSTS': echo $this->lang->line('gen_hamradio_rsts'); break; + case 'RSTR': echo $this->lang->line('gen_hamradio_rstr'); break; + case 'Country': echo $this->lang->line('general_word_country'); break; + case 'IOTA': echo $this->lang->line('gen_hamradio_iota'); break; + case 'SOTA': echo $this->lang->line('gen_hamradio_sota'); break; + case 'State': echo $this->lang->line('gen_hamradio_state'); break; + case 'Grid': echo $this->lang->line('gen_hamradio_gridsquare'); break; + case 'Band': echo $this->lang->line('gen_hamradio_band'); break; + } + echo ''; + switch($this->session->userdata('user_column5')==""?'Country':$this->session->userdata('user_column5')) { + case 'Mode': echo $this->lang->line('gen_hamradio_mode'); break; + case 'RSTS': echo $this->lang->line('gen_hamradio_rsts'); break; + case 'RSTR': echo $this->lang->line('gen_hamradio_rstr'); break; + case 'Country': echo $this->lang->line('general_word_country'); break; + case 'IOTA': echo $this->lang->line('gen_hamradio_iota'); break; + case 'SOTA': echo $this->lang->line('gen_hamradio_sota'); break; + case 'State': echo $this->lang->line('gen_hamradio_state'); break; + case 'Grid': echo $this->lang->line('gen_hamradio_gridsquare'); break; + case 'Band': echo $this->lang->line('gen_hamradio_band'); break; + } + echo 'QSLeQSLLoTWlang->line('gen_hamradio_station'); ?>
COL_TIME_ON); echo date($custom_date_format, $timestamp); ?>COL_TIME_ON); echo date('H:i', $timestamp); ?> + COL_CALL)); ?> + '; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break; + case 'RSTS': echo '' . $row->COL_RST_SENT; if ($row->COL_STX) { echo '' . $row->COL_STX . '';}if ($row->COL_STX_STRING) { echo '' . $row->COL_STX_STRING . '';}; break; + case 'RSTR': echo '' . $row->COL_RST_RCVD; if ($row->COL_SRX) { echo '' . $row->COL_SRX . '';}if ($row->COL_SRX_STRING) { echo '' . $row->COL_SRX_STRING . '';}; break; + case 'Country': echo '' . ucwords(strtolower(($row->COL_COUNTRY)));; break; + case 'IOTA': echo '' . ($row->COL_IOTA); break; + case 'SOTA': echo '' . ($row->COL_SOTA_REF); break; + case 'Grid': echo ''; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break; + case 'Band': echo ''; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break; + case 'State': echo '' . ($row->COL_STATE); break; + } + echo ''; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break; + case 'RSTS': echo '' . $row->COL_RST_SENT; if ($row->COL_STX) { echo '' . $row->COL_STX . '';}if ($row->COL_STX_STRING) { echo '' . $row->COL_STX_STRING . '';}; break; + case 'RSTR': echo '' . $row->COL_RST_RCVD; if ($row->COL_SRX) { echo '' . $row->COL_SRX . '';}if ($row->COL_SRX_STRING) { echo '' . $row->COL_SRX_STRING . '';}; break; + case 'Country': echo '' . ucwords(strtolower(($row->COL_COUNTRY)));; break; + case 'IOTA': echo '' . ($row->COL_IOTA); break; + case 'SOTA': echo '' . ($row->COL_SOTA_REF); break; + case 'Grid': echo ''; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break; + case 'Band': echo ''; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break; + case 'State': echo '' . ($row->COL_STATE); break; + } + echo ''; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break; + case 'RSTS': echo '' . $row->COL_RST_SENT; if ($row->COL_STX) { echo '' . $row->COL_STX . '';}if ($row->COL_STX_STRING) { echo '' . $row->COL_STX_STRING . '';}; break; + case 'RSTR': echo '' . $row->COL_RST_RCVD; if ($row->COL_SRX) { echo '' . $row->COL_SRX . '';}if ($row->COL_SRX_STRING) { echo '' . $row->COL_SRX_STRING . '';}; break; + case 'Country': echo '' . ucwords(strtolower(($row->COL_COUNTRY)));; break; + case 'IOTA': echo '' . ($row->COL_IOTA); break; + case 'SOTA': echo '' . ($row->COL_SOTA_REF); break; + case 'Grid': echo ''; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break; + case 'Band': echo ''; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break; + case 'State': echo '' . ($row->COL_STATE); break; + } + echo ''; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break; + case 'RSTS': echo '' . $row->COL_RST_SENT; if ($row->COL_STX) { echo '' . $row->COL_STX . '';}if ($row->COL_STX_STRING) { echo '' . $row->COL_STX_STRING . '';}; break; + case 'RSTR': echo '' . $row->COL_RST_RCVD; if ($row->COL_SRX) { echo '' . $row->COL_SRX . '';}if ($row->COL_SRX_STRING) { echo '' . $row->COL_SRX_STRING . '';}; break; + case 'Country': echo '' . ucwords(strtolower(($row->COL_COUNTRY)));; break; + case 'IOTA': echo '' . ($row->COL_IOTA); break; + case 'SOTA': echo '' . ($row->COL_SOTA_REF); break; + case 'Grid': echo ''; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break; + case 'Band': echo ''; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break; + case 'State': echo '' . ($row->COL_STATE); break; + } + echo ''; echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; break; + case 'RSTS': echo '' . $row->COL_RST_SENT; if ($row->COL_STX) { echo '' . $row->COL_STX . '';}if ($row->COL_STX_STRING) { echo '' . $row->COL_STX_STRING . '';}; break; + case 'RSTR': echo '' . $row->COL_RST_RCVD; if ($row->COL_SRX) { echo '' . $row->COL_SRX . '';}if ($row->COL_SRX_STRING) { echo '' . $row->COL_SRX_STRING . '';}; break; + case 'Country': echo '' . ucwords(strtolower(($row->COL_COUNTRY)));; break; + case 'IOTA': echo '' . ($row->COL_IOTA); break; + case 'SOTA': echo '' . ($row->COL_SOTA_REF); break; + case 'Grid': echo ''; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break; + case 'Band': echo ''; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break; + case 'State': echo '' . ($row->COL_STATE); break; + } + echo ' + ">▲ + ">▼ + + + + COL_EQSL_QSL_RCVD =='Y') { ?> + COL_PRIMARY_KEY); ?>" data-fancybox="images" data-width="528" data-height="336">▼ + + ▼ + + + + COL_LOTW_QSL_SENT != ''){ ?> + + + + + station_callsign; ?> + +
+ +
diff --git a/application/views/search/stored_queries.php b/application/views/search/stored_queries.php new file mode 100644 index 00000000..5f1e9494 --- /dev/null +++ b/application/views/search/stored_queries.php @@ -0,0 +1,27 @@ + + + + + + + + + + + + + id . '">'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + +
#DescriptionQuery
' . $i++ . '' . $q->description . '' . $q->query . 'Edit'; + echo 'Delete
\ No newline at end of file