<?php
include_once("../includes/tag_inc.php");
//===============================================
if(!isset($_POST['statu']))
	$_POST['statu']='0';
$date=date("Y-m-d H:i:s");$pn=NULL;
if(isset($_POST['action'])&&$_POST['action']=="edit")
{
	$_POST['stime']=strtotime($_POST['stime']);
	$_POST['etime']=strtotime($_POST['etime']);
	$sql="update ".EXHIBIT." SET stime='$_POST[stime]',etime='$_POST[etime]',statu='$_POST[statu]',title='$_POST[title]',con='$_POST[con]',	smalltext='$_POST[smalltext]',pic='$_POST[pic]',tag='$_POST[tag]' WHERE id='$_POST[id]'";
	$re=$db->query($sql);
	if($re)
	{
		unset($_GET['id']);unset($_GET['s']);
		$getstr=implode('&',convert($_GET));
		admin_msg("module.php?m=exhibition&s=exhibitlist.php&$getstr",'操作成功');
	}
}
//=================================================
if(!empty($_POST['action'])&&$_POST['action']=="submit")
{
	$_POST['stime']=strtotime($_POST['stime']);
	$_POST['etime']=strtotime($_POST['etime']);
	$sql="INSERT ".EXHIBIT." (stime,etime,statu,title,con,addTime,smalltext,pic,tag) VALUES    ('$_POST[stime]','$_POST[etime]','$_POST[statu]',   '$_POST[title]','$_POST[con]','$date','$_POST[smalltext]','$_POST[pic]','$_POST[tag]')";
	$re=$db->query($sql);
	if($re)
		admin_msg("module.php?m=exhibition&s=exhibitlist.php",'操作成功');
}
if(isset($_GET['id']))
{
	$sql="select * from ".EXHIBIT." where id='$_GET[id]'";
	$db->query($sql);
	$de=$db->fetchRow();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE><?php echo lang_show('admin_system');?></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" src="../script/Calendar.js"></script>
<script type="text/javascript" src="main.js"></script>

<script src="../script/my_lightbox.js" language="javascript"></script>
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<link href="main.css" rel="stylesheet" type="text/css" />
</HEAD>
<body>
<div class="bigbox">
	<div class="bigboxhead"><?php echo lang_show('news_post');?></div>
	<div class="bigboxbody">
    <form method="post" action="" enctype="multipart/form-data">
    <table width="100%" border="0"  cellpadding="0" cellspacing="0">
        <tr> 
            <td class="body_left"> <?php echo lang_show('show_title');?></td>
            <td  colspan="3"><input class="text" name="title" type="text" value="<?php if(isset($de['title'])){echo $de['title'];}?>"  maxlength="100"></td>
        </tr>
        <tr> 
        <tr>
            <td>关键字</td>
            <td colspan="3">
            <input name="tag" class="text" type="text" id="tag" value="<?php if(isset($de['tag'])){echo $de['tag'];}?>" maxlength="40"><?php echo lang_show('separated');?></td>
        </tr>
        <tr> 
            <td width="10%"  > <?php echo lang_show('show_time');?></td>
            <td  colspan="3">
            <script language="javascript">
            var cdr = new Calendar("cdr");
            document.write(cdr);
            cdr.showMoreDay = true;
            </script>
            <input readonly name="stime" type="text" id="stime" class="ltext" value="<?php if(isset($de['stime'])){echo date("Y-m-d",$de['stime']);}?>" onFocus="cdr.show(this);"> -- 
            <input readonly onFocus="cdr.show(this);" name="etime" type="text" id="etime" class="rtext" value="<?php if(isset($de['etime'])){echo date("Y-m-d",$de['etime']);}?>"></td>
        </tr>
        <tr>
            <td>简介</td>
            <td colspan="3">
            <textarea style="width:99%" name="smalltext" rows="2"><?php if(isset($de['smalltext'])){echo $de['smalltext'];}?></textarea>
            </td>
        </tr>
        <tr> 
        	<td><?php echo lang_show('show_content');?></td>
            <td colspan="3"> 
				<script charset="utf-8" src="../lib/kindeditor/kindeditor-min.js"></script>             
                <script>
                var editor;
                KindEditor.ready(function(K) {
                editor = K.create('textarea[name="con"]', {
                });
                });
                </script>
            <textarea name="con" style="width:90%; height:400px;"><?php echo $de["con"] ?></textarea>
            </td>
        </tr>
        <tr>
            <td><?php echo lang_show('expic');?></td>
            <td colspan="3">
            <input name="pic" type="text" id="pic" value="<?php echo $de['pic'];?>" class="text">
            [<a href="javascript:uploadfile('<?php echo lang_show('upload');?>LOGO','pic',300,300,'exhibition')"><?php echo lang_show('upload');?></a>] 
            [<a href="javascript:preview('pic');"><?php echo lang_show('preview');?></a>]
            [<a href="javascript:delet_pic('pic');"><?php echo lang_show('del');?></a>]
            </td>
        </tr>
        <tr>
            <td><?php echo lang_show('is_post');?></td>
            <td colspan="3">
            <select class="select" name="statu">
            <option <?php if($de['statu']==0) echo 'selected="selected"';?> value="0"><?php echo lang_show('close');?></option>
            <option <?php if($de['statu']==1) echo 'selected="selected"';?> value="1"><?php echo lang_show('show');?></option>
            <option <?php if($de['statu']==2) echo 'selected="selected"';?> value="2"><?php echo lang_show('rec1');?></option>
            <option <?php if($de['statu']==3) echo 'selected="selected"';?> value="3"><?php echo lang_show('rec2');?></option>
            </select>
            </td>
        </tr>
        <tr> 
            <td>&nbsp;</td>
            <td colspan="3"> 
            <input class="btn" type="submit" name="cc" value="<?php echo lang_show('submit');?>">
            <input name="action" type="hidden" id="action" value="<?php if(isset($_GET['id'])) echo "edit";else echo "submit"; ?>">
            <input name="id" type="hidden" id="id" value="<?php if (isset($de['id'])) echo $de['id'];?>"></td>
        </tr>
      </table>
      </form>  
    </div>
</div>
</body>
</html>