Files
streamline-emr/docker/statistics/Modules/PatientDiscounts/Resources/views/family_accounts/statements.blade.php
T
2025-03-31 03:46:05 +03:00

508 lines
24 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/datatables/jquery.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/tables/css/buttons.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
@if(session()->get("print_family_account_receipt_pdf") == 1)
{{ Form::hidden('print_family_account_receipt_pdf', 1, ['id' => 'print_family_account_receipt_pdf']) }}
@endif
@if(session()->get("print_family_account_refund_receipt_pdf") == 1)
{{ Form::hidden('print_family_account_refund_receipt_pdf', 1, ['id' => 'print_family_account_refund_receipt_pdf']) }}
@endif
<div class="row bg-title">
<div class="col-lg-6 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">Family Account Statement <font color="blue">{{ get_full_name($family_account_details->family_head_id, "id", "first_name", "last_name", "patients") }} ({{ get_name($family_account_details->family_head_id, "id", "number","patients") }})</font></h4>
</div>
<div class="col-lg-6 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> Family Account Statement</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('patient_discounts::family_accounts.menu')
</div>
</div>
<div class="white-box">
@include('flash::message')
@php $family_head_id = get_name($family_account_id, "id", "family_head_id", "family_accounts") @endphp
{{ Form::open(['url' => 'family_accounts/' . $family_account_id . '/statement/', 'method' => 'ANY']) }}
<div class="row">
<div class="col-md-2">
{{ Form::hidden('family_account_id', $family_account_id) }}
</div>
<div class="col-md-3">
<div class="form-group" id="searchby">
{{ Form::label('search_by', __('family_accounts.date')) }}
{{ Form::select('search_by', ['0'=>'Last 24 hours','1'=>'Custom Date','2'=>'Custom Range'], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_search">
<div class="form-group" id="reg_date" style="padding-top: 23px;">
<div class="input-group">
{{ Form::text('reg_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_range_search">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('start_date', __('family_accounts.from')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" id="reg_date">
{{ Form::label('end_date', __('family_accounts.to')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" style="padding-top: 5px;"><br>
{{ Form::button(__('family_accounts.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
{{ Form::close() }}
<div class="col-md-1">
<div style="float: right;">
{{ Form::open(['url' => 'family_statement_print'])}}
{{ Form::hidden('family_account_id', $family_account_id) }}
{{ Form::hidden('reg_date', $reg_date) }}
{{ Form::hidden('start_date', $start_date) }}
{{ Form::hidden('end_date', $end_date) }}
<button type="submit" class="btn btn-rounded" style="background-color: #03C03C; color: white;">
<i class="fa fa-print"></i>
<span>Print Statement</span>
</button>
{{ Form::close() }}
<br>
</div>
</div>
</div>
@if(!is_null($reg_date))
<h2>Family Statement as at <font color="blue">{{ streamline_date($reg_date) }}</font></h2>
@elseif(!is_null($start_date) && !is_null($end_date))
<h2>Family statement as at <font color="blue">{{ streamline_date($start_date) }}</font> {{ __('family_accounts.to') }} <font color="blue">{{ streamline_date($end_date) }}</font></h2>
@endif
<h3>Family Deposits</h3>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>{{ __('family_accounts.deposited_on') }}</th>
<th>Received By</th>
<th>{{ __('family_accounts.family_head') }}</th>
<th>{{ __('family_accounts.deposited_by') }}</th>
<th>{{ __('family_accounts.amount_deposited') }}</th>
</tr>
</thead>
<tbody>
@php $counter = 1; $total_family_deposits = 0; $current_balance_total = 0; @endphp
@if(count($family_deposits) > 0)
@foreach($family_deposits as $deposit)
<tr>
<td>{{ $counter }}</td>
<td>{{ streamline_date($deposit->deposit_date) }}</td>
<td>{{ get_full_name($deposit->created_by, "id", "first_name", "last_name", "users") }}</td>
@php $family_head_id = get_name($deposit->family_account_id, "id", "family_head_id", "family_accounts") @endphp
<td>
{{ get_full_name($family_head_id, "id", "first_name", "last_name", "patients") }}
({{ get_name($family_head_id, "id", "number","patients") }})
</td>
@php
$family_members_array = [];
$family_account_details = \Streamline\Models\FamilyAccount::withTrashed()->find($deposit->family_account_id);
$family_members_array = explode(",", $family_account_details->family_members_ids);
@endphp
{{--<td>
@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") }} ({{ get_name($family_members_array[$i], "id", "number","patients") }})</a>
</li>
@endfor
</td>--}}
<td>
{{ $deposit->deposited_by }}
</td>
<td>
@php $total_family_deposits += $deposit->deposit_amount; @endphp
{{ ugandan_shillings($deposit->deposit_amount) }}
</td>
</tr>
@php $counter++; @endphp
@endforeach
@else
<tr>
<td colspan="6" class="text-center"><code>No family deposits have been made</code></td>
</tr>
@endif
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td></td>
<td><strong>{{ __('family_accounts.total') }}</strong></td>
<td></td>
<td><strong>{{ ugandan_shillings($total_family_deposits) }}</strong></td>
</tr>
</tfoot>
</table>
</div>
<h3>Family consumption</h3>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>{{ __('family_accounts.date') }}</th>
<th>Member</th>
<th>{{ __('family_accounts.reason') }}</th>
<th>{{ __('family_accounts.amount_consumed') }}</th>
</tr>
</thead>
<tbody>
@php $counter = 1; $total_consumptions = 0; @endphp
@if(count($family_consumptions) > 0)
@foreach($family_consumptions as $member_consumption)
@php
$expenditure_type = $member_consumption->expenditure_tag;
$items_received_array = [];
if($expenditure_type == "Services"){
$service_deposit_record = \Streamline\Models\ServiceDeposit::where(['patient_id' => $member_consumption->patient_id, 'episode_id' => $member_consumption->episode_id])->first();
if ($service_deposit_record){
$items_received = explode(",", $service_deposit_record->items_ids);
for($i = 0; $i < count($items_received); $i++){
$items_received_array[] = get_name($items_received[$i], "id", "name", "services");
}
}
} elseif($expenditure_type == "Treatment"){
$treatment_deposit_record = \Streamline\Models\TreatmentDeposits::where(['patient_id' => $member_consumption->patient_id, 'episode_id' => $member_consumption->episode_id])->first();
if ($treatment_deposit_record){
$items_received = explode(",", $treatment_deposit_record->treatment_items);
for($i = 0; $i < count($items_received); $i++){
$items_received_array[] = get_name($items_received[$i], "id", "name", "drugs");
}
}
} elseif($expenditure_type == "Sundries"){
$sundries_deposit_record = \Streamline\Models\SundryDeposit::where(['patient_id' => $member_consumption->patient_id, 'episode_id' => $member_consumption->episode_id])->first();
if ($sundries_deposit_record){
$items_received = explode(",", $sundries_deposit_record->sundry_items);
for($i = 0; $i < count($items_received); $i++){
$items_received_array[] = get_name($items_received[$i], "id", "name", "sundries");
}
}
} elseif($expenditure_type == "Investigations"){
$investigation_deposit_record = \Streamline\Models\InvestigationDeposit::where(['patient_id' => $member_consumption->patient_id, 'episode_id' => $member_consumption->episode_id])->first();
if ($investigation_deposit_record){
$items_received = explode(",", $investigation_deposit_record->investigation_items);
for($i = 0; $i < count($items_received); $i++){
$items_received_array[] = get_name($items_received[$i], "id", "name", "investigations");
}
}
} elseif($expenditure_type == "Procedures"){
$procedure_deposit_record = \Streamline\Models\ProcedureDeposit::where(['patient_id' => $member_consumption->patient_id, 'episode_id' => $member_consumption->episode_id])->first();
if ($procedure_deposit_record){
$items_received = explode(",", $procedure_deposit_record->procedure_items);
for($i = 0; $i < count($items_received); $i++){
$items_received_array[] = get_name($items_received[$i], "id", "name", "procedures");
}
}
}
@endphp
<tr>
<td>{{ $counter }}</td>
@php $family_head_id = get_name($member_consumption->family_account_id, "id", "family_head_id", "family_accounts") @endphp
<td>
{{ streamline_date($member_consumption->created_at) }}
</td>
<td>
{{ get_full_name($member_consumption->patient_id, "id", "first_name", "last_name", "patients") }}
</td>
<td>
<strong>{{ $member_consumption->expenditure_tag == "Services" ? "Consultation / Services" : $member_consumption->expenditure_tag }}</strong>
<ol>
@for($j = 0; $j < count($items_received_array); $j++)
<li>{{ $items_received_array[$j] }}</li>
@endfor
</ol>
</td>
<td>
{{ ugandan_shillings($member_consumption->amount_consumed) }}
@php
$total_consumptions += $member_consumption->amount_consumed;
@endphp
</td>
</tr>
@php $counter++; @endphp
@endforeach
@else
<tr>
<td colspan="6" class="text-center"><code>No family consumption has been recorded</code></td>
</tr>
@endif
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td><strong>{{ __('family_accounts.total') }}</strong></td>
<td></td>
<td><strong>{{ ugandan_shillings($total_consumptions) }}</strong></td>
</tr>
</tfoot>
</table>
</div>
<h3>Family Refunds</h3>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>Refunded On</th>
<th>Cashier</th>
<th>{{ __('family_accounts.family_head') }}</th>
<th>Refunded To</th>
<th>Amount Refunded</th>
</tr>
</thead>
<tbody>
@php $counter = 1; $total_family_refunds = 0; @endphp
@if(count($family_refunds) > 0)
@foreach($family_refunds as $refund)
<tr>
<td>{{ $counter }}</td>
<td>{{ streamline_date($refund->created_at) }}</td>
<td>{{ get_full_name($refund->created_by, "id", "first_name", "last_name", "users") }}</td>
@php $family_head_id = get_name($refund->family_account_id, "id", "family_head_id", "family_accounts") @endphp
<td>
{{ get_full_name($family_head_id, "id", "first_name", "last_name", "patients") }}
({{ get_name($family_head_id, "id", "number","patients") }})
</td>
<td>
{{ $refund->refund_to }}
</td>
<td>
@php $total_family_refunds += $refund->refund_amount; @endphp
{{ ugandan_shillings($refund->refund_amount) }}
</td>
</tr>
@php $counter++; @endphp
@endforeach
@else
<tr>
<td colspan="6" class="text-center"><code>No family refunds have been made</code></td>
</tr>
@endif
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td></td>
<td><strong>{{ __('family_accounts.total') }}</strong></td>
<td></td>
<td><strong>{{ ugandan_shillings($total_family_refunds) }}</strong></td>
</tr>
</tfoot>
</table>
</div>
<div style="font-weight: bolder; font-size: 24px;">
<br><br>
<span><strong>Current Balance:</strong> {{ is_numeric($family_account_details->current_balance) ? ugandan_shillings($family_account_details->current_balance) : "N/A" }}</span>
<hr>
</div>
<br><br>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-2">
<a href="/family_accounts/{{ $family_account_details->id }}/edit/" class="btn btn-info btn-block"><i class="fa fa-pencil"></i> {{ __('family_accounts.edit') }}</a>
</div>
<div class="col-md-2">
{{ Form::open(['url' => 'family_accounts/add_deposit']) }}
{{ Form::hidden('family_account_id', $family_account_details->id) }}
{{ Form::submit('Add deposit', ['class' => 'btn btn-success btn-block']) }}
{{ Form::close() }}
</div>
<div class="col-md-2">
<a href="/family_accounts/{{ $family_account_details->id }}/statement/" class="btn btn-primary btn-block"><i class="fa fa-book"></i> Statement</a>
</div>
<div class="col-md-2">
{{ Form::model($family_account_details->id ,['method' => 'DELETE', 'route' => ['family_accounts.destroy', $family_account_details->id]]) }}
<button type="submit" class="btn btn-danger btn-block" onclick="return confirm('Are you sure you want to remove this family account?')"><i class="fa fa-trash"></i> {{ __('family_accounts.deactivate') }}</button>
{{ Form::close() }}
</div>
<div class="col-md-2">
<a href="/family_accounts/refund/{{ $family_account_details->id }}" class="btn btn-default btn-block"> Refund Family Account</a>
</div>
<div class="col-md-1"></div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/dataTables.buttons.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.flash.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/jszip.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/pdfmake.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/vfs_fonts.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.html5.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.print.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.colVis.min.js') }}"></script>
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script>
if ($('#print_family_account_receipt_pdf').val() == 1) {
var win = window.open('/print_family_account_receipt_pdf_details', '_blank');
if (win) {
win.focus();
} else {
alert('Please allow popups for Stre@mline');
}
}
if ($('#print_family_account_refund_receipt_pdf').val() == 1) {
var win = window.open('/print_family_account_refund_receipt_pdf_details', '_blank');
if (win) {
win.focus();
} else {
alert('Please allow popups for Stre@mline');
}
}
var family_name = {!! json_encode(get_full_name($family_head_id, "id", "first_name", "last_name", "patients")) !!};
$('.table111').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy',
{ extend: 'csv',
message: 'CONSUMPTION DETAILS FOR THE FAMILY OF '+family_name
},
{ extend: 'excel',
message: 'CONSUMPTION DETAILS FOR THE FAMILY OF '+family_name,
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
sheetName: 'CONSUMPTION DETAILS FOR THE FAMILY OF '+family_name
},
{ extend: 'pdf',
message: 'CONSUMPTION DETAILS FOR THE FAMILY OF '+family_name,
orientation: 'landscape',
pageSize: 'LETTER',
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
customize: function(doc) {
doc.defaultStyle.fontSize = 10;
}
},
{ extend: 'print',
message: 'CONSUMPTION DETAILS FOR THE FAMILY OF '+family_name,
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt')
.css('background', '#fff')
.prepend(
'<img src="<?php echo asset('uploads/logo/logo-sm.png'); ?>" style="position:absolute; top:0; right:0;" />'
);
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
</script>
@endpush