<?php
include("CheckSession.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="馬戲團" />
<title>馬戲團</title>
<Script Language="javascript" src="control/calendar.js"></Script>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>

<script language="JavaScript" type="text/JavaScript"> 
<!-- 
function MM_openBrWindow(theURL,winName,win_width,win_height) { 
  var PosX = ((screen.width-win_width)/2); 
  var PosY = ((screen.height-win_height)/2);
  features = "status=no,toolbar=no,scrollbars=yes,resizable=yes,width="+win_width+",Height="+win_height+",top="+PosY+",left="+PosX;; 
  var urlStr = theURL + "?CMissCount=" + document.all['CMissCount'].value
               + "&tempCustomerId=" + document.all['tempCustomerId'].value
  var newwin = window.open(urlStr,winName,features); 
}
//--> 
</script>

<?php
$tempCustomerId = $_GET["tempCustomerId"];

require_once("class/DBConfig.php");
require_once("class/DBOperation.php");

$db = new DBOperation();
?>
<SCRIPT language="JavaScript">
function DelMiss(objThisUi)
{
	document.CustomerForm.action = "CustomerMissContentDel.php";
	CustomerForm.submit();	
}
</SCRIPT>
<body>
<form name="CustomerForm" method="post" action="CustomerUpdateDeal.php" id="CustomerForm">
<input type="hidden" name="tempCustomerId" id="tempCustomerId" value="<?php echo $tempCustomerId ?>"/>
<table border="1" cellspacing="2" cellspadding="2" width="100%">
<tr>
<td align="left" width="80%">
<span class="t12">新增</span>
<input type="text" name="CMissCount" value="1" id="CMissCount" size="2" maxlength="2" style="font-size: 12.0pt;font-family: 微軟正黑體;"/>
<span class="t12">筆消費內容</span>
<input type="button" name="btnMiss" id="btnMiss" value="新增" class="t12" onclick="MM_openBrWindow('CustomerMissContent.php','MissContentWin',700,550)"/>
</td>
</tr>
<tr>
<td width="100%">
<table border="0" cellspacing="0" cellspdding="0">
<tr>
<td align="left" colspan="2">

<?php
if($_SESSION['username'] == "admin")
{
?>
<input type="button" name="btnDelMiss" id="btnDelMiss" value="刪除" class="t12" onclick="javascript:DelMiss(this);"/>
<?php }else{ ?>
<input type="button" name="btnDelMiss" id="btnDelMiss" value="刪除" class="t12" disabled="disabled""/>
<?php } ?>
</td>
</tr>
<?php
if($tempCustomerId != null && $tempCustomerId != "")
{
	$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);
	$querySql = "select * from CMissContent Where CCId = '".$tempCustomerId."'";
	$db->query($querySql);	
	while($myrow = $db->fetch_array())
	{
		$x = $x + 1;
?>
<tr>
<td align="left" width="10%">
<input type="checkbox" name="chkM<?php echo $x;?>" id="chkM<?php echo $x;?>" value="<?php echo $myrow['CId'];?>">
</td>
<td align="left">
<span class="t12">
消費內容<?php echo $x;?> - 
<?php echo $myrow['CMiss'];?> - <?php echo $myrow['CPayDate'];?>
</span>
</td>
</tr>
<?php
	}
}
?>
</table>
</td>
</tr>
<input type="hidden" name="CTotalMissCount" id="CTotalMissCount" value="<?php echo $x ?>"/>
</table>
</form>
</body>
</html>
