Source for file matrix.php
Documentation is available at matrix.php
* Booking matrix object for display in a table
* @author Stuart Prescott
* @copyright Copyright Stuart Prescott
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
/** Load ancillary functions */
require_once 'inc/typeinfo.php';
* Booking matrix object for display in a table
* @todo //TODO: documentation
function BookingMatrix($dayStart, $dayStop, $granularity, &$bookings) {
#echo "Preparing matrix with $this->numRows rows for date "
#.$this->day->dateString()."<br/>\n";
// keep track of where we got up to in the calculations (reduces O(n2) to O(n))
// provides 25% performance boost to this function
// foreach is much more expensive than for and since this function is called repeatedly,
// it's best not to do that. (function is 20% faster from this change)
//foreach ($this->bookings as $booknum => $b) {
for ($booknum =
$startnum; $booknum <
$numBookings; $booknum++
) {
#echo "Booking $k, ".$b->start->dateTimeString()." - ".$b->stop->dateTimeString()."<br />";
// the TimeSlot object will cache the dayStart and dayStop calculations.
// (function is 50% faster with this change)
$bookDay =
clone($this->bookings[$booknum]->dayStart());
$bookStopDay =
clone($this->bookings[$booknum]->dayStop());
#echo "Checking eligibility for booking: ".$this->day->ticks .'='.$bookDay->ticks.'||'.$bookStopDay->ticks.'<br />';
if ($bookDay->ticks ==
$this->day->ticks) {
$bookDayStart =
clone($bookDay);
$mystart =
clone( isset
($b->displayStart) ?
$b->displayStart :
$b->start );
$mystop =
clone( isset
($b->displayStop) ?
$b->displayStop :
$b->stop );
$bookDayStart->setTime($this->dayStart);
//$starttime = $b->start->subtract($bookDayStart);
$starttime =
$mystart->subtract($bookDayStart);
//then the start of the booking is after the start time of the matrix
//the booking starts before the matrix; starting row adjusted
$bookDayStop =
clone($bookDay);
$bookDayStop->setTime($this->dayStop);
//$stoptime = $b->stop->subtract($bookDayStop);
$stoptime =
$mystop->subtract($bookDayStop);
//the stop time is before the stop time of the matrix
//$stoptimestart = $b->stop->subtract($bookDayStart);
$stoptimestart =
$mystop->subtract($bookDayStart);
//the stop time is after the stop time of the matrix,
$rowspan =
round($rowstop -
$rowstart);
// Only add the cell to the matrix if the cell doesn't already have an entry in it.
// Otherwise, the second part of a booking that is split across multiple slots would
// overwrite the earlier part.
if (! isset
($this->rows[$rowstart]) &&
$rowspan >
0) {
$this->rows[$rowstart] =
$cell;
// since the list of bookings should be in date order, once we get a negative match
Documentation generated on Tue, 06 Mar 2007 10:01:45 +0000 by phpDocumentor 1.3.0