<?php
/**
 * The detail view file of trip 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      Gang Liu <liugang@cnezsoft.com>
 * @package     trip 
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../../sys/common/view/header.modal.html.php';?>
<table class='table table-bordered'>
  <tr>
    <th class='w-100px'><?php echo $lang->$module->dateRange;?></th>
    <td colspan='3'><?php echo formatTime($trip->begin . ' ' . $trip->start, DT_DATETIME2) . ' ~ ' . formatTime($trip->end . ' ' . $trip->finish, DT_DATETIME2);?></td>
  </tr>
  <?php if($trip->type == 'trip'):?>
  <tr>
    <th><?php echo $lang->$module->placeRange;?></th>
    <td colspan='3'><?php echo $trip->from . ' ~ ' . $trip->to;?></td>
  </tr>
  <?php else:?>
  <tr>
    <th><?php echo $lang->$module->to;?></th>
    <td colspan='3'><?php echo $trip->to;?></td>
  </tr>
  <?php endif;?>
  <tr>
    <th class='text-middle'><?php echo $lang->$module->customer;?></th>
    <td colspan='3'>
      <?php foreach(explode(',', $trip->customers) as $customer) echo "<div>" . zget($customers, $customer) . "</div>";?>
    </td>
  </tr>
  <tr>
    <th><?php echo $lang->$module->desc;?></th>
    <td colspan='3'><?php echo $trip->desc;?></td>
  </tr> 
  <tr>
    <th><?php echo $lang->$module->status;?></th>
    <td colspan='3' class="trip-<?php echo $trip->status;?>"><?php echo zget($lang->trip->statusList, $trip->status);?></td>
  </tr> 
  <?php if($trip->status === 'reject'):?>
  <tr>
    <th><?php echo $lang->trip->rejectReason;?></th>
    <td colspan='3'><?php echo $trip->rejectReason;?></td>
  </tr> 
  <?php endif;?>
  <tr>
    <th><?php echo $lang->trip->createdBy;?></th>
    <td class='w-220px'><?php echo zget($users, $trip->createdBy);?></td>
    <th class='w-100px'><?php echo $lang->trip->reviewedBy;?></th>
    <td id='reviewedBy'><?php echo zget($users, $trip->reviewedBy);?></td>
  </tr>
  <tr>
    <th><?php echo $lang->trip->createdDate;?></th>
    <td><?php echo formatTime($trip->createdDate, DT_DATETIME1);?></td>
    <th><?php echo $lang->trip->reviewedDate;?></th>
    <td><?php echo formatTime($trip->reviewedDate, DT_DATETIME1);?></td>
  </tr>
</table>
<?php echo $this->fetch('action', 'history', "objectType=$module&objectID=$trip->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->trip->isClickable($trip, 'edit');
        $canDelete = $this->trip->isClickable($trip, 'delete');
        $canSwitch = $this->trip->isClickable($trip, 'switchStatus');

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

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