From dc0442f840ca2b0191d8b003dcd3cd8daced11de Mon Sep 17 00:00:00 2001 From: cloud Date: Mon, 23 Dec 2024 04:04:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=86=E6=8E=92=E6=9C=9F?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=EF=BC=8C=E5=8F=AA=E6=98=AF=E6=9B=B4=E6=8D=A2?= =?UTF-8?q?=E4=BA=86=E8=BF=9E=E6=8E=A5=E5=85=A5=E5=8F=A3=EF=BC=8C=E5=8E=9F?= =?UTF-8?q?=E6=9C=89=E7=9A=84=E8=BF=98=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/traits/tdata.class.php | 582 +++++++++++--------- include/traits/tfield.class.php | 372 +++++++------ include/traits/tlist.class.php | 909 +++++++++++++++++++++----------- 3 files changed, 1127 insertions(+), 736 deletions(-) diff --git a/include/traits/tdata.class.php b/include/traits/tdata.class.php index 35e4e51..f3002bf 100644 --- a/include/traits/tdata.class.php +++ b/include/traits/tdata.class.php @@ -9,102 +9,48 @@ trait tdata //sql语句采用分组查询后调整为true 使用子查询计算总条数 public $multi_table = false; + //搜索的input字段,用来处理表数据显示时的颜色加重问题 private $search_input = []; + //搜索的select字段,不用考虑搜索结果 private $search_other = []; + //带有表前缀的搜索字段,主要用于跨表联合查询,要对照上面数组合并后的顺序 private $search_field = []; + //搜索的LIKE字段 private $search_link = []; + //跳过替换为突出显示的字段 private $skip_field = []; + // 场所统计查询内的公用where private $villages_where = ''; + // 根据社区类型和地图选择判断小区的ID private $village_whereid = ''; // 计算社区类型,地图选择,返回被选中的小区ID - private function fun_sqlk_vid() - { - global $_M, $_YW; - $idArr = $vidArr = []; - $countvid = function ($idArr = [], $newvid = []) { - // if (count($newvid) == 0) $newvid = [-1]; - if (count($idArr) > 0) { - $idArr = array_intersect($newvid, $idArr); - // 如果交集为空,则确实通过此条件进行了筛选,就要通知SQL没有任何值满足当前条件,将ID设置为0,肯定查找不到 - // if (count($idArr) == 0) $idArr = [-1]; - } else { - $idArr = $newvid; - } - if (count($idArr) == 0) $idArr = [-1]; - return $idArr; - }; - - // 所属商圈 - if (array_key_exists('vhcname', $this->form) && is_array($this->form['vhcname'])) { - $arrvhcname = array_map(function ($para) { return "'{$para}'"; }, $this->form['vhcname']); - $vhcname = arrayto_string($arrvhcname, ','); - $vid = $this->tsql->table('village')->qfield('id')->where("v_hcname IN({$vhcname}) ")->all(); - $idArr = $countvid($idArr, array_column($vid, 'id')); - } - - // 场所类型 - if (is_array($this->form['vtype'])) { - $vtype = arrayto_string($this->form['vtype'], ','); - $vid = $this->tsql->table('village')->qfield('id')->where("v_type IN({$vtype})")->all(); - $idArr = $countvid($idArr, array_column($vid, 'id')); - } - - // 地图选择 - if ($this->form['v_id']) { - $vidArr = stringto_array($this->form['v_id'], ','); - // 取社区类型和地图筛选的交集,重叠ID,社区类型没有操作则直接按照地图筛选结果 - // $idArr = count($idArr) > 0?array_intersect($vidArr,$idArr):$vidArr; - $idArr = $countvid($idArr, $vidArr); - } - - $funWhere = function ($idArr, &$where) { - if (count($idArr) > 0) { - $strId = arrayto_string($idArr, ','); - $where .= " AND id IN({$strId}) "; - } - }; - - //区域 - $v_province = $this->form['v_province'] && $this->form['v_province'] != '请选择' ? $this->form['v_province'] : ''; - $v_city = $this->form['v_city'] && $this->form['v_city'] != '请选择' ? $this->form['v_city'] : ''; - $v_district = $this->form['v_district'] && $this->form['v_district'] != '请选择' ? $this->form['v_district'] : ''; - if ($v_district && $v_province && $v_city) { - $where = " v_province = '{$this->form['v_province']}' AND v_city = '{$this->form['v_city']}' AND v_district = '{$v_district}' "; - $funWhere($idArr, $where); - $vid = $this->tsql->table('village')->qfield('id')->where($where)->all(); - $idArr = array_column($vid, 'id'); - if (count($idArr) == 0) $idArr = [-1]; - } - - return $idArr; - } - - //表名 public function td_sqlk() { - global $_M, $_YW; + global $_YW; //当天日期时间 $curdate = date('Y-m-d', time()); switch ($this->tname) { 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']}' "; + } $ason = ''; // 计算是否区分广告位,不考虑导出 if (is_array($this->form['e_aps'])) { $veaps = parent::strchange(array_filter($this->form['e_aps'])); - $this->villages_where = " nel.e_aps IN({$veaps}) "; - $ason .= " {$this->villages_where} AND "; + $this->villages_where = " nel.e_aps IN($veaps) "; + $ason .= " $this->villages_where AND "; } // 根据小区单个ID @@ -117,26 +63,28 @@ trait tdata // 通过ID筛选掉不需要的 if (count($idArr) > 0) { $this->village_whereid = arrayto_string(array_unique($idArr), ','); - $ason .= " nel.e_vid IN({$this->village_whereid}) AND "; + $ason .= " nel.e_vid IN($this->village_whereid) AND "; } //表 $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 {$ason} 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 {$ason} 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 {$ason} 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 {$ason} 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 {$ason} 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 * 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 $ason 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 $ason 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 $ason 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 $ason 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 $ason 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; 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 ) " - . "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 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 "; + $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 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 "; break; 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 ) " - . "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 "; + $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 "; break; case 'villages': $son = " FROM {$_YW['k']['countela']} AS el WHERE "; @@ -158,22 +106,28 @@ trait tdata // 计算是否区分广告位 // 检测是否通过JS传递的广告位参数,也就是导出 - if (isset($this->form['jsadd_veaps'])) $this->form['veaps'] = stringto_array($this->form['jsadd_veaps'], ','); + if (isset($this->form['jsadd_veaps'])) { + $this->form['veaps'] = stringto_array($this->form['jsadd_veaps'], ','); + } if (is_array($this->form['veaps'])) { $veaps = parent::strchange(array_filter($this->form['veaps'])); - $this->villages_where = " el.e_aps IN({$veaps}) "; - $son .= " {$this->villages_where} AND "; + $this->villages_where = " el.e_aps IN($veaps) "; + $son .= " $this->villages_where AND "; } // 社区类型 // 先查询出需要的ID - if (isset($this->form['jsadd_vhcname'])) $this->form['vhcname'] = stringto_array($this->form['jsadd_vhcname'], ','); - if (isset($this->form['jsadd_vtype'])) $this->form['vtype'] = stringto_array($this->form['jsadd_vtype'], ','); + if (isset($this->form['jsadd_vhcname'])) { + $this->form['vhcname'] = stringto_array($this->form['jsadd_vhcname'], ','); + } + if (isset($this->form['jsadd_vtype'])) { + $this->form['vtype'] = stringto_array($this->form['jsadd_vtype'], ','); + } $idArr = self::fun_sqlk_vid(); // 通过ID筛选掉不需要的 if (count($idArr) > 0) { $this->village_whereid = arrayto_string(array_unique($idArr), ','); - $son .= " el.e_vid IN({$this->village_whereid}) AND "; + $son .= " el.e_vid IN($this->village_whereid) AND "; } // 空置计算要排除当前排期中的广告位 @@ -181,60 +135,141 @@ trait tdata //加上时间区块 那就是查看在区段内的情况 //增加 s_enable 判断是为了防止过去时间 //空置 - $fwhere = " {$son} NOT EXISTS (SELECT ela.e_number FROM {$_YW['k']['countela']} AS ela WHERE NOT ( ela.l_endtime < '{$vs_starttime}' OR ela.l_starttime > '{$vs_endtime}' ) AND ela.e_number = el.e_number) AND ( (el.l_endtime < '{$vs_starttime}' OR el.l_starttime > '{$vs_endtime}' ) 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 < '$vs_starttime' OR ela.l_starttime > '$vs_endtime' ) AND ela.e_number = el.e_number) AND ( (el.l_endtime < '$vs_starttime' OR el.l_starttime > '$vs_endtime' ) 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 < '{$vs_starttime}' OR ela.l_starttime > '{$vs_endtime}' ) AND NOT(ela.l_endtime < '{$curdate}' OR ela.l_starttime > '{$curdate}' ) AND ela.e_number = el.e_number) AND ( ((el.l_endtime < '{$vs_starttime}' OR el.l_starttime > '{$vs_endtime}') AND el.l_endtime < '{$curdate}' ) OR el.l_id IS NULL ) AND el.e_enable = 1 "; //排期中的 - $lwhere = " {$son} NOT(el.l_endtime < '{$vs_starttime}' OR el.l_starttime > '{$vs_endtime}') "; + $lwhere = " $son NOT(el.l_endtime < '$vs_starttime' OR el.l_starttime > '$vs_endtime') "; // 之前的旧代码 // $lwhere = " {$son} NOT(el.l_endtime < '{$vs_starttime}' OR el.l_starttime > '{$vs_endtime}') AND NOT(el.l_endtime < '{$curdate}' OR el.l_starttime > '{$curdate}' ) "; //多少天到期的 - $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 { //没有时间区段,则按照当天为准则,默认值 //空置,其他不包含当天的 - $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 "; //排期中的,日期包含当天的 - $lwhere = " {$son} NOT(el.l_endtime < '{$curdate}' OR el.l_starttime > '{$curdate}' ) "; + $lwhere = " $son NOT(el.l_endtime < '$curdate' OR el.l_starttime > '$curdate' ) "; //多少天到期的 - $dwhere = " {$son} el.l_endtime BETWEEN '{$curdate}' AND date_add( '{$curdate}', INTERVAL 7 DAY ) "; + $dwhere = " $son el.l_endtime BETWEEN '$curdate' AND date_add( '$curdate', INTERVAL 7 DAY ) "; //预排,开始时间大于当天的 - $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 " - . "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 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 de_vid,COUNT( DISTINCT el.e_number ) AS v_prerow {$pwhere} GROUP BY de_vid ) AS dnum ON dnum.de_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 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 de_vid,COUNT( DISTINCT el.e_number ) AS v_prerow $pwhere GROUP BY de_vid ) AS dnum ON dnum.de_vid = vi.id "; break; case 'contract': $sqlk = "{$_YW['k']['contract']} AS ch LEFT JOIN {$_YW['k']['launch']} AS la ON ch.h_number = la.l_hnumber "; break; 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; + case 'expschedule': + $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; case 'village': $sqlk = "{$_YW['k']['village']} AS vi LEFT JOIN {$_YW['k']['elevator']} AS el ON vi.id = el.e_vid "; break; default: - $sqlk = $_YW['k'][ $this->tname ]; + $sqlk = $_YW['k'][$this->tname]; break; } + return $sqlk; } + //表名 + private function fun_sqlk_vid() + { + $idArr = $vidArr = []; + + $countvid = function ($idArr = [], $newvid = []) { + // if (count($newvid) == 0) $newvid = [-1]; + if (count($idArr) > 0) { + $idArr = array_intersect($newvid, $idArr); + // 如果交集为空,则确实通过此条件进行了筛选,就要通知SQL没有任何值满足当前条件,将ID设置为0,肯定查找不到 + // if (count($idArr) == 0) $idArr = [-1]; + } else { + $idArr = $newvid; + } + if (count($idArr) == 0) { + $idArr = [-1]; + } + + return $idArr; + }; + + // 所属商圈 + if (array_key_exists('vhcname', $this->form) && is_array($this->form['vhcname'])) { + $arrvhcname = array_map(function ($para) { + return "'$para'"; + }, $this->form['vhcname']); + $vhcname = arrayto_string($arrvhcname, ','); + $vid = $this->tsql->table('village')->qfield('id')->where("v_hcname IN($vhcname) ")->all(); + $idArr = $countvid($idArr, array_column($vid, 'id')); + } + + // 场所类型 + if (is_array($this->form['vtype'])) { + $vtype = arrayto_string($this->form['vtype'], ','); + $vid = $this->tsql->table('village')->qfield('id')->where("v_type IN($vtype)")->all(); + $idArr = $countvid($idArr, array_column($vid, 'id')); + } + + // 地图选择 + if ($this->form['v_id']) { + $vidArr = stringto_array($this->form['v_id'], ','); + // 取社区类型和地图筛选的交集,重叠ID,社区类型没有操作则直接按照地图筛选结果 + // $idArr = count($idArr) > 0?array_intersect($vidArr,$idArr):$vidArr; + $idArr = $countvid($idArr, $vidArr); + } + + $funWhere = function ($idArr, &$where) { + if (count($idArr) > 0) { + $strId = arrayto_string($idArr, ','); + $where .= " AND id IN($strId) "; + } + }; + + //区域 + $v_province = $this->form['v_province'] && $this->form['v_province'] != '请选择' ? $this->form['v_province'] : ''; + $v_city = $this->form['v_city'] && $this->form['v_city'] != '请选择' ? $this->form['v_city'] : ''; + $v_district = $this->form['v_district'] && $this->form['v_district'] != '请选择' ? $this->form['v_district'] : ''; + if ($v_district && $v_province && $v_city) { + $where + = " v_province = '{$this->form['v_province']}' AND v_city = '{$this->form['v_city']}' AND v_district = '$v_district' "; + $funWhere($idArr, $where); + $vid = $this->tsql->table('village')->qfield('id')->where($where)->all(); + $idArr = array_column($vid, 'id'); + if (count($idArr) == 0) { + $idArr = [-1]; + } + } + + return $idArr; + } + //字段 + public function td_field() { - global $_M, $_YW; switch ($this->tname) { case 'elevators': - $field = ' el.*,max( la.l_endtime ) AS endtime,count( DISTINCT la.id ) AS e_totalnum,ala.*,if(ala.estate,1,0) AS etypes,bla.*,cla.* '; + $field + = ' el.*,max( la.l_endtime ) AS endtime,count( DISTINCT la.id ) AS e_totalnum,ala.*,if(ala.estate,1,0) AS etypes,bla.*,cla.* '; break; case 'patrol': $field = ' el.*,la.l_hnumber,ala.* '; @@ -245,17 +280,23 @@ trait tdata case 'schedule': $field = 'el.e_enable,el.e_number,el.e_vid,el.e_bno,el.e_aps,el.e_size,el.e_label,la.*,ct.h_cid';// el.e_text, break; + case 'expschedule': + $field = 'el.e_vid,el.e_bno,el.e_label,la.*,ct.h_cid';// el.e_text, + break; case 'villages': - $field = " vi.*, COUNT( DISTINCT el.e_number) AS v_enum,COUNT(DISTINCT el.e_vid, el.e_bno) AS v_ebnonum,COUNT( el.e_enable = 0 OR NULL ) AS noban,ANY_VALUE(anum.v_free) AS v_free,ANY_VALUE( anum.v_bno ) AS v_bno,ANY_VALUE(bnum.v_lease) AS v_lease,ANY_VALUE(cnum.v_endday) AS v_endday,ANY_VALUE(dnum.v_prerow) AS v_prerow "; + $field + = " vi.*, COUNT( DISTINCT el.e_number) AS v_enum,COUNT(DISTINCT el.e_vid, el.e_bno) AS v_ebnonum,COUNT( el.e_enable = 0 OR NULL ) AS noban,ANY_VALUE(anum.v_free) AS v_free,ANY_VALUE( anum.v_bno ) AS v_bno,ANY_VALUE(bnum.v_lease) AS v_lease,ANY_VALUE(cnum.v_endday) AS v_endday,ANY_VALUE(dnum.v_prerow) AS v_prerow "; break; case 'village': - $field = " vi.*, count( el.e_number ) AS total,count( el.e_enable = 0 OR NULL ) AS noban,count( el.e_enable = 1 OR NULL ) AS normal "; + $field + = " vi.*, count( el.e_number ) AS total,count( el.e_enable = 0 OR NULL ) AS noban,count( el.e_enable = 1 OR NULL ) AS normal "; break; default: $field = '*'; break; } + return $field; } @@ -264,85 +305,21 @@ trait tdata * 同时满足条件的,非OR */ - public function td_search($link = true) - { - global $_M, $_YW; - //默认input字段为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)); - //判断是否为链表查询 - $join_field = array_combine($field, count($this->search_field) > 0 ? $this->search_field : $field); - - //相对独立的搜索 - $arrwhere = []; - foreach ($field as $val) { - $search = trim(strtoupper($this->form[ $val ])); - if (strlen($search) > 0) { - $str = $join_field[ $val ]; - if (in_array($val, $this->search_link)) { - $arrwhere[] = " {$str} LIKE '%{$search}%' "; - continue; - } - $arrwhere[] = " {$str} = '{$search}' "; - } - } - - //返回内容 - $where = ''; - if (count($arrwhere) > 0) { - $where = ' AND '; - $where .= arrayto_string($arrwhere, ' AND '); - } - return $where; - } - - //OR 内容搜索 - public function td_search_or($orfield, $search_field = []) - { - global $_M, $_YW; - //判断是否为链表查询 - $join_field = array_combine($orfield, count($search_field) > 0 ? $search_field : $orfield); - //相对独立的搜索 - $arrwhere = []; - foreach ($orfield as $val) { - $search = trim(strtoupper($this->form[ $val ])); - if (strlen($search) > 0) { - $str = $join_field[ $val ]; - if (in_array($val, $this->search_link)) { - $arrwhere[] = " {$str} LIKE '%{$search}%' "; - continue; - } - $arrwhere[] = " {$str} = '{$search}' "; - } - } - - //返回内容 - $where = ''; - if (count($arrwhere) > 0) { - $where .= arrayto_string($arrwhere, ' OR '); - } - return strlen($where) > 0 ? " AND ({$where}) " : ''; - } - - //时间区间 public function td_time_search($field, $search_field = []) { - global $_M, $_YW; list($start, $end) = $field; //判断是否为链表查询 $join_field = array_combine($field, count($search_field) > 0 ? $search_field : $field); //相对独立的搜索 $arrwhere = []; foreach ($field as $val) { - $search = trim(strtoupper($this->form[ $val ])); + $search = trim(strtoupper($this->form[$val])); if (strlen($search) > 0) { - $str = $join_field[ $val ]; + $str = $join_field[$val]; if ($val == $start) { - $arrwhere[] = " {$str} >= '{$search}' "; + $arrwhere[] = " $str >= '$search' "; } else { - $arrwhere[] = " {$str} <= '{$search}' "; + $arrwhere[] = " $str <= '$search' "; } } } @@ -352,47 +329,14 @@ trait tdata if (count($arrwhere) > 0) { $where .= arrayto_string($arrwhere, " AND "); } - return strlen($where) > 0 ? " AND ({$where}) " : ''; - } - - //获取重叠的时间区间 - // $search_field 开始时间和结束时间的字段互相调换,结束的字段在前面 - public function td_time_orsearch($field, $search_field = []) - { - global $_M, $_YW; - list($start, $end) = $field; - //判断是否为链表查询 - $join_field = array_combine($field, count($search_field) > 0 ? $search_field : $field); - //相对独立的搜索 - $arrwhere = []; - foreach ($field as $val) { - $search = trim(strtoupper($this->form[ $val ])); - if (strlen($search) > 0) { - $str = $join_field[ $val ]; - if ($val == $start) { - $arrwhere[] = " {$str} < '{$search}' "; //结束字段,搜索为开始时间 - } else { - $arrwhere[] = " {$str} > '{$search}' "; //开始字段,搜索为结束时间 - } - } - } - //返回内容 - $where = ''; - if (count($arrwhere) > 0) { - $where .= arrayto_string($arrwhere, " OR "); - } - return strlen($where) > 0 ? " AND NOT({$where}) " : ''; + return strlen($where) > 0 ? " AND ($where) " : ''; } - /* - * 【列出】 - * SQL判断语句$where .= $this->search(); - */ + //OR 内容搜索 public function td_where() { - global $_M, $_YW; $where = " 1=1 "; switch ($this->tname) { case 'applan': @@ -404,16 +348,28 @@ trait tdata $veaps = parent::strchange(array_filter($this->form['e_aps'])); $where .= " AND e_aps IN($veaps) "; } - if (strlen($this->village_whereid) > 0) $where .= " AND el.e_vid IN({$this->village_whereid}) "; + if (strlen($this->village_whereid) > 0) { + $where .= " AND el.e_vid IN($this->village_whereid) "; + } break; case 'elevators': $this->search_input = ['e_number']; $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(); //判断是否为备份 - if ($this->bsign) + if ($this->bsign) { parent::where_id($where); + } self::td_groupby($where); break; case 'patrol': @@ -487,16 +443,22 @@ trait tdata $this->form['v_city'] = $this->form['v_address']; $this->form['v_district'] = $this->form['v_address']; - if (strlen($this->villages_where) > 0) $where .= " AND {$this->villages_where} "; - if (strlen($this->village_whereid) > 0) $where .= " AND vi.id IN({$this->village_whereid}) "; + if (strlen($this->villages_where) > 0) { + $where .= " AND $this->villages_where "; + } + if (strlen($this->village_whereid) > 0) { + $where .= " AND vi.id IN($this->village_whereid) "; + } $where .= self::td_search_or($this->search_link); $where .= self::td_search(); //判断是否为备份 - if ($this->bsign) + if ($this->bsign) { parent::where_id($where); + } self::td_groupby($where); break; case 'schedule': + case 'expschedule': $where .= " AND la.id IS NOT NULL "; $this->search_input = ['e_number', 'l_hnumber']; $this->search_other = ['id', 'e_vid']; @@ -516,16 +478,55 @@ trait tdata return $where; } - //分组查询 + //时间区间 + + public function td_search($link = true) + { + //默认input字段为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)); + //判断是否为链表查询 + $join_field = array_combine($field, count($this->search_field) > 0 ? $this->search_field : $field); + + //相对独立的搜索 + $arrwhere = []; + foreach ($field as $val) { + $search = trim(strtoupper($this->form[$val])); + if (strlen($search) > 0) { + $str = $join_field[$val]; + if (in_array($val, $this->search_link)) { + $arrwhere[] = " $str LIKE '%$search%' "; + continue; + } + $arrwhere[] = " $str = '$search' "; + } + } + + //返回内容 + $where = ''; + if (count($arrwhere) > 0) { + $where = ' AND '; + $where .= arrayto_string($arrwhere, ' AND '); + } + + return $where; + } + + //获取重叠的时间区间 + // $search_field 开始时间和结束时间的字段互相调换,结束的字段在前面 + public function td_groupby(&$where) { - global $_M; $this->multi_table = true; switch ($this->tname) { case 'elevators': $where .= " GROUP BY el.e_number "; - if ($this->form['endtime']) + if ($this->form['endtime']) { $where .= " HAVING endtime < '{$this->form['endtime']}' "; + } break; case 'patrol': $where .= " GROUP BY el.e_number "; @@ -534,8 +535,6 @@ trait tdata $where .= " GROUP BY ch.id "; break; case 'villages': - $where .= " GROUP BY vi.id "; - break; case 'village': $where .= " GROUP BY vi.id "; break; @@ -545,6 +544,68 @@ trait tdata } } + /* + * 【列出】 + * SQL判断语句$where .= $this->search(); + */ + + public function td_search_or($orfield, $search_field = []) + { + //判断是否为链表查询 + $join_field = array_combine($orfield, count($search_field) > 0 ? $search_field : $orfield); + //相对独立的搜索 + $arrwhere = []; + foreach ($orfield as $val) { + $search = trim(strtoupper($this->form[$val])); + if (strlen($search) > 0) { + $str = $join_field[$val]; + if (in_array($val, $this->search_link)) { + $arrwhere[] = " $str LIKE '%$search%' "; + continue; + } + $arrwhere[] = " $str = '$search' "; + } + } + + //返回内容 + $where = ''; + if (count($arrwhere) > 0) { + $where .= arrayto_string($arrwhere, ' OR '); + } + + return strlen($where) > 0 ? " AND ($where) " : ''; + } + + //分组查询 + + public function td_time_orsearch($field, $search_field = []) + { + list($start, $end) = $field; + //判断是否为链表查询 + $join_field = array_combine($field, count($search_field) > 0 ? $search_field : $field); + //相对独立的搜索 + $arrwhere = []; + foreach ($field as $val) { + $search = trim(strtoupper($this->form[$val])); + if (strlen($search) > 0) { + $str = $join_field[$val]; + if ($val == $start) { + $arrwhere[] = " $str < '$search' "; //结束字段,搜索为开始时间 + } else { + $arrwhere[] = " $str > '$search' "; //开始字段,搜索为结束时间 + } + } + } + + //返回内容 + $where = ''; + if (count($arrwhere) > 0) { + $where .= arrayto_string($arrwhere, " OR "); + } + + return strlen($where) > 0 ? " AND NOT($where) " : ''; + } + /* * 【列出】 * SQL排序方式语句 @@ -552,51 +613,62 @@ trait tdata public function td_order() { - global $_M; switch ($this->tname) { case 'applan': $order = " `e_enable` DESC "; //按照正常排序,对比相邻广告位的投放广告品类 // order_e_types 按照是否可投放进行排序 if ($this->form['eaps_order'] || $this->form['order_e_types']) { - if (!$this->form['order_e_types']) + if ( ! $this->form['order_e_types']) { $this->form['order_e_types'] = ' ASC '; + } $order .= ", `lanum` {$this->form['order_e_types']} "; } if ($this->form['eaps_order'] == 2) { // 传递进来的编号,不直接查数据是因为有些可能会出现错误,所以直接使用传递进来的,进行排序 $array = array_filter(stringto_array($this->form['l_selectenum'], ',')); $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 "; break; case 'elevators': $order = " `etypes` DESC, endtime DESC, el.`e_vid` ASC, el.`e_bno` ASC, el.`e_aps` ASC "; - if ($this->form['order_e_number']) + if ($this->form['order_e_number']) { $order = " el.e_number {$this->form['order_e_number']} "; - if ($this->form['order_endtime']) + } + if ($this->form['order_endtime']) { $order = " endtime {$this->form['order_endtime']} "; - if ($this->form['order_e_totalnum']) + } + if ($this->form['order_e_totalnum']) { $order = " e_totalnum {$this->form['order_e_totalnum']} "; - if ($this->form['order_etypes']) + } + if ($this->form['order_etypes']) { $order = " `etypes` {$this->form['order_etypes']} "; - if ($this->form['order_nowstime']) + } + if ($this->form['order_nowstime']) { $order = " nowstime {$this->form['order_nowstime']} "; - if ($this->form['order_nowetime']) + } + if ($this->form['order_nowetime']) { $order = " nowetime {$this->form['order_nowetime']} "; - if ($this->form['order_nextstime']) + } + if ($this->form['order_nextstime']) { $order = " nextstime {$this->form['order_nextstime']} "; - if ($this->form['order_nextetime']) + } + if ($this->form['order_nextetime']) { $order = " nextetime {$this->form['order_nextetime']} "; - if ($this->form['order_endstime']) + } + if ($this->form['order_endstime']) { $order = " endstime {$this->form['order_endstime']} "; - if ($this->form['order_endetime']) + } + 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; case 'patrol': @@ -607,54 +679,70 @@ trait tdata break; case 'launch': $order = " `id` DESC "; - if ($this->form['order_l_starttime']) + if ($this->form['order_l_starttime']) { $order = " l_starttime {$this->form['order_l_starttime']} "; - if ($this->form['order_l_endtime']) + } + if ($this->form['order_l_endtime']) { $order = " l_endtime {$this->form['order_l_endtime']} "; + } break; case 'contract': $order = ' ch.`id` DESC'; - if ($this->form['order_h_starttime']) + if ($this->form['order_h_starttime']) { $order = " ch.h_starttime {$this->form['order_h_starttime']} "; - if ($this->form['order_h_endtime']) + } + if ($this->form['order_h_endtime']) { $order = " ch.h_endtime {$this->form['order_h_endtime']} "; + } break; case 'schedule': + case 'expschedule': $order = ' la.l_starttime DESC,la.`id` DESC'; //备份 按照场所排序 if ($this->bsign) { $order = " el.`e_vid` ASC, el.`e_bno` ASC, el.`e_aps` ASC "; } - if ($this->form['order_l_starttime']) + if ($this->form['order_l_starttime']) { $order = " la.l_starttime {$this->form['order_l_starttime']} "; - if ($this->form['order_l_endtime']) + } + if ($this->form['order_l_endtime']) { $order = " la.l_endtime {$this->form['order_l_endtime']} "; + } break; case 'villages': // 默认按照街道排序 $order = ' CONVERT( vi.`v_address` USING gbk ) COLLATE gbk_chinese_ci ASC '; - if ($this->form['order_v_enum']) + if ($this->form['order_v_enum']) { $order = " v_enum {$this->form['order_v_enum']} "; - if ($this->form['order_v_free']) + } + if ($this->form['order_v_free']) { $order = " v_free {$this->form['order_v_free']} "; - if ($this->form['order_v_lease']) + } + if ($this->form['order_v_lease']) { $order = " v_lease {$this->form['order_v_lease']} "; - if ($this->form['order_v_endday']) + } + if ($this->form['order_v_endday']) { $order = " v_endday {$this->form['order_v_endday']} "; - if ($this->form['order_v_prerow']) + } + if ($this->form['order_v_prerow']) { $order = " v_prerow {$this->form['order_v_prerow']} "; - if ($this->form['order_v_ebnonum']) + } + if ($this->form['order_v_ebnonum']) { $order = " v_ebnonum {$this->form['order_v_ebnonum']} "; - if ($this->form['order_v_bno']) + } + if ($this->form['order_v_bno']) { $order = " v_bno {$this->form['order_v_bno']} "; + } break; case 'para': $order = ' `id` DESC'; - if ($this->form['order_p_type']) + if ($this->form['order_p_type']) { $order = " `p_type` {$this->form['order_p_type']} "; - if ($this->form['order_p_order']) + } + if ($this->form['order_p_order']) { $order = " `p_order` {$this->form['order_p_order']} "; + } break; case 'noticeday': $order = ' `endtime` ASC, `h_endtime` ASC '; diff --git a/include/traits/tfield.class.php b/include/traits/tfield.class.php index 563fbe9..fb35b13 100644 --- a/include/traits/tfield.class.php +++ b/include/traits/tfield.class.php @@ -3,236 +3,264 @@ //表对应字段 trait tfield { - + //广告位统计 protected function tf_elevator($sign = true) { global $_M, $_YW; + return [ - 'e_enable' => '状态', - 'e_number' => '广告位编号', - 'e_vid' => '场所名称', - 'e_bno' => '门口方位', - 'e_aps' => '广告位位置', - 'e_size' => '广告位规格', - 'e_label' => '相关标签', - 'e_text' => '备注' + 'e_enable' => '状态', + 'e_number' => '广告位编号', + 'e_vid' => '场所名称', + 'e_bno' => '门口方位', + 'e_aps' => '广告位位置', + 'e_size' => '广告位规格', + 'e_label' => '相关标签', + 'e_text' => '备注', ]; } - + //场所统计 protected function tf_village($sign = true) { global $_M, $_YW; + return [ - 'v_name' => '场所名称', - 'v_type' => '场所分类', - 'v_hcname' => '所属商圈', - 'v_totalstr' => '广告状态', - 'v_address' => '场所地址', - 'v_lxname' => '联系人', - 'v_tel' => '联系电话', - 'v_price' => '场所均价', - 'v_psize' => '居住规模', - 'v_addtime' => '录入时间', - 'v_updatetime' => '修改时间', - 'v_forbidtype' => '禁投行业', - 'v_lnglat' => '经纬度', - 'v_service' => '维保人员', - 'v_text' => '备注' + 'v_name' => '场所名称', + 'v_type' => '场所分类', + 'v_hcname' => '所属商圈', + 'v_totalstr' => '广告状态', + 'v_address' => '场所地址', + 'v_lxname' => '联系人', + 'v_tel' => '联系电话', + 'v_price' => '场所均价', + 'v_psize' => '居住规模', + 'v_addtime' => '录入时间', + 'v_updatetime' => '修改时间', + 'v_forbidtype' => '禁投行业', + 'v_lnglat' => '经纬度', + 'v_service' => '维保人员', + 'v_text' => '备注', ]; } - + //广告合同关联表 protected function tf_schedule($sign = '') { global $_M, $_YW; //Table $array = [ - 'e_enable' => '状态', - 'e_number' => '广告位编号', - 'e_size' => '广告位规格', - 'l_address' => '广告位地址', - 'h_cid' => '签定的公司', - 'l_hnumber' => '合同编号', - 'l_title' => '投放名称', - 'l_starttime' => '开始时间', - 'l_endtime' => '结束时间', - 'ltype' => '投放状态' //标记是否已经结束 + 'e_enable' => '状态', + 'e_number' => '广告位编号', + 'e_size' => '广告位规格', + 'l_address' => '广告位地址', + 'h_cid' => '签定的公司', + 'l_hnumber' => '合同编号', + 'l_title' => '投放名称', + 'l_starttime' => '开始时间', + 'l_endtime' => '结束时间', + 'ltype' => '投放状态', //标记是否已经结束 ]; // 导出专用 $barray = [ - 'e_enable' => '状态', + 'e_enable' => '状态', // 'e_number' => '广告位编号', - 'e_size' => '广告位规格', -// 'e_text' => '备注', - 'e_label' => '相关标签', - 'e_vid' => '场所名称', - 'v_vaddress' => '场所地址', - 'v_hcname' => '所属商圈', - 'e_bno' => '门口方位', - 'e_aps' => '广告位位置', - 'h_cid' => '签定的公司', - 'l_hnumber' => '合同编号', - 'l_title' => '投放名称', - 'l_starttime' => '开始时间', - 'l_endtime' => '结束时间', - 'ltype' => '投放状态' //标记是否已经结束 + 'e_size' => '广告位规格', + // 'e_text' => '备注', + 'e_label' => '相关标签', + 'e_vid' => '场所名称', + 'v_vaddress' => '场所地址', + 'v_hcname' => '所属商圈', + 'e_bno' => '门口方位', + 'e_aps' => '广告位位置', + 'h_cid' => '签定的公司', + 'l_hnumber' => '合同编号', + 'l_title' => '投放名称', + 'l_starttime' => '开始时间', + 'l_endtime' => '结束时间', + 'ltype' => '投放状态', //标记是否已经结束 ]; + return $sign || $this->bsign ? $barray : $array; } - + + // 新的导出备份 + protected function tf_expschedule($sign = '') + { + // 导出专用 + return [ + 'serial_number' => '序号', + 'v_city' => '城市', + 'media_type' => '媒体类型', + 'v_district' => '区域', + 'e_vid' => '社区名称', + 'v_address' => '详细地址', + 'v_type' => '资源类型', + 'e_bno' => '道闸位置', + 'number' => '数量', + 'e_label' => '类型', + ]; + } + //合同 protected function tf_contract($sign = true) { global $_M, $_YW; + return [ - 'h_number' => '合同编号', - 'h_medium' => '投放媒介', - 'h_signtime' => '签订日期', - 'h_cid' => '签定公司', - 'h_tprice' => '合同总额', - 'h_wid' => '签定人员', - 'h_totalnum' => '投放次数', - 'h_starttime' => '订单开始时间', - 'h_endtime' => '订单结束时间', - 'h_noticeday' => '提前通知天数', - 'h_addtime' => '录入时间', - 'h_updatetime' => '修改时间', - 'h_texta' => '投放周期', - 'h_tower' => '投放台数', - 'h_text' => '备注' + 'h_number' => '合同编号', + 'h_medium' => '投放媒介', + 'h_signtime' => '签订日期', + 'h_cid' => '签定公司', + 'h_tprice' => '合同总额', + 'h_wid' => '签定人员', + 'h_totalnum' => '投放次数', + 'h_starttime' => '订单开始时间', + 'h_endtime' => '订单结束时间', + 'h_noticeday' => '提前通知天数', + 'h_addtime' => '录入时间', + 'h_updatetime' => '修改时间', + 'h_texta' => '投放周期', + 'h_tower' => '投放台数', + 'h_text' => '备注', ]; } - + //企业资料 protected function tf_customer($sign = true) { global $_M, $_YW; + return [ - 'c_allname' => '公司名称', - 'c_name' => '公司简称', - 'c_address' => '公司地址', - 'c_lxname' => '联系人', - 'c_tel' => '联系电话', - 'c_addtime' => '录入时间', - 'c_updatetime' => '修改时间', - 'c_text' => '备注', + 'c_allname' => '公司名称', + 'c_name' => '公司简称', + 'c_address' => '公司地址', + 'c_lxname' => '联系人', + 'c_tel' => '联系电话', + 'c_addtime' => '录入时间', + 'c_updatetime' => '修改时间', + 'c_text' => '备注', ]; } - + //企业联系人 protected function tf_workers($sign = true) { global $_M, $_YW; + return [ // 'w_cid' => '隶属公司', - 'w_jid' => '职务id', - 'w_name' => '姓名', - 'w_tel' => '联系电话', - 'w_addtime' => '录入时间', - 'w_updatetime' => '修改时间', - 'w_text' => '备注', + 'w_jid' => '职务id', + 'w_name' => '姓名', + 'w_tel' => '联系电话', + 'w_addtime' => '录入时间', + 'w_updatetime' => '修改时间', + 'w_text' => '备注', ]; } - + //参数 protected function tf_para($sign = true) { global $_M, $_YW; + return [ - 'p_type' => '参数分类', - 'p_value' => '参数值', - 'p_name' => '参数名', - 'p_num' => '有多少数据在使用', - 'p_order' => '排序', - 'p_text' => '备注' + 'p_type' => '参数分类', + 'p_value' => '参数值', + 'p_name' => '参数名', + 'p_num' => '有多少数据在使用', + 'p_order' => '排序', + 'p_text' => '备注', ]; } - + // 投放页面选择广告位 protected function tf_launch($sign = true) { global $_M, $_YW; + return [ - 'l_title' => '名称', - 'l_hnumber' => '合同编号', - 'l_schedule' => '投放进度', - 'l_totalnum' => '广告位个数', - 'l_starttime' => '广告开始时间', - 'l_endtime' => '广告结束时间', - 'l_type' => '广告类型', - 'l_text' => '备注', - 'l_enumber' => '广告位编组(最多显示6个)', - 'l_addtime' => '录入时间', - 'l_updatetime' => '修改时间' + 'l_title' => '名称', + 'l_hnumber' => '合同编号', + 'l_schedule' => '投放进度', + 'l_totalnum' => '广告位个数', + 'l_starttime' => '广告开始时间', + 'l_endtime' => '广告结束时间', + 'l_type' => '广告类型', + 'l_text' => '备注', + 'l_enumber' => '广告位编组(最多显示6个)', + 'l_addtime' => '录入时间', + 'l_updatetime' => '修改时间', ]; } - + // 投放页面选择广告位 protected function tf_applan($sign = true) { global $_M, $_YW; + return [ - 'e_enable' => '状态', - 'e_number' => '广告位编号', - 'e_address' => '广告位地址', //虚拟字段 - 'endtitle' => '上个计划名称', - 'endstime' => '上个开始时间', - 'endetime' => '上个结束时间', - 'nowtitle' => '当前计划名称', - 'nowstime' => '当前开始时间', - 'nowetime' => '当前结束时间', - 'nexttitle' => '下个计划名称', - 'nextstime' => '下个开始时间', - 'nextetime' => '下个结束时间', - 'endtime' => '最大结束时间', - 'e_types' => '状态提示' + 'e_enable' => '状态', + 'e_number' => '广告位编号', + 'e_address' => '广告位地址', //虚拟字段 + 'endtitle' => '上个计划名称', + 'endstime' => '上个开始时间', + 'endetime' => '上个结束时间', + 'nowtitle' => '当前计划名称', + 'nowstime' => '当前开始时间', + 'nowetime' => '当前结束时间', + 'nexttitle' => '下个计划名称', + 'nextstime' => '下个开始时间', + 'nextetime' => '下个结束时间', + 'endtime' => '最大结束时间', + 'e_types' => '状态提示', ]; } - + //广告位查询统计 protected function tf_elevators($sign = true) { global $_M, $_YW; + return [ - 'e_enable' => '状态', - 'e_number' => '广告位编号', - 'e_address' => '广告位地址', //虚拟字段 - 'e_size' => '广告位规格', - 'endtitle' => '上个计划名称', - 'endstime' => '上个开始时间', - 'endetime' => '上个结束时间', - 'nowtitle' => '当前计划名称', - 'nowstime' => '当前开始时间', - 'nowetime' => '当前结束时间', - 'nexttitle' => '下个计划名称', - 'nextstime' => '下个开始时间', - 'nextetime' => '下个结束时间', - 'endtime' => '最大结束时间', - 'e_totalnum' => '投放次数', - 'etypes' => '排期状态' + 'e_enable' => '状态', + 'e_number' => '广告位编号', + 'e_address' => '广告位地址', //虚拟字段 + 'e_size' => '广告位规格', + 'endtitle' => '上个计划名称', + 'endstime' => '上个开始时间', + 'endetime' => '上个结束时间', + 'nowtitle' => '当前计划名称', + 'nowstime' => '当前开始时间', + 'nowetime' => '当前结束时间', + 'nexttitle' => '下个计划名称', + 'nextstime' => '下个开始时间', + 'nextetime' => '下个结束时间', + 'endtime' => '最大结束时间', + 'e_totalnum' => '投放次数', + 'etypes' => '排期状态', ]; } - + //广告位查询统计 protected function tf_villages($sign = true) { global $_M, $_YW; $array = [ - 'v_name' => '场所名称', - 'v_type' => '场所分类', - 'v_hcname' => '所属商圈', - 'v_district' => '所属区域', - 'v_address' => '场所地址', - 'v_enum' => '广告位', - 'v_ebnonum' => '门口方位', - 'v_free' => '广告位', - 'v_bno' => '门口方位', - 'v_lease' => '排期中的个数', - 'v_endday' => '到期个数', - 'v_prerow' => '预排的个数', - 'v_text' => '备注' + 'v_name' => '场所名称', + 'v_type' => '场所分类', + 'v_hcname' => '所属商圈', + 'v_district' => '所属区域', + 'v_address' => '场所地址', + 'v_enum' => '广告位', + 'v_ebnonum' => '门口方位', + 'v_free' => '广告位', + 'v_bno' => '门口方位', + 'v_lease' => '排期中的个数', + 'v_endday' => '到期个数', + 'v_prerow' => '预排的个数', + 'v_text' => '备注', ]; if ($this->bsign) { $array['v_free'] = '闲置广告位总数'; @@ -246,53 +274,57 @@ trait tfield } else { unset($array['v_district']); } + return $array; } - + //广告位查询统计 protected function tf_noticeday($sign = true) { global $_M, $_YW; + return [ - 'h_number' => '合同编号', - 'h_signtime' => '签订日期', - 'h_cid' => '签定公司', - 'h_tprice' => '合同总额', - 'h_wid' => '签定人员', - 'h_starttime' => '投放开始时间', - 'h_endtime' => '投放结束时间', - 'h_text' => '备注', + 'h_number' => '合同编号', + 'h_signtime' => '签订日期', + 'h_cid' => '签定公司', + 'h_tprice' => '合同总额', + 'h_wid' => '签定人员', + 'h_starttime' => '投放开始时间', + 'h_endtime' => '投放结束时间', + 'h_text' => '备注', // 'endtime' => '提醒时间', - 'htypes' => '提示说明' + 'htypes' => '提示说明', ]; } - + //前台巡查页面 protected function tf_patrol($sign = true) { global $_M, $_YW; + return [ - 'e_number' => '编号', - 'e_address' => '地址', //虚拟字段 - 'nowtitle' => '名称', + 'e_number' => '编号', + 'e_address' => '地址', //虚拟字段 + 'nowtitle' => '名称', // 'nowstime' => '开始时间', // 'nowetime' => '剩余', ]; } - + //巡查列表 protected function tf_keylist($sign = true) { global $_M, $_YW; + return [ // 'k_passkey' => '密钥密码', - 'k_basekey' => '密文密码', - 'k_wid' => '相关联系人', - 'k_state' => '密钥状态', - 'k_addtime' => '新增时间', - 'k_updatetime' => '修改时间', - 'k_text' => '备注' + 'k_basekey' => '密文密码', + 'k_wid' => '相关联系人', + 'k_state' => '密钥状态', + 'k_addtime' => '新增时间', + 'k_updatetime' => '修改时间', + 'k_text' => '备注', ]; } - + } diff --git a/include/traits/tlist.class.php b/include/traits/tlist.class.php index 3e12b8a..92e59c7 100644 --- a/include/traits/tlist.class.php +++ b/include/traits/tlist.class.php @@ -8,45 +8,135 @@ trait tlist { //按钮组 - protected $btn = []; - //禁用最后的按钮 - protected $banbtn = false; - // 开启下拉模式组合按钮 - protected $btn_group_toggle = false; - //相关参数缓存 protected static $para = []; - //相关公司缓存 + + //禁用最后的按钮 protected static $customer = []; - //相关联系人缓存 + + // 开启下拉模式组合按钮 protected static $workers = []; - //场所缓存 + + //相关参数缓存 protected static $village = []; + //相关公司缓存 + protected $btn = []; + + //相关联系人缓存 + protected $banbtn = false; + + //场所缓存 + protected $btn_group_toggle = false; + //公用删除 //$query 主要用来替换删除按钮的值 + private $serial_number = 0; + + //整合 + protected function elevator($val, $checked = '') + { + global $_M, $_YW; + //获取字段 + $key = self::tf_elevator(); + + //列表前段 + $base[] = ' + + + '; + //对字段处理 + //门口方位 + if (empty(self::$para['e_bno'])) { + self::$para['e_bno'] = parent::translate(3); + } + //广告位置 + if (empty(self::$para['e_aps'])) { + self::$para['e_aps'] = parent::translate(); + } + //场所 + if (empty(self::$village[$val['e_vid']])) { + self::$village[$val['e_vid']] = parent::villagelist($val['e_vid']); + } + + $scheduleurl = $this->own_name_table.'elevators&e_number='.$val['e_number']; + + $val['e_number'] = ' '.$val['e_number'].''; + $val['e_enable'] = parent::type_onoff('e_enable', $val['e_enable'], $val['id'], ['禁用', '启用']); + + $val['e_vid'] = self::$village[$val['e_vid']]; + $val['e_bno'] = self::$para['e_bno'][$val['e_bno']]; + $val['e_aps'] = self::$para['e_aps'][$val['e_aps']]; + $val['e_state'] = parent::e_state(); + $val['e_label'] = parent::tab_tokenfield($val['e_label'], 2); + + //执行操作按钮 + if (empty($checked)) { + $addtourl = $this->own_name_info.__FUNCTION__.'&id='.$val['id']; + $this->btn[] = '编辑'; + } + //跳过标记突出处理 + $this->skip_field = ['e_number']; + + return self::assemble($key, $base, $val, $checked); + } + + //广告位详细地址转换 + private function assemble($key, $base, $val, $checked, $query = []) + { + global $_M, $_YW; + //搜索处理 + foreach ($this->search_input as $vs) { + if (in_array($vs, $this->skip_field, true)) { + continue; + } + $search = trim(strtoupper($this->form[$vs])); + if ($search != null) { + $val[$vs] = str_ireplace( + $search, + ''.$search.'', + $val[$vs] + ); + } + } + //按钮组处理 + $operation = []; + if ($this->banbtn == false) { + $operation['__operation'] = self::btn_group($val, $checked, $query); + } + + //结果整合处理 + return array_merge( + $base, + $key, + array_intersect_key($val, $key), + $operation + ); + } + + // 到期通知计算【新的】 protected function btn_group($val, $checked, $query = []) { global $_M, $_YW; if (empty($checked)) { if ($query !== false) { $para = [ - 'c' => 'table_off', - 'a' => 'doindex', - 'submit_type' => 'delet', - 'all_id' => $val['id'], - 'tname' => $this->tname, + 'c' => 'table_off', + 'a' => 'doindex', + 'submit_type' => 'delet', + 'all_id' => $val['id'], + 'tname' => $this->tname, ]; $query = array_merge($para, $query); $href = parent::http_build_query($_M['url']['own_name'], $query); - $this->btn[] = 'btn[] = '删除'; } } else { @@ -56,159 +146,24 @@ trait tlist $btnstr = arrayto_string($this->btn, ''); unset($this->btn); // 普通按钮组合 - $btngroup = '
' . $btnstr . '
'; + $btngroup = '
'.$btnstr.'
'; // 下拉方式的组合按钮组 $btngrouptoggle = '
- - +
'; + return $this->btn_group_toggle ? $btngrouptoggle : $btngroup; } } - //整合 - private function assemble($key, $base, $val, $checked, $query = []) - { - global $_M, $_YW; - //搜索处理 - foreach ($this->search_input as $vs) { - if (in_array($vs, $this->skip_field, true)) - continue; - $search = trim(strtoupper($this->form[ $vs ])); - if ($search != null) - $val[ $vs ] = str_ireplace($search, '' . $search . '', $val[ $vs ]); - } - //按钮组处理 - $operation = []; - if ($this->banbtn == false) - $operation['__operation'] = self::btn_group($val, $checked, $query); - //结果整合处理 - return array_merge($base, $key, array_intersect_key($val, $key), $operation); - } - - //广告位详细地址转换 - protected function eaddress(&$val, $_address = 'e_address', $sign = false) - { - global $_M, $_YW; - //门口方位 - if (empty(self::$para['e_bno'])) self::$para['e_bno'] = parent::translate(3); - //广告位置 - if (empty(self::$para['e_aps'])) self::$para['e_aps'] = parent::translate(); - //场所 - if (array_key_exists('v_hcname', $val) || array_key_exists('v_vaddress', $val)) { - //小区 - if (empty(self::$village[ $val['e_vid'] ])) self::$village[ $val['e_vid'] ] = parent::villagelist($val['e_vid'], ['v_name', 'v_hcname', 'v_district', 'v_city', 'v_province', 'v_address']); - } else { - //小区 - if (empty(self::$village[ $val['e_vid'] ])) self::$village[ $val['e_vid'] ] = parent::villagelist($val['e_vid']); - } - - if ($sign) { - if (array_key_exists('v_hcname', $val) || array_key_exists('v_vaddress', $val)) { - $evid = $val['e_vid']; - $val['e_vid'] = self::$village[ $evid ]['v_name']; - $val['v_hcname'] = self::$village[ $evid ]['v_hcname']; - // $val['v_vaddress'] = self::$village[ $evid ]['v_province'] . self::$village[ $evid ]['v_city'] . self::$village[ $evid ]['v_district'] . self::$village[ $evid ]['v_address']; - $val['v_vaddress'] = self::$village[ $evid ]['v_district'] . self::$village[ $evid ]['v_address']; - } else { - $val['e_vid'] = self::$village[ $val['e_vid'] ]; - } - $val['e_bno'] = self::$para['e_bno'][ $val['e_bno'] ]; - $val['e_aps'] = self::$para['e_aps'][ $val['e_aps'] ]; - } else { - if (array_key_exists('v_hcname', $val) || array_key_exists('v_vaddress', $val)) { - $evid = $val['e_vid']; - $v_hcname = self::$village[ $evid ]['v_hcname']; - $evidname = self::$village[ $evid ]['v_name']; - if ($v_hcname) $evidname .= "(" . $v_hcname . ")"; - // $val['v_vaddress'] = self::$village[ $evid ]['v_province'] . self::$village[ $evid ]['v_city'] . self::$village[ $evid ]['v_district'] . self::$village[ $evid ]['v_address']; - $val['v_vaddress'] = self::$village[ $evid ]['v_district'] . self::$village[ $evid ]['v_address']; - } else { - $evidname = self::$village[ $val['e_vid'] ]; - } - $villages = [ - $evidname, - self::$para['e_bno'][ $val['e_bno'] ], - self::$para['e_aps'][ $val['e_aps'] ] - ]; - $val[ $_address ] = arrayto_string($villages, ' '); - } - } - - // 到期通知计算【新的】 - protected function noticestr($noticeday) - { - //首先判断当前这条信息是属于到期前台3天的 还是属于设置的提醒 - //那就是判断订单结束时间和今天的相差天数 - $day = abs($noticeday); - if ($noticeday > 3) { - //按照设置的提醒来计算 - $str = parent::str_color(1, $day, 800); - $htypes = "{$str} 天后到期提醒"; - } else { - //按照前后3天来设置 - if ($noticeday > 0) { - $str = parent::str_color(4, $day, 800); - //说明还没到期 - $htypes = "{$str} 天后到期"; - } else { - //说明已经到期或者过期 - $htypes = $noticeday == 0 ? parent::str_color(0, '今天到期', 800) : parent::str_color(5, "已过期 {$day} 天", 800); - } - } - return $htypes; - } - // +---------------------------------------------------------------------- // | 各表处理 // +---------------------------------------------------------------------- //广告位统计 - protected function elevator($val, $checked = '') - { - global $_M, $_YW; - //获取字段 - $key = self::tf_elevator(); - - //列表前段 - $base[] = ' - - - '; - //对字段处理 - //门口方位 - if (empty(self::$para['e_bno'])) - self::$para['e_bno'] = parent::translate(3); - //广告位置 - if (empty(self::$para['e_aps'])) - self::$para['e_aps'] = parent::translate(); - //场所 - if (empty(self::$village[ $val['e_vid'] ])) - self::$village[ $val['e_vid'] ] = parent::villagelist($val['e_vid']); - - $scheduleurl = $this->own_name_table . 'elevators&e_number=' . $val['e_number']; - - $val['e_number'] = ' ' . $val['e_number'] . ''; - $val['e_enable'] = parent::type_onoff('e_enable', $val['e_enable'], $val['id'], ['禁用', '启用']); - - $val['e_vid'] = self::$village[ $val['e_vid'] ]; - $val['e_bno'] = self::$para['e_bno'][ $val['e_bno'] ]; - $val['e_aps'] = self::$para['e_aps'][ $val['e_aps'] ]; - $val['e_state'] = parent::e_state(); - $val['e_label'] = parent::tab_tokenfield($val['e_label'], 2); - - //执行操作按钮 - if (empty($checked)) { - $addtourl = $this->own_name_info . __FUNCTION__ . '&id=' . $val['id']; - $this->btn[] = '编辑'; - } - //跳过标记突出处理 - $this->skip_field = ['e_number']; - return self::assemble($key, $base, $val, $checked); - } - //场所统计 protected function village($val, $checked = '') { global $_M, $_YW; @@ -217,65 +172,167 @@ trait tlist //列表前段 $base[] = ' - + '; //对字段处理 //场所分类 - if (empty(self::$para['v_type'])) + if (empty(self::$para['v_type'])) { self::$para['v_type'] = parent::translate(6); + } - $vnameurl = $this->own_name_table . 'elevator&e_vid=' . $val['id']; + $vnameurl = $this->own_name_table.'elevator&e_vid='.$val['id']; $totalstr = arrayto_string([$val['total'], $val['noban'], $val['normal']], ' / '); - $val['v_name'] = ' ' . $val['v_name'] . ''; - $val['v_type'] = self::$para['v_type'][ $val['v_type'] ]; + $val['v_name'] = ' '.$val['v_name'].''; + $val['v_type'] = self::$para['v_type'][$val['v_type']]; $val['v_tel'] = parent::tab_tokenfield($val['v_tel'], 1); - $val['v_address'] = $val['v_province'] . $val['v_city'] . $val['v_district'] . $val['v_address']; + $val['v_address'] = $val['v_province'].$val['v_city'].$val['v_district'].$val['v_address']; $val['v_forbidtype'] = parent::tab_tokenfield($val['v_forbidtype'], 2); $val['v_totalstr'] = $val['noban'] > 0 ? parent::str_color(0, $totalstr, 600) : $totalstr; - $val['v_lnglat'] = $val['v_maplng'] . $val['v_maplat']; + $val['v_lnglat'] = $val['v_maplng'].$val['v_maplat']; //执行操作按钮 if (empty($checked)) { $this->btn_group_toggle = '操作按钮'; - $this->btn[] = '查看广告位'; - $addtourl = $this->own_name_info . __FUNCTION__ . '&id=' . $val['id']; - $this->btn[] = '编辑'; + $this->btn[] = '查看广告位'; + $addtourl = $this->own_name_info.__FUNCTION__.'&id='.$val['id']; + $this->btn[] = '编辑'; } - + //跳过标记突出处理 $this->skip_field = ['v_hcname']; return self::assemble($key, $base, $val, $checked); } - //广告合同关联表 + // 排期导出 + protected function expschedule($val, $checked = '', $base = []) + { + //获取字段 + $key = self::tf_expschedule(); + //对字段处理 + $this->serial_number++; + $val['serial_number'] = $this->serial_number; + $val['media_type'] = '社区道闸'; + // 因为是按照广告位导出的,虽然表格中没有提现广告位置,但是若是道闸位置一样,会出现重复,若是需要有意义,查询时就要按照ID、道闸位置对dzadsod_elevator合并计算,这样前面显示的个数就出现合并了 + $val['number'] = 1; + + // 为了获取所有的信息 + $val['v_vaddress'] = ''; + self::eaddress($val, 'village', $this->bsign); + + return self::assemble($key, $base, $val, $checked, false); + } + + //场所统计 + + protected function eaddress(&$val, $_address = 'e_address', $sign = false) + { + global $_M, $_YW; + //门口方位 + if (empty(self::$para['e_bno'])) { + self::$para['e_bno'] = parent::translate(3); + } + //广告位置 + if (empty(self::$para['e_aps'])) { + self::$para['e_aps'] = parent::translate(); + } + //场所分类 + if (empty(self::$para['v_type'])) { + self::$para['v_type'] = parent::translate(6); + } + //场所 + if (array_key_exists('v_hcname', $val) || array_key_exists('v_vaddress', $val)) { + //小区 + if (empty(self::$village[$val['e_vid']])) { + self::$village[$val['e_vid']] = parent::villagelist( + $val['e_vid'], + [ + 'v_name', + 'v_hcname', + 'v_district', + 'v_city', + 'v_province', + 'v_address', + 'v_type', + ] + ); + } + } else { + //小区 + if (empty(self::$village[$val['e_vid']])) { + self::$village[$val['e_vid']] = parent::villagelist($val['e_vid']); + } + } + + if ($sign) { + if (array_key_exists('v_hcname', $val) || array_key_exists('v_vaddress', $val)) { + $evid = $val['e_vid']; + $val['e_vid'] = self::$village[$evid]['v_name']; + $val['v_city'] = self::$village[$evid]['v_city']; + $val['v_district'] = self::$village[$evid]['v_district']; + $val['v_hcname'] = self::$village[$evid]['v_hcname']; + $val['v_address'] = self::$village[$evid]['v_address']; + $val['v_type'] = self::$para['v_type'][self::$village[$evid]['v_type']]; + // $val['v_vaddress'] = self::$village[ $evid ]['v_province'] . self::$village[ $evid ]['v_city'] . self::$village[ $evid ]['v_district'] . self::$village[ $evid ]['v_address']; + $val['v_vaddress'] = self::$village[$evid]['v_district'].self::$village[$evid]['v_address']; + } else { + $val['e_vid'] = self::$village[$val['e_vid']]; + } + $val['e_bno'] = self::$para['e_bno'][$val['e_bno']]; + $val['e_aps'] = self::$para['e_aps'][$val['e_aps']]; + } else { + if (array_key_exists('v_hcname', $val) || array_key_exists('v_vaddress', $val)) { + $evid = $val['e_vid']; + $v_hcname = self::$village[$evid]['v_hcname']; + $evidname = self::$village[$evid]['v_name']; + if ($v_hcname) { + $evidname .= "(".$v_hcname.")"; + } + // $val['v_vaddress'] = self::$village[ $evid ]['v_province'] . self::$village[ $evid ]['v_city'] . self::$village[ $evid ]['v_district'] . self::$village[ $evid ]['v_address']; + $val['v_vaddress'] = self::$village[$evid]['v_district'].self::$village[$evid]['v_address']; + } else { + $evidname = self::$village[$val['e_vid']]; + } + $villages = [ + $evidname, + self::$para['e_bno'][$val['e_bno']], + self::$para['e_aps'][$val['e_aps']], + ]; + $val[$_address] = arrayto_string($villages, ' '); + } + } + protected function schedule($val, $checked = '', $base = []) { global $_M, $_YW; //获取字段 $key = self::tf_schedule(); - //对字段处理 //公司名称 - if (empty(self::$customer[ $val['h_cid'] ])) - self::$customer[ $val['h_cid'] ] = parent::customerlist($val['h_cid']); + if (empty(self::$customer[$val['h_cid']])) { + self::$customer[$val['h_cid']] = parent::customerlist($val['h_cid']); + } $s_type = strtotime($val['l_endtime']) >= strtotime(date('Y-m-d', time())) ? 1 : 0; - if (empty(self::$para['ltype']) && $s_type) + if (empty(self::$para['ltype']) && $s_type) { self::$para['ltype'] = parent::translate(2); + } - $val['ltype'] = parent::state_color($s_type, ['已经结束', self::$para['ltype'][ $val['l_schedule'] ]]); - $val['h_cid'] = self::$customer[ $val['h_cid'] ]; - $val['e_enable'] = $val['e_enable'] == 0 || $this->bsign == false ? parent::state_color($val['e_enable'], ['禁用', '启用']) : ''; + $val['ltype'] = parent::state_color($s_type, ['已经结束', self::$para['ltype'][$val['l_schedule']]]); + $val['h_cid'] = self::$customer[$val['h_cid']]; + $val['e_enable'] = $val['e_enable'] == 0 || $this->bsign == false ? parent::state_color($val['e_enable'], ['禁用', '启用']) + : ''; // 显示商圈 $val['v_hcname'] = $val['v_vaddress'] = ''; self::eaddress($val, 'l_address', $this->bsign); + return self::assemble($key, $base, $val, $checked, false); } - //合同归档 + //广告合同关联表 + protected function contract($val, $checked = '') { global $_M, $_YW; @@ -284,59 +341,77 @@ trait tlist //列表前段 $base[] = ' - + '; //对字段处理 //公司名称 - if (empty(self::$customer[ $val['h_cid'] ])) - self::$customer[ $val['h_cid'] ] = parent::customerlist($val['h_cid']); + if (empty(self::$customer[$val['h_cid']])) { + self::$customer[$val['h_cid']] = parent::customerlist( + $val['h_cid'] + ); + } //投放媒介 - if (empty(self::$para['h_medium'])) + if (empty(self::$para['h_medium'])) { self::$para['h_medium'] = parent::translate(4); + } $h_mediumid = stringto_array($val['h_medium'], '#@met@#'); foreach ($h_mediumid as $hmid) { - $hmediumid[] = self::$para['h_medium'][ $hmid ]; + $hmediumid[] = self::$para['h_medium'][$hmid]; } //相关人员 $workerswid = stringto_array($val['h_wid'], ','); foreach ($workerswid as $hwid) { - if (empty(self::$workers[ $hwid ])) - self::$workers[ $hwid ] = parent::workerslist($hwid); - $workersstr[] = self::$workers[ $hwid ]; + if (empty(self::$workers[$hwid])) { + self::$workers[$hwid] = parent::workerslist($hwid); + } + $workersstr[] = self::$workers[$hwid]; } //内连接 $h_number = $val['h_number']; //避免后面采用 - $launchurl = $this->own_name_table . 'launch&l_hnumber=' . $h_number; + $launchurl = $this->own_name_table.'launch&l_hnumber='.$h_number; $curdate = date('Y-m-d', time()); - $val['h_number'] = ' ' . $h_number . ''; - $val['h_cid'] = self::$customer[ $val['h_cid'] ]; - $val['h_wid'] = parent::tab_tokenfield(arrayto_string($workersstr), 1); + $val['h_number'] = ' '.$h_number + .''; + $val['h_cid'] = self::$customer[$val['h_cid']]; + $val['h_wid'] = parent::tab_tokenfield( + arrayto_string($workersstr), + 1 + ); $val['h_noticeday'] = parent::tab_tokenfield($val['h_noticeday'], 2); - $val['h_medium'] = parent::tab_tokenfield(arrayto_string($hmediumid, ',')); - $val['h_starttime'] = strtotime($val['h_starttime']) > strtotime($curdate) ? parent::str_color(2, $val['h_starttime'], 600) : $val['h_starttime']; - $val['h_endtime'] = strtotime($val['h_endtime']) < strtotime($curdate) ? parent::str_color(0, $val['h_endtime'], 600) : $val['h_endtime']; + $val['h_medium'] = parent::tab_tokenfield( + arrayto_string($hmediumid, ',') + ); + $val['h_starttime'] = strtotime($val['h_starttime']) > strtotime( + $curdate + ) ? parent::str_color(2, $val['h_starttime'], 600) + : $val['h_starttime']; + $val['h_endtime'] = strtotime($val['h_endtime']) < strtotime($curdate) + ? parent::str_color(0, $val['h_endtime'], 600) : $val['h_endtime']; //执行操作按钮 if (empty($checked)) { $this->btn_group_toggle = '操作按钮'; - $addtourl = $this->own_name_info . 'launch&cid=' . $val['id']; - $this->btn[] = '新增投放'; - $this->btn[] = '查看投放'; - $addtourl = $_M['url']['own_name'] . 'c=backups&a=doindex&tname=schedule&l_hnumber=' . $h_number; - $this->btn[] = '导出排期'; - $addtourl = $this->own_name_info . __FUNCTION__ . '&id=' . $val['id']; - $this->btn[] = '编辑'; + $addtourl = $this->own_name_info.'launch&cid='.$val['id']; + $this->btn[] = '新增投放'; + $this->btn[] = '查看投放'; + // $addtourl = $_M['url']['own_name'].'c=backups&a=doindex&tname=schedule&l_hnumber='.$h_number; + $addtourl = $_M['url']['own_name'].'c=backups&a=doindex&tname=expschedule&l_hnumber='.$h_number; + $this->btn[] = '导出排期'; + $addtourl = $this->own_name_info.__FUNCTION__.'&id='.$val['id']; + $this->btn[] = '编辑'; } //跳过标记突出处理 $this->skip_field = ['h_number']; + return self::assemble($key, $base, $val, $checked); } - //公司资料 + //合同归档 + protected function customer($val, $checked = '') { global $_M, $_YW; @@ -345,25 +420,33 @@ trait tlist //列表前段 $base[] = ' - + '; //对字段处理 - $hcidurl = $this->own_name_table . 'contract&h_cid=' . $val['id']; - $val['c_allname'] = ' ' . $val['c_allname'] . ''; + $hcidurl = $this->own_name_table.'contract&h_cid=' + .$val['id']; + $val['c_allname'] = ' '.$val['c_allname'] + .''; $val['c_tel'] = parent::tab_tokenfield($val['c_tel'], 1); - $val['c_address'] = $val['c_province'] . $val['c_city'] . $val['c_district'] . $val['c_address']; + $val['c_address'] = $val['c_province'].$val['c_city'] + .$val['c_district'].$val['c_address']; //执行操作按钮 if (empty($checked)) { - $addtourl = $this->own_name_info . __FUNCTION__ . '&id=' . $val['id']; - $this->btn[] = '编辑'; + $addtourl = $this->own_name_info.__FUNCTION__.'&id=' + .$val['id']; + $this->btn[] = '编辑'; } + return self::assemble($key, $base, $val, $checked); } - //企业联系人 + //公司资料 + protected function workers($val, $checked = '') { global $_M, $_YW; @@ -372,28 +455,34 @@ trait tlist //列表前段 $base[] = ' - + '; //拿到对应的ID //职务 - if (empty(self::$para)) + if (empty(self::$para)) { self::$para = parent::translate(1); + } //对字段处理 - $val['w_jid'] = self::$para[ $val['w_jid'] ]; + $val['w_jid'] = self::$para[$val['w_jid']]; $val['w_tel'] = parent::tab_tokenfield($val['w_tel'], 1); //执行操作按钮 if (empty($checked)) { - $addtourl = $this->own_name_info . __FUNCTION__ . '&id=' . $val['id']; - $this->btn[] = '编辑'; + $addtourl = $this->own_name_info.__FUNCTION__.'&id=' + .$val['id']; + $this->btn[] = '编辑'; } + return self::assemble($key, $base, $val, $checked); } - //参数统计 + //企业联系人 + protected function para($val, $checked = '') { global $_M, $_YW; @@ -402,7 +491,8 @@ trait tlist //列表前段 $base[] = ' - + '; @@ -410,22 +500,34 @@ trait tlist //优先计算 switch ($val['p_type']) { case 0: - $p_num = $this->tsql->table('elevator')->where(['e_aps' => $val['p_value']])->count(); + $p_num = $this->tsql->table('elevator')->where( + ['e_aps' => $val['p_value']] + )->count(); break; case 1: - $p_num = $this->tsql->table('workers')->where(['w_jid' => $val['p_value']])->count(); + $p_num = $this->tsql->table('workers')->where( + ['w_jid' => $val['p_value']] + )->count(); break; case 2: - $p_num = $this->tsql->table('launch')->where(['l_schedule' => $val['p_value']])->count(); + $p_num = $this->tsql->table('launch')->where( + ['l_schedule' => $val['p_value']] + )->count(); break; case 3: - $p_num = $this->tsql->table('elevator')->where(['e_bno' => $val['p_value']])->count(); + $p_num = $this->tsql->table('elevator')->where( + ['e_bno' => $val['p_value']] + )->count(); break; case 6: - $p_num = $this->tsql->table('village')->where(['v_type' => $val['p_value']])->count(); + $p_num = $this->tsql->table('village')->where( + ['v_type' => $val['p_value']] + )->count(); break; case 7: - $p_num = $this->tsql->table('launch')->where(['l_type' => $val['p_value']])->count(); + $p_num = $this->tsql->table('launch')->where( + ['l_type' => $val['p_value']] + )->count(); break; default: @@ -437,10 +539,12 @@ trait tlist $readonly = ' readonly="readonly" '; } - $inputp_num = ''; - $val['p_num'] = $checked ? $inputp_num : $p_num . ' 条' . $inputp_num; + $inputp_num = ''; + $val['p_num'] = $checked ? $inputp_num : $p_num.' 条'.$inputp_num; $val['p_type'] = '
- @@ -451,21 +555,35 @@ trait tlist
'; $val['p_order'] = '
- +
'; $val['p_name'] = '
- +
'; $val['p_value'] = '
- +
'; - $val['p_text'] = ''; + $val['p_text'] = ''; //执行操作按钮 - return self::assemble($key, $base, $val, $checked, $p_num > 0 ? false : []); + return self::assemble( + $key, + $base, + $val, + $checked, + $p_num > 0 ? false : [] + ); } - //投放计划 + //参数统计 + protected function launch($val, $checked = '') { global $_M, $_YW; @@ -474,44 +592,71 @@ trait tlist //列表前段 $base[] = ' - + '; //对字段处理 - if (empty(self::$para['l_schedule'])) + if (empty(self::$para['l_schedule'])) { self::$para['l_schedule'] = parent::translate(2); - if (empty(self::$para['l_type'])) + } + if (empty(self::$para['l_type'])) { self::$para['l_type'] = parent::translate(7); + } $enum = count(array_filter(stringto_array($val['l_enumber'], ','))); - $snum = count(array_filter(stringto_array($val['l_selectenum'], ','))); + $snum = count( + array_filter(stringto_array($val['l_selectenum'], ',')) + ); $esstr = " {$enum} / {$snum} "; $curdate = date('Y-m-d', time()); - $l_titleurl = $this->own_name_table . 'schedule&l_id=' . $val['id']; - $val['l_totalnum'] = $enum == $snum ? $esstr : parent::state_color(0, [$esstr]); //放在最前面,防止后面对l_enumber 字段的处理 - $val['l_title'] = ' ' . $val['l_title'] . ''; - $val['l_enumber'] = parent::tab_tokenfield($val['l_enumber'], 1, ',', 6); - $val['l_schedule'] = parent::tab_tokenfield(self::$para['l_schedule'][ $val['l_schedule'] ], 1); - $val['l_type'] = self::$para['l_type'][ $val['l_type'] ]; + $l_titleurl = $this->own_name_table.'schedule&l_id=' + .$val['id']; + $val['l_totalnum'] = $enum == $snum + ? $esstr + : parent::state_color( + 0, + [$esstr] + ); //放在最前面,防止后面对l_enumber 字段的处理 + $val['l_title'] = ' '.$val['l_title'] + .''; + $val['l_enumber'] = parent::tab_tokenfield( + $val['l_enumber'], + 1, + ',', + 6 + ); + $val['l_schedule'] = parent::tab_tokenfield( + self::$para['l_schedule'][$val['l_schedule']], + 1 + ); + $val['l_type'] = self::$para['l_type'][$val['l_type']]; - $val['l_starttime'] = strtotime($val['l_starttime']) > strtotime($curdate) ? parent::str_color(2, $val['l_starttime'], 600) : $val['l_starttime']; - $val['l_endtime'] = strtotime($val['l_endtime']) < strtotime($curdate) ? parent::str_color(0, $val['l_endtime'], 600) : $val['l_endtime']; + $val['l_starttime'] = strtotime($val['l_starttime']) > strtotime( + $curdate + ) ? parent::str_color(2, $val['l_starttime'], 600) + : $val['l_starttime']; + $val['l_endtime'] = strtotime($val['l_endtime']) < strtotime($curdate) + ? parent::str_color(0, $val['l_endtime'], 600) : $val['l_endtime']; //执行操作按钮 if (empty($checked)) { $this->btn_group_toggle = '操作按钮'; - $this->btn[] = '查看排期'; - $addtourl = $_M['url']['own_name'] . 'c=backups&a=doindex&tname=schedule&id=' . $val['id']; - $this->btn[] = '导出排期'; - $addtourl = $this->own_name_info . __FUNCTION__ . '&fzid=' . $val['id'] . '&eaps_order=2'; - $this->btn[] = '复制'; - $addtourl = $this->own_name_info . __FUNCTION__ . '&slid=' . $val['id'] . '&eaps_order=2'; - $this->btn[] = '编辑'; + $this->btn[] = '查看排期'; + // $addtourl = $_M['url']['own_name'].'c=backups&a=doindex&tname=schedule&id='.$val['id']; + $addtourl = $_M['url']['own_name'].'c=backups&a=doindex&tname=expschedule&id='.$val['id']; + $this->btn[] = '导出排期'; + $addtourl = $this->own_name_info.__FUNCTION__.'&fzid='.$val['id'].'&eaps_order=2'; + $this->btn[] = '复制'; + $addtourl = $this->own_name_info.__FUNCTION__.'&slid='.$val['id'].'&eaps_order=2'; + $this->btn[] = '编辑'; } + return self::assemble($key, $base, $val, $checked); } - //广告位统计 + //投放计划 + protected function applan($val, $checked = '') { global $_M, $_YW; @@ -521,7 +666,11 @@ trait tlist //列表前段 $e_number = $val['e_number']; //判断之前是否已经选中 - $ebool = in_array($e_number, array_filter(stringto_array($this->form['l_selectenum'], ',')), true); + $ebool = in_array( + $e_number, + array_filter(stringto_array($this->form['l_selectenum'], ',')), + true + ); //给予选中标识 $class = ' checkbox-primary '; //刚选择默认颜色 //$val['lanum'] 大于0 说明重复,不可投放 @@ -529,11 +678,18 @@ trait tlist $apchecked = ' checked '; $slid = $this->form['slid']; //判断排期表内是否存在 - if (!empty($this->form['slid'])) { - if (empty(self::$para[ $slid ])) - self::$para[ $slid ] = $this->tsql->table('launch')->where(['id' => $slid])->one(); - $l_hnumber = stringto_array(self::$para[ $slid ]['l_enumber'], ','); - $class = in_array($e_number, $l_hnumber, true) ? ' checkbox-success ' : ' checkbox-danger '; //刚选择默认颜色 + if ( ! empty($this->form['slid'])) { + if (empty(self::$para[$slid])) { + self::$para[$slid] = $this->tsql->table('launch')->where( + ['id' => $slid] + )->one(); + } + $l_hnumber = stringto_array( + self::$para[$slid]['l_enumber'], + ',' + ); + $class = in_array($e_number, $l_hnumber, true) + ? ' checkbox-success ' : ' checkbox-danger '; //刚选择默认颜色 } } @@ -548,7 +704,9 @@ trait tlist } else { $s_starttime = $_M['form']['l_starttime']; $s_endtime = $_M['form']['l_endtime']; - if ($s_starttime && $s_endtime && strtotime($s_starttime) <= strtotime($s_endtime)) { + if ($s_starttime && $s_endtime + && strtotime($s_starttime) <= strtotime($s_endtime) + ) { //判断是否可排期成功 if ($val['lanum'] > 0) { $e_types = parent::str_color(0, '禁止投放'); @@ -566,8 +724,9 @@ trait tlist } // checkbox-danger 没有在排期库的显示为红色 checkbox-primary 正常的显示蓝色 checkbox-success 绿色 - $base[] = ' - + $base[] = ' + '; @@ -575,22 +734,32 @@ trait tlist $curtime = strtotime(date('Y-m-d', time())); //上个排期 if (strtotime($val['endetime']) < $curtime) { - $val['endtitle'] = '' . $val['endtitle'] . ''; - $val['endstime'] = '' . $val['endstime'] . ''; - $val['endetime'] = '' . $val['endetime'] . ''; + $val['endtitle'] = ''.$val['endtitle'] + .''; + $val['endstime'] = ''.$val['endstime'] + .''; + $val['endetime'] = ''.$val['endetime'] + .''; } - $val['endtime'] = strtotime($val['endtime']) < $curtime ? '' . $val['endtime'] . '' : $val['endtime']; + $val['endtime'] = strtotime($val['endtime']) < $curtime + ? ''.$val['endtime'] + .'' : $val['endtime']; $val['e_types'] = $e_types; - $val['e_enable'] = parent::state_color($val['e_enable'], ['禁用', '启用']); + $val['e_enable'] = parent::state_color( + $val['e_enable'], + ['禁用', '启用'] + ); self::eaddress($val, 'e_address'); //比较每个广告位的结束时间 和 现在设置的投放订单的开始时间 大小 //禁用最后的按钮 $this->banbtn = true; + return self::assemble($key, $base, $val, $checked, false); } //广告位统计 + protected function elevators($val, $checked = '') { global $_M, $_YW; @@ -599,44 +768,68 @@ trait tlist //列表前段 $base[] = ' - + '; //对字段处理 $curtime = strtotime(date('Y-m-d', time())); - $scheduleurl = $this->own_name_table . 'schedule&e_number=' . $val['e_number']; - $uplaunchurl = $this->own_name_info . 'uplaunch&e_number=' . $val['e_number']; + $scheduleurl = $this->own_name_table.'schedule&e_number=' + .$val['e_number']; + $uplaunchurl = $this->own_name_info.'uplaunch&e_number=' + .$val['e_number']; - $val['e_number'] = ' ' . $val['e_number'] . ''; - $val['etypes'] = parent::state_color($val['etypes'], [$val['e_enable'] ? '空位' : '已禁用', '排期中']); - $val['e_enable'] = parent::state_color($val['e_enable'], ['禁用', '启用']); + $val['e_number'] = ' '.$val['e_number'] + .''; + $val['etypes'] = parent::state_color( + $val['etypes'], + [$val['e_enable'] ? '空位' : '已禁用', '排期中'] + ); + $val['e_enable'] = parent::state_color( + $val['e_enable'], + ['禁用', '启用'] + ); - $scheduleurlid = $this->own_name_table . 'schedule&l_id='; - $val['endtitle'] = $val['endtitle'] ? '' . $val['endtitle'] . '' : ''; - $val['nowtitle'] = $val['nowtitle'] ? '' . $val['nowtitle'] . '' : ''; - $val['nexttitle'] = $val['nexttitle'] ? '' . $val['nexttitle'] . '' : ''; + $scheduleurlid = $this->own_name_table.'schedule&l_id='; + $val['endtitle'] = $val['endtitle'] ? '' + .$val['endtitle'].'' : ''; + $val['nowtitle'] = $val['nowtitle'] ? '' + .$val['nowtitle'].'' : ''; + $val['nexttitle'] = $val['nexttitle'] ? '' + .$val['nexttitle'].'' + : ''; // 显示商圈 $val['v_hcname'] = ''; self::eaddress($val, 'e_address'); - $val['endtime'] = strtotime($val['endtime']) < $curtime ? '' . $val['endtime'] . '' : $val['endtime']; + $val['endtime'] = strtotime($val['endtime']) < $curtime + ? ''.$val['endtime'] + .'' : $val['endtime']; //上个排期 if (strtotime($val['endetime']) < $curtime) { - $val['endstime'] = '' . $val['endstime'] . ''; - $val['endetime'] = '' . $val['endetime'] . ''; + $val['endstime'] = ''.$val['endstime'] + .''; + $val['endetime'] = ''.$val['endetime'] + .''; } //执行操作按钮 if (empty($checked)) { // $this->btn[] = '调整排期'; - $this->btn[] = '查看排期'; + $this->btn[] = '查看排期'; } //跳过标记突出处理 $this->skip_field = ['e_number']; + return self::assemble($key, $base, $val, $checked, false); } - //场所统计展示 + //广告位统计 + protected function villages($val, $checked = '') { global $_M, $_YW; @@ -645,43 +838,64 @@ trait tlist //列表前段 $base[] = ' - + '; //场所分类 - if (empty(self::$para['v_type'])) + if (empty(self::$para['v_type'])) { self::$para['v_type'] = parent::translate(6); + } //对字段处理 - $scheduleurl = $this->own_name_table . 'schedule&e_vid=' . $val['id']; + $scheduleurl = $this->own_name_table.'schedule&e_vid='.$val['id']; - $val['v_name'] = ' ' . $val['v_name'] . ''; - $val['v_type'] = self::$para['v_type'][ $val['v_type'] ]; - $val['v_free'] = $val['v_free'] ? '' . $val['v_free'] . '' : $val['v_free']; - $val['v_lease'] = $val['v_lease'] ? '' . $val['v_lease'] . '' : $val['v_lease']; - $val['v_endday'] = $val['v_endday'] ? '' . $val['v_endday'] . '' : $val['v_endday']; - $val['v_prerow'] = $val['v_prerow'] ? '' . $val['v_prerow'] . '' : $val['v_prerow']; + $val['v_name'] = ' ' + .$val['v_name'].''; + $val['v_type'] = self::$para['v_type'][$val['v_type']]; + $val['v_free'] = $val['v_free'] + ? ''.$val['v_free'] + .'' : $val['v_free']; + $val['v_lease'] = $val['v_lease'] + ? ''.$val['v_lease'] + .'' : $val['v_lease']; + $val['v_endday'] = $val['v_endday'] + ? '' + .$val['v_endday'].'' : $val['v_endday']; + $val['v_prerow'] = $val['v_prerow'] + ? '' + .$val['v_prerow'].'' : $val['v_prerow']; if ($val['noban'] > 0) { - $val['v_enum'] = '' . $val['v_enum'] . ''; - if ($this->bsign) + $val['v_enum'] = '' + .$val['v_enum'].''; + if ($this->bsign) { $val['v_enum'] .= ' -- '; - $val['v_enum'] .= '' . $val['noban'] . ''; + } + $val['v_enum'] .= '' + .$val['noban'].''; } else { - $val['v_enum'] = $val['v_enum'] ?: '' . $val['v_enum'] . ''; + $val['v_enum'] = $val['v_enum'] + ?: '' + .$val['v_enum'].''; } // $val['v_province'].$val['v_city'] 去掉省市 - if (!$this->bsign) - $val['v_address'] = $val['v_district'] . ' ' . $val['v_address']; + if ( ! $this->bsign) { + $val['v_address'] = $val['v_district'].' '.$val['v_address']; + } //执行操作按钮 if (empty($checked)) { - $addtourl = $this->own_name_table . 'elevators&e_vid=' . $val['id']; - $this->btn[] = '广告位统计'; + $addtourl = $this->own_name_table.'elevators&e_vid=' + .$val['id']; + $this->btn[] = '广告位统计'; } + return self::assemble($key, $base, $val, $checked, false); } //场所统计展示 + protected function noticeday($val, $checked = '', $base = []) { global $_M, $_YW; @@ -691,31 +905,68 @@ trait tlist //列表前段 //对字段处理 //公司 - if (empty(self::$customer[ $val['h_cid'] ])) - self::$customer[ $val['h_cid'] ] = parent::customerlist($val['h_cid']); + if (empty(self::$customer[$val['h_cid']])) { + self::$customer[$val['h_cid']] = parent::customerlist( + $val['h_cid'] + ); + } //相关人员 $workerswid = stringto_array($val['h_wid'], ','); foreach ($workerswid as $hwid) { - if (empty(self::$workers[ $hwid ])) - self::$workers[ $hwid ] = parent::workerslist($hwid); - $workersstr[] = self::$workers[ $hwid ]; + if (empty(self::$workers[$hwid])) { + self::$workers[$hwid] = parent::workerslist($hwid); + } + $workersstr[] = self::$workers[$hwid]; } //设置的到期提醒 //订单到期前后3天提醒 $val['htypes'] = self::noticestr($val['noticeday']); - $val['h_cid'] = self::$customer[ $val['h_cid'] ]; - $val['h_wid'] = parent::tab_tokenfield(arrayto_string($workersstr), 1); + $val['h_cid'] = self::$customer[$val['h_cid']]; + $val['h_wid'] = parent::tab_tokenfield(arrayto_string($workersstr), 1); - $numberurl = $this->own_name_table . 'contract&h_number=' . $val['h_number']; - $val['h_number'] = ' ' . $val['h_number'] . ''; + $numberurl = $this->own_name_table.'contract&h_number=' + .$val['h_number']; + $val['h_number'] = ' ' + .$val['h_number'].''; return self::assemble($key, $base, $val, $checked, false); } + //场所统计展示 + + protected function noticestr($noticeday) + { + //首先判断当前这条信息是属于到期前台3天的 还是属于设置的提醒 + //那就是判断订单结束时间和今天的相差天数 + $day = abs($noticeday); + if ($noticeday > 3) { + //按照设置的提醒来计算 + $str = parent::str_color(1, $day, 800); + $htypes = "{$str} 天后到期提醒"; + } else { + //按照前后3天来设置 + if ($noticeday > 0) { + $str = parent::str_color(4, $day, 800); + //说明还没到期 + $htypes = "{$str} 天后到期"; + } else { + //说明已经到期或者过期 + $htypes = $noticeday == 0 ? parent::str_color( + 0, + '今天到期', + 800 + ) : parent::str_color(5, "已过期 {$day} 天", 800); + } + } + + return $htypes; + } + //前台巡查 + protected function patrol($val, $checked = '') { global $_M, $_YW; @@ -729,9 +980,15 @@ trait tlist $curdate = strtotime(date('Y-m-d', time())); $day = $val['nowetime'] ? abs(($nowetime - $curdate) / 86400) : 0; - $val['e_number'] = parent::state_color($val['e_enable'], [$val['e_number'], $val['e_number']]); + $val['e_number'] = parent::state_color( + $val['e_enable'], + [$val['e_number'], $val['e_number']] + ); self::eaddress($val, 'e_address'); - $val['nowtitle'] = parent::state_color($curdate > $nowetime ? 0 : ($day > 2 ? 1 : 2), [$val['nowtitle'], $val['nowtitle'], $val['nowtitle']]); + $val['nowtitle'] = parent::state_color( + $curdate > $nowetime ? 0 : ($day > 2 ? 1 : 2), + [$val['nowtitle'], $val['nowtitle'], $val['nowtitle']] + ); return self::assemble($key, [], $val, $checked, false); } @@ -745,25 +1002,39 @@ trait tlist //列表前段 $base[] = ' - + '; //对字段处理 - if (empty(self::$workers[ $val['k_wid'] ])) { - $k_wid = parent::workerslist($val['k_wid'], false); - self::$workers[ $val['k_wid'] ] = $k_wid['w_name'] . ',' . $k_wid['w_tel']; + if (empty(self::$workers[$val['k_wid']])) { + $k_wid = parent::workerslist( + $val['k_wid'], + false + ); + self::$workers[$val['k_wid']] = $k_wid['w_name'].',' + .$k_wid['w_tel']; } $val['k_basekey'] = base64_decode($val['k_basekey']); - $val['k_state'] = parent::state_color($val['k_state'], ['禁用', '启用']); - $val['k_wid'] = parent::tab_tokenfield(self::$workers[ $val['k_wid'] ], 1); + $val['k_state'] = parent::state_color( + $val['k_state'], + ['禁用', '启用'] + ); + $val['k_wid'] = parent::tab_tokenfield( + self::$workers[$val['k_wid']], + 1 + ); //执行操作按钮 if (empty($checked)) { - $addtourl = $this->own_name_info . __FUNCTION__ . '&id=' . $val['id']; - $this->btn[] = '编辑'; + $addtourl = $this->own_name_info.__FUNCTION__.'&id=' + .$val['id']; + $this->btn[] = '编辑'; } + //执行操作按钮 return self::assemble($key, $base, $val, $checked); }