Browse Source

Calendar based new-appt. [WIP 2]

Vijayakrishnan 4 years ago
parent
commit
bb89063d32
1 changed files with 12 additions and 24 deletions
  1. 12 24
      resources/views/app/patient/manage-appointment.blade.php

+ 12 - 24
resources/views/app/patient/manage-appointment.blade.php

@@ -63,36 +63,24 @@
                     },
                     },
                     initialDate: '{{ date('Y-m-d') }}',
                     initialDate: '{{ date('Y-m-d') }}',
                     editable: false,
                     editable: false,
-                    navLinks: true, // can click day/week names to navigate views
-                    dayMaxEvents: false, // allow "more" link when too many events
-                    // events: {
-                    //     url: '',
-                    //     failure: function(_e) {
-                    //         // document.getElementById('script-warning').style.display = 'block'
-                    //         console.log(_e);
-                    //     }
-                    // },
+                    navLinks: true,
+                    dayMaxEvents: true,
+                    events: function(info, successCallback, failureCallback) {
+                        $.get('/api/appointment/getAllAppointmentsForPro?start=1990-01-01&end=2025-01-01&timeZone=CENTRAL', function(_data) {
+                            if(_data && _data.success) {
+                                successCallback(_data.data);
+                            }
+                            else {
+                                failureCallback('Unable to fetch appointments!');
+                            }
+                        }, 'json');
+                    },
                     loading: function(bool) {
                     loading: function(bool) {
                         // document.getElementById('loading').style.display =
                         // document.getElementById('loading').style.display =
                         //     bool ? 'block' : 'none';
                         //     bool ? 'block' : 'none';
                     }
                     }
                 });
                 });
                 calendarObject.render();
                 calendarObject.render();
-                refreshEvents();
-            }
-            function refreshEvents() {
-                $.get('/api/appointment/getAllAppointmentsForPro?start=1990-01-01&end=2025-01-01&timeZone=CENTRAL', function(_data) {
-                    if(_data && _data.success) {
-                        calendarObject.removeAllEvents();
-                        for (let i = 0; i < _data.data.length; i++) {
-                            let event = _data.data[i];
-                            calendarObject.addEvent(event);
-                        }
-                    }
-                    else {
-                        toastr.error('Unable to fetch appointments!');
-                    }
-                }, 'json');
             }
             }
             addMCInitializer('patient-manage-appointment-' + Math.random() * 10000, init);
             addMCInitializer('patient-manage-appointment-' + Math.random() * 10000, init);
         })();
         })();