group.inc.php 1.46 KB
<?php
global $_GPC, $_W;
$storeid = $_COOKIE["storeid"];
$cur_store = $this->getStoreById($storeid);
$GLOBALS['frames'] = $this->getMainMenu2();
$pageindex = max(1, intval($_GPC['page']));
$pagesize = 10;
$type = isset($_GPC['type'])? $_GPC['type']: 'all';
$where = " where g.uniacid=:uniacid and g.store_id=:store_id and g.state>0";
$data[':uniacid'] = $_W['uniacid'];
$data[':store_id'] = $_COOKIE["storeid"];
if (isset($_GPC['keywords'])) {
	$where .= " and ( u.name LIKE  concat('%', :name,'%') || g.id LIKE  concat('%', :name,'%'))";
	$data[':name'] = $_GPC['keywords'];
	$type = 'all';
}
if ($_GPC['time']) {
	$start = strtotime($_GPC['time']['start']);
	$end = strtotime($_GPC['time']['end']);
	$where.=" and g.kt_time >='{$start}' and g.kt_time<='{$end}'";
	$type = 'all';
} else {
	if ('ing' == $type) {
		$where.=" and g.state=1";
	}
	if ('success' == $type) {
		$where.=" and g.state=2";
	}
	if ('fail' == $type) {
		$where.=" and g.state=3";
	}

}
$leftJoin = ' left join '.tablename('cjdc_user') .' as u on u.id = g.user_id ';
$sql = "SELECT g.*, u.name as userName, u.img as uImg FROM ".tablename('cjdc_group').' as g '.$leftJoin.$where." ORDER BY g.id DESC";
$total = pdo_fetchcolumn("SELECT count(*) FROM ".tablename('cjdc_group').' as g '.$leftJoin. $where, $data);
$select_sql = $sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;

$list = pdo_fetchall($select_sql, $data);
$pager = pagination($total, $pageindex, $pagesize);
//打印
include $this->template('web/group');