Pārlūkot izejas kodu

Highlight "clientOnly" appts in calendar

Vijayakrishnan 4 gadi atpakaļ
vecāks
revīzija
c8e10b5544

+ 10 - 3
app/Http/Controllers/AppointmentController.php

@@ -18,16 +18,21 @@ class AppointmentController extends Controller
 {
     public function events(Request $request)
     {
-        $proIds = $request->get('proIds');
+        $proIds = explode(',', $request->get('proIds'));
         $start = $request->get('start');
         $end = $request->get('end');
+        $clientId = $request->get('clientId');
         $timeZone = $request->get('timeZone');
         $appointments = Appointment
-            ::whereIn('pro_id', explode(',', $proIds))
-            ->where('status', '!=', 'COMPLETED')
+            ::where('status', '!=', 'COMPLETED')
             ->where('status', '!=', 'CANCELLED')
             ->where('start_time', '>=', $start)
             ->where('start_time', '<=', $end)
+            ->where(function ($query) use ($proIds, $clientId) {
+                $query
+                    ->whereIn('pro_id', $proIds)
+                    ->orWhere('client_id', '=', $clientId);
+            })
             ->get();
         $events = [];
         foreach ($appointments as $appointment) {
@@ -38,9 +43,11 @@ class AppointmentController extends Controller
                 "clientName" => $appointment->client->displayName(),
                 "appointmentUid" => $appointment->uid,
                 "clientUid" => $appointment->client->uid,
+                "proId" => $appointment->pro->id,
                 "proUid" => $appointment->pro->uid,
                 "start" => $this->convertToTimezone($appointment->start_time, $timeZone),
                 "end" => $this->convertToTimezone($appointment->end_time, $timeZone),
+                "clientOnly" => !in_array($appointment->pro->id, $proIds),
                 "editable" => true
             ];
         }

+ 3 - 0
public/css/style.css

@@ -938,3 +938,6 @@ span.select2-container.select2-container--default.select2-container--open {
 .stag-popup .stag-popup-title>span {
     font-size: 17px;
 }
+.fc .opacity-50 {
+    opacity: .5;
+}

+ 7 - 0
resources/views/app/patient/appointment-calendar.blade.php

@@ -453,6 +453,7 @@
                                     }
                                     $.get('/appointment/getAllAppointmentsForPros' +
                                         '?proIds=' + self.proIds +
+                                        '&clientId=' + self.client.id +
                                         '&start=' + info.startStr.substr(0, 10) +
                                         '&end=' + info.endStr.substr(0, 10) +
                                         '&timeZone=' + self.timezone, function(_data) {
@@ -476,6 +477,12 @@
                                         }
                                     }, 'json');
                                 },
+                                eventClassNames: function(arg) {
+                                    if (arg.event.extendedProps.clientOnly) {
+                                        return [ 'opacity-50' ];
+                                    }
+                                    return [];
+                                },
                                 loading: function(bool) {
 
                                 },