<?php
/**
 * The browse view file of annual 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      Gang Liu <liugang@easycorp.ltd>
 * @package     annual
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../common/view/header.html.php';?>
<?php if($type == 'all'):?>
<div class='main-row'>
  <div class='side-col'>
    <div class='panel'>
      <div class='panel-body'>
          <ul class='tree' data-collapsed='true'>
          <?php foreach($years as $currentYear):?>
          <li class='<?php echo $year == $currentYear ? 'active' : ''?>'><?php echo html::a(inlink('all', "mode=$mode&year=$currentYear"), $currentYear);?></li>
          <?php endforeach;?>
          </ul>
      </div>
    </div>
  </div>
  <div class='main-col'>
<?php endif;?>
    <div class='panel panel-block main-table'>
      <table class='table has-sort-head'>
        <thead>
          <tr class='text-center'>
            <?php $vars = "mode=$mode&year=$year&orderBy=%s&recTotal=$pager->recTotal&recPerPage=$pager->recPerPage&pageID=$pager->pageID";?>
            <th><?php commonModel::printOrderLink('account', $orderBy, $vars, $lang->annual->account);?></th>
            <?php if($type == 'personal'):?>
            <th><?php commonModel::printOrderLink('year', $orderBy, $vars, $lang->annual->year);?></th>
            <?php endif;?>
            <th><?php commonModel::printOrderLink('days', $orderBy, $vars, $lang->annual->days);?></th>
            <th><?php commonModel::printOrderLink('balance', $orderBy, $vars, $lang->annual->balance);?></th>
            <th><?php commonModel::printOrderLink('times', $orderBy, $vars, $lang->annual->times);?></th>
            <th class='w-140px'><?php echo $lang->actions;?></th>
          </tr>
        </thead>
        <?php $canEdit       = commonModel::hasPriv('annual', 'edit');?>
        <?php $canView       = commonModel::hasPriv('annual', 'view');?>
        <?php $canConversion = commonModel::hasPriv('conversion', 'create');?>
        <?php foreach($annuals as $annual):?>
        <tr class='text-center'>
          <td><?php echo zget($users, $annual['account']);?></td>
          <?php if($type == 'personal'):?>
          <td><?php echo $annual['year'];?></td>
          <?php endif;?>
          <td><?php echo $annual['days'];?></td>
          <td><?php echo $annual['balance'];?></td>
          <td><?php echo $annual['times'];?></td>
          <td class='actions'>
            <?php
            $annualID = $annual['id'];
            $account  = $annual['account'];
            $year     = $annual['year'];
            if($canConversion)
            {
                if($annual['balance'] > 0)
                {
                    echo html::a($this->createLink('conversion', 'create', "year={$annual['year']}&maxDays={$annual['balance']}"), $lang->annual->conversion, "data-toggle='modal' data-width='400'");
                }
                else
                {
                    echo html::a('javascript:;', $lang->annual->conversion, "class='disabled'");
                }
            }
            if($canEdit) echo html::a(inlink('edit', "annualID=$annualID"), $lang->edit, "data-toggle='modal' data-width='400'");
            if($canView) echo html::a(inlink('view', "account=$account&year=$year"), $lang->detail, "data-toggle='modal'");
            ?>
          </td>
        </tr>
        <?php endforeach;?>
      </table>
      <div class='table-footer'><?php $pager->show();?></div>
    </div>
<?php if($type == 'all'):?>
  </div>
</div>
<?php endif;?>
<?php include '../../common/view/footer.html.php';?>
