search.php

来自「通达OA2007SE源代码 非常好的」· PHP 代码 · 共 650 行 · 第 1/2 页

PHP
650
字号
<?
  include_once 'inc/auth.php';
  include_once 'inc/check_type.php';
  include_once 'inc/utility_all.php';
  echo '
<html>
<head>
<title>考勤情况查询</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body class="bodycolor" topmargin="5">
';
  if (($DATE1 != ''))
  {
    $TIME_OK = is_date ($DATE1);
    if (!$TIME_OK)
    {
      message ('错误', '起始日期格式不对,应形如 1999-1-2');
      button_back ();
      exit ();
    }
  }
  if (($DATE2 != ''))
  {
    $TIME_OK = is_date ($DATE2);
    if (!$TIME_OK)
    {
      message ('错误', '截止日期格式不对,应形如 1999-1-2');
      button_back ();
      exit ();
    }
  }
  if ((compare_date ($DATE1, $DATE2) == 1))
  {
    message ('错误', '查询的起始日期不能晚于截止日期');
    button_back ();
    exit ();
  }
  $CUR_DATE = date ('Y-m-d', time ());
  $query = (((((''.'SELECT to_days(\'').$DATE2).'\')-to_days(\'').$DATE1).'\') from ATTEND_CONFIG');
  $cursor = exequery ($connection, $query);
  if ($ROW = mysql_fetch_array ($cursor))
  {
    $DAY_TOTAL = ($ROW[0] + 1);
  }
  message ('', (((((('查询从 '.format_date ($DATE1)).' 至 ').format_date ($DATE2)).' 共 ').$DAY_TOTAL).' 天的考勤记录'));
  echo '
<!------------------------------------- 上下班 ------------------------------->
<table border="0" width="100%" cellspacing="0" cellpadding="3" class="small">
  <tr>
    <td class="Big"><img src="/images/menu/attendance.gif" WIDTH="22" HEIGHT="20" align="absmiddle">';
  echo '<s';
  echo 'pan class="big3"> 上下班统计</span><br>
    </td>
  </tr>
</table>
';
  $query = (((''.'SELECT * from USER where USER_ID=\'').$USER_ID).'\'');
  $cursor = exequery ($connection, $query);
  $LINE_COUNT = 0;
  if ($ROW = mysql_fetch_array ($cursor))
  {
    $USER_ID = $ROW['USER_ID'];
    $USER_NAME = $ROW['USER_NAME'];
    $DUTY_TYPE = $ROW['DUTY_TYPE'];
  }
  $query1 = ((''.'SELECT * from ATTEND_CONFIG where DUTY_TYPE=').$DUTY_TYPE);
  $cursor1 = exequery ($connection, $query1);
  if ($ROW = mysql_fetch_array ($cursor1))
  {
    $DUTY_NAME = $ROW['DUTY_NAME'];
    $GENERAL = $ROW['GENERAL'];
    $DUTY_TIME1 = $ROW['DUTY_TIME1'];
    $DUTY_TIME2 = $ROW['DUTY_TIME2'];
    $DUTY_TIME3 = $ROW['DUTY_TIME3'];
    $DUTY_TIME4 = $ROW['DUTY_TIME4'];
    $DUTY_TIME5 = $ROW['DUTY_TIME5'];
    $DUTY_TIME6 = $ROW['DUTY_TIME6'];
    $DUTY_TYPE1 = $ROW['DUTY_TYPE1'];
    $DUTY_TYPE2 = $ROW['DUTY_TYPE2'];
    $DUTY_TYPE3 = $ROW['DUTY_TYPE3'];
    $DUTY_TYPE4 = $ROW['DUTY_TYPE4'];
    $DUTY_TYPE5 = $ROW['DUTY_TYPE5'];
    $DUTY_TYPE6 = $ROW['DUTY_TYPE6'];
  }
  $EARLY_COUNT = '';
  $LATE_COUNT = '';
  $DUTY_ON_COUNT = '';
  $DUTY_OFF_COUNT = '';
  $DUTY_ON_TOTAL = '';
  $DUTY_OFF_TOTAL = '';
  $OVER_ON_COUNT = '';
  $OVER_OFF_COUNT = '';
  for ($I = 1; ($I <= 6); ++$I)
  {
    $STR = ('DUTY_TIME'.$I);
    $DUTY_TIME = $$STR;
    $STR = ('DUTY_TYPE'.$I);
    $DUTY_TYPE = $$STR;
    if (($DUTY_TIME == ''))
    {
      continue;
    }
    else
    {
      if (($DUTY_TYPE == 1))
      {
        ($DUTY_ON_TOTAL += $DAY_TOTAL);
      }
      else
      {
        ($DUTY_OFF_TOTAL += $DAY_TOTAL);
      }
      for ($J = $DATE1; ($J <= $DATE2); $J = date ('Y-m-d', (strtotime ($J) + 86400)))
      {
        $WEEK = date ('w', strtotime ($J));
        $HOLIDAY = 0;
        $query = (((((''.'select * from ATTEND_HOLIDAY where BEGIN_DATE <=\'').$J).'\' and END_DATE>=\'').$J).'\'');
        $cursor = exequery ($connection, $query);
        if ($ROW = mysql_fetch_array ($cursor))
        {
          $HOLIDAY = 1;
        }
        else
        {
          if (find_id ($GENERAL, $WEEK))
          {
            $HOLIDAY = 1;
          }
        }
        if (($HOLIDAY == 0))
        {
          $query = (((((((''.'select * from ATTEND_EVECTION where USER_ID=\'').$USER_ID).'\' and ALLOW=\'1\' and to_days(EVECTION_DATE1)<=to_days(\'').$J).'\') and to_days(EVECTION_DATE2)>=to_days(\'').$J).'\')');
          $cursor = exequery ($connection, $query);
          if ($ROW = mysql_fetch_array ($cursor))
          {
            $HOLIDAY = 1;
          }
        }
        if (($HOLIDAY == 0))
        {
          $query = (((((((((((''.'select * from ATTEND_LEAVE where USER_ID=\'').$USER_ID).'\' and ALLOW=\'1\' and LEAVE_DATE1<=\'').$J).' ').$DUTY_TIME).'\' and LEAVE_DATE2>=\'').$J).' ').$DUTY_TIME).'\'');
          $cursor = exequery ($connection, $query);
          if ($ROW = mysql_fetch_array ($cursor))
          {
            $HOLIDAY = 1;
          }
        }
        if (($HOLIDAY == 0))
        {
          $query = (((((((((''.'select * from ATTEND_OUT where USER_ID=\'').$USER_ID).'\' and ALLOW=\'1\' and to_days(SUBMIT_TIME)=to_days(\'').$J).'\') and OUT_TIME1<=\'').substr ($DUTY_TIME, 0, strrpos ($DUTY_TIME, ':'))).'\' and OUT_TIME2>=\'').substr ($DUTY_TIME, 0, strrpos ($DUTY_TIME, ':'))).'\'');
          $cursor = exequery ($connection, $query);
          if ($ROW = mysql_fetch_array ($cursor))
          {
            $HOLIDAY = 1;
          }
        }
        if (($HOLIDAY == 1))
        {
          if (($DUTY_TYPE == 1))
          {
            --$DUTY_ON_TOTAL;
            continue;
          }
          else
          {
            --$DUTY_OFF_TOTAL;
            continue;
          }
          continue;
        }
      }
      $query1 = (((((((((''.'SELECT * from ATTEND_DUTY where USER_ID=\'').$USER_ID).'\' and to_days(REGISTER_TIME)>=to_days(\'').$DATE1).'\') and to_days(REGISTER_TIME)<=to_days(\'').$DATE2).'\') and REGISTER_TYPE=\'').$I).'\'');
      $cursor1 = exequery ($connection, $query1);
      while ($ROW = mysql_fetch_array ($cursor1))
      {
        $REGISTER_TIME = $ROW['REGISTER_TIME'];
        $SOME_DATE = strtok ($REGISTER_TIME, ' ');
        $REGISTER_TIME = strtok (' ');
        $WEEK = date ('w', strtotime ($REGISTER_TIME));
        $HOLIDAY = 0;
        $query = (((((''.'select * from ATTEND_HOLIDAY where BEGIN_DATE <=\'').$SOME_DATE).'\' and END_DATE>=\'').$SOME_DATE).'\'');
        $cursor = exequery ($connection, $query);
        if ($ROW = mysql_fetch_array ($cursor))
        {
          $HOLIDAY = 1;
        }
        else
        {
          if (find_id ($GENERAL, $WEEK))
          {
            $HOLIDAY = 1;
          }
        }
        if (($HOLIDAY == 0))
        {
          $query = (((((((''.'select * from ATTEND_EVECTION where USER_ID=\'').$USER_ID).'\' and ALLOW=\'1\' and to_days(EVECTION_DATE1)<=to_days(\'').$SOME_DATE).'\') and to_days(EVECTION_DATE2)>=to_days(\'').$SOME_DATE).'\')');
          $cursor = exequery ($connection, $query);
          if ($ROW = mysql_fetch_array ($cursor))
          {
            $HOLIDAY = 1;
          }
        }
        if (($HOLIDAY == 0))
        {
          $query = (((((((((((''.'select * from ATTEND_LEAVE where USER_ID=\'').$USER_ID).'\' and ALLOW=\'1\' and LEAVE_DATE1<=\'').$SOME_DATE).' ').$DUTY_TIME).'\' and LEAVE_DATE2>=\'').$SOME_DATE).' ').$DUTY_TIME).'\'');
          $cursor = exequery ($connection, $query);
          if ($ROW = mysql_fetch_array ($cursor))
          {
            $HOLIDAY = 1;
          }
        }
        if (($HOLIDAY == 0))
        {
          $query = (((((((((''.'select * from ATTEND_OUT where USER_ID=\'').$USER_ID).'\' and ALLOW=\'1\' and to_days(SUBMIT_TIME)=to_days(\'').$SOME_DATE).'\') and OUT_TIME1<=\'').substr ($DUTY_TIME, 0, strrpos ($DUTY_TIME, ':'))).'\' and OUT_TIME2>=\'').substr ($DUTY_TIME, 0, strrpos ($DUTY_TIME, ':'))).'\'');
          $cursor = exequery ($connection, $query);
          if ($ROW = mysql_fetch_array ($cursor))
          {
            $HOLIDAY = 1;
          }
        }
        if (($DUTY_TYPE == '1'))
        {
          if (($HOLIDAY == 1))
          {
            ++$OVER_ON_COUNT;
            continue;
          }
          else
          {
            ++$DUTY_ON_COUNT;
            if ((compare_time ($REGISTER_TIME, $DUTY_TIME) == 1))
            {
              ++$LATE_COUNT;
              break 2;
            }
            break 2;
          }
          continue;
        }
      }
      continue;
    }
  }
  while (true)
  {
    break;
  }
  for ($J = $DATE1; ($J <= $DATE2); $J = date ('Y-m-d', (strtotime ($J) + 86400)))
  {
    $COUNT = 0;
    $query = '';
    for ($I = 1; ($I <= 6); ++$I)
    {
      $STR = ('DUTY_TIME'.$I);
      $DUTY_TIME = $$STR;
      $STR = ('DUTY_TYPE'.$I);
      $DUTY_TYPE = $$STR;
      if (($DUTY_TIME != ''))
      {
        ++$COUNT;
        if (($DUTY_TYPE == '1'))
        {
          ($query .= (((((((((''.' REGISTER_TYPE=\'').$I).'\' and to_days(REGISTER_TIME)=to_days(\'').$J).'\') and REGISTER_TIME<=\'').$J).' ').$DUTY_TIME).'\' or'));
          continue;
        }
        else
        {
          ($query .= (((((((((''.' REGISTER_TYPE=\'').$I).'\' and to_days(REGISTER_TIME)=to_days(\'').$J).'\') and REGISTER_TIME>=\'').$J).' ').$DUTY_TIME).'\' or'));
          continue;
        }
        continue;
      }
    }
    $query = substr ($query, 0, -3);
    $query1 = (((''.'SELECT count(*) from ATTEND_DUTY where USER_ID=\'').$USER_ID).'\'');
    if (($query != ''))
    {
      ($query1 .= ((' and ('.$query).')'));
    }
    $cursor1 = exequery ($connection, $query1);
    if ($ROW = mysql_fetch_array ($cursor1))
    {
      $REG_COUNT = $ROW[0];
    }
    if (($COUNT <= $REG_COUNT))
    {
      ++$PERFECT_COUNT;
      continue;
    }
  }
  echo '
<table border="0" cellspacing="1" width="100%" class="small" bgcolor="#000000" cellpadding="3">
  <tr class="TableHeader">
    <td nowrap align="center">全勤(天)</td>
    <td nowrap align="center">迟到</td>
    <td nowrap align="center">上班<br>未登记</td>
    <td nowrap align="center">早退</td>
    <td nowrap align="center">下班<br>未登记</td>
    <td nowrap align="center">加班<br>上班登记</td>
    <td n';
  echo 'owrap align="center">加班<br>下班登记</td>
    <td nowrap align="center">操作</td>
  </tr>
  <tr class="TableData">
    <td nowrap align="center">';
  echo $PERFECT_COUNT;
  echo '</td>
    <td nowrap align="center">';
  echo $LATE_COUNT;
  echo '</td>
    <td nowrap align="center">';
  echo ($DUTY_ON_TOTAL - $DUTY_ON_COUNT);
  echo '</td>
    <td nowrap align="center">';
  echo $EARLY_COUNT;
  echo '</td>
    <td nowrap align="center">';
  echo ($DUTY_OFF_TOTAL - $DUTY_OFF_COUNT);
  echo '</td>
    <td nowrap align="center">';
  echo $OVER_ON_COUNT;
  echo '</td>
    <td nowrap align="center">';
  echo $OVER_OFF_COUNT;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?