<?php
require_once('inc/logincheck.php');
CommTool::checkIncludeByAdminPhp();

if('modify' == $action)
{
  if(empty($readok)){$readok = 0;}
  $strSql = "update {$configTableHead}resume set readok={$readok} where id={$id}";
  if($dbInstance->query($strSql))
  {
    promptMessage("index.php?lang={$kuWebsiteEditVersionLanguage}&path=job&menu=resume_action", $promptEditDataSuccess, $configJumpTime);
    exit;
  }
  else
  {
    promptMessage("javascript:history.go(-1)", $promptEditDataFail, $configJumpTime);
    exit;
  }
}
else if('search' == $action || 'search' == $flag)
{
  if(0 == $readystate && empty($jobpost))
  {
      $strSearchTotalSql = "select count(*) as amount from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0 and readok={$readystate}";  
    $strSearchSql = "select * from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0 and readok={$readystate}";
  }
  else if(0 == $readystate && !empty($jobpost))
  {
      $strSearchTotalSql = "select count(*) as amount from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0 and readok={$readystate} and jobid={$jobpost}";
    $strSearchSql = "select * from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0 and readok={$readystate} and jobid={$jobpost}";
  }
  else if(1 == $readystate && empty($jobpost))
  {
      $strSearchTotalSql = "select count(*) as amount from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0 and readok={$readystate}";
    $strSearchSql = "select * from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0 and readok={$readystate}";
  }
  else if(1 == $readystate && !empty($jobpost))
  {
      $strSearchTotalSql = "select count(*) as amount from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0 and readok={$readystate} and jobid={$jobpost}";
    $strSearchSql = "select * from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0 and readok={$readystate} and jobid={$jobpost}";
  }
  else if(-1 == $readystate && empty($jobpost))
  {
      $strSearchTotalSql = "select count(*) as amount from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0";  
    $strSearchSql = "select * from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0";
  }
    else if(-1 == $readystate && !empty($jobpost))
  {
      $strSearchTotalSql = "select count(*) as amount from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0 and jobid={$jobpost}";
    $strSearchSql = "select * from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0 and jobid={$jobpost}";
  }
}
else if('delete' == $action)
{
  if(empty($id) || ereg("/^d+$/", $id))
  {
    promptMessage("javascript:history.go(-1)", $promptDeleteEmptyId, $configJumpTime);
    exit;
  }
  else
  {
    if(is_array($id))
    {
      foreach($id as $key=>$value)
      {
        $sql = "delete from {$configTableHead}resume where id='{$value}'";
        if(!$flag = $dbInstance->query($sql))
        {
          promptMessage("javascript:history.go(-1)", $prompBatchDeleteFail, $configJumpTime);
          exit;
        }  
      }
      promptMessage("index.php?lang={$kuWebsiteEditVersionLanguage}&path=job&menu=resume_action", $prompBatchDeleteSuccess, $configJumpTime);
      exit;    
    }
    else
    {
      $sql = "delete from {$configTableHead}resume where id='{$id}'";
      if($dbInstance->query($sql))
      {
        promptMessage("index.php?lang={$kuWebsiteEditVersionLanguage}&path=job&menu=resume_action", $promptDeleteDataSuccess, $configJumpTime);
        exit;
      }
      else
      {
        promptMessage("javascript:history.go(-1)", $promptDeleteDataFail, $configJumpTime);
        exit;
      }
    }  
  }  
}


//$sql = "select count(*) as amount from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}'";
if(empty($strSearchTotalSql))
{
  $strSearchTotalSql = "select count(*) as amount from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0";
}
$result = $dbInstance->query($strSearchTotalSql);
$row = $dbInstance->fetchArray($result);
$totalNumber = $row['amount'];                                                      //总记录数
$maxNum = $adminPagingPageNumber;                                                    //每页显示的记录数 
!empty($page) ? ($page = intval($page)) : $page =1;
$actionDisplayNumber = $adminPagingActionsDisplayNumber;                         //活动显示页数 
$type = $adminPagingType;                                         //分页样式0-5 
$isAlwaysShowFirstOrLast = $adminPagingIsAlwaysShowFirstOrLast;                      //是否绍终显示第一页和最后一页
$startNum = ($page - 1) * $maxNum;                                                  //记录查询起始
if(empty($strSearchSql))
{
  $strSearchSql = "select * from {$configTableHead}resume where lang='{$kuWebsiteEditVersionLanguage}' and jobid!=0 order by id desc limit $startNum, $maxNum";
}
else
{
  $strSearchSql = $strSearchSql." order by id desc limit $startNum, $maxNum";
}
$result = $dbInstance->query($strSearchSql);
while($arr = $dbInstance->fetchArray($result)) 
{
  if(1 == $arr['readok'])
  {
    $arr['readok'] = '是';
  }
  else
  {
    $arr['readok'] = '否';
  }
  $resumeList[] = $arr;
}


$sql = "select * from {$configTableHead}job where lang='{$kuWebsiteEditVersionLanguage}'";                                                          
$result = $dbInstance->query($sql);
while($row = $dbInstance->fetchArray($result)) 
{
  $kuJobList[] = $row;
}


$readyStateFlag[$readystate] = "selected='selected'";
$jobPostFlag[$jobpost] = "selected='selected'";

include_once template('resume_manage.html', $adminTemplateName);
?>