Переглянути джерело

Allow NAs to see their patients

Vijayakrishnan 4 роки тому
батько
коміт
a2c8afa250
2 змінених файлів з 20 додано та 16 видалено
  1. 4 2
      app/Models/Pro.php
  2. 16 14
      resources/views/app/patient/note/dashboard.blade.php

+ 4 - 2
app/Models/Pro.php

@@ -292,7 +292,8 @@ class Pro extends Model
                     ->orWhereRaw('id IN (SELECT client_id FROM client_pro_access WHERE is_active AND pro_id = ?)', [$proID])
                     ->orWhereRaw('id IN (SELECT client_id FROM appointment WHERE status NOT IN (\'CANCELLED\', \'ABANDONED\') AND pro_id = ?)', [$proID])
                     ->orWhereRaw('id IN (SELECT mcp_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)')
-                    ->orWhereRaw('id IN (SELECT manager_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)');
+                    ->orWhereRaw('id IN (SELECT manager_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)')
+                    ->orWhereRaw('id IN (SELECT client_id FROM note WHERE ally_pro_id = ? AND is_cancelled = FALSE)', [$proID]);;
             });
         }
         return $query;
@@ -314,7 +315,8 @@ class Pro extends Model
                     ->orWhereRaw('id IN (SELECT client_id FROM client_pro_access WHERE is_active AND pro_id = ?)', [$proID])
                     ->orWhereRaw('id IN (SELECT client_id FROM appointment WHERE status NOT IN (\'CANCELLED\', \'ABANDONED\') AND pro_id = ?)', [$proID])
                     ->orWhereRaw('id IN (SELECT mcp_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)')
-                    ->orWhereRaw('id IN (SELECT manager_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)');
+                    ->orWhereRaw('id IN (SELECT manager_pro_id FROM client_program WHERE client_id = client.id AND is_active = TRUE)')
+                    ->orWhereRaw('id IN (SELECT client_id FROM note WHERE ally_pro_id = ? AND is_cancelled = FALSE)', [$proID]);
             })->count();
         return !!$canAccess;
     }

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

@@ -161,23 +161,25 @@
             </div>
 
 
-            @if($performer->pro->pro_type == 'ADMIN')
+            @if($performer->pro->pro_type == 'ADMIN' || ($note->allyPro && $note->allyPro->uid === $performer->pro->uid))
                 <span class="px-2 border-right d-flex">
                     @if($note->allyPro)
                         <span class="mr-2"><span class="text-secondary">NA:</span>  {{$note->allyPro->name_first}} {{$note->allyPro->name_last}}</span>
-                        <span class="d-inline-block" moe>
-                            <a class="text-danger" href="" show start>
-                                <i class="fa fa-times"></i>
-                            </a>
-                            <form url="/api/note/removeNa">
-                                <input type="hidden" name="uid" value="{{$note->uid}}">
-                                <p>Remove NA?</p>
-                                <div class="mb-0">
-                                    <button class="btn btn-success btn-sm" submit>Submit</button>
-                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                </div>
-                            </form>
-                        </span>
+                        @if($performer->pro->pro_type == 'ADMIN')
+                            <span class="d-inline-block" moe>
+                                <a class="text-danger" href="" show start>
+                                    <i class="fa fa-times"></i>
+                                </a>
+                                <form url="/api/note/removeNa">
+                                    <input type="hidden" name="uid" value="{{$note->uid}}">
+                                    <p>Remove NA?</p>
+                                    <div class="mb-0">
+                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </span>
+                        @endif
                     @else
                         <span class="mr-2"><span class="text-secondary">NA:</span> - </span>
                         <span class="d-block" moe>