<?php
/**
 * The detail view file of view module of ZDOO.
 *
 * @copyright   Copyright 2009-2016 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     商业软件，非开源软件
 * @author      Gang Liu <liugang@cnezsoft.com>
 * @package     view 
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include $app->appRoot . 'common/view/header.html.php';?>
<?php $method = $receivable->type == 'receivable' ? 'receive' : 'pay';?>
<?php $label  = $receivable->type == 'receivable' ? $lang->fund->receive : $lang->fund->pay;?>
<div id='mainTitle' class='clearfix'>
  <div class='btn-toolbar pull-left'>
    <?php if(!isonlybody()):?>
    <?php echo html::a('javascript:history.go(-1);', '<i class="icon icon-back icon-sm"></i> ' . $lang->goback, "class='btn btn-back'");?>
    <div class="divider"></div>
    <?php endif;?>
    <div class="page-title">
      <span class="label label-id"><?php echo $receivable->id;?></span>
      <span class="text"><?php echo $label . $lang->fund->view;?></span>
    </div>
  </div>
</div>
<div class='main-row'>
  <div class='main-col col-8'>
    <div class='panel panel-block'>
      <div class='panel-heading'>
        <strong><?php echo $lang->fund->desc;?></strong>
      </div>
      <div class='panel-body'>
        <p><?php echo $receivable->desc;?></p>
      </div>
    </div>
    <?php echo $this->fetch('action', 'history', "objectType=$receivable->type&objectID=$receivable->id");?>
    <div class='main-actions'>
      <div class='btn-toolbar'>
        <?php echo html::backButton();?>
        <div class='divider'></div>
        <?php 
        if($receivable->deserved > $receivable->actual)
        {
            commonModel::printLink($receivable->type, $method,  "receivableID=$receivable->id", $label, "class='btn btn-default' data-toggle='modal'"); 
        }
        commonModel::printLink($receivable->type, 'edit', "receivableID=$receivable->id", $lang->edit, "class='btn btn-default' data-toggle='modal'");
        commonModel::printLink($receivable->type, 'delete', "receivableID=$receivable->id", $lang->delete, "class='btn btn-default deleter'");
        ?>
      </div>
    </div>
  </div>
  <div class='side-col col-4'>
    <div class='panel panel-block'>
      <div class='panel-heading'>
        <strong><?php echo $lang->fund->basicInfo;?></strong>
      </div>
      <div class='panel-body'>
        <table class='table table-data'>
          <tr>
            <th class='w-80px'><?php echo $lang->fund->trader;?></th>
            <td>
              <?php 
              if(!empty($customer->name))
              {
                  if(!commonModel::printLink('crm.customer', 'view', "customerID=$receivable->trader", $customer->name)) echo $customer->name;
              }
              else
              {
                  echo $receivable->trader ? $receivable->trader : '';
              }
              ?>
            </td>
          </tr>
          <tr>
            <th><?php echo $lang->fund->origin;?></th>
            <td><?php echo zget($lang->fund->originList, $receivable->origin);?></td>
          </tr>
          <tr>
            <th><?php echo $lang->fund->contract;?></th>
            <td>
              <?php 
              if(!empty($contract->name)) 
              {
                  commonModel::printLink('crm.contract', 'view', "contractID=$receivable->contract", $contract->name);
              }
              else
              {
                  echo $receivable->contract ? $receivable : '';
              }
              ?>
            </td>
          </tr>
          <tr>
            <th><?php echo $lang->fund->order;?></th>
            <td>
              <?php 
              if(!empty($order->orderNo))
              {
                  commonModel::printLink("psi.sale", 'detail', "orderID=$receivable->order", $order->orderNo);
              }
              else
              {
                  echo $receivable->order ? $receivable->order : '';
              }
              ?>
            </td>
          </tr>
          <tr>
            <th><?php echo $lang->fund->batch;?></th>
            <td>
              <?php 
              if(!empty($batch->batchNo))
              {
                  commonModel::printLink('psi.batch', 'detail', "batchID=$receivable->batch", $batch->batchNo, "class='notOpenEntry' data-toggle='modal'");
              }
              else
              {
                  echo $receivable->batch ? $receivable->batch : '';
              }
              ?>
            </td>
          </tr>
          <tr>
            <th><?php echo $lang->fund->deserved;?></th>
            <td><?php echo $receivable->deserved;?></td>
          </tr>
          <tr>
            <th><?php echo $lang->fund->actual;?></th>
            <td><?php echo $receivable->actual;?></td>
          </tr>
          <tr>
            <th><?php echo $lang->fund->balance;?></th>
            <td><?php echo $receivable->balance;?></td>
          </tr>
          <tr>
            <th><?php echo $lang->fund->createdBy;?></th>
            <td><?php echo zget($users, $receivable->createdBy, '');?></td>
          </tr>
          <tr>
            <th><?php echo $lang->fund->createdDate;?></th>
            <td><?php echo formatTime($receivable->createdDate, DT_DATE1);?></td>
          </tr>
          <tr>
            <th><?php echo $lang->fund->editedBy;?></th>
            <td><?php echo zget($users, $receivable->editedBy, '');?></td>
          </tr>
          <tr>
            <th><?php echo $lang->fund->editedDate;?></th>
            <td><?php echo formatTime($receivable->editedDate, DT_DATE1);?></td>
          </tr>
        </table>
      </div>
    </div>
  </div>
</div>
<?php include $app->appRoot . 'common/view/footer.html.php';?>
