<?php
(!isset($get_site_id))? $get_site_id=0 : $get_site_id=intval($get_site_id);
$obj_tab_temp=new cls_tab_temp();

if($get_site_id<1){
	$obj_msg->alert("当前模板不存在");
	$obj_msg->on_history_back();
	exit;
}

if(isset($get_act) && $get_act=="save"){
		$obj_tab_site=new cls_tab_temp_site();

		$arr_site=array();
		$arr_val=array();
		$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."temp_site where site_id='".$get_site_id."'");
		if($obj_rs = $obj_db->fetch_array($obj_result))
		{
			$arr_fields=$obj_tab_temp->get_fields($obj_rs["site_temp_id"]);
			$lng_count=count($arr_fields);
			for($i=0;$i<$lng_count;$i++){
				$var_get="get_N_temp_".$i;
				if(isset($$var_get)){
					$arr_val[$arr_fields[$i]["name"]]=$$var_get;
				}
			}
		}
		$str_cont=serialize($arr_val);
		$arr_fields=array();
		$arr_fields["site_id"]=$get_site_id;
		$arr_fields["site_content"]=$str_cont;
		$arr_msg=$obj_tab_site->on_save($arr_fields);
		if($arr_msg["err"]!=""){
			$obj_msg->alert("保存模板失败");
		}else{
			$obj_msg->alert("保存模板成功");
		}
}

$arr_site=array();
$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."temp_site where site_id='".$get_site_id."'");
if($obj_rs = $obj_db->fetch_array($obj_result))
{
	$obj_rs["company_name"]="";
	$obj_rs["temp_title"]="";
	$obj_result2 = $obj_db->query("SELECT temp_pic,temp_id,temp_title FROM ".DB_PRE."temp where temp_id=".$obj_rs["site_temp_id"]);
	if($obj_rs2 = $obj_db->fetch_array($obj_result2))
	{
		$obj_rs["temp_title"]=$obj_rs2["temp_title"];
	}
	$obj_result2 = $obj_db->query("SELECT company_name,company_user_id FROM ".DB_PRE."hr_company where company_user_id=".$obj_rs["site_user_id"]);
	if($obj_rs2 = $obj_db->fetch_array($obj_result2))
	{
		$obj_rs["company_name"]=$obj_rs2["company_name"];
	}
	$obj_rs["site_starttime"]=date("Y-m-d",$obj_rs["site_starttime"]);
	$obj_rs["site_endtime"]=date("Y-m-d",$obj_rs["site_endtime"]);
	$obj_rs["fields"]=$obj_tab_temp->get_fields($obj_rs["site_temp_id"],$obj_rs["site_content"]);
	$arr_site = $obj_rs;
}

?>