<?php
/*
 * 74cms 企业会员中心 
 * ============================================================================
 * 版权所有: 骑士网络，并保留所有权利。
 * 网站地址: http://www.74cms.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once(dirname(__FILE__).'/company_common.php');
$act=trim($_GET["act"])?trim($_GET["act"]):"pms_list";
if($act=="pms_list")
{
	$uid=intval($_SESSION['uid']);
	$is_look=intval($_GET['is_look']);
	$looksql=" ";
	if($is_look>0)
	{
		$looksql=" and p.is_look=$is_look ";
	}
	$wheresql=" where p.uid=$uid ".$looksql;
	require_once(QISHI_ROOT_PATH.'include/page.class.php');
	$perpage=10;
	$total_sql="SELECT COUNT(*) AS num FROM ".table('pms_sys')." as p ".$wheresql;
	$total_val=$db->get_total($total_sql);
	$page = new page(array('total'=>$total_val, 'perpage'=>$perpage));
	$offset=($page->nowindex-1)*$perpage;
	if($total_val>$perpage)
	{
		$smarty->assign('page',$page->show(7));
	}
	$smarty->assign('title'," 消息列表 - 企业会员中心 - ".$_CFG['site_name']);
	$smarty->assign('list',get_pms_list($offset,$perpage,$wheresql));
	$smarty->assign('act',$act);
	$smarty->display('member_company/company_pms_list.htm');
}
// 删除消息
elseif($act=="del_pms")
{
	$pid=$_REQUEST['pid']?$_REQUEST['pid']:showmsg("您没有选择消息",1);
	$uid=intval($_SESSION['uid']);
	if($n=pms_del($pid,$uid))
	{
		showmsg("删除成功！共删除 {$n} 行",2);
	}
	else
	{
		showmsg("删除失败！",0);
	}
}
// 消息详情
elseif($act=="pms_show")
{
	$id=intval($_GET['id']);
	$smarty->assign('title',"消息详细 - 企业会员中心 - ".$_CFG['site_name']);
	$show = get_pms_one($id,$uid);
	
	$smarty->assign('show',$show);
	$smarty->display('member_company/company_pms_show.htm');
}
// 将消息设为已看
elseif($act=="set_look")
{
	$pid=$_REQUEST['pid']?$_REQUEST['pid']:showmsg("您没有选择消息",1);
	$uid=intval($_SESSION['uid']);
	$n=pms_set_look($pid,$uid);
	showmsg("设置成功,共设置 {$n} 行",2);
}
unset($smarty);
?>