rcalendar.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. The rCalendar
  5. */
  6. $DaysShort = api_get_week_days_short();
  7. $DaysLong = api_get_week_days_long();
  8. $MonthsLong = api_get_months_long();
  9. class rCalendar {
  10. function rCalendar() {
  11. }
  12. function get_short_day($day) {
  13. global $DaysShort;
  14. return $DaysShort[$day];
  15. }
  16. function get_long_day($day) {
  17. global $DaysLong;
  18. return $DaysLong[$day];
  19. }
  20. function get_long_month($month) {
  21. global $MonthsLong;
  22. return $MonthsLong[$month];
  23. }
  24. /*
  25. * Deze methode retourneert de maandkalender waarbij dagen MET RESERVATIES groen worden en dagen zonder, grijs
  26. *
  27. */
  28. function get_mini_month($month, $year, $extra, $itemid) {
  29. global $DaysShort;
  30. $month = intval($month);
  31. if ($month < 10)
  32. $month = '0'.$month;
  33. $stamp = Rsys :: mysql_datetime_to_timestamp($year.'-'.$month.'-01 00:00:00');
  34. $daysinmonth = date('t', $stamp);
  35. $dayofweek = date('w', $stamp); // 0-6
  36. if ($dayofweek == 0)
  37. $dayofweek = 7; // 1-7...
  38. echo '<table style="padding:0.2em;border:1px solid #000" cellspacing="1"><tr><th><a style="font-size: 11px;font-family: Verdana,sans-serif;" href="reservation.php?item='.$itemid.'&amp;viewday&amp;changemonth=yes&amp;date='. ($month == 1 ? $year -1 : $year).'-'. ($month == 1 ? 12 : $month -1).'-1'.$extra.'">&laquo;</a></th><th colspan="5" style="font-family: Verdana,sans-serif;border:2px inset #000;background-color:#FF0;font-size:11px">'.$this->get_long_month($month -1).' '.$year.'</th><th><a href="reservation.php?item='.$itemid.'&amp;viewday&amp;changemonth=yes&amp;date='. ($month == 12 ? $year +1 : $year).'-'. ($month == 12 ? 1 : $month +1).'-1'.$extra.'" style="font-size: 11px;font-family: Verdana,sans-serif;">&raquo;</a></th></tr><tr>';
  39. for ($i = 1; $i <= 7; $i ++) {
  40. echo '<th style="color:#036;font-size: 10px;font-family: Verdana,sans-serif; padding: 3px 0.2em 3px 0.2em">'.$this->get_short_day($i == 7 ? 0 : $i).'</th>';
  41. }
  42. echo '</tr><tr>';
  43. for ($i = 1; $i <= 42; $i ++) {
  44. if ($i - $dayofweek < $daysinmonth && $i >= $dayofweek)
  45. echo '<td style="border-bottom:1px solid #CCE;cursor: pointer;border-right:1px solid #CCE;text-align: center;font-size: 11px;font-family: Verdana,sans-serif;" onmouseout="this.style.background=\'#FFF\'" onmouseover="this.style.background=\'#FF0\'" onclick="document.location.href=\'?viewday&amp;date='.$year.'-'.$month.'-'. ($i - $dayofweek +1).$extra.'\'"><a href="?viewday&amp;date='.$year.'-'.$month.'-'. ($i - $dayofweek +1).$extra.'" style="color:'
  46. // Hier wordt een boolean bepaald voor elke dag, TRUE=reservaties op die dag>>Groen, FALSE=geen reservaties op die dag>>Grijs
  47. // (TODO: legende-kleuren retourneren ipv TRUE of FALSE)
  48. //.(Rsys :: check_date_month_calendar($year,$month,($i - $dayofweek +1),$itemid) ? "#0C0" : "#666").
  49. //.Rsys :: check_date_month_calendar($year,$month,($i - $dayofweek +1),$itemid).
  50. .(Rsys :: check_date_month_calendar($year.'-'.$month.'-'. ($i - $dayofweek +1),$itemid) ? "#0C0" : "#666").
  51. '">'.($i - $dayofweek +1).'</a></td>';
  52. elseif ($i < $dayofweek) echo '<td>&nbsp;</td>';
  53. else
  54. break;
  55. if ($i +1 - $dayofweek < $daysinmonth && $i +1 > $dayofweek && $i % 7 == 0)
  56. echo '</tr><tr>';
  57. }
  58. echo '</tr></table>';
  59. }
  60. /*
  61. * Deze methode retourneert een balkje van een gegeven $width met een bepaalde kleur ($color) met evt. een titel
  62. *
  63. */
  64. function get_bar($width, $color, $link = '', $title = '', $itemid=null, $cat=null) {
  65. // 1) width herberekenen om afrondingsfouten te beperken
  66. if($GLOBALS['weekday_pointer']!=$GLOBALS['last_weekday_pointer']) {
  67. $GLOBALS['daytotal']=0;
  68. $GLOBALS['lasttotal']=0;
  69. $GLOBALS['last_weekday_pointer']=$GLOBALS['weekday_pointer'];
  70. }
  71. $GLOBALS['daytotal']+=$width;
  72. $GLOBALS['rounded_total']=round($GLOBALS['daytotal']);
  73. $width=$GLOBALS['rounded_total']-$GLOBALS['lasttotal'];
  74. $GLOBALS['lasttotal']=$GLOBALS['rounded_total'];
  75. // 2) kleur aanpassen indien item op blackout staat
  76. if($GLOBALS['bblackout'] && $color!='red' && $color!='orange' && $color!='grey') {
  77. $color='black';
  78. $link='';
  79. }
  80. $img='';
  81. // 3) html code returnen voor gekleurde bar
  82. if (!empty($itemid) && !empty($cat)&& !empty($link)) {
  83. $link.='&cat='.$cat.'&item='.$itemid;
  84. $img = '<img src="../img/px_'.$color.'.gif" alt="" style="height: 15px;width: '.$width.'px'. (!empty ($link) ? ';cursor: pointer;" onclick="window.location.href=\''.$link.'\'"' : (!empty ($title) ? ';cursor: help;"' : '"')). (!empty ($title) ? ' title="'.$title.'"' : '').' />';
  85. }
  86. else {
  87. $img = '<img src="../img/px_'.$color.'.gif" alt="" style="height: 15px;width: '.$width.'px'. (!empty ($link) ? ';cursor: pointer;" onclick="window.location.href=\''.$link.'\'"' : (!empty ($title) ? ';cursor: help;"' : '"')). (!empty ($title) ? ' title="'.$title.'"' : '').' />';
  88. }
  89. return $img;
  90. }
  91. /*
  92. * Deze methode retourneert de weekkalender
  93. *
  94. * - Deze methode ontvangt een item-id & 1 dag als parameter (dag+maand+jaar), de omliggende week (met reservaties etc.) wordt dan opgehaald
  95. * - hoe groter de $day_scale, hoe kleiner de tabel (86400/$day_scale=breedte van 1 dag)
  96. */
  97. function get_week_view($day, $month, $year, $itemid, $day_scale = 180,$cat) {
  98. // 1) Item is blackout? >> True of False ... wordt gebruikt in get_bar methode om kleur indien nodig om te zetten
  99. $GLOBALS['bblackout']=Rsys::is_blackout($itemid);
  100. // 2) $day_scale controleren en aanpassen indien nodig
  101. // Day_scale mag niet groter zijn dan 3600 (anders wordt de tabel te klein)
  102. if ($day_scale > 3600)
  103. $day_scale = 3600;
  104. // Day_scale mag niet kleiner zijn dan 1 (anders wordt de tabel te groot)
  105. elseif ($day_scale < 1)
  106. $day_scale = 1;
  107. // 3) Een '0' voor de maand-integer zetten indien deze kleiner is dan 10, nodig voor datetime
  108. // bv voor 1 december 1985: '01-12-1985' ipv '1-12-1985' (S�ba's geboortedatum ^^)
  109. if ($month < 10)
  110. $month = '0'.$month;
  111. // 4) Bepaal de juiste start datum (maandag) van de omliggende week
  112. // (verander eventueel maand (en jaar) wanneer de maandag in de vorige maand/jaar ligt)
  113. $fromdate = $year.'-'.$month.'-'. ($day < 10 ? '0'.$day : $day).' 00:00:00';
  114. $stamp = Rsys :: mysql_datetime_to_timestamp($fromdate);
  115. $dayofweek = date('w', $stamp);
  116. if ($dayofweek == 0) {
  117. $stamp = $stamp - (1);
  118. $datum = Rsys :: mysql_datetime_to_array(Rsys :: timestamp_to_datetime($stamp));
  119. $day = $datum['day'];
  120. $month = $datum['month'];
  121. $year = $datum['year'];
  122. }
  123. $fromdate = $year.'-'.$month.'-'.$day.' 00:00:00';
  124. $stamp = Rsys :: mysql_datetime_to_timestamp($fromdate);
  125. $dayofweek = date('w', $stamp);
  126. if ($day - $dayofweek < 0) {
  127. $stamp = $stamp - (60 * 60 * 24 * ($dayofweek -1));
  128. $fromdate = Rsys :: timestamp_to_datetime($stamp);
  129. $tilldate = $stamp;
  130. } else {
  131. $day = $day - $dayofweek +1; // M-FIX: sunday + 1 = monday
  132. $fromdate = $year.'-'.$month.'-'. ($day < 10 ? '0'.$day : $day).' 00:00:00';
  133. $tilldate = Rsys :: mysql_datetime_to_timestamp($fromdate);
  134. }
  135. //zeven Dagen opvullen en eind-datum bepalen (= startdatum + 7 dagen)
  136. for ($i = 1; $i <= 7; $i ++) {
  137. $day_start_dates[$i] = $tilldate;
  138. $tilldate += 60 * 60 * 24;
  139. }
  140. // 5) Haal de reservaties periodes (+ reservaties) op tussen de start en einddatum
  141. $arr = Rsys :: get_item_reservations($fromdate, Rsys :: timestamp_to_datetime($tilldate), $itemid);
  142. // 6) Doorloop $arr met reservatie periodes en vul de $days array op met balkjes (bars) voor elke dag
  143. $weekday_pointer = $GLOBALS['weekday_pointer'] = 1; // Stel de weekdag pointer in op 1 (=maandag)
  144. $one_day = 60 * 60 * 24 - 1; // Het aantal seconden dat ��n dag in beslag neemt (23:59:59)
  145. $last_end = $day_start_dates[1]; // Stel de $last_end pointer in op het begin van maandag (00:00:00)
  146. if (count($arr['reservations'])>0) {
  147. foreach ($arr['reservations'] as $res_id => $res) {
  148. // 6.1) Stel basis variabelen in
  149. $r = $res['info']; // Reservatie periode informatie (start en eind tijd etc.)
  150. $s = $res['subscriptions']; // Reservaties (inschrijvingen) op reservatie periode
  151. $start = Rsys :: mysql_datetime_to_timestamp($r['start_at']); // Start tijd van reservatie periode blok
  152. $end = Rsys :: mysql_datetime_to_timestamp($r['end_at']); // Eind tijd van reservatie periode blok
  153. $timepicker_min = $r['timepicker_min'];
  154. $timepicker_max = $r['timepicker_max'];
  155. $chunk_size = $end - $start; // Unscaled chunk_size (of "reservation-period-block") // een "chunk" is dus een balkje (bar)
  156. // 6.2) Als de weekdag van de huidige start-tijd (van de reservatieperiode) niet overeenkomt met de huidige weekdag-pointer (=$weekday_pointer)
  157. if (date('w', $start) != $weekday_pointer) {
  158. // a) Wijzig de $weekday_pointer naar de weekdag waarin de start-tijd (van de reservatieperiode) zich bevindt
  159. $weekday_pointer = $GLOBALS['weekday_pointer'] = date('w', $start);
  160. if ($weekday_pointer == 0)
  161. $weekday_pointer = 7;
  162. // b) Stel de $last_end in op het begin van de nieuwe dag
  163. $last_end = $day_start_dates[$weekday_pointer];
  164. }
  165. // 6.3) Vul de ruimte tussen $last_end en de huidige start-tijd met een grijze balk
  166. if ($start - $last_end > 0)
  167. $days[$weekday_pointer] .= $this->get_bar(($start - $last_end) / $day_scale, 'grey');
  168. // 6.4.A) Indien het NIET om een timepicker gaat... (= 1 reservatie-blok)
  169. if ($r['timepicker'] != 1) {
  170. // ..a1) bepaal kleur en link (of geen link) op basis van de inschrijvingsperiode en het aantal en het maximaal aantal inschrijvingen
  171. if ($r['subscribers'] < $r['max_users'] && Rsys :: mysql_datetime_to_timestamp($r['start_at']) > time() && ($r['subscribe_from']=='0000-00-00 00:00:00'||(Rsys :: mysql_datetime_to_timestamp($r['subscribe_from']) < time() && Rsys :: mysql_datetime_to_timestamp($r['subscribe_until']) > time()))) {
  172. // Subscription is allowed
  173. $color = "green";
  174. $link = "subscribe.php?rid=".$r['id'];
  175. }
  176. elseif ($r['subscribers'] < $r['max_users'] && (Rsys :: mysql_datetime_to_timestamp($r['subscribe_from']) > time() || Rsys :: mysql_datetime_to_timestamp($r['subscribe_until']) < time() || Rsys :: mysql_datetime_to_timestamp($r['start_at']) < time())) {
  177. // Subscribe_from is not yet reached
  178. $color = "orange";
  179. $link = null;
  180. }
  181. else {
  182. // Subscription is not allowed
  183. $color = "red";
  184. $link = null;
  185. }
  186. // ..a2) stel titel in (dat je ziet als je over het balkje zweeft met je muis)
  187. $title = date('H:i (d/m/Y)', $start).' &raquo; '.date('H:i (d/m/Y)', $end);
  188. // ..a3) controleer of het reservatie-periode-blok de huidige dag overschrijdt
  189. if ($end > $day_start_dates[$weekday_pointer] + $one_day) {
  190. // indien ja, cree�r dan balkjes voor elke volgende dag
  191. $trimmed_chunk_size = $chunk_size - ($end - ($day_start_dates[$weekday_pointer] + $one_day));
  192. $days[$weekday_pointer] .= $this->get_bar($trimmed_chunk_size / $day_scale, $color, $link, $title, $itemid, $cat);
  193. $new_day = true;
  194. while ($new_day && $weekday_pointer < 7) {
  195. $weekday_pointer ++;
  196. $GLOBALS['weekday_pointer']++;
  197. $start = $days[$weekday_pointer];
  198. $chunk_size = $end - $start;
  199. if ($end > $day_start_dates[$weekday_pointer] + $one_day) { // If still larger than one day, trim chunk and continue
  200. $days[$weekday_pointer] .= $this->get_bar($one_day / $day_scale, $color, $link, $title, $itemid, $cat);
  201. } else {
  202. $trimmed_chunk_size = $end - $day_start_dates[$weekday_pointer];
  203. $days[$weekday_pointer] .= $this->get_bar($trimmed_chunk_size / $day_scale, $color, $link, $title, $itemid, $cat);
  204. $new_day = false;
  205. }
  206. }
  207. }
  208. else // indien niet, voeg dan gewoon het balkje toe aan de huidige dag
  209. $days[$weekday_pointer] .= $this->get_bar($chunk_size / $day_scale, $color, $link, $title, $itemid, $cat);
  210. // 6.4.B) Indien het WEL om een timepicker gaat... (max_users telt hier niet)
  211. }
  212. else
  213. {
  214. $timepicker_min *= 60;
  215. $timepicker_max *= 60;
  216. $minute_interval = 30;
  217. $minute_interval *= 60;
  218. $color = "blue";
  219. $pickedcolor = "red";
  220. $tosmallchunkcolor = "yellow";
  221. $start_pointer = $start;
  222. $link = "subscribe.php?rid=".$r['id'].'&amp;timestart='; // + (start)tijd waarop geklikt werd = volwaardige link
  223. if(count($s)==0) {
  224. if ($start > time())
  225. {
  226. //controle of dat de time tussen $r['subscribe_from'] en $r['subscribe_until'] ligt
  227. if((Rsys :: mysql_datetime_to_timestamp($r['subscribe_from']) <= time() && Rsys :: mysql_datetime_to_timestamp($r['subscribe_until']) > time()) || ($r['subscribe_from'] == '0000-00-00 00:00:00' && $r['subscribe_until'] == '0000-00-00 00:00:00')) {
  228. $days[$weekday_pointer] .= $this->get_bar(($end - $start) / $day_scale, $color, $link.$start_pointer, date('H:i', $start).' &raquo; '.date('H:i', $end), $itemid, $cat);
  229. }
  230. else
  231. {
  232. $days[$weekday_pointer] .= $this->get_bar(($end - $start) / $day_scale, 'orange', null, date('H:i', $start).' &raquo; '.date('H:i', $end));
  233. }
  234. }
  235. else
  236. {
  237. if (time() < $end)
  238. {
  239. //eerst oranje daarna blauw of geel
  240. $days[$weekday_pointer] .= $this->get_bar((time() - $start) / $day_scale, 'orange', null, date('H:i', $start).' &raquo; '.date('H:i', time()));
  241. //controle of het stuk nog kan gereserveerd worden -> stuk > timepicker_min
  242. if((Rsys :: mysql_datetime_to_timestamp($r['subscribe_from']) <= time() && Rsys :: mysql_datetime_to_timestamp($r['subscribe_until']) > time()) || ($r['subscribe_from'] == '0000-00-00 00:00:00' && $r['subscribe_until'] == '0000-00-00 00:00:00')) {
  243. if (($end - time()) >= $timepicker_min)
  244. {
  245. $days[$weekday_pointer] .= $this->get_bar(($end - time()) / $day_scale, $color, $link.$start_pointer, date('H:i', time()).' &raquo; '.date('H:i', $end), $itemid, $cat);
  246. }
  247. else
  248. {
  249. $days[$weekday_pointer] .= $this->get_bar(($end - time()) / $day_scale, $tosmallchunkcolor, null, date('H:i', time()).' &raquo; '.date('H:i', $end));
  250. }
  251. }
  252. else
  253. {
  254. $days[$weekday_pointer] .= $this->get_bar(($end - time()) / $day_scale, 'orange', null, date('H:i', time()).' &raquo; '.date('H:i', $end));
  255. }
  256. }
  257. else
  258. {
  259. //volledig oranje blok
  260. $days[$weekday_pointer] .= $this->get_bar(($end - $start) / $day_scale, 'orange', null, date('H:i', $start).' &raquo; '.date('H:i', $end));
  261. }
  262. }
  263. }
  264. else
  265. {
  266. $i = 0;
  267. foreach ($s as $key => $sub) {
  268. $start = Rsys :: mysql_datetime_to_timestamp($sub['start_at']);
  269. $einde = Rsys :: mysql_datetime_to_timestamp($sub['end_at']);
  270. if (Rsys :: mysql_datetime_to_timestamp($sub['start_at']) - $start_pointer <= 0) {
  271. //start onmiddelijk met een rood stuk
  272. $start_tijd = date('H:i',$start_pointer);
  273. $eind_tijd = date('H:i',$einde);
  274. $days[$weekday_pointer] .= $this->get_bar(($einde - $start_pointer) / $day_scale, $pickedcolor, null, $start_tijd.' &raquo; '.$eind_tijd);
  275. }
  276. else {
  277. //start met een blauw of oranje stuk
  278. //kijken of dat de start_tijd al buiten de huidige tijd ligt ->
  279. if ($start_pointer > time()) {
  280. $start_tijd = date('H:i',$start_pointer);
  281. $eind_tijd = date('H:i',$start);
  282. if((Rsys :: mysql_datetime_to_timestamp($r['subscribe_from']) <= time() && Rsys :: mysql_datetime_to_timestamp($r['subscribe_until']) > time()) || ($r['subscribe_from'] == '0000-00-00 00:00:00' && $r['subscribe_until'] == '0000-00-00 00:00:00')) {
  283. //niet buiten tijd!
  284. //blauw stuk maken indien groter dan timepicker_min anders geel
  285. if (($start - $start_pointer) >= $timepicker_min) {
  286. $days[$weekday_pointer] .= $this->get_bar(($start - $start_pointer) / $day_scale, $color, $link.$start_pointer, $start_tijd.' &raquo; '.$eind_tijd, $itemid, $cat);
  287. }
  288. else {
  289. $days[$weekday_pointer] .= $this->get_bar(($start - $start_pointer) / $day_scale, $tosmallchunkcolor, null, $start_tijd.' &raquo; '.$eind_tijd);
  290. }
  291. }
  292. else
  293. {
  294. $days[$weekday_pointer] .= $this->get_bar(($start - $start_pointer) / $day_scale, 'orange', null, $start_tijd.' &raquo; '.$eind_tijd);
  295. }
  296. }
  297. else
  298. {
  299. //controleren of dat tijd nu groter is dan de start van het gereserveerde stuk
  300. //Ja -> stuk voor de start oranje maken
  301. //Neen -> stuk voor de start oranje maken en wat er nog overblijft vr de $start blauw maken
  302. if (time() >= $start)
  303. {
  304. $days[$weekday_pointer] .= $this->get_bar(($start - $start_pointer) / $day_scale, 'orange', null, date('H:i', $start_pointer).' &raquo; '.date('H:i', $start));
  305. }
  306. else
  307. {
  308. //buiten tijd! -> stuk opdelen in een gedeelte buiten tijd en een gedeelte timepicker
  309. //oranje stuk
  310. $days[$weekday_pointer] .= $this->get_bar((time() - $start_pointer) / $day_scale, 'orange', null, date('H:i', $start_pointer).' &raquo; '.date('H:i', time()));
  311. if((Rsys :: mysql_datetime_to_timestamp($r['subscribe_from']) <= time() && Rsys :: mysql_datetime_to_timestamp($r['subscribe_until']) > time()) || ($r['subscribe_from'] == '0000-00-00 00:00:00' && $r['subscribe_until'] == '0000-00-00 00:00:00')) {
  312. //blauw stuk maken indien groter dan timepicker_min anders geel
  313. if (($start - time()) >= $timepicker_min)
  314. {
  315. $days[$weekday_pointer] .= $this->get_bar(($start - time()) / $day_scale, $color, $link.time(), date('H:i', time()).' &raquo; '.date('H:i', $start), $itemid, $cat);
  316. }
  317. else
  318. {
  319. $days[$weekday_pointer] .= $this->get_bar(($start - time()) / $day_scale, $tosmallchunkcolor, null, date('H:i', time()).' &raquo; '.date('H:i', $start), $itemid, $cat);
  320. }
  321. }
  322. else
  323. {
  324. $days[$weekday_pointer] .= $this->get_bar(($start - time()) / $day_scale, 'orange', null, date('H:i', time()).' &raquo; '.date('H:i', $start));
  325. }
  326. }
  327. }
  328. $start_tijd = date('H:i',$start);
  329. $eind_tijd = date('H:i',$einde);
  330. $days[$weekday_pointer] .= $this->get_bar(($einde - $start) / $day_scale, $pickedcolor, null, $start_tijd.' &raquo; '.$eind_tijd);
  331. }
  332. //print_r($days);
  333. $start_pointer = $einde;// + 1;
  334. }
  335. //indien er nog een stuk blauw moet gemaakt worden op het einde vd reservering
  336. if ($start_pointer < $end)
  337. {
  338. //controleren of dat tijd nu groter is dan de start van het gereserveerde stuk
  339. //Ja -> stuk voor de start oranje maken
  340. //Neen -> stuk voor de start oranje maken en wat er nog overblijft vr de $start blauw maken
  341. if (time() >= $end)
  342. {
  343. $days[$weekday_pointer] .= $this->get_bar(($end - $start_pointer) / $day_scale, 'orange', null, date('H:i', $start_pointer).' &raquo; '.date('H:i', $end));
  344. }
  345. else
  346. {
  347. if (time() >= $start_pointer)
  348. {
  349. //buiten tijd! -> stuk opdelen in een gedeelte buiten tijd en een gedeelte timepicker
  350. //oranje stuk
  351. $days[$weekday_pointer] .= $this->get_bar((time() - $start_pointer) / $day_scale, 'orange', null, date('H:i', $start_pointer).' &raquo; '.date('H:i', time()));
  352. if((Rsys :: mysql_datetime_to_timestamp($r['subscribe_from']) <= time() && Rsys :: mysql_datetime_to_timestamp($r['subscribe_until']) > time()) || ($r['subscribe_from'] == '0000-00-00 00:00:00' && $r['subscribe_until'] == '0000-00-00 00:00:00')) {
  353. //blauw stuk maken indien groter dan timepicker_min anders geel
  354. if (($end - time()) >= $timepicker_min)
  355. {
  356. //blauwe stuk
  357. $days[$weekday_pointer] .= $this->get_bar(($end - time()) / $day_scale, $color, $link.time(), date('H:i', time()).' &raquo; '.date('H:i', $end), $itemid, $cat);
  358. }
  359. else
  360. {
  361. //geel stuk
  362. $days[$weekday_pointer] .= $this->get_bar(($end - time()) / $day_scale, $tosmallchunkcolor, null, date('H:i', time()).' &raquo; '.date('H:i', $end));
  363. }
  364. }
  365. else
  366. {
  367. $days[$weekday_pointer] .= $this->get_bar(($end - time()) / $day_scale, 'orange', null, date('H:i', time()).' &raquo; '.date('H:i', $end));
  368. }
  369. }
  370. else
  371. {
  372. if((Rsys :: mysql_datetime_to_timestamp($r['subscribe_from']) <= time() && Rsys :: mysql_datetime_to_timestamp($r['subscribe_until']) > time()) || ($r['subscribe_from'] == '0000-00-00 00:00:00' && $r['subscribe_until'] == '0000-00-00 00:00:00')) {
  373. //blauw stuk maken indien groter dan timepicker_min anders geel
  374. if (($end - $start_pointer) >= $timepicker_min) {
  375. //blauwe stuk
  376. $days[$weekday_pointer] .= $this->get_bar(($end - $start_pointer) / $day_scale, $color, $link.$start_pointer, date('H:i', $start_pointer).' &raquo; '.date('H:i', $end), $itemid, $cat);
  377. }
  378. else {
  379. //gele stuk
  380. $days[$weekday_pointer] .= $this->get_bar(($end - $start_pointer) / $day_scale, $tosmallchunkcolor, null, date('H:i', $start_pointer).' &raquo; '.date('H:i', $end));
  381. }
  382. }
  383. else {
  384. $days[$weekday_pointer] .= $this->get_bar(($end - $start_pointer) / $day_scale, 'orange', null, date('H:i', $start_pointer).' &raquo; '.date('H:i', $end));
  385. }
  386. }
  387. }
  388. }
  389. }
  390. }
  391. // 6.5) Zet de $last_end pointer op de eindtijd van de huidige reservatie periode
  392. $last_end = $end;
  393. }// end if
  394. }
  395. // 7) loop through all days of the week and fill them with the contents of $days
  396. $firstcol = 120; // Width of first col (in pixels)
  397. $x=0;
  398. $borderstyle = "border-bottom: 1px solid #003;";
  399. echo '<table cellspacing="0" style="padding: 1px;width: '. (round($one_day / $day_scale) + $firstcol + $x).'px;border: 1px solid #003;border-bottom: 0"><tr><td style="'.$borderstyle.'width: '.$firstcol.'px;background-color: #069; ">&nbsp;</td><td style="'.$borderstyle.'background-color: #069; color: #FFF; white-space: nowrap; font-family: Arial, sans-serif; font-size:10px;width: '. (round($one_day / $day_scale) + $x).'px">';
  400. $vast = (3600 * 2) / $day_scale;
  401. $lasttotal=0;
  402. for ($i = 0; $i < 22; $i = $i +2) {
  403. $w=$vast;
  404. $total+=$w;
  405. $rounded_total=round($total);
  406. $w=$rounded_total-$lasttotal;
  407. echo '<div style="float:left; width: '. $w .'px">'.$i.'</div>';
  408. $lasttotal=$rounded_total;
  409. }
  410. echo '<div style="float:left;">22</div><div style="float: right">0</float>';
  411. echo '</td></tr>';
  412. for ($i = 1; $i <= 7; $i ++) {
  413. echo '<tr><td style="background-color: #069; color: #FFF; width:'.$firstcol.'px; font-family: Verdana, Arial, sans-serif; font-weight: bold;font-size:10px;'.$borderstyle.';cursor: help" title="'.date('d/m/Y',$day_start_dates[$i]).'">'.$this->get_long_day($i == 7 ? 0 : $i).'</td><td style="'.$borderstyle.' background-color: #CCC; width:'. (round($one_day / $day_scale) + $x).'px; white-space: nowrap;">';
  414. if (is_array($days) && array_key_exists($i, $days))
  415. echo $days[$i];
  416. else
  417. echo '&nbsp;';
  418. echo '</td></tr>'."\n";
  419. }
  420. echo '</table>';
  421. $GLOBALS['weekstart']=date('d/m/Y',$day_start_dates[1]);
  422. $GLOBALS['weekend']=date('d/m/Y',$day_start_dates[7]);
  423. }
  424. }