<?php
	session_start();
	require_once("../Wx.Config.php");	//只加载一次
	header("Content-type:text/html;charset=gb2312");
	//判断是否登录系统		
	if($_SESSION["main_viplogined"]!="1" |$_SESSION["main_vipno"]=="")
	{
		//没有登录开始启动登录
		header('location:login.php?stext=');
		exit;
	}
?>
<!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>

	<script src="jsp4/jquery.js"></script>
	<link rel="stylesheet" href="css/mycss.css"> 
	
	<!--<link rel="stylesheet" href="jsp5/jquery.mobile-1.4.5.min.css">-->
	<!--<script src="jsp4/jquery.mobile-1.4.3.min.js"></script>-->
	<script src="jsp5/jquery.mobile-1.4.5.min.js"></script>
	<link rel="stylesheet" href="jsp5/jquery.mobile-1.4.5.min.css">
	
</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");
		
	
?>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<!--第一个页面的内容实现---------------------------->
<section data-role="page" id="hispage1">
	
	<header data-role="header" data-position="fixed" data-tap-toggle="false" style="border-top-width:0px;border-bottom-width:0px;">
		<table width="100%" height="45" border="0" cellpadding="0" cellspacing="0" bgcolor="<?php echo WxMainConfig::colHeadBkColor;?>">
			<tr>
				<td height="50" width="30" align="right">
	                <a href="vipmain.php" target="_blank"data-iconpos="notext">
	                    <img src="images\back.png" width="12" height="21" border="0" style="margin-top:3px;">
                    </a>
				</td>
				<td height="50" width="10"></td>
				<td height="50" align="left">
					<div style="padding-top:2px;">
						<table width="100%" height="45" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td align="center">
                                    <span style="color:<?php echo WxMainConfig::colHeadTextColor;?>;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:19px;text-shadow:none;">电子优惠券</span>
                                </td>
								<td width="50"></td>
							</tr>
						</table>
					</div>
				</td>
			</tr>
			<tr>
				<td height="1" colspan="3" bgcolor="#F2E2E2"></td>
			</tr>
			<tr>
				<td height="35" colspan="3" bgcolor="#fff">
					<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td width="6%" height="35" align="center"></td>
							<td width="25%" height="35" align="center">
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #BBBB00;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">未使用</span>
										</tr></td>
									</table>
							</td>
							<td width="6%" height="35" align="center"></td>
							<td width="25%" height="35" align="center">
								<div onClick="window.location = 'myvoucher2.php';">
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">已使用</span>
										</tr></td>
									</table>
								</div>
							</td>
							<td width="6%" height="35" align="center"></td>
							<td width="25%" height="35" align="center">
								<div onClick="window.location = 'myvoucher3.php';">
									<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
										<tr><td align="center">
											<span style="color: #000000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:15px;">已过期</span>
										</tr></td>
									</table>
								</div>
							</td>
							<td width="7%" height="35" align="center"></td>
						</tr>
						<tr>
							<td width="6%" height="2" align="center"></td>
							<td width="25%" height="2" align="center" bgcolor="#BBBB00"></td>
							<td width="6%" height="2" align="center"></td>
							<td width="25%" height="2" align="center"></td>
							<td width="6%" height="2" align="center"></td>
							<td width="25%" height="2" align="center"></td>
							<td width="7%" height="2" align="center"></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</header>
	
	<article data-role="none">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FAFAFA" >
			<tr>
				<td height="4" width="8"></td>
				<td height="4" align="left"></td>
				<td height="4" width="8"></td>
			</tr>
			
			<?php
				$intRowIndex=0;
				
				$sql=sprintf("Select Item_No,Item_Type,Item_Value, CONVERT(varchar(10),StartTime, 23) AS StartTime,CONVERT(varchar(10),EndTime, 23)As EndDate,Remarks,dbo.WXF_GetChainName(Chain_No)As ChainName
					,LEFT(CONVERT(varchar(10), Time1,24),5)AS MyTime1,LEFT(CONVERT(varchar(10), Time2,24),5)AS MyTime2 From TR_Vouchers_Item Where Sub_No='%s' 
					And Item_State=1 And EndTime>DateAdd(day,-1,GetDate()) Order By EndDate ASC",$_SESSION["main_vipno"]);

				$result = querySql($sql);
											
				while($row = fetch_array($result))
				{
					$stritemno=$row['Item_No'];
					$stritemtype=$row['Item_Type'];
					$fltitemvalue=$row['Item_Value'];
					$strstartday=$row['StartTime'];
					$strendday=$row['EndDate'];
					$strremarks=trim($row['Remarks']);
					$strchainno=trim($row['ChainName']);
					$strtime1=trim($row['MyTime1']);
					$strtime2=trim($row['MyTime2']);
					
					$intRowIndex=$intRowIndex+1;
					if(strlen($strremarks)>0)
					{
						$intSuitHeight=259;
					}
					else
					{
						$intSuitHeight=238;
					}
					if(strlen($strchainno)<1 | $strchainno=='*')
					{
						$strchainno='所有门店';
					}
					
					$strtimeitem=$strtime1.'至'.$strtime2;
					if(strlen($strtimeitem)>2)
					{
						$intSuitHeight = $intSuitHeight +22;
					}
			?>
			<tr>
				<td width="10"></td>
				<td align="left">
					<div style="width:100%;height:<?php echo $intSuitHeight;?>px;border-radius:4px;border-top:1px solid #F2E2E2;border-bottom:1px solid #F2E2E2;border-left:1px solid #F2E2E2;border-right:1px solid #F2E2E2;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
							<tr><td height="6"  colspan="4" bgcolor="#B48A21"></td></tr>
										
                             <tr>
								<td height="30" width="15" bgcolor="#B48A21"></td>
								<td height="30" align="center" valign="middle" colspan="2" bgcolor="#B48A21">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td width="30" align="left" valign="middle">
												<span style="color:#fff;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:14px;text-shadow:none;"><?php echo $intRowIndex;?></span>
											</td>
											<td align="center" valign="middle">
												<span style="color:#fff;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:18px;text-shadow:none;"><?php echo $stritemtype;?></span>
											</td>
                                            <td width="30" align="left" valign="middle"></td>
										</tr>
									</table>
								</td>
																
								<td height="30" width="15" bgcolor="#B48A21"></td>
							</tr>

							<tr><td height="5"  colspan="4" bgcolor="#B48A21"></td></tr>
                                  
							<tr>
								<td height="1" align="left" bgcolor="#F2E2E2" colspan="4"></td>
							</tr>
                           
                            
							<tr><td height="1"  colspan="4"></td></tr>
                                      
                                      
							<tr>
								<td height="30" width="15"></td>
								<td height="30" align="center" valign="middle" colspan="2">
									<table width="100%" border="0" cellpadding="0" cellspacing="0">
                                    	<tr>
                                        	<td width="40%" align="right">
												<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;">￥</span>
												<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:32px;"><?php echo number_format($fltitemvalue,0); ?></span>
                                            </td>
                                             <td width="20%" align="left">
     											<table width="100%"  height="30" border="0" cellpadding="0" cellspacing="0"> 	
	                                                <tr><td height="5" width="6"></td><td height="5"></td></tr>
                                                	<tr>
                                                    	<td height="10" width="6">
                                                        <td height="10">
                                                        	<div >
                                                    		<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold;font-size:12px;">现金</span></div>
                                                    	</td>
                                                    </tr>
													<tr>
                                                    	<td height="10" width="6">
                                                        <td height="10">
                                                    		<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold;font-size:12px;">抵用券</span>
                                                    	</td>
                                                    </tr>
													<tr><td height="5" width="6"></td><td height="5"></td></tr>
                                                </table>

                                            </td>
											<td width="40%" align="center">
												<img width="80" height="80" src="phpqrcodedo.php?mybar=<?php echo $stritemno;?>">
											</td>
                                        </tr>
                                    </table>
								</td>
								
								<td height="30" width="15"></td>
							</tr>
                            
							<tr>
								<td height="1" width="15" ></td>
								<td height="1" align="left" bgcolor="#F2E2E2"></td>
								<td height="1" width="130" bgcolor="#F2E2E2"></td>
								<td height="1" width="15"></td>
							</tr>
                            
			        		<tr><td height="3" colspan="4"></td></tr>
                                        
							<tr>
								<td height="10" width="15"></td>
								<td height="10" align="left" valign="middle" colspan="2">
									<span style="color: #666666;font: 10px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;">领取日期<?php echo $strstartday;?></span>
								</td>
								<td height="10" width="15"></td>
							</tr>
                            <tr>
								<td height="10" width="15"></td>
								<td height="10" align="left" valign="middle" colspan="2">
									<span style="color: #666666;font: 10px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;">有效日期至<?php echo $strendday;?>截止,请及时使用</span>
								</td>
								<td height="10" width="15"></td>
							</tr>
							
							<?php if(strlen($strtimeitem)>2) { ?>
							<tr>
								<td height="22" width="15"></td>
								<td height="22" align="left" valign="middle" colspan="2">
									<span style="color: #666666;font: 10px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;">使用时段：<?php echo $strtimeitem;?></span>
								</td>
								<td height="22" width="15"></td>
							</tr>
							<?php } ?>
							<tr>
								<td height="10" width="15"></td>
								<td height="10" align="left" valign="middle" colspan="2">
									<span style="color: #666666;font: 10px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;">使用范围：<?php echo $strchainno?></span>
								</td>
								<td height="10" width="15"></td>
							</tr>
							
							<?php if(strlen($strremarks)>0) { ?>
                            <tr>
								<td height="10" width="15"></td>
								<td height="10" align="left" valign="middle" colspan="2">
									<span style="color: #666666;font: 10px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:12px;">注：<?php echo $strremarks;?></span>
								</td>
								<td height="10" width="15"></td>
							</tr>
							<?php } ?>
							
                            <tr><td height="6" align="left" colspan="4"></td></tr>
                           
                            <tr><td height="1" align="left" background="images/hr.gif" colspan="4"><div></div></td></tr>
                            
   							<tr>
                            	<td height="10" width="15" bgcolor="#F1EAEA"></td>
								<td height="38" align="center" bgcolor="#F1EAEA"colspan="2">
	                                <span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:16px;">券编号:</span>
	                                <span style="color: #CD0013;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-weight:bold; font-size:17px;"><?php echo $stritemno;?></span>
                                </td>
                                <td height="10" width="15" bgcolor="#F1EAEA"></td>
							</tr>
                            														
						</table>
					</div>
				</td>
				<td width="10"></td>
			</tr>
			
			<tr>
				<td height="10" width="8"></td>
				<td height="10" align="left"></td>
				<td height="10" width="8"></td>
			</tr>
			<?php 
				}
				//释放数据库
				freeResult($result);
				closeDb();
			?>
									
		</table>
				
	</article>
    
</section>

</body>
	
</html>