function events_data_tables_install()
{
    $table_version = EVENT_ESPRESSO_VERSION;
    function event_espresso_install_system_names()
    {
        global $wpdb;
        $system_name_data = "SELECT system_name FROM " . $wpdb->prefix . "events_question";
        $system_names = $wpdb->get_results($system_name_data);
        foreach ($system_names as $system_name) {
            switch ($system_name->system_name) {
                case 'fname':
                    $fname = true;
                    break;
                case 'lname':
                    $lname = true;
                    break;
                case 'email':
                    $email = true;
                    break;
                case 'address':
                    $adress = true;
                    break;
                case 'address2':
                    $adress2 = true;
                    break;
                case 'city':
                    $city = true;
                    break;
                case 'state':
                    $state = true;
                    break;
                case 'zip':
                    $zip = true;
                    break;
                case 'phone':
                    $phone = true;
                    break;
            }
        }
        if ($fname == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'First Name', 'question_type' => 'TEXT', 'system_name' => 'fname', 'required' => 'Y', 'sequence' => '0'), array('%s', '%s', '%s', '%s', '%s'));
        }
        if ($lname == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Last Name', 'question_type' => 'TEXT', 'system_name' => 'lname', 'required' => 'Y', 'sequence' => '1'), array('%s', '%s', '%s', '%s', '%s'));
        }
        if ($email == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Email', 'question_type' => 'TEXT', 'system_name' => 'email', 'required' => 'Y', 'sequence' => '2'), array('%s', '%s', '%s', '%s', '%s'));
        }
        if ($adress == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Address', 'system_name' => 'address', 'sequence' => '3'), array('%s', '%s', '%s'));
        }
        if ($adress2 == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Address 2', 'system_name' => 'address2', 'sequence' => '3'), array('%s', '%s', '%s'));
        }
        if ($city == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'City', 'system_name' => 'city', 'sequence' => '4'), array('%s', '%s', '%s'));
        }
        if ($state == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'State', 'system_name' => 'state', 'sequence' => '5'), array('%s', '%s', '%s'));
        }
        if ($zip == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Zip', 'system_name' => 'zip', 'sequence' => '6'), array('%s', '%s', '%s'));
        }
        if ($zip == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Country', 'system_name' => 'country', 'sequence' => '6'), array('%s', '%s', '%s'));
        }
        if ($phone == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Phone', 'system_name' => 'phone', 'sequence' => '7'), array('%s', '%s', '%s'));
        }
        $system_group = $wpdb->get_row("SELECT system_group FROM " . $wpdb->prefix . "events_qst_group" . " WHERE system_group = 1");
        if ($wpdb->num_rows == 0) {
            $wpdb->insert($wpdb->prefix . "events_qst_group", array('group_name' => 'Personal Information', 'group_identifier' => sanitize_title_with_dashes('personal_information-' . time()), 'system_group' => 1), array('%s', '%s', '%d'));
            $personal_group_id = $wpdb->insert_id;
            $wpdb->insert($wpdb->prefix . "events_qst_group", array('group_name' => 'Address Information', 'group_identifier' => sanitize_title_with_dashes('address_information-' . time()), 'system_group' => 0), array('%s', '%s', '%d'));
            $address_group_id = $wpdb->insert_id;
            $system_name_data = "SELECT id, system_name FROM " . $wpdb->prefix . "events_question" . " where system_name IN ('fname', 'lname', 'email')";
            $system_names = $wpdb->get_results($system_name_data);
            foreach ($system_names as $system_name) {
                $wpdb->insert($wpdb->prefix . "events_qst_group_rel", array('group_id' => $personal_group_id, 'question_id' => $system_name->id), array('%d', '%d'));
            }
            $system_name_data = "SELECT id, system_name FROM " . $wpdb->prefix . "events_question" . " where system_name IN ('address', 'city', 'state', 'zip' )";
            $system_names = $wpdb->get_results($system_name_data);
            foreach ($system_names as $system_name) {
                $wpdb->insert($wpdb->prefix . "events_qst_group_rel", array('group_id' => $address_group_id, 'question_id' => $system_name->id), array('%d', '%d'));
            }
        }
    }
    function espresso_update_event_ids()
    {
        global $wpdb;
        $event_data = "SELECT id FROM " . $wpdb->prefix . "events_detail WHERE event_code='0' ";
        if ($wpdb->num_rows == 0) {
            $wpdb->update($wpdb->prefix . "events_detail", array('group_name' => 'Personal Information', 'group_identifier' => sanitize_title_with_dashes('personal_information-' . time()), 'system_group' => 1), array('%s', '%s', '%d'));
        }
    }
    function event_espresso_update_shortcodes()
    {
        global $wpdb;
        $wpdb->query("SELECT id FROM " . $wpdb->prefix . "posts " . " WHERE (post_content LIKE '%{ESPRESSO_EVENTS}%' AND `post_type` = 'page') OR (post_content LIKE '%{ESPRESSO_PAYMENTS}%'  AND `post_type` = 'page') OR (post_content LIKE '%{ESPRESSO_TXN_PAGE}%'  AND `post_type` = 'page') ");
        if ($wpdb->num_rows > 0) {
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{ESPRESSO_EVENTS}','[ESPRESSO_EVENTS]')");
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{ESPRESSO_PAYMENTS}','[ESPRESSO_PAYMENTS]')");
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{ESPRESSO_TXN_PAGE}','[ESPRESSO_TXN_PAGE]')");
        }
        $wpdb->query("SELECT id FROM " . $wpdb->prefix . "posts " . " WHERE (post_content LIKE '%{EVENTREGIS}%' AND `post_type` = 'page') OR (post_content LIKE '%{EVENTREGPAY}%' AND `post_type` = 'page') OR (post_content LIKE '%{EVENTPAYPALTXN}%' AND `post_type` = 'page') ");
        if ($wpdb->num_rows > 0) {
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{EVENTREGIS}','[ESPRESSO_EVENTS]')");
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{EVENTREGPAY}','[ESPRESSO_PAYMENTS]')");
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{EVENTPAYPALTXN}','[ESPRESSO_TXN_PAGE]')");
        }
    }
    function espresso_update_attendee_qty()
    {
        global $wpdb;
        $sql = "SELECT id FROM " . $wpdb->prefix . "events_attendee WHERE quantity = 0 ";
        $results = $wpdb->get_results($sql);
        if ($wpdb->num_rows > 0) {
            $update_attendee_qty = $wpdb->query("UPDATE " . $wpdb->prefix . "events_attendee SET quantity = 1 OR quantity = '' WHERE quantity = 0");
            do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, " sqldump = " . var_export($results, true) . " ] [ rows affected = " . var_export($update_attendee_qty, true));
        }
    }
    function events_organization_tbl_install()
    {
        global $wpdb;
        $table_name = $wpdb->prefix . "events_organization";
        //Check to see if upgrading from an earlier version.
        if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
            $payment_subject = __('Payment Received for [event_name]', 'event_espresso');
            $payment_message = __('<p>***This Is An Automated Response*** </p><p>Thank You [fname] [lname]</p>  <p>We have just  received a payment in the amount of [event_price] for your registration to [event_name].</p> <p>Transaction ID: [txn_id]</p>', 'event_espresso');
            $message = __('<p>***This is an automated response - Do Not Reply***</p> <p>Thank you [fname] [lname] for registering for [event].</p><p>This event starts at [start_time] on [start_date] and runs until [end_time] on [end_date].</p><p>Location:<br>[location]</p><p>Phone: [location_phone]</p><p>Google Map: [google_map_link]</p><p> We hope that you will find this event both informative and enjoyable. Should you have any questions, please contact [contact].</p><p>If you have not done so already, please submit your payment in the amount of [cost].</p><p>Click here to review your payment information [payment_url].</p><p>Thank You.</p>', 'event_espresso');
            $new_org_options = array('organization' => get_bloginfo('name'), 'organization_street1' => '123 West Somewhere', 'organization_street2' => '', 'organization_city' => 'Some City', 'organization_state' => 'AZ', 'organization_zip' => '84128', 'contact_email' => get_bloginfo('admin_email'), 'default_mail' => 'Y', 'paypal_id' => 'my_email@my_website.com', 'payment_subject' => $payment_subject, 'payment_message' => $payment_message, 'message' => $message, 'default_payment_status' => '', 'surcharge' => '0.00', 'country_id' => '', 'organization_country' => '64', 'currency_symbol' => '$', 'expire_on_registration_end' => 'Y', 'email_before_payment' => 'N', 'email_fancy_headers' => 'N', 'enable_default_style' => 'Y', 'event_ssl_active' => 'N', 'use_venue_manager' => 'Y');
            add_option('events_organization_settings', $new_org_options);
        } else {
            if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") == $table_name) {
                //If an earlier version is found
                $results = $wpdb->get_results("SELECT * FROM " . EVENTS_ORGANIZATION_TABLE . " WHERE id='1'");
                foreach ($results as $result) {
                    $org_id = $result->id;
                    $Organization = $result->organization;
                    $Organization_street1 = $result->organization_street1;
                    $Organization_street2 = $result->organization_street2;
                    $Organization_city = $result->organization_city;
                    $Organization_state = $result->organization_state;
                    $Organization_zip = $result->organization_zip;
                    $contact = $result->contact_email;
                    $registrar = $result->contact_email;
                    $paypal_id = $result->paypal_id;
                    $paypal_cur = $result->currency_format;
                    $event_page_id = $result->event_page_id;
                    $return_url = $result->return_url;
                    $cancel_return = $result->cancel_return;
                    $notify_url = $result->notify_url;
                    $use_sandbox = $result->use_sandbox;
                    $image_url = $result->image_url;
                    $default_mail = $result->default_mail;
                    $payment_subject = $result->payment_subject;
                    $payment_message = $result->payment_message;
                    $message = $result->message;
                }
                switch ($paypal_cur) {
                    case 'USD':
                    case 'HKD':
                    case 'NZD':
                    case 'SGD':
                        $currency_symbol = '$';
                        break;
                    case 'AUD':
                        $currency_symbol = 'A $';
                        break;
                    case 'GBP':
                        $currency_symbol = '&pound;';
                        break;
                    case 'CAD':
                        $currency_symbol = 'C $';
                        break;
                    case 'EUR':
                        $currency_symbol = 'Euro: ';
                        break;
                    case 'JPY':
                        $currency_symbol = '&yen;';
                        break;
                    default:
                        $currency_symbol = '$';
                        break;
                }
                $org_options = array('organization' => $Organization, 'organization_street1' => $Organization_street1, 'organization_street2' => $Organization_street2, 'organization_city' => $Organization_city, 'organization_state' => $Organization_state, 'organization_zip' => $Organization_zip, 'contact_email' => $contact, 'paypal_id' => $paypal_id, 'currency_format' => $paypal_cur, 'currency_symbol' => $currency_symbol, 'event_page_id' => $event_page_id, 'return_url' => $return_url, 'cancel_return' => $cancel_return, 'notify_url' => $notify_url, 'use_sandbox' => $use_sandbox, 'image_url' => $image_url, 'default_mail' => $default_mail, 'payment_subject' => $payment_subject, 'payment_message' => $payment_message, 'message' => $message, 'country_id' => $country_id, 'expire_on_registration_end' => 'Y', 'email_before_payment' => 'N', 'use_personnel_manager' => 'Y', 'use_venue_manager' => 'Y', 'enable_default_style' => 'Y', 'selected_style' => 'event_espresso_style.css', 'show_pending_payment_options' => 'Y', 'show_reg_footer' => 'Y');
                add_option('events_organization_settings', $org_options);
            }
        }
    }
    $table_name = "events_attendee";
    $sql = " id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  registration_id VARCHAR(23) DEFAULT '0',\n\t\t\t\t\t  lname VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  fname VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  address VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  address2 VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  city VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  state VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  zip VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  country_id VARCHAR(128) DEFAULT NULL,\n\t\t\t\t\t  organization_name VARCHAR(50) DEFAULT NULL,\n\t\t\t\t\t  vat_number VARCHAR(20) DEFAULT NULL,\n\t\t\t\t\t  email VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  phone VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  date timestamp NOT NULL default CURRENT_TIMESTAMP,\n\t\t\t\t\t  payment VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  payment_status VARCHAR(45) DEFAULT 'Incomplete',\n\t\t\t\t\t  txn_type VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  txn_id VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  amount_pd decimal(20,2) DEFAULT '0.00',\n\t\t\t\t\t  total_cost decimal(20,2) DEFAULT '0.00',\n\t\t\t\t\t  price_option VARCHAR(100) DEFAULT NULL,\n\t\t\t\t\t  coupon_code VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  quantity VARCHAR(5) DEFAULT '0',\n\t\t\t\t\t  payment_date VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  event_id VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  event_time VARCHAR(15) DEFAULT NULL,\n\t\t\t\t\t  end_time VARCHAR(15) DEFAULT NULL,\n\t\t\t\t\t  start_date VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  end_date VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  attendee_session VARCHAR(250) DEFAULT NULL,\n\t\t\t\t\t  transaction_details TEXT,\n\t\t\t\t\t  pre_approve INT(11) DEFAULT '1',\n\t\t\t\t\t  checked_in INT(1) DEFAULT '0',\n\t\t\t\t\t  checked_in_quantity INT(11) DEFAULT '0',\n\t\t\t\t\t  hashSalt VARCHAR(250) DEFAULT NULL,\n\t\t\t\t\tPRIMARY KEY  (id),\n\t\t\t\t\tKEY `registration_id` (`registration_id`),\n\t\t\t\t\tKEY `event_id` (`event_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_attendee_meta";
    $sql = "ameta_id bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t\t  attendee_id int(11) DEFAULT NULL,\n\t\t\t  meta_key varchar(255) DEFAULT NULL,\n\t\t\t  meta_value longtext,\n\t\t\t  date_added datetime DEFAULT NULL,\n  \t\t\t  PRIMARY KEY  (ameta_id),\n\t\t\t  KEY `attendee_id` (`attendee_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_detail";
    $sql = "id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t  event_code VARCHAR(26) DEFAULT '0',\n\t\t\t\t  event_name VARCHAR(100) DEFAULT NULL,\n\t\t\t\t  event_desc TEXT,\n\t\t\t\t  display_desc VARCHAR (1) DEFAULT 'Y',\n\t\t\t\t  display_reg_form VARCHAR (1) DEFAULT 'Y',\n\t\t\t\t  event_identifier VARCHAR(75) DEFAULT NULL,\n\t\t\t\t  start_date VARCHAR (15) DEFAULT NULL,\n\t\t\t\t  end_date VARCHAR (15) DEFAULT NULL,\n\t\t\t\t  registration_start VARCHAR (15) DEFAULT NULL,\n\t\t\t\t  registration_end VARCHAR (15) DEFAULT NULL,\n\t\t\t\t  registration_startT VARCHAR (15) DEFAULT NULL,\n  \t\t\t\t  registration_endT VARCHAR (15) DEFAULT NULL,\n\t\t\t\t  visible_on VARCHAR(15) DEFAULT NULL,\n\t\t\t\t  address TEXT,\n\t\t\t\t  address2 TEXT,\n\t\t\t\t  city VARCHAR(100) DEFAULT NULL,\n\t\t\t\t  state VARCHAR(100) DEFAULT NULL,\n\t\t\t\t  zip VARCHAR(11) DEFAULT NULL,\n\t\t\t\t  phone VARCHAR(15) DEFAULT NULL,\n\t\t\t\t  venue_title VARCHAR(250) DEFAULT NULL,\n\t\t\t\t  venue_url VARCHAR(250) DEFAULT NULL,\n\t\t\t\t  venue_image TEXT,\n\t\t\t\t  venue_phone VARCHAR(15) DEFAULT NULL,\n\t\t\t\t  virtual_url VARCHAR(250) DEFAULT NULL,\n\t\t\t\t  virtual_phone VARCHAR(15) DEFAULT NULL,\n\t\t\t\t  reg_limit VARCHAR (25) DEFAULT '999999',\n\t\t\t\t  allow_multiple VARCHAR (15) DEFAULT 'N',\n\t\t\t\t  additional_limit INT(10) DEFAULT '5',\n\t\t\t\t  send_mail VARCHAR(2) DEFAULT 'Y',\n\t\t\t\t  is_active VARCHAR(1) DEFAULT 'Y',\n\t\t\t\t  event_status VARCHAR(1) DEFAULT 'A',\n\t\t\t\t  conf_mail TEXT,\n\t\t\t\t  use_coupon_code VARCHAR(1) DEFAULT 'N',\n\t\t\t\t  use_groupon_code VARCHAR(1) DEFAULT 'N',\n\t\t\t\t  category_id TEXT,\n\t\t\t\t  coupon_id TEXT,\n\t\t\t\t  tax_percentage FLOAT,\n\t\t\t\t  tax_mode INT(11),\n\t\t\t\t  member_only VARCHAR(1),\n\t\t\t\t\tpost_id INT(11) DEFAULT NULL,\n\t\t\t\t\tpost_type VARCHAR(50) DEFAULT NULL,\n\t\t\t\t\tcountry VARCHAR(200) DEFAULT NULL,\n\t\t\t\t\texternalURL VARCHAR(255) DEFAULT NULL,\n\t\t\t\t\tearly_disc VARCHAR(10) DEFAULT NULL,\n\t\t\t\t\tearly_disc_date VARCHAR(15) DEFAULT NULL,\n\t\t\t\t\tearly_disc_percentage VARCHAR(1) DEFAULT 'N',\n\t\t\t\t\tquestion_groups LONGTEXT NULL DEFAULT NULL,\n\t\t\t\t\titem_groups LONGTEXT NULL DEFAULT NULL,\n\t\t\t\t\tevent_type VARCHAR(250) DEFAULT NULL,\n\t\t\t\t\tallow_overflow VARCHAR (1) DEFAULT 'N',\n\t\t\t\t\toverflow_event_id INT(10) DEFAULT '0',\n\t\t\t\t\trecurrence_id int(11) DEFAULT '0',\n\t\t\t\t\temail_id int(11) DEFAULT '0',\n\t\t\t\t\talt_email TEXT,\n\t\t\t\t\tevent_meta LONGTEXT DEFAULT NULL,\n\t\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\t\trequire_pre_approval int(11) DEFAULT '0',\n\t\t\t\t\ttimezone_string VARCHAR(250) DEFAULT NULL,\n\t\t\t\t\tlikes int(22) DEFAULT NULL,\n\t\t\t\t\tsubmitted datetime NOT NULL,\n\t\t\t\t PRIMARY KEY  (`id`),\n\t\t\t\t KEY `event_code` (`event_code`),\n\t\t\t\t KEY `wp_user` (`wp_user`),\n\t\t\t\t KEY `event_name` (`event_name`),\n\t\t\t\t KEY `city` (`city`),\n\t\t\t\t KEY `state` (`state`),\n\t\t\t\t KEY `start_date` (`start_date`),\n\t\t\t\t KEY `end_date` (`end_date`),\n\t\t\t\t KEY `registration_start` (`registration_start`),\n\t\t\t\t KEY `registration_end` (`registration_end`),\n\t\t\t\t KEY `reg_limit` (`reg_limit`),\n\t\t\t\t KEY `event_status` (`event_status`),\n\t\t\t\t KEY `recurrence_id` (`recurrence_id`),\n\t\t\t\t KEY `submitted` (`submitted`),\n  \t\t\t\t KEY `likes` (`likes`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_meta";
    $sql = "emeta_id bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t\t  event_id int(11) DEFAULT NULL,\n\t\t\t  meta_key varchar(255) DEFAULT NULL,\n\t\t\t  meta_value longtext,\n\t\t\t  date_added datetime DEFAULT NULL,\n  \t\t\t  PRIMARY KEY  (emeta_id),\n\t\t\t  KEY `event_id` (`event_id`),\n\t\t\t  KEY `meta_key` (`meta_key`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_email";
    $sql = "id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\temail_name VARCHAR(100) DEFAULT NULL,\n\t\t\t\temail_subject VARCHAR(250) DEFAULT NULL,\n\t\t\t\temail_text TEXT,\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tUNIQUE KEY id (id),\n\t\t\t\tKEY `wp_user` (`wp_user`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_category_detail";
    $sql = "id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\tcategory_name VARCHAR(100) DEFAULT NULL,\n\t\t\t\tcategory_identifier VARCHAR(45) DEFAULT NULL,\n\t\t\t\tcategory_desc TEXT,\n\t\t\t\tdisplay_desc VARCHAR (4) DEFAULT NULL,\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tUNIQUE KEY id (id),\n\t\t\t\tKEY `category_identifier` (`category_identifier`),\n\t\t\t\tKEY `wp_user` (`wp_user`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_category_rel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tcat_id int(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY `event_id` (`event_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_venue";
    $sql = "id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\tname VARCHAR(250) DEFAULT NULL,\n\t\t\t\tidentifier VARCHAR(26) DEFAULT '0',\n\t\t\t\taddress VARCHAR(250) DEFAULT NULL,\n\t\t\t\taddress2 VARCHAR(250) DEFAULT NULL,\n\t\t\t\tcity VARCHAR(250) DEFAULT NULL,\n\t\t\t\tstate VARCHAR(250) DEFAULT NULL,\n\t\t\t\tzip VARCHAR(250) DEFAULT NULL,\n\t\t\t\tcountry VARCHAR(250) DEFAULT NULL,\n\t\t\t\tmeta TEXT,\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tUNIQUE KEY id (id),\n\t\t\t  \tKEY `identifier` (`identifier`),\n\t\t\t\tKEY `wp_user` (`wp_user`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_venue_rel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tvenue_id int(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY `event_id` (`event_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_locale";
    $sql = "`id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t  `name` varchar(250) DEFAULT NULL,\n\t\t\t  `identifier` varchar(26) DEFAULT '0',\n\t\t\t  `wp_user` int(22) DEFAULT '1',\n\t\t\t  UNIQUE KEY `id` (`id`),\n\t\t\t  KEY `identifier` (`identifier`),\n\t\t\t  KEY `wp_user` (`wp_user`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_locale_rel";
    $sql = "`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t`venue_id` int(11) DEFAULT NULL,\n\t\t\t\t`locale_id` int(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (`id`),\n\t\t\t  \tKEY `venue_id` (`venue_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_personnel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tname VARCHAR(250) DEFAULT NULL,\n\t\t\t\trole VARCHAR(250) DEFAULT NULL,\n\t\t\t\tidentifier VARCHAR(26) DEFAULT '0',\n\t\t\t\temail TEXT,\n\t\t\t\tmeta TEXT,\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tUNIQUE KEY id (id),\n\t\t\t  \tKEY `identifier` (`identifier`),\n\t\t\t  \tKEY `wp_user` (`wp_user`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_personnel_rel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tperson_id int(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY `event_id` (`event_id`),\n\t\t\t  \tKEY `person_id` (`person_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_discount_rel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tdiscount_id int(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY `event_id` (`event_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_start_end";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tstart_time varchar(10) DEFAULT NULL,\n\t\t\t\tend_time varchar(10) DEFAULT NULL,\n\t\t\t\treg_limit int (15) DEFAULT '0',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY `event_id` (`event_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_prices";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tprice_type varchar(50) DEFAULT NULL,\n\t\t\t\tevent_cost decimal(20,2) NOT NULL DEFAULT '0.00',\n\t\t\t\tsurcharge decimal(10,2) NOT NULL DEFAULT '0.00',\n\t\t\t\tsurcharge_type varchar(10) DEFAULT NULL,\n\t\t\t\tmember_price_type varchar(50) DEFAULT NULL,\n\t\t\t\tmember_price decimal(20,2) NOT NULL DEFAULT '0.00',\n\t\t\t\tmax_qty int(7) DEFAULT '0',\n\t\t\t\tmax_qty_members int(7) DEFAULT '0',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY `event_id` (`event_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_discount_codes";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tcoupon_code varchar(50) DEFAULT NULL,\n\t\t\t\tcoupon_code_price decimal(20,2) DEFAULT NULL,\n\t\t\t\tuse_percentage VARCHAR(1) DEFAULT NULL,\n\t\t\t\tcoupon_code_description TEXT,\n\t\t\t\teach_attendee VARCHAR(1) DEFAULT NULL,\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY `coupon_code` (`coupon_code`),\n\t\t\t  \tKEY `wp_user` (`wp_user`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_multi_event_registration_id_group";
    $sql = "primary_registration_id varchar(255) DEFAULT NULL,\n\t\t\tregistration_id varchar(255) DEFAULT NULL  ";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_attendee_cost";
    $sql = "attendee_id int(11) DEFAULT NULL,\n\t\t\tcost decimal(20,2) DEFAULT '0.00',\n\t\t\tquantity int(11) DEFAULT NULL,\n\t\t\tKEY `attendee_id` (`attendee_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    events_organization_tbl_install();
    $table_name = "events_question";
    $sql = "id int(11) unsigned NOT NULL auto_increment,\n\t\t\tsequence INT(11) NOT NULL default '0',\n\t\t\tquestion_type enum('TEXT','TEXTAREA','MULTIPLE','SINGLE','DROPDOWN') NOT NULL default 'TEXT',\n\t\t\tquestion text NOT NULL,\n\t\t\tsystem_name varchar(15) DEFAULT NULL,\n\t\t\tresponse text NULL,\n\t\t\trequired ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N',\n\t\t\trequired_text text NULL,\n\t\t\tadmin_only ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N',\n\t\t\twp_user int(22) DEFAULT '1',\n\t\t\tPRIMARY KEY  (id),\n\t\t\tKEY `wp_user` (`wp_user`),\n\t\t\tKEY `system_name` (`system_name`),\n\t\t\tKEY `admin_only` (`admin_only`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_qst_group";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tgroup_name VARCHAR(100) NOT NULL default 'NULL',\n\t\t\t\tgroup_identifier VARCHAR(45) NOT NULL default 'NULL',\n\t\t\t\tgroup_description TEXT,\n\t\t\t\tgroup_order int(11) DEFAULT '0',\n\t\t\t\tshow_group_name TINYINT( 1 ) NOT NULL DEFAULT '1',\n\t\t\t\tshow_group_description TINYINT( 1 ) NOT NULL DEFAULT '1',\n\t\t\t\tsystem_group TINYINT( 1 ) NOT NULL DEFAULT '0',\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY `system_group` (`system_group`),\n\t\t\t  \tKEY `wp_user` (`wp_user`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_qst_group_rel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tgroup_id int(11)  NOT NULL,\n\t\t\t\tquestion_id int(11) NOT NULL,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY `group_id` (`group_id`),\n\t\t\t  \tKEY `question_id` (`question_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    $table_name = "events_answer";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\tregistration_id varchar(23) NOT NULL,\n\t\t\tattendee_id int(11) NOT NULL default '0',\n\t\t\tquestion_id int(11) NOT NULL default '0',\n\t\t\tanswer text NOT NULL,\n\t\t\tPRIMARY KEY  (id),\n\t\t\tKEY `registration_id` (`registration_id`),\n\t\t\tKEY `attendee_id` (`attendee_id`)";
    event_espresso_run_install($table_name, $table_version, $sql);
    event_espresso_install_system_names();
    event_espresso_create_upload_directories();
    event_espresso_update_shortcodes();
    event_espresso_update_attendee_data();
    espresso_update_attendee_qty();
}
function events_data_tables_install()
{
    function event_espresso_install_system_names()
    {
        global $wpdb;
        $system_name_data = "SELECT system_name FROM " . $wpdb->prefix . "events_question";
        $system_names = $wpdb->get_results($system_name_data);
        $fname = false;
        $lname = false;
        $email = false;
        $adress = false;
        $adress2 = false;
        $city = false;
        $state = false;
        $country = false;
        $zip = false;
        $phone = false;
        foreach ($system_names as $system_name) {
            switch ($system_name->system_name) {
                case 'fname':
                    $fname = true;
                    break;
                case 'lname':
                    $lname = true;
                    break;
                case 'email':
                    $email = true;
                    break;
                case 'address':
                    $adress = true;
                    break;
                case 'address2':
                    $adress2 = true;
                    break;
                case 'city':
                    $city = true;
                    break;
                case 'state':
                    $state = true;
                    break;
                case 'country':
                    $country = true;
                    break;
                case 'zip':
                    $zip = true;
                    break;
                case 'phone':
                    $phone = true;
                    break;
            }
        }
        if ($fname == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'First Name', 'question_type' => 'TEXT', 'system_name' => 'fname', 'required' => 'Y', 'sequence' => '0'), array('%s', '%s', '%s', '%s', '%s'));
        }
        if ($lname == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Last Name', 'question_type' => 'TEXT', 'system_name' => 'lname', 'required' => 'Y', 'sequence' => '1'), array('%s', '%s', '%s', '%s', '%s'));
        }
        if ($email == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Email', 'question_type' => 'TEXT', 'system_name' => 'email', 'required' => 'Y', 'sequence' => '2'), array('%s', '%s', '%s', '%s', '%s'));
        }
        if ($adress == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Address', 'system_name' => 'address', 'sequence' => '3'), array('%s', '%s', '%s'));
        }
        if ($adress2 == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Address 2', 'system_name' => 'address2', 'sequence' => '3'), array('%s', '%s', '%s'));
        }
        if ($city == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'City', 'system_name' => 'city', 'sequence' => '4'), array('%s', '%s', '%s'));
        }
        if ($state == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'State', 'system_name' => 'state', 'sequence' => '5'), array('%s', '%s', '%s'));
        }
        if ($country == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Country', 'system_name' => 'country', 'sequence' => '6'), array('%s', '%s', '%s'));
        }
        if ($zip == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Zip', 'system_name' => 'zip', 'sequence' => '6'), array('%s', '%s', '%s'));
        }
        if ($phone == false) {
            $wpdb->insert($wpdb->prefix . "events_question", array('question' => 'Phone', 'system_name' => 'phone', 'sequence' => '7'), array('%s', '%s', '%s'));
        }
        $system_group = $wpdb->get_row("SELECT system_group FROM " . $wpdb->prefix . "events_qst_group" . " WHERE system_group = 1");
        if ($wpdb->num_rows == 0) {
            $wpdb->insert($wpdb->prefix . "events_qst_group", array('group_name' => 'Personal Information', 'group_identifier' => sanitize_title_with_dashes('personal_information-' . time()), 'system_group' => 1), array('%s', '%s', '%d'));
            $personal_group_id = $wpdb->insert_id;
            $wpdb->insert($wpdb->prefix . "events_qst_group", array('group_name' => 'Address Information', 'group_identifier' => sanitize_title_with_dashes('address_information-' . time()), 'system_group' => 0), array('%s', '%s', '%d'));
            $address_group_id = $wpdb->insert_id;
            $system_name_data = "SELECT id, system_name FROM " . $wpdb->prefix . "events_question" . " where system_name IN ('fname', 'lname', 'email')";
            $system_names = $wpdb->get_results($system_name_data);
            foreach ($system_names as $system_name) {
                $wpdb->insert($wpdb->prefix . "events_qst_group_rel", array('group_id' => $personal_group_id, 'question_id' => $system_name->id), array('%d', '%d'));
            }
            $system_name_data = "SELECT id, system_name FROM " . $wpdb->prefix . "events_question" . " where system_name IN ('address', 'city', 'state', 'zip' )";
            $system_names = $wpdb->get_results($system_name_data);
            foreach ($system_names as $system_name) {
                $wpdb->insert($wpdb->prefix . "events_qst_group_rel", array('group_id' => $address_group_id, 'question_id' => $system_name->id), array('%d', '%d'));
            }
        }
    }
    function espresso_update_event_ids()
    {
        global $wpdb;
        $event_data = "SELECT id FROM " . $wpdb->prefix . "events_detail WHERE event_code='0' ";
        if ($wpdb->num_rows == 0) {
            $wpdb->update($wpdb->prefix . "events_detail", array('group_name' => 'Personal Information', 'group_identifier' => sanitize_title_with_dashes('personal_information-' . time()), 'system_group' => 1), array('%s', '%s', '%d'));
        }
    }
    function event_espresso_update_shortcodes()
    {
        global $wpdb;
        $wpdb->query("SELECT id FROM " . $wpdb->prefix . "posts " . " WHERE (post_content LIKE '%{ESPRESSO_EVENTS}%' AND post_type = 'page') OR (post_content LIKE '%{ESPRESSO_PAYMENTS}%'  AND post_type = 'page') OR (post_content LIKE '%{ESPRESSO_TXN_PAGE}%'  AND post_type = 'page') ");
        if ($wpdb->num_rows > 0) {
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{ESPRESSO_EVENTS}','[ESPRESSO_EVENTS]')");
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{ESPRESSO_PAYMENTS}','[ESPRESSO_PAYMENTS]')");
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{ESPRESSO_TXN_PAGE}','[ESPRESSO_TXN_PAGE]')");
        }
        $wpdb->query("SELECT id FROM " . $wpdb->prefix . "posts " . " WHERE (post_content LIKE '%{EVENTREGIS}%' AND post_type = 'page') OR (post_content LIKE '%{EVENTREGPAY}%' AND post_type = 'page') OR (post_content LIKE '%{EVENTPAYPALTXN}%' AND post_type = 'page') ");
        if ($wpdb->num_rows > 0) {
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{EVENTREGIS}','[ESPRESSO_EVENTS]')");
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{EVENTREGPAY}','[ESPRESSO_PAYMENTS]')");
            $wpdb->query("UPDATE " . $wpdb->prefix . "posts SET post_content = REPLACE(post_content,'{EVENTPAYPALTXN}','[ESPRESSO_TXN_PAGE]')");
        }
    }
    function espresso_update_attendee_qty()
    {
        global $wpdb;
        $sql = "SELECT id FROM " . $wpdb->prefix . "events_attendee WHERE quantity = 0 ";
        $results = $wpdb->get_results($sql);
        if ($wpdb->num_rows > 0) {
            $update_attendee_qty = $wpdb->query("UPDATE " . $wpdb->prefix . "events_attendee SET quantity = 1 OR quantity = '' WHERE quantity = 0");
            do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, " sqldump = " . var_export($results, true) . " ] [ rows affected = " . var_export($update_attendee_qty, true));
        }
    }
    function espresso_answer_fix()
    {
        global $wpdb;
        $sql = "SHOW COLUMNS FROM " . EVENTS_ANSWER_TABLE . " LIKE 'id';";
        $test = $wpdb->query($sql);
        if (empty($test)) {
            $sql = "ALTER TABLE " . EVENTS_ANSWER_TABLE . " DROP PRIMARY KEY";
            $wpdb->query($sql);
            $sql = "ALTER TABLE  " . EVENTS_ANSWER_TABLE . " ADD  id INT( 11 ) unsigned NOT NULL AUTO_INCREMENT FIRST , ADD PRIMARY KEY (  id )";
            $wpdb->query($sql);
        }
    }
    function espresso_added_by_admin_session_id_fix()
    {
        global $wpdb;
        $sql = "SELECT id FROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session=''";
        $ids = $wpdb->get_col($sql);
        foreach ($ids as $id) {
            $wpdb->update(EVENTS_ATTENDEE_TABLE, array('attendee_session' => uniqid('', true)), array('id' => $id));
        }
    }
    //This function was creating a new psot everytime EE was activated
    function espresso_add_cancel_shortcode()
    {
        global $org_options;
        $org_options = get_option('events_organization_settings');
        if (!empty($org_options['cancel_return'])) {
            $cancel_page = get_page($org_options['cancel_return'], ARRAY_A);
            $test = strpos($cancel_page['post_content'], '[ESPRESSO_CANCELLED]');
            if ($test === false) {
                $cancel_page['post_content'] = $cancel_page['post_content'] . '[ESPRESSO_CANCELLED]';
                wp_update_post($cancel_page);
            }
        }
    }
    /**
     * espresso_ensure_event_status_is_not_blank
     * 
     * ensure that for each event has an event status
     * if the event status is missing, give it a default value of  'A'
     * 
     * @since 3.1.32
     * @return void
     */
    function espresso_ensure_event_status_is_not_blank()
    {
        global $wpdb;
        $SQL = "SELECT id FROM " . $wpdb->prefix . "events_detail WHERE event_status = '' ORDER BY id";
        if ($events = $wpdb->get_results($SQL)) {
            foreach ($events as $event) {
                $wpdb->update($wpdb->prefix . "events_detail", array('event_status' => 'A'), array('id' => $event->id), array('%s'), array('%d'));
            }
        }
    }
    function events_organization_tbl_install()
    {
        global $wpdb;
        $table_name = $wpdb->prefix . "events_organization";
        //Check to see if upgrading from an earlier version.
        if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
            $payment_subject = __('Payment Received for [event_name]', 'event_espresso');
            $payment_message = __('<p>***This Is An Automated Response*** </p><p>Thank You [fname] [lname]</p>  <p>We have just  received a payment in the amount of [event_price] for your registration to [event_name].</p> <p>Transaction ID: [txn_id]</p>', 'event_espresso');
            $message = __('<p>***This is an automated response - Do Not Reply***</p> <p>Thank you [fname] [lname] for registering for [event].</p><p>This event starts at [start_time] on [start_date] and runs until [end_time] on [end_date].</p><p>Location:<br>[location]</p><p>Phone: [location_phone]</p><p>Google Map: [google_map_link]</p><p> We hope that you will find this event both informative and enjoyable. Should you have any questions, please contact [contact].</p><p>If you have not done so already, please submit your payment in the amount of [cost].</p><p>Click here to review your payment information [payment_url].</p><p>[edit_attendee_link]</p><p>Thank You.</p>', 'event_espresso');
            $new_org_options = array('organization' => get_bloginfo('name'), 'organization_street1' => '123 West Somewhere', 'organization_street2' => '', 'organization_city' => 'Some City', 'organization_state' => 'AZ', 'organization_zip' => '84128', 'contact_email' => get_bloginfo('admin_email'), 'default_mail' => 'Y', 'paypal_id' => 'my_email@my_website.com', 'payment_subject' => $payment_subject, 'payment_message' => $payment_message, 'message' => $message, 'default_payment_status' => '', 'surcharge' => '0.00', 'country_id' => '', 'organization_country' => '64', 'currency_symbol' => '$', 'expire_on_registration_end' => 'Y', 'email_before_payment' => 'N', 'email_fancy_headers' => 'N', 'enable_default_style' => 'N', 'event_ssl_active' => 'N', 'use_venue_manager' => 'Y', 'enable_default_style' => 'N', 'selected_style' => 'event_espresso_style.css', 'show_pending_payment_options' => 'Y', 'show_reg_footer' => 'Y', 'skip_confirmation_page' => 'N', 'allow_mer_discounts' => 'N', 'allow_mer_vouchers' => 'N', 'display_short_description_in_event_list' => 'N', 'display_description_on_multi_reg_page' => 'N', 'display_address_in_event_list' => 'N', 'display_address_in_regform' => 'Y', 'use_custom_post_types' => 'N', 'display_ical_download' => 'Y', 'display_featured_image' => 'N', 'themeroller' => array('themeroller_style' => 'smoothness'), 'style_settings' => array('disable_legacy_styles' => 'Y', 'enable_default_style' => 'Y', 'css_name' => ''));
            add_option('events_organization_settings', $new_org_options);
        } else {
            if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") == $table_name) {
                //If an earlier version is found
                $results = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "events_organization" . " WHERE id='1'");
                foreach ($results as $result) {
                    $org_id = $result->id;
                    $Organization = $result->organization;
                    $Organization_street1 = $result->organization_street1;
                    $Organization_street2 = $result->organization_street2;
                    $Organization_city = $result->organization_city;
                    $Organization_state = $result->organization_state;
                    $Organization_zip = $result->organization_zip;
                    $contact = $result->contact_email;
                    $registrar = $result->contact_email;
                    $paypal_id = $result->paypal_id;
                    $paypal_cur = $result->currency_format;
                    $event_page_id = $result->event_page_id;
                    $return_url = $result->return_url;
                    $cancel_return = $result->cancel_return;
                    $notify_url = $result->notify_url;
                    $use_sandbox = $result->use_sandbox;
                    $image_url = $result->image_url;
                    $default_mail = $result->default_mail;
                    $payment_subject = $result->payment_subject;
                    $payment_message = $result->payment_message;
                    $message = $result->message;
                }
                switch ($paypal_cur) {
                    case 'USD':
                    case 'HKD':
                    case 'NZD':
                    case 'SGD':
                        $currency_symbol = '$';
                        break;
                    case 'AUD':
                        $currency_symbol = 'A $';
                        break;
                    case 'GBP':
                        $currency_symbol = '&pound;';
                        break;
                    case 'CAD':
                        $currency_symbol = 'C $';
                        break;
                    case 'EUR':
                        $currency_symbol = 'Euro: ';
                        break;
                    case 'JPY':
                        $currency_symbol = '&yen;';
                        break;
                    default:
                        $currency_symbol = '$';
                        break;
                }
                $org_options = array('organization' => $Organization, 'organization_street1' => $Organization_street1, 'organization_street2' => $Organization_street2, 'organization_city' => $Organization_city, 'organization_state' => $Organization_state, 'organization_zip' => $Organization_zip, 'contact_email' => $contact, 'paypal_id' => $paypal_id, 'currency_format' => $paypal_cur, 'currency_symbol' => $currency_symbol, 'event_page_id' => $event_page_id, 'return_url' => $return_url, 'cancel_return' => $cancel_return, 'notify_url' => $notify_url, 'use_sandbox' => $use_sandbox, 'image_url' => $image_url, 'default_mail' => $default_mail, 'payment_subject' => $payment_subject, 'payment_message' => $payment_message, 'message' => $message, 'country_id' => $country_id, 'email_before_payment' => 'N', 'use_personnel_manager' => 'Y', 'use_venue_manager' => 'Y', 'enable_default_style' => 'N', 'selected_style' => 'event_espresso_style.css', 'show_pending_payment_options' => 'Y', 'show_reg_footer' => 'Y', 'skip_confirmation_page' => 'N', 'allow_mer_discounts' => 'N', 'allow_mer_vouchers' => 'N');
                add_option('events_organization_settings', $org_options);
            }
        }
    }
    $table_name = "events_attendee";
    $sql = "id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  registration_id VARCHAR(23) DEFAULT '0',\n\t\t\t\t\t  is_primary tinyint(1) DEFAULT '0',\n\t\t\t\t\t  lname VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  fname VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  address VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  address2 VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  city VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  state VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  zip VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  country_id VARCHAR(128) DEFAULT NULL,\n\t\t\t\t\t  organization_name VARCHAR(50) DEFAULT NULL,\n\t\t\t\t\t  vat_number VARCHAR(20) DEFAULT NULL,\n\t\t\t\t\t  email VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  phone VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  date timestamp NOT NULL default CURRENT_TIMESTAMP,\n\t\t\t\t\t  price_option VARCHAR(100) DEFAULT NULL,\n\t\t\t\t\t  orig_price decimal(20,2) DEFAULT '0.00',\n\t\t\t\t\t  final_price decimal(20,2) DEFAULT '0.00',\n\t\t\t\t\t  quantity tinyint(1) DEFAULT '0',\n\t\t\t\t\t  total_cost decimal(20,2) DEFAULT '0.00',\n\t\t\t\t\t  amount_pd decimal(20,2) DEFAULT '0.00',\n\t\t\t\t\t  coupon_code VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  payment VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  payment_status VARCHAR(45) DEFAULT 'Incomplete',\n\t\t\t\t\t  txn_type VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  txn_id VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  payment_date VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  event_id VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  event_time VARCHAR(15) DEFAULT NULL,\n\t\t\t\t\t  end_time VARCHAR(15) DEFAULT NULL,\n\t\t\t\t\t  start_date VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  end_date VARCHAR(45) DEFAULT NULL,\n\t\t\t\t\t  attendee_session VARCHAR(250) DEFAULT NULL,\n\t\t\t\t\t  transaction_details TEXT,\n\t\t\t\t\t  pre_approve INT(11) DEFAULT '1',\n\t\t\t\t\t  checked_in INT(1) DEFAULT '0',\n\t\t\t\t\t  checked_in_quantity INT(11) DEFAULT '0',\n\t\t\t\t\t  hashSalt VARCHAR(250) DEFAULT NULL,\n\t\t\t\t\tPRIMARY KEY  (id),\n\t\t\t\t\tKEY registration_id (registration_id),\n\t\t\t\t\tKEY event_id (event_id)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_attendee_meta";
    $sql = "ameta_id bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t\t  attendee_id int(11) DEFAULT NULL,\n\t\t\t  meta_key varchar(255) DEFAULT NULL,\n\t\t\t  meta_value longtext,\n\t\t\t  date_added datetime DEFAULT NULL,\n\t\t\t  date_updated datetime DEFAULT NULL,\n  \t\t\t  PRIMARY KEY  (ameta_id),\n\t\t\t  KEY attendee_id (attendee_id)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_detail";
    $sql = "id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t  event_code VARCHAR(26) DEFAULT '0',\n\t\t\t\t  event_name VARCHAR(100) DEFAULT NULL,\n\t\t\t\t  event_desc TEXT,\n\t\t\t\t  display_desc VARCHAR (1) DEFAULT 'Y',\n\t\t\t\t  display_reg_form VARCHAR (1) DEFAULT 'Y',\n\t\t\t\t  event_identifier VARCHAR(75) DEFAULT NULL,\n\t\t\t\t  start_date VARCHAR (15) DEFAULT NULL,\n\t\t\t\t  end_date VARCHAR (15) DEFAULT NULL,\n\t\t\t\t  registration_start VARCHAR (15) DEFAULT NULL,\n\t\t\t\t  registration_end VARCHAR (15) DEFAULT NULL,\n\t\t\t\t  registration_startT VARCHAR (15) DEFAULT NULL,\n  \t\t\t\t  registration_endT VARCHAR (15) DEFAULT NULL,\n\t\t\t\t  visible_on VARCHAR(15) DEFAULT NULL,\n\t\t\t\t  address TEXT,\n\t\t\t\t  address2 TEXT,\n\t\t\t\t  city VARCHAR(100) DEFAULT NULL,\n\t\t\t\t  state VARCHAR(100) DEFAULT NULL,\n\t\t\t\t  zip VARCHAR(11) DEFAULT NULL,\n\t\t\t\t  phone VARCHAR(15) DEFAULT NULL,\n\t\t\t\t  venue_title VARCHAR(250) DEFAULT NULL,\n\t\t\t\t  venue_url VARCHAR(250) DEFAULT NULL,\n\t\t\t\t  venue_image TEXT,\n\t\t\t\t  venue_phone VARCHAR(15) DEFAULT NULL,\n\t\t\t\t  virtual_url VARCHAR(250) DEFAULT NULL,\n\t\t\t\t  virtual_phone VARCHAR(15) DEFAULT NULL,\n\t\t\t\t  reg_limit VARCHAR (25) DEFAULT '999999',\n\t\t\t\t  allow_multiple VARCHAR (15) DEFAULT 'N',\n\t\t\t\t  additional_limit INT(10) DEFAULT '5',\n\t\t\t\t  send_mail VARCHAR(2) DEFAULT 'Y',\n\t\t\t\t  is_active VARCHAR(1) DEFAULT 'Y',\n\t\t\t\t  event_status VARCHAR(2) DEFAULT 'A',\n\t\t\t\t  conf_mail TEXT,\n\t\t\t\t  use_coupon_code VARCHAR(1) DEFAULT 'N',\n\t\t\t\t  use_groupon_code VARCHAR(1) DEFAULT 'N',\n\t\t\t\t  category_id TEXT,\n\t\t\t\t  coupon_id TEXT,\n\t\t\t\t  tax_percentage FLOAT,\n\t\t\t\t  tax_mode INT(11),\n\t\t\t\t  member_only VARCHAR(1),\n\t\t\t\t\tpost_id INT(11) DEFAULT NULL,\n\t\t\t\t\tpost_type VARCHAR(50) DEFAULT NULL,\n\t\t\t\t\tcountry VARCHAR(200) DEFAULT NULL,\n\t\t\t\t\texternalURL VARCHAR(255) DEFAULT NULL,\n\t\t\t\t\tearly_disc VARCHAR(10) DEFAULT NULL,\n\t\t\t\t\tearly_disc_date VARCHAR(15) DEFAULT NULL,\n\t\t\t\t\tearly_disc_percentage VARCHAR(1) DEFAULT 'N',\n\t\t\t\t\tquestion_groups LONGTEXT NULL DEFAULT NULL,\n\t\t\t\t\titem_groups LONGTEXT NULL DEFAULT NULL,\n\t\t\t\t\tevent_type VARCHAR(250) DEFAULT NULL,\n\t\t\t\t\tallow_overflow VARCHAR (1) DEFAULT 'N',\n\t\t\t\t\toverflow_event_id INT(10) DEFAULT '0',\n\t\t\t\t\trecurrence_id int(11) DEFAULT '0',\n\t\t\t\t\temail_id int(11) DEFAULT '0',\n\t\t\t\t\talt_email TEXT,\n\t\t\t\t\tevent_meta LONGTEXT DEFAULT NULL,\n\t\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\t\trequire_pre_approval int(11) DEFAULT '0',\n\t\t\t\t\ttimezone_string VARCHAR(250) DEFAULT NULL,\n\t\t\t\t\tlikes int(22) DEFAULT NULL,\n\t\t\t\t\tticket_id int(22) DEFAULT '0',\n\t\t\t\t\tsubmitted datetime NOT NULL,\n\t\t\t\t PRIMARY KEY  (id),\n\t\t\t\t KEY event_code (event_code),\n\t\t\t\t KEY wp_user (wp_user),\n\t\t\t\t KEY event_name (event_name),\n\t\t\t\t KEY city (city),\n\t\t\t\t KEY state (state),\n\t\t\t\t KEY start_date (start_date),\n\t\t\t\t KEY end_date (end_date),\n\t\t\t\t KEY registration_start (registration_start),\n\t\t\t\t KEY registration_end (registration_end),\n\t\t\t\t KEY reg_limit (reg_limit),\n\t\t\t\t KEY event_status (event_status),\n\t\t\t\t KEY recurrence_id (recurrence_id),\n\t\t\t\t KEY submitted (submitted),\n  \t\t\t\t KEY likes (likes)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_meta";
    $sql = "emeta_id bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t\t  event_id int(11) DEFAULT NULL,\n\t\t\t  meta_key varchar(255) DEFAULT NULL,\n\t\t\t  meta_value longtext,\n\t\t\t  date_added datetime DEFAULT NULL,\n  \t\t\t  PRIMARY KEY  (emeta_id),\n\t\t\t  KEY event_id (event_id),\n\t\t\t  KEY meta_key (meta_key)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_email";
    $sql = "id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\temail_name VARCHAR(100) DEFAULT NULL,\n\t\t\t\temail_subject VARCHAR(250) DEFAULT NULL,\n\t\t\t\temail_text TEXT,\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t\tKEY wp_user (wp_user)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_category_detail";
    $sql = "id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\tcategory_name VARCHAR(100) DEFAULT NULL,\n\t\t\t\tcategory_identifier VARCHAR(45) DEFAULT NULL,\n\t\t\t\tcategory_desc TEXT,\n\t\t\t\tcategory_meta TEXT,\n\t\t\t\tdisplay_desc VARCHAR (4) DEFAULT NULL,\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t\tKEY category_identifier (category_identifier),\n\t\t\t\tKEY wp_user (wp_user)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_category_rel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tcat_id int(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY event_id (event_id)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_venue";
    $sql = "id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\tname VARCHAR(250) DEFAULT NULL,\n\t\t\t\tidentifier VARCHAR(26) DEFAULT '0',\n\t\t\t\taddress VARCHAR(250) DEFAULT NULL,\n\t\t\t\taddress2 VARCHAR(250) DEFAULT NULL,\n\t\t\t\tcity VARCHAR(250) DEFAULT NULL,\n\t\t\t\tstate VARCHAR(250) DEFAULT NULL,\n\t\t\t\tzip VARCHAR(250) DEFAULT NULL,\n\t\t\t\tcountry VARCHAR(250) DEFAULT NULL,\n\t\t\t\tmeta TEXT,\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY identifier (identifier),\n\t\t\t\tKEY wp_user (wp_user)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_venue_rel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tvenue_id int(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY event_id (event_id)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_locale";
    $sql = "id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t  name varchar(250) DEFAULT NULL,\n\t\t\t  identifier varchar(26) DEFAULT '0',\n\t\t\t  wp_user int(22) DEFAULT '1',\n\t\t\t  PRIMARY KEY  (id),\n\t\t\t  KEY identifier (identifier),\n\t\t\t  KEY wp_user (wp_user)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_locale_rel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tvenue_id int(11) DEFAULT NULL,\n\t\t\t\tlocale_id int(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY venue_id (venue_id)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_personnel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tname VARCHAR(250) DEFAULT NULL,\n\t\t\t\trole VARCHAR(250) DEFAULT NULL,\n\t\t\t\tidentifier VARCHAR(26) DEFAULT '0',\n\t\t\t\temail TEXT,\n\t\t\t\tmeta TEXT,\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY identifier (identifier),\n\t\t\t  \tKEY wp_user (wp_user)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_personnel_rel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tperson_id int(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY event_id (event_id),\n\t\t\t  \tKEY person_id (person_id)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_discount_rel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tdiscount_id int(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY event_id (event_id)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_start_end";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tstart_time varchar(10) DEFAULT NULL,\n\t\t\t\tend_time varchar(10) DEFAULT NULL,\n\t\t\t\treg_limit int (15) DEFAULT '0',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY event_id (event_id)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_prices";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tevent_id int(11) DEFAULT NULL,\n\t\t\t\tprice_type varchar(50) DEFAULT NULL,\n\t\t\t\tevent_cost decimal(20,2) NOT NULL DEFAULT '0.00',\n\t\t\t\tsurcharge decimal(10,2) NOT NULL DEFAULT '0.00',\n\t\t\t\tsurcharge_type varchar(10) DEFAULT NULL,\n\t\t\t\tmember_price_type varchar(50) DEFAULT NULL,\n\t\t\t\tmember_price decimal(20,2) NOT NULL DEFAULT '0.00',\n\t\t\t\tmax_qty int(7) DEFAULT '0',\n\t\t\t\tmax_qty_members int(7) DEFAULT '0',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY event_id (event_id)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_discount_codes";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tcoupon_code varchar(50) DEFAULT NULL,\n\t\t\t\tcoupon_code_price decimal(20,2) DEFAULT NULL,\n\t\t\t\tuse_percentage VARCHAR(1) DEFAULT NULL,\n\t\t\t\tcoupon_code_description TEXT,\n\t\t\t\teach_attendee VARCHAR(1) DEFAULT NULL,\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY coupon_code (coupon_code),\n\t\t\t  \tKEY wp_user (wp_user)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_multi_event_registration_id_group";
    $sql = "primary_registration_id varchar(255) DEFAULT NULL,\n\t\t\tregistration_id varchar(255) DEFAULT NULL,\n\t\t\tKEY primary_registration_id (primary_registration_id),\n\t\t\tKEY registration_id (registration_id)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_question";
    $sql = "id int(11) unsigned NOT NULL auto_increment,\n\t\t\tsequence INT(11) NOT NULL default '0',\n\t\t\tquestion_type enum('TEXT','TEXTAREA','MULTIPLE','SINGLE','DROPDOWN') NOT NULL default 'TEXT',\n\t\t\tquestion text NOT NULL,\n\t\t\tsystem_name varchar(15) DEFAULT NULL,\n\t\t\tresponse text NULL,\n\t\t\trequired ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N',\n\t\t\tprice_mod ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N',\n\t\t\trequired_text text NULL,\n\t\t\tadmin_only ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N',\n\t\t\twp_user int(22) DEFAULT '1',\n\t\t\tPRIMARY KEY  (id),\n\t\t\tKEY wp_user (wp_user),\n\t\t\tKEY system_name (system_name),\n\t\t\tKEY admin_only (admin_only)";
    $sql = apply_filters('espresso_filter_hook_events_question_sql', $sql);
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_qst_group";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tgroup_name VARCHAR(100) NOT NULL default 'NULL',\n\t\t\t\tgroup_identifier VARCHAR(45) NOT NULL default 'NULL',\n\t\t\t\tgroup_description TEXT,\n\t\t\t\tgroup_order int(11) DEFAULT '0',\n\t\t\t\tshow_group_name TINYINT( 1 ) NOT NULL DEFAULT '1',\n\t\t\t\tshow_group_description TINYINT( 1 ) NOT NULL DEFAULT '1',\n\t\t\t\tsystem_group TINYINT( 1 ) NOT NULL DEFAULT '0',\n\t\t\t\twp_user int(22) DEFAULT '1',\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY system_group (system_group),\n\t\t\t  \tKEY wp_user (wp_user)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_qst_group_rel";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\tgroup_id int(11)  NOT NULL,\n\t\t\t\tquestion_id int(11) NOT NULL,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t  \tKEY group_id (group_id),\n\t\t\t  \tKEY question_id (question_id)";
    event_espresso_run_install($table_name, '', $sql);
    $table_name = "events_answer";
    $sql = "id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\tregistration_id varchar(23) NOT NULL,\n\t\t\tattendee_id int(11) NOT NULL default '0',\n\t\t\tquestion_id int(11) NOT NULL default '0',\n\t\t\tanswer text NOT NULL,\n\t\t\tPRIMARY KEY  (id),\n\t\t\tKEY registration_id (registration_id),\n\t\t\tKEY attendee_id (attendee_id)";
    event_espresso_run_install($table_name, '', $sql);
    events_organization_tbl_install();
    event_espresso_install_system_names();
    event_espresso_create_upload_directories();
    event_espresso_update_shortcodes();
    event_espresso_update_attendee_data();
    espresso_update_attendee_qty();
    espresso_answer_fix();
    espresso_added_by_admin_session_id_fix();
    espresso_add_cancel_shortcode();
    espresso_ensure_event_status_is_not_blank();
    // grab espresso_db_update option
    $espresso_db_update = get_option('espresso_db_update', array());
    // make sure it's an array
    $espresso_db_update = is_array($espresso_db_update) ? $espresso_db_update : array($espresso_db_update);
    // add current EE version to list
    $espresso_db_update[] = EVENT_ESPRESSO_VERSION;
    // resave
    update_option('espresso_db_update', $espresso_db_update);
}
function event_espresso_support()
{
    ?>

	<div class="wrap">
	  <div id="icon-options-event" class="icon32"></div>
	  <h2>
		<?php 
    _e('Help and Support', 'event_espresso');
    ?>
	  </h2>
		<?php 
    if (isset($_REQUEST['action'])) {
        switch ($_REQUEST['action']) {
            case "update_event_dates":
                update_event_data();
                break;
            case "event_espresso_update_attendee_data":
                event_espresso_update_attendee_data();
                break;
        }
    }
    ?>
	<?php 
    ob_start();
    ?>
		<div class="meta-box-sortables ui-sortable">
			<ul id="event_espresso-sortables" class="help-support">
				<li>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Quick Links', 'event_espresso');
    ?>
							</h3>
							<div class="inside">
								<div class="padding">
									<ul id="quick-links">
										<li><a href="#install">
												<?php 
    _e('Installation', 'event_espresso');
    ?>
											</a></li>
										<li><a href="#plugins">
												<?php 
    _e('Recommended Plugins', 'event_espresso');
    ?>
											</a></li>
										<li><a href="#hire_devs">
												<?php 
    _e('Hire a Developer', 'event_espresso');
    ?>
											</a></li>
										<li><a href="#theme_devs">
												<?php 
    _e('Favorite Theme Developers', 'event_espresso');
    ?>
											</a></li>
										<li><a href="#themes">
												<?php 
    _e('Highly Recommended Themes', 'event_espresso');
    ?>
											</a></li>
										<li><a href="#resources">
												<?php 
    _e('Other Resources', 'event_espresso');
    ?>
											</a></li>
										<li><a href="#shortcodes">
												<?php 
    _e('Shortcodes', 'event_espresso');
    ?>
											</a></li>
										<li><a href="#details">
												<?php 
    _e('Important Information', 'event_espresso');
    ?>
											</a></li>
										<li><a href="#support">
												<?php 
    _e('Contact Support', 'event_espresso');
    ?>
											</a></li>
										<li><a href="#faq">
												<?php 
    _e('Frequently Asked Questions', 'event_espresso');
    ?>
											</a></li>
										<li><a href="#additonal">
	<?php 
    _e('Additional Information', 'event_espresso');
    ?>
											</a></li>
									</ul>
								</div>
							</div>
						</div>
					</div>
				</li>
				<li><a name="install" id="install"></a>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Installation', 'event_espresso');
    ?>
							</h3>
							<div class="inside">
								<div class="padding">
									<p>
	<?php 
    _e('For the latest installation instructions please visit:', 'event_espresso');
    ?>
										<a href="http://eventespresso.com/wiki/installing-event-espresso/" target="_blank">http://eventespresso.com/wiki/installing-event-espresso/</a></p>
								</div>
							</div>
						</div>
					</div>
				</li>
				<li>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Event Marketing Resources', 'event_espresso');
    ?>
								<a name="hire_promo" id="hire_promo"></a></h3>
							<div class="inside">
								<div class="padding">
						
									<dl id="hire_promo">
									
									<?php 
    /*?><dt> <a href="http://theadventgroup.net/?referral=eventespresso.com" target="_blank">
    	<?php _e('The Advent Group', 'event_espresso'); ?>
    										</a> </dt>
    										<dd><a href="http://theadventgroup.net/?referral=eventespresso.com" target="_blank"><img src="http://eventespresso.com/wp-content/uploads/2013/03/theadventgroup-logo-300x99.jpg" class="alignright" width="300" height="99" border="0"></a>StickerGiant is two businesses in one. We are a printing company that prints stickers and labels for thousands of customers all over the United States and Canada. We also have a fun online sticker store that has over 26,000 designs from bands to sports and everything in between. Our selection of Embroidered Patches is vast. </dd><?php */
    ?>
										
										
										<dt> <a href="http://www.stickergiant.com/?referral=eventespresso.com" target="_blank">
	<?php 
    _e('StickerGiant.com', 'event_espresso');
    ?>
										</a> </dt>
										<dd><a href="http://www.stickergiant.com/?referral=eventespresso.com" target="_blank"><img src="http://www.stickergiant.com/banners/120x60.gif" class="alignright" width="120" height="60" border="0"></a>StickerGiant is two businesses in one. We are a printing company that prints stickers and labels for thousands of customers all over the United States and Canada. We also have a fun online sticker store that has over 26,000 designs from bands to sports and everything in between. Our selection of Embroidered Patches is vast. </dd>
										<dt> <a href="http://eventespresso.com/contact/?referral=eventespresso_plugin" target="_blank">
	<?php 
    _e('Add a Merketing Resource', 'event_espresso');
    ?>
										</a> </dt>
										<dd>Have a marketing resource you would like to see listed here? Please let us know!</dd>
									</dl>
								</div>
							</div>
						</div>
					</div>
				</li>
				<li>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Partners', 'event_espresso');
    ?>
								<a name="partners" id="partners"></a></h3>
							<div class="inside">
								<div class="padding">
								<p>The following developers have experience with Event Espresso for their clients and have requested to be listed in this directory. Event Espresso does not make any guarantees about their services. This directory is offered as a community benefit to Event Espresso users. We offer our recommendations on <a href="/support/how-to-select-a-developer/">how to select a developer</a>.</p>
									<dl id="partners">
									
									<dt><a href="http://www.ivycat.com/?referral=eventespresso.com" target="_blank">Ivy Cat</a></dt>
<dd><a href="http://www.ivycat.com/?referral=eventespresso.com"><img src="http://eventespresso.com/wp-content/uploads/2013/01/IvyCat_Logo.png" alt="" title="IvyCat_Logo" class="alignright size-thumbnail wp-image-36065" width="150"></a>We're a small, agile team of web designers, developers, and server geeks that love to help businesses strategize, create, market, and maintain strong, effective and profitable websites and web applications.</dd>
<dd>Our staff has well over a decade of experience engineering successful websites in many industries. </dd>
<dd>Check our <a href="http://www.ivycat.com/web-design/portfolio/?referral=eventespresso.com" target="_blank">web design portfolio</a> for examples of our work. </dd>
										
										<dt> <a href="http://pixeljar.net/?referral=eventespresso.com" target="_blank">Pixel Jar</a></dt>
										<dd><a href="http://pixeljar.net/?referral=eventespresso.com" target="_blank"><img src="http://eventespresso.com/wp-content/uploads/2013/01/pixel-jar-logo-150x150.png" alt="" title="pixel-jar-logo" class="alignright size-thumbnail wp-image-36059" height="150" width="150"></a>Pixel Jar creates custom themes, plugins and sites as well as provides custom coding and modifications for existing projects. The co-creators of Pixel Jar, Brandon and Jeff, met working at another web development firm in 2001. Pixel Jar started in 2004 with the goal to provide solid web solutions for small to medium businesses. In 2007 we worked on our first WordPress project and loved it so much that by 2009, our business model was solely WordPress projects. We are very active in the WordPress community, regularly attending and presenting at our local WordPress Meetup, attending regional WordCamps and hosting the annual WordCamp Orange County.</dd>
										
										
										<dt> <a href="http://bigimprint.com/espresso/" target="_blank">Big Imprint Design</a></dt>
										<dd>We create affordable websites for small businesses and non-profits.</dd>
										
										
										<dt> <a href="http://eventespresso.com/contact/?referral=eventespresso_plugin" target="_blank">
	<?php 
    _e('Become a Partner', 'event_espresso');
    ?>
										</a> </dt>
										<dd>Have experience developing websites around Event Espresso? Become a partner!</dd>
									</dl>
								</div>
							</div>
						</div>
					</div>
				</li>
				<li>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Hire a Developer', 'event_espresso');
    ?>
								<a name="hire_devs" id="hire_devs"></a></h3>
							<div class="inside">
								<div class="padding">

									<dl id="hire_devs">
										<dt> <a href="http://jobs.eventespresso.com/?referral=eventespresso.com" target="_blank">
	<?php 
    _e('Event Espresso Job Board', 'event_espresso');
    ?>
										</a> </dt>
										<dd>A dedicated job board that lists the opportunities to work with Event Espresso or our clients.</dd>
										<dt> <a href="http://wpcandy.com/pros/?referral=eventespresso.com" target="_blank">
	<?php 
    _e('WP Candy Pros', 'event_espresso');
    ?>
										</a> </dt>
										<dd>WordPress Professionals and theme developers.</dd>
									</dl>
								</div>
							</div>
						</div>
					</div>
				</li>
				<li>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Favorite Theme Developers', 'event_espresso');
    ?>
								<a name="developers" id="theme_devs"></a></h3>
							<div class="inside">
								<div class="padding">
									<dl id="developers">
										<dt><a href="http://www.mojo-themes.com/?referral=eventespresso.com" target="_blank">MOJO Themes</a></dt>
										<dd>It's simple really – MOJO themes is a marketplace for everyone to <strong><em>buy</em></strong> or <strong><em>sell</em></strong> themes and templates.</dd>
										<dt><a href="http://www.appthemes.com/cp/go.php?r=12413&i=l0" target="_blank">AppThemes</a></dt>
										<dd>AppThemes are built for businesses of all sizes and run on WordPress so  you don't have to worry about the headache of setting up a complex  server environment.</dd>
										<dt><a href="http://www.woothemes.com/amember/go.php?r=28039&amp;i=b16" target="_blank">WooThemes</a></dt>
										<dd>Top quality, cutting edge WordPress themes and superior customer support.</dd>
										<dt><a href="http://www.shareasale.com/r.cfm?B=258340&amp;U=471857&amp;M=27087" target="_blank">PageLines</a></dt>
										<dd>Build websites faster and better using drag and drop, layout, typography, design-control and more... </dd>
										<dt><a href="http://www.studiopress.com/" target="_blank">StudioPress</a></dt>
										<dd>When you buy a StudioPress theme, you are getting state of the art code,  smart design architecture as well as an array of beautiful frames for  your content.</dd>
										<dt><a href="http://www.elegantthemes.com/?referral=eventespresso.com" target="_blank">ElegantThemes</a></dt>
										<dd>Each premium WordPress theme comes expertly coded in valid XHTML and  CSS, and all are made compatible with the latest version of WordPress.</dd>
										<dt><a href="http://allurethemes.com/?referral=eventespresso.com" target="_blank">AllureThemes</a></dt>
										<dd>We create beautiful, top quality WordPress themes for you at amazing prices with exceptional support.</dd>
										<dt><a href="http://museumthemes.com/?referral=eventespresso.com" target="_blank">Museum Themes</a></dt>
										<dd>Fine art WordPress themes.</dd>
									</dl>
								</div>
							</div>
						</div>
					</div>
				</li>

				<li>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Recommended Plugins', 'event_espresso');
    ?>
								<a name="plugins" id="plugins"></a></h3>
							<div class="inside">
								<div class="padding">
									<dl id="plugins">
										<dt><a href="http://wordpress.org/extend/plugins/exclude-pages/" target="_blank">Exclude Pages from Navigation</a></dt>
										<dd> Provides a checkbox on the editing page which you can check to exclude  pages from the primary navigation. IMPORTANT NOTE: This will remove the  pages from any "consumer" side page listings, which may not be limited  to your page navigation listings.</dd>
										<dt><a href="http://wordpress.org/extend/plugins/post-types-order/" target="_blank">Post Types Order</a></dt>
										<dd> Order Post Types Objects using a Drag and Drop Sortable javascript capability
											</dt>

										<dt><a href="https://www.e-junkie.com/ecom/gb.php?cl=54585&amp;c=ib&amp;aff=113214" target="_blank">Gravity Forms</a>
										</dd>
										<dd>
											Build Complex, Powerful Contact Forms in Just Minutes. No Programming Knowledge Required! Yeah, It's Really That Easy.
										</dd>
									</dl>
								</div>
							</div>
						</div>
					</div>
				</li>

				<li>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Highly Recommended Themes', 'event_espresso');
    ?>
								<a name="themes" id="themes"></a></h3>
							<div class="inside">
								<div class="padding">
									<dl id="themes">
										<dt><a href="http://www.pagelines.com/?referral=eventespresso.com" target="_blank">PageLines Framework</a> by Pagelines</dt>
										<dt><a href="http://www.woothemes.com/?referral=eventespresso.com" target="_blank">Diarise</a> by WooThemes</dt>
									</dl>
								</div>
							</div>
						</div>
					</div>
				</li>
				<li>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Other Resources', 'event_espresso');
    ?>
								<a name="resources" id="resources"></a></h3>
							<div class="inside">
								<div class="padding">
									<dl id="resources">
										<dt><a href="http://wordpress.stackexchange.com/" target="_blank">WordPress Answers</a></dt>
									</dl>
								</div>
							</div>
						</div>
					</div>
				</li>

				<li>
					<div class="metabox-holder">
						<div class="postbox"><a name="shortcodes" id="shortcodes"></a>
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Shortcodes', 'event_espresso');
    ?>
							</h3>
							<div class="inside">
								<div class="padding">
									<p>
	<?php 
    _e('For more information, please visit:', 'event_espresso');
    ?>
										<br />
										<a href="http://eventespresso.com/forums/2010/10/post-type-variables-and-shortcodes/" target="_blank">http://eventespresso.com/forums/2010/10/post-type-variables-and-shortcodes/</a></p>
									<hr />
									<div class="shortcode-box">
										<h4>
											<?php 
    _e('Single Events', 'event_espresso');
    ?>
										</h4>
										<p>
	<?php 
    _e('Displays a single event on a page or post', 'event_espresso');
    ?>
										</p>
										<p ><span class="highlight">[SINGLEEVENT single_event_id="your_event_identifier"]</span></p>
									</div>
									<div class="shortcode-box">
										<h4>
											<?php 
    _e('Add Events to Cart', 'event_espresso');
    ?>
										</h4>
										<p>
	<?php 
    _e('Displays an "Add Event to Cart" link that can be added to the event details, page, or post. Requires the <a href="http://eventespresso.com/download/plugins-and-addons/multiple-event-registration/" target="_blank">Multiple Event Registration addon</a>.', 'event_espresso');
    ?>
										</p>
										<p><span class="highlight">[ESPRESSO_CART_LINK]</span></p>
										<h5>
											<?php 
    _e('Additonal Examples:', 'event_espresso');
    ?>
										</h5>
										<p><span class="highlight">[ESPRESSO_CART_LINK direct_to_cart=1 moving_to_cart="Redirecting to cart..."]</span><br />
											<?php 
    _e('(Used to redirect to the shopping cart page. Must be added to an event description.)', 'event_espresso');
    ?>
										</p>
										<p><span class="highlight">[ESPRESSO_CART_LINK event_id="add_event_id_here" direct_to_cart=1 moving_to_cart="Redirecting to cart..."]</span><br />
	<?php 
    _e('(Same as above, but uses the event_id paramter and can be added to a page or post.)', 'event_espresso');
    ?>
										</p>
									</div>
									<div class="shortcode-box">
										<h4>
											<?php 
    _e('Event List', 'event_espresso');
    ?>
										</h4>
										<p>
	<?php 
    _e('Returns a list of events', 'event_espresso');
    ?>
										</p>
										<ul>
											<li><span class="highlight">[EVENT_LIST]</span></li>
											<li><span class="highlight">[EVENT_LIST limit=1]</span></li>
											<li><span class="highlight">[EVENT_LIST show_expired=true]</span></li>
											<li><span class="highlight">[EVENT_LIST show_deleted=true]</span></li>
											<li><span class="highlight">[EVENT_LIST show_secondary=true]</span></li>
											<li><span class="highlight">[EVENT_LIST show_recurrence=true]</span></li>
											<li><span class="highlight">[EVENT_LIST category_identifier=your_category_identifier]</span></li>
											<li><span class="highlight">[EVENT_LIST staff_id=staff_id_number]</span></li>
											<li><span class="highlight">[EVENT_LIST order_by=date(start_date),id]</span></li>
										</ul>
										<h5>
											<?php 
    _e('Order by parameters:', 'event_espresso');
    ?>
										</h5>
										<p>
	<?php 
    _e('(comma separated)', 'event_espresso');
    ?>
										</p>
										<p>id<br />
											date(start_date)<br />
											date(end_date)<br />
											event_name<br />
											date(registration_start)<br />
											date(registration_end)<br />
											city<br />
											state<br />
											category_id<br />
											venue_title </p>
										<p class="yellow_alert"><strong>
											<?php 
    _e('Attention:', 'event_espresso');
    ?>
											</strong><br />
	<?php 
    _e('The [EVENT_LIST] shortcode should not be used as a replacement for the [ESPRESSO_EVENTS] shortcode. Replacing the [ESPRESSO_EVENTS] shortcode will break your registration pages.', 'event_espresso');
    ?>
										</p>
									</div>
									<div class="shortcode-box">
										<h4>
	<?php 
    _e('Attendee Listings', 'event_espresso');
    ?>
										</h4>
										<ul>
											<li><span class="highlight">[LISTATTENDEES]</span></li>
											<li><span class="highlight">[LISTATTENDEES limit="30"]</span> //Number of events to show on the page</li>
											<li><span class="highlight">[LISTATTENDEES show_expired="true"]</span> //Show expired events</li>
											<li><span class="highlight">[LISTATTENDEES show_deleted="true"]</span> //Show deleted events</li>
											<li><span class="highlight">[LISTATTENDEES show_secondary="true"]</span> //Show secondary/backup events</li>
											<li><span class="highlight">[LISTATTENDEES show_gravatar="true"]</span> //Show a Gravatar of the attendee</li>
											<li><span class="highlight">[LISTATTENDEES show_recurrence="false"]</span> //Exclude recurring events</li>
											<li><span class="highlight">[LISTATTENDEES event_identifier="your_event_identifier"]</span> //Show a single event using the event identifier</li>
											<li><span class="highlight">[LISTATTENDEES category_identifier="your_category_identifier"]</span> //Show a group of events in a category using the category identifier</li>
											<li><span class="highlight">[LISTATTENDEES staff_id="staff_id_number"]</span> //Show a list of events that are assigned to a staff member</li>
										</ul>
										<p>
	<?php 
    _e('For more information about the attendee listing shortcodes and customizations. Please view the <a href="http://eventespresso.com/wiki/shortcodes-template-variables/">Attendee Listing Shortcodes</a> page.', 'event_espresso');
    ?>
										</p>
									</div>
									<div class="shortcode-box">
										<h4>
											<?php 
    _e('Venue Shortcodes', 'event_espresso');
    ?>
										</h4>
										<h5>
	<?php 
    _e('As of Event Espresso version 3.1', 'event_espresso');
    ?>
										</h5>
										<a name="venue_shortcode" id="venue_shortcode"></a>
										<dl>
											<dt>
												<?php 
    _e('Event Description Example:', 'event_espresso');
    ?>
											</dt>
											<dd>
											<?php 
    _e('If you want to display venue details within an event, the venue id is not needed. Just add <span class="highlight">[ESPRESSO_VENUE]</span> to your event description.', 'event_espresso');
    ?>
											</dd>
											<dt>
	<?php 
    _e('Example with Optional Parameters:', 'event_espresso');
    ?>
											</dt>
											<dd><span class="highlight">[ESPRESSO_VENUE outside_wrapper="div" outside_wrapper_class="event_venue"]</span></dd>
											<dt>
												<?php 
    _e('Page/Post Example:', 'event_espresso');
    ?>
											</dt>
											<dd>
	<?php 
    _e('You can display the details of any venue to a page, post or event by adding the id of the venue to the shortcode.', 'event_espresso');
    ?>
												<br />
												<span class="highlight">[ESPRESSO_VENUE id="3"]</span></dd>
											<dt>
												<?php 
    _e('Page/Post Example #2:', 'event_espresso');
    ?>
											</dt>
											<dd>
	<?php 
    _e('If you want to display all available venues on a page, post, or event:', 'event_espresso');
    ?>
												<br />
												<span class="highlight">[ESPRESSO_VENUE]</span>
											</dd>
											<dd>
	<?php 
    _e('Add the event id to the shortcode to display all the venues for an event:', 'event_espresso');
    ?>
												<br />
												<span class="highlight">[ESPRESSO_VENUE event_id="8"]</span></dd>

										</dl>
										<h5>
	<?php 
    _e('Available parameters:', 'event_espresso');
    ?>
										</h5>
										<ul>
											<li>outside_wrapper_class = class name for the outside wrapper. Eg. event_venue</li>
											<li>outside_wrapper = outside wrapper element. Eg. div</li>
											<li>inside_wrapper_class = class name for the outside wrapper. Eg. venue_details</li>
											<li>inside_wrapper = inside wrapper element. Eg. p</li>
											<li>title_class = class name for the title Eg. venue_name</li>
											<li>title_wrapper = title wrapper element. Eg. h3</li>
											<li>show_title = show the venue name? (true|false default true)</li>
											<li>image_class = class name for the image. Eg. venue_image</li>
											<li>show_image = show the image? (true|false default true)</li>
											<li>show_description = show the description? (true|false default true)</li>
											<li>show_address = show the address of the venue? (true|false default true)</li>
											<li>show_additional_details = show the additional details? (true|false default true)</li>
											<li>show_google_map_link = show the Google map link? (true|false default true)</li>
											<li>map_link_text = text to display in the link. Eg. Map and Directions</li>
										</ul>

										<dl>
											<dt>
	<?php 
    _e('Show All Events in a Venue:', 'event_espresso');
    ?>
											</dt>
											<dd>
												<span class="highlight">[ESPRESSO_VENUE_EVENTS id="21"]</span></dd>
											<dd>
												<span class="highlight">[ESPRESSO_VENUE_EVENTS id="21" limit="5"]</span></dd>
										</dl> 

									</div>
									<div class="shortcode-box">
										<h4>
											<?php 
    _e('Staff Shortcodes', 'event_espresso');
    ?>
										</h4>
										<h5>
	<?php 
    _e('As of Event Espresso version 3.1', 'event_espresso');
    ?>
										</h5>
										<a name="staff_shortcode" id="staff_shortcode"></a>
										<dl>
											<dt>
												<?php 
    _e('Event Description Example:', 'event_espresso');
    ?>
											</dt>
											<dd>
											<?php 
    _e('If you want to display a list of staff members within an event, the staff id is not needed. Just add <span class="highlight">[ESPRESSO_STAFF]</span> to your event description.', 'event_espresso');
    ?>
											</dd>
											<dt>
	<?php 
    _e('Example with Optional Parameters:', 'event_espresso');
    ?>
											</dt>
											<dd><span class="highlight">[ESPRESSO_STAFF outside_wrapper="div" outside_wrapper_class="event_staff" inside_wrapper="p" inside_wrapper_class="event_person"]</span></dd>
											<dt>
												<?php 
    _e('Page/Post Example:', 'event_espresso');
    ?>
											</dt>
											<dd>
											<?php 
    _e('You can display the details of any staff member to a page, post or event by adding the id of the staff member to the shortcode.', 'event_espresso');
    ?>
												<span class="highlight">[ESPRESSO_STAFF id="3"]</span></dd>
											<dt>
												<?php 
    _e('Page/Post Example #2:', 'event_espresso');
    ?>
											</dt>
											<dd>
	<?php 
    _e('If you want to display a list of staff members assigned to an event, to a page, post or event add the event id to the  <span class="highlight">[ESPRESSO_STAFF]</span> shortcode.', 'event_espresso');
    ?>
												<br />
												<span class="highlight">[ESPRESSO_STAFF event_id="8"]</span></dd>
										</dl>
										<h5><?php 
    _e('Available parameters:', 'event_espresso');
    ?>
</h5>
										<ul>
											<li>outside_wrapper_class = class name for the outside wrapper. Eg. event_staff</li>
											<li>outside_wrapper = outside wrapper element. Eg. div</li>
											<li>inside_wrapper_class = class name for the outside wrapper. Eg. event_person</li>
											<li>inside_wrapper = inside wrapper element. Eg. p</li>
											<li>name_class = class name for the persons name</li>
											<li>name_wrapper = name wrapper element. Eg. strong</li>
											<li>image_class = class name for the image. Eg. venue_image</li>
											<li>show_image = show the persons image? (true|false default true)</li>
											<li>show_staff_titles = show the role/title? (true|false default true)</li>
											<li>show_staff_details = show the details? (true|false default true)</li>
											<li>show_image = show the image? (true|false default true)</li>
											<li>show_description = show the description? (true|false default true)</li>
										</ul>
									</div>
									<div class="shortcode-box">
										<h4><?php 
    _e('Calendar Shortcodes', 'event_espresso');
    ?>
</h4>
										<ul>
											<li><span class="highlight">[ESPRESSO_CALENDAR]</span></li>
											<li><span class="highlight"> [ESPRESSO_CALENDAR show_expired="true"]</span></li>
											<li><span class="highlight">[ESPRESSO_CALENDAR event_category_id="your_category_identifier"]</span></li>
											<li><span class="highlight">[ESPRESSO_CALENDAR event_category_id="your_category_identifier" show_expired="true"]</span></li>
											<li><span class="highlight">[ESPRESSO_CALENDAR cal_view="month"] (Available parameters: month, basicWeek, basicDay, agendaWeek, agendaDay)</span></li>
										</ul>
									</div>
									<div class="shortcode-box">
										<h4><?php 
    _e('Category Shortcodes', 'event_espresso');
    ?>
</h4>
										<p><span class="highlight">[EVENT_ESPRESSO_CATEGORY event_category_id="your_category_indentifier"]</span></p>
									</div>
								</div>
								<!-- / .padding --> 
							</div>
							<!-- / .inside --> 
						</div>
						<!-- / .postbox --> 
					</div>
					<!-- / .metabox-holder --> 
				</li>

				<li><a name="details" id="details"></a>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Important Information', 'event_espresso');
    ?>
							</h3>
							<div class="inside">
								<div class="padding">
									<?php 
    global $wpdb, $wp_version;
    $wp_req_version = '3.1';
    $php_req_version = '5.2';
    $mysql_req_version = '5.0';
    $is_php_valid = version_compare(phpversion(), $php_req_version, '>');
    $is_mysql_valid = version_compare($wpdb->db_version(), $mysql_req_version, '>');
    if (!version_compare($wp_version, $wp_req_version, '>=')) {
        echo '<p class="red_alert">' . __('This version of Event Espresso requires WordPress version', 'event_espresso') . ' ' . $wp_req_version . '+. ' . __('Please upgrade to the latest version of WordPress.', 'event_espresso') . '</p>';
    }
    if (!$is_php_valid) {
        echo '<p class="red_alert">' . __('Your version of PHP is out of date, please update to the latest version of PHP. <br>Required version of PHP:', 'event_espresso') . ' ' . $php_req_version . '</p>';
    }
    if (!$is_mysql_valid) {
        echo '<p class="red_alert">' . __('Your version of MySQL is out of date, please update to the latest version of MySQL. <br>Required version of MySQL:', 'event_espresso') . ' ' . $mysql_req_version . '</p>';
    }
    if (event_espresso_verify_attendee_data() == true) {
        ?>
									  <a name="attendee_data" id="attendee_data"></a>
									  <p class="red_text"><strong>
										<?php 
        _e('Attendee information is outdated', 'event_espresso');
        ?>
										</strong></p>
									  <p>
										<?php 
        _e('Due to recent changes in the way attendee information is handled, attendee data may appear to be missing from some events. In order to reassign attendees to events, please run the attendee update script by pressing the button below.', 'event_espresso');
        ?>
									  </p>
									  <form action="<?php 
        echo $_SERVER["REQUEST_URI"];
        ?>
" method="post" name="form" id="form">
										<p>
										  <input type="hidden" name="action" value="event_espresso_update_attendee_data" />
										  <input class="button-primary" type="submit" name="event_espresso_update_attendee_data_button" value="<?php 
        _e('Run Attendee Update Script', 'event_espresso');
        ?>
" id="event_espresso_update_attendee_data_button"/>
										</p>
									  </form>
								  <?php 
    }
    ?>
									<div class="localhost-information">
										<dl>
											<dt>
	<?php 
    _e('WordPress Version:', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo $wp_version;
    ?>
</dd>
											<dt>
	<?php 
    _e('PHP Version:', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo phpversion();
    ?>
</dd>
											<dt>
	<?php 
    _e('MySQL Version:', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo $wpdb->db_version();
    ?>
</dd>
											<dt>Event Espresso Version:</dt>
											<dd><?php 
    echo EVENT_ESPRESSO_VERSION;
    ?>
</dd>
											<dt>
	<?php 
    _e('WordPress Address (URL):', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo site_url();
    ?>
</dd>
											<dt>
	<?php 
    _e('WordPress Content Directory:', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo WP_CONTENT_DIR;
    ?>
</dd>
											<dt>
	<?php 
    _e('Site address (URL):', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo home_url();
    ?>
</dd>
											<dt>
	<?php 
    _e('Event Espresso Plugin URL:', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
</dd>
											<dt>
	<?php 
    _e('Event Espresso Plugin Path:', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo EVENT_ESPRESSO_PLUGINFULLPATH;
    ?>
</dd>
											<dt>
	<?php 
    _e('Event Espresso Upload URL:', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo EVENT_ESPRESSO_UPLOAD_URL;
    ?>
</dd>
											<dt>
	<?php 
    _e('Event Espresso Upload Path:', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo EVENT_ESPRESSO_UPLOAD_DIR;
    ?>
</dd>
											<dt>
	<?php 
    _e('Event Espresso Template Path:', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo EVENT_ESPRESSO_TEMPLATE_DIR;
    ?>
</dd>
											<dt>
	<?php 
    _e('Event Espresso Gateway Path:', 'event_espresso');
    ?>
											</dt>
											<dd><?php 
    echo EVENT_ESPRESSO_GATEWAY_DIR;
    ?>
</dd>
										</dl>
									</div>
								</div>
							</div>
						</div>
					</div>
				</li>

				<li><a name="support" id="support"></a>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Contact Support', 'event_espresso');
    ?>
							</h3>
							<div class="inside">
								<div class="padding">
									<h4>Before Contacting Support</h4>
									<p>Please understand that our primary goal is to offer Event Espresso as a very low cost solution compared to building your own system or using a 3rd party service to handle your registrations.</p><p> As with most open source programs (and closed licensed programs), chances are you will find the occasional bug, glitch, white screen of death, and/or general failure. Please don't panic!</p>
									<p>If your problems are not urgent, please post in our <a href="http://eventespresso.com/support/forums/" target="_blank">support forums</a>. If you need immediate help. Please purchase a support token below, at which time you can schedule time with a dedicated support tech or core developer.</p>
									<p class="attention-block"><strong class="red_text">
										<?php 
    _e('Attention:', 'event_espresso');
    ?>
										</strong><br />
	<?php 
    _e('When requesting support. Please copy and paste the details displayed of the <a href="admin.php?page=support#details">Important Information</a> section above. This will help us determine potential problems with your server, WordPress installation, and/or the Event Espresso plugin. Please also include a list (or screenshot) of all <a href="plugins.php?plugin_status=active">active plugins</a>.', 'event_espresso');
    ?>
									</p>

									<h4>
										<?php 
    _e('Premium Support Options', 'event_espresso');
    ?>
									</h4>
									<p>
										<?php 
    _e('We offer premium support to customers who desire or require a level of support beyond the complimentary support included with all Event Espresso products.', 'event_espresso');
    ?>
									</p>
									<h5>
										<?php 
    _e('Support Tokens', 'event_espresso');
    ?>
									</h5>
									<p>
										<?php 
    _e('A support token can be used to get priority support for a single  incident. It can be used to schedule support via phone or IM for a  single incident (up to 30 minutes), or to receive priority e-mail  support. A support token can be used for &ldquo;how to&rdquo; questions, technical  issues, &ldquo;best practice&rdquo; questions or for custom development consulting. A  support token consists of the PayPal Transaction ID you received from  PayPal at the time of your purchase.', 'event_espresso');
    ?>
									</p>
									<p>
	<?php 
    _e('<strong>You can purchase support tokens</strong> on the <a href="http://eventespresso.com/product/priority-support-tokens/">Premium Support page</a>. Tokens can be purchased one at a time, or in blocks of three at a discount.', 'event_espresso');
    ?>
									</p>
									<p>Support tokens can be used to schedule live support (phone or IM) or for priority e-mail support. See <a href="http://eventespresso.com/support/">details on premium support</a>.</p>
									<div class="support-tokens">
										<h6><a href="http://eventespresso.com/product/priority-support-tokens/" target="_blank">1 Premium Support Token</a></h6>
										<p>Single incident, up to 30 minutes of live support or priority e-mail support.</p>
										<p class="support-prices"><span class="price">Price: $65.00 </span></p>
									</div>
									<div class="support-tokens">
										<h6><a href="http://eventespresso.com/product/3-premium-support-tokens/" target="_blank">3 Premium Support Tokens</a></h6>
										<p>Up to 90 minutes of live support or priority e-mail support.</p>
										<p class="support-prices"><span class="price">Price: $150.00 </span></p>
									</div>
									<h5>
	<?php 
    _e('Installation &amp; Consulting', 'event_espreso');
    ?>
									</h5>
									<div class="install-options">
										<h6><a href="http://eventespresso.com/product/basic-install/" target="_blank">Basic Install</a></h6>
										<p>Includes plugin installation and setting up basic pages for the plugin.</p>
										<p class="support-prices"><span class="price">Price: $35.00 </span></p>
									</div>
									<div class="install-options">
										<h6><a href="http://eventespresso.com/product/basic-install-with-configuration/" target="_blank">Basic Install with Configuration</a></h6>
										<p>Includes configuration and testing Payment Gateway's .</p>
										<p class="support-prices"><span class="price">Price: $65.00 </span></p>
									</div>
									<div class="install-options">
										<h6><a href="http://eventespresso.com/product/consultation/" target="_blank">Consulting (1 hour)</a></h6>
										<p>Developer support and implementation consulting for the Advanced Events Registration plugin for WordPress.</p>
										<p class="support-prices"><span class="price">Price: $135.00 </span></p>
									</div>
									<h5>* Requirements for installation service:</h5>
									<ul>
										<li> The server must be accessible over the internet.</li>
										<li> The server must meet the server requirements (for Advanced Events Registration).</li>
										<li> You must be able to provide a FTP/SFTP username and password. A MySQL database name, username and password is needed for a Basic Install. A WordPress admin user name, password, and login URL.</li>
									</ul>
								</div>
							</div>
						</div>
					</div>
				</li>
				<li>
					<div class="metabox-holder">
						<div class="postbox">
							<div title="Click to toggle" class="handlediv"><br />
							</div>
							<h3 class="hndle">
	<?php 
    _e('Frequently Asked Questions', 'event_espresso');
    ?>
								<a name="faq" id="faq"></a></h3>
							<div class="inside">
								<div class="padding">
									<dl id="faqs">
										<dt>
											<?php 
    _e('Registration page just refreshes?', 'event_espresso');
    ?>
										</dt>
										<dd>
											<?php 
    _e('Usually its because you need to point the &quot;Main registration page:&quot; (in the Organization Settings page) to whatever page you have the shortcode', 'event_espresso');
    ?>
											[ESPRESSO_EVENTS]
										<?php 
    _e('on', 'event_espresso');
    ?>
											. </dd>
										<dt>
											<?php 
    _e('Paypal IPN Problem?', 'event_espresso');
    ?>
										</dt>
										<dd>
	<?php 
    _e('Four things to check with PayPal when payments notifications are not being sent to Event Espresso.', 'event_espresso');
    ?>
											</p>
											<ol>
												<li>
													<?php 
    _e('Make sure you have a standard or a business PayPal account, personal accounts don\'t work.', 'event_espresso');
    ?>
												</li>
												<li>
													<?php 
    _e('Turn on your IPN.', 'event_espresso');
    ?>
												</li>
												<li>
													<?php 
    _e('Make sure your PayPal account is verified.', 'event_espresso');
    ?>
												</li>
												<li>
	<?php 
    _e('Make sure your Event Espresso pages are not protected or private.', 'event_espresso');
    ?>
												</li>
											</ol>
											<p class="more-info">
	<?php 
    _e('More information can be found here:', 'event_espresso');
    ?>
												<br />
												<a href="http://eventespresso.com/forums/?submit.x=0&submit.y=0&s=ipn" target="_blank"> http://eventespresso.com/forums/?submit.x=0&amp;submit.y=0&amp;s=ipn</a></p>
										</dd>
										<dt>
											<?php 
    _e('Why are mails are not being sent when someone registers?', 'event_espresso');
    ?>
										</dt>
										<dd>
	<?php 
    _e('Check your email settings on the', 'event_espresso');
    ?>
											<a href="admin.php?page=event_espresso#email-settings">Event Espresso > General Settings > Email Settings</a> page<br />
											<img class="email-settings-img" src="http://ee-updates.s3.amazonaws.com/images/email-settings.png" width="472" height="120" />
											</p>
											<p>
	<?php 
    _e('If you\'re using WP SMTP with Gmail, also check your spam box to make sure Gmail isn\'t filtering the confirmation emails as spam.', 'event_espresso');
    ?>
											</p>
										</dd>
										<dt>
	<?php 
    _e('My events are not importing correctly when I use the CSV upload tool.', 'event_espresso');
    ?>
										</dt>
										<dd>
											<p>
	<?php 
    _e('Check your CSV for any apotrophes in the title or description. Using Excel (or someother spreadsheet application) find and replace all apostrophes with <tt>\\&amp;#039;</tt>.  This is the HTML entity for \' and is how the titles are entered into the database.  For more information, see <a href="http://eventespresso.com/forums/2011/08/import-csv-malfunction" target="_blank">this forum post</a>.', 'event_espresso');
    ?>
											</p>
										</dd>
									</dl>
								</div>
							</div>
						</div>
					</div>
				</li>
				<?php 
    /*?><li>
    					<div class="metabox-holder">
    						<div class="postbox">
    	            <div title="Click to toggle" class="handlediv"><br />
    	            </div>
    	            <h3 class="hndle">
    	<?php _e('Additional Information', 'event_espresso'); ?>
    	              <a name="additonal" id="additonal"></a></h3>
    	            <div class="inside">
    								<div class="padding">
    									<dl id="additonal">
    										<dt><a href="http://eventespresso.com/support/documentation/">User Guide Forum</a>
    										</dt>
    										<dt><a href="http://eventespresso.com/forums/category/premium-plugin-support/tutorials/template-customization/">Tutorials</a> </dt><dd>(calendar, css override, payment gateway system, etc.)</dd>
    										<dt><a href="http://eventespresso.com/forums/premium-plugin-support/tutorials/template-customization/">Template Customization</a></dt>
    										<dt><a href="http://eventespresso.com/forums/2010/12/my-first-event/">Adding Your First Event</a> (video)</dt>
    										<dt><a href="http://eventespresso.com/forums/2010/12/video-initial-setp-general-settings-pages/">General Setup &amp; Using Shortcodes</a> (video)</dt>
    										<dt><a href="http://eventespresso.com/forums/2010/12/customizing-the-registration-form/%5C">Customizing the Registration Form</a> (video)</dt>
    										<dt><a href="http://eventespresso.com/forums/2010/07/account-optional-setting/">Optional PayPal Account Settings</a> (video)</dt>
    										<dt><a href="http://eventespresso.com/forums/2011/01/templates-for-the-recurring-events-manager/">Recurring Events Manager</a> (video)</dt>
    										<dt><a href="http://eventespresso.com/forums/2010/10/post-type-variables-and-shortcodes/">Variables and Shortcodes</a></dt>
    										<dt><a href="http://eventespresso.com/forums/category/general/compatiblity-issues/">Compatibility Issues</a></dt>
    										<dt><a href="http://eventespresso.com/forums/category/premium-plugin-support/bug-reports/">Bug Submission Form</a></dt>
    										<dt><a href="http://eventespresso.com/forums/category/premium-plugin-support/news-and-updates/">Change log</a></dt>
    										<dt><a href="http://eventespresso.com/update-request-form/">Update Request Form</a></dt>               <dd>Please use this form if a newer version of Event Espresso or an Addon  has been released and you are unable to download it from the specified  page or the email notification.</dd>
    									</dl>
    								</div>
    							</div>
    						</div>
    					</div>
    				</li><?php */
    ?>


				<?php 
    /* ?>
    
    				  <li>
    				  <div class="metabox-holder">
    				  <div class="postbox">
    				  <div title="Click to toggle" class="handlediv"><br />
    				  </div>
    				  <h3 class="hndle">
    				  <?php _e('Additional Information', 'event_espresso'); ?>
    				  <a name="additonal" id="additonal"></a></h3>
    				  <div class="inside">
    				  <div class="padding">
    				  <dl id="additonal">
    				  <dt>
    				  <?php _e('Registration page just refreshes?', 'event_espresso'); ?>
    				  </dt>
    				  <dd>
    				  <?php _e('Usually its because you need to point the &quot;Main registration page:&quot; (in the Organization Settings page) to whatever page you have the shortcode', 'event_espresso'); ?>
    				  [ESPRESSO_EVENTS]
    				  <?php _e('on', 'event_espresso'); ?>
    				  . </dd>
    				  </dl>
    				  </div>
    				  </div>
    				  </div>
    				  </div>
    				  </li>
    
    				  <?php */
    ?>
			</ul>
		</div>
		<!-- / .meta-box-sortables -->
		<?php 
    $main_post_content = ob_get_clean();
    espresso_choose_layout($main_post_content, event_espresso_display_right_column());
    ?>
	</div>
	<!-- / #wrap --> 
	<script type="text/javascript" charset="utf-8">
		//<![CDATA[
		jQuery(document).ready(function() {
			postboxes.add_postbox_toggles('support');
		}); 
		//]]>
	</script>
	<?php 
}