<?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 add() {
        window.location.href = '/gift2/add';
    }
    //出库
    function output() {
        window.location.href = '/gift2/output';
    }
    //编辑
    function edit(id) {
        window.location.href = '/gift2/edit?id=' + id;
    }
    //删除
    function del(id) {
        if(confirm('是否确认删除?')) {
            $.post('/gift2/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 = "/gift2/index?" + params;
        });
        $('#add-btn').click(function(){
            add();
        });
        $('#output-btn').click(function(){
            output();
        });
    });
</script>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <form id="searchForm">
        <tr>
            <td class="td_bg">
                编号:<input name="code" type="text" value="<?=$code?>">
                车牌:<input name="car_no" type="text" value="<?=$car_no?>">
                <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="入库">
                <input type="button" class="act_btn" id="output-btn" name="output-btn" value="出库">
            </td>
        </tr>
    </form>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
        <td width="50" align="center" align="center" class="bg_tr" nowrap>序号</td>
        <td width="100" align="center" align="center" class="bg_tr" nowrap>编号</td>
        <td width="100" align="center" align="center" class="bg_tr" nowrap>所属类型</td>
        <td width="30%" align="center" align="center" class="bg_tr" nowrap>车牌号</td>
        <td width="120" align="center" align="center" class="bg_tr" nowrap>入库时间</td>
        <td width="120" align="center" align="center" class="bg_tr" nowrap>使用时间</td>
        <td width="80" align="center" class="bg_tr" nowrap>状态</td>
        <td width="120" align="center" class="bg_tr" nowrap>操作员</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 ><?=$index+1?></td>
            <td align="center" class="td_bg" nowrap ><?=sprintf("%07d",$item->code)?></td>
            <td align="center" class="td_bg" nowrap ><?=$item->type?$item->type->name:''?></td>
            <td align="left" class="td_bg" nowrap ><?=$item->car_no?></td>
            <td align="left" class="td_bg" nowrap ><?=$item->input_date?></td>
            <td align="left" class="td_bg" nowrap ><?=$item->status>1?$item->use_date:''?></td>
            <td align="left" class="td_bg" nowrap ><?=$item->getStatus()?></td>
            <td align="left" class="td_bg" nowrap ><?=$item->user?$item->user->getShowName():''?></td>
            <td align="center" class="td_bg" nowrap>
                <?php
                if($item->status > 0) {
                    ?>
                    [<a href="javascript:void(0);" onclick="edit(<?= $item->id ?>)">修改</a>]
                    <?php
                }
                ?>
                <!--
                [<a href="javascript:void(0);" onclick="del(<?=$item->id?>)">删除</a>]
                //-->
            </td>
        </tr>
        <?php
    }
    ?>
    <tr >
        <td height="25" colspan="14" align="center" class="td_bg"><?=$page_info?></td>
    </tr>
</table>