소스 검색

Updated client memos view

Samson Mutunga 1 년 전
부모
커밋
e6fd55c7f0

+ 3 - 1
app/Http/Controllers/PatientController.php

@@ -8,6 +8,7 @@ use App\Models\CareMonth;
 use App\Models\Client;
 use App\Models\ClientBDTDevice;
 use App\Models\ClientInfoLine;
+use App\Models\ClientMemoView;
 use App\Models\ClientPrimaryCoverage;
 use App\Models\ClientProAccess;
 use App\Models\Company;
@@ -112,7 +113,8 @@ class PatientController extends Controller
             ->where('is_removed', false)
             ->orderBy('content_text', 'asc')
             ->get();
-        $clientMemos = $patient->memos;
+
+        $clientMemos = ClientMemoView::where('client_id', $patient->id)->where('is_cancelled', false)->orderBy('created_at', 'DESC')->get();
 
         $shortCutsObject = [];
         foreach ($this->pro->allShortcuts() as $shortcut) {

+ 15 - 0
app/Models/ClientMemoView.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\HasOne;
+
+class ClientMemoView extends Model
+{
+    protected $table = 'client_memo_view';
+
+    public function updates(): HasMany{
+        return $this->hasMany(ClientMemoUpdate::class, 'client_memo_id', 'id')->orderBy('created_at', 'DESC');
+    }
+}

+ 25 - 0
resources/views/app/patient/partials/client-memo-update-history.blade.php

@@ -0,0 +1,25 @@
+<div moe relative bottom class="mr-2">
+    <a start show><i class="fa fa-history"></i></a>
+    <div action="" url right bottom>
+        <table class="table table-condensed table-striped table-sm">
+            <thead>
+                <th>Category</th>
+                <th>Summary</th>
+                <th>Created</th>
+
+            </thead>
+            <tbody>
+                @foreach ($memo->updates as $update)
+                    <tr>
+                        <td>{{ $update->category }}</td>
+                        <td>{{ $update->content }}</td>
+                        <td><strong>{{ $update->createdBy->proname_first }}
+                                {{ $update->createdBy->pro->name_last }}</strong><br />{{ friendly_date_time($update->created_at) }}
+                        </td>
+
+                    </tr>
+                @endforeach
+            </tbody>
+        </table>
+    </div>
+</div>

+ 3 - 28
resources/views/app/patient/partials/client-memos.blade.php

@@ -51,7 +51,6 @@
                 </thead>
                 <tbody>
                     @foreach ($clientMemos as $memo)
-                        <?php $memoCreatedBy = $memo->createdBy->pro; ?>
                         @if (!$memo->is_admin_only || ($memo->is_admin_only && $isProTypeAdmin))
                             <tr>
                                 <td class="text-nowrap">{{ $memo->category }}</td>
@@ -59,7 +58,7 @@
                                     <pre class="m-0 break-spaces">{{ $memo->content }}</pre>
                                 </td>
                                 <td class="text-nowrap">
-                                    <strong>{{ $memoCreatedBy->displayName() }}</strong><br />
+                                    <strong>{{ $memo->creator_pro_display_name }}</strong><br />
                                     {{ friendly_date_time($memo->created_at) }}
                                 </td>
                                 @if ($isProTypeAdmin)
@@ -75,38 +74,14 @@
                                     @if ($memo->mcp_stamp_id)
                                         <span class="text-success">YES <i class="fas fa-info-circle c-pointer"
                                                 data-toggle="tooltip" data-placement="bottom"
-                                                title="{{ friendly_date_time($memo->stamp->created_at) }}"></i></span>
+                                                title="{{ friendly_date_time($memo->stamp_created_at) }}"></i></span>
                                     @else
                                         <span class="text-secondary">NO</span>
                                     @endif
                                 </td>
                                 <td class="text-center delete-column">
                                     @if ($isProTypeAdmin)
-                                        <div moe relative bottom class="mr-2">
-                                            <a start show><i class="fa fa-history"></i></a>
-                                            <div action="" url right bottom>
-                                                <table class="table table-condensed table-striped table-sm">
-                                                    <thead>
-                                                        <th>Category</th>
-                                                        <th>Summary</th>
-                                                        <th>Created</th>
-
-                                                    </thead>
-                                                    <tbody>
-                                                        @foreach ($memo->updates as $update)
-                                                            <tr>
-                                                                <td>{{ $update->category }}</td>
-                                                                <td>{{ $update->content }}</td>
-                                                                <td><strong>{{ $update->createdBy->proname_first }}
-                                                                        {{ $update->createdBy->pro->name_last }}</strong><br />{{ friendly_date_time($update->created_at) }}
-                                                                </td>
-
-                                                            </tr>
-                                                        @endforeach
-                                                    </tbody>
-                                                </table>
-                                            </div>
-                                        </div>
+                                        {{-- @include('app.patient.partials.client-memo-update-history') --}}
                                     @endif
                                     <div moe wide relative class="mr-2">
                                         <a class="on-hover-opaque" start show title="Edit">