<?php
/*
 * 74cms 个人会员中心
 * ============================================================================
 * 版权所有: 骑士网络，并保留所有权利。
 * 网站地址: http://www.74cms.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once(dirname(__FILE__) . '/personal_common.php');
$smarty->assign('nav',"manage_jobs");
//申请的职位列表
if ($act=='apply_jobs')
{
	require_once(QISHI_ROOT_PATH.'include/page.class.php');
	$wheresql=" WHERE a.personal_uid='{$_SESSION['uid']}' ";
	//搜索条件(职位类型\申请反馈\申请时间)
	$utype = intval($_GET['utype']);
	//职位类型: 0->全部     1->企业职位       3->猎头职位
	if($utype>0){
		$wheresql.=" AND j.utype = {$utype}";
	}
	$is_look = intval($_GET['look']);
	//申请反馈: 0->全部   1->未查看   2->已查看
	if($is_look>0){
		$wheresql.=" AND a.is_look = {$is_look}";
	}
	//申请时间
	$starttime = strtotime(trim($_GET['starttime']));
	$endtime = strtotime(trim($_GET['endtime']));
	if($endtime>$starttime && $starttime>0){
		$wheresql.=" AND a.apply_addtime >=".$starttime.' AND a.apply_addtime <='.$endtime.' ';
	}
	//分页
	$perpage=10;
	$joinsql=" LEFT JOIN ".table('jobs')." AS j ON a.jobs_id=j.id ";
	$total_sql="SELECT COUNT(*) AS num FROM ".table('personal_jobs_apply')." AS a ".$joinsql.$wheresql." ";
	$total_val=$db->get_total($total_sql);
	$page = new page(array('total'=>$total_val, 'perpage'=>$perpage));
	$nowpage = intval($_GET['page'])==0?1:intval($_GET['page']);
	$page->nowindex = $nowpage;
	$currenpage=$page->nowindex;
	$offset=($currenpage-1)*$perpage;
	$jobs_apply = get_apply_jobs($offset,$perpage,$joinsql.$wheresql);
	$smarty->assign('title','申请的职位 - 个人会员中心 - '.$_CFG['site_name']);
	$smarty->assign('jobs_apply',$jobs_apply);
	$smarty->assign('fullname',$jobs_apply['fullname']);
	$smarty->assign('act',$act);
	if($total_val>$perpage)
	{
		$smarty->assign('page',$page->show(7));
	}
	$smarty->display('member_personal/personal_apply_jobs.htm');
}
//删除申请的职位
elseif ($act=='del_apply_jobs')
{
	$y_id =$_REQUEST['y_id'];
	if(empty($y_id)){
		showmsg("你没有选择项目！",1);
	}
	$delete =trim($_REQUEST['delete']);
	$delete?(!del_jobs_apply($y_id,$_SESSION['uid'])?showmsg("删除失败！",0):showmsg("删除成功！",2)):'';
}
//面试邀请列表
elseif ($act=='interview')
{
	require_once(QISHI_ROOT_PATH.'include/page.class.php');
	$wheresql=" WHERE  i.resume_uid='{$_SESSION['uid']}' ";
	//搜索条件(职位类型\查看状态\邀请时间)
	$utype = intval($_GET['utype']);
	//职位类型: 0->全部     1->企业职位       3->猎头职位
	if($utype>0){
		$wheresql.=" AND j.utype = {$utype}";
	}
	//查看状态
	$is_look = intval($_GET['look']);
	if($is_look>0){
		$wheresql.=" AND i.is_look = {$is_look}";
	}
	//邀请时间
	$starttime = strtotime(trim($_GET['starttime']));
	$endtime = strtotime(trim($_GET['endtime']));
	if($endtime>$starttime && $starttime>0){
		$wheresql.=" AND i.interview_addtime >=".$starttime.' AND i.interview_addtime <='.$endtime.' ';
	}
	//分页
	$perpage=10;
	$joinsql=" LEFT JOIN  ".table('jobs')." AS j  ON  i.jobs_id=j.id ";
	$total_sql="SELECT COUNT(*) AS num from ".table('company_interview')." AS i ".$joinsql.$wheresql." ";
	$total_val=$db->get_total($total_sql);
	$page = new page(array('total'=>$total_val, 'perpage'=>$perpage));
	$nowpage = intval($_GET['page'])==0?1:intval($_GET['page']);
	$page->nowindex = $nowpage;
	$currenpage=$page->nowindex;
	$offset=($currenpage-1)*$perpage;
	$smarty->assign('title','面试邀请 - 个人会员中心 - '.$_CFG['site_name']);
	$smarty->assign('interview',get_invitation($offset, $perpage,$joinsql.$wheresql));
	if($total_val>$perpage)
	{
		$smarty->assign('page',$page->show(7));
	}
	$smarty->assign('act',$act);
	$smarty->display('member_personal/personal_interview.htm');
}
//删除 面试邀请
elseif ($act=='del_interview')
{
	$y_id =$_GET['y_id'];
	if(empty($y_id)){
		showmsg("你没有选择项目！",1);
	}
	$delete =trim($_REQUEST['delete']);
	$delete?(!del_invitation($y_id,$_SESSION['uid'])?showmsg("删除失败！",0):showmsg("删除成功！",2)):'';
}
//收藏的职位列表
elseif ($act=='favorites')
{
	require_once(QISHI_ROOT_PATH.'include/page.class.php');
	$wheresql=" WHERE f.personal_uid='{$_SESSION['uid']}' ";
	//搜索条件
	$utype = intval($_GET['utype']);
	//职位类型:  0->全部     1->企业职位       3->猎头职位
	if($utype>0){
		$wheresql.=" AND j.utype = {$utype}";
	}
	//收藏时间
	$starttime = strtotime(trim($_GET['starttime']));
	$endtime = strtotime(trim($_GET['endtime']));
	if($endtime>$starttime && $starttime>0){
		$wheresql.=" AND f.addtime >=".$starttime.' AND f.addtime <='.$endtime.' ';
	}
	//分页
	$perpage=10;
	$joinsql=" LEFT JOIN ".table('jobs')." as  j  ON f.jobs_id=j.id ";
	$total_sql="SELECT COUNT(*) AS num FROM ".table('personal_favorites')." AS f ".$joinsql.$wheresql." ";
	$total_val=$db->get_total($total_sql);
	$page = new page(array('total'=>$total_val, 'perpage'=>$perpage));
	$nowpage = intval($_GET['page'])==0?1:intval($_GET['page']);
	$page->nowindex = $nowpage;
	$currenpage=$page->nowindex;
	$offset=($currenpage-1)*$perpage;
	$smarty->assign('title','收藏的职位 - 个人会员中心 - '.$_CFG['site_name']);
	$smarty->assign('favorites',get_favorites($offset,$perpage,$joinsql.$wheresql));
	if($total_val>$perpage)
	{
		$smarty->assign('page',$page->show(7));
	}
	$smarty->assign('act',$act);
	$smarty->display('member_personal/personal_favorites.htm');
}
//删除 收藏的职位
elseif ($act=='del_favorites')
{
	$y_id =$_GET['y_id'];
	if(empty($y_id)){
		showmsg("你没有选择项目！",1);
	}
	$delete =trim($_REQUEST['delete']); 
	$delete?(!del_favorites($y_id,$_SESSION['uid'])?showmsg("删除失败！",0):showmsg("删除成功！",2)):'';
}
//谁在关注我列表
elseif ($act=='attention')
{
	require_once(QISHI_ROOT_PATH.'include/page.class.php');
	$uid = intval($_SESSION['uid']);
	$resumeid = get_pid($uid);
	$wheresql=" WHERE v.resumeid='{$resumeid}' ";
	//搜索条件
	$search_type = intval($_GET['utype']);
	//关注对象: 0->全部     1->企业       3->猎头
	if($search_type>0){
		$wheresql.=" AND v.utype = {$search_type}";
	}
	//关注时间
	$starttime = strtotime(trim($_GET['starttime']));
	$endtime = strtotime(trim($_GET['endtime']));
	if($endtime>$starttime && $starttime>0){
		$wheresql.=" AND v.addtime >=".$starttime.' AND v.addtime <='.$endtime.' ';
	}
	//分页
	$perpage=10;
	$total_sql="SELECT COUNT(*) AS num FROM ".table('view_resume')." AS v ".$wheresql." ";
	$total_val=$db->get_total($total_sql);
	$page = new page(array('total'=>$total_val, 'perpage'=>$perpage));
	$nowpage = intval($_GET['page'])==0?1:intval($_GET['page']);
	$page->nowindex = $nowpage;
	$currenpage=$page->nowindex;
	$offset=($currenpage-1)*$perpage;
	$smarty->assign('title','谁在关注我 - 个人会员中心 - '.$_CFG['site_name']);
	$smarty->assign('attention',get_attention($offset,$perpage,$wheresql));
	if($total_val>$perpage)
	{
		$smarty->assign('page',$page->show(7));
	}
	$smarty->assign('act',$act);
	$smarty->display('member_personal/personal_attention.htm');
}
//删除 谁在关注我列表
elseif ($act=='del_attention')
{
	$y_id =$_GET['y_id'];
	if(empty($y_id)){
		showmsg("你没有选择项目！",1);
	}
	$delete =trim($_REQUEST['delete']); 
	$delete?(!del_attention($y_id)?showmsg("删除失败！",0):showmsg("删除成功！",2)):'';
}

unset($smarty);
?>