Samson Mutunga 1 ano atrás
pai
commit
5a4d8e2347

+ 16 - 14
app/Http/Controllers/AdminController.php

@@ -835,21 +835,23 @@ class AdminController extends Controller
             $qry = $qry . "WHERE lower(p.data) ILIKE any (array[".$searchArrayStrings."])";
         }
 
+        $records = null;
 
-        $records = DB::select($qry);
-
-        $page = $request->get('page', 1);
-        $size = 20;
-        $collect = collect($records);
-
-        $records = new LengthAwarePaginator(
-            $collect->forPage($page, $size),
-            $collect->count(),
-            $size,
-            $page
-          );
-
-        $records->setPath(route('admin.patients-notes-points-filter'));
+        if($searchArrayStrings){
+            $records = DB::select($qry);
+            $page = $request->get('page', 1);
+            $size = 20;
+            $collect = collect($records);
+            $records = new LengthAwarePaginator(
+                $collect->forPage($page, $size),
+                $collect->count(),
+                $size,
+                $page
+            );
+            $records->setPath(route('admin.patients-notes-points-filter'));
+        }
+
+        
 
         return view('app.admin.patients-notes-points-filter', compact('records', 'filters'));
     }

+ 1 - 1
resources/views/app/admin/patients-notes-points-filter-form.blade.php

@@ -38,7 +38,7 @@
 		<div class="">
 			<label>&nbsp;</label>
 			<div class=" d-flex">
-				<button type="button" v-on:click.prevent="doSubmit()" class="btn btn-primary btn-sm mr-2"><i class="fas fa-filter"></i> Filter</button>
+				<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('admin.patients-notes-points-filter')}}')" class="btn btn-link btn-sm text-danger">Clear</a>
 			</div>
 		</div>

+ 53 - 47
resources/views/app/admin/patients-notes-points-filter.blade.php

@@ -13,56 +13,62 @@
 		<div class="p-3">
 			@include('app.admin.patients-notes-points-filter-form')
 		</div>
-		<table class="table table-striped p-0 m-0 table-sm border-top border-bottom ">
-			<thead class="bg-light">
-				<tr>
-					<th class="border-0">Chart #</th>
-					<th class="border-0">Patient</th>
-					<th class="border-0">Cell #</th>
-					<th class="border-0">Phone #</th>
-					<th class="border-0">Email Address</th>
-					<th class="border-0">DOB</th>
-					<th class="border-0">MCP</th>
-					<th class="border-0">Last Visit Date</th>
-					<th class="border-0">Cover</th>
-				</tr>
-			</thead>
-			<tbody>
-				@foreach($records as $record)
-				<tr>
-					<td>
-						<a href="{{route('patients.view.dashboard', $record->client_uid)}}">
-							{{$record->chart_number}}
-						</a>
-					</td>
-					<td>
-						<a href="{{route('patients.view.settings', $record->client_uid)}}">
-							{{$record->patient_name}}
-						</a>
-					</td>
-					<td>{{ $record->cell_number }}</td>
-					<td>{{ $record->phone_home ?? $record->phone_work ?? $record->phone_mobile }}</td>
-					<td>{{ $record->email_address }}</td>
-					<td>{{ friendly_date($record->dob) }}</td>
-					<td>{{ $record->mcp_name }}</td>
-					<td>{{ friendly_date($record->last_visit_date) }}</td>
-					<td>{{ $record->cover }}</td>
-				</tr>
-				@endforeach
+		@if($records)
+			<table class="table table-striped p-0 m-0 table-sm border-top border-bottom ">
+				<thead class="bg-light">
+					<tr>
+						<th class="border-0">Chart #</th>
+						<th class="border-0">Patient</th>
+						<th class="border-0">Cell #</th>
+						<th class="border-0">Phone #</th>
+						<th class="border-0">Email Address</th>
+						<th class="border-0">DOB</th>
+						<th class="border-0">MCP</th>
+						<th class="border-0">Last Visit Date</th>
+						<th class="border-0">Cover</th>
+					</tr>
+				</thead>
+				<tbody>
+					@foreach($records as $record)
+					<tr>
+						<td>
+							<a href="{{route('patients.view.dashboard', $record->client_uid)}}">
+								{{$record->chart_number}}
+							</a>
+						</td>
+						<td>
+							<a href="{{route('patients.view.settings', $record->client_uid)}}">
+								{{$record->patient_name}}
+							</a>
+						</td>
+						<td>{{ $record->cell_number }}</td>
+						<td>{{ $record->phone_home ?? $record->phone_work ?? $record->phone_mobile }}</td>
+						<td>{{ $record->email_address }}</td>
+						<td>{{ friendly_date($record->dob) }}</td>
+						<td>{{ $record->mcp_name }}</td>
+						<td>{{ friendly_date($record->last_visit_date) }}</td>
+						<td>{{ $record->cover }}</td>
+					</tr>
+					@endforeach
 
-				@if(count($records) === 0)
-				<tr>
-					<td colspan="8">No records found!</td>
-				</tr>
-				@endif
-			</tbody>
+					@if(count($records) === 0)
+					<tr>
+						<td colspan="8">No records found!</td>
+					</tr>
+					@endif
+				</tbody>
 
-		</table>
+			</table>
+		@endif
 	</div>
-	<div class="p-3">
-		{{$records->withQueryString()->links()}}
-	</div>
-
+	@if($records)
+		<div class="p-3">
+			{{$records->withQueryString()->links()}}
+		</div>
+	@endif
+	@if(!$records)
+		<small class="text-info">Enter search string(s) in the above input to start filtering!</small>
+	@endif
 </div>
 </div>
 </div>