Source for file bookingdata.php
Documentation is available at bookingdata.php
* Obtains booking data from the database
* @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';
/** loads data into Booking objects */
require_once 'booking.php';
* Obtains booking data from the database
* Can be used either to find all bookings that are within a time period
* or to look for a specific booking id. Note that when using time periods
* to define the query, a booking is within the query time if *any* part of
* the booking period overlaps with *any* part of the query period.
* Can optionally exclude deleted bookings from the list.
/** @var string start of the query (SQL date-time string) */
/** @var string stop of the query (SQL date-time string) */
/** @var integer instrument id number of interest */
/** @var integer specific booking that is of interest */
/** @var array list of Booking objects returned for time period */
/** @var Booking single Booking object returned for id match */
/** @var boolean sql errors are fatal */
/** @var boolean include deleted bookings in listing */
* Obtain the booking listing within defined parameters
* @param array $arr data => value pairs where data can be
* start, stop, instrument, id
$this->start =
$start->dateTimeString();
$this->stop =
$stop->dateTimeString();
* Interrogate the database to get the bookings
* @global string prefix prepended to all table names in database
$q =
'SELECT bookings.id AS bookid,bookwhen,duration,'
.
'DATE_ADD(bookwhen, INTERVAL duration HOUR_SECOND) AS stoptime,'
.
'discount,log,comments,projectid,'
.
'users.username AS username, '
.
'users.email AS email, '
.
'users.phone AS phone, '
.
'bookedby AS masquserid, '
.
'masq.name AS masquser, '
.
'masq.username AS masqusername, '
.
'masq.email AS masqemail, '
.
'projects.name AS project, '
.
'instruments.name AS instrumentname, '
.
'instruments.longname AS instrumentdescription '
.
'FROM '.
$TABLEPREFIX.
'bookings AS bookings '
.
'LEFT JOIN '.
$TABLEPREFIX.
'users AS users ON '
.
'bookings.userid=users.id '
.
'LEFT JOIN '.
$TABLEPREFIX.
'users AS masq ON '
.
'bookings.bookedby=masq.id '
.
'LEFT JOIN '.
$TABLEPREFIX.
'projects AS projects ON '
.
'bookings.projectid=projects.id '
.
'LEFT JOIN '.
$TABLEPREFIX.
'instruments AS instruments ON '
.
'bookings.instrument=instruments.id '
$q .=
'bookings.id='.
qw($this->id);
$q .=
'bookings.userid<>0 AND ';
$q .=
'HAVING (bookwhen <= '.
qw($this->start).
' AND stoptime > '.
qw($this->start).
') '
.
'OR (bookwhen < '.
qw($this->stop).
' AND stoptime >= '.
qw($this->stop).
') '
.
'OR (bookwhen >= '.
qw($this->start).
' AND stoptime <= '.
qw($this->stop).
')'
* obtain the list of bookings
* @return array list of Booking objects
* @return Booking booking object
* Find the next booking already in the database
/** @var string start of the query (SQL date-time string) */
/** @var mixed instrument id number or list of ids of interest */
/** @var SimpleDate start of the next booking (null if none) */
/** @var boolean sql errors are fatal */
/** @var boolean include deleted bookings in listing */
* Obtain the booking listing within defined parameters
* @param SimpleDate $start start date for searching for the next booking
* @param mixed $instrument id for the instrument to check or list of ids
$this->start =
$s->dateTimeString();
* Interrogate the database to get the bookings
* @global string prefix prepended to all table names in database
$q =
'SELECT bookings.id AS bookid, '
.
'FROM '.
$TABLEPREFIX.
'bookings AS bookings '
.
'WHERE bookings.userid<>0 AND ';
$q .=
'AND bookwhen > '.
qw($this->start).
' '
Documentation generated on Tue, 06 Mar 2007 10:00:48 +0000 by phpDocumentor 1.3.0