Samson Mutunga 3 年 前
コミット
88de1e3e01

+ 12 - 2
app/Http/Controllers/PracticeManagementController.php

@@ -299,8 +299,18 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
             default:
                 break;
         }
-        $notes = $query->orderBy('created_at', 'desc')->get();
-        return view('app.practice-management.notes', compact('notes', 'filter'));
+
+        $filters = $request->all();
+
+        $this->filterMultiQuery($request, $query, 'created_at', 'created_at_category', 'created_at_value_1', 'created_at_value_2');
+        $this->filterMultiQuery($request, $query, 'effective_time', 'effective_date_category', 'effective_date_value_1', 'effective_date_value_2');
+       
+        
+
+        $notes = $query->orderBy('created_at', 'desc')->paginate(30);
+        $allProsWithNotesIDs = Note::pluck('hcp_pro_id')->toArray();
+         $allProsWithNotes = Pro::whereIn('id', $allProsWithNotesIDs)->get();
+        return view('app.practice-management.notes', compact('notes', 'filters', 'filter','allProsWithNotes'));
     }
 
     public function dnaNotesPendingMcpSign(Request $request)

+ 34 - 22
resources/views/app/practice-management/notes.blade.php

@@ -2,33 +2,42 @@
 
 @section('content')
 
-    <div class="p-3 mcp-theme-1">
+<div class="p-3 mcp-theme-1">
     <div class="card">
 
-        <div class="card-header px-2 py-1 d-flex align-items-center">
-            <strong class="mr-4">
-                <i class="fas fa-user"></i>
-                Notes
-            </strong>
-            <select class="ml-auto max-width-300px form-control form-control-sm" onchange="fastLoad('/practice-management/notes/' + this.value, true, false, false)">
-                <option value="" {{ $filter === '' ? 'selected' : '' }}>All notes</option>
-                <option value="not-yet-signed" {{ $filter === 'not-yet-signed' ? 'selected' : '' }}>Notes not yet signed</option>
-                <option value="not-yet-signed-but-ally-signed" {{ $filter === 'not-yet-signed-but-ally-signed' ? 'selected' : '' }}>Notes not yet signed (but ally signed)</option>
-            </select>
+        <div class="card-header p-0">
+            <div class="d-flex align-items-center border-bottom px-2 py-1">
+                <strong class="mr-4">
+                    <i class="fas fa-notes-medical"></i>
+                    Notes
+                </strong>
+                <div class="ml-auto">
+                    <div class="d-flex align-items-center">
+                        <select class="max-width-300px form-control form-control-sm" onchange="fastLoad('/practice-management/notes/' + this.value, true, false, false)">
+                            <option value="" {{ $filter === '' ? 'selected' : '' }}>All notes</option>
+                            <option value="not-yet-signed" {{ $filter === 'not-yet-signed' ? 'selected' : '' }}>Notes not yet signed</option>
+                            <option value="not-yet-signed-but-ally-signed" {{ $filter === 'not-yet-signed-but-ally-signed' ? 'selected' : '' }}>Notes not yet signed (but ally signed)</option>
+                        </select>
+                    </div>
+                </div>
+            </div>
+            <div class="px-2 py-1">
+                @include('app.practice-management.notes_filters')
+            </div>
         </div>
         <div class="card-body p-0">
 
             <table class="table table-sm table-striped p-0 m-0">
                 <thead class="bg-light">
-                <tr>
-                    <th class="px-3 border-0">Created</th>
-                    <th class="border-0">Effective Date</th>
-                    <th class="border-0">Patient</th>
-                    <th class="border-0 w-50">Content</th>
-                </tr>
+                    <tr>
+                        <th class="px-3 border-0">Created</th>
+                        <th class="border-0">Effective Date</th>
+                        <th class="border-0">Patient</th>
+                        <th class="border-0 w-50">Content</th>
+                    </tr>
                 </thead>
                 <tbody>
-                @foreach ($notes as $note)
+                    @foreach ($notes as $note)
                     <tr class="{{ $note->is_cancelled ? 'cancelled-item always-clickable' : '' }}">
                         <td class="px-3">
                             {{ friendly_date_time($note->created_at, true) }}
@@ -45,18 +54,21 @@
                         <td class="">
                             <?php
                             $textContent = strip_tags($note->free_text_html);
-                            if(strlen($textContent) > 200) {
+                            if (strlen($textContent) > 200) {
                                 $textContent = substr($textContent, 0, 200) . '…';
                             }
                             ?>
                             {!! empty($textContent) ? '-' : $textContent !!}
                         </td>
                     </tr>
-                @endforeach
+                    @endforeach
                 </tbody>
             </table>
+            <div class="mt-3">
+                {{ $notes->appends(request()->input())->links() }}
+            </div>
         </div>
     </div>
-    </div>
+</div>
 
-@endsection
+@endsection

+ 138 - 0
resources/views/app/practice-management/notes_filters.blade.php

@@ -0,0 +1,138 @@
+<link href="/select2/select2.min.css" rel="stylesheet" />
+<script src="/select2/select2.min.js"></script>
+<style>
+	#notes-filters label {
+		font-weight: bold;
+	}
+
+	#notes-filters .mw-100px {
+		min-width: 100px;
+	}
+
+	.filter-container {
+		display: flex;
+		align-items: flex-start;
+		flex-wrap: wrap;
+	}
+
+	.filter-container>div {
+		width: 200px;
+	}
+
+	.filter-container>div:not(:last-child) {
+		margin-right: 15px;
+	}
+	.select2-container {
+		width: 100% !important;
+	}
+</style>
+<form id="notes-filters" method="GET" action="{{ route('practice-management.notes') }}" class="filter-container" v-cloak>
+	<!-- DATE -->
+	<div>
+		<div class="form-group">
+			<label>Created At:</label>
+			<select name="created_at_category" class="form-control input-sm" v-model="filters.created_at_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.created_at_category" class="mt-2">
+				<div>
+					<input name="created_at_value_1" v-model="filters.created_at_value_1" type="date" class="form-control input-sm" />
+				</div>
+				<div v-show="filters.created_at_category === 'BETWEEN' || filters.created_at_category === 'NOT_BETWEEN'" class="mt-2">
+					<input name="created_at_value_2" v-model="filters.created_at_value_2" type="date" class="form-control input-sm" />
+				</div>
+			</div>
+		</div>
+	</div>
+	<div>
+		<div class="form-group">
+			<label>Effective Date:</label>
+			<select name="effective_date_category" class="form-control input-sm" v-model="filters.effective_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.effective_date_category" class="mt-2">
+				<div>
+					<input name="effective_date_value_1" v-model="filters.effective_date_value_1" type="date" class="form-control input-sm" />
+				</div>
+				<div v-show="filters.effective_date_category === 'BETWEEN' || filters.effective_date_category === 'NOT_BETWEEN'" class="mt-2">
+					<input name="effective_date_value_2" v-model="filters.effective_date_value_2" type="date" class="form-control input-sm" />
+				</div>
+			</div>
+		</div>
+	</div>
+	<div>
+		<div class="form-group">
+			<label>Pro(s):</label>
+			<select multiple class="form-control form-control-sm mr-2" name="pros" v-model="filters.pros">
+				<option value="">All Pros</option>
+				@foreach($allProsWithNotes as $notePro)
+				<option value="{{ $notePro->id }}">{{ $notePro->displayName() }}</option>
+				@endforeach
+			</select>
+		</div>
+	</div>
+
+
+	<div>
+		<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('practice-management.notes')}}')" class="btn btn-link btn-sm text-danger">Clear Filters</a>
+			</div>
+		</div>
+	</div>
+</form>
+<?php
+$loadedFilters = $filters;
+$allFilterKeys = [
+	'created_at_category',
+	'created_at_value_1',
+	'created_at_value_2',
+	'effective_date_category',
+	'effective_date_value_1',
+	'effective_date_value_2',
+	'pros'
+];
+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: '#notes-filters',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: <?= json_encode($loadedFilters) ?>
+				},
+				methods: {
+					doSubmit: function() {
+						fastLoad('{{ route("practice-management.notes") }}?' + $('#notes-filters').serialize());
+						return false;
+					},
+					init: function() {
+						$('select[multiple]').select2();
+					}
+				},
+				mounted: function() {
+					this.init();
+				},
+			});
+		}
+		addMCInitializer('notes-filters', init, '#notes-filters');
+	})();
+</script>

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

@@ -165,6 +165,7 @@
                             <a class="dropdown-item" href="{{ route('practice-management.client-ccm-rm-status') }}">Client RM Status</a>
                             <a class="dropdown-item" href="{{ route('practice-management.rmActionReport') }}">RM Action Report</a>
                             <a class="dropdown-item" href="{{ route('practice-management.hcp-note-activity') }}">HCP Note Activity</a>
+                            <a class="dropdown-item" href="{{ route('practice-management.notes') }}">Notes</a>
                             
                             @if($pro->id == '1' || $pro->id == '16')
                                 <a class="dropdown-item" href="{{ route('practice-management.treatmentServiceUtil') }}">Treatment Service Util.</a>