I altered the database by adding two extra fields (startplace and destination)
CREATE TABLE `reservations` (
`resid` varchar(16) NOT NULL default '',
`machid` varchar(16) NOT NULL default '',
`scheduleid` varchar(16) NOT NULL default '',
`start_date` int(11) NOT NULL default '0',
`end_date` int(11) NOT NULL default '0',
`starttime` int(11) NOT NULL,
`endtime` int(11) NOT NULL,
`created` int(11) NOT NULL default '0',
`modified` int(11) default NULL,
`parentid` varchar(16) default NULL,
`startplace` text,
`destination` text,
`summary` text,
`is_blackout` smallint(1) NOT NULL default '0',
`is_pending` smallint(1) NOT NULL default '0',
`allow_participation` smallint(6) NOT NULL default '0',
`allow_anon_participation` smallint(6) NOT NULL default '0',
PRIMARY KEY (`resid`),
KEY `res_resid` (`resid`),
KEY `res_machid` (`machid`),
KEY `res_startTime` (`starttime`),
KEY `res_endTime` (`endtime`),
KEY `res_created` (`created`),
KEY `res_modified` (`modified`),
KEY `res_isblackout` (`is_blackout`),
KEY `res_scheduleid` (`scheduleid`),
KEY `reservations_ispending` (`is_pending`),
KEY `reservations_startdate` (`start_date`),
KEY `reservations_enddate` (`end_date`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
And in ResDB.class.php I have:
function add_res($res, $is_parent, $users_to_invite, $resources_to_add, $accept_code) {
$id = $this->get_new_id();
// Insert the main reservation data
$values = array (
$id,
$res->get_machid(),
$res->get_scheduleid(),
$res->get_start_date(),
$res->get_end_date(),
$res->get_start(),
$res->get_end(),
mktime(),
null,
($is_parent ? $id : $res->get_parentid()),
intval($res->is_blackout),
$res->get_pending(),
$res->get_startplace(),
$res->get_destination(),
$res->get_summary(),
$res->get_allow_participation(),
$res->get_allow_anon_participation()
);
$query = 'INSERT INTO ' . $this->get_table(TBL_RESERVATIONS) . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
$q = $this->db->prepare($query);
$result = $this->db->execute($q, $values);
$this->check_for_error($result);
// Insert the user participation data
$values = null;
$values[] = array($id, $res->get_memberid(), 1, 0, 1, 1, null);
foreach ($users_to_invite as $memberid => $email) {
$values[] = array($id, $memberid, 0, 1, 0, 0, $accept_code);
}
$query = 'INSERT INTO ' . $this->get_table(TBL_RESERVATION_USERS) . ' VALUES(?,?,?,?,?,?,?)';
$q = $this->db->prepare($query);
$result = $this->db->executeMultiple($q, $values);
$this->check_for_error($result);
// Insert the additional resources data
if (count($resources_to_add) > 0) {
$values = null;
for ($i = 0; $i < count($resources_to_add); $i++) {
$values[] = array($id, $resources_to_add[$i], 0);
}
$query = 'INSERT INTO ' . $this->get_table(TBL_RESERVATION_RESOURCES) . ' VALUES(?,?,?)';
$q = $this->db->prepare($query);
$result = $this->db->executeMultiple($q, $values);
$this->check_for_error($result);
}
unset($values, $query);
return $id;
}