Commit 6134e3a8 by Jansa Jose

cpf availability

parent 3526bec9
...@@ -42,8 +42,10 @@ class Webservice extends CI_Controller { ...@@ -42,8 +42,10 @@ class Webservice extends CI_Controller {
$ress = $this->cpf_valid($data['cpf']); $ress = $this->cpf_valid($data['cpf']);
if((isset($ress)) && ($ress == 1)){ if((isset($ress)) && ($ress == 1)){
$is_cpf = $this->Webservice_model->is_cpf_exist($data['cpf']); $is_cpf = $this->Webservice_model->is_cpf_exist($data['cpf'],0);
if($is_cpf['status'] == 'success'){ if($is_cpf['status'] == 'success'){
$res = $this->registration_processing_user($data,$type); $res = $this->registration_processing_user($data,$type);
}else{ }else{
$res = array( $res = array(
...@@ -117,6 +119,7 @@ class Webservice extends CI_Controller { ...@@ -117,6 +119,7 @@ class Webservice extends CI_Controller {
if($result['status'] == 'success'){ if($result['status'] == 'success'){
$this->Webservice_model->insert_cpf($data['cpf'],$result['userdata']['id'],0);
$fileName = $result['userdata']['id'].'_'.$_FILES['profile_photo']['name']; $fileName = $result['userdata']['id'].'_'.$_FILES['profile_photo']['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;
...@@ -2068,14 +2071,14 @@ class Webservice extends CI_Controller { ...@@ -2068,14 +2071,14 @@ class Webservice extends CI_Controller {
// $data['dob'] = strtotime($dob); // $data['dob'] = strtotime($dob);
$ress = $this->cpf_valid($data['dependent_cpf']); $ress = $this->cpf_valid($data['dependent_cpf']);
if($ress == '1'){ if($ress == '1'){
$is_cpf = $this->Webservice_model->is_cpf_exist($data['dependent_cpf']); /*$is_cpf = $this->Webservice_model->is_cpf_exist($data['dependent_cpf']);
if($is_cpf['status'] == 'error'){ if($is_cpf['status'] == 'error'){
$res = array( $res = array(
"status"=> "error", "status"=> "error",
"error"=> "CPF Exist", "error"=> "CPF Exist",
"message"=> "CPF Already Exist" "message"=> "CPF Already Exist"
); );
}else{ }else{*/
$auth_result = $this->Webservice_model->get_userid_frm_authtoken($headers['Auth']); $auth_result = $this->Webservice_model->get_userid_frm_authtoken($headers['Auth']);
$fileName =$auth_result->userid.'_'.$_FILES['dependent_image']['name']; $fileName =$auth_result->userid.'_'.$_FILES['dependent_image']['name'];
$fileName = str_replace('%','a',$fileName); $fileName = str_replace('%','a',$fileName);
...@@ -2116,7 +2119,7 @@ class Webservice extends CI_Controller { ...@@ -2116,7 +2119,7 @@ class Webservice extends CI_Controller {
'data' =>array('dependent_list'=>$new_data) 'data' =>array('dependent_list'=>$new_data)
); );
} }
} // }
}else{ }else{
$res = array( $res = array(
"status"=> "error", "status"=> "error",
...@@ -2196,14 +2199,14 @@ class Webservice extends CI_Controller { ...@@ -2196,14 +2199,14 @@ class Webservice extends CI_Controller {
if((isset($data['dependent_name'])) && strlen(trim($data['dependent_name']," ")) > 0 && isset($data['dependent_relation']) && strlen(trim($data['dependent_relation']," ")) > 0 && isset($data['dependent_dob']) && strlen(trim($data['dependent_dob']," ")) > 0 && (isset($_FILES['dependent_image']) && isset($data['dependent_id']) && strlen(trim($data['dependent_id']," ")) > 0) && isset($data['dependent_cpf']) && strlen(trim($data['dependent_cpf']," ")) > 0){ if((isset($data['dependent_name'])) && strlen(trim($data['dependent_name']," ")) > 0 && isset($data['dependent_relation']) && strlen(trim($data['dependent_relation']," ")) > 0 && isset($data['dependent_dob']) && strlen(trim($data['dependent_dob']," ")) > 0 && (isset($_FILES['dependent_image']) && isset($data['dependent_id']) && strlen(trim($data['dependent_id']," ")) > 0) && isset($data['dependent_cpf']) && strlen(trim($data['dependent_cpf']," ")) > 0){
$ress = $this->cpf_valid($data['dependent_cpf']); $ress = $this->cpf_valid($data['dependent_cpf']);
if($ress == '1'){ if($ress == '1'){
$is_cpf = $this->Webservice_model->is_cpf_exist($data['dependent_cpf']); /*$is_cpf = $this->Webservice_model->is_cpf_exist($data['dependent_cpf']);
if($is_cpf['status'] == 'error'){ if($is_cpf['status'] == 'error'){
$res = array( $res = array(
"status"=> "error", "status"=> "error",
"error"=> "CPF Exist", "error"=> "CPF Exist",
"message"=> "CPF Already Exist" "message"=> "CPF Already Exist"
); );
}else{ }else{*/
$auth_result = $this->Webservice_model->get_userid_frm_authtoken($headers['Auth']); $auth_result = $this->Webservice_model->get_userid_frm_authtoken($headers['Auth']);
$fileName = $auth_result->userid.'_'.$_FILES['dependent_image']['name']; $fileName = $auth_result->userid.'_'.$_FILES['dependent_image']['name'];
$config = set_upload_options('../assets/uploads/profilepic/patient_dependent/'); $config = set_upload_options('../assets/uploads/profilepic/patient_dependent/');
...@@ -2244,7 +2247,7 @@ class Webservice extends CI_Controller { ...@@ -2244,7 +2247,7 @@ class Webservice extends CI_Controller {
'data' =>array('dependent_list'=>$new_data) 'data' =>array('dependent_list'=>$new_data)
); );
} }
} // }
}else{ }else{
$res = array( $res = array(
"status"=> "error", "status"=> "error",
...@@ -3400,6 +3403,8 @@ class Webservice extends CI_Controller { ...@@ -3400,6 +3403,8 @@ class Webservice extends CI_Controller {
$data['specialization'] = $data['specialization_id']; $data['specialization'] = $data['specialization_id'];
$data['gender'] = strtoupper($data['gender']); $data['gender'] = strtoupper($data['gender']);
$ch = curl_init(); $ch = curl_init();
$area = $data['zip_code']; $area = $data['zip_code'];
$url = "https://maps.googleapis.com/maps/api/geocode/json?address=${area}&key=AIzaSyDMcP8sMKFPmLROvIf3g1U86_Vg5ur41nQ"; $url = "https://maps.googleapis.com/maps/api/geocode/json?address=${area}&key=AIzaSyDMcP8sMKFPmLROvIf3g1U86_Vg5ur41nQ";
...@@ -3419,6 +3424,7 @@ class Webservice extends CI_Controller { ...@@ -3419,6 +3424,7 @@ class Webservice extends CI_Controller {
$result = $this->Webservice_model->registration($data,$type); $result = $this->Webservice_model->registration($data,$type);
if($result['status'] == 'success'){ if($result['status'] == 'success'){
$this->Webservice_model->insert_cpf($data['cpf'],$result['userdata']['id'],1);
$fileName = $result['userdata']['id'].'_'.$_FILES['profile_photo']['name']; $fileName = $result['userdata']['id'].'_'.$_FILES['profile_photo']['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;
...@@ -3526,7 +3532,35 @@ class Webservice extends CI_Controller { ...@@ -3526,7 +3532,35 @@ class Webservice extends CI_Controller {
$cpf = $_GET['cpf']; $cpf = $_GET['cpf'];
if(isset($cpf) && strlen(trim($cpf," ")) > 0 ){ if(isset($cpf) && strlen(trim($cpf," ")) > 0 ){
$is_cpf = $this->Webservice_model->is_cpf_exist($cpf); $is_cpf = $this->Webservice_model->is_cpf_exist($cpf,0);
if($ress['status'] == 'success'){
$res = array(
"status"=> "success",
"data"=>array("is_available"=>true)
);
}else{
$res = array(
"status"=> "success",
"data"=>array("is_available"=>false)
);
}
}else{
$res = array(
"status"=> "error",
"error"=> "required",
"message"=> "CPF is required"
);
}
print json_encode($res);
}
public function cpf_availability_doctor(){
header('Content-type: application/json');
$headers = apache_request_headers();
$cpf = $_GET['cpf'];
if(isset($cpf) && strlen(trim($cpf," ")) > 0 ){
$is_cpf = $this->Webservice_model->is_cpf_exist($cpf,1);
if($ress['status'] == 'success'){ if($ress['status'] == 'success'){
$res = array( $res = array(
"status"=> "success", "status"=> "success",
......
...@@ -1454,8 +1454,14 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender=' ...@@ -1454,8 +1454,14 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender='
//............................ get clinic specialisation //............................ get clinic specialisation
function is_cpf_exist($cpf){ function is_cpf_exist($cpf,$type=''){
if($type == 0){
$res = $this->db->get_where('tbl_cpf_number',array('cpf'=>$cpf,'user_type'=>0))->row();
}else if($type == 1){
$res = $this->db->get_where('tbl_cpf_number',array('cpf'=>$cpf,'user_type'=>1))->row();
}else{
$res = $this->db->get_where('tbl_cpf_number',array('cpf'=>$cpf))->row(); $res = $this->db->get_where('tbl_cpf_number',array('cpf'=>$cpf))->row();
}
if($res){ if($res){
$query = array('status'=>'error'); $query = array('status'=>'error');
}else{ }else{
...@@ -1464,6 +1470,14 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender=' ...@@ -1464,6 +1470,14 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender='
return $query; return $query;
} }
function insert_cpf($cpf,$id,$type){
if($this->db->insert('tbl_cpf_number',array('cpf'=>$cpf,'user_type'=>$type,'user_id'=>$id))){
return true;
}else{
return false;
}
}
function get_clinic_specialisation(){ function get_clinic_specialisation(){
$this->db->select("DISTINCT(tbl_specialization.specialization_name),tbl_clinic_specialization.clinic_id,tbl_specialization.id"); $this->db->select("DISTINCT(tbl_specialization.specialization_name),tbl_clinic_specialization.clinic_id,tbl_specialization.id");
$this->db->join('tbl_specialization','tbl_specialization.id = tbl_clinic_specialization.specialization_id'); $this->db->join('tbl_specialization','tbl_specialization.id = tbl_clinic_specialization.specialization_id');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment