调整场所默认按照地址排序

This commit is contained in:
cloud 2020-07-08 21:13:43 +08:00
parent aafced32ac
commit 8e99421a15
2 changed files with 871 additions and 837 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7,78 +7,79 @@
trait tdata { trait tdata {
//sql语句采用分组查询后调整为true 使用子查询计算总条数 //sql语句采用分组查询后调整为true 使用子查询计算总条数
public $multi_table = false; public $multi_table = false;
//搜索的input字段用来处理表数据显示时的颜色加重问题 //搜索的input字段用来处理表数据显示时的颜色加重问题
private $search_input = []; private $search_input = [];
//搜索的select字段不用考虑搜索结果 //搜索的select字段不用考虑搜索结果
private $search_other = []; private $search_other = [];
//带有表前缀的搜索字段,主要用于跨表联合查询,要对照上面数组合并后的顺序 //带有表前缀的搜索字段,主要用于跨表联合查询,要对照上面数组合并后的顺序
private $search_field = []; private $search_field = [];
//搜索的LIKE字段 //搜索的LIKE字段
private $search_link = []; private $search_link = [];
//跳过替换为突出显示的字段 //跳过替换为突出显示的字段
private $skip_field = []; private $skip_field = [];
// 场所统计查询内的公用where // 场所统计查询内的公用where
private $villages_where = ''; private $villages_where = '';
//表名 //表名
public function td_sqlk() { public function td_sqlk() {
global $_M,$_YW; global $_M, $_YW;
//当天日期时间 //当天日期时间
$curdate = date('Y-m-d',time()); $curdate = date('Y-m-d', time());
switch ($this->tname) { switch ($this->tname) {
case 'applan': case 'applan':
//判断是否可选的依据 //判断是否可选的依据
if(!empty($this->form['slid'])) $where = " AND nla.id != '{$this->form['slid']}' "; if (!empty($this->form['slid']))
$where = " AND nla.id != '{$this->form['slid']}' ";
//表 //表
$sqlk = " {$_YW['k']['elevator']} AS el " $sqlk = " {$_YW['k']['elevator']} AS el "
. "LEFT JOIN (SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nowe_number,ANY_VALUE( nla.id ) AS nowid,ANY_VALUE( nla.l_title ) AS nowtitle,ANY_VALUE( nla.l_starttime ) AS nowstime,ANY_VALUE( nla.l_endtime ) AS nowetime,if(NOT ( nla.l_endtime < '{$curdate}' OR nla.l_starttime > '{$curdate}' ) OR nla.l_starttime > '{$curdate}',1,0) AS estate FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE NOT ( nla.l_endtime < '{$curdate}' OR nla.l_starttime > '{$curdate}' ) AND nla.id IS NOT NULL ORDER BY nowstime ASC ) eala GROUP BY nowe_number ) ala ON ala.nowe_number = el.e_number " . "LEFT JOIN (SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nowe_number,ANY_VALUE( nla.id ) AS nowid,ANY_VALUE( nla.l_title ) AS nowtitle,ANY_VALUE( nla.l_starttime ) AS nowstime,ANY_VALUE( nla.l_endtime ) AS nowetime,if(NOT ( nla.l_endtime < '{$curdate}' OR nla.l_starttime > '{$curdate}' ) OR nla.l_starttime > '{$curdate}',1,0) AS estate FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE NOT ( nla.l_endtime < '{$curdate}' OR nla.l_starttime > '{$curdate}' ) AND nla.id IS NOT NULL ORDER BY nowstime ASC ) eala GROUP BY nowe_number ) ala ON ala.nowe_number = el.e_number "
. "LEFT JOIN (SELECT nel.e_number AS ende_number, max( nla.l_endtime ) AS endtime FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.id IS NOT NULL GROUP BY ende_number) cla ON cla.ende_number = el.e_number " . "LEFT JOIN (SELECT nel.e_number AS ende_number, max( nla.l_endtime ) AS endtime FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.id IS NOT NULL GROUP BY ende_number) cla ON cla.ende_number = el.e_number "
. "LEFT JOIN ( SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nexte_number,ANY_VALUE( nla.id ) AS nextid,ANY_VALUE( nla.l_title ) AS nexttitle,ANY_VALUE( nla.l_starttime ) AS nextstime,ANY_VALUE( nla.l_endtime ) AS nextetime FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.l_starttime > '{$curdate}' AND nla.id IS NOT NULL ORDER BY nextstime ASC ) eala GROUP BY nexte_number ) bla ON bla.nexte_number = el.e_number " . "LEFT JOIN ( SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nexte_number,ANY_VALUE( nla.id ) AS nextid,ANY_VALUE( nla.l_title ) AS nexttitle,ANY_VALUE( nla.l_starttime ) AS nextstime,ANY_VALUE( nla.l_endtime ) AS nextetime FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.l_starttime > '{$curdate}' AND nla.id IS NOT NULL ORDER BY nextstime ASC ) eala GROUP BY nexte_number ) bla ON bla.nexte_number = el.e_number "
. "LEFT JOIN (SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nend_number,ANY_VALUE( nla.id ) AS endid,ANY_VALUE( nla.l_title ) AS endtitle,ANY_VALUE( nla.l_starttime ) AS endstime,ANY_VALUE( nla.l_endtime ) AS endetime FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.l_endtime < '{$curdate}' AND nla.id IS NOT NULL ORDER BY endetime DESC ) eala GROUP BY nend_number ) dla ON dla.nend_number = el.e_number " . "LEFT JOIN (SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nend_number,ANY_VALUE( nla.id ) AS endid,ANY_VALUE( nla.l_title ) AS endtitle,ANY_VALUE( nla.l_starttime ) AS endstime,ANY_VALUE( nla.l_endtime ) AS endetime FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.l_endtime < '{$curdate}' AND nla.id IS NOT NULL ORDER BY endetime DESC ) eala GROUP BY nend_number ) dla ON dla.nend_number = el.e_number "
. "LEFT JOIN (SELECT nel.e_number AS lde_number,count(nel.e_number) AS lanum FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE NOT ( nla.l_endtime < '{$this->form['l_starttime']}' OR nla.l_starttime > '{$this->form['l_endtime']}' ) {$where} GROUP BY lde_number) AS ela ON ela.lde_number = el.e_number "; . "LEFT JOIN (SELECT nel.e_number AS lde_number,count(nel.e_number) AS lanum FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE NOT ( nla.l_endtime < '{$this->form['l_starttime']}' OR nla.l_starttime > '{$this->form['l_endtime']}' ) {$where} GROUP BY lde_number) AS ela ON ela.lde_number = el.e_number ";
break; break;
case 'elevators': case 'elevators':
$sqlk = " {$_YW['k']['elevator']} AS el LEFT JOIN {$_YW['k']['launch']} AS la ON find_in_set( el.e_number, la.l_enumber ) " $sqlk = " {$_YW['k']['elevator']} AS el LEFT JOIN {$_YW['k']['launch']} AS la ON find_in_set( el.e_number, la.l_enumber ) "
. "LEFT JOIN (SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nowe_number,ANY_VALUE( nla.id ) AS nowid,ANY_VALUE( nla.l_title ) AS nowtitle,ANY_VALUE( nla.l_starttime ) AS nowstime,ANY_VALUE( nla.l_endtime ) AS nowetime,if(NOT ( nla.l_endtime < '{$curdate}' OR nla.l_starttime > '{$curdate}' ) OR nla.l_starttime > '{$curdate}',1,0) AS estate FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE NOT ( nla.l_endtime < '{$curdate}' OR nla.l_starttime > '{$curdate}' ) AND nla.id IS NOT NULL ORDER BY nowstime ASC ) eala GROUP BY nowe_number ) ala ON ala.nowe_number = el.e_number " . "LEFT JOIN (SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nowe_number,ANY_VALUE( nla.id ) AS nowid,ANY_VALUE( nla.l_title ) AS nowtitle,ANY_VALUE( nla.l_starttime ) AS nowstime,ANY_VALUE( nla.l_endtime ) AS nowetime,if(NOT ( nla.l_endtime < '{$curdate}' OR nla.l_starttime > '{$curdate}' ) OR nla.l_starttime > '{$curdate}',1,0) AS estate FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE NOT ( nla.l_endtime < '{$curdate}' OR nla.l_starttime > '{$curdate}' ) AND nla.id IS NOT NULL ORDER BY nowstime ASC ) eala GROUP BY nowe_number ) ala ON ala.nowe_number = el.e_number "
. "LEFT JOIN ( SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nexte_number,ANY_VALUE( nla.id ) AS nextid,ANY_VALUE( nla.l_title ) AS nexttitle,ANY_VALUE( nla.l_starttime ) AS nextstime,ANY_VALUE( nla.l_endtime ) AS nextetime FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.l_starttime > '{$curdate}' AND nla.id IS NOT NULL ORDER BY nextstime ASC ) eala GROUP BY nexte_number ) bla ON bla.nexte_number = el.e_number " . "LEFT JOIN ( SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nexte_number,ANY_VALUE( nla.id ) AS nextid,ANY_VALUE( nla.l_title ) AS nexttitle,ANY_VALUE( nla.l_starttime ) AS nextstime,ANY_VALUE( nla.l_endtime ) AS nextetime FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.l_starttime > '{$curdate}' AND nla.id IS NOT NULL ORDER BY nextstime ASC ) eala GROUP BY nexte_number ) bla ON bla.nexte_number = el.e_number "
. "LEFT JOIN (SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nend_number,ANY_VALUE( nla.id ) AS endid,ANY_VALUE( nla.l_title ) AS endtitle,ANY_VALUE( nla.l_starttime ) AS endstime,ANY_VALUE( nla.l_endtime ) AS endetime FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.l_endtime < '{$curdate}' AND nla.id IS NOT NULL ORDER BY endetime DESC ) eala GROUP BY nend_number ) cla ON cla.nend_number = el.e_number "; . "LEFT JOIN (SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nend_number,ANY_VALUE( nla.id ) AS endid,ANY_VALUE( nla.l_title ) AS endtitle,ANY_VALUE( nla.l_starttime ) AS endstime,ANY_VALUE( nla.l_endtime ) AS endetime FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.l_endtime < '{$curdate}' AND nla.id IS NOT NULL ORDER BY endetime DESC ) eala GROUP BY nend_number ) cla ON cla.nend_number = el.e_number ";
break; break;
case 'patrol': case 'patrol':
$sqlk = " {$_YW['k']['elevator']} AS el LEFT JOIN {$_YW['k']['launch']} AS la ON find_in_set( el.e_number, la.l_enumber ) " $sqlk = " {$_YW['k']['elevator']} AS el LEFT JOIN {$_YW['k']['launch']} AS la ON find_in_set( el.e_number, la.l_enumber ) "
. "LEFT JOIN (SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nowe_number,ANY_VALUE( nla.id ) AS nowid,ANY_VALUE( nla.l_title ) AS nowtitle,ANY_VALUE( nla.l_starttime ) AS nowstime,ANY_VALUE( nla.l_endtime ) AS nowetime,if(NOT ( nla.l_endtime < '{$curdate}' OR nla.l_starttime > '{$curdate}' ) OR nla.l_starttime > '{$curdate}',1,0) AS estate FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.l_starttime <= '{$curdate}' AND nla.id IS NOT NULL ORDER BY nowstime DESC ) eala GROUP BY nowe_number ) ala ON ala.nowe_number = el.e_number "; . "LEFT JOIN (SELECT * FROM( SELECT DISTINCT( nel.e_number ) AS nowe_number,ANY_VALUE( nla.id ) AS nowid,ANY_VALUE( nla.l_title ) AS nowtitle,ANY_VALUE( nla.l_starttime ) AS nowstime,ANY_VALUE( nla.l_endtime ) AS nowetime,if(NOT ( nla.l_endtime < '{$curdate}' OR nla.l_starttime > '{$curdate}' ) OR nla.l_starttime > '{$curdate}',1,0) AS estate FROM {$_YW['k']['elevator']} AS nel LEFT JOIN {$_YW['k']['launch']} AS nla ON find_in_set( nel.e_number, nla.l_enumber ) WHERE nla.l_starttime <= '{$curdate}' AND nla.id IS NOT NULL ORDER BY nowstime DESC ) eala GROUP BY nowe_number ) ala ON ala.nowe_number = el.e_number ";
break; break;
case 'villages': case 'villages':
$son = " FROM {$_YW['k']['countela']} AS el WHERE "; $son = " FROM {$_YW['k']['countela']} AS el WHERE ";
//判断执行默认还是时间区段 //判断执行默认还是时间区段
$bool = false; $bool = false;
if($this->form['vs_starttime'] || $this->form['vs_endtime']){ if ($this->form['vs_starttime'] || $this->form['vs_endtime']) {
$bool = true; $bool = true;
$this->form['vs_starttime'] = $this->form['vs_starttime']?:$curdate; $this->form['vs_starttime'] = $this->form['vs_starttime'] ?: $curdate;
$this->form['vs_endtime'] = $this->form['vs_endtime']?:$curdate; $this->form['vs_endtime'] = $this->form['vs_endtime'] ?: $curdate;
if(strtotime($this->form['vs_starttime']) > strtotime($this->form['vs_endtime'])){ if (strtotime($this->form['vs_starttime']) > strtotime($this->form['vs_endtime'])) {
$vs_starttime = $this->form['vs_endtime']; $vs_starttime = $this->form['vs_endtime'];
$vs_endtime = $this->form['vs_starttime']; $vs_endtime = $this->form['vs_starttime'];
}else{ } else {
$vs_starttime = $this->form['vs_starttime']; $vs_starttime = $this->form['vs_starttime'];
$vs_endtime = $this->form['vs_endtime']; $vs_endtime = $this->form['vs_endtime'];
} }
} }
// 计算是否区分广告位 // 计算是否区分广告位
// 检测是否通过JS传递的广告位参数也就是导出 // 检测是否通过JS传递的广告位参数也就是导出
if(isset($this->form['jsadd_veaps'])) $this->form['veaps'] = stringto_array($this->form['jsadd_veaps'],','); if (isset($this->form['jsadd_veaps']))
if(is_array($this->form['veaps'])){ $this->form['veaps'] = stringto_array($this->form['jsadd_veaps'], ',');
$veaps = parent::strchange(array_filter($this->form['veaps'])); if (is_array($this->form['veaps'])) {
$this->villages_where = " el.e_aps IN($veaps) "; $veaps = parent::strchange(array_filter($this->form['veaps']));
$son .= " {$this->villages_where} AND "; $this->villages_where = " el.e_aps IN($veaps) ";
$son .= " {$this->villages_where} AND ";
} }
// 空置计算要排除当前排期中的广告位 // 空置计算要排除当前排期中的广告位
if($bool){ if ($bool) {
//加上时间区块 那就是查看在区段内的情况 //加上时间区块 那就是查看在区段内的情况
//增加 s_enable 判断是为了防止过去时间 //增加 s_enable 判断是为了防止过去时间
//空置 //空置
@ -93,7 +94,7 @@ trait tdata {
$dwhere = " {$son} el.l_endtime BETWEEN '{$vs_starttime}' AND '{$vs_endtime}' "; $dwhere = " {$son} el.l_endtime BETWEEN '{$vs_starttime}' AND '{$vs_endtime}' ";
//预排 //预排
$pwhere = " {$son} NOT(el.l_endtime < '{$vs_starttime}' OR el.l_starttime > '{$vs_endtime}') AND el.l_starttime > '{$curdate}' "; $pwhere = " {$son} NOT(el.l_endtime < '{$vs_starttime}' OR el.l_starttime > '{$vs_endtime}') AND el.l_starttime > '{$curdate}' ";
}else{ } else {
//没有时间区段,则按照当天为准则,默认值 //没有时间区段,则按照当天为准则,默认值
//空置,其他不包含当天的 //空置,其他不包含当天的
$fwhere = " {$son} NOT EXISTS (SELECT ela.e_number FROM {$_YW['k']['countela']} AS ela WHERE NOT ( ela.l_endtime < '{$curdate}' OR ela.l_starttime > '{$curdate}' ) AND ela.e_number = el.e_number) AND (el.l_endtime < '{$curdate}' OR el.l_starttime > '{$curdate}' OR el.l_id IS NULL) AND el.e_enable = 1 "; $fwhere = " {$son} NOT EXISTS (SELECT ela.e_number FROM {$_YW['k']['countela']} AS ela WHERE NOT ( ela.l_endtime < '{$curdate}' OR ela.l_starttime > '{$curdate}' ) AND ela.e_number = el.e_number) AND (el.l_endtime < '{$curdate}' OR el.l_starttime > '{$curdate}' OR el.l_id IS NULL) AND el.e_enable = 1 ";
@ -105,7 +106,7 @@ trait tdata {
$pwhere = " {$son} el.l_starttime > '{$curdate}' "; $pwhere = " {$son} el.l_starttime > '{$curdate}' ";
} }
$sqlk = "{$_YW['k']['village']} AS vi LEFT JOIN {$_YW['k']['elevator']} AS el ON vi.id = el.e_vid " $sqlk = "{$_YW['k']['village']} AS vi LEFT JOIN {$_YW['k']['elevator']} AS el ON vi.id = el.e_vid "
. "LEFT JOIN (SELECT el.e_vid AS ae_vid,COUNT( DISTINCT el.e_number ) AS v_free,COUNT( DISTINCT el.e_vid, el.e_bno ) AS v_bno {$fwhere} GROUP BY ae_vid ) AS anum ON anum.ae_vid = vi.id " . "LEFT JOIN (SELECT el.e_vid AS ae_vid,COUNT( DISTINCT el.e_number ) AS v_free,COUNT( DISTINCT el.e_vid, el.e_bno ) AS v_bno {$fwhere} GROUP BY ae_vid ) AS anum ON anum.ae_vid = vi.id "
. "LEFT JOIN (SELECT el.e_vid AS be_vid,COUNT( DISTINCT el.e_number ) AS v_lease {$lwhere} GROUP BY be_vid ) AS bnum ON bnum.be_vid = vi.id " . "LEFT JOIN (SELECT el.e_vid AS be_vid,COUNT( DISTINCT el.e_number ) AS v_lease {$lwhere} GROUP BY be_vid ) AS bnum ON bnum.be_vid = vi.id "
. "LEFT JOIN (SELECT el.e_vid AS ce_vid,COUNT( DISTINCT el.e_number ) AS v_endday {$dwhere} GROUP BY ce_vid ) AS cnum ON cnum.ce_vid = vi.id " . "LEFT JOIN (SELECT el.e_vid AS ce_vid,COUNT( DISTINCT el.e_number ) AS v_endday {$dwhere} GROUP BY ce_vid ) AS cnum ON cnum.ce_vid = vi.id "
@ -113,17 +114,17 @@ trait tdata {
break; break;
case 'contract': case 'contract':
$sqlk = "{$_YW['k']['contract']} AS ch LEFT JOIN {$_YW['k']['launch']} AS la ON ch.h_number = la.l_hnumber "; $sqlk = "{$_YW['k']['contract']} AS ch LEFT JOIN {$_YW['k']['launch']} AS la ON ch.h_number = la.l_hnumber ";
break; break;
case 'schedule': case 'schedule':
$sqlk = "{$_YW['k']['elevator']} AS el LEFT JOIN {$_YW['k']['launch']} AS la ON find_in_set( el.e_number, la.l_enumber ) LEFT JOIN {$_YW['k']['contract']} AS ct ON la.l_hnumber = ct.h_number"; $sqlk = "{$_YW['k']['elevator']} AS el LEFT JOIN {$_YW['k']['launch']} AS la ON find_in_set( el.e_number, la.l_enumber ) LEFT JOIN {$_YW['k']['contract']} AS ct ON la.l_hnumber = ct.h_number";
break; break;
case 'village': case 'village':
$sqlk = "{$_YW['k']['village']} AS vi LEFT JOIN {$_YW['k']['elevator']} AS el ON vi.id = el.e_vid "; $sqlk = "{$_YW['k']['village']} AS vi LEFT JOIN {$_YW['k']['elevator']} AS el ON vi.id = el.e_vid ";
break; break;
default: default:
$sqlk = $_YW['k'][$this->tname]; $sqlk = $_YW['k'][$this->tname];
break; break;
} }
return $sqlk; return $sqlk;
@ -131,7 +132,7 @@ trait tdata {
//字段 //字段
public function td_field() { public function td_field() {
global $_M,$_YW; global $_M, $_YW;
switch ($this->tname) { switch ($this->tname) {
case 'applan': case 'applan':
$field = '*'; $field = '*';
@ -166,242 +167,248 @@ trait tdata {
* 【列出】 * 【列出】
* 同时满足条件的非OR * 同时满足条件的非OR
*/ */
public function td_search($link = true) { public function td_search($link = true) {
global $_M,$_YW; global $_M, $_YW;
//默认input字段为link搜索 //默认input字段为link搜索
if($link) $this->search_link = array_unique(array_merge($this->search_input,$this->search_link)); if ($link)
$this->search_link = array_unique(array_merge($this->search_input, $this->search_link));
//合成得带搜索字段 //合成得带搜索字段
$field = array_unique(array_merge($this->search_input,$this->search_other)); $field = array_unique(array_merge($this->search_input, $this->search_other));
//判断是否为链表查询 //判断是否为链表查询
$join_field = array_combine($field,count($this->search_field) > 0?$this->search_field:$field); $join_field = array_combine($field, count($this->search_field) > 0 ? $this->search_field : $field);
//相对独立的搜索 //相对独立的搜索
$arrwhere = []; $arrwhere = [];
foreach ($field as $val) { foreach ($field as $val) {
$search = trim(strtoupper($this->form[$val])); $search = trim(strtoupper($this->form[$val]));
if(strlen($search) > 0) { if (strlen($search) > 0) {
$str = $join_field[$val]; $str = $join_field[$val];
if(in_array($val, $this->search_link)){ if (in_array($val, $this->search_link)) {
$arrwhere[] = " {$str} LIKE '%{$search}%' "; $arrwhere[] = " {$str} LIKE '%{$search}%' ";
continue; continue;
} }
$arrwhere[] = " {$str} = '{$search}' "; $arrwhere[] = " {$str} = '{$search}' ";
} }
} }
//返回内容 //返回内容
$where = ''; $where = '';
if(count($arrwhere) > 0){ if (count($arrwhere) > 0) {
$where = ' AND '; $where = ' AND ';
$where .= arrayto_string($arrwhere,' AND '); $where .= arrayto_string($arrwhere, ' AND ');
} }
return $where; return $where;
} }
//OR 内容搜索 //OR 内容搜索
public function td_search_or($orfield,$search_field = []) { public function td_search_or($orfield, $search_field = []) {
global $_M,$_YW; global $_M, $_YW;
//判断是否为链表查询 //判断是否为链表查询
$join_field = array_combine($orfield,count($search_field) > 0?$search_field:$orfield); $join_field = array_combine($orfield, count($search_field) > 0 ? $search_field : $orfield);
//相对独立的搜索 //相对独立的搜索
$arrwhere = []; $arrwhere = [];
foreach ($orfield as $val) { foreach ($orfield as $val) {
$search = trim(strtoupper($this->form[$val])); $search = trim(strtoupper($this->form[$val]));
if(strlen($search) > 0) { if (strlen($search) > 0) {
$str = $join_field[$val]; $str = $join_field[$val];
if(in_array($val, $this->search_link)){ if (in_array($val, $this->search_link)) {
$arrwhere[] = " {$str} LIKE '%{$search}%' "; $arrwhere[] = " {$str} LIKE '%{$search}%' ";
continue; continue;
} }
$arrwhere[] = " {$str} = '{$search}' "; $arrwhere[] = " {$str} = '{$search}' ";
} }
} }
//返回内容 //返回内容
$where = ''; $where = '';
if(count($arrwhere) > 0){ if (count($arrwhere) > 0) {
$where .= arrayto_string($arrwhere,' OR '); $where .= arrayto_string($arrwhere, ' OR ');
} }
return strlen($where) > 0 ?" AND ({$where}) ":''; return strlen($where) > 0 ? " AND ({$where}) " : '';
} }
//时间区间 //时间区间
public function td_time_search($field,$search_field = []) { public function td_time_search($field, $search_field = []) {
global $_M,$_YW; global $_M, $_YW;
list($start,$end) = $field; list($start, $end) = $field;
//判断是否为链表查询 //判断是否为链表查询
$join_field = array_combine($field,count($search_field) > 0?$search_field:$field); $join_field = array_combine($field, count($search_field) > 0 ? $search_field : $field);
//相对独立的搜索 //相对独立的搜索
$arrwhere = []; $arrwhere = [];
foreach ($field as $val) { foreach ($field as $val) {
$search = trim(strtoupper($this->form[$val])); $search = trim(strtoupper($this->form[$val]));
if(strlen($search) > 0) { if (strlen($search) > 0) {
$str = $join_field[$val]; $str = $join_field[$val];
if($val == $start){ if ($val == $start) {
$arrwhere[] = " {$str} >= '{$search}' "; $arrwhere[] = " {$str} >= '{$search}' ";
}else{ } else {
$arrwhere[] = " {$str} <= '{$search}' "; $arrwhere[] = " {$str} <= '{$search}' ";
} }
} }
} }
//返回内容 //返回内容
$where = ''; $where = '';
if(count($arrwhere) > 0){ if (count($arrwhere) > 0) {
$where .= arrayto_string($arrwhere," AND "); $where .= arrayto_string($arrwhere, " AND ");
} }
return strlen($where) > 0 ?" AND ({$where}) ":''; return strlen($where) > 0 ? " AND ({$where}) " : '';
} }
//获取重叠的时间区间 //获取重叠的时间区间
// $search_field 开始时间和结束时间的字段互相调换,结束的字段在前面 // $search_field 开始时间和结束时间的字段互相调换,结束的字段在前面
public function td_time_orsearch($field,$search_field = []) { public function td_time_orsearch($field, $search_field = []) {
global $_M,$_YW; global $_M, $_YW;
list($start,$end) = $field; list($start, $end) = $field;
//判断是否为链表查询 //判断是否为链表查询
$join_field = array_combine($field,count($search_field) > 0?$search_field:$field); $join_field = array_combine($field, count($search_field) > 0 ? $search_field : $field);
//相对独立的搜索 //相对独立的搜索
$arrwhere = []; $arrwhere = [];
foreach ($field as $val) { foreach ($field as $val) {
$search = trim(strtoupper($this->form[$val])); $search = trim(strtoupper($this->form[$val]));
if(strlen($search) > 0) { if (strlen($search) > 0) {
$str = $join_field[$val]; $str = $join_field[$val];
if($val == $start){ if ($val == $start) {
$arrwhere[] = " {$str} < '{$search}' "; //结束字段,搜索为开始时间 $arrwhere[] = " {$str} < '{$search}' "; //结束字段,搜索为开始时间
}else{ } else {
$arrwhere[] = " {$str} > '{$search}' "; //开始字段,搜索为结束时间 $arrwhere[] = " {$str} > '{$search}' "; //开始字段,搜索为结束时间
} }
} }
} }
//返回内容 //返回内容
$where = ''; $where = '';
if(count($arrwhere) > 0){ if (count($arrwhere) > 0) {
$where .= arrayto_string($arrwhere," OR "); $where .= arrayto_string($arrwhere, " OR ");
} }
return strlen($where) > 0 ?" AND NOT({$where}) ":''; return strlen($where) > 0 ? " AND NOT({$where}) " : '';
} }
/* /*
* 【列出】 * 【列出】
* SQL判断语句$where .= $this->search(); * SQL判断语句$where .= $this->search();
*/ */
public function td_where() { public function td_where() {
global $_M,$_YW; global $_M, $_YW;
$where = " 1=1 "; $where = " 1=1 ";
switch ($this->tname) { switch ($this->tname) {
case 'applan': case 'applan':
$this->search_input = ['e_number']; $this->search_input = ['e_number'];
$this->search_other = ['e_bno','e_vid','e_enable']; $this->search_other = ['e_bno', 'e_vid', 'e_enable'];
$where .= self::td_search(); $where .= self::td_search();
if(is_array($this->form['e_aps'])) { if (is_array($this->form['e_aps'])) {
// 不考虑导出的情况 // 不考虑导出的情况
$veaps = parent::strchange(array_filter($this->form['e_aps'])); $veaps = parent::strchange(array_filter($this->form['e_aps']));
$where .= " AND e_aps IN($veaps) "; $where .= " AND e_aps IN($veaps) ";
} }
break; break;
case 'elevators': case 'elevators':
$this->search_input = ['e_number']; $this->search_input = ['e_number'];
$this->search_other = ['e_aps','e_bno','e_vid','e_enable','endid','nowid','nextid']; $this->search_other = ['e_aps', 'e_bno', 'e_vid', 'e_enable', 'endid', 'nowid', 'nextid'];
$this->search_field = ['el.e_number','el.e_aps','el.e_bno','el.e_vid','el.e_enable','cla.endid','ala.nowid','bla.nextid']; $this->search_field = ['el.e_number', 'el.e_aps', 'el.e_bno', 'el.e_vid', 'el.e_enable', 'cla.endid', 'ala.nowid', 'bla.nextid'];
$where .= self::td_search(); $where .= self::td_search();
//判断是否为备份 //判断是否为备份
if($this->bsign) parent::where_id($where); if ($this->bsign)
parent::where_id($where);
self::td_groupby($where); self::td_groupby($where);
break; break;
case 'patrol': case 'patrol':
$this->search_input = ['e_number']; $this->search_input = ['e_number'];
$this->search_other = ['e_aps','e_bno','e_vid','e_enable','nowid','l_hnumber']; $this->search_other = ['e_aps', 'e_bno', 'e_vid', 'e_enable', 'nowid', 'l_hnumber'];
$this->search_field = ['el.e_number','el.e_aps','el.e_bno','el.e_vid','el.e_enable','ala.nowid','la.l_hnumber']; $this->search_field = ['el.e_number', 'el.e_aps', 'el.e_bno', 'el.e_vid', 'el.e_enable', 'ala.nowid', 'la.l_hnumber'];
$where .= self::td_search(); $where .= self::td_search();
//不看空位 //不看空位
$where .= " AND ala.nowid IS NOT NULL "; $where .= " AND ala.nowid IS NOT NULL ";
self::td_groupby($where); self::td_groupby($where);
break; break;
case 'elevator': case 'elevator':
$this->search_input = ['e_number','e_label','e_text']; $this->search_input = ['e_number', 'e_label', 'e_text'];
$this->search_other = ['e_aps','e_bno','e_vid','e_enable']; $this->search_other = ['e_aps', 'e_bno', 'e_vid', 'e_enable'];
$where .= self::td_search(); $where .= self::td_search();
case 'village': case 'village':
$this->search_input = ['v_name','v_text']; $this->search_input = ['v_name', 'v_text'];
$where .= self::td_search(); $where .= self::td_search();
$this->search_link = ['v_province','v_city','v_district','v_address']; $this->search_link = ['v_province', 'v_city', 'v_district', 'v_address'];
$this->search_field = ['vi.v_name','vi.v_text','vi.v_province','vi.v_city','vi.v_district','vi.v_address']; $this->search_field = ['vi.v_name', 'vi.v_text', 'vi.v_province', 'vi.v_city', 'vi.v_district', 'vi.v_address'];
$this->form['v_province'] = $this->form['v_address']; $this->form['v_province'] = $this->form['v_address'];
$this->form['v_city'] = $this->form['v_address']; $this->form['v_city'] = $this->form['v_address'];
$this->form['v_district'] = $this->form['v_address']; $this->form['v_district'] = $this->form['v_address'];
$where .= self::td_search_or($this->search_link,['vi.v_province','vi.v_city','vi.v_district','vi.v_address']); $where .= self::td_search_or($this->search_link, ['vi.v_province', 'vi.v_city', 'vi.v_district', 'vi.v_address']);
self::td_groupby($where); self::td_groupby($where);
break; break;
case 'customer': case 'customer':
$this->search_input = ['c_text']; $this->search_input = ['c_text'];
$this->search_link = ['c_allname','c_name','c_province','c_city','c_district','c_address']; $this->search_link = ['c_allname', 'c_name', 'c_province', 'c_city', 'c_district', 'c_address'];
//名称 //名称
$this->form['c_name'] = $this->form['c_allname']; $this->form['c_name'] = $this->form['c_allname'];
$where .= self::td_search_or(['c_allname','c_name']); $where .= self::td_search_or(['c_allname', 'c_name']);
//地址 //地址
$this->form['c_province'] = $this->form['c_address']; $this->form['c_province'] = $this->form['c_address'];
$this->form['c_city'] = $this->form['c_address']; $this->form['c_city'] = $this->form['c_address'];
$this->form['c_district'] = $this->form['c_address']; $this->form['c_district'] = $this->form['c_address'];
$where .= self::td_search_or(['c_province','c_city','c_district','c_address']); $where .= self::td_search_or(['c_province', 'c_city', 'c_district', 'c_address']);
$where .= self::td_search(); $where .= self::td_search();
break; break;
case 'workers': case 'workers':
$this->search_input = ['w_name','w_tel','w_text']; $this->search_input = ['w_name', 'w_tel', 'w_text'];
$where .= self::td_search(); $where .= self::td_search();
break; break;
case 'contract': case 'contract':
$this->search_input = ['h_number','h_text']; $this->search_input = ['h_number', 'h_text'];
$this->search_other = ['h_cid','h_wid']; $this->search_other = ['h_cid', 'h_wid'];
$this->search_link = ['h_wid']; $this->search_link = ['h_wid'];
$this->search_field = ['ch.h_number','ch.h_text','ch.h_cid','ch.h_wid']; $this->search_field = ['ch.h_number', 'ch.h_text', 'ch.h_cid', 'ch.h_wid'];
$where .= self::td_time_orsearch(['h_starttime','h_endtime'],['ch.h_endtime','ch.h_starttime']); $where .= self::td_time_orsearch(['h_starttime', 'h_endtime'], ['ch.h_endtime', 'ch.h_starttime']);
$where .= self::td_search(); $where .= self::td_search();
self::td_groupby($where); self::td_groupby($where);
break; break;
case 'para': case 'para':
$this->search_other = ['p_type']; $this->search_other = ['p_type'];
$where .= self::td_search(); $where .= self::td_search();
break; break;
case 'launch': case 'launch':
$this->search_input = ['l_title','l_enumber','l_text']; $this->search_input = ['l_title', 'l_enumber', 'l_text'];
$this->search_other = ['l_hnumber']; $this->search_other = ['l_hnumber'];
$where .= self::td_time_orsearch(['l_starttime','l_endtime'],['l_endtime','l_starttime']); $where .= self::td_time_orsearch(['l_starttime', 'l_endtime'], ['l_endtime', 'l_starttime']);
$where .= self::td_search(); $where .= self::td_search();
break; break;
case 'villages': case 'villages':
$this->search_input = ['v_name','v_text']; $this->search_input = ['v_name', 'v_text'];
$this->search_link = ['v_province','v_city','v_district','v_address']; $this->search_link = ['v_province', 'v_city', 'v_district', 'v_address'];
$this->form['v_province'] = $this->form['v_address']; $this->form['v_province'] = $this->form['v_address'];
$this->form['v_city'] = $this->form['v_address']; $this->form['v_city'] = $this->form['v_address'];
$this->form['v_district'] = $this->form['v_address']; $this->form['v_district'] = $this->form['v_address'];
if(is_array($this->form['veaps'])) $where .= " AND {$this->villages_where} "; if (is_array($this->form['veaps']))
$where .= " AND {$this->villages_where} ";
$where .= self::td_search_or($this->search_link); $where .= self::td_search_or($this->search_link);
$where .= self::td_search(); $where .= self::td_search();
//判断是否为备份 //判断是否为备份
if($this->bsign) parent::where_id($where); if ($this->bsign)
parent::where_id($where);
self::td_groupby($where); self::td_groupby($where);
break; break;
case 'schedule': case 'schedule':
$where .= " AND la.id IS NOT NULL "; $where .= " AND la.id IS NOT NULL ";
$this->search_input = ['e_number','l_hnumber']; $this->search_input = ['e_number', 'l_hnumber'];
$this->search_other = ['id','e_vid']; $this->search_other = ['id', 'e_vid'];
$this->search_field = ['el.e_number','la.l_hnumber','la.id','el.e_vid']; $this->search_field = ['el.e_number', 'la.l_hnumber', 'la.id', 'el.e_vid'];
$where .= self::td_time_orsearch(['l_starttime','l_endtime'],['la.l_endtime','la.l_starttime']); $where .= self::td_time_orsearch(['l_starttime', 'l_endtime'], ['la.l_endtime', 'la.l_starttime']);
$where .= self::td_search(); $where .= self::td_search();
break; break;
case 'noticeday': case 'noticeday':
$where .= ' AND ( (endtime BETWEEN DATE_SUB( CURDATE(), INTERVAL 3 DAY ) AND CURDATE()) OR ' //到期提醒 展示3天 // DATE_SUB $where .= ' AND ( (endtime BETWEEN DATE_SUB( CURDATE(), INTERVAL 3 DAY ) AND CURDATE()) OR ' //到期提醒 展示3天 // DATE_SUB
. '(h_endtime BETWEEN DATE_SUB( CURDATE(), INTERVAL 3 DAY ) AND DATE_ADD( CURDATE(), INTERVAL 3 DAY ) ) )'; //订单到期前后展示3天 // DATE_ADD . '(h_endtime BETWEEN DATE_SUB( CURDATE(), INTERVAL 3 DAY ) AND DATE_ADD( CURDATE(), INTERVAL 3 DAY ) ) )'; //订单到期前后展示3天 // DATE_ADD
break; break;
default: default:
// 如果$where 没有值 会导致计算结果出错,导致前台表格无法获取正确的值,分页显示异常 // 如果$where 没有值 会导致计算结果出错,导致前台表格无法获取正确的值,分页显示异常
$where = "1=1"; $where = "1=1";
break; break;
} }
@ -411,11 +418,12 @@ trait tdata {
//分组查询 //分组查询
public function td_groupby(&$where) { public function td_groupby(&$where) {
global $_M; global $_M;
$this->multi_table = true; $this->multi_table = true;
switch ($this->tname) { switch ($this->tname) {
case 'elevators': case 'elevators':
$where .= " GROUP BY el.e_number "; $where .= " GROUP BY el.e_number ";
if($this->form['endtime']) $where .= " HAVING endtime < '{$this->form['endtime']}' "; if ($this->form['endtime'])
$where .= " HAVING endtime < '{$this->form['endtime']}' ";
break; break;
case 'patrol': case 'patrol':
$where .= " GROUP BY el.e_number "; $where .= " GROUP BY el.e_number ";
@ -430,7 +438,7 @@ trait tdata {
$where .= " GROUP BY vi.id "; $where .= " GROUP BY vi.id ";
break; break;
default: default:
$this->multi_table = false; $this->multi_table = false;
break; break;
} }
} }
@ -439,90 +447,119 @@ trait tdata {
* 【列出】 * 【列出】
* SQL排序方式语句 * SQL排序方式语句
*/ */
public function td_order() { public function td_order() {
global $_M; global $_M;
switch ($this->tname) { switch ($this->tname) {
case 'applan': case 'applan':
$order = " `e_enable` DESC "; $order = " `e_enable` DESC ";
//按照正常排序,对比相邻广告位的投放广告品类 //按照正常排序,对比相邻广告位的投放广告品类
// order_e_types 按照是否可投放进行排序 // order_e_types 按照是否可投放进行排序
if($this->form['eaps_order'] || $this->form['order_e_types']){ if ($this->form['eaps_order'] || $this->form['order_e_types']) {
if(!$this->form['order_e_types']) $this->form['order_e_types'] = ' ASC '; if (!$this->form['order_e_types'])
$order .= ", `lanum` {$this->form['order_e_types']} "; $this->form['order_e_types'] = ' ASC ';
$order .= ", `lanum` {$this->form['order_e_types']} ";
} }
if($this->form['eaps_order'] == 2){ if ($this->form['eaps_order'] == 2) {
// 传递进来的编号,不直接查数据是因为有些可能会出现错误,所以直接使用传递进来的,进行排序 // 传递进来的编号,不直接查数据是因为有些可能会出现错误,所以直接使用传递进来的,进行排序
$array = array_filter(stringto_array($this->form['l_selectenum'],',')); $array = array_filter(stringto_array($this->form['l_selectenum'], ','));
$idstr = parent::strchange($array); $idstr = parent::strchange($array);
if(strlen($idstr)) $order = " `e_number` IN({$idstr}) DESC, ".$order; if (strlen($idstr))
$order = " `e_number` IN({$idstr}) DESC, " . $order;
} }
$order .= ", `e_vid` ASC, `e_bno` ASC, `e_aps` ASC "; $order .= ", `e_vid` ASC, `e_bno` ASC, `e_aps` ASC ";
break; break;
case 'elevators': case 'elevators':
$order = " `etypes` DESC, endtime DESC, el.`e_vid` ASC, el.`e_bno` ASC, el.`e_aps` ASC "; $order = " `etypes` DESC, endtime DESC, el.`e_vid` ASC, el.`e_bno` ASC, el.`e_aps` ASC ";
if($this->form['order_e_number']) $order = " el.e_number {$this->form['order_e_number']} "; if ($this->form['order_e_number'])
if($this->form['order_endtime']) $order = " endtime {$this->form['order_endtime']} "; $order = " el.e_number {$this->form['order_e_number']} ";
if($this->form['order_e_totalnum']) $order = " e_totalnum {$this->form['order_e_totalnum']} "; if ($this->form['order_endtime'])
if($this->form['order_etypes']) $order = " `etypes` {$this->form['order_etypes']} "; $order = " endtime {$this->form['order_endtime']} ";
if($this->form['order_nowstime']) $order = " nowstime {$this->form['order_nowstime']} "; if ($this->form['order_e_totalnum'])
if($this->form['order_nowetime']) $order = " nowetime {$this->form['order_nowetime']} "; $order = " e_totalnum {$this->form['order_e_totalnum']} ";
if($this->form['order_nextstime']) $order = " nextstime {$this->form['order_nextstime']} "; if ($this->form['order_etypes'])
if($this->form['order_nextetime']) $order = " nextetime {$this->form['order_nextetime']} "; $order = " `etypes` {$this->form['order_etypes']} ";
if($this->form['order_endstime']) $order = " endstime {$this->form['order_endstime']} "; if ($this->form['order_nowstime'])
if($this->form['order_endetime']) $order = " endetime {$this->form['order_endetime']} "; $order = " nowstime {$this->form['order_nowstime']} ";
if($this->form['order_e_address']) { if ($this->form['order_nowetime'])
$e_address = $this->form['order_e_address']; $order = " nowetime {$this->form['order_nowetime']} ";
if ($this->form['order_nextstime'])
$order = " nextstime {$this->form['order_nextstime']} ";
if ($this->form['order_nextetime'])
$order = " nextetime {$this->form['order_nextetime']} ";
if ($this->form['order_endstime'])
$order = " endstime {$this->form['order_endstime']} ";
if ($this->form['order_endetime'])
$order = " endetime {$this->form['order_endetime']} ";
if ($this->form['order_e_address']) {
$e_address = $this->form['order_e_address'];
$order = " el.e_vid {$e_address}, el.e_bno {$e_address}, el.e_aps {$e_address} "; $order = " el.e_vid {$e_address}, el.e_bno {$e_address}, el.e_aps {$e_address} ";
} }
break; break;
case 'patrol': case 'patrol':
$order = " el.`e_vid` ASC, el.`e_bno` ASC, el.`e_aps` ASC "; $order = " el.`e_vid` ASC, el.`e_bno` ASC, el.`e_aps` ASC ";
break; break;
case 'elevator': case 'elevator':
$order = " `id` DESC "; $order = " `id` DESC ";
break; break;
case 'launch': case 'launch':
$order = " `id` DESC "; $order = " `id` DESC ";
if($this->form['order_l_starttime']) $order = " l_starttime {$this->form['order_l_starttime']} "; if ($this->form['order_l_starttime'])
if($this->form['order_l_endtime']) $order = " l_endtime {$this->form['order_l_endtime']} "; $order = " l_starttime {$this->form['order_l_starttime']} ";
if ($this->form['order_l_endtime'])
$order = " l_endtime {$this->form['order_l_endtime']} ";
break; break;
case 'contract': case 'contract':
$order = ' ch.`id` DESC'; $order = ' ch.`id` DESC';
if($this->form['order_h_starttime']) $order = " ch.h_starttime {$this->form['order_h_starttime']} "; if ($this->form['order_h_starttime'])
if($this->form['order_h_endtime']) $order = " ch.h_endtime {$this->form['order_h_endtime']} "; $order = " ch.h_starttime {$this->form['order_h_starttime']} ";
if ($this->form['order_h_endtime'])
$order = " ch.h_endtime {$this->form['order_h_endtime']} ";
break; break;
case 'schedule': case 'schedule':
$order = ' la.l_starttime DESC,la.`id` DESC'; $order = ' la.l_starttime DESC,la.`id` DESC';
//备份 按照场所排序 //备份 按照场所排序
if($this->bsign){ if ($this->bsign) {
$order = " el.`e_vid` ASC, el.`e_bno` ASC, el.`e_aps` ASC "; $order = " el.`e_vid` ASC, el.`e_bno` ASC, el.`e_aps` ASC ";
} }
if($this->form['order_l_starttime']) $order = " la.l_starttime {$this->form['order_l_starttime']} "; if ($this->form['order_l_starttime'])
if($this->form['order_l_endtime']) $order = " la.l_endtime {$this->form['order_l_endtime']} "; $order = " la.l_starttime {$this->form['order_l_starttime']} ";
if ($this->form['order_l_endtime'])
$order = " la.l_endtime {$this->form['order_l_endtime']} ";
break; break;
case 'villages': case 'villages':
$order = ' vi.`id` DESC'; $order = ' CONVERT( vi.`v_address` USING gbk ) COLLATE gbk_chinese_ci ASC ';
if($this->form['order_v_enum']) $order = " v_enum {$this->form['order_v_enum']} "; if ($this->form['order_v_enum'])
if($this->form['order_v_free']) $order = " v_free {$this->form['order_v_free']} "; $order = " v_enum {$this->form['order_v_enum']} ";
if($this->form['order_v_lease']) $order = " v_lease {$this->form['order_v_lease']} "; if ($this->form['order_v_free'])
if($this->form['order_v_endday']) $order = " v_endday {$this->form['order_v_endday']} "; $order = " v_free {$this->form['order_v_free']} ";
if($this->form['order_v_prerow']) $order = " v_prerow {$this->form['order_v_prerow']} "; if ($this->form['order_v_lease'])
if($this->form['order_v_ebnonum']) $order = " v_ebnonum {$this->form['order_v_ebnonum']} "; $order = " v_lease {$this->form['order_v_lease']} ";
if($this->form['order_v_bno']) $order = " v_bno {$this->form['order_v_bno']} "; if ($this->form['order_v_endday'])
$order = " v_endday {$this->form['order_v_endday']} ";
if ($this->form['order_v_prerow'])
$order = " v_prerow {$this->form['order_v_prerow']} ";
if ($this->form['order_v_ebnonum'])
$order = " v_ebnonum {$this->form['order_v_ebnonum']} ";
if ($this->form['order_v_bno'])
$order = " v_bno {$this->form['order_v_bno']} ";
break; break;
case 'para': case 'para':
$order = ' `id` DESC'; $order = ' `id` DESC';
if($this->form['order_p_type']) $order = " `p_type` {$this->form['order_p_type']} "; if ($this->form['order_p_type'])
if($this->form['order_p_order']) $order = " `p_order` {$this->form['order_p_order']} "; $order = " `p_type` {$this->form['order_p_type']} ";
if ($this->form['order_p_order'])
$order = " `p_order` {$this->form['order_p_order']} ";
break; break;
case 'noticeday': case 'noticeday':
$order = ' `endtime` ASC, `h_endtime` ASC '; $order = ' `endtime` ASC, `h_endtime` ASC ';
break; break;
case 'village': case 'village':
$order = ' vi.`id` DESC'; $order = ' vi.`id` DESC';
break; break;
default: default:
$order = ' `id` DESC'; $order = ' `id` DESC';
break; break;
} }