예제 #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
 /**
  * Get all reservation data
  * This function gets all reservation data
  * between a given start and end date
  * @param int $firstDate first date to return reservations from
  * @param int $lastDate last date to return reservations from
  * @param string $userid id of the user to look up reservations for
  * @param int $filterFirst the first date to filter allowed reservations for
  * @param int $filterLast the last date to filter allowed reservations for
  * @return array of reservation data formatted: $array[date][#] = array of data
  *  or an empty array
  */
 function get_all_reservations($firstDate, $lastDate, $userid, $filterFirst, $filterLast)
 {
     $return = array();
     // If it starts between the 2 dates, ends between the 2 dates, or surrounds the 2 dates, get it
     $sql = 'SELECT res.*, res_users.*, resources.name, resources.location, login.fname, login.lname FROM ' . $this->get_table('reservations') . ' as res' . ' INNER JOIN ' . $this->get_table('reservation_users') . ' as res_users ON res.resid=res_users.resid' . ' INNER JOIN ' . $this->get_table('resources') . ' as resources ON resources.machid=res.machid' . ' INNER JOIN ' . $this->get_table('login') . ' as login ON res_users.memberid = login.memberid' . ' WHERE ( ' . '( ' . '(start_date >= ? AND start_date <= ?)' . ' OR ' . '(end_date >= ? AND end_date <= ?)' . ' )' . ' OR ' . '(start_date <= ? AND end_date >= ?)' . ' )' . ' AND res.is_blackout <> 1' . ' AND res_users.memberid = ?' . ' AND res_users.invited <> 1';
     $sql .= ' ORDER BY res.start_date, res.starttime, res.end_date, res.endtime, resources.name';
     $values = array($firstDate, $lastDate, $firstDate, $lastDate, $firstDate, $lastDate, $userid);
     $p = $this->db->prepare($sql);
     $result = $this->db->execute($p, $values);
     $this->check_for_error($result);
     while ($rs = $result->fetchRow()) {
         $rs['start_date'] = Time::getAdjustedDate($rs['start_date'], $rs['starttime']);
         $rs['end_date'] = Time::getAdjustedDate($rs['end_date'], $rs['endtime']);
         if ($rs['end_date'] >= $filterFirst && $rs['start_date'] <= $filterLast) {
             $return[] = $rs;
         }
     }
     $result->free();
     return $return;
 }
예제 #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);
 }
예제 #4
0
/**
* Print out available times or current reservation's time
* This function will print out all available times to make
*  a reservation or will print out the selected reservation's time
*  (if this is a view).
* @param array $res resource data array
* @param object $rs reservation object
* @param bool $print_min_max bool whether to print the min_max cells
* @param bool $allow_multi bool if multiple day reseravtions are allowed
* @global $conf
*/
function print_time_info($res, $rs, $print_min_max = true, $allow_multi = false)
{
    global $conf;
    $type = $res->get_type();
    $interval = $res->sched['timespan'];
    $startDay = $res->sched['daystart'];
    $endDay = $res->sched['dayend'];
    ?>
    <table width="100%" border="0" cellspacing="0" cellpadding="1">
     <tr class="tableBorder">
      <td>
       <table width="100%" border="0" cellspacing="1" cellpadding="0">
        <tr>
         <td colspan="2" class="cellColor">
         <h5 align='left'>
<?php 
    // Print message depending on viewing type
    switch ($type) {
        case RES_TYPE_ADD:
            $msg = translate('Please select the starting and ending times');
            break;
        case RES_TYPE_MODIFY:
            $msg = translate('Please change the starting and ending times');
            break;
        default:
            $msg = translate('Reserved time');
            break;
    }
    if ((bool) $res->get_pending()) {
        $msg .= ' (' . translate('Pending Approval') . ')';
    }
    echo $msg;
    ?>
        </h5>
        </td>
       </tr>
	   <tr>
	   <td class="formNames"><?php 
    echo translate('Start');
    ?>
</td>
	   <td class="formNames"><?php 
    echo translate('End');
    ?>
</td>
	   </tr>
      <tr>
<?php 
    $start_date = $res->get_start_date();
    $end_date = $res->get_end_date();
    $display_start_date = Time::getAdjustedDate($res->get_start_date(), $res->get_start());
    $display_end_date = Time::getAdjustedDate($res->get_end_date(), $res->get_end());
    // Show reserved time or select boxes depending on type
    if ($type == RES_TYPE_ADD || $type == RES_TYPE_MODIFY || $type == RES_TYPE_APPROVE) {
        // Start time select box
        echo '<td class="formNames" width="50%"><div id="div_start_date" style="float:left;width:86px;">' . Time::formatDate($display_start_date, '', false) . '</div><input type="hidden" id="hdn_start_date" name="start_date" value="' . date('m' . INTERNAL_DATE_SEPERATOR . 'd' . INTERNAL_DATE_SEPERATOR . 'Y', $start_date) . '" onchange="checkCalendarDates();"/>';
        if ($allow_multi) {
            echo '<a href="javascript:void(0);"><img src="img/calendar.gif" border="0" id="img_start_date" alt="' . translate('Start') . '"/></a>' . '<br/><br/>';
        }
        echo "<select name=\"starttime\" class=\"textbox\">\n";
        // Start at startDay time, end 30 min before endDay
        for ($i = $startDay; $i < $endDay + $interval; $i += $interval) {
            echo '<option value="' . $i . '"';
            // If this is a modification, select corrent time
            if ($res->get_start() == $i) {
                echo ' selected="selected" ';
            }
            echo '>' . Time::formatTime($i) . '</option>';
        }
        echo "</select>\n</td>\n";
        // End time select box
        echo '<td class="formNames"><div id="div_end_date" style="float:left;width:86px;">' . Time::formatDate($display_end_date, '', false) . '</div><input type="hidden" id="hdn_end_date" name="end_date" value="' . date('m' . INTERNAL_DATE_SEPERATOR . 'd' . INTERNAL_DATE_SEPERATOR . 'Y', $end_date) . '" onchange="checkCalendarDates();"/>';
        if ($allow_multi) {
            echo '<a href="javascript:void(0);"><img src="img/calendar.gif" border="0" id="img_end_date" alt="' . translate('End') . '"/></a>' . '<br/><br/>';
        }
        echo "<select name=\"endtime\" class=\"textbox\">\n";
        // Start at 30 after startDay time, end 30 at endDay time
        for ($i = $startDay; $i < $endDay + $interval; $i += $interval) {
            echo "<option value=\"{$i}\"";
            // If this is a modification, select corrent time
            if ($res->get_end() == $i) {
                echo ' selected="selected" ';
            }
            echo '>' . Time::formatTime($i) . "</option>\n";
        }
        echo "</select>\n</td>\n";
        if ($print_min_max & !$allow_multi) {
            echo '</tr><tr class="noshow">' . '<td colspan="2">' . translate('Minimum Reservation Length') . ' ' . Time::minutes_to_hours($rs['minres']) . '</td></tr>' . '<tr class="noshow">' . '<td colspan="2">' . translate('Maximum Reservation Length') . ' ' . Time::minutes_to_hours($rs['maxres']) . '</td>';
        }
    } else {
        echo '<td class="formNames" width="50%"><div id="div_start_date" style="float:left;width:86px;">' . Time::formatDate($start_date, '', false) . '</div>' . Time::formatTime($res->get_start()) . "</td>\n" . '<td class="formNames"><div id="div_end_date" style="float:left;width:86px;">' . Time::formatDate($end_date, '', false) . '</div>' . Time::formatTime($res->get_end()) . "</td>\n";
    }
    // Close off table
    echo "</tr>\n</table>\n</td>\n</tr>\n</table>\n<p>&nbsp;</p>\n";
}