<script language="javascript"> 
 
function Reply(id,name,types,content){
	jPrompt("",content,"&nbsp;<font color='red'>发送站内信给："+name+"<span style='margin-left:105px;' onclick='RemoveRe()'>[关&nbsp;闭]</span></font>",function(R){																																															
			window.location='<?php echo S_SiteDomain?>/user/do.php?ac=msg&op=add&content='+R+'&S_Nameb='+types;															  
			})
	}
	
function RemoveRe(){
	$.alerts._hide();
	}	
</script>

<?php
if($op==""){
$op="list";
}
?>
		<div class="userMain">
			<div class="uMain_title"><span class="iconMessage">短消息</span></div>
			<div class="uMain_content">
				<div class="stageBox">
					<div class="stageBoxTop"><span></span></div>
					<div class="stageBoxCenter">
						<div class="stageBoxCenterContent">
							<div class="main_nav">
								<ul>
								<li class="<?php if($op=="wd"){ echo "nava_2";}else{ echo "navb_2";}?>"><a href="?ac=msg&op=wd">未读</a></li>
								<li class="<?php if($op=="list"){ echo "nava_4";}else{ echo "navb_4";}?>"><a href="?ac=msg&op=list">消息列表</a></li>
								<li <?php if($op!="du"){echo 'style="display:none;"';}?> class="<?php if($op=="du"){ echo "nava_4";}else{ echo "navb_4";}?>">查看详情</li>
								</ul>
							<div class="action"><a href="javascript:;"  onclick="Reply(0,'系统消息','<?php echo $chsh_username?>','请输入要说的话')" >发信给管理员</a></div>
							</div>
							<div class="minHeight500" id="msg">
								<div class="msgIgnore">
<?php
if($op=="du"){
$id=SafeRequest("id","get");
$vid=SafeRequest("vid","get");
$name=SafeRequest("name","get");
$db->query("update s_xiaoxi set s_did=1,s_cid=1 where s_id=$id and s_namea='".$chsh_username."'");
$sql="Select * from S_xiaoxi where S_ID=$id";
$row=$db->getrow($sql);
$user=$db->getrow("select * from S_users where S_name='".$row['S_Nameb']."'");
?>
	<span class="name">与 <strong><?php echo $name?></strong> 的短消息对话</span>
	<span onClick="window.open('do.php?ac=msg&op=dell&id=<?php echo $vid?>')">删除本对话</span>
</div>
<div class="msgList">
	<ul>
				<li id="ms-239">
			<div class="icon"><a href="<?php echo userlink("index",$row["S_Nameb"])?>" target="_blank"><img class="avatar-58" src="<?php echo piclink("logo",$user["S_Logo"],"big")?>" onerror="this.onerror=null;this.src='<?php echo S_SiteDomain?>/user/images/avatar/noface_small.gif'" title="<?php echo $row["S_Nameb"]?>"/></a></div>
			<div class="pm">
				<div class="h">
					<div class="f">
						<p><a href="<?php echo userlink("index",$row["S_Nameb"])?>" target="_blank"><?php echo $row["S_Nameb"]?></a></a> <span class="mtime"><?php echo datetime($row["S_Addtime"])?></span></p>
						<div class="c">
							<?php echo $row["S_Content"]?> 						</div>
					</div>
				</div>
			</div>
		</li>
<?php
$a=0;
	global $db;
	$sql="select * from s_xiaoxi where S_Vid='".$vid."' and s_id<>$id order by s_id desc";
		$Arr=getuserpage($sql,"100");//sql,每页显示条数
		$result=$db->query($Arr[2]);
		$numdate="a";
		if($result){
		while ($row = $db ->fetch_array($result)){
		$numdate="b";
	$sqlu="select s_logo,S_RealName,s_name from s_users where S_name='".$row["S_Nameb"]."' order by s_id desc";
	$rsu=$db->query($sqlu);
	$rowu=$db->fetch_array($rsu);
?>

				<li id="ms-239">
			<div class="icon"><a href="<?php echo userlink("index",$row["S_Nameb"])?>" target="_blank"><img class="avatar-58" src="<?php echo piclink("logo",$rowu["s_logo"],"big")?>" onerror="this.onerror=null;this.src='<?php echo S_SiteDomain?>/user/images/avatar/noface_small.gif'" title="<?php echo $row["S_Nameb"]?>"/></a></div>
			<div class="pm">
				<div class="h">
					<div class="f">
						<p><a href="<?php echo userlink("index",$row["S_Nameb"])?>" target="_blank"><?php echo $row["S_Nameb"]?></a></a> <span class="mtime"><?php echo datetime($row["S_Addtime"])?></span></p>
						<div class="c">
							<?php echo $row["S_Content"]?> 						</div>
					</div>
				</div>
			</div>
		</li>
<?php
	}
}
if($numdate=="a"){
		echo("<div class='nothing'>没有消息对话。</div>");
}
?>
				<li>
			<div class="icon"><a href="<?php echo userlink("index",$rowa["S_Namea"])?>" target="_blank"><img class="avatar-58" src="<?php echo piclink("logo",$chsh_logo,"big")?>" onerror="this.onerror=null;this.src='<?php echo S_SiteDomain?>/user/images/avatar/noface_small.gif'" title="<?php echo $rowa["S_Namea"]?>"/></a></div>
			<div class="pm">
				<div class="h">
					<div class="f">
						<p><a href="<?php echo userlink("index",$rowa["S_Namea"])?>" target="_blank"><?php echo $rowa["S_Namea"]?></a></p>
						<div class="c"><form  name="form2" action="do.php?ac=msg&op=dh" method="post">
							<textarea name="S_Content" id="S_Content" ></textarea>
							<input name="name" type="hidden" value="<?php echo $name?>">
							<input name="vid" type="hidden" value="<?php echo $vid?>">
							<p><span class="button-main"><span><button type="submit" id="submit">回复</button></span></span></p>
						</div></form>
					</div>
				</div>
			</div>
		</li>

	</ul>

							</div>
</div>
<?php
}elseif($op=="wd"){
?>
	<span class="name">未读短消息列表</span>
	<span onClick="window.open('do.php?ac=msg&op=duall')">全部设为已读</span></div>
<div class="msgList">
	<ul>
<?php
	global $db;
	$sql="select * from s_xiaoxi where S_Namea='".$chsh_username."' and s_did=0 order by s_id desc";
		$Arr=getuserpage($sql,"20");//sql,每页显示条数
		$result=$db->query($Arr[2]);
		$numdate="a";
		if($result){
			while ($row = $db ->fetch_array($result)){
		$numdate="b";
	$sqlu="select s_logo,S_RealName from s_users where S_name='".$row["S_Nameb"]."' order by s_id desc";
	$rsu=$db->query($sqlu);
	$rowu=$db->fetch_array($rsu);
	$xid=$row["S_Xid"];
	$vid=$row["S_Vid"];
	if($vid==""){
$vid=$row["S_ID"];
}
?>
				<li id="ms-238">
			<div class="icon"><a href="<?php echo userlink("index",$row["S_Nameb"])?>" target="_blank"><img class="avatar-58" src="<?php echo piclink("logo",$rowu["s_logo"],"big")?>" onerror="this.onerror=null;this.src='<?php echo S_SiteDomain?>/user/images/avatar/noface_small.gif'" title="<?php echo $row["S_Nameb"]?>"/></a></div>
			<div class="pm">
				<div class="h">
					<div class="f">
						<p><a href="<?php echo userlink("index",$row["S_Nameb"])?>" target="_blank"><?php echo $row["S_Nameb"]?></a> <span class="mtime"><?php echo datetime($row["S_Addtime"])?></span></p>
						<div class="c">
							<?php echo $row["S_Content"]?>							<span class="nore">(未阅读)</span>							<p><a href="?ac=msg&op=du&name=<?php echo $row["S_Nameb"]?>&vid=<?php echo $vid?>&id=<?php echo $row["S_ID"]?>" target="_blank">查看详情</a></p>
						</div>
						<a onClick="window.open('do.php?ac=msg&op=del&id=<?php echo $row["S_ID"]?>')" class="del" href="javascript:;">删除</a>
					</div>
				</div>
			</div>
		</li>
<?php
}
}
if($numdate=="a"){
		echo("<div class='nothing'>没有未读消息。</div>");
}
?>
			</ul>
</div>
<div class="page"><div class="pages"><?php echo $Arr[0];?></div></div>
							</div>
							<div id="currPageNum">1</div>

<?php
}elseif($op=="list"){
?>
	<span class="name">已读短消息列表</span>
	<span onClick="window.open('do.php?ac=msg&op=delall')">删除全部消息</span></div>
<div class="msgList">
	<ul>
<?php
	global $db;
	$sql="select * from s_xiaoxi where S_Namea='".$chsh_username."' and s_did=1 order by s_id desc";
		$Arr=getuserpage($sql,"20");//sql,每页显示条数
		$result=$db->query($Arr[2]);
		$numdate="a";
		if($result){
			while ($row = $db ->fetch_array($result)){
		$numdate="b";
	$sqlu="select s_logo,S_RealName from s_users where S_name='".$row["S_Nameb"]."' order by s_id desc";
	$rsu=$db->query($sqlu);
	$rowu=$db->fetch_array($rsu);
	$xid=$row["S_Xid"];
	$vid=$row["S_Vid"];
	if($vid==""){
$vid=$row["S_ID"];
}
?>
				<li id="ms-238">
			<div class="icon"><a href="<?php echo userlink("index",$row["S_Nameb"])?>" target="_blank"><img class="avatar-58" src="<?php echo piclink("logo",$rowu["s_logo"],"big")?>" onerror="this.onerror=null;this.src='<?php echo S_SiteDomain?>/user/images/avatar/noface_small.gif'" title="<?php echo $row["S_Nameb"]?>"/></a></div>
			<div class="pm">
				<div class="h">
					<div class="f">
						<p><a href="<?php echo userlink("index",$row["S_Nameb"])?>" target="_blank"><?php echo $row["S_Nameb"]?></a> <span class="mtime"><?php echo datetime($row["S_Addtime"])?></span></p>
						<div class="c">
							<?php echo $row["S_Content"]?>							<span class="nore">(已阅读)</span>							<p><a href="?ac=msg&op=du&name=<?php echo $row["S_Nameb"]?>&vid=<?php echo $vid?>&id=<?php echo $row["S_ID"]?>" target="_blank">查看详情</a></p>
						</div>
						<a onClick="window.open('do.php?ac=msg&op=del&id=<?php echo $row["S_ID"]?>')" class="del" href="javascript:;">删除</a>
					</div>
				</div>
			</div>
		</li>
<?php
}
}
if($numdate=="a"){
		echo("<div class='nothing'>没有消息。</div>");
}
?>
			</ul>
</div>
<div class="page"><div class="pages"><?php echo $Arr[0];?></div></div>
							</div>
							<div id="currPageNum">1</div>
<?php
	}
?>

						</div>
					</div>
					<div class="stageBoxBottom"><span></span></div>
				</div>
			</div>
