@extends('layouts.main') @push('styles') @endpush @section('content')

{{ __('finance.bills') }}

@include('expenses::payments.menu') @include('flash::message')
{{ Form::open(['method'=>'post','route' => 'payments.bills']) }}
{{ Form::submit('Submit', ['class'=>'btn btn-success btn-rounded btn-block pull-right']) }}
{{ Form::close() }}

{{ $display }}



@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) @php $items = explode(',', $bill->item_ids); $quantities = explode(',', $bill->item_quantities); $subtotals = explode(',', $bill->item_subtotals); @endphp @php $_amount_paid = (int)$bill->total_amount - (!is_null($bill->balance) ? (int)$bill->balance : (int)$bill->total_amount) ; @endphp @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
# {{ __('finance.vendor') }} {{ __('finance.bill_number') }} {{ __('finance.bill_date') }} {{ __('finance.bill_due_date') }} {{ __('finance.bill_age') }} {{ __('finance.memo') }} {{ __('finance.payable_account') }} {{ __('finance.items') }} {{ __('finance.item_quantities') }} {{ __('finance.item_amounts') }} {{ __('finance.bill_total') }} {{ __('finance.amount_paid') }} {{ __('finance.balance') }} {{ __('finance.action') }}
{{ ($count + 1)."." }} {{ get_name($bill->vendor, 'id', 'name', 'suppliers') }} {{ $bill->bill_number }} {{ streamline_date($bill->bill_date) }} {{ isset($bill->bill_due_date) ? streamline_date($bill->bill_due_date) : "" }} {{ getDaysTillNow($bill->bill_date) }} {{ $bill->bill_memo }} @php $payable_accounts = explode(',', $bill->payable_account); @endphp @foreach ($payable_accounts as $payable_account) {{ get_name($payable_account, 'id', 'name', 'chart_of_accounts') }}
@endforeach
@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' ) . "
" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!} @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' ) . ",
" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!} @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' ) . ",
" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!} @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' ) . ",
" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!} @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' ) . ",
" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!} @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' ) . ",
" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!} @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' ) . ",
" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!} @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' ) . ",
" ; @endphp @endfor {!! read_more($items_string, 'short_items' . $bill->bill_number, 'long_items' . $bill->bill_number) !!} @endif
@php $quantities_string = ""; @endphp @for($x = 0; $x < count($quantities); $x++) @php $quantities_string .=($quantities[$x]==1) ? $quantities[$x]." unit": $quantities[$x]." units" . "
" ; @endphp @endfor {!! read_more($quantities_string, 'short_quantities' . $bill->bill_number, 'long_quantities' . $bill->bill_number) !!}
@php $subtotals_string = ""; @endphp @for($x = 0; $x < count($subtotals); $x++) @php $subtotals_string .=ugandan_shillings_with_decimals($subtotals[$x]) . "
" ; @endphp @endfor {!! read_more($subtotals_string, 'short_subtotals' . $bill->bill_number, 'long_subtotals' . $bill->bill_number) !!}
{{ ugandan_shillings_with_decimals($bill->total_amount) }} {{ ugandan_shillings_with_decimals($_amount_paid) }} {{ ugandan_shillings_with_decimals(is_null($bill->balance) ? $bill->total_amount : $bill->balance) }} @if ($bill->bill_memo != "UN-VERIFIED AUTO CREATED STRE@MLINE INVENTORY BILL") @if(is_null($bill->balance)) @if( Auth::user()->can('pay-hospital-bills') ) @endif @elseif($bill->balance > 0) @if( Auth::user()->can('pay-hospital-bills') ) @endif {{ __('finance.view_payment_vouchers') }} @elseif($bill->balance == 0) {{ __('finance.view_payment_vouchers') }} @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)) {{ __('payments.edit_bill') }} @elseif($bill->payment_status == 1) {{ __('payments.edit_bill') }} @else {{ __('payments.edit_bill') }} @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)) {{ __('finance.delete_bill') }} @elseif($bill->payment_status == 1) {{ __('finance.delete_bill') }} @else @endif @endif @else {{ __('payments.bill_not_yet_verified') }} @endif
{{ __('payments.total') }} {{ ugandan_shillings($total) }} {{ ugandan_shillings($amount_paid) }} {{ ugandan_shillings($balance) }}
@if(Auth::user()->can('Payments-make-bulk-bill-payments'))

@endif
{{ 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() }} @endsection @push('scripts') @endpush