<?php widget("fhead");include($path_cache.DS."mod_agent_Shared_fhead.php"); ?>
<body class="mainbg">
	<div id="mainhearder"><span>您的位置：<a href="<?php echo $vd['root']; ?>index.php?m=mod_b2b&a=Home">直销商管理系统</a> >> 销售记录 >> 员工结帐管理</span></div>
	<div id="tabs5">
		<ul class="menu5" id="menu5">
		<li onclick="location.href='index.php?m=mod_agent&c=Check&a=Add';" class="hover"><span class="xg">员工结帐</span></li>
		<li onclick="location.href='index.php?m=mod_agent&c=Check';"><span class="jl">结帐记录</span></li>
	</ul>
	</div>
	<div class="main5" id="main5">
	<form name="checkout" method="post" action="index.php?m=mod_agent&c=check&a=Save">
	<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
	<td class="tableleft">
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table1">
		<tr>
		<td width="22%" align="right" class="tableleft1">交班对像：</td>
		<td width="78%" class="tableright1">
		  <select name="staff" id="staff" onchange="getSum()">
          <option value="0||总账号" <?php if($vd['agent'][7]==0){ ?> selected <?php } ?>>总账号</option>
          <?php foreach($vd['staff'] as $item){ ?>
          <option value="<?php echo $item['staffid']; ?>||<?php echo $item['realname']; ?>" <?php if($vd['agent'][9]==$item['staffid']){ ?> selected <?php } ?>><?php echo $item['realname']; ?></option>
          <?php } ?>
      </select>
		</td>
		</tr>
		<tr>
		<td width="22%" align="right" class="tableleft1">接班对像：</td>
		<td width="78%" class="tableright1">
        <select name="otherstaff">
        	<option value="0||总账号">总账号</option>
        	<?php foreach($vd['staff'] as $item){ ?>
        	<option value="<?php echo $item['staffid']; ?>||<?php echo $item['realname']; ?>"><?php echo $item['realname']; ?></option>
        	<?php } ?>
        </select>
      </td>
    </tr>
		<tr>
		<td align="right" class="tableleft1">帐务时间段：</td>
		<td class="tableright1">
    <input type="text" name="startdate" size="18" value="<?php echo date('Y-m-d').' 00:00:00'; ?>" style="vertical-align:middle;" id="startdate" onblur="getSum()"/>

    <strong>至</strong>&nbsp;<input type="text" name="enddate" size="18" value="<?php echo date('Y-m-d H:i:s'); ?>" style="vertical-align:middle;" id="enddate" onblur="getSum()"/>
    </td>
		</tr>
		<tr>
		<td align="right" class="tableleft1">帐面金额：</td>
		<td class="tableright1">
			<input name="ar" size="20" id="ar" type="text" readonly class="input" style="background:#f0f0f0"/> <?php echo $vd['lang']['moneyunit']; ?> <input type="button" name="getcheckoutmoney" value="获取" class="buttonnor" onclick="getSum();" tabindex="12"> <span style="color:#555555">(表示此时间段应结帐的金额)</span>
		</td>
		</tr>
		<tr>
		<td width="20%" align="right" class="tableleft1">实际交款金额：</td>
		<td width="80%" class="tableright1"><input type='text' size='20' class="input" name="ap" id="ap" dataType="Double" msg="实际交款金额填写错误" tabindex="13"></td>
		</tr>
		<tr>
		<td align="right" class="tableleft1">结帐备注：</td>
		<td class="tableright1"><TEXTAREA NAME="remarks" ROWS="5" COLS="70" class="input" require="false" dataType="LimitB" min="1" max="400" msg="结帐备注填写过长" tabindex="14"></TEXTAREA></td>
		</tr>
		<tr>
		<td width="20%" align="right" class="tableleft1">接班人交易密码：</td>
		<td width="80%" class="tableright1">
			<input name="otherpwd" size="20" type="password" class="input"/> <span style="color:#cccccc">(如果是总账号，请输入您的超级密码)</span>
		</td>
		</tr>
		
		<tr>
		<td align="right" class="tableleft1">&nbsp;</td>
		<td class="tableright1"><input type="hidden" name="Login_my" value="37126884"><input type="submit" name="submit" value="确认结帐" class="button" tabindex="16"> <input type="reset" name="reset" value="重新填写" class="button" tabindex="17"></td>
		</tr>
		</table>
	</td>
	</tr>
	</table>
	</form>
	<script type="text/javascript">
function dateDialog(idx)
{
	obj = document.getElementById(idx)
	dv=window.showModalDialog("<?php echo $vd['sc']; ?>tools/datedialog.html?date="+obj.value,"44","center:1;help:no;status:no;dialogHeight:240px;dialogWidth:185px;scroll:no")
  if (dv) 
  {
  	if (dv=="null")
  	{
  	   obj.value='';
  	}
  	else
  	{
  	  obj.value=dv;
  	  getSum();
  	}
  }
}
function openScript(url,name,width,height)
{
    var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no,status=no');
}

var $ = function(id) {
	return document.getElementById(id);
}

getSum();

function getSum()
{
	var xmlhttp = null;
	
	// 针对 Mozilla等浏览器的代码：
  if (window.XMLHttpRequest)
  {
    xmlhttp=new XMLHttpRequest();
  }
  // 针对 IE 的代码：
  else if (window.ActiveXObject)
  {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  tstartdate  = escape($("startdate").value);
  tenddate    = escape($("enddate").value);
  tstaff      = $("staff").options[$("staff").selectedIndex].value;

  tmp         = tstaff.split("||");

  tstaffid     = tmp[0];
  
	myurl       = "index.php?m=mod_agent&c=Check&a=Compute&startdate="+tstartdate+"&enddate="+tenddate+"&staffid="+tstaffid;

  if (xmlhttp!=null)
  {
    xmlhttp.onreadystatechange=function(){
      // 如果 xmlhttp 显示为 "loaded"
      if (xmlhttp.readyState==4)
      {
        // 如果为 "OK"
        if (xmlhttp.status==200)
        {
          // 其他代码..
          var ackdata=xmlhttp.responseText;

          $("ar").value = ackdata;
        }
        else
        {
          alert("您的浏览器不支持XMLHTTP")
        }
      }
    };
    xmlhttp.open("post", myurl, true);
    xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    xmlhttp.send('');
  }
  else
  {
    alert("您的浏览器不支持XMLHTTP")
  }
}

</script>
</body>
</html>
