<?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>
</head>
<?php

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

$CMissCount = $_POST['CMissCount'];
$action = $_POST['action'];
$tempCustomerId = $_POST['tempCustomerId'];
$db = new DBOperation();
$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);

for($x=1;$x<=(int)$CMissCount;$x++){ 
  if($_POST['CMiss'.$x] != null && $_POST['CMiss'.$x] != "")
  {
    $CMiss = $_POST['CMiss'.$x];
    $CMissDate = $_POST['CMissDate'.$x];
		$insertSql = "INSERT INTO CMissContent (CCId,CMiss,CPayDate,CCreateDateTime,CUpdateDateTime,CCreateAcc)"
			              ."VALUES ('".$db->mysql_real_escape_string($tempCustomerId)."'"
			              .",'".$db->mysql_real_escape_string($CMiss)."'"
			              .",'".$db->mysql_real_escape_string($CMissDate)."'"			                         
			              .",'".Date('Y-m-d H:i:s')."'"
			              .",'".Date('Y-m-d H:i:s')."'"
			              .",'".$_SESSION['userId']."')";
		$db->query($insertSql);
	}
}
$db->close_db();
$url = "MissContentOperation.php?tempCustomerId=".$tempCustomerId;
echo '<script type="text/javascript">';
echo 'alert("新增成功!!!!");';
echo 'window.opener.location.href = "'.$url.'";';
echo 'window.close();';
echo '</script>';
?>
</html>