<?php (!defined('IN_ADMIN') || !defined('IN_MUDDER')) && exit('Access Denied'); ?>
<div id="body">
<form method="post" name="disposalfrm" enctype="multipart/form-data" action="admincp.php?action=<?=$action?>&file=<?=$file?>&">
    <? if($file == 'giftedit') { ?>
    <input type="hidden" name="giftid" value="<?=$giftid?>" />
    <? } ?>
    <div class="space">
        <div class="subtitle"><?=($file=='giftadd' ? '增加礼品' : '编辑礼品信息')?></div>
        <table class="maintable" border="0" cellspacing="0" cellpadding="0">
            <tr><td width="60" class="altbg1">礼品名称：</td><td><input type="text" name="gift[name]" value="<?=$gift['name']?>" class="txtbox" /></td></tr>
            <tr><td class="altbg1">显示顺序：</td><td><input type="text" name="gift[displayorder]" value="<?=$gift['displayorder']?>" class="txtbox4" /></td></tr>
            <tr><td class="altbg1">价格：</td><td><input type="text" name="gift[price]" value="<?=$gift['price']?>" class="txtbox4" /></td></tr>
            <tr><td class="altbg1">数量：</td><td><input type="text" name="gift[num]" value="<?=$gift['num']?>" class="txtbox4" /></td></tr>
            <tr><td class="altbg1">图片：</td><td>
                    <? if($file == 'giftedit') { ?><span id="reload"><a href="<?=$_config['siteurl']?>uploads/gifts/<?=$gift['picture']['filename']?>" target="_blank"><?=$gift['picture']['filename']?></a></span>&nbsp;&nbsp;[<a href="javascript:reload();" id="switch">重新上传</a>]<? } else { ?><input type="file" name="picture" size="50" class="upfile"><? } ?>
                </td>
            </tr>
            <tr><td valign="top" class="altbg1">描述：</td><td><?=$fckhtml?></td></tr>
            <tr><td width="60" class="altbg1">状态：</td><td><input type="checkbox" name="gift[available]" value="1" <?=($gift['available'] ? 'checked="checked" ' : '')?>/> 可用</td></tr>
        </table>
        <center><input type="submit" name="dosubmit" value=" 提交 " class="btn" />&nbsp;&nbsp;<input type="button" value=" 返回 " onclick="history.go(-1);" class="btn" /></center></center>
    </div>
</form>
<script type="text/javascript">
var g;
function reload() {
    var obj = document.getElementById('reload');
    var btn = document.getElementById('switch');
    if(obj.innerHTML.match(/^<.+href=.+>/)) {
        g = obj.innerHTML;
        obj.innerHTML = '<input type="file" name="picture" size="50" class="upfile">';
        btn.innerHTML = '取消上传';
    } else {
        obj.innerHTML = g;
        btn.innerHTML = '重新上传';
    }
}
</script>
</div>