db = $db; } public function fetchAllOfflineApp($statu=0,$q=""){ $wheresql = array(); if ($statu==4) $wheresql[] = " (o.ts_approved is null and o.pdflink is not null and d.status=4) "; elseif ($statu==-1) $wheresql[] = " (o.pdflink is not null and o.status=-1)"; else $wheresql[] = " (o.ts_approved is null and o.pdflink is not null and d.status in (3,4))"; if(!empty($q)) { $wheresql[] = " (o.username LIKE '%$q%' OR o.unit LIKE '%$q%' OR o.project LIKE '%$q%' OR o.address LIKE '%$q%') "; } if(count($wheresql)>0) { $wheresql = " WHERE ".join(" AND ",$wheresql); }else{ $wheresql = ""; } $sql = "select distinct(o.*),d.status as datastatus from ".$this->tbl_Offlineapp." o left join ".$this->tbl_Dataorder." d on o.id = d.offlineappid $wheresql order by o.ts_created desc"; $rs = $this->db->query($sql); $rows = $rs->fetchAll(); return $rows; } }