Browse Source

Note <> handouts linkage

Vijayakrishnan 3 năm trước cách đây
mục cha
commit
a0fe503c62

+ 6 - 2
app/Models/Client.php

@@ -193,9 +193,13 @@ class Client extends Model
             ->orderBy('created_at', 'asc');
     }
 
-    public function handouts()
+    public function handouts($note = null)
     {
-        $mappings = HandoutClient::where('client_id', $this->id)->get();
+        $mappings = HandoutClient::where('client_id', $this->id);
+        if($note) {
+            $mappings = $mappings->where('note_id', $note->id);
+        }
+        $mappings = $mappings->get();
         $handouts = new Collection();
         foreach ($mappings as $mapping) {
             $handout = Handout::where('id', $mapping->handout_id)->first();

+ 4 - 4
resources/views/app/patient/handouts-list.blade.php

@@ -6,8 +6,8 @@
             <a start show class="">Add</a>
             <form url="/api/handoutClient/create">
                 <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
-                @if(request()->input('noteUid'))
-                    <input type="hidden" name="noteUid" value="{{ request()->input('noteUid') }}">
+                @if(@$note)
+                    <input type="hidden" name="noteUid" value="{{ $note->uid }}">
                 @endif
                 <div class="mb-2">
                     <select name="handoutUid" class="form-control form-control-sm">
@@ -37,7 +37,7 @@
         </tr>
         </thead>
         <tbody>
-        @foreach($patient->handouts() as $handout)
+        @foreach($patient->handouts($note) as $handout)
             <?php $downloadLink = env('APP_URL') . "/guest/handout/{$handout->handout_client_uid}"; ?>
             <tr>
                 <td>{{$handout->internal_name}}</td>
@@ -47,7 +47,7 @@
                         <i class="fa fa-eye mr-2"></i>View
                     </a>
                 </td>
-                <td><b>{{ $downloadLink }}</b></td>
+                <td><b class="click-to-copy">{{ $downloadLink }}</b></td>
                 <td>
                     <div moe="" relative="">
                         <a start="" show="" href="#">SMS Link</a>

+ 1 - 1
resources/views/app/patient/note/dashboard.blade.php

@@ -728,7 +728,7 @@
                 <!-- handouts -->
                 <div class="p-3 border-bottom screen-only" data-non-segment-section="Handouts">
                     <?php $handouts = \App\Models\Handout::where('is_active', true)->get(); ?>
-                    @include('app.patient.handouts-list', compact('patient', 'handouts'))
+                    @include('app.patient.handouts-list', compact('patient', 'handouts', 'note'))
                 </div>
 
                 <div class="p-3 border-bottom screen-only" data-non-segment-section="Prescriptions">