<?php
/**
 * The admin view file of user 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      Yangyang Shi <shiyangyangwork@yahoo.cn>
 * @package     User
 * @version     $Id: admin.html.php 4029 2016-08-26 06:50:41Z liugang $
 * @link        http://www.zdoo.com
 */
?>
<?php
include '../../common/view/header.html.php';
include '../../common/view/treeview.html.php';
js::set('deptID', $deptID);
js::set('from', 'admin');
js::set('mode', $mode);
?>
<div id='menuActions'>
  <form method='post' class='form-search w-200px' style='display: inline-block; vertical-align: middle;'>
    <div class="input-group" style='padding-left:10px'>
      <?php echo html::input('search', $search, "class='form-control search-query' placeholder='{$lang->user->inputAccount}'"); ?>
      <span class="input-group-btn">
        <?php echo html::submitButton($lang->user->searchUser,"btn btn-primary"); ?>
      </span>
    </div>
  </form>
  <?php commonModel::printLink('user', 'import', '', '<i class="icon-import"></i> ' . $lang->import, "class='btn btn-secondary' data-toggle='modal'");?>
  <?php commonModel::printLink('user', 'exportTemplate', '', '<i class="icon-export"></i> ' . $lang->exportTemplate, "class='btn btn-secondary iframe' data-width='700'");?>
  <?php commonModel::printLink('user', 'create', '', '<i class="icon-plus"></i> ' . $lang->user->create, 'class="btn btn-primary"');?>
  <?php commonModel::printLink('user', 'batchCreate', '', '<i class="icon-plus"></i> ' . $lang->user->batchCreate, 'class="btn btn-primary"');?>
</div>
<div class='main-row'> 
  <?php include './deptside.html.php';?>
  <div class='main-col'>
    <div class='panel main-table'>
      <table class='table has-sort-head table-fixed'>
        <thead>
          <tr class='text-center'>
            <?php $vars = "deptID=$deptID&mode=$mode&search=$search&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
            <th class='w-60px'><?php commonModel::printOrderLink('id', $orderBy, $vars, $lang->user->id);?></th>
            <th class='w-100px'><?php commonModel::printOrderLink('realname', $orderBy, $vars, $lang->user->realname);?></th>
            <th><?php commonModel::printOrderLink('account', $orderBy, $vars, $lang->user->account);?></th>
            <th class='w-60px'><?php commonModel::printOrderLink('gender', $orderBy, $vars, $lang->user->gender);?></th>
            <th><?php commonModel::printOrderLink('dept', $orderBy, $vars, $lang->user->dept);?></th>
            <th class='w-90px'><?php commonModel::printOrderLink('join', $orderBy, $vars, $lang->user->join);?></th>
            <th class='w-80px'><?php commonModel::printOrderLink('visits', $orderBy, $vars, $lang->user->visits);?></th>
            <th class='w-140px'><?php commonModel::printOrderLink('last', $orderBy, $vars, $lang->user->last);?></th>
            <th class='w-110px'><?php commonModel::printOrderLink('ip', $orderBy, $vars, $lang->user->ip);?></th>
            <th class='w-70px'><?php commonModel::printOrderLink('status', $orderBy, $vars, $lang->user->status);?></th>
            <th class='w-<?php echo $lang->user->actionWidth;?>px'><?php echo $lang->actions;?></th>
          </tr>
        </thead>
        <tbody>
        <?php foreach($users as $user):?>
        <tr class='text-center'>
          <td><?php echo $user->id;?></td>
          <td><?php echo $user->realname;?></td>
          <td><?php echo $user->account;?></td>
          <td><?php $gender = $user->gender; echo $lang->user->genderList->$gender;?></td>
          <td><?php echo zget($depts, $user->dept, '');?></td>
          <td><?php echo formatTime($user->join, DT_DATE1);?></td>
          <td><?php echo $user->visits;?></td>
          <td><?php echo formatTime($user->last, DT_DATETIME1);?></td>
          <td><?php echo $user->ip;?></td>
          <td>
            <?php
            $status = 'normal';
            if($user->fails > 4 and $user->locked > helper::now())
            {
                $status = 'locked';
                echo $lang->user->statusList->locked;
            }
            if($user->fails <= 4 and $user->locked > helper::now())
            {
                $status = 'forbidden';
                echo $lang->user->statusList->forbidden;
            }
            if($user->locked <= helper::now()) echo $lang->user->statusList->normal;
            ?>
          </td>
          <td class='operate'>
            <?php
            echo html::a($this->createLink('user', 'edit', "account=$user->account&from=admin"), $lang->edit);
            if($status == 'normal')
            {
                echo html::a($this->createLink('user', 'forbid', "account=$user->account"), $lang->user->forbid, "class='forbider'");
            }
            else
            {
                echo html::a($this->createLink('user', 'active', "account=$user->account"), $lang->user->active, "class='forbider'");
            }
            echo html::a($this->createLink('user', 'delete', "account=$user->account"), $lang->delete, "class='deleter'");
            ?>
          </td>
        </tr>
        <?php endforeach;?>
        </tbody>
      </table>
      <div class='table-footer'><?php $pager->show();?></div>
    </div>
  </div>
</div>
<?php include '../../common/view/footer.html.php';?>
