| Path : /var/www/html/usd_loan_system/resources/views/loan/ |
|
B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H |
| Current File : //var/www/html/usd_loan_system/resources/views/loan/edit.blade.php |
@extends('layouts.master')
@section('title')
{{translate('edit loan')}}
@endsection
@section('content')
<div class="panel panel-white">
<div class="panel-heading">
<h6 class="panel-title">{{translate('edit loan')}}</h6>
<div class="heading-elements">
</div>
</div>
{!! Form::open(array('url' => url('loan/'.$loan->id.'/update'), 'method' => 'post', 'class' => 'form-horizontal',"enctype"=>"multipart/form-data",'id'=>'loan_form')) !!}
<div class="panel-body">
<div class="form-group">
{!! Form::label('borrower_id',translate('borrower')." *",array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::select('borrower_id',$borrowers,$loan->borrower_id, array('class' => ' select2 form-control', 'placeholder'=>"Select",'required'=>'required')) !!}
</div>
</div>
<div class="form-group">
{!! Form::label('loan_officer_id',translate('loan_officer')." *",array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::select('loan_officer_id',$users,$loan->loan_officer_id, array('class' => ' select2 form-control', 'placeholder'=>"Select",'required'=>'required')) !!}
</div>
<div class="col-sm-4">
<i class="icon-info3" data-toggle="tooltip" title="Select the officer in charge of the loan"></i>
</div>
</div>
<div class="form-group">
{!! Form::label('loan_product_id',translate('loan').' '.translate('product')." *",array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::select('loan_product_id',$loan_products,$loan->loan_product_id, array('class' => ' select2 form-control', 'placeholder'=>"Select",'required'=>'required','id'=>'loanProduct')) !!}
</div>
</div>
<div class="form-group">
{!! Form::label('principal',translate('principal').' '.translate('amount')." *",array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::text('principal',$loan->principal, array('class' => 'form-control touchspin', 'placeholder'=>"",'required'=>'required')) !!}
</div>
</div>
<p class="text-red"><b>{{translate('duration')}}:</b></p>
<div class="form-group">
{!! Form::label('loan_duration',translate('loan').' '.translate('duration')." *",array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-2">
{!! Form::number('loan_duration',$loan->loan_duration, array('class' => 'form-control', 'placeholder'=>"5",'required'=>'required')) !!}
</div>
<div class="col-sm-3">
{!! Form::select('loan_duration_type',array('day'=>translate('day').'(s)','week'=>translate('week').'(s)','month'=>translate('month').'(s)','year'=>translate('year').'(s)'),$loan->loan_duration_type, array('class' => 'form-control', 'placeholder'=>"","id"=>"inputMaxInterestPeriod",'required'=>'required')) !!}
</div>
</div>
<div class="form-group">
{!! Form::label('repayment_cycle',translate('repayment_cycle')." *",array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::select('repayment_cycle',array('daily'=>translate('daily'),'weekly'=>translate('weekly'),'monthly'=>translate('monthly'),'bi_monthly'=>translate('bi_monthly'),'quarterly'=>translate('quarterly'),'semi_annual'=>translate('semi_annually'),'annual'=>translate('annual')),$loan->repayment_cycle, array('class' => 'form-control', 'placeholder'=>"","id"=>"",'required'=>'required')) !!}
</div>
</div>
<div class="form-group">
{!! Form::label('release_date',translate('loan').' '.translate('disbursement').' '.translate('date')." *",array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::text('release_date',$loan->release_date, array('class' => 'form-control date-picker', 'placeholder'=>"yyyy-mm-dd",'required'=>'required','id'=>'releaseDate')) !!}
</div>
</div>
<div class="form-group">
{!! Form::label('first_payment_date',translate('first').' '.translate('repayment').' '.translate('date')." *",array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::text('first_payment_date',$loan->first_payment_date, array('class' => 'form-control date-picker', 'placeholder'=>"yyyy-mm-dd",''=>'','id'=>'firstPayment')) !!}
</div>
</div>
<div class="form-group">
{!! Form::label('interest_method',translate('interest').' '.translate('method')." *",array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::select('interest_method',array('flat_rate'=>translate('flat_rate'),'declining_balance_equal_installments'=>translate('declining_balance_equal_installments'),'declining_balance_equal_principal'=>translate('declining_balance_equal_principal'),'interest_only'=>translate('interest_only')),$loan->interest_method, array('class' => 'form-control', 'placeholder'=>"Select",'required'=>'required')) !!}
</div>
</div>
<div class="form-group">
{!! Form::label('interest_rate',translate('loan').' '.translate('interest').' (%) *',array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-2">
{!! Form::text('interest_rate',$loan->interest_rate, array('class' => 'form-control touchspin', 'placeholder'=>"",'required'=>'required')) !!}
</div>
<div class="col-sm-3">
{!! Form::select('interest_period',array('day'=>translate('per_day'),'week'=>translate('per_week'),'month'=>translate('per_month'),'year'=>translate('per_year')),$loan->interest_period, array('class' => 'form-control', 'placeholder'=>"Select","id"=>"inputDefaultInterestPeriod",'required'=>'required')) !!}
</div>
</div>
<div class="form-group">
{!! Form::label('pay_off_interest_rate',translate('loan').' '.translate('pay_off_interest_rate').' (%) *',array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-2">
{!! Form::text('pay_off_interest_rate',$loan->pay_off_interest_rate, array('class' => 'form-control touchspin', 'placeholder'=>"",'required'=>'required')) !!}
</div>
</div>
<!-- <div class="form-group">
{!! Form::label('override_interest',translate('override').' '.translate('interest'),array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::select('override_interest',array('0'=>translate('no'),'1'=>translate('yes')),$loan->override_interest, array('class' => 'form-control','id'=>'override_interest')) !!}
</div>
<div class="col-sm-4">
<i class="icon-info3" data-toggle="tooltip"
title="{{translate('override_msg')}}"></i>
</div>
</div> -->
<!-- <div class="form-group" id="overrideDiv">
{!! Form::label('override_interest_amount',translate('override').' '.translate('interest').' %',array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::text('override_interest_amount',$loan->override_interest_amount, array('class' => 'form-control touchspin','id'=>'override_interest_amount')) !!}
</div>
</div> -->
<!-- <div class="form-group">
{!! Form::label('grace_on_interest_charged',translate('grace_on_interest'),array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::number('grace_on_interest_charged',$loan->grace_on_interest_charged, array('class' => 'form-control', 'placeholder'=>"2")) !!}
</div>
<div class="col-sm-4">
<i class="icon-info3" data-toggle="tooltip"
title="{{translate('grace_on_interest_msg')}}"></i>
</div>
</div> -->
<div class="form-group">
{!! Form::label('decimal_places',translate('decimal_place'),array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::select('decimal_places',array('round_off_to_two_decimal'=>translate('round_off_to_two_decimal'),'round_off_to_integer'=>translate('round_off_to_integer')),$loan->decimal_places, array('class' => 'form-control', 'placeholder'=>"","id"=>"",'required'=>'required')) !!}
</div>
<div class="col-sm-4">
<i class="icon-info3" data-toggle="tooltip"
title="{{translate('loan_decimal_msg')}}"></i>
</div>
</div>
<hr>
<div class="form-group">
{!! Form::label('description',translate('description'),array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::textarea('description',$loan->description, array('class' => 'form-control', 'rows'=>"3")) !!}
</div>
</div>
<div class="form-group">
{!! Form::label('files',translate('loan').' '.translate('file').'('.translate('borrower_file_types').')',array('class'=>'col-sm-3 control-label')) !!}
<div class="col-sm-5">
{!! Form::file('files[]', array('class' => 'form-control file-styled', 'multiple'=>"multiple")) !!}
</div>
<div class="col-sm-9">
@foreach(unserialize($loan->files) as $key=>$value)
<span id="file_{{$key}}_span"><a href="{!!asset('uploads/'.$value)!!}"
target="_blank">{!! $value!!}</a> <button value="{{$key}}"
id="{{$key}}"
onclick="delete_file(this)"
type="button"
class="btn btn-danger btn-xs">
<i class="fa fa-trash"></i></button> </span><br>
@endforeach
</div>
</div>
<!-- <p class="bg-navy color-palette">{{translate('charge')}}</p> -->
<div class="form-group table-responsive" id="chargesDiv">
<div style="display: none;" id="saved_charges">
@foreach($loan->loan_product->charges as $key)
<input name="charges[]" id="charge{{$key->charge_id}}" value="{{$key->charge_id}}">
@endforeach
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>{{translate('name')}}</th>
<th>{{translate('type')}}</th>
<th>{{translate('amount')}}</th>
<th>{{translate('collected on')}}</th>
<th>{{translate('date')}}</th>
</tr>
</thead>
<tbody id="charges_table">
@foreach($loan->loan_product->charges as $key)
@if(!empty($key->charge))
<tr id="row{{$key->charge->id}}">
<td>{{ $key->charge->name }}</td>
<td>
@if($key->charge->charge_option=="fixed")
{{translate('fixed')}}
@endif
@if($key->charge->charge_option=="principal_due")
% {{translate('principal due')}}
@endif
@if($key->charge->charge_option=="principal_interest")
% {{translate('principal')}}
+ {{translate('interest due')}}
@endif
@if($key->charge->charge_option=="interest_due")
% {{translate('interest due')}}
@endif
@if($key->charge->charge_option=="total_due")
% {{translate('total due')}}
@endif
@if($key->charge->charge_option=="original_principal")
% {{translate('original principal')}}
@endif
</td>
<td>
<?php
$charge = \App\Models\LoanCharge::where('charge_id',$key->charge->id)->where('loan_id',$loan->id)->first();
if(!empty($charge)){
$charge_date=$charge->date;
$charge_amount=$charge->amount;
}else{
$charge_date="";
$charge_amount=$key->charge->amount;
}
?>
@if($key->charge->override==1)
<input type="text" class="form-control"
name="charge_amount_{{$key->charge->id}}"
value="{{$charge_amount}}" required>
@else
<input type="text" class="form-control"
name="charge_amount_{{$key->charge->id}}"
value="{{$charge_amount}}">
<!-- {{$charge_amount}} -->
@endif
</td>
<td>
@if($key->charge->charge_type=='disbursement')
{{translate('disbursement')}}
@endif
@if($key->charge->charge_type=='specified_due_date')
{{translate('specified_due_date')}}
@endif
@if($key->charge->charge_type=='installment_fee')
{{translate('installment_fee')}}
@endif
@if($key->charge->charge_type=='overdue_installment_fee')
{{translate('overdue_installment_fee')}}
@endif
@if($key->charge->charge_type=='loan_rescheduling_fee')
{{translate('loan_rescheduling_fee')}}
@endif
@if($key->charge->charge_type=='overdue_maturity')
{{translate('overdue_maturity')}}
@endif
@if($key->charge->charge_type=='savings_activation')
{{translate('savings_activation')}}
@endif
@if($key->charge->charge_type=='withdrawal_fee')
{{translate('withdrawal_fee')}}
@endif
@if($key->charge->charge_type=='monthly_fee')
{{translate('monthly_fee')}}
@endif
@if($key->charge->charge_type=='annual_fee')
{{translate('annual_fee')}}
@endif
</td>
<td>
@if($key->charge->charge_type=='specified_due_date')
<input type="text" class="form-control date-picker"
name="charge_date_{{$key->charge->id}}"
value="{{$charge_date}}" required>
@else
<input type="hidden" class="form-control"
name="charge_date_{{$key->charge->id}}"
value="">
@endif
</td>
</tr>
@endif
@endforeach
</tbody>
</table>
</div>
<!-- <p class="bg-navy disabled color-palette">{{translate('custom_field')}}</p> -->
@foreach($custom_fields as $key)
<div class="form-group">
{!! Form::label($key->id,$key->name,array('class'=>'control-label col-sm-3')) !!}
<div class="col-sm-5">
@if($key->field_type=="number")
<input type="number" class="form-control" name="{{$key->id}}"
@if($key->required==1) required
@endif value="@if(!empty(\App\Models\CustomFieldMeta::where('custom_field_id',$key->id)->where('parent_id',$loan->id)->where('category','loans')->first())){{\App\Models\CustomFieldMeta::where('custom_field_id',$key->id)->where('parent_id',$loan->id)->where('category','loans')->first()->name}} @endif">
@endif
@if($key->field_type=="textfield")
<input type="text" class="form-control" name="{{$key->id}}"
@if($key->required==1) required
@endif value="@if(!empty(\App\Models\CustomFieldMeta::where('custom_field_id',$key->id)->where('parent_id',$loan->id)->where('category','loans')->first())){{\App\Models\CustomFieldMeta::where('custom_field_id',$key->id)->where('parent_id',$loan->id)->where('category','loans')->first()->name}} @endif">
@endif
@if($key->field_type=="date")
<input type="text" class="form-control date-picker" name="{{$key->id}}"
@if($key->required==1) required
@endif value="@if(!empty(\App\Models\CustomFieldMeta::where('custom_field_id',$key->id)->where('parent_id',$loan->id)->where('category','loans')->first())){{\App\Models\CustomFieldMeta::where('custom_field_id',$key->id)->where('parent_id',$loan->id)->where('category','loans')->first()->name}} @endif">
@endif
@if($key->field_type=="textarea")
<textarea class="form-control" name="{{$key->id}}"
@if($key->required==1) required @endif>@if(!empty(\App\Models\CustomFieldMeta::where('custom_field_id',$key->id)->where('parent_id',$loan->id)->where('category','loans')->first())){{\App\Models\CustomFieldMeta::where('custom_field_id',$key->id)->where('parent_id',$loan->id)->where('category','loans')->first()->name}} @endif</textarea>
@endif
@if($key->field_type=="decimal")
<input type="text" class="form-control touchspin" name="{{$key->id}}"
@if($key->required==1) required
@endif value="@if(!empty(\App\Models\CustomFieldMeta::where('custom_field_id',$key->id)->where('parent_id',$loan->id)->where('category','loans')->first())){{\App\Models\CustomFieldMeta::where('custom_field_id',$key->id)->where('parent_id',$loan->id)->where('category','loans')->first()->name}} @endif">
@endif
</div>
</div>
@endforeach
</div>
<!-- /.panel-body -->
<div class="panel-footer">
<div class="heading-elements">
<button type="submit" class="btn btn-primary pull-right">{{translate('save')}}</button>
</div>
</div>
{!! Form::close() !!}
</div>
<!-- /.box -->
@endsection
@section('footer-scripts')
<script>
$(document).ready(function () {
if ($('#override_interest').val() == 0) {
$('#overrideDiv').hide();
$('#override_interest_amount').removeAttr('required');
}
if ($('#override_interest').val() == 1) {
$('#overrideDiv').show();
$('#override_interest_amount').attr('required', 'required');
}
$('#override_interest').change(function (e) {
if ($('#override_interest').val() == 0) {
$('#overrideDiv').hide();
$('#override_interest_amount').removeAttr('required');
}
if ($('#override_interest').val() == 1) {
$('#overrideDiv').show();
$('#override_interest_amount').attr('required', 'required');
}
})
});
function delete_file(e) {
var id = e.id;
swal({
title: 'Are you sure?',
text: '',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Ok',
cancelButtonText: 'Cancel'
}).then(function () {
$.ajax({
type: 'GET',
url: "{!! url('loan/'.$loan->id) !!}/delete_file?id=" + id,
success: function (data) {
$("#file_" + id + "_span").remove();
swal({
title: 'Deleted',
text: 'File successfully deleted',
type: 'success',
showCancelButton: false,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Ok',
timer: 2000
})
}
});
})
}
$("#loan_form").validate({
rules: {
field: {
required: true,
number: true
}
}
});
</script>
@endsection