study group bugfixes

This commit is contained in:
2014-04-29 19:14:04 +10:00
parent 0ff5b531eb
commit eb3fa7e7bf
4 changed files with 47 additions and 22 deletions

View File

@@ -1043,10 +1043,14 @@ function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
if (variable_get('booking_enable_studygroups', 0) == 1)
{
//work out how many study groups there are
//$count = db_query("SELECT count(*) as num_groups FROM {booking_studygroup_list} where booking_eventid = :eventid", array(':eventid' => $event->eid))
// ->fetchObject();
for ($i = 1; $i <= STUDYGROUP_COUNT; $i++)
$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)));
//for ($i = 1; $i <= STUDYGROUP_COUNT; $i++)
for ($i = 1; $i <= $studygroups->numgroups; $i++)
{
$query->leftJoin('booking_studygroup_mapping', 's' . $i,
'p.nid = s' . $i . '.booking_node_id and s' . $i . '.booking_studygroup_id = ' . $i);
@@ -1068,8 +1072,9 @@ function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
//now add the study group fields
for ($i = 1; $i <= STUDYGROUP_COUNT; $i++)
for ($i = 1; $i <= $studygroups->numgroups; $i++)
{
//$label = "Group_" . $studygroups[$i]->booking_studygroup_descrip;
$query->addField('s' . $i, 'booking_session_id', 'session' . $i);
$query->addField('s' . $i, 'booking_is_leader', 'session' . $i . '_leader');
$query->addField('s' . $i, 'booking_is_reserveleader', 'session' . $i . '_reserveleader');
@@ -1095,8 +1100,7 @@ function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
}
//get the query result
//get the query result as either an associative array
if ($fetchAssoc == TRUE)
{
$result = $query->execute()->fetchAllAssoc('nid');
@@ -1106,7 +1110,7 @@ function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
$result = $query->execute();
}
watchdog('booking', "<pre>Loading node query output:\n@info</pre>", array('@info' => print_r( $result, true)));
//watchdog('booking', "<pre>Loading node query output:\n@info</pre>", array('@info' => print_r( $result, true)));
return $result;
}
@@ -1619,6 +1623,8 @@ function booking_view($node, $view_mode) {
array(':eid' => $event->eid));
$studygroups = $studygroups_query->fetchAllAssoc('sid');
watchdog('booking', "<pre>Displaying node studygroups query output:\n@info</pre>", array('@info' => print_r( $studygroups, true)));
for ($i = 1; $i <= STUDYGROUP_COUNT; $i++)
{
$role = "";