<?php
/**
 * The edit mobile view file of order module of ZDOO.
 *
 * @copyright   Copyright 2009-2016 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     ZPL (http://zpl.pub/page/zplv12.html)
 * @author      Hao Sun <sunhao@cnezsoft.com>
 * @package     order 
 * @version     $Id: index.html.php 3830 2016-05-18 09:34:17Z liugang $
 * @link        http://www.zdoo.com
 */

if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper::cd();}?>

<div class='heading divider'>
  <div class='title'><i class='icon-pencil muted'></i> <strong><?php echo $lang->order->edit;?></strong></div>
  <nav class='nav'>
    <a class='text-primary' data-display='modal' data-remote='<?php echo $this->createLink('action', 'history', "objectType=order&objectID={$order->id}") ?>' data-placement='bottom'><i class='icon-history'></i>&nbsp;<?php echo $lang->history;?></a>
    <a data-dismiss='display'><i class='icon-remove muted'></i></a>
  </nav>
</div>

<form class='content has-padding' method='post' id='editOrderForm' action='<?php echo $this->createLink('order', 'edit', "orderID=$order->id") ?>' data-form-refresh='#page'>
  <div class='control '>
    <label for='customer'><?php echo $lang->order->customer;?></label>
    <div class='select'>
      <?php echo html::select('customer', $customers, $order->customer);?>
    </div>
  </div>
  <div class='control'>
    <label for='plan'><?php echo $lang->order->plan;?></label>
    <div class='row'>
      <div class='cell-4'>
        <div class='select fluid'>
          <?php echo html::select('currency', $currencyList, $order->currency, "disabled");?>
        </div>
      </div>
      <div class='cell-8'>
        <input type='number' step='0.01' name='plan' id='plan' class='input' value='<?php echo $order->plan;?>'>
      </div>
    </div>
  </div>
  <div class='control'>
    <label for='real'><?php echo $lang->order->real;?></label>
    <?php echo html::input('real', $order->real, "class='input' disabled");?>
  </div>

  <div class='children' class='has-padding gray'>
    <div class='control'><label><?php echo $lang->order->product;?></label></div>
    <?php $key = 1;?>
    <?php foreach($order->orderProducts as $orderProduct):?>
    <div class='row flex-nowrap'>
      <div class='cell-3'>
        <div class='select fluid'>
          <select name="product[<?php echo $key;?>]" id="product<?php echo $key;?>">
            <option></option>
            <?php foreach($products as $product):?>
            <option value='<?php echo $product->id;?>' data-keys='<?php echo $product->pinyin;?>' data-unit='<?php echo $product->unit;?>' <?php if($product->id == $orderProduct->product) echo 'selected';?>><?php echo $product->name;?></option>
            <?php endforeach;?>
          </select>
        </div>
      </div>
      <div class='cell-2'>
        <?php echo html::input("unit[$key]", $orderProduct->unit, "id='unit{$key}' class='input' placeholder='{$lang->orderProduct->unit}'");?>
      </div>
      <div class='cell-2'>
        <?php echo html::input("price[$key]", $orderProduct->price, "id='price{$key}' class='input' placeholder='{$lang->orderProduct->price}'");?>
      </div>
      <div class='cell-2'>
        <?php echo html::input("amount[$key]", $orderProduct->amount, "id='amount{$key}' class='input' placeholder='{$lang->orderProduct->amount}'");?>
      </div>
      <div class='cell-2'>
        <?php echo html::input("money[$key]", $orderProduct->money, "id='money{$key}' class='input' placeholder='{$lang->orderProduct->money}'");?>
      </div>
      <div class='cell-1 flex-none'>
        <a class='btn product-deleter'><i class='icon-trash text-danger'></i></a>
      </div>
    </div>
    <?php $key++;?>
    <?php endforeach;?>
    <a class="btn text-primary btn-add-product"><i class="icon-plus"></i>&nbsp; <?php echo $lang->add . ' ' . $lang->order->product;?></a>
  </div>

  <div class='control hidden'>
    <label for='assignedTo'><?php echo $lang->order->assignedTo;?></label>
    <div class='select'>
      <?php echo html::select('assignedTo', $users, $order->assignedTo, 'disabled');?>
    </div>
  </div>
  <div class='control hidden'>
    <label for='assignedBy'><?php echo $lang->order->assignedBy;?></label>
    <div class='select'>
      <?php echo html::select('assignedBy', $users, $order->assignedBy, 'disabled');?>
    </div>
  </div>
  <div class='control hidden'>
    <label for='assignedDate'><?php echo $lang->order->assignedDate;?></label>
    <?php echo html::input('assignedDate', formatTime($order->assignedDate), "class='input' disabled");?>
  </div>
  <div class='control'>
    <label for='status'><?php echo $lang->order->status;?></label>
    <div class='select'>
      <?php echo html::select('status', $lang->order->statusList, $order->status);?>
    </div>
  </div>
  <div class='control'>
    <label for='nextDate'><?php echo $lang->order->nextDate;?></label>
    <input type='date' value='<?php echo $order->nextDate ?>' class='input'>
  </div>
  <div class='control hidden'>
    <label for='signedBy'><?php echo $lang->order->signedBy;?></label>
    <div class='select'>
      <?php echo html::select('signedBy', $users, $order->signedBy);?>
    </div>
  </div>
  <div class='control hidden'>
    <label for='signedDate'><?php echo $lang->order->signedDate;?></label>
    <?php echo html::input('signedDate', $order->signedDate, "class='input'");?>
  </div>
  <div class='control hidden'>
    <label for='closedBy'><?php echo $lang->order->closedBy;?></label>
    <div class='select'>
      <?php echo html::select('closedBy', $users, $order->closedBy);?>
    </div>
  </div>
  <div class='control hidden'>
    <label for='closedReason'><?php echo $lang->order->closedReason;?></label>
    <div class='select'>
      <?php echo html::select('closedReason', $lang->order->closedReasonList, $order->closedReason);?>
    </div>
  </div>
  <div class='control hidden'>
    <label for='closedDate'><?php echo $lang->order->closedDate;?></label>
    <?php echo html::input('closedDate', $order->closedDate, "class='input'");?>
  </div>
  <div class='control hidden'>
    <label for='activatedBy'><?php echo $lang->order->activatedBy;?></label>
    <div class='select'>
      <?php echo html::select('activatedBy', $users, $order->activatedBy);?>
    </div>
  </div>
  <div class='control hidden'>
    <label for='activatedDate'><?php echo $lang->order->activatedDate;?></label>
    <?php echo html::input('activatedDate', $order->activatedDate, "class='input'");?>
  </div>
  <?php echo html::hidden('referer', $this->server->http_referer);?>
</form>

<div class='template'>
  <div class='row flex-nowrap'>
    <div class='cell-3'>
      <div class='select fluid'>
        <select name="product[KEY]" id="productKEY">
          <option></option>
          <?php foreach($products as $product):?>
          <option value='<?php echo $product->id;?>' data-keys='<?php echo $product->pinyin;?>' data-unit='<?php echo $product->unit;?>'><?php echo $product->name;?></option>
          <?php endforeach;?>
        </select>
      </div>
    </div>
    <div class='cell-2'>
      <?php echo html::input("unit[KEY]", '', "id='unitKEY' class='input' placeholder='{$lang->orderProduct->unit}'");?>
    </div>
    <div class='cell-2'>
      <?php echo html::input("price[KEY]", '', "id='priceKEY' class='input' placeholder='{$lang->orderProduct->price}'");?>
    </div>
    <div class='cell-2'>
      <?php echo html::input("amount[KEY]", '', "id='amountKEY' class='input' placeholder='{$lang->orderProduct->amount}'");?>
    </div>
    <div class='cell-2'>
      <?php echo html::input("money[KEY]", '', "id='moneyKEY' class='input' placeholder='{$lang->orderProduct->money}'");?>
    </div>
    <div class='cell-1 flex-none'>
      <a class='btn product-deleter'><i class='icon-trash text-danger'></i></a>
    </div>
  </div>
</div>

<div class='footer has-padding'>
  <button type='button' data-submit='#editOrderForm' class='btn primary'><?php echo $lang->save ?></button>
</div>

<?php js::set('key', $key);?>
<?php js::execute($pageJS);?>
