<?php
$user = auth()->user();
?>
<script src="assets/js/king-table.js"></script>
<div class="content">
	<div class="main-content">
		<!-- DATA EXPORT -->
		<form id="frmothercharges" name="frmothercharges" method="post" data-parsley-validate novalidate>
<input type="hidden" name="_token" id="_token" value="{{ csrf_token() }}">
<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-eye"></i> {{ __('report.search_records') }} </h3>
			</div>
			<div class="widget-content">
				<div class="row">		
					<div class="col-md-3">{{ __('mylanguage.member_id') }}
						<input type="text" class="form-control" id="member_id" name="member_id"  value="{{ $data['member_id']  }}" >
					</div>		
					<div class="col-md-3">{{ __('matrimonial.marriage_certificate') }} {{ __('matrimonial.mrg_no') }}
						<input type="text" class="form-control" id="mrg_no" name="mrg_no"  value="{{ $data['mrg_no']  }}" >
					</div>
					<div class="col-md-3">{{ __('report.transaction_fdate') }}
					<input type="date" class="form-control" name="fdate" id="fdate"  value="{{ isset($data) ? $data['fdate'] : date('Y-m-d') }}">
					</div>
					<div class="col-md-3">{{ __('report.transaction_tdate') }}
					<input type="date" class="form-control" name="tdate" id="tdate"  value="{{ isset($data) ? $data['tdate'] : date('Y-m-d') }}">
					</div>
				</div>
			</div>
			
			<div class="widget-header">
				<center>
		<button type="button" id="btnsubmitall" name="btnsubmitall" class="btn btn-default sideClick1" ><i class="fa fa-arrows" aria-hidden="true"></i> Filter Records</button>
				</center>
			</div>
		</div>
		</form>
		<!-- END DATA EXPORT -->
		<!-- DATA EXPORT -->
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-table"></i> {{ __('mylanguage.marr_certi_rpt') }}</h3>
			</div>
			<div class="widget-content">
				<table id="mydatatable" class="table table-sorting table-striped table-hover table-bordered datatable">
					<thead>
						<tr>
							<th style='width: 75px;'>{{ __('report.slno') }}</th>
							<th style='width: 75px;'>{{ __('report.billno') }}</th>
							<th style='width: 100px;'>{{ __('report.transaction_date') }}</th>
							<th style='width: 75px;'>{{ __('mylanguage.member_id') }}</th>
							<th>{{ __('mylanguage.name') }}</th>
							<th>{{ __('report.transaction_type') }}</th>
							<th style='width: 65px;text-align: right;'>{{ __('report.transaction_payment')  }}</th>
						</tr>
					</thead>
					<tbody>				
			<?php
			$payable = 0;
			$paid = 0;
			$totamt = 0;
			$slno = 1;
			?>
						@foreach($data['trn_transaction'] as $trn_val)
<?php
if($trn_val->trn_type == "Matrimonial" )
{
	if($trn_val->trn_type == "Matrimonial")
	{
		echo "<tr style='color: green;'>";
		echo "<td>" . $slno . "</td>";
		echo "<th>" . $trn_val->trn_billno . "</th>";
	}	

		echo "<td>" . date("d-m-Y",strtotime($trn_val->trn_date))  . "</td>";
		echo "<td>" . $trn_val->cstgrdprefix . $trn_val->cst_code  . "</td>";
		echo "<td>" . $trn_val->cst_name  . "</td>";
		echo "<td>";
		echo __('matrimonial.mrg_name') . " - ". $trn_val->mrg_name . " | "; 
		echo __('matrimonial.mrg_marrdt') . " - ". $trn_val->mrg_marriagedate . " | "; 
		echo __('matrimonial.mrg_loc') . " - ". $trn_val->mrg_location; 
		echo "</td>";
	if($trn_val->trn_type == "Matrimonial")
	{
		$payable = $payable + $trn_val->billamt;
		$totamt = $totamt + $trn_val->billamt;
		echo "<th style='text-align: right;'>"  . $trn_val->billamt  ."</th>";
	}

		echo  "</tr>";
		$slno=$slno+1;
}
?>						
						@endforeach				
					</tbody>
					<tfoot>				
						<tr>
							<th></th>
							<th></th>
							<th></th>
							<th style='text-align: right;'></th>
							<th style='text-align: right;'></th>	 	 
							<th style='text-align: right;'>Total :</th>
							<th style='text-align: right;'>{{ $totamt }}</th>				
						</tr>
					</tfoot>
				</table>
			</div>
			<div class="widget-header">
				<center>
				<?php
				$urlparameter = "";
				if(isset($_SERVER['QUERY_STRING']))
				{
				$urlparameter = $_SERVER['QUERY_STRING'];
				}
				?>
		<a type="button" id="btnprintreport" name="btnprintreport" href="matritransreportprint?urlparameter={{ $urlparameter }}" class="btn btn-default" target="_blank" ><i class="fa fa-print" aria-hidden="true"  ></i> Print report</a>
				</center>
			</div>
		</div>
		<!-- END DATA EXPORT -->
	</div>
</div>
<!-- /main -->
<style>
.modal-dialog.modal-100 {
    width: 90%;
    /*margin: 30px auto;*/
}
</style>

<script>
	$('.createMod').click(function(e)
	{   
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href'));
	});
	
</script>
<script>
	function reloadtransreport()
	{
			document.getElementById("btnsubmitall").innerHTML = "<i class='fa fa-arrows fa-spin' aria-hidden='true'></i> Fetching Records";
			var _token = $("input[name='_token']").val();
			var member_id =  $('#member_id').val();
			var grd_id =  $('#grd_id').val();
			var ftyp_id  =  $('#ftyp_id').val();
			var grfn_paycycle =  $('#grfn_paycycle').val();
			var fdate =  $('#fdate').val();
				$.ajax({
					url: "/transactionreport",
					type: 'get',
					//data: {_token:_token, member_id:member_id, grd_id: grd_id, ftyp_id: ftyp_id, grfn_paycycle: grfn_paycycle, fdate:fdate, tdate:tdate},
					success: function(data)
					{
						$('#reloadrecord').html(data);
						document.getElementById("btnsubmitall").innerHTML = "<i class='fa fa-arrows' aria-hidden='true'></i> Filter Records";
					}
				});
	}
</script>
<script>
$('.sideClick1').click(function(e)
{   
	document.getElementById("btnsubmitall").innerHTML = "<i class='fa fa-arrows fa-spin' aria-hidden='true'></i> Fetching Records";
	var _token = $("input[name='_token']").val();
	var member_id =  $('#member_id').val();
	var mrg_no =  $('#mrg_no').val();
	var fdate =  $('#fdate').val();
	var tdate =  $('#tdate').val();
	var submit =  $('#btnsubmitall').val();
	e.preventDefault();
	$('#sideMenu').load('matritransrpt?member_id=' + member_id + '&mrg_no='+mrg_no +  '&fdate='+fdate + '&tdate='+tdate+'&submit=submit');
});
$(document).ready( function () {
    $('#mydatatable').DataTable({
		"sDom": '<"H"lfrp>t<"F"ip>',
	});
} );
</script>