<?php
/**
 * The view file of makeup 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     makeup
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../../sys/common/view/header.modal.html.php';?>
<?php include '../../../sys/common/view/kindeditor.html.php';?>
<?php js::set('confirmReview', $lang->makeup->confirmReview)?>
<table class='table table-bordered'>
  <tr>
    <th><?php echo $lang->makeup->status;?></th>
    <td class='makeup-<?php echo $makeup->status;?>'><?php echo $lang->makeup->statusList[$makeup->status];?></td>
    <th><?php echo $lang->makeup->hours?></th>
    <td><?php echo $makeup->hours . $lang->makeup->hoursTip;?></td>
  </tr> 
  <tr>
    <th><?php echo $lang->makeup->begin?></th>
    <td><?php echo formatTime($makeup->begin . ' ' . $makeup->start, DT_DATETIME2);?></td>
    <th><?php echo $lang->makeup->end?></th>
    <td><?php echo formatTime($makeup->end . ' ' . $makeup->finish, DT_DATETIME2);?></td>
  </tr>
  <?php if($makeup->leave):?>
  <tr>
    <th class='text-middle'><?php echo $lang->makeup->leave;?></th>
    <td colspan='3'>
      <?php foreach(explode(',', trim($makeup->leave, ',')) as $leave):?>
      <?php if($leave) echo zget($leaves, $leave) . '</br>';?>
      <?php endforeach;?>
    </td>
  </tr>
  <?php endif;?>
  <tr>
    <th><?php echo $lang->makeup->desc?></th>
    <td colspan='3'><?php echo $makeup->desc;?></td>
  </tr> 
  <?php if($makeup->status == 'reject' and $makeup->rejectReason):?>
  <tr>
    <th><?php echo $lang->makeup->rejectReason;?></th>
    <td colspan='3'><?php echo $makeup->rejectReason;?></td>
  </tr>
  <?php endif;?>
  <tr>
    <th><?php echo $lang->makeup->createdBy;?></th>
    <td><?php echo zget($users, $makeup->createdBy);?></td>
    <th><?php echo $lang->makeup->reviewedBy;?></th>
    <td id='reviewedBy'><?php echo zget($users, $makeup->reviewedBy);?></td>
  </tr> 
  <tr>
    <th><?php echo $lang->makeup->createdDate;?></th>
    <td><?php echo formatTime($makeup->createdDate, DT_DATETIME1);?></td>
    <th><?php echo $lang->makeup->reviewedDate;?></th>
    <td><?php echo formatTime($makeup->reviewedDate, DT_DATETIME1);?></td>
  </tr> 
</table>
<?php echo $this->fetch('action', 'history', "objectType=makeup&objectID=$makeup->id");?>
<div class='main-actions text-center'>
  <div class='btn-toolbar'>
    <?php
    echo html::a('javascript:;', $lang->goback, "class='btn' data-dismiss='modal'");

    if($type == 'personal')
    {
        $canEdit   = $this->makeup->isClickable($makeup, 'edit');
        $canDelete = $this->makeup->isClickable($makeup, 'delete');
        $canSwitch = $this->makeup->isClickable($makeup, 'switchStatus');

        if($canSwitch or $canEdit or $canDelete)
        {
            echo "<div class='divider'></div>";
            if($canSwitch)
            {
                $switchLabel = $makeup->status == 'wait' ? $lang->makeup->cancel : $lang->makeup->submit;
                echo html::a(inlink('switchStatus', "id=$makeup->id"), $switchLabel, "class='switch-status btn'");
            }
            if($canEdit) echo html::a(inlink('edit', "id=$makeup->id"), $lang->edit, "class='btn loadInModal'");
            if($canDelete) echo html::a(inlink('delete', "id=$makeup->id"), $lang->delete, "class='btn deleteMakeup'");
        }
    }
    else
    {
        $canReview = $this->makeup->isClickable($makeup, 'review');

        if($canReview)
        {
            echo "<div class='divider'></div>";
            echo html::a(inlink('review', "id=$makeup->id&status=pass"),   $lang->makeup->statusList['pass'],   "class='btn reviewPass'");
            echo html::a(inlink('review', "id=$makeup->id&status=reject"), $lang->makeup->statusList['reject'], "class='btn loadInModal'");
        }
    }
    ?>
  </div>
</div>
<?php include '../../../sys/common/view/footer.modal.html.php';?>
