<?php
 /*
 * 74cms 猎头设置
 * ============================================================================
 * 版权所有: 骑士网络，并保留所有权利。
 * 网站地址: http://www.74cms.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once(dirname(__FILE__).'/../data/config.php');
require_once(dirname(__FILE__).'/include/admin_common.inc.php');
require_once(ADMIN_ROOT_PATH.'include/admin_hunter_fun.php');
$act = !empty($_GET['act']) ? trim($_GET['act']) : 'set';
$smarty->assign('pageheader',"猎头设置");
check_permissions($_SESSION['admin_purview'],"set_hunter");
if($act == 'set')
{	
	get_token();
	$smarty->assign('navlabel',"set");
	$smarty->assign('config',$_CFG);
	$smarty->assign('text',get_cache('text'));
	$smarty->display('set_hunter/admin_set_hunter.htm');
}
elseif($act == 'set_save')
{
	check_token();
	foreach($_POST as $k => $v)
	{
	!$db->query("UPDATE ".table('config')." SET value='$v' WHERE name='$k'")?adminmsg('更新设置失败', 1):"";
	}
	foreach($_POST as $k => $v)
	{
	!$db->query("UPDATE ".table('text')." SET value='$v' WHERE name='$k'")?adminmsg('更新设置失败', 1):"";
	}
	refresh_cache('config');
	refresh_cache('text');	
	adminmsg("保存成功！",2);
}
elseif($act == 'set_points')
{
	get_token();
	$smarty->assign('config',$_CFG);
	$smarty->assign('points',get_points_rule());
	$smarty->assign('navlabel',"set_points");
	$smarty->display('set_hunter/admin_mode_points.htm');
}
elseif($act == 'set_points_save')
{
	check_token();
	$ids=$_POST['id'];
	$operation=$_POST['operation'];
	$value=$_POST['value'];
	foreach($ids as $k =>  $id)
	{
	$id=intval($id);
	!$db->query("UPDATE ".table('members_points_rule')." SET value='{$value[$k]}', operation='{$operation[$k]}' WHERE id='{$id}' LIMIT 1")?adminmsg('保存失败', 1):"";
	}
	refresh_points_rule_cache();
	adminmsg("更新设置成功！",2);
}
elseif($act == 'set_level')
{
	get_token();
	$smarty->assign('config',$_CFG);
	$smarty->assign('level',get_level_rule());
	$smarty->assign('navlabel',"set_level");
	$smarty->display('set_hunter/admin_mode_level.htm');
}
elseif($act=="set_level_rule_save")
{
	get_token();
	$ids=$_POST['id'];
	$operation=$_POST['operation'];
	$value=$_POST['value'];
	foreach($ids as $k =>  $id)
	{
	$id=intval($id);
	!$db->query("UPDATE ".table('hunter_level_rule')." SET value='{$value[$k]}', operation='{$operation[$k]}' WHERE id='{$id}' LIMIT 1")?adminmsg('保存失败', 1):"";
	}
	refresh_huter_level_rule_cache();
	adminmsg("更新设置成功！",2);
}
elseif($act=="set_level_meal")
{
	get_token();
	$smarty->assign('level_meal',get_level_meal());
	$smarty->assign('navlabel',"set_level_meal");
	$smarty->display('set_hunter/admin_level_meal.htm');
}
elseif($act=="set_level_meal_edit")
{
	get_token();
	$id=intval($_GET['id']);
	$smarty->assign("show",get_level_meal_one($id));
	$smarty->assign('navlabel',"set_level_meal");
	$smarty->display('set_hunter/admin_level_meal_edit.htm');
}
elseif($act=="set_level_meal_edit_save")
{
	get_token();
	$id=intval($_POST['id']);
	$setsqlarr['name']=$_POST['name'];
	$setsqlarr['jobs_add']=$_POST['jobs_add'];
	$setsqlarr['free_refresh_jobs']=$_POST['free_refresh_jobs'];
	$setsqlarr['down_junior_resume']=$_POST['down_junior_resume'];
	$setsqlarr['down_senior_resume']=$_POST['down_senior_resume'];
	$setsqlarr['resume_to_word']=$_POST['resume_to_word'];
	$setsqlarr['report_junior_resume']=$_POST['report_junior_resume'];
	$setsqlarr['report_senior_resume']=$_POST['report_senior_resume'];
	if (updatetable(table('hunter_level_meal'),$setsqlarr," id=$id"))
	{
	$link[0]['text'] = "返回等级特权设置";
	$link[0]['href'] ="?act=set_level_meal";
	adminmsg("设置成功！",2,$link);
	}
	else
	{
	adminmsg("设置失败！",0);
	}
}
?>