updated streamline-setup v2

This commit is contained in:
2025-01-15 08:53:49 -08:00
committed by alec.turner
parent a2ce9248f0
commit 4b569f81b0
20228 changed files with 2932048 additions and 63204 deletions
@@ -0,0 +1,5 @@
<?php
return [
'name' => 'Invoices'
];
@@ -0,0 +1,13 @@
<?php
namespace Modules\Invoices\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,113 @@
<?php
namespace Modules\Invoices\Providers;
use Illuminate\Support\ServiceProvider;
use Modules\Invoices\Providers\RouteServiceProvider;
class InvoicesServiceProvider extends ServiceProvider{
/**
* @var string $moduleName
*/
protected $moduleName = 'Invoices';
/**
* @var string $moduleNameLower
*/
protected $moduleNameLower = 'invoices';
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->register(RouteServiceProvider::class);
}
/**
* Register config.
*
* @return void
*/
protected function registerConfig()
{
$this->publishes([
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
], 'config');
$this->mergeConfigFrom(
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
);
}
/**
* Register views.
*
* @return void
*/
public function registerViews()
{
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
$sourcePath = module_path($this->moduleName, 'Resources/views');
$this->publishes([
$sourcePath => $viewPath
], ['views', $this->moduleNameLower . '-module-views']);
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
}
/**
* Register translations.
*
* @return void
*/
public function registerTranslations()
{
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
$this->loadJsonTranslationsFrom($langPath);
} else {
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang'));
}
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [];
}
private function getPublishableViewPaths(): array
{
$paths = [];
foreach (\Config::get('view.paths') as $path) {
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
$paths[] = $path . '/modules/' . $this->moduleNameLower;
}
}
return $paths;
}
}
@@ -0,0 +1,68 @@
<?php
namespace Modules\Invoices\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'Modules\Invoices\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(module_path('Invoices', '/Routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(module_path('Invoices', '/Routes/api.php'));
}
}
@@ -0,0 +1,167 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@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">{{ __('finance.patient_category_invoices') }} {{ __('invoices.details') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('invoices.details') }}</li>
</ol>
</div>
</div>
<div class="white-box">
<a target="_blank" class="btn btn-inverse btn-sm float-right" href='<?php echo url("invoices/patient_category_detail_print/{$id}/{$start_date}/{$end_date}"); ?>'>{{ __('invoices.print') }}</a>
<div class="row">
<div class="col-md-4">
<h4>
<b>{{ __('invoices.patient_category') }}:</b> {{ get_name(get_name($invoices[0]->patient_id, 'id', 'category_id', 'patients'), 'id', 'name', 'patient_categories') }}
</h4>
</div>
<div class="col-md-8">
<h4>
<b>{{ __('invoices.patient_names') }}:</b> {{ get_full_name($invoices[0]->patient_id, 'id', 'first_name', 'last_name', 'patients') }} ({{ (get_name($invoices[0]->patient_id, 'id', 'gender', 'patients') == 1) ? 'Male' : 'Female'}} - {{ get_patients_age(get_name($invoices[0]->patient_id, 'id', 'date_of_birth', 'patients')) }})
</h4>
</div>
</div>
<hr>
<div class="table-responsive">
<table class="table table-hover color-bordered-table success-bordered-table">
<thead>
<tr>
<th class="text-center">{{ __('finance.date') }}</th>
<th class="text-center">{{ __('finance.invoice_number') }}</th>
<th class="text-center">{{ __('finance.items') }}</th>
<th class="text-center">{{ __('finance.item_amounts') }}</th>
<th class="text-center">{{ __('finance.patient_amount_paid') }}</th>
<th class="text-center">{{ __('finance.reason') }}</th>
</tr>
@php
$sum_total = 0;
@endphp
</thead>
<tbody>
@foreach($invoices as $invoice)
<tr>
<td class="text-center">{{ streamline_date($invoice->transaction_date) }}</td>
<td class="text-center">
{{--{{ ($invoice->episode_id != 0) ? ((get_claim_number($invoice->episode_id)) ? get_claim_number($invoice->episode_id) : $invoice->receipt_number) : "" }}--}}
{{ ($invoice->number) ?? $invoice->receipt_number }}
</td>
<td class="text-left">
@if($invoice->tag_id == 11)
N/A
@else
@php
$items = explode(",",$invoice->items_ids);
for($i = 0; $i < count($items); $i++){
switch ($invoice->tag_id){
case 1;
case 3;
$name = get_name($items[$i], 'id', 'name', 'drugs');
break;
case 2;
$name = get_name($items[$i], 'id', 'name', 'investigations');
break;
case 4;
$name = get_name($items[$i], 'id', 'name', 'procedures');
break;
case 5;
$name = get_name($items[$i], 'id', 'name', 'sundries');
break;
case 6: case 7: case 8;
$name = get_name($items[$i], 'id', 'name', 'services');
break;
case 10;
$name = "Inpatient Deposit";
break;
case 16;
$name = get_name($items[$i], 'id', 'name', 'eye_glasses');
break;
default:
$name = "";
break;
}
echo ($i + 1).". ".$name."<br/>";
}
@endphp
@endif
</td>
<td class="text-center">
@if($invoice->tag_id == 11)
N/A
@else
@php
$amounts = explode(",",$invoice->items_amounts);
for($i = 0; $i < count($amounts); $i++){
echo ($i + 1).". ".$amounts[$i]."<br/>";
}
$sum_total += $invoice->patient_amount;
@endphp
@endif
</td>
<td class="text-center">{{ ugandan_shillings($invoice->patient_amount) }}</td>
<td class="text-center">
{{ get_name($invoice->tag_id, 'id', "name", 'finance_point_tags') }}
</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th></th>
<th></th>
<th></th>
<th class="text-center"><b>{{ __('finance.total') }}</b></th>
<th class="text-center"><b>{{ ugandan_shillings($sum_total) }}</b></th>
<th></th>
</tr>
</tfoot>
</table>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
function showPopup() {
var myDiv = document.getElementById('invoice');
var newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write(
"<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script>
$('#table').DataTable();
</script>
@endpush
@@ -0,0 +1,151 @@
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" type="image/png" sizes="16x16" href="{{ asset('uploads/streamline/color/streamline_icon-02.png') }}">
<title>{{ config('app.name', 'Patient Category Invoice - Stre@mline') }}</title>
<!-- Bootstrap Core CSS -->
<link href="{{ asset('bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
<style>
body{
/*font-size: 1.2em;*/
}
/*thead, tfoot { display: table-row-group }*/
thead {
display: table-header-group;
}
tfoot {
display: table-row-group;
}
tr {
page-break-before: always;
page-break-after: always;
page-break-inside: avoid;
}
</style>
</head>
<body>
<div class="container-fluid">
@include('layouts.header_pdf_print')
<h4 class="heading" style="text-align: center;">{{ __('invoices.patient_category_invoices') }}</h4>
<hr>
<div class="row">
<div class="col-4">
<h5>
<b>{{ __('invoices.patient_category') }}:</b> {{ get_name(get_name($invoices[0]->patient_id, 'id', 'category_id', 'patients'), 'id', 'name', 'patient_categories') }}
</h5>
</div>
<div class="col-8">
<h5>
<b>{{ __('invoices.patient_names') }}:</b> {{ get_full_name($invoices[0]->patient_id, 'id', 'first_name', 'last_name', 'patients') }} ({{ (get_name($invoices[0]->patient_id, 'id', 'gender', 'patients') == 1) ? 'Male' : 'Female'}} - {{ get_patients_age(get_name($invoices[0]->patient_id, 'id', 'date_of_birth', 'patients')) }})
</h5>
</div>
</div>
<hr>
<table class="table table-sm">
<thead class="thead-light">
<tr>
<th class="text-center">{{ __('finance.date') }}</th>
<th class="text-center">{{ __('finance.invoice_number') }}</th>
<th class="text-center">{{ __('finance.items') }}</th>
<th class="text-center">{{ __('finance.item_amounts') }}</th>
<th class="text-center">{{ __('invoices.total_amount') }}</th>
<th class="text-center">{{ __('finance.reason') }}</th>
</tr>
@php $sum_total = 0; @endphp
</thead>
<tbody>
@foreach($invoices as $invoice)
<tr>
<td class="text-center">{{ streamline_date($invoice->transaction_date) }}</td>
<td class="text-center">
{{ ($invoice->number) ?? $invoice->receipt_number }}
</td>
<td class="text-left">
@if($invoice->tag_id == 11)
N/A
@else
@php
$items = explode(",",$invoice->items_ids);
for($i = 0; $i < count($items); $i++){
switch ($invoice->tag_id){
case 1;
case 3;
$name = get_name($items[$i], 'id', 'name', 'drugs');
break;
case 2;
$name = get_name($items[$i], 'id', 'name', 'investigations');
break;
case 4;
$name = get_name($items[$i], 'id', 'name', 'procedures');
break;
case 5;
$name = get_name($items[$i], 'id', 'name', 'sundries');
break;
case 6: case 7: case 8;
$name = get_name($items[$i], 'id', 'name', 'services');
break;
case 10;
$name = "Inpatient Deposit";
break;
case 16;
$name = get_name($items[$i], 'id', 'name', 'eye_glasses');
break;
default:
$name = "";
break;
}
echo ($i + 1).". ".$name."<br/>";
}
@endphp
@endif
</td>
<td class="text-center">
@if($invoice->tag_id == 11)
N/A
@else
@php
$amounts = explode(",",$invoice->items_amounts);
for($i = 0; $i < count($amounts); $i++){
echo ($i + 1).". ". ugandan_shillings($amounts[$i]) ."<br/>";
}
$sum_total += $invoice->patient_amount;
@endphp
@endif
</td>
<td class="text-center">{{ ugandan_shillings($invoice->patient_amount) }}</td>
<td class="text-center">
{{ get_name($invoice->tag_id, 'id', "name", 'finance_point_tags') }}
</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th class="text-center"><b>{{ __('invoices.total') }}</b></th>
<th class="text-center"><b>{{ ugandan_shillings($sum_total) }}</b></th>
<th></th>
</tr>
</tfoot>
</table>
</div>
</body>
</html>
@@ -0,0 +1,210 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<br/>
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">{{ __('invoices.donor_discount_invoices') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="/invoices">{{ __('invoices.invoices_dashboard') }}</a></li>
<li class="active">{{ __('invoices.donor_discount_invoices') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-body">
<br/>
<h3>{{ __('invoices.select_the_date_range') }}</h3>
<br/>
<br/>
{{ Form::open(['method'=>'post','route' => 'invoices.donor_discounts']) }}
<div class="form-group">
<select class="form-control compulsory required" name="donor" id="donor" required>
<option value="">-{{ __('invoices.select') }}-</option>
@foreach($donors as $item)
<option value="{{ $item->id }}">{{ $item->name }}</option>
@endforeach
</select>
</div>
<div>
<div class="form-group">
{{ Form::label('start_date', __('invoices.start_date')) }}
<div class="input-group">
{{ Form::text('start_date', '', ['class'=>'form-control compulsory','readonly', 'id'=>'start_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="form-group">
{{ Form::label('end_date', __('invoices.end_date')) }}
<div class="input-group">
{{ Form::text('end_date', '', ['class'=>'form-control compulsory', 'readonly', 'id'=>'end_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="form-group">
{{ Form::submit(__('invoices.submit'), ['class'=>'btn btn-success pull-right']) }}
</div>
{{ Form::close() }}
</div>
</div>
</div>
<div class="col-md-9">
<div class="row">
<div class="panel panel-default col-md-12">
<div class="panel-body panel-primary">
{{ Form::open(['method'=>'post','route' => 'invoices.process_donor_invoice']) }}
{{ csrf_field() }}
{{ Form::hidden('start_date', $request->start_date) }}
{{ Form::hidden('end_date', $request->end_date) }}
{{ Form::hidden('status', 'new') }}
{{ Form::hidden('donor', $request->donor) }}
{{ Form::hidden('invoice_number', generateReceiptNumberFromDB() ) }}
@php
$dates = $request->start_date.'/'.subtractDates($request->end_date,'1 days');
@endphp
{{ Form::hidden('invoice_date', $dates ) }}
@if($request != [])
@if($request->donor != null)
<h2><strong>Donor Name: {{ get_name($request->donor, 'id', 'name', 'donors') }}</strong></h2>
@if(isset($request->start_date) && isset($request->end_date))
@if($total > 0)
{{ Form::button('Generate Invoice',['type' => 'submit', 'class' => 'btn btn-success'])}}
@endif
<br/>
@if(isset($display))
<br/>
<h3 class="label label-info col-lg-5"> {!! isset($display) ? $display : '' !!}</h3>
<br/>
<br/>
@endif
<div class="table-responsive">
<table id="table" class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('invoices.date') }}</th>
<th>{{ __('invoices.cashier_name') }}</th>
<th>{{ __('invoices.memo') }}</th>
<th>{{ __('invoices.received_by') }}</th>
<th>{{ __('invoices.reason') }}</th>
<th>{{ __('invoices.discount_type') }}</th>
<th>{{ __('invoices.receipt') }}</th>
<th>{{ __('invoices.amount') }}</th>
</tr>
</thead>
<tbody>
@if(count($discounts) > 0)
@foreach($discounts as $item)
<tr>
<td>{{ streamline_date($item->created_at) }}</td>
<td>{{ get_full_name($item->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>{{ get_name($item->patient_category, 'id', 'name', 'patient_categories') }}</td>
<td>{{ get_full_name(Auth::id(), 'id', 'first_name', 'last_name', 'users') }}</td>
<td>{{ get_name($item->tag_id, 'id', 'name', 'finance_point_tags') }}</td>
<td>{{ get_name($item->donor_discount_category_id, 'id', 'name', 'discount_categories') }}</td>
<td>{{ $item->receipt_number }}</td>
<td>{{ ugandan_shillings($item->donor_to_pay) }}</td>
</tr>
@endforeach
@endif
</tbody>
@if(count($discounts) > 0)
<tr>
<td colspan="6"></td>
<td><strong>{{ __('invoices.total') }}</strong></td>
<td>{{ ugandan_shillings($total) }}</td>
</tr>
@endif
</table>
</div>
@if($total > 0)
{{ Form::button('Generate Invoice',['type' => 'submit', 'class' => 'btn btn-success'])}}
@endif
{{ Form::close() }}
@endif
@else
<h3 class="label label-info">{{ __('invoices.select_patient_category') }}</h3>
@endif
@else
<h3 class="label label-info">{{ __('invoices.select_valid_date_range') }}</h3>
@endif
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
jQuery('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script type="text/javascript">
jQuery('#start_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<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>
$('.table').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
</script>
@endpush
@@ -0,0 +1,127 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<br/>
<div class="row">
<div id="invoice">
<div class="col-md-10 offset-1">
<div class="white-box">
<h3><b>{{ __('invoices.invoice') }}</b> <span class="pull-right">#{{ $request->invoice_number }}</span></h3>
<hr>
<div class="row">
<div class="col-md-12">
<div class="pull-left">
<address>
<h3> &nbsp;<b class="text-danger">{{ $hospital_information->name }}</b></h3>
<p class="text-muted m-l-5">{{ $hospital_information->phone_number }}, {{ $hospital_information->email }},
<br/> {{ get_name($hospital_information->sub_county,'id', 'name', 'subcounties') }}, {{ get_name($hospital_information->district,'id', 'name', 'districts') }},
<br/> {{ $hospital_information->country }}.</p>
</address>
</div>
<div class="pull-right text-right">
<address>
<h3>To,</h3>
<h4 class="font-bold">{{ get_name($request->donor, 'id', 'name', 'donors') }}</h4>
<p class="text-muted m-l-30">{{ streamline_date($request->start_date) }} to {{ streamline_date($request->end_date) }},
<p class="m-t-30"><b>{{ __('invoices.invoice_date') }} : </b> <i class="fa fa-calendar"></i> {{ streamline_date_time(\Carbon\Carbon::now()->toDateTimeString()) }}</p>
<p><b>{{ __('invoices.due_date') }} : </b> <i class="fa fa-calendar"></i> {{ streamline_date_time(\Carbon\Carbon::now()->toDateTimeString()) }}</p>
</address>
</div>
</div>
<div class="col-md-12">
<div class="table-responsive m-t-40">
<table class="table table-hover color-bordered-table success-bordered-table">
<thead>
<tr>
<th class="text-center">{{ __('invoices.date') }}</th>
<th class="text-right">{{ __('invoices.invoice_number') }}</th>
<th class="text-right">{{ __('invoices.patient_name') }}</th>
<th class="text-right">{{ __('invoices.amount') }}</th>
<th class="text-right">{{ __('invoices.reason') }}</th>
</tr>
@php
$sum_total = 0;
@endphp
</thead>
<tbody>
@foreach($invoices as $item)
<tr>
<td class="text-center">{{ streamline_date($item->created_at) }}</td>
<td class="text-right">{{ $item->receipt_number }}</td>
<td class="text-right">{{ get_full_name($item->patient_id, 'id', 'first_name', 'last_name', 'patients') }}</td>
<td class="text-right">
@php
$amount = $item->donor_to_pay;
$sum_total += $amount;
echo ugandan_shillings($amount);
@endphp
</td>
<td class="text-right">
{{ get_name($item->tag_id, 'id', "name", 'finance_point_tags') }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="col-md-12">
<div class="pull-right m-t-30 text-right">
<p>{{ __('invoices.sub_total_amount') }}: {{ ugandan_shillings($sum_total) }}</p>
<p>vat (0%) : </p>
<hr>
<h3><b>{{ __('invoices.total') }} :</b>{{ ugandan_shillings($sum_total) }}</h3> </div><br/>
<p><strong>{{ __('invoices.served_by') }} : </strong></p><h3>{{ $users_name }}</h3>
<p>{{ __('invoices.sign') }}..................................................................................................................</p>
<div class="clearfix"></div>
<hr>
</div>
</div>
</div>
</div>
</div>
<div class="text-right">
{{--<button class="btn btn-danger" type="submit"> Proceed to payment </button>--}}
<button onclick="showPopup();" class="btn btn-default btn-outline" type="button"> <span><i class="fa fa-print"></i> {{ __('invoices.print') }}</span> </button>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
function showPopup() {
var myDiv = document.getElementById('invoice');
var newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write("<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script>
$('#table').DataTable();
</script>
@endpush
@@ -0,0 +1,237 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
<style>
@media print {tr.vendorListHeading {
background-color: #1a4567 !important;
-webkit-print-color-adjust: exact;
}}
@media print {.vendorListHeading th {
color: white !important;
}}
</style>
@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">{{ __('invoices.patient_category_invoices') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active"><i class="fa fa-file"></i> {{ __('invoices.patient_category_invoices') }}</li>
</ol>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-10 text-right">
<a class="btn btn-primary" href="{{ route('invoices.print_invoice', $request->invoice_number) }}" target="_blank"> <span><i class="fa fa-print"></i> {{ __('invoices.print') }}</span> </a>
</div>
</div>
<br>
<div class="row">
<div id="printableContent">
<div class="col-md-12">
<div class="white-box">
<h3><b>{{ __('invoices.invoice') }}</b> <span class="pull-right">#{{ $request->invoice_number }}</span></h3>
<hr>
<div class="row">
<div class="col-md-12">
<div class="pull-left">
<a href="javascript:void(0)" class="text-center db">
@php $hospital_information = \Streamline\Models\HospitalInformation::first(); @endphp
<img src="{{ asset($hospital_information->logo) }}" style="max-height: 160px; margin: auto; max-width: 260px;" alt="Home" /><br/>
</a>
<address>
<h3> &nbsp;<b class="text-danger">{{ $hospital_information->name }}</b></h3>
<p class="text-muted m-l-5">{{ $hospital_information->phone_number }}, {{ $hospital_information->email }},
<br/> {{ get_name($hospital_information->sub_county,'id', 'name', 'subcounties') }}, {{ get_name($hospital_information->district,'id', 'name', 'districts') }},
<br/> {{ $hospital_information->country }}.</p>
</address>
</div>
<div class="pull-right text-right">
<address>
<h3>To,</h3>
<h4 class="font-bold">{{ get_name($request->patient_category, 'id', 'name', 'patient_categories') }} <br> {{ individual_of_invoice($request->invoice_number) ?? "" }}</h4>
<p class="text-muted m-l-30">{{ streamline_date($request->start_date) }} {{ __('invoices.to') }} {{ streamline_date($request->end_date) }},
<p class="m-t-30"><b>{{ __('invoices.invoice_date') }} : </b> <i class="fa fa-calendar"></i> {{ streamline_date_time(\Carbon\Carbon::now()->toDateTimeString()) }}</p>
</address>
</div>
</div>
<div class="col-md-12">
<div class="row">
<div class="col-md-12">
<br/>
<br/>
</div>
</div>
<div class="table-responsive m-t-40">
<table class="table table-hover color-bordered-table success-bordered-table">
<thead>
@if ((count($invoices)==1) && ($invoices[0]->patient_id==0) && ($invoices[0]->episode_id==0))
<tr>
<th>{{ __('invoices.date') }}</th>
<th colspan="4">{{ __('invoices.description') }}</th>
<th>{{ __('invoices.amount') }}</th>
</tr>
@else
<tr>
<th class="text-center">{{ __('invoices.date') }}</th>
<th class="text-center">{{ __('invoices.claim_number') }}</th>
<th class="text-center">{{ __('invoices.patient_number') }}</th>
<th class="text-center">{{ __('invoices.patient_name') }}</th>
<th class="text-center">{{ __('invoices.amount') }}</th>
<th class="text-center">{{ __('invoices.reason') }}</th>
</tr>
@endif
@php
$sum_total = 0;
@endphp
</thead>
<tbody>
@if ((count($invoices)==1) && ($invoices[0]->patient_id==0) && ($invoices[0]->episode_id==0))
{{-- this is more likely a journal so fetch journal details --}}
@php
$journal_number = substr($invoices[0]->items_ids, 10); //now remove the substring "Journal - "
$patient_category_id = $invoices[0]->patient_category;
$journal_details = \Streamline\Models\Journal::where('journal_number', $journal_number)->first();
@endphp
@if ($journal_details)
@php
$journal_name_ids_array = explode(",",$journal_details->name_ids);
$index_of_patient_category = array_search($patient_category_id, $journal_name_ids_array);
$journal_descriptions_array = explode(",",$journal_details->descriptions);
$sum_total += $invoices[0]->patient_amount;
@endphp
<tr>
<td>{{ streamline_date($journal_details->journal_date) }}</td>
<td colspan="4">{{ $journal_descriptions_array[$index_of_patient_category] }}</td>
<td>{{ ugandan_shillings($invoices[0]->patient_amount) }}</td>
</tr>
@endif
@else
@foreach($invoices as $item)
<tr>
<td class="text-center">{{ streamline_date($item->transaction_date) }}</td>
<td class="text-center">{{ ($item->episode_id != 0) ? ((get_claim_number($item->episode_id)) ? get_claim_number($item->episode_id) : $item->receipt_number) : "" }}</td>
<td class="text-center">{{ ($item->patient_id != 0) ? get_name($item->patient_id, 'id', 'number', 'patients') : "" }}</td>
<td class="text-center">{{ ($item->patient_id != 0) ? get_full_name($item->patient_id, 'id', 'first_name', 'last_name', 'patients') : "" }}</td>
<td class="text-center">
@php
$sum_total += intval($item->sum);
echo ugandan_shillings(intval($item->sum));
@endphp
</td>
<td class="text-center">
{{ get_clinic_name($item->episode_id) }}
</td>
</tr>
@endforeach
@endif
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td class="text-center"><b>{{ __('invoices.total') }}</b></td>
<td class="text-center">{{ ugandan_shillings($sum_total) }}</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
@if ($invoice_with_payment_amount_paid > 0)
<div class="col-md-12">
<table class="table">
<tbody>
<tr>
<th style="float: right;">
<strong>Amount paid:</strong>
</th>
<td>
{{ ugandan_shillings_with_decimals($invoice_with_payment_amount_paid) }}
</td>
</tr>
<tr>
<th style="float: right;">
<strong>Balance:</strong>
</th>
<td>
{{ ugandan_shillings_with_decimals($invoice_with_payment_balance) }}
</td>
</tr>
</tbody>
</table>
</div>
@endif
<div class="col-md-12">
<p><strong>{{ __('invoices.served_by') }} : </strong></p><h3>{{ $users_name }}</h3>
<p>{{ __('invoices.sign') }}..................................................................................................................</p>
<div class="clearfix"></div>
<hr>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
function printElementContent(elem){
var mywindow = window.open('', 'PRINT', 'height=400,width=600');
var css = '<link href="elite/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">';
mywindow.document.write('<html><head><title></title>');
mywindow.document.write('</head><body >');
mywindow.document.write(css);
// mywindow.document.write('<center><h3>' + title + '</h3></center>');
mywindow.document.write(document.getElementById(elem).innerHTML);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
//mywindow.focus(); // necessary for IE >= 10*/
setTimeout(function () {
mywindow.focus();
mywindow.print();
mywindow.remove();
}, 500);
return true;
}
$("#printPatientDocButton").click(function(e){
printElementContent('printableContent');
});
</script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script>
$('#table').DataTable();
</script>
@endpush
@@ -0,0 +1,129 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/tables/css/buttons.dataTables.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">{{ __('invoices.invoices_payments') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('invoices.invoices_payments') }}</li>
</ol>
</div>
</div>
<div class="white-box">
{{ Form::open(['method'=>'post','route'=>'invoices.save_hospital_payments' ]) }}
{{ Form::hidden('is_update', $is_update) }}
<div class="row">
<div class="col-sm-6">
<div class="form-group">
{{ Form::label('supplier',__('invoices.supplier')) }}
{{ Form::text('supplier',get_name($supplier_id, 'id', 'name', 'suppliers'),['class' => 'form-control compulsory','readonly']) }}
</div>
<div class="form-group">
{{ Form::label('payment_for',__('invoices.payment_for')) }}
{{ Form::text('payment_for',get_name($quotation_type, 'id', 'name', 'quotation_types'),['class' => 'form-control compulsory', 'readonly']) }}
</div>
<div class="form-group">
{{ Form::label('generated_on',__('invoices.invoice_generated_on')) }}
{{ Form::text('generated_on',streamline_date($invoice_date),['class' => 'form-control compulsory', 'readonly']) }}
{{ Form::hidden('invoice_date', $invoice_date) }}
</div>
@if($is_update)
{{ Form::hidden('payment_id', $payment_id) }}
<div class="form-group">
{{ Form::label('amount',__('invoices.previous_balance')) }}
{{ Form::number('amount',$total_amount_to_pay,['class' => 'form-control compulsory','id'=>'amount','readonly']) }}
</div>
@else
<div class="form-group">
{{ Form::label('amount',__('invoices.amount')) }}
{{ Form::number('amount',$total_amount_to_pay,['class' => 'form-control compulsory','id'=>'amount','readonly']) }}
</div>
@endif
</div>
<div class="col-md-6">
<div class="form-group">
{{ Form::label('invoice_number',__('invoices.invoice_number')) }}
{{ Form::text('invoice_number',$invoice_number,['class' => 'form-control compulsory', 'readonly']) }}
</div>
<div class="form-group">
{{ Form::label('amount_paid',__('invoices.amount_to_deposit')) }}
{{ Form::number('amount_paid','' ,['class' => 'form-control compulsory', 'required', 'id'=>'amount_paid']) }}
</div>
<div class="form-group">
{{ Form::label('balance',__('invoices.balance')) }}
{{ Form::number('balance', '',['class' => 'form-control compulsory','readonly', 'id'=>'balance']) }}
</div>
<div class="form-group">
{{ Form::label('bank_id', __('invoices.expense_account_details')) }}
{{ Form::select('bank_id', $banks, null, ['class'=>'form-control compulsory', 'required', 'onchange' => 'check_account_balance(this.value)']) }}
</div>
</div>
</div>
<hr>
@if($is_update)
<button class="btn btn-success" id="submit_button" disabled>{{ __('invoices.update_payment') }}</button>
@else
<button class="btn btn-success" id="submit_button" disabled>{{ __('invoices.make_new_payment') }}</button>
@endif
{{ Form::close() }}
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script>
$('#amount_paid').change(function () {
let amount = $('#amount').val();
let bal = amount - this.value;
$('#balance').val(bal);
});
function check_account_balance(account_id) {
$.ajax({
method: 'POST',
url: '/payments/get_account_balance',
data: {'bank_id' : account_id},
success: function(response){
let account_balance = response[0].balance;
let amount_to_pay = parseInt($('#amount_paid').val());
if(isNaN(amount_to_pay) || amount_to_pay > account_balance){
alert('Account balance is not enough to cover payment');
$("#submit_button").attr("disabled", true);
} else {
$("#submit_button").attr("disabled", false);
}
},
error: function (error) {
//
}
});
}
</script>
@endpush
@@ -0,0 +1,134 @@
@extends('layouts.main')
@push('styles')
<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')
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">{{ __('invoices.hospital_received_items') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('invoices.hospital_received_items') }}</li>
</ol>
</div>
</div>
@include('flash::message')
<div class="white-box">
{{ Form::open(['method' => 'post', 'route'=>'invoices.generate_hospital_invoices'])}}
<div class="row">
<div class="col-md-3">
{{ Form::label('start_date',__('invoices.start_date')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'start_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="col-md-3">
{{ Form::label('end_date',__('invoices.end_date')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'end_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="col-md-2">
<br>
{{ Form::button(__('invoices.search'),['type'=>'submit','class'=>'btn btn-primary btn-rounded waves-effect waves-light m-r-10 pull-right']) }}
</div>
</div>
{{ Form::close() }}
</div>
<div class="white-box">
<div class="label label-warning"> {!! isset($display) ? $display : '' !!}</div> <br>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-striped table-hover">
<thead>
<tr>
<th>{{ __('invoices.item_type') }}</th>
<th>{{ __('invoices.quantity') }}</th>
<th>{{ __('invoices.cost') }}</th>
<th>{{ __('invoices.supplier') }}</th>
<th>{{ __('invoices.approved_by') }}</th>
<th>{{ __('invoices.received_on') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($quotations) > 0)
@foreach($quotations as $result)
<tr>
<td>
{{ $quotation_type_options[$result->quotation_type_id] }}
</td>
<td>
@php
$quotation_number = $result->quotation_number;
$results_to_count = DB::select("select drug_id from quotations where quotation_number = {$quotation_number} AND deleted_at IS NULL");
@endphp
{{ count($results_to_count) }} Items
</td>
<td>
@php
$quotation_number = $result->quotation_number;
$total_amount = DB::select("select SUM(total_price) as total from quotations where quotation_number = {$quotation_number} AND deleted_at IS NULL");
@endphp
{{ ugandan_shillings($total_amount[0]->total) }}
</td>
<td>
{{ get_name(get_name($result->quotation_number, "quotation_number", "supplier_id", 'quotations'), "id", "name", "suppliers") }}
</td>
<td>
@php
$user_id = get_name($result->quotation_number, "quotation_number", "approval_user", 'quotations');
@endphp
{{ get_full_name($user_id, "id", "first_name", "last_name", "users") }}
</td>
<td>
{{ streamline_date(get_name($result->quotation_number, "quotation_number", "receive_date", 'quotations')) }}
</td>
<td>
{{ Form::open(['method'=>'post','route'=>'invoices.generate_hospital_invoices_confirm' ]) }}
{{ Form::hidden('quotation_number', $result->quotation_number) }}
<button class="btn btn-info btn-rounded btn-sm btn-success">
<i class="fa fa-info-circle"></i>
<span style="margin-left: 10px;">{{ __('invoices.details') }}</span>
</button>
{{ Form::close() }}
</td>
</tr>
@endforeach
@else
<td colspan="7" class="text-center"><span style="color: red;">{{ __('invoices.no_records_found') }}</span></td>
@endif
</tbody>
</table>
</div>
</div>
@endsection
@push('scripts')
<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>
$('#start_date, #end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
});
</script>
@endpush
@@ -0,0 +1,92 @@
@extends('layouts.main')
@push('styles')
<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')
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">{{ __('invoices.generate_invoice') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('invoices.generate_invoice') }}</li>
</ol>
</div>
</div>
@include('flash::message')
<div class="white-box">
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-striped table-hover">
<thead>
<tr>
<th>{{ __('invoices.item_name') }}</th>
<th>{{ __('invoices.quantity') }}</th>
<th>{{ __('invoices.bill_per_item') }}</th>
<th>{{ __('invoices.cost') }}</th>
</tr>
</thead>
<tbody>
@php
$total_amount = 0;
@endphp
@foreach($quotations as $result)
<tr>
<td>
@if($result->quotation_type_id == 1)
{{ get_name($result->drug_id, 'id', 'name', 'drugs') }}
@elseif($result->quotation_type_id == 2)
{{ get_name($result->drug_id, 'id', 'name', 'sundries') }}
@elseif($result->quotation_type_id == 3)
{{ get_name($result->drug_id, 'id', 'name', 'dentals') }}
@elseif($result->quotation_type_id == 4)
{{ get_name($result->drug_id, 'id', 'name', 'radiologies') }}
@elseif($result->quotation_type_id == 5)
{{ get_name($result->drug_id, 'id', 'name', 'labs') }}
@endif
</td>
<td>
{{ $result->quantity }}
</td>
<td>
{{ ugandan_shillings($result->bill) }}
</td>
<td>
@php
$total = (int)($result->quantity * $result->bill);
$total_amount += $total;
@endphp
{{ ugandan_shillings($total) }}
</td>
</tr>
@endforeach
<tr>
<td colspan="3">{{ __('invoices.total') }}</td>
<td>{{ ugandan_shillings($total_amount) }}</td>
</tr>
</tbody>
</table>
</div>
<br>
<p><b>{{ __('invoices.approved_by') }}: </b> {{ get_full_name($quotations[0]->approval_user, 'id', 'first_name', 'last_name', 'users') }}</p>
<p><b>{{ __('invoices.received_by') }}: </b> {{ get_full_name($quotations[0]->receive_user, 'id', 'first_name', 'last_name', 'users') }}</p>
<p><b>{{ __('invoices.received_on') }}: </b> {{ streamline_date($quotations[0]->receive_date) }}</p>
<a href="{{ url('/invoices/save_hospital_invoices/' . $quotation_number) }}" class="btn btn-success">{{ __('invoices.generate_invoice') }}</a>
</div>
@endsection
@push('scripts')
<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>
@endpush
@@ -0,0 +1,121 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@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">{{ __('invoices.hospital_invoices') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('invoices.hospital_invoices') }}</li>
</ol>
</div>
</div>
<br/>
<div class="row">
<div class="panel panel-default col-md-12">
<div id="invoice" class="panel-body panel-primary">
<h2><strong>{{ __('invoices.invoice_payments_trail') }}</strong></h2>
<br/>
<br/>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('invoices.date_paid') }}</th>
<th>{{ __('invoices.staff_in_charge') }}</th>
<th>{{ __('invoices.receipt_number') }}</th>
<th>{{ __('invoices.amount_paid') }}</th>
</tr>
</thead>
@php
$sum_total = 0;
@endphp
<tbody>
@for($i = 0; $i < count($receipt_number_array); $i++)
<tr>
<td>{{ streamline_date($date_paid_array[$i]) }}</td>
<td>{{ get_full_name($staff_incharge_array[$i], 'id', 'first_name', 'last_name', 'users') }}</td>
<td>{{ $receipt_number_array[$i] }}</td>
@php
$sum_total += $amount_paid_array[$i];
@endphp
<td>{{ ugandan_shillings($amount_paid_array[$i]) }}</td>
</tr>
@endfor
</tbody>
<tr>
<td></td>
<td></td>
<td><strong>{{ __('invoices.total') }}</strong></td>
<td>
{{ ugandan_shillings($sum_total) }}
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
function showPopup() {
var myDiv = document.getElementById('invoice');
var newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write("<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
<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>
$('.table').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
</script>
@endpush
@@ -0,0 +1,125 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/typeahead.js-master/dist/typehead-min.css') }}" rel="stylesheet">
<style type="text/css">
#divToPrint{
font-size: 13px;
color: #7c7c7c;
}
#receipt_table{
font-size: 1em;
font-weight: normal;
font-family: monospace
}
#receipt_table th{
border: 1px solid #dddddd;
}
#receipt_table td{
border: 1px solid #dddddd;
}
.receipt-label{
margin-top: 10px;
padding: 10px;
}
.receipt-title{
font-weight: bolder;
text-decoration: underline;
display: block; font-family:
monospace
}
</style>
@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">{{ __('invoices.cashier_receipt') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('invoices.receipt') }}</li>
</ol>
</div>
</div>
@include('flash::message')
<div class="row">
<div class="col-md-6 offset-3">
<div class="white-box">
<div class="row" style="float:right;"><button class="btn btn-success glyphicon glyphicon-print" onclick="print_receipt()"> {{ __('invoices.print') }}</button></div>
<div class="row" id="divToPrint">
<div class="col-sm-12" style="text-align: center;">
<p style="text-align: center; font-size: 1em">
<span style="font-weight: bolder; text-decoration: underline; display: block; font-family: monospace"><b>{{ $hospital_information->name }}</b></span>
<span style="font-weight: bolder; text-decoration: underline; display: block; font-family: monospace">{{ $hospital_information->address }}</span>
<span class="receipt-label"><b>Tel:</b> {{ $hospital_information->phone_number }}</span><br>
<span class="receipt-label"><b>{{ __('invoices.email') }}:</b> {{ $hospital_information->email }}</span><br>
<span class="receipt-label"><b>{{ __('invoices.cashier') }}:</b> {{ auth()->user()->first_name }} {{ auth()->user()->last_name }}</span><br>
<span class="receipt-label"><b>{{ __('invoices.receipt_number') }}:</b> {{ $receipt_number }}</span><br>
</p>
<div>
<table class="table" id="receipt_table">
<thead>
<tr>
<th style="width: 60%; justify-content: center"><b>{{ __('invoices.description') }}</b></th>
<th style="width: 20%"><b>{{ __('invoices.amount') }}</b></th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ __('invoices.total_amount') }}:</td>
<td>{{ ugandan_shillings($total_to_pay) }}</td>
</tr>
<tr>
<td>{{ __('invoices.amount_paid') }}:</td>
<td>{{ ugandan_shillings($amount_paid) }}</td>
</tr>
<tr>
<td>{{ __('invoices.balance') }}:</td>
<td>{{ ugandan_shillings($balance) }}</td>
</tr>
<tr>
<td>{{ __('invoices.reason') }}:</td>
<td>{{ $payment_reason }}</td>
</tr>
<tr>
<td><strong>{{ __('invoices.payment_made_by') }}</strong></td>
<td><strong>{{ auth()->user()->first_name }} {{ auth()->user()->last_name }}</strong></td>
</tr>
</tbody>
</table>
</div>
</div>
<i style="font-size: 0.8em; margin-left: 50%;">&copy; Stre@mline</i>
</div>
</div>
</div>
</div>
@endsection
@push('styles')
<script type="text/javascript">
function print_receipt() {
let myDiv = document.getElementById('divToPrint');
let newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write("<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
@endpush
@@ -0,0 +1,150 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@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">{{ __('invoices.View_hospital_invoices') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('invoices.payments') }}</li>
</ol>
</div>
</div>
@include('flash::message')
<div class="white-box">
<h4><b>{{ __('invoices.new_invoices') }}</b></h4>
<hr>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('invoices.item_type') }}</th>
<th>{{ __('invoices.supplier') }}</th>
<th>{{ __('invoices.date_generated') }}</th>
<th>{{ __('invoices.amount') }}</th>
<th>{{ __('invoices.invoice_number') }}</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($quotations) > 0)
@foreach($quotations as $item)
<tr>
<td>{{ $quotation_type_options[$item->quotation_type_id] }}</td>
<td>{{ get_name($item->supplier_id, 'id', 'name', 'suppliers') }}</td>
<td>
{{ streamline_date($item->invoice_date) }}
</td>
<td>
@php
$invoice_number = $item->invoice_number;
$total_amount = DB::select("select SUM(total_price) as total from quotations where invoice_number = {$invoice_number} AND deleted_at IS NULL");
@endphp
{{ ugandan_shillings($total_amount[0]->total) }}
</td>
<td>
{{ $item->invoice_number }}
</td>
<td>
<a class="btn btn-success" href="{{ url('/invoices/complete_hospital_payments/' . $item->invoice_number) }}">{{ __('invoices.make_payment') }}</a>
</td>
<td>
<a class="btn btn-success" href="{{ url('/invoices/print_hospital_invoices/' . $item->invoice_number) }}">{{ __('invoices.print_invoice') }}</a>
</td>
<td>
<a class="btn btn-danger" href="{{ url('/invoices/delete_hospital_invoices/' . $item->invoice_number) }}">{{ __('invoices.delete_invoice') }}</a>
</td>
</tr>
@endforeach
@else
<tr>
<td class="text-center text-danger" colspan="8">{{ __('invoices.no_records_found') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
<div class="white-box">
<h4><b>{{ __('invoices.invoices_with_balance') }}</b></h4>
<hr>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('invoices.item_type') }}</th>
<th>{{ __('invoices.supplier') }}</th>
<th>{{ __('invoices.amount_to_pay') }}</th>
<th>{{ __('invoices.amount_paid') }}</th>
<th>{{ __('invoices.balance') }}</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($quotations_with_balance) > 0)
@foreach($quotations_with_balance as $item)
@php
$item_type = get_name(get_name($item->invoice_number, 'invoice_number', 'quotation_type_id', 'quotations'), 'id', 'name', 'quotation_types');
$supplier = get_name(get_name($item->invoice_number, 'invoice_number', 'supplier_id', 'quotations'), 'id', 'name', 'suppliers');
@endphp
<tr>
<td>{{ $item_type }}</td>
<td>{{ $supplier }}</td>
<td>{{ ugandan_shillings($item->total) }}</td>
<td>{{ ugandan_shillings($item->amount_paid) }}</td>
<td>{{ ugandan_shillings($item->balance) }}</td>
<td>
<a class="btn btn-success" href="{{ url('/invoices/update_hospital_invoice_payment/' . $item->id) }}">Make Payment</a>
</td>
<td>
<a class="btn btn-success" href="{{ url('/invoices/print_hospital_invoices/' . $item->invoice_number) }}">Print Invoice</a>
</td>
<td>
<a class="btn btn-success" href="{{ url('/invoices/hospital_invoices_payment_history/' . $item->id) }}">Payment History</a>
</td>
</tr>
@endforeach
@else
<tr>
<td class="text-center text-danger" colspan="8">{{ __('invoices.no_records_found') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<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>
@endpush
@@ -0,0 +1,182 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
<style>
@media print {tr.vendorListHeading {
background-color: #1a4567 !important;
-webkit-print-color-adjust: exact;
}}
@media print {.vendorListHeading th {
color: white !important;
}}
</style>
@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">{{ __('invoices.hospital_invoices') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active"><i class="fa fa-file"></i> {{ __('invoices.hospital_invoices') }}</li>
</ol>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-10 offset-1 text-right">
<button class="btn btn-primary" id="printPatientDocButton"> <span><i class="fa fa-print"></i> {{ __('invoices.print') }}</span> </button>
</div>
</div>
<br>
<div class="row">
<div id="printableContent">
<div class="col-md-12">
<div class="white-box">
<h3><b>{{ __('invoices.invoice') }}</b> <span class="pull-right">#{{ $invoice_number }}</span></h3>
<hr>
<div class="row">
<div class="col-md-12">
<div class="pull-left">
<a href="javascript:void(0)" class="text-center db">
@php $hospital_information = \Streamline\Models\HospitalInformation::first(); @endphp
<img src="{{ asset($hospital_information->logo) }}" style="max-height: 160px; margin: auto; max-width: 260px;" alt="Home" /><br/>
</a>
<address>
<h3> &nbsp;<b class="text-danger">{{ $hospital_information->name }}</b></h3>
<p class="text-muted m-l-5">{{ $hospital_information->phone_number }}, {{ $hospital_information->email }},
<br/> {{ get_name($hospital_information->sub_county,'id', 'name', 'subcounties') }}, {{ get_name($hospital_information->district,'id', 'name', 'districts') }},
<br/> {{ $hospital_information->country }}.</p>
</address>
</div>
<div class="pull-right text-right">
<address>
<h3>{{ __('invoices.from') }},</h3>
{!! supplier_address($quotations[0]->supplier_id) !!}
<p class="m-t-30"><b>{{ __('invoices.invoice_date') }} : </b> <i class="fa fa-calendar"></i> {{ streamline_date_time(\Carbon\Carbon::now()->toDateTimeString()) }}</p>
</address>
</div>
</div>
<div class="col-md-12">
<br/>
<br/>
<div class="table-responsive m-t-40">
<table class="table table-hover color-bordered-table success-bordered-table">
<thead>
<tr>
<th class="text-center">{{ __('invoices.item_name') }}</th>
<th class="text-center">{{ __('invoices.quantity') }}</th>
<th class="text-center">{{ __('invoices.bill_per_item') }}</th>
<th class="text-center">{{ __('invoices.cost') }}</th>
</tr>
</thead>
<tbody>
@php
$total_amount = 0;
@endphp
@foreach($quotations as $result)
<tr>
<td class="text-center">
@if($result->quotation_type_id == 1)
{{ get_name($result->drug_id, 'id', 'name', 'drugs') }}
@elseif($result->quotation_type_id == 2)
{{ get_name($result->drug_id, 'id', 'name', 'sundries') }}
@elseif($result->quotation_type_id == 3)
{{ get_name($result->drug_id, 'id', 'name', 'dentals') }}
@elseif($result->quotation_type_id == 4)
{{ get_name($result->drug_id, 'id', 'name', 'radiologies') }}
@elseif($result->quotation_type_id == 5)
{{ get_name($result->drug_id, 'id', 'name', 'labs') }}
@endif
</td>
<td class="text-center">
{{ $result->quantity }}
</td>
<td class="text-center">
{{ ugandan_shillings($result->bill) }}
</td>
<td class="text-center">
@php
$total = (int)($result->quantity * $result->bill);
$total_amount += $total;
@endphp
{{ ugandan_shillings($total) }}
</td>
</tr>
@endforeach
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td class="text-center"><b>{{ __('invoices.total') }}</b></td>
<td class="text-center">{{ ugandan_shillings($total_amount) }}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-md-12">
<p><strong>{{ __('invoices.received_by') }} : </strong></p><h3>{{ $served_by_name }}</h3>
<p>{{ __('invoices.sign') }}..................................................................................................................</p>
<div class="clearfix"></div>
<hr>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
function printElementContent(elem){
var mywindow = window.open('', 'PRINT', 'height=400,width=600');
var css = '<link href="elite/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">';
mywindow.document.write('<html><head><title></title>');
mywindow.document.write('</head><body >');
mywindow.document.write(css);
// mywindow.document.write('<center><h3>' + title + '</h3></center>');
mywindow.document.write(document.getElementById(elem).innerHTML);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
//mywindow.focus(); // necessary for IE >= 10*/
setTimeout(function () {
mywindow.focus();
mywindow.print();
mywindow.remove();
}, 500);
return true;
}
$("#printPatientDocButton").click(function(e){
printElementContent('printableContent');
});
</script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script>
$('#table').DataTable();
</script>
@endpush
@@ -0,0 +1,113 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@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">{{ __('invoices.View_hospital_invoices') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('invoices.payments') }}</li>
</ol>
</div>
</div>
@include('flash::message')
<div class="white-box">
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('invoices.item_type') }}</th>
<th>{{ __('invoices.supplier') }}</th>
<th>{{ __('invoices.amount_to_pay') }}</th>
<th>{{ __('invoices.amount_paid') }}</th>
<th>{{ __('invoices.balance') }}</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($payments) > 0)
@foreach($payments as $item)
@php
$item_type = get_name(get_name($item->invoice_number, 'invoice_number', 'quotation_type_id', 'quotations'), 'id', 'name', 'quotation_types');
$supplier = get_name(get_name($item->invoice_number, 'invoice_number', 'supplier_id', 'quotations'), 'id', 'name', 'suppliers');
@endphp
<tr>
<td>{{ $item_type }}</td>
<td>{{ $supplier }}</td>
<td>{{ ugandan_shillings($item->total) }}</td>
<td>{{ ugandan_shillings($item->amount_paid) }}</td>
<td>{{ ugandan_shillings($item->balance) }}</td>
<td>
<a class="btn btn-success" href="{{ url('/invoices/print_hospital_invoices/' . $item->invoice_number) }}">Print Invoice</a>
</td>
<td>
<a class="btn btn-success" href="{{ url('/invoices/hospital_invoices_payment_history/' . $item->id) }}">Payment History</a>
</td>
</tr>
@endforeach
@else
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>{{ __('invoices.no_records_found') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<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>
$('#uncleared_invoice_table').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel',
],
"aoColumnDefs": [{
"aTargets": [2,3],
"defaultContent": "",
}]
});
$('#invoices_with_balance_table').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv','excel',
],
"aoColumnDefs": [{
"aTargets": [2,3],
"defaultContent": "",
}]
});
</script>
@endpush
@@ -0,0 +1,82 @@
@extends('layouts.main')
@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">{{ __('invoices.invoices') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
</ol>
</div>
</div>
<div class="white-box">
<div class="row">
@if(is_donor_feature_enabled())
<div class="col-md-6">
@else
<div class="col-md-6">
@endif
<h3 class="box-title">{{ __('invoices.patient_category_invoices') }}</h3>
<ul class="feeds">
@if( Auth::user()->can('Invoices-generate'))
<a href="{{ route('invoices.patient_category') }}">
<li>
<div class="bg-success"><i class="fa fa-plus-circle text-white"></i></div> {{ __('invoices.generate_invoices') }} <i class="fa fa-angle-right float-right" style="padding-top: 12.5px;"></i>
</li>
</a>
@endif
@if( Auth::user()->can('Invoices-receive-payments'))
<a href="{{ route('invoices.receive_patient_invoices') }}">
<li>
<div class="bg-info"><i class="fa fa-eye text-white"></i></div> {{ __('invoices.receive_invoice_payments') }} <i class="fa fa-angle-right float-right" style="padding-top: 12.5px;"></i>
</li>
</a>
@endif
@if( Auth::user()->can('Invoices-view-payments-history'))
<a href="{{ route('invoices.patient_history') }}">
<li>
<div class="bg-warning"><i class="fa fa-pencil text-white"></i></div>{{ __('invoices.payments_history') }} <i class="fa fa-angle-right float-right" style="padding-top: 12.5px;"></i>
</li>
</a>
@endif
</ul>
</div>
@if(is_donor_feature_enabled())
<div class="col-md-6">
<h3 class="box-title">{{ __('invoices.donor_discount_invoices') }}</h3>
<ul class="feeds">
@if( Auth::user()->can('Invoices-generate'))
<a href="{{ route('invoices.donor_discounts') }}">
<li>
<div class="bg-success"><i class="fa fa-plus-circle text-white"></i></div> {{ __('invoices.generate_invoices') }} <i class="fa fa-angle-right float-right" style="padding-top: 12.5px;"></i>
</li>
</a>
@endif
@if( Auth::user()->can('Invoices-receive-payments'))
<a href="{{ route('invoices.receive_donor_invoices') }}">
<li>
<div class="bg-info"><i class="fa fa-eye text-white"></i></div> {{ __('invoices.receive_invoice_payments') }} <i class="fa fa-angle-right float-right" style="padding-top: 12.5px;"></i>
</li>
</a>
@endif
@if( Auth::user()->can('Invoices-view-payments-history'))
<a href="{{ route('invoices.donor_history') }}">
<li>
<div class="bg-warning"><i class="fa fa-pencil text-white"></i></div>{{ __('invoices.payments_history') }} <i class="fa fa-angle-right float-right" style="padding-top: 12.5px;"></i>
</li>
</a>
@endif
</ul>
</div>
@endif
</div>
</div>
@endsection
@@ -0,0 +1,265 @@
@extends('layouts.main')
@push('styles')
<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" />
<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" />
@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">{{ __('finance.patient_category_invoices') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active"><i class="fa fa-plus"></i> {{ __('finance.patient_category_invoices') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="">
<div class="panel-body">
{{ Form::open(['method'=>'post','route' => 'invoices.patient_category']) }}
<div class="col-md-3">
<div class="form-group">
<label for="patient_category">{{ __('finance.patient_category') }}</label>
<select class="form-control compulsory required" name="patient_category" id="patient_category" required>
<option value="">{{ __('finance.select') }}</option>
@foreach($patient_categories as $id)
<option value="{{ $id }}">{{ get_name($id, 'id', 'name', 'patient_categories') }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
{{ Form::label('start_date', __('finance.start_date')) }}
<div class="input-group">
{{ Form::text('start_date', '', ['class'=>'form-control compulsory', 'readonly', 'id'=>'start_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
{{ Form::label('end_date', __('finance.end_date')) }}
<div class="input-group">
{{ Form::text('end_date', '', ['class'=>'form-control compulsory', 'readonly', 'id'=>'end_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3">
{{ Form::label('search_patient', 'Search By Patient') }}
<div class="input-group">
<select class="form-control" name="patient_number" id="patient_number"></select>
</div>
</div>
<div class="col-md-2">
<div class="form-group" style="margin-top: 26px;">
{{ Form::submit(__('finance.submit'), ['class'=>'btn btn-success']) }}
</div>
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="row">
<div class="panel panel-default col-md-12">
<div class="panel-body panel-primary">
@php
$patient_category_name = get_name($request->patient_category,'id', 'name', 'patient_categories');
@endphp
{{ Form::open(['method'=>'post','route' => 'invoices.process_invoice']) }}
{{ csrf_field() }}
{{ Form::hidden('start_date', $request->start_date) }}
{{ Form::hidden('end_date', $request->end_date) }}
{{ Form::hidden('patient_category', $request->patient_category) }}
{{ Form::hidden('patient_id', $request->patient_number) }}
{{ Form::hidden('status', 'new') }}
{{ Form::hidden('invoice_number', generateInvoiceNumberFromDB($patient_category_name) ) }}
@php
$dates = $request->start_date.'/'.subtractDates($request->end_date,'1 days');
@endphp
{{ Form::hidden('invoice_date', $dates ) }}
@if($request != [])
@if($request->patient_category != null)
<h2><strong>{{ __('finance.generate_invoice_for') }}: {{ $patient_category_name }}</strong></h2>
@if(isset($request->start_date) && isset($request->end_date))
@if($total > 0)
{{ Form::button(__('finance.generate_invoice'),['type' => 'submit', 'class' => 'btn btn-success'])}}
@endif
<br/>
@if(isset($display))
<br/>
<h3 class="label label-info col-lg-5"> {!! isset($display) ? $display : '' !!}</h3>
<br/>
<br/>
@endif
<div class="table-responsive">
<table id="table" class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('finance.date') }}</th>
<th>{{ __('finance.claim_number') }}</th>
<th>{{ __('finance.patient_name') }}</th>
<th>{{ __('finance.patient_number') }}</th>
<th>{{ __('finance.subtotal') }}</th>
<th>{{ __('finance.reason') }}</th>
<th>{{ __('finance.action') }}</th>
</tr>
</thead>
@php
$sum_total = 0;
@endphp
<tbody>
@if(count($invoices_not_generated) > 0 )
@foreach($invoices_not_generated as $item)
<tr>
<td>{{ streamline_date($item->transaction_date) }}</td>
<td>{{ ($item->episode_id != 0) ? ((get_claim_number($item->episode_id)) ? get_claim_number($item->episode_id) : $item->receipt_number) : "" }}</td>
<td>{{ ($item->patient_id != 0) ? (get_full_name($item->patient_id, 'id', 'first_name', 'last_name', 'patients')) : "" }}</td>
<td>{{ ($item->patient_id != 0) ? get_patient_number($item->patient_id) : "" }}</td>
<td>
@php
$sum_total += (int)$item->sum;
echo ugandan_shillings((int)$item->sum);
@endphp
</td>
<td>
@php $is_inpatient_episode = \Streamline\Models\InpatientInfo::where('episode_id', $item->episode_id)->get()->toArray(); @endphp
{{ (empty($is_inpatient_episode) ? "OPD" : "IPD") }}
</td>
<td>
<a class="btn btn-primary btn-sm btn-rounded" target="_blank" style="color: white" href="/invoices/patient_category_invoice/detail/{{ $item->episode_id }}/{{ $request->start_date }}/{{ $request->end_date }}">{{ __('finance.details') }}</a>
</td>
</tr>
@endforeach
@endif
</tbody>
@if(count($invoices_not_generated) > 0)
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td><strong>{{ __('finance.total') }}</strong></td>
<td>
{{ ugandan_shillings($sum_total) }}
</td>
<td></td>
</tr>
@endif
</table>
</div>
@if($total > 0)
{{ Form::button(__('finance.generate_invoice'),['type' => 'submit', 'class' => 'btn btn-success'])}}
@endif
{{ Form::close() }}
@endif
@else
<h3 class="label label-info">{{ __('finance.select_patient_category') }}</h3>
@endif
@else
<h3 class="label label-info">{{ __('finance.no_data') }}</h3>
@endif
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
jQuery('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script type="text/javascript">
jQuery('#start_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<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>
$('.table').DataTable({
dom: 'Bfrtip',
bInfo: false,
bPaginate: false,
buttons: [
'copy', 'csv', 'excel',
]
});
$('#patient_number').change(function () {
let id = $('#patient_number').val();
$('#patient_id').val(id);
});
$('#patient_number').select2({
placeholder: 'Search by patient details (names and number)',
ajax: {
url: '/patients/search_patient_by_name_number',
dataType: 'json',
delay: 250,
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.first_name + " " + item.last_name + " (" + item.number + ")",
id: item.id
}
})
};
},
cache: true
}
});
</script>
@endpush
@@ -0,0 +1,172 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/tables/css/buttons.dataTables.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">{{ __('finance.invoice_payments') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="/invoices">{{ __('invoices.invoices_dashboard') }}</a></li>
<li class="active">{{ __('finance.invoice_payments') }}</li>
</ol>
</div>
</div>
<div class="container">
{{ Form::open(['method'=>'post','route'=>'invoices.process_donor_payment' ]) }}
<div class="row">
<div class="col-md-12 panel">
<div class="panel-body">
<div class="">
<h2 class="" id="debt_plan_modal_label"><strong>{{ __('invoices.receive_donor_payment') }}</strong></h2>
</div>
<br/>
<div class="">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
{{ Form::label('donor_label',__('invoices.donor')) }}
{{ Form::text('donor_id',get_name($request->donor_id, 'id', 'name', 'donors'),['class' => 'form-control compulsory required','id'=>'amount_owed', 'readonly']) }}
</div>
<div class="form-group">
{{ Form::label('generated_on',__('invoices.invoice_generated_on')) }}
<div class="input-group">
{{ Form::text('invoice_date',streamline_date($request->created_at),['class' => 'form-control compulsory required', 'required','id'=>'date_of_bill', 'readonly']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
@php
$dates = explode('/', $request->invoice_date);
$start_date = $dates[0];
$end_date = $dates[1];
@endphp
<div class="form-group">
{{ Form::label('period',__('invoices.period')) }}
{{ Form::text('period', streamline_date($start_date)." to ".streamline_date($end_date),['class' => 'form-control compulsory required', 'required','id'=>'guarantor_to_pay_modal', 'readonly']) }}
</div>
@if($request->status == "update")
<div class="form-group">
{{ Form::label('amount_label',__('invoices.previous_balance')) }}
{{ Form::number('amount',$request->balance,['class' => 'form-control compulsory required','id'=>'amount','readonly']) }}
</div>
@else
<div class="form-group">
{{ Form::label('amount_label',__('invoices.amount')) }}
{{ Form::number('amount',$request->total,['class' => 'form-control compulsory required','id'=>'amount','readonly']) }}
</div>
@endif
<div class="form-group">
{{ Form::label('amount_paid',__('invoices.amount_to_deposited')) }}
{{ Form::number('amount_paid','' ,['class' => 'form-control compulsory required', 'id'=>'amount_paid']) }}
</div>
<div class="form-group">
{{ Form::label('balance_label',__('invoices.balance')) }}
{{ Form::number('balance', '',['class' => 'form-control compulsory required','readonly', 'id'=>'balance']) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ Form::label('invoice_number_label',__('invoices.invoice_number')) }}
<div class="input-group">
{{ Form::text('invoice_number',$request->invoice_number,['class' => 'form-control compulsory required', 'required','readonly','id'=>'completion_date']) }}
</div>
</div>
<div class="form-group">
{{ Form::label('authorised_by_label',__('invoices.authorised_by')) }}
{{ Form::text('authorised_by',auth()->user()->username,['class' => 'form-control compulsory required','readonly']) }}
</div>
<div class="form-group">
{{ Form::label('payment_received_on_label', __('invoices.payment_received_on')) }}
<div class="input-group">
{{ Form::text('payment_received_on', \Carbon\Carbon::now()->toDateTimeString(), ['class'=>'form-control compulsory required','readonly', 'id'=>'payment_received_on']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel-footer">
@if($request->status == "update")
{{ Form::hidden('total', $request->total) }}
{{ Form::hidden('donor_id', $request->donor_id) }}
{{ Form::hidden('status', $request->status) }}
{{ Form::hidden('id', $request->id) }}
{{ Form::hidden('created_by', $request->created_by) }}
{{ Form::hidden('created_at', $request->created_at) }}
{{ Form::hidden('invoice_date', $request->invoice_date) }}
{{ Form::hidden('invoice_number', $request->invoice_number) }}
{{ Form::hidden('receipt_number',$request->receipt_number ) }}
{{ Form::hidden('amount_paid_history', $request->amount_paid_history) }}
{{ Form::hidden('date_paid_history', $request->date_paid_history) }}
{{ Form::hidden('staff_incharge_history', $request->staff_incharge_history) }}
<button id="update_payment" class="btn btn-success">{{ __('invoices.update_payment') }}</button>
@elseif($request->status == "new")
{{ Form::hidden('total', $request->total) }}
{{ Form::hidden('donor_id', $request->donor_id) }}
{{ Form::hidden('status', $request->status) }}
{{ Form::hidden('id', $request->id) }}
{{ Form::hidden('created_by', $request->created_by) }}
{{ Form::hidden('created_at', $request->created_at) }}
{{ Form::hidden('invoice_date', $request->invoice_date) }}
{{ Form::hidden('invoice_number', $request->invoice_number) }}
{{ Form::hidden('receipt_number',$request->receipt_number ) }}
<button id="update_payment" class="btn btn-success">{{ __('invoices.make_new_payment') }}</button>
@endif
</div>
</div>
</div>
{{ Form::close() }}
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script>
$('#amount_paid').change(function () {
let amount = $('#amount').val();
let bal = amount - this.value;
$('#balance').val(bal);
});
</script>
{{--<script type="text/javascript">--}}
{{--jQuery('#payment_received_on').datepicker({--}}
{{--autoclose: true,--}}
{{--todayHighlight: true,--}}
{{--format: 'yyyy/mm/dd'--}}
{{--});--}}
{{--</script>--}}
{{--<script type="text/javascript">--}}
{{--jQuery('#start_date').datepicker({--}}
{{--autoclose: true,--}}
{{--todayHighlight: true,--}}
{{--format: 'yyyy/mm/dd'--}}
{{--});--}}
{{--</script>--}}
@endpush
@@ -0,0 +1,353 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/tables/css/buttons.dataTables.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">{{ __('finance.invoice_payments') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('finance.invoice_payments') }}</li>
</ol>
</div>
</div>
<div class="container">
@include('flash::message')
{{ Form::open(['method'=>'post','route'=>'invoices.process_patient_payment' ]) }}
<div class="row">
<div class="col-md-12 panel">
<div class="panel-body">
<div class="">
<h2 class="" id="debt_plan_modal_label"><strong>{{ __('finance.receive_invoice_payments') }}</strong></h2>
</div>
<br />
<div class="row">
<div class="col-sm-6">
<div class="form-group">
{{ Form::label('patient_category_label', __('finance.patient_category')) }}
{{ Form::text('patient_category',get_name($patient_category, 'id', 'name', 'patient_categories'),['class' => 'form-control compulsory required','id'=>'amount_owed', 'readonly']) }}
</div>
<div class="form-group">
{{ Form::label('payment_received_on_label', __('finance.payment_received_on')) }}
<div class="input-group">
{{ Form::text('payment_received_on', \Carbon\Carbon::today()->format('d-m-Y'), ['class'=>'form-control','required','autocomplete'=>'off', 'id'=>'payment_received_on']) }}
</div>
</div>
@if($status == "update")
<div class="form-group">
{{ Form::label('amount_label',__('finance.previous_balance')) }}
{{ Form::number('amount',$balance,['class' => 'form-control', 'required','id'=>'amount','readonly']) }}
</div>
@else
<div class="form-group">
{{ Form::label('amount_label',__('finance.amount')) }}
{{ Form::number('amount',$total,['class' => 'form-control','required','id'=>'amount','readonly']) }}
</div>
@endif
<div class="form-group">
{{ Form::label('amount_paid',__('finance.amount_paid')) }}
{{ Form::number('amount_paid', 0 ,['class' => 'form-control compulsory', 'required','id'=>'amount_paid']) }}
</div>
<div class="form-group">
{{ Form::label('balance_label',__('finance.balance')) }}
{{ Form::number('balance', $balance,['class' => 'form-control', 'required','readonly', 'id'=>'balance']) }}
{{ Form::hidden('original_balance', $balance, ['id'=>'original_balance']) }}
</div>
<div class="form-group">
{{ Form::label('generated_on', __('finance.generated_on')) }}
{{ Form::text('generated_on',streamline_date($generated_on),['class' => 'form-control', 'required','id'=>'date_of_bill', 'readonly']) }}
{{ Form::hidden('invoice_date',$invoice_date) }}
</div>
@php
$dates = explode('/', $invoice_date);
$start_date = $dates[0] ?? date('Y-m-d');
$end_date = $dates[1] ?? date('Y-m-d');
$back_date = \Streamline\Models\HospitalInformation::first()->pluck('back_date');
@endphp
<div class="form-group">
{{ Form::label('period',__('finance.for_period')) }}
{{ Form::text('period', streamline_date($start_date)." to ".streamline_date($end_date),['class' => 'form-control', 'required','id'=>'guarantor_to_pay_modal', 'readonly']) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ Form::label('invoice_number_label',__('finance.invoice_number')) }}
<div class="input-group">
{{ Form::text('invoice_number',$invoice_number,['class' => 'form-control compulsory required', 'required','readonly','id'=>'completion_date']) }}
</div>
</div>
<div class="form-group">
{{ Form::label('authorised_by_label', __('finance.authorised_by')) }}
{{ Form::text('authorised_by',auth()->user()->first_name . ' ' . auth()->user()->last_name,['class' => 'form-control compulsory','required','readonly']) }}
</div>
<div id="payment_methods_div">
<div class="form-group">
{{ Form::label('cash_to_pay',__('patient_finance.cash_to_pay')) }}
{{ Form::number('cash_to_pay',0,['class' => 'form-control','id'=>'cash_to_pay','readonly']) }}
</div>
<label class="label label-primary" onclick="add_payment_method();">{{ __('patient_finance.add_payment_method') }}</label>
<br><br>
</div>
<div class="form-group">
<label>{{ __('invoices.do_you_want_receive_bank') }}</label>
<br>
{{ Form::radio('receive_to_bank', 1, false, ['onclick' => 'show_banking_details(1)']) }} Yes &nbsp;&nbsp;
{{ Form::radio('receive_to_bank', 0, true, ['onclick' => 'show_banking_details(0)']) }} No
</div>
<div id="banking_div" style="display: none;">
<div class="form-group">
{{ Form::label('bank', __('invoices.bank')) }}
{{ Form::select('bank', $banks, '', ['class'=>'form-control', 'id'=>'bank']) }}
</div>
<div class="form-group">
{{ Form::label('bank_balance', __('invoices.bank_balance')) }}
<div class="input-group">
{{ Form::text('bank_balance', '', ['class'=>'form-control','readonly', 'id'=>'bank_balance']) }}
{{ Form::hidden('undeposited_funds_bank_balance', '', ['id'=>'undeposited_funds_bank_balance']) }}
</div>
</div>
<div class="form-group">
{{ Form::label('memo',__('invoices.memo')) }}
{{ Form::textarea('memo', '',['class' => 'form-control compulsory']) }}
</div>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-6">
@if($balance > 0 || is_null($balance))
<button class="btn btn-danger" id="write_off_btn">{{ __('invoices.write_off_balance') }}</button>
@endif
</div>
<div class="col-md-6">
{{ Form::hidden('total', $total, ['id' => 'total']) }}
{{ Form::hidden('status', $status, ['id' => 'status']) }}
{{ Form::hidden('patient_category', $patient_category, ['id' => 'patient_category']) }}
{{ Form::hidden('invoice_date', $invoice_date, ['id' => 'invoice_date']) }}
{{ Form::hidden('invoice_number', $invoice_number, ['id' => 'invoice_number']) }}
<button id="update_payment" class="btn btn-success pull-right" onclick="return confirm('{{ __('finance.are_you_sure') }}')">{{ __('finance.receive_payment') }}</button>
</div>
</div>
</div>
</div>
</div>
{{ Form::close() }}
<div class="modal" id="write_off_invoice_balance_modal" tabindex="-1" role="dialog" aria-labelledby="write_off_invoice_balance_modal_label" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header text-center">
<h5 class="modal-title" id="write_off_invoice_balance_modal_label"><b>{{ __('invoices.write_off_invoice_balance') }}</b></h5>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>{{ __('invoices.amount_to_be_written_off') }}</label>
<input id="amount_to_write_off" type="number" class="form-control">
</div>
<div class="form-group">
<label>{{ __('invoices.write_off_memo') }}</label>
<textarea id="write_off_memo" type="number" rows="5" class="form-control"></textarea>
</div>
<div class="form-group">
<label>{{ __('invoices.expense_account') }}</label>
{{ Form::select('expense_account', $expense_accounts, '', ['class'=>'form-control', 'id'=>'expense_account']) }}
</div>
<button class="btn btn-rounded btn-block btn-success" id="finish_write_off">{{ __('invoices.finish') }}</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script>
function add_payment_method() {
$('#cash_to_pay_div').show();
$('#payment_methods_div').append('<div class="row"><div class="col-md-6"><label>Payment Method</label><select class="form-control payment_method" name="payment_method[]"><option value="0">--select method--</option><?php echo $patient_payment_methods_options ?></select></div><div class="col-md-6"><label>Payment Amount</label><input name="payment_methods_amount[]" type="number" class="form-control payment_methods_amount" onkeyup="payment_methods_amount_calculate()"></div></div><br>');
}
function show_banking_details(choice) {
if (choice === 1) {
$('#banking_div').show();
} else {
$('#banking_div').hide();
}
}
$('#amount_to_write_off').on('change keyup', function(e) {
e.preventDefault();
let original_balance = $('#original_balance').val();
let write_off_amount = $('#amount_to_write_off').val();
let balance = original_balance - write_off_amount;
$('#balance').val(balance);
});
$('#amount_paid').change(function() {
$('.payment_methods_amount').each(function () {
$(this).val(0);
});
$('#cash_to_pay').val(this.value);
let amount = $('#amount').val();
let bal = amount - this.value;
$('#balance').val(bal);
if (bal > 0) {
$('#write_off_btn').show();
}
});
function payment_methods_amount_calculate() {
// tally up all the entered values
let total_amount_payment_methods = 0;
$('.payment_methods_amount').each(function () {
total_amount_payment_methods += +$(this).val();
});
let amount_to_pay = $('#amount_paid').val();
let cash_to_pay = amount_to_pay;
cash_to_pay -= total_amount_payment_methods;
if (cash_to_pay < 0) {
alert("You have entered more money in the payment methods than is supposed to be paid");
$('.payment_methods_amount').each(function () {
$(this).val(0);
});
$('#cash_to_pay').val(amount_to_pay);
} else {
$('#cash_to_pay').val(cash_to_pay);
}
}
$('#write_off_btn').click(function(e) {
e.preventDefault();
var balance = $('#balance').val();
$('#amount_to_write_off').val(balance);
$('#write_off_invoice_balance_modal').modal('show');
});
$('#finish_write_off').click(function() {
let amount = $('#amount_to_write_off').val();
let expense_account = $('#expense_account').val();
let write_off_memo = $('#write_off_memo').val();
let status = $('#status').val();
let invoice_number = $('#invoice_number').val();
let total = $('#total').val();
let invoice_date = $('#invoice_date').val();
let patient_category = $('#patient_category').val();
let write_off_date = $('#payment_received_on').val();
if (amount === '') {
alert('Please Enter An Amount To Write Off.')
} else if (expense_account === '') {
alert('Please Select An Expense Account To Write Off To.')
} else if (write_off_memo === '') {
alert('Please Enter A Memo For This Write Off.')
} else {
$.ajax({
method: 'post',
url: '/invoices/write_off_invoice_balance',
data: {
'amount': amount, 'status': status, 'invoice_number': invoice_number, 'total': total, 'patient_category': patient_category,
'expense_account': expense_account, 'write_off_memo': write_off_memo, 'invoice_date': invoice_date, 'write_off_date': write_off_date
},
success: function(response) {
if (response === 'success') {
alert("Write off has been completed successfully");
window.location.href = '/invoices/receive_patient_invoices';
}
}
});
}
});
$('#bank').on('change', function() {
var transfer_to = $('#bank').val();
var transfer_from = '10';
var transfer_date = $('#payment_received_on').val();
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); // January is 0!
var yyyy = today.getFullYear();
var today_formatted = dd + '-' + mm + '-' + yyyy;
$.ajax({
method: 'POST',
url: '/banking/get_latest_bank_balance',
data: {
'to': transfer_to,
'from': transfer_from,
'date': today_formatted, // transfer_date,
},
success: function(response) {
$('#bank_balance').val(parseInt(response[0]));
$('#undeposited_funds_bank_balance').val(parseInt(response[1]));
},
error: function(error) {
console.log(error);
}
});
});
let min_days = <?php echo $back_date[0]; ?>;
var min_date = new Date();
min_date.setDate(min_date.getDate()-min_days);
$('#payment_received_on').datepicker({
autoclose: true,
todayHighlight: true,
endDate: new Date(),
startDate: min_date,
format: 'dd-mm-yyyy'
});
</script>
@endpush
@@ -0,0 +1,129 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@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">{{ __('invoices.donor_discount_invoices') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="/invoices">{{ __('invoices.invoices_dashboard') }}</a></li>
<li class="active">{{ __('invoices.payments_history') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="panel panel-default col-md-10 offset-1">
<div id="invoice" class="panel-body panel-primary">
<h2><strong>{{ __('invoices.invoice_payments_trail') }}</strong></h2>
<br/>
<br/>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('invoices.donor_name') }}</th>
<th>{{ __('invoices.payment_date') }}</th>
<th>{{ __('invoices.period') }}</th>
<th>{{ __('invoices.amount_to_pay') }}</th>
<th>{{ __('invoices.balance') }}</th>
<th>{{ __('invoices.invoice_number') }}</th>
<th colspan="2"></th>
</tr>
</thead>
@php
$sum_total = 0;
@endphp
<tbody>
@foreach($payments as $item)
<tr>
<td>{{ get_name($item->donor_id, 'id', 'name', 'donors') }}</td>
<td>{{ streamline_date_time($item->created_at) }}</td>
<td>
@php
$sum_total += $item->total;
$dates = explode('/', $item->invoice_date);
echo streamline_date($dates[0]). "to" .streamline_date($dates[0]);
@endphp
</td>
<td>{{ ugandan_shillings($item->total) }}</td>
<td>{{ ugandan_shillings($item->balance) }}</td>
<td>{{ $item->invoice_number }}</td>
<td>
{{ Form::open(['method'=>'post','route'=>'invoices.generate_donor_invoice' ]) }}
{{ Form::hidden('invoice_number', $item->invoice_number) }}
{{ Form::hidden('invoice_date', $item->invoice_date) }}
{{ Form::hidden('status', 'reprint') }}
<button id="update_payment" class="btn btn-success">{{ __('invoices.print_invoice') }}</button>
{{ Form::close() }}
</td>
<td>
{{ Form::open(['method'=>'post', 'route'=>'invoices.donor_payments_history' ]) }}
{{ Form::hidden('id', $item->id) }}
<button id="update_payment" class="btn btn-success">{{ __('invoices.payment_history') }}</button>
{{ Form::close() }}
</td>
</tr>
@endforeach
<tr>
<td></td>
<td></td>
<td><strong>@php echo "Total"; @endphp</strong></td>
<td>
{{ ugandan_shillings($sum_total) }}
</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
function showPopup() {
var myDiv = document.getElementById('invoice');
var newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write("<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script>
$('#table').DataTable();
</script>
@endpush
@@ -0,0 +1,129 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@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">{{ __('invoices.donor_discount_invoices') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="/invoices">{{ __('invoices.invoices_dashboard') }}</a></li>
<li class="active">{{ __('invoices.details') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="panel panel-default col-md-10 offset-1">
<div id="invoice" class="panel-body panel-primary">
<h2><strong>{{ __('invoices.invoice_payments_trail') }}</strong></h2>
<br/>
<br/>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('invoices.date') }}</th>
<th>{{ __('invoices.paid_by') }}</th>
<th>{{ __('invoices.staff_in_charge') }}</th>
<th>{{ __('invoices.receipts') }}</th>
<th>{{ __('invoices.amount') }}</th>
</tr>
</thead>
@php
$sum_total = 0;
@endphp
<tbody>
@foreach($payments as $item)
@php
$dates = unserialize($item->date_paid_history);
$staff = unserialize($item->staff_incharge_history);
$receipts = unserialize($item->receipt_number);
$amounts = unserialize($item->amount_paid_history);
for($i = 0; $i< count($dates); $i++){
$sum_total += $amounts[$i];
echo "<tr>";
echo "<td>".streamline_date_time($dates[$i])."</td>";
echo "<td>".get_name($item->donor_id, 'id', 'name', 'donors')."</td>";
echo "<td>".get_full_name($staff[$i], 'id', 'first_name', 'last_name', 'users')."</td>";
echo "<td>".$receipts[$i]."</td>";
echo "<td>".ugandan_shillings($amounts[$i])."</td>";
echo "</tr>";
}
@endphp
@endforeach
</tbody>
<tr>
<td></td>
<td></td>
<td><strong>@php echo "Total"; @endphp</strong></td>
<td></td>
<td>
{{ ugandan_shillings($sum_total) }}
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
function showPopup() {
var myDiv = document.getElementById('invoice');
var newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write("<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
<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>
$('.table').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
</script>
@endpush
@@ -0,0 +1,132 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@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">{{ __('invoices.patient_category_invoices') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('invoices.payments_history') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="panel panel-default col-md-12">
<div id="invoice" class="panel-body panel-primary">
<h2><strong>{{ __('invoices.invoice_payments_trail') }}</strong></h2>
<br/>
<br/>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('invoices.patient_category') }}</th>
<th>{{ __('invoices.payment_date') }}</th>
<th>{{ __('invoices.period') }}</th>
<th>{{ __('invoices.amount_to_pay') }}</th>
<th>{{ __('invoices.balance') }}</th>
<th>{{ __('invoices.invoice_number') }}</th>
<th colspan="2"></th>
</tr>
</thead>
@php
$sum_total = 0;
@endphp
<tbody>
@foreach($payments as $item)
<tr>
<td>{{ get_name($item->patient_category, 'id', 'name', 'patient_categories') }}</td>
<td>{{ streamline_date_time($item->created_at) }}</td>
<td>
@php
$sum_total += $item->total;
$dates = explode('/', $item->invoice_date);
echo streamline_date($dates[0]). "to" .streamline_date($dates[0]);
@endphp
</td>
<td>{{ ugandan_shillings($item->total) }}</td>
<td>{{ ugandan_shillings($item->balance) }}</td>
<td>{{ $item->invoice_number }}</td>
<td>
{{ Form::open(['method'=>'post','route'=>'invoices.generate_invoice' ]) }}
{{ Form::hidden('invoice_number', $item->invoice_number) }}
{{ Form::hidden('invoice_date', $item->invoice_date) }}
{{ Form::hidden('patient_category', $item->patient_category) }}
{{ Form::hidden('status', 'reprint') }}
<button id="update_payment" class="btn btn-success">{{ __('invoices.print_invoice') }}</button>
{{ Form::close() }}
</td>
<td>
{{ Form::open(['method'=>'post', 'route'=>'invoices.patient_payments_history' ]) }}
{{ Form::hidden('invoice_number', $item->invoice_number) }}
<button class="btn btn-success">{{ __('invoices.payment_history') }}</button>
{{ Form::close() }}
</td>
</tr>
@endforeach
<tr>
<td></td>
<td></td>
<td><strong>@php echo "Total"; @endphp</strong></td>
<td>
{{ ugandan_shillings($sum_total) }}
</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
function showPopup() {
var myDiv = document.getElementById('invoice');
var newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write("<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script>
$('#table').DataTable();
</script>
@endpush
@@ -0,0 +1,124 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@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">{{ __('invoices.patient_category_invoices') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('invoices.details') }}</li>
</ol>
</div>
</div>
<br/>
<div class="row">
<div class="panel panel-default col-md-12">
<div id="invoice" class="panel-body panel-primary">
<h2><strong>{{ __('invoices.invoice_payments_trail') }}</strong></h2>
<br/>
<br/>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('invoices.date') }}</th>
<th>{{ __('invoices.paid_by') }}</th>
<th>{{ __('invoices.staff_in_charge') }}</th>
<th>{{ __('invoices.receipts') }}</th>
<th>{{ __('invoices.amount') }}</th>
</tr>
</thead>
@php
$sum_total = 0;
@endphp
<tbody>
@foreach($payments as $item)
<tr>
<td>{{ streamline_date($item->date_paid) }}</td>
<td>{{ $patient_category }}</td>
<td>{{ get_full_name($item->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>{{ $item->receipt_number }}</td>
<td>{{ ugandan_shillings($item->amount_paid) }}</td>
</tr>
@php
$sum_total += $item->amount_paid;
@endphp
@endforeach
</tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td><strong>@php echo "Total"; @endphp</strong></td>
<td>
{{ ugandan_shillings($sum_total) }}
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
function showPopup() {
var myDiv = document.getElementById('invoice');
var newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write("<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
<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>
$('.table').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
</script>
@endpush
@@ -0,0 +1,153 @@
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" type="image/png" sizes="16x16" href="{{ asset('uploads/streamline/color/streamline_icon-02.png') }}">
<title>{{ config('app.name', 'Patient Category Invoices - Stre@mline') }}</title>
<!-- Bootstrap Core CSS -->
<link href="{{ asset('bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
<style>
body{
/*font-size: 1.2em;*/
}
/*thead, tfoot { display: table-row-group }*/
thead {
display: table-header-group;
}
tfoot {
display: table-row-group;
}
tr {
page-break-inside: avoid;
}
</style>
</head>
<body>
<div class="container-fluid">
@include('layouts.header_pdf_print')
<h5 class="heading" style="text-align: center;">
<strong>Invoice Number: #{{ $invoice_number }}</strong><br><br>
<strong>{{ __('finance.invoice_for') }} {{ get_name($patient_category, 'id', 'name', 'patient_categories') }} {{ individual_of_invoice($invoice_number) ?? "" }}</strong>
</h5>
<table class="table table-light table-sm table-borderless">
<thead class="thead-light">
@if ((count($invoices)==1) && ($invoices[0]->patient_id==0) && ($invoices[0]->episode_id==0))
<tr>
<th>{{ __('invoices.date') }}</th>
<th colspan="4">{{ __('invoices.description') }}</th>
<th>{{ __('invoices.amount') }}</th>
</tr>
@else
<tr>
<th>{{ __('invoices.date') }}</th>
<th>{{ __('invoices.patient_number') }}</th>
<th>{{ __('invoices.claim_number') }}</th>
<th>{{ __('invoices.patient_name') }}</th>
<th>{{ __('invoices.amount') }}</th>
<th>{{ __('invoices.reason') }}</th>
</tr>
@endif
@php
$sum_total = 0;
@endphp
</thead>
<tbody>
<tr>
<td colspan="5"></td>
</tr>
@if ((count($invoices)==1) && ($invoices[0]->patient_id==0) && ($invoices[0]->episode_id==0))
{{-- this is more likely a journal so fetch journal details --}}
@php
$journal_number = substr($invoices[0]->items_ids, 10); //now remove the substring "Journal - "
$patient_category_id = $invoices[0]->patient_category;
$journal_details = \Streamline\Models\Journal::where('journal_number', $journal_number)->first();
@endphp
@if ($journal_details)
@php
$journal_name_ids_array = explode(",",$journal_details->name_ids);
$index_of_patient_category = array_search($patient_category_id, $journal_name_ids_array);
$journal_descriptions_array = explode(",",$journal_details->descriptions);
$sum_total += $invoices[0]->patient_amount;
@endphp
<tr>
<td class="text-center">{{ streamline_date($journal_details->journal_date) }}</td>
<td colspan="4">{{ $journal_descriptions_array[$index_of_patient_category] }}</td>
<td>{{ ugandan_shillings($invoices[0]->patient_amount) }}</td>
</tr>
@endif
@else
@foreach($invoices as $item)
<tr>
<td>{{ streamline_date($item->transaction_date) }}</td>
<td>{{ get_name($item->patient_id, 'id', 'number', 'patients') }}</td>
<td>{{ ($item->episode_id != 0) ? ((get_claim_number($item->episode_id)) ? get_claim_number($item->episode_id) : $item->receipt_number) : "" }}</td>
<td>{{ get_full_name($item->patient_id, 'id', 'first_name', 'last_name', 'patients') }}</td>
<td>
@php
$sum_total += intval($item->sum);
echo ugandan_shillings(intval($item->sum));
@endphp
</td>
<td>
{{ get_clinic_name($item->episode_id) }}
</td>
</tr>
@endforeach
@endif
</tbody>
<tfoot>
<tr>
<th></th>
<th></th>
<th><b>{{ __('invoices.total') }}</b></th>
<th>{{ ugandan_shillings($sum_total) }}</th>
<th></th>
</tr>
</tfoot>
</table>
@if ($invoice_with_payment_amount_paid > 0)
<br>
<div class="col-12">
<table class="table">
<tbody>
<tr>
<th>
<strong>Amount paid:</strong>
</th>
<td>
{{ ugandan_shillings_with_decimals($invoice_with_payment_amount_paid) }}
</td>
</tr>
<tr>
<th>
<strong>Balance:</strong>
</th>
<td>
{{ ugandan_shillings_with_decimals($invoice_with_payment_balance) }}
</td>
</tr>
</tbody>
</table>
</div>
@endif
<br>
<span><p><strong>{{ __('invoices.served_by') }} : {{ $served_by }}</strong></p></span>
<p><strong>{{ __('invoices.sign') }}</strong>..................................................................................................................</p>
<div class="clearfix"></div>
<hr>
</div>
</body>
</html>
@@ -0,0 +1,125 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/typeahead.js-master/dist/typehead-min.css') }}" rel="stylesheet">
<style type="text/css">
#divToPrint{
font-size: 13px;
color: #7c7c7c;
}
#receipt_table{
font-size: 1em;
font-weight: normal;
font-family: monospace
}
#receipt_table th{
border: 1px solid #dddddd;
}
#receipt_table td{
border: 1px solid #dddddd;
}
.receipt-label{
margin-top: 10px;
padding: 10px;
}
.receipt-title{
font-weight: bolder;
text-decoration: underline;
display: block; font-family:
monospace
}
</style>
@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">{{ __('invoices.cashier_receipt') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('invoices') }}">{{ __('invoices.invoices') }}</a></li>
<li><a href="{{ route('invoices.receive_donor_invoices') }}">{{ __('invoices.receive_donor_invoice') }}</a></li>
<li class="active">{{ __('invoices.receipt') }}</li>
</ol>
</div>
</div>
@include('flash::message')
<div class="row">
<div class="col-md-6 offset-3">
<div class="white-box">
<div class="row" style="float:right;"><button class="btn btn-success glyphicon glyphicon-print" onclick="print_receipt()"> {{ __('invoices.print') }}</button></div>
<div class="row" id="divToPrint">
<div class="col-sm-12" style="text-align: center;">
<p style="text-align: center; font-size: 1em">
<span style="font-weight: bolder; text-decoration: underline; display: block; font-family: monospace"><b>{{ $hospital_information->name }}</b></span>
<span style="font-weight: bolder; text-decoration: underline; display: block; font-family: monospace">{{ $hospital_information->address }}</span>
<span class="receipt-label"><b>Tel:</b> {{ $hospital_information->phone_number }}</span><br>
<span class="receipt-label"><b>{{ __('invoices.email') }}:</b> {{ $hospital_information->email }}</span><br>
<span class="receipt-label"><b>{{ __('invoices.cashier') }}:</b> {{ auth()->user()->first_name }} {{ auth()->user()->last_name }}</span><br>
<span class="receipt-label"><b>{{ __('invoices.receipt_number') }}:</b> {{ $request->receipt_number }}</span><br>
</p>
<div>
<table class="table" id="receipt_table">
<thead>
<tr>
<th style="width: 60%; justify-content: center"><b>{{ __('invoices.description') }}</b></th>
<th style="width: 20%"><b>{{ __('invoices.amount') }}</b></th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ __('invoices.total_amount') }}:</td>
<td>{{ ugandan_shillings($request->total) }}</td>
</tr>
<tr>
<td>{{ __('invoices.amount_paid') }}:</td>
<td>{{ ugandan_shillings($request->amount_paid) }}</td>
</tr>
<tr>
<td>{{ __('invoices.balance') }}:</td>
<td>{{ ugandan_shillings($request->balance) }}</td>
</tr>
<tr>
<td>{{ __('invoices.reason') }}:</td>
<td>{{ __('invoices.payment_by') }} {{ get_name($request->donor_id, 'id', 'name', 'donors') }}</td>
</tr>
<tr>
<td><strong>{{ __('invoices.received_by') }}</strong></td>
<td><strong>{{ get_full_name($request->created_by, 'id', 'first_name', 'last_name', 'users') }}</strong></td>
</tr>
</tbody>
</table>
</div>
</div>
<i style="font-size: 0.8em; margin-left: 50%;">&copy; Stre@mline</i>
</div>
</div>
</div>
</div>
@endsection
@push('styles')
<script type="text/javascript">
function print_receipt() {
let myDiv = document.getElementById('divToPrint');
let newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write("<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
@endpush
@@ -0,0 +1,126 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/typeahead.js-master/dist/typehead-min.css') }}" rel="stylesheet">
<style type="text/css">
#divToPrint{
font-size: 13px;
color: #7c7c7c;
}
#receipt_table{
font-size: 1em;
font-weight: normal;
font-family: monospace
}
#receipt_table th{
border: 1px solid #dddddd;
}
#receipt_table td{
border: 1px solid #dddddd;
}
.receipt-label{
margin-top: 10px;
padding: 10px;
}
.receipt-title{
font-weight: bolder;
text-decoration: underline;
display: block; font-family:
monospace
}
</style>
@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">{{ __('invoices.cashier_receipt') }}</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> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li><a href="{{ route('invoices.receive_patient_invoices') }}">{{ __('invoices.receive_patient_category_invoice') }}</a></li>
<li class="active">{{ __('invoices.receipts') }}</li>
</ol>
</div>
</div>
@include('flash::message')
<div class="row">
<div class="col-md-6 offset-3">
<div class="white-box">
<div class="row" style="float:right;"><button class="btn btn-success glyphicon glyphicon-print" onclick="print_receipt()"> {{ __('invoices.print') }}</button></div>
<div class="row" id="divToPrint">
<div class="col-sm-12" style="text-align: center;">
<p style="text-align: center; font-size: 1em">
<span style="font-weight: bolder; text-decoration: underline; display: block; font-family: monospace"><b>{{ $hospital_information->name }}</b></span>
<span style="font-weight: bolder; text-decoration: underline; display: block; font-family: monospace">{{ $hospital_information->address }}</span>
<span class="receipt-label"><b>Tel:</b> {{ $hospital_information->phone_number }}</span><br>
<span class="receipt-label"><b>{{ __('invoices.email') }}:</b> {{ $hospital_information->email }}</span><br>
<span class="receipt-label"><b>{{ __('invoices.cashier') }}:</b> {{ auth()->user()->first_name }} {{ auth()->user()->last_name }}</span><br>
<span class="receipt-label"><b>{{ __('invoices.receipt_number') }}:</b> {{ $request->receipt_number }}</span><br>
</p>
<div>
<table class="table" id="receipt_table">
<thead>
<tr>
<th style="width: 60%; justify-content: center"><b>{{ __('invoices.description') }}</b></th>
<th style="width: 20%"><b>{{ __('invoices.amount') }}</b></th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ __('invoices.total_amount') }}:</td>
<td>{{ ugandan_shillings($request->total) }}</td>
</tr>
<tr>
<td>{{ __('invoices.amount_paid') }}:</td>
<td>{{ ugandan_shillings($request->amount_paid) }}</td>
</tr>
<tr>
<td>{{ __('invoices.balance') }}:</td>
<td>{{ ugandan_shillings($request->balance) }}</td>
</tr>
<tr>
<td>{{ __('invoices.reason') }}:</td>
<td>{{ __('invoices.payment_for') }} {{ get_name($request->patient_category, 'id', 'name', 'patient_categories') }} {{ __('invoices.bills') }}</td>
</tr>
<tr>
<td><strong>{{ __('invoices.received_by') }}</strong></td>
<td><strong>{{ auth()->user()->first_name }} {{ auth()->user()->last_name }}</strong></td>
</tr>
</tbody>
</table>
</div>
</div>
<i style="font-size: 0.8em; margin-left: 50%;">&copy; Stre@mline</i>
</div>
</div>
</div>
</div>
@endsection
@push('styles')
<script type="text/javascript">
function print_receipt() {
let myDiv = document.getElementById('divToPrint');
let newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write("<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
@endpush
@@ -0,0 +1,309 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/tables/css/buttons.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
@php
$patient_id = "";
$episode_id = "";
$patient_category = "";
$items_amounts = "";
$items_ids = "";
$patient_amount = "";
$receipt_number = "";
$tag_id = "";
$invoice_generated ="";
$start_date = "";
$total = 0;
$end_date = "";
$invoice_date = "";
$invoice_number = "";
$created_by = "";
$created_at = "";
$reason ="";
$donor_id = "";
@endphp
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">{{ __('invoices.view_donor_invoices') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="/invoices">{{ __('invoices.invoices_dashboard') }}</a></li>
<li class="active">{{ __('invoices.payments') }}</li>
</ol>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="panel panel-default col-md-10 offset-1">
<div class="panel-heading">
<div class="panel-title">
<h3><strong>{{ __('invoices.donor_invoices') }}</strong></h3>
</div>
</div>
<div class="panel-body panel-primary">
<div class="table-responsive">
<table id="table" class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('invoices.donor') }}</th>
<th>{{ __('invoices.date_generated') }}</th>
<th>{{ __('invoices.for_period') }}</th>
<th>{{ __('invoices.amount') }}</th>
<th>{{ __('invoices.invoice_number') }}</th>
<th colspan="2"></th>
</tr>
</thead>
<tbody>
@if(count($uncleared_invoices) > 0)
@foreach($uncleared_invoices as $item)
@php
$sum_total = 0;
$total = 0;
@endphp
<tr>
<td>{{ get_name($item->donor_id, 'id', 'name', 'donors') }}</td>
<td>{{ streamline_date($item->created_at) }}</td>
<td>
@php
$dates = explode('/',$item->invoice_date);
@endphp
{{ streamline_date($dates[0])." to ".streamline_date($dates[1]) }}
</td>
<td>
{{ ugandan_shillings($item->sum) }}
</td>
<td>
{{ $item->invoice_number }}
</td>
<td>
{{ Form::open(['method'=>'post','route'=>'invoices.donor_invoice_payment' ]) }}
{{ Form::hidden('id', $item->id) }}
{{ Form::hidden('donor_id', $item->donor_id) }}
{{ Form::hidden('created_by', $item->created_by) }}
{{ Form::hidden('created_at', $item->created_at) }}
{{ Form::hidden('status', 'new') }}
{{ Form::hidden('total', $item->sum) }}
{{ Form::hidden('invoice_date', $item->invoice_date) }}
{{ Form::hidden('invoice_number', $item->invoice_number) }}
{{ Form::hidden('receipt_number',$item->receipt_number ) }}
<button id="update_payment" class="btn btn-success">{{ __('invoices.receive_payment') }}</button>
{{ Form::close() }}
</td>
<td>
<button id="print_invoice" class="btn btn-success">{{ __('invoices.print_invoice') }}</button>
</td>
</tr>
@php
$donor_id = $item->donor_id;
$patient_id = $item->patient_id;
$episode_id = $item->episode_id;
$patient_category = $item->patient_category;
$items_amounts = $sum_total;
$receipt_number = $item->receipt_number;
$invoice_generated = $item->invoice_generated;
$total = $item->sum;
$start_date = $dates[0];
$end_date = $dates[1];
$invoice_date = $item->invoice_date;
$invoice_number = (string)$item->invoice_number;
$created_by = $item->created_by;
$created_at = $item->updated_at;
@endphp
@endforeach
@else
<tr>
<td colspan="7">{{ __('invoices.no_records_found') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="panel panel-default col-md-10 offset-1">
<div class="panel-heading">
<div class="panel-title">
<h3><strong>{{ __('invoices.donor_invoices_with_balance') }}</strong></h3>
</div>
</div>
<div class="panel-body panel-primary">
<div class="table-responsive">
<table id="table" class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('invoices.patient_category') }}</th>
<th>{{ __('invoices.last_payment_date') }}</th>
<th>{{ __('invoices.total') }}</th>
<th>{{ __('invoices.amount') }}</th>
<th>{{ __('invoices.balance') }}</th>
<th>{{ __('invoices.invoice_number') }}</th>
<th colspan="3"></th>
</tr>
</thead>
@foreach($invoices_with_balance as $item)
@php
$sum_total = 0;
$total = 0;
@endphp
<tbody>
<tr>
<td>{{ get_name($item->donor_id, 'id', 'name', 'donors') }}</td>
<td>{{ streamline_date($item->created_at) }}</td>
<td>{{ ugandan_shillings($item->total) }}</td>
<td>{{ ugandan_shillings($item->amount_paid) }}</td>
<td>{{ ugandan_shillings($item->balance) }}</td>
<td>{{ $item->invoice_number }}</td>
<td>
{{ Form::open(['method'=>'post','route'=>'invoices.donor_invoice_payment' ]) }}
{{ Form::hidden('id', $item->id) }}
{{ Form::hidden('total', $item->total) }}
{{ Form::hidden('amount_paid', $item->amount_paid) }}
{{ Form::hidden('donor_id', $item->donor_id) }}
{{ Form::hidden('balance', $item->balance) }}
{{ Form::hidden('created_by', $item->created_by) }}
{{ Form::hidden('created_at', $item->created_at) }}
{{ Form::hidden('status', 'update') }}
{{ Form::hidden('invoice_date', $item->invoice_date) }}
{{ Form::hidden('invoice_number', $item->invoice_number) }}
{{ Form::hidden('receipt_number',$item->receipt_number ) }}
{{ Form::hidden('amount_paid_history', $item->amount_paid_history) }}
{{ Form::hidden('date_paid_history', $item->date_paid_history) }}
{{ Form::hidden('staff_incharge_history', $item->staff_incharge_history) }}
<button id="update_payment" class="btn btn-success">Receive Payment</button>
{{ Form::close() }}
</td>
<td>
{{ Form::open(['method'=>'post','route'=>'invoices.generate_donor_invoice' ]) }}
{{ Form::hidden('invoice_number', $item->invoice_number) }}
{{ Form::hidden('invoice_date', $item->invoice_date) }}
{{ Form::hidden('status', 'reprint') }}
<button id="update_payment" class="btn btn-success">{{ __('invoices.print_invoice') }}</button>
{{ Form::close() }}
</td>
<td>
{{ Form::open(['method'=>'post', 'route'=>'invoices.donor_payments_history' ]) }}
{{ Form::hidden('id', $item->id) }}
<button id="update_payment" class="btn btn-success">{{ __('invoices.payment_history') }}</button>
{{ Form::close() }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
$('#receive_payment').click(function (e) {
e.preventDefault();
let amount = $('#amount').val();
$('#invoice_payment_modal').modal('show');
$('#amount_paid').change(function () {
let bal = amount - this.value;
$('#balance').val(bal);
})
});
$('#save_payment').click(function (e) {
let invoice_date = "<?php echo $invoice_date ?>";
let total = "<?php echo $total ?>";
let balance = $('#balance').val();
let donor_id = "<?php echo $donor_id ?>";
let invoice_number = "<?php echo $invoice_number ?>";
let patient_category = "<?php echo $patient_category ?>";
let generated_date = "<?php echo $created_at ?>";
let receipt_number = "<?php echo $receipt_number ?>";
let amount_paid = $('#amount_paid').val();
let staff_in_charge = "<?php echo Auth::id() ?>";
let payment_received_on = "<?php echo \Carbon\Carbon::now()->toDateTimeString() ?>";
let data = {
'invoice_date':invoice_date,
'total': total,
'balance':balance,
'donor_id': donor_id,
'invoice_number':invoice_number,
'patient_category' :patient_category,
'generated_date' :generated_date,
'receipt_number' :receipt_number,
'amount_paid' :amount_paid,
'staff_in_charge' :staff_in_charge,
'payment_received_on' :payment_received_on,
};
$.ajax({
method: 'POST',
url: '/invoices/process_donor_payment',
data: data,
success: function (response) {
// if(parseInt(response) === 1){
$('#invoice_payment_modal').modal('hide');
//console.log(JSON.stringify(data));
location.reload();
alert('Payment has Successfully been made.');
},
error: function (response) {
$('#invoice_payment_modal').modal('show');
console.log(JSON.stringify(data));
alert('payment not made, try again.');
}
// location.reload();
})
});
</script>
<script type="text/javascript">
jQuery('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script type="text/javascript">
jQuery('#start_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
@endpush
@@ -0,0 +1,635 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-md-6">
<h4 class="page-title">{{ __('finance.patient_category_invoices') }}</h4>
</div>
<div class="col-md-6">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> {{ __('finance.home') }}</a></li>
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('finance.finance_home') }}</a></li>
<li><a href="{{ route('invoices') }}"><i class="fa fa-file"></i> {{ __('finance.invoices_home') }}</a></li>
<li class="active">{{ __('finance.payments') }}</li>
</ol>
</div>
</div>
{{ Form::open(['route' => 'invoices.receive_patient_invoices' , 'data-toggle' => 'validator']) }}
<div class="white-box">
<div class="row">
<div class="col-md-3">
<div class="form-group" id="lab_numbers">
{{ Form::label('patient_category',__('finance.patient_category')) }}
<select class="form-control required" name="patient_category" id="patient_category" required>
<option value="">{{ __('finance.select') }}</option>
<option value="0">{{ __('invoices.all_patient_categories') }}</option>
@foreach($patient_categories as $id)
<option value="{{ $id }}">{{ get_name($id, 'id', 'name', 'patient_categories') }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
{{ Form::label('start_date', __('invoices.from')) }}
{{ Form::text('start_date','',['class' => 'form-control', 'readonly','id'=>'start_date']) }}
</div>
</div>
<div class="col-md-3">
<div class="form-group">
{{ Form::label('end_date', __('invoices.to')) }}
{{ Form::text('end_date','',['class' => 'form-control', 'readonly','id'=>'end_date']) }}
</div>
</div>
<div class="col-md-3">
<br>
{{ Form::button(__('invoices.search'),['type'=>'submit','class'=>'btn btn-rounded btn-success waves-effect waves-light m-r-10 btn-block', 'style'=>'margin-top: 5px;']) }}
</div>
</div>
</div>
{{ Form::close() }}
<div class="white-box">
@include('flash::message')
@php
$total_amount_to_pay = 0;
$balance_to_pay = 0;
$total_amount_paid = 0;
$payments_sum_total = 0;
$payments_balances = 0;
$payments_amount_paid = 0;
$back_date = \Streamline\Models\HospitalInformation::first()->pluck('back_date');
@endphp
<h3>{{ __('invoices.patient_category') }}: {{ $searched_patient_category }} Date: {{ __('invoices.from') }} {{ streamline_date($start_date) }} {{ __('invoices.to') }} {{ streamline_date($end_date) }}</h3>
<div class="table-responsive">
<table id="invoice_table" class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th class="show_checkboxes" style="display: none;"></th>
<th>{{ __('finance.patient_category') }}</th>
<th>{{ __('finance.date_generated') }}</th>
<th>{{ __('finance.for_period') }}</th>
<th>{{ __('invoices.amount_to_pay') }}</th>
<th>{{ __('invoices.amount_paid') }}</th>
<th>{{ __('invoices.balance') }}</th>
<th>{{ __('finance.invoice_number') }}</th>
<th>{{ __('finance.action') }}</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($invoices) > 0)
@foreach($invoices as $item)
<tr id="invoice_number_{{ $item['invoice_number'] }}">
<td class="show_checkboxes" style="display: none;">
<input id='checkbox_{{ $item['invoice_number'] }}' type='checkbox'/>
</td>
<td>{{ get_name($item['patient_category'], 'id', 'name', 'patient_categories') }}</td>
<input type="hidden" id="invoice_number_patient_category_{{ $item['invoice_number'] }}" value="{{$item['patient_category']}}"/>
<td>
@if(!is_null($item['updated_at']))
{{ streamline_date($item['updated_at']) }}
@else
{{ streamline_date($item['created_at']) }}
@endif
</td>
<td>
@php
$dates = explode('/',$item['invoice_date']);
@endphp
{{ ($dates[0] ?? "")." to ".($dates[1] ?? "") }}
</td>
<td>
@php $total_amount_to_pay += $item['patient_amount']; @endphp
{{ ugandan_shillings($item['patient_amount']) }}
</td>
<td>
@php $total_amount_paid += $item['amount_paid']; @endphp
{{ ugandan_shillings($item['amount_paid']) }}
</td>
<td>
@if($item['has_payment'] == 1)
@php
$balance_to_pay += $item['patient_amount'] - $item['amount_paid'];
@endphp
{{ ugandan_shillings($item['patient_amount'] - $item['amount_paid']) }}
<input type='hidden' value='{{ $item['patient_amount'] - $item['amount_paid'] }}' id='invoice_balance_{{ $item['invoice_number'] }}' />
@else
@php $balance_to_pay += $item['patient_amount']; @endphp
{{--N/A--}}
{{ ugandan_shillings($item['patient_amount']) }}
<input type='hidden' value='{{ $item['patient_amount'] }}' id='invoice_balance_{{ $item['invoice_number'] }}' />
@endif
</td>
<td>
{{ $item['invoice_number'] }}
</td>
<td>
@if($item['has_payment'] == 1)
{{ Form::open(['method'=>'post','route'=>'invoices.patient_invoice_payment' ]) }}
{{ Form::hidden('total', $item['patient_amount']) }}
{{ Form::hidden('amount_paid', $item['amount_paid']) }}
{{ Form::hidden('patient_category', $item['patient_category']) }}
{{ Form::hidden('balance', $item['balance']) }}
{{ Form::hidden('status', 'update') }}
{{ Form::hidden('invoice_date', $item['invoice_date']) }}
{{ Form::hidden('invoice_number', $item['invoice_number']) }}
{{ Form::hidden('generated_on', $item['updated_at']) }}
<button id="update_payment" class="btn btn-success btn-sm">{{ __('finance.update_payment') }}</button>
{{ Form::close() }}
@else
{{ Form::open(['method'=>'post','route'=>'invoices.patient_invoice_payment' ]) }}
{{ Form::hidden('patient_category', $item['patient_category']) }}
{{ Form::hidden('status', 'new') }}
{{ Form::hidden('total', $item['patient_amount']) }}
{{ Form::hidden('amount_paid', 0) }}
{{ Form::hidden('balance', $item['patient_amount']) }}
{{ Form::hidden('invoice_date', $item['invoice_date']) }}
{{ Form::hidden('invoice_number', $item['invoice_number']) }}
{{ Form::hidden('generated_on', $item['updated_at']) }}
<button class="btn btn-success btn-sm">{{ __('finance.receive_payment') }}</button>
{{ Form::close() }}
@endif
</td>
<td>
{{ Form::open(['method'=>'post','route'=>'invoices.generate_invoice' ]) }}
{{ Form::hidden('invoice_number', $item['invoice_number']) }}
{{ Form::hidden('invoice_date', $item['invoice_date']) }}
{{ Form::hidden('patient_category', $item['patient_category']) }}
{{ Form::hidden('status', 'reprint') }}
<button id="update_payment" class="btn btn-success btn-sm">{{ __('finance.print_invoice') }}</button>
{{ Form::close() }}
</td>
<td>
@if($item['has_payment'] == 1)
{{ Form::open(['method'=>'post', 'route'=>'invoices.patient_payments_history' ]) }}
{{ Form::hidden('invoice_number', $item['invoice_number']) }}
<button id="update_payment" class="btn btn-success btn-sm">{{ __('finance.payment_history') }}</button>
{{ Form::close() }}
@endif
</td>
<td>
@if($item['has_payment'] != 1)
<a role="button" class="btn btn-danger btn-sm" style="color: white" href="{{ route('invoices.delete', $item['invoice_number']) }}"><i class="fa fa-trash"></i></a>
@endif
</td>
</tr>
@endforeach
@if(count($payments) > 0)
@foreach($payments as $item)
<tr id="invoice_number_{{ $item->invoice_number }}">
<td class="show_checkboxes" style="display: none;">
<input id='checkbox_{{ $item->invoice_number }}' type='checkbox'/>
</td>
<td>{{ get_name($item->patient_category, 'id', 'name', 'patient_categories') }}</td>
<input type="hidden" id="invoice_number_patient_category_{{ $item->invoice_number }}" value="{{$item->patient_category}}"/>
<td>{{ streamline_date(get_name($item->invoice_number, 'invoice_number', 'updated_at', 'patient_category_invoices')) }}</td>
<td>
@php
$payments_sum_total += $item->total;
$dates = explode('/', $item->invoice_date);
echo streamline_date($dates[0]). " to " .streamline_date($dates[0]);
$amount_paid = $item->amount_paid;
$payments_amount_paid += $amount_paid;
@endphp
</td>
<td>{{ ugandan_shillings($item->total) }}</td>
<td>{{ ugandan_shillings($amount_paid) }}</td>
<td>
{{ ugandan_shillings($item->balance) }}
<input type='hidden' value='{{ $item->balance }}' id='invoice_balance_{{ $item->invoice_number }}' />
</td>
@php $payments_balances += $item->balance; @endphp
<td>{{ $item->invoice_number }}</td>
<td>
</td>
<td>
{{ Form::open(['method'=>'post','route'=>'invoices.generate_invoice' ]) }}
{{ Form::hidden('invoice_number', $item->invoice_number) }}
{{ Form::hidden('invoice_date', $item->invoice_date) }}
{{ Form::hidden('patient_category', $item->patient_category) }}
{{ Form::hidden('status', 'reprint') }}
<button id="update_payment" class="btn btn-success btn-sm">{{ __('invoices.print_invoice') }}</button>
{{ Form::close() }}
</td>
<td>
{{ Form::open(['method'=>'post', 'route'=>'invoices.patient_payments_history' ]) }}
{{ Form::hidden('invoice_number', $item->invoice_number) }}
<button class="btn btn-success btn-sm">{{ __('invoices.payment_history') }}</button>
{{ Form::close() }}
</td>
<td></td>
</tr>
@endforeach
@endif
@else
<tr>
<td colspan="10">{{ __('finance.no_records_available') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
<br><br>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<tbody>
<tr>
<td><b>{{ __('invoices.total_amount_to_pay') }}</b></td>
<td>{{ ugandan_shillings($total_amount_to_pay + $payments_sum_total) }}</td>
</tr>
<tr>
<td><b>{{ __('invoices.total_amount_paid') }}</b></td>
<td>{{ ugandan_shillings($total_amount_paid + $payments_amount_paid) }}</td>
</tr>
<tr>
<td><b>{{ __('invoices.balance_left_to_pay') }}</b></td>
<td>{{ ugandan_shillings($balance_to_pay + $payments_balances) }}</td>
</tr>
</tbody>
</table>
</div>
@if(Auth::user()->can('make-bulk-invoice-payments'))
<hr>
<button class="btn btn-warning btn-rounded" onclick="show_bulk_pay_div()">{{ __('payments.perform_bulk_payment') }}</button>
<br>
@endif
<div id="bulk_pay_div" style="display: none; border:3px solid rgb(148, 146, 146); padding: 5px;">
{{ Form::open(['method'=>'post', 'route'=>'payments.invoices_bulk_pay', 'id'=>'invoice_bulk_pay_form'])}}
<div class='row'>
<div class="col-md-2">
<div class="form-group">
{{ Form::label('amount_to_pay', __('payments.amount_to_be_paid')) }}
{{ Form::number('amount_to_pay', 0, ['class'=>'form-control compulsory', 'required', 'id'=>'bulk_amount_to_pay']) }}
</div>
</div>
<div class="col-md-2">
<div class="form-group">
{{ Form::label('payment_received_on_label', __('finance.payment_received_on')) }}
<div class="input-group">
{{ Form::text('payment_date', \Carbon\Carbon::today()->format('d-m-Y'), ['class'=>'form-control','required','autocomplete'=>'off', 'id'=>'bulk_payment_date']) }}
</div>
</div>
</div>
<div class="col-md-2">
<div id="payment_methods_div">
<div class="form-group">
{{ Form::label('cash_to_pay',__('patient_finance.cash_to_pay')) }}
{{ Form::number('cash_to_pay',0,['class' => 'form-control','id'=>'cash_to_pay','readonly']) }}
</div>
<label class="label label-primary" onclick="add_payment_method();">{{ __('patient_finance.add_payment_method') }}</label>
<br><br>
</div>
</div>
<input type="hidden" name="selected_invoice_numbers" id="selected_invoice_numbers">
<input type="hidden" name="total_amount_paid_off" value="0" id="total_amount_paid_off">
<div class="col-md-4">
<div class="form-group">
<label>{{ __('invoices.do_you_want_receive_bank') }}</label>
<br>
{{ Form::radio('receive_to_bank', 1, false, ['onclick' => 'show_banking_details(1)']) }} Yes &nbsp;&nbsp;
{{ Form::radio('receive_to_bank', 0, true, ['onclick' => 'show_banking_details(0)']) }} No
</div>
<div id="banking_div" style="display: none;">
<div class="form-group">
{{ Form::label('bank', __('invoices.bank')) }}
{{ Form::select('bank', $banks, '', ['class'=>'form-control', 'id'=>'bulk_bank_account']) }}
</div>
<div class="form-group">
{{ Form::label('bank_balance', __('invoices.bank_balance')) }}
<div class="input-group">
{{ Form::text('bank_balance', '', ['class'=>'form-control','readonly', 'id'=>'bank_balance']) }}
{{ Form::hidden('undeposited_funds_bank_balance', '', ['id'=>'undeposited_funds_bank_balance']) }}
</div>
</div>
<div class="form-group">
{{ Form::label('memo',__('invoices.memo')) }}
{{ Form::textarea('memo', '',['class' => 'form-control compulsory banking_memo']) }}
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<button class='btn btn-success btn-rounded btn-block pull-right' id="validate_bulk_pay">{{ __('payments.make_bulk_payment') }}</button>
</div>
</div>
<div class="col-md-4">
<div id="amounts_per_invoice_div">
<h4 id="bulk_title" style="font-weight: bolder; color: blue;"></h4>
</div>
</div>
<div class="col-md-8"></div>
</div>
{{ Form::close() }}
</div>
</div>
{{-- bulk payment message modal --}}
<div class="modal fade" id="bulkPaymentMessage" tabindex="-1" role="dialog" aria-labelledby="bulkPaymentMessageTitle" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content" style="margin-top: 50px;">
<div class="modal-header">
<span class="label label-info">Please note:</span>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
</div>
<div class="modal-body">
<div class="row" style="padding: 10px;">
<div class="col-sm-12">
<h3>Please Be Sure To Select The Invoices That You Wish To Clear</h3>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" data-dismiss="modal" id="confirmsToSelect">{{ __('payments.ok') }}</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">{{ __('payments.cancel') }}</button>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<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>
$('#uncleared_invoice_table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel',
],
"aoColumnDefs": [{
"aTargets": [2,3],
"defaultContent": "",
}]
});
let min_days = <?php echo $back_date[0]; ?>;
var min_date = new Date();
min_date.setDate(min_date.getDate()-min_days);
$('#start_date,#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$('#bulk_payment_date').datepicker({
autoclose: true,
todayHighlight: true,
endDate: new Date(),
startDate: min_date,
format: 'dd-mm-yyyy'
});
$('#invoice_table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'csv', 'excel',
],
"aoColumnDefs": [{
"aTargets": [2,3],
"defaultContent": "",
}]
});
$('#receive_payment').click(function (e) {
e.preventDefault();
let amount = $('#amount').val();
$('#invoice_payment_modal').modal('show');
$('#amount_paid').change(function () {
let bal = amount - this.value;
$('#balance').val(bal);
})
});
$('#confirmsToSelect').click(function (e){
$('#bulk_pay_div').show();
$('.show_checkboxes').show();
});
function show_bulk_pay_div() {
$('#bulkPaymentMessage').modal('show');
}
var ticked_off_invoices_array = [];
var ticked_off_patient_categories_array = [];
$('#bulk_bank_account').on('change', function() {
var transfer_to = $('#bulk_bank_account').val();
var transfer_from = '10';
var transfer_date = $('#payment_received_on').val();
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); // January is 0!
var yyyy = today.getFullYear();
var today_formatted = dd + '-' + mm + '-' + yyyy;
$.ajax({
method: 'POST',
url: '/banking/get_latest_bank_balance',
data: {
'to': transfer_to,
'from': transfer_from,
'date': today_formatted, // transfer_date,
},
success: function(response) {
$('#bank_balance').val(parseInt(response[0]));
$('#undeposited_funds_bank_balance').val(parseInt(response[1]));
},
error: function(error) {
console.log(error);
}
});
});
$('#validate_bulk_pay').click(function(e) {
e.preventDefault();
let payment_date = $('#bulk_payment_date').val();
let bank_account = $('#bulk_bank_account').val();
let account_balance = $('#bulk_account_balance').val();
let amount_to_pay = $('#bulk_amount_to_pay').val();
let receive_money_directly = $('input[name="receive_to_bank"]:checked').val();
if (payment_date === "") {
alert('Please Select A Payment Date.')
} else if (bank_account === "" && receive_money_directly == 1) {
alert('Please Select A Bank Account.')
} else {
if (ticked_off_invoices_array.length !== 0) {
if (confirm("Are you sure ?")) {
$('#invoice_bulk_pay_form').submit();
}
} else {
alert('Please Select The Invoices That You Wish To Pay Off Fully Or Partially')
}
}
});
$("[id^='checkbox_']").on("change", function() {
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
let amount_to_pay = $('#bulk_amount_to_pay').val();
let invoice_balance = $('#invoice_balance_' + id).val();
let amount_paid_off = $('#amount_paid_off_' + id).val();
let total_amount_paid_off = $('#total_amount_paid_off').val();
let new_amount_to_pay = parseInt(amount_to_pay) + parseInt(invoice_balance);
let new_total_amount_paid_off = parseInt(total_amount_paid_off) + parseFloat(amount_paid_off);
if (this.checked) {
$('#invoice_number_' + id).children('td, th').css('background-color', 'gold');
$('#bulk_amount_to_pay').val(new_amount_to_pay);
ticked_off_invoices_array.push(id[0]);
let invoice_patient_category = $('#invoice_number_patient_category_'+id[0]).val();
ticked_off_patient_categories_array.push(invoice_patient_category);
//add the invoice to the dynamic to pay invoices DOM
add_invoice_to_dom(id[0], invoice_patient_category);
} else {
$('#invoice_number_' + id).children('td, th').css('background-color', 'white');
$('#bulk_amount_to_pay').val(parseInt(amount_to_pay) - parseInt(invoice_balance));
const index = ticked_off_invoices_array.indexOf(id);
ticked_off_invoices_array.splice(index, 1);
ticked_off_patient_categories_array.splice(index, 1);
//remove the invoice from dynamic to pay invoices DOM
//console.log("invoice to remove "+id);
remove_invoice_from_dom(id);
}
$('#selected_invoice_numbers').val(ticked_off_invoices_array);
total_balances_for_invoices = calculate_invoice_balances(ticked_off_invoices_array);
//console.log("total balances for ticked invoices === "+total_balances_for_invoices);
$('#cash_to_pay').val(total_balances_for_invoices);
$('#bulk_title').text("Selected invoices to be cleared");
});
$('#amounts_per_invoice_div').on('change','.bulk_invoice_amount_to_pay', function() {
let recalculated_total = 0;
$('.bulk_invoice_amount_to_pay').each(function () {
recalculated_total += +$(this).val();
});
//reculate amount to be paid after editing the amounts for each invoice to be paid
//console.log('the recalculated total after editing amount to pay on each invoice = '+recalculated_total);
$('#bulk_amount_to_pay').val(recalculated_total);
});
function calculate_invoice_balances(ticked_off_invoices_array){
//loop through all the ticked invoice array arrays
let total_balances_to_clear = 0;
//console.log(ticked_off_invoices_array);
console.log(ticked_off_patient_categories_array);
for(let i=0; i<ticked_off_invoices_array.length; i++) {
let invoice_number = ticked_off_invoices_array[i];
invoice_balance = $('#invoice_balance_' + invoice_number).val();
//console.log("single invoice balance == "+invoice_balance);
total_balances_to_clear += parseInt(invoice_balance);
}
return total_balances_to_clear;
}
function add_payment_method() {
$('#cash_to_pay_div').show();
$('#payment_methods_div').append('<div class="row"><div class="col-md-6"><label>Method</label><select class="form-control payment_method" name="payment_method[]"><option value="0">--select method--</option><?php echo $patient_payment_methods_options ?></select></div><div class="col-md-6"><label>Amount</label><input name="payment_methods_amount[]" type="number" class="form-control payment_methods_amount" onkeyup="payment_methods_amount_calculate()"></div></div><br>');
}
function show_banking_details(choice) {
if (choice === 1) {
$('#banking_div').show();
$('.banking_memo').prop('required', true);
$('#bulk_bank_account').prop('required', true);
} else {
$('#banking_div').hide();
$('.banking_memo').removeAttr('required');
$('#bulk_bank_account').removeAttr('required');
}
}
function payment_methods_amount_calculate() {
// tally up all the entered values
let total_amount_payment_methods = 0;
$('.payment_methods_amount').each(function () {
total_amount_payment_methods += +$(this).val();
});
let amount_to_pay = $('#bulk_amount_to_pay').val();
let cash_to_pay = amount_to_pay;
cash_to_pay -= total_amount_payment_methods;
if (cash_to_pay < 0) {
alert("You have entered more money in the payment methods than is supposed to be paid");
$('.payment_methods_amount').each(function () {
$(this).val(0);
});
$('#cash_to_pay').val(amount_to_pay);
} else {
$('#cash_to_pay').val(cash_to_pay);
}
}
function add_invoice_to_dom(invoice_number, invoice_patient_category) {
invoice_balance = $('#invoice_balance_' + invoice_number).val();
$('#amounts_per_invoice_div').append('<div class="row" id="bulk_row_'+invoice_number+'"><div class="col-md-6"><label>Invoice Number</label><input name="bulk_invoices[]" type="text" value="'+invoice_number+'" class="form-control bulk_invoices" readonly><input type="hidden" value="'+invoice_patient_category+'" name="bulk_patient_category[]"/></div><div class="col-md-6"><label>Invoice Amount To Be Paid</label><input name="bulk_invoice_amount_to_pay[]" type="number" class="form-control bulk_invoice_amount_to_pay" value="'+invoice_balance+'"></div></div><br>');
}
function remove_invoice_from_dom(invoice_number){
$('#bulk_row_'+invoice_number).remove();
}
/* $('#show_alert').click(function(e) {
e.preventDefault();
$('#banking_div').show();
$('#dismiss_alert').hide();
}); */
</script>
@endpush
@@ -0,0 +1,18 @@
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:api')->get('/invoices', function () {
return "Invoices";
});
@@ -0,0 +1,57 @@
<?php
use Illuminate\Support\Facades\Route;
Route::group(['middleware' => ['auth', 'disablebackbutton', 'user-locale','subscription-tracking', 'password-expiry']], function () {
/* Invoices */
Route::get('/invoices', 'InvoicesController@index')->name('invoices');
Route::any('/invoices/custom_invoices/{patient_category}/{category}/{is_generated}', 'InvoicesController@custom_invoices')->name('invoices.custom_invoices');
Route::any('/invoices/custom_invoice/{patient_category}/{category}/{id}/{is_generated}', 'InvoicesController@custom_invoice')->name('invoices.custom_invoice');
Route::any('invoices/patient_category', 'InvoicesController@viewPatientCategory')->name('invoices.patient_category');
Route::any('invoices/donor_discounts', 'InvoicesController@viewDonorDiscounts')->name('invoices.donor_discounts');
Route::any('generate_invoice', 'InvoicesController@generate_invoice')->name('invoices.generate_invoice');
Route::any('print_invoice/{invoice_number}', 'InvoicesController@print_invoice')->name('invoices.print_invoice');
Route::any('generate_donor_invoice', 'InvoicesController@generate_donor_invoice')->name('invoices.generate_donor_invoice');
Route::any('process_invoice', 'InvoicesController@process_invoice')->name('invoices.process_invoice');
Route::any('process_donor_invoice', 'InvoicesController@process_donor_invoice')->name('invoices.process_donor_invoice');
Route::any('invoices/receive_patient_invoices', 'InvoicesController@receive_patient_invoices')->name('invoices.receive_patient_invoices');
Route::any('invoices/receive_donor_invoices', 'InvoicesController@receive_donor_invoices')->name('invoices.receive_donor_invoices');
Route::any('invoices/patient_invoice_payment', 'InvoicesController@patient_invoice_payment')->name('invoices.patient_invoice_payment');
Route::any('invoices/donor_invoice_payment', 'InvoicesController@donor_invoice_payment')->name('invoices.donor_invoice_payment');
Route::any('invoices/process_patient_payment', 'InvoicesController@process_patient_payment')->name('invoices.process_patient_payment');
Route::any('invoices/process_donor_payment', 'InvoicesController@process_donor_payment')->name('invoices.process_donor_payment');
Route::any('invoices/patient_payments_history', 'InvoicesController@patient_payments_history')->name('invoices.patient_payments_history');
Route::any('invoices/donor_payments_history/', 'InvoicesController@donor_payments_history')->name('invoices.donor_payments_history');
Route::any('/invoices/update_donor_payment', 'InvoicesController@update_donor_payment')->name('invoices.update_donor_payment');
Route::any('/invoices/update_patient_payment', 'InvoicesController@update_patient_payment')->name('invoices.update_patient_payment');
Route::any('/invoices/donor_history', 'InvoicesController@donor_history')->name('invoices.donor_history');
Route::any('/invoices/patient_history', 'InvoicesController@patient_history')->name('invoices.patient_history');
Route::any('/invoices/donor_payment_receipt', 'InvoicesController@donor_payment_receipt')->name('invoices.donor_payment_receipt');
Route::any('/invoices/patient_payment_receipt', 'InvoicesController@patient_payment_receipt')->name('invoices.patient_payment_receipt');
Route::any('/invoices/patient_category_invoice/detail/{id}/{start_date}/{end_date}', 'InvoicesController@patient_category_detail');
Route::any('/invoices/patient_category_detail_print/{id}/{start_date}/{end_date}', 'InvoicesController@patient_category_detail_print');
Route::any('/invoices/donor_invoice/detail/{id}', 'InvoicesController@patient_payment_receipt')->name('invoices.donor_invoice.detail');
Route::any('/invoices/delete/{id}', 'InvoicesController@delete_patient_category_invoice')->name('invoices.delete');
Route::any('/invoices/write_off_invoice_balance', 'InvoicesController@write_off_invoice_balance')->name('invoices.write_off_invoice_balance');
Route::any('/invoices/generate_hospital_invoices', 'InvoicesController@generate_hospital_invoices')->name('invoices.generate_hospital_invoices');
Route::any('/invoices/generate_hospital_invoices_confirm', 'InvoicesController@generate_hospital_invoices_confirm')->name('invoices.generate_hospital_invoices_confirm');
Route::any('/invoices/save_hospital_invoices/{quotation_number}', 'InvoicesController@save_hospital_invoices');
Route::any('/invoices/print_hospital_invoices/{invoice_number}', 'InvoicesController@print_hospital_invoices');
Route::any('/invoices/make_hospital_payments', 'InvoicesController@make_hospital_payments')->name('invoices.make_hospital_payments');
Route::any('/invoices/delete_hospital_invoices/{invoice_number}', 'InvoicesController@delete_hospital_invoices');
Route::any('/invoices/complete_hospital_payments/{invoice_number}', 'InvoicesController@complete_hospital_payments');
Route::any('/invoices/save_hospital_payments/', 'InvoicesController@save_hospital_payments')->name('invoices.save_hospital_payments');
Route::any('/invoices/hospital_invoices_payment_history/{id}', 'InvoicesController@hospital_invoices_payment_history');
Route::any('/invoices/update_hospital_invoice_payment/{id}', 'InvoicesController@update_hospital_invoice_payment');
Route::any('/invoices/view_hospital_payments', 'InvoicesController@view_hospital_payments')->name('invoices.view_hospital_payments');
Route::any('invoices_bulk_payment', 'InvoicesController@process_invoices_bulk_payment')->name('payments.invoices_bulk_pay');
});
@@ -0,0 +1,316 @@
<?php
namespace Modules\Invoices\Services;
use Carbon\Carbon;
use Illuminate\Database\QueryException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Streamline\Models\InvoicePayment;
use Streamline\Models\InvoicePaymentRecord;
use Streamline\Models\PatientCategoryInvoice;
class InvoicesService
{
public function __construct()
{
}
/**
* @param string $invoice_number
* @param string $receipt_number
* @param int $amount_paid
* @param string $date_paid
* @param int $amount_written_off
* @param string|null $amount_written_off_at
* @param array<string, mixed> $other_parameters
* @return InvoicePaymentRecord|null
*/
public function saveInvoicePaymentRecord(
string $invoice_number, string $receipt_number, int $amount_paid, string $date_paid,
int $amount_written_off = 0, string $amount_written_off_at = null, array $other_parameters = []
): InvoicePaymentRecord | null {
$record = new InvoicePaymentRecord();
$record->invoice_number = $invoice_number;
$record->receipt_number = $receipt_number;
$record->amount_paid = $amount_paid;
$record->date_paid = Carbon::parse($date_paid)->toDateString();
$record->amount_written_off = $amount_written_off;
$record->amount_written_off_at = $amount_written_off_at;
$record->created_by = Auth::id();
foreach ($other_parameters as $key => $value) {
$record->$key = $value;
}
try {
$record->save();
return $record;
} catch (QueryException $e) {
return null;
}
}
public function updateInvoicePayment(
string $invoice_number, int $amount_paid, int $balance
): InvoicePayment | null {
$record = InvoicePayment::where('invoice_number', $invoice_number)->first();
if (!$record) {
return null;
}
$record->amount_paid = $record->amount_paid + $amount_paid;
$record->balance = $balance;
try {
$record->save();
return $record;
} catch (QueryException $e) {
return null;
}
}
public function updateInvoicePaymentRecord(
string $invoice_number, string $receipt_number, int $amount_paid, string $date_paid,
int $amount_written_off = 0, string $amount_written_off_at = null
): InvoicePaymentRecord | null {
$record = new InvoicePaymentRecord();
$record->invoice_number = $invoice_number;
$record->receipt_number = $receipt_number;
$record->amount_paid = $amount_paid;
$record->date_paid = Carbon::parse($date_paid)->toDateString();
$record->amount_written_off = $amount_written_off;
$record->amount_written_off_at = $amount_written_off_at;
$record->created_by = Auth::id();
try {
$record->save();
return $record;
} catch (QueryException $e) {
return null;
}
}
public function saveInvoicePayment(
string $invoice_number, int $total, int $amount_paid, int $balance,
string $invoice_date, string $patient_category
): InvoicePayment | null {
$record = new InvoicePayment();
$record->invoice_number = $invoice_number;
$record->total = $total;
$record->amount_paid = $amount_paid;
$record->balance = $balance;
$record->invoice_date = $invoice_date;
$record->patient_category = $patient_category;
$record->created_by = Auth::id();
try {
$record->save();
return $record;
} catch (QueryException $e) {
return null;
}
}
public function clearInvoice(string $number): void
{
$payment = InvoicePayment::where('invoice_number', $number)->first();
$invoices = PatientCategoryInvoice::where('invoice_number', $number)->get();
$counter = 1;
$total = count($invoices);
$total_invoice_amount_paid = $payment->amount_paid;
foreach ($invoices as $invoice) {
if ($total_invoice_amount_paid > $invoice->patient_amount && $counter < $total) {
PatientCategoryInvoice::where('id', $invoice->id)->update([
'amount_paid_off' => $invoice->patient_amount,
'payment_date' => Carbon::now(),
'balance_remaining' => 0, 'payment_complete' => 1
]);
$total_invoice_amount_paid -= $invoice->patient_amount;
} else {
PatientCategoryInvoice::where('id', $invoice->id)->update([
'amount_paid_off' => $total_invoice_amount_paid,
'payment_date' => Carbon::now(),
'balance_remaining' => ($invoice->patient_amount - $total_invoice_amount_paid)
]);
$total_invoice_amount_paid = 0;
}
$counter++;
if ($total_invoice_amount_paid < 1) {
break;
}
}
}
public function reverseCashReceived($receivedCashId): void
{
$invoice_payments = InvoicePaymentRecord::where('received_id', $receivedCashId)->get();
foreach ($invoice_payments as $payment) {
InvoicePaymentRecord::where('id', $payment->id)->update([
'received_id' => null,
'received_amount' => null
]);
}
}
/**
* TODO Align this function to new data structure
*
* @param $invoice_number
* @param $amount_to_reverse
* @return void
*/
public function reverseClearedInvoice($invoice_number, $amount_to_reverse)
{
//1.update the balance remaning to null, status t0 0, received to null in patient_cat_invoices table
//2.update the payment_complete to 0 on patient_cat_invoice
//loop through the paid records in patient category invoices
//delete that payment from amounts_history, date_paid_history, staff_in_charge_history etc in the invoice_payments table
$invoices = PatientCategoryInvoice::where('invoice_number', $invoice_number)->where(function ($query) {
$query->whereNotNull('balance_remaining')
->orWhere('balance_remaining', '=', 0);
})->get();
$total_invoice_amount_paid = $amount_to_reverse;
$invoice_amount_after_one_patient_bill_reduction = $total_invoice_amount_paid;
foreach ($invoices as $invoice) {
$patient_invoice_bill = $invoice->patient_amount;
if (!is_null($invoice->balance_remaining)) {
if (($invoice_amount_after_one_patient_bill_reduction > $patient_invoice_bill) || ($invoice_amount_after_one_patient_bill_reduction == $patient_invoice_bill)) {
PatientCategoryInvoice::where('id', $invoice->id)->update(['amount_paid_off' => null, 'balance_remaining' => null, 'payment_complete' => 0]);
$invoice_amount_after_one_patient_bill_reduction = $invoice_amount_after_one_patient_bill_reduction - $patient_invoice_bill;
} elseif (($invoice_amount_after_one_patient_bill_reduction < $patient_invoice_bill) && ($invoice_amount_after_one_patient_bill_reduction > 0)) {
//not sober right now, need to review this later
$balance_remaining = $patient_invoice_bill - $invoice_amount_after_one_patient_bill_reduction;
PatientCategoryInvoice::where('id', $invoice->id)->update([
'amount_paid_off' => $invoice_amount_after_one_patient_bill_reduction,
'balance_remaining' => $balance_remaining
]);
break;
}
}
}
//do the adjustments in the invoice_payments table
$invoice_payment = InvoicePayment::where('invoice_number', $invoice_number)->first();
$invoice_payment->amount_paid = $invoice_payment->amount_paid - $amount_to_reverse;
$invoice_payment->balance = $invoice_payment->balance + $amount_to_reverse;
//remove the details in receipt_number, amount_paid_history, date_paid_history, staff_incharge_history, received_id_history, received_amount_history, banked_history
$amount_paid_history_array = unserialize($invoice_payment->amount_paid_history);
$amount_to_reverse_position_offset = array_search($amount_to_reverse, $amount_paid_history_array);
$invoice_payment->amount_paid_history = remove_an_element_from_serialized_data($amount_to_reverse_position_offset, $invoice_payment->amount_paid_history);
$invoice_payment->receipt_number = remove_an_element_from_serialized_data($amount_to_reverse_position_offset, $invoice_payment->receipt_number);
$invoice_payment->date_paid_history = remove_an_element_from_serialized_data($amount_to_reverse_position_offset, $invoice_payment->date_paid_history);
$invoice_payment->staff_incharge_history = remove_an_element_from_serialized_data($amount_to_reverse_position_offset, $invoice_payment->staff_incharge_history);
$invoice_payment->received_id_history = remove_an_element_from_serialized_data($amount_to_reverse_position_offset, $invoice_payment->received_id_history);
$invoice_payment->received_amount_history = remove_an_element_from_serialized_data($amount_to_reverse_position_offset, $invoice_payment->received_amount_history);
$invoice_payment->banked_history = remove_an_element_from_serialized_data($amount_to_reverse_position_offset, $invoice_payment->banked_history);
$invoice_payment->update();
}
public function getInvoicePayments(Request $request): array
{
$results = [];
$staff_member = $request->staff_member;
$today = date('Y-m-d');
$yesterday = date('Y-m-d', strtotime("-1 days"));
$end = Carbon::parse($request->end_date)->toDateString();
$start = Carbon::parse($request->start_date)->toDateString();
$total_amount_paid = 0;
$unreceived_amount = 0;
$received_amount = 0;
if ($request->staff_member == 0) {
if ($request->dates == "today") {
$results = DB::table('invoice_payment_records')->where('date_paid', $today)->whereNull('deleted_at')->get();
} else if ($request->dates == "yesterday") {
$results = DB::table('invoice_payment_records')->where('date_paid', $yesterday)->whereNull('deleted_at')->get();
} else if ($request->dates == "custom_date") {
$results = DB::table('invoice_payment_records')->where('date_paid', $start)->whereNull('deleted_at')->get();
} else if ($request->dates == "custom_date_range") {
$results = DB::table('invoice_payment_records')->whereBetween('date_paid', [$start, $end])->whereNull('deleted_at')->get();
}
} else {
if ($request->dates == "today") {
$results = DB::table('invoice_payment_records')->where('created_by', $staff_member)->where('date_paid', $today)->whereNull('deleted_at')->get();
} else if ($request->dates == "yesterday") {
$results = DB::table('invoice_payment_records')->where('created_by', $staff_member)->where('date_paid', $yesterday)->whereNull('deleted_at')->get();
} else if ($request->dates == "custom_date") {
$results = DB::table('invoice_payment_records')->where('created_by', $staff_member)->where('date_paid', $start)->whereNull('deleted_at')->get();
} else if ($request->dates == "custom_date_range") {
$results = DB::table('invoice_payment_records')->where('created_by', $staff_member)->whereBetween('date_paid', [$start, $end])->whereNull('deleted_at')->get();
}
}
foreach ($results as $result) {
if (is_null($result->received_amount)) {
$unreceived_amount += $result->amount_paid;
} else {
$received_amount += $result->received_amount;
}
$total_amount_paid += $result->amount_paid;
}
return ['total' => $total_amount_paid, 'unreceived' => $unreceived_amount, 'received' => $received_amount];
}
function getDonorInvoicePayments($start, $end, $staff_member): array
{
if ($staff_member == 0) {
$payments = DB::table('donor_invoice_payments')->whereBetween('created_at', [$start, $end])
->whereNull('deleted_at')->get()->toArray();
} else {
$payments = DB::table('donor_invoice_payments')->whereBetween('created_at', [$start, $end])
->where('created_by', $staff_member)->whereNull('deleted_at')->get()->toArray();
}
$total_amount_paid = $received_amount = 0;
foreach ($payments as $payment) {
// get total amount paid regardless of whether its received or not.
$amount_history_array = unserialize($payment->amount_paid_history);
$received_amount_history_array = unserialize($payment->received_amount_history);
$total_amount_paid += is_array($amount_history_array) ? array_sum($amount_history_array) : 0;
// get total of payments received specifically.
if ($payment->received) {
$received_amount += is_array($received_amount_history_array) ? array_sum($received_amount_history_array) : 0;
}
}
$unreceived_amount = $total_amount_paid - $received_amount;
return [
'total' => $total_amount_paid,
'unreceived' => $unreceived_amount,
'received' => $received_amount
];
}
}
@@ -0,0 +1,19 @@
image: alpine/git:latest
pipelines:
branches:
main:
- step:
name: Merge To Beta
script:
- git remote set-url origin https://Kabricks:${APP_SECRET}@bitbucket.org/dcsammi/${BITBUCKET_REPO_SLUG}
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- git fetch
- git checkout beta
- git merge main
- git commit --amend -m "[skip ci] Merge changes from main"
- git push
- step:
name: Deploy To Test
script:
- echo "Ready to deploy to demo or production!"
@@ -0,0 +1,11 @@
{
"name": "Invoices",
"alias": "invoices",
"description": "Invoices",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Invoices\\Providers\\InvoicesServiceProvider"
],
"files": []
}