687 lines
41 KiB
PHP
Executable File

<!--sidebar end-->
<!--main content start-->
<?php
$dayArr=array();
$dayTimeArr=array();
foreach($master_schdule as $schedule){
$dayArr[$schedule->week_day][]=$schedule->id;
$dayTimeArr[$schedule->week_day][]=$schedule->from_time.' - '.$schedule->to_time;
}
$progressData = json_decode($nurse->from_tab_status_pctg);
$progress = $progressData->form1+$progressData->form2+$progressData->form3+$progressData->form4+$progressData->form5+$progressData->form6+$progressData->form7+$progressData->form8+$progressData->form9+$progressData->form10+$progressData->form11;
if($this->session->flashdata('feedback_greeting_by_system_user')){
?>
<script>
Swal.fire({
position: 'center',
icon: 'success',
title: '<?php echo $this->session->flashdata('feedback_greeting_by_system_user'); ?>',
showConfirmButton: false,
timer: 3500
})
</script>
<?php
unset($_SESSION['feedback_greeting_by_system_user']);
}
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
unset($_SESSION['feedback_error']);
}
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
unset($_SESSION['feedback_success']);
}
?>
<div class="app-content content">
<div class="content-wrapper">
<div class="content-body">
<section id="block-examples">
<div class="row">
<div class="col-md-12 col-sm-12">
<div class="card">
<div class="card-header bg-gradient-y-info">
<h2 class="text-center p-1">
<span class="font-weight-bold text-white"><?=lang('Schedule Panel')?></span>
</h2>
</div>
<div class="card-body">
<div class="row mb-0">
<div class="col-md-12">
<?php
if($nurse->submited_for_verification=='yes' && $nurse->verification_status=='verified'){
?>
<div class="state-overview col-md-12">
<div class="clearfix card">
<div class="col-12">
<div class="row ">
<div class="col-11">
<div id='caregiver-calendar' class="rght_calndr mt_20"></div>
</div>
<div class="col-md-1">
<div class="align-items-center mt_20">
<!--- first modal ---->
<a href="#" class="modal1 tooltip" data-toggle="modal" data-target="#exampleModal">
<span class="tooltiptext">Upcoming Schedule</span>
<i class="la la-calendar-o"></i>
</a>
<br>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog2 modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">
<i class="la la-angle-right"></i>
</span>
</button>
<h5 class="modal-title" id="exampleModalLabel">Upcoming Schedule</h5>
</div>
<div class="modal-body">
<div id="patient-Schedule">
<table class="table table-striped table-bordered dom-jQuery-events" cellspacing="0" width="100%">
<thead>
<tr>
<th><?php echo lang('Date'); ?></th>
<th><?php echo lang('From (Time)'); ?></th>
<th><?php echo lang('To (Time)'); ?></th>
<th><?php echo lang('Status'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($upcomming_schedules as $us) { ?>
<tr>
<td><?php echo date("Y/m/d",strtotime($us->start)); ?></td>
<td><?php echo date("g:i A",strtotime($us->start)); ?></td>
<td><?php echo date("g:i A",strtotime($us->end)); ?></td>
<?php
if($us->acceptance_status=='Unconfirmed'){
$style='style="color: #de2066;"';
}else if($us->acceptance_status=='Accepted'){
$style='style="color: #4ac344;"';
}else if($us->acceptance_status=='Declined'){
$style='style="color: #de2066;"';
}else if($us->acceptance_status=='Reported'){
$style='style="color: #bb6e06;"';
}
?>
<td <?php echo $style; ?> ><?php echo $us->acceptance_status; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!--- first modal ---->
<!--- second modal ---->
<a href="#" class="modal2 tooltip" data-toggle="modal" data-target="#exampleModal2">
<span class="tooltiptext">Previous Schedule</span>
<i class="la la-calendar-o"></i>
</a>
<br>
<div class="modal fade" id="exampleModal2" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog2 modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="la la-angle-right"></i></span>
</button>
<h5 class="modal-title" id="exampleModalLabel">Previous Schedule</h5>
</div>
<div class="modal-body">
<div id="patient-Schedule">
<table class="table table-striped table-bordered dom-jQuery-events" cellspacing="0" width="100%">
<thead>
<tr>
<th><?php echo lang('Date'); ?></th>
<th><?php echo lang('From (Time)'); ?></th>
<th><?php echo lang('To (Time)'); ?></th>
<th><?php echo lang('Status'); ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($previuos_schedules as $ps)
{
?>
<tr>
<td><?php echo date("Y/m/d",strtotime($ps->start)); ?></td>
<td><?php echo date("g:i A",strtotime($ps->start)); ?></td>
<td><?php echo date("g:i A",strtotime($ps->end)); ?></td>
<?php
if($ps->acceptance_status=='Unconfirmed'){
$style='style="color: #de2066;"';
}else if($ps->acceptance_status=='Accepted'){
$style='style="color: #4ac344;"';
}else if($ps->acceptance_status=='Declined'){
$style='style="color: #de2066;"';
}else if($ps->acceptance_status=='Reported'){
$style='style="color: #bb6e06;"';
}
?>
<td <?php echo $style; ?> ><?php echo $ps->acceptance_status; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!--- second modal ---->
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
</div>
<!-- Add Availability Modal -->
<div class="modal fade" id="addAvailability" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<form action="<?php echo base_url(); ?>CaregiversSchedule/saveAvailability" use="saveAvailabilityData" method="post">
<input type="hidden" name="caregiver_id" id="caregiver_id" value="">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash(); ?>" />
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Add Availability</h5>
<button type="button" class="close" onclick="modalClose()" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12">
<div class="row">
<div class="form-group col-6">
<label for="exampleInputEmail1" class="required-field"><?php echo lang('Caregiver Name'); ?></label>
<input type="text" class="form-control" id="caregiver_fullName" value='<?php echo $nurse->fname.' '.$nurse->lname; ?>' readonly>
</div>
<div class="form-group col-6">
<label for="exampleInputEmail1" class="required-field"><?php echo lang('Date'); ?></label>
<input type="date" name="Sdate" id="Sdate" class="form-control" readonly>
</div>
<!-- <div class="form-group col-6">
<label for="exampleInputEmail1" class="required-field"><?php echo lang('Preference Time'); ?></label>
<input type="text" class="form-control" value="<?php echo $nurse->preferred_time; ?> " readonly>
</div> -->
</div>
<div class="row" id="timediv">
<div class="form-group col-6">
<label for="exampleInputEmail1" class="required-field"><?php echo lang('From'); ?></label>
<input type="time" name="startTime" id="startTime" value="<?php echo $nurse->preferred_start; ?>" class="form-control">
<div class="error alert alert-light text-danger" id="startError" style="display:none;"></div>
</div>
<div class="form-group col-6">
<label for="exampleInputEmail1" class="required-field"><?php echo lang('To'); ?></label>
<input type="time" name="endTime" id="endTime" value="<?php echo $nurse->preferred_end; ?>" class="form-control">
<div class="error alert alert-light text-danger" id="endError" style="display:none;"></div>
</div>
</div>
<div class="row" id="OldScheduleInfo">
</div>
<div class="row error" id="saveError"></div>
<div class="row error" id="showmsg"></div>
<p id="test"></p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" onclick="modalClose()" data-dismiss="modal">Close</button>
<button type="submit" id="SubmitsaveEvent" class="btn btn-primary" onclick="return check_conflict();">Save</button>
</div>
</form>
</div>
</div>
</div>
<input type="hidden" id="caregiver_name" value="<?php echo $nurse->fname.' '.$nurse->lname; ?>">
<input type="hidden" id="caregiver_day" value="">
<!-- Add Availability Modal Ending here -->
<!-- patient handling modal -->
<div class="modal fade" id="infoSchedule" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-sm modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Schedule Details</h5>
<button type="button" class="close" onclick="modalClose()" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12 insert-html">
<input type="hidden" class="caregiver-id" value="">
<input type="hidden" class="patient-id" value="">
<input type="hidden" class="schedule-id" value="">
<div class="row">
<div class="form-group col-12">
<h4 class="text-center" style="font-weight: bold;">...</h4>
</div>
</div>
<div class="row pt-2">
<div class="form-group col-12 center">
<button class="btn btn-success pull-right clock-in-button">Clock In</button>
</div>
</div>
<div class="row pt-2">
<div class="form-group col-6">
<button class="btn btn-danger pull-right clock-out-button">Clock Out</button>
</div>
<div class="form-group col-6">
<button class="btn btn-warning report-button">Report</button>
</div>
</div>
<div class="row pt-2">
<div class="form-group col-12 center">
<a type="button" href="<?php echo base_url();?>assessment?id=62&scheduleId=109" class="btn btn-danger">Report</a>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" onclick="modalClose()" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- patient handling modal -->
<script type="text/javascript">
function modalClose(){
$("#showmsg").text('');
}
$(document).ready(function(){
var caregiverId=<?php echo $nurse->id;?>;
var today=new Date();
var calendar=$('#caregiver-calendar').fullCalendar({
defaultView:"agendaWeek",
allDaySlot: false,
editable: false,
selectable: true,
droppable: false, // this allows things to be dropped onto the calendar
defaultDate: today,
columnHeaderFormat: 'D - ddd',
events: {
url: '<?php echo base_url(); ?>home/getSchedule/',
data: {caregiverId : caregiverId},
error: function() {
alert('error');
}
},
eventClick: function(event) {
console.log(event);
// if(confirm("Are you sure you want to delete schedule?")){
// deleteSchedule(event.id,event.patientId,event.caregiverId);
// }
getScheduledetails(event.caregiverId,event.patientId,event.id);
},
select: function(info,start) {
var scheduleDate=info.format('YYYY-MM-DD');
if(start.isBefore(moment())) {
$('#caregiver-calendar').fullCalendar('unselect');
console.log('Previous date');
return false;
}else{
if(info){
loadModal(caregiverId,scheduleDate);
}
}
},
});
});
function loadModal(caregiverId,scheduleDate)
{
var CaregiverName=$("#caregiver_name").val();
$(".Error").html('');
$('#caregiver_fullName').val(CaregiverName);
$('#Sdate').val(scheduleDate);
$('#caregiver_id').val(caregiverId);
var newDay=[];
var newAllDay=[];
$.ajax({ //create an ajax request to display.php
type: "GET",
url: "<?php echo base_url(); ?>CaregiversSchedule/getPreferenceDay",
dataType: 'json',
data: {
caregiver_id: caregiverId,
},
success: function(data){
// console.log(data[0]) ;
for(var i=0; i< data.length; i++){
// newDay.push( data[i].day);
if(data[i].day == 1){
newAllDay.push("everyday");
}else if(data[i].day == 2){
newDay.push("Sun");
}else if(data[i].day == 3){
newDay.push("Mon");
}else if(data[i].day == 4){
newDay.push("Tues");
}else if(data[i].day == 5){
newDay.push("Wed");
}else if(data[i].day == 6){
newDay.push("Thu");
}else if(data[i].day == 7){
newDay.push("Fri");
}else if(data[i].day == 8){
newDay.push("Sat");
}
}
$('#caregiver_day').val(JSON.stringify( newDay));
const dateStr = scheduleDate,
getWeekday = s => {
const [yyyy, mm, dd] = s.split('-'),
date = new Date(yyyy, mm-1, dd)
return date.toLocaleDateString('en-US', {weekday: 'short'})
}
var dayName = getWeekday(dateStr);
if(dayName == "Sun"){
var day = 2;
}else if(dayName == "Mon"){
var day = 3;
}else if(dayName == "Tues"){
var day = 4;
}else if(dayName == "Wed"){
var day = 5;
}else if(dayName == "Thu"){
var day = 6;
}else if(dayName == "Fri"){
var day = 7;
}else if(dayName == "Sat"){
var day = 8;
}
if( ($.inArray(dayName, newDay) !== -1) || (newAllDay.length != 0) ) {
if(newAllDay.length != 0){
var allday = 1;
$.ajax({
type: "GET",
url: "<?php echo base_url(); ?>CaregiversSchedule/getCaregiverPreferenceDate",
dataType: 'json',
data: {
caregiver_id: caregiverId,
day: allday,
},
success: function(data){
if(data.time){
let array = (data.time).split(",");
$("#startTime").val(array[0]);
$("#endTime").val(array[1]);
console.log(array);
}else if(data.session){
var name = data.name;
var from_time = "";
var to_time = "";
var parts = (data.name).split(" ");
console.log(parts);
if(parts.length > 1) {
var lastname = parts.pop();
}
else
{
var lastname = " ";
}
var time= lastname.split("-");
from_time = time[0];
to_time = time[1];
var hours = parseInt(from_time.substr(0, 2));
if(from_time.indexOf('am') != -1 && hours == 12) {
from_time = from_time.replace('12', '00'+':00');
}
if(from_time.indexOf('pm') != -1 && hours < 12) {
from_time = from_time.replace(hours, (hours + 12)+':00');
}
if(from_time.indexOf('pm') != -1 && hours == 12) {
from_time = from_time.replace('12', '12'+':00');
}
var to_time_hours = parseInt(to_time.substr(0, 2));
if(to_time.indexOf('am') != -1 && to_time_hours == 12) {
to_time = to_time.replace('12', '00'+':00');
}
if(to_time.indexOf('pm') != -1 && to_time_hours < 12) {
to_time = to_time.replace(to_time_hours, (to_time_hours + 12)+':00');
}
if(to_time.indexOf('pm') != -1 && to_time_hours == 12) {
to_time = to_time.replace('12', '12'+':00');
}
// return to_time.replace(/(am|pm)/, '');
$("#startTime").val(from_time.replace(/(am|pm)/, ''));
$("#endTime").val(to_time.replace(/(am|pm)/, ''));
}
}
})
}else{
$.ajax({
type: "GET",
url: "<?php echo base_url(); ?>CaregiversSchedule/getCaregiverPreferenceDate",
dataType: 'json',
data: {
caregiver_id: caregiverId,
day: day,
},
success: function(data){
if(data.time){
let array = (data.time).split(",");
$("#startTime").val(array[0]);
$("#endTime").val(array[1]);
console.log(array);
}else if(data.session){
var name = data.name;
var from_time = "";
var to_time = "";
var parts = (data.name).split(" ");
console.log(parts);
if(parts.length > 1) {
var lastname = parts.pop();
}
else
{
var lastname = " ";
}
var time= lastname.split("-");
from_time = time[0];
to_time = time[1];
var hours = parseInt(from_time.substr(0, 2));
if(from_time.indexOf('am') != -1 && hours == 12) {
from_time = from_time.replace('12', '00'+':00');
}
if(from_time.indexOf('pm') != -1 && hours < 12) {
from_time = from_time.replace(hours, (hours + 12)+':00');
}
if(from_time.indexOf('pm') != -1 && hours == 12) {
from_time = from_time.replace('12', '12'+':00');
}
var to_time_hours = parseInt(to_time.substr(0, 2));
if(to_time.indexOf('am') != -1 && to_time_hours == 12) {
to_time = to_time.replace('12', '00'+':00');
}
if(to_time.indexOf('pm') != -1 && to_time_hours < 12) {
to_time = to_time.replace(to_time_hours, (to_time_hours + 12)+':00');
}
if(to_time.indexOf('pm') != -1 && to_time_hours == 12) {
to_time = to_time.replace('12', '12'+':00');
}
// return to_time.replace(/(am|pm)/, '');
$("#startTime").val(from_time.replace(/(am|pm)/, ''));
$("#endTime").val(to_time.replace(/(am|pm)/, ''));
}
}
})
}
$("#timediv").show();
$("#SubmitsaveEvent").show();
$("#showmsg").hide();
}else{
// alert("not found");
$("#timediv").hide();
$("#SubmitsaveEvent").hide();
$("#showmsg").append('<div class="alert alert-light text-danger col-12">Caregiver Not Available.</div>');
}
},
error: function(data){
// $("#test").html("ajax error");
}
});
$("#addAvailability").modal('show');
}
function check_conflict(){
var startTime=$("#startTime").val();
var endTime=$("#endTime").val();
var caregiver_id=$("#caregiver_id").val();
//var patient_id=$("#patient_id").val();
var scheduleDate=$("#Sdate").val();
$(".error").html('');
$("#startError").hide();
$("#endError").hide();
if(startTime==""){
$("#startError").html('Please Enter From Time.').show();
return false;
}else
if(endTime==""){
$("#endError").html('Please Enter To Time.').show();
return false;
}else
if(startTime>=endTime){
$("#saveError").append('<div class="alert alert-light text-danger col-12">To Time Must be Greater Then From Time.</div>');
return false;
}else{
$.get('<?php echo base_url(); ?>CaregiversSchedule/CheckAvailability',
{ caregiver_id:caregiver_id, scheduleDate:scheduleDate, startTime:startTime, endTime:endTime },
function(data){
console.log(data);
//return false;
if(data!=""){
$("#saveError").append('<div class="alert alert-light text-danger col-12">'+data+'</div>');
return false;
}else{
$(".error").html('');
$("form[use=saveAvailabilityData]").submit();
return true;
}
}
);
return false;
}
return false;
}
function getScheduledetails(cg_id,pt_id,sch_id){
$.ajax({
url:"<?php echo base_url();?>CaregiversDashboard/getScheduleDetailsByScheduleId",
type:"GET",
data:{cg_id:cg_id,pt_id:pt_id,sch_id:sch_id},
// dataType:"JSON",
success:function(data){
// alert(data.title);
// $(".caregiver-id").val(cg_id);
// $(".patient-id").val(pt_id);
// $(".schedule-id").val(sch_id);
$(".insert-html").html(data);
$(".decline-reason-container").hide();
$("#infoSchedule").modal('show');
}
});
}
</script>
<!-- for accept or declination -->
<script type="text/javascript">
$(document).on('click','.decline-button',function(){
var target_parent=$(this).parent().siblings('.decline-reason-container');
target_parent.toggle("slow");
});
$(document).on('click','.accept-button',function(){
var acceptance_status="Accepted";
var rejection_reason="";
var sch_id=$(this).parent().parent().siblings(".schedule-id").val();
ajaxLoadForAcceptanceUpdate(acceptance_status,rejection_reason,sch_id);
});
$(document).on('click','.decline-save-button',function(){
var acceptance_status="Declined";
var rejection_reason=$(this).parent().siblings(".rejection-reason-container").children(".rejection-reason").val();
var sch_id=$(this).parent().parent().parent().parent().siblings(".schedule-id").val();
if(rejection_reason==""){
alert("Please Provide a reason");
}else{
ajaxLoadForAcceptanceUpdate(acceptance_status,rejection_reason,sch_id);
}
});
function ajaxLoadForAcceptanceUpdate(acceptance_status,rejection_reason,sch_id){
$.ajax({
url:"<?php echo base_url();?>CaregiversDashboard/updateAcceptanceFromDasboard",
type:"GET",
data:{acceptance_status:acceptance_status, rejection_reason:rejection_reason, sch_id:sch_id},
success:function(data){
// alert(data);
Swal.fire({
position: 'center',
icon: 'success',
title: 'You have '+acceptance_status+' the schedule',
showConfirmButton: false,
timer: 3500
});
$("#infoSchedule").modal('hide');
location.reload();
}
});
}
</script>
<!-- for accept or declination -->