<?php
/**
 * The all view file of conversion module of ZDOO.
 *
 * @copyright   Copyright 2009-2022 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     ZPL (http://zpl.pub/page/zplv12.html)
 * @author      LiuRuoGu <liuruogu@easycorp.ltd>
 * @package     conversion 
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('confirmReview', $lang->conversion->confirmReview);?>
<div class='main-row'>
  <div class='side-col'>
    <div class='panel'>
      <div class='panel-body'>
        <nav class='menu leftmenu'>
          <ul class='nav nav-primary'>
            <?php foreach($lang->conversion->menuList as $reviewStatus => $label):?>
            <li <?php if($status == $reviewStatus) echo "class='active'";?>><?php echo html::a(inlink($type, "status={$reviewStatus}"), $label);?></li>
            <?php endforeach;?>
          </ul>
        </nav>
      </div>
    </div>
  </div>
  <div class='main-col'>
    <div class='panel panel-block main-table'>
      <table class='table has-sort-head'>
        <thead>
          <tr class='text-center'>
            <?php $vars = "&status={$status}&orderBy=%s&recTotal=$pager->recTotal&recPerPage=$pager->recPerPage&pageID=$pager->pageID";?>
            <th class='w-100px'><?php commonModel::printOrderLink('id', $orderBy, $vars, 'ID');?></th>
            <th><?php commonModel::printOrderLink('createdBy', $orderBy, $vars, $lang->conversion->createdBy);?></th>
            <th><?php commonModel::printOrderLink('dept', $orderBy, $vars, $lang->conversion->dept);?></th>
            <th><?php commonModel::printOrderLink('year', $orderBy, $vars, $lang->conversion->year);?></th>
            <th><?php echo $this->lang->conversion->days;?></th>
            <th><?php commonModel::printOrderLink('createdDate', $orderBy, $vars, $lang->conversion->createdDate);?></th>
            <?php if($status == 'all'):?>
            <th><?php commonModel::printOrderLink('grantedDate', $orderBy, $vars, $lang->conversion->grantedDate);?></th>
            <?php endif;?>
            <th><?php commonModel::printOrderLink('status', $orderBy, $vars, $lang->conversion->status);?></th>
            <th class='w-160px'><?php echo $this->lang->actions;?></th>
          </tr>
        </thead>
        <?php $canView   = commonModel::hasPriv('conversion', 'view');?>
        <?php $canReview = commonModel::hasPriv('conversion', 'review');?>
        <?php $canGrant  = commonModel::hasPriv('conversion', 'grant');?>
        <?php foreach($conversions as $conversion):?>
        <tr class='text-center'>
          <td><?php echo $conversion->id;?></td>
          <td><?php echo zget($users, $conversion->createdBy);?></td>
          <td><?php echo zget($depts, $conversion->dept);?></td>
          <td><?php echo $conversion->year;?></td>
          <td><?php echo $conversion->days;?></td>
          <td><?php echo formatTime($conversion->createdDate);?></td>
          <?php if($status == 'all'):?>
          <td><?php echo formatTime($conversion->grantedDate);?></td>
          <?php endif;?>
          <td class='conversion-<?php echo $conversion->status;?>'><?php echo zget($lang->conversion->statusList, $conversion->status);?></td>
          <td>
          <?php
            $canClickReview = $this->conversion->isClickable($conversion, 'review');
            $canClickGrant  = $this->conversion->isClickable($conversion, 'grant');

            if($canView) echo html::a(inlink('view', "conversionID={$conversion->id}"), $lang->detail, "data-toggle='modal'");

            if($canReview)
            {
                if($canClickReview)
                {
                    echo html::a(inlink('review', "conversionID={$conversion->id}&status=pass"),   zget($lang->conversion->reviewStatusList, 'pass'),   "class='reviewPass'");
                    echo html::a(inlink('review', "conversionID={$conversion->id}&status=reject"), zget($lang->conversion->reviewStatusList, 'reject'), "data-toggle='modal' data-width='600'");
                }
                else
                {
                    echo html::a('javascript:;', zget($lang->conversion->reviewStatusList, 'pass'),   "class='disabled'");
                    echo html::a('javascript:;', zget($lang->conversion->reviewStatusList, 'reject'), "class='disabled'");
                }
            }

            if($canGrant)
            {
                if($canClickGrant)
                {
                    echo html::a(inlink('grant', "conversionID={$conversion->id}"), $lang->grant, "data-toggle='modal'");
                }
                else
                {
                    echo html::a('javascript:;', $lang->grant, "class='disabled'");
                }
            }
          ?>
          </td>
        </tr>
        <?php endforeach;?>
      </table>
      <div class='table-footer'><?php $pager->show();?></div>
    </div>
  </div>
</div>
<?php include '../../common/view/footer.html.php';?>
