payment gateway completed
Showing
application/config/iugu.php
0 → 100644
application/config/pt-br.txt
0 → 100644
| <?php | ||
| defined('BASEPATH') OR exit('No direct script access allowed'); | ||
| class Home extends CI_Controller { | ||
| function __construct() | ||
| { | ||
| parent::__construct(); | ||
| $this->load->model('Home_model'); | ||
| $this->load->model('Patient_model'); | ||
| $this->load->model('Doctor_model'); | ||
| $this->load->model('Search_doctor_model'); | ||
| $this->load->library('facebook'); // Load facebook library | ||
| //$this->config->load('iugu'); | ||
| if(!$this->session->userdata('language')) { | ||
| $langSet="en"; | ||
| $this->session->set_userdata('language',$langSet); | ||
| } | ||
| } | ||
| /*HOME CONTROLLER - LANDING CONTROLLER*/ | ||
| public function index() | ||
| { | ||
| //print_r($this->config->item('id'));die(); | ||
| $template['page'] = "home"; | ||
| $template['page_title'] = "Home Page"; | ||
| $template['data'] = "Home page"; | ||
| $speciality_list = $this->Home_model->get_speciality(); | ||
| //print_r($speciality_list);die(); | ||
| $template['speciality_list'] = $speciality_list; | ||
| /*FB LOGIN BEGINS*/ | ||
| if(isset($_REQUEST['status'])) | ||
| { | ||
| $template['FBLoginStatus'] = $_REQUEST['status']; | ||
| } | ||
| else | ||
| { | ||
| $template['FBLoginStatus'] = 'fail'; | ||
| } | ||
| $fbuser = ''; | ||
| $template['FBauthUrl'] = $this->facebook->login_url(); | ||
| /*FB LOGIN ENDS*/ | ||
| if($this->session->userdata('UserData')) | ||
| { | ||
| $userdata = $this->session->userdata('UserData'); | ||
| if($userdata['type']=="PATIENT") | ||
| { | ||
| $this->load->view('template/template', $template); | ||
| } | ||
| else | ||
| { | ||
| header('Location: '.base_url().'Doctor'); | ||
| } | ||
| } | ||
| else | ||
| { $this->load->view('template/template', $template); } | ||
| } | ||
| /*FUNCTION FOR CHECKING EMAIL EXIST - PATIENT REGISTRATION*/ | ||
| public function check_email() | ||
| { | ||
| $data = $_POST; | ||
| $check_result = $this->Home_model->emailExist($data); | ||
| //print_r($check_result);die(); | ||
| print json_encode($check_result); | ||
| } | ||
| /*FUNCTION FOR CHECKING USERNAME EXIST - PATIENT REGISTRATION*/ | ||
| public function check_username() | ||
| { | ||
| $data = $_POST; | ||
| $check_result = $this->Home_model->usernameExist($data); | ||
| //print_r($check_result);die(); | ||
| print json_encode($check_result); | ||
| } | ||
| /*FUNCTION FOR VALIDATING CEP CODE - PATIENT REGISTRATION*/ | ||
| public function check_cep() | ||
| { | ||
| $data = $_POST; | ||
| $result= check_cep_viacep($data['cep']); //common helper | ||
| print ($result); | ||
| } | ||
| /*FUNCTION FOR CHECKING USERNAME EXIST - DOCTOR REGISTRATION*/ | ||
| public function check_username_doc() | ||
| { | ||
| $data = $_POST; | ||
| $check_result = $this->Home_model->usernameExist_doc($data); | ||
| //print_r($check_result);die(); | ||
| print json_encode($check_result); | ||
| } | ||
| /*FUNCTION FOR CHECKING EMAIL EXIST - DOCTOR REGISTRATION*/ | ||
| public function check_email_doc() | ||
| { | ||
| $data = $_POST; | ||
| $check_result = $this->Home_model->emailExist_doc($data); | ||
| //print_r($check_result);die(); | ||
| print json_encode($check_result); | ||
| } | ||
| /*FUNCTION FOR PATIENT REGISTRATION - HOME*/ | ||
| public function reg_patient() | ||
| { | ||
| parse_str($_REQUEST['data'], $output); | ||
| $reg_data = array('email' => $output['reg_pat_email'],'name' => $output['reg_pat_name'],'username' => $output['reg_pat_username'],'password' => md5($output['reg_pat_password']),'cpf' => $output['reg_pat_cpf'],'rg' => $output['reg_pat_rg'],'dob' =>strtotime($output['reg_pat_dob']),'gender' => $output['reg_pat_gender'],'weight' => $output['reg_pat_weight'],'height' => $output['reg_pat_height'],'blood_group' => $output['reg_pat_bloodgrp'],'zip_code' => $output['reg_pat_cep'],'street_address' => $output['reg_pat_streetadd'],'locality' => $output['reg_pat_locality'],'number' => $output['reg_pat_number'],'landmark' => $output['reg_pat_complement'],'occupation' => $output['reg_pat_occupation'] ); | ||
| //print_r($reg_data);die(); | ||
| $result = $this->Home_model->registration($reg_data); | ||
| if($result['status'] == 'success') | ||
| { | ||
| if(isset($_FILES['pic'])) | ||
| { | ||
| $fileName = $result['userdata']['id'].'_'.$_FILES['pic']['name']; | ||
| $config = set_upload_options('./assets/uploads/profilepic/patient/'); | ||
| $config['file_name'] = $fileName; | ||
| $this->load->library('upload', $config); | ||
| if ( ! $this->upload->do_upload('pic')) | ||
| { | ||
| $error = array('error' => $this->upload->display_errors('', '')); | ||
| $res = array( | ||
| "status"=> "failure", | ||
| "error"=> "Upload Error", | ||
| "message"=> "Profile Image Upload Error!, ".$error['error'] | ||
| ); | ||
| $this->Home_model->delete_registration($result['userdata']['id']); | ||
| } | ||
| else | ||
| { | ||
| $imagedata = $this->upload->data(); | ||
| $fullfilepath='assets/uploads/profilepic/patient/'.$imagedata['file_name']; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| $fullfilepath = $output['reg_pat_profilepic']; | ||
| } | ||
| if(isset($fullfilepath)) | ||
| { | ||
| $static_string = 'IPOK_User'.time(); | ||
| $authToken = uniqid($static_string); | ||
| $result_authtoken = $this->Home_model->authtoken_registration($authToken,$result['userdata']['id']); | ||
| if($result_authtoken) | ||
| { | ||
| $picdata = array('profile_photo'=>$fullfilepath); | ||
| $finalResult = $this->Home_model->updatePic($picdata,$result['userdata']['id']); | ||
| if($finalResult) | ||
| { | ||
| $res = array('status'=>'success'); | ||
| $cpf_obj = array('cpf' => $reg_data['cpf'] ,'user_type' =>0,'user_id'=>$result['userdata']['id']); | ||
| $this->Home_model->insertcpfunique($cpf_obj); | ||
| } //final success | ||
| else | ||
| { | ||
| $res = array( | ||
| "status"=> "failure", | ||
| "error"=> "Database Error", | ||
| "message"=> load_language('image_upload_error',true) | ||
| ); | ||
| } | ||
| if($this->session->userdata('FBData')) | ||
| { unset($_SESSION['FBData']); } | ||
| } | ||
| } | ||
| } | ||
| else | ||
| { | ||
| $res = array( | ||
| "status"=> "failure", | ||
| "error"=> "Database Error", | ||
| "message"=> load_language('patient_registration_failed',true) | ||
| ); | ||
| } | ||
| print json_encode($res); | ||
| } | ||
| /*FACEBOOK LOGIN CONTROLLER - HOME(PATIENT REGISTRATION)*/ | ||
| public function facebook_login() | ||
| { | ||
| $FBuserData = array(); | ||
| if(isset($_REQUEST['error']) and $_REQUEST['error']=='access_denied' and isset($_REQUEST['error_code']) and $_REQUEST['error_code']==200) | ||
| { | ||
| //header('Location: '.base_url()); | ||
| redirect(base_url()); | ||
| } | ||
| else if($this->facebook->is_authenticated()) // Check if user is logged in | ||
| { | ||
| // Get user facebook profile details | ||
| $userProfile = $this->facebook->request('get', '/me?fields=id,first_name,last_name,email,gender,locale,picture'); | ||
| // Preparing data for database insertion | ||
| $FBuserData['oauth_provider'] = 'facebook'; | ||
| $FBuserData['oauth_uid'] = $userProfile['id']; | ||
| $FBuserData['first_name'] = $userProfile['first_name']; | ||
| $FBuserData['last_name'] = $userProfile['last_name']; | ||
| $FBuserData['email'] = $userProfile['email']; | ||
| $FBuserData['gender'] = $userProfile['gender']; | ||
| $FBuserData['locale'] = $userProfile['locale']; | ||
| $FBuserData['profile_url'] = 'https://www.facebook.com/'.$userProfile['id']; | ||
| $FBuserData['picture_url'] = $userProfile['picture']['data']['url']; | ||
| // print_r($FBuserData);die(); | ||
| if($FBuserData) | ||
| { | ||
| $check_result = $this->Home_model->emailExist(array('email' =>$FBuserData['email'])); | ||
| if($check_result['message']=="success") | ||
| { | ||
| $status = 'success'; | ||
| $this->session->set_userdata('FBData',$FBuserData); | ||
| header('Location: '.base_url().'Home/index?status='.$status); | ||
| } | ||
| else | ||
| { | ||
| //print_r("already registered"); die(); | ||
| $this->session->set_flashdata('message', array('message' => load_language('account_exist_with',true).$FBuserData['email'], 'title' => 'Warning', 'class' => 'info')); | ||
| header('Location: '.base_url()); | ||
| } | ||
| //redirect('Home/index'); | ||
| die(); | ||
| } | ||
| // Get logout URL | ||
| $data['logoutUrl'] = $this->facebook->logout_url(); | ||
| } | ||
| } | ||
| /*FUNCTION FOR LOGIN (DOCTOR AND PATIENT) - HOME*/ | ||
| public function login() | ||
| { | ||
| //parse_str($_REQUEST['LoginData'], $request); | ||
| //print_r($_POST);die(); | ||
| $request = $_POST; | ||
| $result=$this->Home_model->login($request); | ||
| //print_r($result);die(); | ||
| if(($result['status']=='success')&&($result['userdata']['account_status']==0)) | ||
| { | ||
| if(($result['status']=='success')&&($request['login_type']=="PATIENT")) | ||
| { | ||
| //print_r($result);die(); | ||
| $update_location = $this->Home_model->location_update($result['userdata'],$request); | ||
| if($update_location['status']=='success') | ||
| { | ||
| $res = array( | ||
| "status"=> "success", | ||
| "data"=>array( | ||
| "type"=>"PATIENT", | ||
| "id"=> $result['userdata']['id'], | ||
| "name"=> $result['userdata']['name'], | ||
| "username"=> $result['userdata']['username'], | ||
| "email"=> $result['userdata']['email'], | ||
| "password" => $result['userdata']['password'], | ||
| "cpf" => $result['userdata']['cpf'], | ||
| "rg" => $result['userdata']['rg'], | ||
| "dob" => $result['userdata']['dob'], | ||
| "gender" => $result['userdata']['gender'], | ||
| "weight" => $result['userdata']['weight'] , | ||
| "height" => $result['userdata']['height'], | ||
| "blood_group" => $result['userdata']['blood_group'], | ||
| "zip_code" => $result['userdata']['zip_code'], | ||
| "street_address" => $result['userdata']['street_address'], | ||
| "locality" => $result['userdata']['locality'], | ||
| "number" => $result['userdata']['number'], | ||
| "landmark" =>$result['userdata']['landmark'], | ||
| "profile_photo" => $result['userdata']['profile_photo'] | ||
| ) | ||
| ); | ||
| $dependent_data = $this->Patient_model->get_all_dependent_for_patient($result['userdata']['id']); | ||
| if(!empty($dependent_data)){$this->session->set_userdata('DependentData',$dependent_data);} | ||
| } | ||
| else | ||
| { | ||
| $res = array( | ||
| "status"=> "error", | ||
| "error"=> "Location Update Failed", | ||
| "message"=> load_language('check_location_credentials',true) | ||
| ); | ||
| } | ||
| } | ||
| else if(($result['status']=='success')&&($request['login_type']=="DOCTOR")) | ||
| { | ||
| $update_location = $this->Home_model->location_update_doctor($result['userdata'],$request); | ||
| if($update_location['status']=='success') | ||
| { | ||
| $res = array( | ||
| "status"=> "success", | ||
| "data"=>array( | ||
| "type"=>"DOCTOR", | ||
| "id"=> $result['userdata']['id'], | ||
| "name"=> $result['userdata']['name'], | ||
| "username"=> $result['userdata']['username'], | ||
| "email"=> $result['userdata']['email'], | ||
| "password" => $result['userdata']['password'], | ||
| "specialization" => $result['userdata']['specialization'], | ||
| "telphone" => $result['userdata']['telephone'], | ||
| "cpf" => $result['userdata']['cpf'], | ||
| "rg" => $result['userdata']['rg'], | ||
| "dob" => $result['userdata']['dob'], | ||
| "gender" => $result['userdata']['gender'], | ||
| "price" => $result['userdata']['price'], | ||
| "zip_code" => $result['userdata']['cep'], | ||
| "street_address" => $result['userdata']['street_address'], | ||
| "locality" => $result['userdata']['locality'], | ||
| "number" => $result['userdata']['number'], | ||
| "landmark" =>$result['userdata']['complement'], | ||
| "profile_photo" => $result['userdata']['profile_pic'], | ||
| "bio" => $result['userdata']['about'] | ||
| ) | ||
| ); | ||
| $collaborator_data = $this->Doctor_model->get_all_collaborator_for_doctor($result['userdata']['id']); | ||
| $this->session->set_userdata('CollaboratorData',$collaborator_data); | ||
| } | ||
| else | ||
| { | ||
| $res = array( | ||
| "status"=> "error", | ||
| "error"=> "Location Update Failed", | ||
| "message"=> load_language('check_location_credentials',true) | ||
| ); | ||
| } | ||
| } | ||
| else if(($result['status']=='success')&&($request['login_type']=="COLLABORATOR")) | ||
| { | ||
| //print_r($result);die(); | ||
| $doctor_data = $this->Doctor_model->get_single_doctor($result['userdata']['doctor_id']); | ||
| //print_r($doctor_data);die(); | ||
| $res = array( | ||
| "status"=> "success", | ||
| "data"=>array( | ||
| "type"=>"COLLABORATOR", | ||
| "id"=> $doctor_data['doctorid'], | ||
| "name"=> $doctor_data['dr_name'], | ||
| "username"=> $doctor_data['dr_username'], | ||
| "email"=> $doctor_data['dr_email'], | ||
| "specialization_id" => $doctor_data['dr_specialization_id'], | ||
| "specialization" => $doctor_data['dr_specialization'], | ||
| "telphone" => $doctor_data['dr_telephone'], | ||
| "cpf" => $doctor_data['dr_cpf'], | ||
| "rg" => $doctor_data['dr_rg'], | ||
| "dob" => $doctor_data['dr_dob'], | ||
| "gender" => $doctor_data['dr_gender'], | ||
| "price" => $doctor_data['dr_price'], | ||
| "zip_code" => $doctor_data['dr_cep'], | ||
| "street_address" => $doctor_data['dr_rua'], | ||
| "locality" => $doctor_data['dr_neighbourhood'], | ||
| "number" => $doctor_data['dr_number'], | ||
| "landmark" =>$doctor_data['dr_complement'], | ||
| "profile_photo" => $doctor_data['dr_pic'], | ||
| "bio" => $doctor_data['dr_bio'], | ||
| "c_id" => $result['userdata']['id'], | ||
| "c_name" => $result['userdata']['name'], | ||
| "c_email" => $result['userdata']['email'], | ||
| "c_telephone" => $result['userdata']['telephone'], | ||
| "c_cpf" => $result['userdata']['cpf'], | ||
| "c_capabilities" => $result['userdata']['capabilities'] | ||
| ) | ||
| ); | ||
| $collaborator_data = $this->Doctor_model->get_all_collaborator_for_doctor($result['userdata']['id']); | ||
| if(!empty($collaborator_data)){$this->session->set_userdata('CollaboratorData',$collaborator_data);} | ||
| } | ||
| } | ||
| else if(($result['status']=='success')&&($result['userdata']['account_status']==1)) | ||
| { | ||
| $res = array( | ||
| "status"=> "error", | ||
| "error"=> "Login Failed", | ||
| "message"=> load_language('account_disabled',true) | ||
| ); | ||
| } | ||
| else if($result['status']=='fail') | ||
| { | ||
| $res = array( | ||
| "status"=> "error", | ||
| "error"=> "Login Failed", | ||
| "message"=> load_language('invalid_username_or_password',true) | ||
| ); | ||
| } | ||
| if(($res['status']=="success")) | ||
| { | ||
| $this->session->set_userdata('UserData',$res['data']); | ||
| } | ||
| print json_encode($res); | ||
| } | ||
| /*FUNCTION FOR LOGOUT - HOME*/ | ||
| public function logout() | ||
| { | ||
| if($this->session->userdata('UserData')) | ||
| { | ||
| unset($_SESSION['UserData']); | ||
| } | ||
| if($this->session->userdata('DependentData')) | ||
| { | ||
| unset($_SESSION['DependentData']); | ||
| } | ||
| if($this->session->userdata('notifications')) | ||
| { | ||
| unset($_SESSION['notifications']); | ||
| } | ||
| if($this->session->userdata('CollaboratorData')) | ||
| { | ||
| unset($_SESSION['CollaboratorData']); | ||
| } | ||
| header('Location: '.base_url()); | ||
| } | ||
| /*CONTROLLER - DOCTOR REGISTRATION*/ | ||
| public function RegisterDoctor() | ||
| { | ||
| $template['page'] = "register_doctor"; | ||
| $template['page_title'] = "Register Doctor"; | ||
| $speciality_list = $this->Home_model->get_speciality(); | ||
| //print_r($speciality_list);die(); | ||
| $template['speciality_list'] = $speciality_list; | ||
| //$template['data'] = "Home page"; | ||
| $this->load->view('template/template', $template); | ||
| } | ||
| /*FUNCTION FOR INSERTING DOCTOR DATA INTO DB - DOCTOR REGISTRATION*/ | ||
| public function doRegister() | ||
| { | ||
| //print_r($_POST);die(); | ||
| if(isset($_POST) and !empty($_POST)) | ||
| { | ||
| $data = $_POST; | ||
| $data['password'] = md5($data['password']); | ||
| $data['dob'] = strtotime($_POST['dob']); | ||
| $result = $this->Home_model->register_doctor($data); | ||
| //print_r($result); | ||
| if($result['status'] == 'success') | ||
| { | ||
| $fileName = $result['data']['id'].'_'.$_FILES['profile_pic']['name']; | ||
| $config = set_upload_options('./assets/uploads/profilepic/doctors/'); | ||
| $config['file_name'] = $fileName; | ||
| $this->load->library('upload', $config); | ||
| if ( ! $this->upload->do_upload('profile_pic')) | ||
| { | ||
| $error = array('error' => $this->upload->display_errors('', '')); | ||
| $res = array( | ||
| "status"=> "error", | ||
| "error"=> "Upload Error", | ||
| "message"=> load_language('image_upload_error',true)/*.$error['error']*/ | ||
| ); | ||
| $this->Home_model->delete_registration_doctor($result['data']['id']); | ||
| $this->session->set_flashdata('message', array('message' => load_language('image_upload_error',true), 'title' => 'Error', 'class' => 'danger')); | ||
| redirect(base_url().'Home/RegisterDoctor'); | ||
| } | ||
| else | ||
| { | ||
| //print_r($this->input->post('name')); | ||
| //print_r($_POST['username']); | ||
| $static_string = 'IPOK_Doctor'.time(); | ||
| $authToken = uniqid($static_string); | ||
| $result_authtoken = $this->Home_model->authtoken_registration_doctor($authToken,$result['data']['id']); | ||
| $imagedata = $this->upload->data(); | ||
| $fullfilepath='assets/uploads/profilepic/doctors/'.$imagedata['file_name']; | ||
| $picdata = array('profile_pic'=>$fullfilepath); | ||
| $this->Home_model->updatePic_doctor($picdata,$result['data']['id']); | ||
| $cpf_obj = array('cpf' => $data['cpf'] ,'user_type' =>1,'user_id'=>$result['data']['id']); | ||
| $this->Home_model->insertcpfunique($cpf_obj); | ||
| $this->session->set_flashdata('message', array('message' => load_language('register_success_message',true), 'title' => 'Success', 'class' => 'success')); | ||
| header('Location: '.base_url().'Home/RegisterDoctor'); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| $this->session->set_flashdata('message', array('message' => load_language('register_failed_message',true), 'title' => 'Error', 'class' => 'danger')); | ||
| redirect(base_url().'Home/RegisterDoctor'); | ||
| } | ||
| } | ||
| } | ||
| /*FUNCTION FOR REDIRECTING INTO USER(PATIENT/DOCTOR) DASHBOARD - HOME*/ | ||
| public function Dashboard() | ||
| { | ||
| $userdata = $this->session->userdata('UserData'); | ||
| if($userdata['type']=='DOCTOR') | ||
| { | ||
| header('Location: '.base_url().'Doctor'); | ||
| } | ||
| else if($userdata['type']=='PATIENT') | ||
| { | ||
| header('Location: '.base_url().'Patient'); | ||
| } | ||
| } | ||
| /*FUNCTION FOR CHECKING USER CREDENTIALS AND SENT RESET PASSWORD MAIL TO USER*/ | ||
| public function forgotpassword() | ||
| { | ||
| //print_r($_POST); | ||
| if(!empty($_POST)) | ||
| { | ||
| $check_authentic = $this->Home_model->check_valid_email_forgot($_POST['email'],$_POST['type']); | ||
| //print_r($check_authentic);die(); | ||
| if($check_authentic['count']==1) | ||
| { | ||
| //send_mail('test','test','test'); | ||
| $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | ||
| $result = ''; | ||
| for ($i = 0; $i < 24; $i++) | ||
| $result .= $characters[mt_rand(0, 61)]; | ||
| $link = base_url().'Home/resetpassword/?i='.$check_authentic['id'].'&c='.$result.'&t='; | ||
| if($_POST['type']=='DOCTOR') | ||
| { | ||
| $link = $link.'2'; | ||
| $this->Doctor_model->set_confirmation_code($check_authentic,$result); | ||
| } | ||
| else | ||
| { | ||
| $link = $link.'1'; | ||
| $this->Patient_model->set_confirmation_code($check_authentic,$result); | ||
| } | ||
| $msg = "Hi ".$check_authentic['name'].",<br><br>Your request for resetting password has been accepted. Use the following link to reset password. ".$link.". Please Do not share with anyone<br><br>Ipok Team"; | ||
| //print_r($msg); | ||
| send_mail($msg,$_POST['email'],'Reset Password'); | ||
| //sent email | ||
| $res = array('status' => 'success','msg' => load_language('valid_email_address',true)); | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'error','msg' =>load_language('invalid_credentials',true) ); | ||
| } | ||
| print json_encode($res); | ||
| } | ||
| } | ||
| /*FUNCTION FOR RESETING USER PASSWORD FROM MAIL*/ | ||
| public function resetpassword() | ||
| { | ||
| //print_r($_GET["t"]);die(); | ||
| if(!empty($_GET["t"]) and !empty($_GET["c"]) and !empty($_GET["i"])) | ||
| { | ||
| $type=$_GET["t"]; //0->Patient 1->Doctor | ||
| $code=$_GET["c"]; | ||
| $id=$_GET["i"]; | ||
| $db_code = $this->Home_model->check_confirmation_id($id,$code,$type); | ||
| // /print_r($db_code);die(); | ||
| if($db_code['confirmation_code']==$code) | ||
| { | ||
| $template['page'] = "forgot_password"; | ||
| } | ||
| else | ||
| { | ||
| $template['page'] = "forgot_password_error"; | ||
| } | ||
| $template['type'] = $type; | ||
| $template['id'] = $id; | ||
| $template['page_title'] = "Reset Password"; | ||
| $this->load->view('template/template', $template); | ||
| } | ||
| else | ||
| { | ||
| $template['page'] = "forgot_password_error"; | ||
| $template['page_title'] = "Reset Password"; | ||
| $this->load->view('template/template', $template); | ||
| } | ||
| //load the page reseting password both from web and mobile | ||
| } | ||
| /*FUCTION FOR AJAX CALL IN SAVING NEW PASSWAORD*/ | ||
| public function sav_reset() | ||
| { | ||
| //print_r($_POST); | ||
| $update = array('password' => md5($_POST['password']),'confirmation_code' =>''); | ||
| $status = $this->Home_model->update_profile($_POST['id'],$_POST['type'],$update); | ||
| if($status) | ||
| { | ||
| $res = array('status' =>'success'); | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' =>'error'); | ||
| } | ||
| print json_encode($res); | ||
| } | ||
| /*FUNCTION FOR RETRIVING SESSION DATA TO CHAT JS*/ | ||
| public function get_session() | ||
| { | ||
| if($this->session->userdata('UserData')) | ||
| { | ||
| $userdata = $this->session->userdata('UserData'); | ||
| //header('Content-type: application/json'); | ||
| print json_encode($userdata); | ||
| } | ||
| else | ||
| { | ||
| $array = array('status' => 'error','msg' =>load_language('unauthorized_session',true) ); | ||
| print json_encode($array); | ||
| } | ||
| } | ||
| /*FUNCTION FOR RETRIVING OPPONENT DATA TO CHAT JS*/ | ||
| public function get_opponentData() | ||
| { | ||
| if($this->session->userdata('opponentData')) | ||
| { | ||
| $data = $this->session->userdata('opponentData'); | ||
| //print_r($data);die(); | ||
| unset($_SESSION['opponentData']); | ||
| print json_encode($data); | ||
| } | ||
| else | ||
| { | ||
| $array = array('status' => 'error','msg' => load_language('unauthorized_session',true)); | ||
| print json_encode($array); | ||
| } | ||
| } | ||
| /*FUNCTION FOR RETRIVING RECENT CHAT DATA TO CHAT JS*/ | ||
| public function get_recent_chat() | ||
| { | ||
| if($this->session->userdata('UserData')) | ||
| { | ||
| $userdata = $this->session->userdata('UserData'); | ||
| $recent = $this->Home_model->get_recent_chat($userdata['id'],$userdata['type']); | ||
| //print_r($recent);die(); | ||
| //header('Content-type: application/json'); | ||
| print json_encode($recent); | ||
| } | ||
| else | ||
| { | ||
| $array = array('status' => 'error','msg' => load_language('unauthorized_session',true)); | ||
| print json_encode($array); | ||
| } | ||
| } | ||
| /*FUNCTION FOR RETRIVING ALL CHAT USERS TO CHAT JS*/ | ||
| public function get_all_chat_users() | ||
| { | ||
| if($this->session->userdata('UserData')) | ||
| { | ||
| $userdata = $this->session->userdata('UserData'); | ||
| $allusers = $this->Home_model->get_all_chat_users($userdata['id'],$userdata['type']); | ||
| //print_r($allusers);die(); | ||
| //header('Content-type: application/json'); | ||
| print json_encode($allusers); | ||
| } | ||
| else | ||
| { | ||
| $array = array('status' => 'error','msg' => load_language('unauthorized_session',true)); | ||
| print json_encode($array); | ||
| } | ||
| } | ||
| /*FUNCTION FOR UPDATING RECENT CHAT DATA TO CHAT JS*/ | ||
| public function update_recent_chat() | ||
| { | ||
| if($this->session->userdata('UserData') and !empty($_POST)) | ||
| { | ||
| //print_r($_POST);die(); | ||
| $userdata = $this->session->userdata('UserData'); | ||
| $this->Home_model->update_recent_chat($_POST); | ||
| $recent = $this->Home_model->get_recent_chat($userdata['id'],$userdata['type']); | ||
| //print_r($recent);die(); | ||
| //header('Content-type: application/json'); | ||
| print json_encode($recent); | ||
| } | ||
| else | ||
| { | ||
| $array = array('status' => 'error','msg' => load_language('unauthorized_session',true)); | ||
| print json_encode($array); | ||
| } | ||
| } | ||
| /*FUNCTION FOR CHECKING EMAIL EXIST - DOCTOR REGISTRATION*/ | ||
| public function check_email_colabor() | ||
| { | ||
| $data = $_POST; | ||
| $check_result = $this->Home_model->emailExist_colabor($data); | ||
| //print_r($check_result);die(); | ||
| print json_encode($check_result); | ||
| } | ||
| /*FUNCTION TO DISPLAY NOT AUTHORIZED ERROR PAGE*/ | ||
| public function error() | ||
| { | ||
| $template['page'] = "error_notauthorized"; | ||
| //$this->load->view('error_notauthorized', $template); | ||
| if($this->uri->segment(3) and $this->uri->segment(3)=='url') | ||
| { | ||
| $template['page'] = "error_invalidurl"; | ||
| } | ||
| $template['page_title'] = "Error"; | ||
| $this->load->view('template/template', $template); | ||
| } | ||
| /*FUNCTION FOR SENTING CONFRIMATION CODE FOR ACCOUNT DELETION - PATIENT AND DOCTOR*/ | ||
| /*public function sentConfirmationcode($user) | ||
| { | ||
| $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; | ||
| $result = ''; | ||
| for ($i = 0; $i < 8; $i++) | ||
| $result .= $characters[mt_rand(0, 35)]; | ||
| $msg = "Hi Jithin,</br></br>Your Confirmation Code for Ipok Account Deactivation is ".$result.". | ||
| </br></br>Ipok Team"; | ||
| $this->send_mail($msg,'[email protected]','Account Deactivation'); | ||
| //print_r($msg); | ||
| } | ||
| public function send_mail($msg,$email,$sub){ | ||
| $settings = $this->db->get('settings')->row(); | ||
| //print_r($settings); | ||
| $configs = array( | ||
| 'protocol'=>'smtp', | ||
| 'smtp_host'=>$settings->smtp_host, | ||
| 'smtp_user'=>$settings->smtp_username, | ||
| 'smtp_pass'=>$settings->smtp_password, | ||
| 'smtp_port'=>'587', | ||
| 'smtp_timeout'=>20, | ||
| 'mailtype' => 'html', | ||
| 'charset' => 'iso-8859-1', | ||
| 'wordwrap' => TRUE | ||
| ); | ||
| $this->load->library('email', $configs); | ||
| $this->email->initialize($configs); | ||
| $this->email->set_newline("\r\n"); | ||
| $this->email | ||
| ->from($settings->admin_email, 'Ipok') | ||
| ->to($email) | ||
| ->subject($sub) | ||
| ->message($msg); | ||
| $this->email->send(); | ||
| } | ||
| */ | ||
| /*FUCNTION TO ADD BANK DETAILS TO CURRENT USER*/ | ||
| public function addBank() | ||
| { | ||
| if(!empty($this->session->userdata('UserData'))) | ||
| { | ||
| $userdata = $this->session->userdata('UserData'); | ||
| $insert_array = array('account_no' => $_POST['account'],'account_holder' => $_POST['name'],'bank_name' => $_POST['bank'],'agency' => $_POST['agency']); | ||
| if($userdata['type']=="PATIENT") | ||
| { | ||
| $insert_array['type']=0; | ||
| $insert_array['type_id'] = $userdata['id']; | ||
| } | ||
| elseif($userdata['type']=="DOCTOR") | ||
| { | ||
| $insert_array['type']=1; | ||
| $insert_array['type_id'] = $userdata['id']; | ||
| } | ||
| //print_r($insert_array); | ||
| $insert = $this->Home_model->insert_bank_account($insert_array); | ||
| if($insert) | ||
| { | ||
| $res = array('status' => 'success','message' => load_language('bank_added',true)); | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'error','message' => load_language('insertion_failed',true)); | ||
| } | ||
| print json_encode($res); | ||
| } | ||
| } | ||
| /*FUNCTION TO RETURN ALL SAVED BANKS FOR CURRENT USER*/ | ||
| public function getAllBanks() | ||
| { | ||
| if(!empty($this->session->userdata('UserData'))) | ||
| { | ||
| $userdata = $this->session->userdata('UserData'); | ||
| $banks = $this->Home_model->get_all_banks($userdata['id'],$userdata['type']); | ||
| $template['banks'] = $banks; | ||
| $this->load->view('wallet_show_banks',$template); | ||
| } | ||
| } | ||
| /*FUNCTION TO RETURN ALL SAVED BANKS - Wallet display*/ | ||
| public function refreshBankList() | ||
| { | ||
| if(!empty($this->session->userdata('UserData'))) | ||
| { | ||
| $userdata = $this->session->userdata('UserData'); | ||
| $banks = $this->Home_model->get_all_banks($userdata['id'],$userdata['type']); | ||
| $template['banks'] = $banks; | ||
| $this->load->view('wallet_show_bank_redemption',$template); | ||
| } | ||
| } | ||
| /* FUNCTION TO REMOVE BANK FOR GIVEN BANK ID*/ | ||
| public function removeBank() | ||
| { | ||
| if(!empty($_POST['bank_id']) and !empty($this->session->userdata('UserData'))) | ||
| { | ||
| $userdata = $this->session->userdata('UserData'); | ||
| $this->Home_model->remove_bank($_POST['bank_id']); | ||
| $banks = $this->Home_model->get_all_banks($userdata['id'],$userdata['type']); | ||
| $template['banks'] = $banks; | ||
| $this->load->view('wallet_show_banks',$template); | ||
| } | ||
| } | ||
| /*FUNCTION TO PROCESS REDEMPTION REQUEST*/ | ||
| public function redemptionrequest() | ||
| { | ||
| if(!empty($this->session->userdata('UserData')) and !empty($_POST)) | ||
| { | ||
| $userdata = $this->session->userdata('UserData'); | ||
| $get_account_balance = $this->Home_model->get_redemption_balance($userdata['id']); | ||
| $check_valid_bank = $this->Home_model->get_bank_valid($userdata['id'],$_POST['redemption_bank']); | ||
| //print_r($check_valid_bank);die(); | ||
| $nowin_server = date("Y-m-d TH:i:s"); | ||
| if($get_account_balance['reedem_earn']>=$_POST['redemption_amount'] and $check_valid_bank['count']==1) | ||
| { | ||
| $withdrawal_insert = array('bank_id' => $_POST['redemption_bank'], 'amount'=>$_POST['redemption_amount'], 'date'=>time(),'status'=>0,'doctor_id' =>$userdata['id'],'previous_reedem_earn'=>$get_account_balance['reedem_earn']); | ||
| $this->Home_model->add_redemption_request($withdrawal_insert); | ||
| $res = array('status' => 'success','message' => load_language('redemption_requested',true)); | ||
| } | ||
| elseif($get_account_balance['reedem_earn']<=$_POST['redemption_amount'] and $check_valid_bank['count']==1) | ||
| { | ||
| $withdrawal_insert = array('bank_id' => $_POST['redemption_bank'], 'amount'=>$_POST['redemption_amount'], 'date'=>time(),'status'=>3,'doctor_id' =>$userdata['id'],'previous_reedem_earn'=>$get_account_balance['reedem_earn']); | ||
| $this->Home_model->add_redemption_request($withdrawal_insert); | ||
| $res = array('status' => 'error','message' => load_language('error_insufficient_balance',true)); | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'error','message' => load_language('invalid_bank_account',true) ); | ||
| } | ||
| //print_r($withdrawal_insert); | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'error','message' => load_language('facing_technical_issues',true)); | ||
| } | ||
| print json_encode($res); | ||
| } | ||
| public function test() | ||
| { | ||
| /*$cpf_obj = array('cpf' => '456884' ,'user_type' =>1,'user_id'=>$result['data']['id']); | ||
| $this->Home_model->insertcpfunique($cpf_obj);*/ | ||
| } | ||
| public function check_cpfunique() | ||
| { | ||
| $cpf = $_POST['cpf']; | ||
| $result = $this->Home_model->check_cpfunique($cpf); | ||
| if($result['count']==0) | ||
| { | ||
| $res = array('status' => 'success','unique' => 'true'); | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'error','unique' => 'false'); | ||
| } | ||
| print json_encode($res); | ||
| } | ||
| /*CRON JOBS FOR IPOK*/ | ||
| public function cron_jobs() | ||
| { | ||
| /*FUNCTION FOR CANCELING ALL UNPAID BOOKINGS*/ | ||
| $check_payments_booking = $this->Home_model->get_booking_for_payment_cron(); | ||
| print_r($check_payments_booking); | ||
| if(!empty($check_payments_booking)) | ||
| foreach ($check_payments_booking as $key => $value) { | ||
| $this->Doctor_model->change_booking_status($value['id'],4); //canceling all unpaid bookings | ||
| } | ||
| die(); | ||
| /*FUNCTION FOR SENTING CONSULTATION REMINDER*/ | ||
| $nowin_server = date("Y-m-d TH:i:s"); | ||
| //print_r($nowin_server);die(); | ||
| $todays_booking = $this->Home_model->get_todays_booking(); | ||
| //echo "<pre>"; | ||
| //print_r($todays_booking); | ||
| if(!empty($todays_booking)) | ||
| { | ||
| foreach ($todays_booking as $key => $booking) | ||
| { | ||
| //print_r($booking['id']);die(); | ||
| /*CODE FOR SENTING NOTIFICATION - PATIENT NOTIFICATION*/ | ||
| /*------------------------------------------------*/ | ||
| $booking_details = $this->Search_doctor_model->get_booking_details($booking['id']); | ||
| $doctor_data = $this->Doctor_model->get_single_doctor($booking_details['doctor_id']); | ||
| $text_pat = 'You have a scheduled appointment in the system today, at '.date('H:i a',$booking_details['time_start']).', doctor '.$doctor_data['dr_name']; | ||
| $notification_pat = array('patient_id' => $booking_details['patient_id'],'type'=>2,'message'=>$text_pat,'read_status'=>0,'time'=>strtotime($nowin_server),'booking_id' =>$booking['id']); | ||
| $this->Home_model->insert_notification_patient($notification_pat); | ||
| /*------------------------------------------------*/ | ||
| } | ||
| } | ||
| } | ||
| /*FUNCTION FOR LANGUAGE SETTINGS CHANGE*/ | ||
| public function langSettings() | ||
| { | ||
| $data = $_POST; | ||
| $lval=$data['lval']; | ||
| $this->session->set_userdata('language', $lval); | ||
| echo $a= $this->session->userdata('language'); | ||
| } | ||
| /*FUNCTION FOR CHECK LOGIN*/ | ||
| public function islogedin() | ||
| { | ||
| //print_r($this->session->userdata('user_time')); | ||
| if(auto_logout("user_time")) | ||
| { | ||
| $result = array('status' => 'error'); | ||
| $this->session->set_userdata('logout', 'autologoff'); | ||
| $this->session->set_userdata('user_time', time()); | ||
| } | ||
| else | ||
| { | ||
| $result = array('status' => 'success'); | ||
| } | ||
| print json_encode($result); | ||
| } | ||
| } | ||
| <?php | ||
| defined('BASEPATH') OR exit('No direct script access allowed'); | ||
| class Searchdoctor extends CI_Controller { | ||
| function __construct() | ||
| { | ||
| parent::__construct(); | ||
| $this->load->model('Search_doctor_model'); | ||
| $this->load->model('Home_model'); | ||
| $this->load->model('Doctor_model'); | ||
| $this->load->model('Patient_model'); | ||
| $this->config->load('iugu'); | ||
| } | ||
| /*FUNCTION :REDIRECTS TO SEARCH FUNCTION AFTER SETTING LOCAL STORAGE OF SEARCH DATA - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Search data is saved in local storage for showing the previous search data while | ||
| user navigates through search screens*/ | ||
| public function index() | ||
| { | ||
| if(isset($_POST)&&(!empty($_POST))) | ||
| { | ||
| $request = $_POST; | ||
| //print_r($request);die(); | ||
| $this->session->set_userdata('DoctorSearchData',$request); | ||
| } | ||
| header('Location: '.base_url().'Searchdoctor/search'); | ||
| } | ||
| /*FUNCTION : SEARCH FUNCTION FOR FILTERING DOCTORS - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Search data from the local storage is used to filter the search based on various | ||
| factors*/ | ||
| public function search() | ||
| { | ||
| $speciality_list = $this->Home_model->get_speciality(); | ||
| $template['speciality_list'] = $speciality_list; | ||
| if($this->session->userdata('DoctorSearchData')) | ||
| { | ||
| $request = $this->session->userdata('DoctorSearchData'); | ||
| //print_r($request); | ||
| //die(); | ||
| if((isset($request['doctor-search-date']))&&(!empty($request['doctor-search-date']))) | ||
| { | ||
| //$date = str_replace('/', '-', $request['doctor-search-date']); | ||
| $request['doctor-search-date'] = strtotime($request['doctor-search-date']); | ||
| //print_r($request);die(); | ||
| } | ||
| $all_doctors = $this->Search_doctor_model->filter_search($request); | ||
| //echo "<pre>"; | ||
| //print_r($all_doctors);die(); | ||
| $price_min = $this->Search_doctor_model->get_doc_min_price(); | ||
| $price_max = $this->Search_doctor_model->get_doc_max_price(); | ||
| $distance_min = $this->Search_doctor_model->get_doc_min_distance($request); | ||
| $distance_max = $this->Search_doctor_model->get_doc_max_distance($request); | ||
| //print_r($distance_max[0]['dist']);die(); | ||
| /*$filter_autoload = array('price_min' =>$price_min[0]['price'] ,'price_max'=>$price_max[0]['price'],'distance_min'=>$distance_min[0]['dist'],'distance_max'=>$distance_max[0]['dist']);*/ | ||
| $filter_autoload = array('price_min' =>$price_min[0]['price'] ,'price_max'=>$price_max[0]['price'],'distance_min'=>'0','distance_max'=>'15'); | ||
| //print_r($filter_autoload);die(); | ||
| if(!empty($all_doctors)) | ||
| { | ||
| $template['doctors_list'] = $all_doctors; | ||
| } | ||
| $template['page'] = "search_doctor"; | ||
| $template['page_title'] = "Search Doctor"; | ||
| $template['searchdata'] = $request; | ||
| $template['filter_autoload'] = $filter_autoload; | ||
| $this->load->view('template/template', $template); | ||
| } | ||
| else | ||
| { | ||
| $template['page'] = "search_doctor"; | ||
| $template['page_title'] = "Search Doctor"; | ||
| $this->load->view('template/template', $template); | ||
| } | ||
| } | ||
| /*FUNCTION : FILTER FUNCTION FOR FILTERING DOCTORS - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Search data from the local storage is used to filter the search based on various | ||
| factors.here the additional filters from search page is also included*/ | ||
| public function filter_search() | ||
| { | ||
| if(isset($_POST)&&(!empty($_POST))) | ||
| { | ||
| $request = $_POST; | ||
| $this->session->set_userdata('DoctorSearchData',$request); | ||
| //print_r($request);die(); | ||
| if((isset($request['doctor-search-date']))&&(!empty($request['doctor-search-date']))) | ||
| { | ||
| $request['doctor-search-date'] = strtotime($request['doctor-search-date']); | ||
| } | ||
| $template['searchdata'] = $request; | ||
| $all_doctors = $this->Search_doctor_model->filter_search($request); | ||
| $template['doctors_list'] = $all_doctors; | ||
| //echo "<pre>"; | ||
| //print_r($all_doctors);die(); | ||
| $this->load->view('search_doctor_result',$template); | ||
| } | ||
| } | ||
| /*FUNCTION : VIEW DOCTOR COMPLETE PROFILE - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Controller to view doctor profile from doctor search*/ | ||
| public function doctorprofile() | ||
| { | ||
| $doctor_id = $this->uri->segment(3); | ||
| $clinic_id = $this->uri->segment(4); | ||
| $doctor_data = $this->Search_doctor_model->get_single_doctor_clinic($doctor_id,$clinic_id); | ||
| $userdata = $this->session->userdata('UserData'); | ||
| for ($i=0; $i < 7; $i++) | ||
| { | ||
| $day = date('D',strtotime('+'.$i.'day')); | ||
| $dayno = date('d',strtotime('+'.$i.'day')); | ||
| $week_appointments[$i] = $this->Doctor_model->get_doctor_appointments_week($doctor_id,date('y-m-d',strtotime('+'.$i.'day'))); | ||
| } | ||
| $check_profile_view_entry = $this->Search_doctor_model->check_profile_view_entry($doctor_id); | ||
| if($check_profile_view_entry['count']==0) | ||
| { | ||
| $this->Search_doctor_model->insert_profile_view_count($doctor_id); | ||
| } | ||
| $template['week_appointments'] = $week_appointments; | ||
| $template['page'] = "search_doctor_complete_profile"; | ||
| $template['page_title'] = "Doctor Profile"; | ||
| $template['doctor_data'] = $doctor_data; | ||
| $this->load->view('template/template', $template); | ||
| } | ||
| /*FUNCTION : VIEW BOOKING PAGE - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Controller to view booking page from doctor search*/ | ||
| public function confirmbooking() | ||
| { | ||
| $doctor_id = $this->uri->segment(3); | ||
| $clinic_id = $this->uri->segment(4); | ||
| $doctor_data = $this->Search_doctor_model->get_single_doctor_clinic($doctor_id,$clinic_id); | ||
| $policy = $this->Patient_model->get_policy(); | ||
| //$template['time_slot'] = $res_new; | ||
| $template['page'] = "search_doctor_confirm_booking"; | ||
| $template['page_title'] = "Booking"; | ||
| $template['doctor_data'] = $doctor_data; | ||
| $template['policy'] = $policy['waiting_policy']; | ||
| $this->load->view('template/template', $template); | ||
| } | ||
| /*FUNCTION : GET DOCTOR TIMESLOT FOR GIVEN CLINIC - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Returns doctor timeslot for the scheduled agenda excluding the break time*/ | ||
| public function getDoctorClinic_timeslot() | ||
| { | ||
| //print_r($_POST['clinic_id']);die(); | ||
| $result_availability = $this->Search_doctor_model->doctor_availability($_POST['doctor_id'],$_POST['clinic_id']); | ||
| $consult_duration = $this->Doctor_model->check_consult_duration($_POST['doctor_id']); | ||
| //print_r($_POST); | ||
| $res_new = array(); | ||
| $nowin_server = date("Y-m-d TH:i:s"); | ||
| if($_POST['UTCoffset']['sign']=='+') | ||
| { | ||
| //$clienttime_UTC = date("Y-m-d H:i:s",strtotime($_POST['currenttime']." -".$_POST['UTCoffset']['hour']." hours -".$_POST['UTCoffset']['minute']." minutes")); | ||
| //print_r($clienttime_UTC); | ||
| $nowin_server_addoffset = date('Y-m-d H:i:s',strtotime('+'.$_POST['UTCoffset']['hour'].' hour +'.$_POST['UTCoffset']['minute'].' minutes',strtotime($nowin_server))); | ||
| } | ||
| elseif ($_POST['UTCoffset']['sign']=='-') | ||
| { | ||
| //$clienttime_UTC = date("Y-m-d H:i:s",strtotime($_POST['currenttime']." +".$_POST['UTCoffset']['hour']." hours +".$_POST['UTCoffset']['minute']." minutes")); | ||
| //print_r($clienttime_UTC); | ||
| $nowin_server_addoffset = date('Y-m-d H:i:s',strtotime('-'.$_POST['UTCoffset']['hour'].' hour -'.$_POST['UTCoffset']['minute'].' minutes',strtotime($nowin_server))); | ||
| } | ||
| //$clienttime_UTC_add1hr = date("Y-m-d H:i:s",strtotime($clienttime_UTC." + 1hours ")); | ||
| //if(strtotime($clienttime_UTC_add1hr)>strtotime($nowin_server)) | ||
| //{ | ||
| /*print_r($clienttime_UTC); | ||
| print_r($clienttime_UTC_add1hr); | ||
| print_r($nowin_server); | ||
| print_r($nowin_server_addoffset);*/ | ||
| //} | ||
| if($result_availability['data']['active_schedule']=='0') | ||
| { | ||
| $schedule = $result_availability['data']['date']; | ||
| } | ||
| else | ||
| { | ||
| $schedule = $result_availability['data']['date_secondary']; | ||
| } | ||
| if(($result_availability['status']) == 'success' and ($schedule!='""')) | ||
| { | ||
| $day = date('D',strtotime($_POST['book_date'])); | ||
| $res = array(); | ||
| //print_r(strtotime($_POST['currenttime']));die(); | ||
| $schedule = json_decode($schedule,true); | ||
| foreach ($schedule as $key => $value) { | ||
| if($value['day'] == strtolower($day)) | ||
| { | ||
| $interval_time = $consult_duration['consultation_duration']*60; | ||
| $start_time = strtotime($_POST['book_date'].' '.$value['time']['start']); | ||
| $end_time = strtotime($_POST['book_date'].' '.$value['time']['end']); | ||
| $break_start = strtotime($_POST['book_date'].' '.$value['time']['break_from']); | ||
| $break_end = strtotime($_POST['book_date'].' '.$value['time']['break_to']); | ||
| //echo "break_from : ".$break_start."|break_to : ".$break_end."||"; | ||
| for ($i=$start_time; $i<=$end_time; $i=$i+$interval_time) | ||
| { | ||
| $initial = $i; | ||
| $end = $i+$interval_time; | ||
| if(isset($value['time']['break_from']) && isset($value['time']['break_to']) && ($value['time']['break_from'] != 'null' ) && ($value['time']['break_to'] != 'null') && strlen($value['time']['break_from']) && strlen($value['time']['break_to'])) | ||
| { | ||
| if(!((($initial <= $break_start) &&($end > $break_start))||(($initial < $break_end) &&($end >= $break_end))||(($initial > $break_start) &&($end < $break_end)))&&($initial>strtotime($nowin_server_addoffset))) | ||
| { | ||
| //print_r("12");die(); | ||
| if($end <= $end_time && ($initial>strtotime($nowin_server_addoffset))) | ||
| { | ||
| array_push($res, array('time'=>date('h:i a',$initial).' - '.date('h:i a',$end),'start'=>$initial,'end'=>$end)); | ||
| } | ||
| } | ||
| } | ||
| else | ||
| { | ||
| if(($end <= $end_time)&&($initial>strtotime($nowin_server_addoffset))) | ||
| { | ||
| array_push($res, array('time'=>date('h:i a',$initial).' - '.date('h:i a',$end),'start'=>$initial,'end'=>$end)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| $res_new = array_values(array_unique($res,SORT_REGULAR)); | ||
| //$res_new['msg'] = load_language('time_slot',true); | ||
| if(empty($res_new)) | ||
| { | ||
| $res_new_print = array('status' => 'error', 'msg' => load_language('no_time_slot_available',true),'arr' =>$res_new); | ||
| } | ||
| else | ||
| { | ||
| $res_new_print = array('status' => 'success', 'msg' => load_language('time_slot',true),'arr' =>$res_new ); | ||
| } | ||
| //echo "<pre>"; | ||
| //print_r($res_new);die(); | ||
| } | ||
| print json_encode($res_new_print); | ||
| } | ||
| /*FUNCTION : CHECK AVAILABILITY OF A DOCTOR - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Returns whether the booking for given date and timeslot is available or return | ||
| if the doctor is on leave for given date */ | ||
| public function checkDoctorAvailability() | ||
| { | ||
| $check_leave = $this->Search_doctor_model->checkDoctorLeave($_POST); | ||
| $times = explode('-', $_POST['confirm-book-time']); | ||
| $book_start_time = strtotime($_POST['confirm-book-date'].' '.$times[0]); | ||
| if(strtotime($_POST['currenttime'])<$book_start_time) | ||
| { | ||
| if($check_leave['count']==0) | ||
| { | ||
| $check_booking = $this->Search_doctor_model->checkDoctorBooking($_POST); | ||
| //print_r($check_booking);die(); | ||
| if($check_booking['count']==0) | ||
| { | ||
| if($this->session->userdata('UserData')) | ||
| { | ||
| $res = array('status' => 'success', 'msg' => 'booking success','isLogin' =>'true'); | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'success', 'msg' => 'booking success','isLogin' =>'false'); | ||
| } | ||
| } | ||
| elseif($check_booking['count']==1) | ||
| { | ||
| if($this->session->userdata('UserData')) | ||
| { | ||
| $res = array('status' => 'waiting', 'msg' => load_language('booking_full_waiting_list_available',true),'isLogin' =>'true'); | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'waiting', 'msg' => load_language('booking_full_waiting_list_available',true),'isLogin' =>'false'); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'fail', 'type' => 'booking slot','msg' => load_language('booking_slot_unavailable',true)); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'fail','type' => 'doctor leave', 'msg' => load_language('doctor_unavailable',true) ); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'fail','type' => 'booking slot', 'msg' => load_language('invalid_booking_slot',true)); | ||
| } | ||
| //print_r($res);die(); | ||
| print json_encode($res); | ||
| } | ||
| /*FUNCTION : MARK BOOKING FOR A DOCTOR - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Mark an entry in booking table and goes to payment page in confirm booking */ | ||
| public function markbooking() | ||
| { | ||
| if($this->session->userdata('UserData')) | ||
| { | ||
| $userdata = $this->session->userdata('UserData'); | ||
| if($userdata['type']=="PATIENT") | ||
| { | ||
| /*CODE FOR DATA STARTS*/ | ||
| $now = new DateTime(); | ||
| $times = explode('-', $_POST['confirm-book-time']); | ||
| $offset = json_decode($_POST['offset']); | ||
| $nowin_server = date("Y-m-d TH:i:s"); | ||
| if($offset->sign=='+') | ||
| { | ||
| $nowin_server_addoffset = date('Y-m-d H:i:s',strtotime('+'.$offset->hour.' hour +'.$offset->minute.' minutes',strtotime($nowin_server))); | ||
| } | ||
| elseif ($offset->sign=='-') | ||
| { | ||
| $nowin_server_addoffset = date('Y-m-d H:i:s',strtotime('-'.$offset->hour.' hour -'.$offset->minute.' minutes',strtotime($nowin_server))); | ||
| } | ||
| $date = date('y-m-d'); | ||
| $book_start_time = strtotime($_POST['confirm-book-date'].' '.$times[0]); | ||
| $book_end_time = strtotime($_POST['confirm-book-date'].' '.$times[1]); | ||
| $doctor_price = $this->Search_doctor_model->getDoctorPrice($_POST['confirm-book-doctor']); | ||
| $doctor_data = $this->Doctor_model->get_single_doctor($_POST['confirm-book-doctor']); | ||
| $data = array('doctor_id' =>$_POST['confirm-book-doctor'] ,'clinic_id' =>$_POST['confirm-book-clinic'] ,'clinic_id' =>$_POST['confirm-book-clinic'],'patient_id' =>$userdata['id'] ,'date' =>strtotime($_POST['confirm-book-date']),'time' =>$_POST['confirm-book-time'],'amount'=>$doctor_price['price'],'requested_date'=>$now->getTimestamp(),'time_start'=>$book_start_time,'time_end'=>$book_end_time,'visit_type'=>0); | ||
| if(isset($_POST['book-status'])&&$_POST['book-status']=="0") | ||
| { | ||
| $data['booking_status'] = 0; | ||
| } | ||
| else | ||
| { | ||
| $data['booking_status'] = 1; | ||
| } | ||
| $data['total_sum'] = $doctor_price['price']; | ||
| if(($_POST['promocode-status']=='1') and ($_POST['promocode-name']!='0')) | ||
| { | ||
| $data['promo_name'] = $_POST['promocode-name']; | ||
| $promo_value = $this->Search_doctor_model->get_promocode_value($_POST['promocode-name']); | ||
| $offeramount = ($promo_value['amount']/100) * $doctor_price['price']; | ||
| $data['promo_amount'] = $offeramount; | ||
| $data['total_sum'] = $doctor_price['price'] - $offeramount; | ||
| } | ||
| /*CODE FOR DATA ENDS*/ | ||
| $return_inclusive = $this->Search_doctor_model->get_doc_retrun_inclusive($_POST['confirm-book-doctor']); | ||
| if($return_inclusive['accept_return']=='1') | ||
| { | ||
| $check_previous_book = $this->Search_doctor_model->get_previous_book($_POST,$return_inclusive['return_timeperiod'],$userdata['id']); | ||
| //print_r($check_previous_book);die(); | ||
| if($check_previous_book['visit_type']=='0' and $check_previous_book['free_visit_status']=='0') //Free Visit Found | ||
| { | ||
| $data['visit_type']=1; //New Booking is Free | ||
| $data['payment_status'] = 1; //Setting payment done true | ||
| $data['free_visit_status']=2; //Setting free status->not applicable | ||
| $this->Search_doctor_model->mark_freevisit_status($check_previous_book['id']); //MARKING FREE VISIT STATUS OF PREVIOUS BOOKING TO USED | ||
| } | ||
| } | ||
| $ipok_settings = $this->Home_model->get_ipok_settings(); | ||
| $data['ipok_fee'] = $ipok_settings['ipok_fee']; | ||
| //print_r($check_return_book); | ||
| //print_r($data); | ||
| //die(); | ||
| $inserted_id = $this->Search_doctor_model->insertBooking($data); //MARK BOOKING | ||
| if($data['visit_type']==1) | ||
| { | ||
| if($data['booking_status'] == 0) | ||
| { | ||
| /*CODE FOR SENTING WAITING LIST NOTIFICATION FOR FREE VISIT - PATIENT NOTIFICATION*/ | ||
| /*------------------------------------------------*/ | ||
| $text_pat = 'Your appointment was scheduled in the system as waiting, on '.date('d.m.Y',$book_start_time).' at '.date('H:i a',$book_start_time).', doctor '.$doctor_data['dr_name']; | ||
| $notification_pat = array('patient_id' => $userdata['id'],'type'=>1,'message'=>$text_pat,'read_status'=>0,'time'=>strtotime($nowin_server),'booking_id' => $inserted_id); | ||
| $patient_insert_id = $this->Home_model->insert_notification_patient($notification_pat); | ||
| $fcm_user = $this->Home_model->get_patient_fcm($data['patient_id']); | ||
| //print_r($fcm_user); | ||
| if(!empty($fcm_user['fcm_token'])) | ||
| { | ||
| //print_r($fcm_user['fcm_token']);die(); | ||
| $pat_push_obj['id'] = $patient_insert_id; | ||
| $pat_push_obj['type'] = "Waiting List"; | ||
| $pat_push_obj['booking_id'] = $inserted_id; | ||
| $pat_push_obj['booking_date'] = $data['date']; | ||
| $pat_push_obj['doctor_id'] = $data['doctor_id']; | ||
| $pat_push_obj['doctor_name'] = $doctor_data['dr_name']; | ||
| $pat_push_obj['doctor_specialization'] = $doctor_data['dr_specialization']; | ||
| $pat_push_obj['message'] = $text_pat; | ||
| $pat_push_obj['time'] = strtotime($nowin_server); | ||
| $pat_push_obj['to'] = $fcm_user['fcm_token']; | ||
| $user_type = '1'; //patient push | ||
| $push_status = push_sent($pat_push_obj,$user_type); | ||
| } | ||
| /*------------------------------------------------*/ | ||
| } | ||
| else | ||
| { | ||
| /*CODE FOR SENTING NOTIFICATION FOR FREE VISIT - DOCTOR NOTIFICATION*/ | ||
| /*------------------------------------------------*/ | ||
| $text = 'A new appointment was scheduled in the system, on '.date('d.m.Y',$book_start_time).' at '.date('H:i a',$book_start_time).', patient '.$userdata['name']; | ||
| $notification = array('doctor_id' => $data['doctor_id'],'type'=>2,'message'=>$text,'read_status'=>0,'time'=>strtotime($nowin_server) ); | ||
| $doctor_insert_id = $this->Home_model->insert_notification_doctor($notification); | ||
| $fcm_doctor = $this->Home_model->get_doctor_fcm($data['doctor_id']); | ||
| if(!empty($fcm_doctor['fcm_token'])) | ||
| { | ||
| $doc_push_obj['id'] = $doctor_insert_id; | ||
| $doc_push_obj['type'] = "New Consultation"; | ||
| $doc_push_obj['message'] =$text; | ||
| $doc_push_obj['read_status'] = false; | ||
| $doc_push_obj['to'] = $fcm_doctor['fcm_token']; | ||
| $user_type = '2'; | ||
| $push_status = push_sent($doc_push_obj,$user_type); | ||
| } | ||
| /*------------------------------------------------*/ | ||
| /*CODE FOR SENTING NOTIFICATION FOR FREE VISIT - PATIENT NOTIFICATION*/ | ||
| /*------------------------------------------------*/ | ||
| $text_pat = 'Your appointment was scheduled in the system, on '.date('d.m.Y',$book_start_time).' at '.date('H:i a',$book_start_time).', doctor '.$doctor_data['dr_name']; | ||
| $notification_pat = array('patient_id' => $userdata['id'],'type'=>0,'message'=>$text_pat,'read_status'=>0,'time'=>strtotime($nowin_server),'booking_id' => $inserted_id); | ||
| $patient_insert_id = $this->Home_model->insert_notification_patient($notification_pat); | ||
| $fcm_user = $this->Home_model->get_patient_fcm($data['patient_id']); | ||
| //print_r($fcm_user); | ||
| if(!empty($fcm_user['fcm_token'])) | ||
| { | ||
| //print_r($fcm_user['fcm_token']);die(); | ||
| $pat_push_obj['id'] = $patient_insert_id; | ||
| $pat_push_obj['type'] = "Consultation Confirmation"; | ||
| $pat_push_obj['booking_id'] = $inserted_id; | ||
| $pat_push_obj['booking_date'] = $data['date']; | ||
| $pat_push_obj['doctor_id'] = $data['doctor_id']; | ||
| $pat_push_obj['doctor_name'] = $doctor_data['dr_name']; | ||
| $pat_push_obj['doctor_specialization'] = $doctor_data['dr_specialization']; | ||
| $pat_push_obj['message'] = $text_pat; | ||
| $pat_push_obj['time'] = strtotime($nowin_server); | ||
| $pat_push_obj['to'] = $fcm_user['fcm_token']; | ||
| $user_type = '1'; //patient push | ||
| $push_status = push_sent($pat_push_obj,$user_type); | ||
| } | ||
| /*------------------------------------------------*/ | ||
| } | ||
| } | ||
| $res = array('booking_id' =>$inserted_id , 'payment_required'=>$data['visit_type'],'booking_date'=>date('d/m/Y',strtotime($_POST['confirm-book-date'])),'booking_slot'=>$_POST['confirm-book-time']); | ||
| print json_encode($res); | ||
| } | ||
| } | ||
| } | ||
| /*FUNCTION : PROMOCODE VALIDATION IN BOOKING MODULE - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Function will check for validity of applied promocode,checks if its valid for passed doctor id*/ | ||
| public function promocode_validate() | ||
| { | ||
| //print_r($_POST); | ||
| $validation = $this->Search_doctor_model->checkPromocode($_POST); | ||
| $doc_list = explode(",",$validation['doctor_id']); | ||
| if (in_array($_POST['doctorid'], $doc_list)) | ||
| { | ||
| $doctor_price = $this->Search_doctor_model->getDoctorPrice($_POST['doctorid']); | ||
| $offeramount = ($validation['amount']/100) * $doctor_price['price']; | ||
| $res = array('status' => 'success' ,'msg'=>load_language('promotion_success',true),'offeramount' =>$offeramount,'code'=>$validation['promo_name']); | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'error','msg'=>load_language('invalid_promocode',true) ); | ||
| } | ||
| print json_encode($res); | ||
| } | ||
| /*FUNCTION : PAYMENT CONTROLLER IN BOOKING MODULE - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Function will update the payment in booking table for respective booking entry*/ | ||
| public function booking_payment() | ||
| { | ||
| $check_markbooking = $this->Search_doctor_model->checkBooking($_POST['booking_id']); | ||
| //print_r($_POST);die(); | ||
| $booking_details = $this->Search_doctor_model->get_booking_details($_POST['booking_id']); | ||
| $patient_data = $this->Patient_model->get_single_patient($booking_details['patient_id']); | ||
| $doctor_data = $this->Doctor_model->get_single_doctor($booking_details['doctor_id']); | ||
| //print_r($booking_details);die(); | ||
| parse_str($_POST['data'], $card_detail); | ||
| //print_r($card_detail);die(); | ||
| $nowin_server = date("Y-m-d TH:i:s"); | ||
| if($_POST['UTCoffset']['sign']=='+') | ||
| { | ||
| $nowin_server_addoffset = date('Y-m-d H:i:s',strtotime('+'.$_POST['UTCoffset']['hour'].' hour +'.$_POST['UTCoffset']['minute'].' minutes',strtotime($nowin_server))); | ||
| } | ||
| elseif ($_POST['UTCoffset']['sign']=='-') | ||
| { | ||
| $nowin_server_addoffset = date('Y-m-d H:i:s',strtotime('-'.$_POST['UTCoffset']['hour'].' hour -'.$_POST['UTCoffset']['minute'].' minutes',strtotime($nowin_server))); | ||
| } | ||
| /*$payment_post = array('email' => '[email protected]' ,'due_date'=>'2018-05-18','items_total_cents' => 1000); | ||
| $payment_post['payer'] = array('cpf_cnpj' => $patient_data['pt_cpf'],'name' =>$patient_data['pt_name'],'email' => $patient_data['pt_email'] ); | ||
| $payment_post['payer']['address'] = array('zip_code' => $patient_data['pt_zip_code'],'street'=>$patient_data['pt_street_add'],'number'=>$patient_data['pt_number'],'complement'=>$patient_data['pt_complement']);*/ | ||
| //echo "<pre>"; | ||
| $payment_token = array('account_id' => $this->config->item('id'),'method'=>'credit_card','test'=>true, ); | ||
| $payment_token['data'] = array('number' => $card_detail['cardnumber'],'verification_value'=> $card_detail['cvv'],'first_name'=>$card_detail['firstname'],'last_name'=>$card_detail['lastname'],'month'=>$card_detail['month'],'year'=>$card_detail['year']); | ||
| /*print_r($payment_token);die();*/ | ||
| $request = load_curl('https://api.iugu.com/v1/payment_token',$payment_token); | ||
| $token = json_decode($request); | ||
| if($check_markbooking['count']!=1) | ||
| { | ||
| $res = array('status' => 'fail', 'payment_status'=>'0','message'=>load_language('no_booking_found/session_invalid',true)); | ||
| } | ||
| elseif(!empty($token->errors->number)) | ||
| { | ||
| $res = array('status' => 'fail', 'payment_status'=>'0','message'=>load_language('invalid_credit_card',true)); | ||
| } | ||
| else | ||
| { | ||
| if(empty($patient_data['pt_customer_id'])) | ||
| { | ||
| $create_customer = array('email'=>$patient_data['pt_email'],'name'=>$patient_data['pt_name'],'cpf_cnpj'=>$patient_data['pt_cpf'],'zip_code' => $patient_data['pt_zip_code'],'street'=>$patient_data['pt_street_add'],'number'=>$patient_data['pt_number'],'complement'=>$patient_data['pt_complement']); | ||
| $request = load_curl('https://api.iugu.com/v1/customers',$create_customer); | ||
| $customer = json_decode($request); | ||
| $this->Patient_model->update_profile($patient_data['patientid'],array('customer_id' => $customer->id )); | ||
| $patient_data['pt_customer_id'] = $customer->id; | ||
| } | ||
| //print_r($patient_data);die(); | ||
| $create_payment_method = array('description' => 'Booking Payment','token'=> $token->id ); | ||
| $request = load_curl('https://api.iugu.com/v1/customers/'.$patient_data['pt_customer_id'].'/payment_methods',$create_payment_method); | ||
| $payment_method = json_decode($request); | ||
| //print_r($payment_method->id); | ||
| if($check_markbooking['count']==1) | ||
| $create_charge = array('customer_payment_method_id'=>$payment_method->id,'customer_id'=>$patient_data['pt_customer_id'],'email' =>$patient_data['pt_email']); | ||
| $items = array('description' =>'Doctor Visit','price_cents' =>$booking_details['total_sum']*100,'quantity' => 1 ); | ||
| $create_charge['items'] = $items; | ||
| $create_charge['payer'] = array('cpf_cnpj' => $patient_data['pt_cpf'],'name' =>$patient_data['pt_name'],'email' => $patient_data['pt_email'] ); | ||
| $create_charge['payer']['address'] = array('zip_code' => $patient_data['pt_zip_code'],'street'=>$patient_data['pt_street_add'],'number'=>$patient_data['pt_number'],'complement'=>$patient_data['pt_complement']); | ||
| //print_r($create_charge);die(); | ||
| $request = load_curl('https://api.iugu.com/v1/charge',$create_charge); | ||
| $charge =json_decode($request); | ||
| //print_r($charge); | ||
| //print_r($res); | ||
| //die(); | ||
| if(isset($charge->success) and isset($charge->LR) and ($charge->success==true) and ($charge->LR=='00')) | ||
| { | ||
| /*CODE FOR DOCTOR NOTIFICATION ON CONFIRMED CONSULTATION*/ | ||
| $booking_details = $this->Search_doctor_model->get_booking_details($_POST['booking_id']); | ||
| $patient_data = $this->Patient_model->get_single_patient($booking_details['patient_id']); | ||
| $doctor_data = $this->Doctor_model->get_single_doctor($booking_details['doctor_id']); | ||
| /*CODE FOR WALLET INSERTION*/ | ||
| /*------------------------------------------------*/ | ||
| $wallet = $this->Doctor_model->get_wallet_for_doctor($booking_details['doctor_id']); | ||
| if(empty($wallet)) | ||
| { | ||
| $wallet = array('reedem_earn' => 0,'future_earn' => 0 ,'total_earn' => 0 ); | ||
| } | ||
| $earn = $booking_details['total_sum'] - (($booking_details['total_sum'] * $booking_details['ipok_fee'])/100); | ||
| $wallet['future_earn'] = $wallet['future_earn'] + $earn; | ||
| $wallet['total_earn'] = $wallet['total_earn'] + $earn; | ||
| $this->Doctor_model->update_wallet($booking_details['doctor_id'],$wallet); | ||
| /*------------------------------------------------*/ | ||
| if($booking_details['booking_status'] == 0) | ||
| { | ||
| /*CODE FOR SENTING WAITING LIST NOTIFICATION FOR PAID VISIT - PATIENT NOTIFICATION*/ | ||
| /*------------------------------------------------*/ | ||
| $text_pat = 'Your appointment was scheduled in the system as waiting, on '.date('d.m.Y',$booking_details['time_start']).' at '.date('H:i a',$booking_details['time_start']).', doctor '.$doctor_data['dr_name']; | ||
| $notification_pat = array('patient_id' => $booking_details['patient_id'],'type'=>0,'message'=>$text_pat,'read_status'=>0,'time'=>strtotime($nowin_server),'booking_id' =>$_POST['booking_id']); | ||
| $patient_insert_id = $this->Home_model->insert_notification_patient($notification_pat); | ||
| $fcm_user = $this->Home_model->get_patient_fcm($booking_details['patient_id']); | ||
| //print_r($fcm_user); | ||
| if(!empty($fcm_user['fcm_token'])) | ||
| { | ||
| //print_r($fcm_user['fcm_token']);die(); | ||
| $pat_push_obj['id'] = $patient_insert_id; | ||
| $pat_push_obj['type'] = "Waiting List"; | ||
| $pat_push_obj['booking_id'] = $_POST['booking_id']; | ||
| $pat_push_obj['booking_date'] = $booking_details['date']; | ||
| $pat_push_obj['doctor_id'] = $booking_details['doctor_id']; | ||
| $pat_push_obj['doctor_name'] = $doctor_data['dr_name']; | ||
| $pat_push_obj['doctor_specialization'] = $doctor_data['dr_specialization']; | ||
| $pat_push_obj['message'] = $text_pat; | ||
| $pat_push_obj['time'] = strtotime($nowin_server); | ||
| $pat_push_obj['to'] = $fcm_user['fcm_token']; | ||
| $user_type = '1'; //patient push | ||
| $push_status = push_sent($pat_push_obj,$user_type); | ||
| } | ||
| /*------------------------------------------------*/ | ||
| } | ||
| else | ||
| { | ||
| /*CODE FOR SENTING NOTIFICATION - DOCTOR NOTIFICATION*/ | ||
| /*------------------------------------------------*/ | ||
| $text = 'A new appointment was scheduled in the system, on '.date('d.m.Y',$booking_details['time_start']).' at '.date('H:i a',$booking_details['time_start']).', patient '.$patient_data['pt_name']; | ||
| $notification = array('doctor_id' => $booking_details['doctor_id'],'type'=>2,'message'=>$text,'read_status'=>0,'time'=>strtotime($nowin_server) ); | ||
| $doctor_insert_id = $this->Home_model->insert_notification_doctor($notification); | ||
| $fcm_doctor = $this->Home_model->get_doctor_fcm($booking_details['doctor_id']); | ||
| if(!empty($fcm_doctor['fcm_token'])) | ||
| { | ||
| $doc_push_obj['id'] = $doctor_insert_id; | ||
| $doc_push_obj['type'] = "New Consultation"; | ||
| $doc_push_obj['message'] =$text; | ||
| $doc_push_obj['read_status'] = false; | ||
| $doc_push_obj['to'] = $fcm_doctor['fcm_token']; | ||
| $user_type = '2'; | ||
| $push_status = push_sent($doc_push_obj,$user_type); | ||
| } | ||
| /*------------------------------------------------*/ | ||
| /*CODE FOR SENTING NOTIFICATION - PATIENT NOTIFICATION*/ | ||
| /*------------------------------------------------*/ | ||
| $text_pat = 'Your appointment was scheduled in the system, on '.date('d.m.Y',$booking_details['time_start']).' at '.date('H:i a',$booking_details['time_start']).', doctor '.$doctor_data['dr_name']; | ||
| $notification_pat = array('patient_id' => $booking_details['patient_id'],'type'=>0,'message'=>$text_pat,'read_status'=>0,'time'=>strtotime($nowin_server),'booking_id' => $_POST['booking_id']); | ||
| $patient_insert_id = $this->Home_model->insert_notification_patient($notification_pat); | ||
| $fcm_user = $this->Home_model->get_patient_fcm($booking_details['patient_id']); | ||
| //print_r($fcm_user); | ||
| if(!empty($fcm_user['fcm_token'])) | ||
| { | ||
| //print_r($fcm_user['fcm_token']);die(); | ||
| $pat_push_obj['id'] = $patient_insert_id; | ||
| $pat_push_obj['type'] = "Consultation Confirmation"; | ||
| $pat_push_obj['booking_id'] = $_POST['booking_id']; | ||
| $pat_push_obj['booking_date'] = $booking_details['date']; | ||
| $pat_push_obj['doctor_id'] = $booking_details['doctor_id']; | ||
| $pat_push_obj['doctor_name'] = $doctor_data['dr_name']; | ||
| $pat_push_obj['doctor_specialization'] = $doctor_data['dr_specialization']; | ||
| $pat_push_obj['message'] = $text_pat; | ||
| $pat_push_obj['time'] = strtotime($nowin_server); | ||
| $pat_push_obj['to'] = $fcm_user['fcm_token']; | ||
| $user_type = '1'; //patient push | ||
| $push_status = push_sent($pat_push_obj,$user_type); | ||
| } | ||
| /*------------------------------------------------*/ | ||
| } | ||
| $result = $this->Search_doctor_model->set_payment_status($_POST['booking_id']); | ||
| $res = array('status' => 'success', 'payment_status'=>'1','message'=>'payment success','booking_date'=>date('d/m/Y',$check_markbooking['booking_date']),'booking_slot'=>$check_markbooking['booking_slot']); | ||
| $res = array('status' => 'success', 'payment_status'=>'1','message'=>'payment success','booking_date'=>date('d/m/Y',$check_markbooking['booking_date']),'booking_slot'=>$check_markbooking['booking_slot']); | ||
| } | ||
| else | ||
| { | ||
| $res = array('status' => 'fail', 'payment_status'=>'0','message'=>'nobooking/alreadypaid'); | ||
| $res = array('status' => 'fail', 'payment_status'=>'0','message'=>$charge->message); | ||
| } | ||
| } | ||
| //print_r($res);die(); | ||
| print json_encode($res); | ||
| } | ||
| /*FUNCTION : FETCH APPIONTMENTS IN DOCTOR PROFILE VIEW - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Fetching all next appointments*/ | ||
| public function doctor_complete_profile_appointments_week_next() | ||
| { | ||
| $day_appointments = array(); | ||
| for ($i=0; $i < 7; $i++) | ||
| { | ||
| $day = date('D',strtotime('+'.$i.'day', strtotime($_POST['enddate']))); | ||
| $dayno = date('d',strtotime('+'.$i.'day', strtotime($_POST['enddate']))); | ||
| $week_appointments[$i] = $this->Doctor_model->get_doctor_appointments_week($_POST['doctor_id'],date('y-m-d',strtotime('+'.$i.'day', strtotime($_POST['enddate'])))); | ||
| } | ||
| //print_r($week_appointments); | ||
| $template['week_appointments'] = $week_appointments; | ||
| $template['start_day'] = $_POST['enddate']; | ||
| $template['doctorid'] = $_POST['doctor_id']; | ||
| $this->load->view('search_doctor_complete_profile_appointments_week',$template); | ||
| } | ||
| /*FUNCTION : FETCH APPIONTMENTS IN DOCTOR PROFILE VIEW - DOCTOR SEARCH*/ | ||
| /*DESCRIPTION : Fetching all prev appointments*/ | ||
| public function doctor_complete_profile_appointments_week_prev() | ||
| { | ||
| $day_appointments = array(); | ||
| for ($i=6; $i >=0; $i--) | ||
| { /*date('y-m-d', strtotime('-7 days'))*/ | ||
| $day = date('D',strtotime('+'.$i.'day', strtotime($_POST['startdate']))); | ||
| $dayno = date('d',strtotime('+'.$i.'day', strtotime($_POST['startdate']))); | ||
| $week_appointments[$i] = $this->Doctor_model->get_doctor_appointments_week($_POST['doctor_id'],date('y-m-d',strtotime('-'.$i.'day', strtotime($_POST['startdate'],strtotime('-7 days'))))); | ||
| /*print_r(date('y-m-d',strtotime('-'.$i.'day', strtotime($_POST['startdate'])))); */ | ||
| } | ||
| //print_r($week_appointments);die(); | ||
| $template['week_appointments'] = $week_appointments; | ||
| $template['start_day'] = date('y-m-d',strtotime('-6day', strtotime($_POST['startdate']))); | ||
| //print_r($template);die(); | ||
| $template['doctorid'] = $_POST['doctor_id']; | ||
| $this->load->view('search_doctor_complete_profile_appointments_week',$template); | ||
| } | ||
| } | ||
Please
register
or
sign in
to comment