511 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			511 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
<?php
 | 
						|
 | 
						|
if (!defined('BASEPATH'))
 | 
						|
    exit('No direct script access allowed');
 | 
						|
 | 
						|
class Patient_schedule_model extends CI_model {
 | 
						|
 | 
						|
    function __construct() {
 | 
						|
        parent::__construct();
 | 
						|
        $this->load->database();
 | 
						|
    }
 | 
						|
    function getPatientDetails($patientId){
 | 
						|
        $patientobj=$this->db->get_where('patient_details',array('id'=>$patientId))->row();
 | 
						|
        $careobj=$this->db->get_where('master_cg_skills',array('id'=>$patientobj->level_of_service))->row();
 | 
						|
        $languageObj=$this->db->get_where('master_language',array('id'=>$patientobj->primary_language))->row();
 | 
						|
        //echo '<pre>';print_r($patientobj);echo '</pre>';die;
 | 
						|
        $patient=array(
 | 
						|
                'patient_table_id'=>$patientobj->id,
 | 
						|
                'patient_id'=>$patientobj->patient_id,
 | 
						|
                'patient_fullname'=>$patientobj->first_name.' '.$patientobj->last_name,
 | 
						|
                'telephone'=>$patientobj->telephone,
 | 
						|
                'level_service'=>$careobj->name,
 | 
						|
                'distance'=>$patientobj->distance,
 | 
						|
                'gender'=>$patientobj->gender,
 | 
						|
                'primary_language'=>$languageObj->name,
 | 
						|
                'latitude'=>$patientobj->latitude,
 | 
						|
                'longitude'=>$patientobj->longitude,
 | 
						|
                );
 | 
						|
        return $patient;
 | 
						|
    }
 | 
						|
    function patientDetailsForModal($patientId){
 | 
						|
        $this->db->where('id', $patientId);
 | 
						|
        $query = $this->db->get('patient_details');
 | 
						|
        return $query->row();
 | 
						|
    }
 | 
						|
    function getCaregiverList($patientId,$patient){
 | 
						|
        // pre($patient);die();
 | 
						|
        $this->db->select('a.level_of_service,a.service_ids');
 | 
						|
        $this->db->from('patient_details a');
 | 
						|
        $this->db->where('a.id', $patientId); 
 | 
						|
        $data  = $this->db->get()->row();
 | 
						|
        $skillId=$data->level_of_service;
 | 
						|
        $service_id=$data->service_ids;
 | 
						|
 | 
						|
        // $this->db->where('experience_id',$service_id);
 | 
						|
        // $this->db->order_by('group_id','asc');
 | 
						|
        // $this->db->from('caregiver_experience');
 | 
						|
        // $query=$this->db->get();
 | 
						|
        // $result=$query->result();
 | 
						|
        // pre($result);die;
 | 
						|
 | 
						|
        $this->db->select('a.*');
 | 
						|
        $this->db->from('caregiver a');
 | 
						|
        $this->db->join('caregiver_experience b', 'b.caregiver_id = a.id', 'left'); 
 | 
						|
        $this->db->where('a.qualification_type',$skillId);
 | 
						|
        $this->db->where('a.submited_for_verification','yes');
 | 
						|
        $this->db->where('a.verification_status','verified');
 | 
						|
        $this->db->where('a.status',"1");
 | 
						|
        $this->db->where('b.experience_id',$service_id);
 | 
						|
        $query=$this->db->get();
 | 
						|
        $dataCaregiver=$query->result();
 | 
						|
 | 
						|
        // $dataCaregiver=$this->db->get_where('caregiver',array(
 | 
						|
        //                                                         'qualification_type'=>$skillId, 
 | 
						|
        //                                                         'submited_for_verification'=>'yes', 
 | 
						|
        //                                                         'verification_status'=>'verified',
 | 
						|
        //                                                         'status'=>'1'
 | 
						|
        //                                                     ))->result();
 | 
						|
        // pre($dataCaregiver);die;
 | 
						|
 | 
						|
        $i=0;
 | 
						|
        foreach ($dataCaregiver as $caregiver ) {
 | 
						|
            //$cgSkilObj=$this->db->get_where()->row();
 | 
						|
            $careobj=$this->db->get_where('master_cg_skills',array('id'=>$caregiver->qualification_type))->row();
 | 
						|
            $caregiverArr[$i]['caregiver_table_id']= $caregiver->id;   
 | 
						|
            $caregiverArr[$i]['caregiver_id']=$caregiver->caregiver_id;    
 | 
						|
            $caregiverArr[$i]['full_name']= $caregiver->fname.' '.$caregiver->lname;     
 | 
						|
            $caregiverArr[$i]['cellphone']=$caregiver->phone;      
 | 
						|
            $caregiverArr[$i]['email']=$caregiver->email;    
 | 
						|
            $caregiverArr[$i]['contact_method']=$caregiver->preferred_contact;     
 | 
						|
            $caregiverArr[$i]['gendar']=$caregiver->gender;     
 | 
						|
            $caregiverArr[$i]['language']=$caregiver->primary_langualge;     
 | 
						|
            $caregiverArr[$i]['skill_info']['skill']=$careobj->name;
 | 
						|
            $caregiverArr[$i]['match_percent']='';
 | 
						|
            // $caregiverArr[$i]['latitude']=$caregiver->lang1;
 | 
						|
            // $caregiverArr[$i]['longitude']=$caregiver->long1;
 | 
						|
            // $caregiverArr[$i]['distance'] = explode(" ",$this->distance($patient['latitude'],$patient['longitude'],$caregiver->lang1,$caregiver->long1))[0];
 | 
						|
            $caregiverArr[$i]['distance']=$this->distance($patient['latitude'],$patient['longitude'],$caregiver->lang1,$caregiver->long1);
 | 
						|
            // pre($caregiverArr[$i]['distance']);die();                                              
 | 
						|
            $i++;
 | 
						|
        }
 | 
						|
        return $caregiverArr;
 | 
						|
    }
 | 
						|
 | 
						|
    private function distance($pt_lat,$pt_lon,$cg_lat,$cg_lon){
 | 
						|
        $this->load->helper("map_helper");
 | 
						|
        $d_with_unit=distanceApi($pt_lat,$pt_lon,$cg_lat,$cg_lon)['distance'];
 | 
						|
        $dist=explode(" ",$d_with_unit)[0];
 | 
						|
        $len=strlen($dist);
 | 
						|
        $distance="";
 | 
						|
        for($i=0;$i<$len;$i++){
 | 
						|
            if(preg_match('/[0-9.]/',$dist[$i])){$distance.=$dist[$i];}
 | 
						|
        }return $distance;
 | 
						|
    } 
 | 
						|
 | 
						|
    // private function distance($pt_lat,$pt_lon,$cg_lat,$cg_lon){
 | 
						|
    //     $this->load->helper("map_helper");
 | 
						|
    //     $pt_lat="40.6655101";
 | 
						|
    //     $pt_lon="-73.89188969999998";
 | 
						|
    //     $cg_lat="40.6905615";
 | 
						|
    //     $cg_lon="-73.9976592";
 | 
						|
 | 
						|
    //     $pt_lat="34.7801525";
 | 
						|
    //     $pt_lon="-86.3396217";
 | 
						|
    //     $cg_lat="34.7886301";
 | 
						|
    //     $cg_lon="-86.9589404";
 | 
						|
    //     return distanceApi($pt_lat,$pt_lon,$cg_lat,$cg_lon)['distance'];
 | 
						|
    //     return distanceApi($pt_lat,$pt_lon,$cg_lat,$cg_lon);
 | 
						|
    //     return distanceApi()['distance'];
 | 
						|
    //     $data[]=$pt_lat;
 | 
						|
    //     $data[]=$pt_lon;
 | 
						|
    //     $data[]=$cg_lat;
 | 
						|
    //     $data[]=$cg_lon;
 | 
						|
    //     return $data;
 | 
						|
 | 
						|
    // } 
 | 
						|
 | 
						|
    function getEventSchedule($patientId,$caregiverId,$start='',$end=''){
 | 
						|
        $this->db->where('status','1');
 | 
						|
        $this->db->where('patient_id',$patientId);
 | 
						|
        if($start!='' && $end!='')
 | 
						|
            $this->db->where("start >= '".$start."' AND end <= '".$end."'");
 | 
						|
        $query = $this->db->get('caregiver_schedule')->result();
 | 
						|
        $i=0;
 | 
						|
        foreach($query as $q){
 | 
						|
            $id = $q->id;
 | 
						|
            $sed[$id]['id']=$q->id;
 | 
						|
            $sed[$id]['patientId']=$q->patient_id;
 | 
						|
            $sed[$id]['caregiverId']=$q->caregiver_id;
 | 
						|
            $sed[$id]['start']=$q->start;
 | 
						|
            $sed[$id]['end']=$q->end;
 | 
						|
            $sed[$id]['title']=$q->title;
 | 
						|
            $sed[$id]['color']='#e83e8c';
 | 
						|
            $i++;
 | 
						|
        }
 | 
						|
        $this->db->where('status','1');
 | 
						|
        $this->db->where('caregiver_id',$caregiverId);
 | 
						|
        if($start!='' && $end!='')
 | 
						|
            $this->db->where("start >= '".$start."' AND end <= '".$end."'");
 | 
						|
        $query = $this->db->get('caregiver_schedule')->result();
 | 
						|
 | 
						|
        foreach($query as $q){
 | 
						|
            $id = $q->id;
 | 
						|
            $sed[$id]['id']=$q->id;
 | 
						|
            $sed[$id]['patientId']=$q->patient_id;
 | 
						|
            $sed[$id]['caregiverId']=$q->caregiver_id;
 | 
						|
            $sed[$id]['start']=$q->start;
 | 
						|
            $sed[$id]['end']=$q->end;
 | 
						|
            $sed[$id]['title']=$q->title;
 | 
						|
            $sed[$id]['color']='#7c83eb';
 | 
						|
            //$sed[$id]['display']='background';
 | 
						|
            //$sed[$id]['editable']='false';
 | 
						|
 | 
						|
 | 
						|
 | 
						|
           // if(in_array($cid, $sed[])){echo 'duplicate'; }
 | 
						|
            // $sed[$i]['id']=$q->id;
 | 
						|
            // $sed[$i]['start']=$q->start;
 | 
						|
            // $sed[$i]['end']=$q->end;
 | 
						|
            // $sed[$i]['title']=$caregiverId;
 | 
						|
            // $sed[$i]['color']='#7c83eb';
 | 
						|
            // $sed[$i]['display']='background';
 | 
						|
            // $i++;
 | 
						|
        }
 | 
						|
 | 
						|
        $ret = array();
 | 
						|
        foreach($sed as $q){
 | 
						|
            $ret[] = $q;
 | 
						|
        }
 | 
						|
        $this->db->where('status','1');
 | 
						|
        $this->db->where('caregiver_id',$caregiverId);
 | 
						|
        if($start!='' && $end!='')
 | 
						|
            $this->db->where("start >= '".$start."' AND end <= '".$end."'");
 | 
						|
        $availableArray = $this->db->get('caregiver_availability')->result();
 | 
						|
        $arrayCount=count($ret);
 | 
						|
        foreach($availableArray as $avl){
 | 
						|
            $ret[$arrayCount]['id']=$avl->id;
 | 
						|
            $ret[$arrayCount]['caregiverId']=$avl->caregiver_id;
 | 
						|
            $ret[$arrayCount]['start']=$avl->start;
 | 
						|
            $ret[$arrayCount]['end']=$avl->end;
 | 
						|
            $ret[$arrayCount]['rendering']='background';
 | 
						|
            $arrayCount++;
 | 
						|
        }
 | 
						|
         //echo '<pre>';print_r($availableArray);echo '</pre>';
 | 
						|
         //die;
 | 
						|
        return $ret;
 | 
						|
    }
 | 
						|
 | 
						|
    function saveSchedule($data){
 | 
						|
        //echo '<pre>';print_r($data);echo '</pre>';die;
 | 
						|
 | 
						|
        $created_by=$this->session->userdata('user_id');
 | 
						|
        $created_on=date ('Y-m-d H:i:s', now());
 | 
						|
        $data['color']='#2D95BF';
 | 
						|
        $data['start']=$data['Sdate'].' '.$data['startTime'];
 | 
						|
        $data['end']=$data['Sdate'].' '.$data['endTime'];
 | 
						|
        $data['status']=1;
 | 
						|
        unset($data['startTime']);
 | 
						|
        unset($data['endTime']);
 | 
						|
        unset($data['Sdate']);
 | 
						|
 | 
						|
        if($data['switch_with']!=""){
 | 
						|
            $id=$data['switch_with'];
 | 
						|
            $data['update_by']=$created_by;
 | 
						|
            $data['update_on']=$created_on;
 | 
						|
            unset($data['switch_with']);
 | 
						|
            $this->db->where('id', $id);
 | 
						|
            $this->db->update('caregiver_schedule', $data);
 | 
						|
            return $id;            
 | 
						|
        }else{
 | 
						|
            $data['created_by']=$created_by;
 | 
						|
            $data['created_on']=$created_on;
 | 
						|
            $this->db->insert('caregiver_schedule', $data);
 | 
						|
            return $this->db->insert_id();
 | 
						|
        }
 | 
						|
 | 
						|
        
 | 
						|
        //echo '<pre>';print_r($data);echo '</pre>';die;
 | 
						|
        
 | 
						|
        // echo $this->db->last_query();
 | 
						|
        // die;
 | 
						|
        
 | 
						|
        //die;
 | 
						|
    }
 | 
						|
    function PreviousSchedule($data){
 | 
						|
       // print_r($data);die;
 | 
						|
        $start=$data['scheduleDate'].' 00:00:00';
 | 
						|
        $end=$data['scheduleDate'].' 23:59:59';
 | 
						|
        
 | 
						|
        $this->db->where('caregiver_id',$data['caregiverId']);
 | 
						|
        $this->db->where('start>=',$start);
 | 
						|
        $this->db->where('end<=',$end);
 | 
						|
        $this->db->where('status','1');
 | 
						|
        $this->db->order_by('start', 'asc');
 | 
						|
        $caregiverAvailability = $this->db->get('caregiver_availability')->result();
 | 
						|
        // echo $this->db->last_query();
 | 
						|
        // echo '<pre>';print_r($caregiverAvailability); echo '</pre>';die;
 | 
						|
 | 
						|
        $this->db->select('a.*,b.patient_id,b.first_name,b.last_name');
 | 
						|
        $this->db->from('caregiver_schedule a');
 | 
						|
        $this->db->join('patient_details b', 'b.id = a.patient_id', 'left'); 
 | 
						|
        $this->db->where("a.start >= '".$start."' AND a.end <= '".$end."'");
 | 
						|
        $this->db->where('a.caregiver_id',$data['caregiverId']);
 | 
						|
        $this->db->where('a.status','1');
 | 
						|
        $caregiverData = $this->db->get()->result();
 | 
						|
 | 
						|
 | 
						|
        // $this->db->join('caregiver', 'caregiver.id = caregiver_schedule.caregiver_id');
 | 
						|
        
 | 
						|
        // $caregiverData=$this->db->get_where('caregiver_schedule',
 | 
						|
        //     array('caregiver_id'=>$data['caregiverId'],'status'=>1))->result();
 | 
						|
        // echo $this->db->last_query();
 | 
						|
        // die;
 | 
						|
        //echo '<pre>';print_r($caregiverData); echo '</pre>';die;
 | 
						|
        $this->db->select('a.*,b.caregiver_id,b.lname,b.fname');
 | 
						|
        $this->db->from('caregiver_schedule a');
 | 
						|
        $this->db->join('caregiver b', 'b.id = a.caregiver_id', 'left'); 
 | 
						|
        $this->db->where("a.start >= '".$start."' AND a.end <= '".$end."'");
 | 
						|
        $this->db->where('a.patient_id',$data['patientId']);
 | 
						|
        $this->db->where('a.status','1');
 | 
						|
        $patientData = $this->db->get()->result();
 | 
						|
 | 
						|
        // $this->db->where("start >= '".$start."' AND end <= '".$end."'");;
 | 
						|
        // $patientData=$this->db->get_where('caregiver_schedule',
 | 
						|
        //     array('patient_id'=>$data['patientId'],'status'=>1))->result();
 | 
						|
        
 | 
						|
        //die;
 | 
						|
        $output='';
 | 
						|
        $output.='<div class="col-12">
 | 
						|
                    <div class="adv-table editable-table">
 | 
						|
                        <div class="space15"></div>
 | 
						|
                        <h6>Caregiver Availability</h6>
 | 
						|
                        <table class="table table-striped table-bordered dom-jQuery-events" cellspacing="0" width="100%">
 | 
						|
                            <thead>
 | 
						|
                                <tr>
 | 
						|
                                    <th>From</th>
 | 
						|
                                    <th>To</th>
 | 
						|
                                </tr>
 | 
						|
                            </thead>
 | 
						|
                            <tbody>';
 | 
						|
                            foreach ($caregiverAvailability as $ca) {
 | 
						|
                                $stime=date("g:i A",strtotime($ca->start));
 | 
						|
                                $etime=date("g:i A",strtotime($ca->end));
 | 
						|
                        $output.='<tr>';
 | 
						|
                        $output.='   <td>'.$stime.'</td>';
 | 
						|
                        $output.='   <td>'.$etime.'</td>';
 | 
						|
                        
 | 
						|
                        $output.='</tr>';
 | 
						|
                            }
 | 
						|
                                
 | 
						|
        $output.='          </tbody>
 | 
						|
                        </table>
 | 
						|
                    </div>
 | 
						|
                </div>';
 | 
						|
        $output.='<div class="col-12">
 | 
						|
                    <div class="adv-table editable-table">
 | 
						|
                        <div class="space15"></div>
 | 
						|
                        <h6>Caregiver Schedule</h6>
 | 
						|
                        <table class="table table-striped table-bordered dom-jQuery-events" cellspacing="0" width="100%">
 | 
						|
                            <thead>
 | 
						|
                                <tr>
 | 
						|
                                    <th>From</th>
 | 
						|
                                    <th>To</th>
 | 
						|
                                    <th>Patient ID</th>
 | 
						|
                                    <th>Patient Name</th>
 | 
						|
                                    <th>Switch With</th>
 | 
						|
                                </tr>
 | 
						|
                            </thead>
 | 
						|
                            <tbody>';
 | 
						|
                            foreach ($caregiverData as $cd) {
 | 
						|
                                $stime=date("g:i A",strtotime($cd->start));
 | 
						|
                                $etime=date("g:i A",strtotime($cd->end));
 | 
						|
                        $output.='<tr>';
 | 
						|
                        $output.='   <td>'.$stime.'</td>';
 | 
						|
                        $output.='   <td>'.$etime.'</td>';
 | 
						|
                        $output.='   <td>'.$cd->patient_id.'</td>';
 | 
						|
                        $output.='   <td>'.$cd->first_name.' '.$cd->last_name.'</td>';
 | 
						|
                        $output.='   <td><input type="radio" id="CS'.$cd->id.'" name="switch_with" value="'.$cd->id.'">
 | 
						|
                                         <label for="CS'.$cd->id.'">Check</label>
 | 
						|
                                     </td>';
 | 
						|
                        $output.='</tr>';
 | 
						|
                            }
 | 
						|
                                
 | 
						|
        $output.='          </tbody>
 | 
						|
                        </table>
 | 
						|
                    </div>
 | 
						|
                </div>';
 | 
						|
        $output.='<div class="col-12">
 | 
						|
                    <div class="adv-table editable-table">
 | 
						|
                        <div class="space15"></div>
 | 
						|
                        <h6>Patient Schedule</h6>
 | 
						|
                        <table class="table table-striped table-bordered dom-jQuery-events" cellspacing="0" width="100%">
 | 
						|
                            <thead>
 | 
						|
                                <tr>
 | 
						|
                                    <th>From</th>
 | 
						|
                                    <th>To</th>
 | 
						|
                                    <th>Caregiver ID</th>
 | 
						|
                                    <th>Caregiver Name</th>
 | 
						|
                                    <th>Switch With</th>
 | 
						|
                                </tr>
 | 
						|
                            </thead>
 | 
						|
                            <tbody>';
 | 
						|
                            foreach ($patientData as $pd) {
 | 
						|
                                
 | 
						|
                                $stime=date("g:i A",strtotime($pd->start));
 | 
						|
                                $etime=date("g:i A",strtotime($pd->end));
 | 
						|
                                $output.='<tr>';
 | 
						|
                                $output.='   <td>'.$stime.'</td>';
 | 
						|
                                $output.='   <td>'.$etime.'</td>';
 | 
						|
                                $output.='   <td>'.$pd->caregiver_id.'</td>';
 | 
						|
                                $output.='   <td>'.$pd->fname.' '.$pd->lname.'</td>';
 | 
						|
                                $output.='   <td>   <input type="radio" id="PS'.$pd->id.'" name="switch_with" value="'.$pd->id.'">
 | 
						|
                                                    <label for="PS'.$pd->id.'">Check</label>
 | 
						|
                                             </td>';
 | 
						|
                                $output.='</tr>';
 | 
						|
                            }
 | 
						|
            $output.='      </tbody>
 | 
						|
                        </table>
 | 
						|
                    </div>
 | 
						|
                </div>';
 | 
						|
        return $output;
 | 
						|
 | 
						|
    }
 | 
						|
    function CheckSchedule($data){
 | 
						|
        //echo '<pre>';print_r($data); echo '</pre>';die;
 | 
						|
        $start=$data['scheduleDate'].' '.$data['startTime'];
 | 
						|
        $end=$data['scheduleDate'].' '.$data['endTime'];
 | 
						|
        $patient_id=$data['patient_id'];
 | 
						|
        $caregiver_id=$data['caregiver_id'];
 | 
						|
        $sql="SELECT * FROM caregiver_schedule";
 | 
						|
        // $sql.=" where status='1' and patient_id='".$patient_id."' and caregiver_id='".$caregiver_id."'";
 | 
						|
        $sql.=" where status='1' and caregiver_id='".$caregiver_id."'";
 | 
						|
        $sql.=" and ( ('".$start."' between start and end)
 | 
						|
                or 
 | 
						|
                    ('".$end."' between start and end)
 | 
						|
                or 
 | 
						|
                    (start between '".$start."' and '".$end."')
 | 
						|
                or  (end between '".$start."' and '".$end."')
 | 
						|
                 )";
 | 
						|
        $result=$this->db->query($sql)->result();
 | 
						|
        $output='';
 | 
						|
        if(!empty($result)){
 | 
						|
            $output='Schedule Not Available.';
 | 
						|
        }
 | 
						|
        return $output;
 | 
						|
        //echo '<pre>';print_r($result); echo '</pre>';die;
 | 
						|
        // echo $this->db->last_query();
 | 
						|
        // die;
 | 
						|
    }
 | 
						|
    function getEventDetailsById($data){
 | 
						|
        $this->db->where('status','1');
 | 
						|
        $this->db->where('id',$data['id']);
 | 
						|
        $query = $this->db->get('caregiver_schedule')->row();
 | 
						|
        return $query;
 | 
						|
    }
 | 
						|
    function getCaregiverName($data){
 | 
						|
 | 
						|
        $this->db->where('status','1');
 | 
						|
        $this->db->where('id',$data['caregiverId']);
 | 
						|
        $query = $this->db->get('caregiver')->row();
 | 
						|
        $caregiver_name=$query->fname.' '.$query->lname;
 | 
						|
        return $caregiver_name;
 | 
						|
    }
 | 
						|
    function getCaregiverPreviousSchedule($data){
 | 
						|
        $now=date("Y-m-d 00:00:00");
 | 
						|
        $this->db->select('a.id as scheduleId,a.patient_id as patient_row_id,a.*,b.first_name,b.last_name');
 | 
						|
        $this->db->from('caregiver_schedule a');
 | 
						|
        $this->db->join('patient_details b', 'b.id = a.patient_id', 'left'); 
 | 
						|
        $this->db->where('a.start<',$now);
 | 
						|
        $this->db->where('a.caregiver_id',$data);
 | 
						|
        $query = $this->db->get()->result();
 | 
						|
 | 
						|
        //echo '<pre>';print_r($query); echo '</pre>';die;
 | 
						|
        $output='';
 | 
						|
        $output.='  <thead>
 | 
						|
                        <tr>
 | 
						|
                            <th>Date</th>
 | 
						|
                            <th>From (Time)</th>                                
 | 
						|
                            <th>To (Time)</th>
 | 
						|
                            <th>Status</th>
 | 
						|
                        </tr>
 | 
						|
                    </thead>
 | 
						|
                    <tbody>';
 | 
						|
        foreach ($query as $sd) {
 | 
						|
            // if($sd->acceptance_status=='1'){
 | 
						|
            //     $status='Done';
 | 
						|
            // }else{
 | 
						|
            //     $status='Not Done';    
 | 
						|
            // }
 | 
						|
            
 | 
						|
            $output.='     <tr>
 | 
						|
                                <td>'.date("Y/m/d",strtotime($sd->start)).'</td>
 | 
						|
                                <td>'.date("g:i A",strtotime($sd->start)).'</td>
 | 
						|
                                <td>'.date("g:i A",strtotime($sd->end)).'</td>
 | 
						|
                                <td style="color: #de2066;">'.$sd->acceptance_status.'</td>
 | 
						|
                           </tr>
 | 
						|
                ';
 | 
						|
        }
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
            $output.='</tbody>';
 | 
						|
        return $output;
 | 
						|
    }
 | 
						|
    function getCaregiverUpcomingSchedule($data){
 | 
						|
        $now=date("Y-m-d 00:00:00");
 | 
						|
        $this->db->select('a.id as scheduleId,a.patient_id as patient_row_id,a.*,b.first_name,b.last_name');
 | 
						|
        $this->db->from('caregiver_schedule a');
 | 
						|
        $this->db->join('patient_details b', 'b.id = a.patient_id', 'left'); 
 | 
						|
        $this->db->where('a.start>',$now);
 | 
						|
        $this->db->where('a.caregiver_id',$data);
 | 
						|
        $query = $this->db->get()->result();
 | 
						|
 | 
						|
        //echo '<pre>';print_r($query); echo '</pre>';die;
 | 
						|
        $output='';
 | 
						|
        $output.='  <thead>
 | 
						|
                        <tr>
 | 
						|
                            <th>Date</th>
 | 
						|
                            <th>From (Time)</th>                                
 | 
						|
                            <th>To (Time)</th>
 | 
						|
                            <th>Status</th>
 | 
						|
                        </tr>
 | 
						|
                    </thead>
 | 
						|
                    <tbody>';
 | 
						|
        foreach ($query as $sd) {
 | 
						|
            // if($sd->acceptance_status=='1'){
 | 
						|
            //     $status='Done';
 | 
						|
            // }else{
 | 
						|
            //     $status='Not Done';    
 | 
						|
            // }
 | 
						|
            
 | 
						|
            $output.='     <tr>
 | 
						|
                                <td>'.date("Y/m/d",strtotime($sd->start)).'</td>
 | 
						|
                                <td>'.date("g:i A",strtotime($sd->start)).'</td>
 | 
						|
                                <td>'.date("g:i A",strtotime($sd->end)).'</td>
 | 
						|
                                <td style="color: #de2066;">'.$sd->acceptance_status.'</td>
 | 
						|
                           </tr>
 | 
						|
                ';
 | 
						|
        }
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
            $output.='</tbody>';
 | 
						|
        return $output;
 | 
						|
    }
 | 
						|
 | 
						|
    function getFcmToken($caregiver_id){
 | 
						|
        
 | 
						|
        $this->db->select("b.fcm_token,a.id");
 | 
						|
        $this->db->from('caregiver a');
 | 
						|
        $this->db->join('users b', 'b.id = a.ion_user_id', 'left');
 | 
						|
        $this->db->where('a.id',$caregiver_id); 
 | 
						|
        $query = $this->db->get()->row();
 | 
						|
        return $query;
 | 
						|
    }
 | 
						|
 | 
						|
   
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
/* for data table end */ |