Advertisement
Guest User

Untitled

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