<script type="text/javascript">
$(document).ready(function(e) {
     $(".numberinput").forceNumeric();
});
</script>

<div class="modal-body">
<form id="productInfo" action="#" method="post" class="form-horizontal">
<input name="productId" id="productId" type="hidden" value="{$productData->productId}">
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">المنتج الرئيسيى</label>
    <div class="col-lg-4"> <span id="spryselect4">
      <select name="new_cat_id" id="new_cat_id" data-placeholder="اختر" class="select2_customy wdt100" >
        <option>-- اختر المنتج الرئيسي--</option>
            {foreach $categoriesData as $cat}
        <option value="{$cat->productCatId}" {if $productData->productCatId eq $cat->productCatId}selected{/if}>{$cat->productCatName}</option>
         	{/foreach}
      </select>
      <span class="selectRequiredMsg">*</span></span> </div>
  </div>
  <!---------------------------->
  
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">الإسم</label>
    <div class="col-lg-4">
      <input name="new_productName" type="text" id="new_productName" size="50" class=" form-control " required   value="{$productData->productName}" />
    </div>
  </div>
  <!---------------------------->

  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">الباركود</label>
    <div class="col-lg-4">
      <input name="new_parcode" type="text" id="new_parcode"  class=" form-control" size="50"   value="{$productData->parcode}"  />
    </div>
  </div>
  <!---------------------------->
  
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">سعر الشراء</label>
    <div class="col-lg-4">
      <input name="new_productBuyPrice" type="text" id="new_productBuyPrice" class="numberinput form-control" required size="50"  value="{$productData->productBuyPrice}"  />
    </div>
  </div>
  <!---------------------------->
  
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">سعر بيع الجمله</label>
    <div class="col-lg-4">
      <input name="new_productSellAllPrice" type="text" id="new_productSellAllPrice" class="numberinput form-control" value="{$productData->productSellAllPrice}"  onKeyUp="populateSellPrice();" required size="50"   />
    </div>
  </div>
  <!---------------------------->
  
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">سعر بيع الجمله التجزئة</label>
    <div class="col-lg-4">
      <input name="new_productSellHalfPrice" type="text" id="new_productSellHalfPrice" class=" form-control numberinput" required size="50" value="{$productData->productSellHalfPrice}"  />
    </div>
  </div>
  <!---------------------------->
  
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">سعر بيع الوحده</label>
    <div class="col-lg-4">
      <input name="new_productSellUnitPrice" type="text" id="new_productSellUnitPrice" class=" form-control numberinput" required size="50"  value="{$productData->productSellUnitPrice}" />
    </div>
  </div>
  <!---------------------------->
  
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">الكمية</label>
    <div class="col-lg-4">
      <input name="new_productquantity" type="text" id="new_productquantity" class=" form-control numberinput"  required="required"   value="{$productData->productquantity}" size="50"/>
    <input name="storedetailid" id="storedetailid" type="hidden" value="{$productData->storedetailid}" />
    <input name="product_qty_before" id="product_qty_before" type="hidden" value="{$productData->productquantity}" />
    <input name="storeid" id="storeid" type="hidden" value="{$productData->storeid}"/>
    
    </div>
  </div>
  <!---------------------------->
  
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">التاريخ</label>
    <div class="col-lg-4">
      <input name="new_productDate" type="text" id="new_productDate" value="{$productData->productDate}" class=" form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" size="50" required   />
    </div>
  </div>
  <!----------------------------> 
  
  <!--------------------------------  adding units   ----------------------------->
  
  <div id="addUnitsDiv">
    <table id="unitsTable" class="table">
     {assign var=j value=1}
        {foreach $productUnitsData as $pUnit}
      <tr id="unit_row{$j}">
        <td>
          <div class="form-group">
            <label class="col-lg-4 control-label">اسم وحدة القياس</label>
            <div class="col-lg-8">
             <select name="productunit{$j}" id="productunit{$j}" data-placeholder="اختر" class="select2_customy wdt100 chosenproduct"  tabindex="12">
                <option value="-1">اختر وحدة القياس</option>
                      
                            {foreach $unitsData as $unit}
                    
                <option value="{$unit->unitId}" {if $pUnit->unitid eq $unit->unitId}selected{/if}>{$unit->unitName}</option>
                
                            {/foreach}
                  
              </select>
            </div>
          </div>
          <!----------------------------> 
        </td>
        <td>
          <div class="form-group">
            <label class="col-lg-4 control-label">عدد الوحدات</label>
            <div class="col-lg-8">
              <input  name="productnumber{$j}" id="productnumber{$j}" type="text" value="{$pUnit->productnumber}" class="numberinput form-control" />
            </div>
          </div>
          <!----------------------------> 
        </td>
        <td><a id="remove1" onClick="removeUnits({$j});" class="removeUnits">X</a></td>
      </tr>
       {capture assign=j}{$j+1}{/capture}
       {/foreach}
    </table>
    <!--end unitsTable--> 
  </div>
  <input class="addUnits btn btn-primary" onClick="addUnits();" type="button" value="إضافة وحدة قياس"/>
  <input name="unitsItr" id="unitsItr" type="hidden" value="{$unitsItr}" />
  
  <!-------------------------------- end adding units   -------------------------->
  </td>
  <input name="newLinkCurrentId" id="newLinkCurrentId" type="hidden" value="{$itr}" />
  
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-default" id="cancel" onClick="closeProductForm();">إلغاء</button>
    <button type="button" class="btn btn-primary" id="update" onClick="updateProduct();">حفظ</button>
  </div>
</form>
</div>