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

/classes/firebaseclass.php

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

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