rcalendar.php 24 KB

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