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

{{ __('payments.edit_bill') }}

@include('expenses::payments.menu') @include('flash::message') @php $back_date = \Streamline\Models\HospitalInformation::first()->pluck('back_date'); @endphp
{{ Form::model($bill, ['method' => 'PATCH','route' => ['payments.update_bill', $bill->id]]) }}
{{ Form::select('vendor', $suppliers, $bill->vendor, ['class' => 'form-control', 'id'=>'vendor']) }} {{ __('payments.add_vendor') }}
{{ Form::label('start_date', __('finance.bill_date')) }}
{{ Form::text('bill_date', \Carbon\Carbon::parse($bill->bill_date)->format('d-m-Y'), ['class'=>'form-control required compulsory', 'readonly', 'id'=>'bill_date']) }}
{{ Form::label('end_date', __('payments.bill_due_date')) }}
{{ Form::text('bill_due_date', \Carbon\Carbon::parse($bill->bill_due_date)->format('d-m-Y'), ['class'=>'form-control required compulsory', 'readonly', 'id'=>'bill_due_date']) }}
{{ Form::label('bill_number', __('payments.bill_number')) }} {{ Form::text('bill_number', $bill->bill_number, ['class'=>'form-control required compulsory', 'id'=>'bill_number']) }}

@if(count($payments) > 0)

Payments


@php $total = 0; @endphp @foreach($payments as $item) @php $total += $item->amount; @endphp @endforeach
{{ __('payments.item') }} {{ __('payments.vendor') }} {{ __('payments.quantity') }} {{ __('payments.staff') }} {{ __('payments.date') }} {{ __('payments.unit_cost') }} {{ __('payments.amount') }}
@php $bill = \Streamline\Models\HospitalBill::find($item->bill_id); $items = explode(',', $bill->item_ids); $quantities = explode(',', $bill->item_quantities); @endphp @if($bill->bill_type == 'DRU') @for($x = 0; $x < count($items); $x++) {{ get_name($items[$x], 'id', 'name', 'drugs') }}
@endfor @elseif($bill->bill_type == 'SUN') @for($x = 0; $x < count($items); $x++) {{ get_name($items[$x], 'id', 'name', 'sundries') }}
@endfor @elseif($bill->bill_type == 'DEN') @for($x = 0; $x < count($items); $x++) {{ get_name($items[$x], 'id', 'name', 'dentals') }}
@endfor @elseif($bill->bill_type == 'RAD') @for($x = 0; $x < count($items); $x++) {{ get_name($items[$x], 'id', 'name', 'radiologies') }}
@endfor @elseif($bill->bill_type == 'LAB') @for($x = 0; $x < count($items); $x++) {{ get_name($items[$x], 'id', 'name', 'labs') }}
@endfor @elseif($bill->bill_type == 'GEN') @for($x = 0; $x < count($items); $x++) {{ get_name($items[$x], 'id', 'name', 'general_items') }}
@endfor @elseif($bill->bill_type == 'PAY') @for($x = 0; $x < count($items); $x++) {{ get_name($items[$x], 'id', 'name', 'payment_items') }}
@endfor @endif
{{ get_name($item->vendor, 'id', 'name', 'suppliers') }} {{ get_full_name($item->created_by, 'id', 'first_name', 'last_name', 'users') }} {{ streamline_date_time_short($item->created_at) }} @for($x = 0; $x < count($items); $x++) {{ $quantities[$x]." units" }}
@endfor
@if($bill->bill_type == 'DRU') @for($x = 0; $x < count($items); $x++) {{ ugandan_shillings(get_name($items[$x], 'id', 'cost_price', 'drugs')) }}
@endfor @elseif($bill->bill_type == 'SUN') @for($x = 0; $x < count($items); $x++) {{ ugandan_shillings(get_name($items[$x], 'id', 'cost_price', 'sundries')) }}
@endfor @elseif($bill->bill_type == 'DEN') @for($x = 0; $x < count($items); $x++) {{ ugandan_shillings(get_name($items[$x], 'id', 'cost_price', 'dentals')) }}
@endfor @elseif($bill->bill_type == 'RAD') @for($x = 0; $x < count($items); $x++) {{ ugandan_shillings(get_name($items[$x], 'id', 'cost_price', 'radiologies')) }}
@endfor @elseif($bill->bill_type == 'LAB') @for($x = 0; $x < count($items); $x++) {{ ugandan_shillings(get_name($items[$x], 'id', 'cost_price', 'labs')) }}
@endfor @elseif($bill->bill_type == 'GEN') @for($x = 0; $x < count($items); $x++) {{ ugandan_shillings(get_name($items[$x], 'id', 'unit_cost', 'general_items')) }}
@endfor @elseif($bill->bill_type == 'PAY') @for($x = 0; $x < count($items); $x++) {{ ugandan_shillings(get_name($items[$x], 'id', 'unit_cost', 'payment_items')) }}
@endfor @endif
{{ ugandan_shillings($item->amount) }}
{{ __('payments.total') }} {{ ugandan_shillings($total) }}
@endif
@php $items = explode(',', $bill->item_ids); $item_quantity = explode(',', $bill->item_quantities); $item_subtotals = explode(',', $bill->item_subtotals); $expense_accounts = explode(',', $bill->item_accounts); $payable_accounts = explode(',', $bill->payable_account); //$item = explode(',', $bill->item_ids); @endphp @for($i = 0; $i < count($items); $i++) @endfor
{{ __('payments.item') }}
{{ __('payments.quantity') }}
{{ __('payments.unit_cost') }}
{{ __('payments.amount') }}
{{ __('payments.expense_account') }}
{{ __('payments.payable_account') }}
{{ __('payments.action') }}
{{ Form::select('item_id[]', $payment_items, $items[$i], ['class' => 'form-control compulsory', 'id'=>"item_$i"]) }}
@php $option_items = ""; foreach ($option_items_array as $item){ $option_items .= ""; } $option_suppliers = ""; foreach ($option_suppliers_array as $item){ $option_suppliers .= ""; } $option_suppliers .= ""; @endphp
{{ Form::number('quantity[]', (is_null($item_quantity[$i]) ? 1 : $item_quantity[$i]), ['class' => 'form-control compulsory qty', 'id'=>"quantity_$i"]) }}
{{ Form::number('unit_cost[]', ($item_subtotals[$i] / $item_quantity[$i]), ['class' => 'form-control compulsory unit_cost', 'id'=>"unit_cost_$i"]) }}
{{ Form::number('amount[]', $item_subtotals[$i], ['class' => 'form-control amount', 'id'=>"amount_$i"]) }}
{{ Form::text('expense_acc_name[]', isset($chart_of_accounts[$expense_accounts[$i]]) ? $chart_of_accounts[$expense_accounts[$i]] : '', ['class' => 'form-control', 'id'=>"expense_acc_name_$i", 'readonly']) }}
{{ Form::text('payable_acc_name[]', $chart_of_accounts[$payable_accounts[$i]], ['class' => 'form-control', 'id'=>"payable_acc_name_$i", 'readonly']) }}
@if($i == 0) @else @endif


{{ Form::close() }}
@endsection @push('scripts') @endpush