<?php
/**
 * The view weekly view file of effort module of ZDOO.
 *
 * @copyright   Copyright 2009-2016 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     商业软件，非开源软件
 * @author      Tingting Dai <daitingting@xirangit.com>
 * @package     effort 
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../../sys/my/view/header.html.php';?>
<?php js::set('from', $from);?>
<div class='main-row'>
  <div class='main-col col-8'>
    <div class='panel panel-block'>
      <div class='panel-heading'><strong><?php echo $lang->effort->weekly->summary;?></strong></div>
      <div class='panel-body'>
        <?php echo $weekly->summary;?>
      </div>
    </div>

    <?php if(!empty($efforts)):?>
    <div class='panel panel-block table-row'>
      <div class='panel-heading'><strong><?php echo $lang->effort->common;?></strong></div>
      <div class='panel-body'>
        <table class='table table-bordered'>
          <thead>
            <?php $dates = range(strtotime($weekly->begin), strtotime($weekly->end), 60 * 60 * 24);?>
            <tr>
              <?php foreach($dates as $key => $datetime):?>
              <?php $date = date('Y-m-d', $datetime);?>
              <?php if(empty($efforts[$date])):?>
              <?php unset($dates[$key]); continue;?>
              <?php endif;?>
              <?php $width = (1 / count($dates) * 100) . '%';?>
              <th style='width:<?php echo $width;?>'><?php echo zget($lang->effort->weekly->weekList, date('w', $datetime));?></th> 
              <?php endforeach;?>
            </tr>
          </thead>
          <tbody>
            <tr>
              <?php foreach($dates as $datetime):?>
              <?php $date = date('Y-m-d', $datetime);?>
              <td>
                <?php if(!empty($efforts[$date])):?>
                <ol>
                  <?php foreach($efforts[$date] as $effort):?>
                  <li><?php echo $effort->work;?></li>
                  <?php endforeach;?>
                </ol>
                <?php endif;?>
              </td>
              <?php endforeach;?>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <?php endif;?>

    <div class='panel panel-block'>
      <div class='panel-heading'><strong><?php echo $lang->effort->weekly->content;?></strong></div>
      <div class='panel-body'>
        <?php echo $weekly->content;?>
      </div>
    </div>

    <div class='main-actions text-center'>
      <div class='btn-toolbar'>
        <?php if($weekly->createdBy == $this->app->user->account):?>
        <?php commonModel::printLink('effort', 'editWeekly', "id=$weekly->id", $lang->edit, "class='btn'")?>
        <?php commonModel::printLink('effort', 'deleteWeekly', "id=$weekly->id", $lang->delete, "class='btn deleter'")?>
        <div class='divider'></div>
        <?php endif;?>
        <?php echo html::backButton('');?>
      </div>
    </div>
  </div>

  <div class='side-col col-4'>
    <div class='panel panel-block'>
      <div class='panel-heading'><strong><?php echo $lang->effort->weekly->basicInfo;?></strong></div>
      <div class='panel-body'>
        <table class='table table-data'>
          <tr>
            <th class='w-70px'><?php echo $lang->effort->weekly->title;?></th>
            <td><?php echo $weekly->title;?></td> 
          </tr>
          <tr>
            <th><?php echo $lang->effort->weekly->date;?></th>
            <td><?php echo formatTime($weekly->begin, DT_DATE1) . '~' . formatTime($weekly->end, DT_DATE1);?></td> 
          </tr>
          <tr>
            <th><?php echo $lang->effort->weekly->createdBy;?></th>
            <td><?php echo zget($users, $weekly->createdBy) . $lang->at . formatTime($weekly->createdDate, DT_DATETIME1);?></td>
          </tr>
          <tr>
            <th><?php echo $lang->effort->weekly->editedBy;?></th>
            <?php $editedDate = formatTime($weekly->editedDate, DT_DATETIME1);?>
            <td><?php echo zget($users, $weekly->editedBy) . ($editedDate ? $lang->at : '') . $editedDate;?></td>
          </tr>
          <tr>
            <th><?php echo $lang->effort->weekly->status;?></th>
            <td><?php echo zget($lang->effort->weekly->statusList, $weekly->status);?></td> 
          </tr>
        </table>
      </div>
    </div>
  </div>
</div>
<?php include '../../../sys/common/view/footer.html.php'; ?>
