Merge pull request #370 from dg9vh/improve_search

Enhancing advanced search with some more operators and enabling QSO-V…
这个提交包含在:
Peter Goodhall 2019-10-09 21:21:14 +01:00 提交者 GitHub
当前提交 4df3a6ce8b
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 3 个文件被更改,包括 121 次插入4 次删除

查看文件

@ -96,6 +96,63 @@ class Search extends CI_Controller {
} }
} }
if($group_value['operator'] == "begins_with") {
if($values['condition'] == "AND") {
$this->db->where($group_value['field'].' like ', $group_value['value']."%");
} else {
$this->db->or_where($group_value['field'].' like ', $group_value['value']."%");
}
}
if($group_value['operator'] == "contains") {
if($values['condition'] == "AND") {
$this->db->where($group_value['field'].' like ', "%".$group_value['value']."%");
} else {
$this->db->or_where($group_value['field'].' like ', "%".$group_value['value']."%");
}
}
if($group_value['operator'] == "ends_with") {
if($values['condition'] == "AND") {
$this->db->where($group_value['field'].' like ', "%".$group_value['value']);
} else {
$this->db->or_where($group_value['field'].' like ', "%".$group_value['value']);
}
}
if($group_value['operator'] == "is_empty") {
if($values['condition'] == "AND") {
$this->db->where($group_value['field'], "''");
} else {
$this->db->or_where($group_value['field'], "''");
}
}
if($group_value['operator'] == "is_not_empty") {
if($values['condition'] == "AND") {
$this->db->where($group_value['field'].' !=', "''");
} else {
$this->db->or_where($group_value['field'].' !=', "''");
}
}
if($group_value['operator'] == "is_null") {
if($values['condition'] == "AND") {
$this->db->where($group_value['field'].' is ', NULL);
} else {
$this->db->or_where($group_value['field'].' is ', NULL);
}
}
if($group_value['operator'] == "is_not_null") {
if($values['condition'] == "AND") {
$this->db->where($group_value['field'].' is not ', NULL);
} else {
$this->db->or_where($group_value['field'].' is not ', NULL);
}
}
if($group_value['operator'] == "less") { if($group_value['operator'] == "less") {
if($values['condition'] == "AND") { if($values['condition'] == "AND") {
$this->db->where($group_value['field'].' <', $group_value['value']); $this->db->where($group_value['field'].' <', $group_value['value']);
@ -151,6 +208,62 @@ class Search extends CI_Controller {
} }
} }
if($values['operator'] == "begins_with") {
if($search_type == "AND") {
$this->db->where($values['field'].' like ', $values['value']."%");
} else {
$this->db->or_where($values['field'].' like ', $values['value']."%");
}
}
if($values['operator'] == "contains") {
if($search_type == "AND") {
$this->db->where($values['field'].' like ', "%".$values['value']."%");
} else {
$this->db->or_where($values['field'].' like ', "%".$values['value']."%");
}
}
if($values['operator'] == "ends_with") {
if($search_type == "AND") {
$this->db->where($values['field'].' like ', "%".$values['value']);
} else {
$this->db->or_where($values['field'].' like ', "%".$values['value']);
}
}
if($values['operator'] == "is_empty") {
if($search_type == "AND") {
$this->db->where($values['field'], "");
} else {
$this->db->or_where($values['field'], "");
}
}
if($values['operator'] == "is_not_empty") {
if($search_type == "AND") {
$this->db->where($values['field'].' !=', "");
} else {
$this->db->or_where($values['field'].' !=', "");
}
}
if($values['operator'] == "is_null") {
if($search_type == "AND") {
$this->db->where($values['field'].' is ', NULL);
} else {
$this->db->or_where($values['field'].' is ', NULL);
}
}
if($values['operator'] == "is_not_null") {
if($search_type == "AND") {
$this->db->where($values['field'].' is not ', NULL);
} else {
$this->db->or_where($values['field'].' is not ', NULL);
}
}
if($values['operator'] == "less") { if($values['operator'] == "less") {
if($search_type == "AND") { if($search_type == "AND") {
$this->db->where($values['field'].' <', $values['value']); $this->db->where($values['field'].' <', $values['value']);
@ -189,10 +302,9 @@ class Search extends CI_Controller {
} }
$this->db->order_by('COL_TIME_ON', 'DESC'); $this->db->order_by('COL_TIME_ON', 'DESC');
$query = $this->db->get($this->config->item('table_name')); $query = $this->db->get($this->config->item('table_name'));
//echo $this->db->last_query();
echo json_encode($query->result_array()); echo json_encode($query->result_array());
} else { } else {
echo "Noooooooob"; echo "Noooooooob";
} }
} }

查看文件

@ -51,7 +51,7 @@ $(".search-results-box").hide();
operators: ['equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal'] operators: ['equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal']
<?php } else { ?> <?php } else { ?>
type: 'string', type: 'string',
operators: ['equal', 'not_equal'] operators: ['equal', 'not_equal', 'begins_with', 'contains', 'ends_with', 'is_empty', 'is_not_empty', 'is_null', 'is_not_null']
<?php } ?> <?php } ?>
}, },
<?php } ?> <?php } ?>

查看文件

@ -183,6 +183,11 @@
<td><?php echo $row->COL_OPERATOR; ?></td> <td><?php echo $row->COL_OPERATOR; ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) { ?>
<tr>
<td><a href="<?php echo site_url('qso/edit'); ?>/<?php echo $row->COL_PRIMARY_KEY; ?>" href="javascript:;"><i class="fas fa-edit"></i> Edit QSO</a></td>
</tr>
<?php } ?>
</table> </table>
</div> </div>
<div class="col"> <div class="col">