<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">المنتجات</a></li>
            <li><a href="#">المنتجات </a></li>
            <li class="active">تعديل منتج</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">تعديل منتج</h3>
            </div>
            <div class="panel-body">
                <input type="hidden" id="searchvalue" value="0" />
                <input type="hidden" id="changeBuyPriceChangeSellInProductCtrl"
                       value="{$Programsettingdata->changeBuyPriceChangeSellInProductCtrl}" />
                <input type="hidden" id="productBuyPrice1Old" value="{$productsData->productBuyPrice}" />

                <input type="hidden" id="showpriceall" value="{$Programsettingdata->showpriceall}">
                <input type="hidden" id="showpricehalf" value="{$Programsettingdata->showpricehalf}">
                <input type="hidden" id="showpriceunit" value="{$Programsettingdata->showpriceunit}">
                <input type="hidden" id="showprice4" value="{$Programsettingdata->showprice4}">
                <input type="hidden" id="showprice5" value="{$Programsettingdata->showprice5}">
                <input type="hidden" id="showprice6" value="{$Programsettingdata->showprice6}">
                <input type="hidden" id="showprice7" value="{$Programsettingdata->showprice7}">
                <input type="hidden" id="showprice8" value="{$Programsettingdata->showprice8}">
                <input type="hidden" id="showprice9" value="{$Programsettingdata->showprice9}">
                <input type="hidden" id="showprice10" value="{$Programsettingdata->showprice10}">
                <input type="hidden" id="showprice11" value="{$Programsettingdata->showprice11}">
                <input type="hidden" id="showprice12" value="{$Programsettingdata->showprice12}">
                <input type="hidden" id="showprice13" value="{$Programsettingdata->showprice13}">
                <input type="hidden" id="addclienttoproduct" value="{$Programsettingdata->addclienttoproduct}">
                {literal}
                <form class="nameToBeChecked form-horizontal" id="productEditForm"
                      action="productController.php?do=update" method="post" enctype="multipart/form-data" onsubmit="
                              if ($('#productName1').val() == '') {
                                  return false;
                              }
                              //                        if (checkNameWithId(event, 'product', 'productName1', 'productId')) {
                              //                            return true;
                              //                        } else {
                              //                            return false;
                              //                        }
                      ">
                    <!--validate the form before checking name-->
                    {/literal}
                    <input type="hidden" id="ebillsetting" value="{$Programsettingdata->ebill}">
                    <input name="productId" id="productId" type="hidden" value="{$productsData->productId}" />
                    <input name="level" id="level" type="hidden" value="1" />
                    <input name="productCatId0" id="productCatId0" type="hidden"
                           value="{$productsData->productCatId}" />

                    <div class="form-group">
                        <label class="col-lg-2 control-label">تصنيف المنتج</label>
                        <div class="col-lg-4"> <span id="spryselect1">
                                <select name="productCatId" data-placeholder="" class="select2 wdt100" tabindex="1">
                                    <option value="-1">اختر المنتج الرئيسي</option>
                                    {foreach $alldata as $data }
                                    <option value="{$data->productCatId}" {if $productsData->productCatId eq
                                        $data->productCatId}selected{/if}>{$data->productCatName}</option>
                                    {/foreach}
                                </select>
                                <span class="selectInvalidMsg">اختر تصنيف</span><span class="selectRequiredMsg">اختر
                                    تصنيف</span></span> </div>
                    </div>
                    {if $Programsettingdata->showonlinecat eq 1}
                    <div class="form-group">
                        <label class="col-lg-2 control-label">تصنيف اونلاين</label>
                        <div class="col-lg-4"> <span id="spryselect1">
                                <select name="onlinecatid" data-placeholder="" class="select2 wdt100" tabindex="1">
                                    <option value="-1">اختر تصنيف اونلاين</option>
                                    {foreach $allOnlineCat as $cat }
                                    <option value="{$cat.id}" {if $productsData->onlinecatid eq
                                        $cat.id}selected{/if}>{$cat.name}</option>
                                    {/foreach}
                                </select>
                                <span class="selectInvalidMsg">اختر تصنيف</span><span class="selectRequiredMsg">اختر
                                    تصنيف</span></span> </div>
                    </div>
                    {/if}
                    {if $Programsettingdata->showsearchfilter eq 1}
                    <div class="form-group">
                        <label class="col-lg-2 control-label">فلاتر البحث</label>
                        <div class="col-lg-4"> <span id="spryselect1">
                                <select name="searchfiltersid[]" multiple data-placeholder="" class="select2 wdt100" tabindex="1">
                                    <option value="-1">اختر فلتر البحث</option>
                                    {foreach $allSearchFilters as $filter }
                                    <option value="{$filter.id}" {if $filter.id|in_array:$productsData->searchfiltersid}selected{/if}>{$filter.name}</option>
                                    {/foreach}
                                </select>
                                <span class="selectInvalidMsg">اختر تصنيف</span><span class="selectRequiredMsg">اختر
                                    تصنيف</span></span> </div>
                    </div>
                    {/if}
                    <a class="btn pull-left btn-primary " id="reCalcUnitPrices"><u>تعديل اسعار الوحدات</u></a>
                    <input type="hidden" name="dailyentryid" value="{$productsData->dailyentryid}" />

                    <!--==============================-->

                    <table id="product_Table" class="table table-black">
                        <tr>
                            <td colspan="2">الإسم</td>

                            <td>سعر الشراء</td>
                            <td>الخصم المرجح</td>
                            <!-- <td>سعر الشراء الفعلى</td> -->
                            {if $Programsettingdata->showpriceall eq 1}
                            <td>سعر الجمله</td>
                            {/if}
                            {if $Programsettingdata->showpricehalf eq 1}
                            <td>سعر نصف الجمله </td>
                            {/if}
                            {if $Programsettingdata->showpriceunit eq 1}
                            <td>سعر التجزئة</td>
                            {/if}
                            {if $Programsettingdata->showprice4 eq 1}
                            <td>سعر 4</td>
                            {/if}
                            {if $Programsettingdata->showprice5 eq 1}
                            <td>سعر 5</td>
                            {/if}
                            {if $Programsettingdata->showprice6 eq 1}
                            <td>سعر 6</td>
                            {/if}
                            {if $Programsettingdata->showprice7 eq 1}
                            <td>سعر 7</td>
                            {/if}
                            {if $Programsettingdata->showprice8 eq 1}
                            <td>سعر 8</td>
                            {/if}
                            {if $Programsettingdata->showprice9 eq 1}
                            <td>سعر 9</td>
                            {/if}
                            {if $Programsettingdata->showprice10 eq 1}
                            <td>سعر 10</td>
                            {/if}
                            {if $Programsettingdata->showprice11 eq 1}
                            <td>سعر 11</td>
                            {/if}
                            {if $Programsettingdata->showprice12 eq 1}
                            <td>سعر 12</td>
                            {/if}
                            {if $Programsettingdata->showprice13 eq 1}
                            <td>سعر 13</td>
                            {/if}
                        </tr>
                        <tr>

                            <td colspan="2"><span id="sprytextfield7">


                                    <!--<input name="productName1" type="text" id="productName1" size="9" value="{$productsData->productName}" class="form-control" onchange="checkProductNameForEdit($('#productName1').val(), $('#productId').val(), $('#productCatId0').val())"/>-->
                                    <textarea name="productName1" id="productName1" class="form-control"
                                              onchange="checkProductNameForEdit($('#productName1').val(), $('#productId').val(), $('#productCatId0').val())"
                                              rows="2">{$productsData->productName}</textarea>
                                    <span class="textfieldRequiredMsg">*</span></span>
                                <div id="nameError" class="alert alert-block alert-danger fade in" style="display:none">
                                    <button type="button" class="close pull-left" data-dismiss="alert"
                                            aria-hidden="true">&times;</button>
                                    <p>هذا الاسم مستخدم من قبل</p>
                                    <div class="clearfix"></div>
                                </div>
                            </td>

                            <td><span id="sprytextfield1">
                                    <input name="productBuyPrice1" data-id="1" type="text" id="productBuyPrice1"
                                           class="form-control wd50 aw_m aw_mt aw_pp numberclic buy_price enteraction numberinput"
                                           value="{$productsData->productBuyPrice}" />
                                    <span class="textfieldRequiredMsg">*</span><span
                                        class="textfieldInvalidFormatMsg">أدخل رقم</span></span></td>
                            <td><span id="sprytextfield1">
                                    <input name="weightedDiscount1" disabled data-id="1" type="text"
                                           id="weightedDiscount1"
                                           class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"
                                           value="{$productsData->weightedDiscount}" />
                                    <span class="textfieldRequiredMsg">*</span><span
                                        class="textfieldInvalidFormatMsg">أدخل رقم</span></span></td>
                            <!-- <td><span id="sprytextfield1">
                                    <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|floatval}" type="text"
                                       id="productBuyPrice1" data-type="pricereal" tabindex="-1" readonly
                                       class="form-control precentages success  aw_m aw_mt aw_pp numberclic enteraction  numberinput positivefloat buypricereal_precentage1"
                                       data-id="1" width="10" />

                                <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">أدخل
                                    رقم</span></span>
                            </td> -->
                            {if $Programsettingdata->showpriceall eq 1}
                            <td><span id="sprytextfield2">
                                    <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|floatval}" id="productBuyPrice1"
                                           data-type="buytotal" tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat buytotal_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span><span
                                        class="textfieldInvalidFormatMsg">أدخل رقم</span></span></td>
                            {/if}
                            {if $Programsettingdata->showpricehalf eq 1}
                            <td><span id="sprytextfield3">
                                    <!--<input name="productSellHalfPrice1"   type="text" id="productSellHalfPrice1"  class="form-control wd50 aw_m aw_mt aw_pp numberclic buy_hafe1 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="buyhalf"
                                           value="{$productsData->buyhalf_precentage|floatval}" data-type="buyhalf"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction  precentages success numberinput positivefloat buyhafe_precentage1"
                                           data-id="1" width="10" />

                                    <span class="textfieldRequiredMsg">*</span><span
                                        class="textfieldInvalidFormatMsg">أدخل رقم</span></span></td>
                            {/if}
                            {if $Programsettingdata->showpriceunit eq 1}
                            <td><span id="sprytextfield4">
                                    <!--<input name="productSellUnitPrice1"   type="text" id="productSellUnitPrice1" class="form-control wd50 aw_m aw_mt aw_pp numberclic buy_part1 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="buypart"
                                           data-type="buypart" value="{$productsData->buypart_precentage|floatval}"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat buypart_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span><span
                                        class="textfieldInvalidFormatMsg">أدخل رقم</span></span></td>
                            {/if}
                            {if $Programsettingdata->showprice4 eq 1}
                            <td>
                                <span id="sprytextfield8">
                                    <input style="width: 50%;float: left;" name="price4_1" type="text"
                                           data-type="price4" id="price4"
                                           class="form-control aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat price4_1"
                                           value="{$productsData->price4}" data-id="1" width="20" />
                                    <input style="  width: 50%;" name="price4_precentage1" type="text" id="price4"
                                           data-type="price4"
                                           value="{(($productsData->price4/$productsData->productBuyPrice)-1)*100|floatval}"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat price4_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span><span
                                        class="textfieldInvalidFormatMsg">أدخل رقم</span></span>
                            </td>
                            {/if}
                            {if $Programsettingdata->showprice5 eq 1}
                            <td>
                                <span id="sprytextfield9">
                                    <input style="width: 50%;float: left;" name="price5_1" type="text"
                                           data-type="price5" id="price5"
                                           class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat price5_1"
                                           value="{$productsData->price5}" data-id="1" width="20" />
                                    <input style="  width: 50%;" name="price5_precentage1" type="text" id="price5"
                                           data-type="price5"
                                           value="{(($productsData->price5/$productsData->productBuyPrice)-1)*100|floatval}"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat price5_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span>
                                    <span class="textfieldInvalidFormatMsg">أدخل رقم</span>
                                </span>
                            </td>
                            {/if}
                            {if $Programsettingdata->showprice6 eq 1}
                            <td>
                                <span id="sprytextfield10">
                                    <input style="width: 50%;float: left;" name="price6_1" type="text"
                                           data-type="price6" id="price6"
                                           class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat price6_1"
                                           value="{$productsData->price6}" data-id="1" width="20" />
                                    <input style="width: 50%;" name="price6_precentage1" type="text" id="price6"
                                           data-type="price6"
                                           value="{(($productsData->price6/$productsData->productBuyPrice)-1)*100|floatval}"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat price6_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span>
                                    <span class="textfieldInvalidFormatMsg">أدخل رقم</span>
                                </span>
                            </td>
                            {/if}
                            {if $Programsettingdata->showprice7 eq 1}
                            <td>
                                <span id="sprytextfield11">
                                    <input style="width: 50%;float: left;" name="price7_1" type="text"
                                           data-type="price7" id="price7"
                                           class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat price7_1"
                                           value="{$productsData->price7}" data-id="1" width="20" />
                                    <input style="width: 50%;" name="price7_precentage1" type="text" id="price7"
                                           data-type="price7"
                                           value="{(($productsData->price7/$productsData->productBuyPrice)-1)*100|floatval}"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat price7_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span>
                                    <span class="textfieldInvalidFormatMsg">أدخل رقم</span>
                                </span>
                            </td>
                            {/if}
                            {if $Programsettingdata->showprice8 eq 1}
                            <td>
                                <span id="sprytextfield12">
                                    <input style="width: 50%;float: left;" name="price8_1" type="text"
                                           data-type="price8" id="price8"
                                           class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat price8_1"
                                           value="{$productsData->price8}" data-id="1" width="20" />
                                    <input style="width: 50%;" name="price8_precentage1" type="text" id="price8"
                                           data-type="price8"
                                           value="{(($productsData->price8/$productsData->productBuyPrice)-1)*100|floatval}"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat price8_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span>
                                    <span class="textfieldInvalidFormatMsg">أدخل رقم</span>
                                </span>
                            </td>
                            {/if}
                            {if $Programsettingdata->showprice9 eq 1}
                            <td>
                                <span id="sprytextfield12">
                                    <input style="width: 50%;float: left;" name="price9_1" type="text"
                                           data-type="price9" id="price9"
                                           class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat price9_1"
                                           value="{$productsData->price9}" data-id="1" width="20" />
                                    <input style="width: 50%;" name="price9_precentage1" type="text" id="price9"
                                           data-type="price9"
                                           value="{(($productsData->price9/$productsData->productBuyPrice)-1)*100|floatval}"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat price9_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span>
                                    <span class="textfieldInvalidFormatMsg">أدخل رقم</span>
                                </span>
                            </td>
                            {/if}
                            {if $Programsettingdata->showprice10 eq 1}
                            <td>
                                <span id="sprytextfield12">
                                    <input style="width: 50%;float: left;" name="price10_1" type="text"
                                           data-type="price10" id="price10"
                                           class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat price10_1"
                                           value="{$productsData->price10}" data-id="1" width="20" />
                                    <input style="width: 50%;" name="price10_precentage1" type="text" id="price10"
                                           data-type="price10"
                                           value="{(($productsData->price10/$productsData->productBuyPrice)-1)*100|floatval}"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat price10_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span>
                                    <span class="textfieldInvalidFormatMsg">أدخل رقم</span>
                                </span>
                            </td>
                            {/if}
                            {if $Programsettingdata->showprice11 eq 1}
                            <td>
                                <span id="sprytextfield12">
                                    <input style="width: 50%;float: left;" name="price11_1" type="text"
                                           data-type="price11" id="price11"
                                           class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat price11_1"
                                           value="{$productsData->price11}" data-id="1" width="20" />
                                    <input style="width: 50%;" name="price11_precentage1" type="text" id="price11"
                                           data-type="price11"
                                           value="{(($productsData->price11/$productsData->productBuyPrice)-1)*100|floatval}"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat price11_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span>
                                    <span class="textfieldInvalidFormatMsg">أدخل رقم</span>
                                </span>
                            </td>
                            {/if}
                            {if $Programsettingdata->showprice12 eq 1}
                            <td>
                                <span id="sprytextfield12">
                                    <input style="width: 50%;float: left;" name="price12_1" type="text"
                                           data-type="price12" id="price12"
                                           class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat price12_1"
                                           value="{$productsData->price12}" data-id="1" width="20" />
                                    <input style="width: 50%;" name="price12_precentage1" type="text" id="price12"
                                           data-type="price12"
                                           value="{(($productsData->price12/$productsData->productBuyPrice)-1)*100|floatval}"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat price12_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span>
                                    <span class="textfieldInvalidFormatMsg">أدخل رقم</span>
                                </span>
                            </td>
                            {/if}
                            {if $Programsettingdata->showprice13 eq 1}
                            <td>
                                <span id="sprytextfield12">
                                    <input style="width: 50%;float: left;" name="price13_1" type="text"
                                           data-type="price13" id="price13"
                                           class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat price13_1"
                                           value="{$productsData->price13}" data-id="1" width="20" />
                                    <input style="width: 50%;" name="price13_precentage1" type="text" id="price13"
                                           data-type="price13"
                                           value="{(($productsData->price13/$productsData->productBuyPrice)-1)*100|floatval}"
                                           tabindex="-1" readonly
                                           class="form-control  aw_m aw_mt aw_pp numberclic enteraction precentages success numberinput positivefloat price13_precentage1"
                                           data-id="1" width="10" />
                                    <span class="textfieldRequiredMsg">*</span>
                                    <span class="textfieldInvalidFormatMsg">أدخل رقم</span>
                                </span>
                            </td>
                            {/if}
                        </tr>
                        <tr>
                            <td class=" check_tr {if {$Programsettingdata->parcode} eq 1} hidden {/if}">الباركود</td>
                            <td {if {$Programsettingdata->expiredate} eq 1} hidden {/if}> مدة الصلاحية</td>
                            <td>الكمية</td>
                            <td class="{if {$Programsettingdata->date} eq 1} hidden {/if}">التاريخ</td>
                            <td class=" {if {$Programsettingdata->limitamount} eq 1} hidden {/if}">الحد الأدنى للمنتج
                            </td>
                            <td
                                class="{if $Programsettingdata->isCaf != 1 && $Programsettingdata->isRestaurent != 1} hidden {/if}">
                                فى المنيو</td>
                            <td>إخفاء</td>

                            {if $Programsettingdata->addclienttoproduct eq 1}
                            <td>العميل</td>
                            {/if}
                        </tr>
                        <tr>
                            <td class=" check_tr {if {$Programsettingdata->parcode} eq 1} hidden {/if}">
                                <input name="parcode1" type="text" required id="parcode1" size="9"
                                       value="{$productsData->parcode}" class="form-control"
                                       onblur="checkbarcodewithid(this.value, 1);" />
                            </td>
                            <td {if {$Programsettingdata->expiredate} eq 1} hidden {/if}><input name="expireDate1"
                                                                                                type="text" required id="expireDate1" size="9" class="form-control"
                                                                                                value="{$productsData->expireDate}" style="width: 71%;"> <span
                                                                                                style="float: left;margin-top: -27px; color: white;font-size: 15px;font-weight: bold;">يوم</span>
                            </td>
                            <td><span id="sprytextfield5">
                                    <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}" />
                                    <span class="textfieldRequiredMsg">*</span><span
                                        class="textfieldInvalidFormatMsg">أدخل رقم</span></span></td>
                            <td class="{if {$Programsettingdata->date} eq 1} hidden {/if}">
                                <input name="productDate1" type="text" id="productDate1" size="9"
                                       value="{$productsData->productDate}" required class="form-control awdatepicker"
                                       autocomplete="off" data-date-format="yyyy-mm-dd" />
                            </td>
                            <td class=" {if {$Programsettingdata->limitamount} eq 1} hidden {/if}"><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></td>
                            <td
                                class="{if $Programsettingdata->isCaf != 1 && $Programsettingdata->isRestaurent != 1} hidden {/if}">
                                <div class="form-group">
                                    <div class="col-lg-12">
                                        <div class="radio-inline">
                                            <label>
                                                <input value="0" class="radioR" name="inMenu1" type="radio" {if
                                                       {$productsData->inMenu} eq 0} checked="checked" {/if} />

                                                نعم </label>
                                        </div>
                                        <div class="radio-inline">
                                            <label>
                                                <input value="1" class="noradioR" name="inMenu1" type="radio" {if
                                                       {$productsData->inMenu} eq 1} checked="checked" {/if} />
                                                لا </label>
                                        </div>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <div class="form-group">
                                    <div class="col-lg-12">
                                        <div class="radio-inline">
                                            <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>
                            </td>
                            {if $Programsettingdata->addclienttoproduct eq 1}
                            <td>
                                <select name="clientid1" class="form-control">
                                    <option value="0" {if $productsData->clientid eq 0}selected{/if}>كل العملاء</option>
                                    {foreach $clientsData as $client}
                                    <option value="{$client->clientid}" {if $productsData->clientid eq
                                        $client->clientid}selected{/if}>{$client->clientname}</option>
                                    {/foreach}
                                </select>
                            </td>
                            {/if}
                        </tr>

                        <tr>
                            <td>متوسط سعر الشراء</td>
                            <td>متوسط سعر الشراء مع الخصم</td>
                            <td>متوسط سعر الشراء مع الخصم شامل القيمة المضافة</td>
                            <td>المتوسط العام</td>
                            <td>اخر سعر شراء</td>
                            <td>اخر سعر شراء مع الخصم</td>
                            <td>اخر سعر شراء شامل القيمة المضافة</td>
                            <td>اخر سعر شراء مع الخصم شامل القيمة المضافة</td>
                        </tr>
                        <tr>
                            <td>
                                <input name="meanbuyprice1" type="text" id="meanbuyprice1"
                                       class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"
                                       value="{$productsData->meanbuyprice}" />
                            </td>
                            <td>
                                <input name="meanbuyprice_withDiscount1" type="text" id="meanbuyprice_withDiscount1"
                                       class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"
                                       value="{$productsData->meanbuyprice_withDiscount}" />
                            </td>
                            <td>
                                <input name="meanbuyprice_withTax1" type="text" id="meanbuyprice_withTax1"
                                       class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"
                                       value="{$productsData->meanbuyprice_withTax}" />
                            </td>
                            <td>
                                <input name="overAllAveragePrice1" type="text" id="overAllAveragePrice1"
                                       class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"
                                       value="{$productsData->overAllAveragePrice}" />
                            </td>
                            <td>
                                <input name="lastbuyprice1" type="text" id="lastbuyprice1"
                                       class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"
                                       value="{$productsData->lastbuyprice}" />
                            </td>
                            <td>
                                <input name="lastbuyprice_withDiscount1" type="text" id="lastbuyprice_withDiscount1"
                                       class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"
                                       value="{$productsData->lastbuyprice_withDiscount}" />
                            </td>
                            <td>
                                <input name="lastbuyprice_withTax1" type="text" id="lastbuyprice_withTax1"
                                       class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"
                                       value="{$productsData->lastbuyprice_withTax}" />
                            </td>
                            <td>
                                <input name="lastbuyprice_withDiscountAndTax1" type="text" id="lastbuyprice_withDiscountAndTax1"
                                       class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput"
                                       value="{$productsData->lastbuyprice_withDiscountAndTax}" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3"
                                class="check_tr_description {if {$Programsettingdata->description} eq 1} hidden {/if}">
                                التعليق</td>
                            <td>خدمة</td>
                            <td class=" check_tr_production {if {$Programsettingdata->production} eq 1} hidden {/if}">
                                تصنيع</td>
                            <td class=" {if {$Programsettingdata->ebill} neq 1} hidden {/if}">نوع الباركود الضريبى</td>
                            <td class=" {if {$Programsettingdata->ebill} neq 1} hidden {/if}">الباركود الضريبى</td>
                        </tr>
                        <tr>
                            <td colspan="3"
                                class=" check_tr_description {if {$Programsettingdata->description} eq 1} hidden {/if}">
                                <textarea name="productDescription1" id="productDescription1" cols="20" rows="5"
                                          class="form-control">{$productsData->productDescription}</textarea>
                            </td>
                            <td>
                                <div class="form-group">
                                    <div class="col-lg-12">
                                        <div class="radio-inline">
                                            <label>
                                                <input value="1" class="radioR" name="isService" type="radio" {if
                                                       {$productsData->isService} eq 1} checked="checked" {/if} />

                                                نعم </label>
                                        </div>
                                        <div class="radio-inline">
                                            <label>
                                                <input value="0" class="noradioR" name="isService" type="radio" {if
                                                       {$productsData->isService} eq 0} checked="checked" {/if} />
                                                لا </label>
                                        </div>
                                    </div>
                                </div>
                            </td>
                            <td class=" check_tr_production {if {$Programsettingdata->production} eq 1} hidden {/if}">
                                <div class="form-group">
                                    <div class="col-lg-12">
                                        <div class="radio-inline">
                                            <label>
                                                <input value="1" class="radioR" name="type" type="radio" {if
                                                       {$productsData->type} eq 1} checked="checked" {/if} />

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

                            <td class=" {if {$Programsettingdata->ebill} neq 1} hidden {/if}">

                                <div class="form-group">
                                    <div class="col-lg-12">
                                        <div class="radio-inline">
                                            <label>
                                                <input value="GS1" class="noradioR" name="TypeOfBarcodeInTax"
                                                       type="radio" {if {$productsData->TypeOfBarcodeInTax} eq 'GS1'}
                                                checked="checked" {/if} />
                                                GS1 </label>
                                        </div>

                                        <div class="radio-inline">
                                            <label>
                                                <input value="EGS" class="radioR" name="TypeOfBarcodeInTax" type="radio"
                                                       {if {$productsData->TypeOfBarcodeInTax} eq 'EGS'} checked="checked"
                                                {/if} />

                                                EGS </label>
                                        </div>
                                    </div>
                                </div>
                            </td>
                            <td class=" {if {$Programsettingdata->ebill} neq 1} hidden {/if}">

                                <input name="barcodeInTax" type="text" id="barcodeInTax" class="form-control"
                                       autocomplete="off" value="{$productsData->barcodeInTax}">
                            </td>

                        </tr>
                        <tr>
                            <td colspan="3">صورة</td>
                            <td colspan="3">حساب الشجرة</td>
                            <td colspan="3" {if {$Programsettingdata->webApiId} eq 0} hidden {/if}>web Api Id</td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                {if $productsData->logo !="" &&$productsData->logo!="."}<img
                                    src="../views/default/images/product_image/{$productsData->logo}" alt=""
                                    width="{$productsData->displayWidth}" height="{$productsData->displayHeight}"
                                    style="cursor: pointer;" onclick="window.open($(this).attr('src'))" /> {/if}
                                <input type="file" name="logo" id="logo" class="form-control" placeholder="صورة" />
                                <input type="hidden" name="oldlogo" id="oldlogo" value="{$productsData->logo}" />
                            </td>
                            <td colspan="3">
                                <select class="select2" name="treeId" id="treeId">
                                    {$myhtml}
                                </select>
                            </td>
                            <td colspan="3" {if {$Programsettingdata->webApiId} eq 0} hidden {/if}>
                                <input name="webApiId" data-id="1" type="text" id="webApiId" class="form-control wd50 aw_m aw_mt aw_pp numberclic enteraction numberinput" value="{$productsData->webApiId}" autocomplete="off">
                            </td>
                        </tr>

                        {if $Programsettingdata->importproduct eq 1}
                        <tr>
                            <td colspan="1" class="{if $Programsettingdata->shownameE neq 1}hidden{/if}"
                                style="width:250">E الإسم
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showprocode neq 1}hidden{/if}">كود</td>
                            <td colspan="1" class="{if $Programsettingdata->showpartnumber neq 1}hidden{/if}">رقم القطعة
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showtype neq 1}hidden{/if}">النوع
                            </td>
                            <td colspan="2" class="{if $Programsettingdata->showcompany neq 1}hidden{/if}">الشركه
                                المنتجه للصنف </td>
                            <td colspan="1" class="{if $Programsettingdata->showweight neq 1}hidden{/if}">وزن</td>
                            <td colspan="1" class="{if $Programsettingdata->showorigin neq 1}hidden{/if}">منشأ</td>
                            <td colspan="1" class="{if $Programsettingdata->showhscode neq 1}hidden{/if}">رمز النظام
                                المنسق</td>
                            <td colspan="1" class="{if $Programsettingdata->showexpire neq 1}hidden{/if}">صلاحيه</td>
                            <td colspan="1" class="power1 {if $Programsettingdata->showexpire neq 1} hidden {/if}">
                                تاريخ الانتاج</td>
                            <td colspan="1" class="power1 {if $Programsettingdata->showexpire neq 1} hidden {/if}">
                                مدة الصلاحيه</td>
                            <td colspan="1" class="{if $Programsettingdata->showgrantduration neq 1}hidden{/if}">مدة
                                الضمان
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showonline neq 1}hidden{/if}">اونلاين
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showminappear neq 1}hidden{/if}">الحد الأدنى
                                للظهور اونلاين</td>
                            <td colspan="1" class="{if $Programsettingdata->showsellpercentage neq 1}hidden{/if}">
                                نسبة البيع: إضافة/خصم </td>
                            <td colspan="1"
                                class="sellpercentadd1 {if $Programsettingdata->showsellpercentage neq 1}hidden{/if}"
                                {if $productsData->sellpercenttype neq 0}style="display:none;"{/if}>نسبة اضافة
                                بيع</td>
                            <td colspan="1" class="sellpercentdiscount1" {if $productsData->sellpercenttype neq
                                1}style="display:none;"{/if}>نسبة خصم
                                بيع</td>
                            <td colspan="1" class="{if $Programsettingdata->showbuydiscount neq 1}hidden{/if}">نسبة خصم
                                الشراء</td>
                        </tr>
                        <tr>
                            <td colspan="1" class="{if $Programsettingdata->shownameE neq 1}hidden{/if}">
                                <input name="productNameE1" type="text" id="productNameE1" width="100%"
                                       class="form-control" data-itra="1" data-id="1" value="{$productsData->partNumber}">
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showprocode neq 1}hidden{/if}">
                                <input name="procode1" type="text" id="procode1" width="100%" class="form-control"
                                       data-itra="1" data-id="1" value="{$productsData->procode}">
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showpartnumber neq 1}hidden{/if}">
                                <input name="partNumber1" type="text" id="partNumber1" width="100%"
                                       class="form-control positivefloat" data-itra="1" data-id="1"
                                       value="{$productsData->partNumber}">
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showtype neq 1}hidden{/if}">
                                <select name="vehicleType1" id="vehicleType1" class="select2 wdt100 vehicleType">
                                    <option value="-1">اختر</option>
                                    {foreach $vehicletypes as $vehicle}
                                    <option value="{$vehicle->id}" {if $productsData->vehicleType eq
                                        $vehicle->id}selected{/if}>{$vehicle->typename}</option>
                                    {/foreach}
                                </select>


                            </td>
                            <td colspan="2" class="{if $Programsettingdata->showcompany neq 1}hidden{/if}">
                                <select name="company1" id="company1" class="select2 wdt100 vehicleType" data-id="1"
                                        data-itra="1">
                                    <option value="-1">اختر</option>
                                    {foreach $companyproduces as $company}
                                    <option value="{$company->id}" {if $productsData->company eq
                                        $company->id}selected{/if}>{$company->companyname}</option>
                                    {/foreach}
                                </select>
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showweight neq 1}hidden{/if}">
                                <input name="weight1" type="text" id="weight1" width="100%"
                                       class="form-control positivefloat" data-itra="1" data-id="1"
                                       value="{$productsData->weight}">
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showorigin neq 1}hidden{/if}">
                                <input name="origin1" type="text" id="origin1" width="100%" class="form-control"
                                       data-itra="1" data-id="1" value="{$productsData->origin}">
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showhscode neq 1}hidden{/if}">
                                <input name="hscode1" type="text" id="hscode1" width="100%"
                                       class="form-control positivefloat" data-itra="1" data-id="1"
                                       value="{$productsData->hscode}">
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showexpire neq 1}hidden{/if}">
                                <div class="form-group" style="font-size:13px">
                                    <label class='color-black'>
                                        <input value="0" class="power" data-itra="1" name="power1" {if
                                               {$productsData->power} eq 0} checked="checked" {/if} type="radio"
                                        data-id="1"/>
                                        نعم </label>

                                    <label class='color-black'>
                                        <input value="1" class="power" data-itra="1" name="power1" type="radio"
                                               data-id="1" {if {$productsData->power} eq 1} checked="checked" {/if} />
                                        لا </label>
                                </div>
                            </td>
                            <td colspan="1" class="power1 {if $Programsettingdata->showexpire neq 1}hidden{/if}">
                                <input name="ProductionDate1" type="text" id="ProductionDate1" width="100%"
                                       class="form-control awdatepicker" data-date-format="yyyy-mm-dd" data-itra="1"
                                       data-id="1" value="{$productsData->ProductionDate}">
                            </td>
                            <td colspan="1" class="power1 {if $Programsettingdata->showexpire neq 1}hidden{/if}">
                                <input name="expiry1" type="text" id="expiry1" width="100%"
                                       class="form-control positivefloat" data-itra="1" data-id="1"
                                       value="{$productsData->expiry}">
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showgrantduration neq 1}hidden{/if}">
                                <input name="grantduration1" type="text" id="grantduration1" width="100%"
                                       class="form-control positivefloat" data-itra="1" data-id="1" />
                            </td>
                            <td colspan="1" class=" {if $Programsettingdata->showonline neq 1}hidden{/if}">
                                <div class="form-group" style="font-size:13px">
                                    <label class='color-black'>
                                        <input value="1" data-itra="1" name="onlinepro1" type="radio" data-id="1" {if
                                               $productsData->onlinepro eq 1} checked="checked" {/if}/>
                                        نعم </label>

                                    <label class='color-black'>
                                        <input value="0" data-itra="1" name="onlinepro1" type="radio" data-id="1" {if
                                               $productsData->onlinepro eq 0} checked="checked" {/if}/>
                                        لا </label>
                                </div>
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showminappear neq 1}hidden{/if}">
                                <input name="minappearonline1" type="text" id="minappearonline1" width="100%"
                                       class="form-control positivefloat" data-itra="1" data-id="1"
                                       value="{$productsData->minappearonline}" />
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showsellpercentage neq 1}hidden{/if}">
                                <div class="form-group" style="font-size:13px">
                                    <label class='color-black'>
                                        <input value="0" class="sellpercenttype" data-itra="1" name="sellpercenttype1"
                                               {if $productsData->sellpercenttype eq 0} checked="checked" {/if}
                                        type="radio"
                                        data-id="1" />
                                        إضافة </label>

                                    <label class='color-black'>
                                        <input value="1" class="sellpercenttype" data-itra="1" name="sellpercenttype1"
                                               type="radio" data-id="1" {if $productsData->sellpercenttype eq 1}
                                        checked="checked" {/if} />
                                        خصم </label>
                                </div>
                            </td>
                            <td colspan="1"
                                class="sellpercentadd1 {if $Programsettingdata->showsellpercentage neq 1}hidden{/if}"
                                {if $productsData->sellpercenttype neq 0}style="display:none;"{/if}>
                                <input name="selladdpercent1" type="text" id="selladdpercent1" width="100%"
                                       class="form-control positivefloat" data-itra="1" data-id="1"
                                       value="{$productsData->selladdpercent}" />
                            </td>
                            <td colspan="1"
                                class="sellpercentdiscount1 {if $Programsettingdata->showsellpercentage neq 1 }hidden{/if}"
                                {if $productsData->sellpercenttype neq 1}style="display:none;"{/if}>
                                <input name="selldiscountpercent1" type="text" id="selldiscountpercent1" width="100%"
                                       class="form-control positivefloat" data-itra="1" data-id="1"
                                       value="{$productsData->selldiscountpercent}" />
                            </td>
                            <td colspan="1" class="{if $Programsettingdata->showbuydiscount neq 1}hidden{/if}">
                                <input name="buydiscountpercent1" type="text" id="buydiscountpercent1" width="100%"
                                       class="form-control positivefloat" data-itra="1" data-id="1"
                                       value="{$productsData->buydiscountpercent}" />
                            </td>
                        </tr>
                        {/if}
                        <tr>
                            <td colspan="10">
                                <!--------------------------------  adding units   ----------------------------->

                                <div id="addUnitsDiv1"
                                     class="{if {$Programsettingdata->measuringunit} eq 1} hidden {/if}">
                                    <div class="table-responsive">
                                        <table id="unitsTable1" class="table table-black">
                                            {assign var=j value=1}
                                            {foreach $productUnitsData as $proUnit}
                                            <tr>
                                                <td>
                                                    <div>
                                                        <label class="control-label">وحدة القياس</label>
                                                        <select name="productunit1_disabled{$j}"
                                                                id="productunit1_disabled{$j}" disabled="disabled"
                                                                data-placeholder="اختر"
                                                                class="select2 wdt100 aw_m1 chosenproduct" tabindex="12">
                                                            <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>
                                                        <input name="productunit1{$j}" id="productunit1{$j}"
                                                               type="hidden" value="{$proUnit->unitid}" />
                                                        <input name="productunitid{$j}" id="productunitid{$j}"
                                                               type="hidden" value="{$proUnit->productunitid}" />
                                                    </div>
                                                </td>
                                                <td width="13%">
                                                    <div>
                                                        <label class="control-label">عدد الوحدات</label>
                                                        <input name="productnumber1{$j}" readonly="readonly"
                                                               id="productnumber1{$j}" type="text"
                                                               value="{$proUnit->productnumber}" class="form-control" />
                                                    </div>
                                                </td>
                                                <td class=" {if {$Programsettingdata->ebill} neq 1} hidden {/if}">
                                                    <div>
                                                        <label class="control-label"> وحدة القياس الضريبية </label>
                                                        <input name="unitInTax1{$j}" id="unitInTax1{$j}"
                                                               class="unitInTaxClass" type="hidden"
                                                               value="{$proUnit->unitInTax}"
                                                               data-old="{$proUnit->unitInTax}" />
                                                    </div>
                                                </td>
                                                <td>
                                                    <div>
                                                        <label class="control-label">الباركود</label>
                                                        <input name="proUnitParcode1{$j}" id="proUnitParcode1{$j}"
                                                               type="text" class="form-control numberinput positiveNo"
                                                               value="{$proUnit->proUnitParcode}" data-unit-itr="1{$j}"
                                                               data-unitid-itr="{$j}"
                                                               onblur="checkUnitbarcodewithid(this.value, $(this).data('unitid-itr'), $(this).data('unit-itr'));" />
                                                    </div>
                                                </td>
                                                <td width="13%">
                                                    <div>
                                                        <label class="control-label">سعر الشراء</label>
                                                        <input name="proUnitBuyPrice1{$j}" id="proUnitBuyPrice1{$j}"
                                                               type="text" class="form-control positivefloat"
                                                               value="{$proUnit->proUnitBuyPrice}" />
                                                    </div>
                                                </td>
                                                {if $Programsettingdata->showpriceall eq 1}
                                                <td width="13%">
                                                    <div>
                                                        <label class="control-label">سعر الجملة</label>
                                                        <input name="proUnitSellAllPrice1{$j}"
                                                               id="proUnitSellAllPrice1{$j}" type="text"
                                                               class="form-control positivefloat"
                                                               value="{$proUnit->proUnitSellAllPrice}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showpricehalf eq 1}
                                                <td width="13%">
                                                    <div>
                                                        <label class="control-label">سعر نص جملة</label>
                                                        <input name="proUnitSellHalfPrice1{$j}"
                                                               id="proUnitSellHalfPrice1{$j}" type="text"
                                                               class="form-control positivefloat"
                                                               value="{$proUnit->proUnitSellHalfPrice}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showpriceunit eq 1}
                                                <td width="13%">
                                                    <div>
                                                        <label class="control-label">سعر قطاعى</label>
                                                        <input name="proUnitSellUnitPrice1{$j}"
                                                               id="proUnitSellUnitPrice1{$j}" type="text"
                                                               class="form-control positivefloat"
                                                               value="{$proUnit->proUnitSellUnitPrice}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showprice4 eq 1}
                                                <td>
                                                    <div>
                                                        <label class="control-label">سعر4</label>
                                                        <input name="proUnitprice4_1{$j}" id="proUnitprice4_1{$j}"
                                                               type="text" class="form-control positivefloat"
                                                               value="{$proUnit->proUnitPrice4}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showprice5 eq 1}
                                                <td>
                                                    <div>
                                                        <label class="control-label">سعر5</label>
                                                        <input name="proUnitprice5_1{$j}" id="proUnitprice5_1{$j}"
                                                               type="text" class="form-control positivefloat"
                                                               value="{$proUnit->proUnitPrice5}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showprice6 eq 1}
                                                <td>
                                                    <div>
                                                        <label class="control-label">سعر6</label>
                                                        <input name="proUnitprice6_1{$j}" id="proUnitprice6_1{$j}"
                                                               type="text" class="form-control positivefloat"
                                                               value="{$proUnit->proUnitPrice6}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showprice7 eq 1}
                                                <td>
                                                    <div>
                                                        <label class="control-label">سعر7</label>
                                                        <input name="proUnitprice7_1{$j}" id="proUnitprice7_1{$j}"
                                                               type="text" class="form-control positivefloat"
                                                               value="{$proUnit->proUnitPrice7}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showprice8 eq 1}
                                                <td>
                                                    <div>
                                                        <label class="control-label">سعر8</label>
                                                        <input name="proUnitprice8_1{$j}" id="proUnitprice8_1{$j}"
                                                               type="text" class="form-control positivefloat"
                                                               value="{$proUnit->proUnitPrice8}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showprice9 eq 1}
                                                <td>
                                                    <div>
                                                        <label class="control-label">سعر9</label>
                                                        <input name="proUnitprice9_1{$j}" id="proUnitprice9_1{$j}"
                                                               type="text" class="form-control positivefloat"
                                                               value="{$proUnit->proUnitPrice9}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showprice10 eq 1}
                                                <td>
                                                    <div>
                                                        <label class="control-label">سعر10</label>
                                                        <input name="proUnitprice10_1{$j}" id="proUnitprice10_1{$j}"
                                                               type="text" class="form-control positivefloat"
                                                               value="{$proUnit->proUnitPrice10}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showprice11 eq 1}
                                                <td>
                                                    <div>
                                                        <label class="control-label">سعر11</label>
                                                        <input name="proUnitprice11_1{$j}" id="proUnitprice11_1{$j}"
                                                               type="text" class="form-control positivefloat"
                                                               value="{$proUnit->proUnitPrice11}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showprice12 eq 1}
                                                <td>
                                                    <div>
                                                        <label class="control-label">سعر12</label>
                                                        <input name="proUnitprice12_1{$j}" id="proUnitprice12_1{$j}"
                                                               type="text" class="form-control positivefloat"
                                                               value="{$proUnit->proUnitPrice12}" />
                                                    </div>
                                                </td>
                                                {/if}
                                                {if $Programsettingdata->showprice13 eq 1}
                                                <td>
                                                    <div>
                                                        <label class="control-label">سعر13</label>
                                                        <input name="proUnitprice13_1{$j}" id="proUnitprice13_1{$j}"
                                                               type="text" class="form-control positivefloat"
                                                               value="{$proUnit->proUnitPrice13}" />
                                                    </div>
                                                </td>
                                                {/if}

                                                <td><a id="remove1{$j}" onclick="removeUnits(1, {$j});"
                                                       class="removeUnits">X</a></td>
                                            </tr>
                                            {capture assign=j}{$j+1}{/capture}
                                            {/foreach}
                                        </table>
                                    </div>
                                    <!--end unitsTable-->
                                    </ div>
                                    <input
                                        class="addUnits btn btn-warning  {if {$Programsettingdata->measuringunit} eq 1} hidden {/if}"
                                        onClick="addUnits(1);" type="button" value="إضافة وحدة قياس" />
                                    <input name="unitsItr1" id="unitsItr1" type="hidden" value="{$countProductUnits}" />

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

                                    <input name="productItr" id="productItr" type="hidden" value="1" />
                            </td>
                        </tr>
                        {if $isCollective == 1}
                        <tr>
                            <td colspan="10">
                                <!--------------------------------  adding units   ----------------------------->
                                <input type="hidden" name="searchvalue" id="searchvalue"
                                       value="{$Programsettingdata->searchvalue}" />
                                <div class="panel panel-default panel-m">
                                    <div class="panel-heading">
                                        <h3 class="panel-title">المكونات</h3>
                                        <input type="hidden" name="isCollective" id="isCollective" value="1" />
                                    </div>
                                    <div class="panel-body">
                                        <div class="row">
                                            <input type="hidden" name="rowitr" id="rowitr" value="{$noOfRows}" />
                                            <input type="hidden" name="notRawMaterialsOnly" id="notRawMaterialsOnly"
                                                   value="1" />
                                            <div class="col-lg-12">
                                                <button type="button" name="addrow" id="addrow"
                                                        class="btn btn-primary pull-left ft-nor"> اضافة </button>
                                                <button type="button" style="display:none;" name="addrow" id="addrow"
                                                        class="btn btn-primary pull-left ft-nor" onclick="addrow();"> اضافة
                                                    جديد</button>
                                            </div>

                                        </div>
                                        <table class="table billtable table-bordered table-black col-lg-4" id="table">
                                            <thead>
                                                <tr>
                                                    <th class="wdt400">المنتجات الخام</th>
                                                    <th class="wdt200"><span class="sr-only">وحدة القياس</span></th>
                                                    <!--<th  class="wdt200">نسبة المشاركة </th>-->
                                                    <th class="wdt200">عدد الوحدات</th>
                                                    <th class="wdt200">حذف</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                {assign var=i value=1}
                                                {assign var=y value=1}
                                                {foreach $Productionrateproduct as $x}
                                                <tr>
                                                    <td><input type="hidden" name="productionRateProductId{$i}"
                                                               id="productionRateProductId{$i}"
                                                               value="{$x->productionRateProductId}" />

                                                        <!--  <input type="hidden"  class="select2RawMaterials wdt300" name="product{$i}" id="product{$i}" data-placeholder=" اختر منتج خام"  />-->

                                                        <!--               <input type="hidden"   name="oldproduct{$i}" id="oldproduct{$i}" value="{$x->productId}"  />
                                                                                          <input type="hidden"   name="oldproductname{$i}" id="oldproductname{$i}" value="{$x->productName}"  />-->

                                                        <select class="select2 wdt300" name="product{$i}"
                                                                id="product{$i}">


                                                            {foreach $rows as $material}
                                                            <option value="{$material->productId}" {if {$material->
                                                                productId}=={$x->ingridientId}}selected="selected"{/if}
                                                                >{$material->productName}</option>
                                                            {/foreach}


                                                        </select>
                                                    </td>
                                                    <td>
                                                        <div id="unitDiv{$i}">
                                                            <select name="unitId{$i}" id="unitId{$i}"
                                                                    class="select2 wdt300">
                                                                {foreach $productUnitData{$y} as $myUnit}
                                                                <option value="{$myUnit->productunitid}"
                                                                        data-pronum="{$myUnit->productnumber}" {if
                                                                        {$myUnit->
                                                                    productunitid}=={$x->unitId}}selected="selected"{/if}

                                                                    >{$myUnit->unitName}</option>

                                                                {/foreach}
                                                            </select>
                                                            <input type="hidden" name="productBuyPrice{$i}"
                                                                   id="productBuyPrice{$i}"
                                                                   value="{$x->productBuyPrice}" />
                                                            <input type="hidden" name="lastbuyprice{$i}"
                                                                   id="lastbuyprice{$i}" value="{$x->lastbuyprice}" />
                                                            <input type="hidden" name="lastbuyprice_withDiscount{$i}"
                                                                   id="lastbuyprice_withDiscount{$i}"
                                                                   value="{$x->lastbuyprice_withDiscount}" />
                                                            <input type="hidden" name="meanbuyprice{$i}"
                                                                   id="meanbuyprice{$i}" value="{$x->meanbuyprice}" />
                                                            <input type="hidden" name="meanbuyprice_withDiscount{$i}"
                                                                   id="meanbuyprice_withDiscount{$i}"
                                                                   value="{$x->meanbuyprice_withDiscount}" />
                                                        </div>

                                                        <!--<input type="hidden"   name="oldUnit{$i}" id="oldUnit{$i}" value="{$x->unitId}"  />
                                                                            <input type="hidden"   name="oldUnitName{$i}" id="oldUnitName{$i}" value="{$x->unitName}"  /> -->
                                                    </td>
                                                    <!--                                    <td><div id="table">
                                                                                                <input type="text" name="input{$i}" id="input{$i}"  class="form-control check" value="{$x->rate}" tabindex=""  />
                                                                                            </div></td>-->
                                                    <td>
                                                        <div id="table">
                                                            <input name="inputt{$i}" id="inputt{$i}"
                                                                   class="form-control positive" value="{$x->quantity}"
                                                                   tabindex="" />
                                                        </div>
                                                    </td>
                                                    <td id="{$i}">
                                                        <button id="remove{$i}" name="remove{$i}" type="button"
                                                                class="close flt-none removeicon removeproduct"
                                                                aria-hidden="true" onclick="removerow();">&times;</button>
                                                    </td>
                                                </tr>
                                                {capture assign=i}{$i+1}{/capture}
                                                {capture assign=y}{$y+1}{/capture}
                                                {/foreach}
                                            </tbody>
                                        </table>
                                        <p>&nbsp; </p>
                                        <div>
                                            <!--h4><u>حساب تكلفة المنتج من المكونات</u></h4-->
                                            <button type="button" class="btn btn-primary ft-nor"> التكلفة بسعر الشراء
                                                <span class="badge wht-clo">
                                                    <div id="productBuyPrice">{$productsData->productBuyPrice}</div>
                                                </span></button>
                                            &nbsp;
                                            <button type="button" class="btn btn-primary ft-nor"> التكلفة باخر سعر شراء
                                                <span class="badge wht-clo">
                                                    <div id="lastbuyprice">{$productsData->lastbuyprice}</div>
                                                </span></button>
                                            &nbsp;
                                            <button type="button" class="btn btn-primary ft-nor"> التكلفة باخر سعر شراء
                                                مع الخصم
                                                <span class="badge wht-clo">
                                                    <div id="lastbuyprice_withDiscount">
                                                        {$productsData->lastbuyprice_withDiscount}</div>
                                                </span></button>
                                            &nbsp;
                                            <button type="button" class="btn btn-primary ft-nor"> التكلفة بمتوسط سعر
                                                الشراء
                                                <span class="badge wht-clo">
                                                    <div id="meanbuyprice">{$productsData->meanbuyprice}</div>
                                                </span></button>
                                            &nbsp;
                                            <button type="button" class="btn btn-primary ft-nor"> التكلفة بمتوسط سعر
                                                الشراء مع الخصم
                                                <span class="badge wht-clo">
                                                    <div id="meanbuyprice_withDiscount">
                                                        {$productsData->meanbuyprice_withDiscount}</div>
                                                </span></button>

                                            <input type="hidden" name="productBuyPrice_h" id="productBuyPrice_h"
                                                   value="{$productsData->productBuyPrice}" />
                                            <input type="hidden" name="lastbuyprice_h" id="lastbuyprice_h"
                                                   value="{$productsData->lastbuyprice}" />
                                            <input type="hidden" name="lastbuyprice_withDiscount_h"
                                                   id="lastbuyprice_withDiscount_h"
                                                   value="{$productsData->lastbuyprice_withDiscount}" />
                                            <input type="hidden" name="meanbuyprice_h" id="meanbuyprice_h"
                                                   value="{$productsData->meanbuyprice}" />
                                            <input type="hidden" name="meanbuyprice_withDiscount_h"
                                                   id="meanbuyprice_withDiscount_h"
                                                   value="{$productsData->meanbuyprice_withDiscount}" />
                                        </div>
                                        <br />
                                        <div class="clearfix"></div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        {/if}
                        {if $productsData->hasSizeAndColor == 1}
                        <input name="hasSizeAndColor" type="hidden" value="1">
                        <tr>
                            <td colspan="10">
                                <!--------------------------------  adding units   ----------------------------->
                                <div class="panel panel-default panel-m">
                                    <div class="panel-heading">
                                        <h3 class="panel-title">المقاسات والالوان</h3>
                                        <input type="hidden" name="isCollective" id="isCollective" value="1" />
                                    </div>
                                    <div class="panel-body">
                                        <div class="row">
                                            <div class="col-lg-5" id="rightpart" style="display: inline">
                                                <label for="sizes" class="col-lg-4 control-label">المقاسات</label>
                                                <select class="select2" name="sizes[]" id="sizes" multiple="multiple">
                                                    <option value="-1">كل المقاسات</option>
                                                    {foreach $allSizeColor as $data}
                                                    {if $data->type == 0}
                                                    <option value="{$data->id}">{$data->name}</option>
                                                    {/if}
                                                    {/foreach}
                                                </select>
                                            </div>
                                            <div class="col-lg-5" id="leftpart" style="display: inline">
                                                <label for="colors" class="col-lg-4 control-label">الالوان</label>
                                                <select class="select2" name="colors[]" id="colors" multiple="multiple">
                                                    <option value="-1">كل الالوان</option>
                                                    {foreach $allSizeColor as $data}
                                                    {if $data->type == 1}
                                                    <option value="{$data->id}">{$data->name}</option>
                                                    {/if}
                                                    {/foreach}
                                                </select>
                                            </div>
                                            <div class="col-lg-2" id="leftpart" style="display: inline">
                                                <button type="button" class="btn btn-success pull-left"
                                                        style="margin-top: 3px;" id="SizeColorQuantity">ادخال الكميات للكل
                                                </button>
                                                <button type="button" class="btn btn-success pull-left"
                                                        style="margin-top: 5px;" id="SizeColorQuantity_onlyNew">اضافة
                                                    للموجود </button>
                                            </div>


                                        </div>
                                        <div class="clearfix"></div>
                                        <br />
                                        <div class="row" id="quantity_div">
                                            <table class="table">
                                                <thead>
                                                    <tr>
                                                        <th>الباركود</th>
                                                        <th>المقاس</th>
                                                        <th>اللون</th>
                                                        <th>حذف</th>
                                                    </tr>
                                                </thead>
                                                <tbody id="SizeColorTB">
                                                    {assign var=i value=1}
                                                    {foreach $sizeColorStoreDetail as $data}
                                                    <tr>
                                                        <td>
                                                            <input type="hidden" name="sizecolorstoredetail_id{$i}"
                                                                   id="sizecolorstoredetail_id{$i}" value="{$data->id}">
                                                            <input type="hidden" name="size_detail{$i}"
                                                                   id="size_detail{$i}" value="{$data->sizeid}">
                                                            <input type="hidden" name="color_detail{$i}"
                                                                   id="color_detail{$i}" value="{$data->colorid}">

                                                            <input type="text" class="form-control"
                                                                   name="parcode_detail{$i}" id="parcode_detail{$i}"
                                                                   value="{$data->parcode}">
                                                        </td>
                                                        <td><input type="text" class="form-control" readonly=""
                                                                   value="{$data->sizeName}"></td>
                                                        <td><input type="text" class="form-control" readonly=""
                                                                   value="{$data->colorName}"></td>
                                                        <td><a class="btn btn-default btn-lg removeicon removethis"></a>
                                                        </td>
                                                    </tr>
                                                    {assign var=i value=$i+1}
                                                    {/foreach}
                                                </tbody>
                                            </table>
                                            <input type="hidden" id="sizeColorItr" name="sizeColorItr" value="{$i}" />
                                        </div>
                                        <br />
                                        <div class="clearfix"></div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        {/if}
                    </table>
                    <!--==============================-->

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="submit" id="submit" class="btn btn-primary pull-left">تعديل</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div id="productUnitsDiv" style="display:none;">
            <option value="-1">اختر وحدة القياس</option>
            {foreach $unitsData as $unit}
            <option value="{$unit->unitId}">{$unit->unitName}</option>
            {/foreach}
        </div>
    </div>
</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", "real");
    var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9", "real");
    var sprytextfield10 = new Spry.Widget.ValidationTextField("sprytextfield10", "real");
    var sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11", "real");
    var sprytextfield12 = new Spry.Widget.ValidationTextField("sprytextfield12", "real");

    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {invalidValue: "-1"});
    $(function () {
        $('#reCalcUnitPrices').on('click', function () {
            $('[id^="productnumber"]').each(function () {
                var itr = $(this).attr('id').slice(13);
                var unitNum = Number($(this).val());
                var proUnitBuyPrice = unitNum * Number($('#productBuyPrice1').val());
                var proUnitSellAllPrice = unitNum * Number($('#productSellAllPrice').val());
                var proUnitSellHalfPrice = unitNum * Number($('#productSellHalfPrice').val());
                var proUnitSellUnitPrice = unitNum * Number($('#productSellUnitPrice').val());
                $('#proUnitBuyPrice' + itr).val(Number(proUnitBuyPrice.toFixed(3)));
                $('#proUnitSellAllPrice' + itr).val(Number(proUnitSellAllPrice.toFixed(3)));
                $('#proUnitSellHalfPrice' + itr).val(Number(proUnitSellHalfPrice.toFixed(3)));
                $('#proUnitSellUnitPrice' + itr).val(Number(proUnitSellUnitPrice.toFixed(3)));
            })
        })
        $('.unitInTaxClass').each(function () {
            var unitInTaxSelectID = $(this).attr('id');
            var old = $(this).data('old');
            $('#' + unitInTaxSelectID).select2({
                placeholder: "اختر",
                minimumInputLength: 0, // document.getElementById("searchvalue").value,
                multiple: false,
                quietMillis: 100,
                ajax: {
                    url: "eBillRequests.php?do=unit-types",
                    dataType: 'json',
                    data: function (term, page) {
                        return {
                            term: term, //search term
                        };
                    },
                    results: function (data) {
                        return {results: data};
                    }
                },
                formatResult: function (data) {
                    return data.text;
                },
                initSelection: function (element, callback) {
                    var item = element.val().split(':');
                    //  var data = {id: item[0], text: item[1]};
                    var data = {id: item[0], text: item[1]};
                    callback(data);
                },
                //dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
            });
            $('#' + unitInTaxSelectID).select2("data", {id: old, text: old});
        });
    });


</script>
{/literal}