<?php
use \common\libs\MyLib;
?>
<style>
    .act_btn1{
        width: 120px;
        background-repeat: round;
    }
</style>
<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 edit(id) {
        var params = $('#searchForm').serialize();
        window.location.href = '/car/edit?id=' + id  + '&back_params=' + encodeURIComponent(params);
    }
    //删除
    function del(id) {
        if(confirm('是否确认删除?')) {
            $.post('/car/delete',{id:id},function(obj){
                alert(obj.msg);
                if(obj.success) {
                    window.location.reload();
                }
            },'json');
        }
    }

    $(function(){
        $("#search-btn").click(function(){
            $('#page').val(0);
            var params = $('#searchForm').serialize();
            window.location.href = "/database/kufang-index?" + params;
        });
        $('#add-btn').click(function(){
            edit(0);
        });
        $('#move-b-btn').click(function(){
            var unsel_lib = $('#unsel_lib').attr('checked');
            if(unsel_lib != 'checked') {
                alert('请先选择未分配选项');
                return;
            }
            if(confirm('是否确认批量分配操作?')) {
                var params = $('#searchForm').serialize();
                $.post('/database/a-move-b',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        window.location.reload();
                    }
                },'json');
            }
        });
        $('#move-e-btn').click(function(){
            var unsel_lib = $('#unsel_lib').attr('checked');
            if(unsel_lib != 'checked') {
                alert('请先选择未分配选项');
                return;
            }
            if(confirm('是否确认批量分配操作?')) {
                var params = $('#searchForm').serialize();
                $.post('/database/a-move-e',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        window.location.reload();
                    }
                },'json');
            }
        });
        $('#move-right-btn').click(function(){
            var unsel_lib = $('#unsel_lib').attr('checked');
            if(unsel_lib != 'checked') {
                alert('请先选择未分配选项');
                return;
            }
            if(confirm('是否确认批量分配操作?')) {
                var params = $('#searchForm').serialize();
                $.post('/database/a-move-clean',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        window.location.reload();
                    }
                },'json');
            }
        });
        $('#move-btn').click(function(){
            if(confirm('是否确认 A->B 操作?')) {
                var params = $('#listFrm').serialize();
                $.post('/database/a-b',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        window.location.reload();
                    }
                },'json');
            }
        });
        $('#clean-btn').click(function(){
            if(confirm('是否确认 A->清洗库 操作?')) {
                var params = $('#listFrm').serialize();
                $.post('/database/a-clean',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        window.location.reload();
                    }
                },'json');
            }
        });
        $('#move-a2c-btn').click(function(){
            if(confirm('是否确认 A->C 操作?')) {
                var params = $('#listFrm').serialize();
                $.post('/database/a-c',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        window.location.reload();
                    }
                },'json');
            }
        });
        $('#move-a2e-btn').click(function(){
            if(confirm('是否确认 A->E 操作?')) {
                var params = $('#listFrm').serialize();
                $.post('/database/a-e',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        window.location.reload();
                    }
                },'json');
            }
        });
        $('.invalid-btn').click(function(){
            if(confirm('是否确认无效?')) {
                var params = $('#listFrm').serialize();
                var invalid_id = $('#invalid_id').val();
                params = params + '&invalid_id=' + invalid_id;
                $.post('/database/invalid',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        window.location.reload();
                    }
                },'json');
            }
        });
        /*
        $("#output-btn").click(function(){
            $('#page').val(0);
            var params = $('#searchForm').serialize();
            window.open("/database/a-index-output?" + params);
        });
        */
        $('#all').click(function(){
            if($(this).prop('checked')==true) {
                $('.item').each(function() {
                    $(this).prop('checked', true);
                });
            } else {
                $('.item').each(function () {
                    $(this).prop('checked',false);
                });
            }
        });
    });
</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">
                车牌：<input name="car_no" type="text" value="<?=$car_no?>" style="width:100px;">
                发动机号：<input name="engine_no" type="text" value="<?=$engine_no?>"  style="width:100px;">
                <input type="button" class="act_btn" id="search-btn" name="search-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="78" align="center" align="center" class="bg_tr" nowrap>车牌</td>

            <td width="96" align="center" 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 ><input class="item" type="checkbox" name="ids[]" value="<?=$item->id?>"></td>
                <td align="left" class="td_bg"nowrap><?=$item->car_no?></td>
                <td align="left" class="td_bg"nowrap ><?=$item->car_frame_no?></td>

            </tr>
            <?php
        }
        ?>
        <tr >
            <td height="25" colspan="3" align="center" class="td_bg"><?=$page_info?></td>
        </tr>
    </table>
</form>
<script>
    function test() {
        alert(1);
    }
</script>