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,993 @@
@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" />
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-md-7">
<h4>{{ __('finance.bills') }}</h4>
</div>
<div class="col-md-5">
<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 class="active"><i class="fa fa-credit-card"></i> {{ __('finance.view_payments') }}</li>
</ol>
</div>
</div>
@include('expenses::payments.menu')
@include('flash::message')
<div class="white-box">
{{ Form::open(['method'=>'post','route' => 'payments.bills']) }}
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label>{{ __('finance.generated_by') }}:</label>
<select class="form-control compulsory required" name="staff_member" id="staff_member" required>
<option value="">{{ __('finance.select') }}</option>
<option value="ALL STAFF">{{ __('finance.all_staff') }}</option>
@foreach($staff_members as $item)
<option value="{{ $item->id }}">{{ $item->username }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>{{ __('finance.vendor') }}:</label>
<select class="form-control compulsory required" name="vendor" id="vendor" required>
<option value="">{{ __('finance.select') }}</option>
<option value="ALL VENDORS">{{ __('finance.all_vendors') }}</option>
@foreach($suppliers as $item)
<option value="{{ $item->id }}">{{ $item->name }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label>{{ __('finance.status') }}:</label>
<select class="form-control compulsory required" name="bill_status" required>
<option value="">{{ __('finance.select') }}</option>
<option value="ALL BILLS">{{ __('finance.all') }}</option>
<option value="unpaid">{{ __('finance.not_paid') }}</option>
<option value="paid">{{ __('finance.paid') }}</option>
<option value="paid_but_with_balance">{{ __('finance.paid_with_balance') }}</option>
</select>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>{{ __('finance_reports.select_date') }}:</label>
<select class="form-control compulsory required" name="dates" id="dates" required>
<option value="">{{ __('finance_reports.select') }}</option>
<option value="today">{{ __('finance_reports.today') }}</option>
<option value="yesterday">{{ __('finance_reports.yesterday') }}</option>
<option value="custom_date">{{ __('finance_reports.custom_date') }}</option>
<option value="custom_date_range">{{ __('finance_reports.date_range') }}</option>
</select>
</div>
</div>
<div class="col-md-2">
<div id="sDate" style="display: none;">
<div class="form-group">
{{ Form::label('start_date', __('finance.date_on')) }}
<div class="input-group">
{{ Form::text('start_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'start_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<div id="eDate" style="display: none;">
<div class="form-group">
{{ Form::label('end_date', __('finance.end_date')) }}
<div class="input-group">
{{ Form::text('end_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'end_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
<div class="col-md-1">
<div class="form-group" style="margin-top: 25px;">
{{ Form::submit('Submit', ['class'=>'btn btn-success btn-rounded btn-block pull-right']) }}
</div>
</div>
</div>
{{ Form::close() }}
<hr>
<h3><span class="label label-inverse">{{ $display }}</span></h3>
<br><br>
<div class="table-responsive">
<table id="table" class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th class="show_checkboxes" style="display: none;"></th>
<th>#</th>
<th>{{ __('finance.vendor') }}</th>
<th>{{ __('finance.bill_number') }}</th>
<th>{{ __('finance.bill_date') }}</th>
<th>{{ __('finance.bill_due_date') }}</th>
<th>{{ __('finance.bill_age') }}</th>
<th>{{ __('finance.memo') }}</th>
<th>{{ __('finance.payable_account') }}</th>
<th>{{ __('finance.items') }}</th>
<th>{{ __('finance.item_quantities') }}</th>
<th>{{ __('finance.item_amounts') }}</th>
<th>{{ __('finance.bill_total') }}</th>
<th>{{ __('finance.amount_paid') }}</th>
<th>{{ __('finance.balance') }}</th>
<th>{{ __('finance.action') }}</th>
</tr>
</thead>
<tbody>
@php
$count = 0;
$total = 0;
$_amount_paid = 0;
$amount_paid = 0;
$balance = 0;
$back_date = \Streamline\Models\HospitalInformation::first()->pluck('back_date');
@endphp
@foreach( $bills as $bill)
<tr id="bill_record_{{ $bill->id }}">
<td class="show_checkboxes" style="display: none;">
<input id='checkbox_{{ $bill->id }}' type='checkbox' @if ($bill->bill_memo == "UN-VERIFIED AUTO CREATED STRE@MLINE INVENTORY BILL") onclick="return false;" @endif />
</td>
<td>
{{ ($count + 1)."." }}
</td>
<td>{{ get_name($bill->vendor, 'id', 'name', 'suppliers') }}</td>
<td>{{ $bill->bill_number }}</td>
<td>{{ streamline_date($bill->bill_date) }}</td>
<td>{{ isset($bill->bill_due_date) ? streamline_date($bill->bill_due_date) : "" }}</td>
<td>{{ getDaysTillNow($bill->bill_date) }}</td>
<td>{{ $bill->bill_memo }}</td>
<td>
@php $payable_accounts = explode(',', $bill->payable_account); @endphp
@foreach ($payable_accounts as $payable_account)
{{ get_name($payable_account, 'id', 'name', 'chart_of_accounts') }} <br>
@endforeach
</td>
@php
$items = explode(',', $bill->item_ids);
$quantities = explode(',', $bill->item_quantities);
$subtotals = explode(',', $bill->item_subtotals);
@endphp
<td>
@if($bill->bill_type == 'DRU')
@php $items_string = ""; @endphp
@for($x = 0; $x < count($items); $x++) @php $items_string .=get_name($items[$x], 'id' , 'name' , 'drugs' ) . "<br>" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!}
<div id="long_items{{ $bill->bill_number }}" style="display: none;">
{!! $items_string !!}<br />
<a class="read_more" style="color : #0099CC;" onclick="hide('long_items{{ $bill->bill_number }}');show('short_items{{ $bill->bill_number }}');">Read Less</a>
</div>
@elseif($bill->bill_type == 'SUN')
@php $items_string = ""; @endphp
@for($x = 0; $x < count($items); $x++) @php $items_string .=get_name($items[$x], 'id' , 'name' , 'sundries' ) . ",<br>" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!}
<div id="long_items{{ $bill->bill_number }}" style="display: none;">
{!! $items_string !!}<br />
<a class="read_more" style="color : #0099CC;" onclick="hide('long_items{{ $bill->bill_number }}');show('short_items{{ $bill->bill_number }}');">Read Less</a>
</div>
@elseif($bill->bill_type == 'DEN')
@php $items_string = ""; @endphp
@for($x = 0; $x < count($items); $x++) @php $items_string .=get_name($items[$x], 'id' , 'name' , 'dentals' ) . ",<br>" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!}
<div id="long_items{{ $bill->bill_number }}" style="display: none;">
{!! $items_string !!}<br />
<a class="read_more" style="color : #0099CC;" onclick="hide('long_items{{ $bill->bill_number }}');show('short_items{{ $bill->bill_number }}');">Read Less</a>
</div>
@elseif($bill->bill_type == 'RAD')
@php $items_string = ""; @endphp
@for($x = 0; $x < count($items); $x++) @php $items_string .=get_name($items[$x], 'id' , 'name' , 'radiologies' ) . ",<br>" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!}
<div id="long_items{{ $bill->bill_number }}" style="display: none;">
{!! $items_string !!}<br />
<a class="read_more" style="color : #0099CC;" onclick="hide('long_items{{ $bill->bill_number }}');show('short_items{{ $bill->bill_number }}');">Read Less</a>
</div>
@elseif($bill->bill_type == 'LAB')
@php $items_string = ""; @endphp
@for($x = 0; $x < count($items); $x++) @php $items_string .=get_name($items[$x], 'id' , 'name' , 'labs' ) . ",<br>" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!}
<div id="long_items{{ $bill->bill_number }}" style="display: none;">
{!! $items_string !!}<br />
<a class="read_more" style="color : #0099CC;" onclick="hide('long_items{{ $bill->bill_number }}');show('short_items{{ $bill->bill_number }}');">Read Less</a>
</div>
@elseif($bill->bill_type == 'PAY')
@php $items_string = ""; @endphp
@for($x = 0; $x < count($items); $x++) @php $items_string .=get_name($items[$x], 'id' , 'name' , 'payment_items' ) . ",<br>" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!}
<div id="long_items{{ $bill->bill_number }}" style="display: none;">
{!! $items_string !!}<br />
<a class="read_more" style="color : #0099CC;" onclick="hide('long_items{{ $bill->bill_number }}');show('short_items{{ $bill->bill_number }}');">Read Less</a>
</div>
@elseif($bill->bill_type == 'GEN')
@php $items_string = ""; @endphp
@for($x = 0; $x < count($items); $x++) @php $items_string .=get_name($items[$x], 'id' , 'name' , 'general_items' ) . ",<br>" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!}
<div id="long_items{{ $bill->bill_number }}" style="display: none;">
{!! $items_string !!}<br />
<a class="read_more" style="color : #0099CC;" onclick="hide('long_items{{ $bill->bill_number }}');show('short_items{{ $bill->bill_number }}');">Read Less</a>
</div>
@elseif($bill->bill_type == 'EYE')
@php $items_string = ""; @endphp
@for($x = 0; $x < count($items); $x++) @php $items_string .=get_name($items[$x], 'id' , 'name' , 'eye_glasses' ) . ",<br>" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!}
<div id="long_items{{ $bill->bill_number }}" style="display: none;">
{!! $items_string !!}<br />
<a class="read_more" style="color : #0099CC;" onclick="hide('long_items{{ $bill->bill_number }}');show('short_items{{ $bill->bill_number }}');">Read Less</a>
</div>
@endif
</td>
<td>
@php $quantities_string = ""; @endphp
@for($x = 0; $x < count($quantities); $x++) @php $quantities_string .=($quantities[$x]==1) ? $quantities[$x]." unit": $quantities[$x]." units" . "<br>" ; @endphp @endfor {!! read_more($quantities_string, 'short_quantities' . $bill->bill_number, 'long_quantities' . $bill->bill_number) !!}
<div id="long_quantities{{ $bill->bill_number }}" style="display: none;">
{!! $quantities_string !!}<br />
<a class="read_more" style="color : #0099CC;" onclick="hide('long_quantities{{ $bill->bill_number }}');show('short_quantities{{ $bill->bill_number }}');">Read Less</a>
</div>
</td>
<td>
@php $subtotals_string = ""; @endphp
@for($x = 0; $x < count($subtotals); $x++) @php $subtotals_string .=ugandan_shillings_with_decimals($subtotals[$x]) . "<br>" ; @endphp @endfor {!! read_more($subtotals_string, 'short_subtotals' . $bill->bill_number, 'long_subtotals' . $bill->bill_number) !!}
<div id="long_subtotals{{ $bill->bill_number }}" style="display: none;">
{!! $subtotals_string !!}<br />
<a class="read_more" style="color : #0099CC;" onclick="hide('long_subtotals{{ $bill->bill_number }}');show('short_subtotals{{ $bill->bill_number }}');">Read Less</a>
</div>
</td>
<td>{{ ugandan_shillings_with_decimals($bill->total_amount) }}</td>
@php $_amount_paid = (int)$bill->total_amount - (!is_null($bill->balance) ? (int)$bill->balance : (int)$bill->total_amount) ; @endphp
<input type="hidden" id="amount_paid_off_{{ $bill->id }}" value="{{ $_amount_paid }}">
<td>{{ ugandan_shillings_with_decimals($_amount_paid) }}</td>
<td>
{{ ugandan_shillings_with_decimals(is_null($bill->balance) ? $bill->total_amount : $bill->balance) }}
<input type='hidden' value='{{ is_null($bill->balance) ? $bill->total_amount : $bill->balance }}' id='bill_balance_{{ $bill->id }}' />
</td>
<td>
@if ($bill->bill_memo != "UN-VERIFIED AUTO CREATED STRE@MLINE INVENTORY BILL")
@if(is_null($bill->balance))
@if( Auth::user()->can('pay-hospital-bills') )
<button class="btn btn-sm btn-rounded btn-success" id="pay_btn_{{ $bill->id }}" onclick="show_payment_modal('{{ $bill->id }}')">{{ __('finance.pay_bill') }}</button>
<button class="btn btn-sm btn-rounded btn-warning" style="display: none;" id="update_btn_{{ $bill->id }}" onclick="show_update_payment_modal('{{ $bill->id }}')">{{ __('finance.pay_balance') }}</button>
@endif
<a class="btn btn-sm btn-rounded btn-primary" style="display: none;" href="{{ route('payments.voucher', $bill->id) }}" id="voucher_btn_{{ $bill->id }}">{{ __('finance.view_payment_vouchers') }}</a>
@elseif($bill->balance > 0)
@if( Auth::user()->can('pay-hospital-bills') )
<button class="btn btn-sm btn-rounded btn-warning" onclick="show_update_payment_modal('{{ $bill->id }}')">{{ __('finance.pay_balance') }}</button>
@endif
<a class="btn btn-sm btn-rounded btn-primary" href="{{ route('payments.voucher', $bill->id) }}">{{ __('finance.view_payment_vouchers') }}</a>
@elseif($bill->balance == 0)
<a class="btn btn-sm btn-rounded btn-primary" href="{{ route('payments.voucher', $bill->id) }}">{{ __('finance.view_payment_vouchers') }}</a>
@endif
@if((Auth::user()->can('edit-hospital-bills')) && ($bill->bill_type == 'PAY') && (strpos($bill->bill_number, "Journal") !== 0))
@if(is_bill_payment_transaction_reconciled($bill->id))
<a data-toggle="modal" data-target="#reconciledBillModal" class="btn btn-sm btn-rounded btn-info" style="font-size: 12px; background-color:#86b6cb">{{ __('payments.edit_bill') }}</a>
@elseif($bill->payment_status == 1)
<a data-toggle="modal" data-target="#paidBillModal" class="btn btn-sm btn-rounded btn-info" style="font-size: 12px; background-color:#86b6cb">{{ __('payments.edit_bill') }}</a>
@else
<a class="btn btn-sm btn-rounded btn-info" href="{{ route('payments.edit_bill', $bill->id) }}" target="_blank">{{ __('payments.edit_bill') }}</a>
@endif
@endif
{{-- check if it's not a journal before displaying delete --}}
@php
$bill_number = $bill->bill_number;
@endphp
@if(Auth::user()->can('delete-hospital-bills') && strpos($bill_number, 'Journal') === false)
@if(is_bill_payment_transaction_reconciled($bill->id))
<a data-toggle="modal" data-target="#reconciledBillModal" class="btn btn-sm btn-rounded btn-danger" style="font-size: 12px; background-color:rgb(219 162 174)">{{ __('finance.delete_bill') }}</a>
@elseif($bill->payment_status == 1)
<a data-toggle="modal" data-target="#paidBillModal" class="btn btn-sm btn-rounded btn-danger" style="font-size: 12px; background-color:rgb(219 162 174)">{{ __('finance.delete_bill') }}</a>
@else
<button class="btn btn-sm btn-rounded btn-danger" onclick="remove('{{ $bill->id }}', '{{ $bill->bill_number }}')">{{ __('finance.delete_bill') }}</button>
@endif
@endif
@else
<span class="label label-danger"><a href="#" data-toggle="tooltip" rel="tooltip" data-placement="top" title="verify the bill via the received inventory bills button in the top menu"> <i class="fa fa-info-circle"></i></a>{{ __('payments.bill_not_yet_verified') }}</span>
@endif
</td>
</tr>
@php
$count ++;
$total += $bill->total_amount;
$balance += (is_null($bill->balance) ? $bill->total_amount : $bill->balance);
$amount_paid += (is_null($bill->balance) ? 0 : ((int)$bill->total_amount - (int)$bill->balance));
@endphp
@endforeach
</tbody>
<tr>
<td class="show_checkboxes" style="display: none;"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><strong>{{ __('payments.total') }}</strong></td>
<td>{{ ugandan_shillings($total) }}</td>
<td>{{ ugandan_shillings($amount_paid) }}</td>
<td>{{ ugandan_shillings($balance) }}</td>
<td></td>
</tr>
</table>
</div>
@if(Auth::user()->can('Payments-make-bulk-bill-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;">
{{ Form::open(['method'=>'post', 'route'=>'payments.bills_bulk_pay', 'id'=>'bills_bulk_pay_form'])}}
<div class='row'>
<div class="col-md-3">
<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_date', __('payments.payment_date')) }}
{{ Form::text('payment_date', '', ['class'=>'form-control compulsory', 'required', 'readonly', 'id'=>'bulk_payment_date']) }}
</div>
</div>
<input type="hidden" name="selected_bill_ids" id="selected_bill_ids">
<input type="hidden" name="total_amount_paid_off" value="0" id="total_amount_paid_off">
<div class="col-md-3">
<div class="form-group">
{{ Form::label('bank_account', __('payments.bank_account')) }}
{{ Form::select('bank_account', $bank_accounts, null, ['class'=>'form-control compulsory', 'required', 'id'=>'bulk_bank_account']) }}
</div>
</div>
<div class="col-md-2">
<div class="form-group">
{{ Form::label('account_balance', __('payments.account_balance')) }}
{{ Form::number('account_balance', 0, ['class'=>'form-control', 'readonly', 'id'=>'bulk_account_balance']) }}
</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" style='display: none; margin-top:23px;'>{{ __('payments.make_bulk_payment') }}</button>
</div>
</div>
</div>
{{ Form::close() }}
</div>
</div>
{{ Form::open(['method'=>'post','route' => 'payments.bills', 'id'=>'reload_bills_form']) }}
{{ Form::hidden('staff_member', $request->staff_member) }}
{{ Form::hidden('vendor', $request->vendor) }}
{{ Form::hidden('bill_status', $request->bill_status) }}
{{ Form::hidden('dates', $request->dates) }}
{{ Form::hidden('start_date', $request->start_date) }}
{{ Form::hidden('end_date', $request->end_date) }}
{{ Form::close() }}
<div class="modal" id="payment_modal" tabindex="-1" role="dialog" aria-labelledby="banking_modal_label" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<div class="row" style="padding: 10px;">
<div class="col-sm-12 text-center">
<h3 class="modal-title" id="banking_modal_label"><b>{{ __('finance.pay_bill') }}</b></h3>
</div>
</div>
</div>
<div class="modal-body">
<div class="row" style="padding: 10px;">
<div class="col-sm-6">
<div class="form-group">
<label>{{ __('finance.bank_account') }}</label>
<select name="bank_account" class="form-control" id="bank_account" onchange="get_acc_bal(this.value, 'current_account_balance')">
<option>{{ __('finance.select') }}</option>
@foreach($banks as $bank)
<option value="{{ $bank->id }}">{{ $bank->name }}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label>{{ __('finance.bill_total') }}</label>
<input name="bill_total" id="bill_total" type="number" readonly class="form-control">
</div>
<div class="form-group">
<label>{{ __('finance.bill_date') }}</label>
<input name="bill_due_date" id="bill_due_date" readonly class="form-control">
</div>
<div class="form-group">
<label>{{ __('finance.payment_memo') }}</label>
<textarea name="payment_memo" id="payment_memo" class="form-control" rows="5"></textarea>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>{{ __('finance.current_account_balance') }}</label>
<input name="current_account_balance" id="current_account_balance" type="number" readonly class="form-control">
</div>
<div class="form-group">
<label>{{ __('finance.amount_to_pay') }}</label>
<input name="amount_to_pay" id="amount_to_pay" type="number" class="form-control">
</div>
<div class="form-group">
<label>{{ __('finance.bill_balance') }}</label>
<input name="bill_balance" id="bill_balance" type="number" readonly class="form-control">
</div>
<div class="form-group">
<label>{{ __('finance.payment_by') }}</label>
<input name="payment_by_name" readonly value="{{ get_full_name(\Illuminate\Support\Facades\Auth::id(),'id', 'first_name', 'last_name', 'users') }}" class="form-control">
<input type="hidden" id="payment_by_id" value="{{ \Illuminate\Support\Facades\Auth::id() }}">
<input type="hidden" name="bill_id" id="bill_id">
</div>
<div class="form-group">
{{ Form::label('payment_date', __('finance.payment_date')) }}
<div class="input-group">
{{ Form::text('payment_date', '', ['class'=>'form-control compulsory', 'required', 'readonly', 'id'=>'payment_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">{{ __('finance.cancel') }}</button>
<button type="button" class="btn btn-success" id="confirm_payment">{{ __('finance.confirm') }}</button>
</div>
</div>
</div>
</div>
<div class="modal" id="update_payment_modal" tabindex="-1" role="dialog" aria-labelledby="banking_modal_label" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<div class="row" style="padding: 10px;">
<div class="col-sm-12 text-center">
<h3 class="modal-title" id="banking_modal_label"><b>{{ __('finance.update_bill_payment') }}</b></h3>
</div>
</div>
</div>
<div class="modal-body">
<div class="row" style="padding: 10px;">
<div class="col-sm-6">
<div class="form-group">
<label>{{ __('finance.bank_account') }}</label>
<select name="bank_account" class="form-control" id="_bank_account" onchange="get_acc_bal(this.value, '_current_account_balance')">
<option>{{ __('finance.select') }}</option>
@foreach($banks as $bank)
<option value="{{ $bank->id }}">{{ $bank->name }}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label>{{ __('finance.bill_total') }}</label>
<input name="bill_total" id="_bill_total" type="number" readonly class="form-control">
</div>
<div class="form-group">
<label>{{ __('finance.bill_date') }}</label>
<input name="bill_due_date" id="_bill_due_date" readonly class="form-control">
</div>
<div class="form-group">
<label>{{ __('finance.payment_memo') }}</label>
<textarea name="payment_memo" id="_payment_memo" class="form-control" rows="5"></textarea>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>{{ __('finance.current_account_balance') }}</label>
<input name="current_account_balance" id="_current_account_balance" type="number" readonly class="form-control">
</div>
<div class="form-group">
<label>{{ __('finance.amount_to_pay') }}</label>
<input name="amount_to_pay" id="_amount_to_pay" type="number" class="form-control">
</div>
<div class="form-group">
<label>{{ __('finance.bill_balance') }}</label>
<input name="bill_balance" id="_bill_balance" type="number" readonly class="form-control">
</div>
<div class="form-group">
<label>{{ __('finance.payment_by') }}</label>
<input name="payment_by_name" readonly value="{{ get_full_name(\Illuminate\Support\Facades\Auth::id(),'id', 'first_name', 'last_name', 'users') }}" class="form-control">
<input type="hidden" id="_payment_by_id" value="{{ \Illuminate\Support\Facades\Auth::id() }}">
<input type="hidden" name="bill_id" id="_bill_id">
</div>
<div class="form-group">
{{ Form::label('_payment_date', __('finance.payment_date')) }}
<div class="input-group">
{{ Form::text('_payment_date', '', ['class'=>'form-control compulsory', 'required', 'readonly', 'id'=>'_payment_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">{{ __('finance.cancel') }}</button>
<button type="button" class="btn btn-success" id="update_payment">{{ __('finance.confirm') }}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="reconciledBillModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h2><b>{{ __('payments.please_note') }}</b></h2>
</div>
<div class="modal-body">
<div class="row" style="padding: 10px;">
<div class="col-sm-12">
<h3>{{ __('payments.bill_already_reconciled_message') }}</h3>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">{{ __('payments.close') }}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="paidBillModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h2><b>{{ __('payments.please_note') }}</b></h2>
</div>
<div class="modal-body">
<div class="row" style="padding: 10px;">
<div class="col-sm-12">
<h3>{{ __('payments.bill_already_paid_message') }}</h3>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">{{ __('payments.close') }}</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>
var ticked_off_bills_array = [];
var is_payment_of_greater_expense_allowed = <?php echo is_payment_of_greater_expense_allowed(); ?>;
function show_bulk_pay_div() {
alert('Please Be Sure To Select The Bills That You Wish To Clear.')
$('#bulk_pay_div').show();
$('.show_checkboxes').show();
}
$('#bulk_bank_account').on('change', function() {
let payment_date = $('#bulk_payment_date').val();
let bank = this.value;console.log('Bank:'+bank+' date:'+payment_date);
if (payment_date !== "") {
$.ajax({
method: 'POST',
url: '/banking/get_current_account_balance_per_date/',
data: {
'bank': bank,
'date': payment_date
},
success: function(result) {
var record = JSON.parse(result);
if (record !== null) {
var acc_bal = record['account_balance'];
$('#bulk_account_balance').val(acc_bal);
$('#validate_bulk_pay').show();
} else {
alert('No Corresponding Account Balance To The Selected Account.')
$('#validate_bulk_pay').hide();
}
},
error: function(error) {
alert('Something Went Wrong, Please Contact Support.')
}
});
} else {
this.value = '';
alert('Please Select A Payment Date');
}
});
$('#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();
if (payment_date === "") {
alert('Please Select A Payment Date.')
} else if (bank_account === "") {
alert('Please Select A Bank Account.')
} else if (parseInt(amount_to_pay) > parseInt(account_balance)) {
alert('Account Balance Is Low')
} else {
if (ticked_off_bills_array.length !== 0) {
if (confirm("Are you sure ?")) {
$('#bills_bulk_pay_form').submit();
}
} else {
alert('Please Select The Bills 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 bill_balance = $('#bill_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(bill_balance);
let new_total_amount_paid_off = parseInt(total_amount_paid_off) + parseFloat(amount_paid_off);
if (this.checked) {
$('#bill_record_' + id).children('td, th').css('background-color', 'gold');
$('#bulk_amount_to_pay').val(new_amount_to_pay);
$('#total_amount_paid_off').val(new_total_amount_paid_off);
ticked_off_bills_array.push(id[0]);
} else {
$('#bill_record_' + id).children('td, th').css('background-color', 'white');
$('#bulk_amount_to_pay').val(parseInt(amount_to_pay) - parseInt(bill_balance));
$('#total_amount_paid_off').val(parseInt(total_amount_paid_off) - parseInt(amount_paid_off));
const index = ticked_off_bills_array.indexOf(id);
ticked_off_bills_array.splice(index, 1);
}
$('#selected_bill_ids').val(ticked_off_bills_array);
});
function show_payment_modal(id) {
$.ajax({
method: 'GET',
url: '/payments/get_bill_details/' + id,
data: {
'id': id
},
success: function(result) {
$('#bill_id').val(result['id']);
$('#bill_total').val(result['total_amount']);
$('#bill_due_date').val(result['bill_date']);
$('#bill_balance').val(result['balance']);
$('#payment_modal').modal('show');
},
error: function(error) {
alert('Something Went Wrong, Please Contact Support.')
}
});
}
function show_update_payment_modal(id) {
$.ajax({
method: 'GET',
url: '/payments/get_bill_details/' + id,
data: {
'id': id
},
success: function(result) {
$('#_bill_id').val(result['id']);
$('#_amount_to_pay').val(0);
$('#_payment_memo').val('');
$('#_payment_date').val('');
$('#_bill_total').val(result['balance']);
$('#_bill_due_date').val(result['bill_date']);
$('#_bill_balance').val(result['balance']);
$('#update_payment_modal').modal('show');
},
error: function(error) {
alert('Something Went Wrong, Please Contact Support.')
}
});
}
// ---------------------- recheck later -------------------------------------
$('#amount_to_pay').change(function() {
var amount_to_pay = this.value;
var bill_total = $('#bill_total').val();
var account_balance = $('#current_account_balance').val();
var bill_balance = bill_total - amount_to_pay;
if (bill_balance < 0) {
alert('Amount to pay appears to be more than the required bill amount.');
this.value = 0;
} else {
$('#bill_balance').val(bill_balance);
}
});
$('#_amount_to_pay').change(function() {
var amount_to_pay = this.value;
var bill_total = $('#_bill_total').val();
var account_balance = $('#_current_account_balance').val();
var bill_balance = bill_total - amount_to_pay;
if (bill_balance < 0) {
alert('Amount to pay appears to be more than the required bill amount.');
this.value = 0;
} else {
$('#_bill_balance').val(bill_balance);
}
});
$('#update_payment').click(function() {
var bill_id = $('#_bill_id').val();
var bill_balance = $('#_bill_balance').val();
var current_account_balance = $('#_current_account_balance').val();
var payment_date = $('#_payment_date').val();
var bank_account = $('#_bank_account').val();
var amount_to_pay = $('#_amount_to_pay').val();
var payment_memo = $('#_payment_memo').val();
var check = confirm('Are you sure you want to proceed with this payment ?');
if (current_account_balance <= 0) {
alert('Account Balance is Zero(0) UGX');
if (is_payment_of_greater_expense_allowed !== 1) {
return false;
}
} else if (parseInt(amount_to_pay) > current_account_balance) {
alert('Your Account Balance is low');
if (is_payment_of_greater_expense_allowed !== 1) {
return false;
}
}
$(this).prop("disabled", true);
$(this).html("Processing...");
if (check) {
$.ajax({
type: 'POST',
url: '/payments/store_bill_payment',
data: {
'bill_id': bill_id,
'bill_balance': bill_balance,
'payment_date': payment_date,
'bank_account': bank_account,
'amount_to_pay': amount_to_pay,
'payment_memo': payment_memo,
'current_account_balance': current_account_balance,
},
success: function(result) {
// console.log(result);
$('#reload_bills_form').submit();
},
error: function(error) {
console.log(error)
alert('Something Went Wrong, Please Contact Support.')
}
});
}
});
$('#confirm_payment').click(function() {
var bill_id = $('#bill_id').val();
var bill_balance = $('#bill_balance').val();
var current_account_balance = $('#current_account_balance').val();
var payment_date = $('#payment_date').val();
var bank_account = $('#bank_account').val();
var amount_to_pay = $('#amount_to_pay').val();
var payment_memo = $('#payment_memo').val();
var check = confirm('Are you sure you want to proceed with this payment ?');
if (current_account_balance <= 0) {
alert('Account Balance is Zero(0) UGX');
if (is_payment_of_greater_expense_allowed !== 1) {
return false;
}
} else if (parseInt(amount_to_pay) > current_account_balance) {
alert('Your Account Balance is low');
if (is_payment_of_greater_expense_allowed !== 1) {
return false;
}
}
$(this).prop("disabled", true);
$(this).html("Processing...");
if (check) {
$.ajax({
type: 'POST',
url: '/payments/store_bill_payment',
data: {
'bill_id': bill_id,
'bill_balance': bill_balance,
'payment_date': payment_date,
'bank_account': bank_account,
'amount_to_pay': amount_to_pay,
'payment_memo': payment_memo,
'current_account_balance': current_account_balance,
},
success: function(result) {
$('#reload_bills_form').submit();
},
error: function(error) {
console.log(error)
alert('Something Went Wrong, Please Contact Support.')
}
});
}
});
function remove(id, bill_number) {
var check = confirm('Are You Sure You Want To Delete This Bill ?');
if (check) {
$.ajax({
type: 'POST',
url: '/payments/delete_bill',
data: {
'bill_id': id
},
success: function(result) {
if (result != 'fail') {
$('#' + id).remove();
alert('Bill ' + bill_number + ' has been deleted successfully.');
$('#reload_bills_form').submit();
} else {
alert('failed to delete Bill ' + bill_number)
}
},
error: function(error) {
console.log(error)
alert('Something Went Wrong, Please Contact Support.')
}
});
}
}
$('#dates').change(function(e) {
if ($(this).val() === "custom_date") {
$("#eDate").hide();
$("#sDate").show();
} else if ($(this).val() === "custom_date_range") {
$("#sDate").show();
$("#eDate").show();
} else {
$("#eDate").hide();
$("#sDate").hide();
}
});
function get_acc_bal(bank_id, input_id) {
$.ajax({
method: 'POST',
url: '/banking/get_current_account_balance',
data: {
'bank_id': bank_id
},
success: function(response) {
var record = JSON.parse(response);
var acc_bal = record['account_balance'];
var amount = $('#deposit_amount').val();
$('#' + input_id).val(acc_bal);
$('#new_account_balance').val(acc_bal + parseInt(amount));
},
error: function(error) {
console.log(error);
}
});
}
function show(id) {
if (document.getElementById(id).style.display === 'none') {
document.getElementById(id).style.display = '';
}
}
function hide(id) {
document.getElementById(id).style.display = 'none';
}
</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 type="text/javascript">
jQuery('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script type="text/javascript">
jQuery('#start_date ,#deposit_date, #_payment_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
let min_days = <?php echo $back_date[0]; ?>;
var min_date = new Date();
min_date.setDate(min_date.getDate()-min_days);
$('#payment_date, #bulk_payment_date').datepicker({
autoclose: true,
todayHighlight: true,
endDate: new Date(),
startDate: min_date,
format: 'dd-mm-yyyy'
});
</script>
<script>
$('.table').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
"aoColumnDefs": [{
"aTargets": [2, 3],
"defaultContent": "",
}]
});
</script>
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script>
$('#staff_member, #vendor').select2({
placeholder: "-select-"
});
</script>
@endpush