瀏覽代碼

Merge branch 'master' into dev-vj

Vijayakrishnan Krishnan 5 年之前
父節點
當前提交
c4bff94655
共有 4 個文件被更改,包括 305 次插入191 次删除
  1. 34 21
      app/Http/Controllers/HomeController.php
  2. 215 150
      public/js/mc.js
  3. 56 19
      resources/views/app/dashboard.blade.php
  4. 0 1
      routes/web.php

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

@@ -15,6 +15,7 @@ class HomeController extends Controller
 
         //patients where performer is the mcp
         $performer = $this->performer();
+        $performerProID = $performer->pro->id;
 
         $keyNumbers  = [];
 
@@ -22,32 +23,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;
 
@@ -55,16 +56,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)
@@ -88,12 +101,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'));
     }
-
 }

+ 215 - 150
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,161 +67,224 @@ 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 () {
-    if(window === window.top) {
-        window.location.href = '/mc' + window.location.pathname;
-        return;
-    }
-    window.top.ensureRHS();
-    $(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');
-    }
-    initFastLoad();
-    initializeCalendar();
-});
-function enableTimeSpecificFields(_checked, _valueClass, _rangeClass) {
-    if(_valueClass) $('.' + _valueClass).prop('disabled', _checked);
-    if(_rangeClass) $('.' + _rangeClass).prop('disabled', !_checked);
-}
-function toggleDisabledAsNeeded(_el, _targetValue, _enableClass, _disableClass) {
-    if(_el.value === _targetValue) {
-        if(_enableClass) $('.' + _enableClass).prop('disabled', false);
-        if(_disableClass) $('.' + _disableClass).prop('disabled', true);
-    }
-    else {
-        if(_enableClass) $('.' + _enableClass).prop('disabled', true);
-        if(_disableClass) $('.' + _disableClass).prop('disabled', false);
-    }
-}
-function toggleVisibilityAsNeeded(_el, _targetValue, _visibleClass, _hiddenClass) {
-    if(_el.value === _targetValue) {
-        if(_visibleClass) $('.' + _visibleClass).removeClass('d-none');
-        if(_hiddenClass) $('.' + _hiddenClass).addClass('d-none');
-    }
-    else {
-        if(_visibleClass) $('.' + _visibleClass).addClass('d-none');
-        if(_hiddenClass) $('.' + _hiddenClass).removeClass('d-none');
-    }
-}
-var fastCache = {};
+<<<<<<<HEAD
+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);
+        =======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 () {
+            if (window === window.top) {
+                window.location.href = '/mc' + window.location.pathname;
+                return;
+            }
+            window
+                .top
+                .ensureRHS();
+            $(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');
+                } >>>>>>> 8 a6acabd0b62f0eb47602d7d497e73c55fec82d5
+            });
+            $(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");
+                }
+                initFastLoad();
+                initializeCalendar();
+            });
+            function enableTimeSpecificFields(_checked, _valueClass, _rangeClass) {
+                if (_valueClass) 
+                    $('.' + _valueClass).prop('disabled', _checked);
+                if (_rangeClass) 
+                    $('.' + _rangeClass).prop('disabled', !_checked);
+                }
+            function toggleDisabledAsNeeded(_el, _targetValue, _enableClass, _disableClass) {
+                if (_el.value === _targetValue) {
+                    if (_enableClass) 
+                        $('.' + _enableClass).prop('disabled', false);
+                    if (_disableClass) 
+                        $('.' + _disableClass).prop('disabled', true);
+                    }
+                else {
+                    if (_enableClass) 
+                        $('.' + _enableClass).prop('disabled', true);
+                    if (_disableClass) 
+                        $('.' + _disableClass).prop('disabled', false);
+                    }
+                }
+            function toggleVisibilityAsNeeded(_el, _targetValue, _visibleClass, _hiddenClass) {
+                if (_el.value === _targetValue) {
+                    if (_visibleClass) 
+                        $('.' + _visibleClass).removeClass('d-none');
+                    if (_hiddenClass) 
+                        $('.' + _hiddenClass).addClass('d-none');
+                    }
+                else {
+                    if (_visibleClass) 
+                        $('.' + _visibleClass).addClass('d-none');
+                    if (_hiddenClass) 
+                        $('.' + _hiddenClass).removeClass('d-none');
+                    }
+                }
+            var fastCache = {};
 
-function initFastLoad(_parent = false) {
+            function initFastLoad(_parent = false) {
+                fastCache = {};
 
-    fastCache = {};
+                var allAs = $('a:not([onclick]):not([href="#"])');
+                if (_parent) {
+                    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);
+                                }
+                            }
+                        }
+                    });
 
-    var allAs = $('a:not([onclick]):not([href="#"])');
-    if (_parent) {
-        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);
+                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;
+                        });
+                    // console.info('FastLoad enabled for ' + _a.innerText + ' [' + _a.href + ']');
                 }
-            }
-        }
-    });
 
-    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');
+                // fast cache
+                allAs = $('a:not([onclick]):not([href="#"])');
+                allAs.each(function () {
+                    var a = this;
+                    $.get(a.href, function (_data) {
+                        fastCache[a.href] = _data;
+                    });
+                });
             }
-            return false;
-        });
-        // console.info('FastLoad enabled for ' + _a.innerText + ' [' + _a.href + ']');
-    }
-
-    // fast cache
-    allAs = $('a:not([onclick]):not([href="#"])');
-    allAs.each(function () {
-        var a = this;
-        $.get(a.href, function (_data) {
-            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");
+                    if (content && content.length) {
+                        content = content.html();
+                        content += '<script src="/js/yemi.js"></script>';
+                        targetParent.html(content);
+                        initFastLoad(targetParent);
+                        initializeCalendar();
 
-function fastLoad(_href, _history = true, _useCache = true) {
-    function onData(_data) {
-        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>';
-            targetParent.html(content);
-            initFastLoad(targetParent);
-            initializeCalendar();
-
-            // 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);
+                        // 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);
+                                }
+                            }
+                            window
+                                .top
+                                .history
+                                .pushState(target, null, "/mc/" + target);
+                        }
+                    } else {
+                        console.warn("Target page not found: " + _href);
+                        window.location.href = _href; // fallback
                     }
+                    hideMask();
+                }
+                showMask();
+                if (_useCache && !!fastCache[_href]) {
+                    onData(fastCache[_href]);
+                } else {
+                    $.get(_href, onData);
                 }
-                window.top.history.pushState(target, null, '/mc/' + target);
             }
 
-        } else {
-            console.warn('Target page not found: ' + _href);
-            window.location.href = _href; // fallback
-        }
-        hideMask();
-    }
-    showMask();
-    if (_useCache && !!fastCache[_href]) {
-        onData(fastCache[_href]);
-    } else {
-        $.get(_href, onData);
-    }
-}
-
-function 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();
-}
+            function openInRHS(_url) {
+                window
+                    .top
+                    .showRHS();
+                var icon = $(".stag_rhs_toggle i");
+                icon
+                    .removeClass()
+                    .addClass("fa fa-arrow-right");
+                window
+                    .top
+                    .openInRHS(_url);
+                return false;
+            }

+ 56 - 19
resources/views/app/dashboard.blade.php

@@ -1,6 +1,22 @@
 @extends ('layouts.template')
 
 @section('content')
+<<<<<<< HEAD
+<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="p-3">
         <div class="container m-0 mt-4">
             <div class="row">
@@ -15,6 +31,7 @@
                         <div class="card-body p-0">
                             <table class="table table-condensed table-bordered m-0">
                                 <tbody>
+>>>>>>> 8a6acabd0b62f0eb47602d7d497e73c55fec82d5
                                 <tr>
                                     <th>{{$keyNumbers['totalPatients']}}</th>
                                     <th>Total patients</th>
@@ -31,19 +48,19 @@
                                     <th>{{$keyNumbers['pendingNotesToSign']}}</th>
                                     <th>Pending notes to sign</th>
                                 </tr>
-                                </tbody>
-                            </table>
-                        </div>
+                            </tbody>
+                        </table>
                     </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>
+                <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>
                                 <tr>
                                     <th>{{$reimbursement['currentBalance']}}</th>
                                     <th>Current balance</th>
@@ -60,15 +77,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');
-
 });