<?php $__env->startSection('title','تقرير كشف حساب موظف'); ?>
<?php $__env->startSection('content'); ?>
<div class="app-content content ">
      <div class="content-overlay"></div>
      <div class="header-navbar-shadow"></div>
      <div class="content-wrapper container-xxl p-0">
        <div class="content-header row">
        </div>
    <div class="content-body">
	<!-- Dashboard Ecommerce Starts -->
		<section id="dashboard-ecommerce">
		<div class="content-header row">
          <div class="content-header-left col-md-9 col-12 mb-2">
            <div class="row breadcrumbs-top">
              <div class="col-12">
                <h2 class="content-header-title float-start mb-0">كشف حساب موظف</h2>
                <div class="breadcrumb-wrapper">
                  <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="<?php echo e(route('client.home')); ?>">لوحة التحكم</a>
                    </li>
                    <li class="breadcrumb-item"><a href="<?php echo e(route('client.reports')); ?>">التقارير </a>

                    <li class="breadcrumb-item active">كشف حساب موظف 
                    </li>
                  </ol>
                </div>
              </div>
            </div>
          </div>
          <div class="content-header-right text-md-end col-md-3 col-12 d-md-block d-none">
            <div class="mb-1 breadcrumb-right">
			
              <div class="dropdown">
               				
            </div>
          </div>
        </div>
            <div class="col-xl-12 col-md-12 col-12">
                <div class="card">
                    <form  id="search" method="post" action="<?php echo e(route('clients.summary.post')); ?>" >
                      <?php echo csrf_field(); ?>
                      <input name ="company_id" type="hidden" value="<?php echo e($company_id); ?>">
                    <div class="card-body row" align="center">
                        <div class="col-lg-2 col-sm-6-md-6"></div>

                        <div class="col-lg-6 col-sm-6-md-6 ">


                            <div class= "row">
                        <div class="col-lg-4 col-sm-6-md-6 mb-1">
                            <center> <label class="form-label" style="font-weight:bold " > إختر الموظف </label></center>
                        <select  name="employee_id" id="employee_id" class="form-control select2">
                       <option value="">إختر موظف</option>
                       <?php $__currentLoopData = $employees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $employee): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                           <option value="<?php echo e($employee->id); ?>"><?php echo e($employee->name); ?></option>
                       <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                   </select>   
                        </div>
                        <div class="col-lg-4 col-sm-6-md-6 mb-1">
                            <center> <label class="form-label" style="font-weight:bold " > من تاريخ</label></center>
                   <input type="date" name="from_date" id="from_date" class="form-control" >
                       
                </div>
                <div class="col-lg-4 col-sm-6-md-6 mb-1">
                    <center> <label class="form-label" style="font-weight:bold " > إلي تاريخ</label></center>
                    <input type="date" name="to_date" id="to_date" class="form-control" >
                   </div>
                            </div>
                </div>
                        <div class="col-lg-4 col-sm-6-md-6">
                            <center> <label class="form-label" style="font-weight:bold " ></label></center>
            
                            <button type="submit" class="btn btn-success me-1">بحث</button>
            
                         </div>
                      </div>
                    </form>
                </div>
              </div>
              
      <div class="col-xl-12 col-md-12 col-12" id="data-card" style="display: none">
        <div class="card card-statistics">

      <div class="card-body statistics-body">
        <div class="row">

          <div class="card-body" align="center" id="loader">
              <div class="spinner-border text-primary" style="width: 5rem; height: 5rem" role="status">
              </div>
            </div> 

              <div id="header" style="display: none">
            <center>
                <h3 id="header-title"></h3>
                <br>
            </center>
              </div>
                      <div class="card-datatable">
                          <div class="table-responsive">
                              <table class="table table-condensed table-striped table-bordered text-center table-hover " id="employee">
                                  <thead>
                                  <tr>
                                      <th>اسم الموظف</th>
                                      <th>المرتب </th>
                                  </tr>
                                  </thead>
                                  <tbody class="tbody">
                                  </tbody>
                              </table>
                          </div>
                          
                      </div>

                      <div class="divider"></div>

                      <div class="divider divider-primary table">
                          <div class="divider-text"> <h4 id="header-title">    الدفعات  </h4></div>
                          <br>
                      </div>

                    <div class="card-datatable">
                      <div class="table-responsive">
                          <table class="table table-condensed table-striped table-bordered text-center table-hover" id="cash">
                              <thead>
                              <tr>
                                <th>المبلغ </th>
                                <th> الخزنة </th>
                                <th> ملاحظات </th>
                                <th> التاريخ </th>
                                <th> المسؤل </th>
                              </tr>
                              </thead>
                              <tbody class="tbody">
                                  
                              </tbody>
                          </table>
                      </div>
                  </div>
          
        </div>
      </div>
    </div>
  </div>
  <center>
    <div class="col-lg-4 col-md-12" style="display: none" id="additionalData">
      <div class="card" >
        <div class="card-header"  >
          <h4 class="card-title">مختصر عن دفعات الموظف</h4>
        </div>
        <div class="card-body">
          <p class="card-text">
           
          </p>
          <ul class="list-group">
            <li class="list-group-item list-group-item-primary">
              إجمالي الدفعات :
              <span class="badge bg-primary rounded-pill" id="total"></span>
              <?php echo e($company->currency); ?>

            </li>
          </ul>
        </div>
      </div>
    </div>
    </center>
            
          </div>
        </div>
      </div>
    </div>
	</section>

	</div>
      </div>
    </div>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('script'); ?>
<script src="<?php echo e(asset('app-assets/js/select2.min.js')); ?>"></script>
<script>
    $(document).ready(function() {
        $('.select2').select2();
    });


$("#search").on('submit',(function(e) {
e.preventDefault();
  filter();
}));
  var table = $('.table') ;
  function filter() {

var employee = $('#employee_id').val();
var from_date = $('#from_date').val();
var to_date = $('#to_date').val();

if(from_date == '' || to_date == ''){$('#header-title').text('جميع دفعات الموظف ' )}else{$('#header-title').text(' جميع دفعات الموظف من تاريخ '+from_date+' إلي تاريخ '+to_date )}
$.ajax({
    url: "<?php echo e(route('employees.summary.post')); ?>",
    type: "POST",
    data: {
        "_token": "<?php echo e(csrf_token()); ?>",
        "employee": employee,
        "from_date": $("#from_date").val(),
        "to_date" : $("#to_date").val()
    },
    beforeSend : function (){table.hide(); $('#additionalData').hide(); $('#header').hide(); $('#data-card').show();$('#loader').show(); var ifConnected = window.navigator.onLine;if (!ifConnected) {toastr.info("يتم الآن إعادة الإتصال","لا يوجد إتصال بالإنترنت",{positionClass: "toast-top-right",tapToDismiss: !1,timeOut: 2e3,rtl: $("html").attr("data-textdirection")});}},
    success: function (data) {
        $('#loader').hide();
        table.show();
        $('.tbody').empty();
        $('#header').show();
        $('#additionalData').show();


        $('#employee').append(
                '<tr>'+
                '<td>'+data.employee.name+'</td>'+
                '<td>'+data.employee.salary+'</td>'+
                '</tr>'
            );

            var  total = 0;

        $.each( data.result, function( key, value ) {
            total += parseFloat(value.amount);
            $('#cash').append(
                '<tr>'+
                '<td>'+(value.amount)+'</td>'+
                '<td>'+(value.safe.safe_name)+'</td>'+
                '<td>'+value.notes+'</td>'+
                '<td>'+(value.date)+'</td>'+
                '<td>'+value.client.name+'</td>'+
                '</tr>'
            );
        });
        $('#total').text(total);
        if(data.result == ''){ $('#cash').append('<tr style="font-weight:bold;">'+'<td colspan="5">لا يوجد أي معاملات  </td>'+'</tr>')}

          },
   error: function (data) {

    }
});
};


var selectForm = $('#search');

if (selectForm) {
    selectForm.validate({

        rules: {
      'bank_id': {
        required: true,
      }
    }
  });
}
   </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('client.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/barasys/public_html/resources/views/client/summary/employees.blade.php ENDPATH**/ ?>