function event_espresso_add_attendees_to_db($event_id = NULL, $session_vars = NULL) { global $wpdb, $org_options, $espresso_premium; //print_r($session_vars); $count = $wpdb->get_col($wpdb->prepare("SELECT id FROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session=%s", $_SESSION['espresso_session']['id'])); if (!empty($count) && empty($_REQUEST['confirm_registration']) && is_null($session_vars)) { $_SESSION['espresso_session']['id'] = array(); ee_init_session(); } $data_source = $_POST; $att_data_source = $_POST; $multi_reg = false; static $attendee_number = 1; //using this var to keep track of the first attendee static $loop_number = 1; if (!is_null($event_id) && !is_null($session_vars)) { $data_source = $session_vars['data']; //event details, ie qty, price, start.. $att_data_source = $session_vars['event_attendees']; //event attendee info ie name, questions.... $multi_reg = true; } else { $event_id = $data_source['event_id']; } //echo '<p>$att_data_source = ';print_r( $att_data_source); echo '</p>'; static $temp_event_id = ''; // Will be used for multi events to // keep track of evant id change in the loop, // for recording event total cost for each group if ($temp_event_id == '' || $temp_event_id != $event_id) { $temp_event_id = $event_id; $event_change = 1; $total_cost = isset($data_source['cost']) ? $data_source['cost'] : 0; } else { $event_change = 0; $total_cost = 0; } // echo "<pre>", print_r($data_source), "</pre>"; //echo "<pre>", print_r($att_data_source), "</pre>"; // exit; $Organization = $org_options['organization']; $Organization_street1 = $org_options['organization_street1']; $Organization_street2 = $org_options['organization_street2']; $Organization_city = $org_options['organization_city']; $Organization_state = $org_options['organization_state']; $Organization_zip = $org_options['organization_zip']; $contact = $org_options['contact_email']; $contact_email = $org_options['contact_email']; $paypal_id = $org_options['paypal_id']; $paypal_cur = isset($org_options['currency_format']) ? $org_options['currency_format'] : ''; $return_url = $org_options['return_url']; $cancel_return = $org_options['cancel_return']; $notify_url = $org_options['notify_url']; $default_mail = $org_options['default_mail']; $conf_message = $org_options['message']; $email_before_payment = $org_options['email_before_payment']; $fname = isset($att_data_source['fname']) ? $att_data_source['fname'] : ''; $lname = isset($att_data_source['lname']) ? $att_data_source['lname'] : ''; $address = isset($att_data_source['address']) ? $att_data_source['address'] : ''; $address2 = isset($att_data_source['address2']) ? $att_data_source['address2'] : ''; $city = isset($att_data_source['city']) ? $att_data_source['city'] : ''; $state = isset($att_data_source['state']) ? $att_data_source['state'] : ''; $zip = isset($att_data_source['zip']) ? $att_data_source['zip'] : ''; $phone = isset($att_data_source['phone']) ? $att_data_source['phone'] : ''; $email = isset($att_data_source['email']) ? $att_data_source['email'] : ''; //$num_people = $data_source ['num_people']; $amount_pd = isset($data_source["event_cost"]) && $data_source["event_cost"] != '' ? $data_source["event_cost"] : 0.0; //echo $amount_pd; //return; //echo '<p>$amount_pd = '.$amount_pd.'</p>'; $questions = $wpdb->get_row("SELECT question_groups, event_meta FROM " . EVENTS_DETAIL_TABLE . " WHERE id = '" . $event_id . "'"); $event_meta = unserialize($questions->event_meta); $questions = unserialize($questions->question_groups); //echo '<p>$data_source[price_select] = '.$data_source['price_select'].'</p>'; //$payment = $data_source['payment']; //Figure out if the person has registered using a price selection if ($multi_reg) { $event_cost = $_SESSION['espresso_session']['grand_total']; $amount_pd = $attendee_number == 1 ? $event_cost : 0.0; $coupon_code = $attendee_number == 1 ? $_SESSION['espresso_session']['coupon_code'] : ''; $price_type = isset($data_source['price_type']) ? $data_source['price_type'] : espresso_ticket_information(array('type' => 'ticket', 'price_option' => $data_source['price_id'])); $attendee_number++; } elseif (isset($data_source['price_select']) && $data_source['price_select'] == true) { $price_options = explode('|', $data_source['price_option'], 2); $price_id = $price_options[0]; $price_type = $price_options[1]; $event_cost = event_espresso_get_final_price($price_id, $event_id); /* echo '$event_id = '.$event_id.'<br />'; echo '$price_id = '.$price_id.'<br />'; echo '$event_cost = '.$event_cost; return; */ } else { $event_cost = isset($data_source['price_id']) ? event_espresso_get_final_price($data_source['price_id'], $event_id) : 0.0; $coupon_code = ''; $price_type = isset($data_source['price_id']) ? espresso_ticket_information(array('type' => 'ticket', 'price_option' => $data_source['price_id'])) : ''; } //Display the confirmation page if (!empty($data_source['confirm_registration'])) { $registration_id = $data_source['registration_id']; echo espresso_confirm_registration($registration_id); return; } //Check to see if the registration id already exists $incomplete_filter = !$multi_reg ? " AND payment_status ='Incomplete'" : ''; $check_sql = $wpdb->get_results("SELECT attendee_session, id, registration_id FROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session ='" . $_SESSION['espresso_session']['id'] . "' AND event_id ='" . $event_id . "' {$incomplete_filter}"); $num_rows = $wpdb->num_rows; $registration_id = empty($wpdb->last_result[0]->registration_id) ? $registration_id = uniqid('', true) : $wpdb->last_result[0]->registration_id; $txn_type = ""; if (isset($data_source['admin'])) { $payment_status = "Completed"; $payment = "Admin"; $txn_type = __('Added by Admin', 'event_espresso'); $payment_date = date("m-d-Y"); $amount_pd = $data_source["event_cost"] == '' ? 0.0 : $data_source["event_cost"]; $registration_id = uniqid('', true); $_SESSION['espresso_session']['id'] = uniqid('', true); } else { if ($org_options['use_captcha'] == 'Y' && !$multi_reg && !is_user_logged_in()) { //Recaptcha portion //require_once('includes/recaptchalib.php'); if (!function_exists('recaptcha_check_answer')) { require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/recaptchalib.php'; } $resp = recaptcha_check_answer($org_options['recaptcha_privatekey'], $_SERVER["REMOTE_ADDR"], $data_source["recaptcha_challenge_field"], $data_source["recaptcha_response_field"]); if (!$resp->is_valid) { echo '<div class="attention-icon"><p class="event_espresso_attention"><strong>' . __('Sorry, you did not enter the correct anti-spam phrase. Please click your browser\'s back button and try again.', 'event_espresso') . '</strong></p></div>'; return; } } //print_r( $event_meta); $default_payment_status = $event_meta['default_payment_status'] != '' && $org_options['default_payment_status'] != $event_meta['default_payment_status'] ? $event_meta['default_payment_status'] : $org_options['default_payment_status']; $payment_status = $multi_reg && $data_source['cost'] == 0 ? "Completed" : $default_payment_status; $payment = ''; } $times_sql = "SELECT ese.start_time, ese.end_time, e.start_date, e.end_date "; $times_sql .= "FROM " . EVENTS_START_END_TABLE . " ese "; $times_sql .= "LEFT JOIN " . EVENTS_DETAIL_TABLE . " e ON ese.event_id = e.id WHERE "; if (!empty($data_source['start_time_id'])) { $times_sql .= "ese.id='" . $data_source['start_time_id'] . "' AND "; } $times_sql .= "e.id='" . $event_id . "' "; $times = $wpdb->get_results($times_sql); foreach ($times as $time) { $start_time = $time->start_time; $end_time = $time->end_time; $start_date = $time->start_date; $end_date = $time->end_date; } //If we are using the number of attendees dropdown, add that number to the DB //echo $data_source['espresso_addtl_limit_dd']; if (isset($data_source['espresso_addtl_limit_dd'])) { $num_people = $data_source['num_people']; } if (isset($event_meta['additional_attendee_reg_info']) && $event_meta['additional_attendee_reg_info'] == 1) { $num_people = $data_source['num_people']; } else { $num_people = 1; } $start_time = empty($start_time) ? '' : $start_time; $end_time = empty($end_time) ? '' : $end_time; $start_date = empty($start_date) ? '' : $start_date; $end_date = empty($end_date) ? '' : $end_date; $organization_name = empty($organization_name) ? '' : $organization_name; $country_id = empty($country_id) ? '' : $country_id; $payment_date = empty($payment_date) ? '' : $payment_date; $coupon_code = empty($coupon_code) ? '' : $coupon_code; $sql = array('registration_id' => $registration_id, 'attendee_session' => $_SESSION['espresso_session']['id'], 'lname' => $lname, 'fname' => $fname, 'address' => $address, 'address2' => $address2, 'city' => $city, 'state' => $state, 'zip' => $zip, 'email' => $email, 'phone' => $phone, 'payment' => $payment, 'amount_pd' => $amount_pd, 'txn_type' => $txn_type, 'coupon_code' => $coupon_code, 'event_time' => $start_time, 'end_time' => $end_time, 'start_date' => $start_date, 'end_date' => $end_date, 'price_option' => $price_type, 'organization_name' => $organization_name, 'country_id' => $country_id, 'payment_status' => $payment_status, 'payment_date' => $payment_date, 'event_id' => $event_id, 'quantity' => $num_people); $sql_data = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d'); //Debugging output /* echo 'Debug: <br />'; print_r($sql); echo '<br />'; print 'Number of vars: ' . count ($sql); echo '<br />'; print 'Number of cols: ' . count($sql_data); */ if ($num_rows > 0 && $loop_number == 1) { if (!isset($data_source['admin'])) { /* * Added for seating chart addon */ $tmp_session = $_SESSION['espresso_session']['id']; $rem_attendee_ids = $wpdb->get_results(" select t1.id, t1.registration_id FROM " . EVENTS_ATTENDEE_TABLE . " t1 WHERE t1.attendee_session ='" . $_SESSION['espresso_session']['id'] . "' {$incomplete_filter} "); foreach ($rem_attendee_ids as $v) { if (defined('ESPRESSO_SEATING_CHART')) { $wpdb->query("delete from " . EVENTS_SEATING_CHART_EVENT_SEAT_TABLE . " where attendee_id = " . $v->id); } } /* * End */ $wpdb->query(" DELETE t1, t2 FROM " . EVENTS_ATTENDEE_TABLE . " t1 JOIN " . EVENTS_ANSWER_TABLE . " t2 on t1.id = t2.attendee_id WHERE t1.attendee_session ='" . $_SESSION['espresso_session']['id'] . "' {$incomplete_filter} "); } //Added by Imon // First delete attempt might fail if there is no data in answer table. So, second attempt without joining answer table is taken bellow - $wpdb->query(" DELETE t1 FROM " . EVENTS_ATTENDEE_TABLE . " t1 WHERE t1.attendee_session ='" . $_SESSION['espresso_session']['id'] . "' {$incomplete_filter} "); // Clean up any attendee information from attendee_cost table where attendee is not available in attendee table event_espresso_cleanup_multi_event_registration_id_group_data(); event_espresso_cleanup_attendee_cost_data(); } $loop_number++; //Add new or updated data if (!$wpdb->insert(EVENTS_ATTENDEE_TABLE, $sql, $sql_data)) { $error = true; } $attendee_id = $wpdb->insert_id; /* * Added for seating chart addon */ $booking_id = 0; if (defined('ESPRESSO_SEATING_CHART')) { if (seating_chart::check_event_has_seating_chart($event_id) !== false) { if (isset($_POST['seat_id'])) { $booking_id = seating_chart::parse_booking_info($_POST['seat_id']); if ($booking_id > 0) { seating_chart::confirm_a_seat($booking_id, $attendee_id); } } } } //Add a record for the primary attendee $sql = array('attendee_id' => $attendee_id, 'meta_key' => 'primary_attendee', 'meta_value' => 1); $sql_data = array('%s', '%s', '%s'); //Debugging output /* echo 'Debug: <br />'; print_r($sql); echo '<br />'; print 'Number of vars: ' . count ($sql); echo '<br />'; print 'Number of cols: ' . count($sql_data); */ if (!$wpdb->insert(EVENTS_ATTENDEE_META_TABLE, $sql, $sql_data)) { $error = true; } /** * Adding attenddee specific cost to events_attendee_cost table */ if (!isset($data_source['admin'])) { if (isset($att_data_source['price_id'])) { $attendee_price_id = $att_data_source['price_id']; $events_prices = $wpdb->get_row("select * from " . EVENTS_PRICES_TABLE . " where id = {$attendee_price_id} "); } elseif (isset($data_source['price_select']) && $data_source['price_select'] == true) { $price_options = explode('|', $data_source['price_option'], 2); $attendee_price_id = $price_options[0]; $events_prices = $wpdb->get_row("select * from " . EVENTS_PRICES_TABLE . " where id = {$attendee_price_id} "); } else { $events_prices = $wpdb->get_row("select * from " . EVENTS_PRICES_TABLE . " where event_id = {$event_id}"); $attendee_price_id = $events_prices->id; } /* * Added for seating chart add-on * If a seat was selected then price of that seating will be used instead of event price */ $attendee_quantity = 1; if (isset($data_source['seat_id'])) { $attendee_cost = seating_chart::get_purchase_price($booking_id); } else { $attendee_cost = event_espresso_get_final_price($attendee_price_id, $event_id); if (isset($data_source['num_people'])) { $attendee_quantity = $data_source['num_people']; } } } else { /* echo '$data_source[\'event_cost\'] = '.$data_source['event_cost']; return; */ $attendee_quantity = 1; $attendee_cost = $data_source['event_cost']; } $attendee_cost_data = array("attendee_id" => $attendee_id, "quantity" => $attendee_quantity, "cost" => $attendee_cost); /* echo '$attendee_cost_data = '; print_r($attendee_cost_data); return; */ $wpdb->insert(EVENTS_ATTENDEE_COST_TABLE, $attendee_cost_data); /** * End */ if (get_option('event_mailchimp_active') == 'true' && $espresso_premium == true) { MailChimpController::list_subscribe($event_id, $attendee_id, $fname, $lname, $email); } //Since main attendee and additional attendees may have different questions, //$attendee_number check for 2 because is it statically set at 1 first and is incremented for the primary attendee above, hence 2 $questions = $attendee_number > 2 && isset($event_meta['add_attendee_question_groups']) ? $event_meta['add_attendee_question_groups'] : $questions; add_attendee_questions($questions, $registration_id, $attendee_id, array('session_vars' => $att_data_source)); //Add additional attendees to the database if ($event_meta['additional_attendee_reg_info'] == 1) { if (!empty($_REQUEST['num_people']) && $_REQUEST['num_people'] > 1) { } } else { $questions = $event_meta['add_attendee_question_groups']; //Debug //echo "<pre>".print_r($questions,true)."</pre>"; if (isset($att_data_source['x_attendee_fname'])) { $amount_pd = 0.0; //additional attendee can't hold this info foreach ($att_data_source['x_attendee_fname'] as $k => $v) { if (trim($v) != '' && trim($att_data_source['x_attendee_lname'][$k]) != '') { /* * Added for seating chart addon */ $seat_check = true; $x_booking_id = 0; if (defined('ESPRESSO_SEATING_CHART')) { if (seating_chart::check_event_has_seating_chart($event_id) !== false) { if (!isset($att_data_source['x_seat_id'][$k]) || trim($att_data_source['x_seat_id'][$k]) == '') { $seat_check = false; } else { $x_booking_id = seating_chart::parse_booking_info($att_data_source['x_seat_id'][$k]); if ($x_booking_id > 0) { $seat_check = true; } else { $seat_check = false; //Keeps the system from adding an additional attndee if no seat is selected } } } } if ($seat_check) { /* * End */ $sql_a = array('registration_id' => $registration_id, 'attendee_session' => $_SESSION['espresso_session']['id'], 'lname' => $att_data_source['x_attendee_lname'][$k], 'fname' => $v, 'email' => $att_data_source['x_attendee_email'][$k], 'address' => empty($att_data_source['x_attendee_address'][$k]) ? '' : $att_data_source['x_attendee_address'][$k], 'address2' => empty($att_data_source['x_attendee_address2'][$k]) ? '' : $att_data_source['x_attendee_address2'][$k], 'city' => empty($att_data_source['x_attendee_city'][$k]) ? '' : $att_data_source['x_attendee_city'][$k], 'state' => empty($att_data_source['x_attendee_state'][$k]) ? '' : $att_data_source['x_attendee_state'][$k], 'zip' => empty($att_data_source['x_attendee_zip'][$k]) ? '' : $att_data_source['x_attendee_zip'][$k], 'phone' => empty($att_data_source['x_attendee_phone'][$k]) ? '' : $att_data_source['x_attendee_phone'][$k], 'payment' => $payment, 'amount_pd' => $amount_pd, 'event_time' => $start_time, 'end_time' => $end_time, 'start_date' => $start_date, 'end_date' => $end_date, 'price_option' => $price_type, 'organization_name' => $organization_name, 'country_id' => $country_id, 'payment_status' => $payment_status, 'payment_date' => $payment_date, 'event_id' => $event_id, 'quantity' => $num_people); $sql_data_a = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d'); $wpdb->insert(EVENTS_ATTENDEE_TABLE, $sql_a, $sql_data_a); //Added by Imon $ext_attendee_id = $wpdb->insert_id; $mailchimp_attendee_id = $ext_attendee_id; /** * Adding attenddee specific cost to events_attendee cost table */ $attendee_cost_data = array("attendee_id" => $ext_attendee_id, "quantity" => $attendee_quantity, "cost" => $attendee_cost); $wpdb->insert(EVENTS_ATTENDEE_COST_TABLE, $attendee_cost_data); /** * End */ if (get_option('event_mailchimp_active') == 'true' && $espresso_premium == true) { MailChimpController::list_subscribe($event_id, $mailchimp_attendee_id, $v, $att_data_source['x_attendee_lname'][$k], $att_data_source['x_attendee_email'][$k]); } //Added by Imon $ext_att_data_source = array('registration_id' => $registration_id, 'attendee_session' => $_SESSION['espresso_session']['id'], 'lname' => $att_data_source['x_attendee_lname'][$k], 'fname' => $v, 'email' => $att_data_source['x_attendee_email'][$k], 'address' => empty($att_data_source['x_attendee_address'][$k]) ? '' : $att_data_source['x_attendee_address'][$k], 'address2' => empty($att_data_source['x_attendee_address2'][$k]) ? '' : $att_data_source['x_attendee_address2'][$k], 'city' => empty($att_data_source['x_attendee_city'][$k]) ? '' : $att_data_source['x_attendee_city'][$k], 'state' => empty($att_data_source['x_attendee_state'][$k]) ? '' : $att_data_source['x_attendee_state'][$k], 'zip' => empty($att_data_source['x_attendee_zip'][$k]) ? '' : $att_data_source['x_attendee_zip'][$k], 'phone' => empty($att_data_source['x_attendee_phone'][$k]) ? '' : $att_data_source['x_attendee_phone'][$k], 'payment' => $payment, 'amount_pd' => $amount_pd, 'event_time' => $start_time, 'end_time' => $end_time, 'start_date' => $start_date, 'end_date' => $end_date, 'price_option' => $price_type, 'organization_name' => $organization_name, 'country_id' => $country_id, 'payment_status' => $payment_status, 'payment_date' => $payment_date, 'event_id' => $event_id, 'quantity' => $num_people); $questions_in = ''; //Debug //echo "<pre questions - >".print_r($questions,true)."</pre>"; if (!is_array($questions) && !empty($questions)) { $questions = unserialize($questions); } foreach ($questions as $g_id) { $questions_in .= $g_id . ','; } $questions_in = substr($questions_in, 0, -1); $questions_list = $wpdb->get_results("SELECT q.*, qg.group_name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . EVENTS_QUESTION_TABLE . " q\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN " . EVENTS_QST_GROUP_REL_TABLE . " qgr\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ton q.id = qgr.question_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN " . EVENTS_QST_GROUP_TABLE . " qg\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ton qg.id = qgr.group_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE qgr.group_id in (" . $questions_in . ") ORDER BY q.id ASC"); foreach ($questions_list as $question_list) { if ($question_list->system_name != '') { $ext_att_data_source[$question_list->system_name] = $att_data_source['x_attendee_' . $question_list->system_name][$k]; } else { $ext_att_data_source[$question_list->question_type . '_' . $question_list->id] = $att_data_source['x_attendee_' . $question_list->question_type . '_' . $question_list->id][$k]; } } echo add_attendee_questions($questions, $registration_id, $ext_attendee_id, array('session_vars' => $ext_att_data_source)); /* * Added for seating chart addon */ } if (defined('ESPRESSO_SEATING_CHART')) { if (seating_chart::check_event_has_seating_chart($event_id) !== false && $x_booking_id > 0) { seating_chart::confirm_a_seat($x_booking_id, $ext_attendee_id); } } /* * End */ } } } } //Add member data if needed if (get_option('events_members_active') == 'true') { require_once EVENT_ESPRESSO_MEMBERS_DIR . "member_functions.php"; //Load Members functions require EVENT_ESPRESSO_MEMBERS_DIR . "user_vars.php"; //Load Members functions if ($userid != 0) { event_espresso_add_user_to_event($event_id, $userid, $attendee_id); } } //This shows the payment page if (isset($data_source['admin'])) { return $attendee_id; } if (!$multi_reg) { return events_payment_page($attendee_id); } return $registration_id; }
function events_payment_page($attendee_id = FALSE, $notifications = array()) { do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); if (!$attendee_id) { wp_die(__('An error occured. No Attendee was received.', 'event_espresso')); } global $wpdb, $org_options; $num_people = 0; // $Organization = $org_options['organization']; // $Organization_street1 = $org_options['organization_street1']; // $Organization_street2 = $org_options['organization_street2']; // $Organization_city = $org_options['organization_city']; // $Organization_state = $org_options['organization_state']; // $Organization_zip = $org_options['organization_zip']; // $contact = $org_options['contact_email']; // $registrar = $org_options['contact_email']; // $currency_format = getCountryFullData($org_options['organization_country']); $message = $org_options['message']; $return_url = $org_options['return_url']; $cancel_return = $org_options['cancel_return']; $notify_url = $org_options['notify_url']; $event_page_id = $org_options['event_page_id']; // GET ATTENDEE $SQL = "SELECT * FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id =%d"; $attendee = $wpdb->get_row($wpdb->prepare($SQL, $attendee_id)); //printr( $attendee, '$attendee <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); $attendee_last = $attendee->lname; $attendee_first = $attendee->fname; $attendee_name = stripslashes_deep($attendee_first . ' ' . $attendee_last); $attendee_address = $attendee->address; $attendee_address2 = $attendee->address2; $attendee_city = $attendee->city; $attendee_state = $attendee->state; $attendee_zip = $attendee->zip; $attendee_email = $attendee->email; $phone = $attendee->phone; $attendee_phone = $attendee->phone; $date = $attendee->date; $quantity = (int) $attendee->quantity; $payment_status = $attendee->payment_status; $txn_type = $attendee->txn_type; $payment_date = $attendee->payment_date; $event_id = $attendee->event_id; $registration_id = $attendee->registration_id; $orig_price = (double) $attendee->orig_price; $final_price = (double) $attendee->final_price; //Get the questions for the attendee $SQL = "SELECT ea.answer, eq.question "; $SQL .= "\tFROM " . EVENTS_ANSWER_TABLE . " ea "; $SQL .= "LEFT JOIN " . EVENTS_QUESTION_TABLE . " eq ON eq.id = ea.question_id "; $SQL .= "\tWHERE ea.attendee_id = %d and eq.admin_only != 'Y' "; $SQL .= "\tORDER BY eq.sequence asc "; $questions = $wpdb->get_results($wpdb->prepare($SQL, $attendee_id)); // echo '<h4>LQ : ' . $wpdb->last_query . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; // printr( $questions, '$questions <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); $display_questions = ''; foreach ($questions as $question) { $question->question = trim(stripslashes(str_replace(''', "'", $question->question))); $question->question = htmlspecialchars($question->question, ENT_QUOTES, 'UTF-8'); $question->answer = trim(stripslashes(str_replace(''', "'", $question->answer))); $question->answer = htmlspecialchars($question->answer, ENT_QUOTES, 'UTF-8'); $display_questions .= '<p>' . $question->question . ':<br /> ' . str_replace(',', '<br />', $question->answer) . '</p>'; } // update total cost for primary attendee $total_cost = (double) $final_price * (int) $quantity - $attendee->amount_pd; $total_attendees = (int) $quantity; $attendee_prices[] = array('option' => $attendee->price_option, 'qty' => (int) $quantity, 'price' => (double) ($final_price - $attendee->amount_pd)); // get # of attendees $SQL = "SELECT price_option, quantity, final_price, amount_pd FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id =%s"; $prices = $wpdb->get_results($wpdb->prepare($SQL, $registration_id)); //printr( $prices, '$prices <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); if ($prices !== FALSE) { $total_cost = 0; $total_attendees = 0; $attendee_prices = array(); // ensure prices is an array $prices = is_array($prices) ? $prices : array($prices); foreach ($prices as $price) { // update total cost for all attendees $total_cost += (double) ($price->final_price * (int) $price->quantity) - (double) $price->amount_pd; $total_attendees += $price->quantity; $attendee_prices[] = array('option' => $price->price_option, 'qty' => (int) $price->quantity, 'price' => (double) ($price->final_price - $price->amount_pd)); } } $SQL = "SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE id = %d"; $event = $wpdb->get_row($wpdb->prepare($SQL, $event_id)); $event_name = isset($event->event_name) ? stripslashes_deep($event->event_name) : ''; $event_description = $event_desc = isset($event->event_desc) ? stripslashes_deep($event->event_desc) : ''; $event_identifier = isset($event->event_identifier) ? $event->event_identifier : ''; $send_mail = isset($event->send_mail) ? $event->send_mail : ''; $active = isset($event->is_active) ? $event->is_active : TRUE; $conf_mail = isset($event->conf_mail) ? $event->conf_mail : ''; //$event_price_x_attendees = number_format( $final_price * $num_people, 2, '.', '' ); $event_original_cost = $orig_price; // Added for seating chart addon // This code block overrides the cost using seating chart add-on price if (defined('ESPRESSO_SEATING_CHART') && class_exists("seating_chart") && seating_chart::check_event_has_seating_chart($event_id) !== false) { $SQL = "SELECT sum(sces.purchase_price) as purchase_price "; $SQL .= "FROM " . EVENTS_SEATING_CHART_EVENT_SEAT_TABLE . " sces "; $SQL .= "INNER JOIN " . EVENTS_ATTENDEE_TABLE . " ea ON sces.attendee_id = ea.id "; $SQL .= "WHERE ea.registration_id = %s"; if ($seat = $wpdb->get_row($wpdb->prepare($SQL, $registration_id))) { $total_cost = number_format($seat->purchase_price, 2, '.', ''); //$event_price_x_attendees = (float)$final_price; } } if ($total_cost == 0) { $payment_status = 'Completed'; //DO NOT TRANSLATE $today = date(get_option('date_format')); $data = array('amount_pd' => 0.0, 'payment_status' => $payment_status, 'payment_date' => $today); $format = array('%f', '%s', '%s'); $update_id = array('id' => $attendee_id); $wpdb->update(EVENTS_ATTENDEE_TABLE, $data, $update_id, $format, array('%d')); //If this is a group registration, we need to make sure all attendees have the same payment status if (espresso_count_attendees_for_registration($attendee_id) > 1) { $wpdb->query("UPDATE " . EVENTS_ATTENDEE_TABLE . " SET payment_status = '{$payment_status}' WHERE registration_id ='" . $registration_id . "'"); } } if (function_exists('espresso_update_attendee_coupon_info') && $attendee_id && !empty($attendee->coupon_code)) { espresso_update_attendee_coupon_info($attendee_id, $attendee->coupon_code); } if (function_exists('espresso_update_groupon') && $attendee_id && !empty($attendee->coupon_code)) { espresso_update_groupon($attendee_id, $attendee->coupon_code); } // echo '<h4>$attendee_id : ' . $attendee_id . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; // echo '<h4>$total_cost : ' . $total_cost . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; espresso_update_primary_attendee_total_cost($attendee_id, $total_cost, __FILE__); if (!empty($notifications['coupons']) || !empty($notifications['groupons'])) { echo '<div id="event_espresso_notifications" class="clearfix event-data-display no-hide">'; echo $notifications['coupons']; // add space between $coupon_notifications and $groupon_notifications ( if any $groupon_notifications exist ) echo !empty($notifications['coupons']) && !empty($notifications['groupons']) ? '<br/>' : ''; echo $notifications['groupons']; echo '</div>'; } if (isset($org_options['skip_confirmation_page']) && $org_options['skip_confirmation_page'] == 'Y') { $redirect_url = home_url() . '/?page_id=' . $org_options['event_page_id'] . '®event_action=confirm_registration'; $_POST['regevent_action'] = 'confirm_registration'; $_POST['confirm'] = 'Confirm Registration'; $_POST['confirm_registration'] = TRUE; $_POST['attendee_id'] = $attendee_id; $_POST['event_id'] = $event_id; $_POST['registration_id'] = $registration_id; espresso_confirm_registration(); } else { $display_cost = $total_cost > 0 ? $org_options['currency_symbol'] . number_format($total_cost, 2, '.', '') : __('Free', 'event_espresso'); // Pull in the template if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "confirmation_display.php")) { require_once EVENT_ESPRESSO_TEMPLATE_DIR . "confirmation_display.php"; //This is the path to the template file if available } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/confirmation_display.php"; } } }
function event_espresso_run() { global $wpdb, $org_options, $load_espresso_scripts; do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); $load_espresso_scripts = true; //This tells the plugin to load the required scripts ob_start(); //Make sure scripts are loading echo espresso_check_scripts(); // Get action type $regevent_action = isset($_REQUEST['regevent_action']) ? $_REQUEST['regevent_action'] : ''; if (isset($_REQUEST['ee'])) { $regevent_action = "register"; $_REQUEST['event_id'] = $_REQUEST['ee']; } if (isset($_REQUEST['form_action']) && $_REQUEST['form_action'] == 'edit_attendee' || isset($_REQUEST['edit_attendee']) && $_REQUEST['edit_attendee'] == 'true') { $regevent_action = "edit_attendee"; } switch ($regevent_action) { case "register": register_attendees(); break; case "post_attendee": event_espresso_add_attendees_to_db(NULL, NULL, FALSE); break; case "show_shopping_cart": // MER ONLY - This is the form page for registering the attendee event_espresso_require_template('shopping_cart.php'); event_espresso_shopping_cart(); break; case "load_checkout_page": // MER ONLY if ($_POST) { event_espresso_update_item_in_session('details'); } event_espresso_load_checkout_page(); break; case "post_multi_attendee": // MER ONLY event_espresso_update_item_in_session('attendees'); event_espresso_add_attendees_to_db_multi(); break; case "confirm_registration": espresso_confirm_registration(); break; case "edit_attendee": require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/process-registration/attendee_edit_record.php'; attendee_edit_record(); break; default: display_all_events(); } $content = ob_get_contents(); ob_end_clean(); return $content; }
function event_espresso_run() { global $wpdb, $org_options, $load_espresso_scripts, $espresso_content; do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); $load_espresso_scripts = true; //This tells the plugin to load the required scripts ob_start(); //Make sure scripts are loading echo espresso_check_scripts(); // Get action type $regevent_action = isset($_REQUEST['regevent_action']) ? $_REQUEST['regevent_action'] : ''; if (isset($_REQUEST['event_id']) && !empty($_REQUEST['event_id'])) { $_REQUEST['event_id'] = wp_strip_all_tags(absint($_REQUEST['event_id'])); } if (isset($_REQUEST['form_action']) && !empty($_REQUEST['form_action'])) { if (isset($_REQUEST['form_action']) && !$_REQUEST['form_action'] == 'edit_attendee') { $_REQUEST['primary'] = wp_strip_all_tags(absint($_REQUEST['primary'])); } } if (isset($_REQUEST['ee']) && !empty($_REQUEST['ee'])) { $regevent_action = "register"; $_REQUEST['ee'] = wp_strip_all_tags(absint($_REQUEST['ee'])); $_REQUEST['event_id'] = $_REQUEST['ee']; } if (isset($_REQUEST['form_action']) && $_REQUEST['form_action'] == 'edit_attendee' || isset($_REQUEST['edit_attendee']) && $_REQUEST['edit_attendee'] == 'true') { $regevent_action = "edit_attendee"; } switch ($regevent_action) { case "register": register_attendees(); break; case "post_attendee": //Various attendee functions require_once "includes/functions/attendee_functions.php"; //Add attendees to the database require_once "includes/process-registration/add_attendees_to_db.php"; //Payment/Registration Processing - Used to display the payment options and the payment link in the email. Used with the [ESPRESSO_PAYMENTS] tag require_once "includes/process-registration/payment_page.php"; event_espresso_add_attendees_to_db(NULL, NULL, FALSE); break; case "show_shopping_cart": // MER ONLY - This is the form page for registering the attendee event_espresso_require_template('shopping_cart.php'); event_espresso_shopping_cart(); break; case "load_checkout_page": // MER ONLY if ($_POST) { event_espresso_update_item_in_session('details'); } event_espresso_load_checkout_page(); break; case "post_multi_attendee": // MER ONLY //Various attendee functions require_once "includes/functions/attendee_functions.php"; //Add attendees to the database require_once "includes/process-registration/add_attendees_to_db.php"; event_espresso_update_item_in_session('attendees'); event_espresso_add_attendees_to_db_multi(); break; case "confirm_registration": //Various attendee functions require_once "includes/functions/attendee_functions.php"; //Payment/Registration Processing - Used to display the payment options and the payment link in the email. Used with the [ESPRESSO_PAYMENTS] tag require_once "includes/process-registration/payment_page.php"; espresso_confirm_registration(); break; case "edit_attendee": //Various attendee functions require_once "includes/functions/attendee_functions.php"; //Payment/Registration Processing - Used to display the payment options and the payment link in the email. Used with the [ESPRESSO_PAYMENTS] tag require_once "includes/process-registration/payment_page.php"; require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/process-registration/attendee_edit_record.php'; attendee_edit_record(); break; default: display_all_events(); } $content = ob_get_contents(); ob_end_clean(); $espresso_content = $content; add_shortcode('ESPRESSO_EVENTS', 'espresso_return_espresso_content'); }