Kaynağa Gözat

fixed client sms

Josh 3 yıl önce
ebeveyn
işleme
3d0aaf7939

+ 7 - 1
app/Http/Controllers/HomeController.php

@@ -533,12 +533,18 @@ WHERE cl.shadow_pro_id IS NULL
 
         }
 
+        $incomingSmsMessagesPendingReply = DB::select("
+            SELECT cs.* ,c.uid as client_uid, c.name_first as client_name_first, c.name_last as client_name_last FROM client_sms cs LEFT JOIN client c ON c.id = cs.client_id
+            WHERE cs.is_reply_needed = 'YES' AND c.mcp_pro_id = :mcp_pro_id AND incoming_or_outgoing = 'INCOMING'
+            AND (cs.created_at > c.last_sms_sent_to_client_at OR c.last_sms_sent_to_client_at IS NULL)
+        ", ['mcp_pro_id' => $performer->pro->id]);
+
         return view('app/dashboard-mcp', compact('keyNumbers', 'reimbursement', 'milliseconds',
             'businessNumbers',
             'incomingReports', 'tickets', 'supplyOrders',
             'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
             'newMCPAssociations', 'newNAAssociations',
-            'mcpClientMemos', 'mcpClientMemosCount', 'naClientMemos'));
+            'mcpClientMemos', 'mcpClientMemosCount', 'naClientMemos', 'incomingSmsMessagesPendingReply'));
     }
 
     private function dashboard_DNA(Request $request){

+ 4 - 0
app/Models/ClientSMS.php

@@ -7,4 +7,8 @@ namespace App\Models;
 class ClientSMS extends Model
 {
     protected $table = 'client_sms';
+
+    public function client() {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
 }

+ 1 - 2
resources/views/app/dashboard-mcp.blade.php

@@ -272,7 +272,6 @@
                     </div>
                 </div>
                 <div class="col-md-9">
-
                     <div class="row mcp-theme-1" id="pro-dashboard-container" v-cloak>
                         <div class="col-md-6 mcp-theme-1">
                             <div class="card mb-4">
@@ -313,7 +312,7 @@
                                         Messages
                                     </strong>
                                 </div>
-                                <div class="card-body">
+                                <div class="card-body p-0">
                                     @include('app.mcp.dashboard.messages')
                                 </div>
                             </div>

+ 28 - 1
resources/views/app/mcp/dashboard/messages.blade.php

@@ -1 +1,28 @@
-<h1>No messages</h1>
+@if(!$incomingSmsMessagesPendingReply || !count($incomingSmsMessagesPendingReply))
+    <div class="px-2 py-3">No messages</div>
+@else
+    <table class="table table-sm m-0">
+        <tbody>
+        @foreach($incomingSmsMessagesPendingReply as $msg)
+            <tr>
+                <td class="px-1">
+                    <a href="{{route('patients.view.sms', $msg->client_uid)}}">
+                        {{$msg->client_name_first}} {{$msg->client_name_last}}
+                    </a>
+                    <div class="text-secondary text-sm text-nowrap">
+                        {{friendlier_date_time($msg->created_at)}}
+                    </div>
+                </td>
+                <td class="px-1">
+                    {{$msg->body}}
+                </td>
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+    @if(count($incomingSmsMessagesPendingReply) > 10)
+        <div class="p-2 border-top bg-light text-center">
+            Showing 1 to 10 of {{$incomingSmsMessagesPendingReply}} unstamped memos
+        </div>
+    @endif
+@endif

+ 27 - 1
resources/views/app/patient/sms.blade.php

@@ -31,16 +31,42 @@
                 <th class="px-2 text-secondary w-25">From</th>
                 <th class="px-2 text-secondary w-25">To</th>
                 <th class="px-2 text-secondary w-50">Content</th>
+                @if($performer->pro->pro_type == 'ADMIN')
+                    <th></th>
+                @endif
             </tr>
             </thead>
             <tbody>
             @foreach($patient->smses as $sms)
-                <tr>
+                <tr class="{{$sms->created_at > $patient->last_sms_sent_to_client_at && $sms->is_reply_needed == 'YES' ? 'bg-warning': ''}}">
                     <td class="px-2">{{ friendly_date_time($sms->created_at) }}</td>
                     <td class="px-2">{{ ucwords($sms->incoming_or_outgoing) }}</td>
                     <td class="px-2">{{ $sms->from_number }}</td>
                     <td class="px-2">{{ $sms->to_number }}</td>
                     <td class="px-2">{{ $sms->body }}</td>
+                    @if($performer->pro->pro_type == 'ADMIN')
+                        <td>
+                            <div moe relative>
+                                <a start show class="">Update Is Reply Needed</a>
+                                <form url="/api/clientSms/updateIsReplyNeeded" class="mcp-theme-1" right>
+                                    <input type="hidden" name="uid" value="{{ $sms->uid }}">
+                                    <div class="mb-2">
+                                        <label for="" class="text-sm text-secondary mb-1">Is reply needed?</label>
+                                        <select class="form-control form-control-sm" name="isReplyNeeded" value="{{$patient->cell_number}}">
+                                            <option value="UNKNOWN">--</option>
+                                            <option value="YES">Yes</option>
+                                            <option value="NO">No</option>
+                                        </select>
+                                    </div>
+
+                                    <div class="d-flex align-items-center">
+                                        <button class="btn btn-sm btn-primary mr-2" submit>Send</button>
+                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
+                    @endif
                 </tr>
             @endforeach
             </tbody>