<?php
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu();
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'fieldset_display';
$pageindex = max(1, intval($_GPC['page']));
$pagesize=10;
$where=" where b.uniacid=:uniacid";
if(!empty($_GPC['keywords'])){
    $where.=" and a.details LIKE  concat('%', :name,'%') ";
    $data[':name']=$_GPC['keywords'];   
}	
$data[':uniacid']=$_W['uniacid'];
$sql="select a.* ,b.details as tzinfo from " . tablename("zhtc_comments") . " a"  . " left join " . tablename("zhtc_information") . " b on a.information_id=b.id ".$where." order by time DESC";
$total=pdo_fetchcolumn("select count(*) from " . tablename("zhtc_comments") . " a"  . " left join " . tablename("zhtc_information") . " b on a.information_id=b.id".$where,$data);
	$select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
	$list=pdo_fetchall($select_sql,$data);
	$pager = pagination($total, $pageindex, $pagesize);

	if($operation=='delete'){
		$res=pdo_delete('zhtc_comments',array('id'=>$_GPC['id']));
		if($res){
			message('删除成功',$this->createWebUrl('tzpinglun',array()),'success');
		}else{
			message('删除失败','','error');
		}
	}

if ($_GPC['op'] == 'tg') {
	$tz=pdo_get('zhtc_comments',array('id'=>$_GPC['id']));
    $res = pdo_update('zhtc_comments',array('state'=>2), array('id' => $_GPC['id']));
    if ($res) {
    	if($tz['bid'] || $tz['hf_id']){
			file_get_contents("" . $_W['siteroot'] . "app/index.php?i=" . $_W['uniacid'] . "&c=entry&a=wxapp&do=hpMessage2&m=zh_tcwq&id=" . $tz['id']);//模板消息
		}
        file_get_contents("" . $_W['siteroot'] . "app/index.php?i=" . $_W['uniacid'] . "&c=entry&a=wxapp&do=TzhfMessage&m=zh_tcwq&pl_id=" . $tz['id']);//模板消息
        $this->increaseScore($tz['user_id']);
        message('通过成功！', $this->createWebUrl('tzpinglun', array('page' => $_GPC['page'])), 'success');
    } else {
        message('通过失败！', '', 'error');
    }
}
if ($_GPC['op'] == 'jj') {
   $res = pdo_update('zhtc_comments',array('state'=>3), array('id' => $_GPC['id']));
    if ($res) {
        message('拒绝成功！', $this->createWebUrl('tzpinglun', array('page' => $_GPC['page'])), 'success');
    } else {
        message('拒绝失败！', '', 'error');
    }
}
include $this->template('web/tzpinglun');