Selaa lähdekoodia

UI for mcp request & claim functionality

Vijayakrishnan 4 vuotta sitten
vanhempi
commit
e0069bca83

+ 5 - 0
app/Models/Pro.php

@@ -79,4 +79,9 @@ class Pro extends Model
             ->where('is_removed', false)
             ->orderBy('position_index', 'asc');
     }
+
+    public function isWorkingOnClient($_client) {
+        $count = ProClientWork::where('pro_id', $this->id)->where('client_id', $_client->id)->where('is_active', true)->count();
+        return $count > 0;
+    }
 }

+ 11 - 0
app/Models/ProClientWork.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class ProClientWork extends Model
+{
+    protected $table = 'pro_client_work';
+
+}

+ 1 - 0
public/css/yemi.css

@@ -16,6 +16,7 @@
 }
 [moe] [url][right] {
     right: 0;
+    min-width: 200px;
 }
 #moe-form-mask {
     cursor: pointer;

+ 73 - 65
resources/views/layouts/patient.blade.php

@@ -498,76 +498,84 @@
                             ?>
                         </pre>
                     </div>--}}
-                    <div class="text-container px-3 py-2 border-bottom">
+                    <div class="text-container border-bottom d-flex align-items-center mcp-theme-1">
 
-                        {{-- start work on client --}}
-                        <div moe>
-                            <a href="" start show  class="btn btn-sm btn-primary">Start working on this client</a>
-                            <form url="/api/proClientWork/create" class="mcp-theme-1">
-                                <input type="hidden" name="clientUid" value="{{$patient->uid}}">
-                                <p>Start working on this patient?</p>
-                                <div>
-                                    <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                </div>
-                            </form>
-                        </div>
-
-                        {{-- stop work on client --}}
-                        <div moe>
-                            <a href="" start show  class="btn btn-sm btn-primary">Stop working on this client</a>
-                            <form url="/api/proClientWork/KillRunningWorkForSelf" class="mcp-theme-1">
-                                <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                <p>Stop working on this patient?</p>
-                                <div>
-                                    <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                </div>
-                            </form>
-                        </div>
-
-                        |
-
-                        {{-- create mcp request for client --}}
-                        <div moe>
-                            <a href="" start show class="btn btn-sm btn-primary">Create MCP Request</a>
-                            <form url="/api/mcpRequest/createAsPro" class="mcp-theme-1">
-                                <p>Create an MCP Request for this patient?</p>
-                                <div>
-                                    <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                </div>
-                            </form>
-                        </div>
-
-                        {{-- kill mcp request for client --}}
-                        <div moe>
-                            <a href="" start show class="btn btn-sm btn-primary">Kill MCP Request</a>
-                            <form url="/api/mcpRequest/kill" class="mcp-theme-1">
-                                <input type="hidden" name="clientUid" value="{{$patient->uid}}">
-                                <p>Kill the MCP Request for this patient?</p>
-                                <div>
-                                    <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                        <div class="mr-auto px-3 py-2">
+                            @if($pro->isWorkingOnClient($patient))
+                                {{-- stop work on client --}}
+                                <div moe>
+                                    <a href="" start show  class="btn btn-sm btn-danger text-white font-weight-bold small">Stop working on this client</a>
+                                    <form url="/api/proClientWork/KillRunningWorkForSelf" class="mcp-theme-1">
+                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                        <p>Stop working on this patient?</p>
+                                        <div>
+                                            <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
+                                            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                        </div>
+                                    </form>
                                 </div>
-                            </form>
-                        </div>
-
-                        |
-
-                        {{-- kill mcp request for client --}}
-                        <div moe>
-                            <a href="" start show class="btn btn-sm btn-primary">Claim as MCP</a>
-                            <form url="/api/mcpRequest/claim" class="mcp-theme-1">
-                                <input type="hidden" name="clientUid" value="{{$patient->uid}}">
-                                <p>Claim this patient?</p>
-                                <div>
-                                    <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                            @else
+                                {{-- start work on client --}}
+                                <div moe>
+                                    <a href="" start show  class="btn btn-sm btn-primary text-white font-weight-bold small">Start working on this client</a>
+                                    <form url="/api/proClientWork/create" class="mcp-theme-1">
+                                        <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                                        <p>Start working on this patient?</p>
+                                        <div>
+                                            <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
+                                            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                        </div>
+                                    </form>
                                 </div>
-                            </form>
+                            @endif
                         </div>
 
+                        @if($pro->isWorkingOnClient($patient))
+                            <div class="d-flex align-items-center py-2 px-3">
+                                @if($patient->active_mcp_request_id)
+                                    <b>This patient has an active MCP request</b>
+                                    {{-- kill mcp request for client --}}
+                                    <div moe relative class="ml-3">
+                                        <a href="" start show class="btn btn-sm btn-danger text-white font-weight-bold small">Kill MCP Request</a>
+                                        <form url="/api/mcpRequest/kill" class="mcp-theme-1" right>
+                                            <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                                            <p>Kill the MCP Request for this patient?</p>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                    @if($patient->mcp_pro_id !== $pro->id)
+                                        {{-- claim client --}}
+                                        <div moe relative class="ml-2">
+                                            <a href="" start show class="btn btn-sm btn-success text-white font-weight-bold small">Claim as MCP</a>
+                                            <form url="/api/mcpRequest/claim" class="mcp-theme-1" right>
+                                                <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                                                <p>Claim this patient?</p>
+                                                <div>
+                                                    <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
+                                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @endif
+                                @else
+                                    {{-- create mcp request for client --}}
+                                    <b>This patient does not have an active MCP request</b>
+                                    <div moe relative class="ml-3">
+                                        <a href="" start show class="btn btn-sm btn-primary text-white font-weight-bold small">Create MCP Request</a>
+                                        <form url="/api/mcpRequest/createAsPro" class="mcp-theme-1" right>
+                                            <p>Create an MCP Request for this patient?</p>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                            </div>
+                        @endif
                     </div>
                     <div class="card-body">
                         {{--<h1 class="h3">@yield('section-title')</h1>--}}