Added grouped searching and tidied up the search results

这个提交包含在:
Peter Goodhall 2019-09-14 20:40:17 +01:00
父节点 de95ae64b7
当前提交 e81b3c1d5b
共有 4 个文件被更改,包括 126 次插入69 次删除

查看文件

@ -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";

查看文件

@ -52,19 +52,29 @@ $(".search-results-box").hide();
$.post( "<?php echo site_url('search/json_result');?>", { 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('<tr class="qso"><td>' + item.COL_TIME_ON + '</td><td>' + item.COL_TIME_ON + '</td><td>' + item.COL_CALL + '</td><td>' + item.COL_MODE + '</td><td>' + item.COL_RST_SENT + '</td><td>' + item.COL_RST_RCVD + '</td><td>' + item.COL_BAND + '</td><td>' + item.COL_COUNTRY + '</td><td>' + item.COL_QSL_SENT + '</td><td>' + item.COL_EQSL_QSL_SENT + '</td><td></td><td></td></tr>');
var band = "";
if(item.COL_SAT_NAME != "") {
band = item.COL_SAT_NAME;
} else {
band = item.COL_BAND;
}
var callsign = '<a data-fancybox data-type="iframe" data-src="<?php echo site_url('logbook/view');?>/' + item.COL_PRIMARY_KEY + '" data-src="" href="javascript:;">' + item.COL_CALL + '</a>';
$('#results').append('<tr class="qso"><td>' + item.COL_TIME_ON + '</td><td>' + callsign + '</td><td>' + item.COL_MODE + '</td><td>' + item.COL_RST_SENT + '</td><td>' + item.COL_RST_RCVD + '</td><td>' + band + '</td><td>' + item.COL_COUNTRY + '</td><td></td></tr>');
});
});
}
else{
console.log("invalid object :");
//console.log("invalid object :");
}
});

查看文件

@ -52,31 +52,14 @@
<div class="table-responsive">
<table id="results" class="table table-striped table-hover">
<tr class="titles">
<td>Date</td>
<td>Time</td>
<td>Date/Time</td>
<td>Call</td>
<td>Mode</td>
<td>Sent</td>
<td>Recv</td>
<td>Band</td>
<td>Country</td>
<?php if(($this->config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { ?>
<td>QSL</td>
<?php if($this->session->userdata('user_eqsl_name') != "") { ?>
<td>eQSL</td>
<?php } else { ?>
<td></td>
<?php } ?>
<?php if($this->session->userdata('user_lotw_name') != "") { ?>
<td>LoTW</td>
<?php } else { ?>
<td></td>
<?php } ?>
<td></td>
<?php } ?>
</tr>
</table>
</div>

查看文件

@ -33,7 +33,7 @@
<?php echo '<tr class="tr'.($i & 1).'">'; ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('d/m/y', $timestamp); ?></td>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
<td><a class="qsobox" href="<?php echo site_url('logbook/view')."/".$row->COL_PRIMARY_KEY; ?>"><?php echo str_replace("0","&Oslash;",strtoupper($row->COL_CALL)); ?></a></td>
<td><a class="fancybox" href="<?php echo site_url('logbook/view')."/".$row->COL_PRIMARY_KEY; ?>"><?php echo str_replace("0","&Oslash;",strtoupper($row->COL_CALL)); ?></a></td>
<td><?php echo $row->COL_MODE; ?></td>
<td><?php echo $row->COL_RST_SENT; ?> <?php if ($row->COL_STX_STRING) { ?><span class="label"><?php echo $row->COL_STX_STRING;?></span><?php } ?></td>
<td><?php echo $row->COL_RST_RCVD; ?> <?php if ($row->COL_SRX_STRING) { ?><span class="label"><?php echo $row->COL_SRX_STRING;?></span><?php } ?></td>