<?php
/**
 * The browse view file of attendgroup module of ZDOO.
 *
 * @copyright   Copyright 2009-2020 青岛易软天创网络科技有限公司(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     attendgroup
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('groups', $groups);?>
<div id='menuActions'>
  <?php commonModel::printLink('attendgroup', 'create', '', "<i class='icon icon-plus'> </i>" . $lang->attendgroup->create, "class='btn btn-primary' data-toggle='modal'");?>
</div>
<div class='panel main-table'>
  <table class='table has-sort-head'>
    <thead>
      <tr>
        <?php $vars = "orderBy=%s&recTotal=$pager->recTotal&recPerPage=$pager->recPerPage&pageID=$pager->pageID";?>
        <th class='w-80px'><?php commonModel::printOrderLink('id', $orderBy, $vars, $lang->attendgroup->id);?></th>
        <th class='w-200px'><?php commonModel::printOrderLink('name', $orderBy, $vars, $lang->attendgroup->name);?></th>
        <th class='w-120px'><?php commonModel::printOrderLink('signInLimit', $orderBy, $vars, $lang->attendgroup->time);?></th>
        <th class='w-120px'><?php commonModel::printOrderLink('lunchBegin', $orderBy, $vars, $lang->attendgroup->lunch);?></th>
        <th class='w-120px'><?php commonModel::printOrderLink('dinnerBegin', $orderBy, $vars, $lang->attendgroup->dinner);?></th>
        <th><?php commonModel::printOrderLink('users', $orderBy, $vars, $lang->attendgroup->users);?></th>
        <th class='w-100px'><?php echo $lang->actions;?></th>
      </tr>
    </thead>
    <tbody>
      <?php $canEdit   = commonModel::hasPriv('attendgroup', 'edit');?>
      <?php $canDelete = commonModel::hasPriv('attendgroup', 'delete');?>
      <?php foreach($groups as $group):?>
      <tr>
        <td><?php printf('%3d', $group->id);?></td>
        <td title='<?php echo $group->name;?>'><?php echo $group->name;?></td>
        <td><?php echo $group->signInLimit . ' ~ ' . $group->signOutLimit;?></td>
        <td><?php echo $group->lunchBegin . ' ~ ' . $group->lunchEnd;?></td>
        <td><?php echo $group->dinnerBegin . ' ~ ' . $group->dinnerEnd;?></td>
        <?php $groupUsers = '';?>
        <?php foreach(explode(',', $group->users) as $account) $groupUsers .= zget($users, $account) . ' ';?></td>
        <td class='text-ellipsis' title='<?php echo $groupUsers;?>'><?php echo $groupUsers;?></td>
        <td>
          <?php
          if($canEdit) echo html::a(inlink('edit', "groupID=$group->id"), $lang->edit, "data-toggle='modal'");
          $deleteURL = inlink('delete', "groupID=$group->id");
          $checkURL  = inlink('ajaxCheckDelete', "groupID=$group->id");
          if($canDelete) echo html::a('javascript:;', $lang->delete, "data-title='{$lang->attendgroup->delete}' data-deleteurl='{$deleteURL}' data-checkurl='{$checkURL}' class='delete-group'");
          ?>
        </td>
      </tr>
      <?php endforeach;?>
    </tbody>
  </table>
  <div class='table-footer'><?php $pager->show();?></div>
</div>
<?php include '../../common/view/footer.html.php';?>
