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

<script type="text/javascript" src="<?php echo e(asset('abserve/js/plugins/chartjs/Chart.min.js')); ?>"></script>
<div class="page-content row">
	<div class="page-header">
	  <div class="page-title">
		<h3><i class="fa fa-desktop"></i> Dashboard <small> Summary info site </small></h3>
	  </div>
		  
	</div>
	<div class="page-content-wrapper">  
	
	
	<?php if(Auth::check() && Auth::user()->group_id == 1): ?>

<!--<section>
	<div class="row m-l-none m-r-none m-t  white-bg shortcut " >
		<div class="col-sm-6 col-md-3 b-r  p-sm ">
			<span class="pull-left m-r-sm text-navy"><i class="fa fa-plus-circle"></i></span> 
			<a href="<?php echo e(URL::to('abserve/module')); ?>" class="clear">
				<span class="h3 block m-t-xs"><strong>  <?php echo e(Lang::get('core.dash_i_module')); ?>  </strong>
				</span> <small class="text-muted text-uc">  <?php echo e(Lang::get('core.dash_module')); ?></small>
			</a>
		</div>
		<div class="col-sm-6 col-md-3 b-r  p-sm">
			<span class="pull-left m-r-sm text-info">	<i class="fa fa-cogs"></i></span>
			<a href="<?php echo e(URL::to('abserve/config')); ?>" class="clear">
				<span class="h3 block m-t-xs"><strong> <?php echo e(Lang::get('core.dash_i_setting')); ?></strong>
				</span> <small class="text-muted text-uc">   <?php echo e(Lang::get('core.dash_setting')); ?> </small> 
			</a>
		</div>
		<div class="col-sm-6 col-md-3 b-r  p-sm">
			<span class="pull-left m-r-sm text-warning">	<i class="fa fa-sitemap"></i></span>
			<a href="<?php echo e(URL::to('abserve/menu')); ?>" class="clear">
			<span class="h3 block m-t-xs"><strong>  <?php echo e(Lang::get('core.dash_i_sitemenu')); ?> </strong></span>
			<small class="text-muted text-uc">  <?php echo e(Lang::get('core.dash_sitemenu')); ?>  </small> </a>
		</div>
		<div class="col-sm-6 col-md-3 b-r  p-sm">
			<span class="pull-left m-r-sm ">	<i class="fa fa-users"></i></span>
			<a href="<?php echo e(URL::to('core/users')); ?>" class="clear">
			<span class="h3 block m-t-xs"><strong> <?php echo e(Lang::get('core.dash_i_usergroup')); ?></strong>
			</span> <small class="text-muted text-uc">  <?php echo e(Lang::get('core.dash_usergroup')); ?> </small> </a>
		</div>
	</div> 
</section>-->

	
	<div class="row m-t">
	<div class="col-md-12">
	<div><input type="hidden" class="hidden_url" value="<?php echo url();?>/dashboard"><label><b>Date: <input type="text" id="dt1" class=" form-control date" value="<?php echo e($today_date); ?>" /> </b></label><label><input type="submit" value="Submit" class="btn btn-sm btn-success submit_search_date" onclick="search_date()" /></label> <label style="float: right;"><a href="<?php echo url();?>/dashboard"/>Today Report</a></label></div>
	<div id="today_date"><?php echo e($today_date); ?></div>
	<div style="float: right">
                <label><a href="javascript:void(0);" class="printfile" title="Print"><i class="fa fa-download"></i>&nbsp;Print </a></label></div></div>
	<!-- Attendance -->
		<div class="col-md-12">
			<div class="sbox">
				<div class="sbox-title" id="attendance_head"> <h3> Today Attendance <small> </small> </h3> </div>
				<div class="sbox-content">
					<div class="row">
						<div class="col-md-12">
						<div class="table-responsive" id="attendance">
							<table class="table table-striped">
								<tr>
									<th>  </th>
									<th> Site Name </th>
									<th> Labour </th>
								</tr>
						
								<?php 
								if(!empty($attandance)){
								foreach ($attandance as $site=>$labours) {
									echo '<tr style="clear:both;">
									<td></td>
									<td>'.$site.'</td>
									<td><ul>';
									 foreach ($labours as $labour) {
										echo '<li>'.$labour.'</li>';
									} 
									echo '</ul></td>
								</tr>';
							}
						}else{
							echo '<tr><td colspan="3">No records</td></tr>';
						}
								?>
							

							</table>
							</div>
						</div>
						
					</div>
				
						
				</div>
			</div>
		</div>
		
<!-- Materials -->

		<div class="col-md-12">
			<div class="sbox">
				<div class="sbox-title" id="materials_head"> <h3> Today Materials <small> </small> </h3> </div>
				<div class="sbox-content">
					<div class="row">
						<div class="col-md-12">
						<div class="table-responsive"  id="materials">
							<table class="table table-striped">
								<tr>
									<th>  </th>
									<th> Site Name </th>
									<th> Materials </th>
								</tr>
								<?php
								if(!empty($material)){ 
									foreach($material as $site=>$products){
$site_name =\DB::select("SELECT site_name FROM `tb_site` where `id`='".$site."' limit 1");
								echo '<tr>
									<td></td>
									<td>'.$site_name[0]->site_name.'</td>
									<td><table class="inner_table" style="width:  100%;"><tr><th>S.No</th><th>Product</th><th>Qty</th><th>Amount</th></tr>';
									$product_count=0;
									 foreach ($products as $product) {
									 	$product_count++;
									 	$product_name = $product['name'];
									 	if(empty($product['out_qty']))$product['out_qty']=0;
									 	if(empty($product['ret_qty']))$product['ret_qty']=0;
									 	if(empty($product['out_amt']))$product['out_amt']=0;
									 	if(empty($product['ret_amt']))$product['ret_amt']=0;
									 	$product_qty = $product['out_qty']-$product['ret_qty'];
									 	$product_amt = $product['out_amt']-$product['ret_amt'];
										echo '<tr><td>'.$product_count.'</td><td>'.$product_name.'</td><td>'.$product_qty.'( '.$product['out_qty'].' - '.$product['ret_qty'].' )</td><td>'.$product_amt.'( '.$product['out_amt'].' - '.$product['ret_amt'].' )</td></tr>';
									} 
									echo '</table></td>
								</tr>';
							}
							}else{
							echo '<tr><td colspan="3">No records</td></tr>';
						}
								?>

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

<!-- Expenses -->

		<div class="col-md-12">
			<div class="sbox">
				<div class="sbox-title" id="expenses_head"> <h3> Today Expenses <small> </small> </h3> </div>
				<div class="sbox-content">
					<div class="row">
						<div class="col-md-12">
						<div class="table-responsive" id="expenses" >
							<table class="table table-striped">
								<tr>
									<th>  </th>
									<th> Site Name </th>
									<th> Expenses </th>
								</tr>
								<?php 
								if(!empty($expenses)){
									foreach($expenses as $site=>$expense_details){
$site_name =\DB::select("SELECT site_name FROM `tb_site` where `id`='".$site."' limit 1");
								echo '<tr>
									<td></td>
									<td>'.$site_name[0]->site_name.'</td>
									<td><table class="inner_table" style="width:  100%;"><tr><th>S.No</th><th>Description</th><th>Amount</th></tr>';
									$expenses_count=0;
									//var_dump($expense_details);exit;
									 foreach ($expense_details as $expense_detail) {
									 	$expenses_count++;
									 	
									 	$expense_des = $expense_detail['description'];
									 	$expense_amt = $expense_detail['amount'];

										echo '<tr><td>'.$expenses_count.'</td><td>'.$expense_des.'</td><td>'.$expense_amt.'</td></tr>';
									} 
									echo '</table></td>
								</tr>';
							}
								}else{
							echo '<tr><td colspan="3">No records</td></tr>';
						}
								?>
							</table>
							</div>
						</div>
						
					</div>
				
						
				</div>
			</div>
		</div>
		
	
	</div>
	<?php endif; ?>
</div>	
	
</div>

<style type="text/css">
.inner_table{width: 100%;}
.inner_table td{padding: 5px 0;}
#today_date{display: none;}
</style>
<script type="text/javascript">
function search_date(){
var url = $('.hidden_url').val(); 
var from_filter = $('#dt1').val();
url += '?date='+from_filter;
   
window.location.href = url;
 return false;

}
function printData()
{
	var today_date = document.getElementById("today_date");
   var attendance=document.getElementById("attendance");
   var materials=document.getElementById("materials");
   var expenses=document.getElementById("expenses");

var attendance_head=document.getElementById("attendance_head");
   var materials_head=document.getElementById("materials_head");
   var expenses_head=document.getElementById("expenses_head");

   newWin= window.open("");
   newWin.document.write(today_date.innerHTML+attendance_head.innerHTML+'<br>'+attendance.innerHTML+'<br>'+materials_head.outerHTML+'<br>'+materials.outerHTML+'<br>'+expenses_head.innerHTML+'<br>'+expenses.innerHTML);
   newWin.print();
   newWin.close();
}
    $(document).ready(function () {
        jQuery('.printfile').click( function() {
            printData();
        });
    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>