Add token for leader-helper pairs
This commit is contained in:
@@ -1180,6 +1180,92 @@ function _booking_studygroup_email_summary($node) {
|
|||||||
return implode("\n", $rows);
|
return implode("\n", $rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to format information matching leaders and helpers, to be used as a token
|
||||||
|
*/
|
||||||
|
function _booking_leader_helper_email_summary($node) {
|
||||||
|
global $event;
|
||||||
|
$rows = array();
|
||||||
|
$found = FALSE;
|
||||||
|
|
||||||
|
//display study session data if enabled
|
||||||
|
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||||
|
{
|
||||||
|
//look up the titles of the study groups
|
||||||
|
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid",
|
||||||
|
array(':eid' => $event->eid));
|
||||||
|
$studygroups = $studygroups_query->fetchAllAssoc('sid');
|
||||||
|
|
||||||
|
for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++)
|
||||||
|
{
|
||||||
|
//don't print info about the readings groups
|
||||||
|
if ($i == variable_get('booking_readinggroup_id','7'))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//calculate the session references
|
||||||
|
$sessionid = "session" . $i;
|
||||||
|
$roleid = $sessionid . "_role";
|
||||||
|
$otherperson_name = "TBA";
|
||||||
|
|
||||||
|
//check that this study group session has been defined for this attendee and that they
|
||||||
|
if (!empty($node->$sessionid) && $node->$roleid > 0)
|
||||||
|
{
|
||||||
|
//make sure we only add this prefix text once, as soon as we've found a matching role
|
||||||
|
if ($found == FALSE)
|
||||||
|
{
|
||||||
|
$found = TRUE;
|
||||||
|
$rows[] = t("You have been assigned to perform the following roles for study groups:");
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: use a function for this.
|
||||||
|
//if they're a leader or reserver leader, then the matching person is the helper
|
||||||
|
if ($node->$roleid == 1 || $node->$roleid == 3)
|
||||||
|
{
|
||||||
|
$role = "Leader";
|
||||||
|
$otherrole = "Helper";
|
||||||
|
$otherrole_id = 2;
|
||||||
|
}
|
||||||
|
//otherwise the matching person is the leader
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$role = "Helper";
|
||||||
|
$otherrole = "Leader";
|
||||||
|
$otherrole_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//find the other person
|
||||||
|
$otherperson_query = db_query("SELECT m.*, p.booking_firstname, p.booking_lastname FROM {booking_studygroup_mapping} m " .
|
||||||
|
" INNER JOIN {booking_person} p on m.booking_node_id = p.nid " .
|
||||||
|
" WHERE booking_eventid = :eid " .
|
||||||
|
" AND booking_studygroup_id = :group AND booking_studygroup_role = :role AND booking_session_id = :session",
|
||||||
|
array(':eid' => $event->eid, ':group' => $i, ':role' => $otherrole_id, ':session' => $node->$sessionid,
|
||||||
|
));
|
||||||
|
$otherperson = $otherperson_query->fetchAll();
|
||||||
|
|
||||||
|
watchdog('booking', "<pre>Other person for studygroup !group and role !role result:\n@info</pre>",
|
||||||
|
array('!group' => $i, '!role' => $otherrole_id, '@info' => print_r( $otherperson, true)));
|
||||||
|
|
||||||
|
foreach ($otherperson as $other)
|
||||||
|
{
|
||||||
|
$otherperson_name = $other->booking_firstname . ' ' . $other->booking_lastname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$rows[] = t('!role for !descrip (section !id). Your !otherrole is !other.',
|
||||||
|
array('!role' => $role, '!id' => $studygroups[$i]->sid, '!descrip' => $studygroups[$i]->booking_studygroup_descrip,
|
||||||
|
'!otherrole' => $otherrole, '!other' => $otherperson_name,
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($rows as $key => $value)
|
||||||
|
$rows[$key] = wordwrap($value);
|
||||||
|
|
||||||
|
return implode("\n", $rows);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to format summary of room allocation to be used as a token
|
* Helper function to format summary of room allocation to be used as a token
|
||||||
*/
|
*/
|
||||||
|
@@ -354,10 +354,12 @@ function booking_update_7215() {
|
|||||||
function booking_update_7216() {
|
function booking_update_7216() {
|
||||||
$booking_room_mapping = array(
|
$booking_room_mapping = array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
|
'mid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||||
'booking_roomid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
'booking_roomid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||||
'booking_nodeid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
'booking_nodeid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||||
),
|
),
|
||||||
|
'primary key' => array('mid'),
|
||||||
);
|
);
|
||||||
|
|
||||||
db_create_table('booking_room_mapping', $booking_room_mapping);
|
db_create_table('booking_room_mapping', $booking_room_mapping);
|
||||||
@@ -383,6 +385,14 @@ function booking_update_7218() {
|
|||||||
db_add_field('booking_room_mapping', 'booking_room_bedtype', $spec);
|
db_add_field('booking_room_mapping', 'booking_room_bedtype', $spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add index to room mapping table
|
||||||
|
*/
|
||||||
|
function booking_update_7219() {
|
||||||
|
//$spec = array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10');
|
||||||
|
//db_add_field('booking_room_mapping', 'rid', $spec);
|
||||||
|
//db_add_index('booking_room_mapping', 'rid', array('booking_roomid', 'booking_eventid', 'booking_nodeid'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of hook_install().
|
* Implementation of hook_install().
|
||||||
|
@@ -440,8 +440,9 @@ function booking_room_edit_form_submit($form, &$form_state) {
|
|||||||
'booking_roomid' => $details->rid,
|
'booking_roomid' => $details->rid,
|
||||||
'booking_room_bedtype' => $values['booking_room_bedtype'],
|
'booking_room_bedtype' => $values['booking_room_bedtype'],
|
||||||
))
|
))
|
||||||
->condition('booking_eventid', $event->eid)
|
->condition('mid', $check->mid)
|
||||||
->condition('booking_nodeid', $values['personid'])
|
//->condition('booking_eventid', $event->eid)
|
||||||
|
//->condition('booking_nodeid', $values['personid'])
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1484,10 +1484,11 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
//attach the custom css
|
//attach the custom css
|
||||||
|
/*
|
||||||
$form['#attached']['css'] = array(
|
$form['#attached']['css'] = array(
|
||||||
drupal_get_path('module', 'booking') . '/booking.css',
|
drupal_get_path('module', 'booking') . '/booking.css',
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
//verify that $group_id is a number
|
//verify that $group_id is a number
|
||||||
if (! preg_match('/^[0-9]+$/', $group_id)) {
|
if (! preg_match('/^[0-9]+$/', $group_id)) {
|
||||||
drupal_set_message("Error: Invalid study group ID '" . $group_id . "' supplied. Unable to view group membership.", 'error', FALSE);
|
drupal_set_message("Error: Invalid study group ID '" . $group_id . "' supplied. Unable to view group membership.", 'error', FALSE);
|
||||||
@@ -1515,8 +1516,14 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
|||||||
$header = array(
|
$header = array(
|
||||||
'booking_session_id' => array('data' => t('Study Group Session'), 'field' => 'm.booking_session_id', 'sort' => 'asc'),
|
'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_name' => array('data' => t('Name'), 'field' => 'p.booking_lastname'),
|
||||||
'booking_status' => array('data' => t('Booking Status'), 'field' => 'p.booking_status'),
|
'booking_gender' => array('data' => t('Gender'), 'field' => 'p.booking_gender'),
|
||||||
|
'booking_age' => array('data' => t('Age'), 'field' => 'p.booking_dob'),
|
||||||
|
'booking_baptised' => array('data' => t('Baptised?'), 'field' => 'p.booking_baptised'),
|
||||||
|
'booking_married' => array('data' => t('Married?'), 'field' => 'p.booking_married'),
|
||||||
|
'booking_phone' => array('data' => t('Phone Number'), 'field' => 'p.booking_mobile'),
|
||||||
|
//'booking_status' => array('data' => t('Booking Status'), 'field' => 'p.booking_status'),
|
||||||
'booking_studygroup_role' => array('data' => t('Studygroup Role'), 'field' => 'p.booking_studygroup_role'),
|
'booking_studygroup_role' => array('data' => t('Studygroup Role'), 'field' => 'p.booking_studygroup_role'),
|
||||||
|
'booking_committee' => array('data' => t('Committee Member?'), 'field' => 'p.booking_committee_member'),
|
||||||
//'booking_is_leader' => array('data' => t('Leader?'), 'field' => 'm.booking_is_leader'),
|
//'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_helper' => array('data' => t('Helper?'), 'field' => 'm.booking_is_helper'),
|
||||||
//'booking_is_reserveleader' => array('data' => t('Reserve Leader?'), 'field' => 'm.booking_is_reserveleader'),
|
//'booking_is_reserveleader' => array('data' => t('Reserve Leader?'), 'field' => 'm.booking_is_reserveleader'),
|
||||||
@@ -1581,37 +1588,66 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$session = $is_reading_group == TRUE ? _booking_readinggroup_colour_lookup($data->booking_session_id) : $data->booking_session_id;
|
$session = $is_reading_group == TRUE ? _booking_readinggroup_colour_lookup($data->booking_session_id) : $data->booking_session_id;
|
||||||
|
/*
|
||||||
$options[$data->nid] = array (
|
$options[$data->nid] = array (
|
||||||
'booking_session_id' => $session,
|
'booking_session_id' => $session,
|
||||||
'booking_name' => l(t('!first !last', array('!first' => $data->booking_firstname, '!last' => $data->booking_lastname)),
|
'booking_name' => l(t('!first !last', array('!first' => $data->booking_firstname, '!last' => $data->booking_lastname)),
|
||||||
t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))),
|
t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))),
|
||||||
'booking_status' => _booking_status_generate($data->booking_status),
|
'booking_status' => _booking_status_generate($data->booking_status),
|
||||||
'booking_studygroup_role' => _booking_studygroup_role_lookup($data->booking_studygroup_role),
|
'booking_studygroup_role' => _booking_studygroup_role_lookup($data->booking_studygroup_role),
|
||||||
|
'booking_committee' => $data->booking_committee_member == 'Y' ? 'Yes' : 'No',
|
||||||
//'booking_is_leader' => $data->booking_is_leader == 'Y' ? 'Yes' : 'No',
|
//'booking_is_leader' => $data->booking_is_leader == 'Y' ? 'Yes' : 'No',
|
||||||
//'booking_is_helper' => $data->booking_is_helper == 'Y' ? 'Yes' : 'No',
|
//'booking_is_helper' => $data->booking_is_helper == 'Y' ? 'Yes' : 'No',
|
||||||
//'booking_is_reserveleader' => $data->booking_is_reserveleader == 'Y' ? 'Yes' : 'No',
|
//'booking_is_reserveleader' => $data->booking_is_reserveleader == 'Y' ? 'Yes' : 'No',
|
||||||
'#attributes' => array('id' => array($class))
|
'#attributes' => array('id' => array($class))
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
$rows[] = array (
|
||||||
|
'data' => array(
|
||||||
|
$session,
|
||||||
|
l(t('!first !last', array('!first' => $data->booking_firstname, '!last' => $data->booking_lastname)),
|
||||||
|
t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))),
|
||||||
|
//_booking_status_generate($data->booking_status),
|
||||||
|
$data->booking_gender == 'M' ? 'Male' : 'Female',
|
||||||
|
_booking_get_age_years($data->booking_dob),
|
||||||
|
$data->booking_baptised == 'Y' ? 'Yes' : 'No',
|
||||||
|
$data->booking_married == 'Y' ? 'Yes' : 'No',
|
||||||
|
$data->booking_mobile,
|
||||||
|
_booking_studygroup_role_lookup($data->booking_studygroup_role),
|
||||||
|
$data->booking_committee_member == 'Y' ? 'Yes' : 'No',
|
||||||
|
),
|
||||||
|
'id' => array($class),
|
||||||
|
);
|
||||||
|
|
||||||
$last_session = $data->booking_session_id;
|
$last_session = $data->booking_session_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$prefix = t("<h2>Study Group !descrip</h2>", array('!descrip' => $group->booking_studygroup_descrip));
|
$prefix = t("<h2>Study Group !descrip</h2>", array('!descrip' => $group->booking_studygroup_descrip));
|
||||||
|
/*
|
||||||
$form['table'] = array (
|
$form['table'] = array (
|
||||||
'#type' => 'tableselect',
|
'#type' => 'tableselect',
|
||||||
'#header' => $header,
|
'#header' => $header,
|
||||||
'#options' => $options,
|
'#options' => $options,
|
||||||
//'#attributes' => array('id' => 'sort-table'),
|
//'#attributes' => array('id' => 'sort-table'),
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
return array (
|
return array (
|
||||||
|
'#attached' => array (
|
||||||
|
'css' => array(drupal_get_path('module', 'booking') . '/booking.css')
|
||||||
|
),
|
||||||
'first_para' => array (
|
'first_para' => array (
|
||||||
'#type' => 'markup',
|
'#type' => 'markup',
|
||||||
'#markup' => $prefix,
|
'#markup' => $prefix,
|
||||||
),
|
),
|
||||||
'form' => $form,
|
'table' => array (
|
||||||
|
'#theme' => 'table',
|
||||||
|
'#header' => $header,
|
||||||
|
'#rows' => $rows,
|
||||||
|
'#attributes' => array('id' => 'sort-table'),
|
||||||
|
//'#sticky' => FALSE,
|
||||||
|
)
|
||||||
|
//'form' => $form,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -580,6 +580,10 @@ function booking_token_info() {
|
|||||||
'name' => t('Registration Study Group Summary'),
|
'name' => t('Registration Study Group Summary'),
|
||||||
'description' => t('Summary of allocated study groups.')
|
'description' => t('Summary of allocated study groups.')
|
||||||
);
|
);
|
||||||
|
$info['tokens']['booking']['leaderhelper-pair'] = array(
|
||||||
|
'name' => t('Registration Study Group Leader-Helper Pair'),
|
||||||
|
'description' => t('List out the leader and helper pairs, with intro text.')
|
||||||
|
);
|
||||||
$info['tokens']['booking']['room-allocation'] = array(
|
$info['tokens']['booking']['room-allocation'] = array(
|
||||||
'name' => t('Room Allocation'),
|
'name' => t('Room Allocation'),
|
||||||
'description' => t('Details of room allocated to attendee.')
|
'description' => t('Details of room allocated to attendee.')
|
||||||
@@ -709,6 +713,7 @@ function booking_define_personspecific_tokens($node)
|
|||||||
$tokens['regn-summary'] = _booking_details_email_summary($node);
|
$tokens['regn-summary'] = _booking_details_email_summary($node);
|
||||||
$tokens['travel-summary'] = _booking_travelform_email_summary($node);
|
$tokens['travel-summary'] = _booking_travelform_email_summary($node);
|
||||||
$tokens['studygroup-summary'] = _booking_studygroup_email_summary($node);
|
$tokens['studygroup-summary'] = _booking_studygroup_email_summary($node);
|
||||||
|
$tokens['leaderhelper-pair'] = _booking_leader_helper_email_summary($node);
|
||||||
$tokens['room-allocation'] = _booking_room_email_summary($node);
|
$tokens['room-allocation'] = _booking_room_email_summary($node);
|
||||||
$tokens['bed-type'] = _booking_room_bedtype_lookup($node->booking_room_bedtype);
|
$tokens['bed-type'] = _booking_room_bedtype_lookup($node->booking_room_bedtype);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user