<?php
	include_once("check_login.php");
	include_once("include/config.php");
	$action = trim($_GET["action"]);
	$job_id = trim($_GET["job_id"]);
	if(!check_is_numb($job_id) || $job_id < 1)
		show_err("职位信息参数出错，请返回重新操作");
	$filter_arr[0] = array("0",$job_id,false);
	if(!$hm_arr = get_job($filter_arr))
		show_err("系统中没有你要修改的职位信息");
	if($action == "save"){
		unset($hm_arr);
		check_site_url();
		array_pop($_POST);//表单提交上来的数据都存入$_POST数组中，现在弹出最后一个数组值，因为最后一个是按纽
		extract($_POST);//把数组名作为变量名，数组值作为变量值

		$job_name = trim($job_name);
		(strlen($job_name) < 1 || check_bad_str($job_name)) ? show_err("请输入职位名，或职位名中有非法字符") : $job_name = addslashes($job_name);
		$job_address = trim($job_address);
		(strlen($job_address) < 1 || check_bad_str($job_address)) ? show_err("请输入工作地点，或工作地点中有非法字符") : $job_address = addslashes($job_address);
		$job_xl = trim($job_xl);
		!is_numeric($job_xl) && show_err("请选择要求的最低学历");
		$job_zy = trim($job_zy);
		(strlen($job_zy) < 1 || check_bad_str($job_zy)) ? show_err("请输入要求的专业，或专业中有非法字符") : $job_zy = addslashes($job_zy);
		$job_pay = trim($job_pay);
		(strlen($job_pay) < 1 || check_bad_str($job_pay)) ? show_err("请输入薪资待遇，或薪资待遇中有非法字符") : $job_pay = addslashes($job_pay);
		$job_available = trim($job_available) == "hmcss" ? 1 : 0;
		
		strlen($job_require) < 9 ? show_err("请输入至少10个英文字符或5个中文字的职位要求") : $job_require = addslashes($job_require);
		strlen($job_do) < 9 ? show_err("请输入至少10个英文字符或5个中文字的工作范围") : $job_do = addslashes($job_do);
		mysql_query("update hmcss_job_main set job_name = '$job_name',job_address = '$job_address',job_xl = '$job_xl',job_zy = '$job_zy',job_pay = '$job_pay',job_available = $job_available,job_require = '$job_require',job_do = '$job_do' where job_id = $job_id")
			or show_err("修改招聘信息出错，请联系管理员");
		show_err("该招聘信息已成功修改","set_job_list.php");
	}
?>
<!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" />
<title>修改招聘信息</title>
<script language = "javascript" src="include/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckfinder/ckfinder.js"></script>
<style type="text/css">
input,select{margin:4px auto;}
</style>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>
<div class="head_menu"><span class="head_menu_on"><a href="set_job_list.php">职位列表</a></span><a href="set_job_new.php">添加招聘</a><a href="set_job_good.php">福利待遇</a></div>
<div class="set_main_out">
  <form id="form1" name="form1" method="post" action="set_job_edit.php?action=save&job_id=<?php echo $job_id; ?>">
    <div class="set_main">
      <ul>
        <li style="width:100px; color:#C03;">岗位名称:</li>
        <li style="width:278px;"><input name="job_name" type="text" id="job_name" size="30" maxlength="100" value="<?php echo stripslashes($hm_arr[0][1]); ?>" /></li>
        <li style="width:100px; color:#C03;">工作地点:</li>
        <li style="width:278px;"><input name="job_address" type="text" id="job_address" size="30" maxlength="100" value="<?php echo stripslashes($hm_arr[0][2]); ?>" /></li>
        <li style="width:100px; color:#C03;">学历要求:</li>
        <li style="width:278px;"><?php echo get_user_xl($hm_arr[0][3],true); ?></li>
        <li style="width:100px; color:#C03;">所学专业:</li>
        <li style="width:278px;"><input name="job_zy" type="text" id="job_zy" size="30" maxlength="100" value="<?php echo stripslashes($hm_arr[0][4]); ?>" /></li>
        <li style="width:100px; color:#C03;">薪资待遇:</li>
        <li style="width:278px;"><input name="job_pay" type="text" id="job_pay" size="30" maxlength="100" value="<?php echo stripslashes($hm_arr[0][5]); ?>" /></li>
        <li style="width:100px; color:#C03;">是否发布:</li>
        <li style="width:278px;"><input name="job_available" type="checkbox" id="job_available" value="hmcss" <?php if($hm_arr[0][6]) echo "checked=\"checked\""; ?> /></li>
        <li style="width:100px; height:290px; color:#C03;">职位要求:</li>
        <li style="width:678px; height:290px;"><textarea cols="80" id="job_require" name="job_require" rows="10" style="margin:0px auto;"><?php echo stripslashes($hm_arr[0][7]); ?></textarea>
            <script type="text/javascript">
            if (typeof CKEDITOR == 'undefined') {
            	document.write('加载CKEditor失败');
            	}
            	else {
            	var editor = CKEDITOR.replace('job_require');
            	CKFinder.SetupCKEditor(editor, 'ckfinder'); //ckfinder总目录的相对路径.
            	}
                CKEDITOR.config.height = 200;
				CKEDITOR.config.width = 670;
            </script></li>
        <li style="width:100px; height:290px; color:#C03;">工作范围:</li>
        <li style="width:678px; height:290px;"><textarea cols="80" id="job_do" name="job_do" rows="10" style="margin:0px auto;"><?php echo stripslashes($hm_arr[0][8]); ?></textarea>
            <script type="text/javascript">
            if (typeof CKEDITOR == 'undefined') {
            	document.write('加载CKEditor失败');
            	}
            	else {
            	var editor = CKEDITOR.replace('job_do');
            	CKFinder.SetupCKEditor(editor, 'ckfinder'); //ckfinder总目录的相对路径.
            	}
                CKEDITOR.config.height = 200;
				CKEDITOR.config.width = 670;
            </script></li>
        <li style="width:789px; text-indent:0px; text-align:center;">
          <input type="submit" name="button" id="button" value="  提 交  " />
        </li>
      </ul>
    </div>
  </form>
</div>
</body>
</html>