<?php
require 'inc.php';
$obj_tab_verify=new cls_tab_sys_verify();
$arr_state=$obj_tab_verify->state;

if(!isset($get_s_key)) $get_s_key="";
(isset($get_s_state))? $get_s_state=(int)$get_s_state:$get_s_state=-101;
if(!isset($get_s_updatetime1)) $get_s_updatetime1="";
if(!isset($get_s_updatetime2)) $get_s_updatetime2="";
(isset($get_verify_type)) ? $get_verify_type=intval($get_verify_type):$get_verify_type=1;

$get_issearch=0;

if($get_act=="del"){
	$arr_return=$obj_tab_verify->on_del($get_id);
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}
if($get_act=="del_sel"){
	$arr_return=$obj_tab_verify->on_del($get_verifyids);
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}
if($get_act=="state" && isset($get_state_val)){
	$arr_return=$obj_tab_verify->on_state($get_verifyid,$get_state_val);
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}

$page_footer_info=<<<HTML
<input type='hidden' name='verify_type' value='$get_verify_type'>
HTML;


switch($get_act)
{	
	default:
	{
		$get_issearch="";
		//·ÖÒ³
		$str_where=" where a.verify_user_id=b.user_id and verify_type=".$get_verify_type;
		if($get_s_key!=""){
			$get_issearch="1";
			if(is_numeric($get_s_key)){
				$str_where.=" and user_id=".$str_s_key;
			}else{
				$str_where.=" and user_name like '%".$str_s_key."%'";
			}
		}
		if($get_s_state!=-101){
			$str_where.=" and verify_state='".$get_s_state."'";
			$get_issearch="1";
		}
		if(is_date($get_s_updatetime1)){
			$str_where.=" and verify_addtime>='".strtotime($get_s_updatetime1)."'";
			$get_issearch="1";
		}
		if(is_date($get_s_updatetime2)){
			if(strtotime($get_s_updatetime2)!=strtotime(date("Y-m-d",strtotime($get_s_updatetime2)))) $get_s_updatetime2=date("Y-m-d",strtotime($get_s_updatetime2))." 23:59:59";
			$str_where.=" and verify_addtime<='".strtotime($get_s_updatetime2)."'";
			$get_issearch="1";
		}
		$arr_verify=array();
		$obj_rs   = $obj_db->get_one("SELECT count(1) as num FROM ".DB_PRE."sys_verify a,".DB_PRE."sys_user b".$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;
		$arr_company_userid=array();
		$arr_personal_userid=array();
		$arr_name=array();
		$obj_result = $obj_db->query("SELECT a.*,b.user_name,b.user_type FROM ".DB_PRE."sys_verify a,".DB_PRE."sys_user b".$str_where.$str_limit);
		while($obj_rs = $obj_db->fetch_array($obj_result))
		{
			$obj_rs["state"]=array_search($obj_rs["verify_state"],$arr_state);
			$obj_rs["updatetime"]=date("Y-m-d",$obj_rs["verify_updatetime"]);
			if($obj_rs["user_type"]=="company"){
				$arr_company_userid[]=$obj_rs["verify_user_id"];
			}else if($obj_rs["user_type"]=="personal"){
				$arr_personal_userid[]=$obj_rs["verify_user_id"];
			}
			$arr_name["id_".$obj_rs["verify_user_id"]]=$obj_rs["user_name"];
			$arr_verify[] = $obj_rs;
		}
		if(count($arr_company_userid)>0){
			$str_ids=implode(",",$arr_company_userid);
			$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_name["id_".$obj_rs["company_user_id"]]=$obj_rs["company_name"];
			}
		}
		include "tpl/verify.tpl.php";
	}
}

?>
