Explorar el Código

Recent sticky notes

Samson Mutunga hace 3 años
padre
commit
0a94ccf3ba

+ 21 - 0
app/Models/ClientStickyNote.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\HasOne;
+
+class ClientStickyNote extends Model
+{
+    protected $table = 'client_sticky_note';
+
+    public function createdBy(): HasOne
+    {
+        return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
+    }
+
+    public function client(): HasOne
+    {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+}

+ 42 - 0
resources/views/app/patient/partials/sticky-notes-history.blade.php

@@ -0,0 +1,42 @@
+<?php
+
+use App\Models\ClientStickyNote;
+
+$recentStickyNotes = ClientStickyNote::where('client_id', $patient->id)->orderBy('created_at', 'DESC')->limit(5)->get();
+?>
+<div moe relative wide center class="ml-2 hide-inside-popup">
+	<a start show><i class="fas fa-history fa-fw on-hover-opaque"></i></a>
+	<form url="" class="mcp-theme-1">
+		<div>
+			<div class="d-flex align-items-center justify-content-between pb-2 mb-1">
+				<h5 class="mb-0 font-weight-bold">Recent Sticky Notes</h5>
+				<button cancel class="btn btn-sm btn-default border">
+					<i class="fas fa-times"></i>
+				</button>
+			</div>
+			<table class="table table-sm table-striped table-bordered">
+				<thead class="bg-light">
+					<tr>
+						<th class="border-bottom-0">Date</th>
+						<th class="border-bottom-0">Note</th>
+						<th class="border-bottom-0">Created By</th>
+					</tr>
+				</thead>
+				<tbody>
+					@foreach($recentStickyNotes as $sn)
+					<tr>
+						<td>{{ friendly_date_time($sn->created_at) }}</td>
+						<td style="max-width: 400px;"><?= nl2br($sn->sticky_note) ?></td>
+						<td>{{ $sn->createdBy->pro->displayName() }}</td>
+					</tr>
+					@endforeach
+					@if(!count($recentStickyNotes))
+						<tr>
+							<td colspan="4">No records found</td>
+						</tr>
+					@endif
+				</tbody>
+			</table>
+		</div>
+	</form>
+</div>

+ 1 - 0
resources/views/layouts/patient-header.blade.php

@@ -486,6 +486,7 @@ $addressParts .= implode(", ", $addressPart2);
       <div>
         <div class="d-flex">
           <label class="">Sticky Note:</label>
+          @include('app.patient.partials.sticky-notes-history')
           <div moe relative wide class="ml-2 hide-inside-popup">
             <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
             <form url="/api/client/updateStickyNote" class="mcp-theme-1" right>