<?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(){
        $('#save-btn').click(function(){
            var params = $('#theFrm').serialize();
            $.post('/appointment/save',params,function(obj){
                if(obj.success) {
                    window.location.reload();
                } else {
                    alert(obj.msg);
                }
            },'json');
        });
        //返回按钮
        $('#back-btn').click(function(){
            history.go(-1);
        });
    });
</script>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <form id="theFrm">
        <input type="hidden" name="car_id" value="<?=$car_id?>">
        <tr>
            <td align="right" class="bg_tr">预约日期：</td>
            <td class="td_bg">
                <div align="left">
                    <input id="pdate" name="pdate" type="text" value="" onClick="WdatePicker()"/>
                </div>
            </td>
            <td align="right" class="bg_tr">预约时间：</td>
            <td class="td_bg">
                <div align="left">
                    <select name="ptime" id="ptime">
                        <option>08:00</option>
                        <option>08:30</option>
                        <option>09:00</option>
                        <option>09:30</option>
                        <option>10:00</option>
                        <option>10:30</option>
                        <option>11:00</option>
                        <option>11:30</option>
                        <option>12:00</option>
                        <option>13:00</option>
                        <option>13:30</option>
                        <option>14:00</option>
                        <option>14:30</option>
                        <option>15:00</option>
                        <option>15:30</option>
                        <option>16:00</option>
                        <option>16:30</option>
                        <option>17:00</option>
                    </select>
                </div>
            </td>
            <td align="right" class="bg_tr">当天预约人数：</td>
            <td width="50" class="td_bg">
                <div align="left">
                    <span id="day_count">0</span>
                </div>
            </td>
        </tr>
        <tr>
            <td align="right" class="bg_tr">预约备注：</td>
            <td colspan="5" class="td_bg">
                <div align="left">
                    <textarea name="remark" id="remark" style="width:600px; height: 30px;"></textarea>
                </div>
            </td>
        </tr>
        <tr>
            <td height="22" colspan="6" align="center" class="td_bg">
                <input id="save-btn" type=button class="ACT_btn" name="save-btn" value=" 保存 "/>
                <input id="back-btn" type=button class="ACT_btn" name=Submit1 value=" 返回 "/>
            </td>
        </tr>
    </form>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
        <td width="50" align="center" class="bg_tr" nowrap>序号</td>
        <td width="80" align="center" class="bg_tr" nowrap>预约日期</td>
        <td width="80" align="center" class="bg_tr" nowrap>预约时间</td>
        <td width="60%" align="center" class="bg_tr" nowrap>预约备注</td>
        <td width="30" align="center" class="bg_tr" nowrap>业务员</td>
        <td width="30" align="center" class="bg_tr" nowrap>操作时间</td>
    </tr>
    <?php
    foreach($items as $index => $item) {
        $start_index = ($page-1) * 20 + $index;
        $car_info = $item->car;
        ?>
        <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
            <td align="center" class="td_bg"nowrap ><?=$start_index+1?></td>
            <td align="center" class="td_bg" nowrap><?=$item->pdate?></td>
            <td align="center" class="td_bg" nowrap><?=$item->ptime?></td>
            <td class="td_bg" ><?=$item->remark?></td>
            <td class="td_bg" nowrap><?=$item->user?$item->user->getShowName():''?></td>
            <td align="center" class="td_bg" nowrap><?=$item->updated_at?></td>
        </tr>
        <?php
    }
    ?>
    <tr>
        <td height="25" colspan="11" align="center" class="td_bg"><?=$page_info?></td>
    </tr>
</table>
