<?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 edit(id) {
        var params = $('#searchForm').serialize();
        window.location.href = '/finance/caiwu-zc-info?id=' + id + '&back_params=' + encodeURIComponent(params);
    }
    //删除
    function del(id) {
        if(confirm('是否确认删除?')) {
            $.post('/finance/caiwu-zc-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 = "/finance/caiwu-zc-list?" + params;
        });
        $('#searchForm').submit(function(){
            $('#search-btn').click();
            return false;
        });
        $("#add-btn").click(function(){
            edit(0);
        });
    });


</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="record_s_date" id="record_s_date" class="Wdate" type="text" value="<?=$record_s_date?>" onClick="WdatePicker()">
                -
                <input name="record_e_date" id="record_e_date" class="Wdate" type="text" value="<?=$record_e_date?>" onClick="WdatePicker()">
                大类：<select name="class_id">
                    <option value="">全部</option>
                    <?php
                    foreach($class_list as $class_info) {
                        echo '<option value="'.$class_info->id.'"';
                        if($class_id == $class_info->id)
                            echo ' selected ';
                        echo '>'.$class_info->name.'</option>';
                    }
                    ?>
                </select>
                项目：<input type="text" name="title" value="<?=$title?>" typeof="width:100">
                <input type="submit" class="act_btn" id="search-btn" name="search-btn" value="搜索">
                <input type="button" class="act_btn" id="add-btn" name="add-btn" value="添加">
            </td>
        </tr>
    </form>
</table>
<table width="98%" border="0" align="center" cellpadding="3" 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 align="center" class="bg_tr" nowrap>大类</td>
        <td align="center" class="bg_tr" nowrap>项目</td>
        <td align="center" class="bg_tr" nowrap>单价</td>
        <td align="center" class="bg_tr" nowrap>数量</td>
        <td align="center" class="bg_tr" nowrap>总计</td>
        <td align="center" class="bg_tr" nowrap>备注</td>
        <td width="30" align="center" class="bg_tr" nowrap>操作</td>
    </tr>
    <form id="delFrm">
        <?php
        foreach($items as $index => $item) {
            $namess=$item->class;
            $names=$namess['name'];

            ?>
            <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
                <td align="center" class="td_bg" nowrap><?=$index+1?></td>
                <td align="center" class="td_bg" nowrap><?=$item->record_date?></td>
                <td align="center" class="td_bg" nowrap><?=$names?></td>
                <td align="center" class="td_bg" nowrap><?=$item->title?></td>
                <td align="center" class="td_bg" nowrap><?=number_format($item->price,2)?></td>
                <td align="center" class="td_bg" nowrap><?=$item->num?></td>
                <td align="center" class="td_bg" nowrap><?=number_format($item->total,2)?></td>
                <td align="center" class="td_bg" nowrap><?=$item->note?></td>
                <td align="center" class="td_bg" nowrap>
                    [<a href="javascript:void(0);" onclick="edit(<?=$item->id?>)">修改</a>]
                    [<a href="javascript:void(0);" onclick="del(<?=$item->id?>)">删除</a>]
                </td>
            </tr>
            <?php
        }
        ?>
    </form>
    <tr >
        <td height="25" colspan="9" align="center" class="td_bg"><?=$page_info?></td>
    </tr>
</table>
