diff --git a/application/controllers/Search.php b/application/controllers/Search.php index 272df4fc..60ac4348 100644 --- a/application/controllers/Search.php +++ b/application/controllers/Search.php @@ -71,61 +71,125 @@ class Search extends CI_Controller { if(is_array($value)) { foreach($value as $values) { - //print_r($values['field']); - if($values['operator'] == "equal") { - if($search_type == "AND") { - $this->db->where($values['field'], $values['value']); + + if(isset($values['rules'])) { + if($values['condition'] == "AND") { + $this->db->group_start(); } else { - $this->db->or_where($values['field'], $values['value']); + $this->db->or_group_start(); + } + foreach($values['rules'] as $group_value) + { + if($group_value['operator'] == "equal") { + if($values['condition'] == "AND") { + $this->db->where($group_value['field'], $group_value['value']); + } else { + $this->db->or_where($group_value['field'], $group_value['value']); + } + } + + if($group_value['operator'] == "not_equal") { + if($values['condition'] == "AND") { + $this->db->where($group_value['field'].' !=', $group_value['value']); + } else { + $this->db->or_where($group_value['field'].' !=', $group_value['value']); + } + } + + if($group_value['operator'] == "less") { + if($values['condition'] == "AND") { + $this->db->where($group_value['field'].' <', $group_value['value']); + } else { + $this->db->or_where($group_value['field'].' <', $group_value['value']); + } + } + + if($group_value['operator'] == "less_or_equal") { + if($values['condition'] == "AND") { + $this->db->where($group_value['field'].' <=', $group_value['value']); + } else { + $this->db->or_where($group_value['field'].' <=', $group_value['value']); + } + } + + if($group_value['operator'] == "greater") { + if($values['condition'] == "AND") { + $this->db->where($group_value['field'].' >', $group_value['value']); + } else { + $this->db->or_where($group_value['field'].' >', $group_value['value']); + } + } + + if($group_value['operator'] == "greater_or_equal") { + if($values['condition'] == "AND") { + $this->db->where($group_value['field'].' >=', $group_value['value']); + } else { + $this->db->or_where($group_value['field'].' >=', $group_value['value']); + } + } + + } + $this->db->group_end(); + } else { + //print_r($values['field']); + if(isset($values['operator'])) { + + } + if($values['operator'] == "equal") { + if($search_type == "AND") { + $this->db->where($values['field'], $values['value']); + } else { + $this->db->or_where($values['field'], $values['value']); + } + } + + if($values['operator'] == "not_equal") { + if($search_type == "AND") { + $this->db->where($values['field'].' !=', $values['value']); + } else { + $this->db->or_where($values['field'].' !=', $values['value']); + } + } + + if($values['operator'] == "less") { + if($search_type == "AND") { + $this->db->where($values['field'].' <', $values['value']); + } else { + $this->db->or_where($values['field'].' <', $values['value']); + } + } + + if($values['operator'] == "less_or_equal") { + if($search_type == "AND") { + $this->db->where($values['field'].' <=', $values['value']); + } else { + $this->db->or_where($values['field'].' <=', $values['value']); + } + } + + if($values['operator'] == "greater") { + if($search_type == "AND") { + $this->db->where($values['field'].' >', $values['value']); + } else { + $this->db->or_where($values['field'].' >', $values['value']); + } + } + + if($values['operator'] == "greater_or_equal") { + if($search_type == "AND") { + $this->db->where($values['field'].' >=', $values['value']); + } else { + $this->db->or_where($values['field'].' >=', $values['value']); + } } } - - if($values['operator'] == "not_equal") { - if($search_type == "AND") { - $this->db->where($values['field'].' !=', $name); - } else { - $this->db->or_where($values['field'].' !=', $name); - } - } - - if($values['operator'] == "less") { - if($search_type == "AND") { - $this->db->where($values['field'].' <', $name); - } else { - $this->db->or_where($values['field'].' <', $name); - } - } - - if($values['operator'] == "less_or_equal") { - if($search_type == "AND") { - $this->db->where($values['field'].' <=', $name); - } else { - $this->db->or_where($values['field'].' <=', $name); - } - } - - if($values['operator'] == "greater") { - if($search_type == "AND") { - $this->db->where($values['field'].' >', $name); - } else { - $this->db->or_where($values['field'].' >', $name); - } - } - - if($values['operator'] == "greater_or_equal") { - if($search_type == "AND") { - $this->db->where($values['field'].' >=', $name); - } else { - $this->db->or_where($values['field'].' >=', $name); - } - } - + } } } $this->db->order_by('COL_TIME_ON', 'DESC'); $query = $this->db->get($this->config->item('table_name')); - + //echo $this->db->last_query(); echo json_encode($query->result_array()); } else { echo "Noooooooob"; diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 2e6bc356..2563a018 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -52,19 +52,29 @@ $(".search-results-box").hide(); $.post( "", { search: JSON.stringify(result, null, 2), temp: "testvar" }) .done(function( data ) { - //console.log(data) + console.log(data) //alert( "Data Loaded: " + data ); $('.qso').remove(); $(".search-results-box").show(); $.each(JSON.parse(data), function(i, item) { - $('#results').append('' + item.COL_TIME_ON + '' + item.COL_TIME_ON + '' + item.COL_CALL + '' + item.COL_MODE + '' + item.COL_RST_SENT + '' + item.COL_RST_RCVD + '' + item.COL_BAND + '' + item.COL_COUNTRY + '' + item.COL_QSL_SENT + '' + item.COL_EQSL_QSL_SENT + ''); + + var band = ""; + if(item.COL_SAT_NAME != "") { + band = item.COL_SAT_NAME; + } else { + band = item.COL_BAND; + } + + var callsign = '' + item.COL_CALL + ''; + + $('#results').append('' + item.COL_TIME_ON + '' + callsign + '' + item.COL_MODE + '' + item.COL_RST_SENT + '' + item.COL_RST_RCVD + '' + band + '' + item.COL_COUNTRY + ''); }); }); } else{ - console.log("invalid object :"); + //console.log("invalid object :"); } }); diff --git a/application/views/search/filter.php b/application/views/search/filter.php index f8f0a574..6c89c4af 100644 --- a/application/views/search/filter.php +++ b/application/views/search/filter.php @@ -52,31 +52,14 @@
- - + - config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { ?> - - - session->userdata('user_eqsl_name') != "") { ?> - - - - - - session->userdata('user_lotw_name') != "") { ?> - - - - - -
DateTimeDate/Time Call Mode Sent Recv Band CountryQSLeQSLLoTW
diff --git a/application/views/search/result_search.php b/application/views/search/result_search.php index ac573b54..5b6d3473 100644 --- a/application/views/search/result_search.php +++ b/application/views/search/result_search.php @@ -33,7 +33,7 @@ '; ?> COL_TIME_ON); echo date('d/m/y', $timestamp); ?> COL_TIME_ON); echo date('H:i', $timestamp); ?> - COL_PRIMARY_KEY; ?>">COL_CALL)); ?> + COL_PRIMARY_KEY; ?>">COL_CALL)); ?> COL_MODE; ?> COL_RST_SENT; ?> COL_STX_STRING) { ?>COL_STX_STRING;?> COL_RST_RCVD; ?> COL_SRX_STRING) { ?>COL_SRX_STRING;?>