{load(fhead)}
<body class="mainbg">
	<div id="mainhearder"><span>您的位置：<a href="{$vd['root']}index.php?m=mod_b2b&a=Home">直销商管理系统</a> >> 销售记录 >> 销售记录查询</span></div>
	<div id="type">
		<ul>
			<li><span class="jl">销售收入入帐记录</span></li>
		</ul>
	</div>
	<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
	<!--$ptype=request('ptype');$ordstate=request('ordstate');-->
	<td class="tableleft">
		<form name="salecardhistory" method="get" action="index.php" id="advsearch">
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table1">
		<!--$vhistory=$vd['ishistory']==1?0:1;if($vd['hashistory'] == 1){-->
  	<tr>
      <td width="22%" height="30" class="tableleft1">
        &nbsp;
      </td>
      <td width="78%" class="tableright1">
      	<input type="hidden" name="ishistory" value="{$vd['ishistory']}" />
        <a href="index.php?m=mod_agent&c=AOrder&ishistory={$vhistory}"><font color="#ff0000"><u><!--if($vd['ishistory']==0){-->历史数据查询<!--}else{-->回到当前数据查询<!--}--></u></font></a>
      </td>
    </tr>
    <!--}-->
		<tr>
		<td width="22%" height="30" class="tableleft1">商品类型：</td>
		<td width="78%" class="tableright1">
			<select name="ptype" onchange="setk(this)">
        <option value="">全部类型</option>
        <option value="km" <!--if($ptype=='km'){-->selected<!--}-->>虚拟卡密</option>
        <option value="sd" <!--if($ptype=='sd'){-->selected<!--}-->>充值商品</option>
      </select>
		</td>
		</tr>
		<tr id="stypetr" style="<!--if($ptype !='km' && $ptype !='cz'){-->display:none<!--}-->">
      <td class="tableleft1"><span id="stypelabel"><!--if($ptype=='cz'){-->充值帐号：<!--}else if($ptype=='km'){-->卡号密码：<!--}--></span></td>
      <td class="tableright1"><input type="hidden" id="stype" name="stype" value="<!--if($ptype=='sd'){-->czaccount<!--}else if($ptype=='km'){-->cardnumber<!--}else{-->pname<!--}-->"><input type="text" size="22" name="keywords"  id="tkeywords" value="{$vd['kw']}"><span id="stypetip"><!--if($ptype=='km'){-->&nbsp;格式：卡号|密码<!--}--></span></td>
    </tr>
		<tr>
		<td class="tableleft1">订单状态：</td>
		<td class="tableright1">
			<select name="ordstate">
				<option value="">所有</option>
      	<option value="2" <!--if($ordstate==2){-->selected<!--}-->>成功订单</option>
        <option value="-1" <!--if($ordstate==-1){-->selected<!--}-->>失败订单</option>
        <option value="1" <!--if($ordstate==1){-->selected<!--}-->>处理中订单</option>
        
      </select>
		</td>
		</tr>
		<tr>
		<td height="35" class="tableleft1">查询时间段：</td>
		<td class="tableright1">
    <input type="text" name="startdate" size="18" value="{$vd['startdate']}" style="vertical-align:middle;" id="startdate"/>
    <strong>至</strong>&nbsp;<input type="text" name="enddate" size="18" value="{$vd['enddate']}" style="vertical-align:middle;" id="enddate"/>
    </td>
		</tr>
		<tr>
		<td height="30" class="tableleft1">&nbsp;</td>
		<td class="tableright1">
			<input type="hidden" name="m" value="mod_agent" />
			<input type="hidden" name="c" value="AOrder" />
			<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 class="table" width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
		<td width="8%" class="heardertop1">购买用户</td>
    <td width="13%" class="heardertop1">定购商品</td>
    <td width="6%" class="heardertop1">数量</td>
    <td width="6%" class="heardertop1">单价</td>
    <td width="6%" class="heardertop1">总额</td>
    <td width="6%" class="heardertop1">进价</td>  
    <td width="6%" class="heardertop1">费率</td> 
    <td width="8%" class="heardertop1">手续费</td> 
    <td width="8%" class="heardertop1">经销提成</td> 
    <td width="8%" class="heardertop1">入账金额</td> 
    <td width="10%" class="heardertop1">订单状态</td>
    <td width="10%" class="heardertop1">日期</td>
    <td width="5%" class="heardertop1">详细</td>
		</tr>
		<!--$dollars_sum = 0;$moneyfee_sum = 0;$qty_sum = 0;$agentprofit_sum = 0;$ownermoney_sum = 0;foreach($vd['items'] as $item) {-->
    <tr class="stline" onmouseover="this.className='nd'" onmouseout="this.className='stline'">
      <td>{$item['company']}({#DisplayCode($item['cid'])})</td>
      <td>{$item['pname']}</td>
      <td>{$item['qty']}</td>
      <td>{$item['cprice']}</td>
      <td>{$item['dollars']}</td> 
      <td>{$item['price']}</td>
      <td><!--echo ($item['fee']*100).'%';--></td>
      <td>{$item['moneyfee']}</td>
      <td>{$item['agentprofit']}</td>
      <td>{$item['ownermoney']}</td>
      <td>{#OrderState($item['ordstate'],$item['ptype'])}</td>
      <td>{$item['orddate']}</td>
      <td>
        <a href="index.php?m=mod_agent&c=AOrder&a=detail&ordno={$item['ordno']}">查看</a>
      </td>
    </tr>
    <!--$dollars_sum=$dollars_sum+$item['dollars'];$moneyfee_sum=$moneyfee_sum+$item['moneyfee'];$qty_sum=$qty_sum+$item['qty'];$agentprofit_sum=$agentprofit_sum+$item['agentprofit'];$ownermoney_sum=$ownermoney_sum+$item['ownermoney']; }-->
    <tr class=thr>
      <td align="center" colspan="2">本页合计</td>
      <td>{$qty_sum}</td>
      <td>&nbsp;</td>
      <td>{$dollars_sum}</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>{$moneyfee_sum}</td>
      <td>{$agentprofit_sum}</td> 
      <td>{$ownermoney_sum}</td> 
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr class=thr>
      <td align="center" colspan="2">查询合计</td>
      <td>{$vd['tradedata']['qty_sum']}&nbsp;</td>
      <td>&nbsp;</td>
      <td>{$vd['tradedata']['dollars_sum']}&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>{$vd['tradedata']['moneyfee_sum']}&nbsp;</td>
      <td>{$vd['tradedata']['agentprofit_sum']}&nbsp;</td> 
      <td>{$vd['tradedata']['ownermoney_sum']}&nbsp;</td> 
      <td colspan="3">&nbsp;</td>
    </tr>
    </table>
	</td>
	</tr>
	</table>
	<div id="page">
		{load(fpage)}
	</div>
	
</body>
</html>
<script type="text/javascript">
function openScript(url,name,width,height)
{
    var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no,status=no');
}

function dateDialog(idx)
{
  obj = document.getElementById(idx)
  dv=window.showModalDialog("{$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;}
}

function setk(obj)
{
  v = obj.options[obj.selectedIndex].value;
  $("tkeywords").value = "";
  if(v == "")
  {
    $("stypetr").style.display = "none";
    $("stype").value = "pname";
  }
  else if(v == "km")
  {
    $("stypetr").style.display = "";
    $("stype").value = "cardnumber";
    $("stypelabel").innerHTML = "卡号密码：";
    $("stypetip").innerHTML = "&nbsp;格式：卡号|密码";
  }
  else if(v == "sd")
  {
    $("stypetr").style.display = "";
    $("stype").value = "czaccount";
    $("stypelabel").innerHTML = "充值帐号：";
    $("stypetip").innerHTML = "";
  }
}

function setAct(v)
{
	$("export").value = v;
	if(v > 0)
	{
	  $("advsearch").submit();
	}
}

</script>