Code to manually update studygroup sessions
This commit is contained in:
@@ -547,7 +547,7 @@ function _booking_amount_paid($nid, $person = NULL)
|
|||||||
// $amount_paid = $person->booking_amount_paid;
|
// $amount_paid = $person->booking_amount_paid;
|
||||||
}
|
}
|
||||||
|
|
||||||
watchdog('booking', "Total amount already paid for this registration " . $nid . " is " . $amount_paid);
|
//watchdog('booking', "Total amount already paid for this registration " . $nid . " is " . $amount_paid);
|
||||||
|
|
||||||
return $amount_paid;
|
return $amount_paid;
|
||||||
}
|
}
|
||||||
|
@@ -337,6 +337,15 @@ function booking_menu() {
|
|||||||
//'type' => MENU_NORMAL_ITEM,
|
//'type' => MENU_NORMAL_ITEM,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$items['admin/booking/%/edit-studygroup'] = array(
|
||||||
|
'title' => 'Edit Study Group Allocation',
|
||||||
|
'description' => 'Manually Update Study Group memberships',
|
||||||
|
'page callback' => 'drupal_get_form',
|
||||||
|
'page arguments' => array('booking_studygroups_edit_form', 2),
|
||||||
|
'access arguments' => array('edit study groups'),
|
||||||
|
'type' => MENU_CALLBACK,
|
||||||
|
);
|
||||||
|
|
||||||
$items['admin/booking/studygroups/%/view/print'] = array(
|
$items['admin/booking/studygroups/%/view/print'] = array(
|
||||||
'title' => 'Print Study Group',
|
'title' => 'Print Study Group',
|
||||||
'description' => 'Print Study Group memberships',
|
'description' => 'Print Study Group memberships',
|
||||||
|
@@ -24,6 +24,7 @@ function booking_report_summary() {
|
|||||||
$person_count = 0;
|
$person_count = 0;
|
||||||
$welfare_count = 0;
|
$welfare_count = 0;
|
||||||
$fullypaid_count = 0;
|
$fullypaid_count = 0;
|
||||||
|
$travelform_count = 0;
|
||||||
|
|
||||||
$stats_attributes = array('style' => 'max-width:30%');
|
$stats_attributes = array('style' => 'max-width:30%');
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ function booking_report_summary() {
|
|||||||
$header = array(
|
$header = array(
|
||||||
array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'),
|
array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'),
|
||||||
array('data' => t('Name'), 'field' => 'booking_lastname'),
|
array('data' => t('Name'), 'field' => 'booking_lastname'),
|
||||||
|
array('data' => t('Edit Studygroups')),
|
||||||
array('data' => t('Email'), 'field' => 'booking_email'),
|
array('data' => t('Email'), 'field' => 'booking_email'),
|
||||||
array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'),
|
array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'),
|
||||||
array('data' => t('Total Payment Required')),
|
array('data' => t('Total Payment Required')),
|
||||||
@@ -82,11 +84,13 @@ function booking_report_summary() {
|
|||||||
|
|
||||||
//more detailed summary
|
//more detailed summary
|
||||||
//allow user-selectable sorting of columns as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7
|
//allow user-selectable sorting of columns as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7
|
||||||
$query = db_select('booking_person', 'p')
|
$query = db_select('booking_person', 'p');
|
||||||
->fields('p')
|
|
||||||
->fields('pr', array('booking_price', 'booking_late_price'))
|
|
||||||
->condition('p.booking_event_id', $event->eid, '=');
|
|
||||||
$query->join('booking_price', 'pr', 'pr.pid = p.booking_payment_id');
|
$query->join('booking_price', 'pr', 'pr.pid = p.booking_payment_id');
|
||||||
|
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
|
||||||
|
$query->condition('p.booking_event_id', $event->eid, '=')
|
||||||
|
->fields('p')
|
||||||
|
->fields('t')
|
||||||
|
->fields('pr', array('booking_price', 'booking_late_price'));
|
||||||
|
|
||||||
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
|
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
|
||||||
$result = $table_sort->execute();
|
$result = $table_sort->execute();
|
||||||
@@ -101,6 +105,7 @@ function booking_report_summary() {
|
|||||||
l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))),
|
l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))),
|
||||||
t('node/!id/edit', array('!id' => $person->nid))
|
t('node/!id/edit', array('!id' => $person->nid))
|
||||||
),
|
),
|
||||||
|
l(t('Edit'), t('admin/booking/!id/edit-studygroup', array('!id' => $person->nid))),
|
||||||
t('!email', array('!email' => $person->booking_email)),
|
t('!email', array('!email' => $person->booking_email)),
|
||||||
t('!payment', array('!payment' => $person->booking_amount_paid)),
|
t('!payment', array('!payment' => $person->booking_amount_paid)),
|
||||||
t('!payment', array('!payment' => $amount_owing == 0 ? $person->booking_total_pay_reqd : _booking_total_due($person))),
|
t('!payment', array('!payment' => $amount_owing == 0 ? $person->booking_total_pay_reqd : _booking_total_due($person))),
|
||||||
@@ -110,6 +115,10 @@ function booking_report_summary() {
|
|||||||
//add up the total paid
|
//add up the total paid
|
||||||
$total_paid += $person->booking_amount_paid;
|
$total_paid += $person->booking_amount_paid;
|
||||||
|
|
||||||
|
//travel form completed?
|
||||||
|
if (! empty($person->tid))
|
||||||
|
$travelform_count++;
|
||||||
|
|
||||||
//booking status
|
//booking status
|
||||||
if ($person->booking_status == 0)
|
if ($person->booking_status == 0)
|
||||||
$notpaid_counter++;
|
$notpaid_counter++;
|
||||||
@@ -162,8 +171,8 @@ function booking_report_summary() {
|
|||||||
$output .= t("There are !bookedin registrations currently booked in, !waiting on waiting list, !notpaid haven't paid, and !notcoming are no longer coming, which comes to a total of !total people who have filled in the registration form.</p>",
|
$output .= t("There are !bookedin registrations currently booked in, !waiting on waiting list, !notpaid haven't paid, and !notcoming are no longer coming, which comes to a total of !total people who have filled in the registration form.</p>",
|
||||||
array('!bookedin' => $bookedin_counter, '!waiting' => $waiting_counter, '!notpaid' => $notpaid_counter, '!total' => $person_count,
|
array('!bookedin' => $bookedin_counter, '!waiting' => $waiting_counter, '!notpaid' => $notpaid_counter, '!total' => $person_count,
|
||||||
'!notcoming' => $notcoming_counter));
|
'!notcoming' => $notcoming_counter));
|
||||||
$output .= t("<p>There are !welfare people with special financial consideration approved. !fullypaid people have completed their payments.<br />",
|
$output .= t("<p>There are !welfare people with special financial consideration approved. !fullypaid people have completed their payments and !travel people have filled in their travel form.<br />",
|
||||||
array('!welfare' => $welfare_count, '!fullypaid' => $fullypaid_count
|
array('!welfare' => $welfare_count, '!fullypaid' => $fullypaid_count, '!travel' => $travelform_count,
|
||||||
));
|
));
|
||||||
$output .= t("Total amount paid: $!paid</p>", array('!paid' => $total_paid));
|
$output .= t("Total amount paid: $!paid</p>", array('!paid' => $total_paid));
|
||||||
$output .= t("<h3>Bookings by state</h3>");
|
$output .= t("<h3>Bookings by state</h3>");
|
||||||
|
@@ -344,6 +344,112 @@ function booking_available_leadhelp_select_form_submit($form, &$form_state) {
|
|||||||
watchdog('booking', $message);
|
watchdog('booking', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for manually assigning study group sessions for a person
|
||||||
|
*/
|
||||||
|
function booking_studygroups_edit_form($node, &$form_state, $nid) {
|
||||||
|
global $event;
|
||||||
|
|
||||||
|
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||||
|
$form = array ();
|
||||||
|
$options = array ();
|
||||||
|
$session_options = array();
|
||||||
|
$session_options[0] = '';
|
||||||
|
|
||||||
|
//verify that $nid is a number
|
||||||
|
if (! preg_match('/^[0-9]+$/', $nid)) {
|
||||||
|
drupal_set_message("Error: Invalid registration ID '" . $nid . "' supplied. Unable to edit study group sessions.", 'error', FALSE);
|
||||||
|
drupal_goto('admin/booking/studygroups');
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//check that this person exists
|
||||||
|
$person = db_query("SELECT person.nid, person.booking_firstname, person.booking_lastname " .
|
||||||
|
"FROM {booking_person} person " .
|
||||||
|
"WHERE nid = :nid",
|
||||||
|
array(':nid' => $nid))
|
||||||
|
->fetchObject();
|
||||||
|
//throw an error if they don't exist
|
||||||
|
if (! $person)
|
||||||
|
{
|
||||||
|
drupal_set_message("Error: Unable to find booking corresponding with registration ID '" . $nid . "'.", 'error', FALSE);
|
||||||
|
drupal_goto('admin/booking/studygroups');
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
$prefix = t("<p>Manually assign/update study group sessions for !first !last. Note: Not yet functional!</p>", array('!first' => $person->booking_firstname, '!last' => $person->booking_lastname));
|
||||||
|
|
||||||
|
//select the groups this person is already assigned to, indexed by studygroup id
|
||||||
|
$person_groups_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid AND booking_node_id = :nid",
|
||||||
|
array(':eid' => $event->eid, ':nid' => $nid));
|
||||||
|
$person_groups = $person_groups_query->fetchAllAssoc('booking_studygroup_id');
|
||||||
|
|
||||||
|
//select all the study groups for this event id
|
||||||
|
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid", array(':eid' => $event->eid));
|
||||||
|
$studygroups = $studygroups_query->fetchAll();
|
||||||
|
|
||||||
|
//retrieve the number of study group sessions, assume they all have the same number of sessions
|
||||||
|
$num_sessions = reset($studygroups)->booking_num_group_sessions;
|
||||||
|
//create the array for our html select fields
|
||||||
|
for ($i = 1; $i <= $num_sessions; $i++)
|
||||||
|
$session_options[$i] = $i;
|
||||||
|
|
||||||
|
//select any entries already in the mapping table
|
||||||
|
$group_mapping_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid", array(':eid' => $event->eid));
|
||||||
|
$group_mapping = $group_mapping_query->fetchAllAssoc('sid');
|
||||||
|
|
||||||
|
//***form starts here***
|
||||||
|
$header = array(
|
||||||
|
'booking_studygroup_descrip' => array('data' => t('Study Group')),
|
||||||
|
'booking_current_session_id' => array('data' => t('Current Session Number')),
|
||||||
|
'booking_session_id' => array('data' => t('Select Session Number')),
|
||||||
|
);
|
||||||
|
|
||||||
|
//create a new row for each group
|
||||||
|
foreach ($studygroups as $group)
|
||||||
|
{
|
||||||
|
//retrieve the current session id for this group if defined already
|
||||||
|
$default = empty($person_groups[$group->sid]) ? '' : $person_groups[$group->sid]->booking_session_id;
|
||||||
|
|
||||||
|
$options[] = array (
|
||||||
|
'booking_studygroup_descrip' => $group->booking_studygroup_descrip,
|
||||||
|
'booking_current_session_id' => $default,
|
||||||
|
'booking_session_id' => array('data' => array(
|
||||||
|
'#type' => 'select',
|
||||||
|
'#options' => $session_options,
|
||||||
|
'#value' => $default,
|
||||||
|
'#name' => 'booking_assign_sessionid[' . $nid . ']',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//so we can access the dropdown elements
|
||||||
|
$form['booking_assign_sessionid'] = array( '#type' => 'value', );
|
||||||
|
|
||||||
|
//generate the render array
|
||||||
|
$form['table'] = array (
|
||||||
|
'#type' => 'tableselect',
|
||||||
|
'#header' => $header,
|
||||||
|
'#options' => $options,
|
||||||
|
);
|
||||||
|
$form['submit'] = array (
|
||||||
|
'#type' => 'submit',
|
||||||
|
'#value' => t('Submit'),
|
||||||
|
);
|
||||||
|
|
||||||
|
return array (
|
||||||
|
'first_para' => array (
|
||||||
|
'#type' => 'markup',
|
||||||
|
'#markup' => $prefix,
|
||||||
|
),
|
||||||
|
'form' => $form,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function for defining the number of study group sessions
|
* Function for defining the number of study group sessions
|
||||||
* Note: This is hard-coded for now in the install file
|
* Note: This is hard-coded for now in the install file
|
||||||
|
Reference in New Issue
Block a user