diff --git a/booking.helper.inc b/booking.helper.inc index 3a451c3..77c92b4 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -994,6 +994,46 @@ function _booking_paypal_form_builder($node, &$form_state, $person, $invoiceid, 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("
Upload csv file containing data to import. Minimum fields present should be nid, " . + $prefix = t("
Upload csv file containing data to import. Minimum fields present should be nid and booking_status, " . " along with user-specified fields of !config. CSV Column names should match exactly (case sensitive).
", 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 elseif ($field == 'booking_status') { + $update_text .= " set booking status to '" . $record[$field] . "'; "; $update_array[$field] = _booking_status_lookup($record[$field]); } elseif ( (! isset($record[$field])) || $record[$field] == '' ) @@ -155,7 +156,8 @@ function booking_import_data_admin_submit($form, &$form_state) //$args = $query->getArguments(); - watchdog('booking', "Update Query:@values", + 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', diff --git a/booking.install b/booking.install index a4a4ef0..ce293fd 100644 --- a/booking.install +++ b/booking.install @@ -389,11 +389,29 @@ function booking_update_7218() { * Add index to room mapping table */ 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'); //db_add_field('booking_room_mapping', 'rid', $spec); //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(). */ @@ -467,7 +485,7 @@ function booking_schema() { 'booking_timestamp' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'), '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_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_lastname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE), 'booking_gender' => array('type' => 'varchar', 'length' => '1', 'not null' => TRUE), diff --git a/booking.module b/booking.module index 9e80d2b..c5aa23c 100644 --- a/booking.module +++ b/booking.module @@ -210,6 +210,14 @@ function booking_menu() { //'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 $items['booking'] = array( diff --git a/booking.register.inc b/booking.register.inc index 5c0cf51..7e61f71 100644 --- a/booking.register.inc +++ b/booking.register.inc @@ -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... if ($inserting != TRUE) { $form['your-details']['booking_status'] = array( - '#type' => 'radios', + '#type' => 'select', '#title' => t('Registration Status'), '#options' => _booking_status_generate(), '#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_label_position' => 'within', '#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( @@ -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_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_destination_country = empty($values['booking_destination_country']) ? '' : $values['booking_destination_country']; //payment details $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_name' => $node->booking_passport_issue_name, 'booking_passport_expiry_date' => $node->booking_passport_expiry_date, + 'booking_destination_country' => $node->booking_destination_country, 'booking_gender' => $node->booking_gender, 'booking_street' => $node->booking_street, 'booking_suburb' => $node->booking_suburb, @@ -1244,7 +1256,8 @@ function _booking_update($node) { 'booking_passport_num' => $node->booking_passport_num, 'booking_passport_issue_location' => $node->booking_passport_issue_location, '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_street' => $node->booking_street, '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 Exact Issued Name:'), $node->booking_passport_issue_name); $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))); @@ -1689,6 +1703,7 @@ function booking_view($node, $view_mode) { $rows[] = array(t('Previous Mission Experience:'), $node->booking_mission_experience_details); } $rows[] = array(t('Temporary UUID:'), $node->booking_tempid); + $rows[] = array(t('Lanyard lucky number:'), $node->booking_luckynum); //display room allocation data if enabled if (variable_get('booking_enable_roomallocations', 0) == 1) diff --git a/booking.rooms.inc b/booking.rooms.inc index 50efbb0..06330ff 100644 --- a/booking.rooms.inc +++ b/booking.rooms.inc @@ -748,7 +748,7 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) { //query for attendees $query = db_query("SELECT nid, booking_firstname, booking_lastname, booking_gender, booking_dob, booking_partner_id " . " 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)); //make a list of all attendees that are booked in