<?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/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
    //编辑
    function edit(id) {
        var params = $('#searchForm').serialize();
        window.location.href = '/non-auto-insurance/info?id=' + id + '&back_params=' + encodeURIComponent(params);
    }
    //删除
//    function del(id) {
//        if(confirm('是否确认删除?')) {
//            $.post('/fix-car/my-list-delete',{id:id},function(obj){
//                alert(obj.msg);
//                if(obj.success) {
//                    window.location.reload();
//                }
//            },'json');
//        }
//    }
    $(function(){
        $("#search-btn").click(function(){
            var params = $('#searchForm').serialize();
            window.location.href = "/non-auto-insurance/index?" + params;
        });
        $('#add-btn').click(function(){
            window.location.href = '/non-auto-insurance/info';
        });
        $('#assign-btn').click(function(){
            if(confirm('是否确认分配操作?')) {
                var params = $('#listFrm').serialize();
                var user_id = $('#user_id').val();
                params = params + '&user_id=' + user_id;
                $.post('/non-auto-insurance/assign',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        window.location.reload();
                    }
                },'json');
            }
        });
        $('#return-btn').click(function(){
            if(confirm('是否确认收回操作?')) {
                var params = $('#listFrm').serialize();
                $.post('/non-auto-insurance/return',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        window.location.reload();
                    }
                },'json');
            }
        });
    });
</script>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <form id="searchForm">
        <tr>
            <td class="td_bg">
                被保险人：<input name="insurant_name" type="text" value="<?=$insurant_name?>">
                分配状态：<select name="status">
                    <option value="0">全部</option>
                    <option value="1" <?=$status==1?'selected':''?>>未分配</option>
                    <option value="2" <?=$status==2?'selected':''?>>已分配</option>
                </select>
                <input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索">
                <input type="button" class="act_btn" id="add-btn" name="add-btn" value="添加">
                业务员：<select name="user_id" id="user_id">
                    <option value="0">请选择</option>
                    <?php
                    foreach($user_items as $item) {
                        echo '<option value="'.$item->id.'"';
                        if($item->id == $user_id)
                            echo ' selected ';
                        echo '>'.$item->getShowName().'</option>';
                    }
                    ?>
                </select>
                <input type="button" class="act_btn" id="assign-btn" name="assign-btn" value="勾选分配">
                <input type="button" class="act_btn" id="return-btn" name="return-btn" value="勾选收回">
            </td>
        </tr>
    </form>
</table>
<form id="listFrm">
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
        <td align="center" width="24" align="center" class="bg_tr"><input type="checkbox" id="all"></td>
        <td width="50" align="center" align="center" class="bg_tr" nowrap>排序</td>
        <td align="center" align="center" class="bg_tr">被保险人</td>
        <td align="center" align="center" class="bg_tr">被保险人证件号</td>
        <td align="center" align="center" class="bg_tr">投保人</td>
        <td align="center" align="center" class="bg_tr">投保人证件号</td>
        <td align="center" align="center" class="bg_tr">操作员</td>

        <td width="30" align="center" class="bg_tr">操作</td>
    </tr>
    <?php
    foreach($items as $index => $item) {
        ?>
        <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
            <td align="center" class="td_bg"nowrap ><input type="checkbox" name="ids[]" value="<?=$item->id?>"></td>
            <td align="center" class="td_bg" nowrap><?=$index+1?></td>
            <td align="left" class="td_bg" nowrap><?=$item->insurant_name?></td>
            <td align="left" class="td_bg" nowrap><?=$item->insurant_number?></td>
            <td align="left" class="td_bg" nowrap><?=$item->policy_holder_name?></td>
            <td align="left" class="td_bg" nowrap><?=$item->policy_holder_number?></td>
            <td align="left" class="td_bg" nowrap><?=$item->non_user_id?$item->nonUser->getShowName():''?></td>
            <td align="center" class="td_bg" nowrap>

                    [<a href="javascript:void(0);" onclick="edit(<?= $item->id ?>)">修改</a>]


            </td>
        </tr>
        <?php
    }
    ?>
    <tr >
        <td height="25" colspan="12" align="center" class="td_bg"><?=$page_info?></td>
    </tr>
</table>
</form>
