Some tweaks

This commit is contained in:
2014-02-28 19:05:38 +11:00
parent e690d5b8c8
commit 8fb838d9eb
4 changed files with 85 additions and 40 deletions

View File

@@ -1025,6 +1025,7 @@ function booking_form_submit($form, &$form_state) {
}
function booking_load($nodes) {
global $event;
//watchdog('booking', 'Loading node with params: @info', array('@info' => var_export($nodes, TRUE)));
// note that $nodes is an array of object references, keyed by nid
@@ -1035,11 +1036,46 @@ function booking_load($nodes) {
//perform an inner join
$query->join('booking_price', 'pr', 'p.booking_payment_id = pr.pid');
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
//filter the results and select the appropriate fields
$query->condition('p.nid', array_keys($nodes), 'IN')
->fields('p')
->fields('t')
->fields('pr', array('booking_price', 'booking_price_descrip'));
//add the fields for study groups
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 <= 7; $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 and select the appropriate fields
$query->condition('p.nid', array_keys($nodes), 'IN')
->fields('p')
->fields('t')
->fields('pr', array('booking_price', 'booking_price_descrip'));
//now add the study group fields
for ($i = 1; $i <= 7; $i++)
{
$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');
$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 and select the appropriate fields
$query->condition('p.nid', array_keys($nodes), 'IN')
->fields('p')
->fields('t')
->fields('pr', array('booking_price', 'booking_price_descrip'));
}
//get the query result
$result = $query->execute();
@@ -1048,7 +1084,7 @@ function booking_load($nodes) {
//add that data to the array of node references
foreach ($result as $record)
{
watchdog('booking', "<pre>Loading node:\n@info</pre>", array('@info' => print_r( $record, true)));
//watchdog('booking', "<pre>Loading node:\n@info</pre>", array('@info' => print_r( $record, true)));
// run through each result row and add in the needed attributes
foreach ($record as $key => $value)
{