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

285 lines
15 KiB
PHP
Executable File

@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/tables/css/buttons.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@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">{{ __('family_accounts.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> {{ __('family_accounts.view_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')
{{ Form::open(['url' => 'family_accounts_search', 'method' => 'ANY']) }}
<div class="row">
<div class="col-md-3">
<div class="form-group">
{{ Form::label('family_account_id', __('family_accounts.family_of')) }}
{{ Form::select('family_account_id', $family_accounts_array, '', ['class' => 'form-control compulsory', 'id' => 'family_account_id_dropdown']) }}
<div class="help-block with-errors"></div>
</div>
</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('Submit',['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
</div>
{{ Form::close() }}
@if(!is_null($reg_date))
<h4>{{ __('family_accounts.showing_consumption_of') }}<font color="blue">{{ streamline_date($reg_date) }}</font></h4>
@elseif(!is_null($start_date) && !is_null($end_date))
<h4>{{ __('family_accounts.showing_consumption_from') }}<font color="blue">{{ streamline_date($start_date) }}</font> {{ __('family_accounts.to') }} <font color="blue">{{ streamline_date($end_date) }}</font></h4>
@endif
<div class="row">
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>{{ __('family_accounts.family_head') }}</th>
<th>{{ __('family_accounts.family_members') }}</th>
<th>{{ __('family_accounts.last_deposit') }}</th>
<th>{{ __('family_accounts.current_balance') }}</th>
<th>{{ __('family_accounts.opening_amount') }}</th>
<th>{{ __('family_accounts.credit_limit') }}</th>
<th colspan="4">{{ __('family_accounts.action') }}</th>
</tr>
</thead>
<tbody>
@php $counter = 1; $current_balance_total = 0; @endphp
@if(count($family_accounts) > 0)
@foreach($family_accounts as $family_account)
<tr>
<td>{{ $counter }}</td>
<td>
<a href="patients/{{ $family_account->family_head_id }}">{{ get_full_name($family_account->family_head_id, "id", "first_name", "last_name", "patients") }} ({{ get_name($family_account->family_head_id, "id", "number", "patients") }})</a>
</td>
<td>
@php
$members_array = explode(",", $family_account->family_members_ids);
@endphp
<ol>
@for($i=0; $i < count($members_array); $i++)
<li><a href="patients/{{ $members_array[$i] }}">{{ get_full_name($members_array[$i], "id", "first_name", "last_name", "patients") }} ({{ get_name($members_array[$i], "id", "number", "patients") }})</a></li>
@endfor
</ol>
</td>
<td>
@php
$family_deposit_record = \Streamline\Models\FamilyAccountDeposit::where('family_account_id', $family_account->id)->orderBy('id', 'desc')->get();
$last_deposit_amount = 0;
if(count($family_deposit_record) > 0){
$last_deposit_record_amount = $family_deposit_record->first();
$last_deposit_amount = $last_deposit_record_amount->deposit_amount;
}
@endphp
{{ ugandan_shillings($last_deposit_amount) }}<br>
<small>(Date: {{ get_name($family_account->id, "family_account_id", "created_at", "family_account_deposits") != "N/A" ? streamline_date(get_name($family_account->id, "family_account_id", "deposit_date", "family_account_deposits")) : "N/A" }})</small>
</td>
<td>
{{ is_numeric($family_account->current_balance) ? ugandan_shillings($family_account->current_balance) : "N/A" }}
@php $current_balance_total += $family_account->current_balance; @endphp
</td>
<td>
{{ is_numeric($family_account->opening_amount) ? ugandan_shillings($family_account->opening_amount) : "" }}
</td>
<td>
{{ is_numeric($family_account->credit_limit) ? ugandan_shillings($family_account->credit_limit) : "" }}
</td>
<td>
<a href="/family_accounts/{{ $family_account->id }}/edit/" class="btn btn-info btn-sm"><i class="fa fa-pencil"></i> {{ __('family_accounts.edit') }}</a>
</td>
<td>
{{ Form::open(['url' => 'family_accounts/add_deposit']) }}
{{ Form::hidden('family_account_id', $family_account->id) }}
{{ Form::submit('Add deposit', ['class' => 'btn btn-success btn-sm']) }}
{{ Form::close() }}
</td>
<td>
<a href="/family_accounts/{{ $family_account->id }}/statement/" class="btn btn-primary btn-sm"><i class="fa fa-book"></i> Statement</a>
</td>
<td>
{{ Form::model($family_account->id, ['method' => 'DELETE', 'route' => ['family_accounts.destroy', $family_account->id], 'id' => 'delete_form_'.$family_account->id]) }}
<button type="submit" class="btn btn-danger btn-sm" id="{{$family_account->id}}"><i class="fa fa-trash"></i> {{ __('family_accounts.deactivate') }}</button>
{{ Form::close() }}
</td>
</tr>
@php $counter++; @endphp
@endforeach
@endif
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td></td>
<td><strong>{{ __('family_accounts.total') }}</strong></td>
<td><strong>{{ ugandan_shillings($current_balance_total) }}</strong></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script>
$('.btn-danger').click(function(e){
let id = $(this).attr('id');
e.preventDefault();
let sure = confirm('Are you sure you want to remove this family account?');
if(sure){
$.ajax({
url: '/get_family_acc_balance/'+id,
data: {},
success: function(response){
console.log("family balance === "+response);
if(response != 0){
if(response > 0){
alert("The family account has a balance of "+response+". First make a refund to the family before deleting the account");
}
if(response < 0){
alert("The family account has a balance of "+response+". Let the family pay the excess balance before deleting the account");
}
return false;
} else{
$('#delete_form_'+id).submit();
}
},
error: function(response){
console.log(response);
return false;
}
});
}
return false;
});
</script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.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/bower_components/select2/select2.min.js') }}"></script>
<script>
$('#family_account_id_dropdown').select2({
placeholder: "-- select --"
});
$('#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();
}
});
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
</script>
@endpush