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