<?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="type">
		<ul>
			<?php if($vd['tradetype'] == '31,32'){ ?>
			<li><a href="index.php?m=mod_agent&c=funds&a=tran"><span class="yuan">转款给下级</span></a></li>
			<li><span class="jl">转款记录</span></li>
			<?php }else{ ?>
			<li><span class="jl">加款扣款记录</span></li>
			<li><a href="index.php?m=mod_agent&c=order"><span class="jl">进货记录查询</span></a></li>
			<li><a href="index.php?m=mod_agent&c=VOrder&ordstate=2"><span class="jl">销售记录查询</span></a></li>
			<?php } ?>
		</ul>
	</div>
	<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
	<td class="tableleft">
		<form name="history" method="post" action="index.php?m=mod_agent&c=trade&tpl=history"  id="advsearch">
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table1">
	  <?php $vhistory=$vd['ishistory']==1?0:1;if($vd['hashistory'] == 1){ ?>
  	<tr>
      <td class="tableleft1">
        &nbsp;
      </td>
      <td class="tableright1">
      	<input type="hidden" name="ishistory" value="<?php echo $vd['ishistory']; ?>" />
        <a href="index.php?m=mod_agent&c=trade&tpl=history&ishistory=<?php echo $vhistory; ?>"><font color="#ff0000"><u><?php if($vd['ishistory']==0){ ?>历史数据查询<?php }else{ ?>回到当前数据查询<?php } ?></u></font></a>
      </td>
    </tr>
    <?php } ?>
		<tr>
		<td class="tableleft1">查询条件：</td>
		<td class="tableright1">
		<div id="table1" >
		&nbsp;<select name="tradetype">
		<?php (Option($vd['tradetypes'], $vd['tradetype'])); ?>
		</select>
		</div>
		<div id="table2" style=display:none>
		<select name="SearchType2">
		<option value="0" >全部类型</option>
		<option value="1" >欠款记录</option>
		<option value="2" >还款记录</option>
		</select>
		</div>
		</td>
		</tr>
		<tr>
		<td height="35" class="tableleft1">查询时间段：</td>
		<td class="tableright1">
    &nbsp;<input type="text" name="startdate" value="<?php echo $vd['startdate']; ?>" class="search_inputdate" id="startdate"/>
    
    <strong>至</strong>&nbsp;<input type="text" name="enddate" value="<?php echo $vd['enddate']; ?>" class="search_inputdate" id="enddate"/>
    </td>
		</tr>
		<tr>
		<td height="30" class="tableleft1">&nbsp;</td>
		<td class="tableright1">&nbsp;
			<input type="hidden" id="export" name="export" value="0"/>
      <input type="submit" value="马上查询 &gt;&gt;" class="button" onclick="setAct(0)"/>
      <input type="submit" value="导出Excel &gt;&gt;" class="button" onclick="setAct(1)"/>
      <input type="submit" value="导出Csv &gt;&gt;" class="button" onclick="setAct(2)"/>
		</td>
		</tr>
		</table>
		</form>
	</td>
	</tr>
	</table>
	<br>
	<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
	<td class="tableleft">
		
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="table">
		<tr>
		<td width="25%" class="heardertop1">交易日期</td>
		<td width="20%" class="heardertop1">交易类型</td>
		<td width="15%" class="heardertop1">交易前</td>
		<td width="15%" class="heardertop1">交易金额</td>
		<td width="15%" class="heardertop1">交易后</td>
		<td width="10%" class="heardertop1">详细</td>
		</tr>
		<?php $thisincome=0;$thisoutcome=0;foreach($vd['items'] as $item) { ?>
		<tr class="stline" onmouseover="this.className='nd'" onmouseout="this.className='stline'">
		<td><?php echo $item['createdate']; ?></td>
		<td><?php (TradeType($item['tradetype'])); ?></td>
		<td><?php echo $item['fbt']; ?></td>
		<td><strong><font color=#006600><?php if($item['income'] !== '' && $item['outcome'] == 0 ){echo '+'.round($item['income'],3);$thisincome += $item['income'];}else if($item['outcome'] !== ''){echo '-'.round($item['outcome'],3);$thisoutcome += $item['outcome'];} ?></font></strong></td>
		<td><?php echo $item['fat']; ?></td>
		<td><input type="button" name="detail" value="详细" <?php if($item['tradetype'] != 1 && $item['tradetype'] != 12){ ?> disabled<?php } ?> class="<?php if($item['tradetype'] != 1 && $item['tradetype'] != 12){ ?>buttonnor<?php }else{ ?>buttonadd<?php } ?>" onclick="javascript:location.href='<?php (UrlByTradeType($item['tradetype'], $item['ordno'])); ?>';" ></td>
		</tr>
		<?php } ?>
		<tr class="thr"><td>本页合计：</td><td colspan=5>收入合计：<?php echo round($thisincome, 3); ?>&nbsp;&nbsp;&nbsp;&nbsp;支出合计：<?php echo round($thisoutcome, 3); ?></td></tr>
		<tr class="thr"><td>查询总计：</td><td colspan=5>收入总计：<?php if($vd['record']['income'] != ''){ echo round($vd['record']['income'], 3);}else{echo 0;} ?>&nbsp;&nbsp;&nbsp;&nbsp;支出总计：<?php if($vd['record']['outcome'] != ''){ echo round($vd['record']['outcome'], 3);}else{echo 0;} ?></td></tr>
		</table>
		
	</td>
	</tr>
	</table>
	<div id="page" align="right">
		<?php widget("fpage");include($path_cache.DS."mod_agent_Shared_fpage.php"); ?>
	</div>
	
</body>
</html>
<script type="text/javascript">
function setAct(v)
{
	$("export").value = v;
	if(v > 0)
	{
	  $("advsearch").submit();
	}
}
</script>
