@include('admin.layouts.headerPOS')

            <span id="ex"> @include('admin.layouts.messages')</span>
    <form id="form" action="{{url('PostPOS')}}" method="post">
        {!! csrf_field() !!}

        <input type="hidden" id="priceSale" value="{{auth()->guard('admin')->user()->price_sale}}">
        <input type="hidden" id="discount" value="{{auth()->guard('admin')->user()->discount}}">
            <input type="hidden" name="Shift_Code" id="Shift_Code"  value="{{$shift->Code}}">
            <input type="hidden" name="Sale_Type"  value="POS">
                  <input type="hidden" name="Hold" id="HOLD" value="0">
                  <input type="hidden" name="Code_Order" value="{{$HoldCode}}">
        <input type="hidden" name="TaxBill" value="{{$Def->TaxType}}">
        <input type="hidden" name="DiscountTaxShow" value="0">
        <div class="start-pos">
            <div class="row">

                @if(auth()->guard('admin')->user()->pos_product == 1)

                <div class="col-md-6 ENGLISH">
                    <div class="second-card card">
                        <div class="first-part">
                        <div class="top-btn">
                            <div class="row">
                                <div class="col-md-4">
                                 <button onclick="Lock()" type="button" class="btn btn-block btn-outline-primary waves-effect waves-themed" data-toggle="modal" data-target="#default-example-modal-center-shiftDetails">
                                     <span class="fal fa-toggle-on "></span>
                                     {{trans('admin.Shift_Details')}}
                                 </button>
                                </div>
                                <div class="col-md-4">
                                 <button type="button" class="btn btn-block btn-outline-primary waves-effect waves-themed" data-toggle="modal" data-target="#default-example-modal-center-closeShift">
                                     <span class="fal fa-toggle-off "></span> {{trans('admin.Close_Shift')}}
                                 </button>
                                </div>
                                <div class="col-md-4">
                                 <a href="{{url('KlarAdmin')}}" type="button" class="btn btn-block btn-outline-primary waves-effect waves-themed">
                                     <span class="fal fa-home-alt "></span>{{trans('admin.Home')}}

                                 </a>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-4">
                                    <button type="button" class="btn btn-block btn-primary waves-effect waves-themed" data-toggle="modal" data-target="#groups">
                                        {{trans('admin.Groups')}}
                                    </button>
                                   </div>
                                   <div class="col-md-4">
                                    <button type="button" class="btn btn-block btn-primary waves-effect waves-themed" data-toggle="modal" data-target="#brands">
                                           {{trans('admin.Brands')}}
                                    </button>
                                   </div>
                                   <div class="col-md-4">
                                    <button type="button" class="btn btn-block btn-primary waves-effect waves-themed" onclick="AllProductsPOS()">
                                           {{trans('admin.All_Products')}}
                                    </button>
                                   </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                         @if($show->SearchCode == 1)
                        <div class="form-group col-lg-6">
                        <span  id="data" style="display: none">
                            <div class="row Data">
                            </div>
                            </span>
                            <div class="input-items">
                             <input type="text" id="search" class="form-control" placeholder="   {{trans('admin.Search_For_Products')}}" autofocus>

                                      @if(app()->getLocale() == 'ar' )
                     <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;left:3px;"></i>
                      @else
                            <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;right: 0;left:auto;"></i>
                      @endif
                            </div>
                         </div>
                        <div class="form-group col-lg-6">
                            <div class="input-items">
                             <input type="text" id="SearchCode" class="form-control" placeholder="{{trans('admin.SearchCode')}}" autofocus>

                                      @if(app()->getLocale() == 'ar' )
                     <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;left:3px;"></i>
                      @else
                            <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;right: 0;left:auto;"></i>
                      @endif
                            </div>
                         </div>
                        @else
                    <div class="form-group col-lg-12">
                        <span  id="data" style="display: none">
                            <div class="row Data">

                            </div>
                            </span>
                            <div class="input-items">
                             <input type="text" id="search" class="form-control" placeholder="   {{trans('admin.Search_For_Products')}}" autofocus>

                                      @if(app()->getLocale() == 'ar' )
                     <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;left:3px;"></i>
                      @else
                            <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;right: 0;left:auto;"></i>
                      @endif
                            </div>
                         </div>

                        @endif
                    </div>
                    <div class="second-part">

                          <div class="row">

                          <div class="col-md-12">
                              <!--<h4>{{trans('admin.Products')}}</h4>-->
                              <div class="items">
                                <audio id="audio"><source src="{{asset('Admin/css/click.wav')}}" type="audio/ogg" /> </audio>
                                  <div class="row Group">

                                  </div>
                              </div>
                          </div>

                        </div>
                    </div>
                    </div>
                </div>

                @endif


                <div class="col-md-6 ENGLISH" >
                    <div class="first-card card">
                        <div class="first-section">

                     @if(auth()->guard('admin')->user()->pos_product == 1)
                       <div class="row">
                        <div class="form-group col-lg-2 col-4">
                           <label class="form-label" for="simpleinput">{{trans('admin.Code')}} </label>
                                            <input type="text" value="{{$Code}}" class="form-control " disabled>
                                            <input type="hidden" name="Code" value="{{$Code}}" class="form-control">
                        </div>


                              @if(auth()->guard('admin')->user()->emp == 0)
                          <div class="form-group col-lg-2 col-4">
                                                 <label class="form-label" for="simpleinput">{{trans('admin.Date')}}</label>
                           <input type="date" name="Date" value="{{date('Y-m-d')}}" class="form-control" required>
                        </div>
                                        @else

                                         @if(auth()->guard('admin')->user()->Date == 1)
                   <div class="form-group col-lg-2 col-4">
                                                 <label class="form-label" for="simpleinput">{{trans('admin.Date')}}</label>
                           <input type="date" name="Date" value="{{date('Y-m-d')}}" class="form-control" required>
                        </div>
                                        @else
                     <div class="form-group col-lg-2 col-4">
                                                 <label class="form-label" for="simpleinput">{{trans('admin.Date')}}</label>
                           <input type="date" name="Date" value="{{date('Y-m-d')}}" class="form-control" required readonly>
                        </div>
                                        @endif

                                        @endif

                           @if($show->POS_RecivedDate == 1)
                                    <div class="form-group col-lg-2 col-4">
                                                 <label class="form-label" for="simpleinput">{{trans('admin.RecivedDate')}}</label>
                           <input type="date" name="RecivedDate" value="" class="form-control">
                        </div>
                           @else
                           <input type="hidden" name="RecivedDate" value="" class="form-control">
                           @endif

      @if(auth()->guard('admin')->user()->pos_stores == 0)
<input type="hidden" name="Store" id="store" value="{{auth()->guard('admin')->user()->store}}">
        @else

                               @if($Def->StoresQty == 1)
<div class="form-group col-lg-3 col-4">
        <label class="form-label" for="">{{trans('admin.Store')}}</label>
                                            <select class="select2 form-control w-100" id="store" name="Store" required>
                                            @foreach($Stores as $stor)
            <option value="{{$stor->id}}" @if(auth()->guard('admin')->user()->store == $stor->id) selected @endif>

                                        @if(!empty($stor->Name))
                 {{app()->getLocale() == 'ar' ?$stor->Name :$stor->NameEn}}

                @endif
                                                </option>
                                            @endforeach
                                            </select>
                                        </div>
                                   @else


                                   <div class="form-group col-lg-3 col-4">
                                       <label class="form-label" for="">{{trans('admin.Store')}}</label>
                                       <select class="select2 form-control w-100" id="store" name="Store" required>
                                           @foreach($Stores as $stor)
                                               <option value="{{$stor->Store}}" @if(auth()->guard('admin')->user()->store == $stor->Store) selected @endif>

                                                   @if(!empty($stor->Store()->first()->Name))
                                                       {{app()->getLocale() == 'ar' ?$stor->Store()->first()->Name :$stor->Store()->first()->NameEn}}

                                                   @endif
                                               </option>
                                           @endforeach
                                       </select>
                                   </div>

                                   @endif


        @endif



<input type="hidden" name="Safe"  value="{{auth()->guard('admin')->user()->safe}}">
<input type="hidden" name="Coin"  value="{{$Def->Coin}}">
<input type="hidden" name="Draw"  value="{{$Def->Draw}}">
<input type="hidden" name="Status"  value="1">





@if(auth()->guard('admin')->user()->emp != 0)


                               @if($show->Executor_Sale == 1)


                                   @if($Def->ExecuteEmp == 0)
                             <input type="hidden" name="Executor" value="{{auth()->guard()->user()->executor}}">
                           @else
                                         <div class="form-group col-lg-2">
                                            <label class="form-label" for="">{{trans('admin.Executor')}}</label>
                                  <select  class="js-data-example-ajax form-control w-100" id="Emp" name="Executor" >
      <option value="{{auth()->guard()->user()->executor}}">

                         {{app()->getLocale() == 'ar' ?auth()->guard()->user()->executor()->first()->Name :auth()->guard()->user()->executor()->first()->NameEn}}
                                      </option>
                                            </select>
                                        </div>

                           @endif


                                        @else
                       <input type="hidden" name="Executor" value="{{auth()->guard()->user()->executor}}">
                                        @endif



@endif






                           @if($crm->Client_Delegate == 1)
                        <div class="form-group col-lg-3 col-sm-12">
                            <label class="form-label" for="Status">{{trans('admin.Account')}} ({{trans('admin.Client')}})</label>
                       <select  class="select2 form-control w-100" id="client" name="Client" required>



                                            </select>
                        </div>
                           @else
                                   <div class="form-group col-lg-3 col-sm-12">
                            <label class="form-label" for="Status">{{trans('admin.Account')}} ({{trans('admin.Client')}})</label>
                       <select  class="select2 form-control w-100" id="client" name="Client" required>

                            <option value="{{$Def->Client}}">

                            {{app()->getLocale() == 'ar' ?$Def->Client()->first()->Name :$Def->Client()->first()->NameEn}}
                           </option>

                                            </select>
                        </div>
                           @endif

                             @can('خانه رصيد حساب العميل')   @php $credStyle="block"; @endphp @endcan

                         <div class="form-group col-lg-2 col-4" style="display: {{$credStyle}}">
                     <label class="form-label" for="simpleinput"> {{trans('admin.Account_Credit')}} </label>
                             <input type="text" name="Current_Credit" id="AccountCredit" value="0" class="form-control " readonly>
                        </div>
                        <div class="form-group col-lg-1 col-2">
                            <button style="margin-top: 23px;height: 27px;line-height: 13px;" type="button" class="btn btn-default" data-toggle="modal" data-target="#NewClient">
                                <i class="fal fa-user"></i>
                         </button>
                        </div>


                          @if($EMP->Emp_Type != 'Saller')



                               @if($Def->DelegateEmp == 0)
                                   <input type="hidden" name="Delegate"  value="{{$EMP->id}}">
                               @else

                        <div class="form-group col-lg-4 col-4">
                   <label class="form-label" for="Status">{{trans('admin.Delegate')}}</label>
                               <select class="select2 form-control w-100 EmpDele" name="Delegate">
                                          <option value=""> {{trans('admin.Delegate')}}</option>
                                            @foreach($Employess as $emp)
                                                <option value="{{$emp->id}}" @if($Def->Delegate == $emp->id) selected @endif>

                                     {{app()->getLocale() == 'ar' ?$emp->Name :$emp->NameEn}}
                                                </option>
                                            @endforeach
                                            </select>
                        </div>
                               @endif
                           @else
                     <input type="hidden" name="Delegate"  value="{{$EMP->id}}">

                           @endif



                                         @if($show->Show_File_Sales == 1)
                                     <div class="form-group col-lg-12">
                                    <label class="form-label" for="simpleinput">{{trans('admin.File')}}</label>
                                    <input type="file" name="File"  class="form-control">
                                </div>
                                @endif

                            @if($show->Note_POS == 1)
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#Note">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Note')}}">
                                <img src="{{asset('Admin/img/245-edit-document-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endif

                           @can('اضافه سند قبض')
                      <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#Recipt">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Recipt_Voucher')}}">
                                <img src="{{asset('Admin/img/37-approve-checked-simple-outline.gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan

                                  @can('سند عميل')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#ReciptTwo">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Client_Voucher')}}">
                                <img src="{{asset('Admin/img/981-consultation-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan




                              @can('اضافه سند صرف')
                       <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#PayVouch">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Payment_Voucher')}}">
                                <img src="{{asset('Admin/img/290-coin-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan
                              @can('سند مصروف')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#PayyVouch">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Expenses_Voucher')}}">
                                <img src="{{asset('Admin/img/12-layes-outline (2).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan
                                       @can('سند مورد')
                    <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#PayyyVouch">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Vendor_Voucher')}}">
                                <img src="{{asset('Admin/img/955-demand-outline.gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan


                                        @can('جدول عرض سعر مصور')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#">
                                 <a href="{{url('QuoteImagesSechdule')}}" data-toggle="tooltip" data-placement="top" title="{{trans('admin.QuoteImagesSechdules')}}" target="_blank">
                               <img src="{{asset('Admin/img/56-document-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan



                              @can('عرض سعر مصور')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#">
                                 <a href="{{url('QuoteImages')}}" data-toggle="tooltip" data-placement="top" title="{{trans('admin.QuoteImages')}}" target="_blank">
                               <img src="{{asset('Admin/img/62-film-outline.gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan


                             @can('جدول امر البيع')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#">
                                 <a href="{{url('SalesOrderSechdule')}}" data-toggle="tooltip" data-placement="top" title="{{trans('admin.SalesOrderSechdule')}}" target="_blank">
                               <img src="{{asset('Admin/img/1384-page-view-array-outline.gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan
                               @can('جدول المبيعات')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#">
                                 <a   href="{{url('SalesSechdule')}}" data-toggle="tooltip" data-placement="top" title="{{trans('admin.SalesSechdule')}}" target="_blank">
                                 <img src="{{asset('Admin/img/970-video-conference-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan
                              @can('جدول عرض سعر')
                        <div class="form-group col-lg-1 col-2">
                            <button  type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#">
                                 <a  href="{{url('Quote_Sechdule')}}" data-toggle="tooltip" data-placement="top" title="{{trans('admin.Quote_Sechdule')}}" target="_blank">
                                 <img src="{{asset('Admin/img/298-coins-outline (1).gif')}}" alt="">
                                </a>
                         </button>



                        </div>
                           @endcan
                              @can('تقفيل اليوميه')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('DailyClosing')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.DailyClosing')}}" target="_blank">
                                  <img src="{{asset('Admin/img/946-equity-security-outline.gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                              @can('تقرير المصاريف')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('ExpensesReport')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.Expenses')}}" target="_blank">
                                  <img src="{{asset('Admin/img/945-dividends-outline (1).gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                              @can('اضافه تحويلات المخازن')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('StoresTransfers')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.Stores_Transfers')}}" target="_blank">
                                  <img src="{{asset('Admin/img/950-attract-customers-outline (1).gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                              @can('اضافه مشتريات')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('Purchases')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.Purchases')}}" target="_blank">
                                  <img height="20" src="{{asset('Admin/img/526-paper-bag-vegetables-outline.gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                              @can('جدول المشتريات')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('PurchasesSechdule')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.PurchasesSechdule')}}" target="_blank">
                                  <img height="20" src="{{asset('Admin/img/1387-page-view-column-outline.gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                                     @can('اضافه سلفه')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('AddBorrow')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.Add_Borrow')}}" target="_blank">
                                  <img height="20" src="{{asset('Admin/img/49-plus-circle-outline.gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                                @can('الاصناف اليوميه')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('DailyProducts')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.Products_Daily')}}" target="_blank">
                                  <img height="20" src="{{asset('Admin/img/948-stock-share-outline (1).gif')}}" alt="">
                                </a>
                        </div>
                           @endcan

                                @if($show->Open_Drawer == 1)
                        <div class="form-group col-lg-1 col-2">

          <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#OpenSafe">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Open_Safe_Drawer')}}" >
                                <img src="{{asset('Admin/img/1933-vote-elections-outline.gif')}}" alt="">
                                </a>
                         </button>

                        </div>
                    @endif

                    </div>
                    @else
                           <div class="row" style="display: none">
                        <div class="form-group col-lg-2 col-4">
                           <label class="form-label" for="simpleinput">{{trans('admin.Code')}} </label>
                                            <input type="text" value="{{$Code}}" class="form-control " disabled>
                                            <input type="hidden" name="Code" value="{{$Code}}" class="form-control">
                        </div>
                        <div class="form-group col-lg-3 col-4">
                                                 <label class="form-label" for="simpleinput">{{trans('admin.Date')}}</label>
                           <input type="date" name="Date" value="{{date('Y-m-d')}}" class="form-control" required>
                        </div>



      @if(auth()->guard('admin')->user()->pos_stores == 0)
<input type="hidden" name="Store" id="store" value="{{auth()->guard('admin')->user()->store}}">
        @else
<div class="form-group col-lg-3 col-4">
        <label class="form-label" for="">{{trans('admin.Store')}}</label>
                                            <select class="select2 form-control w-100" id="store" name="Store" required>
                                            @foreach($Stores as $stor)
            <option value="{{$stor->Store}}" @if(auth()->guard('admin')->user()->store == $stor->Store) selected @endif>
                                        @if(!empty($stor->Store))

                 {{app()->getLocale() == 'ar' ?$stor->Store()->first()->Name :$stor->Store()->first()->NameEn}}
                @endif
                                                </option>
                                            @endforeach
                                            </select>
                                        </div>
        @endif



<input type="hidden" name="Safe"  value="{{auth()->guard('admin')->user()->safe}}">
<input type="hidden" name="Coin"  value="{{$Def->Coin}}">
<input type="hidden" name="Draw"  value="{{$Def->Draw}}">
<input type="hidden" name="Status"  value="1">

@if(auth()->guard('admin')->user()->emp != 0)
        @if($show->Executor_Sale == 1)
                                         <div class="form-group col-lg-2">
                                            <label class="form-label" for="">{{trans('admin.Executor')}}</label>
                                  <select  class="js-data-example-ajax form-control w-100" id="Emp" name="Executor" >
      <option value="{{auth()->guard()->user()->executor}}">

                             {{app()->getLocale() == 'ar' ?auth()->guard()->user()->executor()->first()->Name :auth()->guard()->user()->executor()->first()->NameEn}}
                                      </option>
                                            </select>
                                        </div>
                                        @else
                       <input type="hidden" name="Executor" value="{{auth()->guard()->user()->executor}}">
                                        @endif




@else
        @if($show->Executor_Sale == 1)
                                         <div class="form-group col-lg-2">
                                            <label class="form-label" for="">{{trans('admin.Executor')}}</label>
                                  <select  class="js-data-example-ajax form-control w-100" id="Emp" name="Executor" >


                                            </select>
                                        </div>
                                        @else
                       <input type="hidden" name="Executor" value="">
                                        @endif

@endif

                        <div class="form-group col-lg-3 col-4">
                            <label class="form-label" for="Status">{{trans('admin.Account')}} ({{trans('admin.Client')}})</label>
                       <select  class="select2 form-control w-100" id="client" name="Client" required>

                              <option value="{{$Def->Client}}">

                                   {{app()->getLocale() == 'ar' ?$Def->Client()->first()->Name :$Def->Client()->first()->NameEn}}
                           </option>


                                            </select>
                        </div>
                         <div class="form-group col-lg-2 col-4">
                     <label class="form-label" for="simpleinput"> {{trans('admin.Account_Credit')}} </label>
                             <input type="text" id="AccountCredit" value="0" class="form-control " disabled>
                        </div>
                        <div class="form-group col-lg-1 col-2">
                            <button style="margin-top: 23px;height: 27px;line-height: 13px;" type="button" class="btn btn-default" data-toggle="modal" data-target="#NewClient">
                                <i class="fal fa-user"></i>
                         </button>
                        </div>


                          @if($EMP->Emp_Type != 'Saller')
                        <div class="form-group col-lg-4 col-4">
                   <label class="form-label" for="Status">{{trans('admin.Delegate')}}</label>
                               <select class="select2 form-control w-100" name="Delegate">
                                          <option value=""> {{trans('admin.Delegate')}}</option>
                                            @foreach($Employess as $emp)
                                                <option value="{{$emp->id}}" @if($Def->Delegate == $emp->id) selected @endif>

                                        {{app()->getLocale() == 'ar' ?$emp->Name :$emp->NameEn}}
                                                </option>
                                            @endforeach
                                            </select>
                        </div>
                           @else
                     <input type="hidden" name="Delegate"  value="{{$EMP->id}}">

                           @endif


                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#Note">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Note')}}">
                                <img src="{{asset('Admin/img/245-edit-document-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>

                           @can('اضافه سند قبض')
                      <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#Recipt">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Recipt_Voucher')}}">
                                <img src="{{asset('Admin/img/37-approve-checked-simple-outline.gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan

                                  @can('سند عميل')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#ReciptTwo">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Client_Voucher')}}">
                                <img src="{{asset('Admin/img/37-approve-checked-simple-outline.gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan




                              @can('اضافه سند صرف')
                       <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#PayVouch">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Payment_Voucher')}}">
                                <img src="{{asset('Admin/img/290-coin-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan
                              @can('اضافه سند صرف')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#PayyVouch">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Expenses_Voucher')}}">
                                <img src="{{asset('Admin/img/290-coin-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan
                                       @can('اضافه سند صرف')
                    <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#PayyyVouch">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Vendor_Voucher')}}">
                                <img src="{{asset('Admin/img/290-coin-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan


                                        @can('جدول عرض سعر مصور')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#">
                                 <a href="{{url('QuoteImagesSechdule')}}" data-toggle="tooltip" data-placement="top" title="{{trans('admin.QuoteImagesSechdules')}}" target="_blank">
                               <img src="{{asset('Admin/img/56-document-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan


                              @can('عرض سعر مصور')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#">
                                 <a href="{{url('QuoteImages')}}" data-toggle="tooltip" data-placement="top" title="{{trans('admin.QuoteImages')}}" target="_blank">
                               <img src="{{asset('Admin/img/56-document-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan


                             @can('جدول امر البيع')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#">
                                 <a href="{{url('SalesOrderSechdule')}}" data-toggle="tooltip" data-placement="top" title="{{trans('admin.SalesOrderSechdule')}}" target="_blank">
                               <img src="{{asset('Admin/img/56-document-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan
                               @can('جدول المبيعات')
                        <div class="form-group col-lg-1 col-2">
                            <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#">
                                 <a   href="{{url('SalesSechdule')}}" data-toggle="tooltip" data-placement="top" title="{{trans('admin.SalesSechdule')}}" target="_blank">
                                 <img src="{{asset('Admin/img/970-video-conference-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan
                              @can('جدول عرض سعر')
                        <div class="form-group col-lg-1 col-2">
                            <button  type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#">
                                 <a  href="{{url('Quote_Sechdule')}}" data-toggle="tooltip" data-placement="top" title="{{trans('admin.Quote_Sechdule')}}" target="_blank">
                                 <img src="{{asset('Admin/img/298-coins-outline (1).gif')}}" alt="">
                                </a>
                         </button>
                        </div>
                           @endcan
                              @can('تقفيل اليوميه')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('DailyClosing')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.DailyClosing')}}" target="_blank">
                                  <img src="{{asset('Admin/img/946-equity-security-outline.gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                              @can('تقرير المصاريف')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('ExpensesReport')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title=" {{trans('admin.Expenses')}} " target="_blank">
                                  <img src="{{asset('Admin/img/945-dividends-outline (1).gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                              @can('اضافه تحويلات المخازن')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('StoresTransfers')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.Stores_Transfers')}}" target="_blank">
                                  <img src="{{asset('Admin/img/950-attract-customers-outline (1).gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                              @can('اضافه مشتريات')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('Purchases')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.Purchases')}}" target="_blank">
                                  <img height="20" src="{{asset('Admin/img/526-paper-bag-vegetables-outline.gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                              @can('جدول المشتريات')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('PurchasesSechdule')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.PurchasesSechdule')}}" target="_blank">
                                  <img height="20" src="{{asset('Admin/img/1387-page-view-column-outline.gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                                     @can('اضافه سلفه')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('AddBorrow')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.Add_Borrow')}}" target="_blank">
                                  <img height="20" src="{{asset('Admin/img/49-plus-circle-outline.gif')}}" alt="">
                                </a>
                        </div>
                           @endcan
                                @can('الاصناف اليوميه')
                        <div class="form-group col-lg-1 col-2">
                                 <a href="{{url('DailyProducts')}}" class="btn btn-default pos-icon" data-toggle="tooltip" data-placement="top" title="{{trans('admin.Products_Daily')}}" target="_blank">
                                  <img height="20" src="{{asset('Admin/img/948-stock-share-outline (1).gif')}}" alt="">
                                </a>
                        </div>
                           @endcan


                        <div class="form-group col-lg-1 col-2">

          <button type="button" class="btn btn-default pos-icon" data-toggle="modal" data-target="#OpenSafe">
                                 <a data-toggle="tooltip" data-placement="top" title="{{trans('admin.Open_Safe_Drawer')}}" >
                                <img src="{{asset('Admin/img/290-coin-outline (1).gif')}}" alt="">
                                </a>
                         </button>

                        </div>


                    </div>
                    @endif

                </div>
                   <div class="second-section">
                    <div class="row">
                        <div class="col-md-12">
                            <table id="dt" class="table table-bordered table-hover table-striped TABLEENGLISH">
                                <thead class="bg-primary-600">
                                    <tr>
                                        <th style="width: 26px"><i class="fal fa-trash-alt"></i></th>
                                        <th style="width: 200px;">{{trans('admin.Name')}}</th>
                                        @if($show->Show_Unit == 1)
                                        <th style="width: 70px">{{trans('admin.Unit')}}</th>
                                        @endif
                                        <th style="width: 70px;">{{trans('admin.Qty')}}</th>
                                        <th style="width: 70px;">{{trans('admin.Price')}}</th>
                                        @if($show->Disc == 1)
                                        <th style="width: 50px;">{{trans('admin.Discount')}}</th>
                                        @endif
                                        @if($show->Show_Total == 1)
                                        <th style="width:130px;">{{trans('admin.Total')}}</th>
                                        @endif
                                        @if($show->Show_Net == 1)
                                        <th style="width:130px;">{{trans('admin.The_Net')}}</th>
                                        @endif

                                    </tr>
                                </thead>
                                <tbody id="data-dt">


                                </tbody>
                            </table>
                        </div>
                    </div>
                   </div>
                        <div class="last-section" id="ActionAlert" style="display: none">
                {{trans('admin.Cant_Discount_This_Amount_From_That_Product')}}
                        </div>
                                  <div class="last-section" id="QTYAlert" style="display: none">
                       {{trans('admin.Not_Enough_Qty')}}    {{trans('admin.or')}}  {{trans('admin.PriceLowThanCost')}}
                        </div>
                   <div class="last-section" id="Action">
                    <div class="row" >
                       <div class="col-md-12">
                        <table class="table table-bordered table-hover table-striped">

                            <tbody>
                                <tr>

                                    <td>{{trans('admin.Product_Numbers')}}({{trans('admin.Total_Qty')}})</td>
                                    <td><span id="ProNums">0</span>(<span id="ProQty">0</span>)</td>
                                    <td>{{trans('admin.Total_Price')}}({{trans('admin.Total_Discount')}}) ({{trans('admin.Total_Taxes')}})</td>
                                    <td><span id="TotalPrice">0</span>(<span id="Total_DiscountTTShow">0</span>)(<span id="Total_TaxesShow">0</span>)</td>

                                </tr>
                            </tbody>
                        </table>
                    </div>
                   @if(auth()->guard('admin')->user()->pos_product == 1)
                            @if(auth()->guard('admin')->user()->pos_hold == 1 )
                    <div class="col-md-3">
                        <button onclick="Hol(1)" type="button" class="btn btn-sm btn-block btn-outline-primary waves-effect waves-themed"  data-toggle="modal" data-target="#default-example-modal-lg-center-bill">
                              {{trans('admin.Holding')}}</button>
                    </div>
                        @endif

             @if(auth()->guard('admin')->user()->pos_pay == 1 )
                    <div class="col-md-3">
                        <button type="button" onclick="Hol(0)" class="btn btn-sm btn-block btn-outline-success waves-effect waves-themed"  data-toggle="modal" data-target="#default-example-modal-center-payment">
                              {{trans('admin.Payment_Method')}}</button>
                    </div>
                @endif
                  @if(auth()->guard('admin')->user()->pos_hold == 1 )
                                   <div class="col-md-3">
                        <td>
                            <button type="button" class="btn btn-sm btn-block btn-outline-dark waves-effect waves-themed"  data-toggle="modal" data-target="#Holddd">
                                 {{trans('admin.Holding_Bill')}}</button>



                        </td>
                    </div>
                        @endif

                              <div class="col-md-3">
                        <td>
                            <button type="button" class="btn btn-sm btn-block btn-outline-dark waves-effect waves-themed"  data-toggle="modal" data-target="#default-example-modal-center-cancelPayment">
                                {{trans('admin.Cancel')}}</button>
                        </td>
                    </div>
                @else
                  @if(auth()->guard('admin')->user()->pos_hold == 1 )
                                   <div class="col-md-3">
                        <td>
                            <button type="button" class="btn btn-sm btn-block btn-outline-dark waves-effect waves-themed"  data-toggle="modal" data-target="#Holddd">
                                 {{trans('admin.Holding_Bill')}}</button>



                        </td>
                    </div>
                        @endif

                @endif

                    </div>
                   </div>
                    </div>
                </div>


                  <!-- Note modal -->
   <div class="modal fade" id="Note" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                               {{trans('admin.Notes')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>


                    <div class="modal-body">
                        <div class="row">
                  <div class="form-group col-lg-12 col-12">
                            <label class="form-label" for="simpleinput">{{trans('admin.Notes')}}</label>
                         <input type="text" name="Note" value="{{old('Note')}}" class="form-control">
                        </div>

                        </div>
                    </div>
                    <div class="modal-footer">
             <button type="button" class="btn btn-secondary" data-dismiss="modal">   {{trans('admin.Close')}}</button>
                    </div>
                </div>
            </div>
        </div>

                <!-- Hold bill modal -->
                <div class="modal fade" id="default-example-modal-lg-center-bill" tabindex="-1" role="dialog" aria-hidden="true">
                    <div class="modal-dialog  modal-dialog-centered" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h4 class="modal-title">
                                   {{trans('admin.Holding')}}
                                </h4>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                </button>
                            </div>
                            <div class="modal-body">
                                {{trans('admin.RUSWHB')}} :: {{$HoldCode}}

                              <!--   <div class="row mt-2">
                                <div class="col-md-6">
                                <label class="form-label">    {{trans('admin.Paid')}}</label>
              <input type="number" class="form-control" step="any" name="CashhHold" id="CashhHold" onkeyup="Diff()" onclick="Diff()">
                                    </div>
                                        <div class="col-md-6">
                                <label class="form-label">    {{trans('admin.Residual')}}</label>
                        <input type="number" class="form-control" step="any" id="ResidualHold" disabled>
                                    </div>
                               </div> -->
                            </div>
                            <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal"> {{trans('admin.No')}}</button>
                                  <div id="Submit">
            <button type="button"  class="btn btn-primary" onclick="SPS()"> <i class="fal fa-folder"></i> {{trans('admin.Yes')}} </button>

          <button type="button"  class="btn btn-primary" onclick="SPP()"><i class="fal fa-save"></i>  {{trans('admin.YesandPrint')}} </button>

                  <!--     <button type="button"  class="btn btn-primary" onclick="SPP8()"><i class="fal fa-save"></i>  {{trans('admin.YesandPrint8')}} </button>    -->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Cancel payment modal -->
                <div class="modal fade" id="default-example-modal-center-cancelPayment" tabindex="-1" role="dialog" aria-hidden="true">
                    <div class="modal-dialog modal-dialog-centered" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h4 class="modal-title">
                              {{trans('admin.Cancel')}}
                                </h4>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                </button>
                            </div>
                            <div class="modal-body">

                                 {{trans('admin.RUSWCO')}}
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">  {{trans('admin.No')}}</button>
                                <button type="button" class="btn btn-primary" onclick="window.location.reload();">  {{trans('admin.Yes')}}</button>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Payment modal -->
                <div class="modal fade" id="default-example-modal-center-payment" tabindex="-1" role="dialog" aria-hidden="true">
                    <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h4 class="modal-title">
                                   {{trans('admin.Payment_Method')}}
                                </h4>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                </button>
                            </div>
                            <div class="modal-body">



                                <div class="form-row">
                                    <div class="form-group col-lg-4">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.Product_Numbers')}} </label>
                                        <input type="text" id="Product_Numbers" disabled class="form-control">
                                        <input type="hidden" id="Product_NumbersHide" name="Product_Numbers">
                                    </div>
                                    <div class="form-group col-lg-4">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.Total_Qty')}} </label>
                                        <input type="text" id="Total_Qty" disabled class="form-control">
                                        <input type="hidden" id="Total_QtyHide" name="Total_Qty">
                                    </div>
                                    <div class="form-group col-lg-4">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.Total_Price')}}</label>
                                        <input type="text" id="Total_Price" disabled class="form-control">
                                        <input type="hidden" id="Total_PriceHide" name="Total_Price">
                                        <input type="hidden" id="Total_Bf_Taxes" disabled class="form-control">
                                        <input type="hidden" id="Total_Bf_TaxesHide" name="Total_BF_Taxes">
                                        <input type="hidden" id="Total_Discount" disabled class="form-control">
                                        <input type="hidden" id="Total_DiscountHide" name="Total_Discount">
                                        <input type="hidden" id="TotalCost" name="Total_Cost">
                                    </div>
                                    <div class="form-group col-lg-3">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.Total_Taxes')}}</label>
                                        <input type="text" id="Total_Taxes" disabled class="form-control">
                                        <input type="hidden" id="Total_TaxesHide" name="Total_Taxes">
                                    </div>
                                    <div class="form-group col-lg-3">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.Total_After_Taxes')}}</label>
                                        <input type="text" id="Total_After_Taxes" disabled class="form-control">
                                    </div>
                                    <div class="form-group col-lg-3">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.Total_Discount')}} </label>
                                        <input type="text" id="Total_DiscountTT" disabled class="form-control">
                                        <input type="hidden" id="Total_DiscountHideTT" name="Total_Discount">
                                    </div>
                                    <div class="form-group col-lg-3">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.Total_af_Discount')}} </label>
                                        <input type="text" class="form-control" id="TAFterD" disabled>
                                    </div>

                                    <div class="form-group col-lg-2">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.Total_Bill')}} </label>
                                        <input type="text" id="Total_Bill" disabled class="form-control">
                                    </div>


                                    @if(auth()->guard('admin')->user()->emp == 0)
                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for="simpleinput"> {{trans('admin.Discount_Bill')}} </label>
                                            <input type="text" class="form-control" id="resdiual" name="DiscountBill" value="0" onkeyup="Statuss()">
                                        </div>
                                    @else

                                        <div class="form-group col-lg-2" @if(auth()->guard('admin')->user()->bill_discount == 0) style="display: none" @endif >
                                            <label class="form-label" for="simpleinput"> {{trans('admin.Discount_Bill')}} </label>
                                            <input type="text" class="form-control" id="resdiual" name="DiscountBill" value="0" onkeyup="Statuss()">
                                        </div>

                                    @endif

                                    <div class="form-group col-lg-2">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.Total_Net')}} </label>
                                        <input type="text" class="form-control" id="Total_PriceW" disabled>
                                    </div>
                                    <div class="form-group col-lg-2">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.Paid')}} </label>
                                        <input type="number" step="any" name="Pay" id="paid" onkeyup="PayInstall()" onclick="PayInstall()" class="form-control">

                                    </div>
                                    @php $d='none'; @endphp
                                    @can('نسبه الربح') @php $d='block'; @endphp    @endcan
                                    <div class="form-group col-lg-2" style="display: {{$d}}">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.Profit')}} </label>
                                        <input type="number" step="any" name="ProfitPrecent" id="ProfitPrecent" class="form-control" value="0" readonly>

                                    </div>
                                    <div class="form-group col-lg-2" style="display: {{$d}}">
                                        <label class="form-label" for="simpleinput"> {{trans('admin.ProfitPrecent')}} %</label>
                                        <input type="number" step="any"  id="proPrecent" class="form-control" value="0" readonly>
                                    </div>


                                @if($show->TaxOnTotal == 1)
                                        <div class="form-group col-lg-3">
                                            <label class="form-label" for="simpleinput"> {{trans('admin.TaxOnTotal')}} </label>
                                            <select class="select2 form-control" name="TaxOnTotal">
                                                <option value="No">{{trans('admin.No')}}</option>
                                                <option value="Yes">{{trans('admin.Yes')}}</option>
                                            </select>
                                        </div>

                                        <div class="form-group col-lg-3">
                                            <label class="form-label" for="simpleinput"> {{trans('admin.TaxOnTotalType')}} </label>
                                            <select class="select2 form-control" name="TaxOnTotalType" id="TaxOnTotalType" onchange="TaxOn()">
                                                <option value="">{{trans('admin.TaxOnTotalType')}}</option>
                                                @foreach($Taxes as $tax)
                                                    <option value="{{$tax->id}}"> {{app()->getLocale() == 'ar' ?$tax->Name :$tax->NameEn}}</option>
                                                @endforeach
                                            </select>
                                        </div>


                                        <div class="form-group col-lg-3">
                                            <label class="form-label" for="simpleinput"> {{trans('admin.ProfitTax')}} </label>
                                            <input type="text" class="form-control" id="ProfitTax" name="ProfitTax" value="0" readonly>
                                        </div>
                                    @endcan


                                    @if($Def->Total_Wight_Bill == 1)
                                        <div class="form-group col-lg-3">
                                            <label class="form-label" for="simpleinput"> {{trans('admin.Total_Wight_Bill')}} </label>
                                            <input type="number" step="any" name="Total_Wight_Bill" id="Total_Wight_Bill" class="form-control" value="0" readonly>

                                        </div>
                                    @endif
                                </div>

                                <ul class="nav nav-tabs" role="tablist">

                                         @if(auth()->guard('admin')->user()->Cash == 1)
                                    <li class="nav-item"><a onclick="Pay('Cash')" id="T1" class="nav-link active" data-toggle="tab" href="#tab_direction-1" role="tab" aria-selected="true">{{trans('admin.Cash')}}</a></li>
                                    @endif
                                         @if(auth()->guard('admin')->user()->Later == 1)
                                    <li class="nav-item"><a onclick="Pay('Later')" id="T2" class="nav-link active" data-toggle="tab" href="#tab_direction-2" role="tab" aria-selected="false">{{trans('admin.Later')}}</a></li>
                                    @endif
                                         @if(auth()->guard('admin')->user()->Check == 1)
                                    <li class="nav-item"><a onclick="Pay('Check')" id="T3" class="nav-link active" data-toggle="tab" href="#tab_direction-3" role="tab" aria-selected="false">{{trans('admin.Check')}}</a></li>
                                    @endif

                                         @if(auth()->guard('admin')->user()->Installment == 1)
                                    <li class="nav-item"><a onclick="Pay('Installment')" id="T4" class="nav-link active" data-toggle="tab" href="#tab_direction-4" role="tab" aria-selected="false">{{trans('admin.Installment')}}</a></li>
                                    @endif

                                         @if(auth()->guard('admin')->user()->Cash_Visa == 1)
                            <li class="nav-item"><a onclick="Pay('Cash_Visa')" id="T5" class="nav-link active" data-toggle="tab" href="#tab_direction-5" role="tab" aria-selected="false">{{trans('admin.Cash_Visa')}}</a></li>
                                    @endif
                                         @if(auth()->guard('admin')->user()->Cash_Collection == 1)
                                 <li class="nav-item"><a onclick="Pay('Cash_Collection')" id="T6" class="nav-link active" data-toggle="tab" href="#tab_direction-6" role="tab" aria-selected="false">{{trans('admin.Cash_Collection')}}</a></li>
                                    @endif

                                         @if(auth()->guard('admin')->user()->Delivery == 1)

                                <li class="nav-item"><a onclick="Pay('Delivery')" id="T7" class="nav-link active" data-toggle="tab" href="#tab_direction-7" role="tab" aria-selected="false">{{trans('admin.Delivery')}}</a></li>
                                    @endif

                                         @if(auth()->guard('admin')->user()->InstallmentCompanies == 1)

                                 <li class="nav-item"><a onclick="Pay('InstallmentCompanies')" id="T8" class="nav-link active" data-toggle="tab" href="#tab_direction-8" role="tab" aria-selected="false">{{trans('admin.InstallmentCompanies')}}</a></li>
                                    @endif



                                                        @if(auth()->guard('admin')->user()->Visa_Network == 1)
                            <li class="nav-item"><a onclick="Pay('Visa')" id="T9" class="nav-link active" data-toggle="tab" href="#tab_direction-9" role="tab" aria-selected="false">{{trans('admin.Visa')}} ({{trans('admin.Visa2')}})</a></li>
                                    @endif
                                </ul>
                                <div class="tab-content p-3">
                            <input type="hidden" name="Payment_Method" id="Payment_Method" value="Cash">

                                    <div class="tab-pane fade active show" id="tab_direction-1" role="tabpanel">


                                    </div>
                                    <div class="tab-pane fade active show" id="tab_direction-2" role="tabpanel">
                                 <label>{{trans('admin.Later_Due')}}</label>
<input type="date" class="form-control" name="Later_Due">
                                    </div>
                                    <div class="tab-pane fade active show"  id="tab_direction-3" role="tabpanel">
                                    <div class="row">
                                                  <div class="form-group col-lg-4">
                                            <label class="form-label" for="">{{trans('admin.Check_Type')}}</label>
                                            <select class="select2 form-control w-100"  name="Check_Type" >
                                                <option value=""> {{trans('admin.Check_Type')}}</option>
                                            @foreach($ChecksTypes as $type)
                                                <option value="{{$type->id}}">

                                             {{app()->getLocale() == 'ar' ?$type->Arabic_Name :$type->English_Name}}
                                                </option>
                                            @endforeach
                                            </select>
                                        </div>

                                                              <div class="form-group col-lg-4">
                                            <label class="form-label" for="simpleinput">{{trans('admin.Due_Date')}}  </label>
                      <input type="date"  value="{{old('Due_Date')}}" class="form-control" name="Due_Date">
                                        </div>


                                      <div class="form-group col-lg-4">
                                   <label class="form-label" for="simpleinput">{{trans('admin.Check_Number')}}  </label>
             <input type="number" step="any"  value="{{old('Check_Number')}}" class="form-control" name="Check_Number">
                                        </div>
                                </div>
                                    </div>
                                    <div class="tab-pane fade active show"  id="tab_direction-4" role="tabpanel">
                                     <div class="row">
                                <div class="form-group col-lg-3">
                         <label class="form-label" for="simpleinput">{{trans('admin.Presenter')}}</label>
           <input type="number" onclick="Install()" onkeyup="Install()" step="any" id="presenter" name="presenter" value="{{old('presenter')}}" class="form-control" >
                                        </div>

                                  <div class="form-group col-lg-3">
                           <label class="form-label" for="simpleinput">{{trans('admin.annual_interest')}}</label>
           <input type="number" step="any" onclick="Install()" onkeyup="Install()"  id="annual_interest" name="annual_interest" value="{{old('annual_interest')}}" class="form-control">
                                        </div>



                                         <div class="form-group col-lg-3">
                               <label class="form-label" for="simpleinput">{{trans('admin.Years_Number')}}</label>
     <input type="number" step="any" onclick="Install()" onkeyup="Install()" id="Years_Number" name="Years_Number" value="{{old('Years_Number')}}" class="form-control">
                                        </div>

                                     <div class="form-group col-lg-3">
                               <label class="form-label" for="simpleinput">{{trans('admin.total')}}</label>
     <input type="number" onclick="Install()" onkeyup="Install()"  step="any" id="total" name="total" value="{{old('total')}}" class="form-control" readonly>

                                        </div>


                                         <div class="form-group col-lg-4">
                               <label class="form-label" for="simpleinput">{{trans('admin.Date_First_installment')}}</label>
     <input type="date" onchange="Install()"  name="Date_First_installment" value="{{old('Date_First_installment')}}" class="form-control">
                                        </div>

                                           <div class="form-group col-lg-4">
                          <label class="form-label" for="simpleinput">{{trans('admin.monthly_installment')}}</label>
     <input type="number" step="any" id="monthly_installment" value="{{old('monthly_installment')}}" class="form-control" disabled>

              <input type="hidden" step="any" id="monthly_installmentHide" name="monthly_installment">

                                        </div>
                             <div class="form-group col-lg-4">
                               <label class="form-label" for="simpleinput">{{trans('admin.installment_Num')}}</label>
     <input type="number" step="any" id="installment_Num"  value="{{old('installment_Num')}}" class="form-control" disabled>
                            <input type="hidden" step="any" id="installment_NumHide" name="installment_Num">
                                        </div>



                                    </div>
                                    </div>
                                    <div class="tab-pane fade active show"  id="tab_direction-5" role="tabpanel">
                                      <div class="row">
                                              <div class="form-group col-md-4">

                              <label class="form-label" for="example-textarea"> {{trans('admin.Cash')}} </label>

                           <input  name="Cash" class="form-control use-keyboard-number" value="0">
                                            </div>

                                  <div class="form-group col-md-4">

                              <label class="form-label" for="example-textarea"> {{trans('admin.Visa')}} </label>

                               <input  name="Visa" class="form-control use-keyboard-number" value="0">
                                            </div>


                                                         <div class="form-group col-lg-4">
                                                             <label class="form-label" for="example-textarea"> {{trans('admin.Bank')}} </label>
                                            <select class="select2 form-control w-100" name="SafeVisa">
                                                 <option value=""> {{trans('admin.Safe')}}</option>
                                            @foreach($Banks as $safe)
                                                <option value="{{$safe->id}}" @if($Def->Bank == $safe->id) selected @endif>
                                                     {{app()->getLocale() == 'ar' ?$safe->Name :$safe->NameEn}}
                                                </option>
                                            @endforeach
                                            </select>
                                        </div>

                                      </div>
                                    </div>
                                    <div class="tab-pane fade active show" id="tab_direction-6" role="tabpanel">
                                        <div class="row form-group">
                                            <div class="col-md-2">
                              <label class="form-label" for="example-textarea"> {{trans('admin.Paid')}} </label>
                                                </div>
                                            <div class="col-md-12">
                                    <input  name="Cash_Collection" class="form-control use-keyboard-number">
                                            </div>
                                        </div>

                                    </div>
                                    <div class="tab-pane fade active show" id="tab_direction-7" role="tabpanel">
                                        <div class="row form-group">
                                            <div class="col-md-6">
                                                 <label>{{trans('admin.Delivery')}}</label>
                              <select class="select2 form-control" name="Delivery" id="Delivery">
                                        <option value="">{{trans('admin.Delivery')}}</option>
                                  @foreach($Deliveries as $del)
                    <option value="{{$del->id}}" @if($Def->Delivery == $del->id) selected @endif>

                                   {{app()->getLocale() == 'ar' ?$del->Name :$del->NameEn}}
                                  </option>
                                  @endforeach
                                                </select>
                                                </div>
                                                         <div class="col-md-6">
                                    <label>{{trans('admin.Client_Address')}}</label>
                              <select class="select2 form-control" name="Client_Address" id="Client_Address">


                                                </select>
                                                </div>

                                        </div>

                                    </div>
                                    <div class="tab-pane fade active show" id="tab_direction-8" role="tabpanel">
                                <div class="row form-group">
                           <div class="form-group col-lg-4">
                              <label class="form-label" for="">{{trans('admin.InstallCompany')}}</label>
                              <select class="select2 form-control w-100"  name="InstallCompany" id="InstallCompany" onchange="InstaallComp()" >
                                 <option value=""> {{trans('admin.InstallCompany')}}</option>
                                 @foreach($InstallmentCompanies as $inst)
                                 <option value="{{$inst->id}}">

                                      {{app()->getLocale() == 'ar' ?$inst->Arabic_Name :$inst->English_Name}}
                                 </option>
                                 @endforeach
                              </select>
                           </div>


                                        <div class="form-group col-lg-4">
                           <label class="form-label" for="simpleinput">{{trans('admin.ContractNumber')}}  </label>
                           <input type="text" name="ContractNumber" value="{{old('ContractNumber')}}" class="form-control">
                        </div>



                                         <div class="form-group col-lg-4">
                              <label class="form-label" for="">{{trans('admin.PayFees')}}</label>
                              <select class="select2 form-control w-100"  name="PayFees"  >
                                 <option value="No"> {{trans('admin.No')}}</option>
                                 <option value="Yes"> {{trans('admin.Yes')}}</option>
                              </select>
                           </div>

                                              @can('رسوم خدمات شركات التقسيط')  @php $Style='block';  @endphp   @endcan

                                                        <div class="form-group col-lg-4" style="display: {{$Style}}">
                           <label class="form-label" for="simpleinput">{{trans('admin.ServiceFee')}}  </label>
                           <input type="text" name="ServiceFee" id="ServiceFee" value="{{old('ServiceFee')}}" class="form-control" readonly>
                        </div>


                                                                           <div class="form-group col-lg-4" style="display: {{$Style}}">
                           <label class="form-label" for="simpleinput">{{trans('admin.CompanyPrecent')}}  </label>
                           <input type="text" name="CompanyPrecent" id="CompanyPrecent" value="{{old('CompanyPrecent')}}" class="form-control" readonly>
                        </div>

                                                      <div class="form-group col-lg-4" style="display: {{$Style}}">
                           <label class="form-label" for="simpleinput">{{trans('admin.TotalServiceFee')}}  </label>
                           <input type="text"  id="TotalServiceFee"  class="form-control" readonly>
                        </div>


                           </div>
                                    </div>
                                     <div class="tab-pane fade active show"  id="tab_direction-9" role="tabpanel">
                                      <div class="row">
                                              <div class="form-group col-md-4" style="display: none">

                              <label class="form-label" for="example-textarea"> {{trans('admin.Cash')}} </label>

                           <input  name="Cash2" class="form-control use-keyboard-number"  value="0">
                                            </div>

                                  <div class="form-group col-md-4">

                              <label class="form-label" for="example-textarea"> {{trans('admin.Visa')}} </label>

                               <input  name="Visa2" class="form-control use-keyboard-number" id="Visa2" >
                                            </div>


                                                         <div class="form-group col-lg-4">
                                                             <label class="form-label" for="example-textarea"> {{trans('admin.Bank')}} </label>
                                            <select class="select2 form-control w-100" name="SafeVisa2">
                                                 <option value=""> {{trans('admin.Safe')}}</option>
                                            @foreach($Banks as $safe)
                                                <option value="{{$safe->id}}" @if($Def->Bank == $safe->id) selected @endif>
                                                     {{app()->getLocale() == 'ar' ?$safe->Name :$safe->NameEn}}
                                                </option>
                                            @endforeach
                                            </select>
                                        </div>

                                      </div>
                                    </div>
                                </div>



                            </div>
                            <div class="modal-footer" >
                            <div id="SubmitY" >
                                <button type="button" class="btn btn-secondary mt-2" data-dismiss="modal">      {{trans('admin.Close')}}</button>

                                                    <input type="hidden" id="sp" name="SP">


            <button type="button"  class="btn btn-primary mt-2" onclick="SPS()"> <i class="fal fa-folder"></i> {{trans('admin.Save')}} </button>

                                  @if($show->A4 == 1)
          <button type="button"  class="btn btn-primary mt-2" onclick="SPP()"><i class="fal fa-save"></i>  {{trans('admin.SaveandPrint')}} </button>
                            @endif
                                  @if($show->CM8 == 1)
                       <button type="button"  class="btn btn-primary mt-2" onclick="SPP8()"><i class="fal fa-save"></i>  {{trans('admin.SaveandPrint8')}} </button>
                                @endif


                            </div>
                            </div>
                        </div>
                    </div>
                </div>

                   <!-- All Hold Bills -->
                   <div class="modal fade" id="Holddd" tabindex="-1" role="dialog" aria-hidden="true">
                    <div class="modal-dialog modal-dialog-centered modal-xl" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h4 class="modal-title">
                                 {{trans('admin.Holding_Bill')}}
                                </h4>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                </button>
                            </div>
                            <div class="modal-body">
                    <div class="row">

                              <div class="input-items col-md-12 mb-2">
                             <input type="text" id="searchHold" class="form-control" placeholder="   {{trans('admin.Code')}}">

                                      @if(app()->getLocale() == 'ar' )
                     <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;left:3px;"></i>
                      @else
                            <i class="fal fa-barcode-alt" style="position:absolute ;top:5px;right: 0;left:auto;"></i>
                      @endif
                            </div>
                        </div>
                                <div class="row HOLDD" >
                            @foreach($HoldSales as $sal)



                          <a  href="{{url('HoldSale/'.$sal->id)}}" class="col-md-6">

                          <table  style="position:relative;background: #c59cc5;" class="table table-bordered w-100">

                                      @can('حذف امر البيع')
                               <a class="btn btn-primary btn-sm" href="{{url('DeleteHoldBill/'.$sal->id)}}" style="margin-right:11px;height:35px;position:absolute;left:17px;top:5px;z-index:22;"><i class="fal fa-trash"></i></a>
                                    @endcan
                              <tr>
                                  <td> {{trans('admin.Code')}}</td>
                                  <td> {{$sal->Code}}</td>


                              </tr>
                                 <tr>
                                  <td>{{trans('admin.Client')}}</td>
                                  <td>

                                    {{app()->getLocale() == 'ar' ?$sal->Client()->first()->Name :$sal->Client()->first()->NameEn}}
                                     </td>

                              </tr>
                                    <tr>
                                  <td>{{trans('admin.User')}}</td>
                                  <td>

                            {{app()->getLocale() == 'ar' ?$sal->User()->first()->name :$sal->User()->first()->nameEn}}
                                        </td>

                              </tr>
                              <tr>
                                  <td>{{trans('admin.Date')}}</td>
                                  <td>{{$sal->Date}}</td>

                              </tr>
                              <tr>
                                  <td>{{trans('admin.Total_Price')}}</td>
                                  <td>{{$sal->Total_Price}}</td>

                              </tr>
                          </table>
                 </a>

                            @endforeach
                            </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">  {{trans('admin.Close')}}</button>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>

    </form>



                          <!-- Modal New Client -->
            <div class="modal fade" id="NewClient" tabindex="-1" role="dialog" aria-hidden="true">
                        <div class="modal-dialog modal-dialog-centered modal-xl" role="document">
                            <div class="modal-content">
                                <div class="modal-header">

                                    <h4 class="modal-body row">


                                        <div class="form-group col-md-3">
                                 <label class="form-label" for="simpleinput">   {{trans('admin.Code')}}</label>
                                 <input type="text" id="CODE"  value="{{$CodeUser}}" disabled class="form-control">

                                                                    </div>
                                                   <div class="form-group col-md-3">
                <label class="form-label" for="simpleinput"> {{trans('admin.Arabic_Name')}}  </label><span class="strick">*</span>
                        <input type="text" id="Name" value="{{old('Name')}}" class="form-control">
                                                                    </div>

                                        <div class="form-group col-md-3">
                <label class="form-label" for="simpleinput"> {{trans('admin.English_Name')}}  </label><span class="strick">*</span>
                        <input type="text" id="NameEn" value="{{old('NameEn')}}" class="form-control">
                                                                    </div>

                                                     <div class="form-group col-md-3">
                <label class="form-label" for="simpleinput"> {{trans('admin.Phone')}}  </label><span class="strick">*</span>
                        <input type="number" id="Phone" value="{{old('Phone')}}" class="form-control">
                                                                    </div>
                                                               <div class="form-group col-md-3">
                <label class="form-label" for="">   {{trans('admin.Price_Level')}} </label><span class="strick">*</span>
                             <select class="select2 form-control w-100" id="PriceLevel">
                                    <option value="1"> {{trans('admin.Level1')}} </option>
                                    <option value="2"> {{trans('admin.Level2')}} </option>
                                    <option value="3"> {{trans('admin.Level3')}} </option>

                                                                        </select>
                                                                    </div>

                                     <div class="row">
                  <div class="form-group col-md-2">
                    <label>{{trans('admin.Address_Name')}}</label>
                    <input type="text" id="NaameAddress" class="form-control" value="العنوان الرئيسي">
                                    </div>
                  <div class="form-group col-md-2">
                      <label>{{trans('admin.Governrate')}}</label>
                      <select class="select2 form-control w-100" id="Governrate" >
                     <option value="">{{trans('admin.Governrate')}}</option>
                     @foreach($Governrates as $gov)
                     <option value="{{$gov->id}}">


                 {{app()->getLocale() == 'ar' ?$gov->Arabic_Name :$gov->English_Name}}
                     </option>
                     @endforeach
                  </select>
                    </div>
                  <div class="form-group col-md-2">
                      <label>{{trans('admin.City')}}</label>
                           <select class="select2 form-control w-100" id="City" >

                                       </select>
                                        </div>
                  <div class="form-group col-md-2"><label>{{trans('admin.Place')}}</label>
                           <select class="select2 form-control w-100" id="Place" >

                                       </select>
                                         </div>
                  <div class="form-group col-md-2"><label>{{trans('admin.Street')}}</label>
                            <input type="text" id="Street" class="form-control">
                                         </div>
                  <div class="form-group col-md-2"><label>{{trans('admin.Buliding')}}</label>
                                <input type="text" id="Buliding" class="form-control">
                                         </div>
                  <div class="form-group col-md-2"><label>{{trans('admin.Floor')}}</label>
                             <input type="text" id="Floor" class="form-control">
                                         </div>
                  <div class="form-group col-md-2"><label>{{trans('admin.Flat')}}</label>
                               <input type="text" id="Flat" class="form-control">
                                         </div>
                  <div class="form-group col-md-2"><label>{{trans('admin.Special_Mark')}}</label>
                            <input type="text" id="Special_Mark" class="form-control">
                                         </div>
                  <div class="form-group col-md-2"><label>{{trans('admin.Location')}}</label>
                           <input type="text" id="Location" class="form-control">
                                         </div>
                  <div class="form-group col-md-4"><label>{{trans('admin.Address_Details')}}</label>
                   <input type="text"  id="Address_Details" class="form-control" value="العنوان بتفصيل">
                                         </div>

                                        </div>


                                    </h4>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                    </button>
                                </div>

                                <div class="modal-footer">
                  <button type="button" class="btn btn-secondary" data-dismiss="modal"> {{trans('admin.No')}}</button>
                   <button type="button" onclick="NewClients()"  class="btn btn-primary"> {{trans('admin.AddNew')}}</button>
                                </div>

                            </div>
                        </div>
                    </div>


        <!-- Shift Details -->
         <div class="modal fade" id="default-example-modal-center-shiftDetails" tabindex="-1" role="dialog" aria-hidden="true">

            <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                           {{trans('admin.Shift_Details')}}  {{$shift->Code}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>

                     <div class="modal-body" id="LOCKK">
                      <div class="row">
                        <div class="col-md-10">
                    <label>{{trans('admin.Password')}}</label>
              <input type="password" id="Pass" class="form-control">
              <input type="hidden" id="RightPass" value="{{$Def->Shift_Pass}}">
                            </div>
                        <div class="col-md-2">
            <button type="button" onclick="Unlock()" class="'btn btn-primary m-4"><i class="fal fa-lock"></i></button>
                            </div>
                        </div>
                    </div>


                    <div class="modal-body" id="DETALIS" style="display: none">
                      <table class="table table-bordered">
                          <tbody>
                              <tr>
                                  <td>{{trans('admin.Total_Cash')}} </td>
                                  <td>{{$shift->Total_Cash}}</td>
                              </tr>
                              <tr>
                                    <td>{{trans('admin.Total_Later')}} </td>
                                  <td>{{$shift->Total_Later}}</td>
                              </tr>
                              <tr>
                                    <td>{{trans('admin.Total_Later_Not_Paid')}} </td>
                                  <td>{{$shift->Total_Later_Not_Paid}}</td>
                              </tr>
                              <tr>
                                    <td>{{trans('admin.Total_Later_Paid')}} </td>
                                  <td>{{$shift->Total_Later_Paid}}</td>
                              </tr>
                              <tr>
                                    <td>{{trans('admin.Total_Installment')}} </td>
                                  <td>{{$shift->Total_Installment}}</td>
                              </tr>
                                      <tr>
                                    <td>{{trans('admin.Total_Checks')}} </td>
                                  <td>{{$shift->Total_Checks}}</td>
                              </tr>
                                      <tr>
                                    <td>{{trans('admin.Total_Delivery')}} </td>
                                  <td>{{$shift->Total_Delivery}}</td>
                              </tr>
                                      <tr>
                                    <td>{{trans('admin.Total_Installment_Companies')}} </td>
                                  <td>{{$shift->Total_Installment_Companies}}</td>
                              </tr>

                              <tr>
                                     <td>{{trans('admin.Total_Visa')}} </td>
                                  <td>{{$shift->Total_Visa}}</td>
                              </tr>

                                     <tr>
                                     <td>{{trans('admin.Total_Recipt')}} </td>
                                  <td>{{$shift->Total_Recipt}}</td>
                              </tr>

{{--                                     <tr>--}}
{{--                                     <td>{{trans('admin.Total_Payment')}} </td>--}}
{{--                                  <td>{{$shift->Total_Payment}}</td>--}}
{{--                              </tr>--}}
                              <tr>
                                  <td>{{trans('admin.Total')}} </td>
                                  <td>{{$shift->Total}}</td>
                              </tr>
                          </tbody>
                      </table>
                    </div>
                    <div class="modal-footer">

                    </div>
                </div>
            </div>
        </div>

               <!-- Open Safe -->
         <div class="modal fade" id="OpenSafe" tabindex="-1" role="dialog" aria-hidden="true">

            <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
{{trans('admin.Password_To_Open_SafeDrawer')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>

                     <div class="modal-body" id="BLOCKSAFE">
                      <div class="row">
                        <div class="col-md-10">
                    <label>{{trans('admin.Password')}}</label>
              <input type="password" id="PassSafe" class="form-control">
              <input type="hidden" id="RightPassSafe" value="{{$Def->Shift_Pass}}">
                            </div>
                        <div class="col-md-2">
            <button type="button" onclick="UnlockSafe()" class="'btn btn-primary m-4"><i class="fal fa-lock"></i></button>
                            </div>
                        </div>
                    </div>



                    <div class="modal-footer">

                    </div>
                </div>
            </div>
        </div>

         <!-- Close Shift -->
         <div class="modal fade" id="default-example-modal-center-closeShift" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                          {{trans('admin.Close_Shift')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>
                    <div class="modal-body">

                    <form action="{{url('CloseShift')}}" method="post">
                        {!! csrf_field()  !!}

                      <input type="hidden" name="ShiftID" value="{{$shift->id}}">
                            <div class="row">
                                <div class="form-group col-lg-2 col-12">
                                    <label class="form-label" for="simpleinput">{{trans('admin.Shift_Code')}} </label>
                                    <input type="text"  class="form-control " disabled value="{{$shift->Code}}">
                                </div>
                                <div class="form-group col-lg-4 col-12">
                                    <label class="form-label" for="simpleinput">{{trans('admin.Amount')}} </label>
              <input type="number" step="any" name="AmountShift"  class="form-control use-keyboard-input" required>
                                </div>
                                <div class="form-group col-lg-6 col-12">
                                    <label class="form-label" for="simpleinput">{{trans('admin.Notes')}} </label>
                                    <input type="text" name="Note"  class="form-control use-keyboard-input">
                                </div>
                                         <div class="form-group col-lg-6 col-6">
                   <button type="submit" class="btn btn-primary"> {{trans('admin.Close_Shift')}}</button>
                                </div>
                            </div>
                             </form>

                    </div>
                    <div class="modal-footer">

                    </div>
                </div>
            </div>
        </div>


        <!-- Groups modal -->
        <div class="modal fade" id="groups" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                        {{trans('admin.Groups')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            @foreach($ItemsGroups as $group)

                            <div class="col-md-2">
                                <a data-dismiss="modal" onclick="GROUP({{$group->id}})">
                               <div class="group-details">
                                   @if(!empty($group->Image))
                                   <img src="{{URL::to($group->Image)}}" alt="">
                                   @else
                                      <img src="{{asset('Admin/img/demo/gallery/5.jpg')}}" alt="">
                                   @endif

                                  <p>
                                    {{app()->getLocale() == 'ar' ?$group->Name :$group->NameEn}}
                                   </p>
                                 </div>
                                </a>
                            </div>

                            @endforeach
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">{{trans('admin.Close')}}</button>
                    </div>
                </div>
            </div>
        </div>


        <!-- Brands modal -->
        <div class="modal fade" id="brands" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                               {{trans('admin.Brands')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                                          @foreach($Brands as $brand)

                            <div class="col-md-2">
                                <a data-dismiss="modal" onclick="BRAND({{$brand->id}})">
                               <div class="group-details">
                                   @if(!empty($brand->Image))
                                   <img src="{{URL::to($brand->Image)}}" alt="">
                                   @else
                                      <img src="{{asset('Admin/img/demo/gallery/5.jpg')}}" alt="">
                                   @endif

                                  <p>
                                             {{app()->getLocale() == 'ar' ?$brand->Name :$brand->NameEn}}
                                   </p>
                                 </div>
                                </a>
                            </div>

                            @endforeach
                        </div>
                    </div>
                    <div class="modal-footer">
             <button type="button" class="btn btn-secondary" data-dismiss="modal">   {{trans('admin.Close')}}</button>
                    </div>
                </div>
            </div>
        </div>


            <!--         Recipt Voucher modal -->
        <div class="modal fade" id="Recipt" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                               {{trans('admin.Receipt_Voucher')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>


                    <div class="modal-body">
                        <div class="row">


                <div class="col-md-6">
                <label>{{trans('admin.Creditor')}}</label>
                    <input type="number" step="any" class="form-control" id="Creditor">
                        </div>

                        <div class="col-md-6">
                <label>{{trans('admin.Account')}}</label>
            <select  class="select2 form-control w-100" id="AccountCode" >

                          </select>
                        </div>

                            @if($Def->Choice_Collector_POS == 1)
                                <div class="form-group col-lg-4">
                                    <label class="form-label" for="">{{trans('admin.Collector')}}</label>
                                    <select class="select2 form-control w-100" id="Collector">
                                        <option value="">{{trans('admin.Collector')}}</option>
                                        @foreach($Employess as $emp)
                                            <option value="{{$emp->id}}">

                                                {{app()->getLocale() == 'ar' ?$emp->Name :$emp->NameEn}}
                                            </option>
                                        @endforeach
                                    </select>
                                </div>
                            @else
                                <input type="hidden"  id="Collector" value="{{auth()->guard('admin')->user()->emp}}" class="form-control" />
                            @endif

                                 <div class="col-md-12">
                <label>{{trans('admin.Statement')}}</label>
                    <input type="text"  class="form-control" id="STATEMENT">
                        </div>


<input type="hidden" id="Shift"  value="{{$shift->Code}}">
<input type="hidden" id="Safe"  value="{{auth()->guard('admin')->user()->safe}}">
<input type="hidden" id="Coin"  value="{{$Def->Coin}}">
<input type="hidden" id="Draw"  value="{{$Def->Draw}}">
 <input type="hidden" id="STORE" value="{{auth()->guard('admin')->user()->store}}">


                        </div>
                    </div>
                    <div class="modal-footer">
             <button type="button" class="btn btn-secondary" data-dismiss="modal">   {{trans('admin.Close')}}</button>
             <button type="button" class="btn btn-secondary" id="ReciptVoucher">   {{trans('admin.Save')}}</button>
                    </div>
                </div>
            </div>
        </div>

                 <!--         Recipt Voucher 2 modal -->
        <div class="modal fade" id="ReciptTwo" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                                 {{trans('admin.Payment_Voucher')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>


                    <div class="modal-body">
                        <div class="row">


                <div class="col-md-6">
                <label>{{trans('admin.Creditor')}}</label>
                    <input type="number" step="any" class="form-control" id="CreditorF">
                        </div>

                        <div class="col-md-6">
                <label>{{trans('admin.Account')}}</label>
            <select  class="select2 form-control w-100" id="AccountCodeF" >

                          </select>
                        </div>

                            @if($Def->Choice_Collector_POS == 1)
                                <div class="form-group col-lg-4">
                                    <label class="form-label" for="">{{trans('admin.Collector')}}</label>
                                    <select class="select2 form-control w-100" id="CollectorF">
                                        <option value="">{{trans('admin.Collector')}}</option>
                                        @foreach($Employess as $emp)
                                            <option value="{{$emp->id}}">

                                                {{app()->getLocale() == 'ar' ?$emp->Name :$emp->NameEn}}
                                            </option>
                                        @endforeach
                                    </select>
                                </div>
                            @else
                                <input type="hidden"  id="CollectorF" value="{{auth()->guard('admin')->user()->emp}}" class="form-control" />
                            @endif

                                <div class="col-md-12">
                <label>{{trans('admin.Statement')}}</label>
                    <input type="text"  class="form-control" id="STATEMENTF">
                        </div>

<input type="hidden" id="ShiftF"  value="{{$shift->Code}}">
<input type="hidden" id="SafeF"  value="{{auth()->guard('admin')->user()->safe}}">
<input type="hidden" id="CoinF"  value="{{$Def->Coin}}">
<input type="hidden" id="DrawF"  value="{{$Def->Draw}}">
 <input type="hidden" id="STOREF" value="{{auth()->guard('admin')->user()->store}}">


                        </div>
                    </div>
                    <div class="modal-footer">
             <button type="button" class="btn btn-secondary" data-dismiss="modal">   {{trans('admin.Close')}}</button>
             <button type="button" class="btn btn-secondary" id="ReciptVoucher">   {{trans('admin.Save')}}</button>
                    </div>
                </div>
            </div>
        </div>


                 <!--         Payment Voucher modal -->
        <div class="modal fade" id="PayVouch" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                               {{trans('admin.Payment_Voucher')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>


                    <div class="modal-body">
                        <div class="row">


                <div class="col-md-6">
                <label>{{trans('admin.Debitor')}}</label>
                    <input type="number" step="any" class="form-control" id="Debitor">
                        </div>

                        <div class="col-md-6">
                <label>{{trans('admin.Account')}}</label>
            <select  class="select2 form-control w-100" id="AccountCodee" >

                          </select>
                        </div>

                                      <div class="col-md-12">
                <label>{{trans('admin.Statement')}}</label>
                    <input type="text"  class="form-control" id="STATEMENTP">
                        </div>

<input type="hidden" id="ShiftP"  value="{{$shift->Code}}">
<input type="hidden" id="SafeP"  value="{{auth()->guard('admin')->user()->safe}}">
<input type="hidden" id="CoinP"  value="{{$Def->Coin}}">
<input type="hidden" id="DrawP"  value="{{$Def->Draw}}">
 <input type="hidden" id="STOREP" value="{{auth()->guard('admin')->user()->store}}">


                        </div>
                    </div>
                    <div class="modal-footer">
             <button type="button" class="btn btn-secondary" data-dismiss="modal">   {{trans('admin.Close')}}</button>
             <button type="button" class="btn btn-secondary" id="PaymentVoucher">   {{trans('admin.Save')}}</button>
                    </div>
                </div>
            </div>
        </div>

                      <!--         Payment 2 Voucher modal -->
        <div class="modal fade" id="PayyVouch" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                       {{trans('admin.Expenses_Voucher')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>


                    <div class="modal-body">
                        <div class="row">


                <div class="col-md-6">
                <label>{{trans('admin.Debitor')}}</label>
                    <input type="number" step="any" class="form-control" id="Debitorr">
                        </div>

                        <div class="col-md-6">
                <label>{{trans('admin.Account')}}</label>
            <select  class="select2 form-control w-100" id="AccountCodeee" >

                          </select>
                        </div>


                                          <div class="col-md-12">
                <label>{{trans('admin.Statement')}}</label>
                    <input type="text"  class="form-control" id="STATEMENTPr">
                        </div>
<input type="hidden" id="ShiftPr"  value="{{$shift->Code}}">
<input type="hidden" id="SafePr"  value="{{auth()->guard('admin')->user()->safe}}">
<input type="hidden" id="CoinPr"  value="{{$Def->Coin}}">
<input type="hidden" id="DrawPr"  value="{{$Def->Draw}}">
 <input type="hidden" id="STOREPr" value="{{auth()->guard('admin')->user()->store}}">


                        </div>
                    </div>
                    <div class="modal-footer">
             <button type="button" class="btn btn-secondary" data-dismiss="modal">   {{trans('admin.Close')}}</button>
             <button type="button" class="btn btn-secondary" id="PaymentVoucherr">   {{trans('admin.Save')}}</button>
                    </div>
                </div>
            </div>
        </div>

                              <!--         Payment 3 Voucher modal -->
        <div class="modal fade" id="PayyyVouch" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                                  {{trans('admin.Vendor_Voucher')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>


                    <div class="modal-body">
                        <div class="row">


                <div class="col-md-6">
                <label>{{trans('admin.Debitor')}}</label>
                    <input type="number" step="any" class="form-control" id="Debitorrr">
                        </div>

                        <div class="col-md-6">
                <label>{{trans('admin.Account')}}</label>
            <select  class="select2 form-control w-100" id="AccountCodeeee" >

                          </select>
                        </div>

                                                     <div class="col-md-12">
                <label>{{trans('admin.Statement')}}</label>
                    <input type="text"  class="form-control" id="STATEMENTPrP">
                        </div>

<input type="hidden" id="ShiftPrP"  value="{{$shift->Code}}">
<input type="hidden" id="SafePrP"  value="{{auth()->guard('admin')->user()->safe}}">
<input type="hidden" id="CoinPrP"  value="{{$Def->Coin}}">
<input type="hidden" id="DrawPrP"  value="{{$Def->Draw}}">
 <input type="hidden" id="STOREPrP" value="{{auth()->guard('admin')->user()->store}}">


                        </div>
                    </div>
                    <div class="modal-footer">
             <button type="button" class="btn btn-secondary" data-dismiss="modal">   {{trans('admin.Close')}}</button>
             <button type="button" class="btn btn-secondary" id="PaymentVoucherrr">   {{trans('admin.Save')}}</button>
                    </div>
                </div>
            </div>
        </div>


              <!-- UnitTTT modal -->
        <div class="modal fade" id="UnitTTT" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog  modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                        {{trans('admin.Unit')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                        <div class="col-md-12">
                    <input type="hidden" id="R">
                    <input type="hidden" id="ProR">
                    <input type="hidden" id="CodeR">
                    <input type="hidden" id="StoR">
                        <select class="select2 form-control" id="ChUnit" onchange="UnitCodePurch()">

                            </select>
                        </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">{{trans('admin.Close')}}</button>
                    </div>
                </div>
            </div>
        </div>


          <!-- Tax modal -->
        <div class="modal fade" id="TAXXXX" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog  modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">
                        {{trans('admin.Unit')}}
                        </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                        <div class="col-md-12">
                    <input type="hidden" id="RX">
                    <input type="hidden" id="ProRX">
                        <select class="select2 form-control" id="OLDTAX" onchange="TAXPurch()">
                            @foreach($TAXESS as $tax)
                    <option value="{{$tax->id}}">

                         {{app()->getLocale() == 'ar' ?$tax->Name :$tax->NameEn}}
                            </option>
                              @endforeach
                            </select>
                        </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">{{trans('admin.Close')}}</button>
                    </div>
                </div>
            </div>
        </div>

          @if(auth()->guard('admin')->user()->pos_stores == 1)

         <!-- Other Qty -->
        <div class='modal fade' id='Avilable' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel' aria-hidden='true'>
        <div class='modal-dialog' role='document'>
        <div class='modal-content'>
        <div class='modal-header'>
        <h5 class='modal-title' id='exampleModalLabel'>{{trans('admin.Qty_In_OtherStores')}}</h5><button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
        </div>
        <div class='modal-body'>
                       <table class="table table-bordered table-hover table-striped">
                            <thead>
                                <th>{{trans('admin.Store')}}</th>
                                <th>{{trans('admin.Qty')}}</th>
                            </thead>
                            <tbody class="QTYOTHERSTORES">

                            </tbody>
                        </table>
        </div>
        <div class='modal-footer'>
        <button type='button' class='btn btn-secondary' data-dismiss='modal'>Close</button>
            </div>
            </div>
            </div>
            </div>



        @endif

        <!-- END Messenger -->



@push('posjs')
         @if($Def->Discount == 0)
            <input type="hidden" id="DIS" value="0">  <!-- Number -->
        @else
            <input type="hidden" id="DIS" value="1">  <!-- Precent -->
        @endif


                 @if($show->Tax_POS == 0)
            <input type="hidden" id="ShowTax" value="0">
        @else
            <input type="hidden" id="ShowTax" value="1">
        @endif


        @if($show->POS_Qty == 0)
            <input type="hidden" id="POS_Qty" value="0">
        @else
            <input type="hidden" id="POS_Qty" value="1">
        @endif

        @if($show->POS_Barcode == 0)
            <input type="hidden" id="POS_Barcode" value="0">
        @else
            <input type="hidden" id="POS_Barcode" value="1">
        @endif

  @if(app()->getLocale() == 'ar' )
<input type="hidden" id="LANG" value="ar">
@else
<input type="hidden" id="LANG" value="en">
@endif
<input type="hidden" id="LOWCOSTPRICE" value="{{$Def->SalesLowCostPrice}}">
        <input type="hidden" id="LimitSalesQty" value="{{$Def->LimitSalesQty}}">
<input type="hidden" id="RATOO" value="0">
<input type="hidden" id="DEFAULTCOSTPRICE" value="{{$FCOST->Cost_Price}}">

         <input type="hidden" id="DISCSHOW" value="{{$show->Disc}}">
         <input type="hidden" id="Show_Unit" value="{{$show->Show_Unit}}">
         <input type="hidden" id="Show_Total" value="{{$show->Show_Total}}">
         <input type="hidden" id="Show_Net" value="{{$show->Show_Net}}">


 <!-- Search Selecet -->
<script>
    $(document).ready(function () {
        $(function () {

            $(".select2").select2();

            $(".select2-placeholder-multiple").select2({
                placeholder: "Select State",
            });
            $(".js-hide-search").select2({
                minimumResultsForSearch: 1 / 0,
            });
            $(".js-max-length").select2({
                maximumSelectionLength: 2,
                placeholder: "Select maximum 2 items",
            });
            $(".select2-placeholder").select2({
                placeholder: "Select a state",
                allowClear: true,
            });

            $(".js-select2-icons").select2({
                minimumResultsForSearch: 1 / 0,
                templateResult: icon,
                templateSelection: icon,
                escapeMarkup: function (elm) {
                    return elm;
                },
            });

            function icon(elm) {
                elm.element;
                return elm.id ? "<i class='" + $(elm.element).data("icon") + " mr-2'></i>" + elm.text : elm.text;
            }

            $("#Emp").select2({
                placeholder: "select...",
                ajax: {
                    type: "GET",
                    dataType: "json",
                    url: "AllEmps",
                    processResults: function (data) {
                        return {
                            results: $.map(data, function (obj, index) {
                                return { id: index, text: obj };
                            }),
                        };

                        console.log(data);
                    },
                  data: function (params) {


                   var query = {
                            search: params.term,
                        };


              $.ajax({
                              url: 'AllEmpsJ/'+params.term,
                              type:"GET",
                              dataType:"json",
                              beforeSend: function(){
                                  $('#loader').css("visibility", "visible");
                              },

                              success:function(data) {
                                          $('#Emp').empty();
                                  $.each(data, function(key, value){

                         $('#Emp').append('<option value="'+ key +'">' + value + '</option>');

                                  });
                              },
                              complete: function(){
                                  $('#loader').css("visibility", "hidden");
                              }
                          });



        }
                },
            });

            $("#Emp").on("select2:select", function (e) {
                console.log("select done", e.params.data);
            });

              $("#client").select2({
                placeholder: "select...",
                ajax: {
                    type: "GET",
                    dataType: "json",
                    url: "AllClientsFilter",
                    processResults: function (data) {
                        return {
                            results: $.map(data, function (obj, index) {

                                return { id: index, text: obj };
                            }),
                        };

                        console.log(data);
                    },
                     data: function (params) {


                   var query = {
                            search: params.term,
                        };


              $.ajax({
                              url: 'AllClientsFilterJS/'+params.term,
                              type:"GET",
                              dataType:"json",
                              beforeSend: function(){
                                  $('#loader').css("visibility", "visible");
                              },

                              success:function(data) {
                                          $('#client').empty();
                                  $.each(data, function(key, value){

                         $('#client').append('<option value="'+ key +'">' + value + '</option>');

                                  });

                                      var countryId = $('#client').val();
                      if(countryId) {
                          $.ajax({
                              url: 'AccountBalanceSOFilter/'+countryId,
                              type:"GET",
                              dataType:"json",
                              beforeSend: function(){
                                  $('#loader').css("visibility", "visible");
                              },

                              success:function(data) {
                                  $.each(data, function(key, value){


                    $('#AccountCredit').val(key);
                    $('#AccountCredit').val(value);
                                  });
                              },
                              complete: function(){
                                  $('#loader').css("visibility", "hidden");
                              }
                          });
                      } else {

                          $('select[name="state"]').empty();
                      }


                              },
                              complete: function(){
                                  $('#loader').css("visibility", "hidden");
                              }
                          });



        }
                },
            });

            $("#client").on("select2:select", function (e) {
                console.log("select done", e.params.data);
            });


              $('#AccountCode').select2({
    placeholder: "select...",
    ajax: {
        type: "GET",
        dataType: 'json',
        url: 'AllSubAccounts',
        processResults: function (data) {
          return {
            results: $.map(data, function(obj, index) {
              return { id: index, text: obj };
            })
          };

            	console.log(data);

        },
         data: function (params) {


                   var query = {
                            search: params.term,
                        };


              $.ajax({
                              url: 'AllSubAccountsJ/'+params.term,
                              type:"GET",
                              dataType:"json",
                              beforeSend: function(){
                                  $('#loader').css("visibility", "visible");
                              },

                              success:function(data) {
                                          $('#AccountCode').empty();
                                  $.each(data, function(key, value){

                         $('#AccountCode').append('<option value="'+ key +'">' + value + '</option>');

                                  });
                              },
                              complete: function(){
                                  $('#loader').css("visibility", "hidden");
                              }
                          });



        }
    }
  });


$('#AccountCode').on('select2:select', function (e) {
	console.log("select done", e.params.data);
});


        $('#AccountCodee').select2({
    placeholder: "select...",
    ajax: {
        type: "GET",
        dataType: 'json',
        url: 'AllSubAccounts',
        processResults: function (data) {
          return {
            results: $.map(data, function(obj, index) {
              return { id: index, text: obj };
            })
          };

            	console.log(data);

        },
         data: function (params) {


                   var query = {
                            search: params.term,
                        };


              $.ajax({
                              url: 'AllSubAccountsJ/'+params.term,
                              type:"GET",
                              dataType:"json",
                              beforeSend: function(){
                                  $('#loader').css("visibility", "visible");
                              },

                              success:function(data) {
                                          $('#AccountCodee').empty();
                                  $.each(data, function(key, value){

                         $('#AccountCodee').append('<option value="'+ key +'">' + value + '</option>');

                                  });
                              },
                              complete: function(){
                                  $('#loader').css("visibility", "hidden");
                              }
                          });



        }
    }
  });


$('#AccountCodee').on('select2:select', function (e) {
	console.log("select done", e.params.data);
});


                    $('#AccountCodeee').select2({
    placeholder: "select...",
    ajax: {
        type: "GET",
        dataType: 'json',
        url: 'AllSubAccountsMsrofat',
        processResults: function (data) {
          return {
            results: $.map(data, function(obj, index) {
              return { id: index, text: obj };
            })
          };

            	console.log(data);

        },
         data: function (params) {


                   var query = {
                            search: params.term,
                        };


              $.ajax({
                              url: 'AllSubAccountsMsrofatJ/'+params.term,
                              type:"GET",
                              dataType:"json",
                              beforeSend: function(){
                                  $('#loader').css("visibility", "visible");
                              },

                              success:function(data) {
                                          $('#AccountCodeee').empty();
                                  $.each(data, function(key, value){

                         $('#AccountCodeee').append('<option value="'+ key +'">' + value + '</option>');

                                  });
                              },
                              complete: function(){
                                  $('#loader').css("visibility", "hidden");
                              }
                          });



        }
    }
  });


$('#AccountCodeee').on('select2:select', function (e) {
	console.log("select done", e.params.data);
});

 $('#AccountCodeeee').select2({
    placeholder: "select...",
    ajax: {
        type: "GET",
        dataType: 'json',
        url: 'AllSubAccountsMwrden',
        processResults: function (data) {
          return {
            results: $.map(data, function(obj, index) {
              return { id: index, text: obj };
            })
          };

            	console.log(data);

        },
         data: function (params) {


                   var query = {
                            search: params.term,
                        };


              $.ajax({
                              url: 'AllSubAccountsMwrdenJ/'+params.term,
                              type:"GET",
                              dataType:"json",
                              beforeSend: function(){
                                  $('#loader').css("visibility", "visible");
                              },

                              success:function(data) {
                                          $('#AccountCodeeee').empty();
                                  $.each(data, function(key, value){

                         $('#AccountCodeeee').append('<option value="'+ key +'">' + value + '</option>');

                                  });
                              },
                              complete: function(){
                                  $('#loader').css("visibility", "hidden");
                              }
                          });



        }
    }
  });


$('#AccountCodeeee').on('select2:select', function (e) {
	console.log("select done", e.params.data);
});


             $("#AccountCodeF").select2({
                placeholder: "select...",
                ajax: {
                    type: "GET",
                    dataType: "json",
                    url: "AllClientsFilter",
                    processResults: function (data) {
                        return {
                            results: $.map(data, function (obj, index) {

                                return { id: index, text: obj };
                            }),
                        };

                        console.log(data);
                    },
                     data: function (params) {


                   var query = {
                            search: params.term,
                        };


              $.ajax({
                              url: 'AllClientsFilterJS/'+params.term,
                              type:"GET",
                              dataType:"json",
                              beforeSend: function(){
                                  $('#loader').css("visibility", "visible");
                              },

                              success:function(data) {
                                          $('#AccountCodeF').empty();
                                  $.each(data, function(key, value){

                         $('#AccountCodeF').append('<option value="'+ key +'">' + value + '</option>');

                                  });
                              },
                              complete: function(){
                                  $('#loader').css("visibility", "hidden");
                              }
                          });



        }
                },
            });

            $("#AccountCodeF").on("select2:select", function (e) {
                console.log("select done", e.params.data);
            });


                    $(".EmpDele").select2({
               placeholder: "select...",
               ajax: {
                   type: "GET",
                   dataType: "json",
                   url: "AllEmps",
                   processResults: function (data) {
                       return {
                           results: $.map(data, function (obj, index) {
                               return { id: index, text: obj };
                           }),
                       };

                       console.log(data);
                   },
                  data: function (params) {


                  var query = {
                           search: params.term,
                       };


             $.ajax({
                             url: 'AllEmpsJ/'+params.term,
                             type:"GET",
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {
                                         $('.EmpDele').empty();
                                 $.each(data, function(key, value){

                        $('.EmpDele').append('<option value="'+ key +'">' + value + '</option>');

                                 });
                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });



       }
               },
           });

           $(".EmpDele").on("select2:select", function (e) {
               console.log("select done", e.params.data);
           });



        });
    });
</script>

<!-- Client Address -->
<script>
 $('#client').on('change', function(){
      var CLIENT = $('#client').val();
                         $.ajax({
                   url: 'AllClientsAddressFilter',
                   type:"GET",
                data:{
                  CLIENT:CLIENT
                },
                   dataType:"json",
                   beforeSend: function(){
                       $('#loader').css("visibility", "visible");
                   },

                   success:function(data) {

                       $('#Client_Address').empty();

                       $.each(data, function(key, value){

             $('#Client_Address').append('<option value="'+ key +'">' + value + '</option>');

                       });


                   },
                   complete: function(){
                       $('#loader').css("visibility", "hidden");
                   }
               });


 });

   $(document).ready(function() {
          var CLIENT = $('#client').val();
                         $.ajax({
                   url: 'AllClientsAddressFilter',
                   type:"GET",
                data:{
                  CLIENT:CLIENT
                },
                   dataType:"json",
                   beforeSend: function(){
                       $('#loader').css("visibility", "visible");
                   },

                   success:function(data) {

                       $('#Client_Address').empty();

                       $.each(data, function(key, value){

             $('#Client_Address').append('<option value="'+ key +'">' + value + '</option>');

                       });


                   },
                   complete: function(){
                       $('#loader').css("visibility", "hidden");
                   }
               });



   });

</script>

<!-- Account Balance -->
<script>
   $(document).ready(function() {

                  $('#client').on('change', function(){
                      var countryId = $(this).val();
                      if(countryId) {
                          $.ajax({
                              url: 'AccountBalanceSOFilter/'+countryId,
                              type:"GET",
                              dataType:"json",
                              beforeSend: function(){
                                  $('#loader').css("visibility", "visible");
                              },

                              success:function(data) {
                                  $.each(data, function(key, value){


                    $('#AccountCredit').val(parseFloat(key).toFixed(2));
                    $('#AccountCredit').val(parseFloat(value).toFixed(2));
                                  });
                              },
                              complete: function(){
                                  $('#loader').css("visibility", "hidden");
                              }
                          });
                      } else {

                          $('select[name="state"]').empty();
                      }

                  });

              });

     $(document).ready(function() {

                      var countryId = $('#client').val();
                      if(countryId) {
                          $.ajax({
                              url: 'AccountBalanceSFilter/'+countryId,
                              type:"GET",
                              dataType:"json",
                              beforeSend: function(){
                                  $('#loader').css("visibility", "visible");
                              },

                              success:function(data) {
                                  $.each(data, function(key, value){


                    $('#AccountCredit').val(parseFloat(key).toFixed(2));
                    $('#AccountCredit').val(parseFloat(value).toFixed(2));
                                  });
                              },
                              complete: function(){
                                  $('#loader').css("visibility", "hidden");
                              }
                          });
                      } else {

                          $('select[name="state"]').empty();
                      }

     });
</script>

<!--  Filter Products -->
<script>
   $(document).ready(function(){

    fetch_customer_data();

    function fetch_customer_data(search = '',store='',client='')
    {
     $.ajax({
      url:'SalesProductsPOSFilter',
      method:'GET',
      data:{search:search,store:store,client:client},
      dataType:'json',
      success:function(data)
      {

        document.getElementById('data').style.display="block";
       $('.Data').html(data.table_data);

           if(search.toString().length  == 13){

                if(parseFloat(data.count) == 1){

                  if(search.slice(0, 2)  == 20){
                               var t = search.slice(0, 7) ;
                               var x = search.slice(7, 13) ;
                               var y = search.slice(12, 13) ;


var z= parseFloat(x) - parseFloat(y) ;
//var z=  x.slice(0, 5);

var zz= parseFloat(z) / parseFloat(10000) ;

                            FunMyzan(data.Get,t,zz);
                           }else{

                             Fun(data.Get);
            $('#search').val('');

                           }

                }


           }else{


                 if(parseFloat(data.count) == 1){

                 Fun(data.Get);
            $('#search').val('');

      document.getElementById('data').style.display="none";
          }



           }



      }
     })
    }


   $(document).on('keyup', '#search', function(event){

     var search = $(this).val();
     var store = $('#store').val();
     var client = $('#client').val();
     var SCAN = $('#SCAN').val(search);
  if (event.which == '10' || event.which == '50' || event.which == '54' || event.which == '52'  || event.which == '48' || event.which == '55' || event.which == '56' || event.which == '49' || event.which == '53' || event.which == '51'  || event.which == '57') {

   document.getElementById('data').style.display="none";

   }else{

    fetch_customer_data(search,store,client);



   }



    });


    $(document).on('change', '#client', function(){
     var client = $(this).val();
     var search = $('#search').val();
     var store = $('#store').val();
        if(search != ''){
     fetch_customer_data(search,store,client);
       }else{
      document.getElementById('data').style.display="none";

       }
    });

   });
</script>

<!--  Filter SearchCode -->
<script>
   $(document).ready(function(){

    fetch_customer_data();

    function fetch_customer_data(search = '',store='',client='')
    {
     $.ajax({
      url:'SalesProductsPOSSearchCodeFilter',
      method:'GET',
      data:{search:search,store:store,client:client},
      dataType:'json',
      success:function(data)
      {

        document.getElementById('data').style.display="block";
       $('.Data').html(data.table_data);

           if(search.toString().length  == 13){

                if(parseFloat(data.count) == 1){

                  if(search.slice(0, 2)  == 20){
                               var t = search.slice(0, 7) ;
                               var x = search.slice(7, 13) ;
                               var y = search.slice(12, 13) ;


var z= parseFloat(x) - parseFloat(y) ;
//var z=  x.slice(0, 5);

var zz= parseFloat(z) / parseFloat(10000) ;

                            FunMyzan(data.Get,t,zz);
                           }else{

                             Fun(data.Get);
            $('#SearchCode').val('');

                           }

                }


           }else{


                 if(parseFloat(data.count) == 1){

                 Fun(data.Get);
            $('#SearchCode').val('');

      document.getElementById('data').style.display="none";
          }



           }



      }
     })
    }


   $(document).on('keyup', '#SearchCode', function(event){
     var search = $(this).val();
     var store = $('#store').val();
     var client = $('#client').val();
     var SCAN = $('#SCAN').val(search);
  if (event.which == '10' || event.which == '50' || event.which == '54' || event.which == '52'  || event.which == '48' || event.which == '55' || event.which == '56' || event.which == '49' || event.which == '53' || event.which == '51') {

   document.getElementById('data').style.display="none";

   }else{

    fetch_customer_data(search,store,client);



   }



    });


   });
</script>

<!-- Add New Client -->
<script>
    function NewClients(){

    var co = $('#CODE').val();
    var Name = $('#Name').val();
    var PriceLevel = $('#PriceLevel').val();
    var Phone = $('#Phone').val();

    var NaameAddress = $('#NaameAddress').val();
    var Governrate = $('#Governrate').val();
    var City = $('#City').val();
    var Place = $('#Place').val();
    var Street = $('#Street').val();
    var Buliding = $('#Buliding').val();
    var Floor = $('#Floor').val();
    var Flat = $('#Flat').val();
    var Special_Mark = $('#Special_Mark').val();
    var Location = $('#Location').val();
    var Address_Details = $('#Address_Details').val();
        var NameEn = $('#NameEn').val();
   var LANG = $('#LANG').val();
       if(NameEn == ''){

               NameEn = Name ;
          }
          if(Name) {
                         $.ajax({
                             url: 'AddNewClientPOS',
                             type:"GET",
                             data:{
                                 co:co,
                                 Phone:Phone,
                                 Name:Name,
                                 PriceLevel:PriceLevel,
                               NaameAddress:NaameAddress,
                                Governrate:Governrate,
                                City:City,
                                Place:Place,
                                Street:Street,
                                Buliding:Buliding,
                                Floor:Floor,
                                Flat:Flat,
                                Special_Mark:Special_Mark,
                                Location:Location,
                                Address_Details:Address_Details,
                                NameEn:NameEn
                             },
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {
                                 $.each(data, function(key, value){

                                          if(LANG == 'ar'){
                            alert('تم الاضافه بنجاح');
                       }else{
                           alert('Added Successfully');
                       }

                                 });
                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });
                     }else{


                                  if(LANG == 'ar'){
                       alert('حقل الاسم مطلوب');
                      }else{

                       alert('Name Input is Required');
                      }

                     }



    }
</script>

<!-- LOCK and Unlock SHift -->
<script>
function  Unlock(){

var Pass = $('#Pass').val();
var RightPass = $('#RightPass').val();
   var LANG = $("#LANG").val();

    if(Pass == RightPass){

       document.getElementById('LOCKK').style.display='none';
       document.getElementById('DETALIS').style.display='block';
    }else{

         document.getElementById('LOCKK').style.display='block';
       document.getElementById('DETALIS').style.display='none';

           if(LANG == 'ar' ){
          alert('كلمه المرور خطأ');
          }else{
         alert('Password Incorrect');
          }

    }


}

function  Lock(){
    $('#Pass').val('');
     document.getElementById('LOCKK').style.display='block';
       document.getElementById('DETALIS').style.display='none';
}

    function  UnlockSafe(){

var Pass = $('#PassSafe').val();
var RightPass = $('#RightPassSafe').val();

    if(Pass == RightPass){

       document.getElementById('BLOCKSAFE').style.display='none';

        window.print();

    }else{

         document.getElementById('BLOCKSAFE').style.display='block';
        alert('كلمه المرور خطأ');
    }


}



</script>

<!-- Add Products -->
<script>
   function Fun(r) {

             var P_Ar_Name = $("#P_Ar_Name"+r).val();
             var P_En_Name= $("#P_En_Name"+r).val();
             var Product = $("#Product"+r).val();
             var UnitID = $("#UnitPurch"+r).val();
             var UnitName = $("#UnitPurchName"+r).val();
             var Qty = $("#Qty"+r).val();
             var AvQty = $("#AvQty"+r).val();
             var Barcode = $("#CodePurch"+r).val();
             var Price = $("#Price"+r).val();
             var Total = $("#Total"+r).val();
             var ExpDate = $("#ExpDate"+r).val();
             var PurchTax = $("#PurchTax"+r).val();
             var TotalTax = $("#Tax"+r).val();
             var Discount = $("#Discount"+r).val();
             var TotalBFTax = $("#TotalBFTax"+r).val();
             var StorePurch = $("#StorePurchName"+r).val();
             var StorePurchName = $("#StorePurchName"+r).val();
             var PurchTax = $("#PurchTax"+r).val();
             var VOne = $("#VOne"+r).val();
             var VTwo = $("#VTwo"+r).val();
             var V_Name = $("#V_Name"+r).val();
             var VV_Name = $("#VV_Name"+r).val();
             var TaxRate = $("#TaxRate"+r).val();
             var TaxType = $("#TaxType"+r).val();
             var Viro = '';
             var VViro = '';
               var priceSale =$("#priceSale").val();
               var discount =$("#discount").val();
               var serial =$("#serial"+r).val();
                var TDiscPro = $("#TDiscPro"+r).val();
    var CostPrice = $("#CostPrice"+r).val();


                      var weight = $("#weight"+r).val();
                var maxSales = $("#maxSales"+r).val();
                var RATOO = $("#UnitRato"+r).val();
                var LimitSalesQty = $("#LimitSalesQty").val();
          var DEFAULTCOSTPRICE = $("#DEFAULTCOSTPRICE").val();

       var TWeight=parseFloat(Qty) * (parseFloat(weight) * parseFloat(RATOO)) ;


              if(DEFAULTCOSTPRICE == 2){

            $.ajax({
                             url: 'NewCostProductFilter',
                             type:"GET",
                            data:{
                              store:StorePurch,
                              pro_code:Barcode,
                              Product:Product,
                              Qty:Qty,
                              UnitID:UnitID
                            },
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {


                                 $("#CostPrice"+r).val(data.total_cost);

                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });


          }


       if( V_Name != ''){

          Viro= '(' + V_Name +')';
       }

       if( VV_Name != ''){

         VViro= '(' + VV_Name +')';
       }


       if(parseFloat(priceSale) == 0){

           var PRIce = 'disabled';
           var PRIceTwo = '';

       }else{

           var PRIce = '';
                 var PRIceTwo = 'disabled';
       }

        if(parseFloat(discount) == 0){
             var Dicco = 'disabled';
             var DiccoTwo = '';

       }else{

           var Dicco = '';
           var DiccoTwo = 'disabled';
       }

         if(parseFloat(serial) == 1){
             var ser = 'disabled';
             var serTwo = '';


       }else{

           var ser = '';
           var serTwo = 'disabled';

       }

          document.getElementById("Row"+r).style.display = "none";

   var i = 0;
   var ii=0;
   var iii=0;

         var HighDisc = $("#HighDisc"+r).val();
       var DIS = $("#DIS").val();

       if(parseFloat(DIS) == 0){

           Discount=$("#Discount"+r).val();
       }else{

           var d= Discount / 100 ;
           var Multi= parseFloat(Qty) * parseFloat(Price) ;
          var dd= Multi * d;

        Discount=  dd;
       }

         var BFG =  parseFloat(Qty) * parseFloat(Discount) ;
             $("#TDiscPro"+r).val(parseFloat(BFG));

       if(TaxType == 1){
           //Precent

      var BF =  parseFloat(Qty) *  (parseFloat(Price) );


           TotalBFTax = parseFloat(BF) ;

       i =    parseFloat(TaxRate)  / 100 ;

        ii=  parseFloat(BF) * parseFloat(i) ;


           TotalTax=parseFloat(ii);

       iii =  parseFloat(BF) + parseFloat(ii) ;


           Total=parseFloat(iii);

       }else if(TaxType == 2){
          //Number
         var BF =  parseFloat(Qty) *  (parseFloat(Price) );
               TotalBFTax = parseFloat(BF) ;

            i =    parseFloat(TaxRate)   ;

              TotalTax=parseFloat(i);

       iii =  parseFloat(BF) + parseFloat(i) ;

            Total=parseFloat(iii);


       }


         var POS_Qty = $("#POS_Qty").val();
         var POS_Barcode = $("#POS_Barcode").val();

       if(parseFloat(POS_Qty) == 1){
          var ShowAvQty="<span style='color:red'>(<b id='AVVQ"+r+"'><button onclick='OtherQTY("+Product+","+Barcode+")' type='button' class='bt' style='padding:0 !imporatnt' data-toggle='modal' data-target='#Avilable'>"+AvQty+"</button></b>)</span>";
          }else{
             var ShowAvQty="<span style='color:red;display:none'>(<b id='AVVQ"+r+"'><button onclick='OtherQTY("+Product+","+Barcode+")' type='button' class='bt' style='padding:0 !imporatnt' data-toggle='modal' data-target='#Avilable'>"+AvQty+"</button></b>)</span>";
          }


               if(parseFloat(POS_Barcode) == 1){
          var ShowBarcode = "(<b id='Coding"+r+"'>"+ Barcode +"</b>)";
          }else{
           var ShowBarcode = "<b id='Coding"+r+"' style='display:none'>"+ Barcode +"</b>";
          }

         var DIS = $("#DIS").val();
        var RFF= parseFloat(Qty) * parseFloat(Price);
       var RFFResult= parseFloat(RFF) - parseFloat(Total);


       var ShowTax = $("#ShowTax").val();

               var LANG = $("#LANG").val();
   if(LANG == 'ar' ){
          var Nemo = P_Ar_Name ;
          }else{
             var Nemo = P_En_Name ;
          }


       var Show_Unit = $("#Show_Unit").val();
       var DISCSHOW = $("#DISCSHOW").val();
       var Show_Total = $("#Show_Total").val();
       var Show_Net = $("#Show_Net").val();

       if (Show_Unit == 1) {

           var UNITSHOWW = "";

       } else {

           var UNITSHOWW = "none";
       }
       if (DISCSHOW == 1) {

           var DISCOUNTSHOW = "";

       } else {

           var DISCOUNTSHOW = "none";
       }


       if (Show_Total == 1) {

           var TOTALSHOWW = "";

       } else {

           var TOTALSHOWW = "none";
       }

       if (Show_Net == 1) {

           var NETSHOWW = "";

       } else {

           var NETSHOWW = "none";
       }
       var Net=(parseFloat(Total) ) - (parseFloat(Discount) * parseFloat(Qty));


if(parseFloat(Net) >   0){
   var TotCostNew=parseFloat(Qty) * parseFloat(CostPrice) ;
   }else{
       var TotCostNew=0; ;
   }


       if(parseFloat(ShowTax) == 1){
var markup = "<tr><td><i id='DelAssem' class='fal fa-trash-alt'></i></td><td>" + Nemo + ""+ Viro +" "+ VViro +" "+ShowBarcode+" "+ShowAvQty+" <button type='button'  class='btn btn-sm btn-block btn-outline-success waves-effect waves-themed'  data-toggle='modal' onclick='TaxPro("+Product+","+r+")' style='width: 10%;' data-target='#TAXXXX'><i class='fal fa-calculator'></i></button> </td><td style='display: "+UNITSHOWW+"'><input type='hidden' id='un"+r+"' name='Unit[]' value='"+UnitID+"'><button type='button'  class='btn btn-sm btn-block btn-outline-success waves-effect waves-themed'  data-toggle='modal' onclick='UniPro("+Product+","+r+","+Barcode+","+StorePurch+")' data-target='#UnitTTT'><span id='TextUni"+r+"'>" + UnitName + "<span></button></td><td><input  type='number' "+ser+" step='any' onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' id='QTTY"+r+"' name='Qty[]' class='form-control input-width Qun' value='"+parseFloat(Qty).toFixed(2)+"'><input "+serTwo+" type='hidden' name='Qty[]' value='"+parseFloat(Qty).toFixed(2)+"'></td><td><input type='number' step='any' "+PRIce+" class='form-control input-width' onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' id='PRICE"+r+"' name='Price[]' value='"+Price+"'><input "+PRIceTwo+" type='hidden' name='Price[]' value='"+Price+"' id='PCL"+r+"'></td><td style='width:50px;display: "+DISCOUNTSHOW+"'><input  onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' type='number' step='any' class='form-control Disc input-width' "+Dicco+" name='Discount[]' id='DISC"+r+"' value='"+Discount+"'><input type='hidden' "+DiccoTwo+" name='Discount[]' value='"+Discount+"'></td><td  style='width:130px;display: "+TOTALSHOWW+"'><input  type='hidden' name='Total[]' id='TOTT"+r+"' value='"+parseFloat(Total).toFixed(2)+"'><input class='form-control Tot total-input-width'  type='text' disabled id='TOTTNo"+r+"' value='"+parseFloat(Total).toFixed(2)+"'></td><td style='display: "+NETSHOWW+"'><input class='net form-control' type='number' step='any' id='NetD" + r + "' readonly   name='Total_Net[]' value='" + Net + "'></td><input type='hidden' name='V_Name[]' value='"+Viro+"'><input type='hidden' name='VV_Name[]' value='"+VViro+"'><input type='hidden' id='PurchTaxx"+r+"' name='PurchTax[]'  value='"+PurchTax+"'><input type='hidden' name='VOne[]' id='V"+r+"' value='"+VOne+"'><input id='VV"+r+"' type='hidden' name='VTwo[]' value='"+VTwo+"'><input type='hidden' id='PRO"+r+"' name='Product[]' value='"+Product+"'><input type='hidden' name='P_Ar_Name[]' value='"+P_Ar_Name+"'><input type='hidden' name='P_En_Name[]' value='"+P_En_Name+"'><input type='hidden' name='P_Code[]' id='CodingHide"+r+"' value='"+Barcode+"'><input id='AVHide"+r+"' type='hidden' name='AvQty[]' value='"+AvQty+"'><input class='TotalBFTax' id='TBFTax"+r+"' type='hidden' name='TotalBFTax[]' value='"+TotalBFTax+"'><input class='TotalTax' type='hidden' name='TotalTax[]' id='TTax"+r+"' value='"+TotalTax+"'><input id='STORETABLE"+r+"'  type='hidden' name='StorePurch[]' value='"+StorePurch+"'><input type='hidden' name='Exp_Date[]' value='"+ExpDate+"'><input type='hidden' id='RATE"+r+"'  value='"+TaxRate+"'><input type='hidden' id='TYPE"+r+"'  value='"+TaxType+"'><input type='hidden' id='HighDisc"+r+"'  value='"+HighDisc+"'><input type='hidden' id='Enough"+r+"' name='AllEnough[]'  value='0'><input type='hidden' class='DiscoPrecent' id='disssccoount"+r+"' value='"+RFFResult+"'><input type='hidden' class='TDISCOOO' id='TDiscProEdit"+r+"' name='TDiscPro[]' value='"+TDiscPro+"'><input type='hidden' id='costPric"+r+"'   name='CostPrice[]' value='"+CostPrice+"'><input type='hidden' id='weightT"+r+"'   name='weight[]' value='"+weight+"'><input type='hidden' id='UnitRate"+r+"'   name='UnitRate[]' value='"+RATOO+"'><input type='hidden' id='Total_Wight"+r+"' class='W'  name='Total_Wight[]' value='"+TWeight+"'><input type='hidden' id='maxSa"+r+"' value='"+maxSales+"'><input type='hidden' class='COSTPRICES' id='TotCostNew"+r+"' name='TotCostNew[]' value='"+TotCostNew+"'></tr>";
   }else{
      var markup = "<tr><td><i id='DelAssem' class='fal fa-trash-alt'></i></td><td>" + Nemo + ""+ Viro +" "+ VViro +" "+ShowBarcode+" "+ShowAvQty+"</td><td style='display: "+UNITSHOWW+"'><input type='hidden' id='un"+r+"' name='Unit[]' value='"+UnitID+"'><button type='button'  class='btn btn-sm btn-block btn-outline-success waves-effect waves-themed'  data-toggle='modal' onclick='UniPro("+Product+","+r+","+Barcode+","+StorePurch+")' data-target='#UnitTTT'><span id='TextUni"+r+"'>" + UnitName + "<span></button></td><td><input  type='number' "+ser+" step='any' onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' id='QTTY"+r+"' name='Qty[]' class='form-control input-width Qun' value='"+parseFloat(Qty).toFixed(2)+"'><input "+serTwo+" type='hidden' name='Qty[]' value='"+parseFloat(Qty).toFixed(2)+"'></td><td><input type='number' step='any' "+PRIce+" class='form-control input-width' onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' id='PRICE"+r+"' name='Price[]' value='"+Price+"'><input "+PRIceTwo+" type='hidden' name='Price[]' value='"+Price+"' id='PCL"+r+"'></td><td style='width:50px;display: "+DISCOUNTSHOW+"''><input  onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' type='number' step='any' class='form-control Disc input-width' "+Dicco+" name='Discount[]' id='DISC"+r+"' value='"+Discount+"'><input type='hidden' "+DiccoTwo+" name='Discount[]' value='"+Discount+"'></td><td style='width:130px;display: "+TOTALSHOWW+"'><input  type='hidden' name='Total[]' id='TOTT"+r+"' value='"+parseFloat(Total).toFixed(2)+"'><input class='form-control Tot total-input-width'  type='text' disabled id='TOTTNo"+r+"' value='"+parseFloat(Total).toFixed(2)+"'></td><td style='display: "+NETSHOWW+"'><input class='net form-control' type='number' step='any' id='NetD" + r + "' readonly   name='Total_Net[]' value='" + Net + "'></td><input type='hidden' name='V_Name[]' value='"+Viro+"'><input type='hidden' name='VV_Name[]' value='"+VViro+"'><input type='hidden' id='PurchTaxx"+r+"' name='PurchTax[]'  value='"+PurchTax+"'><input type='hidden' name='VOne[]' id='V"+r+"' value='"+VOne+"'><input id='VV"+r+"' type='hidden' name='VTwo[]' value='"+VTwo+"'><input type='hidden' id='PRO"+r+"' name='Product[]' value='"+Product+"'><input type='hidden' name='P_Ar_Name[]' value='"+P_Ar_Name+"'><input type='hidden' name='P_En_Name[]' value='"+P_En_Name+"'><input type='hidden' name='P_Code[]' id='CodingHide"+r+"' value='"+Barcode+"'><input id='AVHide"+r+"' type='hidden' name='AvQty[]' value='"+AvQty+"'><input class='TotalBFTax' id='TBFTax"+r+"' type='hidden' name='TotalBFTax[]' value='"+TotalBFTax+"'><input class='TotalTax' type='hidden' name='TotalTax[]' id='TTax"+r+"' value='"+TotalTax+"'><input  type='hidden' id='STORETABLE"+r+"' name='StorePurch[]' value='"+StorePurch+"'><input type='hidden' name='Exp_Date[]' value='"+ExpDate+"'><input type='hidden' id='RATE"+r+"'  value='"+TaxRate+"'><input type='hidden' id='TYPE"+r+"'  value='"+TaxType+"'><input type='hidden' id='HighDisc"+r+"'  value='"+HighDisc+"'><input type='hidden' id='Enough"+r+"' name='AllEnough[]'  value='0'><input type='hidden' class='DiscoPrecent' id='disssccoount"+r+"' value='"+RFFResult+"'><input type='hidden' class='TDISCOOO' id='TDiscProEdit"+r+"' name='TDiscPro[]' value='"+TDiscPro+"'><input type='hidden' id='costPric"+r+"' name='CostPrice[]' value='"+CostPrice+"'><input type='hidden' id='weightT"+r+"'   name='weight[]' value='"+weight+"'><input type='hidden' id='UnitRate"+r+"'   name='UnitRate[]' value='"+RATOO+"'><input type='hidden' id='Total_Wight"+r+"' class='W'  name='Total_Wight[]' value='"+TWeight+"'><input type='hidden' id='maxSa"+r+"' value='"+maxSales+"'><input type='hidden' class='COSTPRICES' id='TotCostNew"+r+"' name='TotCostNew[]' value='"+TotCostNew+"'></tr>";

   }



    var P = $("#PRO"+r).val();
     var Q = $("#QTTY"+r).val();
     var VO = $("#V"+r).val();
        var VOO = $("#VV"+r).val();
        var PRICE = $("#PRICE"+r).val();
        var DISC = $("#DISC"+r).val();
        var RATE = $("#RATE"+r).val();
        var TYPE = $("#TYPE"+r).val();



          if(LimitSalesQty == 1){

       if(maxSales >= Qty){



       if(Product == P){

         if(parseFloat(serial) == 0){

           if(VO == VOne  && VOO == VTwo){
           var rt=parseFloat(Q) + parseFloat(1);
           $("#QTTY"+r).val(parseFloat(rt));
               $('#search').val('');
                document.getElementById('data').style.display="none";
           }

  $('.Data').hide();
var TaxRate = $("#RATE"+r).val();
   var TaxType = $("#TYPE"+r).val();
   var Qty = $("#QTTY"+r).val();
   var Price = $("#PRICE"+r).val();
   var Discount = $("#DISC"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;

             var HighDisc = $("#HighDisc"+r).val();
       var DIS = $("#DIS").val();

       if(parseFloat(DIS) == 0){

           Discount=$("#DISC"+r).val();
       }else{

           var d= Discount / 100 ;
           var Multi= parseFloat(Qty) * parseFloat(Price) ;
          var dd= Multi * d;

        Discount=  dd;
       }

        if(HighDisc != 0){


           if(parseFloat(Discount)  >  parseFloat(HighDisc)){
                     document.getElementById("Action").style.display = "none";
                     document.getElementById("ActionAlert").style.display = "block";
           }else{
                   document.getElementById("Action").style.display = "block";
                   document.getElementById("ActionAlert").style.display = "none";

           }


       }

             var BFG =  parseFloat(Qty) * parseFloat(Discount) ;
             $("#TDiscPro"+r).val(parseFloat(BFG));



       if(TaxType == 1){
           //Precent

  var BF =  parseFloat(Qty) *  (parseFloat(Price) );

       $("#TBFTax"+r).val(parseFloat(BF));

       i =    parseFloat(TaxRate)  / 100 ;

        ii=  parseFloat(BF) * parseFloat(i) ;

           $("#TTax"+r).val(parseFloat(ii));

       iii =  parseFloat(BF) + parseFloat(ii) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));

       }else if(TaxType == 2){
          //Number
        var BF =  parseFloat(Qty) *  (parseFloat(Price) );
         $("#TBFTax"+r).val(parseFloat(BF));

            i =    parseFloat(TaxRate)   ;

           $("#TTax"+r).val(parseFloat(i));

       iii =  parseFloat(BF) + parseFloat(i) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));


       }


          play();
         }else{

             alert('لا يمكن اضافه هذا المنتج مره اخري');

         }

       }else{
        $("#data-dt").append(markup);
           $('#search').val('');
         document.getElementById('data').style.display="none";
           play();
       }




          }else{

      if(LANG == 'ar' ){
    alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
      }else{

    alert('You have exceeded the selling limit for this product');
      }

          }

          }else{



       if(Product == P){

         if(parseFloat(serial) == 0){

           if(VO == VOne  && VOO == VTwo){
           var rt=parseFloat(Q) + parseFloat(1);
           $("#QTTY"+r).val(parseFloat(rt));
               $('#search').val('');
                document.getElementById('data').style.display="none";
           }

  $('.Data').hide();
var TaxRate = $("#RATE"+r).val();
   var TaxType = $("#TYPE"+r).val();
   var Qty = $("#QTTY"+r).val();
   var Price = $("#PRICE"+r).val();
   var Discount = $("#DISC"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;

             var HighDisc = $("#HighDisc"+r).val();
       var DIS = $("#DIS").val();

       if(parseFloat(DIS) == 0){

           Discount=$("#DISC"+r).val();
       }else{

           var d= Discount / 100 ;
           var Multi= parseFloat(Qty) * parseFloat(Price) ;
          var dd= Multi * d;

        Discount=  dd;
       }

        if(HighDisc != 0){


           if(parseFloat(Discount)  >  parseFloat(HighDisc)){
                     document.getElementById("Action").style.display = "none";
                     document.getElementById("ActionAlert").style.display = "block";
           }else{
                   document.getElementById("Action").style.display = "block";
                   document.getElementById("ActionAlert").style.display = "none";

           }


       }

             var BFG =  parseFloat(Qty) * parseFloat(Discount) ;
             $("#TDiscPro"+r).val(parseFloat(BFG));



       if(TaxType == 1){
           //Precent

  var BF =  parseFloat(Qty) *  (parseFloat(Price) );

       $("#TBFTax"+r).val(parseFloat(BF));

       i =    parseFloat(TaxRate)  / 100 ;

        ii=  parseFloat(BF) * parseFloat(i) ;

           $("#TTax"+r).val(parseFloat(ii));

       iii =  parseFloat(BF) + parseFloat(ii) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));

       }else if(TaxType == 2){
          //Number
        var BF =  parseFloat(Qty) *  (parseFloat(Price) );
         $("#TBFTax"+r).val(parseFloat(BF));

            i =    parseFloat(TaxRate)   ;

           $("#TTax"+r).val(parseFloat(i));

       iii =  parseFloat(BF) + parseFloat(i) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));


       }


          play();
         }else{

             alert('لا يمكن اضافه هذا المنتج مره اخري');

         }

       }else{
        $("#data-dt").append(markup);
           $('#search').val('');
         document.getElementById('data').style.display="none";
           play();
       }




          }

        document.getElementById('data').style.display="none";

      $.fn.rowCount = function() {
     return $('tr', $(this).find('tbody')).length;
   };

   var rowctr = $('#dt').rowCount();

    var sumQ = 0;
   $('.Qun').each(function(){
   sumQ += parseFloat($(this).val());
   });

    var sumT = 0;
   $('.Tot').each(function(){
   sumT += parseFloat($(this).val());
   });

        var sumD = 0;
   $('.Disc').each(function(){
   sumD += parseFloat($(this).val());
   });


           var sumBF = 0;
   $('.TotalBFTax').each(function(){
   sumBF += parseFloat($(this).val());
   });

           var sumTax = 0;
   $('.TotalTax').each(function(){
   sumTax += parseFloat($(this).val());
   });

                                  var prec = 0;
   $('.DiscoPrecent').each(function(){
   prec += parseFloat($(this).val());
   });



              var sumTTD = 0;
   $('.TDISCOOO').each(function(){
   sumTTD += parseFloat($(this).val());
   });

         var COPRI = 0;
   $('.COSTPRICES').each(function(){
   COPRI += parseFloat($(this).val());
   });

              var COWeight = 0;
   $('.W').each(function(){
   COWeight += parseFloat($(this).val());
   });



       $('#Total_Wight_Bill').val(parseFloat(COWeight));
       $('#Product_Numbers').val(parseFloat(rowctr));
       $('#Product_NumbersHide').val(parseFloat(rowctr));

       $('#Total_Qty').val(parseFloat(sumQ));
       $('#Total_QtyHide').val(parseFloat(sumQ));

       var TootPriice = parseFloat(sumT) - parseFloat(sumTax);
       $('#Total_Price').val(parseFloat(TootPriice).toFixed(2));
       $('#Total_PriceHide').val(parseFloat(TootPriice).toFixed(2));


       var NEEET = 0;
       $('.net').each(function() {
           NEEET += parseFloat($(this).val());
       });


       var PROFIIIT = parseFloat(NEEET) - parseFloat(COPRI);
       $('#ProfitPrecent').val(parseFloat(PROFIIIT).toFixed(2));

       var nfd = (parseFloat(PROFIIIT) * 100) / parseFloat(COPRI);
       $('#proPrecent').val(parseFloat(nfd).toFixed(2));


       $('#Total_DiscountTT').val(parseFloat(sumTTD).toFixed(2));
       $('#Total_DiscountHideTT').val(parseFloat(sumTTD).toFixed(2));

       $('#Total_Discount').val(parseFloat(sumD).toFixed(2));
       $('#Total_DiscountHide').val(parseFloat(sumD).toFixed(2));


       var BEFO = parseFloat(sumBF) ;

       $('#Total_Bf_Taxes').val(parseFloat(BEFO).toFixed(2));
       $('#Total_Bf_TaxesHide').val(parseFloat(BEFO).toFixed(2));

       $('#Total_Taxes').val(parseFloat(sumTax).toFixed(2));
       $('#Total_TaxesHide').val(parseFloat(sumTax).toFixed(2));

       $('#Total_After_Taxes').val(parseFloat(sumTax) + parseFloat(TootPriice));
       $('#TotalCost').val(parseFloat(COPRI).toFixed(2));

       var RRR = parseFloat(sumTax) + parseFloat(TootPriice) - parseFloat(sumTTD);
       $('#TAFterD').val(parseFloat(RRR).toFixed(2));
       $('#Total_Bill').val(parseFloat(RRR).toFixed(2));
       $('#Total_PriceW').val(parseFloat(RRR).toFixed(2));

       var resdiual = $('#resdiual').val();
       var total = $('#Total_PriceHide').val();
       var totalDisc = $('#Total_DiscountHideTT').val();

       var totalTax = $('#Total_TaxesHide').val();


       var RR = (parseFloat(total) + parseFloat(totalTax)) - (parseFloat(resdiual) + parseFloat(totalDisc));
       var RRR = parseFloat(total) - (parseFloat(resdiual) + parseFloat(totalDisc));

       $('#paid').val(parseFloat(RR).toFixed(2));

       $('#presenter').val(parseFloat(RR).toFixed(2));
       $('#total').val(parseFloat(sumT).toFixed(2));



       $('#ProNums').text(parseFloat(rowctr));
       $('#ProQty').text(parseFloat(sumQ).toFixed(2));
       $('#TotalPrice').text(parseFloat(TootPriice));
       $('#Total_DiscountTTShow').text(parseFloat(sumTTD).toFixed(2));
       $('#Total_TaxesShow').text(parseFloat(sumTax));






          var TaxRate = $("#RATE"+r).val();
   var TaxType = $("#TYPE"+r).val();
   var Qty = $("#QTTY"+r).val();
   var AVQty = $("#AVHide"+r).val();
   var Price = $("#PRICE"+r).val();
   var Discount = $("#DISC"+r).val();
       var CostPrice = $("#costPric"+r).val();
          var LOWCOSTPRICE = $("#LOWCOSTPRICE").val();
                var DEFAULTCOSTPRICE = $("#DEFAULTCOSTPRICE").val();
           var weight = $("#weightT"+r).val();
    var RATOO = $("#UnitRate"+r).val();
    var maxSales = $("#maxSa"+r).val();
    var LimitSalesQty = $("#LimitSalesQty").val();
    var LANG = $("#LANG").val();
       if(parseFloat(Qty) > parseFloat(AVQty)){


      document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);

       }else{

           if(parseFloat(Qty) < 0){
                   document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
           }else{


              if(parseFloat(LOWCOSTPRICE) == 0){

                  if(DEFAULTCOSTPRICE == 2){


                   if(parseFloat(Price)*parseFloat(Qty) < parseFloat(CostPrice)){

                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);

                         }else{



   if(LimitSalesQty == 1){

       if(maxSales >= Qty){

                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);


          }else{
 document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
      if(LANG == 'ar' ){
    alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
      }else{

    alert('You have exceeded the selling limit for this product');
      }

          }

   }else{
                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);

   }




                         }

                     }else{

                      if(parseFloat(Price) < parseFloat(CostPrice)){

                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);

                         }else{



   if(LimitSalesQty == 1){

       if(maxSales >= Qty){

                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);


          }else{
 document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
      if(LANG == 'ar' ){
    alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
      }else{

    alert('You have exceeded the selling limit for this product');
      }

          }

   }else{
                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);

   }




                         }

              }



                     }else{


        if(LimitSalesQty == 1){

       if(maxSales >= Qty){

                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);


          }else{
 document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
      if(LANG == 'ar' ){
    alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
      }else{

    alert('You have exceeded the selling limit for this product');
      }

          }

   }else{
                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);

   }


                     }


       }
       }

       var enough=0;
    $('input[name^="AllEnough"]').each(function() {


        enough +=$(this).val();

});


             if(parseFloat(enough) > 0){

               document.getElementById("Action").style.display = "none";
   document.getElementById("QTYAlert").style.display = "block";
        }else{
               document.getElementById("Action").style.display = "block";
   document.getElementById("QTYAlert").style.display = "none";

        }

                       var Total_PriceW =$('#Total_PriceW').val();

             if(enough == 0){

             if(Total_PriceW == 'NaN'){
                   document.getElementById("Action").style.display = "none";
                    }else{
        document.getElementById("Action").style.display = "block";
             }

       }else{

        document.getElementById("Action").style.display = "none";
       }



         var TWeight=parseFloat(Qty) * (parseFloat(weight) * parseFloat(RATOO)) ;

                $("#Total_Wight"+r).val(parseFloat(TWeight));


       var COWeight = 0;
   $('.W').each(function(){
   COWeight += parseFloat($(this).val());
   });

      $('#Total_Wight_Bill').val(parseFloat(COWeight));




       document.getElementById("search").focus();


        $('#data-dt').on('click', '#DelAssem', function(e){
                $(this).closest('tr').remove();


      $.fn.rowCount = function() {
     return $('tr', $(this).find('tbody')).length;
   };

   var rowctr = $('#dt').rowCount();

    var sumQ = 0;
   $('.Qun').each(function(){
   sumQ += parseFloat($(this).val());
   });

    var sumT = 0;
   $('.Tot').each(function(){
   sumT += parseFloat($(this).val());
   });

        var sumD = 0;
   $('.Disc').each(function(){
   sumD += parseFloat($(this).val());
   });


           var sumBF = 0;
   $('.TotalBFTax').each(function(){
   sumBF += parseFloat($(this).val());
   });

           var sumTax = 0;
   $('.TotalTax').each(function(){
   sumTax += parseFloat($(this).val());
   });


                                  var prec = 0;
   $('.DiscoPrecent').each(function(){
   prec += parseFloat($(this).val());
   });


              var sumTTD = 0;
   $('.TDISCOOO').each(function(){
   sumTTD += parseFloat($(this).val());
   });

             var COPRI = 0;
   $('.COSTPRICES').each(function(){
   COPRI += parseFloat($(this).val());
   });

                   var COWeight = 0;
   $('.W').each(function(){
   COWeight += parseFloat($(this).val());
   });

            $('#Total_Wight_Bill').val(parseFloat(COWeight));

            $('#Total_Wight_Bill').val(parseFloat(COWeight));
            $('#Product_Numbers').val(parseFloat(rowctr));
            $('#Product_NumbersHide').val(parseFloat(rowctr));

            $('#Total_Qty').val(parseFloat(sumQ));
            $('#Total_QtyHide').val(parseFloat(sumQ));

            var TootPriice = parseFloat(sumT) - parseFloat(sumTax);
            $('#Total_Price').val(parseFloat(TootPriice).toFixed(2));
            $('#Total_PriceHide').val(parseFloat(TootPriice).toFixed(2));


            var NEEET = 0;
            $('.net').each(function() {
                NEEET += parseFloat($(this).val());
            });


            var PROFIIIT = parseFloat(NEEET) - parseFloat(COPRI);
            $('#ProfitPrecent').val(parseFloat(PROFIIIT).toFixed(2));

            var nfd = (parseFloat(PROFIIIT) * 100) / parseFloat(COPRI);
            $('#proPrecent').val(parseFloat(nfd).toFixed(2));


            $('#Total_DiscountTT').val(parseFloat(sumTTD).toFixed(2));
            $('#Total_DiscountHideTT').val(parseFloat(sumTTD).toFixed(2));

            $('#Total_Discount').val(parseFloat(sumD).toFixed(2));
            $('#Total_DiscountHide').val(parseFloat(sumD).toFixed(2));


            var BEFO = parseFloat(sumBF) ;

            $('#Total_Bf_Taxes').val(parseFloat(BEFO).toFixed(2));
            $('#Total_Bf_TaxesHide').val(parseFloat(BEFO).toFixed(2));

            $('#Total_Taxes').val(parseFloat(sumTax).toFixed(2));
            $('#Total_TaxesHide').val(parseFloat(sumTax).toFixed(2));

            $('#Total_After_Taxes').val(parseFloat(sumTax) + parseFloat(TootPriice));
            $('#TotalCost').val(parseFloat(COPRI).toFixed(2));

            var RRR = parseFloat(sumTax) + parseFloat(TootPriice) - parseFloat(sumTTD);
            $('#TAFterD').val(parseFloat(RRR).toFixed(2));
            $('#Total_Bill').val(parseFloat(RRR).toFixed(2));
            $('#Total_PriceW').val(parseFloat(RRR).toFixed(2));

            var resdiual = $('#resdiual').val();
            var total = $('#Total_PriceHide').val();
            var totalDisc = $('#Total_DiscountHideTT').val();

            var totalTax = $('#Total_TaxesHide').val();


            var RR = (parseFloat(total) + parseFloat(totalTax)) - (parseFloat(resdiual) + parseFloat(totalDisc));
            var RRR = parseFloat(total) - (parseFloat(resdiual) + parseFloat(totalDisc));

            $('#paid').val(parseFloat(RR).toFixed(2));

            $('#presenter').val(parseFloat(RR).toFixed(2));
            $('#total').val(parseFloat(sumT).toFixed(2));



            $('#ProNums').text(parseFloat(rowctr));
            $('#ProQty').text(parseFloat(sumQ).toFixed(2));
            $('#TotalPrice').text(parseFloat(TootPriice));
            $('#Total_DiscountTTShow').text(parseFloat(sumTTD).toFixed(2));
            $('#Total_TaxesShow').text(parseFloat(sumTax));



        })


     }

     function FunMyzan(r,t,zz) {

             var P_Ar_Name = $("#P_Ar_Name"+r).val();
             var P_En_Name= $("#P_En_Name"+r).val();
             var Product = $("#Product"+r).val();
             var UnitID = $("#UnitPurch"+r).val();
             var UnitName = $("#UnitPurchName"+r).val();
             var Qty = $("#Qty"+r).val();
             var AvQty = $("#AvQty"+r).val();
             var Barcode = $("#CodePurch"+r).val();
             var Price = $("#Price"+r).val();
             var Total = $("#Total"+r).val();
             var ExpDate = $("#ExpDate"+r).val();
             var PurchTax = $("#PurchTax"+r).val();
             var TotalTax = $("#Tax"+r).val();
             var Discount = $("#Discount"+r).val();
             var TotalBFTax = $("#TotalBFTax"+r).val();
             var StorePurch = $("#StorePurchName"+r).val();
             var StorePurchName = $("#StorePurchName"+r).val();
             var PurchTax = $("#PurchTax"+r).val();
             var VOne = $("#VOne"+r).val();
             var VTwo = $("#VTwo"+r).val();
             var V_Name = $("#V_Name"+r).val();
             var VV_Name = $("#VV_Name"+r).val();
             var TaxRate = $("#TaxRate"+r).val();
             var TaxType = $("#TaxType"+r).val();
             var Viro = '';
             var VViro = '';
               var priceSale =$("#priceSale").val();
               var discount =$("#discount").val();
               var serial =$("#serial"+r).val();
  var TDiscPro = $("#TDiscPro"+r).val();
    var CostPrice = $("#CostPrice"+r).val();

                             var weight = $("#weight"+r).val();
                var maxSales = $("#maxSales"+r).val();
                var RATOO = $("#UnitRato"+r).val();
                var LimitSalesQty = $("#LimitSalesQty").val();
            var DEFAULTCOSTPRICE = $("#DEFAULTCOSTPRICE").val();

       var TWeight=parseFloat(Qty) * (parseFloat(weight) * parseFloat(RATOO)) ;


                if(DEFAULTCOSTPRICE == 2){

            $.ajax({
                             url: 'NewCostProductFilter',
                             type:"GET",
                            data:{
                              store:StorePurch,
                              pro_code:Barcode,
                              Product:Product,
                              Qty:Qty,
                              UnitID:UnitID
                            },
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {


                                 $("#CostPrice"+r).val(data.total_cost);

                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });


          }


         Qty=parseFloat(zz);
         Barcode=parseFloat(t);

       if( V_Name != ''){

          Viro= '(' + V_Name +')';
       }

       if( VV_Name != ''){

         VViro= '(' + VV_Name +')';
       }


       if(parseFloat(priceSale) == 0){

           var PRIce = 'disabled';
           var PRIceTwo = '';

       }else{

           var PRIce = '';
                 var PRIceTwo = 'disabled';
       }

        if(parseFloat(discount) == 0){
             var Dicco = 'disabled';
             var DiccoTwo = '';

       }else{

           var Dicco = '';
           var DiccoTwo = 'disabled';
       }

         if(parseFloat(serial) == 1){
             var ser = 'disabled';
             var serTwo = '';


       }else{

           var ser = '';
           var serTwo = 'disabled';

       }

          document.getElementById("Row"+r).style.display = "none";

   var i = 0;
   var ii=0;
   var iii=0;

         var POS_Qty = $("#POS_Qty").val();
         var POS_Barcode = $("#POS_Barcode").val();

         if(parseFloat(POS_Qty) == 1){
             var ShowAvQty="<span style='color:red'>(<b id='AVVQ"+r+"'><button onclick='OtherQTY("+Product+","+Barcode+")' type='button' class='bt' style='padding:0 !imporatnt' data-toggle='modal' data-target='#Avilable'>"+AvQty+"</button></b>)</span>";
         }else{
             var ShowAvQty="<span style='color:red;display:none'>(<b id='AVVQ"+r+"'><button onclick='OtherQTY("+Product+","+Barcode+")' type='button' class='bt' style='padding:0 !imporatnt' data-toggle='modal' data-target='#Avilable'>"+AvQty+"</button></b>)</span>";
         }


         if(parseFloat(POS_Barcode) == 1){
             var ShowBarcode = "(<b id='Coding"+r+"'>"+ Barcode +"</b>)";
         }else{
             var ShowBarcode = "<b id='Coding"+r+"' style='display:none'>"+ Barcode +"</b>";
         }

         var HighDisc = $("#HighDisc"+r).val();
       var DIS = $("#DIS").val();

       if(parseFloat(DIS) == 0){

           Discount=$("#Discount"+r).val();
       }else{

           var d= Discount / 100 ;
           var Multi= parseFloat(Qty) * parseFloat(Price) ;
          var dd= Multi * d;

        Discount=  dd;
       }
             var BFG =  parseFloat(Qty) * parseFloat(Discount) ;
             $("#TDiscPro"+r).val(parseFloat(BFG));


       if(TaxType == 1){
           //Precent
       var BF =  parseFloat(Qty) *  (parseFloat(Price) );


           TotalBFTax = parseFloat(BF) ;

       i =    parseFloat(TaxRate)  / 100 ;

        ii=  parseFloat(BF) * parseFloat(i) ;


           TotalTax=parseFloat(ii);

       iii =  parseFloat(BF) + parseFloat(ii) ;


           Total=parseFloat(iii);

       }else if(TaxType == 2){
          //Number
    var BF =  parseFloat(Qty) *  (parseFloat(Price) );
               TotalBFTax = parseFloat(BF) ;

            i =    parseFloat(TaxRate)   ;

              TotalTax=parseFloat(i);

       iii =  parseFloat(BF) + parseFloat(i) ;

            Total=parseFloat(iii);


       }

  var DIS = $("#DIS").val();
  var RFF= parseFloat(Qty) * parseFloat(Price);
       var RFFResult= parseFloat(RFF) - parseFloat(Total);


              var ShowTax = $("#ShowTax").val();
                  var LANG = $("#LANG").val();
   if(LANG == 'ar' ){
          var Nemo = P_Ar_Name ;
          }else{
             var Nemo = P_En_Name ;
          }


         var Show_Unit = $("#Show_Unit").val();
         var DISCSHOW = $("#DISCSHOW").val();
         var Show_Total = $("#Show_Total").val();
         var Show_Net = $("#Show_Net").val();

         if (Show_Unit == 1) {

             var UNITSHOWW = "";

         } else {

             var UNITSHOWW = "none";
         }
         if (DISCSHOW == 1) {

             var DISCOUNTSHOW = "";

         } else {

             var DISCOUNTSHOW = "none";
         }


         if (Show_Total == 1) {

             var TOTALSHOWW = "";

         } else {

             var TOTALSHOWW = "none";
         }

         if (Show_Net == 1) {

             var NETSHOWW = "";

         } else {

             var NETSHOWW = "none";
         }
         var Net=(parseFloat(Total) ) - (parseFloat(Discount) * parseFloat(Qty));


         if(parseFloat(Net) >   0){
             var TotCostNew=parseFloat(Qty) * parseFloat(CostPrice) ;
         }else{
             var TotCostNew=0; ;
         }


         if(parseFloat(ShowTax) == 1){
             var markup = "<tr><td><i id='DelAssem' class='fal fa-trash-alt'></i></td><td>" + Nemo + ""+ Viro +" "+ VViro +" "+ShowBarcode+" "+ShowAvQty+" <button type='button'  class='btn btn-sm btn-block btn-outline-success waves-effect waves-themed'  data-toggle='modal' onclick='TaxPro("+Product+","+r+")' style='width: 10%;' data-target='#TAXXXX'><i class='fal fa-calculator'></i></button> </td><td style='display: "+UNITSHOWW+"'><input type='hidden' id='un"+r+"' name='Unit[]' value='"+UnitID+"'><button type='button'  class='btn btn-sm btn-block btn-outline-success waves-effect waves-themed'  data-toggle='modal' onclick='UniPro("+Product+","+r+","+Barcode+","+StorePurch+")' data-target='#UnitTTT'><span id='TextUni"+r+"'>" + UnitName + "<span></button></td><td><input  type='number' "+ser+" step='any' onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' id='QTTY"+r+"' name='Qty[]' class='form-control input-width Qun' value='"+parseFloat(Qty).toFixed(2)+"'><input "+serTwo+" type='hidden' name='Qty[]' value='"+parseFloat(Qty).toFixed(2)+"'></td><td><input type='number' step='any' "+PRIce+" class='form-control input-width' onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' id='PRICE"+r+"' name='Price[]' value='"+Price+"'><input "+PRIceTwo+" type='hidden' name='Price[]' value='"+Price+"' id='PCL"+r+"'></td><td style='width:50px;display: "+DISCOUNTSHOW+"'><input  onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' type='number' step='any' class='form-control Disc input-width' "+Dicco+" name='Discount[]' id='DISC"+r+"' value='"+Discount+"'><input type='hidden' "+DiccoTwo+" name='Discount[]' value='"+Discount+"'></td><td  style='width:130px;display: "+TOTALSHOWW+"'><input  type='hidden' name='Total[]' id='TOTT"+r+"' value='"+parseFloat(Total).toFixed(2)+"'><input class='form-control Tot total-input-width'  type='text' disabled id='TOTTNo"+r+"' value='"+parseFloat(Total).toFixed(2)+"'></td><td style='display: "+NETSHOWW+"'><input class='net form-control' type='number' step='any' id='NetD" + r + "' readonly   name='Total_Net[]' value='" + Net + "'></td><input type='hidden' name='V_Name[]' value='"+Viro+"'><input type='hidden' name='VV_Name[]' value='"+VViro+"'><input type='hidden' id='PurchTaxx"+r+"' name='PurchTax[]'  value='"+PurchTax+"'><input type='hidden' name='VOne[]' id='V"+r+"' value='"+VOne+"'><input id='VV"+r+"' type='hidden' name='VTwo[]' value='"+VTwo+"'><input type='hidden' id='PRO"+r+"' name='Product[]' value='"+Product+"'><input type='hidden' name='P_Ar_Name[]' value='"+P_Ar_Name+"'><input type='hidden' name='P_En_Name[]' value='"+P_En_Name+"'><input type='hidden' name='P_Code[]' id='CodingHide"+r+"' value='"+Barcode+"'><input id='AVHide"+r+"' type='hidden' name='AvQty[]' value='"+AvQty+"'><input class='TotalBFTax' id='TBFTax"+r+"' type='hidden' name='TotalBFTax[]' value='"+TotalBFTax+"'><input class='TotalTax' type='hidden' name='TotalTax[]' id='TTax"+r+"' value='"+TotalTax+"'><input id='STORETABLE"+r+"'  type='hidden' name='StorePurch[]' value='"+StorePurch+"'><input type='hidden' name='Exp_Date[]' value='"+ExpDate+"'><input type='hidden' id='RATE"+r+"'  value='"+TaxRate+"'><input type='hidden' id='TYPE"+r+"'  value='"+TaxType+"'><input type='hidden' id='HighDisc"+r+"'  value='"+HighDisc+"'><input type='hidden' id='Enough"+r+"' name='AllEnough[]'  value='0'><input type='hidden' class='DiscoPrecent' id='disssccoount"+r+"' value='"+RFFResult+"'><input type='hidden' class='TDISCOOO' id='TDiscProEdit"+r+"' name='TDiscPro[]' value='"+TDiscPro+"'><input type='hidden' id='costPric"+r+"'   name='CostPrice[]' value='"+CostPrice+"'><input type='hidden' id='weightT"+r+"'   name='weight[]' value='"+weight+"'><input type='hidden' id='UnitRate"+r+"'   name='UnitRate[]' value='"+RATOO+"'><input type='hidden' id='Total_Wight"+r+"' class='W'  name='Total_Wight[]' value='"+TWeight+"'><input type='hidden' id='maxSa"+r+"' value='"+maxSales+"'><input type='hidden' class='COSTPRICES' id='TotCostNew"+r+"' name='TotCostNew[]' value='"+TotCostNew+"'></tr>";
         }else{
             var markup = "<tr><td><i id='DelAssem' class='fal fa-trash-alt'></i></td><td>" + Nemo + ""+ Viro +" "+ VViro +" "+ShowBarcode+" "+ShowAvQty+"</td><td style='display: "+UNITSHOWW+"'><input type='hidden' id='un"+r+"' name='Unit[]' value='"+UnitID+"'><button type='button'  class='btn btn-sm btn-block btn-outline-success waves-effect waves-themed'  data-toggle='modal' onclick='UniPro("+Product+","+r+","+Barcode+","+StorePurch+")' data-target='#UnitTTT'><span id='TextUni"+r+"'>" + UnitName + "<span></button></td><td><input  type='number' "+ser+" step='any' onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' id='QTTY"+r+"' name='Qty[]' class='form-control input-width Qun' value='"+parseFloat(Qty).toFixed(2)+"'><input "+serTwo+" type='hidden' name='Qty[]' value='"+parseFloat(Qty).toFixed(2)+"'></td><td><input type='number' step='any' "+PRIce+" class='form-control input-width' onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' id='PRICE"+r+"' name='Price[]' value='"+Price+"'><input "+PRIceTwo+" type='hidden' name='Price[]' value='"+Price+"' id='PCL"+r+"'></td><td style='width:50px;display: "+DISCOUNTSHOW+"''><input  onkeyup='PurchTotal("+r+")' onclick='PurchTotal("+r+")' type='number' step='any' class='form-control Disc input-width' "+Dicco+" name='Discount[]' id='DISC"+r+"' value='"+Discount+"'><input type='hidden' "+DiccoTwo+" name='Discount[]' value='"+Discount+"'></td><td style='width:130px;display: "+TOTALSHOWW+"'><input  type='hidden' name='Total[]' id='TOTT"+r+"' value='"+parseFloat(Total).toFixed(2)+"'><input class='form-control Tot total-input-width'  type='text' disabled id='TOTTNo"+r+"' value='"+parseFloat(Total).toFixed(2)+"'></td><td style='display: "+NETSHOWW+"'><input class='net form-control' type='number' step='any' id='NetD" + r + "' readonly   name='Total_Net[]' value='" + Net + "'></td><input type='hidden' name='V_Name[]' value='"+Viro+"'><input type='hidden' name='VV_Name[]' value='"+VViro+"'><input type='hidden' id='PurchTaxx"+r+"' name='PurchTax[]'  value='"+PurchTax+"'><input type='hidden' name='VOne[]' id='V"+r+"' value='"+VOne+"'><input id='VV"+r+"' type='hidden' name='VTwo[]' value='"+VTwo+"'><input type='hidden' id='PRO"+r+"' name='Product[]' value='"+Product+"'><input type='hidden' name='P_Ar_Name[]' value='"+P_Ar_Name+"'><input type='hidden' name='P_En_Name[]' value='"+P_En_Name+"'><input type='hidden' name='P_Code[]' id='CodingHide"+r+"' value='"+Barcode+"'><input id='AVHide"+r+"' type='hidden' name='AvQty[]' value='"+AvQty+"'><input class='TotalBFTax' id='TBFTax"+r+"' type='hidden' name='TotalBFTax[]' value='"+TotalBFTax+"'><input class='TotalTax' type='hidden' name='TotalTax[]' id='TTax"+r+"' value='"+TotalTax+"'><input  type='hidden' id='STORETABLE"+r+"' name='StorePurch[]' value='"+StorePurch+"'><input type='hidden' name='Exp_Date[]' value='"+ExpDate+"'><input type='hidden' id='RATE"+r+"'  value='"+TaxRate+"'><input type='hidden' id='TYPE"+r+"'  value='"+TaxType+"'><input type='hidden' id='HighDisc"+r+"'  value='"+HighDisc+"'><input type='hidden' id='Enough"+r+"' name='AllEnough[]'  value='0'><input type='hidden' class='DiscoPrecent' id='disssccoount"+r+"' value='"+RFFResult+"'><input type='hidden' class='TDISCOOO' id='TDiscProEdit"+r+"' name='TDiscPro[]' value='"+TDiscPro+"'><input type='hidden' id='costPric"+r+"' name='CostPrice[]' value='"+CostPrice+"'><input type='hidden' id='weightT"+r+"'   name='weight[]' value='"+weight+"'><input type='hidden' id='UnitRate"+r+"'   name='UnitRate[]' value='"+RATOO+"'><input type='hidden' id='Total_Wight"+r+"' class='W'  name='Total_Wight[]' value='"+TWeight+"'><input type='hidden' id='maxSa"+r+"' value='"+maxSales+"'><input type='hidden' class='COSTPRICES' id='TotCostNew"+r+"' name='TotCostNew[]' value='"+TotCostNew+"'></tr>";

         }



    var P = $("#PRO"+r).val();
     var Q = $("#QTTY"+r).val();
     var VO = $("#V"+r).val();
        var VOO = $("#VV"+r).val();
        var PRICE = $("#PRICE"+r).val();
        var DISC = $("#DISC"+r).val();
        var RATE = $("#RATE"+r).val();
        var TYPE = $("#TYPE"+r).val();




          if(LimitSalesQty == 1){

       if(maxSales >= Qty){



       if(Product == P){

         if(parseFloat(serial) == 0){

           if(VO == VOne  && VOO == VTwo){
           var rt=parseFloat(Q) + parseFloat(1);
           $("#QTTY"+r).val(parseFloat(rt));
               $('#search').val('');
                document.getElementById('data').style.display="none";
           }

  $('.Data').hide();
var TaxRate = $("#RATE"+r).val();
   var TaxType = $("#TYPE"+r).val();
   var Qty = $("#QTTY"+r).val();
   var Price = $("#PRICE"+r).val();
   var Discount = $("#DISC"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;

             var HighDisc = $("#HighDisc"+r).val();
       var DIS = $("#DIS").val();

       if(parseFloat(DIS) == 0){

           Discount=$("#DISC"+r).val();
       }else{

           var d= Discount / 100 ;
           var Multi= parseFloat(Qty) * parseFloat(Price) ;
          var dd= Multi * d;

        Discount=  dd;
       }

        if(HighDisc != 0){


           if(parseFloat(Discount)  >  parseFloat(HighDisc)){
                     document.getElementById("Action").style.display = "none";
                     document.getElementById("ActionAlert").style.display = "block";
           }else{
                   document.getElementById("Action").style.display = "block";
                   document.getElementById("ActionAlert").style.display = "none";

           }


       }

             var BFG =  parseFloat(Qty) * parseFloat(Discount) ;
             $("#TDiscPro"+r).val(parseFloat(BFG));



       if(TaxType == 1){
           //Precent

  var BF =  parseFloat(Qty) *  (parseFloat(Price) );

       $("#TBFTax"+r).val(parseFloat(BF));

       i =    parseFloat(TaxRate)  / 100 ;

        ii=  parseFloat(BF) * parseFloat(i) ;

           $("#TTax"+r).val(parseFloat(ii));

       iii =  parseFloat(BF) + parseFloat(ii) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));

       }else if(TaxType == 2){
          //Number
        var BF =  parseFloat(Qty) *  (parseFloat(Price) );
         $("#TBFTax"+r).val(parseFloat(BF));

            i =    parseFloat(TaxRate)   ;

           $("#TTax"+r).val(parseFloat(i));

       iii =  parseFloat(BF) + parseFloat(i) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));


       }


          play();
         }else{

             alert('لا يمكن اضافه هذا المنتج مره اخري');

         }

       }else{
        $("#data-dt").append(markup);
           $('#search').val('');
         document.getElementById('data').style.display="none";
           play();
       }




          }else{

      if(LANG == 'ar' ){
    alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
      }else{

    alert('You have exceeded the selling limit for this product');
      }

          }

          }else{



       if(Product == P){

         if(parseFloat(serial) == 0){

           if(VO == VOne  && VOO == VTwo){
           var rt=parseFloat(Q) + parseFloat(1);
           $("#QTTY"+r).val(parseFloat(rt));
               $('#search').val('');
                document.getElementById('data').style.display="none";
           }

  $('.Data').hide();
var TaxRate = $("#RATE"+r).val();
   var TaxType = $("#TYPE"+r).val();
   var Qty = $("#QTTY"+r).val();
   var Price = $("#PRICE"+r).val();
   var Discount = $("#DISC"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;

             var HighDisc = $("#HighDisc"+r).val();
       var DIS = $("#DIS").val();

       if(parseFloat(DIS) == 0){

           Discount=$("#DISC"+r).val();
       }else{

           var d= Discount / 100 ;
           var Multi= parseFloat(Qty) * parseFloat(Price) ;
          var dd= Multi * d;

        Discount=  dd;
       }

        if(HighDisc != 0){


           if(parseFloat(Discount)  >  parseFloat(HighDisc)){
                     document.getElementById("Action").style.display = "none";
                     document.getElementById("ActionAlert").style.display = "block";
           }else{
                   document.getElementById("Action").style.display = "block";
                   document.getElementById("ActionAlert").style.display = "none";

           }


       }

             var BFG =  parseFloat(Qty) * parseFloat(Discount) ;
             $("#TDiscPro"+r).val(parseFloat(BFG));



       if(TaxType == 1){
           //Precent

  var BF =  parseFloat(Qty) *  (parseFloat(Price) );

       $("#TBFTax"+r).val(parseFloat(BF));

       i =    parseFloat(TaxRate)  / 100 ;

        ii=  parseFloat(BF) * parseFloat(i) ;

           $("#TTax"+r).val(parseFloat(ii));

       iii =  parseFloat(BF) + parseFloat(ii) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));

       }else if(TaxType == 2){
          //Number
        var BF =  parseFloat(Qty) *  (parseFloat(Price) );
         $("#TBFTax"+r).val(parseFloat(BF));

            i =    parseFloat(TaxRate)   ;

           $("#TTax"+r).val(parseFloat(i));

       iii =  parseFloat(BF) + parseFloat(i) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));


       }


          play();
         }else{

             alert('لا يمكن اضافه هذا المنتج مره اخري');

         }

       }else{
        $("#data-dt").append(markup);
           $('#search').val('');
         document.getElementById('data').style.display="none";
           play();
       }




          }






        document.getElementById('data').style.display="none";

      $.fn.rowCount = function() {
     return $('tr', $(this).find('tbody')).length;
   };

   var rowctr = $('#dt').rowCount();

    var sumQ = 0;
   $('.Qun').each(function(){
   sumQ += parseFloat($(this).val());
   });

    var sumT = 0;
   $('.Tot').each(function(){
   sumT += parseFloat($(this).val());
   });

        var sumD = 0;
   $('.Disc').each(function(){
   sumD += parseFloat($(this).val());
   });


           var sumBF = 0;
   $('.TotalBFTax').each(function(){
   sumBF += parseFloat($(this).val());
   });

           var sumTax = 0;
   $('.TotalTax').each(function(){
   sumTax += parseFloat($(this).val());
   });

                                          var prec = 0;
   $('.DiscoPrecent').each(function(){
   prec += parseFloat($(this).val());
   });


              var sumTTD = 0;
   $('.TDISCOOO').each(function(){
   sumTTD += parseFloat($(this).val());
   });

        var COPRI = 0;
   $('.COSTPRICES').each(function(){
   COPRI += parseFloat($(this).val());
   });

                var COWeight = 0;
   $('.W').each(function(){
   COWeight += parseFloat($(this).val());
   });

         $('#Total_Wight_Bill').val(parseFloat(COWeight));

         $('#Total_Wight_Bill').val(parseFloat(COWeight));
         $('#Product_Numbers').val(parseFloat(rowctr));
         $('#Product_NumbersHide').val(parseFloat(rowctr));

         $('#Total_Qty').val(parseFloat(sumQ));
         $('#Total_QtyHide').val(parseFloat(sumQ));

         var TootPriice = parseFloat(sumT) - parseFloat(sumTax);
         $('#Total_Price').val(parseFloat(TootPriice).toFixed(2));
         $('#Total_PriceHide').val(parseFloat(TootPriice).toFixed(2));


         var NEEET = 0;
         $('.net').each(function() {
             NEEET += parseFloat($(this).val());
         });


         var PROFIIIT = parseFloat(NEEET) - parseFloat(COPRI);
         $('#ProfitPrecent').val(parseFloat(PROFIIIT).toFixed(2));

         var nfd = (parseFloat(PROFIIIT) * 100) / parseFloat(COPRI);
         $('#proPrecent').val(parseFloat(nfd).toFixed(2));

         $('#Total_DiscountTT').val(parseFloat(sumTTD).toFixed(2));
         $('#Total_DiscountHideTT').val(parseFloat(sumTTD).toFixed(2));

         $('#Total_Discount').val(parseFloat(sumD).toFixed(2));
         $('#Total_DiscountHide').val(parseFloat(sumD).toFixed(2));


         var BEFO = parseFloat(sumBF) ;

         $('#Total_Bf_Taxes').val(parseFloat(BEFO).toFixed(2));
         $('#Total_Bf_TaxesHide').val(parseFloat(BEFO).toFixed(2));

         $('#Total_Taxes').val(parseFloat(sumTax).toFixed(2));
         $('#Total_TaxesHide').val(parseFloat(sumTax).toFixed(2));

         $('#Total_After_Taxes').val(parseFloat(sumTax) + parseFloat(TootPriice));
         $('#TotalCost').val(parseFloat(COPRI).toFixed(2));

         var RRR = parseFloat(sumTax) + parseFloat(TootPriice) - parseFloat(sumTTD);
         $('#TAFterD').val(parseFloat(RRR).toFixed(2));
         $('#Total_Bill').val(parseFloat(RRR).toFixed(2));
         $('#Total_PriceW').val(parseFloat(RRR).toFixed(2));

         var resdiual = $('#resdiual').val();
         var total = $('#Total_PriceHide').val();
         var totalDisc = $('#Total_DiscountHideTT').val();

         var totalTax = $('#Total_TaxesHide').val();


         var RR = (parseFloat(total) + parseFloat(totalTax)) - (parseFloat(resdiual) + parseFloat(totalDisc));
         var RRR = parseFloat(total) - (parseFloat(resdiual) + parseFloat(totalDisc));

         $('#paid').val(parseFloat(RR).toFixed(2));

         $('#presenter').val(parseFloat(RR).toFixed(2));
         $('#total').val(parseFloat(sumT).toFixed(2));



         $('#ProNums').text(parseFloat(rowctr));
         $('#ProQty').text(parseFloat(sumQ).toFixed(2));
         $('#TotalPrice').text(parseFloat(TootPriice));
         $('#Total_DiscountTTShow').text(parseFloat(sumTTD).toFixed(2));
         $('#Total_TaxesShow').text(parseFloat(sumTax));


         var TaxRate = $("#RATE"+r).val();
   var TaxType = $("#TYPE"+r).val();
   var Qty = $("#QTTY"+r).val();
   var AVQty = $("#AVHide"+r).val();
   var Price = $("#PRICE"+r).val();
   var Discount = $("#DISC"+r).val();
       var CostPrice = $("#costPric"+r).val();
          var LOWCOSTPRICE = $("#LOWCOSTPRICE").val();

           var weight = $("#weightT"+r).val();
    var RATOO = $("#UnitRate"+r).val();
    var maxSales = $("#maxSa"+r).val();
    var LimitSalesQty = $("#LimitSalesQty").val();
    var LANG = $("#LANG").val();
       if(parseFloat(Qty) > parseFloat(AVQty)){


      document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);

       }else{

           if(parseFloat(Qty) < 0){
                   document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
           }else{


              if(parseFloat(LOWCOSTPRICE) == 0){

                     if(parseFloat(DEFAULTCOSTPRICE) == 2){

                          if(parseFloat(Price)*parseFloat(Qty) < parseFloat(CostPrice)){

                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);

                         }else{



   if(LimitSalesQty == 1){

       if(maxSales >= Qty){

                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);


          }else{
 document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
      if(LANG == 'ar' ){
    alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
      }else{

    alert('You have exceeded the selling limit for this product');
      }

          }

   }else{
                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);

   }




                         }


                     }else{
                      if(parseFloat(Price) < parseFloat(CostPrice)){

                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);

                         }else{



   if(LimitSalesQty == 1){

       if(maxSales >= Qty){

                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);


          }else{
 document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
      if(LANG == 'ar' ){
    alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
      }else{

    alert('You have exceeded the selling limit for this product');
      }

          }

   }else{
                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);

   }




                         }
                     }

                     }else{


        if(LimitSalesQty == 1){

       if(maxSales >= Qty){

                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);


          }else{
 document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
      if(LANG == 'ar' ){
    alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
      }else{

    alert('You have exceeded the selling limit for this product');
      }

          }

   }else{
                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);

   }


                     }


       }
       }

       var enough=0;
    $('input[name^="AllEnough"]').each(function() {


        enough +=$(this).val();

});


             if(parseFloat(enough) > 0){

               document.getElementById("Action").style.display = "none";
   document.getElementById("QTYAlert").style.display = "block";
        }else{
               document.getElementById("Action").style.display = "block";
   document.getElementById("QTYAlert").style.display = "none";

        }

                       var Total_PriceW =$('#Total_PriceW').val();

             if(enough == 0){

             if(Total_PriceW == 'NaN'){
                   document.getElementById("Action").style.display = "none";
                    }else{
        document.getElementById("Action").style.display = "block";
             }

       }else{

        document.getElementById("Action").style.display = "none";
       }



                  var TWeight=parseFloat(Qty) * (parseFloat(weight) * parseFloat(RATOO)) ;

                $("#Total_Wight"+r).val(parseFloat(TWeight));


       var COWeight = 0;
   $('.W').each(function(){
   COWeight += parseFloat($(this).val());
   });

      $('#Total_Wight_Bill').val(parseFloat(COWeight));


         document.getElementById("search").focus();



        $('#data-dt').on('click', '#DelAssem', function(e){
                $(this).closest('tr').remove();


      $.fn.rowCount = function() {
     return $('tr', $(this).find('tbody')).length;
   };

   var rowctr = $('#dt').rowCount();

    var sumQ = 0;
   $('.Qun').each(function(){
   sumQ += parseFloat($(this).val());
   });

    var sumT = 0;
   $('.Tot').each(function(){
   sumT += parseFloat($(this).val());
   });

        var sumD = 0;
   $('.Disc').each(function(){
   sumD += parseFloat($(this).val());
   });


           var sumBF = 0;
   $('.TotalBFTax').each(function(){
   sumBF += parseFloat($(this).val());
   });

           var sumTax = 0;
   $('.TotalTax').each(function(){
   sumTax += parseFloat($(this).val());
   });

            var prec = 0;
   $('.DiscoPrecent').each(function(){
   prec += parseFloat($(this).val());
   });


              var sumTTD = 0;
   $('.TDISCOOO').each(function(){
   sumTTD += parseFloat($(this).val());
   });

     var COPRI = 0;
   $('.COSTPRICES').each(function(){
   COPRI += parseFloat($(this).val());
   });

                   var COWeight = 0;
   $('.W').each(function(){
   COWeight += parseFloat($(this).val());
   });

            $('#Total_Wight_Bill').val(parseFloat(COWeight));

            $('#Total_Wight_Bill').val(parseFloat(COWeight));
            $('#Product_Numbers').val(parseFloat(rowctr));
            $('#Product_NumbersHide').val(parseFloat(rowctr));

            $('#Total_Qty').val(parseFloat(sumQ));
            $('#Total_QtyHide').val(parseFloat(sumQ));

            var TootPriice = parseFloat(sumT) - parseFloat(sumTax);
            $('#Total_Price').val(parseFloat(TootPriice).toFixed(2));
            $('#Total_PriceHide').val(parseFloat(TootPriice).toFixed(2));


            var NEEET = 0;
            $('.net').each(function() {
                NEEET += parseFloat($(this).val());
            });


            var PROFIIIT = parseFloat(NEEET) - parseFloat(COPRI);
            $('#ProfitPrecent').val(parseFloat(PROFIIIT).toFixed(2));

            var nfd = (parseFloat(PROFIIIT) * 100) / parseFloat(COPRI);
            $('#proPrecent').val(parseFloat(nfd).toFixed(2));


            $('#Total_DiscountTT').val(parseFloat(sumTTD).toFixed(2));
            $('#Total_DiscountHideTT').val(parseFloat(sumTTD).toFixed(2));

            $('#Total_Discount').val(parseFloat(sumD).toFixed(2));
            $('#Total_DiscountHide').val(parseFloat(sumD).toFixed(2));


            var BEFO = parseFloat(sumBF) ;

            $('#Total_Bf_Taxes').val(parseFloat(BEFO).toFixed(2));
            $('#Total_Bf_TaxesHide').val(parseFloat(BEFO).toFixed(2));

            $('#Total_Taxes').val(parseFloat(sumTax).toFixed(2));
            $('#Total_TaxesHide').val(parseFloat(sumTax).toFixed(2));

            $('#Total_After_Taxes').val(parseFloat(sumTax) + parseFloat(TootPriice));
            $('#TotalCost').val(parseFloat(COPRI).toFixed(2));

            var RRR = parseFloat(sumTax) + parseFloat(TootPriice) - parseFloat(sumTTD);
            $('#TAFterD').val(parseFloat(RRR).toFixed(2));
            $('#Total_Bill').val(parseFloat(RRR).toFixed(2));
            $('#Total_PriceW').val(parseFloat(RRR).toFixed(2));

            var resdiual = $('#resdiual').val();
            var total = $('#Total_PriceHide').val();
            var totalDisc = $('#Total_DiscountHideTT').val();

            var totalTax = $('#Total_TaxesHide').val();


            var RR = (parseFloat(total) + parseFloat(totalTax)) - (parseFloat(resdiual) + parseFloat(totalDisc));
            var RRR = parseFloat(total) - (parseFloat(resdiual) + parseFloat(totalDisc));

            $('#paid').val(parseFloat(RR).toFixed(2));

            $('#presenter').val(parseFloat(RR).toFixed(2));
            $('#total').val(parseFloat(sumT).toFixed(2));



            $('#ProNums').text(parseFloat(rowctr));
            $('#ProQty').text(parseFloat(sumQ).toFixed(2));
            $('#TotalPrice').text(parseFloat(TootPriice));
            $('#Total_DiscountTTShow').text(parseFloat(sumTTD).toFixed(2));
            $('#Total_TaxesShow').text(parseFloat(sumTax));




        })


     }

</script>

<!-- Total Products -->
<script>
   function PurchTotal(r) {
   var TaxRate = $("#RATE"+r).val();
   var TaxType = $("#TYPE"+r).val();
   var Qty = $("#QTTY"+r).val();
   var AVQty = $("#AVHide"+r).val();
   var Price = $("#PRICE"+r).val();
   var Discount = $("#DISC"+r).val();
       var CostPrice = $("#costPric"+r).val();
       var StorePurch = $("#STORETABLE"+r).val();
       var Barcode = $("#CodingHide"+r).val();
       var Product = $("#PRO"+r).val();
       var UnitID = $("#un"+r).val();


          var LOWCOSTPRICE = $("#LOWCOSTPRICE").val();

           var weight = $("#weightT"+r).val();
    var RATOO = $("#UnitRate"+r).val();
    var maxSales = $("#maxSa"+r).val();
    var LimitSalesQty = $("#LimitSalesQty").val();
    var LANG = $("#LANG").val();
          var DEFAULTCOSTPRICE = $("#DEFAULTCOSTPRICE").val();

   var i = 0;
   var ii=0;
   var iii=0;


             var TWeight=parseFloat(Qty) * (parseFloat(weight) * parseFloat(RATOO)) ;




       if(DEFAULTCOSTPRICE == 2){

           $.ajax({
               url: 'NewCostProductFilter',
               type:"GET",
               data:{
                   store:StorePurch,
                   pro_code:Barcode,
                   Product:Product,
                   Qty:Qty,
                   UnitID:UnitID
               },
               dataType:"json",
               beforeSend: function(){
                   $('#loader').css("visibility", "visible");
               },

               success:function(data) {


                   $("#costPric"+r).val(data.total_cost);

               },
               complete: function(){
                   $('#loader').css("visibility", "hidden");
               }
           });


       }





       $("#Total_Wight"+r).val(parseFloat(TWeight));



         var HighDisc = $("#HighDisc"+r).val();
       var DIS = $("#DIS").val();

       if(parseFloat(DIS) == 0){

           Discount=$("#DISC"+r).val();
       }else{

           var d= Discount / 100 ;
           var Multi= parseFloat(Qty) * parseFloat(Price) ;
          var dd= Multi * d;

        Discount=  dd;
       }

           var BFG =  parseFloat(Qty) * parseFloat(Discount) ;
             $("#TDiscProEdit"+r).val(parseFloat(BFG));

       if(TaxType == 1){
           //Precent

      var BF =  parseFloat(Qty) *  (parseFloat(Price));

       $("#TBFTax"+r).val(parseFloat(BF));

       i =    parseFloat(TaxRate)  / 100 ;

        ii=  parseFloat(BF) * parseFloat(i) ;

           $("#TTax"+r).val(parseFloat(ii));

       iii =  parseFloat(BF) + parseFloat(ii) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));

       }else if(TaxType == 2){
          //Number
         var BF =  parseFloat(Qty) *  (parseFloat(Price) );
         $("#TBFTax"+r).val(parseFloat(BF));

            i =    parseFloat(TaxRate)   ;

           $("#TTax"+r).val(parseFloat(i));

       iii =  parseFloat(BF) + parseFloat(i) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));


       }



           var Total = $("#TOTT"+r).val();
       var RFF= parseFloat(Qty) * parseFloat(Price);
       var RFFResult= parseFloat(RFF) - parseFloat(Total);
         $("#disssccoount"+r).val(parseFloat(RFFResult));



       var Total =$("#TOTT" + r).val();
       var TotalTax =$("#TTax" + r).val();
       var Net=(parseFloat(Total) ) - (parseFloat(Discount) * parseFloat(Qty));
       $("#NetD" + r).val(parseFloat(Net).toFixed(2));

if(parseFloat(Net) > 0) {
    var TotCostNew = parseFloat(Qty) * parseFloat(CostPrice);
    $("#TotCostNew" + r).val(parseFloat(TotCostNew).toFixed(2));
}else{
    var TotCostNew = 0;
    $("#TotCostNew" + r).val(parseFloat(TotCostNew).toFixed(2));
}



     $.fn.rowCount = function() {
     return $('tr', $(this).find('tbody')).length;
   };

   var rowctr = $('#dt').rowCount();

    var sumQ = 0;
   $('.Qun').each(function(){
   sumQ += parseFloat($(this).val());
   });

    var sumT = 0;
   $('.Tot').each(function(){
   sumT += parseFloat($(this).val());
   });

        var sumD = 0;
   $('.Disc').each(function(){
   sumD += parseFloat($(this).val());
   });


           var sumBF = 0;
   $('.TotalBFTax').each(function(){
   sumBF += parseFloat($(this).val());
   });

           var sumTax = 0;
   $('.TotalTax').each(function(){
   sumTax += parseFloat($(this).val());
   });

                                      var prec = 0;
   $('.DiscoPrecent').each(function(){
   prec += parseFloat($(this).val());
   });

              var sumTTD = 0;
   $('.TDISCOOO').each(function(){
   sumTTD += parseFloat($(this).val());
   });

        var COPRI = 0;
   $('.COSTPRICES').each(function(){
   COPRI += parseFloat($(this).val());
   });

                     var COWeight = 0;
   $('.W').each(function(){
   COWeight += parseFloat($(this).val());
   });

       $('#Total_Wight_Bill').val(parseFloat(COWeight));

       $('#Total_Wight_Bill').val(parseFloat(COWeight));
       $('#Product_Numbers').val(parseFloat(rowctr));
       $('#Product_NumbersHide').val(parseFloat(rowctr));

       $('#Total_Qty').val(parseFloat(sumQ));
       $('#Total_QtyHide').val(parseFloat(sumQ));

       var TootPriice = parseFloat(sumT) - parseFloat(sumTax);
       $('#Total_Price').val(parseFloat(TootPriice).toFixed(2));
       $('#Total_PriceHide').val(parseFloat(TootPriice).toFixed(2));


       var NEEET = 0;
       $('.net').each(function() {
           NEEET += parseFloat($(this).val());
       });


       var PROFIIIT = parseFloat(NEEET) - parseFloat(COPRI);
       $('#ProfitPrecent').val(parseFloat(PROFIIIT).toFixed(2));

       var nfd = (parseFloat(PROFIIIT) * 100) / parseFloat(COPRI);
       $('#proPrecent').val(parseFloat(nfd).toFixed(2));


       $('#Total_DiscountTT').val(parseFloat(sumTTD).toFixed(2));
       $('#Total_DiscountHideTT').val(parseFloat(sumTTD).toFixed(2));

       $('#Total_Discount').val(parseFloat(sumD).toFixed(2));
       $('#Total_DiscountHide').val(parseFloat(sumD).toFixed(2));


       var BEFO = parseFloat(sumBF) ;

       $('#Total_Bf_Taxes').val(parseFloat(BEFO).toFixed(2));
       $('#Total_Bf_TaxesHide').val(parseFloat(BEFO).toFixed(2));

       $('#Total_Taxes').val(parseFloat(sumTax).toFixed(2));
       $('#Total_TaxesHide').val(parseFloat(sumTax).toFixed(2));

       $('#Total_After_Taxes').val(parseFloat(sumTax) + parseFloat(TootPriice));
       $('#TotalCost').val(parseFloat(COPRI).toFixed(2));

       var RRR = parseFloat(sumTax) + parseFloat(TootPriice) - parseFloat(sumTTD);
       $('#TAFterD').val(parseFloat(RRR).toFixed(2));
       $('#Total_Bill').val(parseFloat(RRR).toFixed(2));
       $('#Total_PriceW').val(parseFloat(RRR).toFixed(2));

       var resdiual = $('#resdiual').val();
       var total = $('#Total_PriceHide').val();
       var totalDisc = $('#Total_DiscountHideTT').val();

       var totalTax = $('#Total_TaxesHide').val();


       var RR = (parseFloat(total) + parseFloat(totalTax)) - (parseFloat(resdiual) + parseFloat(totalDisc));
       var RRR = parseFloat(total) - (parseFloat(resdiual) + parseFloat(totalDisc));

       $('#paid').val(parseFloat(RR).toFixed(2));

       $('#presenter').val(parseFloat(RR).toFixed(2));
       $('#total').val(parseFloat(sumT).toFixed(2));



       $('#ProNums').text(parseFloat(rowctr));
       $('#ProQty').text(parseFloat(sumQ).toFixed(2));
       $('#TotalPrice').text(parseFloat(TootPriice));
       $('#Total_DiscountTTShow').text(parseFloat(sumTTD).toFixed(2));
       $('#Total_TaxesShow').text(parseFloat(sumTax));



       if(HighDisc != 0){


           if(parseFloat(Discount)  >  parseFloat(HighDisc)){
                     document.getElementById("Action").style.display = "none";
                   document.getElementById("ActionAlert").style.display = "block";
           }else{
                   document.getElementById("Action").style.display = "block";
                document.getElementById("ActionAlert").style.display = "none";

           }


       }

       if(parseFloat(Qty) > parseFloat(AVQty)){


      document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);

       }else{

           if(parseFloat(Qty) < 0){
                   document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
           }else{


              if(parseFloat(LOWCOSTPRICE) == 0){



                     if(DEFAULTCOSTPRICE == 2){

                           if(parseFloat(Price)*parseFloat(Qty) < parseFloat(CostPrice)){

                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);

                         }else{



   if(LimitSalesQty == 1){

       if(maxSales >= Qty){

                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);


          }else{
 document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
      if(LANG == 'ar' ){
    alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
      }else{

    alert('You have exceeded the selling limit for this product');
      }

          }

   }else{
                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);

   }




                         }

                     }else{



                      if(parseFloat(Price) < parseFloat(CostPrice)){

                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);

                         }else{



   if(LimitSalesQty == 1){

       if(maxSales >= Qty){

                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);


          }else{
 document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
      if(LANG == 'ar' ){
    alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
      }else{

    alert('You have exceeded the selling limit for this product');
      }

          }

   }else{
                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);

   }




                         }

                     }

                     }else{


        if(LimitSalesQty == 1){

       if(maxSales >= Qty){

                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);


          }else{
 document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);
      if(LANG == 'ar' ){
    alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
      }else{

    alert('You have exceeded the selling limit for this product');
      }

          }

   }else{
                          document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);

   }


                     }


       }
       }

       var enough=0;
    $('input[name^="AllEnough"]').each(function() {


        enough +=$(this).val();

});


             if(parseFloat(enough) > 0){

               document.getElementById("Action").style.display = "none";
   document.getElementById("QTYAlert").style.display = "block";
        }else{
               document.getElementById("Action").style.display = "block";
   document.getElementById("QTYAlert").style.display = "none";

        }

                       var Total_PriceW =$('#Total_PriceW').val();

             if(enough == 0){

             if(Total_PriceW == 'NaN'){
                   document.getElementById("Action").style.display = "none";
                    }else{
        document.getElementById("Action").style.display = "block";
             }

       }else{

        document.getElementById("Action").style.display = "none";
       }




   }
</script>

<!-- Scanner  problem -->
<script>
   $(".form-control").keypress(function(event){
   if (event.which == '10' || event.which == '13') {
   event.preventDefault();
   }
   });
      $("#search").keypress(function(event){
   if (event.which == '10' || event.which == '13') {
   event.preventDefault();
   }
   });



</script>

<!-- Groups Filter -->
<script>
function GROUP(r){

    var store = $('#store').val();
     var client = $('#client').val();
     $.ajax({
      url:'GroupPosFilter',
      method:'GET',
      data:{
      group:r,
      store:store,
      client:client
      },
      dataType:'json',
      success:function(data)
      {

       $('.Group').html(data.table_data);

      }
     })

}

$(document).on('change', '#client', function(event){

    $('.Group').empty();

    });
</script>

<!-- Brands Filter -->
<script>
function BRAND(r){

    var store = $('#store').val();
     var client = $('#client').val();
     $.ajax({
      url:'BrandsPosFilter',
      method:'GET',
      data:{
      group:r,
      store:store,
      client:client
      },
      dataType:'json',
      success:function(data)
      {

       $('.Group').html(data.table_data);

      }
     })

}
</script>

<!-- Payment Method -->
<script>
function Pay(r){

    $('#Payment_Method').val(r);

    if(r == 'Later'){
       $('#paid').val('');
       }
    if(r == 'Visa'){
       $('#Visa2').val($('#Total_PriceW').val());
       }

}
</script>

<!-- Installment Total -->
<script>
 function Install(){

   var presenter =$('#presenter').val();
   var annual_interest =$('#annual_interest').val();
   var Years_Number =$('#Years_Number').val();
   var total =$('#total').val();


     var dif = parseFloat(total) - parseFloat(presenter) ;

     var Percent = parseFloat(annual_interest) / parseFloat(100) ;

     var Tp = parseFloat(dif) * parseFloat(Percent) ;

     var years = parseFloat(Tp) * parseFloat(Years_Number) ;

     var tot = parseFloat(dif) + parseFloat(years) ;

     var monthly = parseFloat(Years_Number) * parseFloat(12) ;

     var t = parseFloat(tot) / parseFloat(monthly) ;


            $('#monthly_installment').val(parseFloat(t));
            $('#monthly_installmentHide').val(parseFloat(t));
            $('#installment_Num').val(parseFloat(monthly));
            $('#installment_NumHide').val(parseFloat(monthly));

 }
</script>

<!-- Holding or Not -->
<script>
function Hol(r){

    $('#HOLD').val(r);

}
</script>

<!-- Submit Script -->
<script>

        function SPP(){
           $('#sp').val(1);
           var x= $('#sp').val();
          var client= $('#client').val();
          var Total_QtyHide= $('#Total_QtyHide').val();

       if(client == null){

              alert('تأكد من اختيار عميل');

       }else{

                      if(Total_QtyHide == ''){

              alert('يجب اختيار اصناف اولا');

              }else{
              if(x == 1){
             document.getElementById("SubmitY").style.display = "none";
      document.getElementById('form').submit();
        }
              }
       }
    }


       function SPS(){
           $('#sp').val(0);
           var x= $('#sp').val();
           var client= $('#client').val();
           var Total_QtyHide= $('#Total_QtyHide').val();
       if(client == null){

              alert('تأكد من اختيار عميل');

       }else{



           if(Total_QtyHide == ''){

              alert('يجب اختيار اصناف اولا');

              }else{
           if(x == 0){
              document.getElementById("SubmitY").style.display = "none";
   document.getElementById('form').submit();
        }
       }
       }
    }

      function SPP8(){
           $('#sp').val(2);
           var x= $('#sp').val();
               var Total_QtyHide= $('#Total_QtyHide').val();
         var client= $('#client').val();

            if(client == null){

              alert('تأكد من اختيار عميل');

       }else{

                      if(Total_QtyHide == ''){

              alert('يجب اختيار اصناف اولا');

              }else{
              if(x == 2){
             document.getElementById("SubmitY").style.display = "none";
      document.getElementById('form').submit();
        }
              }

       }
    }



</script>

<!-- Search Hold Bills -->
<script>
$(document).ready(function(){

    fetch_customer_data();

    function fetch_customer_data(searchHold = '')
    {
     $.ajax({
      url:'SalesHoldBillsPOSFilter',
      method:'GET',
      data:{searchHold:searchHold},
      dataType:'json',
      success:function(data)
      {

       $('.HOLDD').html(data.table_data);


      }
     })
    }

   $(document).on('keyup', '#searchHold', function(){
     var searchHold = $(this).val();
     fetch_customer_data(searchHold);
    });



    });
</script>

<!-- Press Enter Open Model  F2 Cash  F4 Later = Cash nd Visa  -  Delivery Example(fn + f1)-->
<script>



    document.onkeyup = KeyCheck;

function KeyCheck(e)
{
   var KeyID = (window.event) ? event.keyCode : e.keyCode;
   if(KeyID == 113)
   {
   $('#default-example-modal-center-payment').modal('show');
       Pay('Cash');

     $("#T1").removeClass("active");
     $("#T2").removeClass("active");
     $("#T3").removeClass("active");
     $("#T4").removeClass("active");
     $("#T5").removeClass("active");
     $("#T6").removeClass("active");
     $("#T7").removeClass("active");
     $("#T8").removeClass("active");
     $("#T9").removeClass("active");

     $("#tab_direction-1").removeClass("active show");
     $("#tab_direction-2").removeClass("active show");
     $("#tab_direction-3").removeClass("active show");
     $("#tab_direction-4").removeClass("active show");
     $("#tab_direction-5").removeClass("active show");
     $("#tab_direction-6").removeClass("active show");
     $("#tab_direction-7").removeClass("active show");
     $("#tab_direction-8").removeClass("active show");
     $("#tab_direction-9").removeClass("active show");

  $("#T1").addClass("active");
  $("#tab_direction-1").addClass("active show");

   }

     if(KeyID == 115)
   {
   $('#default-example-modal-center-payment').modal('show');
       Pay('Later');

            $("#T1").removeClass("active");
     $("#T2").removeClass("active");
     $("#T3").removeClass("active");
     $("#T4").removeClass("active");
     $("#T5").removeClass("active");
     $("#T6").removeClass("active");
     $("#T7").removeClass("active");
     $("#T8").removeClass("active");
        $("#T9").removeClass("active");

        $("#tab_direction-1").removeClass("active show");
     $("#tab_direction-2").removeClass("active show");
     $("#tab_direction-3").removeClass("active show");
     $("#tab_direction-4").removeClass("active show");
     $("#tab_direction-5").removeClass("active show");
     $("#tab_direction-6").removeClass("active show");
     $("#tab_direction-7").removeClass("active show");
     $("#tab_direction-8").removeClass("active show");
     $("#tab_direction-9").removeClass("active show");

  $("#T2").addClass("active");
  $("#tab_direction-2").addClass("active show");


   }


     if(KeyID == 187)
   {
   $('#default-example-modal-center-payment').modal('show');
       Pay('Cash_Visa');

            $("#T1").removeClass("active");
     $("#T2").removeClass("active");
     $("#T3").removeClass("active");
     $("#T4").removeClass("active");
     $("#T5").removeClass("active");
     $("#T6").removeClass("active");
     $("#T7").removeClass("active");
     $("#T8").removeClass("active");
     $("#T9").removeClass("active");

        $("#tab_direction-1").removeClass("active show");
     $("#tab_direction-2").removeClass("active show");
     $("#tab_direction-3").removeClass("active show");
     $("#tab_direction-4").removeClass("active show");
     $("#tab_direction-5").removeClass("active show");
     $("#tab_direction-6").removeClass("active show");
     $("#tab_direction-7").removeClass("active show");
     $("#tab_direction-8").removeClass("active show");
     $("#tab_direction-9").removeClass("active show");

  $("#T5").addClass("active");
  $("#tab_direction-5").addClass("active show");


   }

     if(KeyID == 189)
   {
   $('#default-example-modal-center-payment').modal('show');
       Pay('Delivery');

            $("#T1").removeClass("active");
     $("#T2").removeClass("active");
     $("#T3").removeClass("active");
     $("#T4").removeClass("active");
     $("#T5").removeClass("active");
     $("#T6").removeClass("active");
     $("#T7").removeClass("active");
     $("#T8").removeClass("active");
     $("#T9").removeClass("active");


        $("#tab_direction-1").removeClass("active show");
     $("#tab_direction-2").removeClass("active show");
     $("#tab_direction-3").removeClass("active show");
     $("#tab_direction-4").removeClass("active show");
     $("#tab_direction-5").removeClass("active show");
     $("#tab_direction-6").removeClass("active show");
     $("#tab_direction-7").removeClass("active show");
     $("#tab_direction-8").removeClass("active show");
     $("#tab_direction-9").removeClass("active show");

  $("#T7").addClass("active");
  $("#tab_direction-7").addClass("active show");


   }


}




        </script>

 <!-- Recipy Voucher Add Ajax -->
<script>
    $(document).ready(function(){

    fetch_customer_data();

    function fetch_customer_data(Creditor = '',AccountCode='',Shift='',Safe='',Coin='',Draw='',STORE='',STATEMENT='',Collector='')
    {
     $.ajax({
      url:'AddReciptVoucherAjax',
      method:'GET',
      data:{Creditor:Creditor,AccountCode:AccountCode,Shift:Shift,Safe:Safe,Coin:Coin,Draw:Draw,STORE:STORE,STATEMENT:STATEMENT,Collector:Collector},
      dataType:'json',
      success:function(data)
      {

           var LANG= $('#LANG').val();
  if(LANG == 'ar'){
                            alert('تم الاضافه بنجاح');
                       }else{
                           alert('Added Successfully');
                       }

          $('#Creditor').val('');
          $('#STATEMENT').val('');
$('#AccountCode').empty();

      }
     })
    }

   $(document).on('click', '#ReciptVoucher', function(){

     var Creditor = $('#Creditor').val();
     var AccountCode = $('#AccountCode').val();
     var Shift = $('#Shift_Code').val();
     var Safe = $('#Safe').val();
     var Coin = $('#Coin').val();
     var Draw = $('#Draw').val();
     var STORE = $('#STORE').val();
     var STATEMENT = $('#STATEMENT').val();
     var Collector = $('#Collector').val();

       if(Creditor != '' && AccountCode != ''){
        fetch_customer_data(Creditor,AccountCode,Shift,Safe,Coin,Draw,STORE,STATEMENT,Collector);
       }

    });




   });

     $(document).ready(function(){

    fetch_customer_data();

    function fetch_customer_data(Creditor = '',AccountCode='',Shift='',Safe='',Coin='',Draw='',STORE='',STATEMENT='',Collector='')
    {
     $.ajax({
      url:'AddReciptVoucherAjax',
      method:'GET',
      data:{Creditor:Creditor,AccountCode:AccountCode,Shift:Shift,Safe:Safe,Coin:Coin,Draw:Draw,STORE:STORE,STATEMENT:STATEMENT,Collector:Collector},
      dataType:'json',
      success:function(data)
      {

          alert('تم الاضافه بنجاح');
        $('#STATEMENTF').val('');
          $('#CreditorF').val('');
$('#AccountCodeF').empty();

      }
     })
    }

   $(document).on('click', '#ReciptVoucher', function(){

     var Creditor = $('#CreditorF').val();
     var AccountCode = $('#AccountCodeF').val();
     var Shift = $('#Shift_Code').val();
     var Safe = $('#SafeF').val();
     var Coin = $('#CoinF').val();
     var Draw = $('#DrawF').val();
     var STORE = $('#STOREF').val();
           var STATEMENT = $('#STATEMENTF').val();
           var Collector = $('#CollectorF').val();
       if(Creditor != '' && AccountCode != ''){
        fetch_customer_data(Creditor,AccountCode,Shift,Safe,Coin,Draw,STORE,STATEMENT,Collector);
       }

    });




   });
</script>

 <!-- Payment Voucher Add Ajax -->
<script>
    $(document).ready(function(){

    fetch_customer_data();

    function fetch_customer_data(Debitor = '',AccountCodee='',Shift='',Safe='',Coin='',Draw='',STORE='',STATEMENT='')
    {
     $.ajax({
      url:'AddPaymentVoucherAjax',
      method:'GET',
      data:{Debitor:Debitor,AccountCodee:AccountCodee,Shift:Shift,Safe:Safe,Coin:Coin,Draw:Draw,STORE:STORE,STATEMENT:STATEMENT},
      dataType:'json',
      success:function(data)
      {

        var LANG= $('#LANG').val();
  if(LANG == 'ar'){
                            alert('تم الاضافه بنجاح');
                       }else{
                           alert('Added Successfully');
                       }
      $('#STATEMENTP').val('');
          $('#Debitor').val('');
$('#AccountCodee').empty();

      }
     })
    }

   $(document).on('click', '#PaymentVoucher', function(){

     var Debitor = $('#Debitor').val();
     var AccountCodee = $('#AccountCodee').val();
     var Shift = $('#Shift_Code').val();
     var Safe = $('#SafeP').val();
     var Coin = $('#CoinP').val();
     var Draw = $('#DrawP').val();
     var STORE = $('#STOREP').val();
        var STATEMENT = $('#STATEMENTP').val();
       if(Debitor != '' && AccountCodee != ''){
        fetch_customer_data(Debitor,AccountCodee,Shift,Safe,Coin,Draw,STORE,STATEMENT);
       }

    });





   });

        $(document).ready(function(){

    fetch_customer_data();

    function fetch_customer_data(Debitor = '',AccountCodee='',Shift='',Safe='',Coin='',Draw='',STORE='',STATEMENT='')
    {
     $.ajax({
      url:'AddPaymentVoucherAjax',
      method:'GET',
      data:{Debitor:Debitor,AccountCodee:AccountCodee,Shift:Shift,Safe:Safe,Coin:Coin,Draw:Draw,STORE:STORE,STATEMENT:STATEMENT},
      dataType:'json',
      success:function(data)
      {

          alert('تم الاضافه بنجاح');
      $('#STATEMENTPr').val('');
          $('#Debitorr').val('');
$('#AccountCodeee').empty();

      }
     })
    }

   $(document).on('click', '#PaymentVoucherr', function(){

     var Debitor = $('#Debitorr').val();
     var AccountCodee = $('#AccountCodeee').val();
     var Shift = $('#Shift_Code').val();
     var Safe = $('#SafePr').val();
     var Coin = $('#CoinPr').val();
     var Draw = $('#DrawPr').val();
     var STORE = $('#STOREPr').val();
        var STATEMENT = $('#STATEMENTPr').val();
       if(Debitor != '' && AccountCodee != ''){
        fetch_customer_data(Debitor,AccountCodee,Shift,Safe,Coin,Draw,STORE,STATEMENT);
       }

    });





   });


     $(document).ready(function(){

    fetch_customer_data();

    function fetch_customer_data(Debitor = '',AccountCodee='',Shift='',Safe='',Coin='',Draw='',STORE='',STATEMENT='')
    {
     $.ajax({
      url:'AddPaymentVoucherAjax',
      method:'GET',
      data:{Debitor:Debitor,AccountCodee:AccountCodee,Shift:Shift,Safe:Safe,Coin:Coin,Draw:Draw,STORE:STORE,STATEMENT:STATEMENT},
      dataType:'json',
      success:function(data)
      {

          alert('تم الاضافه بنجاح');
      $('#STATEMENTPrP').val('');
          $('#Debitorrr').val('');
$('#AccountCodeeee').empty();

      }
     })
    }

   $(document).on('click', '#PaymentVoucherrr', function(){

     var Debitor = $('#Debitorrr').val();
     var AccountCodee = $('#AccountCodeeee').val();
     var Shift = $('#Shift_Code').val();
     var Safe = $('#SafePrP').val();
     var Coin = $('#CoinPrP').val();
     var Draw = $('#DrawPrP').val();
     var STORE = $('#STOREPrP').val();
        var STATEMENT = $('#STATEMENTPrP').val();
       if(Debitor != '' && AccountCodee != ''){
        fetch_customer_data(Debitor,AccountCodee,Shift,Safe,Coin,Draw,STORE,STATEMENT);
       }

    });





   });


</script>
<!-- Cash and Residual -->
<script>
function Dif(){

    var Total=$("#Total_PriceHide").val();
    var paid=$('#paid').val();

    var res=parseFloat(Total) - parseFloat(paid) ;

    if(parseFloat(res) > 0){
        $('#resdiual').val(res);
        $('#Total_DiscountHide').val(res);
    }else{
       $('#resdiual').val(0);
       $('#Total_DiscountHide').val(0);
    }


    $('#Res').val(Math.abs(res));



}

function Diff(){

    var Total=$("#Total_PriceHide").val();
    var paid=$('#CashhHold').val();

    var res=parseFloat(Total) - parseFloat(paid) ;
    $('#ResidualHold').val(res);


}
</script>

<!-- Unit Change and Select -->
        <script>
    function UniPro(Pro,r,co,st){
        $('#R').val(r);
        $('#ProR').val(Pro);
        $('#CodeR').val(co);
        $('#StoR').val(st);
          $.ajax({
                              url: 'UnitsOfProducts/'+Pro,
                              type:"GET",
                              dataType:"json",
                              beforeSend: function(){
                                  $('#loader').css("visibility", "visible");
                              },

                              success:function(data) {
                                          $('#ChUnit').empty();

                                          var LANG = $("#LANG").val();
   if(LANG == 'ar' ){
          $('#ChUnit').append('<option value="">اختر الوحده</option>');
          }else{
          $('#ChUnit').append('<option value=""> Choice Unit</option>');
          }




                                  $.each(data, function(key, value){

                         $('#ChUnit').append('<option value="'+ key +'">' + value + '</option>');


           var Qty = $("#QTTY"+r).val();
           var AVQty = $("#AVHide"+r).val();

                              var Product = $("#Product"+r).val();
             var UnitID = $("#UnitPurch"+r).val();
            $.ajax({
                             url: 'UnitSalesRateFilter',
                             type:"GET",
                            data:{
                              Product:Product,
                              UnitID:UnitID
                            },
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {


                     $('#UnitRato'+r).val(data.rate);


                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });






       if(parseFloat(Qty) > parseFloat(AVQty)){


      document.getElementById("QTTY"+r).style.border="1px solid darkred";
             $("#Enough"+r).val(1);

       }else{

     document.getElementById("QTTY"+r).style.border="none";
             $("#Enough"+r).val(0);

       }

       var enough=0;
    $('input[name^="AllEnough"]').each(function() {


        enough +=$(this).val();

});


             if(parseFloat(enough) > 0){

               document.getElementById("Action").style.display = "none";
   document.getElementById("QTYAlert").style.display = "block";
        }else{
               document.getElementById("Action").style.display = "block";
   document.getElementById("QTYAlert").style.display = "none";

        }




                                  });
                              },
                              complete: function(){
                                  $('#loader').css("visibility", "hidden");
                              }
                          });

    }

       function  UnitCodePurch(){

    var r=$('#R').val();
   var countryId = $('#ChUnit').val();
   var Pro = $('#ProR').val();
   var client = $('#client').val();
   var code = $('#CodeR').val();
   var Store = $('#StoR').val();
         var DEFAULTCOSTPRICE = $("#DEFAULTCOSTPRICE").val();
                     if(countryId) {
                         $.ajax({
                             url: 'UnitSalesFilter',
                             type:"GET",
                             data:{
                                 countryId:countryId,
                                 Pro:Pro,
                                 client:client,
                                 code:code,
                                 Store:Store
                             },
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {

                                   var V=$('#V'+r).val();

           if(V == ''){
                       $('#Coding'+r).text(data.code);
                                     $('#CodeR').val(data.code);
                                     $('#CodingHide').val(data.code);
           }
                       $('#un'+r).val(countryId);
                       $('#TextUni'+r).text(data.name);
                       $('#PRICE'+r).val(data.price);
                       $('#PCL'+r).val(data.price);
                       $('#AVVQ'+r).text(parseFloat(data.qty).toFixed(2));
                       $('#AVHide'+r).val(parseFloat(data.qty).toFixed(2));
                                 $("#costPric" + r).val(data.cost);

    var TaxRate = $("#RATE"+r).val();
   var TaxType = $("#TYPE"+r).val();
   var Qty = $("#QTTY"+r).val();
   var Price = $("#PRICE"+r).val();
   var Discount = $("#DISC"+r).val();
   var CostPrice = $("#costPric"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;
                                 var DEFAULTCOSTPRICE = $("#DEFAULTCOSTPRICE").val();



                                 if(DEFAULTCOSTPRICE == 2){

                                     $.ajax({
                                         url: 'NewCostProductFilter',
                                         type:"GET",
                                         data:{
                                             store:StorePurch,
                                             pro_code:Barcode,
                                             Product:Product,
                                             Qty:Qty,
                                             UnitID:UnitID
                                         },
                                         dataType:"json",
                                         beforeSend: function(){
                                             $('#loader').css("visibility", "visible");
                                         },

                                         success:function(data) {


                                             $("#costPric"+r).val(data.total_cost);

                                         },
                                         complete: function(){
                                             $('#loader').css("visibility", "hidden");
                                         }
                                     });


                                 }

                                 var TotCostNew=parseFloat(Qty) * parseFloat(CostPrice) ;

                                 $("#TotCostNew"+r).val(parseFloat(TotCostNew).toFixed(2));



                                 var Product = $("#Product"+r).val();
             var UnitID = $("#UnitPurch"+r).val();
            $.ajax({
                             url: 'UnitSalesRateFilter',
                             type:"GET",
                            data:{
                              Product:Product,
                              UnitID:UnitID
                            },
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {


                         $('#UnitRato'+r).val(data.rate);


                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });




         var HighDisc = $("#HighDisc"+r).val();
       var DIS = $("#DIS").val();

       if(parseFloat(DIS) == 0){

           Discount=$("#DISC"+r).val();

       }else{

           var d= Discount / 100 ;
           var Multi= parseFloat(Qty) * parseFloat(Price) ;
          var dd= Multi * d;

        Discount=  dd;
       }


           var BFG =  parseFloat(Qty) * parseFloat(Discount) ;
             $("#TDiscProEdit"+r).val(parseFloat(BFG));

       if(TaxType == 1){
           //Precent

      var BF =  parseFloat(Qty) *  (parseFloat(Price) );

       $("#TBFTax"+r).val(parseFloat(BF));

       i =    parseFloat(TaxRate)  / 100 ;

        ii=  parseFloat(BF) * parseFloat(i) ;

           $("#TTax"+r).val(parseFloat(ii));

       iii =  parseFloat(BF) + parseFloat(ii) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));

       }else if(TaxType == 2){
          //Number
         var BF =  parseFloat(Qty) *  (parseFloat(Price) );
         $("#TBFTax"+r).val(parseFloat(BF));

            i =    parseFloat(TaxRate)   ;

           $("#TTax"+r).val(parseFloat(i));

       iii =  parseFloat(BF) + parseFloat(i) ;

           $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
           $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));


       }

                                        var Total = $("#TOTT"+r).val();
       var RFF= parseFloat(Qty) * parseFloat(Price);
       var RFFResult= parseFloat(RFF) - parseFloat(Total);
         $("#disssccoount"+r).val(parseFloat(RFFResult));


                                 $.fn.rowCount = function() {
                                     return $('tr', $(this).find('tbody')).length;
                                 };

                                 var rowctr = $('#dt').rowCount();

                                 var sumQ = 0;
                                 $('.Qun').each(function(){
                                     sumQ += parseFloat($(this).val());
                                 });

                                 var sumT = 0;
                                 $('.Tot').each(function(){
                                     sumT += parseFloat($(this).val());
                                 });

                                 var sumD = 0;
                                 $('.Disc').each(function(){
                                     sumD += parseFloat($(this).val());
                                 });


                                 var sumBF = 0;
                                 $('.TotalBFTax').each(function(){
                                     sumBF += parseFloat($(this).val());
                                 });

                                 var sumTax = 0;
                                 $('.TotalTax').each(function(){
                                     sumTax += parseFloat($(this).val());
                                 });

                                 var prec = 0;
                                 $('.DiscoPrecent').each(function(){
                                     prec += parseFloat($(this).val());
                                 });



                                 var sumTTD = 0;
                                 $('.TDISCOOO').each(function(){
                                     sumTTD += parseFloat($(this).val());
                                 });

                                 var COPRI = 0;
                                 $('.COSTPRICES').each(function(){
                                     COPRI += parseFloat($(this).val());
                                 });

                                 var COWeight = 0;
                                 $('.W').each(function(){
                                     COWeight += parseFloat($(this).val());
                                 });



                                 $('#Total_Wight_Bill').val(parseFloat(COWeight));
                                 $('#Product_Numbers').val(parseFloat(rowctr));
                                 $('#Product_NumbersHide').val(parseFloat(rowctr));

                                 $('#Total_Qty').val(parseFloat(sumQ));
                                 $('#Total_QtyHide').val(parseFloat(sumQ));

                                 var TootPriice = parseFloat(sumT) - parseFloat(sumTax);
                                 $('#Total_Price').val(parseFloat(TootPriice).toFixed(2));
                                 $('#Total_PriceHide').val(parseFloat(TootPriice).toFixed(2));


                                 var NEEET = 0;
                                 $('.net').each(function() {
                                     NEEET += parseFloat($(this).val());
                                 });


                                 var PROFIIIT = parseFloat(NEEET) - parseFloat(COPRI);
                                 $('#ProfitPrecent').val(parseFloat(PROFIIIT).toFixed(2));

                                 var nfd = (parseFloat(PROFIIIT) * 100) / parseFloat(COPRI);
                                 $('#proPrecent').val(parseFloat(nfd).toFixed(2));


                                 $('#Total_DiscountTT').val(parseFloat(sumTTD).toFixed(2));
                                 $('#Total_DiscountHideTT').val(parseFloat(sumTTD).toFixed(2));

                                 $('#Total_Discount').val(parseFloat(sumD).toFixed(2));
                                 $('#Total_DiscountHide').val(parseFloat(sumD).toFixed(2));


                                 var BEFO = parseFloat(sumBF) ;

                                 $('#Total_Bf_Taxes').val(parseFloat(BEFO).toFixed(2));
                                 $('#Total_Bf_TaxesHide').val(parseFloat(BEFO).toFixed(2));

                                 $('#Total_Taxes').val(parseFloat(sumTax).toFixed(2));
                                 $('#Total_TaxesHide').val(parseFloat(sumTax).toFixed(2));

                                 $('#Total_After_Taxes').val(parseFloat(sumTax) + parseFloat(TootPriice));
                                 $('#TotalCost').val(parseFloat(COPRI).toFixed(2));

                                 var RRR = parseFloat(sumTax) + parseFloat(TootPriice) - parseFloat(sumTTD);
                                 $('#TAFterD').val(parseFloat(RRR).toFixed(2));
                                 $('#Total_Bill').val(parseFloat(RRR).toFixed(2));
                                 $('#Total_PriceW').val(parseFloat(RRR).toFixed(2));

                                 var resdiual = $('#resdiual').val();
                                 var total = $('#Total_PriceHide').val();
                                 var totalDisc = $('#Total_DiscountHideTT').val();

                                 var totalTax = $('#Total_TaxesHide').val();


                                 var RR = (parseFloat(total) + parseFloat(totalTax)) - (parseFloat(resdiual) + parseFloat(totalDisc));
                                 var RRR = parseFloat(total) - (parseFloat(resdiual) + parseFloat(totalDisc));

                                 $('#paid').val(parseFloat(RR).toFixed(2));

                                 $('#presenter').val(parseFloat(RR).toFixed(2));
                                 $('#total').val(parseFloat(sumT).toFixed(2));



                                 $('#ProNums').text(parseFloat(rowctr));
                                 $('#ProQty').text(parseFloat(sumQ).toFixed(2));
                                 $('#TotalPrice').text(parseFloat(TootPriice));
                                 $('#Total_DiscountTTShow').text(parseFloat(sumTTD).toFixed(2));
                                 $('#Total_TaxesShow').text(parseFloat(sumTax));






                                 var TaxRate = $("#RATE"+r).val();
                                 var TaxType = $("#TYPE"+r).val();
                                 var Qty = $("#QTTY"+r).val();
                                 var AVQty = $("#AVHide"+r).val();
                                 var Price = $("#PRICE"+r).val();
                                 var Discount = $("#DISC"+r).val();
                                 var CostPrice = $("#costPric"+r).val();
                                 var LOWCOSTPRICE = $("#LOWCOSTPRICE").val();
                                 var DEFAULTCOSTPRICE = $("#DEFAULTCOSTPRICE").val();
                                 var weight = $("#weightT"+r).val();
                                 var RATOO = $("#UnitRate"+r).val();
                                 var maxSales = $("#maxSa"+r).val();
                                 var LimitSalesQty = $("#LimitSalesQty").val();
                                 var LANG = $("#LANG").val();
                                 if(parseFloat(Qty) > parseFloat(AVQty)){


                                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                     $("#Enough"+r).val(1);

                                 }else{

                                     if(parseFloat(Qty) < 0){
                                         document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                         $("#Enough"+r).val(1);
                                     }else{


                                         if(parseFloat(LOWCOSTPRICE) == 0){

                                             if(DEFAULTCOSTPRICE == 2){


                                                 if(parseFloat(Price)*parseFloat(Qty) < parseFloat(CostPrice)){

                                                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                                     $("#Enough"+r).val(1);

                                                 }else{



                                                     if(LimitSalesQty == 1){

                                                         if(maxSales >= Qty){

                                                             document.getElementById("QTTY"+r).style.border="none";
                                                             $("#Enough"+r).val(0);


                                                         }else{
                                                             document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                                             $("#Enough"+r).val(1);
                                                             if(LANG == 'ar' ){
                                                                 alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
                                                             }else{

                                                                 alert('You have exceeded the selling limit for this product');
                                                             }

                                                         }

                                                     }else{
                                                         document.getElementById("QTTY"+r).style.border="none";
                                                         $("#Enough"+r).val(0);

                                                     }




                                                 }

                                             }else{

                                                 if(parseFloat(Price) < parseFloat(CostPrice)){

                                                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                                     $("#Enough"+r).val(1);

                                                 }else{



                                                     if(LimitSalesQty == 1){

                                                         if(maxSales >= Qty){

                                                             document.getElementById("QTTY"+r).style.border="none";
                                                             $("#Enough"+r).val(0);


                                                         }else{
                                                             document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                                             $("#Enough"+r).val(1);
                                                             if(LANG == 'ar' ){
                                                                 alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
                                                             }else{

                                                                 alert('You have exceeded the selling limit for this product');
                                                             }

                                                         }

                                                     }else{
                                                         document.getElementById("QTTY"+r).style.border="none";
                                                         $("#Enough"+r).val(0);

                                                     }




                                                 }

                                             }



                                         }else{


                                             if(LimitSalesQty == 1){

                                                 if(maxSales >= Qty){

                                                     document.getElementById("QTTY"+r).style.border="none";
                                                     $("#Enough"+r).val(0);


                                                 }else{
                                                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                                     $("#Enough"+r).val(1);
                                                     if(LANG == 'ar' ){
                                                         alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
                                                     }else{

                                                         alert('You have exceeded the selling limit for this product');
                                                     }

                                                 }

                                             }else{
                                                 document.getElementById("QTTY"+r).style.border="none";
                                                 $("#Enough"+r).val(0);

                                             }


                                         }


                                     }
                                 }

                                 var enough=0;
                                 $('input[name^="AllEnough"]').each(function() {


                                     enough +=$(this).val();

                                 });


                                 if(parseFloat(enough) > 0){

                                     document.getElementById("Action").style.display = "none";
                                     document.getElementById("QTYAlert").style.display = "block";
                                 }else{
                                     document.getElementById("Action").style.display = "block";
                                     document.getElementById("QTYAlert").style.display = "none";

                                 }

                                 var Total_PriceW =$('#Total_PriceW').val();

                                 if(enough == 0){

                                     if(Total_PriceW == 'NaN'){
                                         document.getElementById("Action").style.display = "none";
                                     }else{
                                         document.getElementById("Action").style.display = "block";
                                     }

                                 }else{

                                     document.getElementById("Action").style.display = "none";
                                 }



                                 var TWeight=parseFloat(Qty) * (parseFloat(weight) * parseFloat(RATOO)) ;

                                 $("#Total_Wight"+r).val(parseFloat(TWeight));


                                 var COWeight = 0;
                                 $('.W').each(function(){
                                     COWeight += parseFloat($(this).val());
                                 });

                                 $('#Total_Wight_Bill').val(parseFloat(COWeight));




                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });
                     } else {

                         $('select[name="state"]').empty();
                     }




   }
        </script>

    <!-- All Prods Filter -->
<script>
function AllProductsPOS(){

    var store = $('#store').val();
     var client = $('#client').val();
     $.ajax({
      url:'AllProsPosFilter',
      method:'GET',
      data:{
      store:store,
      client:client
      },
      dataType:'json',
      success:function(data)
      {

       $('.Group').html(data.table_data);

      }
     })

}
</script>

      <!-- Other Stores Qty -->
<script>
    function OtherQTY(Product,Barcode){
  $.ajax({
      url:'POSOtherQtyFilter',
      method:'GET',
      data:{Product:Product,Barcode:Barcode},
      dataType:'json',
      success:function(data)
      {

       $('.QTYOTHERSTORES').html(data.table_data);

      }
     })
    }

</script>


<!-- Filter Governrate and City !-->
<script>
   $(document).ready(function() {

       $('#Governrate').on('change', function(){
           var countryId = $(this).val();
           if(countryId) {
               $.ajax({
                   url: 'GovernrateFilter/'+countryId,
                   type:"GET",
                   dataType:"json",
                   beforeSend: function(){
                       $('#loader').css("visibility", "visible");
                   },

                   success:function(data) {

                       $('#City').empty();

                       $.each(data, function(key, value){

             $('#City').append('<option value="'+ key +'">' + value + '</option>');

                       });

                      var CIITY = $('#City').val();
                         $.ajax({
                   url: 'CityFilter/'+CIITY,
                   type:"GET",
                   dataType:"json",
                   beforeSend: function(){
                       $('#loader').css("visibility", "visible");
                   },

                   success:function(data) {

                       $('#Place').empty();

                       $.each(data, function(key, value){

             $('#Place').append('<option value="'+ key +'">' + value + '</option>');

                       });


                   },
                   complete: function(){
                       $('#loader').css("visibility", "hidden");
                   }
               });



                   },
                   complete: function(){
                       $('#loader').css("visibility", "hidden");
                   }
               });
           } else {

               $('select[name="states"]').empty();
           }

       });

   });

   $(document).ready(function() {


           var countryId = $('#Governrate').val();
           if(countryId) {
               $.ajax({
                   url: 'GovernrateFilter/'+countryId,
                   type:"GET",
                   dataType:"json",
                   beforeSend: function(){
                       $('#loader').css("visibility", "visible");
                   },

                   success:function(data) {

                       $('#City').empty();

                       $.each(data, function(key, value){

             $('#City').append('<option value="'+ key +'">' + value + '</option>');

                       });

                     var CIITY = $('#City').val();
                         $.ajax({
                   url: 'CityFilter/'+CIITY,
                   type:"GET",
                   dataType:"json",
                   beforeSend: function(){
                       $('#loader').css("visibility", "visible");
                   },

                   success:function(data) {

                       $('#Place').empty();

                       $.each(data, function(key, value){

             $('#Place').append('<option value="'+ key +'">' + value + '</option>');

                       });


                   },
                   complete: function(){
                       $('#loader').css("visibility", "hidden");
                   }
               });




                   },
                   complete: function(){
                       $('#loader').css("visibility", "hidden");
                   }
               });
           } else {

               $('select[name="states"]').empty();
           }


   });


 $('#City').on('change', function(){
      var CIITY = $('#City').val();
                         $.ajax({
                   url: 'CityFilter/'+CIITY,
                   type:"GET",
                   dataType:"json",
                   beforeSend: function(){
                       $('#loader').css("visibility", "visible");
                   },

                   success:function(data) {

                       $('#Place').empty();

                       $.each(data, function(key, value){

             $('#Place').append('<option value="'+ key +'">' + value + '</option>');

                       });


                   },
                   complete: function(){
                       $('#loader').css("visibility", "hidden");
                   }
               });


 });

</script>

<script>

    $(document).ready(function() {


               $('#tab_direction-2').removeClass('active show');
                        $('#T2').removeClass('active');

          $('#tab_direction-3').removeClass('active show');
                        $('#T3').removeClass('active');

          $('#tab_direction-4').removeClass('active show');
                        $('#T4').removeClass('active');

          $('#tab_direction-5').removeClass('active show');
                        $('#T5').removeClass('active');

          $('#tab_direction-6').removeClass('active show');
                        $('#T6').removeClass('active');


                        $('#T7').removeClass('active');
        $('#tab_direction-7').removeClass('active show');

                            $('#T8').removeClass('active');
        $('#tab_direction-8').removeClass('active show');

        $('#T9').removeClass('active');
        $('#tab_direction-9').removeClass('active show');


                        $('#T1').addClass('active');
          $('#tab_direction-1').addClass('active show');




    });


</script>


<!-- Change Tax -->
<script>
     function  TaxPro(Pro,r){
         $('#RX').val(r);
         $('#ProRX').val(Pro);
     }

     function  TAXPurch(){
 var r=$('#RX').val();
            var DEFAULTCOSTPRICE = $("#DEFAULTCOSTPRICE").val();
   var countryId = $('#OLDTAX').val();

                     if(countryId) {
                         $.ajax({
                             url: 'TaxNamePurchasesFilter/'+countryId,
                             type:"GET",
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {


                       $('#RATE'+r).val(data.rate);
                       $('#TYPE'+r).val(data.type);
                       $('#PurchTaxx'+r).val(data.tax);


     var TaxRate = $("#RATE"+r).val();
   var TaxType = $("#TYPE"+r).val();
   var Qty = $("#QTTY"+r).val();
   var Price = $("#PRICE"+r).val();
   var Discount = $("#DISC"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;

                                 var DEFAULTCOSTPRICE = $("#DEFAULTCOSTPRICE").val();
                                 var CostPrice = $("#costPric"+r).val();


                                 if(DEFAULTCOSTPRICE == 2){

                                     $.ajax({
                                         url: 'NewCostProductFilter',
                                         type:"GET",
                                         data:{
                                             store:StorePurch,
                                             pro_code:Barcode,
                                             Product:Product,
                                             Qty:Qty,
                                             UnitID:UnitID
                                         },
                                         dataType:"json",
                                         beforeSend: function(){
                                             $('#loader').css("visibility", "visible");
                                         },

                                         success:function(data) {


                                             $("#costPric"+r).val(data.total_cost);

                                         },
                                         complete: function(){
                                             $('#loader').css("visibility", "hidden");
                                         }
                                     });


                                 }

                                 var TotCostNew=parseFloat(Qty) * parseFloat(CostPrice) ;

                                 $("#TotCostNew"+r).val(parseFloat(TotCostNew).toFixed(2));



                                 var Product = $("#Product"+r).val();
             var UnitID = $("#UnitPurch"+r).val();
            $.ajax({
                             url: 'UnitSalesRateFilter',
                             type:"GET",
                            data:{
                              Product:Product,
                              UnitID:UnitID
                            },
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {


                     $('#UnitRato'+r).val(data.rate);


                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });

         var HighDisc = $("#HighDisc"+r).val();

                                 var TaxRate = $("#RATE"+r).val();
                                 var TaxType = $("#TYPE"+r).val();
                                 var Qty = $("#QTTY"+r).val();
                                 var AVQty = $("#AVHide"+r).val();
                                 var Price = $("#PRICE"+r).val();
                                 var Discount = $("#DISC"+r).val();
                                 var CostPrice = $("#costPric"+r).val();
                                 var StorePurch = $("#STORETABLE"+r).val();
                                 var Barcode = $("#CodingHide"+r).val();
                                 var Product = $("#PRO"+r).val();
                                 var UnitID = $("#un"+r).val();


                                 var LOWCOSTPRICE = $("#LOWCOSTPRICE").val();

                                 var weight = $("#weightT"+r).val();
                                 var RATOO = $("#UnitRate"+r).val();
                                 var maxSales = $("#maxSa"+r).val();
                                 var LimitSalesQty = $("#LimitSalesQty").val();
                                 var LANG = $("#LANG").val();
                                 var DEFAULTCOSTPRICE = $("#DEFAULTCOSTPRICE").val();

                                 var i = 0;
                                 var ii=0;
                                 var iii=0;


                                 var TWeight=parseFloat(Qty) * (parseFloat(weight) * parseFloat(RATOO)) ;




                                 if(DEFAULTCOSTPRICE == 2){

                                     $.ajax({
                                         url: 'NewCostProductFilter',
                                         type:"GET",
                                         data:{
                                             store:StorePurch,
                                             pro_code:Barcode,
                                             Product:Product,
                                             Qty:Qty,
                                             UnitID:UnitID
                                         },
                                         dataType:"json",
                                         beforeSend: function(){
                                             $('#loader').css("visibility", "visible");
                                         },

                                         success:function(data) {


                                             $("#costPric"+r).val(data.total_cost);

                                         },
                                         complete: function(){
                                             $('#loader').css("visibility", "hidden");
                                         }
                                     });


                                 }





                                 $("#Total_Wight"+r).val(parseFloat(TWeight));



                                 var HighDisc = $("#HighDisc"+r).val();
                                 var DIS = $("#DIS").val();

                                 if(parseFloat(DIS) == 0){

                                     Discount=$("#DISC"+r).val();
                                 }else{

                                     var d= Discount / 100 ;
                                     var Multi= parseFloat(Qty) * parseFloat(Price) ;
                                     var dd= Multi * d;

                                     Discount=  dd;
                                 }

                                 var BFG =  parseFloat(Qty) * parseFloat(Discount) ;
                                 $("#TDiscProEdit"+r).val(parseFloat(BFG));

                                 if(TaxType == 1){
                                     //Precent

                                     var BF =  parseFloat(Qty) *  (parseFloat(Price));

                                     $("#TBFTax"+r).val(parseFloat(BF));

                                     i =    parseFloat(TaxRate)  / 100 ;

                                     ii=  parseFloat(BF) * parseFloat(i) ;

                                     $("#TTax"+r).val(parseFloat(ii));

                                     iii =  parseFloat(BF) + parseFloat(ii) ;

                                     $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
                                     $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));

                                 }else if(TaxType == 2){
                                     //Number
                                     var BF =  parseFloat(Qty) *  (parseFloat(Price) );
                                     $("#TBFTax"+r).val(parseFloat(BF));

                                     i =    parseFloat(TaxRate)   ;

                                     $("#TTax"+r).val(parseFloat(i));

                                     iii =  parseFloat(BF) + parseFloat(i) ;

                                     $("#TOTT"+r).val(parseFloat(iii).toFixed(2));
                                     $("#TOTTNo"+r).val(parseFloat(iii).toFixed(2));


                                 }



                                 var Total = $("#TOTT"+r).val();
                                 var RFF= parseFloat(Qty) * parseFloat(Price);
                                 var RFFResult= parseFloat(RFF) - parseFloat(Total);
                                 $("#disssccoount"+r).val(parseFloat(RFFResult));



                                 var Total =$("#TOTT" + r).val();
                                 var TotalTax =$("#TTax" + r).val();
                                 var Net=(parseFloat(Total) ) - (parseFloat(Discount) * parseFloat(Qty));
                                 $("#NetD" + r).val(parseFloat(Net).toFixed(2));

                                 if(parseFloat(Net) > 0) {
                                     var TotCostNew = parseFloat(Qty) * parseFloat(CostPrice);
                                     $("#TotCostNew" + r).val(parseFloat(TotCostNew).toFixed(2));
                                 }else{
                                     var TotCostNew = 0;
                                     $("#TotCostNew" + r).val(parseFloat(TotCostNew).toFixed(2));
                                 }



                                 $.fn.rowCount = function() {
                                     return $('tr', $(this).find('tbody')).length;
                                 };

                                 var rowctr = $('#dt').rowCount();

                                 var sumQ = 0;
                                 $('.Qun').each(function(){
                                     sumQ += parseFloat($(this).val());
                                 });

                                 var sumT = 0;
                                 $('.Tot').each(function(){
                                     sumT += parseFloat($(this).val());
                                 });

                                 var sumD = 0;
                                 $('.Disc').each(function(){
                                     sumD += parseFloat($(this).val());
                                 });


                                 var sumBF = 0;
                                 $('.TotalBFTax').each(function(){
                                     sumBF += parseFloat($(this).val());
                                 });

                                 var sumTax = 0;
                                 $('.TotalTax').each(function(){
                                     sumTax += parseFloat($(this).val());
                                 });

                                 var prec = 0;
                                 $('.DiscoPrecent').each(function(){
                                     prec += parseFloat($(this).val());
                                 });

                                 var sumTTD = 0;
                                 $('.TDISCOOO').each(function(){
                                     sumTTD += parseFloat($(this).val());
                                 });

                                 var COPRI = 0;
                                 $('.COSTPRICES').each(function(){
                                     COPRI += parseFloat($(this).val());
                                 });

                                 var COWeight = 0;
                                 $('.W').each(function(){
                                     COWeight += parseFloat($(this).val());
                                 });

                                 $('#Total_Wight_Bill').val(parseFloat(COWeight));

                                 $('#Total_Wight_Bill').val(parseFloat(COWeight));
                                 $('#Product_Numbers').val(parseFloat(rowctr));
                                 $('#Product_NumbersHide').val(parseFloat(rowctr));

                                 $('#Total_Qty').val(parseFloat(sumQ));
                                 $('#Total_QtyHide').val(parseFloat(sumQ));

                                 var TootPriice = parseFloat(sumT) - parseFloat(sumTax);
                                 $('#Total_Price').val(parseFloat(TootPriice).toFixed(2));
                                 $('#Total_PriceHide').val(parseFloat(TootPriice).toFixed(2));


                                 var NEEET = 0;
                                 $('.net').each(function() {
                                     NEEET += parseFloat($(this).val());
                                 });


                                 var PROFIIIT = parseFloat(NEEET) - parseFloat(COPRI);
                                 $('#ProfitPrecent').val(parseFloat(PROFIIIT).toFixed(2));

                                 var nfd = (parseFloat(PROFIIIT) * 100) / parseFloat(COPRI);
                                 $('#proPrecent').val(parseFloat(nfd).toFixed(2));


                                 $('#Total_DiscountTT').val(parseFloat(sumTTD).toFixed(2));
                                 $('#Total_DiscountHideTT').val(parseFloat(sumTTD).toFixed(2));

                                 $('#Total_Discount').val(parseFloat(sumD).toFixed(2));
                                 $('#Total_DiscountHide').val(parseFloat(sumD).toFixed(2));


                                 var BEFO = parseFloat(sumBF) ;

                                 $('#Total_Bf_Taxes').val(parseFloat(BEFO).toFixed(2));
                                 $('#Total_Bf_TaxesHide').val(parseFloat(BEFO).toFixed(2));

                                 $('#Total_Taxes').val(parseFloat(sumTax).toFixed(2));
                                 $('#Total_TaxesHide').val(parseFloat(sumTax).toFixed(2));

                                 $('#Total_After_Taxes').val(parseFloat(sumTax) + parseFloat(TootPriice));
                                 $('#TotalCost').val(parseFloat(COPRI).toFixed(2));

                                 var RRR = parseFloat(sumTax) + parseFloat(TootPriice) - parseFloat(sumTTD);
                                 $('#TAFterD').val(parseFloat(RRR).toFixed(2));
                                 $('#Total_Bill').val(parseFloat(RRR).toFixed(2));
                                 $('#Total_PriceW').val(parseFloat(RRR).toFixed(2));

                                 var resdiual = $('#resdiual').val();
                                 var total = $('#Total_PriceHide').val();
                                 var totalDisc = $('#Total_DiscountHideTT').val();

                                 var totalTax = $('#Total_TaxesHide').val();


                                 var RR = (parseFloat(total) + parseFloat(totalTax)) - (parseFloat(resdiual) + parseFloat(totalDisc));
                                 var RRR = parseFloat(total) - (parseFloat(resdiual) + parseFloat(totalDisc));

                                 $('#paid').val(parseFloat(RR).toFixed(2));

                                 $('#presenter').val(parseFloat(RR).toFixed(2));
                                 $('#total').val(parseFloat(sumT).toFixed(2));



                                 $('#ProNums').text(parseFloat(rowctr));
                                 $('#ProQty').text(parseFloat(sumQ).toFixed(2));
                                 $('#TotalPrice').text(parseFloat(TootPriice));
                                 $('#Total_DiscountTTShow').text(parseFloat(sumTTD).toFixed(2));
                                 $('#Total_TaxesShow').text(parseFloat(sumTax));



                                 if(HighDisc != 0){


                                     if(parseFloat(Discount)  >  parseFloat(HighDisc)){
                                         document.getElementById("Action").style.display = "none";
                                         document.getElementById("ActionAlert").style.display = "block";
                                     }else{
                                         document.getElementById("Action").style.display = "block";
                                         document.getElementById("ActionAlert").style.display = "none";

                                     }


                                 }

                                 if(parseFloat(Qty) > parseFloat(AVQty)){


                                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                     $("#Enough"+r).val(1);

                                 }else{

                                     if(parseFloat(Qty) < 0){
                                         document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                         $("#Enough"+r).val(1);
                                     }else{


                                         if(parseFloat(LOWCOSTPRICE) == 0){



                                             if(DEFAULTCOSTPRICE == 2){

                                                 if(parseFloat(Price)*parseFloat(Qty) < parseFloat(CostPrice)){

                                                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                                     $("#Enough"+r).val(1);

                                                 }else{



                                                     if(LimitSalesQty == 1){

                                                         if(maxSales >= Qty){

                                                             document.getElementById("QTTY"+r).style.border="none";
                                                             $("#Enough"+r).val(0);


                                                         }else{
                                                             document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                                             $("#Enough"+r).val(1);
                                                             if(LANG == 'ar' ){
                                                                 alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
                                                             }else{

                                                                 alert('You have exceeded the selling limit for this product');
                                                             }

                                                         }

                                                     }else{
                                                         document.getElementById("QTTY"+r).style.border="none";
                                                         $("#Enough"+r).val(0);

                                                     }




                                                 }

                                             }else{



                                                 if(parseFloat(Price) < parseFloat(CostPrice)){

                                                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                                     $("#Enough"+r).val(1);

                                                 }else{



                                                     if(LimitSalesQty == 1){

                                                         if(maxSales >= Qty){

                                                             document.getElementById("QTTY"+r).style.border="none";
                                                             $("#Enough"+r).val(0);


                                                         }else{
                                                             document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                                             $("#Enough"+r).val(1);
                                                             if(LANG == 'ar' ){
                                                                 alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
                                                             }else{

                                                                 alert('You have exceeded the selling limit for this product');
                                                             }

                                                         }

                                                     }else{
                                                         document.getElementById("QTTY"+r).style.border="none";
                                                         $("#Enough"+r).val(0);

                                                     }




                                                 }

                                             }

                                         }else{


                                             if(LimitSalesQty == 1){

                                                 if(maxSales >= Qty){

                                                     document.getElementById("QTTY"+r).style.border="none";
                                                     $("#Enough"+r).val(0);


                                                 }else{
                                                     document.getElementById("QTTY"+r).style.border="1px solid darkred";
                                                     $("#Enough"+r).val(1);
                                                     if(LANG == 'ar' ){
                                                         alert('تجاوزت الحد المسموح  لبيع كمية هذا المنتج');
                                                     }else{

                                                         alert('You have exceeded the selling limit for this product');
                                                     }

                                                 }

                                             }else{
                                                 document.getElementById("QTTY"+r).style.border="none";
                                                 $("#Enough"+r).val(0);

                                             }


                                         }


                                     }
                                 }

                                 var enough=0;
                                 $('input[name^="AllEnough"]').each(function() {


                                     enough +=$(this).val();

                                 });


                                 if(parseFloat(enough) > 0){

                                     document.getElementById("Action").style.display = "none";
                                     document.getElementById("QTYAlert").style.display = "block";
                                 }else{
                                     document.getElementById("Action").style.display = "block";
                                     document.getElementById("QTYAlert").style.display = "none";

                                 }

                                 var Total_PriceW =$('#Total_PriceW').val();

                                 if(enough == 0){

                                     if(Total_PriceW == 'NaN'){
                                         document.getElementById("Action").style.display = "none";
                                     }else{
                                         document.getElementById("Action").style.display = "block";
                                     }

                                 }else{

                                     document.getElementById("Action").style.display = "none";
                                 }



                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });
                     } else {

                         $('select[name="state"]').empty();
                     }

   }
    function PayInstall(){

           var Pay= $('#paid').val();

          $('#presenter').val(parseFloat(Pay).toFixed(2));

    }
</script>

<!-- Status -->
<script>
    function Statuss(){
        var Pay =$('#Payment_Method').val();
        var Stat =$('#Status').val();
        var paid =$('#paid').val();
        var resdiual =$('#resdiual').val();
        var total =$('#Total_PriceHide').val();
        var totalDisc =$('#Total_DiscountHideTT').val();

          var totalTax =$('#Total_TaxesHide').val();


         var RR= (parseFloat(total) + parseFloat(totalTax) ) - (parseFloat(resdiual) + parseFloat(totalDisc));
             var RRR= parseFloat(total) - (parseFloat(resdiual) + parseFloat(totalDisc));
          $('#TAFterD').val(parseFloat(RRR).toFixed(2));
         $('#paid').val(parseFloat(RR).toFixed(2));
   $('#Total_PriceW').val(parseFloat(RR));
         $('#presenter').val(parseFloat(RR).toFixed(2));
         $('#total').val(parseFloat(RR).toFixed(2));
        $('#Visa2').val($('#Total_PriceW').val());
  $.fn.rowCount = function() {
     return $('tr', $(this).find('tbody')).length;
   };

   var rowctr = $('#dt').rowCount();

   if(Pay == 'Later'  ||  Pay == 'Installment'  &&  Stat == 0 ){

             if(paid == 0 || paid < 0){
        document.getElementById("Submit").style.display = "none";
             }else{

           if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{


           if(paid != 0  ||  paid == ''){

                document.getElementById("Submit").style.display = "block";
           }else{

                     document.getElementById("Submit").style.display = "none";
           }


       }



             }

       }else{

       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

            if(paid != 0  ||  paid == ''){

                document.getElementById("Submit").style.display = "block";
           }else{

                     document.getElementById("Submit").style.display = "none";
           }

       }
       }


     if(Pay == 'Installment'){

            document.getElementById("Install").style.display = "block";

     }else{

          document.getElementById("Install").style.display = "none";

     }


               if(Pay == 'Check'){

           document.getElementById("CHECK").style.display = "block";

       }else{

         document.getElementById("CHECK").style.display = "none";
       }

               if(Pay == 'Later'){

           document.getElementById("Later_Due").style.display = "block";
                   $('#paid').val('');

       }else{

         document.getElementById("Later_Due").style.display = "none";
       }

    }

</script>

        <!-- Tax on Total -->
<script>
      function  TaxOn(){

   var TaxOnTotalType = $('#TaxOnTotalType').val();
   var TotalNet = $('#Total_PriceW').val();


                     if(TaxOnTotalType) {
                         $.ajax({
                             url: 'TaxOnTotalTypeFilter',
                             type:"GET",
                             data:{
                               TaxOnTotalType:TaxOnTotalType
                             },
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {

            if(data.TaxType == 1){
         //Precent
             var i= parseFloat(data.TaxRate)  / parseFloat(100) ;

                var ii=  parseFloat(TotalNet) * parseFloat(i) ;
                 $('#ProfitTax').val(parseFloat(ii));

                var iii =  $('#ProfitTax').val();
                var iiii = parseFloat(iii) + parseFloat(TotalNet);
                $('#Total_PriceW').val(parseFloat(iiii));
                $('#paid').val(parseFloat(iiii));



}else if(data.TaxType == 2){
        //Number



                 $('#ProfitTax').val(parseFloat(data.TaxRate));

                var iii =  $('#ProfitTax').val();
                var iiii = parseFloat(iii) + parseFloat(TotalNet);
                $('#Total_PriceW').val(parseFloat(iiii));
                $('#paid').val(parseFloat(iiii));

}






                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });
                     } else {

                         $('select[name="state"]').empty();
                     }




   }
</script>

<!-- installment Compamies -->
<script>
      function  InstaallComp(){

   var InstallCompany = $('#InstallCompany').val();
   var TotalNet = $('#Total_PriceW').val();


                     if(InstallCompany) {
                         $.ajax({
                             url: 'InstallCompanyFilter',
                             type:"GET",
                             data:{
                               InstallCompany:InstallCompany,
                               TotalNet:TotalNet
                             },
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

                             success:function(data) {

                               $('#ServiceFee').val(data.Fee);
                               $('#CompanyPrecent').val(data.Prec);
                               $('#TotalServiceFee').val(data.Tot);



                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });
                     } else {

                         $('select[name="state"]').empty();
                     }




   }
</script>

          <script type="text/javascript">
        function disableBack() { window.history.forward(); }
        setTimeout("disableBack()", 0);
        window.onunload = function () { null };
    </script>

       <!-- to play audio when click on image -->
       <script>

        function play() {
          var audio = document.getElementById("audio");
          audio.play();
        }
      </script>
      <!-- <script src="keyboard/keyboard.js"></script> -->

    @if($show->Totuch_Screen == 1)
      <script src="{{asset('Admin/keyboard/keyboard-number.js')}}"></script>
   @endif


@endpush


@include('admin.layouts.footerPOS')
