Commit 382986b4 by Jansa Jose

waiting list concept

parent ab67c440
......@@ -10,7 +10,6 @@
header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}"); exit(0);
}
class Webservice extends CI_Controller {
......@@ -2471,6 +2470,73 @@ class Webservice extends CI_Controller {
print json_encode($res);
}
public function cancel_booking_resend_cron($type=null){
if(isset($type) && !empty($type)){
$result = $this->db->query('SELECT * FROM `tbl_waiting_list_id_crone` WHERE booking_id ='.$type)->result_array();
}else{
$result = $this->db->query('SELECT * FROM `tbl_waiting_list_id_crone` WHERE TIMESTAMPDIFF(minute, `push_time`, NOW()) > 20 AND status = 1')->result_array();
}
foreach ($result as $key => $value){
$book_data = $this->db->get_where('tbl_booking',array('id'=>$value['booking_id']))->row_array();
//if($book_data['booking_status'] == 0){
$this->db->update('tbl_waiting_list_id_crone',array('status'=>'0'),array('id'=>$value['id']));
$this->db->select('tbl_booking.id');
$this->db->from('tbl_waiting_list_id_crone');
$this->db->join('tbl_booking','tbl_booking.id = tbl_waiting_list_id_crone.booking_id');
$this->db->where('tbl_booking.doctor_id',$book_data['doctor_id']);
$this->db->where('tbl_booking.clinic_id',$book_data['clinic_id']);
$this->db->where('tbl_waiting_list_id_crone.book_date',$value['book_date']);
$this->db->where('tbl_waiting_list_id_crone.status','0');
$inserted_id = $this->db->get()->result_array();
//print_r($inserted_id);exit();
if(count($inserted_id)> 0){
foreach ($inserted_id as $keys => $values) {
$newarray[] = $values['id'];
}
$inserted_id = $newarray;
}else{
$inserted_id = '';
}
//print_r($inserted_id);exit();
$nextday = $value['book_date'];
$next_day_consult = $this->Webservice_model->wait_list_data($book_data,$nextday,$inserted_id);
if(count($next_day_consult) > 0){
$fcm_user = $this->db->get_where('tbl_authtoken',array('userid'=>$next_day_consult[0]['patient_id']))->row();
$doctr_data = $this->db->get_where('tbl_doctors',array('id'=>$next_day_consult[0]['doctor_id']))->row_array();
$special = $this->db->get_where('tbl_specialization',array('id'=>$doctr_data['specialization']))->row();
$conslt_time = date('Y-m-d h:i:s');
$msg3 = "Your Wait Listed Appointment on ".date('d.m.Y h:i a',$next_day_consult[0]['time_start'])." can be changed to ".date('d.m.Y h:i a',$book_data['time_start'])." as the Time Slot is Available Now. Would you like to change the Appointment on Available Slot ?";
$this->db->insert('tbl_patient_notification',array('patient_id'=>$next_day_consult[0]['patient_id'],'type'=>'4','message'=>$msg3,'time'=>$conslt_time,'booking_id'=>$next_day_consult[0]['id'],'read_status'=>'0','free_booking_id'=>$value['free_booking_id']));
$new_patient_insert_id = $this->db->insert_id();
$fcm_user_new = $this->db->get_where('tbl_authtoken',array('userid'=>$next_day_consult[0]['patient_id']))->row();
$new['id'] = $new_patient_insert_id;
$new['type'] = "Consultation Updates";
$new['booking_id'] = $next_day_consult[0]['id'];
$new['booking_date'] = $book_data['date'];
$new['doctor_id'] = $book_data['doctor_id'];
$new['doctor_name'] = $doctr_data['name'];
$new['doctor_specialization'] = $special->specialization_name;
$new['message'] = $msg3;
$new['time'] = $conslt_time;
$new['to'] =$fcm_user_new->fcm_token;
$user_type = '1';
$push = $this->Webservice_model->push_sent($new,$user_type);
$this->db->insert('tbl_waiting_list_id_crone',array('booking_id'=>$next_day_consult[0]['id'],'push_time'=>$conslt_time,'book_time'=>$value['book_time'],'free_booking_id'=>$value['free_booking_id'],'book_date'=>$value['book_date']));
}
}
}
/*..........................................................................................*/
/*..................................get promocode hospital list.............................*/
......@@ -7145,6 +7211,7 @@ class Webservice extends CI_Controller {
if(isset($data['id']) && strlen(trim($data['id']," ")) > 0 && isset($data['booking_id']) && strlen(trim($data['booking_id']," ")) > 0 && isset($data['doctor_id']) && strlen(trim($data['doctor_id']," ")) > 0) {
$result = $this->Webservice_model->reject_consultation_date_change($data);
if($result){
$this->cancel_booking_resend_cron($data['booking_id']);
$res = array('status'=>'success');
}else{
$res = array('status'=>'error','error'=>'error','message'=>'Something Went Wrong.. Try Again Later..!');
......@@ -7212,29 +7279,5 @@ class Webservice extends CI_Controller {
}
print json_encode($res);
}
}
?>
\ No newline at end of file
......@@ -2271,7 +2271,6 @@ CASE when tbl_doctors.gender='0' then 'MALE' when tbl_doctors.gender='1' then 'F
}else{
$nowin_server_addoffset = date('Y-m-d H:i:s',strtotime('-'.$new_time[0].' hour -'.$new_time[1].' minutes',strtotime($nowin_server)));
}
$nowin_server_addoffset = strtotime($nowin_server_addoffset);
$this->db->select('name,specialization');
......@@ -2301,7 +2300,7 @@ CASE when tbl_doctors.gender='0' then 'MALE' when tbl_doctors.gender='1' then 'F
$user_type = '1';
$push = $this->push_sent($new,$user_type);
$ress = $this->db->get_where('tbl_booking',array('doctor_id'=>$query['doctor_id'],'clinic_id'=>$query['clinic_id'],'booking_status'=>'0','date >'=>$query['date']))->row_array();
//$ress = $this->db->get_where('tbl_booking',array('doctor_id'=>$query['doctor_id'],'clinic_id'=>$query['clinic_id'],'booking_status'=>'0','date >'=>$query['date']))->row_array();
// echo $this->db->last_query();exit();
/* if($ress){
$cron_res = $this->cancel_booking_resend_cron($ress,$data);
......@@ -2310,6 +2309,7 @@ CASE when tbl_doctors.gender='0' then 'MALE' when tbl_doctors.gender='1' then 'F
$ress = $this->db->get_where('tbl_booking',array('doctor_id'=>$query['doctor_id'],'clinic_id'=>$query['clinic_id'],'date'=>$query['date'],'time'=>$query['time'],'booking_status'=>'0'))->row_array();
if($ress){
//echo "if";exit();
$this->db->update('tbl_booking',array('booking_status'=>'1'),array('id'=>$ress['id']));
$this->db->insert('tbl_patient_notification',array('patient_id'=>$ress['patient_id'],'type'=>'0','message'=>$msg2,'time'=>$conslt_time,'booking_id'=>$query['id'],'read_status'=>'0'));
$patient_insert_id = $this->db->insert_id();
......@@ -2341,20 +2341,22 @@ CASE when tbl_doctors.gender='0' then 'MALE' when tbl_doctors.gender='1' then 'F
$doctor_type = '2';
$doctor_push = $this->push_sent($news,$doctor_type);
}else{
$nextday = strtotime(date('Y-m-d', strtotime('+1 day', $query['date'])));
$next_day_consult = $this->db->get_where('tbl_booking',array('doctor_id'=>$query['doctor_id'],'clinic_id'=>$query['clinic_id'],'date'=>$nextday,'booking_status'=>'0','time'=>$query['time'],'payment_status'=>'1'))->row_array();
if($next_day_consult){
//echo "no";exit();
//$nextday = strtotime(date('Y-m-d', strtotime('+1 day', $query['date'])));
//$this->db->order_by('date','ASC');
$nextday = $query['date'];
$next_day_consult = $this->wait_list_data($query,$nextday,'');
if(count($next_day_consult) > 0){
$msg3 = "Your Wait Listed Appointment on ".date('d.m.Y h:i a',$next_day_consult['time_start'])." can be changed to ".date('d.m.Y h:i a',$query['time_start'])." as the Time Slot is Available Now. Would you like to change the Appointment on Available Slot ?";
$msg3 = "Your Wait Listed Appointment on ".date('d.m.Y h:i a',$next_day_consult[0]['time_start'])." can be changed to ".date('d.m.Y h:i a',$query['time_start'])." as the Time Slot is Available Now. Would you like to change the Appointment on Available Slot ?";
$this->db->insert('tbl_patient_notification',array('patient_id'=>$next_day_consult['patient_id'],'type'=>'4','message'=>$msg3,'time'=>$conslt_time,'booking_id'=>$next_day_consult['id'],'read_status'=>'0','free_booking_id'=>$data['booking_id']));
$this->db->insert('tbl_patient_notification',array('patient_id'=>$next_day_consult[0]['patient_id'],'type'=>'4','message'=>$msg3,'time'=>$conslt_time,'booking_id'=>$next_day_consult[0]['id'],'read_status'=>'0','free_booking_id'=>$data['booking_id']));
$new_patient_insert_id = $this->db->insert_id();
$fcm_user_new = $this->db->get_where('tbl_authtoken',array('userid'=>$next_day_consult['patient_id']))->row();
$fcm_user_new = $this->db->get_where('tbl_authtoken',array('userid'=>$next_day_consult[0]['patient_id']))->row();
$new['id'] = $new_patient_insert_id;
$new['type'] = "Consultation Updates";
$new['booking_id'] = $next_day_consult['id'];
$new['booking_id'] = $next_day_consult[0]['id'];
$new['booking_date'] = $query['date'];
$new['doctor_id'] = $query['doctor_id'];
$new['doctor_name'] = $doctr_data['name'];
......@@ -2364,7 +2366,12 @@ CASE when tbl_doctors.gender='0' then 'MALE' when tbl_doctors.gender='1' then 'F
$new['to'] =$fcm_user_new->fcm_token;
$user_type = '1';
$push = $this->push_sent($new,$user_type);
}
$this->db->insert('tbl_waiting_list_id_crone',array('booking_id'=>$next_day_consult[0]['id'],'push_time'=> date('Y-m-d h:i:s'),'book_time'=>$query['time'],'free_booking_id'=>$data['booking_id'],'book_date'=>$query['date']));
}/*else{
$nextday = strtotime(date('Y-m-d', strtotime('+1 day', $nextday)));
$next_day_consult = $this->wait_list_data($query,$nextday);
}*/
}
if($query['visit_type'] == '0' && $query['payment_type'] == '2'){
$doctor_wallet = $this->db->get_where('tbl_wallet_details',array('doctor_id'=>$query['doctor_id']))->row();
......@@ -2387,10 +2394,31 @@ CASE when tbl_doctors.gender='0' then 'MALE' when tbl_doctors.gender='1' then 'F
return $res;
}
/*public function cancel_booking_resend_cron($res,$data){
public function wait_list_data($query,$nextday,$insertid){
//print_r($insertid);exit();
$this->db->order_by('id','ASC');
if(isset($insertid) && !empty($insertid)){
$this->db->where_not_in('id', $insertid);
}
*/
//$this->db->limit('1','1');
$next_day_consult = $this->db->get_where('tbl_booking',array('doctor_id'=>$query['doctor_id'],'clinic_id'=>$query['clinic_id'],'booking_status'=>'0','date'=>$nextday,'payment_status'=>'1'))->result_array();
/*print_r(date('y-m-d h:i:s',$nextday));
echo $this->db->last_query();
print_r($next_day_consult);*/
if(count($next_day_consult) > 0){
return $next_day_consult;
}else{
if(isset($insertid) && !empty($insertid)){
$insert_id = $insertid;
}else{
$insert_id = '';
}
$nextday = strtotime(date('Y-m-d', strtotime('+1 day', $nextday)));
return $this->wait_list_data($query,$nextday,$insert_id);
}
}
//.................get promocode hospital list
public function get_promocode_hospital_list($id,$lat,$lng){
......@@ -4375,7 +4403,6 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender='
}else{
$data['telephone'] = '';
}
return $query;
}
......@@ -4565,6 +4592,7 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender='
$result = $this->db->get_where('tbl_patient_notification',array('id'=>$data['id']))->row();
if($result){
if($this->db->delete('tbl_patient_notification',array('id'=>$data['id']))){
$this->db->update('tbl_waiting_list_id_crone',array('status'=>'0'),array('booking_id'=>$data['id']));
return true;
}
}
......@@ -4573,22 +4601,23 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender='
public function accept_consultation_date_change($data){
$result = $this->db->get_where('tbl_patient_notification',array('id'=>$data['id']))->row();
if($result){
$book_data = $this->db->get_where('tbl_patient_notification',array('id'=>$data['free_booking_id']))->row_array();
$update_data = array(
'booking_status'=>'1',
'date'=>$book_data['date'],
'time'=>$book_data['time'],
'time_start'=>$book_data['time_start'],
'time_end'=>$book_data['time_end'],
);
$this->db->delete('tbl_patient_notification',array('id'=>$data['id']));
if($this->db->update('tbl_booking',array('booking_status'=>1),array('id'=>$data['booking_id']))){
$this->db->delete('tbl_waiting_list_id_crone',array('booking_id'=>$data['id']));
if($this->db->update('tbl_booking',$update_data,array('id'=>$data['booking_id']))){
return true;
}
}
}
/*............................................................................................*/
}
?>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"description": "The CodeIgniter framework",
"name": "codeigniter/framework",
"type": "project",
"homepage": "https://codeigniter.com",
"license": "MIT",
"support": {
"forum": "http://forum.codeigniter.com/",
"wiki": "https://github.com/bcit-ci/CodeIgniter/wiki",
"irc": "irc://irc.freenode.net/codeigniter",
"source": "https://github.com/bcit-ci/CodeIgniter"
},
"require": {
"php": ">=5.3.7",
"ktamas77/firebase-php": "dev-master"
},
"suggest": {
"paragonie/random_compat": "Provides better randomness in PHP 5.x"
},
"require-dev": {
"mikey179/vfsStream": "1.1.*",
"phpunit/phpunit": "4.* || 5.*"
"cboden/ratchet": "^0.4.1"
}
}
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment