<?php $__env->startSection('content'); ?>
<?php /**/ usort($tableGrid, "SiteHelpers::_sort") /**/ ?>
  <div class="page-content row">
    <!-- Page header -->
    <div class="page-header">
      <div class="page-title">
        <h3> <?php echo e($pageTitle); ?> <small><?php echo e($pageNote); ?></small></h3>
      </div>

      <ul class="breadcrumb">
        <li><a href="<?php echo e(URL::to('dashboard')); ?>"> Dashboard </a></li>
        <li class="active"><?php echo e($pageTitle); ?></li>
      </ul>	  
	  
    </div>
	
	
	<div class="page-content-wrapper m-t">	 	

<div class="sbox animated fadeInRight">
	<div class="sbox-title" style="background-color:#ef6c6c;font-size: 26px;line-height: 16px;text-align: center;"> <h5> <i class="fa fa-table"></i> </h5> Returns
<div class="sbox-tools" >
		<a href="<?php echo e(url($pageModule)); ?>" class="btn btn-xs btn-white tips" title="Clear Search" ><i class="fa fa-trash-o"></i> Clear Search </a>
		<?php if(Session::get('gid') ==1): ?>
			<a href="<?php echo e(URL::to('abserve/module/config/'.$pageModule)); ?>" class="btn btn-xs btn-white tips" title=" <?php echo e(Lang::get('core.btn_config')); ?>" ><i class="fa fa-cog"></i></a>
		<?php endif; ?> 
		</div>
	</div>
	<div class="sbox-content"> 	
	    <div class="toolbar-line ">
			<?php if($access['is_add'] ==1): ?>
	   		<a href="<?php echo e(URL::to('materialreturns/update')); ?>" class="tips btn btn-sm btn-white"  title="<?php echo e(Lang::get('core.btn_create')); ?>">
			<i class="fa fa-plus-circle "></i>&nbsp;<?php echo e(Lang::get('core.btn_create')); ?></a>
			<?php endif; ?>  
			<?php if($access['is_remove'] ==1): ?>
			<a href="javascript://ajax"  onclick="AbserveDelete();" class="tips btn btn-sm btn-white" title="<?php echo e(Lang::get('core.btn_remove')); ?>">
			<i class="fa fa-minus-circle "></i>&nbsp;<?php echo e(Lang::get('core.btn_remove')); ?></a>
			<?php endif; ?> 
			<a href="<?php echo e(URL::to( 'materialreturns/search')); ?>" class="btn btn-sm btn-white" onclick="AbserveModal(this.href,'Advance Search'); return false;" ><i class="fa fa-search"></i> Search</a>				
			<?php if($access['is_excel'] ==1): ?>
			<a href="<?php echo e(URL::to('materialreturns/download?return='.$return)); ?>" class="tips btn btn-sm btn-white" title="<?php echo e(Lang::get('core.btn_download')); ?>">
			<i class="fa fa-download"></i>&nbsp;<?php echo e(Lang::get('core.btn_download')); ?> </a>
			<?php endif; ?>	
<?php
$search_from_date_val=$search_to_date_val=$search_site_val='';
if(isset($_GET['search'])){
	$search_parts = explode('|',$_GET['search']);
	foreach ($search_parts as $search_part) {
		$seachterm = explode(':', $search_part);
		if($seachterm[0]=='date'){
			$search_from_date_val=date('d-m-Y',strtotime($seachterm[2]));
			$search_to_date_val=date('d-m-Y',strtotime($seachterm[3]));
		}
		if($seachterm[0]=='site'){
			$search_site_val=$seachterm[2];
		}
	}
}
?>
			<div class="form-group" style="width: 60%;float:  right;">
			<ul style="list-style: none;"><li class="col-md-3"><label>
	<input type="text" id="dt1" placeholder="From" class="form-control date" value="<?php echo $search_from_date_val; ?>"></label></li>
			<li class="col-md-3"><label>
	<input type="text" id="dt2" placeholder="To" class="form-control date" value="<?php echo $search_to_date_val; ?>"></label></li><li><div class="col-md-5">
	
                <select class="select2" id="search_site">
                <option value=""></option>
                <?php foreach($sites as $key => $val): ?>
                <?php 
                $selected='';
                if($search_site_val==$val->id){
					$selected='selected="selected"';
                	} ?>
                <option <?php echo $selected; ?> value="<?php // echo URL::to('materialoutwards?search=site:equal:'); ?><?php echo e($val->id); ?>|"><?php echo e($val->site_name); ?></option>
                <?php endforeach; ?>
                </select></div>
            </li><li class="col-md-1"><button class="btn btn" onclick="searchfilter()">Go</button></li></ul>
                </div>	
		 
		</div> 		

	
	
	 <?php echo Form::open(array('url'=>'materialreturns/delete/', 'class'=>'form-horizontal' ,'id' =>'AbserveTable' )); ?>

	 <div class="table-responsive" style="min-height:300px;clear:  both;">
    <table class="table table-striped ">
        <thead>
			<tr>
				<th class="number"> No </th>
				<th> <input type="checkbox" class="checkall" /></th>
				
				<?php foreach($tableGrid as $t): ?>
					<?php if($t['view'] =='1'): ?>				
						<?php $limited = isset($t['limited']) ? $t['limited'] :''; ?>
						<?php if(SiteHelpers::filterColumn($limited )): ?>
						
							<th><?php echo e($t['label']); ?></th>			
						<?php endif; ?> 
					<?php endif; ?>
				<?php endforeach; ?>
				<th width="70" ><?php echo e(Lang::get('core.btn_action')); ?></th>
			  </tr>
        </thead>

        <tbody>        						
            <?php foreach($rowData as $row): ?>
<?php 
$date = $row->date;
$str = $date;
$date1 = DateTime::createFromFormat('Y-m-d', $str);
?>
                <tr>
					<td width="30"> <?php echo e(++$i); ?> </td>
					<td width="50"><input type="checkbox" class="ids" name="ids[]" value="<?php echo e($row->id); ?>" />  </td>									
				 <?php foreach($tableGrid as $field): ?>
					 <?php if($field['view'] =='1'): ?>
					 	<?php $limited = isset($field['limited']) ? $field['limited'] :''; ?>
					 	<?php if(SiteHelpers::filterColumn($limited )): ?>
						 <td>					 
						 	<?php if($field['attribute']['image']['active'] =='1'): ?>
								<?php echo SiteHelpers::showUploadedFile($row->$field['field'],$field['attribute']['image']['path']); ?>

							<?php else: ?>	
								<?php if($field['field'] == 'date'): ?>
							 	<?php echo $date1->format('d-m-Y')?>
							 	<?php else: ?>
										<?php /**/ $conn = (isset($field['conn']) ? $field['conn'] : array() ) /**/ ?>
										<?php echo SiteHelpers::gridDisplay($row->{$field['field']},$field['field'],$conn); ?>

								<?php endif; ?>	
							<?php endif; ?>						 
						 </td>
						<?php endif; ?>	
					 <?php endif; ?>					 
				 <?php endforeach; ?>
				 <td>
					 	<?php if($access['is_detail'] ==1): ?>
						<a href="<?php echo e(URL::to('materialreturns/show/'.$row->id.'?return='.$return)); ?>" class="tips btn btn-xs btn-primary" title="<?php echo e(Lang::get('core.btn_view')); ?>"><i class="fa  fa-search "></i></a>
						<?php endif; ?>
						<?php if($access['is_edit'] ==1): ?>
						<a  href="<?php echo e(URL::to('materialreturns/update/'.$row->id.'?return='.$return)); ?>" class="tips btn btn-xs btn-success" title="<?php echo e(Lang::get('core.btn_edit')); ?>"><i class="fa fa-edit "></i></a>
						<?php endif; ?>
												
					
				</td>				 
                </tr>
				
            <?php endforeach; ?>
              
        </tbody>
      
    </table>
	<input type="hidden" name="md" value="" />
	</div>
	<?php echo Form::close(); ?>

	<?php echo $__env->make('footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
	</div>
</div>	
	</div>	  
</div>	
<script>
function searchfilter(){
var $from = $('#dt1').val();
$from = $from.split("-");
$from_day = $from[0];
$from_month = $from[1];
$from_year = $from[2];
var $to = $('#dt2').val();
if($to==null || $to==''){
	var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
	if(dd<10){
	    dd='0'+dd;
	} 
	if(mm<10){
	    mm='0'+mm;
	} 
	$to=dd+'-'+mm+'-'+yyyy;
}
$to = $to.split("-");
$to_day = $to[0];
$to_month = $to[1];
$to_year = $to[2];
var $search_query='';
var $search_site = $('#search_site').val();

var $from_date = $('#dt1').val();

if($from_date!=null && $from_date!=''){
	$search_query = $search_query+$search_query+'date:between:'+$from_year+'-'+$from_month+'-'+$from_day+':'+$to_year+'-'+$to_month+'-'+$to_day+'|';
}
if($search_site!=null && $search_site!=''){
	$search_query = $search_query+'site:equal:'+$search_site+'|';
}
var redirect_url = '<?php echo url().'/materialreturns?search='; ?>';
window.location = redirect_url+$search_query;
}
$(document).ready(function(){

	$('.do-quick-search').click(function(){
		$('#AbserveTable').attr('action','<?php echo e(URL::to("materialreturns/multisearch")); ?>');
		$('#AbserveTable').submit();
	});
	
});	
</script>		
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>