$empty_search = false;
$search_fields = false;
- $this->table = GLM_MEMBERS_OBITS_PLUGIN_DB_PREFIX . 'obits';
+ $this->table = GLM_MEMBERS_OBITS_PLUGIN_DB_PREFIX . 'obits';
- $view = 'search';
- $placeholders = array('Last Name', 'First Middle', 'Birth Year', 'Death Year', 'Maiden or Other Name', 'Spouse or Partner Name');
+ $view = 'search';
+ $placeholders = array('Last Name', 'First Middle', 'Birth Year', 'Death Year', 'Maiden or Other Name', 'Spouse or Partner Name');
$year_ranges = new glmObitSupportFunctions($this->wpdb, $this->config);
$birth_death_range = array('birth' => $year_ranges->getObitYearRange(BIRTH_YEAR_START), 'death' => $year_ranges->getObitYearRange(DEATH_YEAR_START));
$logic_dropdown = array('Contains' => 'LIKE' ,'Starts With' => 'LIKE%','Equals' => '=', 'More than' => '>', 'Less than' => '<');
- $per_page = isset( $_REQUEST['results-limit']) ? (int)filter_var( $_REQUEST['results-limit'], FILTER_SANITIZE_STRING) : 50;
+ $per_page = isset( $_REQUEST['results-limit']) ? (int)filter_var( $_REQUEST['results-limit'], FILTER_SANITIZE_STRING) : 50;
// only execute search if the search button is clicked or there are search params in the url
if ( isset( $_REQUEST['searchButton'] ) || !empty( $_GET['alpha'] ) || !empty( $_GET['pageSelect'] ) ){
$clause = ' OR ';
} else if ( isset( $_REQUEST['conditions'] ) && $_REQUEST['conditions'][0] == 'all') {
$clause = ' AND ';
+ } else if( isset( $_REQUEST['clause'] ) && $_REQUEST['clause'] == 'OR'){
+ $clause = ' OR ';
+ } else if( isset( $_REQUEST['clause'] ) && $_REQUEST['clause'] == 'AND' ) {
+ $clause = ' AND ';
+ }else {
+ $clause = ' AND ';
}
// separate the search fields from the logic ('not', 'contains, 'equals') etc.
if($value !== ''){
$where .= "$key LIKE '%$value%' $clause ";
}
-
}
// remove the last AND or OR statement from the query string
-// $where = substr($where, 0, -5);
+ if ($clause === ' AND '){
+ $where = substr($where, 0, -5);
+ } else {
+ $where = substr($where, 0, -4);
+ }
+
} else {
$start = $newStart;
}
}
-
+
$obits = $this->getList($where, 'last_name', $fieldVals = true, $idField = 'id', $start, $per_page);
- echo $where;
+
$returned = $obits['returned'];
// Get paging results
<!-- {include file='front/obits/search.html'}-->
<div class="search-container sidebar-container row">
<div class="small-12 columns">
- <input class="sidebar-criteria" type="radio" {if $clause == ' AND '}checked {/if} value="all" name="conditions[]">All
- <input class="sidebar-criteria" type="radio" {if $clause == ' OR '}checked {/if} value="any" name="conditions[]">Any
+ <input class="sidebar-criteria" type="radio" {if $clause == 'AND'}checked {/if} value="all" name="conditions[]">All
+ <input class="sidebar-criteria" type="radio" {if $clause == 'OR'}checked {/if} value="any" name="conditions[]">Any
<a href="#" class="expand-collapse">Show Options</a>