Advertisement
Guest User

Untitled

a guest
Jun 7th, 2023
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.41 KB | None | 0 0
  1. <?php
  2. //session_start();
  3.  
  4. class Core {
  5. /* */
  6.  
  7. private static $config_file = "conf.ini";
  8.  
  9. /* */
  10. //var $db_conf;
  11.  
  12. private static $link = null;
  13.  
  14. /**
  15. *
  16. * @param type $file
  17. */
  18. public static function getDBConfig() {
  19. $conf = parse_ini_file(Core::$config_file);
  20. return $conf;
  21. //die(var_dump($conf) );
  22. //exit;
  23. //$db_conf = array();
  24. //$this->db_conf = $conf;
  25. }
  26.  
  27. public static function connectDB() {
  28. $conf = Core::getDBConfig();
  29. //$link = mysql_connect($conf["host"], $conf["user"], $conf["password"]) or die("Could not connect: " . mysql_error());
  30. /*$link = mysql_connect (MYSQL_HOST,
  31. MYSQL_BENUTZER,
  32. MYSQL_KENNWORT,
  33. MYSQL_DATENBANK);*/
  34. //Core::$link = new mysqli(MYSQL_HOST, MYSQL_BENUTZER, MYSQL_KENNWORT, MYSQL_DATENBANK);
  35. Core::$link = new mysqli($conf["host"], $conf["user"], $conf["password"], $conf["name"]);
  36. //mysql_set_charset('utf8', $link);
  37. /* check connection */
  38. if (mysqli_connect_errno()) {
  39. printf("Connect failed: %s\n", mysqli_connect_error());
  40. exit();
  41. }
  42. if (!Core::$link->set_charset("utf8")) {
  43. printf("Error loading character set utf8: %s\n", Core::$link->error);
  44. } else {
  45. //printf("Current character set: %s\n", Core::$link->character_set_name());
  46. }
  47.  
  48. // select our database
  49.  
  50. // select our database
  51. //mysql_select_db(MYSQL_DATENBANK) or die(mysql_error());
  52. Core::$link->select_db($conf["name"]);
  53. }
  54.  
  55. public static function closeDB() {
  56. //mysql_close();
  57. Core::$link->close();
  58. }
  59.  
  60. /**
  61. * Adds a patient into db-table 'patients'.
  62. * @param array $patient [surname, prename, birthday, telephone, description]
  63. */
  64. public static function addStaff(array $staff) {
  65. $sql = "INSERT INTO staff (surname, prename, birthday, telephone, description_text) " .
  66. " VALUES ('" . $staff['surname'] . "', '" . $staff['prename'] . "', '" . $staff['birthday'] . "', '" . $staff['telephone'] . "', '" . $staff['description_text'] . "')";
  67. //echo $sql;
  68. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  69. $result = Core::$link->query($sql);
  70.  
  71. if (!$result) {
  72. return 'Error: ' . mysqli_error(Core::$link);
  73. }
  74. //while ($myrow = mysql_fetch_array($result)) {
  75. //}
  76. //mysql_free_result($result);
  77. //$result->close();
  78. return true;
  79. }
  80.  
  81. /**
  82. * Adds a patient into db-table 'patients'.
  83. * @param array $patient [surname, prename, birthday, telephone, description]
  84. */
  85. public static function addPatient(array $patient) {
  86. $sql = "INSERT INTO patients (surname, prename, birthday, telephone, description_text, town, zipcode, street) " .
  87. " VALUES ('" . $patient['surname'] . "', '" . $patient['prename'] . "', '" . $patient['birthday'] . "', '" . $patient['telephone'] . "', '" . $patient['description_text'] . "', '" . $patient['town'] . "', '" . $patient['zipcode'] . "' ,'" . $patient['street'] . "')";
  88. //echo $sql;
  89. //r$esult = mysql_query($sql) or die("Invalid query: " . mysql_error());
  90. $result = Core::$link->query($sql);
  91.  
  92. if (!$result) {
  93. return 'Error: ' . mysqli_error(Core::$link);
  94. }
  95. //while ($myrow = mysql_fetch_array($result)) {
  96. //}
  97. //mysql_free_result($result);
  98. //$result->close();
  99. return true;
  100. }
  101.  
  102. /**
  103. * Deletes a patient from database.
  104. * Caution: No valid-checking.
  105. *
  106. * @param type $id_patient
  107. */
  108. public static function removePatient($id_patient) {
  109. $sql = "DELETE FROM patients WHERE id_patient=" . $id_patient;
  110. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  111. $result = Core::$link->query($sql);
  112.  
  113. if (!$result) {
  114. return 'Error: ' . mysqli_error(Core::$link);
  115. }
  116. //mysql_free_result($result);
  117. //$result->close();
  118. return true;
  119. }
  120.  
  121. /**
  122. * Deletes a staff from database.
  123. * Caution: No valid-checking.
  124. *
  125. * @param type $id_patient
  126. */
  127. public static function removeStaff($id_staff) {
  128. $sql = "DELETE FROM staff WHERE id_staff = " . intval($id_staff). ";";
  129. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  130. $result = Core::$link->query($sql);
  131.  
  132. if (!$result) {
  133. return 'Error: ' . mysqli_error(Core::$link);
  134. }
  135. //mysql_free_result($result);
  136. //$result->close();
  137. //echo "staff: ".$id_staff;
  138. return true;
  139. }
  140.  
  141.  
  142. public static function removeStaffWorkingTime($id_staff_workingtime) {
  143. $sql = "DELETE FROM staff_workingtimes WHERE id_staff_workingtime=" . $id_staff_workingtime;
  144. //echo $sql;
  145. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  146. $result = Core::$link->query($sql);
  147.  
  148. if (!$result) {
  149. return 'Error: ' . mysqli_error(Core::$link);
  150. }
  151. //mysql_free_result($result);
  152. //$result->close();
  153. //echo "staff: ".$id_staff;
  154. return true;
  155. }
  156.  
  157. /**
  158. * Updates a patient from database.
  159. * Caution: No valid-checking.
  160. *
  161. * @param array $patient
  162. */
  163. public static function updatePatient(array $patient) {
  164. $update_fields = "";
  165. //if(isset($patient['surname']) && $pat
  166.  
  167. $sql = "UPDATE patients SET " .
  168. "surname='" . $patient['surname'] . "', " .
  169. "prename='" . $patient['prename'] . "', " .
  170. "birthday='" . $patient['birthday'] . "', " .
  171. "telephone='" . $patient['telephone'] . "', " .
  172. "description_text='" . $patient['description_text'] . "', " .
  173. "town='" . $patient['town'] . "', " .
  174. "zipcode='" . $patient['zipcode'] . "', " .
  175. "street='" . $patient['street'] . "' " .
  176. "WHERE id_patient=" . $patient['id_patient'];
  177. //echo $sql;
  178. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  179. $result = Core::$link->query($sql);
  180.  
  181. if (!$result) {
  182. return 'Error: ' . mysqli_error(Core::$link);
  183. }
  184. //mysql_free_result($result);
  185. return true;
  186. }
  187.  
  188.  
  189. /**
  190. * Updates a staff from database.
  191. * Caution: No valid-checking.
  192. *
  193. * @param array $patient
  194. */
  195. public static function updateStaff(array $staff) {
  196. $update_fields = "";
  197. //if(isset($patient['surname']) && $pat
  198.  
  199. $sql = "UPDATE staff SET " .
  200. "surname='" . $staff['surname'] . "', " .
  201. "prename='" . $staff['prename'] . "', " .
  202. "birthday='" . $staff['birthday'] . "', " .
  203. "telephone='" . $staff['telephone'] . "', " .
  204. "description_text='" . $staff['description_text'] . "', " .
  205. "is_present='".$staff['active']. "' ".
  206. "WHERE id_staff=" . $staff['id_staff'];
  207. //echo $sql;
  208. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  209. $result = Core::$link->query($sql);
  210.  
  211. if (!$result) {
  212. return 'Error: ' . mysqli_error(Core::$link);
  213. }
  214. //mysql_free_result($result);
  215. return true;
  216. }
  217.  
  218. public static function updateStaffActiveCheck($id_staff, $checked){
  219.  
  220. $sql = "UPDATE staff SET ".
  221. "is_present='".$checked."' ".
  222. "WHERE id_staff=".$id_staff;
  223. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  224. $result = Core::$link->query($sql);
  225.  
  226. if (!$result) {
  227. return 'Error: ' . mysqli_error(Core::$link);
  228. }
  229. //mysql_free_result($result);
  230. return true;
  231. }
  232.  
  233. public static function updatePatientTreatmentCheck($id_patient_treatment, $checked){
  234. $sql = "UPDATE patients_treatments SET ".
  235. "is_present='".$checked."' ".
  236. "WHERE id_patient_treatment=".$id_patient_treatment;
  237. //echo $sql;
  238. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  239. $result = Core::$link->query($sql);
  240.  
  241. if (!$result) {
  242. return 'Error: ' . mysqli_error(Core::$link);
  243. }
  244. //mysql_free_result($result);
  245. return true;
  246. }
  247.  
  248. public static function getStaffList($session){
  249.  
  250. if ($session['name'] =="admin" || $session['name'] =="Piet") {
  251. $sql = "SELECT * FROM staff";
  252. }
  253. else {
  254. $sql = "SELECT * FROM staff where surname = '".$session['name']."'";
  255. }
  256.  
  257. $result = Core::$link->query($sql);
  258.  
  259. if (!$result) {
  260. return 'Error: ' . mysqli_error(Core::$link);
  261. }
  262.  
  263. $return = array();
  264. while ($myrow = mysqli_fetch_assoc($result)) {
  265. if ($myrow['birthday'] !== '0000-00-00') {
  266. $myrow['birthday'] = date("d.m.Y", strtotime($myrow['birthday']));
  267. } else {
  268. $myrow['birthday'] = '';
  269. }
  270. $return[] = $myrow;
  271. }
  272.  
  273. return $return;
  274. }
  275.  
  276. public static function getStaff($id_staff) {
  277. $sql = "SELECT * FROM staff WHERE id_staff=" . $id_staff;
  278. //$result = mysql_query($sql);
  279. $result = Core::$link->query($sql);
  280.  
  281. if (!$result) {
  282. return 'Error: ' . mysqli_error(Core::$link);
  283. }
  284. $return = mysqli_fetch_assoc($result);
  285. if ($return['birthday'] !== '0000-00-00') {
  286. $return['birthday'] = date("d.m.Y", strtotime($return['birthday']));
  287. } else {
  288. $return['birthday'] = '';
  289. }
  290. //mysql_free_result($result);
  291. //$result->close();
  292. return $return;
  293. }
  294.  
  295.  
  296. public static function getPatients() {
  297. // $patient = array();
  298. // $patient['id_patient'] = 64;
  299. // $patient['surname'] = 'testiwow';
  300. // $patient['prename'] = 'warum denn nur';
  301. // updatePatientAction($patient);
  302. // echo "warum test";
  303. $sql = "SELECT * FROM patients ORDER BY surname ASC";
  304. //$result = mysql_query($sql);
  305.  
  306. $result = Core::$link->query($sql);
  307.  
  308. if (!$result) {
  309. return 'Error: ' . mysqli_error(Core::$link);
  310. }
  311.  
  312. $return = array();
  313. while ($myrow = mysqli_fetch_assoc($result)) {
  314. if ($myrow['birthday'] !== '0000-00-00') {
  315. $myrow['birthday'] = date("d.m.Y", strtotime($myrow['birthday']));
  316. } else {
  317. $myrow['birthday'] = '';
  318. }
  319. $return[] = $myrow;
  320. }
  321.  
  322. //mysql_free_result($result);
  323. //$result->close();
  324. return $return;
  325. }
  326.  
  327. public static function getTreatmentDate($date, $id_staff = null){
  328. //$date = "2014-03-19";
  329. //echo $date;
  330. //$sql = "SELECT * FROM patients_treatments WHERE date(treatment_date)='". $date. "' ORDER BY treatment_date ASC";
  331.  
  332. // original
  333. if(isset($id_staff)){
  334. $sql = "SELECT pt.*, p.surname, p.prename, t.shortcut, t.color, t.is_multiple_patients FROM patients_treatments pt LEFT JOIN patients p ON pt.id_patient=p.id_patient LEFT JOIN treatments t ON pt.id_treatment=t.id_treatment WHERE date(pt.treatment_date)='". $date. "' AND pt.id_staff=".$id_staff." ORDER BY treatment_date DESC";
  335. }
  336. else{
  337. $sql = "SELECT pt.*, p.surname, p.prename, t.shortcut, t.color, t.is_multiple_patients FROM patients_treatments pt LEFT JOIN patients p ON pt.id_patient=p.id_patient LEFT JOIN treatments t ON pt.id_treatment=t.id_treatment WHERE date(pt.treatment_date)='". $date. "' ORDER BY treatment_date DESC";
  338. }
  339.  
  340. //echo $sql;
  341. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());;
  342. $result = Core::$link->query($sql);
  343.  
  344. if (!$result) {
  345. return 'Error: ' . mysqli_error(Core::$link);
  346. }
  347.  
  348. $return = array();
  349. while($myrow = mysqli_fetch_assoc($result)){
  350. //echo $myrow['id_patient_treatment']."\n";
  351. //$myrow['treatment_date'] = date
  352. $myrow['treatment_date'] = date("d.m.Y H:i", strtotime($myrow['treatment_date']));
  353. $myrow['treatment_time_end'] = date("H:i", strtotime($myrow['treatment_time_end']));
  354. $return[] = $myrow;
  355. }
  356.  
  357. //mysql_free_result($result);
  358. //$result->close();
  359. //echo var_dump($return);
  360. return $return;
  361. }
  362.  
  363. public static function getTreatmentDates($id_patient){
  364. $sql = "SELECT * FROM patients_treatments WHERE id_patient=". $id_patient. " ORDER BY treatment_date DESC";
  365. //$result = mysql_query($sql);
  366.  
  367. $result = Core::$link->query($sql);
  368.  
  369. if (!$result) {
  370. return 'Error: ' . mysqli_error(Core::$link);
  371. }
  372.  
  373. $return = array();
  374. while($myrow = mysqli_fetch_assoc($result)){
  375. //$myrow['treatment_date'] = date
  376. $myrow['treatment_date'] = date("d.m.Y H:i", strtotime($myrow['treatment_date']));
  377. $myrow['treatment_time_end'] = date("H:i", strtotime($myrow['treatment_time_end']));
  378. $return[] = $myrow;
  379. }
  380.  
  381. //mysql_free_result($result);
  382. //$result->close();
  383. return $return;
  384. }
  385.  
  386. public static function getTreatmentDatesByStaff($id_staff){
  387. $sql = "SELECT * FROM patients_treatments WHERE id_staff=". $id_staff. " ORDER BY treatment_date ASC";
  388. //$result = mysql_query($sql);
  389.  
  390. $result = Core::$link->query($sql);
  391.  
  392. if (!$result) {
  393. return 'Error: ' . mysqli_error(Core::$link);
  394. }
  395.  
  396. $return = array();
  397. while($myrow = mysqli_fetch_assoc($result)){
  398. //$myrow['treatment_date'] = date
  399. $myrow['treatment_date'] = date("d.m.Y H:i", strtotime($myrow['treatment_date']));
  400. $myrow['treatment_time_end'] = date("H:i", strtotime($myrow['treatment_time_end']));
  401. $return[] = $myrow;
  402. }
  403.  
  404. //mysql_free_result($result);
  405. //$result->close();
  406. return $return;
  407. }
  408.  
  409. public static function getPatientTreatment($id_patient_treatment){
  410. $sql = "SELECT * FROM patients_treatments WHERE id_patient_treatment=". $id_patient_treatment. " ORDER BY treatment_date ASC";
  411. //$result = mysql_query($sql);
  412. $result = Core::$link->query($sql);
  413.  
  414. if (!$result) {
  415. return 'Error: ' . mysqli_error(Core::$link);
  416. }
  417. $return = mysqli_fetch_assoc($result);
  418. //$myrow['treatment_date'] = date
  419. $return['treatment_date'] = date("d.m.Y H:i", strtotime($return['treatment_date']));
  420. $return['treatment_time_end'] = date("H:i", strtotime($return['treatment_time_end']));
  421. //$return[] = $myrow;
  422.  
  423.  
  424. //mysql_free_result($result);
  425. //$result->close();
  426. return $return;
  427. }
  428.  
  429. public static function getWorkingTimes($id_staff, $date){
  430. $sql = "";
  431. if(isset($id_staff)){
  432. $sql = "SELECT * FROM staff_workingtimes WHERE id_staff=".$id_staff;
  433. if(isset($date) && $date !== ""){
  434. //$sql .= " AND date(beginning_time) >='".$date."' AND date(end_time) <='".$date."'";
  435. $sql .= " AND date(beginning_time) <='".$date."' AND date(end_time) >='".$date."'";
  436. }
  437. }
  438. else{
  439. $sql = "SELECT * FROM staff_workingtimes";
  440. if(isset($date) && $date !== ""){
  441. $sql .= " WHERE date(beginning_time) <='".$date."' AND date(end_time) >='".$date."'";
  442. }
  443. }
  444. //return $sql;
  445. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  446. $result = Core::$link->query($sql);
  447.  
  448. if (!$result) {
  449. return 'Error: ' . mysqli_error(Core::$link);
  450. }
  451. $return = array();
  452. while($myrow = mysqli_fetch_assoc($result)){
  453. //echo $myrow['id_staff'];
  454. //echo $myrow['id_patient_treatment']."\n";
  455. //$myrow['treatment_date'] = date
  456. $myrow['beginning_time'] = date("d.m.Y H:i", strtotime($myrow['beginning_time']));
  457. $myrow['end_time'] = date("d.m.Y H:i", strtotime($myrow['end_time']));
  458. $return[] = $myrow;
  459. }
  460.  
  461. //mysql_free_result($result);
  462. //$result->close();
  463. return $return;
  464. }
  465.  
  466. public static function getPatient($id_patient) {
  467. $sql = "SELECT * FROM patients WHERE id_patient=" . $id_patient;
  468. //$result = mysql_query($sql);
  469. $result = Core::$link->query($sql);
  470.  
  471. if (!$result) {
  472. return 'Error: ' . mysqli_error(Core::$link);
  473. }
  474. $return = mysqli_fetch_assoc($result);
  475. if ($return['birthday'] !== '0000-00-00') {
  476. $return['birthday'] = date("d.m.Y", strtotime($return['birthday']));
  477. } else {
  478. $return['birthday'] = '';
  479. }
  480. //mysql_free_result($result);
  481. //$result->close();
  482. return $return;
  483. }
  484.  
  485. public static function checkOverlappingTreatmentDates($id_staff, $treatment_date, $treatment_time_end){
  486. // (t1 < t1_a && t1_a < t2) || (t1 < t2_a && t2_a < t2)
  487. //SELECT * FROM patients_treatments WHERE id_staff=1 AND treatment_date LIKE '%2014-03-20%' AND ((treatment_date <= '2014-03-20 11:05' AND '11:05' < treatment_time_end) OR (treatment_date < '2014-03-20 11:25' AND '11:25' <= treatment_time_end));
  488. $tdate = explode(' ', $treatment_date);
  489. //$sql = "SELECT COUNT(id_patient_treatment) FROM patients_treatments WHERE id_staff=".$id_staff." AND (treatment_date >= '".$treatment_date."' AND treatment_time_end='".$tdate[1]."') OR (treatment_date ";
  490. $sql = "SELECT COUNT(id_patient_treatment) FROM patients_treatments WHERE id_staff=".$id_staff." AND treatment_date LIKE '%".$tdate[0]."%' AND ((treatment_date <= '".$treatment_date."' AND '".$tdate[1]."' < treatment_time_end) OR (treatment_date < '".$tdate[0]." ".$treatment_time_end."' AND '".$treatment_time_end."' <= treatment_time_end) OR ('".$treatment_date."' <= treatment_date AND treatment_time_end <= '".$treatment_time_end."'))";
  491. //echo $sql;
  492. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  493. $result = Core::$link->query($sql);
  494.  
  495. if (!$result) {
  496. return 'Error: ' . mysqli_error(Core::$link);
  497. }
  498. $row = mysqli_fetch_assoc($result);
  499. //mysql_free_result($result);
  500. //$result->close();
  501. if($row['COUNT(id_patient_treatment)']){
  502. return false;
  503. }
  504. return true;
  505. }
  506.  
  507. public static function isHitExactlyTreatmentDate($id_staff, $treatment_date, $treatment_time_end){
  508. $tdate = explode(' ', $treatment_date);
  509.  
  510. //$sql = "SELECT COUNT(pt.id_patient_treatment) FROM patients_treatments pt LEFT JOIN treatments t ON pt.id_treatment=t.id_treatment WHERE pt.id_staff=".$id_staff." AND t.is_multiple_patients='true' AND pt.treatment_date LIKE '%".$tdate[0]."%' AND ((treatment_date = '".$treatment_date."' AND '".$tdate[1]."' = treatment_time_end) OR (treatment_date = '".$tdate[0]." ".$treatment_time_end."' AND '".$treatment_time_end."' = treatment_time_end) OR ('".$treatment_date."' = treatment_date AND treatment_time_end = '".$treatment_time_end."'))";
  511. $sql = "SELECT COUNT(pt.id_patient_treatment) FROM patients_treatments pt LEFT JOIN treatments t ON pt.id_treatment=t.id_treatment WHERE pt.id_staff=".$id_staff." AND t.is_multiple_patients='true' AND pt.treatment_date = '".$tdate[0]." ".$tdate[1]."' AND pt.treatment_time_end='".$treatment_time_end."'";
  512. //return $sql;
  513. $result = Core::$link->query($sql);
  514.  
  515. if (!$result) {
  516. return 'Error: ' . mysqli_error(Core::$link);
  517. }
  518. $row = mysqli_fetch_assoc($result);
  519. //mysql_free_result($result);
  520. //$result->close();
  521. //return $row['COUNT(pt.id_patient_treatment)'];
  522. if($row['COUNT(pt.id_patient_treatment)']){
  523. return true;
  524. }
  525. return false;
  526. }
  527.  
  528.  
  529. public static function isOnHoliday($id_staff, $treatment_date, $treatment_time_end){
  530. $tdate = explode(' ', $treatment_date);
  531.  
  532. $sql = "SELECT COUNT(id_staff_workingtime) FROM staff_workingtimes WHERE id_staff=".$id_staff." AND matter='HOLIDAY' AND date(beginning_time)<='".$tdate[0]."' AND date(end_time)>='".$tdate[0]."'";
  533.  
  534. $result = Core::$link->query($sql);
  535.  
  536. if (!$result) {
  537. return 'Error: ' . mysqli_error(Core::$link);
  538. }
  539. $row = mysqli_fetch_assoc($result);
  540. //return $sql;
  541. //mysql_free_result($result);
  542. //$result->close();
  543. if($row['COUNT(id_staff_workingtime)']){
  544. return true;
  545. }
  546.  
  547. return false;
  548.  
  549. }
  550. public static function insertTreatmentDate($id_patient, $id_staff, $id_treatment, $treatment_date, $treatment_time_end, $description) {
  551. $sql = "INSERT INTO patients_treatments (id_patient, id_staff, id_treatment, treatment_date, treatment_time_end, description) " .
  552. "VALUES ('" . $id_patient . "', '" . $id_staff . "', '" . $id_treatment . "', '" . $treatment_date . "', '" . $treatment_time_end . "', '". $description."')";
  553. //echo $sql;
  554. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  555.  
  556. $result = Core::$link->query($sql);
  557.  
  558. if (!$result) {
  559. return 'Error: ' . mysqli_error(Core::$link);
  560. }
  561.  
  562. //mysql_free_result($result);
  563. //$result->close();
  564. return true;
  565. }
  566.  
  567. public static function insertWorkingTime($id_staff, $beginning_time, $end_time, $matter){
  568. $sql = "INSERT INTO staff_workingtimes (id_staff, beginning_time, end_time, matter) ".
  569. "VALUES ('".$id_staff."', '". $beginning_time. "', '".$end_time."', '".$matter."')";
  570. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  571. $result = Core::$link->query($sql);
  572.  
  573. if (!$result) {
  574. return 'Error: ' . mysqli_error(Core::$link);
  575. }
  576. //mysql_free_result($result);
  577. //$result->close();
  578. return true;
  579. }
  580.  
  581. public static function removeTreatmentDate($id_patient_treatment) {
  582. $sql = "DELETE FROM patients_treatments WHERE id_patient_treatment=" . $id_patient_treatment;
  583. //echo $sql;
  584. //$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
  585. $result = Core::$link->query($sql);
  586.  
  587. if (!$result) {
  588. return 'Error: ' . mysqli_error(Core::$link);
  589. }
  590. //mysql_free_result($result);
  591. //$result->close();
  592. }
  593.  
  594. public static function getTreatments(){
  595. $sql = "SELECT * FROM treatments";
  596. //$result = mysql_query($sql);
  597. $result = Core::$link->query($sql);
  598.  
  599. if (!$result) {
  600. return 'Error: ' . mysqli_error(Core::$link);
  601. }
  602. $return = array();
  603. while($myrow = mysqli_fetch_assoc($result)){
  604. //$myrow['treatment_time_end'] = "what";//date("H:i", strtotime($myrow['treatment_time_end'])). "what";
  605. $return[] = $myrow;
  606. }
  607.  
  608. //mysql_free_result($result);
  609. //$result->close();
  610. return $return;
  611. }
  612.  
  613. public static function getTreatment($id_treatment) {
  614. $sql = "SELECT * FROM treatments WHERE id_treatment=" . $id_treatment;
  615. //$result = mysql_query($sql);
  616. //echo $sql;
  617. $result = Core::$link->query($sql);
  618.  
  619. // if (!$result) {
  620. // return 'Error: ' . mysqli_error(Core::$link);
  621. // }
  622. $return = mysqli_fetch_assoc($result);
  623. //mysql_free_result($result);
  624. //$result->close();
  625. return $return;
  626. }
  627. }
  628. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement