<?php
/**
 * The create 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();}

$products = $this->loadModel('product')->getList();
$products = $this->product->formatProductNameInList($products);
?>

<style>
#createOrderForm .create-customer-fields {display: none}

#createOrderForm.create-customer .create-customer-fields {display: block;}
#createOrderForm.create-customer .row.create-customer-fields {display: flex;}
#createOrderForm.create-customer .select-customer-fields {display: none;}

#createOrderForm.create-customer .create-customer-field.control,
#createOrderForm.create-customer .create-customer-fields.row {background: #ebf2f9; padding: 0 .5rem .5rem; margin-right: -.5rem; margin-left: -.5rem;}
#createOrderForm.create-customer .create-customer-field.control {margin-bottom: 0; padding-top: .5rem}
#createOrderForm.create-customer .create-customer-fields.row {margin-right: -.75rem; margin-left: -.75rem;}
</style>

<div class='heading divider'>
  <div class='title'><i class='icon-plus muted'></i> <strong><?php echo $lang->order->create; ?></strong></div>
  <nav class='nav'><a data-dismiss='display'><i class='icon icon-remove muted'></i></a></nav>
</div>

<form class='content has-padding' method='post' id='createOrderForm' action='<?php echo $this->createLink('order', 'create') ?>' data-form-refresh='#page'>
  <div class='control create-customer-field'>
    <div class='checkbox pull-right'>
      <input type='checkbox' name='createCustomer' id='createCustomer' value='1'>
      <label for='createCustomer' class='text-link'><?php echo $lang->order->createCustomer;?></label>
    </div>
    <label for='customer'><?php echo $lang->order->customer;?></label>
    <div class='select select-customer-fields'>
      <?php echo html::select('customer', $customers);?>
    </div>
    <?php echo html::input('name', '', "class='input create-customer-fields'");?>
  </div>

  <div class='row create-customer-fields'>
    <div class='cell-6'>
      <div class='control'>
        <label for='contact'><?php echo $lang->customer->contact;?></label>
        <?php echo html::input('contact', '', "class='input' placeholder='{$lang->required}'");?>
      </div>
    </div>
    <div class='cell-6'>
      <div class='control'>
        <label for='phone'><?php echo $lang->customer->phone;?></label>
        <?php echo html::input('phone', '', "class='input'");?>
      </div>
    </div>
    <div class='cell-6'>
      <div class='control'>
        <label for='email'><?php echo $lang->customer->email;?></label>
        <input type="email" id='email' name='email' class='input'>
      </div>
    </div>
    <div class='cell-6'>
      <div class='control'>
        <label for='qq'><?php echo $lang->customer->qq;?></label>
        <?php echo html::input('qq', '', "class='input'");?>
      </div>
    </div>
    <div class='cell-6'>
      <div class='control'>
        <label for='weixin'><?php echo $lang->customer->weixin;?></label>
        <?php echo html::input('weixin', '', "class='input'");?>
      </div>
    </div>
  </div>

  <div class='children' class='has-padding gray'>
    <div class='control'><label><?php echo $lang->order->product;?></label></div>
    <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'>
    <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);?>
        </div>
      </div>
      <div class='cell-8'>
        <input type='number' step='0.01' name='plan' id='plan' class='input'>
      </div>
    </div>
  </div>
</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='#createOrderForm' class='btn primary'><?php echo $lang->save ?></button>
</div>

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