<?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 active">المحاسبة
                    </li>
                    <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" name="date" >
                    <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">
                           <center> <label class="form-label" style="font-weight:bold " >إختر التاريخ لعرض جدول اليومية الخاص به</label></center>
                            <input type="date" class="form-control"name="date"  id="date" value="<?php echo e(date('Y-m-d')); ?>" >
                        </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">
          <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 class="table-responsive">
                        <div class="card-datatable">
                            <div class="table-responsive">
                                <table  class="table" id="table" style="display:none" >

                                    <thead>
                                    <tr>
                                        <th>رقم القيد</th>
                                        <th>التاريخ</th>
                                        <th>بيان القيد</th>
                                        <th>مدين</th>
                                        <th>داين</th>




                                    </tr>
                                    </thead>
                                    <tbody id="tbody">
                                       
                                    </tbody>
                                </table>
                            </div>
                            
                        </div>
            </div>
          </div>
        </div>
      </div>
    </div>
	</section>

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

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

      filter(); 
      var table =$('#table')
       function filter() {

var date = $('#date').val();
$.ajax({
    url: "<?php echo e(route('client.journal.post')); ?>",
    type: "POST",
    data: {
        "_token": "<?php echo e(csrf_token()); ?>",
        "date": date,
    },
    beforeSend : function (){$('#table').hide(); $('#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();
        let count = 0 ;
        var credit =0 ;
        var debit =0 ;
        $.each( data.jornal, function( key, value ) {
             credit +=  Math.abs(parseFloat(value.credit)) ;
             debit +=  Math.abs(parseFloat(value.debit)) ;

            table.append(
                '<tr>'+
                '<td>'+(++count)+'</td>'+
                '<td>'+value.date.split('T')[0]+'</td>'+
                '<td style="font-weight:bold;">'+value.explanation+'</td>'+
                '<td>'+Math.abs(value.debit)+'</td>'+
                '<td>'+Math.abs(value.credit)+'</td>'+
                '</tr>'
            );
            
        });
        if(data.jornal != ''){
        table.append(
                '<tr style="background-color: #F3F2F7; color:#151617; font-weight:bold;" >'+
                '<td colspan="3">ميزان المراجعة</td>'+
                '<td>'+debit+'</td>'+
                '<td>'+credit+'</td>'+
                '</tr>'
            )
       
                }else{table.append('<tr style="background-color: #dfbfbf;font-weight:bold;">'+'<td colspan="5">لا يوجد أي معاملات مالية في هذا اليوم</td>'+'</tr>')}
    },
    error: function (data) {

    }
});
};



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

<?php $__env->startSection('style'); ?>
<style>
   

td{
	text-align:center;
	border:2px solid black; 
}thead{
	border-bottom: 2px solid;
	border:2px solid black; 
}
th{
    border-bottom: 2px solid;
	text-align:center;
	border:2px solid black; 
}
.table {
    vertical-align: bottom;
    border-bottom: 2px solid #151617;
	border:2px solid black; 

}

</style>
<?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/daily/daily.blade.php ENDPATH**/ ?>