<?php
/**
 * The edit view file of order 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     order
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../common/view/header.html.php'; ?>
<?php include '../../common/view/datepicker.html.php';?>
<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="text"><?php echo $lang->order->edit . $lang->minus . $order->title;?></span>
    </div>
  </div>
</div>
<form method='post' id='ajaxForm' class='main-row'>
  <div class='main-col col-8'>
    <div class='panel panel-block table-row' id='orderDetailPanel'>
      <?php
      $payed = $order->status == 'payed';
      $customerLink = html::a($this->createLink('customer', 'view', "customerID={$customer->id}"), $customer->name);
      $productLink = '';
      foreach($order->products as $product)
      {
          $productLink .= html::a($this->createLink('product', 'view', "productID={$product->id}"), $product->name);
      }

      if($contract) $contractLink = html::a($this->createLink('contract', 'view', "contractID={$contract->id}"), $contract->name);
      ?>
      <div class='panel-heading table-col col-4 no-padding-right text-middle'>
        <div class='table-row table-auto'>
          <div class='table-col col-10 text-lg strong title'>
            <div class='table-row space-sm'><?php echo $customerLink;?></div>
            <div class='table-row space-sm'><?php echo $productLink;?></div>
            <div class='table-row'>
            <?php if(!empty($lang->customer->levelNameList[$customer->level])):?>
            <span class='label label-pale label-lg'><span class='text-yellow'><?php echo $lang->customer->levelNameList[$customer->level];?></span></span>
            <?php endif;?>
            <span class='label label-pale label-lg'><?php echo $lang->order->statusList[$order->status];?></span>
            </div>
          </div>
          <div class='table-col col-2 text-lg text-right has-padding-sm-h no-padding-right'>
           <?php echo $lang->order->buy;?>
          </div>
          <div class="table-col divider-right has-padding-h"></div>
        </div>
      </div>
      <div class='panel-body table-col has-padding-lg no-padding-left col-8'>
        <div class='table-row width-auto'>
          <?php if($contract):?>
          <div class='table-row'>
            <div class='table-col has-padding-lg-h has-padding-sm-v'>
              <span class='text-gray space-sm has-padding-lg-h no-padding-left'><?php echo $lang->order->infoContract;?></span>
              <span class='text-lg'><?php echo $contractLink;?></span>
            </div>
          </div>
          <?php endif;?>
          <div class='table-row'>
            <div class='table-col col-6 has-padding-lg-h has-padding-sm-v'>
              <span class='text-gray space-sm has-padding-lg-h no-padding-left'><?php echo $lang->order->infoPlanAmount;?></span>
              <span class='text-lg'><?php echo zget($currencySign, $order->currency, '');?><strong><?php echo formatMoney($order->plan);?></strong></span>
            </div>
            <div class='table-col col-6 has-padding-lg-h has-padding-sm-v'>
              <span class='text-gray space-sm has-padding-lg-h no-padding-left'><?php echo $lang->order->infoRealAmount;?></span>
              <span class='text-lg'><?php echo zget($currencySign, $order->currency, '');?><strong class='text-red'><?php echo formatMoney($order->real);?></strong></span>
            </div>
          </div>
          <?php if(formatTime($order->contactedDate) || formatTime($order->nextDate)):?>
          <div class='table-row'>
            <?php if(formatTime($order->contactedDate)):?>
            <div class='table-col col-6 has-padding-lg-h has-padding-sm-v'>
              <span class='text-gray space-sm has-padding-lg-h no-padding-left'><?php echo $lang->order->infoContacted;?></span>
              <span><?php echo formatTime($order->contactedDate, DT_DATE1);?></span>
            </div>
            <?php endif;?>
            <?php if(formatTime($order->nextDate)):?>
            <div class='table-col col-6 has-padding-lg-h has-padding-sm-v'>
              <span class='text-gray space-sm has-padding-lg-h no-padding-left'><?php echo $lang->order->infoNextDate;?></span>
              <span><?php echo formatTime($order->nextDate, DT_DATE1);?></span>
            </div>
            <?php endif;?>
          </div>
          <?php endif;?>
        </div>
      </div>
    </div>
    <?php echo $this->fetch('action', 'history', "objectType=order&objectID={$order->id}");?>
    <div class='main-actions'>
      <?php echo html::submitButton() . html::backButton();?>
      <?php echo html::hidden('referer', $this->server->http_referer);?>
    </div>
  </div>
  <div class='side-col col-4'>
    <div class='panel'>
      <div class='panel-heading'><strong><i class="icon icon-list-info"></i> <?php echo $lang->order->basicInfo;?></strong></div>
      <div class='panel-body'>
        <table class='table table-form'>
          <tbody>
            <tr>
              <th class='w-80px'><?php echo $lang->order->customer;?></th>
              <td><?php echo html::select('customer', $customers, $order->customer, "class='form-control chosen' data-no_results_text='" . $lang->searchMore . "'");?></td>
            </tr>
            <tr>
              <th><?php echo $lang->order->product;?></th>
              <td><?php echo html::select('product[]', $products, $order->product, "class='form-control chosen' multiple");?></td>
            </tr>
            <tr>
              <th><?php echo $lang->order->currency;?></th>
              <td><?php echo html::select('currency', $currencyList, $order->currency, "class='form-control' disabled");?></td>
            </tr>
            <tr>
              <th><?php echo $lang->order->plan;?></th>
              <td><?php echo html::input('plan', $order->plan, "class='form-control'");?></td>
            </tr>
            <tr>
              <th><?php echo $lang->order->real;?></th>
              <td><?php echo html::input('real', $order->real, "class='form-control' disabled");?></td>
            </tr>
            <tr>
              <th><?php echo $lang->order->assignedTo;?></th>
              <td><?php echo html::select('assignedTo', $users, $order->assignedTo, "class='form-control'");?></td>
            </tr>
            <tr>
              <th><?php echo $lang->order->assignedBy;?></th>
              <td><?php echo html::select('assignedBy', $users, $order->assignedBy, "class='form-control'");?></td>
            </tr>
            <tr>
              <th><?php echo $lang->order->assignedDate;?></th>
              <td><?php echo html::input('assignedDate', formatTime($order->assignedDate), "class='form-control form-datetime'");?></td>
            </tr>
            <tr>
              <th><?php echo $lang->order->status;?></th>
              <td><?php echo html::select('status', $lang->order->statusList, $order->status, "class='form-control'");?></td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <div class='panel'>
      <div class='panel-heading'><strong><i class='icon icon-file-text-alt'></i> <?php echo $lang->order->lifetime;?></strong></div>
      <div class='panel-body'>
        <table class='table table-form'>
          <tr>
            <th class='w-80px'><?php echo $lang->order->createdBy;?></th>
            <td><?php echo zget($users, $order->createdBy);?></td>
          </tr>
          <tr>
            <th><?php echo $lang->order->contactedDate;?></th>
            <td><?php echo formatTime($order->contactedDate, DT_DATETIME1);?></td>
          </tr>
          <tr>
            <th><?php echo $lang->order->nextDate;?></th>
            <td><?php echo html::input('nextDate', formatTime($order->nextDate), "class='form-control form-date'");?></td>
          </tr>
          <tr>
            <th><?php echo $lang->order->signedBy;?></th>
            <td><?php echo html::select('signedBy', $users, $order->signedBy, "class='form-control'");?></td>
          </tr>
          <tr>
            <th><?php echo $lang->order->signedDate;?></th>
            <td><?php echo html::input('signedDate', formatTime($order->signedDate), "class='form-control form-date'");?></td>
          </tr>
          <tr>
            <th><?php echo $lang->order->closedBy;?></th>
            <td><?php echo html::select('closedBy', $users, $order->closedBy, "class='form-control'");?></td>
          </tr>
          <tr>
            <th><?php echo $lang->order->closedReason;?></th>
            <td><?php echo html::select('closedReason', $lang->order->closedReasonList, $order->closedReason, "class='form-control'");?></td>
          </tr>
          <tr>
            <th><?php echo $lang->order->closedDate;?></th>
            <td><?php echo html::input('closedDate', formatTime($order->closedDate), "class='form-control form-datetime'");?></td>
          </tr>
          <tr>
            <th><?php echo $lang->order->activatedBy;?></th>
            <td><?php echo html::select('activatedBy', $users, $order->activatedBy, "class='form-control'");?></td>
          </tr>
          <tr>
            <th><?php echo $lang->order->activatedDate;?></th>
            <td><?php echo html::input('activatedDate', formatTime($order->activatedDate), "class='form-control form-datetime'");?></td>
          </tr>
        </table>
      </div>
    </div>
  </div>
</form>
<script>
<?php helper::import('../js/searchcustomer.js');?>
</script>
<?php include '../../common/view/footer.html.php';?>
