resolved conflicts

This commit is contained in:
2025-03-31 03:46:05 +03:00
6454 changed files with 1520539 additions and 9 deletions
@@ -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