Commit ebb584e3 by Jansa Jose

doctor booking change

parent 1d22351d
...@@ -1265,9 +1265,9 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender=' ...@@ -1265,9 +1265,9 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender='
$diff = $data['amount']; $diff = $data['amount'];
$promo_name = ''; $promo_name = '';
} }
$this->db->or_where("(booking_status = '1' OR booking_status = '2')"); // $this->db->or_where("(booking_status = '1' OR booking_status = '2')");
$check = $this->db->get_where('tbl_booking',array('doctor_id'=>$data['doctor_id'],'clinic_id'=>$data['clinic_id'],'date'=>$data['date'],'time'=>$data['time'],'payment_status'=>'1')); $check = $this->db->get_where('tbl_booking',array('doctor_id'=>$data['doctor_id'],'clinic_id'=>$data['clinic_id'],'date'=>$data['date'],'time'=>$data['time'],'payment_status'=>'1'));
echo $this->db->last_query();exit(); //echo $this->db->last_query();exit();
$this->db->select('name,profile_pic,specialization'); $this->db->select('name,profile_pic,specialization');
$doctr_data = $this->db->get_where('tbl_doctors',array('id'=>$data['doctor_id']))->row_array(); $doctr_data = $this->db->get_where('tbl_doctors',array('id'=>$data['doctor_id']))->row_array();
...@@ -1342,35 +1342,83 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender=' ...@@ -1342,35 +1342,83 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender='
} }
} }
elseif($check->num_rows() == 1){ elseif($check->num_rows() == 1){
$date_def = date('Y-m-d',$data['date']); $check_data = $check->row_array();
$times = explode('-', $data['time']); if($check_data['booking_status'] == 4){
$start_time = strtotime($date_def.$times[0]); $date_def = date('Y-m-d',$data['date']);
$end_time = strtotime($date_def.$times[1]); $times = explode('-', $data['time']);
$start_time = strtotime($date_def.$times[0]);
$msg = "Your appointment was scheduled in the system as waiting, on ".date('d.m.Y',$start_time)." at ".date('H:i a',$start_time).", doctor ".$doctr_data['name']; $end_time = strtotime($date_def.$times[1]);
$msg = "Your appointment was scheduled in the system, on ".date('d.m.Y',$start_time)." at ".date('H:i a',$start_time).", doctor ".$doctr_data['name'];
$msg2 = "A new appointment was scheduled in the system, on ".date('d.m.Y',$start_time)." at ".date('H:i a',$start_time).", patient ".decrypt_data($pat_data['name']);
if($this->db->insert('tbl_booking',array('doctor_id'=>$data['doctor_id'],'clinic_id'=>$data['clinic_id'],'patient_id'=>$patientid['userid'],'ipok_fee'=>$ipokefees,'date'=>$data['date'],'time'=>$data['time'],'booking_status'=>'1','payment_status'=>$payment_status,'free_visit_status'=>$free_visit_status,'visit_type'=>$visit,'amount'=>$data['amount'],'promo_name'=>$promo_name,'promo_amount'=>$new_amnt,'payment_type'=>$data['payment_mode'],'total_sum'=>$diff,'time_start'=>$start_time,'time_end'=>$end_time,'requested_date'=>time()))){
$insert_id = $this->db->insert_id();
if($payment_status == '1'){
$this->db->insert('tbl_patient_notification',array('patient_id'=>$patientid['userid'],'type'=>'0','message'=>$msg,'time'=>$conslt_time,'booking_id'=>$insert_id,'read_status'=>'0'));
$patient_insert_id = $this->db->insert_id();
$new['id'] = $patient_insert_id;
$new['type'] = "Consultation Confirmation";
$new['booking_id'] = $insert_id;
$new['booking_date'] = $data['date'];
$new['doctor_id'] = $data['doctor_id'];
$new['doctor_name'] = $doctr_data['name'];
$new['doctor_specialization'] = $special->specialization_name;
$new['doctor_photo'] = $doctr_data['profile_pic'];
$new['message'] = $msg;
$new['time'] = $conslt_time;
$new['to'] =$fcm_user->fcm_token;
$user_type = '1';
$user_push = $this->push_sent($new,$user_type);
$this->db->insert('tbl_doctor_notifications',array('doctor_id'=>$data['doctor_id'],'type'=>'2','message'=>$msg2,'time'=>$conslt_time,'read_status'=>'0'));
$doctor_insert_id = $this->db->insert_id();
$fcm_doctor = $this->db->get_where('tbl_authtoken_doctors',array('doctor_id'=>$data['doctor_id']))->row();
$news['id'] = $doctor_insert_id;
$news['type'] = "New Consultation";
$news['message'] =$msg2;
$news['read_status'] = false;
$news['to'] = $fcm_doctor->fcm_token;
$doctor_type = '2';
$doctor_push = $this->push_sent($news,$doctor_type);
}
$return_array = array('status'=>'success','data'=>array('booking_id'=>$insert_id,'is_waiting'=>false,'is_payment_required'=>$is_payment_required));
}
else{
$return_array = array('status'=>'fail','msg' =>'insertion failed');
}
}else{
$date_def = date('Y-m-d',$data['date']);
$times = explode('-', $data['time']);
$start_time = strtotime($date_def.$times[0]);
$end_time = strtotime($date_def.$times[1]);
if($this->db->insert('tbl_booking',array('doctor_id'=>$data['doctor_id'],'clinic_id'=>$data['clinic_id'],'patient_id'=>$patientid['userid'],'ipok_fee'=>$ipokefees,'date'=>$data['date'],'time'=>$data['time'],'booking_status'=>'0','payment_status'=>$payment_status,'free_visit_status'=>$free_visit_status,'visit_type'=>$visit,'amount'=>$data['amount'],'promo_name'=>$promo_name,'promo_amount'=>$new_amnt,'payment_type'=>$data['payment_mode'],'total_sum'=>$diff,'time_start'=>$start_time,'time_end'=>$end_time,'requested_date'=>time()))){ $msg = "Your appointment was scheduled in the system as waiting, on ".date('d.m.Y',$start_time)." at ".date('H:i a',$start_time).", doctor ".$doctr_data['name'];
$insert_id = $this->db->insert_id();
if($payment_status == '1'){
$this->db->insert('tbl_patient_notification',array('patient_id'=>$patientid['userid'],'type'=>'1','message'=>$msg,'time'=>$conslt_time,'booking_id'=>$insert_id,'read_status'=>'0'));
$patient_insert_id = $this->db->insert_id();
$new['id'] = $patient_insert_id; if($this->db->insert('tbl_booking',array('doctor_id'=>$data['doctor_id'],'clinic_id'=>$data['clinic_id'],'patient_id'=>$patientid['userid'],'ipok_fee'=>$ipokefees,'date'=>$data['date'],'time'=>$data['time'],'booking_status'=>'0','payment_status'=>$payment_status,'free_visit_status'=>$free_visit_status,'visit_type'=>$visit,'amount'=>$data['amount'],'promo_name'=>$promo_name,'promo_amount'=>$new_amnt,'payment_type'=>$data['payment_mode'],'total_sum'=>$diff,'time_start'=>$start_time,'time_end'=>$end_time,'requested_date'=>time()))){
$new['type'] = "Waiting List"; $insert_id = $this->db->insert_id();
$new['booking_id'] = $insert_id; if($payment_status == '1'){
$new['booking_date'] = $data['date']; $this->db->insert('tbl_patient_notification',array('patient_id'=>$patientid['userid'],'type'=>'1','message'=>$msg,'time'=>$conslt_time,'booking_id'=>$insert_id,'read_status'=>'0'));
$new['doctor_id'] = $data['doctor_id']; $patient_insert_id = $this->db->insert_id();
$new['doctor_name'] = $doctr_data['name'];
$new['doctor_specialization'] = $special->specialization_name; $new['id'] = $patient_insert_id;
$new['doctor_photo'] = $doctr_data['profile_pic']; $new['type'] = "Waiting List";
$new['message'] = $msg; $new['booking_id'] = $insert_id;
$new['time'] = $conslt_time; $new['booking_date'] = $data['date'];
$new['to'] =$fcm_user->fcm_token; $new['doctor_id'] = $data['doctor_id'];
$user_type = '1'; $new['doctor_name'] = $doctr_data['name'];
$user_push = $this->push_sent($new,$user_type); $new['doctor_specialization'] = $special->specialization_name;
$new['doctor_photo'] = $doctr_data['profile_pic'];
$new['message'] = $msg;
$new['time'] = $conslt_time;
$new['to'] =$fcm_user->fcm_token;
$user_type = '1';
$user_push = $this->push_sent($new,$user_type);
}
$return_array = array('status'=>'failed','data' =>array('booking_id'=>$insert_id,'is_waiting'=>true,'is_payment_required'=>$is_payment_required));
} }
$return_array = array('status'=>'failed','data' =>array('booking_id'=>$insert_id,'is_waiting'=>true,'is_payment_required'=>$is_payment_required)); }
}
} }
elseif($check->num_rows() > 1){ elseif($check->num_rows() > 1){
......
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