db = \Zend_Registry::get('db'); $this->config = \Zend_Registry::get('config'); $Listener = new ManagerListener(); @$this->events()->attachAggregate($Listener); } 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; } /************* status: 1 开始进入离线申请申请程序中 2 填写并提交离线申请表 3 邮寄离线申请表 4 收到离线申请表 5 处理离线申请表 10:离线申请完成? -1: 取消了在线下载进程 **************/ //接收 public function receive($id) { if(empty($id) || !is_numeric($id)) { return "参数错误"; } $sql="update dataorder set status=4,ts_received=now() where offlineappid=$id"; if($this->db->exec($sql) > 0) { @$this->db->exec("UPDATE offlineapp SET status=4,ts_received=now() WHERE id=$id"); @$this->events()->trigger('offlineapp.received', $this, compact('id')); return true; }else{ return "接收失败,请重试"; } } //获取一个申请的详细信息 public function getOneAppInfo($id) { $sql = "SELECT off.*,o.status,o.applicationform FROM offlineapp off LEFT JOIN dataorder o ON off.id=o.offlineappid WHERE off.id = $id "; $rs = $this->db->query($sql); return $rs->fetchAll(); }// //重置申请表 public function resetAppForm($id) { $sql = "SELECT * FROM dataorder WHERE offlineappid=$id"; $rs = $this->db->query($sql); $rows = $rs->fetchAll(); $ids = array(); foreach($rows as $v) { $ids[] = $v['id']; } if(file_exists($rows[0]['applicationform'])) { @unlink($rows[0]['applicationform']); } if($this->db->exec("UPDATE dataorder SET applicationform=NULL WHERE offlineappid=$id")>0) { @$this->events()->trigger('offlineapp.AppFormReseted', $this, compact('id')); return true; }else{ return "重置遇到问题,请重试"; } } //提交给作者的时候需要处理的内容 public function sendToAuthor() { } /////////////////////////////////////////// public function offLineAppMakeQuery($opt) { $def = array( 'field' => ' off.*,o.id as orderid,o.status,o.applicationform,u.realname,u.username,md.title ', 'table' => ' dataorder o ', 'join' => ' LEFT JOIN offlineapp off ON off.id=o.offlineappid LEFT JOIN users u ON u.id = off.userid LEFT JOIN metadata md ON md.uuid=o.uuid', 'order' => ' o.id DESC ' ); return array_merge($def,$opt); } public function fetchNotReceived() { $opt = $this->offLineAppMakeQuery(array( 'where' => ' o.offlineappid != -1 AND o.status=3' )); $dbh = new dbh(); //echo $dbh->select($opt,true);exit(); return $dbh->select($opt); }//未接受的 public function fetchNoPdf() { $opt = $this->offLineAppMakeQuery(array( 'where' => ' o.offlineappid != -1 AND o.status=4 AND (o.applicationform IS NULL OR o.applicationform=\'\') ' )); $dbh = new dbh(); //echo $dbh->select($opt,true);exit(); return $dbh->select($opt); }//没有pdf的 public function fetchNotApprove() { $opt = $this->offLineAppMakeQuery(array( 'where' => ' o.offlineappid != -1 AND o.status=4 AND (o.applicationform IS NOT NULL || o.applicationform!=\'\') ' )); $dbh = new dbh(); return $dbh->select($opt); }//待审核 }