db = \Zend_Registry::get('db'); }else{ $this->db = $db; } $this->config = \Zend_Registry::get('config'); $Listener = new Listener(); @$this->events()->attachAggregate($Listener); $this->table = new \Helpers\Table(); } public function events(\Zend_EventManager_EventCollection $events = NULL) { if ($events !== NULL) { $this->events = $events; } elseif ($this->events === NULL) { $this->events = new \Zend_EventManager_EventManager(__CLASS__); } return $this->events; } //逐数据申请列表 public function fetchByData($statu = 0 , $q = NULL) { $wheresql = array(); $wheresql[] = "o.uuid IS NOT NULL"; if ($statu==4) $wheresql[] = " (off.ts_approved is null and off.pdflink is not null and o.status=4) "; elseif ($statu==-1) $wheresql[] = " (off.pdflink is not null and o.status=-1)"; elseif ($statu == 3) $wheresql[] = " (off.applicationform is not null and o.status=3 ) "; elseif ($statu == 5) $wheresql[] = " (off.status=5) "; else $wheresql[] = " (off.ts_approved is null and off.pdflink is not null and o.status in (3,4))"; if(!empty($q)) { $wheresql[] = " (off.username LIKE '%$q%' OR off.unit LIKE '%$q%' OR off.project LIKE '%$q%' OR off.address LIKE '%$q%' OR md.title LIKE '%$q%') "; } $wheresql = join(" AND ",$wheresql); $sql = "SELECT o.*,o.status as datastatus, md.title,u.username, off.unit,off.address,off.postcode,off.project,off.project_title ,off.project_type,off.project_id,off.datalist FROM dataorder o LEFT JOIN {$this->config->sub->metadata} md ON o.uuid=md.uuid LEFT JOIN users u ON u.id = o.userid LEFT JOIN offlineapp off ON o.offlineappid = off.id WHERE $wheresql"; $rs = $this->db->query($sql); return $rs->fetchAll(); } //已经通过的所有申请 public function passed() { $select=$this->db->select(); $select ->from('offlineapp') ->where('ts_approved is not null') ->where('pdflink is not null') ->where('status>=0') ->where('id in (select offlineappid from dataorder where uuid in (select uuid from'.$this->config->sub->metadata.'))') ->order('ts_created desc'); if(!empty($this->keyword)) { $select ->where(" (username LIKE '%{$this->keyword}%' OR unit LIKE '%{$this->keyword}%' OR project_id LIKE '%{$this->keyword}%' OR project_type LIKE '%{$this->keyword}%' OR project_leader LIKE '%{$this->keyword}%' OR project LIKE '%{$this->keyword}%' )"); } return $select; } }