<?php
/**
 * The task view file of my 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     my
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include './header.html.php';?>
<?php js::set('type', $type);?>
<div class='main-table' data-ride='table'>
  <?php $canBatchClose = commonModel::hasPriv('task', 'batchClose') && $tasks;?>
  <?php if($canBatchClose):?>
  <form id='ajaxForm' method='post' action="<?php echo $this->createLink('proj.task', 'batchClose');?>">
  <?php endif;?>
    <table class='table has-sort-head' id='taskList'>
      <thead>
        <tr class='text-center'>
          <?php $vars = "type={$type}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
          <th class='text-left w-100px'>
            <?php if($canBatchClose):?>
            <div class='checkbox-primary check-all' title='<?php echo $this->lang->selectAll;?>'><label></label></div>
            <?php endif;?>
            <?php commonModel::printOrderLink('id', $orderBy, $vars, $lang->task->id);?>
          </th>
          <th class='w-40px'> <?php commonModel::printOrderLink('pri',         $orderBy, $vars, $lang->task->lblPri);?></th>
          <th>                <?php commonModel::printOrderLink('name',        $orderBy, $vars, $lang->task->name);?></th>
          <th class='w-100px'><?php commonModel::printOrderLink('deadline',    $orderBy, $vars, $lang->task->deadline);?></th>
          <th class='w-80px'> <?php commonModel::printOrderLink('assignedTo',  $orderBy, $vars, $lang->task->assignedTo);?></th>
          <th class='w-90px'> <?php commonModel::printOrderLink('status',      $orderBy, $vars, $lang->task->status);?></th>
          <th class='w-100px'><?php commonModel::printOrderLink('createdDate', $orderBy, $vars, $lang->task->createdDate);?></th>
          <th class='w-90px'> <?php commonModel::printOrderLink('consumed',    $orderBy, $vars, $lang->task->consumedAB . $lang->task->lblHour);?></th>
          <th class='w-110px'> <?php commonModel::printOrderLink('left',       $orderBy, $vars, $lang->task->left . $lang->task->lblHour);?></th>
          <th class='w-<?php echo $lang->my->taskActionWidth;?>px'><?php echo $lang->actions;?></th>
        </tr>
      </thead>
      <tbody>
        <?php foreach($tasks as $task):?>
        <tr class='text-center'>
          <td class='text-left'>
            <?php if($canBatchClose):?>
            <div class='checkbox-primary'><input type='checkbox' name='taskIDList[]' value="<?php echo $task->id;?>" id="taskIDList<?php echo $task->id;?>">
              <label for="taskIDList<?php echo $task->id;?>"></label>
            </div>
            <?php endif;?>
            <?php echo $task->id;?>
          </td>
          <td><span class='active label-pri label-pri-<?php echo $task->pri; ?>'><?php echo zget($lang->task->priList, $task->pri, '');?></span></td>
          <td class='text-left <?php if(!empty($task->children)) echo 'has-child';?>'>
            <?php if($task->parent != 0) echo "<span class='label'>{$lang->task->childrenAB}</span>"?>
            <?php if(!empty($task->team)) echo "<span class='label'>{$lang->task->multipleAB}</span>"?>
            <?php echo html::a("javascript:$.openEntry(\"proj\", \"" . $this->createLink('proj.task', 'view', "taskID=$task->id") . "\")", $task->name, "title='$task->name'");?>
            <?php if(!empty($task->children)) echo '<a class="task-toggle" data-id="' . $task->id . '"><i class="icon icon-angle-right"></i></a>';?>
          </td>
          <td><?php echo formatTime($task->deadline, DT_DATE1);?></td>
          <td><?php echo zget($users, $task->assignedTo);?></td>
          <td><?php echo zget($lang->task->statusList, $task->status);?></td>
          <td><?php echo formatTime($task->createdDate, DT_DATE1);?></td>
          <td><?php echo $task->consumed;?></td>
          <td><?php echo $task->left;?></td>
          <td class='text-left actions'><?php $this->task->buildOperateMenu($task);?></td>
        </tr>
        <?php if(!empty($task->children)):?>
        <?php $i = 0;?>
        <?php foreach($task->children as $key => $child):?>
        <?php $class  = $i == 0 ? ' table-child-top' : '';?>
        <?php $class .= ($i + 1 == count($task->children)) ? ' table-child-bottom' : '';?>
        <tr class='text-center table-children<?php echo $class;?> parent-<?php echo $task->id;?>' data-id='<?php echo $child->id?>' data-status='<?php echo $child->status?>' data-estimate='<?php echo $child->estimate?>' data-consumed='<?php echo $child->consumed?>' data-left='<?php echo $child->left?>'>
          <td class='text-left'>
            <?php if($canBatchClose):?>
            <div class='checkbox-primary'><input type='checkbox' name='taskIDList[]' value="<?php echo $child->id;?>" id="taskIDList<?php echo $child->id;?>">
              <label for="taskIDList<?php echo $child->id;?>"></label>
            </div>
            <?php endif;?>
            <?php echo $child->id;?>
          </td>
          <td><span class='active label-pri label-pri-<?php echo $child->pri; ?>'><?php echo $lang->task->priList[$child->pri];?></span></td>
          <td class='text-left' title='<?php echo $child->name;?>'>
            <span class='label'><?php echo $lang->task->childrenAB?></span>
            <?php echo html::a("javascript:$.openEntry(\"proj\", \"" . $this->createLink('proj.task', 'view', "taskID=$child->id") . "\")", $child->name, "title='$child->name'");?>
          </td>
          <td><?php echo formatTime($child->deadline, DT_DATE1);?></td>
          <td><?php if(isset($users[$child->assignedTo])) echo $users[$child->assignedTo];?></td>
          <td><?php echo zget($lang->task->statusList, $child->status);?></td>
          <td><?php echo formatTime($child->createdDate, DT_DATE1);?></td>
          <td> <?php echo $child->consumed;?></td>
          <td><?php echo $child->left;?></td>
          <td class='text-left actions'><?php $this->task->buildOperateMenu($child);?></td>
        </tr>
        <?php $i ++;?>
        <?php endforeach;?>
        <?php endif;?>
        <?php endforeach;?>
      </tbody>
    </table>
    <div class='table-footer'>
      <?php if($canBatchClose):?>
      <div class='checkbox-primary check-all'><label><?php echo $lang->selectAll?></label></div>
      <div class='table-actions btn-toolbar'><?php echo html::submitButton($lang->close, 'btn btn-default');?></div>
      <div class='table-statistic'></div>
      <?php endif;?>
      <?php $pager->show();?>
    </div>
  <?php if($canBatchClose):?>
  </form>
  <?php endif;?>
</div>
<?php include '../../common/view/footer.html.php';?>
