Make node_load more generalised

This commit is contained in:
2014-04-28 11:46:42 +10:00
parent 6e2abbc92a
commit 0ff5b531eb
3 changed files with 89 additions and 34 deletions

View File

@@ -986,10 +986,13 @@ function booking_studygroups_printview_form($node, &$form_state, $group_id) {
$rows = array();
$last_session = "";
/*
//attach the custom css
$form['#attached']['css'] = array(
drupal_get_path('module', 'booking') . '/booking.css',
);
*/
//verify that $group_id is a number
if (! preg_match('/^[0-9]+$/', $group_id)) {
@@ -1011,11 +1014,10 @@ function booking_studygroups_printview_form($node, &$form_state, $group_id) {
}
$header = array(
'booking_session_id' => array('data' => t('Study Group Session'), 'field' => 'm.booking_session_id', 'sort' => 'asc'),
'booking_name' => array('data' => t('Name'), 'field' => 'p.booking_lastname'),
'booking_is_leader' => array('data' => t('Leader?'), 'field' => 'm.booking_is_leader'),
'booking_is_helper' => array('data' => t('Helper?'), 'field' => 'm.booking_is_helper'),
'booking_is_reserveleader' => array('data' => t('Reserve Leader?'), 'field' => 'm.booking_is_reserveleader'),
'booking_session_id' => array('data' => t('Study Group Session'), 'field' => 'm.booking_session_id'),
'booking_name' => array('data' => t('Name'), 'field' => 'p.booking_lastname', 'sort' => 'asc'),
'booking_mobilenum' => array('data' => t('Mobile Number'), 'field' => 'p.booking_mobile'),
'booking_studygroup_role' => array('data' => t('Role')),
);
$query = db_select('booking_person', 'p');
@@ -1024,22 +1026,35 @@ function booking_studygroups_printview_form($node, &$form_state, $group_id) {
$db_and->condition('p.booking_event_id', $event->eid, '=');
$db_and->condition('m.booking_studygroup_id', $group_id, '=');
$query->condition($db_and);
$query->fields('p')->fields('m')->orderBy('p.booking_lastname', 'ASC');
$result = $query->execute();
$query->fields('p')->fields('m');
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
$result = $table_sort->execute();
//$result = $query->execute();
//watchdog('booking', 'Study groups raw data: @info', array ('@info' => var_export($result, TRUE)));
foreach($result as $data)
{
$class = "";
$role = "";
//apply theme as required
if ($data->booking_is_leader == 'Y')
{
$class = "leader-row";
$role = "Leader";
}
elseif ($data->booking_is_helper == 'Y')
{
$class = "helper-row";
$role = "Helper";
}
elseif ($data->booking_is_reserveleader == 'Y')
$class = "helper-row";
{
$class = "helper-row";
$role = "Reserve Leader";
}
else
$class = "normal-row";
@@ -1047,12 +1062,10 @@ function booking_studygroups_printview_form($node, &$form_state, $group_id) {
'data' => array(
$data->booking_session_id,
$data->booking_firstname . " " . $data->booking_lastname,
$data->booking_is_leader == 'Y' ? 'Yes' : 'No',
$data->booking_is_helper == 'Y' ? 'Yes' : 'No',
$data->booking_is_reserveleader == 'Y' ? 'Yes' : 'No',
$data->booking_mobile,
$role,
),
'class' => $class,
'no_striping' => TRUE,
'class' => array($class),
);
}
@@ -1066,7 +1079,7 @@ function booking_studygroups_printview_form($node, &$form_state, $group_id) {
//'#attributes' => array('id' => 'sort-table'),
);
*/
return array (
$result = array (
'first_para' => array (
'#type' => 'markup',
'#markup' => $prefix,
@@ -1075,10 +1088,13 @@ function booking_studygroups_printview_form($node, &$form_state, $group_id) {
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#sticky' => FALSE,
'#attributes' => array('id' => 'sort-table'),
//'#sticky' => FALSE,
)
);
watchdog('booking', "<pre>Group printable format:\n@info</pre>", array('@info' => print_r( $result, true)));
return $result;
}
/**