<?php
require 'inc.php';
$obj_tab_account=new cls_tab_sys_account;

(isset($get_s_key)) ? $get_s_key=chk_escape($get_s_key) : $get_s_key="";
(isset($get_s_uid)) ? $get_s_uid=(int)$get_s_uid : $get_s_uid=0;
if(!isset($get_s_addtime1)) $get_s_addtime1="";
if(!isset($get_s_addtime2)) $get_s_addtime2="";
$page_footer_info=<<<HTML
<input type="hidden" name="s_uid" value="{$get_s_uid}">
HTML;

switch($get_act)
{	
	default:
	{
		$get_issearch=0;
		$str_where=" where 1";
		if($get_s_uid>0) $str_where.=" and gold_user_id=".$get_s_uid;
		if($get_s_key!="" && $get_s_uid<1){
			$get_issearch=1;
			if(is_numeric($get_s_key)){
				$arr_where[]="gold_user_id=".$get_s_key;
			}
			$arr_uid=$obj_ctl_user->get_user_id($get_s_key);
			if(count($arr_uid)>0){
				$arr_where[]="gold_user_id=".$arr_uid[$get_s_key];
			}else{
				$obj_rs=$obj_db->get_one("select company_user_id from ".DB_PRE."hr_company where company_name like '%".$get_s_key."%'");
				if(isset($obj_rs["company_user_id"])){
					$arr_where[]="gold_user_id=".$obj_rs["company_user_id"];
				}else{
					$obj_rs=$obj_db->get_one("select resume_user_id from ".DB_PRE."hr_resume where resume_name like '%".$get_s_key."%'");
					if(isset($obj_rs["company_user_id"])){
						$arr_where[]="gold_user_id=".$obj_rs["resume_user_id"];
					}else{
						$arr_where[]="1>2";
					}
				}
			}
			$str_where.=" and (".implode(" or ",$arr_where).")";
		}
		if(is_date($get_s_addtime1)){
			$get_issearch=1;
			$str_where.=" and gold_addtime>='".strtotime($get_s_addtime1)."'";
		}
		if(is_date($get_s_addtime2)){
			$get_issearch=1;
			$str_x=date("Y-m-d",strtotime($get_s_addtime2));
			if(strtotime($str_x)==strtotime($get_s_addtime2)) $str_y=$str_x." 23:59:59";
			$str_where.=" and gold_addtime<'".strtotime($str_y)."'";
		}

		$arr_gold = array();
		$arr_userid=array();
		$arr_uid=array();
		$arr_showname=array();
		$obj_rs  = $obj_db->get_one("SELECT count(*) as num FROM ".DB_PRE."sys_account_gold".$str_where);
		$int_total=$obj_rs["num"];
		$int_pages= ceil($int_total/$int_pagesize);
		$get_page = min($int_pages, $get_page);
		$get_page = max($get_page, 1);
		$page_split_page=get_pages($int_total, $get_page, $int_pagesize);
		$int_offset = $int_pagesize*($get_page-1);
		$str_limit = " limit ".$int_offset.",".$int_pagesize;
		$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."sys_account_gold".$str_where." order by gold_id desc".$str_limit);
		while($obj_rs = $obj_db->fetch_array($obj_result))
		{
			$obj_rs["addtime"]=date("Y-m-d H:i:s",$obj_rs["gold_addtime"]);
			$arr_userid[]=$obj_rs["gold_user_id"];
			$arr_showname["id_".$obj_rs["gold_user_id"]]="";
			$arr_gold[]=$obj_rs;
		}
		if(count($arr_userid)>0){
			$arr_uname=$obj_ctl_user->get_user_name($arr_userid);
			$str_ids=implode(",",$arr_userid);
			$obj_result=$obj_db->query("select resume_name,resume_user_id from ".DB_PRE."hr_resume where resume_user_id in(".$str_ids.")");
			while($obj_rs=$obj_db->fetch_array($obj_result)){
				$arr_showname["id_".$obj_rs["resume_user_id"]]=$obj_rs["resume_name"]."(¸öÈË)";
			}
			$obj_result=$obj_db->query("select company_name,company_user_id from ".DB_PRE."hr_company where company_user_id in(".$str_ids.")");
			while($obj_rs=$obj_db->fetch_array($obj_result)){
				$arr_showname["id_".$obj_rs["company_user_id"]]=$obj_rs["company_name"]."(ÆóÒµ)";
			}
		}
		include 'tpl/gold.tpl.php';
	}
}


?>
