Commit 6134e3a8 by Jansa Jose

cpf availability

parent 3526bec9
......@@ -42,8 +42,10 @@ class Webservice extends CI_Controller {
$ress = $this->cpf_valid($data['cpf']);
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'){
$res = $this->registration_processing_user($data,$type);
}else{
$res = array(
......@@ -117,6 +119,7 @@ class Webservice extends CI_Controller {
if($result['status'] == 'success'){
$this->Webservice_model->insert_cpf($data['cpf'],$result['userdata']['id'],0);
$fileName = $result['userdata']['id'].'_'.$_FILES['profile_photo']['name'];
$config = set_upload_options('../assets/uploads/profilepic/patient/');
$config['file_name'] = $fileName;
......@@ -2068,14 +2071,14 @@ class Webservice extends CI_Controller {
// $data['dob'] = strtotime($dob);
$ress = $this->cpf_valid($data['dependent_cpf']);
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'){
$res = array(
"status"=> "error",
"error"=> "CPF Exist",
"message"=> "CPF Already Exist"
);
}else{
}else{*/
$auth_result = $this->Webservice_model->get_userid_frm_authtoken($headers['Auth']);
$fileName =$auth_result->userid.'_'.$_FILES['dependent_image']['name'];
$fileName = str_replace('%','a',$fileName);
......@@ -2116,7 +2119,7 @@ class Webservice extends CI_Controller {
'data' =>array('dependent_list'=>$new_data)
);
}
}
// }
}else{
$res = array(
"status"=> "error",
......@@ -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){
$ress = $this->cpf_valid($data['dependent_cpf']);
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'){
$res = array(
"status"=> "error",
"error"=> "CPF Exist",
"message"=> "CPF Already Exist"
);
}else{
}else{*/
$auth_result = $this->Webservice_model->get_userid_frm_authtoken($headers['Auth']);
$fileName = $auth_result->userid.'_'.$_FILES['dependent_image']['name'];
$config = set_upload_options('../assets/uploads/profilepic/patient_dependent/');
......@@ -2244,7 +2247,7 @@ class Webservice extends CI_Controller {
'data' =>array('dependent_list'=>$new_data)
);
}
}
// }
}else{
$res = array(
"status"=> "error",
......@@ -3400,6 +3403,8 @@ class Webservice extends CI_Controller {
$data['specialization'] = $data['specialization_id'];
$data['gender'] = strtoupper($data['gender']);
$ch = curl_init();
$area = $data['zip_code'];
$url = "https://maps.googleapis.com/maps/api/geocode/json?address=${area}&key=AIzaSyDMcP8sMKFPmLROvIf3g1U86_Vg5ur41nQ";
......@@ -3419,6 +3424,7 @@ class Webservice extends CI_Controller {
$result = $this->Webservice_model->registration($data,$type);
if($result['status'] == 'success'){
$this->Webservice_model->insert_cpf($data['cpf'],$result['userdata']['id'],1);
$fileName = $result['userdata']['id'].'_'.$_FILES['profile_photo']['name'];
$config = set_upload_options('../assets/uploads/profilepic/doctors/');
$config['file_name'] = $fileName;
......@@ -3526,7 +3532,35 @@ class Webservice extends CI_Controller {
$cpf = $_GET['cpf'];
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'){
$res = array(
"status"=> "success",
......
......@@ -1454,8 +1454,14 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender='
//............................ get clinic specialisation
function is_cpf_exist($cpf){
$res = $this->db->get_where('tbl_cpf_number',array('cpf'=>$cpf))->row();
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();
}
if($res){
$query = array('status'=>'error');
}else{
......@@ -1464,6 +1470,14 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender='
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(){
$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');
......
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