

<?php $__env->startSection('title', 'Daily Summary Report'); ?>

<?php $__env->startPush('css'); ?>
<!-- bootstrap-datetimepicker -->
	<link rel="stylesheet" href="<?php echo e(asset('myfile/backend/assets/datepicker/zebra_datepicker.min.css')); ?>" type="text/css">
	<link rel="stylesheet" href="<?php echo e(asset('myfile/backend/assets/datepicker/examples.css')); ?>" type="text/css">
	<style>
		#search-btn{
			margin-top:24px;
		}
	</style>
<?php $__env->stopPush(); ?>
<?php $__env->startSection('content'); ?>
	<div class="right_col" role="main">
		<div class="x_panel">
			<div class="x_title">
				<h2 class="widget-title">Daily Summary Report</h2>
				<ul class="nav navbar-right panel_toolbox">
					<!--<li><a class="collapse-link" onclick="printDiv('printableArea')" ><i class="fa fa-print"></i></a></li>-->
					<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
					<li class="dropdown">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
						<ul class="dropdown-menu" role="menu">
							<li><a href="#">Settings 1</a>
							</li>
							<li><a href="#">Settings 2</a>
							</li>
						</ul>
					</li>
					<li><a class="close-link"><i class="fa fa-close"></i></a>
					</li>
				</ul>
				<div class="clearfix"></div>
			</div>
			<div class="x_content">
			    <div class="row">
			        <form action="<?php echo e(route('ledger.daily_summary')); ?>" method="Post" >
			            <?php echo e(method_field('Get')); ?>

			            <div class="col-sm-4"></div>
			            <div class="col-sm-4">
			                <div class="form-group">
                                <input id="datepicker" type="text" name="summary_date"  class="form-control" data-zdp_readonly_element="false" value="<?php echo e(date('d-m-Y',strtotime($today))); ?>" placeholder="dd-mm-yyyy">
                                <p class="error-sms"><?php echo e($errors->first('summary_date')); ?></p>
                            </div>
			            </div>
		            	<div class="col-sm-1">
							<div class="form-group">
								<button class="btn btn-primary btn-xs" id="search-bt">
									<i class="ace-icon fa fa-search fa-2x icon-only"></i>
								</button>
							</div>
						</div>
						<div class="col-sm-1">
							<a href="#" id="search-bt" class="btn btn-primary btn-xs" onclick="printDiv('printableArea')">
								<i class="ace-icon fa fa-print fa-2x icon-only"></i>
							</a>
						</div>
				    </form>
			    </div>
			    <hr/>
				<div class="" id="printableArea">
					<div class="row">
						<div class="col-xs-12 col-sm-12">
							<div class="row">
								<div class="col-xs-1"></div>
								<div class="col-xs-1">
									<img src="<?php echo e(asset('storage/about/'.about()->logo)); ?>" class="img-responsive img-thumbnail" alt="logo" width="85px" height="75px" >
								</div>
								<div class="col-xs-8">
									<div class="text-center">
										<h4><?php echo e(about()->english_name); ?></h4>
										<p>Phone:  <?php echo e(about()->phone); ?>, Email: <?php echo e(about()->email); ?></p>
										<p>Address: <?php echo e(about()->address); ?> </p>
										<h4>Daily Summary Report</h4>
										<p>Date: <span id="summary_date"><?php echo e(date('d-m-Y',strtotime($today))); ?></span> </p>
									</div>
								</div>
								<div class="col-xs-2">
								</div>
							</div>
							<hr/>
							<table class="table table-bordered" >
								<thead>
									<tr>
										<th>SL</th>
										<th>Description</th>
										<th>Transaction</th>
										<th>Receipt</th>
										<th>Payment</th>
									</tr>
								</thead>
								<tbody>
									<?php 
										$total = 0;
										$ex_total = 0;
									 ?>
								<?php $__currentLoopData = $sum; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$sm): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
									<?php 
										$total = $total + $sm['income'];
										$ex_total = $ex_total + $sm['expense'];
									 ?>
									<tr>
										<td><?php echo e($key + 1); ?></td>
										<th><a href="#" class="myModal"><?php echo e($sm['description']); ?></a></th>
										<td><?php echo e($sm['transaction']); ?></td>
										<td><?php echo e($sm['income']); ?></td>
										<td><?php echo e($sm['expense']); ?></td>
									</tr>
								<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
									<tr>
										<th colspan="2"></th>
										<th>Grand Total =</th>
										<th><?php echo e($total); ?></th>
										<th><?php echo e($ex_total); ?></th>
									</tr>
								</tbody>
							</table>
							<!--Saving Modal -->
							<div id="myModal" class="modal fade" role="dialog">
								<div class="modal-dialog">
									<div class="modal-content" >
										<div class="modal-header">
												<a href="#" id="" class="" onclick="printDiv('SavingPrintArea')"><i class="ace-icon fa fa-print fa-2x icon-only"></i></a>
												<button type="button" class="close" data-dismiss="modal">&times;</button>
											<div id="SavingPrintArea">
												<div class="text-center">
													<h3><?php echo e(about()->english_name); ?></h3>
													<h4>Daily Summary Details</h4>
													<p id="head_name"></p>
												</div>
												<div class="modal-body">
													<table class="table table-bordered table-condensed" id="modalTable">
														<thead>
															<tr>
																<th>SL</th>
																<th>Name</th>
																<th>Receipt</th>
																<th>Payment</th>
															</tr>
														</thead>
														<tbody>
														</tbody>
														<tfoot>
															<tr>
																<th colspan="2">Total:</th>
																<th id="credit_total"></th>
																<th id="debit_total"></th>
															</tr>
														</tfoot>
													</table>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php $__env->stopSection(); ?>

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

<!-- Jquery Plugin For Date Calender-->
<script type="text/javascript" src="<?php echo e(asset('myfile/backend/assets/datepicker/zebra_datepicker.src.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('myfile/backend/assets/datepicker/examples.js')); ?>"></script>
<script>
    $(document).ready(function(){
        $('#datepicker').Zebra_DatePicker({
            format: 'd-m-Y',
        });
	});
	/*------summary details------*/
	
	$(document).on('click','.myModal',function(){
		var table = $(this).html();
		var sdate = $('#summary_date').html();
		var token = "<?php echo e(csrf_token()); ?>";
		$.ajax({
			url: '<?php echo e(route('ledger.summaryDetails')); ?>',
			type: 'Get',
			data: {table: table,sdate:sdate, '_token' : token},
			dataType: 'json',
			success: function(response){
				//console.log(response)
				var len = response.length;
				//empty the table tbody
				$("#modalTable tbody tr").remove();
				$("#credit_total").html('');
				$("#debit_total").html('');
				var credit_total = 0;
				var debit_total = 0;

				for (var i = 0; i < len; i++) {
					var id = response[i]['id'];
					var name = response[i]['name'];
					var credit = response[i]['credit'] || 0;
					var debit = response[i]['debit'] || 0;
					credit_total+= parseInt(response[i]['credit'] || 0);
					debit_total+= parseInt(response[i]['debit'] || 0);
					/*--------------*/
					$("#modalTable tbody").append(
						"<tr>"
							+"<td>"+(i+1)+"</td>"
							+"<td>"+name+"</td>"
							+"<td>"+credit+"</td>"
							+"<td>"+debit+"</td>"
						+"</tr>"
					)
				}
				$("#head_name").html(table);
				$("#credit_total").html(credit_total);
				$("#debit_total").html(debit_total);
				$('#myModal').modal('show');	
			}
		});
	});
    function printDiv(divName) {
    	 var printContents = document.getElementById(divName).innerHTML;
    	 var originalContents = document.body.innerHTML;
    	 document.body.innerHTML = printContents;
    	 window.print();
    	 document.body.innerHTML = originalContents;
	}
</script>
<?php $__env->stopPush(); ?>
    
 
<?php echo $__env->make('backend.layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>