PageRenderTime 30ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 1ms

/firebaseclass.php

https://bitbucket.org/devpronitzz/healthcase
PHP | 2823 lines | 2224 code | 357 blank | 242 comment | 103 complexity | 48ac0966e9d8fc21f852cbcc5ad85f0d MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, BSD-3-Clause, Apache-2.0, MIT

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. $root = $_SERVER['DOCUMENT_ROOT'];
  3. /*
  4. include_once $root.'/services/connection/db.php';
  5. include_once $root.'/services/classes/publicClass/commanClass.php';
  6. include_once $root.'/services/classes/publicClass/responseClass.php';
  7. */
  8. //include_once 'connection/db.php';
  9. include_once 'publicClass/responseClass.php';
  10. require './firebase/vendor/autoload.php';
  11. use Kreait\Firebase\Factory;
  12. use Kreait\Firebase\ServiceAccount;
  13. error_reporting(E_ALL ^ E_DEPRECATED);
  14. //Create Connection Class
  15. class UserClass
  16. {
  17. var $conn;
  18. //constructor to eastablishment connection with database
  19. public function __construct()
  20. {
  21. $serviceAccount = ServiceAccount::fromJsonFile('./firebase/firebase_credentials.json');
  22. $firebase = (new Factory)
  23. ->withServiceAccount($serviceAccount)
  24. ->withDatabaseUri('https://projects-a6962.firebaseio.com')
  25. ->create();
  26. $this->conn = $firebase->getDatabase();
  27. }
  28. /*********Query start Following Block 1********/
  29. /*public function imageupload()
  30. {
  31. $image_name = $_FILES["fileUpload1"]["name"];
  32. $tmp_arr = explode(".",$image_name);
  33. $img_extn = end($tmp_arr);
  34. $new_image_name = 'image_'. uniqid() . date('YmdHis').'.'.$img_extn;
  35. $flag=0;
  36. if (file_exists("uploads/".$new_image_name))
  37. {
  38. return false;
  39. }
  40. else
  41. {
  42. move_uploaded_file($_FILES["fileUpload1"]["tmp_name"],"uploads/". $new_image_name);
  43. $flag = 1;
  44. $static_url = "http://bytesnmaterials.com/healthcare/uploads/".$new_image_name;
  45. return $static_url;
  46. }
  47. }*/
  48. //$imagePath = 'http://bytesnmaterials.com/healthcare/profile/profile.png';
  49. public function signup_doctor($doctorName,$address,$mobileNo,$emailID,$passwordD,$deviceID,$register_image,$latID,$logID,$file_url_name,$imagePath,$unionID1,$feeID,$specialID,$callstatus)
  50. {
  51. /*mysql_query("set character_set_server='utf8'");
  52. mysql_query("set names 'utf8'");
  53. */
  54. if(isset($_FILES['imageData']['name']))
  55. {
  56. if((($_FILES['imageData']['type'] == "image/jpeg")|| ($_FILES['imageData']['type'] == "image/gif")|| ($_FILES['imageData']['type'] == "image/jpg")|| ($_FILES['imageData']['type'] == "image/png")&& ($_FILES['imageData']['size'] < 1000000000000000))){
  57. if ($_FILES["imageData"]["error"] > 0) echo "Return Code: " . $_FILES["imageData"]["error"] . "<br />"; else {
  58. $Ex = end(explode(".",$_FILES['imageData']['name']));
  59. $array = explode(".",$_FILES['imageData']['name']);
  60. $file_url_name = $array[0].time().".".$Ex;
  61. move_uploaded_file($_FILES["imageData"]["tmp_name"], "uploads/col_certificate/".$file_url_name);
  62. }
  63. }
  64. }
  65. $file_url_name1 = "http://bytesnmaterials.com/healthcare/uploads/col_certificate/".$file_url_name;
  66. $register_image1 = "http://bytesnmaterials.com/healthcare/uploads/register_image/".$register_image;
  67. /*$sql = "INSERT INTO `doctor_signup` (`device_id`,`register_image`, `doctor_name`, `address`, `mobile_no`, `email_id`, `password`, `lat`, `log`,`col_certificate`, `union_id`, `status`, `type`, `profile_pic`, `specialization`,`payment_id`, `fee`, `chat_status`,`call_status`) VALUES ('$deviceID','$register_image1', '$doctorName', '$address', '$mobileNo', '$emailID', '$passwordD', '$latID', '$logID' ,'$file_url_name1', '$unionID1', '0', 'D','http://bytesnmaterials.com/healthcare/profile/profile.png','$specialID','0','$feeID','0','$callstatus')";
  68. $result=mysql_query($sql);
  69. return $result;*/
  70. $postData = [
  71. 'device_id' => $deviceID,
  72. 'register_image' => $register_image1,
  73. 'doctor_name' => $doctorName,
  74. 'address' => $address,
  75. 'mobile_no' => $mobileNo,
  76. 'email_id' => $emailID,
  77. 'password' => $passwordD,
  78. 'lat' => $latID,
  79. 'log' => $logID,
  80. 'col_certificate' =>$file_url_name1,
  81. 'union_id' => $unionID1,
  82. 'status' => '0',
  83. 'type' => 'D',
  84. 'profile_pic' => 'http://bytesnmaterials.com/healthcare/profile/profile.png',
  85. 'specialization' => $specialID,
  86. 'payment_id' => '0',
  87. 'fee' => $feeID,
  88. 'chat_status' => '0',
  89. 'call_status' => $callstatus,
  90. 'union_id' => '',
  91. 'doctor_id' => '',
  92. 'register_image' => ''
  93. ];
  94. $postRef = $this->conn->getReference('doctor_signup')->push($postData);
  95. return $postRef;
  96. }
  97. public function insert_notification_details($tokenID,$patientID,$doctorID,$name,$message,$caseD,$date,$type,$status)
  98. {
  99. mysql_query("set character_set_server='utf8'");
  100. mysql_query("set names 'utf8'");
  101. $sql = "INSERT INTO `push_notification`(`doctor_id`, `patient_id`, `name`, `message`, `token`, `case_description`,`date`, `type`, `status`) VALUES ('$doctorID', '$patientID','$name','$message','$tokenID','$caseD','$date','P','$status')";
  102. $result=mysql_query($sql);
  103. return $result;
  104. }
  105. public function insert_push_notification_details($tokenID,$patientID,$patientname,$getresult,$caseD,$date,$type,$status)
  106. {
  107. mysql_query("set character_set_server='utf8'");
  108. mysql_query("set names 'utf8'");
  109. //$sql = "INSERT INTO `push_notification`(`doctor_id`, `patient_id`, `name`, `message`, `token`, `case_description`,`date`, `type`, `status`) VALUES ('$getresult', '$patientID','$name','Request To Chat','$tokenID','$caseD','$date','$type','$status')";
  110. $sql = "INSERT INTO `chat_message`(`from_id`, `to_id`, `message`, `status`, `type`, `message_type`, `read_status`) VALUES ('$patientID','$getresult','$caseD','0','P','p_text','0')";
  111. //echo $sql;
  112. $result=mysql_query($sql);
  113. return $result;
  114. }
  115. public function insert_patient_notification($patientID,$doctorID,$message,$date,$status)
  116. {
  117. mysql_query("set character_set_server='utf8'");
  118. mysql_query("set names 'utf8'");
  119. $sql = "INSERT INTO `push_notification_details`(`patient_id`, `doctor_id`, `message`, `status`, `date`) VALUES ('$patientID','$doctorID','$message','$status','$date')";
  120. $result=mysql_query($sql);
  121. return $result;
  122. }
  123. public function update_pushnotification($id,$status)
  124. {
  125. mysql_query("set character_set_server='utf8'");
  126. mysql_query("set names 'utf8'");
  127. $sql = "UPDATE `push_notification` SET `status`='$status' WHERE `id`='$id'";
  128. $result=mysql_query($sql);
  129. return $result;
  130. }
  131. public function insert_patient_details($patientName,$emailID,$phoneNo,$address,$case_desc,$password,$age,$latitude,$logitude,$type,$tokenID)
  132. {
  133. /*mysql_query("set character_set_server='utf8'");
  134. mysql_query("set names 'utf8'");
  135. $sql = "INSERT INTO `patient` (`patient_name`, `email_id`, `mobile_no`, `address`,`case_desc`, `profile_pic`, `password`, `age`, `lat`, `log`, `type`, `token`, `took`,`status`,`call_status`) VALUES ('$patientName', '$emailID', '$phoneNo', '$address','$case_desc', 'http://bytesnmaterials.com/healthcare/profile/profile.png', '$password', '$age', '$latitude', '$logitude', '$type', '$tokenID','0','0','1')";
  136. $result=mysql_query($sql);
  137. return $result;*/
  138. $postData = [
  139. 'patient_name' => $patientName,
  140. 'email_id' => $emailID,
  141. 'mobile_no' => $phoneNo,
  142. 'address' => $address,
  143. 'case_desc' => $case_desc,
  144. 'profile_pic' => "http://bytesnmaterials.com/healthcare/profile/profile.png",
  145. 'password' => $password,
  146. 'age'=> $age,
  147. 'type' => $type,
  148. 'lat' => $latitude,
  149. 'log' => $logitude,
  150. 'token' => $tokenID,
  151. 'took' => '0',
  152. 'status' => '0',
  153. 'call_status' => '1'
  154. ];
  155. $postRef = $this->conn->getReference('patient')->push($postData);
  156. // print_r($postRef);
  157. // exit;
  158. return $postRef;
  159. }
  160. public function insert_pharmacy_details($pharmacyName,$emailID,$phoneNo,$address,$password,$age,$latitude,$logitude,$type,$tokenID,$hour_status,$working_hour)
  161. {
  162. if($is_24_hours_support == ""){
  163. $is_24_hours_support1 = "false";
  164. }else{
  165. $is_24_hours_support1 = $is_24_hours_support;
  166. }
  167. /*mysql_query("set character_set_server='utf8'");
  168. mysql_query("set names 'utf8'");
  169. $sql = "INSERT INTO `pharmacy`(`pharmacy_name`, `email_id`, `mobile_no`, `address`, `profile_pic`, `password`, `age`, `lat`, `log`, `type`, `token`, `call_status`, `hour_status`, `home_delivery`, `working_hour`, `injection_provider`, `status`) VALUES ('$pharmacyName', '$emailID', '$phoneNo', '$address', 'http://bytesnmaterials.com/healthcare/profile/profile.png', '$password', '$age', '$latitude', '$logitude', '$type', '$tokenID','1','$hour_status','0','$working_hour','0','0')";
  170. $result=mysql_query($sql);
  171. return $result;*/
  172. $postData = [
  173. 'pharmacy_name' => $pharmacyName,
  174. 'email_id' => $emailID,
  175. 'mobile_no' => $phoneNo,
  176. 'address' => $address,
  177. 'profile_pic' => "http://bytesnmaterials.com/healthcare/profile/profile.png",
  178. 'password' => $password,
  179. 'age'=> $age,
  180. 'type' => $type,
  181. 'lat' => $latitude,
  182. 'log' => $logitude,
  183. 'token' => $tokenID,
  184. 'status' => '0',
  185. 'call_status' => '1',
  186. 'hour_status' => $hour_status,
  187. 'home_delivery' => '0',
  188. 'working_hour' => $working_hour,
  189. 'injection_provider' => '0'
  190. ];
  191. $postRef = $this->conn->getReference('pharmacy')->push($postData);
  192. return $postRef;
  193. }
  194. public function check_patient_mobile_details($mobile,$email_id)
  195. {
  196. // mysql_query("set names 'utf8'");
  197. // $sql = "SELECT * FROM `patient` WHERE mobile_no = '".$mobile."'";
  198. // //echo $sql;
  199. // $result=mysql_query($sql);
  200. // return $result;
  201. $check_mobile = $this->conn->getReference('patient')
  202. ->orderByChild('mobile_no')
  203. ->equalTo($mobile);
  204. $snapshot_mobile = $check_mobile->getSnapshot();
  205. $k1 = $snapshot_mobile->getValue();
  206. $check_email = $this->conn->getReference('patient')
  207. ->orderByChild('email_id')
  208. ->equalTo($email_id);
  209. $snapshot_email = $check_email->getSnapshot();
  210. $k2 = $snapshot_email->getValue();
  211. if(!empty($k1) || !empty($k2)){
  212. $k = empty($k1)?$k2:$k1;
  213. }
  214. else{
  215. $k = [] ;
  216. }
  217. return $k;
  218. }
  219. public function insert_quick_registration($mobile_no,$emailId,$password,$latitude,$logitude,$tokenID)
  220. {
  221. // mysql_query("set character_set_server='utf8'");
  222. // mysql_query("set names 'utf8'");
  223. // $sql = "INSERT INTO `patient` (`mobile_no`, `password`, `type`, `lat`, `log`, `token`) VALUES ('$mobile_no', '$password', 'P', '$latitude', '$logitude','$tokenID')";
  224. // //echo $sql;
  225. // $result=mysql_query($sql);
  226. // return $result;
  227. $postData = [
  228. 'address' => "",
  229. 'age' => "",
  230. 'call_status' => "",
  231. 'case_desc' => "",
  232. 'patient_name' => "",
  233. 'profile_pic' => "",
  234. 'took' => "",
  235. 'email_id' => $emailId,
  236. 'age' => "",
  237. 'status' =>"",
  238. 'password' => $password,
  239. 'type' => 'P',
  240. 'lat' => $latitude,
  241. 'log' => $logitude,
  242. 'token' => $tokenID,
  243. 'patient_id' => "",
  244. 'mobile_no' => $mobile_no
  245. ];
  246. $postRef = $this->conn->getReference('patient')->push($postData);
  247. return $postRef;
  248. }
  249. public function get_doctor_details($doctorName,$emailID)
  250. {
  251. /*mysql_query("set character_set_server='utf8'");
  252. mysql_query("set names 'utf8'");
  253. $sql = "select * from doctor_signup where doctor_name = '$doctorName' and email_id = '$emailID'";
  254. $result=mysql_query($sql);
  255. return $result;*/
  256. $newPost = $this->conn->getReference('doctor_signup')
  257. ->orderByChild('email_id')
  258. ->equalTo($emailID);
  259. $snapshot_unionid = $newPost->getSnapshot();
  260. $refID = $snapshot_unionid->getValue();
  261. $getRefKey = array_keys($refID)[0];
  262. if(count($refID) == 1){
  263. $data_arr = array_values($refID);
  264. $data_arr[0]['doctor_id'] = $getRefKey;
  265. return $data_arr;
  266. }else{
  267. return [];
  268. }
  269. }
  270. public function get_patient_notification_id($patientID,$doctorID,$date,$tokenID)
  271. {
  272. mysql_query("set character_set_server='utf8'");
  273. mysql_query("set names 'utf8'");
  274. $sql = "select * from push_notification where doctor_id = '$doctorID' and patient_id = '$patientID' AND date = '$date' AND token = '$tokenID'";
  275. $result=mysql_query($sql);
  276. return $result;
  277. }
  278. public function update_patient_lat_log_api($doctorID,$lat,$log)
  279. {
  280. mysql_query("set character_set_server='utf8'");
  281. mysql_query("set names 'utf8'");
  282. $sql = "UPDATE doctor_signup SET lat = '$lat', log = '$log' WHERE doctor_id='$doctorID'";
  283. $result=mysql_query($sql);
  284. return $result;
  285. }
  286. public function get_detail_doctor($toID)
  287. {
  288. mysql_query("set character_set_server='utf8'");
  289. mysql_query("set names 'utf8'");
  290. $sql = "select * from doctor_signup where doctor_id = '$toID'";
  291. $result=mysql_query($sql);
  292. return $result;
  293. }
  294. public function check_union_id($unionID)
  295. {
  296. /*mysql_query("set character_set_server='utf8'");
  297. mysql_query("set names 'utf8'");
  298. $sql = "select * from doctor_signup where union_id = '$unionID'";
  299. $result=mysql_query($sql);
  300. return $result;*/
  301. $newPost = $this->conn->getReference('doctor_signup')
  302. ->orderByChild('union_id')
  303. ->equalTo($unionID);
  304. $snapshot_unionid = $newPost->getSnapshot();
  305. $refID = $snapshot_unionid->getValue();
  306. if(count($refID) == 1){
  307. return $refID;
  308. }else{
  309. return [];
  310. }
  311. }
  312. public function check_patient_notification($patientID,$doctorID,$status)
  313. {
  314. mysql_query("set character_set_server='utf8'");
  315. mysql_query("set names 'utf8'");
  316. $sql = "select * from push_notification_details where doctor_id = '$patientID' and patient_id = '$doctorID' and status = '$status'";
  317. $result=mysql_query($sql);
  318. return $result;
  319. }
  320. public function get_all_patient_details_app($doctorID)
  321. {
  322. mysql_query("set character_set_server='utf8'");
  323. mysql_query("set names 'utf8'");
  324. $sql = "SELECT p.* FROM `patient` as p,push_notification_details as ps WHERE ps.doctor_id = '$doctorID'";
  325. $result=mysql_query($sql);
  326. return $result;
  327. }
  328. public function get_patients_notification_details($patientID,$typeID)
  329. {
  330. mysql_query("set character_set_server='utf8'");
  331. mysql_query("set names 'utf8'");
  332. $sql = "SELECT p.*, pn.status,pn.date,pn.message,pn.id
  333. FROM push_notification AS pn, patient AS p
  334. WHERE pn.doctor_id = '$patientID'
  335. AND pn.type != '$typeID'
  336. AND pn.patient_id = p.patient_id ORDER BY pn.id DESC";
  337. $result=mysql_query($sql);
  338. return $result;
  339. }
  340. public function get_doctor_notification_details($patientID,$typeID)
  341. {
  342. mysql_query("set character_set_server='utf8'");
  343. mysql_query("set names 'utf8'");
  344. $sql = "SELECT pn.status,pn.date,pn.message,pn.id , d . *
  345. FROM `push_notification` AS pn, `doctor_signup` AS d
  346. WHERE pn.patient_id = '$patientID'
  347. AND pn.type != '$typeID'
  348. AND d.doctor_id = pn.doctor_id ORDER BY pn.id DESC";
  349. $result=mysql_query($sql);
  350. return $result;
  351. }
  352. /*-----------------------------------------NOTIFICATION---------------------------------------------------*/
  353. public function insert_token($tokenID)
  354. {
  355. mysql_query("set character_set_server='utf8'");
  356. mysql_query("set names 'utf8'");
  357. $sql = "INSERT INTO `push_notification`(`token`) VALUES ('$tokenID')";
  358. $result=mysql_query($sql);
  359. return $result;
  360. }
  361. public function gettokendetails($tokenID)
  362. {
  363. mysql_query("set character_set_server='utf8'");
  364. mysql_query("set names 'utf8'");
  365. $sql = "select * from push_notification where token = '$tokenID'";
  366. $result=mysql_query($sql);
  367. return $result;
  368. }
  369. public function get_patient_name($patientID)
  370. {
  371. mysql_query("set character_set_server='utf8'");
  372. mysql_query("set names 'utf8'");
  373. $sql = "select * from patient where patient_id = '$patientID'";
  374. $result=mysql_query($sql);
  375. return $result;
  376. }
  377. public function get_patient_name_det($patientID)
  378. {
  379. mysql_query("set character_set_server='utf8'");
  380. mysql_query("set names 'utf8'");
  381. $sql = "select patient_id as id,patient_name as name,profile_pic,type from patient where patient_id = '$patientID'";
  382. $result=mysql_query($sql);
  383. return $result;
  384. }
  385. /*--------------------------------------------------------------------------------------------------------*/
  386. public function update_doctor_profile_details($doctorID,$doctorName,$emailID,$address,$mobileNO,$file_url)
  387. {
  388. mysql_query("set character_set_server='utf8'");
  389. mysql_query("set names 'utf8'");
  390. $sql = "UPDATE `doctor_signup` SET `doctor_name`='$doctorName',`address`='$address',`mobile_no`='$mobileNO',email_id = '$emailID',`profile_pic`='$file_url' WHERE `doctor_id`='$doctorID'";
  391. $result=mysql_query($sql);
  392. return $result;
  393. }
  394. public function update_patient_profile_details($patientID,$patientName,$emailID,$mobileNO,$addressID,$file_url)
  395. {
  396. mysql_query("set character_set_server='utf8'");
  397. mysql_query("set names 'utf8'");
  398. $sql = "UPDATE `patient` SET `patient_name`='$patientName',`profile_pic`='$file_url',`email_id`='$emailID',`mobile_no`='$mobileNO',`address`='$addressID' WHERE patient_id = '$patientID'";
  399. $result=mysql_query($sql);
  400. return $result;
  401. }
  402. public function update_patient_profile($patientID,$patientName,$emailID,$mobileNO,$addressID,$array_full)
  403. {
  404. mysql_query("set character_set_server='utf8'");
  405. mysql_query("set names 'utf8'");
  406. $array_full1 = "http://bytesnmaterials.com/healthcare/profile/".$array_full;
  407. $sql = "UPDATE `patient` SET `patient_name`='$patientName',`email_id`='$emailID',`mobile_no`='$mobileNO',`address`='$addressID',`profile_pic`='$array_full1' WHERE patient_id = '$patientID'";
  408. $result=mysql_query($sql);
  409. return $result;
  410. }
  411. public function update_pharmacyd_profile($patientID,$patientName,$emailID,$mobileNO,$addressID,$array_full,$lat,$log)
  412. {
  413. if($is_24_hours_support == ""){
  414. $is_24_hours_support1 = "false";
  415. }else{
  416. $is_24_hours_support1 = $is_24_hours_support;
  417. }
  418. mysql_query("set character_set_server='utf8'");
  419. mysql_query("set names 'utf8'");
  420. $array_full1 = "http://bytesnmaterials.com/healthcare/profile/".$array_full;
  421. $sql = "UPDATE `pharmacy` SET `pharmacy_name`='$patientName',`email_id`='$emailID',`mobile_no`='$mobileNO',`address`='$addressID',`profile_pic`='$array_full1',`lat`='$lat',`log`='$log' WHERE pharmacy_id = '$patientID'";
  422. $result=mysql_query($sql);
  423. return $result;
  424. }
  425. public function update_phar_profile($patientID,$patientName,$emailID,$mobileNO,$addressID)
  426. {
  427. mysql_query("set character_set_server='utf8'");
  428. mysql_query("set names 'utf8'");
  429. $sql = "UPDATE `pharmacy` SET `pharmacy_name`='$patientName',`email_id`='$emailID',`mobile_no`='$mobileNO',`address`='$addressID' WHERE pharmacy_id = '$patientID'";
  430. $result=mysql_query($sql);
  431. return $result;
  432. }
  433. public function update_pharmacy_profile($pharmacyID,$pharmacyName,$emailID,$mobileNO,$addressID)
  434. {
  435. mysql_query("set character_set_server='utf8'");
  436. mysql_query("set names 'utf8'");
  437. $sql = "UPDATE `pharmacy` SET `pharmacy_name`='$pharmacyName',`email_id`='$emailID',`mobile_no`='$mobileNO',`address`='$addressID' WHERE pharmacy_id = '$pharmacyID'" or die(mysql_error());
  438. $result=mysql_query($sql);
  439. return $result;
  440. }
  441. public function update_doctor_profile($doctorID,$doctorName,$emailID,$feeID,$address,$mobileNO,$array_full)
  442. {
  443. mysql_query("set character_set_server='utf8'");
  444. mysql_query("set names 'utf8'");
  445. $array_full1 = "http://bytesnmaterials.com/healthcare/profile/".$array_full;
  446. $sql = "UPDATE `doctor_signup` SET `doctor_name`='$doctorName',`address`='$address',`mobile_no`='$mobileNO',`email_id`='$emailID',`profile_pic`='$array_full1',`fee`='$feeID' WHERE `doctor_id`='$doctorID'";
  447. $result=mysql_query($sql);
  448. return $result;
  449. }
  450. public function updatedoctortoken($emailID,$password,$token,$latitude,$logitude,$refID)
  451. {
  452. // mysql_query("set character_set_server='utf8'");
  453. // mysql_query("set names 'utf8'");
  454. // $sql = "UPDATE `doctor_signup` SET `device_id`='$token', lat = '$latitude', log = '$logitude', status = '1' WHERE (`email_id` = '$emailID' OR `mobile_no` = '$emailID') and password = '$password'";
  455. // $result=mysql_query($sql);
  456. // return $result;
  457. $newPost = $this->conn->getReference('doctor_signup')
  458. ->orderByChild('email_id')
  459. ->equalTo($emailID);
  460. $mobileCheck = $this->conn->getReference('doctor_signup')
  461. ->orderByChild('mobile_no')
  462. ->equalTo($emailID);
  463. $snapshot_email = $newPost->getSnapshot();
  464. $refID_email = $snapshot_email->getValue();
  465. $snapshot_mobile = $mobileCheck->getSnapshot();
  466. $refID_mobile = $snapshot_mobile->getValue();
  467. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  468. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  469. $refUpdateKey = empty($refID_email) ? array_keys($refID_mobile)[0] : array_keys($refID_email)[0];
  470. $resetArray = array_values($refIDKey);
  471. if($resetArray[0]['password'] == $password){
  472. if(isset($refUpdateKey)) {
  473. $updates = [
  474. //'doctor_signup/'.$newPostKey => $postData
  475. 'doctor_signup/'.$refUpdateKey.'/device_id' => $token,
  476. 'doctor_signup/'.$refUpdateKey.'/lat' => $latitude,
  477. 'doctor_signup/'.$refUpdateKey.'/log' => $logitude,
  478. 'doctor_signup/'.$refUpdateKey.'/status' => '1',
  479. ];
  480. $res = $this->conn->getReference() // this is the root reference
  481. ->update($updates);
  482. }
  483. else{
  484. die("update key not found");
  485. }
  486. }
  487. else{
  488. die("password validation failed");
  489. }
  490. }
  491. else{
  492. die("no match");
  493. }
  494. return true;
  495. }
  496. public function updatepatienttoken($emailID,$password,$token,$latitude,$logitude)
  497. {
  498. // mysql_query("set character_set_server='utf8'");
  499. // mysql_query("set names 'utf8'");
  500. // $sql = "UPDATE `patient` SET `token`='$token', lat = '$latitude', log = '$logitude', status = '1' WHERE (`email_id` = '$emailID' OR `mobile_no` = '$emailID') and `password` = '$password'";
  501. // $result=mysql_query($sql);
  502. // return $result;
  503. $newPost = $this->conn->getReference('patient')
  504. ->orderByChild('email_id')
  505. ->equalTo($emailID);
  506. $mobileCheck = $this->conn->getReference('patient')
  507. ->orderByChild('mobile_no')
  508. ->equalTo($emailID);
  509. $snapshot_email = $newPost->getSnapshot();
  510. $refID_email = $snapshot_email->getValue();
  511. $snapshot_mobile = $mobileCheck->getSnapshot();
  512. $refID_mobile = $snapshot_mobile->getValue();
  513. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  514. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  515. $refUpdateKey = empty($refID_email) ? array_keys($refID_mobile)[0] : array_keys($refID_email)[0];
  516. $resetArray = array_values($refIDKey);
  517. if($resetArray[0]['password'] == $password){
  518. if(isset($refUpdateKey)){
  519. $updates = [
  520. //'doctor_signup/'.$newPostKey => $postData
  521. 'patient/'.$refUpdateKey.'/token' => $token,
  522. 'patient/'.$refUpdateKey.'/lat' => $latitude,
  523. 'patient/'.$refUpdateKey.'/log' => $logitude,
  524. 'patient/'.$refUpdateKey.'/status' => '1'
  525. ];
  526. $res = $this->conn->getReference() // this is the root reference
  527. ->update($updates);
  528. }
  529. else{
  530. die("update key not found : updatepatienttoken ");
  531. }
  532. }
  533. else{
  534. die("password validation failed");
  535. }
  536. }
  537. else{
  538. die("no match");
  539. }
  540. return true;
  541. }
  542. public function updatepharmacytoken($emailID,$password,$token,$latitude,$logitude)
  543. {
  544. // mysql_query("set character_set_server='utf8'");
  545. // mysql_query("set names 'utf8'");
  546. // $sql = "UPDATE `pharmacy` SET `token`='$token', status = '1' WHERE (`email_id` = '$emailID' OR `mobile_no` = '$emailID') and `password` = '$password'";
  547. // $result=mysql_query($sql);
  548. // return $result;
  549. $newPost = $this->conn->getReference('pharmacy')
  550. ->orderByChild('email_id')
  551. ->equalTo($emailID);
  552. $mobileCheck = $this->conn->getReference('pharmacy')
  553. ->orderByChild('mobile_no')
  554. ->equalTo($emailID);
  555. $snapshot_email = $newPost->getSnapshot();
  556. $refID_email = $snapshot_email->getValue();
  557. $snapshot_mobile = $mobileCheck->getSnapshot();
  558. $refID_mobile = $snapshot_mobile->getValue();
  559. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  560. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  561. $refUpdateKey = empty($refID_email) ? array_keys($refID_mobile)[0] : array_keys($refID_email)[0];
  562. $resetArray = array_values($refIDKey);
  563. if($resetArray[0]['password'] == $password){
  564. if(isset($refUpdateKey)) {
  565. $updates = [
  566. //'doctor_signup/'.$newPostKey => $postData
  567. 'pharmacy/'.$refUpdateKey.'/token' => $token,
  568. 'pharmacy/'.$refUpdateKey.'/lat' => $latitude,
  569. 'pharmacy/'.$refUpdateKey.'/log' => $logitude,
  570. 'pharmacy/'.$refUpdateKey.'/status' => '1'
  571. ];
  572. $res = $this->conn->getReference() // this is the root reference
  573. ->update($updates);
  574. }
  575. else{
  576. die("update key not found");
  577. }
  578. }
  579. else{
  580. die("password validation failed");
  581. }
  582. }
  583. else{
  584. die("no match");
  585. }
  586. return true;
  587. }
  588. public function getalldoctordetails()
  589. {
  590. mysql_query("set character_set_server='utf8'");
  591. mysql_query("set names 'utf8'");
  592. $sql = "select * from doctor_signup";
  593. $result=mysql_query($sql);
  594. return $result;
  595. }
  596. public function get_patient_profile_details($patientID)
  597. {
  598. mysql_query("set character_set_server='utf8'");
  599. mysql_query("set names 'utf8'");
  600. $sql = "select * from patient where patient_id = '$patientID'";
  601. $result=mysql_query($sql);
  602. return $result;
  603. }
  604. public function get_pharmacy_profile_details($pharmacyID)
  605. {
  606. mysql_query("set character_set_server='utf8'");
  607. mysql_query("set names 'utf8'");
  608. $sql = "select * from pharmacy where pharmacy_id = '$pharmacyID'";
  609. $result=mysql_query($sql);
  610. return $result;
  611. }
  612. public function getalldoctor_details()
  613. {
  614. mysql_query("set character_set_server='utf8'");
  615. mysql_query("set names 'utf8'");
  616. $sql = "select device_id from doctor_signup";
  617. $result=mysql_query($sql);
  618. return $result;
  619. }
  620. public function checknotificationdetails($patientID,$doctorID)
  621. {
  622. mysql_query("set character_set_server='utf8'");
  623. mysql_query("set names 'utf8'");
  624. $sql = "select * from push_notification where patient_id = '$patientID' and doctor_id = '$doctorID'";
  625. $result=mysql_query($sql);
  626. return $result;
  627. }
  628. public function get_doctor_profile_details($doctorID)
  629. {
  630. mysql_query("set character_set_server='utf8'");
  631. mysql_query("set names 'utf8'");
  632. $sql = "select * from doctor_signup where doctor_id = '$doctorID'";
  633. $result=mysql_query($sql);
  634. //$result3 = mysql_fetch_array($sql);
  635. // $image_old = $result3['profile_pic'];
  636. return $result;
  637. }
  638. public function patientdetail($emailID,$phoneNo,$patientName)
  639. {
  640. //mysql_query("set character_set_server='utf8'");
  641. //mysql_query("set names 'utf8'");
  642. //$sql = "select patient_id,patient_name,email_id,mobile_no,address,case_description,age,lat,log,type,token from patient where patient_name = '$patientName' and email_id = '$emailID' and mobile_no = '$phoneNo'";
  643. //$sql = "select * from patient where patient_name = '$patientName' and email_id = '$emailID' and mobile_no = '$phoneNo'";
  644. //$result=mysql_query($sql);
  645. //return $result;
  646. $mobileCheck = $this->conn->getReference('patient')
  647. ->orderByChild('email_id')
  648. ->equalTo($emailID);
  649. $snapshot_mobile = $mobileCheck->getSnapshot();
  650. $refID_mobile = $snapshot_mobile->getValue();
  651. $data_arr = array_values($refID_mobile);
  652. if(count($refID_mobile)==1 ){
  653. if($data_arr[0]['mobile_no']==$phoneNo ){
  654. $extractKey = array_keys($refID_mobile)[0];
  655. $data_arr[0]['patient_id'] = $extractKey;
  656. return $data_arr;
  657. }else{
  658. return [];
  659. }
  660. }
  661. else{
  662. return [];
  663. }
  664. }
  665. public function get_pharmacy_detail($emailID,$phoneNo,$pharmacyName)
  666. {
  667. // mysql_query("set character_set_server='utf8'");
  668. // mysql_query("set names 'utf8'");
  669. // //$sql = "select patient_id,patient_name,email_id,mobile_no,address,case_description,age,lat,log,type,token from patient where patient_name = '$patientName' and email_id = '$emailID' and mobile_no = '$phoneNo'";
  670. // $sql = "select * from pharmacy where pharmacy_name = '$pharmacyName' and email_id = '$emailID' and mobile_no = '$phoneNo'";
  671. // $result=mysql_query($sql);
  672. // return $result;
  673. $mobileCheck = $this->conn->getReference('pharmacy')
  674. ->orderByChild('email_id')
  675. ->equalTo($emailID);
  676. $snapshot_mobile = $mobileCheck->getSnapshot();
  677. $refID_mobile = $snapshot_mobile->getValue();
  678. $data_arr = array_values($refID_mobile);
  679. if(count($refID_mobile)==1 ){
  680. if($data_arr[0]['mobile_no']==$phoneNo){
  681. $extractKey = array_keys($refID_mobile)[0];
  682. $data_arr[0]['pharmacy_id'] = $extractKey;
  683. return $data_arr;
  684. }
  685. else{
  686. return [];
  687. }
  688. }
  689. else{
  690. return [];
  691. }
  692. }
  693. public function getdoctordetaildetails($emailID,$password)
  694. {
  695. // mysql_query("set character_set_server='utf8'");
  696. // mysql_query("set names 'utf8'");
  697. // $sql = "select * from doctor_signup where (email_id = '$emailID' OR mobile_no = '$emailID') and password = '$password'";
  698. // $result=mysql_query($sql);
  699. // return $result;
  700. $newPost = $this->conn->getReference('doctor_signup')
  701. ->orderByChild('email_id')
  702. ->equalTo($emailID);
  703. $mobileCheck = $this->conn->getReference('doctor_signup')
  704. ->orderByChild('mobile_no')
  705. ->equalTo($emailID);
  706. $snapshot_email = $newPost->getSnapshot();
  707. $refID_email = $snapshot_email->getValue();
  708. $snapshot_mobile = $mobileCheck->getSnapshot();
  709. $refID_mobile = $snapshot_mobile->getValue();
  710. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  711. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  712. $refKeyU = array_keys($refIDKey)[0];
  713. $resetArray = array_values($refIDKey);
  714. if($resetArray[0]['password'] == $password){
  715. $resetArray[0]['doctor_id'] = $refKeyU;
  716. return $resetArray[0];
  717. }
  718. else{
  719. die("password validation failed : getdoctordetaildetails");
  720. }
  721. }
  722. else{
  723. die("no match: getdoctordetaildetails");
  724. }
  725. }
  726. public function getquickregistrationdetail($mobile_no,$password)
  727. {
  728. // mysql_query("set character_set_server='utf8'");
  729. // mysql_query("set names 'utf8'");
  730. // $sql = "select * from patient where mobile_no = '$mobile_no' and password = '$password'";
  731. // $result=mysql_query($sql);
  732. // return $result;
  733. $mobileCheck = $this->conn->getReference('patient')
  734. ->orderByChild('mobile_no')
  735. ->equalTo($mobile_no);
  736. $snapshot_mobile = $mobileCheck->getSnapshot();
  737. $refID_mobile = $snapshot_mobile->getValue();
  738. if(count($refID_mobile)==1 ){
  739. $refIDKey =$refID_mobile;
  740. $resetArray = array_values($refIDKey);
  741. if($resetArray[0]['password'] == $password){
  742. return $refIDKey;
  743. }
  744. else{
  745. die("password validation failed : getquickregistrationdetail");
  746. }
  747. }
  748. else{
  749. die("no match: getquickregistrationdetail");
  750. }
  751. }
  752. public function getpatient_details($emailID,$password)
  753. {
  754. // mysql_query("set character_set_server='utf8'");
  755. // mysql_query("set names 'utf8'");
  756. // $sql = "select * from patient where (email_id = '$emailID' OR mobile_no = '$emailID') and password = '$password'";
  757. // $result=mysql_query($sql);
  758. // return $result;
  759. $newPost = $this->conn->getReference('patient')
  760. ->orderByChild('email_id')
  761. ->equalTo($emailID);
  762. $mobileCheck = $this->conn->getReference('patient')
  763. ->orderByChild('mobile_no')
  764. ->equalTo($emailID);
  765. $snapshot_email = $newPost->getSnapshot();
  766. $refID_email = $snapshot_email->getValue();
  767. $snapshot_mobile = $mobileCheck->getSnapshot();
  768. $refID_mobile = $snapshot_mobile->getValue();
  769. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  770. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  771. $refKeyU = array_keys($refIDKey)[0];
  772. $resetArray = array_values($refIDKey);
  773. if($resetArray[0]['password'] == $password){
  774. $resetArray[0]['patient_id'] = $refKeyU;
  775. return $resetArray[0];
  776. }
  777. else{
  778. die("password validation failed : getpatient_details");
  779. }
  780. }
  781. else{
  782. die("no match: getpatient_details");
  783. }
  784. }
  785. public function getpharmacy_details($emailID,$password)
  786. {
  787. // mysql_query("set character_set_server='utf8'");
  788. // mysql_query("set names 'utf8'");
  789. // $sql = "select * from pharmacy where (email_id = '$emailID' OR mobile_no = '$emailID') and password = '$password'";
  790. // $result=mysql_query($sql);
  791. // return $result;
  792. $newPost = $this->conn->getReference('pharmacy')
  793. ->orderByChild('email_id')
  794. ->equalTo($emailID);
  795. $mobileCheck = $this->conn->getReference('pharmacy')
  796. ->orderByChild('mobile_no')
  797. ->equalTo($emailID);
  798. $snapshot_email = $newPost->getSnapshot();
  799. $refID_email = $snapshot_email->getValue();
  800. $snapshot_mobile = $mobileCheck->getSnapshot();
  801. $refID_mobile = $snapshot_mobile->getValue();
  802. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  803. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  804. $refKeyU = array_keys($refIDKey)[0];
  805. $resetArray = array_values($refIDKey);
  806. if($resetArray[0]['password'] == $password){
  807. $resetArray[0]['pharmacy_id'] = $refKeyU;
  808. return $resetArray[0];
  809. }
  810. else{
  811. die("password validation failed : getpharmacy_details");
  812. }
  813. }
  814. else{
  815. die("no match: getpharmacy_details");
  816. }
  817. }
  818. public function get_patient_details($doctorID)
  819. {
  820. mysql_query("set character_set_server='utf8'");
  821. mysql_query("set names 'utf8'");
  822. $sql = "select pa.*,p.*, pa.status as TookStatus from patient_took as pa,patient as p where pa.doctor_id = '$doctorID' and p.patient_id=pa.patient_id and pa.status != 0";
  823. $result=mysql_query($sql);
  824. return $result;
  825. }
  826. public function getMyHistory($doctorID)
  827. {
  828. mysql_query("set character_set_server='utf8'");
  829. mysql_query("set names 'utf8'");
  830. $sql = "select pa.*,p.*, pa.status as TookStatus from patient_took as pa,doctor_signup as p where pa.time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND pa.patient_id = '$doctorID' and p.doctor_id=pa.doctor_id";
  831. $result=mysql_query($sql);
  832. return $result;
  833. }
  834. public function getpatientdetailsa($patientID)
  835. {
  836. mysql_query("set character_set_server='utf8'");
  837. mysql_query("set names 'utf8'");
  838. $sql = "select * from patient where patient_id = '$patientID'";
  839. $result=mysql_query($sql);
  840. return $result;
  841. }
  842. public function check_login_details($email,$password,$type)
  843. {
  844. $newPost = $this->conn->getReference('healthcare_login')
  845. ->orderByChild('email_id')
  846. ->equalTo($email);
  847. $mobileCheck = $this->conn->getReference('healthcare_login')
  848. ->orderByChild('mobile_no')
  849. ->equalTo($email);
  850. $snapshot_email = $newPost->getSnapshot();
  851. $refID_email = $snapshot_email->getValue();
  852. $snapshot_mobile = $mobileCheck->getSnapshot();
  853. $refID_mobile = $snapshot_mobile->getValue();
  854. if(count($refID_email) > 0 || count($refID_mobile) > 0 ){
  855. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  856. $filteredItems = array_filter( $refIDKey, function($item) use($password,$type){
  857. return $item['password']==$password && $item['type']==$type;
  858. });
  859. if(!empty($filteredItems) && count($filteredItems)==1){
  860. //login true
  861. return $filteredItems;
  862. }
  863. else{
  864. return [];
  865. }
  866. }
  867. else{
  868. return [];
  869. }
  870. }
  871. public function checkemaildetails($email)
  872. {
  873. /*mysql_query("set character_set_server='utf8'");
  874. mysql_query("set names 'utf8'");
  875. $sql = "select * from healthcare_login where email_id = '$emailID'";
  876. $result=mysql_query($sql);
  877. return $result;*/
  878. $newPost = $this->conn->getReference('healthcare_login')
  879. ->orderByChild('email_id')
  880. ->equalTo($email);
  881. $snapshot_email = $newPost->getSnapshot();
  882. $refID_email = $snapshot_email->getValue();
  883. if(count($refID_email) == 1){
  884. return $refID_email;
  885. }
  886. else{
  887. return [];
  888. }
  889. }
  890. public function check_mobile_no_s($mobileNo)
  891. {
  892. /*mysql_query("set character_set_server='utf8'");
  893. mysql_query("set names 'utf8'");
  894. $sql = "select * from healthcare_login where mobile_no = '$mobileNo'";
  895. $result=mysql_query($sql);
  896. return $result;*/
  897. $mobileCheck = $this->conn->getReference('healthcare_login')
  898. ->orderByChild('mobile_no')
  899. ->equalTo($mobileNo);
  900. $snapshot_mobile = $mobileCheck->getSnapshot();
  901. $refID_mobile = $snapshot_mobile->getValue();
  902. if(count($refID_mobile) == 1){
  903. return $refID_mobile;
  904. }
  905. else{
  906. return [];
  907. }
  908. }
  909. public function insert_login($dID,$emailID,$mobileNo,$passwordD,$type)
  910. {
  911. /*mysql_query("set character_set_server='utf8'");
  912. mysql_query("set names 'utf8'");
  913. $sql = "INSERT INTO `healthcare_login`(`id`,`email_id`, `mobile_no`, `password`, `type`) VALUES
  914. ('$dID','$emailID','$mobileNo','$passwordD','D')";
  915. $result=mysql_query($sql);
  916. return $result;*/
  917. $postData = [
  918. 'id' => $dID,
  919. 'email_id' => $emailID,
  920. 'mobile_no' => $mobileNo,
  921. 'password' => $passwordD,
  922. 'type' => 'D'
  923. ];
  924. $postRef = $this->conn->getReference('healthcare_login')->push($postData);
  925. return $postRef;
  926. }
  927. public function quick_health_registration($mobileNo,$emailId,$password,$id)
  928. {
  929. // mysql_query("set character_set_server='utf8'");
  930. // mysql_query("set names 'utf8'");
  931. // $sql = "INSERT INTO `healthcare_login`(`mobile_no`, `password`, `type`) VALUES ('$mobileNo','$passwordD','P')";
  932. // $result=mysql_query($sql);
  933. // return $result;
  934. $postData = [
  935. 'password' => $password,
  936. 'type' => 'P',
  937. 'mobile_no' => $mobileNo,
  938. 'login_id' => "",
  939. 'id' => $id,
  940. 'email_id' => $emailId
  941. ];
  942. $postRef = $this->conn->getReference('healthcare_login')->push($postData);
  943. return $postRef;
  944. }
  945. public function insert_p_login($pID,$emailID,$mobile_no,$passwordD)
  946. {
  947. /*mysql_query("set character_set_server='utf8'");
  948. mysql_query("set names 'utf8'");
  949. $sql = "INSERT INTO `healthcare_login`(`id`,`email_id`,`mobile_no`, `password`, `type`) VALUES ('$pID','$emailID','$mobile_no','$passwordD','P')";
  950. $result=mysql_query($sql);
  951. return $result;*/
  952. $postData = [
  953. 'id' => $pID,
  954. 'email_id' => $emailID,
  955. 'mobile_no' => $mobile_no,
  956. 'password' => $passwordD,
  957. 'type' => 'p'
  958. ];
  959. $postRef = $this->conn->getReference('healthcare_login')->push($postData);
  960. return $postRef;
  961. }
  962. public function insert_pharmacy_login($p_ID,$emailID,$mobile_no,$passwordD)
  963. {
  964. /*mysql_query("set character_set_server='utf8'");
  965. mysql_query("set names 'utf8'");
  966. $sql = "INSERT INTO `healthcare_login`(`id`,`email_id`,`mobile_no`, `password`, `type`) VALUES ('$p_ID','$emailID','$mobile_no','$passwordD','F')";
  967. $result=mysql_query($sql);
  968. return $result;*/
  969. $postData = [
  970. 'id' => $p_ID,
  971. 'email_id' => $emailID,
  972. 'mobile_no' => $mobile_no,
  973. 'password' => $passwordD,
  974. 'type' => 'F'
  975. ];
  976. $postRef = $this->conn->getReference('healthcare_login')->push($postData);
  977. return $postRef;
  978. }
  979. public function update_status_detail($doctorID,$paymentID)
  980. {
  981. mysql_query("set character_set_server='utf8'");
  982. mysql_query("set names 'utf8'");
  983. $sql = "UPDATE `doctor_signup` SET `payment_id`= '$paymentID',`status`= 1 WHERE `doctor_id`='$doctorID'";
  984. $result=mysql_query($sql);
  985. return $result;
  986. }
  987. public function checkemailid($emailID)
  988. {
  989. /*mysql_query("set character_set_server='utf8'");
  990. mysql_query("set names 'utf8'");
  991. $sql = "select * from doctor_signup where email_id = '$emailID'";
  992. $result=mysql_query($sql);
  993. return $result;*/
  994. $newPost = $this->conn->getReference('doctor_signup')
  995. ->orderByChild('email_id')
  996. ->equalTo($emailID);
  997. $snapshot_emailID = $newPost->getSnapshot();
  998. $refID = $snapshot_emailID->getValue();
  999. if(count($refID) == 1){
  1000. return $refID;
  1001. }else{
  1002. return [];
  1003. }
  1004. }
  1005. public function check_patient_mobile_no($emailID,$phoneNo)
  1006. {
  1007. mysql_query("set character_set_server='utf8'");
  1008. mysql_query("set names 'utf8'");
  1009. $sql = "select * from patient where email_id = '$emailID' OR mobile_no = '$phoneNo'";
  1010. $result=mysql_query($sql);
  1011. return $result;
  1012. }
  1013. public function check_doctor_ID($doctorID)
  1014. {
  1015. mysql_query("set character_set_server='utf8'");
  1016. mysql_query("set names 'utf8'");
  1017. $sql = "select * from doctor_signup where doctor_id = '$doctorID'";
  1018. $result=mysql_query($sql);
  1019. return $result;
  1020. }
  1021. /*------------------------------------------Chat-------------------------------------------------*/
  1022. public function get_type_details($id)
  1023. {
  1024. mysql_query("set character_set_server='utf8'");
  1025. mysql_query("set names 'utf8'");
  1026. //$sql = "select * from push_notification_details where doctor_id = '$id' and status = '1'";
  1027. $sql = "select * from chat_message where from_id = '$id' OR to_id = '$id' and type = 'D' Group By to_id";
  1028. $result=mysql_query($sql);
  1029. return $result;
  1030. }
  1031. public function get_last_message_date($fromID,$toID,$type)
  1032. {
  1033. mysql_query("set character_set_server='utf8'");
  1034. mysql_query("set names 'utf8'");
  1035. $sql = "select * from chat_message where to_id = '$toID' and from_id = '$fromID' and type = '$type' ORDER BY chatmsg_id DESC LIMIT 1";
  1036. $result=mysql_query($sql);
  1037. return $result;
  1038. }
  1039. public function get_farmacy_last_message_date($fromID,$toid,$type)
  1040. {
  1041. mysql_query("set character_set_server='utf8'");
  1042. mysql_query("set names 'utf8'");
  1043. $sql = "select * from chat_message where to_id = '$toid' and from_id = '$fromID' and type = '$type' ORDER BY chatmsg_id DESC LIMIT 1";
  1044. $result=mysql_query($sql);
  1045. return $result;
  1046. }
  1047. public function get_farmacy_p_last_message_date($fromID,$toid,$type)
  1048. {
  1049. mysql_query("set character_set_server='utf8'");
  1050. mysql_query("set names 'utf8'");
  1051. $sql = "select * from chat_message where to_id = '$toid' and from_id = '$fromID' and type = '$type' ORDER BY chatmsg_id DESC LIMIT 1";
  1052. $result=mysql_query($sql);
  1053. return $result;
  1054. }
  1055. public function get_chat_patient_details($id,$type)
  1056. {
  1057. mysql_query("set character_set_server='utf8'");
  1058. mysql_query("set names 'utf8'");
  1059. $sql = "select from_id,to_id from chat_message where (from_id = '$id' AND type = 'D') OR (to_id = '$id' AND type = 'P') GROUP BY from_id";
  1060. $result=mysql_query($sql);
  1061. $PatToID = array();
  1062. $PatFromID = array();
  1063. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'D')";
  1064. $qryT=mysql_query($sqlT);
  1065. while($resultT=mysql_fetch_assoc($qryT)) {
  1066. $PatToID[] = $resultT['to_id'];
  1067. }
  1068. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'P')";
  1069. $qryF=mysql_query($sqlF);
  1070. while($resultF=mysql_fetch_assoc($qryF)) {
  1071. $PatFromID[] = $resultF['from_id'];
  1072. }
  1073. $array_merge_patients = array_merge($PatToID, $PatFromID);
  1074. $Newpatients = array_unique($array_merge_patients);
  1075. $all_chat_patients = array_values($Newpatients);
  1076. /*echo "<pre>";
  1077. print_r($all_chat_patients);
  1078. echo "</pre>";*/
  1079. return $all_chat_patients;
  1080. }
  1081. public function get_chat_pharmacy_details($id,$type)
  1082. {
  1083. mysql_query("set character_set_server='utf8'");
  1084. mysql_query("set names 'utf8'");
  1085. $sql = "select from_id,to_id from chat_message where to_id = '$id' AND (type = 'DF' OR type = 'FD') GROUP BY from_id";
  1086. $result=mysql_query($sql);
  1087. $PhRToID = array();
  1088. $PhRFromID = array();
  1089. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'DF')";
  1090. $qryT=mysql_query($sqlT);
  1091. while($resultT=mysql_fetch_assoc($qryT)) {
  1092. $PhRToID[] = $resultT['to_id'];
  1093. }
  1094. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'FD')";
  1095. $qryF=mysql_query($sqlF);
  1096. while($resultF=mysql_fetch_assoc($qryF)) {
  1097. $PhRFromID[] = $resultF['from_id'];
  1098. }
  1099. $array_merge_pharmcy = array_merge($PhRToID, $PhRFromID);
  1100. $Newpharmcy = array_unique($array_merge_pharmcy);
  1101. $all_chat_pharmcy = array_values($Newpharmcy);
  1102. return $all_chat_pharmcy;
  1103. //return $all_chat_pharmcy;
  1104. }
  1105. public function get_chat_pharmacy_patient_details($id,$type)
  1106. {
  1107. mysql_query("set character_set_server='utf8'");
  1108. mysql_query("set names 'utf8'");
  1109. /*$sql = "select from_id,to_id from chat_message where from_id = '$id' AND (type = 'FP' OR type = 'PF') GROUP BY to_id";
  1110. $result=mysql_query($sql);*/
  1111. $PhRToID = array();
  1112. $PhRFromID = array();
  1113. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'PF')";
  1114. $qryT=mysql_query($sqlT);
  1115. while($resultT=mysql_fetch_assoc($qryT)) {
  1116. $PhRToID[] = $resultT['to_id'];
  1117. }
  1118. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'FP')";
  1119. $qryF=mysql_query($sqlF);
  1120. while($resultF=mysql_fetch_assoc($qryF)) {
  1121. $PhRFromID[] = $resultF['from_id'];
  1122. }
  1123. $array_merge_pharmcy = array_merge($PhRToID, $PhRFromID);
  1124. $Newpharmcy = array_unique($array_merge_pharmcy);
  1125. $all_chat_pharmcy = array_values($Newpharmcy);
  1126. return $all_chat_pharmcy;
  1127. }
  1128. public function get_patient_id_chat($id,$type)
  1129. {
  1130. mysql_query("set character_set_server='utf8'");
  1131. mysql_query("set names 'utf8'");
  1132. /*$sql = "select from_id,to_id from chat_message where (from_id = '$id' AND type = 'FP') OR (to_id = '$id' AND type = 'PF') GROUP BY from_id";
  1133. $result=mysql_query($sql);*/
  1134. $PatToID = array();
  1135. $PatFromID = array();
  1136. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'FP')";
  1137. $qryT=mysql_query($sqlT);
  1138. while($resultT=mysql_fetch_assoc($qryT)) {
  1139. $PatToID[] = $resultT['to_id'];
  1140. }
  1141. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'PF')";
  1142. $qryF=mysql_query($sqlF);
  1143. while($resultF=mysql_fetch_assoc($qryF)) {
  1144. $PatFromID[] = $resultF['from_id'];
  1145. }
  1146. $array_merge_patients = array_merge($PatToID, $PatFromID);
  1147. $Newpatients = array_unique($array_merge_patients);
  1148. $all_chat_patients = array_values($Newpatients);
  1149. return $all_chat_patients;
  1150. }
  1151. public function get_doctor_id_chat($id,$type)
  1152. {
  1153. mysql_query("set character_set_server='utf8'");
  1154. mysql_query("set names 'utf8'");
  1155. /*$sql = "select from_id,to_id from chat_message where (from_id = '$id' AND type = 'FD') OR (to_id = '$id' AND type = 'DF') GROUP BY to_id";
  1156. $result=mysql_query($sql);*/
  1157. $DcoToID = array();
  1158. $DocFromID = array();
  1159. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'FD')";
  1160. $qryT=mysql_query($sqlT);
  1161. while($resultT=mysql_fetch_assoc($qryT)) {
  1162. $DcoToID[] = $resultT['to_id'];
  1163. }
  1164. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'DF')";
  1165. $qryF=mysql_query($sqlF);
  1166. while($resultF=mysql_fetch_assoc($qryF)) {
  1167. $DocFromID[] = $resultF['from_id'];
  1168. }
  1169. $array_merge_doctors = array_merge($DcoToID, $DocFromID);
  1170. $Newdoctors= array_unique($array_merge_doctors);
  1171. $all_chat_doctors = array_values($Newdoctors);
  1172. return $all_chat_doctors;
  1173. }
  1174. public function get_pharmacy_det_id()
  1175. {
  1176. mysql_query("set character_set_server='utf8'");
  1177. mysql_query("set names 'utf8'");
  1178. $sql = "select * from pharmacy";
  1179. $result=mysql_query($sql);
  1180. return $result;
  1181. }
  1182. public function get_chat_doctor_chatlist($id)
  1183. {
  1184. mysql_query("set character_set_server='utf8'");
  1185. mysql_query("set names 'utf8'");
  1186. $sql = "SELECT from_id,to_id
  1187. FROM `chat_message`
  1188. WHERE (from_id = '$id'
  1189. OR to_id = '$id') AND type='DD'
  1190. GROUP BY (
  1191. to_id
  1192. AND from_id
  1193. )";
  1194. $result=mysql_query($sql);
  1195. return $result;
  1196. }
  1197. public function get_chat_doctor_details($id,$type)
  1198. {
  1199. mysql_query("set character_set_server='utf8'");
  1200. mysql_query("set names 'utf8'");
  1201. /*$sql = "select * from chat_message where from_id = '$id' AND type = '$type' GROUP BY to_id";
  1202. $result=mysql_query($sql);*/
  1203. $DocToID = array();
  1204. $DocFromID = array();
  1205. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'P')";
  1206. $qryT=mysql_query($sqlT);
  1207. while($resultT=mysql_fetch_assoc($qryT)) {
  1208. $DocToID[] = $resultT['to_id'];
  1209. }
  1210. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'D')";
  1211. $qryF=mysql_query($sqlF);
  1212. while($resultF=mysql_fetch_assoc($qryF)) {
  1213. $DocFromID[] = $resultF['from_id'];
  1214. }
  1215. $array_merge_doctor = array_merge($DocToID, $DocFromID);
  1216. $Newdoctor = array_unique($array_merge_doctor);
  1217. $all_chat_doctor = array_values($Newdoctor);
  1218. return $all_chat_doctor;
  1219. }
  1220. public function get_doctor

Large files files are truncated, but you can click here to view the full file