<?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 info(id) {
        var params = $('#searchForm').serialize();
        window.location.href = '/insurer/financial-settlement-detail?id=' + id + '&back_params=' + encodeURIComponent(params);
    }
    function unlock(id) {
        $.post('/insurer/unlocked',{id:id},function(obj){
            if(obj.success) {
                alert(obj.msg);
                window.location.reload();
            } else {
                alert(obj.msg);
            }

        },'json');

    }
    $(function(){
        $("#search-btn").click(function(){
            $('#page').val(0);
            var params = $('#searchForm').serialize();
            window.location.href = "/insurer/financial-settlement-list?" + params;
        });
    });
</script>

<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <form id="searchForm">
        <input type="hidden" id="page" name="page" value="<?=$page?>">
        <tr>
            <td class="td_bg">
                <select name="status" class="status">
                    <option value=0>全部</option>
                    <option value=1 <?= $status==1?'selected':'' ?>>未完成</option>
                    <option value=2 <?= $status==2?'selected':'' ?>>完成</option>
                </select>
                被保险人：<input name="car_man" type="Text" value="<?=$car_man?>">
                车牌：<input name="car_no" type="Text" value="<?=$car_no?>">
                级别：<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="Text" class="Wdate" name="begin_date" onclick="WdatePicker()" value="<?= $begin_date ?>" />
                --
                <input type="Text" class="Wdate" name="end_date" onclick="WdatePicker()" value="<?= $end_date ?>" />
                转账日期：
                <input type="Text" class="Wdate" name="tbegin_date" onclick="WdatePicker()" value="<?= $tbegin_date ?>" />
                --
                <input type="Text" class="Wdate" name="tend_date" onclick="WdatePicker()" value="<?= $tend_date ?>" />
                转账状态：
                <select name="caiwu_status_id" class="caiwu_status_id">
                    <option value=0>全部</option>
                    <option value=1 <?= $caiwu_status_id==1?'selected':'' ?>>完成</option>
                    <option value=2 <?= $caiwu_status_id==2?'selected':'' ?>>未完成</option>
                    <option value=3 <?= $caiwu_status_id==3?'selected':'' ?>>正冲</option>
                    <option value=4 <?= $caiwu_status_id==4?'selected':'' ?>>信息不全</option>
                </select>
                工号：<input name="username" type="text" value="<?=$username?>" style="width:50px;">
                <input type="button" class="act_btn" id="search-btn" name="search-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">序号</td>
        <td width="50" align="center" class="bg_tr">被保险人</td>
        <td width="60" align="center" class="bg_tr">保险公司</td>
        <td width="60" align="center" class="bg_tr">车牌号</td>
        <td width="60" align="center" class="bg_tr">送单日期</td>
        <td width="60" align="center" class="bg_tr">正本时间</td>
        <td width="60" align="center" class="bg_tr">商业保单号</td>
        <td width="80" align="center" class="bg_tr">交强保单号</td>
        <td width="60" align="center" class="bg_tr">共计签单</td>
        <td width="60" align="center" class="bg_tr">级别</td>
        <td width="60" align="center" class="bg_tr">销售座席</td>
        <td width="60" align="center" class="bg_tr">状态</td>
        <td width="60" align="center" class="bg_tr">转账状态</td>
        <td width="60" align="center" class="bg_tr">转账时间</td>
        <td width="60" align="center" class="bg_tr">减免金额</td>
        <td width="60" align="center" class="bg_tr">支付方式</td>
        <td width="60" align="center" class="bg_tr">当前操作</td>
        <td width="30" align="center" class="bg_tr">操作</td>
    </tr>
    <?php
    foreach($items as $index => $order_info) {
        $start_index = ($page - 1) * 20 + $index;
        $carwu_info = $order_info->caiwu;
//        if(!$order_info->user) continue;
        $users=$order_info->user->group;
        $nams=$users['name'];
        ?>
        <tr onMouseOver="overColor(this)" onMouseOut="outColor(this)">
            <td align="center" class="td_bg" nowrap ><?=$order_info->id?></td>
            <td class="td_bg" nowrap><?=MyLib::substr_cut($order_info->id_man,20)?></td>
            <td class="td_bg" nowrap><?=$order_info->company2?$order_info->company2->name:''?></td>
            <td class="td_bg" nowrap><?=$order_info->car_no?></td>
            <td class="td_bg" nowrap><?=$order_info->send_date?></td>
            <td class="td_bg" nowrap><?=$order_info->print_date?></td>
            <td class="td_bg" nowrap><?=$order_info->insurer1_no?></td>
            <td class="td_bg" nowrap><?=$order_info->insurer2_no?></td>
            <td class="td_bg" align="center" nowrap><?=$order_info->total_all?></td>
            <td align="center" class="td_bg" nowrap><?=$nams?></td>
            <td class="td_bg" nowrap><?=$order_info->user?$order_info->user->getShowName():''?>&nbsp;</td>
            <td class="td_bg" nowrap><?=$carwu_info->status->name?></td>
            <td class="td_bg" nowrap><?=$carwu_info->caiwuStatus ? $carwu_info->caiwuStatus->name : ''?></td>
            <td class="td_bg" nowrap><?=$carwu_info->transfer_date?></td>
            <td class="td_bg" align="center" nowrap><?=$order_info->total1_dis?></td>
            <td class="td_bg" align="center" nowrap><?=$order_info->shoufei_id?MyLib::zhifufs($order_info->shoufei_id).'-':''?><?=$order_info->payType?$order_info->payType->name:''?></td>
            <td class="td_bg" nowrap><?=$carwu_info->lock?$carwu_info->lock->getShowName():''?></td>
            <td align="center" class="td_bg" nowrap>
                [<a href="javascript:void(0);" onclick="unlock(<?=$carwu_info->order_id?>)">解锁</a>]
                [<a href="javascript:void(0);" onclick="info(<?=$carwu_info->order_id?>)">详情</a>]
            </td>
        </tr>
        <?php
    }
    ?>
    <tr>
        <td width="24" align="center" class="bg_tr">总计</td>
        <td width="50" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="80" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"><?=number_format($total1_dis,2) ?></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="60" align="center" class="bg_tr"></td>
        <td width="30" align="center" class="bg_tr"></td>
    </tr>
    <tr >
        <td height="25" colspan="18" align="center" class="td_bg"><?=$page_info?></td>
    </tr>
</table>

