예제 #1
0
 function formatSettings()
 {
     $builder = new StringBuilder();
     $builder->append("UID:{$this->_reservation->id}\r\n");
     $adjusted = Time::getAdjustedTime(mktime());
     $builder->append(sprintf("DTSTAMP:%sT%sZ\r\n", date('Ymd', $adjusted), date('His', $adjusted)));
     $adjusted_start = Time::getAdjustedMinutes($this->_reservation->start);
     $builder->append(sprintf("DTSTART:%sT%s%s00Z\r\n", date('Ymd', Time::getAdjustedDate($this->_reservation->start_date, $this->_reservation->start)), Time::getHours($adjusted_start), Time::getMinutes($adjusted_start)));
     $adjusted_end = Time::getAdjustedMinutes($this->_reservation->end);
     $builder->append(sprintf("DTEND:%sT%s%s00Z\r\n", date('Ymd', Time::getAdjustedDate($this->_reservation->end_date, $this->_reservation->end)), Time::getHours($adjusted_end), Time::getMinutes($adjusted_end)));
     $adjusted = Time::getAdjustedTime($this->_reservation->created);
     $builder->append(sprintf("CREATED:%sT%sZ\r\n", date('Ymd', $adjusted), date('His', $adjusted)));
     if (!empty($this->_reservation->modified)) {
         $adjusted = Time::getAdjustedTime($this->_reservation->modified);
         $builder->append(sprintf("LAST-MODIFIED:%sT%sZ\r\n", date('Ymd', $adjusted), date('His', $adjusted)));
     }
     return $builder->toString();
 }
예제 #2
0
/**
* Prints all reservations for a given day
* @param array $reservations array of all reservation data for this day
* @param int $datestamp the unix datestamp for the first day shown
* @param int $days number of days to print out
* @param int $start_time starting time of the day for this reservation's schedule
* @param int $end_time ending time of the day for this reservation's schedule
* @param int $time_span the time span interval for this reservation's schedule
* @param string $resource_name the name of this resource
* @param bool $is_private if we are in privacy mode and should hide user details
*/
function print_signup_sheet($reservations, $datestamp, $days, $start_time, $end_time, $time_span, $resource_name, $is_private = false)
{
    echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"background-color:#ffffff;\">\n<table border=\"1\" bordercolor=\"#000000\" width=\"100%\" cellspacing=\"1\" cellpadding=\"3\">\n";
    $date_vars = getdate($datestamp);
    $col_width = intval(100 / $days);
    $hour_line = array();
    $date_cells_taken = array();
    $datestamps = array();
    // This will store the datestamp for each date on the calendar
    // Print out a date header for each date in the calendar view
    echo '<tr><td>&nbsp;</td>';
    for ($day_count = 0; $day_count < $days; $day_count++) {
        $datestamps[$day_count] = mktime(0, 0, 0, $date_vars['mon'], $date_vars['mday'] + $day_count, $date_vars['year']);
        echo '<td width="' . $col_width . '%" align="center"><b>' . $resource_name . '</b><br/>' . translate_date('schedule_daily', $datestamps[$day_count]) . '</td>';
    }
    echo "</tr>\n";
    for ($i = 0; $i < count($reservations); $i++) {
        $reservations[$i]['starttime'] = Time::getAdjustedMinutes($reservations[$i]['starttime']);
        $reservations[$i]['endtime'] = Time::getAdjustedMinutes($reservations[$i]['endtime']);
        // If the reservation starts on a day other than the first day shown then just show it at the start time of the first day
        $day = $reservations[$i]['start_date'] >= $datestamp ? ($reservations[$i]['start_date'] - $datestamp) / SECONDS_IN_DAY : 0;
        // This will tell how many days ahead of the first day this reservation occurs
        // If the reseravtion ends on a day further from the last day shown, then make the endday equal to the last day
        $endday = $reservations[$i]['end_date'] <= $datestamps[$days - 1] ? ($reservations[$i]['end_date'] - $datestamp) / SECONDS_IN_DAY : $days - 1;
        // This will tell how many days ahead of the first day this reservation occurs
        // Get temporary start and end times for dates that are off the viewable days
        $starttime = $reservations[$i]['start_date'] >= $datestamp ? $reservations[$i]['starttime'] : $start_time;
        $endtime = $reservations[$i]['end_date'] <= $datestamps[$days - 1] ? $reservations[$i]['endtime'] : $end_time;
        $hour_line[$starttime][$day] =& $reservations[$i];
        // If this is a multi day reservation, make sure we populate the $hour_line of the last day/time for this reservation
        if ($day != $endday) {
            for ($d = $day + 1; $d <= $endday; $d++) {
                $hour_line[$start_time][$d] =& $reservations[$i];
            }
        }
        // Keep an array of the cells that are taken by the rowspan of another reservation
        if ($day != $endday) {
            // MULTIDAY
            for ($d = $day; $d <= $endday; $d++) {
                if ($d == $day) {
                    for ($time = $starttime; $time < $end_time; $time += $time_span) {
                        $date_cells_taken[$d][$time] = 1;
                    }
                } else {
                    if ($d == $endday) {
                        for ($time = $start_time; $time < $endtime; $time += $time_span) {
                            $date_cells_taken[$d][$time] = 1;
                        }
                    } else {
                        for ($time = $start_time; $time < $end_time; $time += $time_span) {
                            $date_cells_taken[$d][$time] = 1;
                        }
                    }
                }
            }
        } else {
            // SINGLE DAY
            for ($time = $starttime; $time < $endtime; $time += $time_span) {
                $date_cells_taken[$day][$time] = 1;
            }
        }
    }
    // The reservation data is stored in a 2D array of time (x axis) and date (y axis)
    // This simply loops through all time/date possibilities and prints out the reservation data for each cell
    for ($time = $start_time; $time < $end_time; $time += $time_span) {
        echo '<tr><td valign="top">' . Time::formatTime($time, false) . '</td>';
        for ($date = 0; $date < $days; $date++) {
            if (isset($hour_line[$time][$date])) {
                $res = $hour_line[$time][$date];
                if ($is_private) {
                    $res['fname'] = 'Private';
                    $res['lname'] = '';
                }
                $starttime = $res['starttime'];
                $endtime = $res['endtime'];
                // Set temporary start/end times for multiday reservations so that the rowspan is correct
                if ($res['start_date'] != $res['end_date']) {
                    if ($res['start_date'] == $datestamps[$date]) {
                        $endtime = $end_time;
                    } else {
                        $starttime = $start_time;
                    }
                }
                $rowspan = intval(($endtime - $starttime) / $time_span);
                echo "<td valign=\"top\" rowspan=\"{$rowspan}\" class=\"\">&#8226; ";
                echo "{$res['fname']} {$res['lname']}";
                if (!empty($res['parentid'])) {
                    echo ' <img src="img/recurring.gif" width="15" height="15" alt="' . translate('Recurring') . '" title="' . translate('Recurring') . '"/>';
                }
                if ($res['start_date'] != $res['end_date']) {
                    echo ' <img src="img/multiday.gif" width="8" height="9" alt="' . translate('Multiple Day') . '" title="' . translate('Multiple Day') . '"/>';
                }
                echo '</td>';
            } else {
                if (!isset($date_cells_taken[$date][$time])) {
                    echo '<td valign="top">&nbsp;</td>';
                    // There is no reservation for this time, print out an empty cell
                }
            }
        }
        echo "</tr>\n";
        // End the time row
    }
    echo "</table>\n</td></tr><table>\n";
}
예제 #3
0
 /**
  * Gets the user selected time and converts it into the server stored timezone
  * @param int $datestamp the datestamp to adjust
  * @param int $minutes number of minutes past midnight
  */
 function getServerTime($datestamp, $minutes = null)
 {
     if (Time::getHourOffset() == 0) {
         $date = $datestamp;
         $time = $minutes;
     } else {
         $date = Time::getAdjustedDate($datestamp, $minutes, true);
         $time = Time::getAdjustedMinutes($minutes, true);
     }
     return new ReservationTime($date, $time);
 }