<?php
require "./FCKeditor/fckeditor.php";
class jobsAction extends CommonAction{
	private $oFCKeditor;
	private $jobs;
	function __construct(){
			parent::__construct();
			$this->jobs = new jobsModel();
			$this->oFCKeditor = new FCKeditor("content") ;          // 创建FCKeditor实例，可创建多个实例
			$this->oFCKeditor->BasePath = './FCKeditor/';
		}

	function jobs_add(){
		$timelimit[]=date("Y-m-d",time());
		$timelimit[]=date("Y-m-d",time()+3600*24*30);
		$this->assign('timelimit',$timelimit);
		$this->assign('channelid',$_REQUEST['channelid']);
		$this->assign("FCKeditor",$this->oFCKeditor->Create());
		$this->display("admin/jobs/jobs.html");
	}

	function jobs_insert(){
			if($this->jobs->chech_form()){

				if($this->jobs->add($_POST)){
					$this->showMsg("成功发布招聘信息","admin.php?m=jobs&a=jobs_add&channelid=$_REQUEST[channelid]");
				}else{
					$this->showMsg("发布招聘信息失败","admin.php?m=jobs&a=jobs_add&channelid=$_REQUEST[channelid]");;
				}

			}else{
				$this->showMsg($this->jobs->getMessList(),"admin.php?m=jobs&a=jobs_add&channelid=$_REQUEST[channelid]");
			}
	}

	function jobs_mod(){
		if($_REQUEST[channelid]){
			$where="where channelid=$_REQUEST[channelid]";
		}

		$total = count( $this->jobs->total($where));
		$this->page = new page($total,10,'');
		$val = $this->jobs->findAll("",$this->page->getOffset(),10,$where,"id");
		$fpage =$this->page->fpage();
		$this->assign("fpage",$fpage);
		$this->assign("jobs",$val);
		$this->assign("channelid",$_REQUEST['channelid']);
		$this->display("admin/jobs/jobsmod.html");
	}

	function jobs_del(){
		if($_REQUEST["id"]=="data"){
		$_REQUEST["id"]=$_REQUEST["xm"];
		}
		if($this->jobs->del($_REQUEST["id"])){
			$this->showMsg("成功删除内容","admin.php?m=jobs&a=jobs_mod&channelid=".$_REQUEST[channelid]."");
		}else{
			$this->showMsg("删除内容失败","admin.php?m=jobs&a=jobs_mod&channelid=".$_REQUEST[channelid]."");
		}
	}


	function jobs_edit(){
		$_POST=$this->jobs->find($_REQUEST["id"]);
		$this->oFCKeditor->Value=$_POST["content"];
		$this->assign("post",$_POST);
		$this->assign("FCKeditor",$this->oFCKeditor->Create());
		$this->display('admin/jobs/jobsedit.html');
	}

	function jobs_update(){
			if($this->jobs->chech_form()){
				if($this->jobs->mod($_POST)){
					$this->showMsg("招聘信息修改成功","admin.php?m=jobs&a=jobs_edit&id=$_REQUEST[id]&channelid=$_REQUEST[channelid]");
				}else{
					$this->showMsg("修改招聘信息失败","admin.php?m=jobs&a=jobs_edit&id=$_REQUEST[id]&channelid=$_REQUEST[channelid]");
				}

			}else{
				$this->showMsg($this->jobs->getMessList(),"-1");
			}
	}


}
?>
