Added destination country and updated import data functions

This commit is contained in:
2014-06-25 11:33:52 +10:00
parent e64749704e
commit d7b12517b5
6 changed files with 90 additions and 7 deletions

View File

@@ -994,6 +994,46 @@ function _booking_paypal_form_builder($node, &$form_state, $person, $invoiceid,
return $form; return $form;
} }
/**
* Function for generating the "lucky number" to be used on the lanyard
*/
function booking_generate_luckynumbers() {
global $event;
$i = 0;
//query for the mappings relating to $readinggroup_studygroup_id
$attendee_query = db_query("SELECT * FROM {booking_person} WHERE booking_event_id = :eid",
array(':eid' => $event->eid));
$attendees = $attendee_query->fetchAll();
//assuming there's less than 900 people, generate numbers within that range and shuffle the order
$numbers = range(100,999);
shuffle($numbers);
foreach ($attendees as $attendee)
{
$luckynum = $numbers[$i++];
drupal_set_message(t('Updating user !id to have lucky number !num.',
array('!id' => $attendee->nid, '!num' => $luckynum)));
//run an update query
db_update('booking_person')
->fields(array (
'booking_luckynum' => $luckynum,
))
->condition('nid', $attendee->nid)
->execute();
}
drupal_set_message(t('Finished.'));
return t("<h3>Generate Lucky Numbers</h3>");
}
/** /**
* Helper function to format registrations details for summary in the confirmation email * Helper function to format registrations details for summary in the confirmation email
*/ */

View File

@@ -11,7 +11,7 @@ function booking_import_data_admin()
{ {
global $event; global $event;
$prefix = t("<p>Upload csv file containing data to import. Minimum fields present should be <strong>nid</strong>, " . $prefix = t("<p>Upload csv file containing data to import. Minimum fields present should be <strong>nid and booking_status</strong>, " .
" along with user-specified fields of <strong>!config</strong>. CSV Column names should match exactly (case sensitive).</p>", " along with user-specified fields of <strong>!config</strong>. CSV Column names should match exactly (case sensitive).</p>",
array('!config' => variable_get('booking_import_include_fields', ''))); array('!config' => variable_get('booking_import_include_fields', '')));
@@ -129,6 +129,7 @@ function booking_import_data_admin_submit($form, &$form_state)
//convert the booking status to the number used internally //convert the booking status to the number used internally
elseif ($field == 'booking_status') elseif ($field == 'booking_status')
{ {
$update_text .= " set booking status to '" . $record[$field] . "'; ";
$update_array[$field] = _booking_status_lookup($record[$field]); $update_array[$field] = _booking_status_lookup($record[$field]);
} }
elseif ( (! isset($record[$field])) || $record[$field] == '' ) elseif ( (! isset($record[$field])) || $record[$field] == '' )
@@ -155,7 +156,8 @@ function booking_import_data_admin_submit($form, &$form_state)
//$args = $query->getArguments(); //$args = $query->getArguments();
watchdog('booking', "Update Query:<br />@info<br />Rows affected<br />@rows", array('@info' => (string) $query, '@rows' => $rows)); watchdog('booking', "Update Query:<br />@info<br />Condition: @nid<br />Rows affected: @rows<br />Values: <br /><pre>@values</pre>",
array('@info' => (string) $query, '@nid' => $record['nid'], '@rows' => $rows, '@values' => print_r( $update_array, true) ));
/* /*
$result_array[] = t('Setting payment for id !nid to $!price of total required $!total and status to !status', $result_array[] = t('Setting payment for id !nid to $!price of total required $!total and status to !status',

View File

@@ -389,11 +389,29 @@ function booking_update_7218() {
* Add index to room mapping table * Add index to room mapping table
*/ */
function booking_update_7219() { function booking_update_7219() {
//couldn't get this to work, added via mysql directly
//ALTER TABLE booking_room_mapping ADD mid Int NOT NULL AUTO_INCREMENT PRIMARY KEY;
//$spec = array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'); //$spec = array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10');
//db_add_field('booking_room_mapping', 'rid', $spec); //db_add_field('booking_room_mapping', 'rid', $spec);
//db_add_index('booking_room_mapping', 'rid', array('booking_roomid', 'booking_eventid', 'booking_nodeid')); //db_add_index('booking_room_mapping', 'rid', array('booking_roomid', 'booking_eventid', 'booking_nodeid'));
} }
/**
* Add field for "lucky number" on the lanyard
*/
function booking_update_7220() {
$spec = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0);
db_add_field('booking_person', 'booking_luckynum', $spec);
}
/**
* Add field for destination country when collecting passport informaiton
*/
function booking_update_7221() {
$spec = array('type' => 'varchar', 'length' => '500', 'not null' => FALSE);
db_add_field('booking_person', 'booking_destination_country', $spec);
}
/** /**
* Implementation of hook_install(). * Implementation of hook_install().
*/ */
@@ -467,7 +485,7 @@ function booking_schema() {
'booking_timestamp' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'), 'booking_timestamp' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
'booking_status' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE), 'booking_status' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
'booking_welfare_required' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'), 'booking_welfare_required' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
'booking_barcode' => array('type' => 'varchar', 'length' => '8', 'not null' => FALSE), 'booking_barcode' => array('type' => 'varchar', 'length' => '20', 'not null' => FALSE),
'booking_firstname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE), 'booking_firstname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE),
'booking_lastname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE), 'booking_lastname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE),
'booking_gender' => array('type' => 'varchar', 'length' => '1', 'not null' => TRUE), 'booking_gender' => array('type' => 'varchar', 'length' => '1', 'not null' => TRUE),

View File

@@ -210,6 +210,14 @@ function booking_menu() {
//'type' => MENU_LOCAL_TASK, //'type' => MENU_LOCAL_TASK,
); );
//one off internal tasks
$items['admin/booking/luckynumbers'] = array(
'title' => 'Booking Generate Lucky Numbers',
'description' => 'Calculate lucky numbers for lanyard',
'page callback' => 'booking_generate_luckynumbers',
'access arguments' => array('edit bookings'),
'type' => MENU_CALLBACK,
);
//pages for attendees to fill out information //pages for attendees to fill out information
$items['booking'] = array( $items['booking'] = array(

View File

@@ -149,7 +149,7 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
// The status field should not be visible unless this registration is being updated...i.e. not at actual registration time... // The status field should not be visible unless this registration is being updated...i.e. not at actual registration time...
if ($inserting != TRUE) { if ($inserting != TRUE) {
$form['your-details']['booking_status'] = array( $form['your-details']['booking_status'] = array(
'#type' => 'radios', '#type' => 'select',
'#title' => t('Registration Status'), '#title' => t('Registration Status'),
'#options' => _booking_status_generate(), '#options' => _booking_status_generate(),
'#default_value' => !empty($data->booking_status) ? $data->booking_status : '', '#default_value' => !empty($data->booking_status) ? $data->booking_status : '',
@@ -389,7 +389,17 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
'#date_format' => 'd/m/Y', '#date_format' => 'd/m/Y',
//'#date_label_position' => 'within', //'#date_label_position' => 'within',
'#date_year_range' => '+0:+13' '#date_year_range' => '+0:+13'
); );
if ($inserting == FALSE)
{
$form['passport-details']['booking_destination_country'] = array(
'#type' => 'textfield',
'#title' => t('Which country is this person going to?'),
'#maxlength' => 120,
'#required' => FALSE,
'#default_value' => !empty($data->booking_destination_country) ? $data->booking_destination_country : '',
);
}
} }
$form['contact-details'] = array( $form['contact-details'] = array(
@@ -930,6 +940,7 @@ function booking_form_submit($form, &$form_state) {
$node->booking_passport_issue_location = empty($values['booking_passport_issue_location']) ? '' : $values['booking_passport_issue_location']; $node->booking_passport_issue_location = empty($values['booking_passport_issue_location']) ? '' : $values['booking_passport_issue_location'];
$node->booking_passport_issue_name = empty($values['booking_passport_issue_name']) ? '' : $values['booking_passport_issue_name']; $node->booking_passport_issue_name = empty($values['booking_passport_issue_name']) ? '' : $values['booking_passport_issue_name'];
$node->booking_passport_expiry_date = empty($values['booking_passport_expiry_date']) ? '0' : _datearray_to_ts($values['booking_passport_expiry_date']); $node->booking_passport_expiry_date = empty($values['booking_passport_expiry_date']) ? '0' : _datearray_to_ts($values['booking_passport_expiry_date']);
$node->booking_destination_country = empty($values['booking_destination_country']) ? '' : $values['booking_destination_country'];
//payment details //payment details
$node->booking_payment_id = $values['booking_payment_id']; $node->booking_payment_id = $values['booking_payment_id'];
@@ -1161,6 +1172,7 @@ function _booking_insert($node) {
'booking_passport_issue_location' => $node->booking_passport_issue_location, 'booking_passport_issue_location' => $node->booking_passport_issue_location,
'booking_passport_issue_name' => $node->booking_passport_issue_name, 'booking_passport_issue_name' => $node->booking_passport_issue_name,
'booking_passport_expiry_date' => $node->booking_passport_expiry_date, 'booking_passport_expiry_date' => $node->booking_passport_expiry_date,
'booking_destination_country' => $node->booking_destination_country,
'booking_gender' => $node->booking_gender, 'booking_gender' => $node->booking_gender,
'booking_street' => $node->booking_street, 'booking_street' => $node->booking_street,
'booking_suburb' => $node->booking_suburb, 'booking_suburb' => $node->booking_suburb,
@@ -1244,7 +1256,8 @@ function _booking_update($node) {
'booking_passport_num' => $node->booking_passport_num, 'booking_passport_num' => $node->booking_passport_num,
'booking_passport_issue_location' => $node->booking_passport_issue_location, 'booking_passport_issue_location' => $node->booking_passport_issue_location,
'booking_passport_issue_name' => $node->booking_passport_issue_name, 'booking_passport_issue_name' => $node->booking_passport_issue_name,
'booking_passport_expiry_date' => _date_to_ts($node->booking_passport_expiry_date), 'booking_passport_expiry_date' => _date_to_ts($node->booking_passport_expiry_date),
'booking_destination_country' => $node->booking_destination_country,
'booking_gender' => $node->booking_gender, 'booking_gender' => $node->booking_gender,
'booking_street' => $node->booking_street, 'booking_street' => $node->booking_street,
'booking_suburb' => $node->booking_suburb, 'booking_suburb' => $node->booking_suburb,
@@ -1605,6 +1618,7 @@ function booking_view($node, $view_mode) {
$rows[] = array(t('Passport Expiry:'), t('!timestamp', array('!timestamp' => _booking_convert_ts($node->booking_passport_expiry_date)->format('d/m/Y')))); $rows[] = array(t('Passport Expiry:'), t('!timestamp', array('!timestamp' => _booking_convert_ts($node->booking_passport_expiry_date)->format('d/m/Y'))));
$rows[] = array(t('Passport Exact Issued Name:'), $node->booking_passport_issue_name); $rows[] = array(t('Passport Exact Issued Name:'), $node->booking_passport_issue_name);
$rows[] = array(t('Passport Issue Location:'), $node->booking_passport_issue_location); $rows[] = array(t('Passport Issue Location:'), $node->booking_passport_issue_location);
$rows[] = array(t('Destination Country:'), $node->booking_destination_country);
} }
$rows[] = array(t('Payment Type Selected:'), t('!amount_paid', array('!amount_paid' => $payment_type))); $rows[] = array(t('Payment Type Selected:'), t('!amount_paid', array('!amount_paid' => $payment_type)));
@@ -1689,6 +1703,7 @@ function booking_view($node, $view_mode) {
$rows[] = array(t('Previous Mission Experience:'), $node->booking_mission_experience_details); $rows[] = array(t('Previous Mission Experience:'), $node->booking_mission_experience_details);
} }
$rows[] = array(t('Temporary UUID:'), $node->booking_tempid); $rows[] = array(t('Temporary UUID:'), $node->booking_tempid);
$rows[] = array(t('Lanyard lucky number:'), $node->booking_luckynum);
//display room allocation data if enabled //display room allocation data if enabled
if (variable_get('booking_enable_roomallocations', 0) == 1) if (variable_get('booking_enable_roomallocations', 0) == 1)

View File

@@ -748,7 +748,7 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) {
//query for attendees //query for attendees
$query = db_query("SELECT nid, booking_firstname, booking_lastname, booking_gender, booking_dob, booking_partner_id " . $query = db_query("SELECT nid, booking_firstname, booking_lastname, booking_gender, booking_dob, booking_partner_id " .
" FROM {booking_person} " . " FROM {booking_person} " .
" WHERE booking_event_id = :eid and booking_status=1 order by booking_lastname, booking_firstname", " WHERE booking_event_id = :eid and (booking_status=1 or booking_status=5) order by booking_lastname, booking_firstname",
array(':eid' => $event->eid)); array(':eid' => $event->eid));
//make a list of all attendees that are booked in //make a list of all attendees that are booked in