Samson Mutunga 2 年之前
父節點
當前提交
3dbeb6b768

+ 32 - 1
app/Http/Controllers/AdminController.php

@@ -28,9 +28,10 @@ use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\File;
 use App\Models\Bill;
 use App\Models\ClientSMS;
-
+use App\Models\Point;
 use Illuminate\Support\Facades\Http;
 use PDF;
+use Illuminate\Support\Facades\Schema;
 
 class AdminController extends Controller
 {
@@ -712,4 +713,34 @@ class AdminController extends Controller
         return view('app.admin.patients_missing_default_settings', compact('patients', 'filters'));
     }
 
+    public function points(Request $request){
+        $filters = $request->all();
+        $points = Point::query();
+        $points = $points->where('is_removed','!=', true);
+
+        if ($request->input('name')) {
+            $name = trim($request->input('name'));
+            if ($name) {
+                $points = $points->whereHas('client', function ($q) use ($name) {
+                    $q->where('name_first', 'ILIKE', '%' . $name . '%')
+                        ->orWhere('name_last', 'ILIKE', '%' . $name . '%');
+                });
+            }
+        }
+
+        if ($request->input('mcp')) {
+            $mcp = Pro::where('uid', trim($request->input('mcp')))->first();
+            if ($mcp) {
+                $points = $points->where('created_by_pro_id', $mcp->id);
+            }
+        }
+
+        $points = $points->paginate(30);
+
+        $_point = new Point;
+        $tableName = $_point->getTable();
+        $columns = Schema::getColumnListing($tableName);
+        return view('app.admin.points.index', compact('points', 'filters', 'columns'));
+    }
+
 }

+ 1 - 0
app/Models/Point.php

@@ -555,4 +555,5 @@ class Point extends Model
 
         return $point;
     }
+    
 }

+ 95 - 0
resources/views/app/admin/points/filters.blade.php

@@ -0,0 +1,95 @@
+<style>
+    #admin-points-filters label {
+        font-weight: bold;
+    }
+
+    #admin-points-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: 10px;
+    }
+
+    .sm-section {
+        width: 125px !important;
+        margin-bottom: 10px;
+    }
+</style>
+<form id="admin-points-filters" method="GET" action="{{ route('admin.points') }}" class="filter-container" v-cloak>
+    <div class="sm-section">
+        <div class="">
+            <label>Name:</label>
+            <input name="name" class="form-control input-sm" v-model="filters.name">
+        </div>
+    </div>
+
+    <div class="sm-section">
+        <div class="mcp-filter-container">
+            <label>MCP:</label>
+        </div>
+    </div>
+
+    <div>
+        <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>
+                <a href="#" v-on:click.prevent="fastLoad('{{route('admin.points')}}')" class="btn btn-link btn-sm text-danger">Clear</a>
+            </div>
+        </div>
+    </div>
+</form>
+
+<?php
+$loadedFilters = $filters;
+$allFilterKeys = [
+    'name',
+];
+for ($i = 0; $i < count($allFilterKeys); $i++) {
+    if (!isset($loadedFilters[$allFilterKeys[$i]]) || !$loadedFilters[$allFilterKeys[$i]]) {
+        $loadedFilters[$allFilterKeys[$i]] = '';
+    }
+}
+?>
+<script>
+    (function() {
+        function init() {
+            new Vue({
+                el: '#admin-points-filters',
+                delimiters: ['@{{', '}}'],
+                data: {
+                    filters: <?= json_encode($loadedFilters) ?>
+                },
+                methods: {
+                    init: function() {
+
+                    },
+                    doSubmit: function() {
+                        fastLoad("{{ route('admin.points') }}?" + $('#admin-points-filters').serialize());
+                        return false;
+                    }
+                },
+                mounted: function() {
+                    console.log(this.filters);
+                    this.init();
+                    let mcpSelect = $('<select name="mcp" class="form-control min-width-unset input-sm" provider-search data-pro-uid="{{request()->input('mcp')}}" provider-type="hcp"><option value="">--select--</option></select>').appendTo('.mcp-filter-container');
+                    initProSuggest();
+                },
+            });
+
+
+        }
+        addMCInitializer('admin-points-filters', init, '#admin-points-filters');
+    })();
+</script>

+ 20 - 0
resources/views/app/admin/points/index.blade.php

@@ -0,0 +1,20 @@
+@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-user"></i>
+                    Points
+                </strong>
+            </div>
+                <div class="p-3">
+                    @include('app.admin.points.filters')
+                </div>
+                @include('app.admin.points.table')
+            </div>
+        </div>
+    </div>
+@endsection

+ 29 - 0
resources/views/app/admin/points/record-details.blade.php

@@ -0,0 +1,29 @@
+<div moe relative class="mt-1">
+    <a class="text-nowrap" href="" show start>View Details</a>
+    <form url="" right>
+        <div class="mb-2" style="width: 500px;">
+            <table class="table table-sm border w-100">
+                <tbody>
+                    @foreach($columns as $column)
+                    <tr>
+                        <th>{{ $column }}</th>
+                        <td class="text-wrap">
+                            @if($column === 'data')
+                            <?php 
+                                $__data = json_decode($point->{$column}, true);
+                                parseRender($__data);
+                            ?>
+                            @else
+                            <?= $point->{$column} ?>
+                            @endif
+                        </td>
+                    </tr>
+                    @endforeach
+                </tbody>
+            </table>
+        </div>
+        <div>
+            <button class="btn btn-default border btn-sm" cancel>Close</button>
+        </div>
+    </form>
+</div>

+ 51 - 0
resources/views/app/admin/points/table.blade.php

@@ -0,0 +1,51 @@
+<div class="table-responsive">
+    <table class="table p-0 m-0 table-sm table-striped table-bordered border-bottom text-nowrap">
+        <thead class="bg-light">
+            <tr>
+                <th class="border-0">Date</th>
+                <th class="border-0">Patient</th>
+                <th class="border-0">Note</th>
+                <th class="border-0">Creator Pro</th>
+                <th class="border-0">Parent Category</th>
+                <th class="border-0">Category</th>
+                <th class="border-0">Intetion</th>
+                <th class="border-0">ICD</th>
+                <th class="border-0"></th>                
+            </tr>
+        </thead>
+        <tbody>
+            @foreach($points as $point)
+            <tr>
+                <td>{{ friendly_date($point->created_at) }}</td>
+                <td>
+                    <a native target="_blank" href="{{route('patients.view.dashboard', $point->client)}}">
+                        {{$point->client->displayName()}}
+                    </a>
+                </td>
+                <td>
+                    @if($point->note)
+                    <a native target="_blank"
+                        href="/patients/view/{{ $point->note->client->uid }}/notes/view/{{ $point->note->uid }}">
+                        <b>{{ friendly_date_time($point->note->effective_dateest, false) }}</b>
+                    </a>
+                    @endif
+                </td>
+                <td>
+                    {{ $point->creatorPro->displayName() }}
+                </td>
+                <td>{{ $point->parent_category }}</td>
+                <td>{{ $point->category }}</td>
+                <td>{{ $point->intention }}</td>
+                <td>{{ $point->icd }}</td>
+                <td>
+                    @include('app.admin.points.record-details')
+                </td>
+            </tr>
+            @endforeach
+        </tbody>
+    </table>
+</div>
+<div class="px-3 pt-3 d-flex align-items-center">
+    {{$points->withQueryString()->links()}}
+    <div class="ml-4 mb-3">Showing <b>{{$points->firstItem()}}</b> to <b>{{$points->lastItem()}}</b> (page {{$points->currentPage()}}) of <b>{{$points->total()}}</b> points</div>
+</div>