<?php $__env->startSection('content'); ?>
<?php
use App\Models\SalesDefaultData;
$Def=SalesDefaultData::orderBy('id','desc')->first();
?>

     <title><?php echo e(trans('admin.AddSalary')); ?></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.HR')); ?> </a></li>
                        <li class="breadcrumb-item active"><?php echo e(trans('admin.AddSalary')); ?>  </li>
                        <li class="position-absolute pos-top pos-right d-none d-sm-block"><span
                                class="js-get-date"></span></li>
                    </ol>
        
                    <form action="<?php echo e(url('PostAddSalary')); ?>" method="post">
                         <?php echo csrf_field(); ?>

                              <?php echo view('honeypot::honeypotFormFields'); ?>
                            <div class="row">
                                    <div class="col-xl-12">
                                        <div  class="panel">
                                            <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="modal-header">
                                                        <h5 class="modal-title"><?php echo e(trans('admin.AddSalary')); ?>  </h5>
                                                    </div>
                                                    <div class="panel-container show">
                                                        <div class="panel-content">
                                              
                                        <div class="form-row">
                                      <div class="form-group col-lg-3">
                                            <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Code')); ?> </label>
                                            <input type="text" value="<?php echo e($Code); ?>" class="form-control " disabled>
                                            <input type="hidden" name="Code" value="<?php echo e($Code); ?>" class="form-control">
                                        </div>
                                        <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>
                                        <div class="form-group col-lg-3">
                               <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Borrow_Month')); ?></label>
                <input onchange="Check()" type="month" id="Month" name="Month" value="<?php echo e(date('Y-m')); ?>" class="form-control" required>
                                        </div>        
                                        <div class="form-group col-lg-3">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Safe')); ?></label>
                                            <select class="select2 form-control w-100" name="Safe" id="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($Def->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-3">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Coin')); ?></label>
                                            <select class="select2 form-control w-100" name="Coin" required>
                                                 <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($Def->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>
                                        </div>
                                        <div class="form-group col-lg-3">
                                            <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Draw')); ?></label>
                                            <input type="text" name="Draw" value="1" class="form-control" required>
                                        </div>
                                            <div class="form-group col-lg-3">
                                            <label class="form-label" for=""> <?php echo e(trans('admin.Cost_Center')); ?> </label>
                                            <select class="select2 form-control w-100" name="Cost_Center">
                                            <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 echo e(app()->getLocale() == 'ar' ?$cost->Arabic_Name :$cost->English_Name); ?>                
                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>  
                                            </select>
                                        </div>
                                        <div class="form-group col-lg-3">
                                            <label class="form-label" for=""><?php echo e(trans('admin.Employee')); ?></label>
                               <select onchange="Check()" class="js-data-example-ajax form-control w-100" id="Emp" name="Emp" required>

                                            </select>
                        

                                        </div>
      
                                        <div class="form-group col-lg-3">
                                 <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Salary')); ?>     </label>
                                            <input type="text" id="Salary"  disabled  class="form-control">
                                   <input type="hidden" name="Salary" id="SalaryHide" >
                                        </div>
                                  
                                            
                                 <div class="form-group col-lg-3">
                                 <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Total_Borrow')); ?>    </label>
                                   <input type="text" id="TotalBorrow"  disabled class="form-control">
                                       <input type="hidden" name="Borrow" id="TotalBorrowHide" >                      
                                        </div>            
                                                       
                                            
                                                        <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Deducation')); ?>    </label>
                                   <input type="text" id="Deduction"  disabled class="form-control">
                                       <input type="hidden" name="Deduction" id="DeductionHide" >                      
                                        </div>
                                            
                                            
                                         <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Entitlements')); ?>    </label>
                                   <input type="text" id="Entitlement"  disabled class="form-control">
                                       <input type="hidden" name="Entitlement" id="EntitlementHide" >                      
                                        </div>
                                       
                                      <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Loan_Installment')); ?>    </label>
                                   <input type="text" id="Loan"  disabled class="form-control">
                                       <input type="hidden" name="Loan" id="LoanHide" >                      
                                        </div>                        

                                <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Overtime')); ?>    </label>
                                   <input type="text" id="Overtime"  disabled class="form-control">
                                       <input type="hidden" name="Overtime" id="OvertimeHide" >                      
                                        </div>                            
                                            
                                   <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Attendence_Hours')); ?>    </label>
                                   <input type="text" id="Attendence_Hours"  disabled class="form-control">
                                    <input type="hidden" name="Attendence_Hours" id="Attendence_HoursHide" >
                                        </div>  
                                            
                                <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Attendence')); ?>    </label>
                                   <input type="text" id="Attendence"  disabled class="form-control">
                                    <input type="hidden" name="Attendence" id="AttendenceHide" >
                                        </div> 
                                            
                                            <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Attendence_Discount')); ?>    </label>
                 <input type="number" step="any" onclick="change()" onkeyup="change()" name="Attendence_Discount" id="Attendence_Discount"   class="form-control">
                                 <!--   <input type="hidden" name="Attendence_Discount" id="Attendence_DiscountHide" >  -->          
                                        </div>                     
                                            
               <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Holidays_Per_Days')); ?>    </label>
                                   <input type="text" id="Holidays"  disabled class="form-control">
                                    <input type="hidden" name="Holidays" id="HolidaysHide" >
                                        </div>  
                                            
                                          <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Holiday_Discount')); ?>    </label>
                      <input  type="number" step="any" onclick="change()" onkeyup="change()" id="Holiday_Discount"  name="Holiday_Discount"  class="form-control">
                                  <!--  <input type="hidden" name="Holiday_Discount" id="Holiday_DiscountHide" >  -->         
                                        </div>                         

                                                    
                                            <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Settlements')); ?>    </label>
      <input type="number" step="any" onclick="change()" onkeyup="change()" id="Settlements"  disabled class="form-control">
                                       <input type="hidden" name="Settlements" id="SettlementsHide" >                      
                                        </div>                
                                      
                                               <div class="form-group col-lg-3" style="display: none">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Later_Sales_Bill')); ?>    </label>
                                   <input type="text" id="Later_Sales_Bill"  class="form-control" name="Later_Sales_Bill">
                                       <input type="hidden"  id="Later_Sales_BillHide" >                      
                                        </div>                    
                                            
                     
                                             <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Allowances')); ?>    </label>
                                   <input type="text" id="Allowances" name="Allowances" readonly class="form-control">
                                        </div> 
                                            
                                            
                                                                    <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Discounts')); ?>    </label>
                                   <input type="text" id="Discounts" name="Discounts" readonly class="form-control">
                                        </div>   
                                            

                                           <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.ProducationPoints')); ?>    </label>
                                   <input type="text" id="ProducationPoints" name="ProducationPoints" readonly class="form-control">
                                        </div>   
                                            
                                                                <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.DiscountLate')); ?>    </label>
                                   <input type="text" id="DiscountLate" name="DiscountLate" readonly class="form-control">
                                        </div>   
                                            
                                                                 <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.DiscountDeparture')); ?>    </label>
                                   <input type="text" id="DiscountDeparture" name="DiscountDeparture" readonly class="form-control">
                                        </div>   
                                            
                                      <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Shipping_Precent')); ?>    </label>
                                   <input type="text" id="Shipping_Precent" name="Shipping_Precent" readonly class="form-control">
                                        </div>   

                            <div class="form-group col-lg-3">
                <label class="form-label" for="simpleinput">   <?php echo e(trans('admin.Resduial_Salary')); ?>    </label>
                                   <input type="text" id="Resduial_Salary"  disabled class="form-control">
                                    <input type="hidden" name="Resduial_Salary" id="Resduial_SalaryHide" >
                                        </div>  
 
                                        <div class="form-group col-lg-12">
                                            <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Notes')); ?>  </label>
                                            <input type="text" name="Note" value="<?php echo e(old('Note')); ?>" class="form-control">
                                        </div>            
                                     
                                    
                                    <div class="form-row" style="display: none" id="Alert">
                                      <span id="ALertText" class="alert alert-danger"></span>
                                            </div>    
                                            
                                    <div class="form-row" style="display: none" id="Submit">
                                  <input type="hidden" class="form-control btn btn-primary" id="SafeBalance" value="0">
                                     
                            <button type="submit" class="btn btn-primary">
                                        <?php echo e(trans('admin.Save')); ?>

                                        </button>                
                                            </div>        
                                            
                                        </div>
                     
                        
                        
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                </div>
    </div>
               </form>
</main>

<?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/select2/select2.bundle.css')); ?>">
    <script src="<?php echo e(asset('Admin/js/formplugins/select2/select2.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/datagrid/datatables/datatables.bundle.js')); ?>"></script>

    <script>
        //_fnFeatureHtmlLength();
        $(document).ready(function () {
            // Setup - add a text input to each footer cell
            $('#dt-basic-example thead tr').clone(true).appendTo('#dt-basic-example thead');
            $('#dt-basic-example thead tr:eq(1) th').each(function (i) {
                var title = $(this).text();
                $(this).html('<input type="text" class="form-control form-control-sm" placeholder="Search ' + title + '" />');

                $('input', this).on('keyup change', function () {
                    if (table.column(i).search() !== this.value) {
                        table
                            .column(i)
                            .search(this.value)
                            .draw();
                    }
                });
            });
            var table = $('#dt-basic-example').DataTable(
                {
                    responsive: true,
                    orderCellsTop: true,
                    fixedHeader: true,
                    lengthChange: true,

                    dom: "<'row mb-3'<'col-sm-12 col-md-3 d-flex align-items-center justify-content-start'f><'col-sm-12 col-md-9 d-flex align-items-center justify-content-end'B>>" +
                        "<'row'<'col-sm-12'tr>>" +
                        "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",

                    buttons: [
                        {
                            extend: 'pageLength',
                            className: 'btn-outline-default'
                        },
                        {
                            extend: 'colvis',
                            text: 'Column Visibility',
                            titleAttr: 'Col visibility',
                            className: 'btn-outline-default'
                        },
                        {
                            extend: 'pdfHtml5',
                            text: 'PDF',
                            titleAttr: 'Generate PDF',
                            className: 'btn-outline-danger btn-sm mr-1'
                        },
                        {
                            extend: 'excelHtml5',
                            text: 'Excel',
                            titleAttr: 'Generate Excel',
                            className: 'btn-outline-success btn-sm mr-1'
                        },
                        {
                            extend: 'csvHtml5',
                            text: 'CSV',
                            titleAttr: 'Generate CSV',
                            className: 'btn-outline-primary btn-sm mr-1'
                        },
                        {
                            extend: 'copyHtml5',
                            text: 'Copy',
                            titleAttr: 'Copy to clipboard',
                            className: 'btn-outline-primary btn-sm mr-1'
                        },
                        {
                            extend: 'print',
                            text: 'Print',
                            titleAttr: 'Print Table',
                            className: 'btn-outline-primary btn-sm'
                        }
                    ],
                });
            $('.js-thead-colors a').on('click', function () {
                var theadColor = $(this).attr("data-bg");
                console.log(theadColor);
                $('#dt-basic-example thead').removeClassPrefix('bg-').addClass(theadColor);
            });

            $('.js-tbody-colors a').on('click', function () {
                var theadColor = $(this).attr("data-bg");
                console.log(theadColor);
                $('#dt-basic-example').removeClassPrefix('bg-').addClass(theadColor);
            });

        });

    </script>


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

        });
    });
</script>

<!-- Safe Balnces  -->
<script>
   $(document).ready(function() {
   
                  $('#Safe').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 = $('#Safe').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>  

<!-- Check Emp -->
<script>

   function  Check(){
   
   var Emp = $('#Emp').val();
   var Month = $('#Month').val();
  
                     if(Emp) {
                         $.ajax({
                             url: 'EmpCheckSalary/'+Emp+'/'+Month,
                             type:"GET",
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },
   
                             success:function(data) {
                                 $.each(data, function(key, value){
                                     
                       $('#TotalBorrow').val(data.Total); 
                       $('#TotalBorrowHide').val(data.Total); 
                       $('#Salary').val(data.Salary); 
                       $('#SalaryHide').val(data.Salary); 
                       $('#Deduction').val(data.Dedu);              
                       $('#DeductionHide').val(data.Dedu); 
                       $('#Entitlement').val(data.Entit);              
                       $('#EntitlementHide').val(data.Entit);           
                       $('#Loan').val(data.Loan);              
                       $('#LoanHide').val(data.Loan); 
                       $('#Overtime').val(data.Over); 
                       $('#OvertimeHide').val(data.Over); 
                       $('#Attendence_Hours').val(data.HWork); 
                       $('#Attendence_HoursHide').val(data.HWork); 
                       $('#Attendence').val(data.Att); 
                       $('#AttendenceHide').val(data.Att); 
                       $('#Attendence_Discount').val(data.AttDisc); 
                       $('#Attendence_DiscountHide').val(data.AttDisc); 
                       $('#Holidays').val(data.Holi); 
                       $('#HolidaysHide').val(data.Holi); 
                       $('#Holiday_Discount').val(data.HoliDisc); 
                       $('#Holiday_DiscountHide').val(data.HoliDisc);                    
                       $('#SettlementsHide').val(data.Settle); 
                       $('#Settlements').val(data.Settle);                 
                       $('#Later_Sales_Bill').val(data.later); 
                       $('#Later_Sales_BillHide').val(data.later);   
                       $('#Allowances').val(data.Allowances);   
                       $('#Discounts').val(data.Discounts);   
                       $('#ProducationPoints').val(data.Points);   
                       $('#DiscountLate').val(data.DiscountLate);   
                       $('#DiscountDeparture').val(data.DiscountDeparture);   
                       $('#Shipping_Precent').val(data.Shipping_Precent);   
        
                                     
        var  Borrow=  $('#TotalBorrow').val(); 
         var  Salary=  $('#Salary').val(); 
        var  Deduction=  $('#Deduction').val();   
        var  Entitlement=  $('#Entitlement').val();   
        var  Loan=  $('#Loan').val();    
        var  Overtime=  $('#Overtime').val(); 
       var  Attendence_Discount=  $('#Attendence_Discount').val(); 
       var  Holiday_Discount=   $('#Holiday_Discount').val(); 
       var  Settlements=   $('#Settlements').val(); 
       var  Later_Sales_Bill=   $('#Later_Sales_Bill').val(); 
       var  Allowances=   $('#Allowances').val(); 
       var  Discounts=   $('#Discounts').val(); 
       var  ProducationPoints=   $('#ProducationPoints').val(); 
       var  DiscountLate=   $('#DiscountLate').val(); 
       var  DiscountDeparture=   $('#DiscountDeparture').val(); 
       var  Shipping_Precent=   $('#Shipping_Precent').val(); 
       
       
                                     
        var result = 
         
   ( parseFloat(Salary) +  parseFloat(Entitlement) + parseFloat(Overtime) + parseFloat(Allowances) + parseFloat(ProducationPoints) + parseFloat(Shipping_Precent) )               
            
            -
            
    ( parseFloat(Borrow) + parseFloat(Deduction) + parseFloat(Loan) + parseFloat(Attendence_Discount) + parseFloat(Holiday_Discount) + parseFloat(Settlements) + parseFloat(Later_Sales_Bill) + parseFloat(Discounts) + parseFloat(DiscountLate) + parseFloat(DiscountDeparture))   
            
        ;
                  
                $('#Resduial_Salary').val(parseFloat(result).toFixed(2));                       
                $('#Resduial_SalaryHide').val(parseFloat(result).toFixed(2));                       

                          var S = data.New ;
                     
                if(S == 1){
    document.getElementById("Submit").style.display = "none";              
                    document.getElementById("Alert").style.display = "block"; 
                      $('#ALertText').text('تم تسليم راتب هذا الشهر لهذا الموظف من قبل');      
    
}else{
    
    var RS= $('#Resduial_Salary').val();
    if(RS == 0 || RS < 0){
      
        document.getElementById("Submit").style.display = "none";              
                    document.getElementById("Alert").style.display = "block"; 
                      $('#ALertText').text('لا يوجد متبقي من الراتب ليتم صرفه');      
        
    }else{

        document.getElementById("Submit").style.display = "block";              
                    document.getElementById("Alert").style.display = "none"; 
                      $('#ALertText').text(''); 
    }
    
    
}

                                 });
                                
                             var SafeBalance= $('#SafeBalance').val();   
           var Amount= $('#Resduial_Salary').val();   
        
            if(parseFloat(Amount) > parseFloat(SafeBalance)){
  alert('المبلغ غير كافي في الخزينه');
                  document.getElementById("Submit").style.display = "none";              
   
         }
                                 
                                 
                             }
                                 });
                     }
   }
   
      
</script>  

<!-- Change -->
<script>
     function  change(){
         
         var  Borrow=  $('#TotalBorrow').val(); 
         var  Salary=  $('#Salary').val(); 
        var  Deduction=  $('#Deduction').val();   
        var  Entitlement=  $('#Entitlement').val();   
        var  Loan=  $('#Loan').val();    
        var  Overtime=  $('#Overtime').val(); 
       var  Attendence_Discount=  $('#Attendence_Discount').val(); 
       var  Holiday_Discount=   $('#Holiday_Discount').val(); 
       var  Settlements=   $('#Settlements').val(); 
       var  Later_Sales_Bill=   $('#Later_Sales_Bill').val(); 
                       var  Allowances=   $('#Allowances').val(); 
       var  Discounts=   $('#Discounts').val(); 
       var  ProducationPoints=   $('#ProducationPoints').val(); 
       var  DiscountLate=   $('#DiscountLate').val(); 
       var  DiscountDeparture=   $('#DiscountDeparture').val(); 
       var  Shipping_Precent=   $('#Shipping_Precent').val(); 
                          
        var result = 
         
   ( parseFloat(Salary) + parseFloat(Entitlement) + parseFloat(Overtime) + parseFloat(Allowances) + parseFloat(ProducationPoints) + parseFloat(Shipping_Precent) )               
            
            -
            
    ( parseFloat(Borrow) + parseFloat(Deduction) + parseFloat(Loan) + parseFloat(Attendence_Discount) + parseFloat(Holiday_Discount) +  parseFloat(Settlements) +   parseFloat(Later_Sales_Bill)  + parseFloat(Discounts) + parseFloat(DiscountLate) + parseFloat(DiscountDeparture))   
            
        ;
                  
                $('#Resduial_Salary').val(parseFloat(result).toFixed(2));                       
                $('#Resduial_SalaryHide').val(parseFloat(result).toFixed(2));        
         
         
         var RS= $('#Resduial_Salary').val();
    if(RS == 0 || RS < 0){
      
        document.getElementById("Submit").style.display = "none";              
                    document.getElementById("Alert").style.display = "block"; 
                      $('#ALertText').text('لا يوجد متبقي من الراتب ليتم صرفه');      
        
    }else{

        document.getElementById("Submit").style.display = "block";              
                    document.getElementById("Alert").style.display = "none"; 
                      $('#ALertText').text(''); 
    }
  
              var SafeBalance= $('#SafeBalance').val();   
           var Amount= $('#Resduial_Salary').val();   
        
            if(parseFloat(Amount) > parseFloat(SafeBalance)){
  alert('المبلغ غير كافي في الخزينه');
                  document.getElementById("Submit").style.display = "none";              
   
         } 
         
         
         
     }

</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/1.klarapps.com/resources/views/admin/HR/AddSalary.blade.php ENDPATH**/ ?>