<?php 
	session_start(); 
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	require_once('inc/check.php');
	$opendb=new mydb();
	require_once('inc/char_set.php');
	$ls_msg="常见问题";
	$ls_msg2="修改常见问题操作";
	$id=$_GET['id'];

	$problem_sql="select ls_problem.ID, ls_problem.cate, ls_problem.enable, ls_problem.problemTitle, ls_problem.problemDate,ls_problem.keywords, ls_problem.problemText, ls_functioncates.cateName, ls_problem.Num from ls_problem, ls_functioncates where ls_problem.ID=".$id." and ls_problem.cate = ls_functioncates.ID";
	$problem_query=$opendb->query($problem_sql);
	$problem_rows=mysql_fetch_assoc($problem_query);
	$selectcate=$_GET['selectcate'];

	$news_sql="select * from ls_problem where ID=".$id." ";
	$news_query=$opendb->query($news_sql);
	$news_rows=mysql_fetch_assoc($news_query);
	
	$title_sql = "select * from ls_config";
	$title_query = $opendb->query($title_sql);
	$title_value = mysql_fetch_assoc($title_query)

?>
<!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>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link href="css/admin.css" rel="stylesheet" type="text/css">
        <script language="JavaScript" src="js/jquery.js"></script>
		<script language="JavaScript" src="js/ls.js"></script>
		<title>无标题文档</title>
<link rel="stylesheet" href="kindeditor-4.1.10/themes/default/default.css" />
<link rel="stylesheet" href="kindeditor-4.1.10/plugins/code/prettify.css" />
<script charset="utf-8" src="kindeditor-4.1.10/kindeditor.js"></script>
<script charset="utf-8" src="kindeditor-4.1.10/lang/zh_CN.js"></script>
<script charset="utf-8" src="kindeditor-4.1.10/plugins/code/prettify.js"></script>
<script>
    KindEditor.ready(function(K) {
        var editor1 = K.create('textarea[name="problemText"]', {
            cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
            uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
            fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
            allowFileManager : true,
			afterBlur: function(){
				this.sync();
			},
            afterCreate : function() {
                var self = this;
                K.ctrl(document, 13, function() {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
                K.ctrl(self.edit.doc, 13, function() {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
            }
        });
        prettyPrint();
    });
</script>
	</head>

	<body>
		<table width="96%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#6396d6">
			<tr>
				<td height="18" background="images/admin_bg.gif"><div align="center"><font color="#ffffff"><strong>修改<?=$ls_msg?></strong></font></div>
				</td>
			</tr>
			<tr>
				<td height="213" valign="top" bgcolor="#dee7ff"><br>
				 <form name="problemform" enctype="multipart/form-data" method="post" action="saveproblem.php" onSubmit="return checkSubmitForm('problemDate,cate,Num,problemTitle','日期,新闻分类,序号,新闻标题');">
					<input type="hidden" value="update" name="ls">
					<input type="hidden" value="<?php echo $id;?>" name="id">
					<table border="0" width="90%" align="center">
						<tr>
							<td>提示：<font color="#FF0000"><?php echo $ls_msg2; ?></font></td>
							<td align="right"><img src="images/shao.gif">&nbsp;<a href="problem.php?selectcate=<?=$selectcate?>"><u>返回</u></a></td>
						</tr>
					</table>
					<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
					 
					  <tr bgcolor="#B9DAFF"> 
						<td height="28" colspan="3"></td>
					  </tr>
					  <tr bgcolor="#f4f4f4"> 
						<td style="padding-left:20px;" width="12%"><?=$ls_msg?>
					    分类：</td>
						<td width="39%"><input type="text" name="cate" id="cate" style="width:155px;" value="<?php echo $problem_rows['cateName'];?>" readonly />
						  <input type="hidden" value="<?php echo $problem_rows['cate'];?>" name="cateID" />
                           &nbsp; 分类：
                          <select name="select2" id="select2"  onchange="problemform.cate.value=this.options[this.selectedIndex].text;problemform.cateID.value=this.value;">
                            <option value="0">请选择一个类别：</option>
                            <?
			$problem_sql="SELECT ID, cateName FROM ls_functioncates  where functionName='常见问题' order by Num";//count the error by searchtype
			$problem_query=$opendb->query($problem_sql);
			while($problem_rows2=mysql_fetch_assoc($problem_query))
		  	{
				echo "<option value=".$problem_rows2['ID'].">".$problem_rows2['cateName']."</option>";
			}

			?>
                          </select>
</td>
						<td width="49%" rowspan="3"><table border="0" width="98%">
						  <tr>
						    <td bgcolor="#f4f4f4" >标题 Title</td>
						    <td><input name="newsTitle" id="newsTitle" type="text" value="<?php echo $news_rows['title'];?>" size="70" /></td>
					      </tr>
						  <tr>
						    <td bgcolor="#f4f4f4" >关键字 Keywords</td>
						    <td><input name="newsKeywords" id="newsKeywords" type="text" value="<?php echo $news_rows['keywords'];?>" size="70" /></td>
					      </tr>
						  <tr>
						    <td bgcolor="#f4f4f4"  >描述 Description<br /></td>
						    <td><textarea name="newsDescription" cols="72" rows="3" id="newsDescription"><?php echo $news_rows['description'];?></textarea></td>
					      </tr>
					    </table></td>
					  </tr>
					  <tr bgcolor="#f4f4f4">
						<td style="padding-left:20px;"><?=$ls_msg?>
					    标题：</td>
						<td ><input type="text" name="problemTitle"  id="problemTitle" style="width:350px;" value="<?php echo $problem_rows['problemTitle'];?>" /></td>
					  </tr>
                      <tr bgcolor="#f4f4f4">
                      		<td style="padding-left:20px;">序号：</td>
                            <td>
                              <input name="Num"  id="Num" type="text" style="width:40px;" value="<?php echo $problem_rows['Num'];?>" size="6" maxlength="6" /> &nbsp; 
日期：
<input name="problemDate" id="problemDate" type="text" style="width:90px;" value="<?=date('y-m-d')?>" size="20"  />
                           </td>
                      </tr>
					  <tr bgcolor="#f4f4f4"> 
						<td colspan="2" style="padding-left:20px;" ><?=$ls_msg?>内容：</td>
						<td style="padding-left:150px;" ><div align="center">
						  <input type="submit" value="保存"> &nbsp; 
						  <input type="reset" name="button" id="button" value="重置" /> &nbsp; 
                          <input type="button" name="button" id="button" value="SEO"  onclick="
                            if(confirm('您确定要修改SEO设置吗？')){
                            $('#newsTitle').val($('#problemTitle').val()+' - '+$('#cate').val()); 
						$('#newsKeywords').val('<?=$title_value['siteKeywords']?>');
						$('#newsDescription').val($('#problemText').val().substr(0, 86).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
	}else{
		return false;
	}"/>
						</div></td>
					  </tr>
					  <tr bgcolor="#f4f4f4"> 
						<td style="padding-left:20px;" colspan="3" ><!--
						<input type="hidden" name="problemText" value="<?php //echo htmlspecialchars($problem_rows['problemText']);?>">
						<iframe ID="eWebEditor1" src="ewebeditor/ewebeditor.php?id=problemText&style=coolblue" frameborder="0" scrolling="no" width="100%" HEIGHT="350"></iframe>-->
                        <textarea name="problemText" id="problemText" style="width:100%;height:350px;visibility:hidden;"><?php echo htmlspecialchars($problem_rows['problemText']); ?></textarea>
						</td>
						</tr>
					  <tr bgcolor="#B9DAFF"> 
						<td height="25" colspan="3" align="center"><span style="float:right;"><img src="images/shao.gif" alt="" />&nbsp;<a href="problem.php?selectcate=<?=$selectcate?>"><u>返回</u></a></span><input type="submit" value="保存" /> &nbsp; 
					    <input type="reset" name="button2" id="button2" value="重置" />	</td>
					  </tr>
					</table>
					<br />
                 </form>
				</td>
			</tr>
		</table>
	</body>
</html>