<?php
/**
 * The personal 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';?>
<div class='panel panel-block main-table'>
  <table class='table has-sort-head'>
    <thead>
      <tr class='text-center'>
        <?php $vars = "orderBy=%s&recTotal=$pager->recTotal&recPerPage=$pager->recPerPage&pageID=$pager->pageID";?>
        <th><?php commonModel::printOrderLink('year', $orderBy, $vars, $lang->conversion->year);?></th>
        <th><?php commonModel::printOrderLink('days', $orderBy, $vars, $lang->conversion->days);?></th>
        <th><?php commonModel::printOrderLink('createdDate', $orderBy, $vars, $lang->conversion->createdDate);?></th>
        <th><?php commonModel::printOrderLink('grantedDate', $orderBy, $vars, $lang->conversion->grantedDate);?></th>
        <th><?php commonModel::printOrderLink('status', $orderBy, $vars, $lang->conversion->status);?></th>
        <th class='w-200px'><?php echo $lang->actions;?></th>
      </tr>
    </thead>
    <?php $canView   = commonModel::hasPriv('conversion', 'view');?>
    <?php $canEdit   = commonModel::hasPriv('conversion', 'edit');?>
    <?php $canSwitch = commonModel::hasPriv('conversion', 'switchStatus');?>
    <?php $canDelete = commonModel::hasPriv('conversion', 'delete');?>
    <?php foreach($conversions as $conversion):?>
    <tr class='text-center'>
      <td><?php echo $conversion->year;?></td>
      <td><?php echo $conversion->days;?></td>
      <td><?php echo formatTime($conversion->createdDate);?></td>
      <td><?php echo formatTime($conversion->grantedDate);?></td>
      <td class='conversion-<?php echo $conversion->status;?>'><?php echo zget($lang->conversion->statusList, $conversion->status);?></td>
      <td>
      <?php
        $canClickEdit   = $this->conversion->isClickable($conversion, 'edit');
        $canClickDelete = $this->conversion->isClickable($conversion, 'delete');
        $canClickSwitch = $this->conversion->isClickable($conversion, 'switchstatus');

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

        if($canSwitch)
        {
            $switchLabel = $conversion->status == 'wait' ? $lang->cancel : $lang->submit;
            if($canClickSwitch)
            {
                echo html::a(inlink('switchStatus', "conversionID={$conversion->id}"), $switchLabel);
            }
            else
            {
                echo html::a('javascript:;', $switchLabel, "class='disabled'");
            }
        }

        if($canEdit)
        {
            if($canClickEdit)
            {
                echo html::a(inlink('edit', "conversionID={$conversion->id}"), $lang->edit, "data-toggle='modal' data-width='400'");
            }
            else
            {
                echo html::a('javascript:;', $lang->edit, "class='disabled'");
            }
        }

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