<?php
/**
 * The browse view file of lieu 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      Tingting Dai <daitingting@xirangit.com>
 * @package     lieu
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../common/view/header.html.php';?>
<?php $canCreate = commonModel::hasPriv('lieu', 'createConversion');?>
<div class='main-row'>
  <div class='main-col'>
    <div class='panel main-table' data-ride='table'>
      <table class='table has-sort-head' id='lieuTable'>
        <thead>
          <tr>
            <?php $vars = "&orderBy=%s&recTotal=$pager->recTotal&recPerPage=$pager->recPerPage&pageID=$pager->pageID";?>
            <th class='w-100px'><?php echo $lang->lieuconversion->realname;?></th>
            <th class='w-100px'><?php commonModel::printOrderLink('dept', $orderBy, $vars, $lang->user->dept);?></th>
            <?php foreach($monthList as $month):?>
            <th class='w-90px text-center'><?php echo date('Y-m', strtotime($month . '01'));?></th>
            <?php endforeach;?>
            <th class='w-100px text-center'><?php echo $lang->lieuconversion->totalHours;?></th>
            <th class='w-100px text-center'><?php echo $lang->lieuconversion->waitHours;?></th>
            <?php if($canCreate):?>
            <th class='w-100px text-center'><?php echo $lang->actions;?></th>
            <?php endif;?>
          </tr>
        </thead>
        <?php foreach($attendstats as $account => $attendstat):?>
        <tr>
          <td><?php echo zget(zget($users, $account, ''), 'realname');?></td>
          <td><?php echo zget($deptList, zget(zget($users, $account, ''), 'dept'));?></td>
          <?php foreach($monthList as $month):?>
          <?php $toLieu = zget(zget($attendstat['month'], $month, array()), 'toLieu', 0);?>
          <td class='w-100px text-center'><?php echo (float)$toLieu;?></td>
          <?php endforeach;?>
          <?php $availableHours = $attendstat['totalHours'] - $attendstat['waitHours'];?>
          <td class='w-100px text-center'><?php echo (float)$availableHours;?></td>
          <td class='w-100px text-center'><?php echo (float)$attendstat['waitHours'];?></td>
          <?php if($canCreate):?>
          <td class='text-center'>
            <?php echo html::a(inlink('createConversion', "account={$account}&maxHours={$availableHours}"), $lang->lieu->createConversion, "data-toggle='modal' data-width='600'");?>
          </td>
          <?php endif;?>
        </tr>
        <?php endforeach;?>
      </table>
        <div class='table-footer'>
          <?php $pager->show();?>
        </div>
    </div>
  </div>
</div>
<?php include '../../common/view/footer.html.php';?>
