<?php
/**
 * The browse file of todo 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      chujilu <chujilu@cnezsoft.com>
 * @package     todo
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include $app->getModuleRoot() . 'my/view/header.html.php';?>
<?php js::set('type', $type)?>
<div class='main-row'>
  <div class='side-col'>
    <div class='panel'>
      <div class='panel-body'>
        <div class='form-group'>
          <div class='input-group'>
            <span class='input-group-addon'><?php echo $lang->my->company->dept?></span>
            <?php echo html::select('dept', $deptList, $dept, "class='form-control chosen'")?>
          </div>
        </div>
        <div class='form-group'>
          <div class='input-group'>
            <span class='input-group-addon'><?php echo $lang->my->company->account?></span>
            <?php echo html::select('account', $users, $account, "class='form-control chosen'")?>
          </div>
        </div>
        <div class='form-group'>
          <div class='input-group'>
            <span class='input-group-addon'><?php echo $lang->my->company->begin?></span>
            <?php echo html::input('begin', formatTime($begin), "class='form-control form-date'")?>
          </div>
        </div>
        <div class='form-group'>
          <div class='input-group'>
            <span class='input-group-addon'><?php echo $lang->my->company->end?></span>
            <?php echo html::input('end', $end, "class='form-control form-date'")?>
          </div>
        </div>
        <div class='form-group'>
          <?php echo html::a('javascript:void(0)', $lang->my->company->view, "class='btn btn-primary submit'")?>
        </div>
      </div>
    </div>
  </div>
  <div class='main-col'>
    <div class='panel'>
      <div class='panel-body'>
        <table class='table table-bordered datatable' data-fixed-left-width='200' data-fixed-right-width='200'>
          <thead>
            <tr>
              <th class='text-center'><?php echo $lang->my->company->dept?></th>
              <th class='text-center'><?php echo $lang->my->company->account?></th>
              <?php foreach($dateList as $currentDate):?>
              <?php if($currentDate == end($dateList)) continue;?>
              <th class='text-center flex-col' data-width='200'><?php echo date(DT_DATE1, $currentDate);?></th>
              <?php endforeach;?>
              <th class='text-center' data-width='200'><?php echo date(DT_DATE1, end($dateList));?></th>
            </tr>
          </thead>
          <tbody>
            <?php foreach($todoList as $user => $todos):?>
            <tr>
              <td class='text-center'><?php echo zget($deptList, $userDept[$user], ' ')?></td>
              <td class='text-center'><?php echo zget($users, $user)?></td>
              <?php foreach($dateList as $currentDate):?>
              <td>
                <?php foreach($todos as $todo):?>
                <?php if($todo->date == date(DT_DATE1, $currentDate)):?>
                <div class='text-nowrap text-ellipsis w-180px <?php echo $todo->status?>' title='<?php echo $todo->name?>'>
                  <?php if(!empty($todo->begin)) echo $todo->begin . '~' . $todo->end;?>
                  <?php if($todo->type != 'leave' and $todo->type != 'trip'):?>
                  <?php echo html::a($this->createLink('todo', 'view', "todoID={$todo->id}"), $todo->name, "data-toggle='modal' data-width='80%'")?>
                  <?php elseif($todo->type == 'leave'):?>
                  <div class='text-danger'><?php echo $todo->name;?>
                  <?php else:?>
                  <div class='text-warning'><?php echo $todo->name;?>
                  <?php endif;?>
                </div>
                <?php endif;?>
                <?php endforeach;?>
              </td>
              <?php endforeach;?>
            </tr>
            <?php endforeach;?>
          </tbody>
        </table>
        <div class='table-footer'><?php $pager->show();?></div>
      </div>
    </div>
  </div>
</div>
<?php include $app->getModuleRoot() . 'common/view/footer.html.php';?>
