Samson Mutunga 3 år sedan
förälder
incheckning
0aa87d9f03

+ 24 - 0
app/Http/Controllers/DnaController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Models\Appointment;
 use App\Models\BDTDevice;
+use App\Models\Bill;
 use App\Models\CareMonth;
 use App\Models\Client;
 use App\Models\ClientBDTDevice;
@@ -109,6 +110,29 @@ class DnaController extends Controller
         return view('app.dna.care-months', compact('careMonths', 'filters'));
     }
 
+    public function financialTransactions(Request $request){
+        $filters = $request->all();
+        $financialTransactions = Bill::paginate(20);
+        return view('app.dna.financial-transactions', compact('financialTransactions', 'filters'));
+    }
+    public function myBills(Request $request){
+        $filters = $request->all();
+        $bills = Bill::where('na_pro_id', $this->performer->pro->id);
+        $this->filterMultiQuery($request, $bills, 'created_at', 'date_category', 'date_value_1', 'date_value_2');
+        $this->filterMultiQuery($request, $bills, 'na_expected_payment_amount', 'amount_category', 'amount_value_1', 'amount_value_2');
+        
+        $status = $request->get('status');
+        if($status){
+            if($status === 'VERIFIED') $bills = $bills->where('is_verified', true);
+            if($status === 'ACTIVE') $bills = $bills->where('is_cancelled', false);
+            if($status === 'CANCELLED') $bills = $bills->where('is_cancelled', true);
+            if($status === 'SUBMITTED') $bills = $bills->where('is_submitted', true);
+        }
+        
+        $bills = $bills->orderBy('created_at', 'DESC')->paginate(20);
+        return view('app.dna.my-bills', compact('bills', 'filters'));
+    }
+
     public function bills(Request $request)
     {
         $data = [];

+ 50 - 0
resources/views/app/dna/financial-transactions.blade.php

@@ -0,0 +1,50 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-calendar-alt"></i>
+                Financial Transactions
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <div class="p-3">
+                <!-- Filter -->
+            </div>
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                    <th class="px-3 border-0">Date</th>
+                    <th class="px-3 border-0">Type</th>
+                    <th class="px-3 border-0">Chart</th>
+                    <th class="px-3 border-0">Context</th>
+                    <th class="px-3 border-0">Amount</th>
+                    <th class="px-3 border-0">Balance</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($financialTransactions as $financialTransaction)
+                    <tr>
+                        
+                    </tr>
+                    @endforeach
+
+                    @if(count($financialTransactions) === 0)
+                    <tr>
+                        <td colspan="9">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $financialTransactions->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 79 - 0
resources/views/app/dna/my-bills.blade.php

@@ -0,0 +1,79 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-calendar-alt"></i>
+                My Bills
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <div class="p-3">
+                @include('app.dna.my_bills_filters')
+            </div>
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                        <th class="px-3 border-0">Date</th>
+                        <th class="px-3 border-0">Patient</th>
+                        <th class="px-3 border-0">Service</th>
+                        <th class="px-3 border-0">Amount</th>
+                        <th class="px-3 border-0">Submitted</th>
+                        <th class="px-3 border-0">Verified</th>
+                        <th class="px-3 border-0">Cancelled</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($bills as $bill)
+                    <tr>
+                        <td>{{ friendly_date($bill->created_at) }}</td>
+                        <td>
+                            <a native target="_blank" href="{{route('patients.view.dashboard', $bill->client)}}">
+                                {{$bill->client->displayName()}}
+                            </a>
+                        </td>
+                        <td>{{ $bill->bill_service_type }}</td>
+                        <td>{{ $bill->na_expected_payment_amount ? '$'.$bill->na_expected_payment_amount : '' }}</td>
+                        <td>
+                            @if($bill->is_submitted)
+                            <span>YES</span>
+                            @else
+                            <span>NO</span>
+                            @endif
+                        </td>
+                        <td>
+                            @if($bill->is_verified)
+                            <span>YES</span>
+                            @else
+                            <span>NO</span>
+                            @endif
+                        </td>
+                        <td>
+                            @if($bill->is_cancelled)
+                            <span>YES</span>
+                            @else
+                            <span>NO</span>
+                            @endif
+                        </td>
+                    </tr>
+                    @endforeach
+
+                    @if(count($bills) === 0)
+                    <tr>
+                        <td colspan="9">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $bills->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 135 - 0
resources/views/app/dna/my_bills_filters.blade.php

@@ -0,0 +1,135 @@
+<style>
+	#dna-my-bills-filters label {
+		font-weight: bold;
+	}
+
+	#dna-my-bills-filters .mw-100px {
+		min-width: 100px;
+	}
+	.filter-container{
+		display: flex;
+		align-items: flex-start;
+		flex-wrap: wrap;
+	}
+	.filter-container >div {
+		width: 165px;
+	}
+	.filter-container >div:not(:last-child) {
+		margin-right: 15px;
+	}
+</style>
+<form id="dna-my-bills-filters" method="GET" action="{{ route('dna.myBills') }}" class="filter-container" v-cloak>
+	   <!-- DATE -->
+	<div class="">
+		<div class="form-group">
+			<label>Date:</label>
+			<select name="date_category" class="form-control input-sm" v-model="filters.date_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+			<div v-show="filters.date_category" class="mt-2">
+				<div>
+					<input  name="date_value_1" v-model="filters.date_value_1" type="date" class="form-control input-sm"/>
+				</div>
+				<div v-show="filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN'" class="mt-2">
+					<input name="date_value_2" v-model="filters.date_value_2" type="date" class="form-control input-sm"/>
+				</div>
+			</div>
+		</div>
+	</div>
+	<div class="">
+		<div class="form-group">
+			<label>Amount:</label>
+			<select name="amount_category" class="form-control input-sm" v-model="filters.amount_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+			<div v-show="filters.amount_category" class="mt-2">
+				<div>
+					<input  name="amount_value_1" v-model="filters.amount_value_1" type="date" class="form-control input-sm"/>
+				</div>
+				<div v-show="filters.amount_category === 'BETWEEN' || filters.amount_category === 'NOT_BETWEEN'" class="mt-2">
+					<input name="amount_value_2" v-model="filters.amount_value_2" type="date" class="form-control input-sm"/>
+				</div>
+			</div>
+		</div>
+	</div>
+	<!-- STATUS -->
+	<div class="">
+		<div class="form-group">
+			<label>Status:</label>
+			<select name="status" class="form-control input-sm" v-model="filters.status">
+				<option value="">All</option>
+				<option value="ACTIVE">ACTIVE</option>
+				<option value="SUBMITTED">SUBMITTED</option>
+				<option value="CANCELLED">CANCELLED</option>
+				<option value="VERIFIED">VERIFIED</option>
+			</select>
+		</div>
+	</div>
+
+	<div class="">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<div class="d-flex">
+				<button type="submit" v-on:click.prevent="doSubmit()" class="btn btn-primary btn-sm mr-2"><i class="fas fa-filter"></i> Filter</button>
+				<a href="#" v-on:click.prevent="fastLoad('{{route('dna.myBills')}}')" class="btn btn-link btn-sm text-danger">Clear Filters</a>
+			</div>
+		</div>
+	</div>
+</form>
+
+<?php
+$loadedFilters = $filters;
+$allFilterKeys = [
+	'date_category',
+	'date_value_1',
+	'date_value_2',
+	'amount_category',
+	'amount_value_1',
+	'amount_value_2',
+	'status'
+];
+for ($i=0; $i < count($allFilterKeys); $i++) {
+	if (!isset($loadedFilters[$allFilterKeys[$i]]) || !$loadedFilters[$allFilterKeys[$i]]) {
+		$loadedFilters[$allFilterKeys[$i]] = '';
+	}
+}
+?>
+
+<script>
+	(function() {
+		function init() {
+			window.apapp = new Vue({
+				el: '#dna-my-bills-filters',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: <?= json_encode($loadedFilters) ?>
+				},
+				methods: {
+					doSubmit: function() {
+						fastLoad('{{ route("dna.myBills") }}?' + $('#dna-my-bills-filters').serialize());
+						return false;
+					},
+					init: function() {
+
+					}
+				},
+				mounted: function() {
+					this.init();
+				},
+			});
+
+
+		}
+		addMCInitializer('dna-my-bills-filters', init, '#dna-my-bills-filters');
+	})();
+</script>

+ 2 - 0
resources/views/layouts/template.blade.php

@@ -215,6 +215,8 @@
                             <a class="dropdown-item" href="{{ route('dna.encounters') }}">Encounters</a>
                             <a class="dropdown-item" href="{{ route('dna.appointments') }}">Appointments</a>
                             <a class="dropdown-item" href="{{ route('dna.careMonths') }}">Care Months</a>
+                            <a class="dropdown-item" href="{{ route('dna.financialTransactions') }}">Financial Transactions</a>
+                            <a class="dropdown-item" href="{{ route('dna.myBills') }}">My Bills</a>
 
                         @endif
 

+ 2 - 0
routes/web.php

@@ -111,6 +111,8 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('notes', 'DnaController@notes')->name('notes');
         Route::get('appointments', 'DnaController@appointments')->name('appointments');
         Route::get('care-months', 'DnaController@careMonths')->name('careMonths');
+        Route::get('financial-transactions', 'DnaController@financialTransactions')->name('financialTransactions');
+        Route::get('my-bills', 'DnaController@myBills')->name('myBills');
 
         Route::get('bills', 'DnaController@bills')->name('bills');
         Route::get('erx-and-orders', 'DnaController@erx_and_orders')->name('erx_and_orders');