<script>

//alert(666);
//alert($("#parcode1").val());

    checkbarcodewithid($("#parcode1").val(), 1);</script>



<form  action="" class="form-horizontal myform" method="post" id="productEditForm" onsubmit="submitEditForm(event, this);">
    <input name="productId" type="hidden" value="{$productsData->productId}"  id="productId"/>
    <div class="form-group">
        <label class="col-lg-2 control-label">تصنيف المنتج</label>
        <div class="col-lg-6"> <span id="spryselect1">
                <select name="productCatId" name="productCatId"  class="select2_custom wdt100">
                    <option value="-1">اختر المنتج الرئيسي</option>

                    {foreach from=$alldata key=k item=v }

                    <option value="{$k}" {if $productsData->productCatId eq $k}selected{/if}>{$v}</option>

                    {/foreach}

                </select>
                <span class="selectInvalidMsg">اختر تصنيف</span><span class="selectRequiredMsg">اختر تصنيف</span></span> </div>
    </div>

    <!--==============================-->
    <div id="productsTable">
        <div class="form-group">
            <label class="col-lg-2 control-label">الإسم</label>
            <div class="col-lg-6"> <span id="sprytextfield7">
                    <input name="productName1" type="text" id="productName1" class="form-control" size="9" value="{$productsData->productName}" onchange="checkProductNameForEdit(this.value, $('#productId').val(), $('#productCatId').val());"/>
                    <span class="textfieldRequiredMsg">*</span></span> </div>
        </div>

        <div class="form-group {if $Programsettingdata->isCaf != 1 && $Programsettingdata->isRestaurent != 1} hidden {/if}">
            <label class="col-lg-2 control-label">فى المنيو </label>
            <div class="col-lg-4">
                <div class="radio-inline">
                    <label>
                        <input value="0"  class="radioR" name="inMenu1"  {if {$productsData->inMenu} eq 0} checked="checked"  {/if} type="radio" />

                        نعم </label>
                </div>
                <div class="radio-inline">
                    <label>
                        <input value="1"  class="noradioR" name="inMenu1" {if {$productsData->inMenu} eq 1} checked="checked"  {/if}    type="radio" />
                        لا </label>
                </div>

            </div>
        </div>

        <div class="form-group check_tr_production {if {$Programsettingdata->production} eq 1} hidden {/if}">
            <label class="col-lg-2 control-label">تصنيع </label>
            <div class="col-lg-4">
                <div class="radio-inline">
                    <label>
                        <input value="1"  class="radioR" name="manufacture"  {if {$productsData->type} eq 1} checked="checked"  {/if} type="radio" />

                        نعم </label>
                </div>
                <div class="radio-inline">
                    <label>
                        <input value="0"  class="noradioR" name="manufacture" {if {$productsData->type} eq 0} checked="checked"  {/if}    type="radio" />
                        لا </label>
                </div>

            </div>
        </div>

        <div class="form-group  {if {$Programsettingdata->service} eq 1} hidden {/if}">
            <label class="col-lg-2 control-label">خدمة </label>
            <div class="col-lg-4">
                <div class="radio-inline">
                    <label>
                        <input value="1"  class="radioR isserviceedit" name="isservice1"  {if {$productsData->isService} eq 1} checked="checked"  {/if} type="radio" />

                        نعم </label>
                </div>
                <div class="radio-inline">
                    <label>
                        <input value="0"  class="noradioR isserviceedit" name="isservice1" {if {$productsData->isService} eq 0} checked="checked"  {/if}    type="radio" />
                        لا </label>
                </div>

            </div>
        </div>
        <!--==============================-->
        <div class="form-group {if {$Programsettingdata->parcode} eq 1} hidden {/if}" >
            <label class="col-lg-2 control-label">الباركود</label>
            <div class="col-lg-6">
                <input name="parcode1" type="text"   id="parcode1" size="9"  required  class="form-control" value="{$productsData->parcode}"  onkeyup="checkbarcodewithid(this.value, 1);" />
            </div>
        </div>
        <!--==============================-->
        <div class="form-group" {if {$Programsettingdata->expiredate} eq 1} hidden {/if} >
            <label class="col-lg-2 control-label"> مدة الصلاحية</label>
            <div class="col-lg-6"><span id="sprytextfield8">
                    <input name="expireDate1"  type="text" id="expireDate1" style="width: 92%;" class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"  value="{$productsData->expireDate}" />
                    <span style="float: left;margin-top: -27px; color: white;font-size: 15px;font-weight: bold;">يوم</span>
                    <span class="textfieldRequiredMsg"> ادخل رقم</span></span></div>
        </div>
        <!--==============================-->
        <div class="form-group">
            <label class="col-lg-2 control-label">سعر الشراء</label>
            <div class="col-lg-6"> <span id="sprytextfield1">
                    {if $productsData->isService eq 1}
                    <input name="productBuyPrice1"  type="text" id="productBuyPrice1" class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"  value="" disabled />
                    {else}
                    <input name="productBuyPrice1"  type="text" id="productBuyPrice1" class="form-control wd50 aw_m aw_mt aw_pp numberclic buy_price enteraction numberinput"  data-id="1" value="{$productsData->productBuyPrice}" />
                    {/if}
                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">أدخل رقم</span></span> </div>
        </div>
        <div class="form-group">
            <label class="col-lg-2 control-label">سعر الشراء الفعلى</label>
            <div class="col-lg-6"> <span id="sprytextfield1">
                    {if $productsData->isService eq 1}
                    <input style="width: 50%;float: left;" name="productbuypricereal1" value="{$productsData->productbuypricereal}" type="text" id="buypricereal1"  data-type="pricereal" disabled  class="form-control prices  aw_m aw_mt aw_pp numberclic enteraction  numberinput positivefloat buy_pricereal1" data-id="1" width="10"/></span>
                <input style="  width: 50%;"  name="buypricereal_precentage1"  value="{$productsData->buypricereal_precentage}" type="text" id="productBuyPrice1" data-type="pricereal" disabled  class="form-control precentages  aw_m aw_mt aw_pp numberclic enteraction  numberinput positivefloat buypricereal_precentage1" data-id="1" width="10" />

                <!--<input name="productbuypricereal1"  type="text" id="productBuyPrice1" class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"  value="" disabled />-->
                {else}
                <!--<input name="productbuypricereal1"  type="text" id="productBuyPrice1" class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"  value="{$productsData->productbuypricereal}" />-->
                <input style="width: 50%;float: left;" name="productbuypricereal1" value="{$productsData->productbuypricereal}" type="text" id="buypricereal1"  data-type="pricereal"  class="form-control prices  aw_m aw_mt aw_pp numberclic enteraction  numberinput positivefloat buy_pricereal1" data-id="1" width="10"/></span>
                <input style="  width: 50%;"  name="buypricereal_precentage1"  value="{$productsData->buypricereal_precentage}" type="text" id="productBuyPrice1" data-type="pricereal"  class="form-control precentages  aw_m aw_mt aw_pp numberclic enteraction  numberinput positivefloat buypricereal_precentage1" data-id="1" width="10" />

                {/if}
                <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">أدخل رقم</span></span> </div>
        </div>
        <!--==============================-->

        <div class="form-group">
            <label class="col-lg-2 control-label">سعر الجملة</label>
            <div class="col-lg-6"> <span id="sprytextfield2">
                    <!--<input name="productSellAllPrice1"   type="text" id="productSellAllPrice1" onkeyup="populateSellPrice(1);" class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput" value="{$productsData->productSellAllPrice}"  />-->
                    <input style="width: 50%;float: left;" name="productSellAllPrice1" type="text" id="productSellAllPrice" data-type="buytotal"  class="form-control prices aw_m aw_mt aw_pp numberclic positivefloat buy_total1 enteraction numberinput" value="{$productsData->productSellAllPrice}" data-id="1" width="10"/>
                    <input style="  width: 50%;"  name="buytotal_precentage1" type="text"  value="{$productsData->buytotal_precentage}" id="productBuyPrice1"   data-type="buytotal" class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages numberinput positivefloat buytotal_precentage1" data-id="1" width="10"/>

                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">أدخل رقم</span></span> </div>
        </div>
        <!--==============================-->

        <div class="form-group">
            <label class="col-lg-2 control-label">سعر نصف جملة</label>
            <div class="col-lg-6"> <span id="sprytextfield3">
                    <!--<input name="productSellHalfPrice1"   type="text" id="productSellHalfPrice1"  class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"  value="{$productsData->productSellHalfPrice}" />-->
                    <input  style="width: 50%;float: left;"  name="productSellHalfPrice1" type="text" data-type="buyhalf" id="productSellHalfPrice" value="{$productsData->productSellHalfPrice}"   class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat buy_hafe1" data-id="1" width="10"/>
                    <input style="  width: 50%;"  name="buyhalf_precentage1" type="text" id="productBuyPrice1"  value="{$productsData->buyhalf_precentage}"   data-type="buyhalf" class="form-control  aw_m aw_mt aw_pp numberclic enteraction  precentages numberinput positivefloat buyhafe_precentage1" data-id="1" width="10"/>
                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">أدخل رقم</span></span> </div>
        </div>
        <!--==============================-->

        <div class="form-group">
            <label class="col-lg-2 control-label">سعر التجزئة</label>
            <div class="col-lg-6"> <span id="sprytextfield4">
                    <!--<input name="productSellUnitPrice1"  type="text" id="productSellUnitPrice1"  class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"   value="{$productsData->productSellUnitPrice}"/>-->
                    <input  style="width: 50%;float: left;" name="productSellUnitPrice1" type="text" data-type="buypart"  id="productSellUnitPrice"  class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat buy_part1"   value="{$productsData->productSellUnitPrice}" data-id="1"  width="20"/>
                    <input style="  width: 50%;"  name="buypart_precentage1" type="text" id="productBuyPrice1" data-type="buypart"   value="{$productsData->buypart_precentage}"    class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages numberinput positivefloat buypart_precentage1" data-id="1" width="10"/>

                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">أدخل رقم</span></span> </div>
        </div>
        <!--==============================-->

        <div class="form-group">
            <label class="col-lg-2 control-label">الكمية</label>
            <div class="col-lg-6"> <span id="sprytextfield5">
                    {if $productsData->isService eq 1}
                    <input name="productquantity1" readonly="readonly"  type="text" id="productquantity1" class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput" value="" disabled/>
                    {else}
                    <input name="productquantity1" readonly="readonly"  type="text" id="productquantity1" class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput" value="{$productsData->sumProductQuantity}"/>
                    {/if}
                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">أدخل رقم</span></span> </div>
        </div>
        <!--==============================-->

        <div class="form-group {if {$Programsettingdata->date} eq 1} hidden {/if}" >
            <label class="col-lg-2 control-label">التاريخ</label>
            <div class="col-lg-6">
                <input name="productDate1" class="form-control awdatepicker" autocomplete="off"  data-date-format="yyyy-mm-dd"  type="text" id="productDate1" size="9" class="form-control"  value="{$productsData->productDate}"/>
            </div>
        </div>
        <!--==============================-->

        <div class="form-group">
            <label class="col-lg-2 control-label">الحد الأدنى للمنتج</label>
            <div class="col-lg-6"> <span id="sprytextfield6">
                    <input name="limitamount1" type="text" id="limitamount1" class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput" value="{$productsData->limitamount}"/>
                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">أدخل رقم</span></span> </div>
        </div>
        <!--==============================-->

        <div class="form-group {if {$Programsettingdata->description} eq 1} hidden {/if}" >
            <label class="col-lg-2 control-label">الوصف</label>
            <div class="col-lg-6">
                <textarea name="productDescription1" id="productDescription1" cols="5" rows="5" class="form-control">{$productsData->productDescription}</textarea>
            </div>
        </div>
        <!--==============================-->

        <div class="form-group">
            <label class="col-lg-2 control-label">إخفاء</label>
            <div class="col-lg-6">
                <div class="radio-inline">
                    <label>
                        <input name="conditions" type="radio" value="1" {if {$productsData->
                        conditions} eq 1} checked="checked" {/if} />
                        نعم </label>
                </div>
                <div class="radio-inline">
                    <label>
                        <input name="conditions" type="radio" {if {$productsData->
                        conditions} eq 0} checked="checked" {/if} value="0" />
                        لا </label>
                </div>
            </div>
        </div>
        <!--==============================-->

        <!--------------------------------  adding units   ----------------------------->

        <div id="addUnitsDiv1">
            <table id="unitsTable1" class="table-black">
                {assign var=j value=1}
                {foreach $productUnitsData as $proUnit}
                <tr>
                    <td>
                        <div>
                            <label class="control-label">وحدة القياس</label>
                            <select name="productunit1{$j}" id="productunit1{$j}" data-placeholder="اختر" class="select2_custom wdt100 chosenproduct" >
                                <option value="-1">اختر وحدة القياس</option>
                                {foreach $unitsData as $unit}
                                <option value="{$unit->unitId}" {if $proUnit->unitid eq $unit->unitId}selected{/if}>{$unit->unitName}</option>
                                {/foreach}
                            </select>
                        </div>
                    </td>
                    <td>
                        <div>
                            <label class="control-label">عدد الوحدات</label>
                            <input name="productnumber1{$j}" readonly="readonly"  id="productnumber1{$j}" class="form-control" type="text" value="{$proUnit->productnumber}"/>
                            <input name="productunitid{$j}" id="productunitid{$j}" type="hidden" value="{$proUnit->productunitid}" />
                        </div>
                    </td>
                    <td>
                        <div>
                            <label class="control-label">الباركود </label>
                            <input name="proUnitParcode1{$j}" id="proUnitParcode1{$j}" class="form-control positiveNo" type="text" value="{$proUnit->proUnitParcode}" data-unit-itr="{$j}" data-unitid-itr="{$j}" onblur="checkUnitbarcodewithid(this.value, $(this).data('unitid-itr'), $(this).data('unit-itr'));"/>
                        </div>
                    </td>
                    <td>
                        <div>
                            <label class="control-label">سعر الشراء </label>
                            <input name="proUnitBuyPrice1{$j}" id="proUnitBuyPrice1{$j}" class="form-control positivefloat" type="text" value="{$proUnit->proUnitBuyPrice}"/>
                        </div>
                    </td>
                    <td>
                        <div>
                            <label class="control-label">سعر الجملة </label>
                            <input name="proUnitSellAllPrice1{$j}" id="proUnitSellAllPrice1{$j}" class="form-control positivefloat" type="text" value="{$proUnit->proUnitSellAllPrice}"/>
                        </div>
                    </td>
                    <td>
                        <div>
                            <label class="control-label">سعر نص جملة </label>
                            <input name="proUnitSellHalfPrice1{$j}" id="proUnitSellHalfPrice1{$j}" class="form-control positivefloat" type="text" value="{$proUnit->proUnitSellHalfPrice}"/>
                        </div>
                    </td>
                    <td>
                        <div>
                            <label class="control-label">سعر قطاعى </label>
                            <input name="proUnitSellUnitPrice1{$j}" id="proUnitSellUnitPrice1{$j}" class="form-control positivefloat" type="text" value="{$proUnit->proUnitSellUnitPrice}"/>
                        </div>
                    </td>
                    <td><a id="remove1{$j}" onclick="removeUnits(1, {$j});"  class="removeUnits">X</a></td>
                </tr>
                {capture assign=j}{$j+1}{/capture}
                {/foreach}
            </table>
            <!--end unitsTable-->
        </div>
        <input class="addUnits btn btn-success" onclick="addUnits(1);" type="button" value="إضافة وحدة قياس"/>
        <input name="unitsItr1" id="unitsItr1" type="hidden" value="{$countProductUnits}" />

        <!-------------------------------- end adding units   -------------------------->
        </td>
    </div>
    <!--end productsTable -->

    <input name="productItr" id="productItr" type="hidden" value="1" />
    <div class="form-group">
        <div class="col-lg-offset-2 col-lg-6" id="myxdiv">
            <button type="submit" id="submit" class="btn btn-primary pull-left">حفظ</button>
        </div>
    </div>
</form>
<div id="productUnitsDiv" style="display:none;">
    <option value="-1">اختر وحدة القياس</option>
    {foreach $unitsData as $unit}
    <option value="{$unit->unitId}">{$unit->unitName}</option>
    {/foreach} </div>
<div id="result"></div>
{literal}
<script type="text/javascript">
    /*
     var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "real");
     var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "real");
     var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "real");
     var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "real");
     var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "integer");
     var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "integer");
     var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7");
     var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8","integer");
     var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {invalidValue:"-1"});*/
</script>
{/literal}

