<input type="hidden" name="printURL" id="printURL" value="{$printURL}" />
<script>
    var printURL = $('#printURL').val();
    if (printURL != "") {
        window.open(printURL);
    }
</script>
<style>
    .newoption {
        background-color: #CCCCCC !important;
        font-weight: bold !important;
    }
</style>

<div class="row">
    <div class="container {if $lang_code == 'en'} gt4-ltr{/if}">
        <ol class="breadcrumb">
            <li><a href="#">{$smarty.const.BUY_BILL_BILLING_MANAGEMENT}</a></li>
            <li><a href="#">{$smarty.const.BUY_BILL_PURCHASE_INVOICE}</a></li>
            <li class="active">{$smarty.const.BUY_BILL_ADD_INVOICE}</li>
        </ol>
        <!-- === start addrowcreated === -->
        <div id="addrowcreated" style="display:none">
            <option value="-1">{$smarty.const.BUY_BILL_SELECT}</option>
            {assign var=j value=0}
            {foreach $productsData as $product}
            <option value="{$product->productId}">{$names{$j}} {$product->productName} </option>
            {capture assign=j}{$j+1}{/capture}
            {/foreach}
        </div>

        <!-- === end addrowcreated === -->
        <h3>{$billnameAddData->name}</h3>
        <hr />
        <input type="hidden" name="searchWithCatAndProductNameOnly" id="searchWithCatAndProductNameOnly"
               value="{$billsettingsData[97]->billsettingsvalue}" />
        <input type="hidden" id="stopStoreSearch" value="1" />
        <input type="hidden" id="supplierWithAddOption" value="{$usergroup->addsupplierInBill}" />
        <input type="hidden" id="canEditAddDiscountPercentage" value="{$usergroup->canEditAddDiscountPercentage}"/>
        {literal}
        <form class="form-horizontal" role="form" action="buyBillController.php?do=add" method="post" id="billform"
              enctype="multipart/form-data" onsubmit="if (Spry.Widget.Form.validate(this)) {
                          $('#saveAndNew').css('display', 'none');
                          $('#saveBill').css('display', 'none');
                          return true;
                      } else {
                          return false;
                      }">
            {/literal}
            <!-- =========================== START BUY BILL SETTINGS ================================== -->
            <input type="hidden" name="valueaddeddiscount" id="valueaddeddiscount"
                   value="{$Programsettingdata->valueaddeddiscount}" />
            <input type="hidden" name="scunitnamevalue" id="scunitnamevalue"
                   value="{$Programsettingdata->scunitname}" />
            <input type="hidden" name="usedParcode" id="usedParcode" value="{$Programsettingdata->usedParcode}" />
            <input type="hidden" name="valueaddedbuy" id="valueaddedbuy" value="{$Programsettingdata->valueaddedbuy}" />
            <input type="hidden" value="{$Programsettingdata->enablequantityfractions}" id="enablequantityfractions" />

            <input type="hidden" name="productAndQuantityOnly" id="productAndQuantityOnly"
                   value="{$billnameAddData->productAndQuantityOnly}" />
            <input type="hidden" name="billtype2" id="billtype2" value="{$billnameAddData->billtype2}" />
            <input type="hidden" name="ordertype" id="ordertype" value="{$billnameAddData->ordertype}" />
            <input type="hidden" name="offerId" id="offerId" value="{$offerId}" />
            <input type="hidden" name="billnameid" id="billnameid" value="{$billnameid}" />
            <input type="hidden" name="returnBillSetting" id="returnBillSetting"
                   value="{$billsettingsData[0]->billsettingsvalue}" />
            <input type="hidden" name="storeSetting" id="storeSetting"
                   value="{$billsettingsData[2]->billsettingsvalue}" />
            <input type="hidden" name="parcodeSetting" id="parcodeSetting"
                   value="{$billsettingsData[4]->billsettingsvalue}" />
            <input type="hidden" name="dateSetting" id="dateSetting"
                   value="{$billsettingsData[5]->billsettingsvalue}" />
            <input type="hidden" name="newProductSetting" id="newProductSetting"
                   value="{$billsettingsData[6]->billsettingsvalue}" />
            <input type="hidden" name="noteSetting" id="noteSetting"
                   value="{$billsettingsData[7]->billsettingsvalue}" />
            <input type="hidden" name="productDiscountSetting" id="productDiscountSetting"
                   value="{$billsettingsData[8]->billsettingsvalue}" />
            <input type="hidden" name="productTaxSetting" id="productTaxSetting"
                   value="{$billsettingsData[96]->billsettingsvalue}" />
            <input type="hidden" name="quantityOrParcodeSetting" id="quantityOrParcodeSetting"
                   value="{$billsettingsData[9]->billsettingsvalue}" />
            <input type="hidden" name="payNumSetting" id="payNumSetting"
                   value="{$billsettingsData[11]->billsettingsvalue}" />
            <input type="hidden" name="unitSetting" id="unitSetting"
                   value="{$billsettingsData[53]->billsettingsvalue}" />
            <input type="hidden" name="commentSetting" id="commentSetting"
                   value="{$billsettingsData[12]->billsettingsvalue}" />
            <input type="hidden" name="searchvalue" id="searchvalue" value="{$Programsettingdata->searchvalue}" />
            <input type="hidden" name="discountrowtype" id="discountrowtype"
                   value="{$billsettingsData[34]->billsettingsvalue}" />
            <input type="hidden" name="payedSetting" id="payedSetting"
                   value="{$billsettingsData[71]->billsettingsvalue}" />
            <input type="hidden" name="saveBtnGoesTo" id="saveBtnGoesTo"
                   value="{$billsettingsData[75]->billsettingsvalue}" />
            <input type="hidden" name="userSaveCurrencyName" id="userSaveCurrencyName"
                   value="{$userSaveData->currencyName}" />
            <input type="hidden" name="userSaveconversionFactor" id="userSaveconversionFactor"
                   value="{$userSaveData->conversionFactor}" />
            <input type="hidden" name="oldCFactor" id="oldCFactor" value="0" />
            <input type="hidden" name="hideBillPrices" id="hideBillPrices" value="{$usergroup->hideBillPrices}" />
            <input type="hidden" name="withNakdi" id="withNakdi" value="{$usergroup->showClientAndSupplierOne}" />

            <input type="hidden" name="shownumber" id="shownumber" value="{$billsettingsData[40]->billsettingsvalue}" />
            <input type="hidden" id="checkRedundantProducts" value="{$billsettingsData[107]->billsettingsvalue}" />
            <input type="hidden" id="proNumType" value="{$billsettingsData[113]->billsettingsvalue}" />


            <!-- ==========================  END BUY BILL SETTINGS ============================ -->

            <!-- =========================== START GENERAL INFO PANEL =====================-->
            <div class="row">


                <div class="col-lg-8">
                    <div class="form-group mg-bt5" {if {$billsettingsData[45]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_COST_CENTER}</label>
                        <div class="col-lg-4">

                            <select class="select2 wdt100" name="Costcenter" id="Costcenter">


                                <option value="-1">{$smarty.const.BUY_BILL_SELECT_COST_CENTER}</option>
                                {foreach $allCostcenter as $myallCostcenter}



                                <option value="{$myallCostcenter->id}">{$myallCostcenter->name}</option>

                                {/foreach}


                            </select>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    {if $Programsettingdata->clientserial eq 1}
                    <div class="form-group">
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_SERIAL_NUMBER}</label>
                        <div class="col-lg-4">
                            <input type="text" value="{$nextId}" class="form-control" disabled readonly />
                        </div>
                    </div>
                    {/if}

                    <div class="form-group" {if $billsettingsData[61]->billsettingsvalue eq 0} {else}
                        style="display:none !important;" {/if}>
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_INVOICE_NUMBER}</label>
                        <div class="col-lg-4">
                            <input name="pay_num" id="pay_num" type="text" value="{$unique}" class="form-control" />
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group" {if $billsettingsData[48]->billsettingsvalue eq 0} {else}
                        style="display:none !important;" {/if}>
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_PAYMENT_PROCESS}</label>
                        <div class="col-lg-4">
                            <input name="pay_num_optional" id="pay_num_optional" class="form-control" type="text"
                                   tabindex="1" />
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group" {if $billsettingsData[5]->billsettingsvalue eq 0} {else} style="display:none
                        !important;" {/if}>
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_INVOICE_DATE}</label>
                        <div class="col-lg-4">
                            <!--input name="bn" type="text" class=" form-control awdatepicker" autocomplete="off"  data-date-format="yyyy-mm-dd" id="bn" value="{$today}" placeholder="تاريخ الفاتورة" {if $Programsettingdata->allowdateedit == 1}disabled="disabled"{/if} tabindex="2"/-->
                            {if $Programsettingdata->allowdateedit == 1}
                            <input type="text" class="form-control" placeholder="{$smarty.const.BUY_BILL_INVOICE_DATE}"
                                   readonly
                                   value="{if isset($billFromExcel_date)&& $billFromExcel_date !=''}{$billFromExcel_date}{else}{$today}{/if}"
                                   name="bn" id="bn">
                            {else}
                            <div class="input-group date form_datetime col-md-5" data-date=""
                                 data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                <input class="form-control" size="16" type="text"
                                       value="{if isset($billFromExcel_date)&& $billFromExcel_date !=''}{$billFromExcel_date}{else}{$today}{/if}"
                                       name="bn" id="bn readonly="" >
                                <span class=" input-group-addon "><span class=" glyphicon glyphicon-remove
                                                                        col-lg-4"></span></span>
                                <span class="input-group-addon"><span
                                        class="glyphicon glyphicon-th col-lg-4"></span></span>
                            </div>
                            {/if}
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>
                <!-- end of bill no-->
                <div class="col-lg-4">
                    <div class="form-group mg-bt5" {if $billsettingsData[1]->billsettingsvalue eq 0} {else}
                        style="display:none !important;" {/if}>
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_SUPPLIER_NAME}</label>
                        <div class="col-lg-8">
                            <span id="spryselect1">
                                <div id="supplierIdDiv">

                                    <input type="hidden" name="supplier" id="supplier" class="select2Supp" />
                                    <input type="hidden" name="oldsupplierid" id="oldsupplierid"
                                           value="{$mysupplierdata->supplierid}" />
                                    <input type="hidden" name="oldsuppliername" id="oldsuppliername"
                                           value="{$mysupplierdata->suppliername}" />


                                </div>
                                <input type="hidden" value="{$buyBillData->buybillsupplierid}"
                                       name="buybillsupplierid" />
                                <span class="selectInvalidMsg">{$smarty.const.BUY_BILL_CHOOSE_SUPPLIER}</span>
                            </span>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5" {if {$billsettingsData[56]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_DEBT_BALANCE}</label>
                        <div class="col-lg-8">
                            <div id="debt" class="form-control-static">{$mysupplierdata->suppliercurrentDebt} </div>
                            <input name="hidden_debt" id="hidden_debt" type="hidden"
                                   value="{$mysupplierdata->suppliercurrentDebt}" class="form-control" tabindex="4" />
                            <span class="aw_ras"><a id="editdebt" style="display:none;"
                                                    href="#">{$smarty.const.BUY_BILL_EDIT}</a></span>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <hr class="mg-bt5 mg-tp5" />
                    <div class="form-group mg-bt5" {if $billsettingsData[115]->billsettingsvalue eq 0} style="display:none !important;" {/if}>
                        <label class="col-lg-4 control-label">العميل</label>
                        <div class="col-lg-8">
                            <input type="hidden" name="client" id="client" class="select2client" />
                            <input type="hidden" name="oldclientid" id="oldclientid" value="{$myclientdata->clientid}" />
                            <input type="hidden" name="oldclientname" id="oldclientname" value="{$myclientdata->clientname}" />
                        </div>
                    </div>
                    <div class="form-group mg-bt5" {if $billsettingsData[2]->billsettingsvalue eq 0} {else}
                        style="display:none !important;" {/if}>

                        {if $userdata->userstoreid eq 0}


                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_STORE}</label>
                        <div class="col-lg-8">
                            <select name="storeId" id="storeId" data-placeholder="{$smarty.const.BUY_BILL_SELECT}"
                                    class="select2 wdt100 aw_m1" tabindex="5">
                                {if $usergroup->dontChooseStore == 1}<option value="-1"></option>{/if}
                                {foreach $storesData as $store}



                                <option value="{$store->storeId}" {if {$buyBillData->buybillstoreid} eq
                                    {$store->storeId} || ($userdata->userstoreidDef eq
                                    $store->storeId && $usergroup->dontChooseStore ==0)}selected{/if}>{$store->storeName}</option>



                                {/foreach}



                            </select>
                        </div>
                        {else}

                        <input name="storeId" id="storeId" type="hidden"
                               value="{if isset($buyBillData->buybillstoreid) && $buyBillData->buybillstoreid > 0}{$buyBillData->buybillstoreid}{else}{$userdata->userstoreid}{/if}" />

                        {if isset($buyBillData->buybillstoreid) && $buyBillData->buybillstoreid > 0}

                        {foreach $storesData as $store}
                        {if {$store->storeId} eq {$buyBillData->buybillstoreid}}
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_STORE}</label>
                        <div class="col-lg-8"> {$store->storeName}</div>
                        {/if}
                        {/foreach}

                        {else}

                        {foreach $storesData as $store}
                        {if {$store->storeId} eq {$userdata->userstoreid}}
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_STORE}</label>
                        <div class="col-lg-8"> {$store->storeName}</div>
                        {/if}
                        {/foreach}

                        {/if}



                        {/if}
                    </div>

                    <!-- end of form-group-->
                    {if {$billsettingsData[87]->billsettingsvalue} neq 1}
                    <input type="hidden" name="saveid" value="{$sessionSave}" />
                    {else}
                    <div {if {$billsettingsData[87]->billsettingsvalue} eq 1} {else} style="display:none" {/if} >
                        <div class="form-group mg-bt5">
                            <label class="col-lg-4 col-sm-4 control-label">الخزنة</label>
                            <div class="col-lg-8 col-sm-8">
                                <select class="select2 wdt100 autoSaveBillMainPart" name="saveid" id="saveid">
                                    {foreach $allSaves as $data}
                                    <option value="{$data->saveid}" data-curr={$data->currencyId} {if ($manyParcodes ==
                                        1 && ($mysellbilldata->sellbillsaveid ==
                                        $data->saveid||$mysellbilldata->returnsellbillsaveid ==
                                        $data->saveid||$manyParcodesSaveid == $data->saveid))||( $manyParcodes != 1
                                        &&$sessionSave eq $data->saveid)} selected="selected" {/if}>{$data->savename}
                                    </option>

                                    {/foreach}
                                </select>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!--only currency allowed now is supplier currency ,,, till we manage it in php-->
                    <div class="form-group mg-bt5 hidden" {if $Programsettingdata->showCurrency !=
                        1}style="display:none;"{/if}>
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_CURRENCY}</label>
                        <div class="col-lg-8">
                            <select class="select2" name="currencyId" id="currencyId">
                                {foreach $allCurrency as $data}
                                <option value="{$data->id}" data-cfactor="{$data->conversionFactor}"
                                        data-othercfactor="{$data->otherconversionFactor}">{$data->name}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="clear"></div>
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_CONVERSION_FACTOR}</label>
                        <div class="col-lg-8">
                            <input type="text" name="cFactor" id="cFactor" class="form-control positivefloat calcOther"
                                   onkeyup="populateDebtAfter();" style="display: inline-block;width: 34%" />
                            =
                            <div class="input-group" style="display: inline;">
                                <input type="text" name="otherCFactor" id="otherCFactor"
                                       class="form-control positivefloat calcOther"
                                       style="display: inline-block;width: 34%" />
                                <span class="input-group-addon"
                                      style="display: inline-block;width: 23%">{$currency}</span>
                            </div>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5" {if $billsettingsData[12]->billsettingsvalue eq 0} {else}
                        style="display:none !important;" {/if}>
                        <label class="col-lg-4 control-label">{$smarty.const.BUY_BILL_COMMENT}</label>
                        <div class="col-lg-8">
                            <textarea name="comment" id="comment" cols="" rows="" class="form-control"
                                      tabindex="6">{$buyBillData->comment}</textarea>
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>
                <!-- end of client info-->

            </div>
            <!-- =========================== END GENERAL INFO PANEL ====================== -->
            <!-- التحكم فى استخدام نسب الخصم -->
            <input type="hidden" name="hide_discount" id="hide_discount"
                   value="{$billsettingsData[63]->billsettingsvalue}" />
            <input type="hidden" name="realprice_precentage1" value="0" id='realprice_precentage1' />
            <input type="hidden" name="realprice_precentage_re1" value="0" id='realprice_precentage_re1' />

            <!-- =========================== START BUY BILL PANEL ======================= -->
            <div class="row" {if $billsettingsData[14]->billsettingsvalue eq 0} {else} style="display:none !important;"
                {/if}>
                <div class="row">
                    <hr />
                    <div class="col-lg-6">
                        <h4>{$smarty.const.BUY_BILL_BUY}</h4>
                    </div>
                    <div class="col-lg-6">
                        <button type="button" name="addpro" id="addpro"
                                class="btn btn-primary pull-left ft-nor">{$smarty.const.BUY_BILL_ADD_NEW} </button>
                        <button type="button" style="display:none;" name="addpro" id="addpro"
                                class="btn btn-primary pull-left ft-nor">{$smarty.const.BUY_BILL_ADD_NEW}</button>
                        <button type="button" onclick="$('#billAsExcelFile').click();" name="billAsExcel"
                                id="billAsExcel" class="btn btn-success pull-left ft-nor"
                                style="margin-left:3px;">{$smarty.const.BUY_BILL_EXCEL}</button>
                        <button type="button" class="btn btn-primary pull-left ft-nor addProSizeColor"
                                style="margin-left:3px;">{$smarty.const.BUY_BILL_ADD_PRO_SIZE_COLOR} </button>
                    </div>
                </div>
                <!-- end of title row-->
                <div class="table-responsive bd-gr">
                    <table class="table billtable table-bordered table-black" id="containerpros">
                        <thead>
                            <tr>
                                <th class="wdt60" {if $billsettingsData[6]->billsettingsvalue eq 0} {else}
                                    style="display:none !important;" {/if}>{$smarty.const.BUY_BILL_NEW}</th>
                                <th class="wdt20" {if {$billsettingsData[40]->billsettingsvalue} eq 0} {else}
                                    style="display:none !important;" {/if}>{$smarty.const.BUY_BILL_NUMBER}</th>
                                <th
                                    class="wdt120 check_tr_parcode {if {$billsettingsData[4]->billsettingsvalue} eq 1}  hidden {/if}">
                                    {$smarty.const.BUY_BILL_BARCODE}</th>
                                <th class="wdt400">{$smarty.const.BUY_BILL_PRODUCT_NAME}</th>
                                <th class="wdt240" {if $billsettingsData[7]->billsettingsvalue eq 0} {else}
                                    style="display:none !important;" {/if}>{$smarty.const.BUY_BILL_NOTES}</th>
                                <th
                                    class="wdt100n check_tr_unit {if {$billsettingsData[53]->billsettingsvalue} eq 1}  hidden {/if}">
                                    {$smarty.const.BUY_BILL_UNIT}</th>



                                <th
                                    class="wdt100n check_tr_quantity {if {$billsettingsData[64]->billsettingsvalue} eq 1}  hidden {/if}">
                                    {$smarty.const.BUY_BILL_QUANTITY}</th>

                                <th class="wdt100n   {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    {$Programsettingdata->scunitname}</th>

                                <th class="wdt80 {if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    {$smarty.const.BUY_BILL_PRICE}</th>
                                <th
                                    class="wdt80 check_tr_discount {if $usergroup->hideBillPrices == 1}hidden{/if} {if {$billsettingsData[8]->billsettingsvalue} eq 1}  hidden {/if}">
                                    {$smarty.const.BUY_BILL_DISCOUNT}</th>
                                <th
                                    class="wdt80 check_tr_tax {if $usergroup->hideBillPrices == 1}hidden{/if} {if {$billsettingsData[96]->billsettingsvalue} eq 1}  hidden {/if}">
                                    {$smarty.const.BUY_BILL_ROW_TAX}</th>
                                <!--<th class="wdt100n" {if $billnameAddData->productAndQuantityOnly eq 1} style="display:none !important;" {/if}>الاجمالى-->
                                <th class="wdt100n buydiscountClass {if $Programsettingdata->showbuydiscount != 1}hidden{/if}">النسبه</th>
                                <th class="wdt100n {if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    {$smarty.const.BUY_BILL_TOTAL}
                                    <input name="hidden_itr" id="hidden_itr" type="hidden"
                                           value="{if (isset($billFromExcel_date)&& $billFromExcel_date !='') || $offerId>0}{$countBillDetails}{else}1{/if}" />
                                </th>
                                <th class="wdt80">{$smarty.const.BUY_BILL_DELETE}</th>
                            </tr>
                        </thead>
                        <tbody>
                            {assign var=piecesCount value=0}
                            {if $countBillDetails > 0}<!-- having products from excel -->

                            {assign var=x value=1}

                            {foreach $buyBillDetails as $mybuyBillDetails}
                            <tr id="newProduct{$x}">
                                <td {if $billsettingsData[6]->billsettingsvalue eq 0} {else} style="display:none
                                    !important;" {/if}><a onClick="javascript:showModalBox(this.name);"
                                                          class="newLink btn btn-primary  btn-xs conformdel" id="new1"
                                                          name="1">{$smarty.const.BUY_BILL_NEW}</a></td>
                                <td {if {$billsettingsData[40]->billsettingsvalue} eq 0} {else} style="display:none
                                    !important;" {/if}>{$mybuyBillDetails@iteration}</td>
                                <td {if {$billsettingsData[4]->billsettingsvalue} eq 0} {else} style="display:none"
                                    {/if}>
                                    <input type="text" class="form-control txt-nonraduis"
                                           placeholder="{$smarty.const.BUY_BILL_BARCODE}" name="parcode{$x}"
                                           id="parcode{$x}" value="{$mybuyBillDetails->parcode}"
                                           onKeyPress="getproductbyParcode(event, this.value, {$x});" autocomplete="off"
                                           tabindex="7">
                                </td>
                                <td>
                                    <div id="productdiv{$x}">
                                        <input type="hidden" id="product{$x}" name="product{$x}"
                                               data-placeholder="{$smarty.const.BUY_BILL_SELECT}"
                                               class="select2product wdt100" tabindex="7" />
                                        <input type="hidden" id="oldproduct{$x}" name="oldproduct{$x}"
                                               value="{if $mybuyBillDetails->sizeid > 0 && $mybuyBillDetails->colorid > 0}hasSizeColor{$mybuyBillDetails->buybilldetailproductid}-{$mybuyBillDetails->sizeid}-{$mybuyBillDetails->colorid}{else}{$mybuyBillDetails->buybilldetailproductid}{/if}" />
                                        <input type="hidden" id="oldname{$x}" name="oldname{$x}"
                                               value="{$mybuyBillDetails->productName}
                                               {if $mybuyBillDetails->sizeName != ''}/ {$mybuyBillDetails->sizeName}{/if}
                                               {if $mybuyBillDetails->colorName != ''}/ {$mybuyBillDetails->colorName}{/if}" />
                                    </div>


                                </td>
                                <td {if $billsettingsData[7]->billsettingsvalue eq 0} {else} style="display:none
                                    !important;" {/if}>
                                    <textarea class="form-control txt-nonraduis" rows="1" name="note{$x}" id="note{$x}"
                                              tabindex="7">{$mybuyBillDetails->note}</textarea>
                                </td>
                                <td
                                    class=" check_tr_unit {if {$billsettingsData[53]->billsettingsvalue} eq 0}  {else} hidden {/if}">
                                    <div id="unitDiv{$x}">
                                        <select name="unitId{$x}" id="unitId{$x}" size="3"
                                                onchange="getUnitPrice({$x});"
                                                data-placeholder="{$smarty.const.BUY_BILL_SELECT}"
                                                class="select2 aw_m1 wdt100 chosenproduct" tabindex="7">
                                            <option value="-1"></option>
                                            {assign var=ui value=1}
                                            {foreach $myunitdata{$x} as $mymyunitdata}
                                            <!--<option   {if {$mybuyBillDetails->productunitid} eq {$mymyunitdata->productunitid} } selected="selected"  {/if}   value="{$mymyunitdata->productunitid}" >{$mymyunitdata->unitName}</option>-->
                                            <option {if $ui==1 } selected="selected" {/if}
                                                    value="{$mymyunitdata->productunitid}">{$mymyunitdata->unitName}
                                            </option>
                                            {assign var=ui value=$ui+1}
                                            {/foreach}

                                        </select>
                                    </div>
                                </td>
                                <td
                                    class="check_tr_quantity {if {$billsettingsData[64]->billsettingsvalue} eq 0} {else}  hidden   {/if}">
                                    <input name="pronum{$x}" id="pronum{$x}"
                                           class="form-control getprototal numberclic enteraction numberinput txt-nonraduis {if $billsettingsData[113]->billsettingsvalue == 1} positiveNo {else} positivefloat {/if}"
                                           placeholder="{$smarty.const.BUY_BILL_QUANTITY}" type="text" tabindex="7"
                                           value="{$mybuyBillDetails->buybilldetailquantity}" />
                                    {assign var=piecesCount value=$piecesCount+$mybuyBillDetails->buybilldetailquantity}
                                </td>

                                <td class="  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    <input name="scunitname{$x}" id="scunitname{$x}"
                                           value="{$mybuyBillDetails->otherdetailquantity}"
                                           class="form-control txt-nonraduis positiveNo"
                                           placeholder="{$smarty.const.BUY_BILL_QUANTITY}" type="text" tabindex="7" />
                                </td>
                                <td class="{if $usergroup->hideBillPrices == 1}hidden{/if}" {if $billnameAddData->
                                    productAndQuantityOnly eq 1} style="display:none !important;" {/if}>
                                    <div id="propricechange{$x}">
                                        <input name="proprice{$x}" id="proprice{$x}"
                                               placeholder="{$smarty.const.BUY_BILL_PRICE}"
                                               class="form-control txt-nonraduis getprototal numberclic enteraction numberinput positivefloat"
                                               type="text" value="{$mybuyBillDetails->buybilldetailprice}" tabindex="7" />
                                    </div>
                                </td>
                                <td class="{if $usergroup->hideBillPrices == 1}hidden{/if}" {if $billsettingsData[8]->
                                    billsettingsvalue eq 0&& $billnameAddData->productAndQuantityOnly eq 0} {else}
                                    style="display:none !important;" {/if}>
                                    <input name="prodis{$x}" id="prodis{$x}" value="{$mybuyBillDetails->discountvalue}"
                                           class="form-control getprototal numberonly enteraction numberinput txt-nonraduis positiveNo"
                                           placeholder="{$smarty.const.BUY_BILL_DISCOUNT}" tabindex="7" {if
                                           {$billsettingsData[34]->billsettingsvalue} eq 0} type="text" {else}
                                    type="hidden" {/if}/>
                                    <input name="discounttype{$x}" id="discounttype{$x}"
                                           value="{$mybuyBillDetails->discounttype}"
                                           class="form-control getprototal numberonly enteraction numberinput txt-nonraduis positivefloat"
                                           tabindex="7" {if {$billsettingsData[34]->billsettingsvalue} eq 1} type="text"
                                    {else} type="hidden" {/if}/>
                                </td>
                                <td class="{if $usergroup->hideBillPrices == 1}hidden{/if}" {if $billsettingsData[96]->
                                    billsettingsvalue eq 0&& $billnameAddData->productAndQuantityOnly eq 0} {else}
                                    style="display:none !important;" {/if}>
                                    <input name="rowtaxval{$x}" id="rowtaxval{$x}"
                                           value="{$mybuyBillDetails->rowtaxval}"
                                           class="form-control getprototal numberonly enteraction numberinput txt-nonraduis positiveNo"
                                           placeholder="{$smarty.const.BUY_BILL_ROW_TAX}" type="hidden" />
                                    <input name="rowtaxper{$x}" id="rowtaxper{$x}"
                                           value="{$mybuyBillDetails->rowtaxper}"
                                           class="form-control getprototal numberonly enteraction numberinput txt-nonraduis positiveNo"
                                           tabindex="7" type="text" />
                                </td>
                                <td class="buydiscountClass {if $Programsettingdata->showbuydiscount != 1}hidden{/if}">
                                    {if $usergroup->canEditAddDiscountPercentage != 1}<span id="probuyDiscountPer_span{$x}">{$mybuyBillDetails->probuyDiscountPer}</span>{/if}
                                    <input name="probuyDiscountPer{$x}" id="probuyDiscountPer{$x}" value="{$mybuyBillDetails->probuyDiscountPer}"
                                           class="form-control txt-nonraduis positiveNo probuyDiscountPerClass getprototal" tabindex="7"
                                           {if $usergroup->canEditAddDiscountPercentage == 1}type="text"{else}type="hidden"{/if} />
                                </td>
                                <td class="aw_totalprice {if $usergroup->hideBillPrices == 1}hidden{/if}" {if
                                    $billnameAddData->productAndQuantityOnly eq 1} style="display:none !important;"
                                    {/if}>
                                    <!--                                        <div id="prototal{$x}" class="aw_mt form-control-static"> {$mybuyBillDetails->buybilldetailtotalprice} {$currency}</div>
                                                                            <input name="hidden_prototal{$x}" id="hidden_prototal{$x}" type="hidden" value="{$mybuyBillDetails->buybilldetailtotalprice}"  tabindex="7"/>-->

                                    <input name="hidden_prototal{$x}" id="hidden_prototal{$x}"
                                           class="editTotal form-control txt-nonraduis enteraction numberinput positiveNo"
                                           value="{$mybuyBillDetails->buybilldetailtotalprice}" type="text" />
                                </td>
                                <td>
                                    <button type="button" id="remove{$x}" class="removeproduct close flt-none"
                                            aria-hidden="true" onclick="removeproduct({$x});">&times;</button>
                                </td>
                            </tr>

                            {capture assign=x}{$x+1}{/capture}
                            {/foreach}

                            {else}
                            <tr id="newProduct1">
                                <td {if $billsettingsData[6]->billsettingsvalue eq 0} {else} style="display:none
                                    !important;" {/if}><a onClick="javascript:showModalBox(this.name);"
                                                          class="newLink btn btn-primary  btn-xs conformdel" id="new1"
                                                          name="1">{$smarty.const.BUY_BILL_NEW}</a></td>
                                <td {if {$billsettingsData[40]->billsettingsvalue} eq 0} {else} style="display:none
                                    !important;" {/if}>1</td>
                                <td
                                    class="check_tr_parcode {if {$billsettingsData[4]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <input type="text" class="form-control txt-nonraduis"
                                           placeholder="{$smarty.const.BUY_BILL_BARCODE}" name="parcode1" id="parcode1"
                                           onKeyPress="getproductbyParcode(event, this.value, 1);" autocomplete="off"
                                           tabindex="7">
                                </td>
                                <td>
                                    {if $billnameAddData->billtype2 == "1"}
                                    <div style="display: inline">
                                        <select class="select2 productCat productCat1" style="display: inline"
                                                data-level="0" data-itr="1" name="productCatId0_1" id="productCatId0_1">
                                            <option value="-1">{$smarty.const.BUY_BILL_CHOOSE_RATING}</option>
                                            {foreach $catDataReport as $data}
                                            <option value="{$data->productCatId}">{$data->productCatName}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                    <input type="hidden" id="level_1" data-itr="1" name="level_1" value="0">
                                    <div id="manyParents_1" data-itr="1" style="display: inline">

                                    </div>
                                    {else}
                                    <!-- product -->
                                    <div id="productdiv1">
                                        <input type="hidden" id="product1" name="product1"
                                               data-placeholder="{$smarty.const.BUY_BILL_SELECT}"
                                               class="select2product wdt100" tabindex="7" />
                                    </div>
                                    {/if}
                                </td>
                                <td {if $billsettingsData[7]->billsettingsvalue eq 0} {else} style="display:none
                                    !important;" {/if}>
                                    <textarea class="form-control txt-nonraduis" rows="1" name="note1" id="note1"
                                              tabindex="7"></textarea>
                                </td>
                                <td
                                    class="check_tr_unit {if {$billsettingsData[53]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <!-- unit -->
                                    <div id="unitDiv1">
                                        <select name="unitId1" id="unitId1" size="3" onchange="getUnitPrice(1);"
                                                data-placeholder="{$smarty.const.BUY_BILL_SELECT}"
                                                class="select2 aw_m1 wdt100 chosenproduct" tabindex="7">
                                        </select>
                                    </div>
                                </td>


                                <td
                                    class="check_tr_quantity {if {$billsettingsData[64]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <input name="pronum1" id="pronum1" value="1"
                                           class="form-control getprototal numberclic enteraction numberinput txt-nonraduis {if $billsettingsData[113]->billsettingsvalue == 1} positiveNo {else} positivefloat {/if}"
                                           placeholder="{$smarty.const.BUY_BILL_DELETE}" type="text" tabindex="7" />
                                </td>

                                <td class="  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    <input name="scunitname1" id="scunitname1" value="0"
                                           class="form-control txt-nonraduis positiveNo"
                                           placeholder="{$smarty.const.BUY_BILL_DELETE}" type="text" tabindex="7" />
                                </td>
                                <td class="{if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    <!-- price -->
                                    <div id="propricechange1">
                                        <input name="proprice1" id="proprice1"
                                               placeholder="{$smarty.const.BUY_BILL_PRICE}" value="0"
                                               class="form-control txt-nonraduis getprototal numberclic enteraction numberinput positivefloat"
                                               type="text" tabindex="7" />
                                    </div>
                                </td>
                                <td
                                    class="check_tr_discount {if $usergroup->hideBillPrices == 1}hidden{/if} {if {$billsettingsData[8]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <input name="prodis1" id="prodis1" value="0"
                                           class="form-control getprototal numberonly enteraction numberinput txt-nonraduis positiveNo"
                                           placeholder="{$smarty.const.BUY_BILL_DISCOUNT}" tabindex="7" {if
                                           {$billsettingsData[34]->billsettingsvalue} eq 0} type="text" {else}
                                    type="hidden" {/if}/>
                                    <input name="discounttype1" id="discounttype1" value="0"
                                           class="form-control getprototal numberonly enteraction numberinput txt-nonraduis positivefloat"
                                           tabindex="7" {if {$billsettingsData[34]->billsettingsvalue} eq 1} type="text"
                                    {else} type="hidden" {/if}/>
                                </td>
                                <td class="{if $usergroup->hideBillPrices == 1}hidden{/if}" {if $billsettingsData[96]->
                                    billsettingsvalue eq 0&& $billnameAddData->productAndQuantityOnly eq 0} {else}
                                    style="display:none !important;" {/if}>
                                    <input name="rowtaxval1" id="rowtaxval1" value="0"
                                           class="form-control getprototal numberonly enteraction numberinput txt-nonraduis positiveNo"
                                           placeholder="{$smarty.const.BUY_BILL_ROW_TAX}" type="hidden" />
                                    <input name="rowtaxper1" id="rowtaxper1" value="0"
                                           class="form-control getprototal numberonly enteraction numberinput txt-nonraduis positiveNo"
                                           tabindex="7" type="text" />
                                </td>
                                <td class="{if $Programsettingdata->showbuydiscount != 1}hidden{/if}">
                                    {if $usergroup->canEditAddDiscountPercentage != 1}<span id="probuyDiscountPer_span1">0</span>{/if}
                                    <input name="probuyDiscountPer1" id="probuyDiscountPer1" value="0"
                                           class="form-control txt-nonraduis positiveNo probuyDiscountPerClass getprototal" tabindex="7"
                                           {if $usergroup->canEditAddDiscountPercentage == 1}type="text"{else}type="hidden"{/if} />
                                </td>
                                <td class="aw_totalprice {if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    <!--<td class="aw_totalprice" {if $billnameAddData->productAndQuantityOnly eq 1} style="display:none !important;" {/if}>-->
                                    <!--                                    <div id="prototal1" class="aw_mt form-control-static">0 {$currency}</div>
                                                                        <input name="hidden_prototal1" id="hidden_prototal1" type="hidden" value="0"  tabindex="7"/>-->

                                    <input name="hidden_prototal1" id="hidden_prototal1"
                                           class="editTotal form-control txt-nonraduis enteraction numberinput positiveNo"
                                           value="0" type="text" />

                                </td>
                                <td>
                                    <button type="button" id="remove1" class="removeproduct close flt-none"
                                            aria-hidden="true" onclick="removeproduct(1);">&times;</button>
                                </td>
                            </tr>
                            {/if}
                        </tbody>
                    </table>
                </div>
                <button type="button"
                        class="btn btn-primary pull-left ft-nor {if $usergroup->hideBillPrices == 1}hidden{/if}">{$smarty.const.BUY_BILL_TOTAL_BUY}<span
                        class="badge wht-clo">
                        <div id="buyBillTotal">0</div>
                        <input type="hidden" value="0" name="totalBuyBill" id="totalBuyBill" />
                    </span></button>
            </div>
            <!-- end of second row-->
            <!-- =========================== END BUY BILL PANEL ==================== -->

            <!-- =========================== START RETURN BUY BILL PANEL ====================== -->
            <div class="row" {if $billsettingsData[0]->billsettingsvalue eq 0} {else} style="display:none !important;"
                {/if}>

                <div class="row">
                    <hr />
                    <div class="col-lg-6">
                        <h4>{$smarty.const.RETURN_BUY_BILL_BUY_RETURNS}</h4>
                    </div>
                    <div class="col-lg-6">
                        <button type="button" name="addpro_re" id="addpro_re" class="btn btn-primary  pull-left ft-nor">
                            {$smarty.const.BUY_BILL_ADD_NEW}</button>
                        <button type="button" style="display:none !important;" name="addpro_re" id="addpro_re"
                                class="btn btn-primary pull-left ft-nor"> {$smarty.const.BUY_BILL_ADD_NEW}</button>
                    </div>
                </div>
                <!-- end of title row-->
                <div class="table-responsive bd-rd">
                    <table class="table billtable table-bordered table-black" id="containerpros_re">
                        <thead>
                            <tr>
                                <th class="wdt20" {if {$billsettingsData[40]->billsettingsvalue} eq 0} {else}
                                    style="display:none !important;" {/if}>{$smarty.const.BUY_BILL_NUMBER}</th>
                                <th
                                    class="check_tr_parcode {if {$billsettingsData[4]->billsettingsvalue} eq 1}  hidden {/if}">
                                    {$smarty.const.BUY_BILL_BARCODE}</th>
                                <th class="wdt400">{$smarty.const.BUY_BILL_PRODUCT_NAME}</th>
                                <th class="wdt240" {if $billsettingsData[7]->billsettingsvalue eq 0} {else}
                                    style="display:none !important;" {/if}>{$smarty.const.BUY_BILL_NOTES}</th>
                                <th
                                    class="wdt100n check_tr_unit {if {$billsettingsData[53]->billsettingsvalue} eq 1}  hidden {/if}">
                                    {$smarty.const.BUY_BILL_UNIT}</th>
                                <th
                                    class="wdt100n check_tr_quantity {if {$billsettingsData[64]->billsettingsvalue} eq 1}  hidden {/if}">
                                    {$smarty.const.BUY_BILL_QUANTITY}</th>
                                <!--------------- الوحده الاخرى--------->
                                <th class="wdt100n   {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    {$Programsettingdata->scunitname}</th>

                                <th class="wdt80 {if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    {$smarty.const.BUY_BILL_PRICE}</th>
                                <th
                                    class="wdt80 check_tr_discount {if $usergroup->hideBillPrices == 1}hidden{/if} {if {$billsettingsData[8]->billsettingsvalue} eq 1}  hidden {/if}">
                                    {$smarty.const.BUY_BILL_DISCOUNT}</th>
                                <th
                                    class="wdt80 check_tr_tax {if $usergroup->hideBillPrices == 1}hidden{/if} {if {$billsettingsData[96]->billsettingsvalue} eq 1}  hidden {/if}">
                                    {$smarty.const.BUY_BILL_ROW_TAX}</th>
                                <th class="wdt100n {if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    {$smarty.const.BUY_BILL_TOTAL}
                                    <input name="hidden_itr_re" id="hidden_itr_re" type="hidden" value="1" />
                                </th>
                                <th class="wdt80">{$smarty.const.BUY_BILL_DELETE}</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td {if {$billsettingsData[40]->billsettingsvalue} eq 0} {else} style="display:none
                                    !important;" {/if}>1</td>
                                <td
                                    class="check_tr_parcode {if {$billsettingsData[4]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <input name="parcode_re1" type="text" id="parcode_re1"
                                           class="form-control  txt-nonraduis"
                                           placeholder="{$smarty.const.BUY_BILL_BARCODE}"
                                           onkeypress="getreturnproductbyParcode(event, this.value, 1);" autocomplete="off"
                                           tabindex="301" />
                                </td>

                                <td><!-- اسم المنتج -->
                                    {if $billnameAddData->billtype2 == "1"}
                                    <div style="display: inline">
                                        <select class="select2 productCat_re productCat_re1" style="display: inline"
                                                data-level="0" data-itr="1" name="productCatId_re0_1"
                                                id="productCatId_re0_1">
                                            <option value="-1">{$smarty.const.BUY_BILL_CHOOSE_RATING}</option>
                                            {foreach $catDataReport as $data}
                                            <option value="{$data->productCatId}">{$data->productCatName}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                    <input type="hidden" id="level_re_1" data-itr="1" name="level_re_1" value="0">
                                    <div id="manyParents_re_1" data-itr="1" style="display: inline">

                                    </div>
                                    {else}
                                    <!-- product -->
                                    <div id="productdiv_re1">
                                        <input type="hidden" id="product_re1" name="product_re1"
                                               data-placeholder="{$smarty.const.BUY_BILL_SELECT}"
                                               class="select2product_re wdt100" tabindex="301" />
                                    </div>
                                    {/if}
                                </td>

                                <td {if $billsettingsData[7]->billsettingsvalue eq 0} {else} style="display:none
                                    !important;" {/if}>
                                    <input name="note_re1" id="note_re1" type="text" class="form-control  txt-nonraduis"
                                           tabindex="301" />
                                </td>

                                <!-- الوحدة -->
                                <td class="check_tr_unit {if {$billsettingsData[53]->billsettingsvalue} eq 1}  hidden {/if}"">
                                    <div id="unitDiv_re1">
                                        <select name="unitId_re1" id="unitId_re1" onchange="return_getUnitPrice(1);"
                                                data-placeholder="{$smarty.const.BUY_BILL_SELECT}"
                                                class="select2 aw_m1 wdt100 chosenproduct" tabindex="301">
                                        </select>
                                    </div>
                                </td>

                                <td class="check_tr_quantity {if {$billsettingsData[64]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <input name="pronum_re1" id="pronum_re1" value="1"
                                           class="form-control return_getprototal numberclic txt-nonraduis enteraction numberinput {if $billsettingsData[113]->billsettingsvalue == 1} positiveNo {else} positivefloat {/if}"
                                           placeholder="{$smarty.const.BUY_BILL_QUANTITY}" type="text" tabindex="301" />
                                </td>

                                <td class="  {if {$Programsettingdata->scunitname} eq '0'}  hidden {/if}">
                                    <input name="scunitname_re1" id="scunitname_re1" value="0"
                                           class="form-control txt-nonraduis positivefloat" placeholder="{$smarty.const.BUY_BILL_QUANTITY}"
                                           type="text" tabindex="7" />
                                </td>
                                <td class="{if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    <div id="propricechange_re1">
                                        <input name="proprice_re1" id="proprice_re1" placeholder="{$smarty.const.BUY_BILL_PRICE}"
                                               value="0"
                                               class="form-control txt-nonraduis return_getprototal numberclic enteraction numberinput positivefloat"
                                               type="text" tabindex="301" />
                                    </div>
                                </td>
                                <td
                                    class="check_tr_discount {if $usergroup->hideBillPrices == 1}hidden{/if} {if {$billsettingsData[8]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <input name="prodis_re1" id="prodis_re1" value="0"
                                           class="form-control return_getprototal txt-nonraduis numberonly enteraction numberinput positiveNo"
                                           placeholder="{$smarty.const.BUY_BILL_DISCOUNT}" tabindex="301" {if
                                           {$billsettingsData[34]->billsettingsvalue} eq 0} type="text" {else} type="hidden" {/if}/>
                                    <input name="discounttype_re1" id="discounttype_re1" value="0"
                                           class="form-control return_getprototal numberonly enteraction numberinput txt-nonraduis positivefloat"
                                           tabindex="301" {if {$billsettingsData[34]->billsettingsvalue} eq 1} type="text" {else}
                                    type="hidden" {/if}/>
                                </td>
                                <td class="{if $usergroup->hideBillPrices == 1}hidden{/if}" {if $billsettingsData[96]->billsettingsvalue
                                    eq 0&& $billnameAddData->productAndQuantityOnly eq 0} {else} style="display:none !important;" {/if}>
                                    <input name="rowtaxval_re1" id="rowtaxval_re1" value="0"
                                           class="form-control return_getprototal numberonly enteraction numberinput txt-nonraduis positiveNo"
                                           placeholder="{$smarty.const.BUY_BILL_ROW_TAX}" type="hidden" />
                                    <input name="rowtaxper_re1" id="rowtaxper_re1" value="0"
                                           class="form-control return_getprototal numberonly enteraction numberinput txt-nonraduis positiveNo"
                                           tabindex="7" type="text" />
                                </td>
                                <td class="aw_totalprice_re {if $usergroup->hideBillPrices == 1}hidden{/if}">
                                    <!--                                    <div id="prototal_re1" class="aw_mt form-control-static">0 {$currency}</div>
                                                                                                        <input name="hidden_prototal_re1" id="hidden_prototal_re1" type="hidden" value="0"  tabindex="301"/>-->
                                    <input name="hidden_prototal_re1" id="hidden_prototal_re1"
                                           class="returnEditTotal form-control txt-nonraduis enteraction numberinput positiveNo" value="0"
                                           type="text" />

                                </td>
                                <td>
                                    <button type="button" id="remove_re1" class="removeproduct_re close flt-none" aria-hidden="true"
                                            onclick="removeproduct_re(1);">&times;</button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <button type="button"
                        class="btn btn-primary pull-left ft-nor {if $usergroup->hideBillPrices == 1}hidden{/if}">
                    {$smarty.const.RETURN_BUY_BILL_TOTAL_BUY_RETURNS} <span class="badge wht-clo">
                        <div id="buyBillTotal_re">0</div>
                        <input type="hidden" value="0" name="returnBuyBillTotal" id="returnBuyBillTotal" />

                    </span>
                </button>
            </div>
            <!-- =========================== END RETURN BUY BILL PANEL ======================== -->

            <!-- =========================== START TOTAL VALUES PANEL ======================= -->
            <div class="row {if $usergroup->hideBillPrices == 1}hidden{/if}">
                <div class="col-lg-7">
                    <div class="form-group mg-bt5">
                        <label class="col-lg-1 control-label">{$smarty.const.BUY_BILL_PAID}</label>
                        <div class="col-lg-3">
                            <input type="text" class="form-control" placeholder="{$smarty.const.BUY_BILL_PAID}" name="genpay2"
                                   id="genpay2">
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div class="form-group mg-bt5">
                        <label class="col-lg-1 control-label">{$smarty.const.BUY_BILL_REST}</label>
                        <div class="col-lg-3">
                            <p class="form-control-static" id="gen3total2">0 {$currency}</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 {if {$billsettingsData[91]->billsettingsvalue} eq 1}  hidden {/if}">
                        <label class="col-lg-1 control-label">{$smarty.const.BUY_BILL_TOTAL_INCLUSIVE_VAT}</label>
                        <div class="col-lg-3">
                            <input type="text" class="form-control positivefloat" id="vatIncludedTotalIfRow" value="" />
                        </div>
                    </div>
                    <div class="form-group mg-bt5 "><!-- {if {$billsettingsData[91]->billsettingsvalue} eq 1}  hidden {/if} -->
                        <label class="col-lg-1 control-label">المرفقات</label>
                        <div class="col-lg-3">
                            <input type="file" id="multiupload" name="files[]" multiple>
                        </div>
                    </div>

                    <!-- end of form-group-->
                </div>
                <!-- end of calucation center-->

                <div class="col-lg-5">
                    <hr />
                    <div class="form-group mg-bt5" {if {$billsettingsData[58]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-5 control-label">{$smarty.const.BUY_BILL_NUMBER_PIECES}</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="totalQty">{$piecesCount}</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5" {if $billsettingsData[0]->billsettingsvalue eq 0} {else} style="display:none
                        !important;" {/if}>
                        <label class="col-lg-5 control-label">{$smarty.const.BUY_BILL_NUMBER_PIECES_RETURNED}</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="returnTotalQty">0</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5 {if $Programsettingdata->showbuydiscount != 1}hidden{/if}">
                        <label class="col-lg-5 control-label">اجمالى خصومات الشراء</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="totalBuyDiscountVal">0</p>
                            <input type="hidden" name="totalBuyDiscountVal_hidden" id="totalBuyDiscountVal_hidden" value="0"/>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5">
                        <label class="col-lg-5 control-label">{$smarty.const.BUY_BILL_TOTAL_AMOUNT}</label>
                        <div class="col-lg-7">
                            <input type="hidden" name="totalbeforediscount" id="totalbeforediscount"
                                   value="{$buyBillData->buybilltotalbill}" />
                            <p class="form-control-static" id="gentotal">0</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    {if $billsettingsData[44]->billsettingsvalue eq "0"}
                    <input type="hidden" name="discount_type" id="discount_type" value="0" />
                    <div
                        class="form-group mg-bt5 check_tr_discount {if {$billsettingsData[57]->billsettingsvalue} eq 1}  hidden {/if}">
                        <label class="col-lg-5 control-label">{$smarty.const.BUY_BILL_DISCOUNT_TYPE}</label>
                        <div class="col-lg-7">
                            <label> {$smarty.const.BUY_BILL_DIRECT_DISCOUNT}</label>
                        </div>
                    </div>
                    {elseif $billsettingsData[44]->billsettingsvalue eq 1}
                    <input type="hidden" name="discount_type" id="discount_type" value="1" />
                    <div
                        class="form-group mg-bt5 check_tr_discount {if {$billsettingsData[57]->billsettingsvalue} eq 1}  hidden {/if}">
                        <label class="col-lg-5 control-label">{$smarty.const.BUY_BILL_DISCOUNT_TYPE}</label>
                        <div class="col-lg-7">
                            <label> {$smarty.const.BUY_BILL_PERCENTAGE_DISCOUNT}</label>
                        </div>
                    </div>
                    {elseif $billsettingsData[44]->billsettingsvalue eq 2}
                    <div
                        class="form-group mg-bt5 check_tr_discount {if {$billsettingsData[57]->billsettingsvalue} eq 1}  hidden {/if}">
                        <label class="col-lg-5 control-label">{$smarty.const.BUY_BILL_DISCOUNT_TYPE}</label>
                        <div class="col-lg-7">
                            <select name="discount_type" id="discount_type" class="select2 wdt100" dir="rtl">
                                <option value="0" {if ($offerId> 0 && $buyBillData->buybilldiscountrype eq
                                    0)}selected{/if}>{$smarty.const.BUY_BILL_DIRECT_DISCOUNT}</option>
                                <option value="1" {if ($offerId> 0 && $buyBillData->buybilldiscountrype eq
                                    1)}selected{/if}>{$smarty.const.BUY_BILL_PERCENTAGE_DISCOUNT}</option>
                            </select>
                        </div>
                    </div>
                    {/if}

                    <!-- end of form-group-->
                    <div
                        class="form-group mg-bt5 check_tr_discount {if {$billsettingsData[57]->billsettingsvalue} eq 1}  hidden {/if}">
                        <label class="col-lg-5 control-label"> {$smarty.const.BUY_BILL_DISCOUNT_VALUE}</label>
                        <div class="col-lg-7"><span id="sprytextfield3">
                                <input name="gendis" id="gendis" class="form-control numberclic numberinput positivefloat" {if
                                       isset($buyBillData->buybilldiscount)}value="{$buyBillData->buybilldiscount}"{else} {if
                                {$billsettingsData[57]->billsettingsvalue} neq "0" || $usergroup->hideBillPrices == 1}value="0"
                                {/if}{/if} type="text" placeholder="{$smarty.const.BUY_BILL_DISCOUNT_VALUE}" />
                                <span class="textfieldRequiredMsg">*</span></span></div>
                    </div>

                    <!-- end of form-group-->
                    <div {if {$billsettingsData[89]->billsettingsvalue} eq 0} style="display:none" {/if}>
                        <hr class="mg-tp5 mg-bt5" />
                        <div class="form-group mg-bt5">
                            <label class="col-lg-5 col-sm-7 control-label">ضريبه خصم
                                ({$billnameAddData->taxOfDiscountVal}%)</label>
                            <div class="col-lg-7 col-sm-5">
                                <div class="input-group">
                                    <input type="hidden" name="taxOfDiscountPercentage" id="taxOfDiscountPercentage" {if
                                           isset($buyBillData->taxOfDiscountPer)}value="{$buyBillData->taxOfDiscountPer}"{else}value="{$billnameAddData->taxOfDiscountVal}"{/if}/>
                                    <input type="hidden" name="taxOfDiscountVal_h" id="taxOfDiscountVal_h" value="0" />
                                    <input type="text" name="taxOfDiscountVal"
                                           class="form-control numberinput positiveNo autoSaveBillMainPart" id="taxOfDiscountVal"
                                           {if
                                           isset($buyBillData->taxOfDiscountVal)}value="{$buyBillData->taxOfDiscountVal}"{else}value="{$billnameAddData->taxOfDiscountVal}"{/if}"
                                    readonly/>
                                    <span class="input-group-addon">{$Programsettingdata->currancy}</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- end of form-group-->

                    <div {if {$billsettingsData[36]->billsettingsvalue} eq "0"} {else} style="display:none" {/if}>
                        <hr class="mg-tp5 mg-bt5" />
                        <div class="form-group mg-bt5">
                            <label class="col-lg-5 control-label">{$smarty.const.BUY_BILL_VALUE_TAX}</label>
                            <div class="col-lg-7">

                                <div class="input-group">
                                    <input type="text" name="payedtax" class="form-control numberinput positiveNo" id="payedtax"
                                           value="{if isset($buyBillData->payedtax)}{$buyBillData->payedtax}{else}{$Programsettingdata->vatValue}{/if}"
                                           onkeyup="checkdisValue();" />
                                    <span class="input-group-addon">%</span>
                                </div>
                                <div class="input-group" style="padding-top: 1px;">
                                    <input type="text" name="taxVal" class="form-control numberinput positiveNo" id="taxVal"
                                           value="0" readonly />
                                    <span class="input-group-addon">{$Programsettingdata->currancy}</span>
                                </div>
                            </div>
                        </div>


                    </div>

                    <!-- end of form-group-->
                    <hr class="mg-tp5 mg-bt5" />
                    <div class="form-group mg-bt5" {if {$billsettingsData[51]->billsettingsvalue} eq "0"} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-5 control-label">{$smarty.const.BUY_BILL_PURE}</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="gen2total">{$buyBillData->buybillaftertotalbill}</p>
                            <input type="hidden" name="totalafterdiscount" id="totalafterdiscount"
                                   value="{$buyBillData->buybillaftertotalbill}" />
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5" {if {$billsettingsData[54]->billsettingsvalue} eq "0"} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-5 control-label">{$smarty.const.BUY_BILL_PAID}</label>
                        <div class="col-lg-7">
                            <input name="genpay" id="genpay" class="form-control numberclic numberinput positivefloat"
                                   type="text" placeholder="0" />
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <hr class="mg-tp5 mg-bt5" />
                    <div class="form-group mg-bt5 bg-yel" {if {$billsettingsData[55]->billsettingsvalue} eq 0} {else}
                        style="display:none" {/if}>
                        <label class="col-lg-5 control-label">{$smarty.const.BUY_BILL_RESIDUAL}</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="gen3total">0</p>
                        </div>
                    </div>
                    <!-- end of form-group-->
                    <div class="form-group mg-bt5" {if $billnameAddData->productAndQuantityOnly eq 1} style="display:none
                        !important;" {/if}>
                        <label class="col-lg-5 control-label">{$smarty.const.BUY_BILL_REST_DEBT}</label>
                        <div class="col-lg-7">
                            <p class="form-control-static" id="gen4total">0</p>
                            <input type="hidden" name="supplierdebtafter" id="supplierdebtafter" value="0" />
                        </div>
                    </div>
                    <!-- end of form-group-->
                </div>
                <!-- end of totals center-->
            </div>
            <!-- end of fourth row-->

            <input type="hidden" value="{$roundNumbersStatus}" id="round_numbers" name="round_numbers" />
            <input type="hidden" value="{$noOfDecimalPlaces}" id="noOfDecimalPlaces" name="noOfDecimalPlaces" />
            <div class="row">
                <button type="submit" id="saveBill" class="btn btn-primary">{$smarty.const.BUY_BILL_SAVE}</button>
                <button type="submit" id="saveAndNew" class="btn btn-success"
                        onclick="return changeFormAction({$billnameid});">{$smarty.const.BUY_BILL_SAVE_NEW}</button>
            </div>
            <br />
            <div class="row">
                <style>
                    .unsufficient {
                        background-color: #f59a99 !important;
                    }

                    .note-warning {
                        background-color: #faeaa9;
                        border-color: #f3cc31;
                        color: #000;
                        border-right: 5px solid #f3cc31;
                        border-radius: 4px 0 0 4px;
                        margin: 0 0 20px;
                        padding: 15px 15px 15px 30px;
                    }
                </style>
                <input type="hidden" name="storenegative" id="storenegative" value="{$storenegative}" />
                <div class="note-warning" style="display: none" id="check_store_div">
                    <h4 class="block" id="check_store_msg"></h4>
                </div>
            </div>
            <!-- end of fifth row-->

            <!-- =========================== END TOTAL VALUESPANEL ====================== -->
        </form>

        <!-- Modal -->
        <input type="hidden" name="productAddMultiCatLevel" id="productAddMultiCatLevel" value="1" />
        <div class="modal fade" id="productModal2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog" style="width: 910px;">
                <div classnew_cat_id="modal-content bg-modal" class="bg-modal">
                    <div class="modal-header">
                        <button type="button" class="close pull-left" data-dismiss="modal"
                                aria-hidden="true">&times;</button>
                        <h4 class="modal-title"> إضافة منتج</h4>
                    </div>
                    <div class="productForm">
                        <div class="modal-body ">{literal}
                            <form id="productInfo" action="#" method="post" class="nameToBeChecked form-horizontal"
                                  onsubmit="if (Spry.Widget.Form.validate(this)) {
                                              checkName(event, 'product', 'new_productName');
                                              insertIntoTemp(event);
                                          } else {
                                              return false;
                                          }">
                                {/literal} <div class="form-group">
                                    <label for="inputEmail1" class="col-lg-2 control-label">المنتج الرئيسي</label>
                                    <div class="col-lg-4"> <span id="spryselect4">
                                            <select name="new_cat_id" id="new_cat_id" data-placeholder="اختر"
                                                    class="select2 aw_m1 productCat" tabindex="12">
                                                <option>-- اختر المنتج الرئيسي</option>

                                                {foreach $categoriesData as $cat}

                                                <option value="{$cat->productCatId}">{$cat->productCatName}</option>

                                                {/foreach}

                                            </select>
                                            <span class="selectRequiredMsg">*</span></span> </div>
                                </div>
                                <!---------------------------->

                                <div class="form-group">
                                    <label for="inputEmail1" class="col-lg-2 control-label">الإسم </label>
                                    <div class="col-lg-4">
                                        <input name="new_productName" type="text" id="new_productName" size="50"
                                               class=" form-control " required />
                                        <!----------- start nameError alert -------------->
                                        <div id="new_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>
                                            <h4>رسالة خطأ</h4>
                                            <p>هذا الإسم مستخدم من قبل</p>
                                            <div class="clearfix"></div>
                                        </div>
                                        <!----------- end nameError alert ------------->
                                    </div>


                                </div>



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

                                <div
                                    class="form-group check_tr_parcode {if {$billsettingsData[4]->billsettingsvalue} eq 1}  hidden {/if}">
                                    <label for="inputEmail1" class="col-lg-2 control-label">الباركود</label>
                                    <div class="col-lg-4">
                                        <input name="new_parcode" type="text" id="new_parcode" class=" form-control"
                                               size="50" />
                                    </div>
                                </div>
                                <!---------------------------->

                                <div class="form-group">
                                    <label for="inputEmail1" class="col-lg-2 control-label">سعر الشراء</label>
                                    <div class="col-lg-4">
                                        <input name="new_productBuyPrice" type="text" id="new_productBuyPrice"
                                               class="numberinput form-control" required size="50" />
                                    </div>
                                </div>
                                <!---------------------------->

                                <div class="form-group">
                                    <label for="inputEmail1" class="col-lg-2 control-label">سعر بيع الجمله</label>
                                    <div class="col-lg-4">
                                        <input name="new_productSellAllPrice" type="text" id="new_productSellAllPrice"
                                               class="numberinput form-control" onKeyUp="populateSellPrice();" required
                                               size="50" />
                                    </div>
                                </div>
                                <!---------------------------->

                                <div class="form-group">
                                    <label for="inputEmail1" class="col-lg-2 control-label">سعر بيع الجمله التجزئة</label>
                                    <div class="col-lg-4">
                                        <input name="new_productSellHalfPrice" type="text" id="new_productSellHalfPrice"
                                               class=" form-control numberinput" required size="50" />
                                    </div>
                                </div>
                                <!---------------------------->

                                <div class="form-group">
                                    <label for="inputEmail1" class="col-lg-2 control-label">سعر بيع الوحده</label>
                                    <div class="col-lg-4">
                                        <input name="new_productSellUnitPrice" type="text" id="new_productSellUnitPrice"
                                               class=" form-control numberinput" required size="50" />
                                    </div>
                                </div>
                                <!---------------------------->

                                <div class="form-group">
                                    <label for="inputEmail1" class="col-lg-2 control-label">الكمية</label>
                                    <div class="col-lg-4">
                                        <input name="new_productquantity" type="text" id="new_productquantity"
                                               class=" form-control numberinput" required="required" value="0" size="50" />
                                    </div>
                                </div>
                                <!---------------------------->
                                <div class="form-group ">
                                    <label for="inputEmail1" class="col-lg-2 control-label">فى المنيو</label>
                                    <div class="col-lg-4">



                                        <label>
                                            <input value="0" class="radioR" name="inMenu1" checked="checked" type="radio" />

                                            نعم </label>

                                        <label>
                                            <input value="1" class="noradioR" name="inMenu1" type="radio" />
                                            لا </label>



                                    </div>
                                </div>
                                <!---------------------------->

                                <div class="form-group">
                                    <label for="inputEmail1" class="col-lg-2 control-label">التصنيع</label>
                                    <div class="col-lg-4">



                                        <label>
                                            <input value="1" class="radioR" name="type1" type="radio" />

                                            نعم </label>

                                        <label>
                                            <input value="0" class="noradioR" name="type1" checked="checked" type="radio" />
                                            لا </label>



                                    </div>
                                </div>
                                <!---------------------------->






                                <div class="form-group">
                                    <label for="inputEmail1" class="col-lg-2 control-label">التاريخ</label>
                                    <div class="col-lg-4">
                                        <input name="new_productDate" type="text" id="new_productDate"
                                               class=" form-control awdatepicker" autocomplete="off"
                                               data-date-format="yyyy-mm-dd" size="50" value="{$today}" required />
                                    </div>
                                </div>
                                <!---------------------------->

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

                                <div id="addUnitsDiv">
                                    <table id="unitsTable" class="table">
                                        <tr id="unit_row1">
                                            <td>
                                                <div class="form-group">
                                                    <label for="inputEmail1" class="col-lg-4 control-label">اسم وحدة
                                                        القياس</label>
                                                    <div class="col-lg-8">
                                                        <select name="productunit1" id="productunit1"
                                                                data-placeholder="اختر" class="select2 aw_m1 chosenproduct"
                                                                tabindex="12">
                                                            <option value="-1">اختر وحدة القياس</option>







                                                            {foreach $unitsData as $unit}







                                                            <option value="{$unit->unitId}">{$unit->unitName}</option>







                                                            {/foreach}







                                                        </select>
                                                    </div>
                                                </div>
                                                <!---------------------------->
                                            </td>
                                            <td>
                                                <div class="form-group">
                                                    <label for="inputEmail1" class="col-lg-4 control-label">عدد
                                                        الوحدات</label>
                                                    <div class="col-lg-8">
                                                        <input name="productnumber1" id="productnumber1"
                                                               class="numberinput form-control" type="text" />
                                                    </div>
                                                </div>
                                                <!---------------------------->
                                            </td>
                                            <td><a id="remove1" onClick="removeUnits(1);" class="removeUnits">X</a></td>
                                        </tr>
                                    </table>
                                    <!--end unitsTable-->
                                </div>
                                <!--<input class="addUnits btn btn-primary" onClick="addUnits();" type="button" value="إضافة وحدة قياس"/>-->
                                <input name="unitsItr" id="unitsItr" type="hidden" value="1" />

                                <!-------------------------------- end adding units   -------------------------->
                                <!---------------------------->
                                <div class="clearfix"></div>
                                <br />
                                <div class="form-group "
                                     style="padding: 8px; line-height: 1.428571429; vertical-align: top; border-top: 1px solid #ddd;">
                                    <label for="inputEmail1" class="col-lg-2 control-label">بمقاسات و الوان</label>
                                    <div class="col-lg-4">
                                        <label>
                                            <input value="1" class="radioR hasSizeAndColor" name="hasSizeAndColor"
                                                   type="radio" />
                                            نعم </label>
                                        <label>
                                            <input value="0" class="noradioR hasSizeAndColor" name="hasSizeAndColor"
                                                   type="radio" checked="checked" />
                                            لا </label>
                                    </div>
                                </div>
                                <!---------------------------->
                                <!-- size color ------------------------------->
                                <div class="panel panel-default panel-m" id="sizeColorDiv" style="display:none">
                                    <div class="panel-heading">
                                        <h3 class="panel-title">المقاسات و الالوان</h3>
                                    </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"
                                                        id="SizeColorQuantity">ادخال الكميات </button>
                                            </div>


                                        </div>
                                        <div class="clearfix"></div>
                                        <br />
                                        <div class="row" id="quantity_div" style="display:none">
                                            <table class="table">
                                                <thead>
                                                    <tr>
                                                        <th>الباركود</th>
                                                        <th>المقاس</th>
                                                        <th>اللون</th>
                                                        <th>الكمية</th>
                                                        <th>حذف</th>
                                                    </tr>
                                                </thead>
                                                <tbody id="SizeColorTB">

                                                </tbody>
                                            </table>
                                            <input type="hidden" id="sizeColorItr" name="sizeColorItr" value="0" />
                                        </div>

                                    </div>
                                </div>
                                <!-- END  size color ---------------------->
                                </td>
                                <input name="newLinkCurrentId" id="newLinkCurrentId" type="hidden" value="" />
                                <!--        <input type="button" id="cancel" onClick="closeProductForm();" value="إلغاء" />
                                  <input type="button" id="insert" onClick="insertIntoTemp();" value="إضافة" />
                                -->

                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" id="cancel"
                                    onClick="closeProductForm();">إلغاء</button>
                            <button type="submit" class="btn btn-primary" id="insert">حفظ</button>
                        </div>
                        </form>
                    </div>
                    <!-- /.productForm -->
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->

        <div id="productSelect" style="display:none;"> {foreach $categoriesData as $cat}
            <option value="{$cat->productCatId}">{$cat->productCatName}</option>
            {/foreach}
        </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 id="productUnitsDiv_new" style="display:none;">
            <option value="-1">اختر وحدة القياس</option>
            {foreach $unitsData as $unit}
            <option value="{$unit->unitId}">{$unit->unitName}</option>
            {/foreach}
        </div>

        {if $billnameAddData->billtype2 == "1"}
        <div id="cats" style="display:none;">
            <option value="-1">اختر تصنيف</option>
            {foreach $catDataReport as $data}
            <option value="{$data->productCatId}">{$data->productCatName}</option>
            {/foreach}
        </div>
        {/if}

        <!---================== END ADD PRODUCT MODAL BOX ==================--->

        <!---================== START NEW UNIT ROW  ==================--->
        <div id="unitsTableHidden" style="display:none !important;">
            <tr>
                <td>
                    <div class="form-group">
                        <label for="inputEmail1" class="col-lg-2 control-label">اسم وحدة القياس</label>
                        <div class="col-lg-4">
                            <select name="productunit1" id="productunit1" data-placeholder="اختر"
                                    class="select2 aw_m1 chosenproduct" tabindex="12">
                                <option value="-1">اختر وحدة القياس</option>


                                {foreach $unitsData as $unit}

                                <option value="{$unit->unitId}">{$unit->unitName}</option>


                                {/foreach}



                            </select>
                        </div>
                    </div>
                    <!---------------------------->
                </td>
                <td>
                    <div class="form-group">
                        <label for="inputEmail1" class="col-lg-2 control-label">عدد الوحدات</label>
                        <div class="col-lg-4">
                            <input name="productnumber1" id="productnumber1" class="numberinput form-control" type="text" />
                        </div>
                    </div>
                    <!---------------------------->
                </td>
                <td><a id="remove1" onClick="removeUnits(1);" class="removeUnits">X</a></td>
            </tr>
        </div>
        <!---================== END NEW UNIT ROW  ==================--->

        <!-- ======================= Supplier Modal Box =========== -->
        <!-- Modal -->
        <div class="modal fade" id="supplierModal" tabindex="-1" role="dialog" aria-labelledby="supplierModalLabel"
             aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content bg-modal">
                    <div class="modal-header">
                        <button type="button" class="close pull-left" data-dismiss="modal"
                                aria-hidden="true">&times;</button>
                        <h4 class="modal-title">عنوان الرسالة</h4>
                    </div>
                    <div class="modal-body">
                        <form id="supplierInfo" action="#" method="post" class="form-horizontal">
                            <div class="form-group">
                                <label class="col-lg-2 control-label">اسم المورد</label>
                                <div class="col-lg-4"> <span id="sprytextfield1">
                                        <input name="txtName" type="text" id="sup_txtName" class="form-control" />
                                        <span class="textfieldRequiredMsg">*</span></span> </div>
                            </div>
                            <!------------------------------>

                            <div class="form-group">
                                <label class="col-lg-2 control-label">العنوان</label>
                                <div class="col-lg-4">
                                    <input name="txtAddress" type="text" id="sup_txtAddress" class="form-control" />
                                </div>
                            </div>
                            <!------------------------------>
                            <div class="form-group">
                                <label class="col-lg-2 control-label">رقم التليفون</label>
                                <div class="col-lg-4">
                                    <input name="txtPhone" type="text" id="sup_txtPhone" class="numberinput form-control" />
                                </div>
                            </div>
                            <!------------------------------>

                            <div class="form-group">
                                <label class="col-lg-2 control-label">قيمة المديونية</label>
                                <div class="col-lg-4"> <span id="sprytextfield2">
                                        <input type="text" name="txtDebt" id="sup_txtDebt"
                                               class="numberinput positivefloat form-control" />
                                        <span class="textfieldRequiredMsg">يرجى إدخال رقم صحيح</span><span
                                            class="textfieldInvalidFormatMsg">*</span></span> </div>
                            </div>
                            <!------------------------------>
                            <div class="form-group">
                                <label class="col-lg-2 control-label">تفاصيل أخرى</label>
                                <div class="col-lg-4">
                                    <textarea name="textDetails" cols="" rows="" id="sup_textDetails"
                                              class="form-control"></textarea>
                                </div>
                            </div>
                            <!------------------------------>

                            <!--  <div class="form-group">
                                        <div class="col-lg-offset-2 col-lg-4">
                                          <input type="button" id="cancel" onClick="closeSupplierForm();" class="btn btn-error pull-left" value="إلغاء" />
                                          <input type="button" id="insert" onClick="insertSupplier();" class="btn btn-primary pull-left" value="إضافة" />
                                        </div>
                                      </div>-->
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" id="cancel"
                                onClick="closeSupplierForm();">اغلاق</button>
                        <button type="button" id="insert" class="btn btn-primary savemodel_supplier"
                                onClick="insertSupplier();">حفظ</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->
        <!-- ============================================= -->
        <!-- ======================= Supplier Modal Box =========== -->
        <!-- Modal -->
        <div class="modal fade" id="proPriceUpdateModal" tabindex="-1" role="dialog"
             aria-labelledby="proPriceUpdateModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content bg-modal">
                    <div class="modal-header">
                        <button type="button" class="close pull-left" data-dismiss="modal"
                                aria-hidden="true">&times;</button>
                        <h4 class="modal-title">تم تعديل سعر شراء المنتج تحديث الاسعار؟</h4>
                    </div>
                    <div class="modal-body">
                        <form id="proPriceInfo" action="#" method="post" class="form-horizontal">

                        </form>
                        <input type="hidden" id="showProPriceUpdateModalIfBuyPriceChange"
                               value="{$billsettingsData[95]->billsettingsvalue}" />
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">اغلاق</button>
                        <button type="button" class="btn btn-primary" data-rowItr="" id="saveProPricesBtn">حفظ</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->
        <!------------------------Products with size & color Model----------------------------->
        <!-- Modal -->
        <div class="modal fade" id="proSizeColorModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
             aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content bg-modal">
                    <div class="modal-header">
                        <button type="button" class="close pull-left savemodel2" data-dismiss="modal"
                                aria-hidden="true">&times;</button>
                        <h4 class="modal-title">{$smarty.const.BUY_BILL_ADD_PRO_SIZE_COLOR}</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="debtLimit"
                                   class="col-lg-3 control-label">{$smarty.const.BUY_BILL_PRODUCT_NAME}</label>
                            <div class="col-lg-9">
                                <input type="hidden" id="productSC" name="productSC"
                                       data-placeholder="{$smarty.const.BUY_BILL_SELECT}" class="select2productSC wdt100"
                                       data-getColorSizeOnly="1" />
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <br />
                        <div class="row" id="quantity_div">
                            <table class="table table-bordered">
                                <thead>
                                    <tr>
                                        <th>الباركود</th>
                                        <th>المقاس</th>
                                        <th>اللون</th>
                                        <th>الكمية</th>
                                        <th>سعر الشراء</th>
                                        <th>حذف</th>
                                    </tr>
                                </thead>
                                <tbody id="SizeColorTB_eman">

                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default savemodel2"
                                data-dismiss="modal">{$smarty.const.BUY_BILL_CANCEL}</button>
                        <button type="button" class="btn btn-primary"
                                id="doAddProWithSC">{$smarty.const.BUY_BILL_SAVE}</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->
        <!-- ============================================= -->

    </div>
</div>

<form action="buyBillController.php?do=excelToBill" method="post" enctype="multipart/form-data" id="billAsExcelForm">
    <input name="billAsExcelFile" id="billAsExcelFile" type="file"
           accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
           class="hidden" />
</form>
{literal}
<script type="text/javascript">
    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {isRequired: false, invalidValue: "-1"});
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    //var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2", {isRequired:false, invalidValue:"-1"});
    //var spryselect3 = new Spry.Widget.ValidationSelect("spryselect3");
    var spryselect4 = new Spry.Widget.ValidationSelect("spryselect4");</script>
<script type="text/javascript">
    var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
</script>
{/literal}