Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- error_reporting(0);
- class Android_api extends CI_Controller {
- public function index()
- {
- $this->load->view('login');
- }
- public function login_check()
- {
- //echo "id is";
- $username=$_POST['user_name'];
- $password=$_POST['password'];
- $table='tbl_employee_master';
- $where=array('is_deleted'=>'N','employee_contact'=>$username,'employee_password'=>$password);
- $result = $this->Select_model->select_table_data($table,$where);
- //echo $result;
- if($result!=0)
- {
- echo json_encode($result);
- //echo "pass";
- }
- else if($result==0)
- {
- echo "fail";
- }
- }
- public function change_password()
- {
- $user_name=$_POST['user_name'];
- $otp=$_POST['otp'];
- $change_password=$_POST['change_password'];
- $confirm_password=$_POST['confirm_password'];
- $table='tbl_employee_master';
- $where=array('employee_contact'=>$user_name,'is_deleted'=>'N');
- $result=$this->Select_model->select_table_data($table,$where);
- //$data['res'] = $this->Master_model->select_register($table,$where);
- //echo $this->db->last_query();
- //print_r($result);
- foreach($result as $userdata)
- {
- $employee_email=$userdata->employee_email;
- $employee_id=$userdata->employee_id;
- $employee_contact=$userdata->employee_contact;
- $employee_password=$userdata->employee_password;
- }
- if($employee_password == $otp)//$password is from db and $otp is from form
- {
- //echo "inside if";
- if($change_password == $confirm_password)//$change_password and $confirm_password is from form
- {
- $result1 = $this->Select_model->update_password($table,$change_password,$employee_contact);
- //echo $this->db->last_query();
- //print_r($result1);
- if($result1=='Updatetrue')
- {
- echo "pass";
- }
- if($result1=='Updatefalse')
- {
- echo "fail";
- }
- }
- }
- else{
- echo "fail";
- }
- }
- public function forgotpassword()
- {
- $Username=$_POST['user_name'];
- if($Username=='')
- {
- }
- else{
- $mailresult=$this->Login_model->recovery_mail($Username);
- if($mailresult==1)
- {
- echo "Pass";
- }
- else
- {
- echo "fail";
- }
- }
- }
- public function patient_details()
- {
- $query = $this->db->query("SELECT * from tbl_patient_details where is_deleted='N' ");
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- public function appointment_details()
- {
- $query = $this->db->query
- ("SELECT appoint.*,patient.*,appoint.patient_id as patient_id from tbl_appointment_details as appoint, tbl_patient_details as patient
- where
- appoint.is_deleted='N' and patient.is_deleted='N' and
- appoint.appointment_date between '".date('Y-m-d')."' and '".date('Y-m-d')." 23:59:59' group by appoint.appointment_date");
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- public function doctor_appoint($doctor_id)
- {
- //$doctor_id='2';
- if($doctor_id!='')
- {
- $query = $this->db->query("SELECT app.*,appoint.*,patient.*,appoint.patient_id as patient_id from tbl_appointment_details as appoint join tbl_patient_details as patient on appoint.patient_id= patient.patient_id join appointment as app on app.patient_id= patient.patient_id where appoint.is_deleted='N' and patient.is_deleted='N' and app.is_deleted='N' and appoint.appointment_date between '".date('Y-m-d')."' and '".date('Y-m-d')." 23:59:59' and app.doctor_id='".$doctor_id."' group by appoint.appointment_date");
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- else
- {
- echo "fail";
- }
- }
- //appointment_detail_search
- public function patient_quick_search()
- {
- $appointment_search=$_POST['appointment_search'];
- if($appointment_search!='')
- {
- $query = $this->db->query("SELECT appoint.*,patient.*,appoint.patient_id as patient_id from tbl_appointment_details as appoint, tbl_patient_details as patient
- where
- appoint.patient_id like('".$appointment_search."%') or appoint.patient_name like('".$appointment_search."%') or appoint.referral_contact like('".$appointment_search."%')
- and appoint.is_deleted='N' and appoint.patient_id=patient.patient_id
- group by appoint.patient_id");
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- else
- {
- echo "fail";
- }
- }
- public function opd_details($id)
- {
- //$id=$_POST['patient_id']='5';
- if($id!='')
- {
- $query = $this->db->query("SELECT * from tbl_opd_details
- where patient_id ='".$id."' and is_deleted='N'");
- // echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- else
- {
- echo "fail";
- }
- }
- // 3 tables joins api
- public function instruction_details()
- {
- // $instruction_id=$_POST['instruction_id'];
- // echo "sdss";
- $query = $this->db->query("
- SELECT medicine.*,dosage.*,instruction.*,prescription.*
- from tbl_prescription_details as prescription join tbl_master_medicine as medicine on prescription.medicine_name=medicine.medicine_name
- join tbl_master_dosage as dosage on prescription.prescription_dosage=dosage.dosage
- join tbl_master_instructions as instruction on prescription.prescription_insructions=instruction.instructions
- where prescription.is_deleted='N'");
- $lab_test_query = $this->db->query("SELECT * from tbl_master_lab_test where is_deleted='N'");
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode(array("prescription details"=>$query->result(),"Lab test details"=>$lab_test_query->result()));
- }
- else
- {
- echo "fail";
- }
- }
- public function doctors_list()
- {
- $query = $this->db->query("SELECT * from tbl_employee_master where is_deleted='N' ");
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- public function doctors_slot($id)
- {
- $id=$_POST['id']="2";
- if($id!='')
- {
- $query = $this->db->query("SELECT * from tbl_doctor_schedule
- where doctor_id ='".$id."' and is_deleted='N'");
- $query2 = $this->db->query("SELECT * from appointment
- where doctor_id ='".$id."' and is_deleted='N'");
- // echo $this->db->last_query();
- //echo $id;
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode(array("doctor"=>$query->result(),"doctor_booked_slot"=>$query2->result()));
- //echo json_encode(array("doctor_booked_slot"=>$query2->result()));
- }
- else
- {
- echo "fail";
- }
- }
- else
- {
- echo "fail";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement