<?php $__env->startSection('content'); ?>
   <?php
use App\Models\SalesDefaultData;
$Def=SalesDefaultData::orderBy('id','desc')->first();
use App\Models\DefaultDataShowHide;
$show=DefaultDataShowHide::orderBy('id','desc')->first();
?>
  <title><?php echo e(trans('admin.Return_Sales')); ?></title>

    <main id="js-page-content" role="main" class="page-content">
                    <ol class="breadcrumb page-breadcrumb">
                        <li class="breadcrumb-item"><a href="javascript:void(0);"><?php echo e(trans('admin.Sales')); ?> </a></li>
                        <li class="breadcrumb-item active"><?php echo e(trans('admin.Return_Sales')); ?> </li>
                        <li class="position-absolute pos-top pos-right d-none d-sm-block"><span
                                class="js-get-date"></span></li>
                    </ol>

    <form id="form" action="<?php echo e(url('PostReturn_Sales/'.$item->id)); ?>" method="post" enctype="multipart/form-data">
        <?php echo csrf_field(); ?>

               <?php echo view('honeypot::honeypotFormFields'); ?>
                    <div class="row">
                        <div class="col-lg-12">
                            <div id="panel-2" class="panel">
                                <div class="panel-hdr">
                                    <h2>
                                        <span class="fw-300"><i>   <?php echo e(trans('admin.Return_Sales')); ?>  </i></span>
                                    </h2>
                                </div>
                                <div class="panel-container show">
                                      <span id="ex"> <?php echo $__env->make('admin.layouts.messages', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?></span>
                                    <div class="panel-content">
                                    <div class="form-row">
                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Code')); ?> </label>
                                            <input type="text" name="Code" value="<?php echo e($Code); ?>" class="form-control " readonly>
                                              <input type="hidden" name="ReturnDate" value="<?php echo e($item->Date); ?>" class="form-control">
                                        </div>

                                <?php if(auth()->guard('admin')->user()->emp == 0): ?>
                      <div class="form-group col-lg-3">
                                    <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Date')); ?></label>
                                    <input type="date" name="Date" value="<?php echo e(date('Y-m-d')); ?>" class="form-control" required>
                                </div>
                                        <?php else: ?>

                                         <?php if(auth()->guard('admin')->user()->Date == 1): ?>
                                   <div class="form-group col-lg-3">
                                    <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Date')); ?></label>
                                    <input type="date" name="Date" value="<?php echo e(date('Y-m-d')); ?>" class="form-control" required>
                                </div>
                                        <?php else: ?>
                                 <div class="form-group col-lg-3">
                                    <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Date')); ?></label>
                                    <input type="date" name="Date" value="<?php echo e(date('Y-m-d')); ?>" class="form-control" required readonly>
                                </div>
                                        <?php endif; ?>

                                        <?php endif; ?>
                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Store')); ?></label>
                                            <select class="select2 form-control w-100" disabled>
                                                <option value=""> <?php echo e(trans('admin.Store')); ?></option>
                                            <?php $__currentLoopData = $Stores; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $stor): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <option value="<?php echo e($stor->id); ?>" <?php if($item->Store == $stor->id): ?>  selected  <?php endif; ?>>
                                              <?php echo e(app()->getLocale() == 'ar' ?$stor->Name :$stor->NameEn); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                    <input type="hidden" name="Store" id="store" value="<?php echo e($item->Store); ?>">
                                        </div>


                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Safe')); ?></label>
                                            <select class="select2 form-control w-100" id="SSAFE"  name="Safe" required>
                                                 <option value=""> <?php echo e(trans('admin.Safe')); ?></option>
                                            <?php $__currentLoopData = $Safes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $safe): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <option value="<?php echo e($safe->id); ?>" <?php if($item->Safe == $safe->id): ?>  selected  <?php endif; ?>>
                                               <?php echo e(app()->getLocale() == 'ar' ?$safe->Name :$safe->NameEn); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>

                                        </div>



                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Coin')); ?></label>
                                            <select class="select2 form-control w-100"  disabled>
                                                 <option value=""> <?php echo e(trans('admin.Coin')); ?></option>
                                            <?php $__currentLoopData = $Coins; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $coin): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                 <option value="<?php echo e($coin->id); ?>" <?php if($item->Coin == $coin->id): ?>  selected  <?php endif; ?>>
                                              <?php echo e(app()->getLocale() == 'ar' ?$coin->Arabic_Name :$coin->English_Name); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>

                                 <input type="hidden" name="Coin" value="<?php echo e($item->Coin); ?>">
                                        </div>
                                        <div class="form-group col-lg-2">
                              <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Draw')); ?></label>
                              <input type="text"  value="<?php echo e($item->Draw); ?>" class="form-control"  disabled>
                                       <input type="hidden" name="Draw" value="<?php echo e($item->Draw); ?>">
                                        </div>

                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for=""> <?php echo e(trans('admin.Bill_Payment_Method')); ?></label>
                                            <select class="select2 form-control w-100" disabled>
                                                <option value="Cash" <?php if($item->Payment_Method == 'Cash'): ?> selected <?php endif; ?>><?php echo e(trans('admin.Cash')); ?> </option>
                                                <option value="Later" <?php if($item->Payment_Method == 'Later'): ?> selected <?php endif; ?>><?php echo e(trans('admin.Later')); ?></option>
                                                <option value="Installment"  <?php if($item->Payment_Method == 'Installment'): ?> selected <?php endif; ?>><?php echo e(trans('admin.Installment')); ?></option>
                                                <option value="Check" <?php if($item->Payment_Method == 'Check'): ?> selected <?php endif; ?>><?php echo e(trans('admin.Check')); ?></option>
                                                <option value="InstallmentCompanies" <?php if($item->Payment_Method == 'InstallmentCompanies'): ?> selected <?php endif; ?>><?php echo e(trans('admin.InstallmentCompanies')); ?></option>
                                                <option value="Delivery" <?php if($item->Payment_Method == 'Delivery'): ?> selected <?php endif; ?>><?php echo e(trans('admin.Delivery')); ?></option>
                                                <option value="Cash_Visa" <?php if($item->Payment_Method == 'Cash_Visa'): ?> selected <?php endif; ?>><?php echo e(trans('admin.Cash_Visa')); ?></option>
                                                <option value="Visa" <?php if($item->Payment_Method == 'Visa'): ?> selected <?php endif; ?>><?php echo e(trans('admin.Visa')); ?></option>
                                                <option value="Cash_Collection" <?php if($item->Payment_Method == 'Cash_Collection'): ?> selected <?php endif; ?>><?php echo e(trans('admin.Cash_Collection')); ?></option>
                                            </select>
                                        </div>


                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for=""> <?php echo e(trans('admin.Payment_Method')); ?></label>
         <select class="select2 form-control w-100"  id="Payment_Method" name="Payment_Method" required>
          <option value="Cash" <?php if($item->Payment_Method == 'Cash'): ?>  selected  <?php endif; ?> ><?php echo e(trans('admin.Cash')); ?> </option>
        <option value="Later"  <?php if($item->Payment_Method == 'Later'): ?>  selected  <?php endif; ?>><?php echo e(trans('admin.Later')); ?></option>
                                            </select>
                                        </div>
                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Status')); ?></label>
         <select class="select2 form-control w-100"  onchange="Statuss()" id="Status"   disabled>
          <option value="1"   selected   ><?php echo e(trans('admin.Recived')); ?> </option>
          <option value="0"><?php echo e(trans('admin.Pending')); ?></option>
                                            </select>
                                <input type="hidden" name="Status" value="<?php echo e($item->Status); ?>">
                                        </div>
                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for=""> <?php echo e(trans('admin.Cost_Center')); ?> </label>
                                            <select class="select2 form-control w-100"  disabled>
                                            <option value=""> <?php echo e(trans('admin.Cost_Center')); ?></option>
                                            <?php $__currentLoopData = $CostCenters; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cost): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
         <option value="<?php echo e($cost->id); ?>" <?php if($item->Cost_Center == $cost->id): ?>  selected  <?php endif; ?>>
                                        <?php echo e(app()->getLocale() == 'ar' ?$cost->Arabic_Name :$cost->English_Name); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                        <input type="hidden" name="Cost_Center" value="<?php echo e($item->Cost_Center); ?>">
                                        </div>
                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Delegate')); ?></label>
                                            <select class="select2 form-control w-100"  disabled>
                                          <option value=""> <?php echo e(trans('admin.Delegate')); ?></option>
                                            <?php $__currentLoopData = $Employess; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $emp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                  <option value="<?php echo e($emp->id); ?>" <?php if($item->Delegate == $emp->id): ?>  selected  <?php endif; ?>>
                                       <?php echo e(app()->getLocale() == 'ar' ?$emp->Name :$emp->NameEn); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                 <input type="hidden" name="Delegate" value="<?php echo e($item->Delegate); ?>">
                                        </div>
                                        <div class="form-group col-lg-2">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Executor')); ?></label>
                <select  class="js-data-example-ajax form-control w-100" id="Emp" disabled >
                     <?php if(!empty($item->Executor)): ?>
                              <option value="<?php echo e($item->Executor); ?>">  <?php echo e(app()->getLocale() == 'ar' ?$item->Executor()->first()->Name :$item->Executor()->first()->NameEn); ?> </option>
                    <?php endif; ?>
                                            </select>
                        <input type="hidden" name="Executor" value="<?php echo e($item->Executor); ?>">
                                        </div>
                                        <div class="form-group col-lg-2">
                             <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Refrence_Number')); ?></label>
                   <input type="text"  value="<?php echo e($item->Refernce_Number); ?>" class="form-control" disabled>
                         <input type="hidden" name="Refernce_Number" value="<?php echo e($item->Refernce_Number); ?>">
                                        </div>
                                        <div class="form-group col-lg-4">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Account')); ?> (<?php echo e(trans('admin.Client')); ?>)</label>
                                            <select class="select2 form-control w-100" id="client"   disabled>
                                 <option value=""> <?php echo e(trans('admin.Account')); ?></option>
                                            <?php $__currentLoopData = $Clients; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cli): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                 <option value="<?php echo e($cli->id); ?>" <?php if($item->Client == $cli->id): ?>  selected  <?php endif; ?>>
                                                      <?php echo e(app()->getLocale() == 'ar' ?$cli->Name :$cli->NameEn); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                               <input type="hidden" name="Client" id="vendor" value="<?php echo e($item->Client); ?>">
                                        </div>
                                        <div class="form-group col-lg-2">
                                 <label class="form-label" for="simpleinput"> <?php echo e(trans('admin.Account_Credit')); ?> </label>
                             <input type="text" id="AccountCredit" name="Current_Credit" value="0" class="form-control " readonly>
                                        </div>

                                                       <div class="form-group col-lg-3">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Shipping_Compaines')); ?></label>
                                            <select class="select2 form-control w-100" disabled  >
                                                <option value=""> <?php echo e(trans('admin.Shipping_Compaines')); ?></option>
                                            <?php $__currentLoopData = $Shippings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ship): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($ship->id); ?>">

                                            <?php echo e(app()->getLocale() == 'ar' ?$ship->Name :$ship->NameEn); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                                   <input type="hidden" name="Ship" value="<?php echo e($item->Ship); ?>">
                                        </div>

                                        <div class="form-group col-lg-3">
                                            <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Notes')); ?>  </label>
                                   <input type="text"  value="<?php echo e($item->Note); ?>" class="form-control" disabled>
                                   <input type="hidden" name="Note" value="<?php echo e($item->Note); ?>">
                                        </div>
                                    </div>

                             <div id="Install" style="display: none">

                                <div class="row">
                                <div class="form-group col-lg-3">
                         <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Presenter')); ?></label>
           <input type="number" onclick="Install()" onkeyup="Install()" step="any" id="presenter" name="presenter" value="<?php echo e($item->presenter); ?>" class="form-control">
                                        </div>

                                  <div class="form-group col-lg-3">
                           <label class="form-label" for="simpleinput"><?php echo e(trans('admin.annual_interest')); ?></label>
           <input type="number" step="any" onclick="Install()" onkeyup="Install()"  id="annual_interest" name="annual_interest" value="<?php echo e($item->annual_interest); ?>" class="form-control">
                                        </div>



                                         <div class="form-group col-lg-3">
                               <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Years_Number')); ?></label>
     <input type="number" step="any" onclick="Install()" onkeyup="Install()" id="Years_Number" name="Years_Number" value="<?php echo e($item->Years_Number); ?>" class="form-control">
                                        </div>

                                     <div class="form-group col-lg-3">
                               <label class="form-label" for="simpleinput"><?php echo e(trans('admin.total')); ?></label>
     <input type="number" onclick="Install()" onkeyup="Install()"  step="any" id="total" name="total" value="<?php echo e($item->total); ?>" class="form-control">

                                        </div>


                                         <div class="form-group col-lg-4">
                               <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Date_First_installment')); ?></label>
     <input type="date" onchange="Install()"  name="Date_First_installment" value="<?php echo e($item->Date_First_installment); ?>" class="form-control">
                                        </div>

                                           <div class="form-group col-lg-4">
                          <label class="form-label" for="simpleinput"><?php echo e(trans('admin.monthly_installment')); ?></label>
     <input type="number" step="any" id="monthly_installment" value="<?php echo e($item->monthly_installment); ?>" class="form-control" disabled>

              <input type="hidden" step="any" id="monthly_installmentHide" name="monthly_installment" value="<?php echo e($item->monthly_installment); ?>">

                                        </div>
                             <div class="form-group col-lg-4">
                               <label class="form-label" for="simpleinput"><?php echo e(trans('admin.installment_Num')); ?></label>
     <input type="number" step="any" id="installment_Num"  value="<?php echo e($item->installment_Num); ?>" class="form-control" disabled>
                            <input type="hidden" step="any" id="installment_NumHide" name="installment_Num" value="<?php echo e($item->installment_Num); ?>">
                                        </div>



                                    </div>
                                        </div>
                            </div>
                        </div>
                    </div>
                    </div>
                    <div class="col-xl-12">
                        <div id="panel-1" class="panel">
                            <div class="form-group col-lg-12" style="display: none">
                                <label class="form-label" for="simpleinput">  </label>
                                <div class="input-items">
                 <input type="text" id="search" class="form-control" placeholder="<?php echo e(trans('admin.Search_For_Products')); ?>">
                                 <i class="fal fa-barcode-alt"></i>
                                </div>
                             </div>
                            <div class="panel-container show">
                                <div class="panel-content">
                                    <table style="display: none"
                                    class="table table-bordered table-hover table-striped w-100">
                                    <thead>
                                        <tr>
                                            <th><?php echo e(trans('admin.Name')); ?></th>
                                            <th><?php echo e(trans('admin.Unit')); ?></th>
                                            <th><?php echo e(trans('admin.Code')); ?></th>
                                            <th><?php echo e(trans('admin.Qty')); ?></th>
                                            <th><?php echo e(trans('admin.Price')); ?></th>
                                            <th><?php echo e(trans('admin.Discount')); ?></th>
                                            <th><?php echo e(trans('admin.Store')); ?></th>
                                            <th><?php echo e(trans('admin.Exp_Date')); ?></th>
                                            <th><?php echo e(trans('admin.Actions')); ?></th>
                                        </tr>
                                    </thead>
                                    <tbody class="Data">

                                    </tbody>
                                    </table>
                                    <!-- datatable start -->
                                    <div style="overflow:auto">
                                    <table id="dt"
                                        class="table table-bordered table-hover table-striped table-color2" width="120px">
                                        <thead>
                                            <tr>
                                            <th><?php echo e(trans('admin.Name')); ?></th>
                                            <th><?php echo e(trans('admin.Unit')); ?></th>
                                            <th><?php echo e(trans('admin.Code')); ?></th>
                                                          <?php if($show->Patch_Number == 1): ?>
                                            <th><?php echo e(trans('admin.Patch_Number')); ?></th>
                                            <?php endif; ?>
                                            <th><?php echo e(trans('admin.Original_Qty')); ?></th>
                                            <th><?php echo e(trans('admin.Qty')); ?></th>
                                            <th><?php echo e(trans('admin.Return_Qty')); ?></th>
                                            <th><?php echo e(trans('admin.Price')); ?></th>
                                            <th><?php echo e(trans('admin.Discount')); ?></th>
                                            <th><?php echo e(trans('admin.Total_Bf_Taxes')); ?></th>
                                            <th><?php echo e(trans('admin.Tax')); ?></th>
                                            <th><?php echo e(trans('admin.Total_Recived_Qty')); ?></th>
                                            <th><?php echo e(trans('admin.Store')); ?></th>
                                            <th><?php echo e(trans('admin.Exp_Date')); ?></th>
                                            </tr>
                                        </thead>
                                        <tbody id="data-dt">

                                  <?php $__currentLoopData = $details; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pro): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr id="TR<?php echo e($pro->id); ?>">
                        <td>

                       <?php echo e(app()->getLocale() == 'ar' ?$pro->Product()->first()->P_Ar_Name :$pro->Product()->first()->P_En_Name); ?>

                        <input type='hidden' name='P_Ar_Name[]' value='<?php echo e($pro->Product()->first()->P_Ar_Name); ?>'>
                    <input type='hidden' name='P_En_Name[]' value='<?php echo e($pro->Product()->first()->P_En_Name); ?>'>

                    <?php if(!empty($pro->V1)): ?>
                 ( <?php echo e(app()->getLocale() == 'ar' ?$pro->V1()->first()->Name :$pro->V1()->first()->NameEn); ?> )

                        <input type='hidden' name='VOne[]' value='<?php echo e($pro->V1); ?>'>
                        <input type='hidden' name='V_Name[]' value='<?php echo e($pro->V_Name); ?>'>

                    <?php else: ?>
                       <input type='hidden' name='VOne[]' value=''>
                        <input type='hidden' name='V_Name[]' value=''>
                    <?php endif; ?>

                      <?php if(!empty($pro->V2)): ?>
                                  ( <?php echo e(app()->getLocale() == 'ar' ?$pro->V2()->first()->Name :$pro->V2()->first()->NameEn); ?> )
                        <input type='hidden' name='VTwo[]' value='<?php echo e($pro->V2); ?>'>
                        <input type='hidden' name='VV_Name[]' value='<?php echo e($pro->VV_Name); ?>'>
                    <?php else: ?>
                         <input type='hidden' name='VTwo[]' value=''>
                      <input type='hidden' name='VV_Name[]' value=''>
                    <?php endif; ?>

                    </td>
                <td><input type='hidden' name='Unit[]' value='<?php echo e($pro->Unit); ?>'><?php echo e(app()->getLocale() == 'ar' ?$pro->Unit()->first()->Name :$pro->Unit()->first()->NameEn); ?></td>
             <td><input type='hidden' name='P_Code[]' value='<?php echo e($pro->Product_Code); ?>'>

                 <?php echo e($pro->Product_Code); ?>

                   <input type='hidden' name='Patch_Number[]' value='<?php echo e($pro->Patch_Number); ?>'>
                                    </td>

                                <?php if($show->Patch_Number == 1): ?>
                                     <td><?php echo e($pro->Patch_Number); ?></td>
                                            <?php endif; ?>

            <td><input  type='hidden' name='Original_Qty[]' value='<?php echo e($pro->Original_Qty); ?>'><?php echo e($pro->Original_Qty); ?></td>
            <td>
                <input class='Qun' type='text' id="RQuantity<?php echo e($pro->id); ?>"  value='<?php echo e($pro->Qty); ?>' disabled>
                <input  type='hidden' id="RQuantityHide<?php echo e($pro->id); ?>" name='Qty[]' value='<?php echo e($pro->Qty); ?>'>
                <input  type='hidden' id="RQuantityHidee<?php echo e($pro->id); ?>"  value='<?php echo e($pro->Qty); ?>'>

                    </td>
                <td>

            <input class='RecviedQun' onkeyup="RecivedQuantityy(<?php echo e($pro->id); ?>)" onclick="RecivedQuantityy(<?php echo e($pro->id); ?>)" id="RecivedQuantity<?php echo e($pro->id); ?>" type='number' step="any" name='Return_Qty[]' value="0">

                </td>
                <td><input type='hidden' id="Price<?php echo e($pro->id); ?>" name='Price[]' value='<?php echo e($pro->Price); ?>'><?php echo e($pro->Price); ?></td>
            <td><input  id="Discount<?php echo e($pro->id); ?>" type='hidden' name='Discount[]' value='<?php echo e($pro->Discount); ?>'><?php echo e($pro->Discount); ?></td>
                   <input type='hidden'  id='TDiscProEdit<?php echo e($pro->id); ?>' name='TDiscPro[]' value='<?php echo e($pro->TDiscount); ?>'>

                      <input type="hidden" class='Disc' id="Return_Discount<?php echo e($pro->id); ?>" value="0">
                                    <td>
                         <input class='TransBFTot form-control' type='text' id="TransTotBF<?php echo e($pro->id); ?>"  value='0' disabled>
                <input  type='hidden' id="TransBFTotHide<?php echo e($pro->id); ?>" name='TransTotalBF[]' value='0'>


                                    </td>
        <td>

                    <input class='TransTotTax form-control' type='text' id="TransTotTax<?php echo e($pro->id); ?>"  value='0' disabled>
                <input  type='hidden' id="TransTotTaxHide<?php echo e($pro->id); ?>" name='TransTotTax[]' value='0'>


            <input class='TotalBFTax' type='hidden' name='TotalBFTax[]' value='<?php echo e($pro->Total_Bf_Tax); ?>'>
            <input class='TotalTax' type='hidden' name='TotalTax[]' value='<?php echo e($pro->Total_Tax); ?>'>
            <input  type='hidden' name='AvQty[]' value='<?php echo e($pro->AvQty); ?>'>
             <input class='Tot' type='hidden' name='Total[]' value='<?php echo e($pro->Total); ?>'>

                </td>

            <td>
                <input class='TransTot form-control' type='text' id="TransTot<?php echo e($pro->id); ?>"  value='0' disabled>
                <input  type='hidden' id="TransTotHide<?php echo e($pro->id); ?>" name='TransTotal[]' value='0'>
                 <input type='hidden' class='COSTPRICES' id="CostPrice<?php echo e($pro->id); ?>"  name='CostPrice[]' value='<?php echo e($pro->CostPrice); ?>'>
                 <input type='hidden' class='ReturnCOSTPRICES' id="ReturnCostPrice<?php echo e($pro->id); ?>"  value='0'>

                    </td>

        <td><input  type='hidden' name='StorePurch[]' value='<?php echo e($pro->Store); ?>'><?php echo e(app()->getLocale() == 'ar' ?$pro->Store()->first()->Name :$pro->Store()->first()->NameEn); ?></td>
        <td><input type='hidden' name='Exp_Date[]' value='<?php echo e($pro->Exp_Date); ?>'><?php echo e($pro->Exp_Date); ?>

                 <input type='hidden' name='Product[]' value='<?php echo e($pro->Product); ?>'>

        <input type='hidden' name='PurchTax[]' value='<?php echo e($pro->Tax); ?>'>

        <input type='hidden' id="TaxRate<?php echo e($pro->id); ?>"   value='<?php echo e($pro->Tax()->first()->Rate); ?>'>

        <input type='hidden' id="TaxType<?php echo e($pro->id); ?>"   value='<?php echo e($pro->Tax()->first()->Type); ?>'>
        <input type='hidden' class="X" id="X<?php echo e($pro->id); ?>"   value='0'>

                        </td>
        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                        </tbody>

                                    </table>
                                    </div>
                                    <!-- datatable end -->
                                     <div class="form-row">



                                        <div class="form-group col-lg-4">
                        <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Total_Bf_Taxes')); ?> </label>
                                          <input type="text" id="RTotal_Bf_Taxes" disabled  class="form-control" value="0">
                                            <input type="hidden" id="RTotal_Bf_TaxesHide" name="Total_BF_Taxes" value="0">
                                        </div>
                                        <div class="form-group col-lg-4">
                          <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Total_Taxes')); ?></label>
                                         <input type="text" id="RTotal_Taxes" disabled value="0"  class="form-control">
                                            <input type="hidden" id="RTotal_TaxesHide" name="Total_Taxes" value="0">
                                        </div>

                                        <div class="form-group col-lg-4">
                           <label class="form-label" for="simpleinput"> <?php echo e(trans('admin.Total_Return_Qty')); ?> </label>
                                    <input type="text"  id="Total_Trans_Qty" value="0"   class="form-control" disabled>
                                         <input type="hidden" name="Total_Return_Qty" value="0"  id="Total_Trans_QtyHide" >
                                        </div>
                                                                           <div class="form-group col-lg-4">
                                  <label class="form-label" for="simpleinput"> <?php echo e(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-4">
                           <label class="form-label" for="simpleinput"> <?php echo e(trans('admin.Total_Return_Value')); ?> </label>
                                    <input type="text"  id="Total_Trans_Value"  class="form-control" value="0" disabled>
                                     <input type="hidden" name="Total_Return_Value"  id="Total_Trans_ValueHide" value="0" >
                                     <input type="hidden" name="Total_Cost_Return_Value"  id="Total_Cost_Return_Value" >

                                        </div>

                                                                       <div class="form-group col-lg-4">
                           <label class="form-label" for="simpleinput"> <?php echo e(trans('admin.Paid')); ?> </label>
                                    <input type="text" name="Pay" id="paid" onkeyup="Statuss()"  class="form-control">

                                        </div>


                                    </div>
                                    <div class="buttons mt-3" id="recived" style="display: none">
                                        <input type="hidden" id="sp" name="sp">
                                        <input type="hidden" id="Submit">
            <button type="button" onclick="SPP()"  class="btn btn-primary"> <i class="fal fa-folder"></i> <?php echo e(trans('admin.Returnn')); ?> </button>

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



                    </div>

                </form>
                </main>


              <?php if($Def->Discount == 0): ?>
            <input type="hidden" id="DIS" value="0">  <!-- Number -->
        <?php else: ?>
            <input type="hidden" id="DIS" value="1">  <!-- Precent -->
        <?php endif; ?>


 <input type="hidden"  id="SafeBalance" value="0">
<?php $__env->stopSection(); ?>

<?php $__env->startPush('js'); ?>

    <link rel="stylesheet" media="screen, print" href="<?php echo e(asset('Admin/css/datagrid/datatables/datatables.bundle.css')); ?>">
    <link rel="stylesheet" media="screen, print" href="<?php echo e(asset('Admin/css/formplugins/summernote/summernote.css')); ?>">
    <link rel="stylesheet" media="screen, print" href="<?php echo e(asset('Admin/css/formplugins/select2/select2.bundle.css')); ?>">

    <script src="<?php echo e(asset('Admin/js/datagrid/datatables/datatables.bundle.js')); ?>"></script>
    <script src="<?php echo e(asset('Admin/js/datagrid/datatables/datatables.export.js')); ?>"></script>
    <script src="<?php echo e(asset('Admin/js/formplugins/summernote/summernote.js')); ?>"></script>
    <script src="<?php echo e(asset('Admin/js/formplugins/select2/select2.bundle.js')); ?>"></script>

     <script>
        var autoSave = $('#autoSave');
        var interval;
        var timer = function()
        {
            interval = setInterval(function()
            {
                //start slide...
                if (autoSave.prop('checked'))
                    saveToLocal();

                clearInterval(interval);
            }, 3000);
        };

        //save
        var saveToLocal = function()
        {
            localStorage.setItem('summernoteData', $('#saveToLocal').summernote("code"));
            console.log("saved");
        }

        //delete
        var removeFromLocal = function()
        {
            localStorage.removeItem("summernoteData");
            $('#saveToLocal').summernote('reset');
        }

        $(document).ready(function()
        {
            //init default
            $('.js-summernote').summernote(
            {
                height: 200,
                tabsize: 2,
                placeholder: "Type here...",
                dialogsFade: true,
                toolbar: [
                    ['style', ['style']],
                    ['font', ['strikethrough', 'superscript', 'subscript']],
                    ['font', ['bold', 'italic', 'underline', 'clear']],
                    ['fontsize', ['fontsize']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']]
                    ['table', ['table']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ],
                callbacks:
                {
                    //restore from localStorage
                    onInit: function(e)
                    {
                        $('.js-summernote').summernote("code", localStorage.getItem("summernoteData"));
                    },
                    onChange: function(contents, $editable)
                    {
                        clearInterval(interval);
                        timer();
                    }
                }
            });

            //load emojis
            $.ajax(
            {
                url: 'https://api.github.com/emojis',
                async: false
            }).then(function(data)
            {
                window.emojis = Object.keys(data);
                window.emojiUrls = data;
            });

            //init emoji example
            $(".js-hint2emoji").summernote(
            {
                height: 100,
                toolbar: false,
                placeholder: 'type starting with : and any alphabet',
                hint:
                {
                    match: /:([\-+\w]+)$/,
                    search: function(keyword, callback)
                    {
                        callback($.grep(emojis, function(item)
                        {
                            return item.indexOf(keyword) === 0;
                        }));
                    },
                    template: function(item)
                    {
                        var content = emojiUrls[item];
                        return '<img src="' + content + '" width="20" /> :' + item + ':';
                    },
                    content: function(item)
                    {
                        var url = emojiUrls[item];
                        if (url)
                        {
                            return $('<img />').attr('src', url).css('width', 20)[0];
                        }
                        return '';
                    }
                }
            });

            //init mentions example
            $(".js-hint2mention").summernote(
            {
                height: 100,
                toolbar: false,
                placeholder: "type starting with @",
                hint:
                {
                    mentions: ['jayden', 'sam', 'alvin', 'david'],
                    match: /\B@(\w*)$/,
                    search: function(keyword, callback)
                    {
                        callback($.grep(this.mentions, function(item)
                        {
                            return item.indexOf(keyword) == 0;
                        }));
                    },
                    content: function(item)
                    {
                        return '@' + item;
                    }
                }
            });

        });

    </script>
     <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
                }

                $(".js-data-example-ajax").select2(
                {
                    ajax:
                    {
                        url: "https://api.github.com/search/repositories",
                        dataType: 'json',
                        delay: 250,
                        data: function(params)
                        {
                            return {
                                q: params.term, // search term
                                page: params.page
                            };
                        },
                        processResults: function(data, params)
                        {
                            // parse the results into the format expected by Select2
                            // since we are using custom formatting functions we do not need to
                            // alter the remote JSON data, except to indicate that infinite
                            // scrolling can be used
                            params.page = params.page || 1;

                            return {
                                results: data.items,
                                pagination:
                                {
                                    more: (params.page * 30) < data.total_count
                                }
                            };
                        },
                        cache: true
                    },
                    placeholder: 'Search for a repository',
                    escapeMarkup: function(markup)
                    {
                        return markup;
                    }, // let our custom formatter work
                    minimumInputLength: 1,
                    templateResult: formatRepo,
                    templateSelection: formatRepoSelection
                });

                function formatRepo(repo)
                {
                    if (repo.loading)
                    {
                        return repo.text;
                    }

                    var markup = "<div class='select2-result-repository clearfix d-flex'>" +
                        "<div class='select2-result-repository__avatar mr-2'><img src='" + repo.owner.avatar_url + "' class='width-2 height-2 mt-1 rounded' /></div>" +
                        "<div class='select2-result-repository__meta'>" +
                        "<div class='select2-result-repository__title fs-lg fw-500'>" + repo.full_name + "</div>";

                    if (repo.description)
                    {
                        markup += "<div class='select2-result-repository__description fs-xs opacity-80 mb-1'>" + repo.description + "</div>";
                    }

                    markup += "<div class='select2-result-repository__statistics d-flex fs-sm'>" +
                        "<div class='select2-result-repository__forks mr-2'><i class='fal fa-lightbulb'></i> " + repo.forks_count + " Forks</div>" +
                        "<div class='select2-result-repository__stargazers mr-2'><i class='fal fa-star'></i> " + repo.stargazers_count + " Stars</div>" +
                        "<div class='select2-result-repository__watchers mr-2'><i class='fal fa-eye'></i> " + repo.watchers_count + " Watchers</div>" +
                        "</div>" +
                        "</div></div>";

                    return markup;
                }

                function formatRepoSelection(repo)
                {
                    return repo.full_name || repo.text;
                }
            });
        });

    </script>


<!-- Unit Code and Name -->
<script>
   function  UnitCodePurch(r){

   var countryId = $('#UnitPurch'+r).val();
   var Pro = $('#Product'+r).val();
   var client = $('#client').val();

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

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

                       $('#CodePurch'+r).val(data.code);
                       $('#UnitPurchName'+r).val(data.name);
                       $('#TaxRate'+r).val(data.rate);
                       $('#TaxType'+r).val(data.type);
                       $('#Price'+r).val(data.price);
                       $('#PurchTax'+r).val(data.tax);


                                 });

   var TaxRate = $("#TaxRate"+r).val();
   var TaxType = $("#TaxType"+r).val();
   var Qty = $("#Qty"+r).val();
   var Price = $("#Price"+r).val();
   var Discount = $("#Discount"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;


       if(TaxType == 1){
           //Precent

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

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

       i =    parseFloat(TaxRate)  / 100 ;

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

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

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

           $("#Total"+r).val(parseFloat(iii));

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

            i =    parseFloat(TaxRate)   ;

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

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

           $("#Total"+r).val(parseFloat(iii));


       }


        var Total = $("#Total"+r).val();
        var TotalBFTax = $("#TotalBFTax"+r).val();
        var Tax = $("#Tax"+r).val();
        var UnitID = $("#UnitPurch"+r).val();
        var StorePurch = $("#StorePurch"+r).val();
        var AvQty = $("#AvQty"+r).val();
        var x= 0;

       if(TaxRate == ''  || TaxType == ''  ||  Qty == '' || Price == '' || Discount == '' || Total == '' || TotalBFTax == '' || Tax == '' || UnitID == '' || StorePurch == ''){

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


       if(TaxRate != ''  && TaxType != ''  &&  Qty != '' && Price != '' && Discount != '' && Total != '' && TotalBFTax != '' && Tax != '' && UnitID != '' && StorePurch != ''){

        document.getElementById("AddBtnPur"+r).style.display = "block";
     }

                 // x de elly hya lw byshtghl bsalb
              if(x == 0){

       if(AvQty != 0){


       if(parseFloat(AvQty) >= parseFloat(Qty)){

    document.getElementById("AddBtnPur"+r).style.display = "block";

        }else{


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

        }


           }else{

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


    }else{

       document.getElementById("AddBtnPur"+r).style.display = "block";

    }



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

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

   }
</script>

<!-- Store Name -->
<script>
   function  StoreNamePurch(r){

   var countryId = $('#StorePurch'+r).val();
   var Product = $('#Product'+r).val();
   var Code = $('#CodePurch'+r).val();
                     if(countryId) {
                         $.ajax({
                             url: 'StoreNameSalesFilter/'+countryId+'/'+Product+'/'+Code,
                             type:"GET",
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },

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

                       $('#StorePurchName'+r).val(data.name);
                       $('#AvQty'+r).val(data.AvQty);



                                 });

   var TaxRate = $("#TaxRate"+r).val();
   var TaxType = $("#TaxType"+r).val();
   var Qty = $("#Qty"+r).val();
   var Price = $("#Price"+r).val();
   var Discount = $("#Discount"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;


       if(TaxType == 1){
           //Precent

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

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

       i =    parseFloat(TaxRate)  / 100 ;

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

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

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

           $("#Total"+r).val(parseFloat(iii));

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

            i =    parseFloat(TaxRate)   ;

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

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

           $("#Total"+r).val(parseFloat(iii));


       }


        var Total = $("#Total"+r).val();
        var TotalBFTax = $("#TotalBFTax"+r).val();
        var Tax = $("#Tax"+r).val();
        var UnitID = $("#UnitPurch"+r).val();
        var StorePurch = $("#StorePurch"+r).val();
  var AvQty = $("#AvQty"+r).val();
   var x= 0;




       if(TaxRate == ''  || TaxType == ''  ||  Qty == '' || Price == '' || Discount == '' || Total == '' || TotalBFTax == '' || Tax == '' || UnitID == '' || StorePurch == ''){

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


       if(TaxRate != ''  && TaxType != ''  &&  Qty != '' && Price != '' && Discount != '' && Total != '' && TotalBFTax != '' && Tax != '' && UnitID != '' && StorePurch != ''){

        document.getElementById("AddBtnPur"+r).style.display = "block";
     }

          // x de elly hya lw byshtghl bsalb
      if(x == 0){

       if(AvQty != 0){


       if(parseFloat(AvQty) >= parseFloat(Qty)){

    document.getElementById("AddBtnPur"+r).style.display = "block";

        }else{

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

        }


           }else{

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


    }else{

       document.getElementById("AddBtnPur"+r).style.display = "block";

    }




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

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

   }
</script>

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

                  $('#client').on('change', function(){
                      var countryId = $(this).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(key);
                    $('#AccountCredit').val(value);
                                  });
                              },
                              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(key);
                    $('#AccountCredit').val(value);
                                  });
                              },
                              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:'1/SalesProductsFilter',
      method:'GET',
      data:{search:search,store:store,client:client},
      dataType:'json',
      success:function(data)
      {
       $('.Data').html(data.table_data);
      }
     })
    }

   $(document).on('keyup', '#search', function(){
     var search = $(this).val();
     var store = $('#store').val();
     var client = $('#client').val();
     fetch_customer_data(search,store,client);
    });


    $(document).on('change', '#store', function(){
     var store = $(this).val();
     var search = $('#search').val();
     var client = $('#client').val();
     fetch_customer_data(search,store,client);
    });

    $(document).on('change', '#client', function(){
     var client = $(this).val();
     var search = $('#search').val();
     var store = $('#store').val();
     fetch_customer_data(search,store,client);
    });

   });
</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 = $("#StorePurch"+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 Viro = '';
             var VViro = '';

       if( V_Name != ''){

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

       if( VV_Name != ''){

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

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

             var markup = "<tr><td><input type='hidden' name='P_Ar_Name[]' value='"+P_Ar_Name+"'><input type='hidden' name='P_En_Name[]' value='"+P_En_Name+"'>" + P_Ar_Name + ""+ Viro +" "+ VViro +"</td><td><input type='hidden' name='Unit[]' value='"+UnitID+"'>" + UnitName + "</td><td><input type='hidden' name='P_Code[]' value='"+Barcode+"'>" + Barcode + "</td><td><input type='hidden' name='AvQty[]' value='"+AvQty+"'>" + AvQty + "</td><td><input class='Qun' type='hidden' name='Qty[]' value='"+Qty+"'>" + Qty + "</td><td><input type='hidden' name='Price[]' value='"+Price+"'>" + Price + "</td><td><input class='Disc' type='hidden' name='Discount[]' value='"+Discount+"'>" + Discount + "</td><td><input class='TotalBFTax' type='hidden' name='TotalBFTax[]' value='"+TotalBFTax+"'>" + TotalBFTax + "</td><td><input class='TotalTax' type='hidden' name='TotalTax[]' value='"+TotalTax+"'>" + TotalTax + "</td><td><input class='Tot' type='hidden' name='Total[]' value='"+Total+"'>" + Total + "</td><td><input  type='hidden' name='StorePurch[]' value='"+StorePurch+"'>" + StorePurchName + "</td><td><input type='hidden' name='Exp_Date[]' value='"+ExpDate+"'>" + ExpDate + "</td><td><button id='DelAssem' type='button' class='btn btn-default'><i class='fal fa-trash'></i></button><input type='hidden' name='Product[]' value='"+Product+"'><input type='hidden' name='VOne[]' value='"+VOne+"'><input type='hidden' name='VTwo[]' value='"+VTwo+"'></td><input type='hidden' name='V_Name[]' value='"+Viro+"'><input type='hidden' name='VV_Name[]' value='"+VViro+"'><input type='hidden' name='PurchTax[]' value='"+PurchTax+"'></tr>";


             $("#data-dt").append(markup);

      $.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());
   });


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

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

   $('#Total_Price').val(parseFloat(sumT));
   $('#Total_PriceHide').val(parseFloat(sumT));


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

   $('#Total_Bf_Taxes').val(parseFloat(sumBF));
   $('#Total_Bf_TaxesHide').val(parseFloat(sumBF));

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


       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }

            var Pay =$('#Payment_Method').val();
        var Stat =$('#Status').val();
        var paid =$('#paid').val();

      if(Pay == 'Later' &&  Stat == 0 ){

             if(paid == 0 || paid < 0){
        document.getElementById("Submit").style.display = "none";
             }else{

           if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }



             }

       }else{

       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }
       }

        $('#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());
   });


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

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

   $('#Total_Price').val(parseFloat(sumT));
   $('#Total_PriceHide').val(parseFloat(sumT));


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

          $('#Total_Bf_Taxes').val(parseFloat(sumBF));
   $('#Total_Bf_TaxesHide').val(parseFloat(sumBF));

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


       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }

                  var Pay =$('#Payment_Method').val();
        var Stat =$('#Status').val();
        var paid =$('#paid').val();

      if(Pay == 'Later' &&  Stat == 0 ){

             if(paid == 0 || paid < 0){
        document.getElementById("Submit").style.display = "none";
             }else{

           if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }



             }

       }else{

       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }
       }






                    })


     }
</script>

<!-- Total Products -->
<script>
   function PurchTotal(r) {
   var TaxRate = $("#TaxRate"+r).val();
   var TaxType = $("#TaxType"+r).val();
   var Qty = $("#Qty"+r).val();
   var AvQty = $("#AvQty"+r).val();
   var Price = $("#Price"+r).val();
   var Discount = $("#Discount"+r).val();
   var i = 0;
   var ii=0;
   var iii=0;
   var x= 0;


       if(TaxType == 1){
           //Precent

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

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

       i =    parseFloat(TaxRate)  / 100 ;

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

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

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

           $("#Total"+r).val(parseFloat(iii));

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

            i =    parseFloat(TaxRate)   ;

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

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

           $("#Total"+r).val(parseFloat(iii));


       }


        var Total = $("#Total"+r).val();
        var TotalBFTax = $("#TotalBFTax"+r).val();
        var Tax = $("#Tax"+r).val();
        var UnitID = $("#UnitPurch"+r).val();
        var StorePurch = $("#StorePurch"+r).val();

       if(TaxRate == ''  || TaxType == ''  ||  Qty == '' || Price == '' || Discount == '' || Total == '' || TotalBFTax == '' || Tax == '' || UnitID == '' || StorePurch == ''){

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


       if(TaxRate != ''  && TaxType != ''  &&  Qty != '' && Price != '' && Discount != '' && Total != '' && TotalBFTax != '' && Tax != '' && UnitID != '' && StorePurch != ''){

        document.getElementById("AddBtnPur"+r).style.display = "block";
     }

      // x de elly hya lw byshtghl bsalb
    if(x == 0){

       if(parseFloat(AvQty) != 0){


        if(parseFloat(AvQty) >= parseFloat(Qty)){


    document.getElementById("AddBtnPur"+r).style.display = "block";

        }else{

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

        }


           }else{

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


    }else{

       document.getElementById("AddBtnPur"+r).style.display = "block";

    }



   }
</script>

<!-- Scanner  problem -->
<script>
   $(".form-control").keypress(function(event){
   if (event.which == '10' || event.which == '13') {
   event.preventDefault();
   }
   });


</script>

<!-- Status -->
<script>
    function Statuss(){

        var Pay =$('#Payment_Method').val();
        var Stat =$('#Status').val();
        var paid =$('#paid').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{

        document.getElementById("Submit").style.display = "block";
       }



             }

       }else{

       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }
       }


     if(Pay == 'Installment'){

            document.getElementById("Install").style.display = "block";

     }else{

          document.getElementById("Install").style.display = "none";

     }




    }
</script>

<!-- Submit Script -->
<script>
   function SPP(){
      $('#sp').val(1);
      var x= $('#sp').val();

             var store= $('#store').val();
      var SSAFE= $('#SSAFE').val();
      var vendor= $('#vendor').val();

          var Pay =$('#Payment_Method').val();
 var paid =$('#paid').val();

           var SafeBalance= $('#SafeBalance').val();
           var Amount= $('#Total_Trans_ValueHide').val();

       if(Pay == 'Later'){

     if(parseFloat(paid) > parseFloat(SafeBalance)){
  alert('المبلغ غير كافي في الخزينه');
         }else{

   if(store != '' && SSAFE != '' && vendor != null){
        if(x == 1){
         document.getElementById("recived").style.display = "none";
   document.getElementById('form').submit();
   }
   }else{

           alert('تأكد من اختيار مخزن و خزنه وحساب');

       }


       }
          }else{
            if(parseFloat(Amount) > parseFloat(SafeBalance)){
  alert('المبلغ غير كافي في الخزينه');
         }else{

   if(store != '' && SSAFE != '' && vendor != null){
        if(x == 1){
         document.getElementById("recived").style.display = "none";
   document.getElementById('form').submit();
   }
   }else{

           alert('تأكد من اختيار مخزن و خزنه وحساب');

       }


       }
   }



   }

</script>

<script>
 $(document).ready(function() {
   $.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());
   });


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

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

   $('#Total_Price').val(parseFloat(sumT));
   $('#Total_PriceHide').val(parseFloat(sumT));


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

   $('#Total_Bf_Taxes').val(parseFloat(sumBF));
   $('#Total_Bf_TaxesHide').val(parseFloat(sumBF));

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


       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }

            var Pay =$('#Payment_Method').val();
        var Stat =$('#Status').val();
        var paid =$('#paid').val();

      if(Pay == 'Later' &&  Stat == 0 ){

             if(paid == 0 || paid < 0){
        document.getElementById("Submit").style.display = "none";
             }else{

           if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }



             }

       }else{

       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }
       }

 });

      $('#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());
   });


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

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

   $('#Total_Price').val(parseFloat(sumT));
   $('#Total_PriceHide').val(parseFloat(sumT));


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

          $('#Total_Bf_Taxes').val(parseFloat(sumBF));
   $('#Total_Bf_TaxesHide').val(parseFloat(sumBF));

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


       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }

                  var Pay =$('#Payment_Method').val();
        var Stat =$('#Status').val();
        var paid =$('#paid').val();

      if(Pay == 'Later' &&  Stat == 0 ){

             if(paid == 0 || paid < 0){
        document.getElementById("Submit").style.display = "none";
             }else{

           if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }



             }

       }else{

       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }
       }






                    })
</script>

<script>
 $(document).ready(function() {


        var Pay =$('#Payment_Method').val();
        var Stat =$('#Status').val();
        var paid =$('#paid').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{

        document.getElementById("Submit").style.display = "block";
       }



             }

       }else{

       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }
       }


     if(Pay == 'Installment'){

            document.getElementById("Install").style.display = "block";

     }else{

          document.getElementById("Install").style.display = "none";

     }



 });
</script>

<script>
  $(document).on('change', '#store', function(){

      $("#dt").find("tr:gt(0)").remove();


    });

    $(document).on('change', '#client', function(){

      $("#dt").find("tr:gt(0)").remove();


    });
</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>

<script>
 $(document).ready(function() {


        var Pay =$('#Payment_Method').val();
        var Stat =$('#Status').val();
        var paid =$('#paid').val();



     if(Pay == 'Installment'){

            document.getElementById("Install").style.display = "block";

     }else{

          document.getElementById("Install").style.display = "none";

     }



  $.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{

        document.getElementById("Submit").style.display = "block";
       }



             }

       }else{

       if(rowctr == 0){
        document.getElementById("Submit").style.display = "none";

       }else{

        document.getElementById("Submit").style.display = "block";
       }
       }




 });
</script>

<!-- Total Trans Quantity -->
<script>

    function RecivedQuantityy(r){

        var Qty = $('#RQuantityHidee'+r).val();
        var RecivedQty = $('#RecivedQuantity'+r).val();
        var Price = $('#Price'+r).val();
        var TaxType = $('#TaxType'+r).val();
        var TaxRate = $('#TaxRate'+r).val();
        var Discount = $('#Discount'+r).val();
        var CostPrice = $('#CostPrice'+r).val();
        var i = 0;
        var ii=0;
        var iii=0;
        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(RecivedQty) * parseFloat(Discount) ;
                     var ffg =  parseFloat(RecivedQty) * parseFloat(CostPrice) ;
             $("#TDiscProEdit"+r).val(parseFloat(BFG));
             $("#Return_Discount"+r).val(parseFloat(BFG));

 var z = parseFloat(Qty) - parseFloat(RecivedQty) ;

        $('#RQuantity'+r).val(parseFloat(z));
        $('#RQuantityHide'+r).val(parseFloat(z));

        $('#ReturnCostPrice'+r).val(parseFloat(ffg));

  if(TaxType == 1){
           //Precent

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

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

       i =    parseFloat(TaxRate)  / 100 ;

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

           $("#TransTotTax"+r).val(parseFloat(ii).toFixed(2));
           $("#TransTotTaxHide"+r).val(parseFloat(ii).toFixed(2));

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

           $("#TransTot"+r).val(parseFloat(iii).toFixed(2));
           $("#TransTotHide"+r).val(parseFloat(iii).toFixed(2));

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

            i =    parseFloat(TaxRate)   ;

           $("#TransTotTax"+r).val(parseFloat(i).toFixed(2));
           $("#TransTotTaxHide"+r).val(parseFloat(i).toFixed(2));

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

           $("#TransTot"+r).val(parseFloat(iii).toFixed(2));
           $("#TransTotHide"+r).val(parseFloat(iii).toFixed(2));


       }

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

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


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


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

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

  $('#Total_Cost_Return_Value').val(parseFloat(sumTRcost).toFixed(2));



       $('#Total_Trans_Qty').val(parseFloat(sumQ));
        $('#Total_Trans_QtyHide').val(parseFloat(sumQ));

         $('#Total_Trans_Value').val(parseFloat(sumT));
        $('#Total_Trans_ValueHide').val(parseFloat(sumT));

           $('#RTotal_Bf_Taxes').val(parseFloat(sumTBF));
        $('#RTotal_Bf_TaxesHide').val(parseFloat(sumTBF));

           $('#RTotal_Taxes').val(parseFloat(sumTax));
        $('#RTotal_TaxesHide').val(parseFloat(sumTax));


                  var sumTTD = 0;
   $('.Disc').each(function(){
   sumTTD += parseFloat($(this).val());
   });
        $('#Total_DiscountTT').val(parseFloat(sumTTD).toFixed(2));
   $('#Total_DiscountHideTT').val(parseFloat(sumTTD).toFixed(2));
    var   Tooot=  $('#Total_Trans_Qty').val();
    var   Total_Trans_ValueHide=  $('#Total_Trans_ValueHide').val();
                      var XX = 0;



        if(parseFloat(Tooot) != 0 || parseFloat(Tooot) > 0){

             if(parseFloat(RecivedQty) > parseFloat(Qty)){


           document.getElementById("recived").style.display = "none";
           document.getElementById("TR"+r).style.border = "solid 1px red";

             $('#X'+r).val(1);


       }else{

                if(parseFloat(RecivedQty) < 0){
                         document.getElementById("recived").style.display = "none";
           document.getElementById("TR"+r).style.border = "solid 1px red";

             $('#X'+r).val(1);
                }else{
                   document.getElementById("recived").style.display = "none";
     document.getElementById("TR"+r).style.border = "none";
           $('#X'+r).val(0);
                }


       }

        }else{


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


           $('.X').each(function(){
   XX += parseFloat($(this).val());
   });


        if(parseFloat(XX) == 0){
        if(Total_Trans_ValueHide == 'NaN' || Total_Trans_ValueHide == 0){

                 document.getElementById("recived").style.display = "none";

        }else{

             document.getElementById("recived").style.display = "block";

        }

       }else{

         document.getElementById("recived").style.display = "none";

       }


    }

</script>

<!-- Scanner  problem -->
<script>
   $(".form-control").keypress(function(event){
   if (event.which == '10' || event.which == '13') {
   event.preventDefault();
   }
   });


</script>


<!-- Safe Balnces  -->
<script>
   $(document).ready(function() {

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

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


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

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

                  });

              });

     $(document).ready(function() {

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

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


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

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


              });
</script>


<?php $__env->stopPush(); ?>

<?php echo $__env->make('admin.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/klarapps/public_html/test.klarapps.com/resources/views/admin/Sales/ReturnSales.blade.php ENDPATH**/ ?>