<?php
/**
 * The view view file of task 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     task
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include $app->getModuleRoot() . 'common/view/header.html.php';?>
<?php js::set('notAllowed', $lang->task->notAllowed);?>
<?php js::set('groupBy', $groupBy);?>
<?php js::set('backLink', $backLink);?>
<div class='page-content'>
  <div class='boards-container'>
    <div class='boards task-boards clearfix' id='taskKanban'>
    <?php foreach($tasks as $groupKey => $groupTasks):?>
      <div class='board task-board' data-group="<?php echo $groupBy?>" data-key="<?php echo $groupKey;?>" style="width: <?php echo $colWidth?>%">
        <?php if(empty($groupKey))      $panelStatus = 'panel-info';?>
        <?php if($groupKey == 'wait')   $panelStatus = 'panel-primary';?>
        <?php if($groupKey == 'doing')  $panelStatus = 'panel-danger';?>
        <?php if($groupKey == 'done')   $panelStatus = 'panel-success';?>
        <?php if($groupKey == 'cancel') $panelStatus = 'panel-warning';?>
        <?php if($groupKey == 'closed') $panelStatus = '';?>
        <div class="panel <?php echo $panelStatus;?>">
        <div class='panel-heading no-border'>
            <?php if(empty($groupKey)):?>
            <?php echo $lang->task->unkown;?>
            <?php elseif($groupBy == 'status'):?>
            <?php echo $lang->task->statusList[$groupKey];?>
            <?php else:?>
            <?php echo zget($users, $groupKey);?>
            <?php endif;?>
          </div>
          <div class='panel-body'>
            <div class='board-list'>
              <?php foreach($groupTasks as $task):?>
              <div class='board-item task' data-id="<?php echo $task->id;?>">
                <div class='task-heading'>
                  <?php echo html::a($this->createLink('task', 'view', "taskID={$task->id}"), $task->name)?>
                  <?php if(!empty($task->children)) echo "<span class='label'>{$lang->task->parentAB}</span>"?> 
                  <?php if(!empty($task->team))     echo "<span class='label'>{$lang->task->multipleAB}</span>"?>
                  <?php if(!empty($task->parent))   echo "<span class='label'>{$lang->task->childrenAB}</span>"?>
                </div>
                <?php if(!empty($task->desc)): ?>
                <div class='text-muted'><?php echo trim($task->name) == trim($task->desc) ? '' : $task->desc;?></div>
                <?php endif; ?>
                <div class='task-info clearfix'>
                  <div class='pull-left'>
                  <span class="label-pri label-pri-<?php echo $task->pri; ?>">P<?php echo $task->pri;?></span>
                  <?php if($groupBy != 'status'):?>
                    <span class="task-status text-<?php echo $task->status;?>"><small><?php echo $lang->task->statusList[$task->status];?></small></span>&nbsp;
                  <?php endif;?>
                  <?php if(!empty($task->assignedTo)):?>
                    <span class='task-assignedTo text-muted'><i class='icon-hand-right'></i> <small><?php echo $task->assignedTo;?></small></span>
                  <?php endif;?>
                  </div>
                  <?php if(!empty($task->deadline) and formatTime($task->deadline)):?>
                  <div class='task-deadline text-warning pull-right'><i class='icon-time'></i> <small><?php echo formatTime($task->deadline, DT_DATE1);?></small></div>
                  <?php endif;?>
                </div>
                <div class='task-actions'>
                  <button type='button' class='btn btn-mini btn-link btn-info-toggle'><i class='icon-angle-down'></i></button>
                  <div class='dropdown'>
                    <button type='button' class='btn btn-mini btn-link dropdown-toggle' data-toggle='dropdown'>
                      <span class='icon-more-v icon-md'></span>
                    </button>
                    <div class='dropdown-menu pull-right w-100px'>
                      <?php $this->task->buildOperateMenu($task);?>
                    </div>
                  </div>
                </div>
              </div>
              <?php if(!empty($task->children)):?>
              <?php foreach($task->children as $child):?>
              <div class='board-item task' data-id="<?php echo $child->id;?>">
                <div class='task-heading'>
                  <?php echo html::a($this->createLink('task', 'view', "taskID={$child->id}"), $child->name)?>
                  <?php if(!empty($child->team))   echo "<span class='label'>{$lang->task->multipleAB}</span>"?>
                  <?php echo "<span class='label'>{$lang->task->childrenAB}</span>"?>
                </div>
                <?php if(!empty($child->desc)): ?>
                <div class='text-muted'><?php echo trim($child->name) == trim($child->desc) ? '' : $child->desc;?></div>
                <?php endif; ?>
                <div class='task-info clearfix'>
                  <div class='pull-left'>
                  <span class="label-pri label-pri-<?php echo $child->pri; ?>">P<?php echo $child->pri;?></span>
                  <?php if($groupBy != 'status'):?>
                    <span class="task-status text-<?php echo $child->status;?>"><small><?php echo $lang->task->statusList[$child->status];?></small></span>&nbsp;
                  <?php endif;?>
                  <?php if(!empty($child->assignedTo)):?>
                    <span class='task-assignedTo text-muted'><i class='icon-hand-right'></i> <small><?php echo $child->assignedTo;?></small></span>
                  <?php endif;?>
                  </div>
                  <?php if(!empty($child->deadline) and formatTime($child->deadline)):?>
                  <div class='task-deadline text-warning pull-right'><i class='icon-time'></i> <small><?php echo formatTime($child->deadline, DT_DATE1);?></small></div>
                  <?php endif;?>
                </div>
                <div class='task-actions'>
                  <button type='button' class='btn btn-mini btn-link btn-info-toggle'><i class='icon-angle-down'></i></button>
                  <div class='dropdown'>
                    <button type='button' class='btn btn-mini btn-link dropdown-toggle' data-toggle='dropdown'>
                      <span class='icon-more-v icon-md'></span>
                    </button>
                    <div class='dropdown-menu pull-right w-100px'>
                      <?php $this->task->buildOperateMenu($child);?>
                    </div>
                  </div>
                </div>
              </div>
              <?php endforeach;?>
              <?php endif;?>
              <?php endforeach;?>
            </div>
          </div>
        </div>
      </div>
    <?php endforeach;?>
    </div>
  </div>
</div>
<?php include $app->getModuleRoot() . 'common/view/footer.html.php';?>
