diff --git a/classes/OccurrenceEditorManager.php b/classes/OccurrenceEditorManager.php index 20288e120b..0abe5579c3 100644 --- a/classes/OccurrenceEditorManager.php +++ b/classes/OccurrenceEditorManager.php @@ -471,6 +471,7 @@ private function setSqlWhere(){ $sqlWhere .= 'AND (exn.ometid = '.$this->qryArr['exsid'].') '; } //Custom search fields + $customWhere = ''; for($x=1;$x<9;$x++){ $cao = (array_key_exists('cao'.$x,$this->qryArr)?$this->cleanInStr($this->qryArr['cao'.$x]):''); $cop = (array_key_exists('cop'.$x,$this->qryArr)?$this->cleanInStr($this->qryArr['cop'.$x]):''); @@ -492,55 +493,56 @@ private function setSqlWhere(){ $cf = 'o.'.$cf; } if($ct=='NULL'){ - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' IS NULL) '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' IS NULL) '.($ccp?$ccp.' ':''); } elseif($ct=='NOTNULL'){ - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' IS NOT NULL) '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' IS NOT NULL) '.($ccp?$ccp.' ':''); } elseif($ct=='NOT EQUALS' && $cv){ if(!is_numeric($cv)) $cv = '"'.$cv.'"'; - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' <> '.$cv.') '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' <> '.$cv.') '.($ccp?$ccp.' ':''); } elseif($ct=='GREATER' && $cv){ if(!is_numeric($cv)) $cv = '"'.$cv.'"'; - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' > '.$cv.') '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' > '.$cv.') '.($ccp?$ccp.' ':''); } elseif($ct=='LESS' && $cv){ if(!is_numeric($cv)) $cv = '"'.$cv.'"'; - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' < '.$cv.') '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' < '.$cv.') '.($ccp?$ccp.' ':''); } elseif($ct=='LIKE' && $cv){ if(strpos($cv,'%') !== false){ - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' LIKE "'.$cv.'") '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' LIKE "'.$cv.'") '.($ccp?$ccp.' ':''); } else{ - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' LIKE "%'.$cv.'%") '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' LIKE "%'.$cv.'%") '.($ccp?$ccp.' ':''); } } elseif($ct=='NOT LIKE' && $cv){ if(strpos($cv,'%') !== false){ - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' NOT LIKE "'.$cv.'") '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' NOT LIKE "'.$cv.'") '.($ccp?$ccp.' ':''); } else{ - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' NOT LIKE "%'.$cv.'%") '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' NOT LIKE "%'.$cv.'%") '.($ccp?$ccp.' ':''); } } elseif($ct=='STARTS' && $cv){ if(strpos($cv,'%') !== false){ - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' LIKE "'.$cv.'") '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' LIKE "'.$cv.'") '.($ccp?$ccp.' ':''); } else{ - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' LIKE "'.$cv.'%") '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' LIKE "'.$cv.'%") '.($ccp?$ccp.' ':''); } } elseif($cv){ - $sqlWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' = "'.$cv.'") '.($ccp?$ccp.' ':''); + $customWhere .= $cao.($cop?' '.$cop:'').' ('.$cf.' = "'.$cv.'") '.($ccp?$ccp.' ':''); } } else if($x > 1 && !$cf && $ccp){ - $sqlWhere .= ' '.$ccp.' '; + $customWhere .= ' '.$ccp.' '; } } + if($customWhere) $sqlWhere .= 'AND ('.substr($customWhere,3).') '; if($this->crowdSourceMode){ $sqlWhere .= 'AND (q.reviewstatus = 0) '; } @@ -551,7 +553,7 @@ private function setSqlWhere(){ if($this->collId) $sqlWhere .= 'AND (o.collid ='.$this->collId.') '; if($sqlWhere) $sqlWhere = 'WHERE '.substr($sqlWhere,4); - //echo $sqlWhere; + //echo $sqlWhere.'
'; $this->sqlWhere = $sqlWhere; }