464 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			464 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
 | 
						|
<!--sidebar end-->
 | 
						|
<!--main content start-->
 | 
						|
<?php if($this->session->flashdata('feedback_error')){ ?>
 | 
						|
    <script>
 | 
						|
    Swal.fire({
 | 
						|
              position: 'center',
 | 
						|
              icon: 'error',
 | 
						|
              title: '<?php echo $this->session->flashdata('feedback_error'); ?>',
 | 
						|
              showConfirmButton: false,
 | 
						|
              timer: 3500
 | 
						|
            })
 | 
						|
    </script>
 | 
						|
<?php } ?>
 | 
						|
<?php if($this->session->flashdata('feedback_success')){ ?>
 | 
						|
    <script>
 | 
						|
    Swal.fire({
 | 
						|
              position: 'center',
 | 
						|
              icon: 'success',
 | 
						|
              title: '<?php echo $this->session->flashdata('feedback_success'); ?>',
 | 
						|
              showConfirmButton: false,
 | 
						|
              timer: 3500
 | 
						|
            })
 | 
						|
    </script>
 | 
						|
<?php } ?>
 | 
						|
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
 | 
						|
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
 | 
						|
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> -->
 | 
						|
<div class="app-content content">
 | 
						|
    <section class="content-wrapper">
 | 
						|
        <div class="row">
 | 
						|
            <div class="col-12">
 | 
						|
                <div class="card">
 | 
						|
                    <div class="card-header">
 | 
						|
                        <div class="row">
 | 
						|
                            <div class="col-md-12">
 | 
						|
                                <h3 class="font-weight-bold">
 | 
						|
                                <?php echo lang('Schedule of').' '.$caregiver->fname.' '.$caregiver->lname; ?>
 | 
						|
                                </h3>
 | 
						|
                            </div>
 | 
						|
                        </div>
 | 
						|
                    </div>
 | 
						|
                    <hr class="mt-0 mb-0" />
 | 
						|
                    
 | 
						|
                    <div class="card-body">
 | 
						|
                        <div class="row">
 | 
						|
                            <div class="col-8">
 | 
						|
                                <div class="row">
 | 
						|
                                    <div class="form-group col-md-3">
 | 
						|
                                        <label for="exampleInputEmail1" class="required-field">Select Patient</label>
 | 
						|
                                    </div>
 | 
						|
                                    <div class="form-group col-md-9">
 | 
						|
                                        <select class="form-control" name="parient" onchange="getPatientSchedule(this.value)">
 | 
						|
                                            <option value="" selected disabled>Select</option>
 | 
						|
                                            <?php foreach($patients as $patient){ ?>
 | 
						|
                                              <option value="<?php echo $patient->id; ?>"><?php echo $patient->first_name.' '.$patient->last_name; ?></option>
 | 
						|
                                            <?php } ?> 
 | 
						|
                                        </select>
 | 
						|
                                    </div>
 | 
						|
                                </div>
 | 
						|
                            </div>    
 | 
						|
                        </div>    
 | 
						|
                        <div class="row" id="view_calendar" style="display:none;">
 | 
						|
                            <div class="col-12">
 | 
						|
                                <div class="row" >
 | 
						|
                                  <!-- <div class="col-2">
 | 
						|
                                    <div id='external-events'>
 | 
						|
                                      <h4>Drage me</h4>
 | 
						|
                                      <div class="fc-events-container">
 | 
						|
                                        <div class='fc-event' data-duration='24:00' data-color='#ff4d4d'>On Leave</div>
 | 
						|
                                        <?php foreach($patients as $patient){ ?>
 | 
						|
                                        <div class='fc-event' data-event='{ "url":"abcd", title": "<?php echo $patient->first_name.' '.$patient->last_name; ?>" }' data-color='#2D95BF'><?php echo $patient->first_name.' '.$patient->last_name; ?></div>
 | 
						|
                                        <?php } ?>
 | 
						|
                                        
 | 
						|
                                        <p>
 | 
						|
                                          <input type='checkbox' id='drop-remove' />
 | 
						|
                                          <label for='drop-remove'>remove after drop</label>
 | 
						|
                                        </p>
 | 
						|
                                      </div>
 | 
						|
                                    </div>
 | 
						|
                                  </div> -->
 | 
						|
                                  <div class="col-12">
 | 
						|
                                    <div id='caregiver-calendar'></div>
 | 
						|
                                  </div>
 | 
						|
                                </div>
 | 
						|
                            </div>
 | 
						|
                        </div>
 | 
						|
                    </div>
 | 
						|
                </div>
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
    </section>
 | 
						|
</div>
 | 
						|
<button type="button" onclick="ShowModal()" >
 | 
						|
  Launch demo modal
 | 
						|
</button>
 | 
						|
<!-- Add Schedule Modal -->
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<!-- Modal -->
 | 
						|
 | 
						|
<!-- Modal -->
 | 
						|
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
 | 
						|
  <div class="modal-dialog modal-dialog-centered" role="document">
 | 
						|
    <div class="modal-content">
 | 
						|
      <div class="modal-header">
 | 
						|
        <h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
 | 
						|
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
 | 
						|
          <span aria-hidden="true">×</span>
 | 
						|
        </button>
 | 
						|
      </div>
 | 
						|
      <div class="modal-body">
 | 
						|
        ...
 | 
						|
      </div>
 | 
						|
      <div class="modal-footer">
 | 
						|
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
 | 
						|
        <button type="button" class="btn btn-primary">Save changes</button>
 | 
						|
      </div>
 | 
						|
    </div>
 | 
						|
  </div>
 | 
						|
</div>
 | 
						|
 | 
						|
<script>
 | 
						|
    $(document).ready(function () {
 | 
						|
        // var calendar=$('#caregiver-calendar').fullCalendar({
 | 
						|
        //     header: {
 | 
						|
        //         left: 'prev,next today',
 | 
						|
        //         center: 'title',
 | 
						|
        //         right: 'agendaWeek'
 | 
						|
        //     },
 | 
						|
        //     editable: true,
 | 
						|
        //     selectable: true,
 | 
						|
        //     droppable: true, // this allows things to be dropped onto the calendar
 | 
						|
        //     defaultDate: new Date(),
 | 
						|
        //     defaultView: 'agendaWeek',
 | 
						|
        //     slotDuration: '01:00',
 | 
						|
        //     defaultTimedEventDuration: '00:60:00',
 | 
						|
        //     forceEventDuration: true,
 | 
						|
        //     eventOverlap: false,
 | 
						|
        //     events: {
 | 
						|
        //         url: 'caregivers/caregiverEventDetails/',
 | 
						|
        //         data: {id : 12},
 | 
						|
        //         error: function() {
 | 
						|
        //             alert('error');
 | 
						|
        //         }
 | 
						|
        //     },
 | 
						|
        //     select: function(start) {
 | 
						|
        //       //alert('selected ' + info.startStr + ' to ' + info.endStr);
 | 
						|
        //       console.log(start.format());
 | 
						|
        //       //console.log(date);
 | 
						|
        //       ShowModal();
 | 
						|
        //       //$("#addScheduleModal").modal();
 | 
						|
        //     },
 | 
						|
        //     // dayClick: function(date, jsEvent, view) { 
 | 
						|
        //     //     alert('Clicked on: ' + date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear());  
 | 
						|
        //     // },
 | 
						|
        //     drop: function(info) {
 | 
						|
        //         // is the "remove after drop" checkbox checked?
 | 
						|
        //         if ($('#drop-remove').is(':checked')) {
 | 
						|
        //             // if so, remove the element from the "Draggable Events" list
 | 
						|
        //             $(this).remove();
 | 
						|
        //         }
 | 
						|
        //     },
 | 
						|
            
 | 
						|
        //     eventClick: function(event) {
 | 
						|
        //        //console.log(event.id);
 | 
						|
 | 
						|
        //        if(confirm("Are you sure you want to delete schedule?")){
 | 
						|
        //            $.post('caregivers/caregiverEventDelete/',
 | 
						|
        //                     {
 | 
						|
        //                         id: event.id,
 | 
						|
        //                     },
 | 
						|
        //                     function(data, status){
 | 
						|
        //                         console.log(data);
 | 
						|
        //                         console.log(status);
 | 
						|
        //                         if(status=='success'){
 | 
						|
        //                             Swal.fire({
 | 
						|
        //                               position: 'center',
 | 
						|
        //                               icon: 'success',
 | 
						|
        //                               title: 'Schedule deleted.',
 | 
						|
        //                               showConfirmButton: false,
 | 
						|
        //                               timer: 3500
 | 
						|
        //                             });
 | 
						|
        //                             //$("#caregiver-calendar").fullCalendar('eventDestroy');
 | 
						|
        //                             $("#caregiver-calendar").fullCalendar('refetchEvents');
 | 
						|
        //                         }
 | 
						|
        //                     }
 | 
						|
        //                 );
 | 
						|
                   
 | 
						|
        //         }
 | 
						|
 | 
						|
        //     },
 | 
						|
        //     eventDrop: function (info,event) {
 | 
						|
        //         //console.log(info);
 | 
						|
        //         $.post('caregivers/caregiverEventUpdate/',
 | 
						|
        //                 {
 | 
						|
        //                     event_id: info.id,
 | 
						|
        //                     start: info.start.format(),
 | 
						|
        //                     end: info.end.format(),
 | 
						|
        //                 },
 | 
						|
        //                 function(data, status){
 | 
						|
        //                     console.log(data);
 | 
						|
        //                     console.log(status);
 | 
						|
        //                     if(status=='success'){
 | 
						|
        //                         Swal.fire({
 | 
						|
        //                           position: 'center',
 | 
						|
        //                           icon: 'success',
 | 
						|
        //                           title: 'Schedule Updated.',
 | 
						|
        //                           showConfirmButton: false,
 | 
						|
        //                           timer: 3500
 | 
						|
        //                         });
 | 
						|
        //                     }
 | 
						|
        //                     //$("#caregiver-calendar").fullCalendar('refetchEvents');
 | 
						|
        //                 }
 | 
						|
        //             );
 | 
						|
        //     },
 | 
						|
        //     eventReceive:function(event, info){
 | 
						|
        //         //console.log(event);
 | 
						|
        //         //console.log(info);
 | 
						|
        //         //var attr=calendar.calendar.getEvents();
 | 
						|
        //         //console.log(attr);
 | 
						|
        //         //console.log(event);
 | 
						|
        //         $.post('caregivers/caregiverEventSave/',
 | 
						|
        //                 {
 | 
						|
        //                     title: event.title,   
 | 
						|
        //                     start: event.start.format(),
 | 
						|
        //                     end: event.end.format(),
 | 
						|
        //                     color:event.color,
 | 
						|
        //                     caregiver_id:<?php echo $caregiver_id; ?>,
 | 
						|
        //                 },
 | 
						|
        //                 function(data, status){
 | 
						|
        //                     console.log(data);
 | 
						|
        //                     console.log(status);
 | 
						|
        //                     if(status=='success'){
 | 
						|
        //                         Swal.fire({
 | 
						|
        //                           position: 'center',
 | 
						|
        //                           icon: 'success',
 | 
						|
        //                           title: 'Schedule Saved.',
 | 
						|
        //                           showConfirmButton: false,
 | 
						|
        //                           timer: 3500
 | 
						|
        //                         });
 | 
						|
        //                     }
 | 
						|
        //                     //$("#caregiver-calendar").fullCalendar('refetchEvents');
 | 
						|
        //                 }
 | 
						|
        //             );
 | 
						|
                
 | 
						|
        //     },
 | 
						|
        //     eventResize:function(info){
 | 
						|
        //         // console.log(info.start.format());//SET
 | 
						|
        //         // console.log(info.end.format());//SET
 | 
						|
        //         // console.log(info.title);//SET
 | 
						|
        //         $.post('caregivers/caregiverEventUpdate/',
 | 
						|
        //                 {
 | 
						|
        //                     event_id: info.id,
 | 
						|
        //                     start: info.start.format(),
 | 
						|
        //                     end: info.end.format(),
 | 
						|
        //                 },
 | 
						|
        //                 function(data, status){
 | 
						|
        //                     console.log(data);
 | 
						|
        //                     console.log(status);
 | 
						|
        //                     if(status=='success'){
 | 
						|
        //                         Swal.fire({
 | 
						|
        //                           position: 'center',
 | 
						|
        //                           icon: 'success',
 | 
						|
        //                           title: 'Schedule Updated.',
 | 
						|
        //                           showConfirmButton: false,
 | 
						|
        //                           timer: 3500
 | 
						|
        //                         });
 | 
						|
        //                     }
 | 
						|
        //                     //$("#caregiver-calendar").fullCalendar('refetchEvents');
 | 
						|
        //                 }
 | 
						|
        //             );
 | 
						|
        //     },
 | 
						|
 | 
						|
        //     eventRender: function(event, element) {
 | 
						|
        //         element.append( "<span class='closeon'>X</span>" );
 | 
						|
        //         element.find(".closeon").click(function() {
 | 
						|
        //            $('#calendar').fullCalendar('removeEvents',event._id);
 | 
						|
        //         });
 | 
						|
        //     }
 | 
						|
        // });
 | 
						|
        // calendar.on('eventClick', function (info) {
 | 
						|
        //     calendar.getEventById(info.event.id).remove();
 | 
						|
        //     console.log(info);
 | 
						|
        // });
 | 
						|
    });
 | 
						|
    function ShowModal(){
 | 
						|
        //e.preventDefault();
 | 
						|
       // $('#exampleModalCenter').modal();
 | 
						|
        $('#exampleModalCenter').dialog({modal:true});   
 | 
						|
        
 | 
						|
    }
 | 
						|
    function getPatientSchedule(id){
 | 
						|
      //alert(id);
 | 
						|
      patient_id=id;
 | 
						|
      caregiver_id=<?php echo $caregiver->id;?>;
 | 
						|
      //alert(caregiver_id);
 | 
						|
      var calendar=$('#caregiver-calendar').fullCalendar({
 | 
						|
            header: {
 | 
						|
                left: 'prev,next today',
 | 
						|
                center: 'title',
 | 
						|
                right: 'agendaWeek'
 | 
						|
            },
 | 
						|
            editable: true,
 | 
						|
            selectable: true,
 | 
						|
            droppable: true, // this allows things to be dropped onto the calendar
 | 
						|
            defaultDate: new Date(),
 | 
						|
            defaultView: 'agendaWeek',
 | 
						|
            slotDuration: '01:00',
 | 
						|
            defaultTimedEventDuration: '00:60:00',
 | 
						|
            forceEventDuration: true,
 | 
						|
            eventOverlap: false,
 | 
						|
            events: {
 | 
						|
                url: 'caregivers/caregiverEventDetails/',
 | 
						|
                data: {id : 12},
 | 
						|
                error: function() {
 | 
						|
                    alert('error');
 | 
						|
                }
 | 
						|
            },
 | 
						|
            select: function(start) {
 | 
						|
              //alert('selected ' + info.startStr + ' to ' + info.endStr);
 | 
						|
              console.log(start.format());
 | 
						|
              //console.log(date);
 | 
						|
              ShowModal();
 | 
						|
              //$("#addScheduleModal").modal();
 | 
						|
            },
 | 
						|
            // dayClick: function(date, jsEvent, view) { 
 | 
						|
            //     alert('Clicked on: ' + date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear());  
 | 
						|
            // },
 | 
						|
            drop: function(info) {
 | 
						|
                // is the "remove after drop" checkbox checked?
 | 
						|
                if ($('#drop-remove').is(':checked')) {
 | 
						|
                    // if so, remove the element from the "Draggable Events" list
 | 
						|
                    $(this).remove();
 | 
						|
                }
 | 
						|
            },
 | 
						|
            
 | 
						|
            eventClick: function(event) {
 | 
						|
               //console.log(event.id);
 | 
						|
 | 
						|
               if(confirm("Are you sure you want to delete schedule?")){
 | 
						|
                   $.post('caregivers/caregiverEventDelete/',
 | 
						|
                            {
 | 
						|
                                id: event.id,
 | 
						|
                            },
 | 
						|
                            function(data, status){
 | 
						|
                                console.log(data);
 | 
						|
                                console.log(status);
 | 
						|
                                if(status=='success'){
 | 
						|
                                    Swal.fire({
 | 
						|
                                      position: 'center',
 | 
						|
                                      icon: 'success',
 | 
						|
                                      title: 'Schedule deleted.',
 | 
						|
                                      showConfirmButton: false,
 | 
						|
                                      timer: 3500
 | 
						|
                                    });
 | 
						|
                                    //$("#caregiver-calendar").fullCalendar('eventDestroy');
 | 
						|
                                    $("#caregiver-calendar").fullCalendar('refetchEvents');
 | 
						|
                                }
 | 
						|
                            }
 | 
						|
                        );
 | 
						|
                   
 | 
						|
                }
 | 
						|
 | 
						|
            },
 | 
						|
            eventDrop: function (info,event) {
 | 
						|
                //console.log(info);
 | 
						|
                $.post('caregivers/caregiverEventUpdate/',
 | 
						|
                        {
 | 
						|
                            event_id: info.id,
 | 
						|
                            start: info.start.format(),
 | 
						|
                            end: info.end.format(),
 | 
						|
                        },
 | 
						|
                        function(data, status){
 | 
						|
                            console.log(data);
 | 
						|
                            console.log(status);
 | 
						|
                            if(status=='success'){
 | 
						|
                                Swal.fire({
 | 
						|
                                  position: 'center',
 | 
						|
                                  icon: 'success',
 | 
						|
                                  title: 'Schedule Updated.',
 | 
						|
                                  showConfirmButton: false,
 | 
						|
                                  timer: 3500
 | 
						|
                                });
 | 
						|
                            }
 | 
						|
                            //$("#caregiver-calendar").fullCalendar('refetchEvents');
 | 
						|
                        }
 | 
						|
                    );
 | 
						|
            },
 | 
						|
            eventReceive:function(event, info){
 | 
						|
                //console.log(event);
 | 
						|
                //console.log(info);
 | 
						|
                //var attr=calendar.calendar.getEvents();
 | 
						|
                //console.log(attr);
 | 
						|
                //console.log(event);
 | 
						|
                $.post('caregivers/caregiverEventSave/',
 | 
						|
                        {
 | 
						|
                            title: event.title,   
 | 
						|
                            start: event.start.format(),
 | 
						|
                            end: event.end.format(),
 | 
						|
                            color:event.color,
 | 
						|
                            caregiver_id:<?php echo $caregiver_id; ?>,
 | 
						|
                        },
 | 
						|
                        function(data, status){
 | 
						|
                            console.log(data);
 | 
						|
                            console.log(status);
 | 
						|
                            if(status=='success'){
 | 
						|
                                Swal.fire({
 | 
						|
                                  position: 'center',
 | 
						|
                                  icon: 'success',
 | 
						|
                                  title: 'Schedule Saved.',
 | 
						|
                                  showConfirmButton: false,
 | 
						|
                                  timer: 3500
 | 
						|
                                });
 | 
						|
                            }
 | 
						|
                            //$("#caregiver-calendar").fullCalendar('refetchEvents');
 | 
						|
                        }
 | 
						|
                    );
 | 
						|
                
 | 
						|
            },
 | 
						|
            eventResize:function(info){
 | 
						|
                // console.log(info.start.format());//SET
 | 
						|
                // console.log(info.end.format());//SET
 | 
						|
                // console.log(info.title);//SET
 | 
						|
                $.post('caregivers/caregiverEventUpdate/',
 | 
						|
                        {
 | 
						|
                            event_id: info.id,
 | 
						|
                            start: info.start.format(),
 | 
						|
                            end: info.end.format(),
 | 
						|
                        },
 | 
						|
                        function(data, status){
 | 
						|
                            console.log(data);
 | 
						|
                            console.log(status);
 | 
						|
                            if(status=='success'){
 | 
						|
                                Swal.fire({
 | 
						|
                                  position: 'center',
 | 
						|
                                  icon: 'success',
 | 
						|
                                  title: 'Schedule Updated.',
 | 
						|
                                  showConfirmButton: false,
 | 
						|
                                  timer: 3500
 | 
						|
                                });
 | 
						|
                            }
 | 
						|
                            //$("#caregiver-calendar").fullCalendar('refetchEvents');
 | 
						|
                        }
 | 
						|
                    );
 | 
						|
            },
 | 
						|
 | 
						|
            eventRender: function(event, element) {
 | 
						|
                element.append( "<span class='closeon'>X</span>" );
 | 
						|
                element.find(".closeon").click(function() {
 | 
						|
                   $('#calendar').fullCalendar('removeEvents',event._id);
 | 
						|
                });
 | 
						|
            }
 | 
						|
        });
 | 
						|
      $('#view_calendar').show();
 | 
						|
    }
 | 
						|
</script>
 | 
						|
<!--main content end-->
 | 
						|
<!--footer start-->
 | 
						|
 | 
						|
 | 
						|
 |