<?php
require 'inc.php';
$obj_tab_photo=new cls_tab_hr_photo();
$arr_state=$obj_tab_photo->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="";
$get_issearch=0;

if($get_act=="del"){
	$arr_return=$obj_tab_photo->on_del($get_id);
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}
if($get_act=="del_sel"){
	$arr_return=$obj_tab_photo->on_del($get_photoids);
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}
if($get_act=="state" && isset($get_state_val)){
	$arr_return=$obj_tab_photo->on_state($get_photoids,$get_state_val);
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}
switch($get_act)
{	
	default:
	{
		//·ÖÒ³
		$str_where=" where a.photo_user_id=b.company_user_id";
		if(isset($get_s_state) && $get_s_state!=-101){
			$str_where.=" and photo_state='".intval($get_s_state)."'";
			$get_issearch=1;
		}
		if(isset($get_s_date1) && is_date($get_s_date1)){
			$str_where.=" and photo_updatetime>='".$get_s_updatetime1."'";
			$get_issearch=1;
		}
		if(isset($get_s_date2) && is_date($get_s_date2)){
			$str_where.=" and photo_updatetime=<'".$get_s_updatetime2."'";
			$get_issearch=1;
		}
		if(isset($get_s_key) && !empty($get_s_key)){
			$str_where.=" and photo_title like '%".$get_s_key."%'";
			$get_issearch=1;
		}
		$arr_photo=array();
		$obj_rs   = $obj_db->get_one("SELECT count(1) as num FROM ".DB_PRE."hr_photo a,".DB_PRE."hr_company 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;
		$obj_result = $obj_db->query("SELECT a.*,b.company_name FROM ".DB_PRE."hr_photo a,".DB_PRE."hr_company b".$str_where.$str_limit);
		while($obj_rs = $obj_db->fetch_array($obj_result))
		{
			$obj_rs["state"]=array_search($obj_rs["photo_state"],$arr_state);
			$obj_rs["addtime"]=date("Y-m-d",$obj_rs["photo_addtime"]);
			$obj_rs["url"]=get_html_url($obj_rs["photo_url"]);
			$arr_photo[] = $obj_rs;
		}
		include "tpl/photo.tpl.php";

	}
}

?>
