<!-- MAIN CONTENT WRAPPER -->
<script src="assets/js/king-table.js"></script>
			<div class="content">
				<div class="main-content">
					<div class="row">
                    	
						<div class="col-md-12">
							<!-- BASIC VALIDATION -->
								<div class="widget widget-table">
						<div class="widget-header">
							<h3><i class="fa fa-table"></i> 									
									<?php
									if($data['ftyp_module'] == "Income")
									{
										echo __('fundtype.income_typeviewftype');
									}
									if($data['ftyp_module'] == "Expense")
									{
										echo __('fundtype.expense_typeviewftype');
									}
									if($data['ftyp_module'] == "Loan")
									{
										echo __('fundtype.loan_typeviewftype');
									}
									?>
							</h3> 
                        </div>
						<div class="widget-content">
<table class="table table-sorting table-striped table-hover table-bordered datatable">
	<thead>
		<tr>
			<th style="width: 75px;">{{ __('report.slno') }}</th>
			<th>
				<?php
				if($data['ftyp_module'] == "Income")
				{
					echo __('fundtype.income');
				}
				if($data['ftyp_module'] == "Expense")
				{
					echo __('fundtype.expense');
				}
				?> {{ __('fundtype.types') }}
			</th>
			<th style="width: 275px;">{{ __('fundtype.description') }}</th>
			<th style="text-align: right;width: 150px;">{{ __('report.total') }}</th>
			<th style="width: 100px;">{{ __('report.add_amt') }}</th>
			<th style="width: 100px;">{{ __('report.report') }}</th>
		</tr>
	</thead>
	<tbody>
	<?php $slno = 1; ?>
	@foreach($data['fundtype'] as $fundtype)
		<tr>    
			<td>{{$slno}}</td>
			<td>{{$fundtype->ftyp_fundtype}}</td>
			<td>{{$fundtype->ftyp_description}}</td>
			<td style="text-align: right;" id="tot_{{$fundtype->ftyp_id}}">{{$fundtype->totalamt}}</td>
			<td>
			<?php
			if($data['ftyp_module'] == "Income")
			{
			?>
<button class="btn btn-primary btn-xs" data-toggle="modal" id="{{$fundtype->ftyp_id}}" data-target="#myotheramt"><i class="fa fa-plus" aria-hidden="true"></i>{{  __("report.add_amt") }}</button>
			<?php
			}
			if($data['ftyp_module'] == "Loan")
			{
			?>
<button class="btn btn-warning btn-xs" id="{{$fundtype->ftyp_id}}" onclick="viewloanvoucher({{$fundtype->ftyp_id}},'Loan')" style="color: black;"><i class="fa fa-shopping-cart" aria-hidden="true"></i>{{  __("incexp.loan_voucher") }}</button>
			<?php
			}
			if($data['ftyp_module'] == "Expense")
			{
			?>
<button class="btn btn-primary btn-xs" id="{{$fundtype->ftyp_id}}" onclick="viewexpensevoucher({{$fundtype->ftyp_id}},'Expense')"><i class="fa fa-plus" aria-hidden="true"></i>{{  __("report.expense_voucher") }}</button>
			<?php
			}
			?>
			</td>
			<td><button class="btn btn-success btn-xs" onclick="viewtransrecord({{$fundtype->ftyp_id}},'{{$data['ftyp_module']}}')"><i class="fa fa-eye" aria-hidden="true"></i>{{  __("report.report") }}</button></td>
		</tr>
		<?php $slno = $slno + 1; ?>
	@endforeach
	</tbody>
</table>
							
						</div>
					</div>
							<!-- END BASIC VALIDATION -->
						</div>

					</div>
				</div>
			</div>
			<!-- /main -->
<!-- The Modal Other amount starts here-->
<div class="modal" id="myotheramt">
    <div class="modal-dialog">
      <div class="modal-content">
        <!-- Modal Header -->
        <div class="modal-header">
          <h4 class="modal-title"><?php
				if($data['ftyp_module'] == "Income")
				{
					echo __('fundtype.income');
				}
				if($data['ftyp_module'] == "Expense")
				{
					echo __('fundtype.expense');
				}
				?></h4>
        </div>
        
        <!-- Modal body -->
        <div class="modal-body">
			<form id="frmothercharges" name="frmothercharges" method="post" data-parsley-validate novalidate>
				<input type="hidden" name="_token1" id="_token1" value="{{ csrf_token() }}">
				<input type="hidden" name="ftyp_id" id="ftyp_id" value="0">
				<input type="hidden" class="form-control" id="fyr_id" name="fyr_id" value="{{$data['fiscalyear'][0]->fyr_id}}" >
	{!! csrf_field() !!}           
	<div class="alert  alert-info " >
		<ul><li class="fa fa-cog  fa-1x fa-fw"></li>{{ __('grade.enter_details') }}...</ul>
	</div>						
	<div class="alert alert-success print-success-msg" style="display:none">
		<ul></ul>
	</div>	
	<div class="alert alert-danger print-error-msg" style="display:none">
		<ul></ul>
	</div>
	<div class="row">		
		<div class="form-group col-md-6">
			<label for="text-input1"><?php
				if($data['ftyp_module'] == "Income")
				{
					echo __('fundtype.income');
				}
				if($data['ftyp_module'] == "Expense")
				{
					echo __('fundtype.expense');
				}
				?> {{ __('fundtype.type') }}</label>
			<input type="text" name="ftyp_fundtype" id="ftyp_fundtype" class="form-control" readonly>
		</div>
		<div class="form-group col-md-6">
			<input type="hidden" name="trn_type" id="trn_type" class="form-control" value="<?php echo $data['ftyp_module']; ?>" readonly >
		</div>
	</div>
	<div class="row">
		<div class="form-group col-md-6">
			<label for="text-input1">{{ __('mylanguage.entry_date') }}</label>
			<input type="date" name="entry_date" id="entry_date" value="<?php echo date("Y-m-d"); ?>" class="form-control">
			<small class="text-danger" id="errentry_date"></small>
		</div>
		<div class="form-group col-md-6">
			<label for="text-input1">{{ __('grade.amount') }}*</label>
			<input type="text" name="grfn_amt" id="grfn_amt" class="form-control" >
			<small class="text-danger" id="errgrfn_amt"></small>
		</div>
	</div>
	<div class="row">
		<div class="form-group col-md-12">
			<label for="text-input1">{{ __('grade.description') }}</label>
			<textarea name="grfn_description" id="grfn_description" class="form-control" ></textarea>
			<small class="text-danger" id="errgrfn_description"></small>
		</div>
	</div>
        </div>
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
		  <button type="button" class="btn btn-primary submitgradefund">Submit</button>
        </div>
	</form>
      </div>
    </div>
</div>
<!-- The Modal Other amount ends here -->
<script>
//Modal other payment starts here	
	$('#myotheramt').on('show.bs.modal', function(e) {
        var $modal = $(this),
            ftyp_id = e.relatedTarget.id;
			$('#ftyp_id').val(ftyp_id);
			$('#grfn_amt').val('');
			$.ajax({
				url: 'loadincexp',
				type: 'GET',
				data:'&ftyp_id='+ftyp_id,
				success: function(data)
				{
					$('#ftyp_fundtype').val(data['fundtypes'].ftyp_fundtype);
					//$('#memid').val(data.cst_code);
				}
			});
    })
//Modal other payment ends here
</script>
<script type="application/javascript">
	$('.submitgradefund').click(function()
	{
		i=0;
			$(".alert-info").find("ul").html('<li class="fa fa-cog fa-spin fa-1x fa-fw"></li>Processing...');
			var _token = $("input[name='_token1']").val();
			var ftyp_id =  $('#ftyp_id').val();
			var grd_id =  $('#grd_id').val();
			var entry_date =  $('#entry_date').val();
			var trn_type =  $('#trn_type').val();
			var grfn_amt =  $('#grfn_amt').val();
			var grfn_description = $("input[name='grfn_description']").val();
			
			document.getElementById("errgrfn_amt").innerHTML = "";		   	
			document.getElementById("errentry_date").innerHTML = "";		   	

			if(entry_date == "")
			{
				document.getElementById("errentry_date").innerHTML = "Date Shoud not be empty...";
				$(".alert-info").find("ul").html('<li class="fa fa-cog fa-1x fa-fw"></li>Kindly check the error...');
			}
			else if(grfn_amt == "")
			{
				document.getElementById("errgrfn_amt").innerHTML = "Amount Shoud not be empty...";
				$(".alert-info").find("ul").html('<li class="fa fa-cog fa-1x fa-fw"></li>Kindly check the error...');
			}
			else
			{
			  if(i==0)
			  {
			   i++;
					$.ajax({
						url: "/insertincexp",
						type:'POST',
						data: $('#frmothercharges').serialize(),
						success: function(data) {											
							if(data.status == 1)
							{
								$('#tot_'+ftyp_id).html(""+ data.bil_billrec[0].totalamt);
								$('#myotheramt').modal('toggle');
								printSuccessMsg(data.message);
							}
							else
							{
								printErrorMsg(data.message)
							}
						}
					});
				}
			}	
		return false;
	});
	function printErrorMsg (msg) {			
		$(".alert-info").css('display','none');
		$(".print-success-msg").css('display','none');
		$(".print-error-msg").find("ul").html('');
		$(".print-error-msg").css('display','block');
		$(".print-error-msg").find("ul").append('<li class="fa fa-times-circle fa-1x fa-fw"></li>'+msg);
	}	
	function printSuccessMsg (msg) {
		$(".alert-info").css('display','none');
		$(".print-error-msg").css('display','none');
		$(".print-success-msg").find("ul").html('');
		$(".print-success-msg").css('display','block');
		$(".print-success-msg").find("ul").append('<li class="fa fa-check  fa-1x fa-fw"></li>'+msg);
	}
</script>
<script>
function viewtransrecord(ftyp_id,ftyp_module)
{
	$.ajax({
		url: 'viewincomeexpenserec',
		type: 'GET',
		data:'&ftyp_id='+ftyp_id+'&ftyp_module='+ftyp_module,
		success: function(data)
		{
			$('#sideMenu').html(data);
		}
	});
}
</script>
<script>
function viewexpensevoucher(ftyp_id,ftyp_module)
{
	$.ajax({
		url: 'ieexpensevoucher',
		type: 'GET',
		data:'&ftyp_id='+ftyp_id+'&ftyp_module='+ftyp_module,
		success: function(data)
		{
			$('#sideMenu').html(data);
		}
	});
}
</script>
<script>
function viewloanvoucher(ftyp_id,ftyp_module)
{
	$.ajax({
		url: 'ieloanvoucher',
		type: 'GET',
		data:'&ftyp_id='+ftyp_id+'&ftyp_module='+ftyp_module,
		success: function(data)
		{
			$('#sideMenu').html(data);
		}
	});
}
$(document).ready( function () {
    $('#mydatatable').DataTable({
		"sDom": '<"H"lfrp>t<"F"ip>',
	});
} );
</script>