<?php
use \common\libs\MyLib;
?>
<script type="text/javascript" language="javascript" src="/js/jquery.min.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 info(id,total1_rate) {
        var year=$('#year').val();
        var month = $('#month').val();
        var area_id = $('#area_id').val();
        var name = $('#name').val();
        window.location.href = '/finance/pay-list-info?id=' + id + '&year=' + year + '&month=' + month + '&area_id=' + area_id + '&name=' + name + '&total1_rate=' + total1_rate;
    }

    $(function(){
        $("#search-btn").click(function(){
            $('#page').val(0);
            var params = $('#searchForm').serialize();
            window.location.href = "/finance/pay-list?" + params;
        });
        $('#cal-btn').click(function(){
            if(confirm('是否确认提交?')) {
                var params = $("#searchForm").serialize();
                $('#cal-btn').attr('disabled','true');
                $('#cal-btn').val('正在计算中……');
                $.post('/finance/gz-cal',params,function(obj){
                    alert(obj.msg);
                    window.location.reload();
                },'json');
            }
        });
        $("#gift-btn").click(function(){
            var year = $('#year').val();
            var month = $('#month').val();

            window.location.href = "/finance/gift-price?year=" + year + '&month=' + month;
        });
    });
</script>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <form id="searchForm">
        <tr>
            <td class="td_bg">
                月份：<input name="year" id="year" type="text" value="<?=$year?>" style="width:100px;">年<select name="month" id="month">
                    <option value="01" <?=$month=='01'?'selected':''?>>01</option>
                    <option value="02" <?=$month=='02'?'selected':''?>>02</option>
                    <option value="03" <?=$month=='03'?'selected':''?>>03</option>
                    <option value="04" <?=$month=='04'?'selected':''?>>04</option>
                    <option value="05" <?=$month=='05'?'selected':''?>>05</option>
                    <option value="06" <?=$month=='06'?'selected':''?>>06</option>
                    <option value="07" <?=$month=='07'?'selected':''?>>07</option>
                    <option value="08" <?=$month=='08'?'selected':''?>>08</option>
                    <option value="09" <?=$month=='09'?'selected':''?>>09</option>
                    <option value="10" <?=$month=='10'?'selected':''?>>10</option>
                    <option value="11" <?=$month=='11'?'selected':''?>>11</option>
                    <option value="12" <?=$month=='12'?'selected':''?>>12</option>
                </select>
                工号：<input id="name" name="name" type="text" value="<?=$name?>" style="width:100px;">
                级别：<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>
                <input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索">
                <input type="button" class="act_btn" id="cal-btn" name="cal-btn" value="重新计算">
                <input type="button" class="act_btn" id="gift-btn" name="gift-btn" value="礼品价格">
            </td>
        </tr>
    </form>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
        <td width="24" align="center" class="bg_tr" nowrap>工号</td>
        <td align="center" class="bg_tr" nowrap>真实姓名</td>
        <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 width="100" align="center" class="bg_tr" nowrap>商业跟单手续费</td>
        <td width="60" align="center" class="bg_tr" nowrap>免费礼品数</td>
        <td align="center" class="bg_tr" nowrap>免费礼品价格</td>
        <td width="80" align="center" class="bg_tr" nowrap>优惠款</td>
        <td width="60" align="center" class="bg_tr" nowrap>自费礼品数</td>
        <td 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 width="60" align="center" class="bg_tr" nowrap>详情</td>
    </tr>
    <?php
    foreach($items as $index => $item) {
        ?>
        <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
            <td align="center" class="td_bg"nowrap ><?=$item['username']?></td>
            <td align="center" class="td_bg"nowrap ><?=$item['name']?></td>
            <td align="center" class="td_bg" nowrap><?=$item['order_count']?></td>
            <td align="center" class="td_bg" nowrap><?=$item['total1_clear']?></td>
            <td align="center" class="td_bg" nowrap><?=$item['tj']?></td>
            <td align="center" class="td_bg" nowrap><?=$item['total1_rate']?></td>
            <td align="center" class="td_bg" nowrap><a href="/finance/pay-gift-list?year=<?=$year?>&month=<?=$month?>&user_id=<?=$item['id']?>&is_free=1"><?=$item['gift1_count'].'个'?></a></td>
            <td align="center" class="td_bg" nowrap><?=$item['gift1_total']?></td>
            <td align="center" class="td_bg" nowrap><?=$item['total1_dis']?></td>
            <td align="center" class="td_bg" nowrap><a href="/finance/pay-gift-list?year=<?=$year?>&month=<?=$month?>&user_id=<?=$item['id']?>&is_free=0"><?=$item['gift2_count'].'个'?></a></td>
            <td align="center" class="td_bg" nowrap><?=$item['gift2_total']?></td>
            <td align="center" class="td_bg" nowrap><?=$item['tc']?></td>
            <td align="center" class="td_bg" nowrap><?=$item['yf']?></td>
            <td align="center" class="td_bg" nowrap>
                [<a href="javascript:void(0);" onclick="info(<?=$item['id']?>,<?=$item['total1_rate']?>)">详情</a>]
            </td>
        </tr>
        <?php
    }
    ?>
</table>
