module."/search'> searchTerm != '')?'value="'.$this->searchTerm.'"':'')."> "; $highlight = array(); if($this->searchTerm != ''){ $str .= "Delete Client "; foreach($this->getSearchTerms() as $term){ $highlight[] = "$('table').highlight('".$term."');"; } } $str .= ""; $str .= ""; return $str; } public function setModule($m){ $this->module = $m; } public function setSearchTerm($search){ $this->searchTerm = trim($search); $parts = explode(" ",$this->searchTerm); foreach($parts as $search){ if(stristr($search,":") && preg_match('/^[a-z_A-Z]+$/',$search) >= 0){ $key = substr($search,0,strpos($search,":")); $value = substr($search,strpos($search,":")+1); $searcha[$key] = $value; } else{ $searchb[] = $search; } } $this->searcha = $searcha; $this->searchb = $searchb; #print_a($searcha,$searchb); } public function getSearchTerm(){ return $this->searchTerm; } public function getSearchTerms(){ $beta = $this->searcha; foreach($this->searchb as $b) $beta[] = $b; return $beta; } public function search($array){ foreach($array as $counter => $cig){ if(is_object($cig)){ $cig = $cig->toArray(); } foreach($cig as $k => $v){ if(count($this->searcha) > 0){ foreach($this->searcha as $sk => $sv){ if($k == $sk){ if(stristr($v,$sv)){ $com1[] = $counter; } } } } if(count($searchb) >= 0){ foreach($this->searchb as $sk => $sv){ $comm = stristr($v,$sv); if($comm != false){ $com2[] = $counter; break; } } } } } if (count($this->searcha) == 0){ $data = $com2; } if (count($this->searchb) == 0){ $data = $com1; } if (count($this->searcha) > 0 && count($this->searchb) > 0){ $data = array_intersect($com1,$com2); } $data = array_unique($data); foreach( $data as $c) $ges[] = $array[$c]; return $ges; } }