Browse Source

Appt decision confirmation notifications

Vijayakrishnan 3 years ago
parent
commit
341f19b28b
2 changed files with 143 additions and 1 deletions
  1. 37 1
      app/Http/Controllers/HomeController.php
  2. 106 0
      resources/views/app/dashboard.blade.php

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

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Lib\Backend;
 use App\Models\Appointment;
+use App\Models\AppointmentConfirmationDecision;
 use App\Models\AppSession;
 use App\Models\ClientMemo;
 use App\Models\ClientProChange;
@@ -393,6 +394,40 @@ class HomeController extends Controller
             ->whereNull('current_client_pro_change_decision_id')
             ->get();
 
+        $proApptUpdates = AppointmentConfirmationDecision
+            ::select('appointment_confirmation_decision.uid', 'client.name_first', 'client.name_last', 'appointment.start_time')
+            ->rightJoin('appointment', 'appointment.id', '=', 'appointment_confirmation_decision.appointment_id')
+            ->rightJoin('client', 'client.id', '=', 'appointment.client_id')
+            ->where('appointment_confirmation_decision.was_acknowledged_by_appointment_pro', false)
+            ->where('appointment.status', '!=', 'CREATED')
+            ->where('appointment.status', '!=', 'COMPLETED')
+            ->where('appointment.status', '!=', 'ABANDONED')
+            ->where('appointment.pro_id', $performerProID)
+            ->where('client.mcp_pro_id', $performerProID)
+            ->orderBy('appointment.start_time', 'DESC')
+            ->get();
+
+        $naApptUpdates = AppointmentConfirmationDecision
+            ::select('appointment_confirmation_decision.uid', 'client.name_first', 'client.name_last', 'pro.name_first as pro_name_first', 'pro.name_last as pro_name_last', 'appointment.start_time')
+            ->rightJoin('appointment', 'appointment.id', '=', 'appointment_confirmation_decision.appointment_id')
+            ->rightJoin('client', 'client.id', '=', 'appointment.client_id')
+            ->rightJoin('pro', 'pro.id', '=', 'appointment.pro_id')
+            ->where('appointment_confirmation_decision.was_acknowledged_by_appointment_pro', false)
+            ->where('appointment.status', '!=', 'CREATED')
+            ->where('appointment.status', '!=', 'COMPLETED')
+            ->where('appointment.status', '!=', 'ABANDONED')
+            ->where('client.default_na_pro_id', $performerProID)
+            ->orderBy('appointment.start_time', 'DESC')
+            ->get();
+
+//        $naApptUpdates = AppointmentConfirmationDecision
+//            ::join('appointment', 'appointment.id', '=', 'appointment_confirmation_decision.appointment_id')
+//            ->join('client', 'client.id', '=', 'appointment.client_id')
+//            ->where('client.default_na_pro_id', $performerProID)
+//            ->where('appointment_confirmation_decision.was_acknowledged_by_client_default_na', false)
+//            ->orderBy('appointment.start_time DESC')
+//            ->get();
+
         // unstamped client memos
         // for mcp
         $mcpClientMemos = DB::select(
@@ -529,7 +564,8 @@ WHERE ((client.mcp_pro_id = {$performer->pro->id}) OR (client.rmm_pro_id = {$per
             'incomingReports', 'tickets', 'supplyOrders',
             'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
             'newMCPAssociations', 'newNAAssociations',
-            'mcpClientMemos', 'naClientMemos'));
+            'mcpClientMemos', 'naClientMemos',
+            'proApptUpdates', 'naApptUpdates'));
     }
 
     public function dashboardMeasurementsTab(Request $request, $page = 1) {

+ 106 - 0
resources/views/app/dashboard.blade.php

@@ -203,6 +203,62 @@
 
                 <div class="row">
                     <div class="col-6">
+
+                        <!-- Appointment Updates -->
+                        @if(count($proApptUpdates))
+                            <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                <p class="pt-1 mb-2"><b>Appointment Updates</b></p>
+                                <table class="table table-sm table-hover table-bordered">
+                                    <thead>
+                                    <tr>
+                                        <th>Client</th>
+                                        <th>Appt. Date/Time</th>
+                                        <th>Status</th>
+                                        <th></th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                        @foreach($proApptUpdates as $update)
+                                            <tr>
+                                                <td>{{$update->name_first}} {{$update->name_last}}</td>
+                                                <td>{{friendlier_date_time($update->start_time)}}</td>
+                                                <td>{{$update->status}}</td>
+                                                <td><a href="#" class="ack-pro-appt-update" data-uid="{{$update->uid}}">Acknowledge</a></td>
+                                            </tr>
+                                        @endforeach
+                                    </tbody>
+                                </table>
+                            </div>
+                        @endif
+
+                        @if(count($naApptUpdates))
+                            <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                <p class="pt-1 mb-2"><b>Appointment Updates</b></p>
+                                <table class="table table-sm table-hover table-bordered">
+                                    <thead>
+                                    <tr>
+                                        <th>Client</th>
+                                        <th>Pro</th>
+                                        <th>Appt. Date/Time</th>
+                                        <th>Status</th>
+                                        <th></th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    @foreach($naApptUpdates as $update)
+                                        <tr>
+                                            <td>{{$update->name_first}} {{$update->name_last}}</td>
+                                            <td>{{$update->pro_name_first}} {{$update->pro_name_last}}</td>
+                                            <td>{{friendlier_date_time($update->start_time)}}</td>
+                                            <td>{{$update->status}}</td>
+                                            <td><a href="#" class="ack-na-appt-update" data-uid="{{$update->uid}}">Acknowledge</a></td>
+                                        </tr>
+                                    @endforeach
+                                    </tbody>
+                                </table>
+                            </div>
+                        @endif
+
                         <!-- new associations -->
                         @if(count($newMCPAssociations))
                             <div class="mb-3 border rounded px-3 py-2 ack-container">
@@ -781,6 +837,56 @@
                     }, 'json');
                     return false;
                 });
+
+            $(document)
+                .off('click', '.ack-pro-appt-update')
+                .on('click', '.ack-pro-appt-update', function() {
+                    let trigger = $(this).text('…');
+                    $.post('/api/appointmentConfirmationDecision/acknowledgeAsAppointmentPro', {
+                        uid: $(this).attr('data-uid')
+                    }, _data => {
+                        if(!hasResponseError(_data)) {
+                            trigger.hide();
+                            let doneElem = $('<i class="text-success fa fa-check"></i>');
+                            doneElem.insertAfter(trigger);
+                            setTimeout(() => {
+                                let ackContainer = trigger.closest('tbody');
+                                trigger.closest('tr').slideUp('fast', function() {
+                                    $(this).remove();
+                                    if(!ackContainer.find('>tr').length) {
+                                        ackContainer.remove();
+                                    }
+                                });
+                            }, 500);
+                        }
+                    }, 'json');
+                    return false;
+                });
+
+            $(document)
+                .off('click', '.ack-na-appt-update')
+                .on('click', '.ack-na-appt-update', function() {
+                    let trigger = $(this).text('…');
+                    $.post('/api/appointmentConfirmationDecision/acknowledgeAsClientDefaultNa', {
+                        uid: $(this).attr('data-uid')
+                    }, _data => {
+                        if(!hasResponseError(_data)) {
+                            trigger.hide();
+                            let doneElem = $('<i class="text-success fa fa-check"></i>');
+                            doneElem.insertAfter(trigger);
+                            setTimeout(() => {
+                                let ackContainer = trigger.closest('tbody');
+                                trigger.closest('tr').slideUp('fast', function() {
+                                    $(this).remove();
+                                    if(!ackContainer.find('>tr').length) {
+                                        ackContainer.remove();
+                                    }
+                                });
+                            }, 500);
+                        }
+                    }, 'json');
+                    return false;
+                });
         }
         addMCInitializer('pro-dashboard', init, '#pro-dashboard-container');
     })();