111 lines
3.5 KiB
PHP
Executable File
111 lines
3.5 KiB
PHP
Executable File
<?php
|
|
|
|
if (!defined('BASEPATH'))
|
|
exit('No direct script access allowed');
|
|
|
|
class Test_model extends CI_model {
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->load->database();
|
|
}
|
|
|
|
function name_by_code($code){
|
|
$this->db->like('stateCode', $code);
|
|
$query = $this->db->get('master_statelist');
|
|
return $query->row();
|
|
}
|
|
|
|
function inset_test_corn($data){
|
|
$this->db->insert('test', $data);
|
|
}
|
|
function deleteCaregiver($id)
|
|
{
|
|
$this->db->where('id',$id);
|
|
$users=$this->db->get('users')->row();
|
|
$user_id=$users->id;
|
|
if($user_id){
|
|
$this->db->where('id',$id);
|
|
$this->db->delete('users');
|
|
$row1=$this->db->affected_rows();
|
|
if($row1>0){$table1="users";$stat1="Successfully Deleted";}
|
|
else{$table1="users";$stat1="Didn't Detele";}
|
|
}
|
|
else{
|
|
$table1="users";
|
|
$stat1="Not Exist";
|
|
}
|
|
|
|
$this->db->where('ion_user_id',$id);
|
|
$cg=$this->db->get('caregiver')->row();
|
|
$cg_id=$cg->id;
|
|
if($cg_id){
|
|
$this->db->where('id',$cg_id);
|
|
$this->db->delete('caregiver');
|
|
$row2=$this->db->affected_rows();
|
|
if($row2>0){$table2="caregiver";$stat2="Successfully Deleted";}
|
|
else{$table2="caregiver";$stat2="Didn't Detele";}
|
|
|
|
$this->db->where('caregiver_table_id',$cg_id);
|
|
$this->db->delete('caregiver_step2');
|
|
$row3=$this->db->affected_rows();
|
|
if($row3>0){$table3="caregiver_step2";$stat3="Successfully Deleted";}
|
|
else{$table3="caregiver_step2";$stat3="Didn't Detele";}
|
|
|
|
$this->db->where('caregiver_table_id',$cg_id);
|
|
$this->db->delete('caregiver_step3');
|
|
$row4=$this->db->affected_rows();
|
|
if($row4>0){$table4="caregiver_step3";$stat4="Successfully Deleted";}
|
|
else{$table4="caregiver_step3";$stat4="Didn't Detele";}
|
|
|
|
|
|
}else{
|
|
$table2="caregiver";
|
|
$stat2="Not Exist";
|
|
$table3="caregiver_step2";
|
|
$stat3="Not Exist";
|
|
$table4="caregiver_step3";
|
|
$stat4="Not Exist";
|
|
}
|
|
|
|
$response=[
|
|
$table1.'_table'=>$stat1,
|
|
$table2.'_table'=>$stat2,
|
|
$table3.'_table'=>$stat3,
|
|
$table4.'_table'=>$stat4,
|
|
];
|
|
return $response;
|
|
|
|
|
|
}
|
|
function isAnyCgUser($id)
|
|
{
|
|
$this->db->where('ion_user_id',$id);
|
|
$cg=$this->db->get('caregiver')->row();
|
|
$cg_id=$cg->id;
|
|
$this->db->where('id',$id);
|
|
$userRows=$this->db->get('users')->num_rows();
|
|
$this->db->where('id',$cg_id);
|
|
$cgRows=$this->db->get('caregiver')->num_rows();
|
|
$this->db->where('caregiver_table_id',$cg_id);
|
|
$cg2Rows=$this->db->get('caregiver_step2')->num_rows();
|
|
$this->db->where('caregiver_table_id',$cg_id);
|
|
$cg3Rows=$this->db->get('caregiver_step3')->num_rows();
|
|
$data=[
|
|
'users_table'=>$userRows,
|
|
'caregiver_table'=>$cgRows,
|
|
'caregiver_step2_table'=>$cg2Rows,
|
|
'caregiver_step3_table'=>$cg3Rows,
|
|
];
|
|
return $data;
|
|
}
|
|
function getDummyPatientInfo($ids){
|
|
$this->db->select('p.id, p.patient_id, p.ion_user_id');
|
|
$this->db->from('patient_details p');
|
|
$this->db->where_in('patient_id', $ids);
|
|
$query=$this->db->get();
|
|
return $query->result();
|
|
}
|
|
|
|
}
|