Bladeren bron

fixed calendar data

Josh Kamau 5 jaren geleden
bovenliggende
commit
aa0db25fb7
4 gewijzigde bestanden met toevoegingen van 181 en 127 verwijderingen
  1. 34 21
      app/Http/Controllers/HomeController.php
  2. 94 72
      public/js/mc.js
  3. 53 33
      resources/views/app/dashboard.blade.php
  4. 0 1
      routes/web.php

+ 34 - 21
app/Http/Controllers/HomeController.php

@@ -17,6 +17,7 @@ class HomeController extends Controller
 
         //patients where performer is the mcp
         $performer = $this->performer();
+        $performerProID = $performer->pro->id;
 
         $keyNumbers  = [];
 
@@ -24,32 +25,32 @@ class HomeController extends Controller
         $keyNumbers['totalPatients'] = $totalPatients;
 
         $patientNotSeenYet = Client::where('mcp_pro_id', $performer->pro->id)
-            ->where(function($query){
+            ->where(function ($query) {
                 $query->where('has_mcp_done_onboarding_visit', 'UNKNOWN')
-                ->orWhere('has_mcp_done_onboarding_visit', 'NO');
+                    ->orWhere('has_mcp_done_onboarding_visit', 'NO');
             })->count();
         $keyNumbers['patientsNotSeenYet'] = $patientNotSeenYet;
 
-        $performerProID = $performer->pro->id;
-        $pendingBillsToSign = Bill::where(function($query) use ($performerProID){
+
+        $pendingBillsToSign = Bill::where(function ($query) use ($performerProID) {
             $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);
         })
-        ->orWhere(function($query) use ($performerProID){
-            $query->where('cm_pro_id', $performerProID)->where('is_signed_by_cm', false)->where('is_cancelled', false);;
-        })->orWhere(function($query) use ($performerProID){
-            $query->where('rme_pro_id', $performerProID)->where('is_signed_by_rme', false)->where('is_cancelled', false);;
-        })->orWhere(function($query) use ($performerProID){
-            $query->where('rmm_pro_id', $performerProID)->where('is_signed_by_rmm', false)->where('is_cancelled', false);;
-        })->count();
+            ->orWhere(function ($query) use ($performerProID) {
+                $query->where('cm_pro_id', $performerProID)->where('is_signed_by_cm', false)->where('is_cancelled', false);;
+            })->orWhere(function ($query) use ($performerProID) {
+                $query->where('rme_pro_id', $performerProID)->where('is_signed_by_rme', false)->where('is_cancelled', false);;
+            })->orWhere(function ($query) use ($performerProID) {
+                $query->where('rmm_pro_id', $performerProID)->where('is_signed_by_rmm', false)->where('is_cancelled', false);;
+            })->count();
 
         $keyNumbers['pendingBillsToSign'] = $pendingBillsToSign;
 
-        $pendingNotesToSign = Note::where(function($query) use ($performerProID){
+        $pendingNotesToSign = Note::where(function ($query) use ($performerProID) {
             $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_cancelled', false);;
         })
-        ->orWhere(function($query) use ($performerProID){
-            $query->where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false);;
-        })->count();
+            ->orWhere(function ($query) use ($performerProID) {
+                $query->where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false)->where('is_cancelled', false);;
+            })->count();
 
         $keyNumbers['pendingNotesToSign'] = $pendingNotesToSign;
 
@@ -57,16 +58,28 @@ class HomeController extends Controller
         $reimbursement["currentBalance"] = $performer->pro->balance;
         $reimbursement["nextPaymentDate"] = '--';
         $lastPayment = ProTransaction::where('pro_id', $performerProID)->where('plus_or_minus', 'PLUS')->orderBy('created_at', 'DESC')->first();
-        if($lastPayment) {
+        if ($lastPayment) {
             $reimbursement["lastPayment"] = $lastPayment->amount;
             $reimbursement["lastPaymentDate"] = $lastPayment->created_at;
-        }else{
+        } else {
             $reimbursement["lastPayment"] = '--';
             $reimbursement["lastPaymentDate"] = '--';
         }
 
+        $clientsWithAppointments = Client::where("mcp_pro_id", $performerProID)
+            ->whereNotNull('next_mcp_appointment')->get();
+
+        $appointments = [];
+        foreach ($clientsWithAppointments as $client) {
+            $appointment = [
+                'client_uid' => $client->uid,
+                'title' => $client->name_first . ' ' . $client->name_last,
+                'start' => $client->next_mcp_appointment
+            ];
+            $appointments[] = $appointment;
+        }
 
-        return view('app/dashboard', compact('keyNumbers','reimbursement'));
+        return view('app/dashboard', compact('keyNumbers', 'reimbursement', 'appointments'));
     }
 
     public function patients(Request $request)
@@ -80,12 +93,12 @@ class HomeController extends Controller
         return view('app/new-patient');
     }
 
-    public function mc(Request $request, $fragment = "") {
+    public function mc(Request $request, $fragment = "")
+    {
         $page = "/";
-        if($fragment) {
+        if ($fragment) {
             $page = '/' . $fragment;
         }
         return view('app/mc', compact('page'));
     }
-
 }

+ 94 - 72
public/js/mc.js

@@ -12,7 +12,6 @@ var findEventHandlers = function (eventType, jqSelector) {
         return arrayIntersection(array1, array2).length !== 0;
     };
 
-
     var addEventHandlerInfo = function (element, event, $elementsCovered) {
         var extendedEvent = event;
         if ($elementsCovered !== void 0 && $elementsCovered !== null) {
@@ -33,13 +32,16 @@ var findEventHandlers = function (eventType, jqSelector) {
             results.push(eventInfo);
         } else {
             eventInfo = eventsInfo[0];
-            eventInfo.events.push(extendedEvent);
+            eventInfo
+                .events
+                .push(extendedEvent);
         }
     };
 
-
     var $elementsToWatch = $(jqSelector);
-    if (jqSelector === "*") //* does not include document and we might be interested in handlers registered there
+    if (jqSelector === "*") 
+        // * does not include document and we might be interested in handlers registered
+        // there
         $elementsToWatch = $elementsToWatch.add(document);
     var $allElements = $("*").add(document);
 
@@ -65,41 +67,59 @@ var findEventHandlers = function (eventType, jqSelector) {
     return results;
 };
 
-window.top.addEventListener('popstate', function (event) {
-    window.setTimeout(function () {
-        if (!event) return;
-        var state = event.state;
-        if (state === '') state = '/';
-        if (state[0] !== '/') state = '/' + state;
-        if (!!state) fastLoad(state, false, true);
-    }, 0);
-});
-$(document).ready(function () {
-    $(document).on('click', '.stag_rhs_toggle', function () {
-        var state = window.top.toggleRHS(),
-            icon = $(this).find('i');
-        if (state === 'collapsed') {
-            icon.removeClass().addClass('fa fa-arrow-left');
-        } else {
-            icon.removeClass().addClass('fa fa-arrow-right');
-        }
+window
+    .top
+    .addEventListener("popstate", function (event) {
+        window
+            .setTimeout(function () {
+                if (!event) 
+                    return;
+                var state = event.state;
+                if (state === "") 
+                    state = "/";
+                if (state[0] !== "/") 
+                    state = "/" + state;
+                if (!!state) 
+                    fastLoad(state, false, true);
+                }
+            , 0);
     });
+$(document).ready(function () {
+    $(document)
+        .on("click", ".stag_rhs_toggle", function () {
+            var state = window
+                    .top
+                    .toggleRHS(),
+                icon = $(this).find("i");
+            if (state === "collapsed") {
+                icon
+                    .removeClass()
+                    .addClass("fa fa-arrow-left");
+            } else {
+                icon
+                    .removeClass()
+                    .addClass("fa fa-arrow-right");
+            }
+        });
     var body = $(window.top.document.body),
-        icon = $('.stag_rhs_toggle i');
-    if (body.is('.stag_rhs_collapsed')) {
-        icon.removeClass().addClass('fa fa-arrow-left');
+        icon = $(".stag_rhs_toggle i");
+    if (body.is(".stag_rhs_collapsed")) {
+        icon
+            .removeClass()
+            .addClass("fa fa-arrow-left");
     }
     initFastLoad();
 });
 function enableTimeSpecificFields(_checked, _valueClass, _rangeClass) {
-    if(_valueClass) $('.' + _valueClass).prop('disabled', _checked);
-    if(_rangeClass) $('.' + _rangeClass).prop('disabled', !_checked);
-}
+    if (_valueClass) 
+        $("." + _valueClass).prop("disabled", _checked);
+    if (_rangeClass) 
+        $("." + _rangeClass).prop("disabled", !_checked);
+    }
 
 var fastCache = {};
 
 function initFastLoad(_parent = false) {
-
     fastCache = {};
 
     var allAs = $('a:not([onclick]):not([href="#"])');
@@ -107,29 +127,33 @@ function initFastLoad(_parent = false) {
         allAs = _parent.find('a:not([onclick]):not([href="#"])');
     }
     // find links without event handlers
-    allAs.each(function () {
-        if (!$(this).closest('[moe]').length) {
-            if ($(this).closest('.dropdown-menu[aria-labelledby="practice-management"]').length) {
-                enableFastLoad(this, true);
-            } else {
-                var handlers = findEventHandlers('click', this);
-                if (!handlers || !handlers.length) {
-                    enableFastLoad(this);
+    allAs
+        .each(function () {
+            if (!$(this).closest("[moe]").length) {
+                if ($(this).closest('.dropdown-menu[aria-labelledby="practice-management"]').length) {
+                    enableFastLoad(this, true);
+                } else {
+                    var handlers = findEventHandlers("click", this);
+                    if (!handlers || !handlers.length) {
+                        enableFastLoad(this);
+                    }
                 }
             }
-        }
-    });
+        });
 
     function enableFastLoad(_a, _menuItem = false) {
-        $(_a).on('click', function () {
-            fastLoad(this.href, true, true);
-            if (_menuItem) {
-                $(this).closest('.dropdown-menu')
-                    .removeClass('show')
-                    .prev('.dropdown-toggle').attr('aria-expanded', 'false');
-            }
-            return false;
-        });
+        $(_a)
+            .on("click", function () {
+                fastLoad(this.href, true, true);
+                if (_menuItem) {
+                    $(this)
+                        .closest(".dropdown-menu")
+                        .removeClass("show")
+                        .prev(".dropdown-toggle")
+                        .attr("aria-expanded", "false");
+                }
+                return false;
+            });
         // console.info('FastLoad enabled for ' + _a.innerText + ' [' + _a.href + ']');
     }
 
@@ -141,14 +165,13 @@ function initFastLoad(_parent = false) {
             fastCache[a.href] = _data;
         });
     });
-
 }
 
 function fastLoad(_href, _history = true, _useCache = true) {
     function onData(_data) {
-        var targetParent = $('.stag-content');
-        _data = '<div>' + _data + '</div>';
-        var content = $(_data).find('.stag-content');
+        var targetParent = $(".stag-content");
+        _data = "<div>" + _data + "</div>";
+        var content = $(_data).find(".stag-content");
         if (content && content.length) {
             content = content.html();
             content += '<script src="/js/yemi.js"></script>';
@@ -159,17 +182,19 @@ function fastLoad(_href, _history = true, _useCache = true) {
             // push state
             if (_history) {
                 var target = _href;
-                if (target.indexOf('//') !== -1) {
-                    target = target.split('//')[1];
-                    if (target.indexOf('/') !== -1) {
-                        target = target.substr(target.indexOf('/') + 1);
+                if (target.indexOf("//") !== -1) {
+                    target = target.split("//")[1];
+                    if (target.indexOf("/") !== -1) {
+                        target = target.substr(target.indexOf("/") + 1);
                     }
                 }
-                window.top.history.pushState(target, null, '/mc/' + target);
+                window
+                    .top
+                    .history
+                    .pushState(target, null, "/mc/" + target);
             }
-
         } else {
-            console.warn('Target page not found: ' + _href);
+            console.warn("Target page not found: " + _href);
             window.location.href = _href; // fallback
         }
         hideMask();
@@ -183,18 +208,15 @@ function fastLoad(_href, _history = true, _useCache = true) {
 }
 
 function openInRHS(_url) {
-    window.top.showRHS();
-    var icon = $('.stag_rhs_toggle i');
-    icon.removeClass().addClass('fa fa-arrow-right');
-    window.top.openInRHS(_url);
+    window
+        .top
+        .showRHS();
+    var icon = $(".stag_rhs_toggle i");
+    icon
+        .removeClass()
+        .addClass("fa fa-arrow-right");
+    window
+        .top
+        .openInRHS(_url);
     return false;
 }
-
-function initializeCalendar() {
-    if(!$('#calendar').length) return;
-    var calendarEl = document.getElementById('calendar');
-    var calendar = new FullCalendar.Calendar(calendarEl, {
-        initialView: 'dayGridMonth'
-    });
-    calendar.render();
-}

+ 53 - 33
resources/views/app/dashboard.blade.php

@@ -1,20 +1,20 @@
 @extends ('layouts.template')
 
 @section('content')
-    <div class="mt-3">
-        <div class="container m-0 mt-4">
-            <div class="row">
-                <div class="col-md-4">
-                    <div class="card">
-                        <div class="card-header">
-                            <strong>
-                                <i class="fas fa-chart-bar"></i>
-                                Key Numbers
-                            </strong>
-                        </div>
-                        <div class="card-body p-0">
-                            <table class="table table-condensed table-bordered m-0">
-                                <tbody>
+<div class="mt-3">
+    <div class="container m-0 mt-4">
+        <div class="row">
+            <div class="col-md-4">
+                <div class="card">
+                    <div class="card-header">
+                        <strong>
+                            <i class="fas fa-chart-bar"></i>
+                            Key Numbers
+                        </strong>
+                    </div>
+                    <div class="card-body p-0">
+                        <table class="table table-condensed table-bordered m-0">
+                            <tbody>
                                 <tr>
                                     <th>{{$keyNumbers['totalPatients']}}</th>
                                     <th>Total patients</th>
@@ -31,19 +31,19 @@
                                     <th>{{$keyNumbers['pendingNotesToSign']}}</th>
                                     <th>Pending notes to sign</th>
                                 </tr>
-                                </tbody>
-                            </table>
-                        </div>
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+                <div class="card mt-3">
+                    <div class="card-header">
+                        <strong>
+                            Reimbursement
+                        </strong>
                     </div>
-                    <div class="card mt-3">
-                        <div class="card-header">
-                            <strong>
-                                Reimbursement
-                            </strong>
-                        </div>
-                        <div class="card-body p-0">
-                            <table class="table table-condensed table-bordered m-0">
-                                <tbody>
+                    <div class="card-body p-0">
+                        <table class="table table-condensed table-bordered m-0">
+                            <tbody>
                                 <tr>
                                     <th>{{$reimbursement['currentBalance']}}</th>
                                     <th>Current balance</th>
@@ -60,15 +60,35 @@
                                     <th>{{$reimbursement['lastPaymentDate']}}</th>
                                     <th>Last payment date</th>
                                 </tr>
-                                </tbody>
-                            </table>
-                        </div>
+                            </tbody>
+                        </table>
                     </div>
                 </div>
-                <div class="col-md-8">
-                    <div id='calendar'></div>
-                </div>
+            </div>
+            <div class="col-md-8">
+                <div id='calendar'></div>
             </div>
         </div>
     </div>
-@endsection
+</div>
+
+<script>
+    var events = JSON.parse('{!! json_encode($appointments) !!}')
+    function initializeCalendar() {
+        if (!$("#calendar").length) 
+            return;
+        var calendarEl = document.getElementById("calendar");
+        var calendar = new FullCalendar.Calendar(calendarEl, {
+            initialView: "dayGridMonth",
+            headerToolbar: {
+                left: "dayGridMonth,timeGridWeek,timeGridDay",
+                center: "title",
+                right: "prevYear,prev,next,nextYear"
+            },
+            events: events
+        });
+        calendar.render();
+    }
+    initializeCalendar();
+</script>
+@endsection

+ 0 - 1
routes/web.php

@@ -85,5 +85,4 @@ Route::middleware('pro.auth')->group(function () {
     Route::get('/section_create_form/{note_uid}/{section_template_uid}', 'NoteController@sectionCreateForm')->name('section_create_form');
     Route::get('/section_update_form/{section_uid}', 'NoteController@sectionUpdateForm')->name('section_update_form');
     Route::post("/process_form_submit", 'NoteController@processFormSubmit')->name('process_form_submit');
-
 });