<?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>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<?php

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

$CCId = $_GET['CCId'];
$CNickname = $_GET['CNickname'];

//取得记录总数，计算总页数用
$db = new DBOperation();
$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);
$db->query("select count(*) from Customer");
$row = $db->fetch_row();
$db->close_db();
$numrows = $row[0];

$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);
$querySql = "select CId,CMiss,CPayDate from CMissContent where CCId = '".$CCId."' order by CPayDate desc";
$db->query($querySql);

?>
<SCRIPT language="JavaScript">
window.onbeforeunload  = function(event){
  event = event || window.event;

    var confirmClose = 'Are you sure?';

    // For IE and Firefox prior to version 4
    if (event) {
       event.returnValue = confirmClose;
    }
  //window.opener.location.reload(true);
}
function checkDelete(id)
{
	if(confirm("確定要刪除嗎????"))
	{
     location.href = "CMissContentDeleteDeal.php?id=" + id + "&CCId=<?php echo $CCId;?>&CNickname=<?php echo $CNickname;?>";
	}
}
</SCRIPT>
<body>
<form name="form" method="post" action="CMissContentInput.php?actionOp=Insert&CCId=<?php echo $CCId; ?>&CNickname=<?php echo $CNickname; ?>">
<input type="hidden" name="CCId" id="CCId" value="<?php echo $CCId; ?>"/>
<input type="hidden" name="CNickname" id="CNickname" value="<?php echo $CNickname; ?>"/>
<table border="0" cellspacing="1" cellspadding="1" width="95%">
<tr>
<td align="center" colspan="2">
<span class="title"><b><?php echo $CNickname;?>的消費內容</b></span>
</td>
</tr>
<tr>
<td align="center" colspan="2">
&nbsp;
</td>
</tr>
<?php
if(str_indexof($_SESSION['rights'],"B1I") >= 0)
{
?>
<tr>
<td align="left" colspan="2">
<input type="submit" name="btnSub" id="btnSub" value="新增消費內容" class="t12" />
</td>
</tr>
<?php
}
?>
<tr>
<td align="left" colspan="2" width="100%">
<?php
if($myrow = $db->fetch_array())     
{     
  $i=0;     
  ?>       
  <table width="100%" border="1" cellspacing="2" cellpadding="2">     
  <tr>     
  <td width="10%" bgcolor="#E1E9FB" align="center"><span class="t12r">序號</span></td>     
  <td width="30%" bgcolor="#E1E9FB" align="center"><span class="t12r">消費內容</span></td>
  <td width="30%" bgcolor="#E1E9FB" align="center"><span class="t12r">消費日期</span></td>
  <td width="10%" bgcolor="#E1E9FB" align="center"><span class="t12r">修改</span></td>  
  <td width="10%" bgcolor="#E1E9FB" align="center"><span class="t12r">刪除</span></td>
  </tr>     
  <?php
  $index = 0;
  do{  	
    $i++;
  ?>     
	  <tr>     
	  <td bgcolor="#E6F2FF"><?php echo $myrow['CId'];?></td>     
	  <td bgcolor="#E6F2FF">
	  <span class="t12">
	  <?php echo $myrow['CMiss'];?></span></td>
	  <td bgcolor="#E6F2FF">
	  <span class="t12">
	  <?php echo $myrow['CPayDate'];?></span></td>
	  <td bgcolor="#E6F2FF" align="center">
	   <?php
			if(str_indexof($_SESSION['rights'],"B1U") >= 0)
			{
		?>
	  <span class="t12">
	  <a href="CMissContentInput.php?actionOp=Update&id=<?php echo $myrow['CId'];?>&CCId=<?php echo $CCId;?>&CNickname=<?php echo $CNickname;?>")">
	  <b>修改</b></a></span>
	  <?php
			}
		?>
	  </td>	 		
	  <td bgcolor="#E6F2FF" align="center">
	  <?php
			if(str_indexof($_SESSION['rights'],"B1D") >= 0)
			{
		?>
	  <span class="t12">	  
	  <a href="javascript:void(0);" onclick="checkDelete('<?php echo $myrow['CId'];?>');">
	  <b>刪除</b></a></span>
	   <?php
			}
		?> 
	  </td>	  
	  </tr>     
  <?php     
  }while($myrow = $db->fetch_array());
  echo "</table>";     
  }  
?>
</td>
</tr>
</table>
</form>
</body>
</html>
