<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <form id="theFrm">
        <input type="hidden" name="id" value="<?=$info->id?>">
        <tr>
            <td width="100" height="25" class="td_bg">礼券</td>
            <td height="25" class="td_bg">
                <select name="gift_id" id="gift_id">
                    <option value="0">请选择</option>
                    <?php
                    foreach($gift_items as $gift_info) {
                        echo '<option value="'.$gift_info->id.'"';
                        if($gift_info->id == $info->gift_id)
                            echo ' selected ';
                        echo '>'.$gift_info->type->name.'</option>';
                    }
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td width="100" height="25" class="td_bg">编号</td>
            <td height="25" class="td_bg">
                <input name="code" type="text" id="code" value="<?=$info->code?>" style="width:100px;"/>
            </td>
        </tr>
        <tr>
            <td width="100" height="25" class="td_bg">车牌号</td>
            <td height="25" class="td_bg">
                <input name="car_no" type="text" id="car_no" value="<?=$info->car_no?>" style="width:100px;"/>
            </td>
        </tr>
        <tr>
            <td width="100" height="25" class="td_bg">出库时间</td>
            <td colspan="3" height="25" class="td_bg"><?=$info->output_date?></td>
        </tr>
        <tr>
            <td width="100" height="25" class="td_bg">使用时间</td>
            <td colspan="3" height="25" class="td_bg"><?=$info->use_date?></td>
        </tr>
        <tr>
            <td width="100" height="25" class="td_bg">状态</td>
            <td colspan="3" height="25" class="td_bg"><?=$info->getStatus()?></td>
        </tr>
    </form>
    <tr>
        <td height="22" colspan="4" align="center" class="td_bg">
            <?php
            if($info->status == 0) {
                ?>
                <input id="output-btn" type=button class="ACT_btn" name=Submit1 value=" 出库 "/>
                &nbsp;&nbsp;
                <?php
            }
            if($info->status == 1) {
                ?>
                <input id="use-btn" type=button class="ACT_btn" name=Submit2 value=" 使用 "/>
                &nbsp;&nbsp;
                <input id="cancel-btn" type=button class="ACT_btn" name=Submit3 value=" 退回 "/>
                &nbsp;&nbsp;
                <?php
            }
            ?>
            <input id="back-btn" type="button" class="ACT_btn" name="Submit4" value=" 返回 ">
        </td>
    </tr>
</table>
<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 () {
        //出库按钮
        $("#output-btn").click(function(){
            if(confirm('是否确认提交?')) {
                var params = $("#theFrm").serialize();
                params += '&status=1';
                $.post('/gift2/ticket-save',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        $('#back-btn').click();
                    }
                },'json');
            }
        });
        //使用按钮
        $("#use-btn").click(function(){
            if(confirm('是否确认提交?')) {
                var params = $("#theFrm").serialize();
                params += '&status=2';
                $.post('/gift2/ticket-save',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        $('#back-btn').click();
                    }
                },'json');
            }
        });
        //退回按钮
        $("#cancel-btn").click(function(){
            if(confirm('是否确认提交?')) {
                var params = $("#theFrm").serialize();
                params += '&status=3';
                $.post('/gift2/ticket-save',params,function(obj){
                    alert(obj.msg);
                    if(obj.success) {
                        $('#back-btn').click();
                    }
                },'json');
            }
        });

        //返回按钮
        $('#back-btn').click(function(){
            window.location.href='/gift2/ticket-list';
        });
    })
</script>
