= 4 anni fa
parent
commit
166b965653

+ 7 - 0
app/Models/Client.php

@@ -253,6 +253,13 @@ class Client extends Model
             ->orderBy('created_at', 'desc');
     }
 
+    public function deactivatedDevices()
+    {
+        return $this->hasMany(ClientBDTDevice::class, 'client_id', 'id')
+            ->where('is_active', false)
+            ->orderBy('created_at', 'desc');
+    }
+
     public function hasDevice($_device)
     {
         $count = ClientBDTDevice::where('client_id', $this->id)

+ 12 - 0
app/Models/ClientMemo.php

@@ -2,8 +2,20 @@
 
 namespace App\Models;
 
+use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\HasOne;
+
 class ClientMemo extends Model
 {
     protected $table = 'client_memo';
 
+    public function createdBy(): HasOne
+    {
+        return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
+    }
+
+    public function updates(): HasMany{
+        return $this->hasMany(ClientMemoUpdate::class, 'client_memo_id', 'id')->orderBy('created_at', 'DESC');
+    }
+
 }

+ 17 - 0
app/Models/ClientMemoUpdate.php

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

+ 32 - 2
resources/views/app/patient/dashboard.blade.php

@@ -874,8 +874,38 @@
                                 @foreach($patient->memos as $memo)
                                     <tr>
                                         <td class="px-2 text-nowrap">{{ $memo->category }}</td>
-                                        <td class="px-2"><pre class="m-0 break-spaces">{{ $memo->content }}</pre></td>
-                                        <td class="px-2 text-nowrap">{{ friendly_date_time($memo->created_at) }}</td>
+                                        <td class="px-2">
+                                            <pre class="m-0 break-spaces">{{ $memo->content }}</pre>
+                                            @if($performer->pro->pro_type == 'ADMIN')
+                                            <div moe>
+                                                <a start show>Show Changelog</a>
+                                                <div action="" url>
+                                                    <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>
+                                            @endif
+                                        </td>
+                                        <td class="px-2 text-nowrap">
+                                            @if($performer->pro->pro_type == 'ADMIN')
+                                            <strong>{{$memo->createdBy->proname_first}} {{$memo->createdBy->pro->name_last}}</strong><br/>
+                                            @endif
+                                            {{ friendly_date_time($memo->created_at) }}
+                                        </td>
                                         <td class="px-2 text-center delete-column">
                                             <div moe wide relative class="mr-2">
                                                 <a class="on-hover-opaque" start show title="Edit">

+ 57 - 1
resources/views/app/patient/devices.blade.php

@@ -53,6 +53,7 @@
                     <th class="px-2 text-secondary">Created</th>
                     <th class="px-2 text-secondary w-25">Category</th>
                     <th class="px-2 text-secondary w-50">IMEI</th>
+                    <th class="px-2 text-secondary"></th>
                 </tr>
                 </thead>
                 <tbody>
@@ -61,17 +62,72 @@
                         <td class="px-2">{{ friendly_date_time($device->device->created_at) }}</td>
                         <td class="px-2">{{ $device->device->category }}</td>
                         <td class="px-2"><pre class="m-0">{{ $device->device->imei }}</pre></td>
+                        <td>
+                            <div moe relative>
+                                <a start show class="on-hover-opaque">Deactivate</a>
+                                <form url="/api/clientBdtDevice/deactivate" right>
+                                    <input type="hidden" name="uid" value="{{ $device->uid }}">
+                                    <p class="small">Are you sure you want to deactivate this device?</p>
+                                    <div class="d-flex align-items-center">
+                                        <button class="btn btn-sm btn-danger mr-2" submit>Deactivate</button>
+                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
                     </tr>
                 @endforeach
                 </tbody>
             @else
                 <tbody>
                     <tr>
-                        <td class="text-secondary p-3">No devices for this patient</td>
+                        <td class="text-secondary p-3">No active devices for this patient</td>
                     </tr>
                 </tbody>
             @endif
         </table>
+        <hr>
+        <h2>Deactivated Devices</h2>
+        <table class="table table-striped table-sm table-bordered mb-0">
+            @if($patient->deactivatedDevices && count($patient->deactivatedDevices))
+                <thead>
+                <tr>
+                    <th class="px-2 text-secondary">Created</th>
+                    <th class="px-2 text-secondary w-25">Category</th>
+                    <th class="px-2 text-secondary w-50">IMEI</th>
+                    <th class="px-2 text-secondary"></th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($patient->deactivatedDevices as $deactivatedDevice)
+                    <tr>
+                        <td class="px-2">{{ friendly_date_time($deactivatedDevice->device->created_at) }}</td>
+                        <td class="px-2">{{ $deactivatedDevice->device->category }}</td>
+                        <td class="px-2"><pre class="m-0">{{ $deactivatedDevice->device->imei }}</pre></td>
+                        <td>
+                            <div moe relative>
+                                <a start show class="on-hover-opaque">Reactivate</a>
+                                <form url="/api/clientBdtDevice/reactivate" right>
+                                    <input type="hidden" name="uid" value="{{ $deactivatedDevice->uid }}">
+                                    <p class="small">Are you sure you want to reactivate this device?</p>
+                                    <div class="d-flex align-items-center">
+                                        <button class="btn btn-sm btn-danger mr-2" submit>Reactivate</button>
+                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            @else
+                <tbody>
+                <tr>
+                    <td class="text-secondary p-3">No deactivated devices for this patient</td>
+                </tr>
+                </tbody>
+            @endif
+        </table>
     </div>
     <script>
         (function() {