<?
session_start();
require_once "../init.php";
if($_POST['UserName'] != '')
{
	$UserName = $_POST['UserName'];
}
else
{
	$UserName = $_GET['UserName'];
}
$Amount = $_POST['Amount'];
$iStatus = $_POST['iStatus'];
$About = $_POST['About'];
$dtCreate = $_POST['dtCreate'];
if($_POST['ukey'] != '')
{
	$ukey = $_POST['ukey'];
}
else
{
	$ukey = $_GET['ukey'];
}
$add = $_POST['add'];
$backUrl = $_GET['backUrl'];

//echo $ukey."=".md5($UserName)."--->".$UserName;
if(md5($UserName)!=$ukey)die("参数错误 <a href='javascript:history.back()'>返回</a>");
require_once "../authority.inc.php";
require_once "../../common/Datepicker.inc.php";
$backUrl=$backUrl?$backUrl:$_SERVER["HTTP_REFERER"];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>财务记录录入</title>
<LINK href="../share/style.css" rel=stylesheet>
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css" />
<script language=javascript src="../share/cal.js"></script>
<script>
function clearProd(form){
   form.fIDProd.value='';
   form.ProdName.value='';
}
function check(form){
   if(/^[-]{0,1}[0-9]+$/.test(form.Amount.value)==false){
      alert("金额只能是正或负的数字");
	  form.Amount.focus();
	  return false;
   }
}
</script>
</head>
<body>
<? include "../share/top.php"?>
<div id="topLink">
<div id="topInfo">
	<span class="tTitle">财务记录</span>
	<span class="sarr"> > </span>财务录款
	
</div>
</div>
<div class="page-container">
<!--子导航-->
<? include "financial_nav.inc.php"?>
<!--结束-->

	<?if($add != 1){?>
	<form action="financial_add.php" method="post" name="mainform" onSubmit="return check(this)">
	<table width="100%"  border="0" cellspacing="0" cellpadding="0" id="table" class="table">
	  <tr id="tr">
		<td colspan="2">财务记录录入</td>
	  </tr>
	  <tr>
		<td align="right" width="40%">用户ID:</td>
		<td>
			<input type="text" name="UserName" class="inputline" value="<?=$UserName?>" readonly>(不可修改)
		</td>
	  </tr>
	  <tr>
		<td align="right">金额:</td>
		<td><input name="Amount" type="text" class="inputline">(如果是扣款的请用负数)</td>
	  </tr>
	  <tr>
		<td align="right">是否生效:</td>
		<td>
			<select name="iStatus">
			  <option value="0">否</option>
			  <option value="1">是</option>
			</select> (只有生效的财务记录才被算入用户的支出及余额当中)
		</td>
	  </tr>
	  <tr>
		<td align="right">描述:</td>
		<td><input name="About" type="text" class="inputline" size="50"></td>
	  </tr>
	  <tr>
		<td align="right">建立时间:</td>
		<td>
		<input name="dtCreate" type="text" id="dtCreate" onClick="OpenDate(dtCreate)" size="10" maxlength="10" value="<?=Date("Y-n-d")?>" class="inputcal">
		</td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		<td><input type="submit" class="bt2" value="提交">
		&nbsp;
		  <input type="reset" class="bt2" value="重置">&nbsp;
		  <input type="button" class="bt2" value="上一页" onClick="history.back()">&nbsp;
		  <input type="button" class="bt2" value="返回" onClick="location='<?=$backUrl?>'">&nbsp;
		  <input type="hidden" name="backUrl" value="<?=$backUrl?>">
		  <input type="hidden" name="ukey" value="<?=$ukey?>">
		  <input type="hidden" name="add" value="1">
		</td>
	  </tr>
	</table>
	</form>
	<?}else{
	  $sql="insert into financial set UserName='$UserName',Amount='$Amount',iStatus='$iStatus',".
		   "About='$About',dtCreate='$dtCreate ".date("H:i:s")."'";
	  $DB->query($sql);
	  $IDFin=$DB->insert_id();
	  echo "<center><br><br><br>财务记录 <font color='blue'> $About </font>录入成功";
	  echo "<br><br><br><a href='financial_user_record.php?UserName=$UserName&backUrl=".urlencode($backUrl)."'>返回用户财务记录信息</a>  <br><br><a href='$backUrl'>[ 返 回 ]</a><br><br><br>";
	}?>
</div>
<? 
$DB->close();
include "../share/bottom.php";
?>
</body>
</html>
