<link href="/css/tabs.css" rel="stylesheet" type="text/css">
<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>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <tr>
        <td height="22" class="td_bg">
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                <TBODY>
                <TR>
                    <TD height="30" align="center" class=tab-on id=navcell onclick=switchCell(1) name="navcell">配件列表
                    </TD>
                    <TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(2) name="navcell">辅料列表
                    </TD>
                    <TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(3) name="navcell">入库记录
                    </TD>
                    <TD height="30" class=tab-none>&nbsp;</TD>
                </TR>
                </TBODY>
            </TABLE>
        </td>
    </tr>
    <tr>
        <td height="22" colspan="2" class="td_bg">
            <table width="100%" align="center" height="120" border="0" cellpadding="0" cellspacing="0" id="mainTable">
                <tr>
                    <td height="120" valign="top" class="td_bg">
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb">
                            <TR>
                                <TD valign="top">
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                           class="table" style="table-layout: fixed;">
                                        <form id="searchForm">
                                            <tr>
                                                <td class="td_bg">
                                                    <label for="category_1">分类:</label>
                                                    <select name="category_1" id="category_1" onchange="changeCategory()">
                                                        <option value="0" <?= '0' === $category_1 ? 'selected' : ''  ?>>--请选择--</option>
                                                        <option value="1" <?= '1' === $category_1 ? 'selected' : ''  ?>>配件</option>
                                                        <option value="2" <?= '2' === $category_1 ? 'selected' : ''  ?>>材料</option>
                                                        <option value="3" <?= '3' === $category_1 ? 'selected' : ''  ?>>辅料</option>
                                                    </select>
                                                    <label for="brand_id" class="c-hide">品牌:</label>
                                                    <select name="brand_id" id="brand_id" class="c-hide">
                                                        <option value="0">--请选择--</option>
                                                        <?php if($brands): ?>
                                                            <?php foreach($brands as $brand): ?>
                                                                <option value="<?= $brand->id ?>" <?= $brand->id == $brand_id ? 'selected' : '' ?>><?= $brand->name ?></option>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                    </select>
                                                    <label for="series_id" class="c-hide">车型:</label>
                                                    <select name="series_id" id="series_id" class="c-hide">
                                                        <option value="0">--请选择--</option>
                                                        <?php if(isset($series)): ?>
                                                            <?php foreach ($series as $serie): ?>
                                                                <option value="<?= $serie->id ?>" <?= $serie->id == $series_id ? 'selected' : '' ?>><?= $serie->name ?></option>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                    </select>
                                                    <label for="displacement_id" class="c-hide">排量:</label>
                                                    <select name="displacement_id" id="displacement_id" class="c-hide">
                                                        <option value="0">--请选择--</option>
                                                        <?php if(isset($displacements)): ?>
                                                            <?php foreach($displacements as $displacement): ?>
                                                                <option value="<?= $displacement->id ?>" <?= $displacement->id == $displacement_id ? 'selected' : '' ?>><?= $displacement->name ?></option>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                    </select>
                                                    <label for="year_id" class="c-hide">年份:</label>
                                                    <select name="year_id" id="year_id" class="c-hide">
                                                        <option value="0">--请选择--</option>
                                                        <?php if($years): ?>
                                                            <?php foreach ($years as $year): ?>
                                                                <option value="<?= $year->id ?>"><?= $year->name ?></option>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                    </select>

                                                    <input type="submit" class="act_btn" id="search-btn" name="search-btn" value="搜索">
                                                    <input type="button" class="act_btn" value="添加" onclick="location.href='/store-room/put-in-store-info'">
                                                </td>
                                            </tr>
                                        </form>
                                    </table>
                                    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                           class="table">
                                        <tr>
                                            <td 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 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" width="10%">入库时间</td>
                                            <td align="center" class="bg_tr">操作</td>
                                        </tr>
                                        <?php if ($stores): ?>
                                            <?php foreach ($stores as $key => $store): ?>
                                                <tr onMouseOver="outColor(this)" onMouseOut="overColor(this)">
                                                    <td align="center" class="td_bg" nowrap><?= $key + 1 ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= $store->good_sn ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= $store->name ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= $store->model ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= $store->producing_area ?></td>
                                                    <td align="center" class="td_bg" nowrap>
                                                        <?php if($store->number < 1): ?>
                                                            <span style="color:red;">缺货</span>
                                                        <?php else: ?>
                                                            <?= $store->number.$store->monad ?>
                                                        <?php endif; ?>
                                                    </td>
                                                    <td align="center" class="td_bg" nowrap><?= $store->price ?>元</td>
                                                    <td align="center" class="td_bg" nowrap><?= $store->selling_price ?>元</td>
                                                    <td align="center" class="td_bg" nowrap><?= $store->created_at ?></td>
                                                    <td align="center" class="td_bg" nowrap>
                                                        [<a href="javascript:void(0);" onclick="edit('<?= $store->id ?>')">详情</a>]
                                                        [<a href="javascript:void(0);">删除</a>]
                                                    </td>
                                                </tr>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                        <tr>
                                            <td height="25" colspan="14" align="center" class="td_bg"><?= $page_info ?></td>
                                        </tr>
                                    </table>
                                </TD>
                            </TR>
                        </TABLE>
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
                            <TR>
                                <TD valign="top">
                                    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                           class="table" style="table-layout: fixed;">
                                        <form id="searchForm">
                                            <tr>
                                                <td class="td_bg">
                                                    <input type="button" class="act_btn" value="添加" onclick="location.href='/store-room/ingredients-view'">
                                                </td>
                                            </tr>
                                        </form>
                                    </table>
                                    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                           class="table" style="table-layout: fixed;">
                                        <tr>
                                            <td 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 align="center" align="center" class="bg_tr" width="10%">入库时间</td>
                                            <td align="center" class="bg_tr">操作</td>
                                        </tr>
                                        <?php if ($stores): ?>
                                            <?php foreach ($stores as $key => $store): ?>
                                                <tr>
                                                    <td align="center" class="td_bg" nowrap><?= $key + 1 ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= $store->name ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= $store->producing_area ?></td>
                                                    <td align="center" class="td_bg" nowrap>
                                                        <?php if($store->number < 1): ?>
                                                            <span style="color:red;">缺货</span>
                                                        <?php else: ?>
                                                            <?= $store->number ?>
                                                        <?php endif; ?>
                                                    </td>
                                                    <td align="center" class="td_bg" nowrap><?= number_format($store->price,2) ?>元</td>
                                                    <td align="center" class="td_bg" nowrap>元</td>
                                                    <td align="center" class="td_bg" nowrap><?= $store->created_at ?></td>
                                                    <td align="center" class="td_bg" nowrap>
                                                        [<a href="javascript:void(0);" onclick="edit('<?= $store->id ?>')">详情</a>]
                                                        [<a href="javascript:void(0);">删除</a>]
                                                    </td>
                                                </tr>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                        <tr>
                                            <td height="25" colspan="8" align="center" class="td_bg"><?= $page_info ?></td>
                                        </tr>
                                    </table>
                                </TD>
                            </TR>
                        </TABLE>
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
                            <TR>
                                <TD>
                                    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                           class="table" style="table-layout: fixed;">
                                        <tr>
                                            <td align="center" class="bg_tr" nowrap width="5%">排序</td>
                                            <td align="center" align="center" class="bg_tr" nowrap>品牌</td>
                                            <td align="center" align="center" class="bg_tr" nowrap>车型</td>
                                            <td align="center" align="center" class="bg_tr" nowrap>排量</td>
                                            <td align="center" align="center" class="bg_tr" nowrap>年份</td>
                                            <td align="center" align="center" class="bg_tr" nowrap>配件名字</td>
                                            <td align="center" align="center" class="bg_tr" nowrap>数量</td>
                                            <td align="center" align="center" class="bg_tr" nowrap>操作人</td>
                                            <td align="center" align="center" class="bg_tr" nowrap>操作时间</td>
                                        </tr>
                                        <?php if (isset($store_logs)): ?>
                                            <?php foreach ($store_logs as $key => $store_log): ?>
                                                <tr>
                                                    <td align="center" class="td_bg" nowrap><?= $key + 1 ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= isset($store_log->brand_id) ? $store_log->brand->name : '' ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= isset($store_log->series_id) ? $store_log->series->name : '' ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= isset($store_log->displacement_id) ? $store_log->displacement->name : ''?></td>
                                                    <td align="center" class="td_bg" nowrap><?= isset($store_log->year_id) ? $store_log->year->name : '' ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= $store_log->name ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= $store_log->number ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= $store_log->op_man ?></td>
                                                    <td align="center" class="td_bg" nowrap><?= $store_log->op_time ?></td>
                                                </tr>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                        <!--    <tr>-->
                                        <!--        <td height="25" colspan="12" align="center" class="td_bg">分页位置</td>-->
                                        <!--    </tr>-->
                                    </table>
                                </TD>
                            </TR>
                        </TABLE>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<script type="text/javascript" language="javascript" src="/js/common.js"></script>
<script type="text/javascript" language="javascript">
    //编辑
    function edit(id) {
        window.location.href = '/store-room/put-in-store-info?id=' + id;
    }
    changeCategory();
    function changeCategory(){
        var cid = $('#category_1').val();
        $('.c-hide').hide();
        if('1' === cid) $('.c-hide').show();
    }
</script>
