Files
booking/booking.install

468 lines
23 KiB
Plaintext

<?php
// $Id$
function booking_update_7100() {
$spec = array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '5', 'scale' => '2');
db_add_field( 'booking_price', 'booking_late_price', $spec);
}
function booking_update_7101() {
$spec = array('type' => 'varchar', 'length' => '50', 'not null' => FALSE);
db_add_field( 'booking_price', 'booking_late_buttonid', $spec);
}
function booking_update_7102() {
$spec = array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11');
db_add_field( 'booking_person', 'booking_deposit_timestamp', $spec);
}
function booking_update_7103() {
$spec = array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11');
db_add_field( 'booking_event', 'booking_event_start', $spec);
$spec = array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11');
db_add_field( 'booking_event', 'booking_event_end', $spec);
}
function booking_update_7104() {
$spec = array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11');
db_change_field('booking_person', 'booking_deposit_timestamp', 'booking_deposit_timestamp', $spec);
}
function booking_update_7105() {
//remove no longer used earlybird rate flag, replaced by regular and late prices
db_drop_field('booking_price', 'booking_earlybird_rate');
}
function booking_update_7106() {
//add passport details
$spec = array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11');
db_add_field( 'booking_person', 'booking_passport_issue_date', $spec);
db_add_field( 'booking_person', 'booking_passport_expiry_date', $spec);
$spec = array('type' => 'varchar', 'length' => '50', 'not null' => FALSE);
db_add_field( 'booking_person', 'booking_passport_num', $spec);
//add mission area experience details
$spec = array('type' => 'varchar', 'length' => '1', 'not null' => FALSE);
db_add_field( 'booking_person', 'booking_has_mission_experience', $spec);
$spec = array('type' => 'varchar', 'length' => '200', 'not null' => FALSE);
db_add_field( 'booking_person', 'booking_mission_experience_details', $spec);
}
function booking_update_7107() {
$spec = array('type' => 'varchar', 'length' => '500', 'not null' => FALSE);
db_change_field('booking_person', 'booking_mission_experience_details', 'booking_mission_experience_details', $spec);
}
/**
* Add special skills section, update passport info
*/
function booking_update_7108() {
//passport updates
$spec = array('type' => 'varchar', 'length' => '200', 'not null' => FALSE);
db_add_field( 'booking_person', 'booking_passport_issue_location', $spec);
db_add_field( 'booking_person', 'booking_passport_issue_name', $spec);
db_drop_field('booking_price', 'booking_passport_issue_date');
//skills type flags
$spec_flag = array('type' => 'varchar', 'length' => '1', 'not null' => FALSE);
db_add_field( 'booking_person', 'booking_skills_builder', $spec_flag);
db_add_field( 'booking_person', 'booking_skills_cooking', $spec_flag);
db_add_field( 'booking_person', 'booking_skills_childminding', $spec_flag);
db_add_field( 'booking_person', 'booking_skills_language', $spec_flag);
db_add_field( 'booking_person', 'booking_skills_language_details', $spec);
db_add_field( 'booking_person', 'booking_skills_other', $spec_flag);
db_add_field( 'booking_person', 'booking_skills_other_details', $spec);
}
/**
* Make varchar fields bigger
*/
function booking_update_7109() {
$spec = array('type' => 'varchar', 'length' => '500', 'not null' => FALSE);
db_change_field('booking_person', 'booking_passport_issue_location', 'booking_passport_issue_location', $spec);
db_change_field('booking_person', 'booking_skills_language_details', 'booking_skills_language_details', $spec);
db_change_field('booking_person', 'booking_skills_other_details', 'booking_skills_other_details', $spec);
}
/**
* Add event ID field to the payments table
*/
function booking_update_7201() {
//$spec = array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10');
//db_add_field( 'booking_payment', 'booking_eventid', $spec);
}
/**
* Add table for variety sessions
*/
function booking_update_7202() {
$booking_variety_options = array(
'fields' => array(
'vid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_variety_status' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
'booking_variety_timeslot_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_variety_descrip' => array('type' => 'varchar', 'length' => '500', 'not null' => TRUE),
'booking_variety_maxsize' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_variety_regncount' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
),
'primary key' => array('vid'),
);
$booking_variety_times = array(
'fields' => array(
'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_variety_status' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
'booking_variety_time_descrip' => array('type' => 'varchar', 'length' => '500', 'not null' => TRUE),
'booking_variety_start' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
'booking_variety_end' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
),
'primary key' => array('tid'),
);
$booking_variety_regn = array(
'fields' => array(
'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_variety_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_node_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
),
'primary key' => array('rid'),
);
db_create_table('booking_variety_options', $booking_variety_options);
db_create_table('booking_variety_times', $booking_variety_times);
db_create_table('booking_variety_regn', $booking_variety_regn);
//TODO: create tables for variety session timeslots and variety session registrations (map user to variety session id)
//admin forms to create timeslots, then add variety sessions to each timeslot
//user form to register for a given variety session
}
/**
* Add tables for study group calculations
*/
function booking_update_7203() {
//This lists all the study group sessions
$booking_studygroup_list = array(
'fields' => array(
'sid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_studygroup_descrip' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
'booking_num_group_sessions' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10', 'default' => 1),
),
'primary key' => array('sid'),
);
//this maps people to particular study groups
$booking_studygroup_mapping = array(
'fields' => array(
'sid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_node_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_studygroup_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_is_leader' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
'booking_is_helper' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
),
'primary key' => array('sid'),
);
//this defines the number of leader/helper sessions for a particular person
$booking_leadhelp_list = array(
'fields' => array(
'id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_node_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_total_lead' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_total_help' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_available_lead' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_available_help' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
),
'primary key' => array('id'),
);
db_create_table('booking_studygroup_list', $booking_studygroup_list);
db_create_table('booking_studygroup_mapping', $booking_studygroup_mapping);
db_create_table('booking_leadhelp_list', $booking_leadhelp_list);
}
/**
* Pre-populate the study group sessions table
*/
function booking_update_7204() {
$result = db_insert('booking_studygroup_list')
->fields(array(
'booking_eventid' => 2,
'booking_studygroup_descrip' => 'Monday',
'booking_num_group_sessions' => 16,
))
->execute();
$result = db_insert('booking_studygroup_list')
->fields(array(
'booking_eventid' => 2,
'booking_studygroup_descrip' => 'Tuesday',
'booking_num_group_sessions' => 16,
))
->execute();
$result = db_insert('booking_studygroup_list')
->fields(array(
'booking_eventid' => 2,
'booking_studygroup_descrip' => 'Wednesday',
'booking_num_group_sessions' => 16,
))
->execute();
$result = db_insert('booking_studygroup_list')
->fields(array(
'booking_eventid' => 2,
'booking_studygroup_descrip' => 'Thursday',
'booking_num_group_sessions' => 16,
))
->execute();
$result = db_insert('booking_studygroup_list')
->fields(array(
'booking_eventid' => 2,
'booking_studygroup_descrip' => 'Friday',
'booking_num_group_sessions' => 16,
))
->execute();
$result = db_insert('booking_studygroup_list')
->fields(array(
'booking_eventid' => 2,
'booking_studygroup_descrip' => 'Saturday',
'booking_num_group_sessions' => 16,
))
->execute();
}
/**
* Add extra field to the study group sessions table
*/
function booking_update_7205() {
}
/**
* Implementation of hook_install().
*/
function booking_install() {
// Create tables.
//not needed for d7
//drupal_install_schema('booking');
//TODO: Don't hard code this
//define('EVENTID', 1);
/*
limit bookings to 350
non workers $260
workers $300
married $540
full payment after 28 feb
$380 pp
*/
$result = db_insert('booking_price')
->fields(array(
'booking_eventid' => 1,
'booking_price' => '50.00',
'booking_price_descrip' => 'Deposit',
'booking_buttonid' => '9LMSELBEEL5W2',
'booking_price_active' => 1,
'booking_depositonly' => 1,
))
->execute();
$result = db_insert('booking_price')
->fields(array(
'booking_eventid' => 1,
'booking_price' => '300.00',
'booking_price_descrip' => 'Worker',
'booking_buttonid' => 'R7PR6FASQMHSS',
'booking_price_active' => 1,
'booking_depositonly' => 0,
))
->execute();
$result = db_insert('booking_price')
->fields(array(
'booking_eventid' => 1,
'booking_price' => '260.00',
'booking_price_descrip' => 'Non-Worker',
'booking_buttonid' => 'R2CF3G96WX4XA',
'booking_price_active' => 1,
'booking_depositonly' => 0,
))
->execute();
$result = db_insert('booking_price')
->fields(array(
'booking_eventid' => 1,
'booking_price' => '540.00',
'booking_price_descrip' => 'Married Couple',
'booking_buttonid' => 'QST6YCMZFYEN4',
'booking_price_active' => 1,
'booking_depositonly' => 0,
))
->execute();
$result = db_insert('booking_event')
->fields(array(
'booking_eventname' => 'Study Weekend 2012',
'booking_event_active' => 1,
'booking_register_open' => 1312207199,
'booking_register_close' => 1340459999,
'booking_earlybird_close' => 1328018399,
))
->execute();
//earlybird close is 31st Jan 2012 at 13:59:59 UTC
}
/**
* Implementation of hook_uninstall()
*/
function booking_uninstall() {
// Remove tables.
drupal_uninstall_schema('booking');
}
/**
* Implementation of hook_schema().
*/
function booking_schema() {
$schema['booking_person'] = array(
'fields' => array(
//identifiers
'nid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_event_id' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
'booking_tempid' => array('type' => 'varchar', 'length' => '40', 'not null' => FALSE),
'booking_timestamp' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
'booking_status' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
'booking_barcode' => array('type' => 'varchar', 'length' => '8', '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),
'booking_dob' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
'booking_shirt_size' => array('type' => 'varchar', 'length' => '20', 'not null' => FALSE),
//address details
'booking_street' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
'booking_suburb' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
'booking_postcode' => array('type' => 'varchar', 'length' => '8', 'not null' => FALSE),
'booking_state' => array('type' => 'varchar', 'length' => '30', 'not null' => FALSE),
'booking_country' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
'booking_phone' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
'booking_mobile' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
'booking_email' => array('type' => 'varchar', 'length' => '200', 'not null' => TRUE),
'booking_ecclesia' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
'booking_baptised' => array('type' => 'varchar', 'length' => '1', 'not null' => TRUE),
//relationships
'booking_married' => array('type' => 'varchar', 'length' => '1', 'not null' => TRUE),
'booking_partner_name' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
'booking_partner_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10'),
'booking_room_mate1' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
'booking_room_mate2' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
//helping areas
'booking_readinggroup' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
'booking_help_music' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
'booking_help_reading' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
'booking_help_chairing' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
'booking_help_discussgroup_lead' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
'booking_help_readgroup_lead' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
'booking_help_praying' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
'booking_help_meditations' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
//emergency contact info
'booking_guardian_name' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE),
'booking_guardian_type' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE),
'booking_guardian_phone' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
'booking_guardian_phone_alt' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
'booking_medicare' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
//'booking_medicare_expiry' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
//'booking_medicare_linenum' => array('type' => 'varchar', 'length' => '2', 'not null' => FALSE),
'booking_lifesaver' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
'booking_firstaid' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
'booking_nurse' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
'booking_doctor' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
'booking_dietary' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
'booking_medical_conditions' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
//payment info
'booking_payment_id' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
//'booking_payment_method' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE),
'booking_total_pay_reqd' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '5', 'scale' => '2'),
'booking_amount_paid' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '5', 'scale' => '2'),
'booking_deposit_timestamp' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
),
'primary key' => array('nid'),
);
$schema['booking_event'] = array(
'fields' => array(
'eid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_eventname' => array('type' => 'varchar', 'length' => '200', 'not null' => TRUE),
'booking_event_active' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
'booking_register_open' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
'booking_register_close' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
'booking_earlybird_close' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
'booking_event_start' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
'booking_event_end' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
),
'primary key' => array('eid'),
);
$schema['booking_price'] = array(
'fields' => array(
'pid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_price' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '5', 'scale' => '2'),
'booking_late_price' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '5', 'scale' => '2'),
'booking_price_descrip' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE),
'booking_buttonid' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
'booking_late_buttonid' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
'booking_price_active' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
'booking_earlybird_rate' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
'booking_depositonly' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
),
'primary key' => array('pid'),
);
$schema['booking_payment'] = array(
'fields' => array(
'payid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_person_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_mc_gross' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '5', 'scale' => '2'),
'booking_mc_currency' => array('type' => 'varchar', 'length' => '10', 'not null' => FALSE),
'booking_mc_fee' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '5', 'scale' => '2'),
'booking_quantity' => array('type' => 'int', 'length' => 11, 'not null' => FALSE, 'default' => 0),
'booking_invoice' => array('type' => 'varchar', 'length' => '150', 'not null' => FALSE),
'booking_payer_id' => array('type' => 'varchar', 'length' => '150', 'not null' => FALSE),
'booking_payment_date' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
'booking_payment_status' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
'booking_first_name' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
'booking_last_name' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
'booking_buyer_email' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
'booking_payer_status' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
'booking_item_name' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
'booking_ipn_track_id' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE)),
'primary key' => array('payid'),
);
$schema['booking_variety_options'] = array(
'fields' => array(
'vid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_variety_status' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
'booking_variety_timeslot_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_variety_descrip' => array('type' => 'varchar', 'length' => '500', 'not null' => TRUE),
'booking_variety_maxsize' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_variety_regncount' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
),
'primary key' => array('vid'),
);
return $schema;
}