<table class='table table-form'>
  <tr class='emptyTR'>
    <td class='w-60px'></td>
    <td></td>
    <td class='w-100px'></td>
    <td class='w-120px'></td>
    <td class='w-120px'></td>
    <td class='w-140px'></td>
    <td class='w-60px'></td>
  </tr>
  <tr>
    <th class='w-60px'><?php echo $lang->contract->name;?></th>
    <td colspan='5'><?php echo html::input('name', isset($quotation) ? $quotation->name : '', "class='form-control'");?></td>
    <td></td>
  </tr>
  <?php 
  $i = 1; 
  $newItemsCount = $config->order->itemsCount;
  $productsCount = 0;
  ?>
  <?php if(!empty($orderProducts)):?>
  <?php $productsCount = count($orderProducts);?>
  <?php foreach($orderProducts as $orderProduct):?>
  <tr>
    <?php if($i == 1):?>
    <th id='product_title' rowspan='<?php echo $productsCount < $newItemsCount ? $newItemsCount : $productsCount + 1;?>'><?php echo $lang->order->product;?></th>
    <?php endif;?>
    <td>
      <div class='input-group'>
        <?php $product = zget($products, $orderProduct->product);?>
        <select id='product<?php echo $i;?>' name='product[<?php echo $i;?>]' class='product-batchEdit select-product form-control chosen' data-placeholder='<?php echo $lang->orderProduct->product;?>'>
          <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>
    </td>
    <td><?php echo html::input("unit[$i]", $orderProduct->unit, "id='unit{$i}' class='product-batchEdit form-control' placeholder='{$lang->orderProduct->unit}'");?></td>
    <td><?php echo html::input("price[$i]", $orderProduct->price, "id='price{$i}' class='product-batchEdit form-control product-price' placeholder='{$lang->orderProduct->price}'");?></td>
    <td><?php echo html::input("amount[$i]", $orderProduct->amount, "id='amount{$i}' class='product-batchEdit form-control product-amount' placeholder='{$lang->orderProduct->amount}'");?></td>
    <td><?php echo html::input("money[$i]", $orderProduct->money, "id='money{$i}' class='product-batchEdit form-control product-money' placeholder='{$lang->orderProduct->money}'");?></td>
    <td>
      <?php 
      echo html::a('javascript:;', "<i class='icon-plus'></i>", "class='btn-plus'") . html::a('javascript:;', "<i class='icon-remove'></i>", "class='btn-remove'");
      echo html::hidden("mode[$i]", 'update', "id='mode{$i}'");
      echo html::hidden("id[$i]", $orderProduct->id, "id='id{$i}'");
      ?>
    </td>
  </tr>
  <?php $i ++;?>
  <?php endforeach;?>
  <?php endif;?>
  <?php $count = $productsCount < $newItemsCount ? $newItemsCount - $productsCount : 1;?>
  <?php for($j = 0; $j < $count; $j ++, $i ++):?>
  <tr>
    <?php if($i == 1):?>
    <th id='product_title' rowspan='<?php echo $productsCount < $newItemsCount ? $newItemsCount : $productsCount + 1;?>'><?php echo $lang->order->product;?></th>
    <?php endif;?>
    <td>
      <div class='input-group'>
        <select id='product<?php echo $i;?>' name='product[<?php echo $i;?>]' class='product-batchEdit select-product form-control chosen' data-placeholder='<?php echo $lang->orderProduct->product;?>'>
          <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>
    </td>
    <td><?php echo html::input("unit[$i]", '', "id='unit{$i}' class='product-batchEdit form-control' placeholder='{$lang->orderProduct->unit}'");?></td>
    <td><?php echo html::input("price[$i]", '', "id='price{$i}' class='product-batchEdit form-control product-price' placeholder='{$lang->orderProduct->price}'");?></td>
    <td><?php echo html::input("amount[$i]", '', "id='amount{$i}' class='product-batchEdit form-control product-amount' placeholder='{$lang->orderProduct->amount}'");?></td>
    <td><?php echo html::input("money[$i]", '', "id='money{$i}' class='product-batchEdit form-control product-money' placeholder='{$lang->orderProduct->money}'");?></td>
    <td>
      <?php echo html::a('javascript:;', "<i class='icon-plus'></i>", "class='btn-plus'");?>
      <?php echo html::a('javascript:;', "<i class='icon-remove'></i>", "class='btn-remove'");?>
      <?php echo html::hidden("mode[$i]", 'new', "id='mode{$i}' class='product-batchEdit'");?>
    </td>
  </tr>
  <?php endfor;?>
  <tr>
    <th><?php echo $lang->orderProduct->money;?></th>
    <td><?php echo html::input('totalMoney', isset($quotation) ? $quotation->amount : '', "class='form-control'") . html::hidden('update', '1');?></td>
    <td colspan='5'></td>
  </tr>
  <tr>
    <th></th>
    <td colspan='6' class='form-actions'><?php echo html::submitButton() . html::hidden('prompt', '1');?></td>
  </tr>
</table>
