Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.46 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. error_reporting(0);
  4. class Android_api extends CI_Controller {
  5.  
  6. public function index()
  7. {
  8. $this->load->view('login');
  9.  
  10. }
  11.  
  12. public function login_check()
  13. {
  14. //echo "id is";
  15. $username=$_POST['user_name'];
  16. $password=$_POST['password'];
  17. $table='tbl_employee_master';
  18. $where=array('is_deleted'=>'N','employee_contact'=>$username,'employee_password'=>$password);
  19.  
  20. $result = $this->Select_model->select_table_data($table,$where);
  21. //echo $result;
  22.  
  23. if($result!=0)
  24. {
  25. echo json_encode($result);
  26. //echo "pass";
  27. }
  28. else if($result==0)
  29. {
  30. echo "fail";
  31. }
  32. }
  33.  
  34.  
  35.  
  36.  
  37. public function change_password()
  38. {
  39.  
  40. $user_name=$_POST['user_name'];
  41. $otp=$_POST['otp'];
  42. $change_password=$_POST['change_password'];
  43. $confirm_password=$_POST['confirm_password'];
  44.  
  45. $table='tbl_employee_master';
  46. $where=array('employee_contact'=>$user_name,'is_deleted'=>'N');
  47. $result=$this->Select_model->select_table_data($table,$where);
  48. //$data['res'] = $this->Master_model->select_register($table,$where);
  49. //echo $this->db->last_query();
  50. //print_r($result);
  51.  
  52.  
  53. foreach($result as $userdata)
  54. {
  55. $employee_email=$userdata->employee_email;
  56. $employee_id=$userdata->employee_id;
  57. $employee_contact=$userdata->employee_contact;
  58. $employee_password=$userdata->employee_password;
  59.  
  60. }
  61.  
  62.  
  63. if($employee_password == $otp)//$password is from db and $otp is from form
  64. {
  65. //echo "inside if";
  66.  
  67. if($change_password == $confirm_password)//$change_password and $confirm_password is from form
  68. {
  69. $result1 = $this->Select_model->update_password($table,$change_password,$employee_contact);
  70. //echo $this->db->last_query();
  71.  
  72. //print_r($result1);
  73.  
  74. if($result1=='Updatetrue')
  75. {
  76. echo "pass";
  77. }
  78.  
  79. if($result1=='Updatefalse')
  80. {
  81. echo "fail";
  82. }
  83. }
  84.  
  85.  
  86.  
  87. }
  88. else{
  89. echo "fail";
  90. }
  91. }
  92.  
  93. public function forgotpassword()
  94. {
  95. $Username=$_POST['user_name'];
  96. if($Username=='')
  97. {
  98.  
  99. }
  100. else{
  101. $mailresult=$this->Login_model->recovery_mail($Username);
  102.  
  103. if($mailresult==1)
  104. {
  105. echo "Pass";
  106. }
  107. else
  108. {
  109. echo "fail";
  110. }
  111. }
  112. }
  113.  
  114.  
  115. public function patient_details()
  116. {
  117.  
  118. $query = $this->db->query("SELECT * from tbl_patient_details where is_deleted='N' ");
  119. if($query->num_rows()>0)
  120. {
  121. //echo "Pass";
  122. echo json_encode($query->result());
  123. }
  124. else
  125. {
  126. echo "fail";
  127. }
  128.  
  129. }
  130.  
  131. public function appointment_details()
  132. {
  133.  
  134. $query = $this->db->query
  135.  
  136. ("SELECT appoint.*,patient.*,appoint.patient_id as patient_id from tbl_appointment_details as appoint, tbl_patient_details as patient
  137.  
  138. where
  139.  
  140. appoint.is_deleted='N' and patient.is_deleted='N' and
  141.  
  142. appoint.appointment_date between '".date('Y-m-d')."' and '".date('Y-m-d')." 23:59:59' group by appoint.appointment_date");
  143.  
  144. //echo $this->db->last_query();
  145.  
  146. if($query->num_rows()>0)
  147. {
  148. //echo "Pass";
  149. echo json_encode($query->result());
  150. }
  151. else
  152. {
  153. echo "fail";
  154. }
  155.  
  156. }
  157.  
  158.  
  159. public function doctor_appoint($doctor_id)
  160. {
  161. //$doctor_id='2';
  162. if($doctor_id!='')
  163. {
  164. $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");
  165.  
  166. //echo $this->db->last_query();
  167.  
  168. if($query->num_rows()>0)
  169. {
  170. //echo "Pass";
  171. echo json_encode($query->result());
  172. }
  173. else
  174. {
  175. echo "fail";
  176. }
  177. }
  178. else
  179. {
  180. echo "fail";
  181. }
  182. }
  183.  
  184.  
  185. //appointment_detail_search
  186.  
  187. public function patient_quick_search()
  188. {
  189.  
  190. $appointment_search=$_POST['appointment_search'];
  191.  
  192. if($appointment_search!='')
  193. {
  194.  
  195. $query = $this->db->query("SELECT appoint.*,patient.*,appoint.patient_id as patient_id from tbl_appointment_details as appoint, tbl_patient_details as patient
  196.  
  197. where
  198.  
  199. appoint.patient_id like('".$appointment_search."%') or appoint.patient_name like('".$appointment_search."%') or appoint.referral_contact like('".$appointment_search."%')
  200.  
  201. and appoint.is_deleted='N' and appoint.patient_id=patient.patient_id
  202.  
  203. group by appoint.patient_id");
  204.  
  205. //echo $this->db->last_query();
  206.  
  207. if($query->num_rows()>0)
  208. {
  209. //echo "Pass";
  210. echo json_encode($query->result());
  211. }
  212. else
  213. {
  214. echo "fail";
  215. }
  216. }
  217. else
  218. {
  219. echo "fail";
  220. }
  221.  
  222. }
  223.  
  224.  
  225. public function opd_details($id)
  226. {
  227. //$id=$_POST['patient_id']='5';
  228. if($id!='')
  229. {
  230. $query = $this->db->query("SELECT * from tbl_opd_details
  231. where patient_id ='".$id."' and is_deleted='N'");
  232.  
  233. // echo $this->db->last_query();
  234.  
  235. if($query->num_rows()>0)
  236. {
  237. //echo "Pass";
  238. echo json_encode($query->result());
  239. }
  240. else
  241. {
  242. echo "fail";
  243. }
  244. }
  245.  
  246. else
  247. {
  248. echo "fail";
  249. }
  250.  
  251. }
  252.  
  253. // 3 tables joins api
  254.  
  255. public function instruction_details()
  256. {
  257.  
  258. // $instruction_id=$_POST['instruction_id'];
  259.  
  260. // echo "sdss";
  261.  
  262. $query = $this->db->query("
  263.  
  264. SELECT medicine.*,dosage.*,instruction.*,prescription.*
  265. from tbl_prescription_details as prescription join tbl_master_medicine as medicine on prescription.medicine_name=medicine.medicine_name
  266. join tbl_master_dosage as dosage on prescription.prescription_dosage=dosage.dosage
  267. join tbl_master_instructions as instruction on prescription.prescription_insructions=instruction.instructions
  268. where prescription.is_deleted='N'");
  269.  
  270. $lab_test_query = $this->db->query("SELECT * from tbl_master_lab_test where is_deleted='N'");
  271.  
  272. //echo $this->db->last_query();
  273.  
  274. if($query->num_rows()>0)
  275. {
  276. //echo "Pass";
  277. echo json_encode(array("prescription details"=>$query->result(),"Lab test details"=>$lab_test_query->result()));
  278. }
  279. else
  280. {
  281. echo "fail";
  282. }
  283.  
  284. }
  285.  
  286.  
  287.  
  288.  
  289.  
  290. public function doctors_list()
  291. {
  292. $query = $this->db->query("SELECT * from tbl_employee_master where is_deleted='N' ");
  293.  
  294. //echo $this->db->last_query();
  295.  
  296. if($query->num_rows()>0)
  297. {
  298. //echo "Pass";
  299. echo json_encode($query->result());
  300. }
  301. else
  302. {
  303. echo "fail";
  304. }
  305.  
  306. }
  307.  
  308.  
  309.  
  310. public function doctors_slot($id)
  311. {
  312. $id=$_POST['id']="2";
  313. if($id!='')
  314. {
  315.  
  316. $query = $this->db->query("SELECT * from tbl_doctor_schedule
  317. where doctor_id ='".$id."' and is_deleted='N'");
  318.  
  319. $query2 = $this->db->query("SELECT * from appointment
  320. where doctor_id ='".$id."' and is_deleted='N'");
  321.  
  322. // echo $this->db->last_query();
  323. //echo $id;
  324.  
  325. if($query->num_rows()>0)
  326. {
  327. //echo "Pass";
  328. echo json_encode(array("doctor"=>$query->result(),"doctor_booked_slot"=>$query2->result()));
  329.  
  330. //echo json_encode(array("doctor_booked_slot"=>$query2->result()));
  331.  
  332.  
  333. }
  334. else
  335. {
  336. echo "fail";
  337. }
  338. }
  339.  
  340. else
  341. {
  342. echo "fail";
  343. }
  344.  
  345. }
  346.  
  347.  
  348.  
  349.  
  350. }
  351.  
  352.  
  353.  
  354. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement