Files
streamline-emr/docker/streamline-src/Modules/PatientDiscounts/Resources/views/family_accounts/refund.blade.php
T

170 lines
8.1 KiB
PHP
Executable File

@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/typeahead.js-master/dist/typehead-min.css') }}" rel="stylesheet">
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">Refund Family Accounts</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> {{ __('family_accounts.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('family_accounts.finance_home') }}</a></li>
<li class="active"><i class="fa fa-eye"></i> Refund Family Accounts</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('patient_discounts::family_accounts.menu')
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="white-box">
@include('flash::message')
<div class="row">
<div class="col-md-4">
{{ Form::open(['method'=>'post','route'=>'family_accounts.store_family_refund']) }}
<div class="form-group">
{{ Form::label('family_head',__('family_accounts.family_head')) }}
{{ Form::text('family_head', get_full_name($family_account_details->family_head_id, "id", "first_name", "last_name", "patients"), ['class' => 'form-control col-sm-12 compulsory', 'readonly' => 'true']) }}
</div>
{{ Form::hidden('family_account_id', $family_account_details->id) }}
<div class="form-group">
{{ Form::label('current_balance', 'Current Balance') }}
{{ Form::number('current_balance', $family_account_details->current_balance,['class' => 'form-control compulsory', 'id' => 'current_balance', 'readonly']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('refund_amount', 'Amount to refund') }}
{{ Form::number('refund_amount', '',['class' => 'form-control compulsory', 'id' => 'refund_amount', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('account_id','Account To Pay From') }}
{{ Form::select('account_id', $banks, '', ['class' => 'form-control compulsory','required', 'id' => 'account_id', 'onchange' => 'get_bank_balance()']) }}
</div>
<div class="form-group">
{{ Form::label('account_balance','Account Balance') }}
{{ Form::text('account_balance', 0, ['class'=>'form-control compulsory', 'id'=>'account_balance', 'readonly']) }}
</div>
<div class="form-group">
{{ Form::label('refund_date', 'Refund Date') }}
<div class="input-group">
{{ Form::text('refund_date', date('d-m-Y'), ['class'=>'form-control compulsory', 'required' , 'readonly', 'id'=>'refund_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="form-group">
{{ Form::label('refunded_to', 'Refunded To') }}
{{ Form::text('refunded_to', '', ['class'=>'form-control compulsory', 'required']) }}
</div>
<div>
{{ Form::submit(__('family_accounts.save'),['class'=>'btn btn-success submit_btn'])}}
{{ Form::reset(__('family_accounts.cancel'),['type'=>'reset','class'=>'btn btn-default'])}}
</div>
{{ Form::close() }}
</div>
<div class="col-md-8">
<h3>{{ __('family_accounts.family_members') }}</h3>
@php
$family_members_array = explode(",", $family_account_details->family_members_ids);
@endphp
<ol>
@for($i = 0; $i < count($family_members_array); $i++)
<li>
<a href="patients/{{ $family_members_array[$i] }}">{{ get_full_name($family_members_array[$i], "id", "first_name", "last_name", "patients") }}</a>
<br>
<strong>{{ __('family_accounts.number') }} </strong>{{ get_name($family_members_array[$i], "id", "number","patients") }}
<br>
<strong>{{ __('family_accounts.contact') }}</strong>{{ get_name($family_members_array[$i], "id", "phone","patients") }}<br>
<strong>{{ __('family_accounts.residence') }}</strong>{{ patient_residence($family_members_array[$i]) }}
</li>
@endfor
</ol>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
$('#refund_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
function get_bank_balance() {
let refund_amount = parseInt($('#refund_amount').val());
if (!isNaN(refund_amount)) {
let account_id = $('#account_id').val();
let today = new Date();
let today_formatted = String(today.getDate()).padStart(2, '0') + '-' + String(today.getMonth() + 1).padStart(2, '0') + '-' + today.getFullYear();
if (account_id !== '') {
$.ajax({
method: 'POST',
url: '/banking/get_current_account_balance_per_date',
data: {
'bank': account_id,
'date': today_formatted
},
async: true,
success: function(response) {
var bank_record = JSON.parse(response);
var account_balance = bank_record['account_balance'];
$('#account_balance').val(account_balance);
if (account_balance <= 0) {
alert('Account Balance is Zero(0) UGX');
$('.submit_btn').hide();
} else if (refund_amount > account_balance) {
alert('Your Account Balance is low');
$('.submit_btn').hide();
} else {
$('.submit_btn').show();
}
},
error: function(error) {
//console.log(error);
}
});
}
} else {
alert("Please enter the refund before selecting an account");
$('#account_id').val('');
}
}
</script>
@endpush