reservation.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php // $Id: reservation.php,v 1.34 2006/05/10 12:30:38 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. Copyright (c) Julio Montoya Armas
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  17. Mail: info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. ---------------------------------------------------------------------
  22. Reservation-manager (add, edit & delete)
  23. ---------------------------------------------------------------------
  24. */
  25. require_once('rsys.php');
  26. Rsys :: protect_script('reservation');
  27. $tool_name = get_lang('Booking');
  28. ///$interbreadcrumb[] = array ("url" => 'reservation.php', "name" => get_lang('Booking'));
  29. Display :: display_header($tool_name);
  30. api_display_tool_title($tool_name);
  31. echo '<div class="actions">';
  32. /// echo '<a href="m_reservation.php?action=add"><img src="../img/view_more_stats.gif" border="0" alt="" title="'.get_lang('AddNewBookingPeriod').'"/>'.get_lang('AddNewBookingPeriod').'</a>';
  33. //echo '&nbsp;&nbsp;&nbsp;<a href="m_reservation.php?action=overviewsubscriptions">'.get_lang('OverviewReservedPeriods').'</a>';
  34. echo '<div style="float: right;"><a href="mysubscriptions.php">'.Display::return_icon('file_txt.gif',get_lang('BookingListView'),array('width'=>'22')).'&nbsp;'.get_lang('GoToListView').'</a></div>';
  35. echo '<a href="m_item.php?view=calendar">'.Display::return_icon('cube.png',get_lang('Resources')).'&nbsp;'.get_lang('Resources').'</a>';
  36. echo '&nbsp;&nbsp;<a href="m_reservation.php?view=calendar">'.Display::return_icon('calendar_day.gif',get_lang('BookingPeriods')).'&nbsp;'.get_lang('BookingPeriods').'</a>';
  37. echo '&nbsp;&nbsp;<a href="m_reservation.php?action=add&view=calendar">'.Display::return_icon('calendar_add.gif',get_lang('BookIt')).'&nbsp;'.get_lang('BookIt').'</a>';
  38. if (api_is_platform_admin())
  39. {
  40. //echo '&nbsp;&nbsp;<a href="m_category.php">'.Display::return_icon('settings.gif',get_lang('Configuration')).'&nbsp;'.get_lang('Configuration').'</a>';
  41. }
  42. echo '</div><br />';
  43. function getBlock($color) {
  44. return '<img src="../img/px_'.$color.'.gif" alt="" style="border:1px solid #000;height: 10px;width: 10px;vertical-align:top;margin-left:10px" />';
  45. }
  46. $gogogo=false;
  47. // Get resolution of user
  48. if((empty($_SESSION['swidth'])||empty($_SESSION['sheight']))&&(empty($_GET['swidth'])||empty($_GET['sheight']))) {
  49. ?>
  50. <script type="text/javascript">
  51. window.location.href='reservation.php?sheight='+screen. height+'&swidth='+screen.width;
  52. </script>
  53. <?php
  54. }
  55. elseif((empty($_SESSION['swidth']))) {
  56. $_SESSION['swidth']=$_GET['swidth'];
  57. $_SESSION['sheight']=$_GET['sheight'];
  58. $gogogo=true;
  59. }
  60. else
  61. $gogogo=true;
  62. echo '<div style="float: left;"><form id="cat_form" action="reservation.php" method="get"><input type="hidden" name="cat" value="'.$_GET['cat'].'" /><div style="float: left;">'.get_lang('ResourceType').': <select name="cat" onchange="this.form.submit();"><option value="0">'.get_lang('Select').'</option>';
  63. $cats = Rsys :: get_category_with_items();
  64. if(count($cats)>0){
  65. foreach ($cats as $cat)
  66. echo '<option value="'.$cat['id'].'"'. ($cat['id'] == $_GET['cat'] ? ' selected="selected"' : '').'>'.$cat['name'].'</option>';
  67. }
  68. echo '</select></div></form></div>';
  69. if ($gogogo&&!empty($_GET['cat'])) {
  70. $itemlist = Rsys :: get_cat_items($_GET['cat']);
  71. echo '<div style="float: left;">';
  72. if (count($itemlist) != 0) {
  73. echo '<form id="item_form" action="reservation.php?cat='.$_GET['cat'].'&amp;item=" method="get">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="cat" value="'.$_GET['cat'].'" />'.get_lang('Resource').': <select name="item" onchange="this.form.submit();"><option value="0">'.get_lang('Select').'</option>';
  74. foreach ($itemlist as $id => $item)
  75. echo '<option value="'.$id.'"'. ($id == $_GET['item'] ? ' selected="selected"' : '').'>'.$item.'</option>';
  76. echo '</select></form>';
  77. }else{
  78. echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.get_lang('NoItemsReservation');
  79. }
  80. echo '</div>';
  81. if(!empty($_GET['item'])) {
  82. $calendar = new rCalendar();
  83. $time=Rsys::mysql_datetime_to_array($_GET['date'].' 00:00:00');
  84. ob_start();
  85. echo '<div style="float: left; margin-right: 10px">';
  86. if(isset($_GET['changemonth'])) {
  87. echo $calendar->get_mini_month(intval($time['month']),intval($time['year']),"&amp;cat=".$_GET['cat']."&amp;item=".$_GET['item']."&amp;changemonth=yes",$_GET['item']);
  88. }
  89. else
  90. echo $calendar->get_mini_month(date('m'),date('Y'),"&amp;cat=".$_GET['cat']."&amp;item=".$_GET['item'],$_GET['item']);
  91. echo '</div><div style="float: left" >';
  92. switch($_SESSION['swidth']) {
  93. case '640': $week_scale= 170;break;
  94. case '1024': $week_scale=130;break;
  95. case '1152': $week_scale=110;break;
  96. case '1280': $week_scale=94;break;
  97. case '1600': $week_scale=70;break;
  98. case '1792': $week_scale=60;break;
  99. case '1800': $week_scale=50;break;
  100. case '1920': $week_scale=40;break;
  101. case '2048': $week_scale=30;break;
  102. default: $week_scale= 150; // 800x600
  103. }
  104. if(isset($_GET['date'])){
  105. echo $calendar->get_week_view(intval($time['day']),intval($time['month']), $time['year'],$_GET['item'], $week_scale,$_GET['cat']);
  106. }else
  107. echo $calendar->get_week_view(intval(date('d')), intval(date('m')), intval(date('Y')), $_GET['item'], $week_scale,$_GET['cat']);
  108. echo '</div>';
  109. $buffer=ob_get_contents();
  110. ob_end_clean();
  111. $legend=getBlock('green').' '.ucfirst(get_lang('OpenBooking')).' '.getBlock('blue').' '.get_lang('TimePicker').' '.getBlock('orange').' '.get_lang('OutPeriod').' '.getBlock('red').' '.get_lang('Reserved').' '.getBlock('grey').' '.get_lang('NoReservations').' '.getBlock('black').' '.get_lang('Blackout');
  112. echo '<br /><br /><div style="text-align:right; border-bottom: 2px dotted #666; margin: 0 0 0.2em 0; padding: 0.2em;clear:both;font-family: Verdana,sans-serif;font-size: 1.2em;color:#666;font-weight:bold">'.$GLOBALS['weekstart'].' - '.$GLOBALS['weekend'].'</div>'.$buffer.'<div style="clear:both;">&nbsp;</div><div style="background-color:#EEE;padding: 0.5em;font-family:Verdana;sans-serif;font-size:10px;text-align:center">'.$legend.'</div>';
  113. }
  114. }
  115. Display :: display_footer();
  116. ?>