111 lines
2.7 KiB
PHP
111 lines
2.7 KiB
PHP
<?php
|
|
namespace Order\Manager;
|
|
|
|
use \Helpers\View as view;
|
|
use \Helpers\dbh;
|
|
use \Order\Listener\ApplicationListener as Listener;
|
|
|
|
class Application
|
|
{
|
|
public $config;
|
|
public $db;
|
|
public $table;
|
|
|
|
public $keyword;
|
|
public $filter;
|
|
|
|
public function __construct($db = NULL,$auth = NULL)
|
|
{
|
|
if(empty($db))
|
|
{
|
|
$this->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($q = NULL)
|
|
{
|
|
$wheresql = array();
|
|
|
|
$wheresql[] = "o.uuid IS NOT NULL";
|
|
|
|
$wheresql[] = '(off.ts_approved is null and off.pdflink is not null and o.status=3)';
|
|
|
|
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 finish($id)
|
|
{
|
|
|
|
}
|
|
|
|
//拒绝
|
|
public function deny($id)
|
|
{
|
|
|
|
}
|
|
|
|
//已经通过的所有申请
|
|
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;
|
|
}
|
|
} |