<?php
/**
 * The create view file of contract 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      Yidong Wang <yidong@cnezsoft.com>
 * @package     contract
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../../sys/common/view/editor.html.php';?>
<?php js::set('customer', isset($customer) ? $customer : 0);?>
<?php js::set('order', isset($orderID) ? $orderID : 0);?>
<?php js::set('label', $lang->$moduleType->order);?>
<?php js::set('relation', $config->contract->customerType[$type]);?>
<div class='panel'>
  <div class='panel-heading'>
    <strong><?php echo $lang->$moduleType->create;?></strong>
  </div>
  <div class='panel-body'>
    <form method='post' id='ajaxForm'>
      <table class='table table-form w-p70'>
        <?php if($moduleType == 'contract'):?>
        <tr>
          <th class='w-80px'><?php echo $lang->contract->signType;?></th>
          <td class='w-400px'><?php echo html::select('signType', $lang->contract->signTypeList, '', "class='form-control'");?></select></td>
        </tr>
        <?php endif;?>
        <tr>
          <th><?php echo $lang->$moduleType->customer;?></th>
          <td><?php echo html::select('customer', $customers, isset($customer) ? $customer : '', "class='form-control chosen' data-no_results_text='" . $lang->searchMore . "'");?></td>
        </tr>
        <?php if($moduleType == 'contract'):?>
        <?php if(isset($currentOrder)):?>
        <tr>
          <th class='orderTH'><?php echo $lang->$moduleType->order;?></th>
          <td id='orderTD'>
            <div class='form-group'>
              <span class='col-sm-7'>
                <select name='order[]' class='select-order form-control'>
                  <option value=''></option>
                  <?php foreach($orders as $order):?>
                  <?php $selected = $orderID == $order->id ? 'selected' : ''; ?>
                  <option value="<?php echo $order->id;?>" <?php echo $selected;?>  data-real="<?php echo $order->plan;?>" data-currency="<?php echo $order->currency?>"><?php echo $order->title;?></option>
                  <?php endforeach;?>
                </select>
              </span>
              <span class='col-sm-5'>
                <div class='input-group'>
                  <span class='input-group-addon order-currency'><?php echo zget($currencySign, $currentOrder->currency, '');?></span>
                  <?php echo html::input('real[]', $currentOrder->plan, "class='order-real form-control' placeholder='{$this->lang->contract->placeholder->real}'");?>
                  <span class='input-group-btn'><?php echo html::a('javascript:;', "<i class='icon-plus'></i>", "class='plus btn'");?></span>
                  <span class='input-group-btn'><?php echo html::a('javascript:;', "<i class='icon-remove'></i>", "class='minus btn'");?></span>
                </div>
              </span>
            </div>
          </td>
        </tr>
        <?php endif;?>
        <tr id='orderTR' class='hide'>
          <th class='orderTH'><?php echo $lang->$moduleType->order;?></th>
          <td id='orderTD'></td>
        </tr>
        <tr class='hide' id='tmpData'><td></td></tr>
        <?php endif;?>
        <tr>
          <th class='w-80px'><?php echo $lang->$moduleType->name;?></th>
          <td class='w-p40'><?php echo html::input('name', '', "class='form-control'");?></td><td></td>
        </tr>
        <tr>
          <th class='w-80px'><?php echo $lang->$moduleType->code;?></th>
          <td class='w-p40'><?php echo html::input('code', '', "class='form-control'");?></td><td></td>
        </tr>
        <tr>
          <th><?php echo $lang->$moduleType->amount;?></th>
          <td>
            <div class='row'>
              <div class='col-sm-3'><?php echo html::select('currency', $currencyList, isset($currentOrder) ? $currentOrder->currency : '', "class='form-control'");?></div>
              <div class='col-sm-9'><?php echo html::input('amount', isset($currentOrder) ? $currentOrder->plan : '', "class='form-control'");?></div>
            </div>
          </td>
        </tr>
        <tr>
          <th><?php echo $lang->$moduleType->contact;?></th>
          <td class='contactTD'><select name='contact' id='contact' class='form-control'></select></td>
        </tr>
        <?php if($moduleType == 'contract'):?>
        <tr>
          <th><?php echo $lang->$moduleType->address;?></th>
          <td>
            <div class='input-group'>
              <?php echo html::select('address', '', '', "class='form-control chosen'");?>
              <?php echo html::input('newAddress', '', "class='form-control' style='display: none'");?>
              <span class='input-group-addon'>
                <label class='checkbox-inline'>
                  <input type='checkbox' name='createAddress' id='createAddress' value='1' /> <?php echo $lang->$moduleType->createAddress;?>
                </label>
              </span>
            </div>
          </td>
        </tr>
        <?php endif;?>
        <tr>
          <th><?php echo $lang->$moduleType->signedBy;?></th>
          <td><?php echo html::select('signedBy', $users, '', "class='form-control chosen'");?></td>
        </tr>
        <tr>
          <th><?php echo $lang->$moduleType->signedDate;?></th>
          <td><?php echo html::input('signedDate', '', "class='form-control form-date'");?></td>
        </tr>
        <tr>
          <th><?php echo $lang->$moduleType->dateRange;?></th>
          <td>
          <div class="input-group">
            <?php echo html::input('begin', '', "class='form-control form-date' placeholder='{$lang->$moduleType->begin}'");?>
            <span class='input-group-addon'><?php echo $lang->minus;?></span>
            <?php echo html::input('end', '', "class='form-control form-date' placeholder='{$lang->$moduleType->end}'");?></td>
          </div>
          </td>
        </tr>
        <?php if($moduleType == 'contract'):?>
        <tr>
          <th><?php echo $lang->$moduleType->handlers;?></th>
          <td><?php echo html::select('handlers[]', $users, $this->app->user->account, "class='form-control chosen' multiple");?></td>
        </tr>
        <?php endif;?>
        <tr>
          <th><?php echo $lang->$moduleType->items;?></th>
          <td colspan='2'><?php echo html::textarea('items', '',"rows='5' class='form-control'");?></td>
        </tr>
        <?php echo $this->printExtendFields('', 'table');?>
        <?php if(commonModel::hasPriv('file', 'upload')):?>
        <tr>
          <th><?php echo $lang->$moduleType->uploadFile;?></th>
          <td colspan='2'><?php echo $this->fetch('file', 'buildForm');?></td>
        </tr>
        <?php endif;?>
        <tr>
          <th></th>
          <td class='form-actions'><?php echo html::submitButton() . html::backButton();?></td>
        </tr>
      </table>
    </form>
  </div>
</div>
<table class='hide'><tr class='orderInfo'><td></td></tr></table>
<?php js::set('currencySign', array('' => '') + $currencySign);?>
<?php include '../../common/view/footer.html.php';?>
