PageRenderTime 61ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/include/imgcreator/log-timebar.php

https://github.com/timschofield/2.8
PHP | 183 lines | 106 code | 36 blank | 41 comment | 22 complexity | 31ddac09a4c1c618500e8c8ce43eb650 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-2.0
  1. <?php
  2. error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
  3. require('./roots.php');
  4. require(CARE_BASE .'include/helpers/inc_environment_global.php');
  5. /*
  6. CARE2X Integrated Information System for Hospitals and Health Care Organizations and Services
  7. Copyright (C) 2002,2003,2004,2005 Elpidio Latorilla & Intellin.org
  8. GNU GPL. For details read file "copy_notice.txt".
  9. */
  10. // globalize POST, GET, & COOKIE vars
  11. if(!extension_loaded('gd')) dl('php_gd.dll');
  12. $tabhi=90;
  13. $tablen=3000; //original length
  14. $tabcols=$tablen/24;
  15. $tabrows=$tabhi/6;
  16. header ("Content-type: image/PNG");
  17. $im = @ImageCreate ($tablen, $tabhi)
  18. or die ("Cannot Initialize new GD image stream");
  19. $background_color = ImageColorAllocate ($im, 255,255,255);
  20. $text_color = ImageColorAllocate ($im, 0, 170, 255);
  21. $black = ImageColorAllocate ($im, 0, 0, 0);
  22. $red =ImageColorAllocate ($im, 255, 0, 0);
  23. /* Establish db connection */
  24. if(!isset($db)||!$db) include(CARE_BASE .'include/helpers/inc_db_makelink.php');
  25. if($dblink_ok){
  26. $sql="SELECT entry_out,cut_close,wait_time,bandage_time,repos_time FROM care_encounter_op
  27. WHERE encounter_nr='$enc_nr'
  28. AND dept_nr='$dept_nr'
  29. AND op_room='$saal'
  30. AND op_nr='$op_nr'";
  31. if($ergebnis=$db->Execute($sql)){
  32. $rows=$ergebnis->RecordCount();
  33. if($rows==1){
  34. $result=$ergebnis->FetchRow();
  35. }
  36. }else{exit;}
  37. }else{exit;}
  38. $x=$tabcols/2;
  39. $h=$tabrows*2;
  40. $mincols=$tablen/(12*24);
  41. $lock=1;
  42. for($i=$tabrows;$i<$tabhi;$i+=$tabrows)
  43. {
  44. ImageLine($im,0,$i,$tablen-1,$i,$text_color);
  45. for ($n=$mincols;$n<=$tablen;$n+=$mincols)
  46. {
  47. if($lock<12)
  48. {
  49. ImageLine($im,$n,($h-($tabrows*0.30)),$n,$h-1,$text_color);
  50. $lock++;
  51. }
  52. else{ $lock=1;}
  53. }
  54. $h+=$tabrows;
  55. }
  56. for ($h=$tabrows*2;$h<=$tabhi;$h+=$tabrows)
  57. ImageLine($im,($tabcols/4),$h-($tabrows*0.50),($tabcols/4),$h-1,$text_color);
  58. for($i=$tabcols,$j=1;$i<=$tablen;$i+=$tabcols,$j++)
  59. {
  60. ImageLine($im,$i,0,$i,$tabhi-1,$text_color);
  61. if($j>23) $j=0;
  62. // *******************************************************************
  63. // * the following code is for ttf fonts use only for php machines with ttf support
  64. // * uncomment the following line to use ttf font and comment the default line
  65. // *******************************************************************
  66. // ImageTTFText ($im, 12, 0,$i-7, 10, $red, "arial.ttf",$j);
  67. // ******************************************************************
  68. // * the following code is the default - uses system fonts
  69. // * comment the following line if you use the ttf font line above
  70. // ******************************************************************
  71. ImageString($im,3,$i-7,3,$j,$red);
  72. for ($h=$tabrows*2;$h<=$tabhi;$h+=$tabrows)
  73. {
  74. ImageLine($im,$i-$x,($h-($tabrows*0.70)),$i-$x,$h-1,$black);
  75. ImageLine($im,$i-($tabcols/4),($h-($tabrows*0.50)),$i-($tabcols/4),$h-1,$text_color);
  76. ImageLine($im,$i+($tabcols/4),($h-($tabrows*0.50)),$i+($tabcols/4),$h-1,$text_color);
  77. }
  78. }
  79. ImageLine($im,0,$tabhi-1,$tablen-1,$tabhi-1,$text_color);
  80. // * here starts the drawing of the time bars
  81. $idx1=array("ein","schnitt","bwarte","bgips","brepos");
  82. $idx2=array("aus","naht","ewarte","egips","erepos");
  83. $element=array("entry_out","cut_close","wait_time","bandage_time","repos_time");
  84. for($i=0,$j=1;$i<sizeof($element);$i++,$j++)
  85. {
  86. $datarray=explode("~",trim($result[$element[$i]]));
  87. for($n=0;$n<sizeof($datarray);$n++)
  88. {
  89. parse_str($datarray[$n],$dat);
  90. if((!$dat['s']&&!$dat['e'])) continue;
  91. if($dat['s']!=NULL)
  92. {
  93. $dat['s']=(float) $dat['s'];
  94. if($dat['s']==0) $dat['s']=0.01;
  95. $buf= (int) trim($dat['s']);
  96. $buff= (int) (($dat['s']-$buf)*100);
  97. $buff=$buf+($buff/60);
  98. //print $buff."<p> dats";
  99. // *******************************************************************
  100. // * the following code is for ttf fonts use only for php machines with ttf support
  101. // * uncomment the following line to use ttf font and comment the default line
  102. // *******************************************************************
  103. // ImageTTFText ($im, 9, 45,($buff*$tabcols),($tabrows*(0.50+$j)), $black, "arial.ttf",$dat['s']);
  104. // ******************************************************************
  105. // * the following code is the default - uses system fonts
  106. // * comment the following line if you use the ttf font line above
  107. // ******************************************************************
  108. ImageString($im,1,($buff*$tabcols),($tabrows*$j+1),strtr($dat['s'],'.',':'),$black);
  109. }
  110. if($dat['e']!=NULL)
  111. {
  112. $dat['e']=(float) $dat['e'];
  113. // *******************************************************************
  114. // * uncomment the following line if you want to display midnight as 24.00
  115. // *******************************************************************
  116. //if($dat['e']==0) $dat['e']=24.00;
  117. $buf2=(int) trim($dat['e']);
  118. $buff2= (int) (($dat['e']-$buf2)*100);
  119. $buff2=$buf2+($buff2/60);
  120. // *******************************************************************
  121. // * the following code is for ttf fonts use only for php machines with ttf support
  122. // * uncomment the following line to use ttf font and comment the default line
  123. // *******************************************************************
  124. // ImageTTFText ($im, 9, 45,($buff2*$tabcols),($tabrows*(0.50+$j)), $black, "arial.ttf",$dat['e']);
  125. // ******************************************************************
  126. // * the following code is the default - uses system fonts
  127. // * comment the following line if you use the ttf font line above
  128. // ******************************************************************
  129. ImageString($im,1,($buff2*$tabcols),($tabrows*$j+1),strtr($dat['e'],'.',':'),$black);
  130. }
  131. if(($buff<$buff2)||($dat['e']==NULL))
  132. {
  133. if(($dat['s']!=NULL)&&($dat['e']!=NULL)) ImageFilledRectangle($im,($buff*$tabcols),($tabrows*(0.65+$j)),($buff2*$tabcols),($tabrows*(0.85+$j)),$red);
  134. if(($dat['s']!=NULL)&&($dat['e']==NULL)) ImageFilledRectangle($im,($buff*$tabcols),($tabrows*(0.65+$j)),(($buff*$tabcols)+4),($tabrows*(0.85+$j)),$red);
  135. if(($dat['s']==NULL)&&($dat['e']!=NULL)) ImageFilledRectangle($im,(($buff2*$tabcols)+4),($tabrows*(0.65+$j)),($buff2*$tabcols),($tabrows*(0.85+$j)),$red);
  136. }
  137. else
  138. {
  139. $blue = ImageColorAllocate ($im, 0, 0, 255);
  140. ImageFilledRectangle($im,($buff*$tabcols),($tabrows*(0.75+$j)),(24*$tabcols),($tabrows*(0.95+$j)),$blue);
  141. ImageFilledRectangle($im,(0.009*$tabcols),($tabrows*(0.75+$j)),($buff2*$tabcols),($tabrows*(0.95+$j)),$blue);
  142. }
  143. }
  144. }
  145. ImagePNG($im); ImageDestroy ($im);
  146. ?>