<?php
use \common\libs\MyLib;
?>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/datepicker/WdatePicker.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
    $(function(){
        $("#search-btn").click(function(){
            $('#page').val(0);
            var params = $('#searchForm').serialize();
            window.location.href = "/statistics/work?" + params;
        });
        //导出
        $("#output-btn").click(function(){
            $('#page').val(0);
            var params = $('#searchForm').serialize();
            window.location.href = "/statistics/work-output?" + params;
        });
    });
</script>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <form id="searchForm">
        <tr>
            <td class="td_bg">
                提单日期:从<input name="date_begin" type="text" value="<?=$date_begin?>" style="width:100px;" onclick="WdatePicker()">到<input name="date_end" type="text" value="<?=$date_end?>" style="width:100px;" onclick="WdatePicker()">截止
                正本日期:从<input name="date2_begin" type="text" value="<?=$date2_begin?>" style="width:100px;" onclick="WdatePicker()">到<input name="date2_end" type="text" value="<?=$date2_end?>" style="width:100px;" onclick="WdatePicker()">截止
                工号:<input name="username" type="text" value="<?=$username?>">
                级别:<select name="group_id">
                    <option value="0">全部</option>
                    <?php
                    foreach($group_items as $item) {
                        echo '<option value="'.$item->id.'"';
                        if($item->id == $group_id)
                            echo ' selected ';
                        echo '>'.$item->name.'</option>';
                    }
                    ?>
                </select>
                <select name="company_id">
                    <option value="0">全部</option>
                    <?php
                    foreach($company_items as $item) {
                        echo '<option value="'.$item->id.'"';
                        if($item->id == $company_id)
                            echo ' selected ';
                        echo '">'.$item->name.'</option>';
                    }
                    ?>
                </select>
                <input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索">
                <input type="button" class="act_btn" id="output-btn" name="output-btn" value="导出">
                <a href="/statistics/work?date_begin=<?=date('Y-m-d')?>&date_end=<?=date('Y-m-d')?>">当天</a>&nbsp;&nbsp;
                <a href="/statistics/work?date_begin=<?=date('Y-m-d',strtotime("-7 day"))?>&date_end=<?=date('Y-m-d')?>">7天</a>&nbsp;&nbsp;
                <a href="/statistics/work?date_begin=<?=date('Y-m-d',strtotime("-1 month"))?>&date_end=<?=date('Y-m-d')?>">1个月</a>&nbsp;&nbsp;
                <a href="/statistics/work?date_begin=<?=date('Y-m-d',strtotime("-3 month"))?>&date_end=<?=date('Y-m-d')?>">3个月</a>&nbsp;&nbsp;
            </td>
        </tr>
    </form>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
        <td width="50" align="center" class="bg_tr" nowrap>工号</td>
        <td width="60" align="center" class="bg_tr" nowrap>真实姓名</td>
        <td width="80" align="center" class="bg_tr" nowrap>通时</td>
        <td align="center" class="bg_tr" nowrap>提车总数</td>
        <td align="center" class="bg_tr" nowrap>提单总数</td>
        <td align="center" class="bg_tr" nowrap>商业总净保费</td>
        <td align="center" class="bg_tr" nowrap>交强总净保费</td>
        <td align="center" class="bg_tr" nowrap>商业已收净保费</td>
        <td align="center" class="bg_tr" nowrap>交强已收净保费</td>
        <td align="center" class="bg_tr" nowrap>总签单净保费</td>
        <td align="center" class="bg_tr" nowrap>详情</td>
    </tr>
    <?php
    foreach($user_rows as $row) {
        ?>
        <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
            <td align="center" class="td_bg" nowrap><?=$row['username']?></td>
            <td align="center" class="td_bg" nowrap><?=$row['truename']?></td>
            <td align="center" class="td_bg" nowrap><?=$row['total'][0]!=''?$row['total'][0]:''?></td>
            <td align="center" class="td_bg" nowrap><?=$row['total'][7]>0?$row['total'][7]:''?></td>
            <td align="center" class="td_bg" nowrap><?=$row['total'][1]>0?$row['total'][1]:''?></td>
            <td align="center" class="td_bg" nowrap><?=$row['total'][2]>0?'¥'.number_format($row['total'][2],2):''?></td>
            <td align="center" class="td_bg" nowrap><?=$row['total'][3]>0?'¥'.number_format($row['total'][3],2):''?></td>
            <td align="center" class="td_bg" nowrap><?=$row['total'][4]>0?'¥'.number_format($row['total'][4],2):''?></td>
            <td align="center" class="td_bg" nowrap><?=$row['total'][5]>0?'¥'.number_format($row['total'][5],2):''?></td>
            <td align="center" class="td_bg" nowrap><?=$row['total'][6]>0?'¥'.number_format($row['total'][6],2):''?></td>
            <td align="center" class="td_bg" nowrap>[<a href="/statistics/work-info?user_id=<?=$row['id']?>&date_begin=<?=$date_begin?>&date_end=<?=$date_end?>&date2_begin=<?=$date2_begin?>&date2_end=<?=$date2_end?>&username=<?=$username?>">详情</a>]</td>
        </tr>
        <?php
    }
    ?>
    <tr>
        <td width="50" align="center" class="bg_tr" nowrap>汇总</td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td align="center" class="bg_tr" nowrap><?=$sum_total[7]?$sum_total[7]:''?></td>
        <td align="center" class="bg_tr" nowrap><?=$sum_total[1]?$sum_total[1]:''?></td>
        <td align="center" class="bg_tr" nowrap><?=$sum_total[2]?'¥'.number_format($sum_total[2],2):''?></td>
        <td align="center" class="bg_tr" nowrap><?=$sum_total[3]?'¥'.number_format($sum_total[3],2):''?></td>
        <td align="center" class="bg_tr" nowrap><?=$sum_total[4]?'¥'.number_format($sum_total[4],2):''?></td>
        <td align="center" class="bg_tr" nowrap><?=$sum_total[5]?'¥'.number_format($sum_total[5],2):''?></td>
        <td align="center" class="bg_tr" nowrap><?=$sum_total[6]?'¥'.number_format($sum_total[6],2):''?></td>
        <td align="center" class="bg_tr" nowrap></td>
    </tr>
</table>