Преглед изворни кода

Merge branch 'cleanup' of https://rav.triplestart.com/tigerphp/stagfe2 into cleanup

root пре 1 година
родитељ
комит
c28eddef92

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

@@ -806,9 +806,12 @@ class AdminController extends Controller
         }
 
 
+        //Query distinct clients who have points that contain specific substrings in the point.data
+
         $qry = "
         SELECT
-        DISTINCT p.client_id,
+        DISTINCT ON (p.client_id)
+        p.client_id,
         p.id,
         p.uid,
         c.uid as client_uid,
@@ -830,26 +833,30 @@ class AdminController extends Controller
         LEFT JOIN pro mcp on mcp.id = c.mcp_pro_id
         LEFT JOIN client_primary_coverage cover on cover.client_id = c.id
         ";
+        
 
         if($searchArrayStrings){
-            $qry = $qry . "WHERE lower(p.data) ILIKE any (array[".$searchArrayStrings."])";
+            $qry = $qry . " WHERE lower(p.data) ILIKE any (array[".$searchArrayStrings."])";
         }
+        $qry = $qry . " ORDER BY p.client_id DESC, p.created_at DESC";
 
+        $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>