reservation.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. Reservation-manager (add, edit & delete)
  5. */
  6. require_once('rsys.php');
  7. Rsys :: protect_script('reservation');
  8. $tool_name = get_lang('Booking');
  9. ///$interbreadcrumb[] = array ("url" => 'reservation.php', "name" => get_lang('Booking'));
  10. Display :: display_header($tool_name);
  11. api_display_tool_title($tool_name);
  12. if (isset($_GET['cat'])) {
  13. $category_id = Security::remove_XSS($_GET['cat']);
  14. }
  15. echo '<div class="actions">';
  16. /// 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>';
  17. //echo '&nbsp;&nbsp;&nbsp;<a href="m_reservation.php?action=overviewsubscriptions">'.get_lang('OverviewReservedPeriods').'</a>';
  18. echo '<div style="float: right;"><a href="mysubscriptions.php">'.Display::return_icon('file_txt.gif',get_lang('BookingListView'),array('width'=>ICON_SIZE_SMALL)).'&nbsp;'.get_lang('GoToListView').'</a></div>';
  19. echo '<a href="m_item.php?view=calendar">'.Display::return_icon('cube.png',get_lang('Resources')).'&nbsp;'.get_lang('Resources').'</a>';
  20. echo '&nbsp;&nbsp;<a href="m_reservation.php?view=calendar">'.Display::return_icon('calendar_day.gif',get_lang('BookingPeriods')).'&nbsp;'.get_lang('BookingPeriods').'</a>';
  21. 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>';
  22. if (api_is_platform_admin())
  23. {
  24. //echo '&nbsp;&nbsp;<a href="m_category.php">'.Display::return_icon('settings.gif',get_lang('Configuration')).'&nbsp;'.get_lang('Configuration').'</a>';
  25. }
  26. echo '</div><br />';
  27. function getBlock($color) {
  28. return '<img src="../img/px_'.$color.'.gif" alt="" style="border:1px solid #000;height: 10px;width: 10px;vertical-align:top;margin-left:10px" />';
  29. }
  30. $gogogo=false;
  31. // Get resolution of user
  32. if((empty($_SESSION['swidth'])||empty($_SESSION['sheight']))&&(empty($_GET['swidth'])||empty($_GET['sheight']))) {
  33. ?>
  34. <script type="text/javascript">
  35. window.location.href='reservation.php?sheight='+screen. height+'&swidth='+screen.width;
  36. </script>
  37. <?php
  38. }
  39. elseif((empty($_SESSION['swidth']))) {
  40. $_SESSION['swidth']=$_GET['swidth'];
  41. $_SESSION['sheight']=$_GET['sheight'];
  42. $gogogo=true;
  43. }
  44. else
  45. $gogogo=true;
  46. echo '<div style="float: left;"><form id="cat_form" action="reservation.php" method="get"><input type="hidden" name="cat" value="'.$category_id.'" /><div style="float: left;">'.get_lang('ResourceType').': <select name="cat" onchange="this.form.submit();"><option value="0">'.get_lang('Select').'</option>';
  47. $cats = Rsys :: get_category_with_items();
  48. if(count($cats)>0){
  49. foreach ($cats as $cat)
  50. echo '<option value="'.$cat['id'].'"'. ($cat['id'] == $category_id ? ' selected="selected"' : '').'>'.$cat['name'].'</option>';
  51. }
  52. echo '</select></div></form></div>';
  53. if ($gogogo&&!empty($category_id)) {
  54. $itemlist = Rsys :: get_cat_items($category_id);
  55. echo '<div style="float: left;">';
  56. if (count($itemlist) != 0) {
  57. echo '<form id="item_form" action="reservation.php?cat='.$category_id.'&amp;item=" method="get">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="cat" value="'.$category_id.'" />'.get_lang('Resource').': <select name="item" onchange="this.form.submit();"><option value="0">'.get_lang('Select').'</option>';
  58. foreach ($itemlist as $id => $item)
  59. echo '<option value="'.$id.'"'. ($id == $_GET['item'] ? ' selected="selected"' : '').'>'.$item.'</option>';
  60. echo '</select></form>';
  61. }else{
  62. echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.get_lang('NoItemsReservation');
  63. }
  64. echo '</div>';
  65. if(!empty($_GET['item'])) {
  66. $calendar = new rCalendar();
  67. $time=Rsys::mysql_datetime_to_array($_GET['date'].' 00:00:00');
  68. ob_start();
  69. echo '<div style="float: left; margin-right: 10px">';
  70. if(isset($_GET['changemonth'])) {
  71. echo $calendar->get_mini_month(intval($time['month']),intval($time['year']),"&amp;cat=".$category_id."&amp;item=".$_GET['item']."&amp;changemonth=yes",$_GET['item']);
  72. }
  73. else
  74. echo $calendar->get_mini_month(date('m'),date('Y'),"&amp;cat=".$category_id."&amp;item=".$_GET['item'],$_GET['item']);
  75. echo '</div><div style="float: left" >';
  76. switch($_SESSION['swidth']) {
  77. case '640': $week_scale= 170;break;
  78. case '1024': $week_scale=130;break;
  79. case '1152': $week_scale=110;break;
  80. case '1280': $week_scale=94;break;
  81. case '1600': $week_scale=70;break;
  82. case '1792': $week_scale=60;break;
  83. case '1800': $week_scale=50;break;
  84. case '1920': $week_scale=40;break;
  85. case '2048': $week_scale=30;break;
  86. default: $week_scale= 150; // 800x600
  87. }
  88. if(isset($_GET['date'])){
  89. echo $calendar->get_week_view(intval($time['day']),intval($time['month']), $time['year'],$_GET['item'], $week_scale,$category_id);
  90. }else
  91. echo $calendar->get_week_view(intval(date('d')), intval(date('m')), intval(date('Y')), $_GET['item'], $week_scale,$category_id);
  92. echo '</div>';
  93. $buffer=ob_get_contents();
  94. ob_end_clean();
  95. $legend=getBlock('green').' '.api_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');
  96. 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>';
  97. }
  98. }
  99. Display :: display_footer();
  100. ?>