<?php
/**
 * The personal view file of attend module of ZDOO.
 *
 * @copyright   Copyright 2009-2018 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     ZPL (http://zpl.pub/page/zplv12.html)
 * @author      chujilu <chujilu@cnezsoft.com>
 * @package     attend
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('confirmReview', $lang->attend->confirmReview);?>

<?php if($reviewStatus == 'all'):?>
<?php
$reviewStatusColors['wait']   = 'text-yellow';
$reviewStatusColors['pass']   = 'text-green';
$reviewStatusColors['reject'] = 'text-red';
?>
<div class='main-row'>
  <div class='side-col'>
    <div class='panel'>
      <div class='panel-body'>
        <ul class='tree'>
          <?php foreach($yearList as $year):?>
          <li class='<?php echo $year == $currentYear ? 'active' : ''?>'>
            <?php commonModel::printLink('attend', 'allreview', "date={$year}&dept=&orderBy={$orderBy}", $year);?>
            <ul>
              <?php foreach($monthList[$year] as $month):?>
              <li class='<?php echo ($year == $currentYear and $month == $currentMonth) ? 'active' : ''?>'>
                <?php commonModel::printLink('attend', 'allreview', "date=$year$month&dept=&orderBy=$orderBy", $year . $month);?>
              </li>
              <?php endforeach;?>
            </ul>
          </li>
          <?php endforeach;?>
        </ul>
      </div>
    </div>
  </div>
  <div class='main-col'>
<?php endif;?>

    <div class='panel main-table' data-ride='table'>
      <?php $canBatchReview = ($attends && commonModel::hasPriv('attend', 'batchReview'));?>
      <?php if($canBatchReview && $reviewStatus == 'wait'):?>
      <form id='batchReviewForm' method='post' action='<?php echo inlink('batchReview', 'status=pass');?>'>
      <?php endif;?>
        <table class='table has-sort-head'>
          <thead>
            <tr class='text-center'>
              <?php $vars = "&date={$currentYear}{$currentMonth}&dept=&orderBy=%s&recTotal=$pager->recTotal&recPerPage=$pager->recPerPage&pageID=$pager->pageID";?>
              <th class='w-90px text-left'>
                <?php if($canBatchReview && $reviewStatus == 'wait'):?>
                <div class='checkbox-primary check-all' title='<?php echo $this->lang->selectAll;?>'><label></label></div>
                <?php endif;?>
                <?php commonModel::printOrderLink('id', $orderBy, $vars, $lang->attend->id);?>
              </th>
              <th class='w-100px'><?php echo $lang->user->dept;?></th>
              <th class='w-100px'><?php commonModel::printOrderLink('account', $orderBy, $vars, $lang->attend->account);?></th>
              <th class='w-100px'><?php commonModel::printOrderLink('date', $orderBy, $vars, $lang->attend->date);?></th>
              <th class='w-80px'><?php commonModel::printOrderLink('manualIn', $orderBy, $vars, $lang->attend->manualIn);?></th>
              <th class='w-80px'><?php commonModel::printOrderLink('manualOut', $orderBy, $vars, $lang->attend->manualOut);?></th>
              <th class='w-100px'><?php echo $lang->attend->reason;?></th>
              <th><?php echo $lang->attend->desc;?></th>
              <th class='w-100px'><?php commonModel::printOrderLink('status', $orderBy, $vars, $lang->attend->status);?></th>
              <?php if($reviewStatus == 'all'):?>
              <th class='w-100px'><?php commonModel::printOrderLink('reviewStatus', $orderBy, $vars, $lang->attend->reviewStatus);?></th>
              <?php endif;?>
              <?php if($reviewStatus == 'wait'):?>
              <th class='w-100px'><?php echo $lang->actions;?></th>
              <?php endif;?>
            </tr>
          </thead>
          <?php foreach($attends as $attend):?>
          <?php if(!isset($users[$attend->account])) continue;?>
          <?php $user = $users[$attend->account];?>
          <tr class='text-center'>
            <td class='text-left'>
              <?php if($canBatchReview && $reviewStatus == 'wait'):?>
              <div class='checkbox-primary'><input type='checkbox' name='attendIDList[]' value="<?php echo $attend->id;?>" id="attendIDList<?php echo $attend->id;?>">
                <label for="attendIDList<?php echo $attend->id;?>"></label>
              </div>
              <?php endif;?>
              <?php echo $attend->id;?>
            </td>
            <td><?php echo zget($deptList, $user->dept, '');?></td>
            <td><?php echo $user->realname;?></td>
            <td><?php echo formatTime($attend->date, DT_DATE1)?></td>
            <td><?php echo substr($attend->manualIn, 0, 5)?></td>
            <td><?php echo substr($attend->manualOut, 0, 5)?></td>
            <td><?php echo zget($lang->attend->reasonList, $attend->reason)?></td>
            <td class='text-left' title="<?php echo $attend->desc;?>"><?php echo $attend->desc?></td>
            <td><?php echo zget($lang->attend->statusList, $attend->status)?></td>
            <?php if($reviewStatus == 'all'):?>
            <td class="<?php echo zget($reviewStatusColors, $attend->reviewStatus);?>"><?php echo zget($lang->attend->reviewStatusList, $attend->reviewStatus)?></td>
            <?php endif;?>
            <?php if($reviewStatus == 'wait'):?>
            <td>
              <?php
              $canReview = $this->attend->isClickable($attend, 'review');
              if($canReview)
              {
                  echo html::a(inlink('review', "attendID={$attend->id}&status=pass"),   $lang->attend->reviewStatusList['pass'],   "class='pass'");
                  echo html::a(inlink('review', "attendID={$attend->id}&status=reject"), $lang->attend->reviewStatusList['reject'], "data-toggle='modal'");
              }
              else
              {
                  echo html::a('javascript:;', $lang->attend->reviewStatusList['pass'],   "class='disabled'");
                  echo html::a('javascript:;', $lang->attend->reviewStatusList['reject'], "class='disabled'");
              }
              ?>
            </td>
            <?php endif;?>
          </tr>
          <?php endforeach;?>
        </table>
        <div class='table-footer'>
          <?php if($canBatchReview && $reviewStatus == 'wait'):?>
          <div class='checkbox-primary check-all'><label><?php echo $lang->selectAll?></label></div>
          <div class='table-actions btn-toolbar'><?php echo html::a('javascript:;', $lang->attend->reviewStatusList['pass'], "class='btn batchPass'");?></div>
          <?php endif;?>
          <div class='table-statistic'></div>
          <?php $pager->show();?>
        </div>
      <?php if($canBatchReview && $reviewStatus == 'wait'):?>
      </form>
      <?php endif;?>
    </div>
<?php if($reviewStatus == 'all'):?>
  </div>
</div>
<?php endif;?>
<?php include '../../common/view/footer.html.php';?>
