<?php
	session_start();
	ini_set('session.gc_maxlifetime', 99999999); //设置时间 永不过期	
	//判断是否登录系统
	if($_SESSION['main_wx_userlogined']!="1" | $_SESSION['main_wx_userno']=="")
	{
		//没有登录开始启动登录
		header('location:..\loginwx.php?rset=0');
		exit;
	}
	header("Content-type: text/html; charset=gb2312"); 
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="gb2312">	
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
	<meta name="apple-mobile-web-app-capable" content="1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=0">
	<meta name="apple-touch-fullscreen" content="1">

	<title>云点通——部门营业</title>

	<link rel="stylesheet" href="jsp4/jquery.mobile-1.4.3.min.css">
	<script src="jsp4/jquery.js"></script>
	<script src="jsp4/jquery.mobile-1.4.3.min.js"></script>
	<link rel="stylesheet" href="css/mycss.css"> 
	
	<script>
		//清空登录信息资料
		var ddt=<?php echo $_SESSION["main_defusernoflag_ydtpos"]; ?>;
		if(ddt=="1")
		{	ddt=<?php echo $_SESSION["main_defuserno_ydtpos"]; ?>;
			localStorage["main_defuserno_ydtpos"]=ddt;
		}
	</script>
</head>

<script>	
	//隐藏维信右上角菜单
	function onBridgeReady(){
		WeixinJSBridge.call('hideOptionMenu');
	}

	if (typeof WeixinJSBridge == "undefined")
	{
		if( document.addEventListener )
		{
			document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
		}
		else if (document.attachEvent)
		{
			document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
			document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
		}
	}
	else
	{
		onBridgeReady();
	}
</script>

<?php		
	require_once("db/db.php");	
	require_once("common/common.php");
	
	//得到默认日期
	$strdepartname="";
	$strdepartID=$_REQUEST['sldpart'];
	$nowchainno=$_SESSION['ChainNo_ydtpos'];
	
	
	$strdepartID=trim($strdepartID);
	if(strlen($strdepartID)>0)
	{
		$sql=sprintf("SELECT DepartName FROM TCP_Depart_Inform WHERE ListNo=%s",$strdepartID);
		$result = querySql($sql);					
		if($row = fetch_array($result))
		{
			$strdepartname = $row['DepartName'];  	
		}
		freeResult($result);
	}
?>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">

<!--选择部门的部分代码---------------------------->
<section data-role="page" id="pagedepartment">
	<header data-role="header" data-position="fixed" data-tap-toggle="false">
		<table width="100%" height="35" border="0" cellpadding="0" cellspacing="0">
		   <tr>
				<td height="35" width="50" align="right"><a href="index.php?selno=<?php echo $nowchainno;?>" target="_parent" data-role="button" data-iconpos="notext" data-icon="carat-l"></td>
				<?php if(strlen($strdepartname)>0) { ?>
					<td height="35" align="center"><?php echo $strdepartname;?></td>
				<?php } else { ?>
					<td height="35" align="center">未选择部门</td>
				<?php } ?>
				<td height="35" width="20" ></td>			
		  </tr>
		</table>
	</header>
	<article data-role="content">
		<ul data-role="listview" data-inset="true">    
		 <?php
		 
			$seldepartname="";
			$seldepartlistno="";
			
			$sql=sprintf("SELECT ListNo,DepartName FROM TCP_Depart_Inform WHERE Chain_No='%s'",$nowchainno);
			$result = querySql($sql);
										
			while($row = fetch_array($result))
			{
				$seldepartname = $row['DepartName'];
				$seldepartlistno = $row['ListNo'];
		?>
			<li>
				<a class="ui-btn ui-corner-all ui-shadow ui-btn-inline" href="index.php?selno=<?php echo $nowchainno;?>&seldpt=<?php echo $seldepartlistno;?>" target="_blank" data-transition="flip">
				<?php echo $seldepartname;?></a>
			</li> 
		<?php
			}
			//释放数据库
			freeResult($result);
			closeDb();
		 ?>
		  
		</ul> 
	</article>
	
	<footer data-role="footer" data-position="fixed" data-tap-toggle="false">
		<div>&nbsp;</div>
	</footer>
</section>
</body>
	
</html>