Skip to content

Commit

Permalink
Merge pull request #68 from BioKIC/master
Browse files Browse the repository at this point in the history
Occurrence Editor
  • Loading branch information
egbot authored Oct 28, 2021
2 parents ab5250d + 16bbee4 commit b8d1002
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions classes/OccurrenceEditorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]):'');
Expand All @@ -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) ';
}
Expand All @@ -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.'<br/>';
$this->sqlWhere = $sqlWhere;
}

Expand Down

0 comments on commit b8d1002

Please sign in to comment.