<?php
/**
 * The batch create view 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      Yidong Wang <Yidong@cnezsoft.com>
 * @package     task
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php
$isChildren = !empty($parent);
if(helper::isAjaxRequest())
{
    include $app->getAppRoot() . '../sys/common/view/header.modal.html.php';
}
else
{
    include $app->getAppRoot() . '../sys/common/view/header.html.php';
}
?>

<?php if(!$isChildren):?>
<div class='main-row'>
  <div class='panel'>
<?php endif;?>
    <form id='batchCreateForm' method='post' action='<?php echo $this->createLink('task', 'batchCreate', "projectID=$projectID&parent=$parent");?>'>
      <table class='table table-form'>
        <thead>
          <tr class='text-center'>
            <th class='w-60px'><?php echo $lang->task->id;?></th>
            <th><?php echo $lang->task->name;?> <span class='required'></span></th>
            <th class='w-110px'><?php echo $lang->task->assignedTo;?></th>
            <th class='w-p25'><?php echo $lang->task->desc;?></th>
            <th class='w-120px'><?php echo $lang->task->deadline;?></th>
            <th class='w-70px'><?php echo $lang->task->pri;?></th>
            <th class='w-70px'><?php echo $lang->task->estimateAB;?></th>
          </tr>
        </thead>

        <?php
        $teamUsers = $users;
        ?>
        <?php for($i = 0; $i < $config->task->batchCreate; $i++):?>
        <?php
        $member = $i == 0 ? '' : 'ditto';
        $pri = 3;
        if($i == 1) $users['ditto'] = $lang->ditto;
        ?>
        <tr>
          <td class='text-center'><?php echo $i+1;?><?php echo html::input("parent[$i]", $parent, "class='hide'");?></td>
          <?php if($isChildren):?>
          <td><?php echo html::input("name[$i]", '', "class='form-control'");?></td>
          <td><?php echo html::select("assignedTo[$i]", $users, $member, "class='form-control chosen'");?></td>
          <?php else:?>
          <td>
            <div class='input-group'>
              <?php echo html::input("name[$i]", '', "class='form-control'");?>
              <span class='input-group-addon'>
                <label class='checkbox-inline'>
                  <input type='checkBox' data-id='<?php echo $i?>' name='<?php echo "multiple[$i]"?>' value='1' />
                  <?php echo $lang->task->multipleAB;?>
                </label>
              </span>
            </div>
            <div class="modal fade modal-team" id="modal<?php echo $i;?>">
              <div class="modal-dialog">
                <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only"><?php echo $lang->close?></span></button>
                  <h4 class="modal-title"><?php echo $lang->task->team?></h4>
                </div>
                <div class="modal-content">
                  <table class='table-form'>
                    <thead>
                      <tr class='text-center'>
                        <th><?php echo $lang->task->team;?></th>
                        <th class='w-150px'><?php echo $lang->project->role;?></th>
                        <th class='w-130px'><?php echo $lang->task->recordEstimate;?></th>
                        <th class='w-90px'></th>
                      </tr>
                    </thead>
                    <?php for($mi = 0; $mi < 6; $mi++):?>
                    <tr>
                      <td><?php echo html::select("team[$i][]", $teamUsers, '', "class='form-control chosen'")?></td>
                      <td><?php echo html::input("role[$i][]", '', "class='form-control'")?></td>
                      <td>
                        <div class='input-group'>
                          <?php echo html::input("teamEstimate[$i][]", '', "class='form-control text-center' placeholder='{$lang->task->estimateAB}'")?>
                          <span class='input-group-addon'><?php echo $lang->task->hour?></span>
                        </div>
                      </td>
                      <td>
                        <a href='javascript:;' class='btn btn-move-up btn-sm'><i class='icon-arrow-up'></i></a>
                        <a href='javascript:;' class='btn btn-move-down btn-sm'><i class='icon-arrow-down'></i></a>
                      </td>
                    </tr>
                    <?php endfor;?>
                    <tr><td colspan='4' class='text-center form-actions'><?php echo html::a('javascript:void(0)', $lang->save, "class='btn btn-primary' data-dismiss='modal'")?></td></tr>
                  </table>
                </div>
              </div>
            </div>
          </td>
          <td>
            <div class='input-group'>
              <?php echo html::select("assignedTo[$i]", $users, $member, "class='form-control'");?>
              <?php echo html::input("teamMember[$i]", '', "class='form-control team-group hidden' readonly='readonly'");?>
              <span class='input-group-addon fix-padding team-group hidden'></span>
              <?php echo html::a("#modal{$i}", $lang->task->team, "class='form-control btn hidden' data-toggle='modal' data-target='#modal{$i}'");?>
            </div>
          </td>
          <?php endif;?>
          <td><?php echo html::textarea("desc[$i]", '', "rows='1' class='form-control'");?></td>
          <td><?php echo html::input("deadline[$i]", '', "class='form-control form-date'");?></td>
          <td><?php echo html::select("pri[$i]", $lang->task->priList, $pri, "class=form-control");?></td>
          <td><?php echo html::input("estimate[$i]", '', "class='form-control text-center' placeholder='{$lang->task->hour}'");?></td>
        </tr>
        <?php endfor;?>
        <tfoot>
          <tr>
            <td colspan='<?php echo $isChildren ? 6 : 7?>' class='text-center form-actions'>
            <?php
            $browseLink = $this->session->taskList ? $this->session->taskList : inlink('browse', "project=$task->project");
            echo html::submitButton() . html::a($browseLink, $lang->goback, "class='btn btn-back'") . html::hidden('referer', $this->server->http_referer);
            ?>
            </td>
          </tr>
        </tfoot>
      </table>
    </form>
<?php if(!$isChildren):?>
  </div>
</div>
<?php endif;?>
<?php include $app->getAppRoot() . '../sys/common/view/footer.modal.html.php';?>
