Skip to content

Commit

Permalink
Interface updates
Browse files Browse the repository at this point in the history
  • Loading branch information
steven1350 committed Feb 4, 2015
1 parent 2c3e132 commit b92eb64
Show file tree
Hide file tree
Showing 26 changed files with 336 additions and 107 deletions.
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
application/cache/*
application/logs/*
cache*
temp*
/application/cache/*
/application/logs/*
/cache/*
/temp/*
!/temp/README.txt
8 changes: 4 additions & 4 deletions application/controllers/booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ class Booking extends CI_Controller {
//$this->template->load(template, view, vars)
function Booking(){
parent::__construct();

//TEMP



//Check for existing login
if(!strlen($this->session->userdata('username')) > 0){
$this->session->set_flashdata('origin', current_url());
Expand Down Expand Up @@ -176,6 +173,8 @@ function submit(){
$this->email->message($email_content);
$this->email->attach('temp/'.$id.'.ics');
$this->email->send();
$this->booking_model->delete_ics($id);



$this->session->set_flashdata('success', "Booking Successfully Made");
Expand All @@ -193,4 +192,5 @@ function submit(){
redirect(base_url());
}
}

}
6 changes: 3 additions & 3 deletions application/libraries/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ function drawCalendar($month = null, $year = null, $selected_day = null) {
$rows = 1;

$output = "";
$output .= '<table class="table_calendar">';
$output .= '<tr><th class="month_year" colspan="7"><a style="float: left; font-size: 25px;" href="'. base_url() .'booking?month=' . date("Ym", strtotime("-1 month", $date)) .'">&lt;</a>&nbsp;&nbsp;'. date('F Y', $date) .'&nbsp;&nbsp;<a style="float:right; font-size: 25px;" href="'. base_url() .'booking?month=' . date("Ym", strtotime("+1 month", $date)) .'">&gt;</a></th></tr>';
$output .= "<tr><th>Su</th><th>Mo</th><th>Tu</th><th>We</th><th>Th</th><th>Fr</th><th>Sa</th></tr>";
$output .= '<table class="table_calendar" cellpadding="0">';
$output .= '<tr><th colspan="7"><div class="month_year" ><a class="month_arrow" style="float: left; " href="'. base_url() .'booking?month=' . date("Ym", strtotime("-1 month", $date)) .'"><img src="'.base_url().'assets/img/Book-Room-Icon5.png" width="50" alt="Previous Month" /></a>'. strtoupper(date('F Y', $date)) .'<a style="float:right;" class="month_arrow" href="'. base_url() .'booking?month=' . date("Ym", strtotime("+1 month", $date)) .'"><img src="'.base_url().'assets/img/Book-Room-Icon4.png" width="50" alt="Next Month" /></a></div></th></tr>';
$output .= "<tr><th>SUN</th><th>MON</th><th>TUE</th><th>WED</th><th>THU</th><th>FRI</th><th>SAT</th></tr>";
$output .= "<tr>";

for($i = 1; $i <= $offset; $i++){
Expand Down
16 changes: 16 additions & 0 deletions application/models/booking_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,17 @@ function is_allowed($room_id){

function book_room($room_id, $start, $end, $comment){
//Make sure the slot is not already booked!
$this->db->cache_off();

$sql = "SELECT * FROM bookings WHERE
start >= '". date('Y-m-d H:i:s', $start)."'
and end <= '". date('Y-m-d H:i:s', $end)."'
and room_id = $room_id";

$existing_bookings = $this->db->query($sql);

$this->db->cache_on();

if($existing_bookings->num_rows() == 0){
$data = array(
'room_id' => $room_id,
Expand Down Expand Up @@ -281,15 +285,27 @@ function set_block_booking_rooms($rooms, $bb_id){
}

function generate_ics($booking_id){
$this->load->model('room_model');

$this->db->where('booking_id', $booking_id);
$booking_data = $this->db->get('bookings')->row();

$room_result = $this->room_model->load_room($booking_data->room_id);
$room = $room_result['room_data']->row();

$data = array(
'start' => strtotime($booking_data->start),
'end' => strtotime($booking_data->end),
'room' => $room->name,
'booking_id' => $booking_id,
);

$ics_content = $this->load->view('email/booking_ics',$data, TRUE);
file_put_contents('temp/'.$booking_id.'.ics', $ics_content);
}

function delete_ics($booking_id){
@unlink('temp/'.$booking_id.'.ics');
return;
}
}
113 changes: 67 additions & 46 deletions application/views/booking/booking_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,56 @@
<?php if($this->session->flashdata('success') !== FALSE): ?><div class="alert alert-success" role="alert"><?php echo $this->session->flashdata('success'); ?></div><?php endif; ?>
<?php if($this->session->flashdata('danger') !== FALSE): ?><div class="alert alert-danger" role="alert"><?php echo $this->session->flashdata('danger'); ?></div><?php endif; ?>

<div class="calendar_container">
<?php
echo $calendar;
?>
</div>
<div class="center"><a href="<?php echo base_url() . 'booking?month=' . date('Ym') . '&date=' . date('Ymd')?>" id="showtoday">SHOW TODAY</a></div>

<?php if($this->input->get('date') !== FALSE): ?>

<div class="center"><a href="#" id="filter_link">Filter</a>
<div id="filter_container">
<!-- Disable autocomplete to prevent the browser from leaving boxes checked/unchecked on refresh -->
<form autocomplete="off">
<?php foreach($resources_filter->result() as $resource): ?>
<div class="checkbox">
<label>
<input type="checkbox" class="resource_checkbox filter_checkbox" value="<?php echo $resource->resource_id ?>">
<?php echo $resource->name; ?>
</label>
<div id="top_content">
<div id="top_left">
<div id="app_links">
<ul>
<li><a class="selected" href="#">Dashboard</a></li>
<li><a href="#">MAIN PAGE</a></li>
<li><a href="#">MY BOOKINGS</a></li>
<li><a href="<?php echo base_url(); ?>logout">LOG OUT</a></li>
</ul>
</div>
<?php endforeach; ?>

<?php foreach($buildings->result() as $building): ?>
<div class="checkbox">
<label>
<input type="checkbox" class="building_checkbox filter_checkbox" value="<?php echo $building->building_id ?>">
<?php echo $building->name; ?>
</label>
<div id="lower_left_content">
<div class="center" id="filter_link_title">Specify your Search<a href="#" id="filter_link">+</a>
<div id="filter_container">
<!-- Disable autocomplete to prevent the browser from leaving boxes checked/unchecked on refresh -->
<form autocomplete="off">
<?php foreach($resources_filter->result() as $resource): ?>
<div class="checkbox">
<label>
<input type="checkbox" class="resource_checkbox filter_checkbox" value="<?php echo $resource->resource_id ?>">
<?php echo $resource->name; ?>
</label>
</div>
<?php endforeach; ?>

<?php foreach($buildings->result() as $building): ?>
<div class="checkbox">
<label>
<input type="checkbox" class="building_checkbox filter_checkbox" value="<?php echo $building->building_id ?>">
<?php echo $building->name; ?>
</label>
</div>
<?php endforeach; ?>
</form>

</div>
</div>
</div>
<?php endforeach; ?>
</form>
</div>

<div class="calendar_container">
<?php
echo $calendar;
?>
</div>
</div>

<?php if($this->input->get('date') !== FALSE): ?>


<div style="clear:both"></div>


Expand All @@ -84,21 +100,21 @@
if(isset($rooms[$role->role_id])):
?>

<h4><?php echo $role->name; ?></h4>


<?php if($hours['min'] == 2 || $hours['max'] == -1): ?>
<h4><?php echo $role->name; ?></h4>
<div class="alert alert-warning" role="alert">All rooms are closed!</div>
<?php else: ?>

<div class="role_title"><?php echo $role->name; ?><span class="role_title_collapse"><a href="#">+</a></span></div>
<div class="table-wrapper">



<table class="" style="width: 100%;">
<table class="booking_table" style="width: 100%; border-collapse: initial;" cellspacing="0">
<thead>

<?php
//Create the top row listing the times as table headers
echo '<tr><th>&nbsp;</th>';
echo '<tr><th><div class="table_cell_height">&nbsp;</div></th>';

$tStart = mktime(0,0,0) + (($hours['min'] * 24) * 60 * 60);

Expand All @@ -110,7 +126,7 @@
$tNow = $tStart;

while($tNow <= $tEnd){
echo '<th>'.date("g:iA",$tNow).'</th>';
echo '<th><div class="table_cell_height">'.date("g:iA",$tNow).'</div></th>';
$tNow += 60 * 30; //30 MINUTES (60 seconds * 30)
}

Expand All @@ -130,7 +146,7 @@
else{
$seats = "1 seat";
}
echo '<tr data-buildingid="'.$room->building_id.'" data-seats="'.$room->seats.'" class="room_row"><th class="room_name">'.$room->name .' ('.$seats.') <div class="room_resources">';
echo '<tr data-buildingid="'.$room->building_id.'" data-seats="'.$room->seats.'" class="room_row"><th class="room_name"><div class="table_cell_height">'.$room->name .' &bull; '.$seats.'</div><div class="room_resources">';

foreach($resources[$room->room_id]->result() as $resource){
echo '<span class="resource_element" data-resourceid="'.$resource->resource_id.'">'.$resource->name . '</span>';
Expand All @@ -144,7 +160,7 @@
$numSlots = ceil(((($hours['max'] - $hours['min']) * 24) * 60) / 30) + 1;

//Output the placeholder
echo '<td colspan="'. $numSlots .'" class="closed booking_cell">Closed</td>';
echo '<td colspan="'. $numSlots .'" class="closed booking_cell"><div class="table_cell_height">Closed</div></td>';

$tStart = mktime(0,0,0, $date_raw['month'], $date_raw['day'], $date_raw['year']) + (($hours['min'] * 24) * 60 * 60); //Start the "closed" slot at the earliest time
}
Expand All @@ -153,7 +169,7 @@
$numSlots = ceil(((($hours[$room->external_id]->STARTTIME - $hours['min']) * 24) * 60) / 30);

//Output the placeholder
echo '<td colspan="'. $numSlots .'" class="closed booking_cell">Closed</td>';
echo '<td colspan="'. $numSlots .'" class="closed booking_cell"><div class="table_cell_height">Closed</div></td>';

//Adjust the starting time to be offset
$tStart = mktime(0,0,0,$date_raw['month'], $date_raw['day'], $date_raw['year']) + (($hours[$room->external_id]->STARTTIME * 24) * 60 * 60);
Expand All @@ -176,10 +192,12 @@
if(strtotime($block_booking['start']) < $tStart){
$block_booking['start'] = date('Y-m-d H:i:s', $tStart);
}

//Since we bumped the start time forward, make sure it didn't pass the end time. If it did, ignore the block booking (since the booking started/ended during closed hours)
if($block_booking['end'] > $block_booking['start']){

if(array_key_exists($room->room_id, $block_booking['room']) && strtotime($block_booking['start']) == $tNow){

$bbStart = strtotime($block_booking['start']);
$bbEnd = strtotime($block_booking['end']);

Expand All @@ -199,7 +217,7 @@
$end_row = true;
}

echo '<td class="closed booking_cell" colspan="'.$colspan.'">'.$block_booking['reason'].'</td>';
echo '<td class="closed booking_cell" colspan="'.$colspan.'"><div class="table_cell_height">'.$block_booking['reason'].'</div></td>';

break;
}
Expand All @@ -219,11 +237,14 @@
$booker_name = $bookings[$room->room_id][$tNow]->booker_name;

//If this is your booking, or you are admin, show who booked it
if($booker_username == $this->session->userdata('username') || $this->session->userdata('super_admin') == TRUE){
echo '<td colspan="'.($diff/30) .'" class="booked_cell booking_cell">'.$booker_name.'</td>';
if($booker_username == $this->session->userdata('username') ){
echo '<td colspan="'.($diff/30) .'" class="my_booked_cell booking_cell"><div class="table_cell_height">'.$booker_name.'</div></td>';
}
else if($this->session->userdata('super_admin') == TRUE){
echo '<td colspan="'.($diff/30) .'" class="booked_cell booking_cell"><div class="table_cell_height">'.$booker_name.'</div></td>';
}
else{
echo '<td colspan="'.($diff/30) .'" class="booked_cell booking_cell">Booked</td>';
echo '<td colspan="'.($diff/30) .'" class="booked_cell booking_cell"><div class="table_cell_height">Booked</div></td>';
}
$tNow += 60 * $diff ; //Add "diff" minutes

Expand All @@ -237,10 +258,10 @@

//Check to see if the date is in the past, or too far in the future
if(time() > $tNow){
echo '<td class="not_avail booking_cell">'.date("g:iA",$tNow).'</td>';
echo '<td class="not_avail booking_cell"><div class="table_cell_height">'.date("g:iA",$tNow).'</div></td>';
}
else{
echo '<td class="room_free booking_cell"><a class="" href="'. base_url() . 'booking/book_room?' . $uri . '">'.date("g:iA",$tNow).'</a></td>';
echo '<td class="room_free booking_cell"><div class="table_cell_height"><a class="" href="'. base_url() . 'booking/book_room?' . $uri . '">'.date("g:iA",$tNow).'</a></div></td>';
}

$tNow += 60 * 30; //Add 30 minutes
Expand All @@ -254,7 +275,7 @@
$numSlots = ceil(((($hours['max'] - $hours[$room->external_id]->ENDTIME) * 24) * 60) / 30);

//Output the placeholder
echo '<td colspan="'. $numSlots .'" class="closed booking_cell">Closed</td>';
echo '<td colspan="'. $numSlots .'" class="closed booking_cell"><div class="table_cell_height">Closed</div></td>';
}

echo '</tr>';
Expand Down
15 changes: 15 additions & 0 deletions application/views/denied.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php ob_start();?>

<?php $head = ob_get_contents();ob_end_clean();$this->template->set('headers', $head);?>

<?php ob_start();?>

<h3 style="text-align: center; font-weight: bold; margin-bottom: 1em;">Ryerson University Libray Room Booking</h3>
<span style="text-align: center">
<p>You do not have access to the Library Room Booking System</p>

<p>If you believe you have reached this page in error, please contact <a href="mailto:<?php echo SITE_ADMIN; ?>"><?php echo SITE_ADMIN; ?></a></p>

<p><a href="<?php echo base_url(); ?>logout">Logout</a></p>
</span>
<?php $content = ob_get_contents();ob_end_clean();$this->template->set('content', $content);?>
12 changes: 6 additions & 6 deletions application/views/email/booking_ics.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
VERSION:2.0
PRODID:-//Ryerson University Library//NONSGML v1.0//EN
BEGIN:VEVENT
UID:<?php echo $this->session->userdata('username').EMAIL_SUFFIX; ?>
DTSTAMP:<?php echo date('Ymd\THis\ZO', $start); ?>
DTSTART:<?php echo date('Ymd\THis\ZO', $start); ?>
DTEND:<?php echo date('Ymd\THis\ZO', $end); ?>
SUMMARY: Library Room Booking
LOCATION: TST100
UID:<?php echo $this->session->userdata('username').EMAIL_SUFFIX. ":". $booking_id. "\n"; ?>
DTSTAMP:<?php echo date('Ymd\THis\ZO', $start). "\n"; ?>
DTSTART:<?php echo date('Ymd\THis\ZO', $start). "\n"; ?>
DTEND:<?php echo date('Ymd\THis\ZO', $end). "\n"; ?>
SUMMARY: Library Room Booking
LOCATION: <?php echo $room. "\n"; ?>
END:VEVENT
END:VCALENDAR
Loading

0 comments on commit b92eb64

Please sign in to comment.