Added beginning code for room allocation, changing studygroup role field

This commit is contained in:
Nathan Coad
2014-05-26 22:03:32 +10:00
parent c07605ab73
commit 7e464bca59
8 changed files with 463 additions and 52 deletions

View File

@@ -1058,74 +1058,55 @@ function booking_form_submit($form, &$form_state) {
function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
{
global $event;
$studygroup_count = variable_get('booking_studygroup_count','0');
$query = db_select('booking_person', 'p');
//perform an inner join
//add price info
$query->join('booking_price', 'pr', 'p.booking_payment_id = pr.pid');
//add travel form info if it exists
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
//add the fields for study groups
//add the joins to flatten out study groups into columns
if (variable_get('booking_enable_studygroups', 0) == 1)
{
//work out how many study groups there are
//$studygroups = db_query("SELECT count(*) as numgroups from {booking_studygroup_list} s INNER JOIN {booking_event} e ON s.booking_eventid = e.eid WHERE e.booking_event_active = 1")
// ->fetchObject();
//$studygroups = db_query("SELECT s.* from {booking_studygroup_list} s INNER JOIN {booking_event} e ON s.booking_eventid = e.eid WHERE e.booking_event_active = 1")
// ->fetchAllAssoc('sid');
//watchdog('booking', "<pre>Loading node studygroups query output:\n@info</pre>", array('@info' => print_r( $studygroups, true)));
$studygroup_count = variable_get('booking_studygroup_count','0');
//for ($i = 1; $i <= STUDYGROUP_COUNT; $i++)
for ($i = 1; $i <= $studygroup_count; $i++)
{
$query->leftJoin('booking_studygroup_mapping', 's' . $i,
'p.nid = s' . $i . '.booking_node_id and s' . $i . '.booking_studygroup_id = ' . $i);
}
}
//filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id
if (! is_null($node_ids))
{
$query->condition('p.nid', $node_ids, 'IN');
}
else
{
$query->condition('p.booking_event_id', $event->eid, '=');
}
//filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id
if (! is_null($node_ids))
{
$query->condition('p.nid', $node_ids, 'IN');
}
else
{
$query->condition('p.booking_event_id', $event->eid, '=');
}
//add the fields we want
$query->fields('p')
->fields('t')
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
//add the database fields we always want to retrieve
$query->fields('p')
->fields('t')
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
//now add the study group fields
//now add the study group fields if applicable
if (variable_get('booking_enable_studygroups', 0) == 1)
{
for ($i = 1; $i <= $studygroup_count; $i++)
{
//$label = "Group_" . $studygroups[$i]->booking_studygroup_descrip;
$query->addField('s' . $i, 'booking_session_id', 'session' . $i);
$query->addField('s' . $i, 'booking_studygroup_role', 'session' . $i . '_role');
$query->addField('s' . $i, 'booking_is_leader', 'session' . $i . '_leader');
$query->addField('s' . $i, 'booking_is_reserveleader', 'session' . $i . '_reserveleader');
$query->addField('s' . $i, 'booking_is_helper', 'session' . $i . '_helper');
}
}
//not looking after study groups so don't add all the extra fields
else
{
//filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id
if (! is_null($node_ids))
{
$query->condition('p.nid', $node_ids, 'IN');
}
else
{
$query->condition('p.booking_event_id', $event->eid, '=');
}
//add the fields we want
$query->fields('p')
->fields('t')
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
}
//get the query result as either an associative array
if ($fetchAssoc == TRUE)
@@ -1557,13 +1538,13 @@ function booking_view($node, $view_mode) {
$rows[] = array(t('Total Amount Due:'), t('!amount_paid', array('!amount_paid' => $node->booking_total_pay_reqd)));
$rows[] = array(t('Refund Due:'), t('!amount_due', array('!amount_due' => $node->booking_refund_due)));
$rows[] = array(t('Refund Processed:'), t('!ans', array('!ans' => ($node->booking_refund_processed == 'Y' ? 'Yes' : 'No'))));
$rows[] = array(t('Reading Group:'), t('!group', array('!group' => $node->booking_readinggroup)));
if (variable_get('booking_enable_tshirts', 0) == 1)
{
$rows[] = array(t('Hoodie Size:'), $node->booking_shirt_size);
}
$rows[] = array(t('Home Phone Number:'), t('!home', array('!home' => $node->booking_phone)));
$rows[] = array(t('Mobile Phone Number:'), t('!mob', array('!mob' => $node->booking_mobile)));
$rows[] = array(t('Postal Address:'), t('!street<br />!suburb !state !code<br />!country',
@@ -1574,7 +1555,7 @@ function booking_view($node, $view_mode) {
$rows[] = array(t('Ecclesia:'), t('!ecclesia', array('!ecclesia' => $node->booking_ecclesia)));
$rows[] = array(t('Baptised:'), t('!ans', array('!ans' => ($node->booking_baptised == 'Y' ? 'Yes' : 'No'))));
$rows[] = array(t('Married:'), t('!ans', array('!ans' => ($node->booking_married == 'Y' ? 'Yes' : 'No'))));
//$rows[] = array(t("If married, attending partner's name:"), t('!name', array('!name' => $node->booking_partner_name)));
$rows[] = array(t('Linked Partner:'), t($partner_name));
$rows[] = array(t('Linked Boyfriend/Girlfriend:'), t($bf_gf));
$rows[] = array(t('Emergency Contact Name:'), $node->booking_guardian_name);
@@ -1673,10 +1654,14 @@ function booking_view($node, $view_mode) {
for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++)
{
$role = "";
//calculate the session references
$sessionid = "session" . $i;
$roleid = $sessionid . "_role";
/*
$role = "";
$leaderid = $sessionid . "_leader";
$helperid = $sessionid . "_helper";
$reserveleaderid = $sessionid . "_reserveleader";
@@ -1687,9 +1672,10 @@ function booking_view($node, $view_mode) {
$role = "Helper";
elseif ($node->$reserveleaderid == 'Y')
$role = "Reserve Leader";
*/
$group_rows[] = array(t('<b>' . $studygroups[$i]->booking_studygroup_descrip . '</b> group number'), $node->$sessionid);
$group_rows[] = array(t('Role'), $role);
$group_rows[] = array(t('Role'), _booking_studygroup_role_lookup($node->$roleid));
}
$node->content['group-heading'] = array(