Example #1
0
    function event_espresso_additional_attendees($event_id = 0, $additional_limit = 2, $available_spaces = 999, $label = '', $show_label = true, $event_meta = '')
    {
        $event_id = $event_id == 0 ? $_REQUEST['event_id'] : $event_id;
        if ($event_meta == '' && ($event_id != '' || $event_id != 0)) {
            $event_meta = event_espresso_get_event_meta($event_id);
        }
        $i = 0;
        if ($event_meta['additional_attendee_reg_info'] == 1) {
            $label = $label == '' ? __('Number of Tickets', 'event_espresso') : $label;
            $html = '<span class="espresso_additional_limit">';
            $html .= $show_label == true ? '<label for="num_people">' . $label . '</label>' : '';
            $html .= '<select name="num_people" id="num_people-' . $event_id . '" style="width:70px;">';
            while ($i <= $additional_limit && $i < $available_spaces) {
                $i++;
                $html .= '<option value="' . $i . '">' . $i . '</option>';
            }
            $html .= '</select>';
            //$html .= '<br />';
            $html .= '<input type="hidden" name="espresso_addtl_limit_dd" value="true">';
            $html .= '</span>';
            $buffer = '';
        } else {
            while ($i <= $additional_limit && $i < $available_spaces) {
                $i++;
            }
            $i = $i - 1;
            $html = '<p class="event_form_field additional_header" id="additional_header">';
            // fixed for translation string, previous string untranslatable - http://events.codebasehq.com/projects/event-espresso/tickets/11
            //$html .= '<a onclick="return false;" href="#">' . __('Add More Attendees? (click to toggle, limit ' . $i . ')', 'event_espresso') . '</a>';
            $html .= '<a onclick="return false;" href="#">' . __('Add More Attendees? (click to toggle, limit ', 'event_espresso');
            $html .= $i . ')</a>';
            $html .= '</p>';
            $html .= '<div id="additional_attendees">';
            $html .= '<div class="clone espresso_add_attendee">';
            /*
             * Added for seating chart addon
             */
            if (defined('ESPRESSO_SEATING_CHART')) {
                if (seating_chart::check_event_has_seating_chart($_REQUEST['event_id']) !== false) {
                    $html .= '<p>';
                    $html .= '<label>' . __('Select a Seat:', 'event_espresso') . '</label>';
                    $html .= '<input type="text" name="x_seat_id[]" value="" class="ee_s_select_seat" event_id="' . $_REQUEST['event_id'] . '" readonly="readonly" />';
                    $html .= '<br/>[' . __('If you do not select a seat this attendee will not be added', 'event_espresso') . ']';
                    $html .= '</p>';
                }
            }
            if ($event_meta['additional_attendee_reg_info'] == 2) {
                $html .= '<p>';
                $html .= '<label for="x_attendee_fname">' . __('First Name:', 'event_espresso') . '</label>';
                $html .= '<input type="text" name="x_attendee_fname[]" class="input"/>';
                $html .= '</p>';
                $html .= '<p>';
                $html .= '<label for="x_attendee_lname">' . __('Last Name:', 'event_espresso') . '</label>';
                $html .= '<input type="text" name="x_attendee_lname[]" class="input"/>';
                $html .= '</p>';
                $html .= '<p>';
                $html .= '<label for="x_attendee_email">' . __('Email:', 'event_espresso') . '</label>';
                $html .= '<input type="text" name="x_attendee_email[]" class="input"/>';
                $html .= '</p>';
            } else {
                $html .= event_espresso_add_question_groups($event_meta['add_attendee_question_groups'], '', null, 0, array("x_attendee" => true));
            }
            $html .= '<a href="#" class="add" rel=".clone" title="' . __('Add an Additonal Attendee', 'event_espresso') . '"><img src="' . EVENT_ESPRESSO_PLUGINFULLURL . 'images/icons/add.png" alt="' . __('Add an Additonal Attendee', 'event_espresso') . '" /></a>';
            $html .= '</div>';
            $html .= '<hr />';
            $html .= '</div>';
            ob_start();
            ?>
			<script type="text/javascript">$jaer = jQuery.noConflict();jQuery(document).ready(function($jaer) { $jaer(function(){var removeLink = '<a style="" class="remove" href="#" onclick="$jaer(this).parent().slideUp(function(){ $jaer(this).remove() }); return false"><img src="<?php 
            echo EVENT_ESPRESSO_PLUGINFULLURL . "images/icons/remove.gif";
            ?>
" alt="<?php 
            _e('Remove Attendee', 'event_espresso');
            ?>
" /></a>';$jaer('a.add').relCopy({limit: <?php 
            echo $i;
            ?>
, append: removeLink});$jaer("#additional_attendees").hide();/*toggle the componenet with class msg_body*/$jaer("#additional_header").click(function(){$jaer(this).next("#additional_attendees").slideToggle(500);});});});</script>
			<?php 
            $buffer = ob_get_contents();
            ob_end_clean();
        }
        return $html . $buffer;
    }
    function event_espresso_add_attendees_to_db_multi()
    {
        global $wpdb, $org_options;
        //Added by Imon
        $primary_registration_id = NULL;
        $events_in_session = $_SESSION['espresso_session']['events_in_session'];
        if (event_espresso_invoke_cart_error($events_in_session)) {
            return false;
        }
        $count_of_events = count($events_in_session);
        $current_session_id = $_SESSION['espresso_session']['id'];
        //Debug
        //echo "<pre>", print_r($_SESSION), "</pre>";
        //echo '<pre>'.print_r($_POST, true).'</pre>';
        //echo "<pre>", print_r($events_in_session), "</pre>";
        //echo "<pre>", print_r($org_options), "</pre>";
        $event_name = $count_of_events . ' ' . $org_options['organization'] . __(' events', 'event_espresso');
        $event_cost = $_SESSION['espresso_session']['grand_total'];
        $multi_reg = true;
        // If there are events in the session, add them one by one to the attendee table
        if ($count_of_events > 0) {
            //first event key will be used to find the first attendee
            $first_event_id = key($events_in_session);
            //Debug
            //echo '<pre>$events_in_session - '.print_r($events_in_session, true).'</pre>';
            reset($events_in_session);
            foreach ($events_in_session as $key => $_event_id) {
                //Debug
                //echo '<p>$_event_id - '. $_event_id.'</p>';
                //echo '<pre>'.print_r($_event_id, true).'</pre>';
                $event_meta = event_espresso_get_event_meta($key);
                $event_attendees = $_event_id['event_attendees'];
                $session_vars['data'] = $_event_id;
                //Debug
                //echo '<p>$_event_id - '. $_event_id.'</p>';
                //echo '<pre>'.print_r($session_vars['data'], true).'</pre>';
                if (is_array($event_attendees)) {
                    $counter = 1;
                    foreach ($event_attendees as $k_price_id => $v_attendees) {
                        //foreach price type in event attendees
                        $session_vars['data'] = $_event_id;
                        //Debug
                        //echo '<pre>$session_vars[\'data\' - ]'.print_r($session_vars['data'], true).'</pre>';
                        foreach ($v_attendees as $vkey => $vval) {
                            //Added by Imon
                            $vval['price_id'] = $k_price_id;
                            $session_vars['event_attendees'] = $vval;
                            //this has all the attendee information, name, questions....
                            $session_vars['data']['price_type'] = $_event_id['price_id'][$k_price_id]['price_type'];
                            if (isset($event_meta['additional_attendee_reg_info']) && $event_meta['additional_attendee_reg_info'] == 1) {
                                //Getting he wrong number of attendees at this point
                                //Debug
                                //echo '<p>$_REQUEST[\'num_people\'] - '.$_REQUEST['num_people'].'</p>';
                                //echo '<p>$_event_id[\'price_id\'][$k_price_id] - '.$_event_id['price_id'][$k_price_id].'</p>';
                                //echo '<pre>$_event_id[\'price_id\'][$k_price_id] - '.print_r($_event_id['price_id'][$k_price_id]['attendee_quantity'], true).'</pre>';
                                //echo '<pre>'.print_r($_POST, true).'</pre>';
                                $num_people = $_event_id['price_id'][$k_price_id]['attendee_quantity'];
                                $session_vars['data']['num_people'] = empty($num_people) || $num_people == 0 ? 1 : $num_people;
                                //Debug
                                //echo '<p>$session_vars[\'data\'][\'num_people\'] - '.$session_vars['data']['num_people'].'</p>';
                            }
                            //Debug
                            /* echo $key.'<br />';
                            	  echo '<pre>$session_vars - '.print_r($session_vars, true).'</pre>';
                            	  echo '<br />'; */
                            $tmp_registration_id = event_espresso_add_attendees_to_db($key, $session_vars);
                            //Debug
                            //echo 'tmp_registration_id =' . $tmp_registration_id.'<br />';
                            if ($primary_registration_id === NULL) {
                                $primary_registration_id = $tmp_registration_id;
                            }
                            $c2_sql = "select * from " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " where primary_registration_id = '{$primary_registration_id}' and registration_id = '{$tmp_registration_id}'";
                            //Debug
                            //echo $c2_sql.'<br />';
                            $check = $wpdb->get_row($c2_sql);
                            if ($check === NULL) {
                                $tmp_data = array("primary_registration_id" => $primary_registration_id, "registration_id" => $tmp_registration_id);
                                $wpdb->insert(EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE, $tmp_data);
                            }
                        }
                        $counter++;
                    }
                }
            }
            //Post the gateway page with the payment options
            if ($event_cost != '0.00') {
                //find first registrant's name, email, count of registrants
                $sql = "SELECT id, fname, lname, email, address, city, state, zip, event_id, registration_id,\n\t\t\t\t\t\t(SELECT count( id )\n\t\t\t\t\t\t\tFROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session = '" . $wpdb->escape($current_session_id) . "'\n\t\t\t\t\t\t\t) AS quantity\n\t\t\t\t\t\t\tFROM " . EVENTS_ATTENDEE_TABLE . " WHERE event_id = " . $wpdb->escape($first_event_id) . " AND attendee_session = '" . $wpdb->escape($current_session_id) . "' LIMIT 1";
                //echo $sql;
                $r = $wpdb->get_row($sql);
                $event_id = $r->event_id;
                $attendee_id = $r->id;
                $fname = $r->fname;
                $lname = $r->lname;
                $address = $r->address;
                $city = $r->city;
                $state = $r->state;
                $zip = $r->zip;
                $attendee_email = $r->email;
                $registration_id = $r->registration_id;
                $quantity = espresso_count_attendees_for_registration($r->registration_id);
                ?>
				<?php 
                /* //removing edit links for now...will fix edit attendee page in 3.2 cb #830
                			<a href="?page_id=<?php echo $org_options['event_page_id']; ?>&regevent_action=show_shopping_cart">  <?php _e('Edit Cart', 'event_espresso'); ?> </a>
                			<?php _e(' or ', 'event_espresso'); ?>
                			<a href="?page_id=<?php echo $org_options['event_page_id']; ?>&regevent_action=load_checkout_page"> <?php _e('Edit Registrant Information', 'event_espresso'); ?></a>
                			*/
                ?>

				<h3><?php 
                _e('Your registration is not complete until payment is received.', 'event_espresso');
                ?>
</h3>

				<p><strong class="event_espresso_name">
						<?php 
                _e('Amount due: ', 'event_espresso');
                ?>
					</strong> <span class="event_espresso_value"><?php 
                echo $org_options['currency_symbol'];
                echo $event_cost;
                ?>
</span></p>

				<p><?php 
                echo $org_options['email_before_payment'] == 'Y' ? __('A confirmation email has been sent with additional details of your registration.', 'event_espresso') : '';
                ?>
</p>

				<?php 
                //Show payment options
                if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "gateway_display.php")) {
                    require_once EVENT_ESPRESSO_GATEWAY_DIR . "gateway_display.php";
                } else {
                    require_once EVENT_ESPRESSO_PLUGINFULLPATH . "gateways/gateway_display.php";
                }
                //Check to see if the site owner wants to send an confirmation eamil before payment is recieved.
                if ($org_options['email_before_payment'] == 'Y') {
                    event_espresso_email_confirmations(array('session_id' => $_SESSION['espresso_session']['id'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true', 'multi_reg' => true));
                }
            } else {
                ?>

				<p><?php 
                _e('Thank you! Your registration is confirmed for', 'event_espresso');
                ?>
 <strong><?php 
                echo stripslashes_deep($event_name);
                ?>
</strong></p>

				<p><?php 
                _e('A confirmation email has been sent with additional details of your registration.', 'event_espresso');
                ?>
</p>

				<?php 
                event_espresso_email_confirmations(array('session_id' => $_SESSION['espresso_session']['id'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true', 'multi_reg' => true));
                event_espresso_clear_session();
            }
        }
    }
    function event_espresso_additional_attendees($event_id = 0, $additional_limit = 2, $available_spaces = 999, $label = '', $show_label = true, $event_meta = '', $qstn_class = '')
    {
        global $espresso_premium;
        $event_id = $event_id == 0 ? $_REQUEST['event_id'] : $event_id;
        if ($event_meta == 'admin') {
            $admin = true;
            $event_meta = '';
        }
        if ($event_meta == '' && ($event_id != '' || $event_id != 0)) {
            $event_meta = event_espresso_get_event_meta($event_id);
        }
        //If the additional attednee questions are empty, then default to the first question group
        if (empty($event_meta['add_attendee_question_groups'])) {
            $event_meta['add_attendee_question_groups'] = array(1 => 1);
        }
        $i = 0;
        if (isset($event_meta['additional_attendee_reg_info']) && $event_meta['additional_attendee_reg_info'] == 1 || $espresso_premium == FALSE) {
            $label = $label == '' ? __('Number of Tickets', 'event_espresso') : $label;
            $html = '<p class="espresso_additional_limit highlight-bg">';
            $html .= $show_label == true ? '<label for="num_people">' . $label . '</label>' : '';
            $html .= '<select name="num_people" id="num_people-' . $event_id . '" style="width:70px;">';
            while ($i < $additional_limit && $i < $available_spaces) {
                $i++;
                $html .= '<option value="' . $i . '">' . $i . '</option>';
            }
            $html .= '</select>';
            //$html .= '<br />';
            $html .= '<input type="hidden" name="espresso_addtl_limit_dd" value="true">';
            $html .= '</p>';
            $buffer = '';
        } else {
            //			while (($i < $additional_limit) && ($i < $available_spaces)) {
            //				$i++;
            //			}
            $i = min($additional_limit, $available_spaces) - 1;
            $html = '<div id="additional_header" class="event_form_field additional_header espresso_add_subtract_attendees">';
            // fixed for translation string, previous string untranslatable - http://events.codebasehq.com/projects/event-espresso/tickets/11
            $html .= '<a id="add-additional-attendee-1" rel="1" class="add-additional-attendee-lnk additional-attendee-lnk ui-state-highlight">' . sprintf(__('Add More Attendees? (click to toggle, limit %s)', 'event_espresso'), $i) . '</a></div>';
            //ob_start();
            $attendee_form = '<div id="additional_attendee_XXXXXX" class="espresso_add_attendee">';
            $attendee_form .= '<h4 class="additional-attendee-nmbr-h4">' . __('Attendee #', 'event_espresso') . 'XXXXXX</h4>';
            /*
             * Added for seating chart addon
             */
            if (defined('ESPRESSO_SEATING_CHART')) {
                if (seating_chart::check_event_has_seating_chart($_REQUEST['event_id']) !== false) {
                    $attendee_form .= '<p>';
                    $attendee_form .= '<label>' . __('Select a Seat:', 'event_espresso') . '</label>';
                    $attendee_form .= '<input type="text" name="x_seat_id[XXXXXX]" value="" class="ee_s_select_seat" event_id="' . $_REQUEST['event_id'] . '" readonly="readonly" />';
                    $attendee_form .= '<br/>[' . __('If you do not select a seat this attendee will not be added', 'event_espresso') . ']';
                    $attendee_form .= '</p>';
                }
            }
            if ($event_meta['additional_attendee_reg_info'] == 2) {
                $attendee_form .= '<p>';
                $attendee_form .= '<label for="x_attendee_fname">' . __('First Name:', 'event_espresso') . '</label>';
                $attendee_form .= '<input type="text" name="x_attendee_fname[XXXXXX]" class="ee-reg-page-text-input fname"/>';
                $attendee_form .= '</p>';
                $attendee_form .= '<p>';
                $attendee_form .= '<label for="x_attendee_lname">' . __('Last Name:', 'event_espresso') . '</label>';
                $attendee_form .= '<input type="text" name="x_attendee_lname[XXXXXX]" class="ee-reg-page-text-input lname"/>';
                $attendee_form .= '</p>';
                $attendee_form .= '<p>';
                $attendee_form .= '<label for="x_attendee_email">' . __('Email:', 'event_espresso') . '</label>';
                $attendee_form .= '<input type="text" name="x_attendee_email[XXXXXX]" class="ee-reg-page-text-input email"/>';
                $attendee_form .= '</p>';
            } else {
                $attendee_form .= '<input type="hidden" name="x_attendee_nmbr[XXXXXX]" class="x_attendee_nmbr" value="XXXXXX"/>';
                $meta = array("x_attendee" => true);
                if (!empty($admin)) {
                    $meta['admin_only'] = true;
                }
                $attendee_form .= event_espresso_add_question_groups($event_meta['add_attendee_question_groups'], '', null, 0, $meta, $qstn_class);
            }
            $attendee_form .= '<div class="espresso_add_subtract_attendees">';
            $attendee_form .= '
			<div class="additional-attendee-div"><a id="remove-additional-attendee-XXXXXX" rel="XXXXXX" class="remove-additional-attendee-lnk additional-attendee-lnk ui-priority-primary " title="' . __('Remove Attendee Above', 'event_espresso') . '">
				<img src="' . EVENT_ESPRESSO_PLUGINFULLURL . 'images/icons/remove.gif" alt="' . __('Remove Attendee', 'event_espresso') . '" />
				' . __('Remove Attendee Above', 'event_espresso') . '
			</a></div>';
            $attendee_form .= '
			<div class="additional-attendee-div"><a id="add-additional-attendee-XXXXXX" rel="XXXXXX" class="add-additional-attendee-lnk additional-attendee-lnk ui-priority-primary " title="' . __('Add Additional Attendee', 'event_espresso') . '">
				<img src="' . EVENT_ESPRESSO_PLUGINFULLURL . 'images/icons/add.png" alt="' . __('Add Additional Attendee', 'event_espresso') . '" />
				' . __('Add Additional Attendee', 'event_espresso') . '
			</a></div>';
            $attendee_form .= '</div></div>';
            wp_register_script('espresso_add_reg_attendees', EVENT_ESPRESSO_PLUGINFULLURL . 'scripts/espresso_add_reg_attendees.js', array('jquery'), '0.1', TRUE);
            wp_enqueue_script('espresso_add_reg_attendees');
            $espresso_add_reg_attendees = array('additional_limit' => min($additional_limit, $available_spaces), 'attendee_form' => stripslashes($attendee_form));
            wp_localize_script('espresso_add_reg_attendees', 'espresso_add_reg_attendees', $espresso_add_reg_attendees);
        }
        return $html;
    }
$data['city'] = isset($city) && !empty($city) ? $city : '';
$data['state'] = isset($state) && !empty($state) ? $state : '';
$data['country'] = isset($country) && !empty($country) ? $country : '';
$data['country'] = isset($country_id) && !empty($country_id) && $data['country'] == '' ? $country_id : '';
$data['zip'] = isset($zip) && !empty($zip) ? $zip : '';
if (empty($event_cost)) {
    $data['event_cost'] = $total_cost;
} else {
    $data['event_cost'] = $event_cost;
}
$data['attendee_id'] = $attendee_id;
$data['event_id'] = $event_id;
$data['event_name'] = isset($event_name) && !empty($event_name) ? $event_name : '';
$data['registration_id'] = $registration_id;
$data['phone'] = isset($phone) && !empty($phone) ? $phone : '';
$data['event_meta'] = event_espresso_get_event_meta($event_id);
//This file builds the gateways that are available
echo '<div id="payment-options-dv" class="event-display-boxes ui-widget">';
echo '<h2 class="section-heading ui-widget-header ui-corner-top">' . __('Please choose a payment option', 'event_espresso') . '</h2>';
echo '<div class="event-data-display ui-widget-content ui-corner-bottom">';
do_action('action_hook_espresso_display_onsite_payment_header');
do_action('action_hook_espresso_display_onsite_payment_gateway', $data);
do_action('action_hook_espresso_display_onsite_payment_footer');
do_action('action_hook_espresso_display_offsite_payment_header');
do_action('action_hook_espresso_display_offsite_payment_gateway', $data);
do_action('action_hook_espresso_display_offsite_payment_footer');
do_action('action_hook_espresso_display_offline_payment_header');
do_action('action_hook_espresso_display_offline_payment_gateway', $data);
do_action('action_hook_espresso_display_offline_payment_gateway_2', $data);
do_action('action_hook_espresso_display_offline_payment_footer');
echo '</div><!-- / .event-data-display -->';
Example #5
0
    function event_espresso_add_attendees_to_db_multi()
    {
        //echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
        do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
        global $wpdb, $org_options;
        if (espresso_verify_recaptcha()) {
            $primary_registration_id = NULL;
            $multi_reg = true;
            $events_in_session = $_SESSION['espresso_session']['events_in_session'];
            if (event_espresso_invoke_cart_error($events_in_session)) {
                return false;
            }
            $count_of_events = count($events_in_session);
            $current_session_id = $_SESSION['espresso_session']['id'];
            $biz_name = $count_of_events . ' ' . $org_options['organization'] . __(' events', 'event_espresso');
            $event_cost = $_SESSION['espresso_session']['grand_total'];
            $event_cost = apply_filters('filter_hook_espresso_cart_grand_total', $event_cost);
            // If there are events in the session, add them one by one to the attendee table
            if ($count_of_events > 0) {
                //first event key will be used to find the first attendee
                $first_event_id = key($events_in_session);
                reset($events_in_session);
                foreach ($events_in_session as $event_id => $event) {
                    $event_meta = event_espresso_get_event_meta($event_id);
                    $session_vars['data'] = $event;
                    if (is_array($event['event_attendees'])) {
                        $counter = 1;
                        //foreach price type in event attendees
                        foreach ($event['event_attendees'] as $price_id => $event_attendees) {
                            $session_vars['data'] = $event;
                            foreach ($event_attendees as $attendee) {
                                $attendee['price_id'] = $price_id;
                                //this has all the attendee information, name, questions....
                                $session_vars['event_attendees'] = $attendee;
                                $session_vars['data']['price_type'] = $event['price_id'][$price_id]['price_type'];
                                if (isset($event_meta['additional_attendee_reg_info']) && $event_meta['additional_attendee_reg_info'] == 1) {
                                    $num_people = (int) $event['price_id'][$price_id]['attendee_quantity'];
                                    $session_vars['data']['num_people'] = empty($num_people) || $num_people == 0 ? 1 : $num_people;
                                }
                                // ADD ATTENDEE TO DB
                                $return_data = event_espresso_add_attendees_to_db($event_id, $session_vars, TRUE);
                                $tmp_registration_id = $return_data['registration_id'];
                                $notifications = $return_data['notifications'];
                                if ($primary_registration_id === NULL) {
                                    $primary_registration_id = $tmp_registration_id;
                                }
                                $SQL = "SELECT * FROM " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . "  ";
                                $SQL .= "WHERE primary_registration_id = %s AND registration_id = %s";
                                $check = $wpdb->get_row($wpdb->prepare($SQL, $primary_registration_id, $tmp_registration_id));
                                if ($check === NULL) {
                                    $tmp_data = array('primary_registration_id' => $primary_registration_id, 'registration_id' => $tmp_registration_id);
                                    $wpdb->insert(EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE, $tmp_data, array('%s', '%s'));
                                }
                                $counter++;
                            }
                        }
                    }
                }
                $SQL = "SELECT a.*, ed.id AS event_id, ed.event_name, dc.coupon_code_price, dc.use_percentage ";
                $SQL .= "FROM " . EVENTS_ATTENDEE_TABLE . " a JOIN " . EVENTS_DETAIL_TABLE . " ed ON a.event_id=ed.id ";
                $SQL .= "LEFT JOIN " . EVENTS_DISCOUNT_CODES_TABLE . " dc ON a.coupon_code=dc.coupon_code ";
                $SQL .= "WHERE attendee_session=%s ORDER BY a.id ASC";
                $attendees = $wpdb->get_results($wpdb->prepare($SQL, $current_session_id));
                //printr( $attendees, '$attendees  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                $quantity = 0;
                $final_total = 0;
                $sub_total = 0;
                $discounted_total = 0;
                $discount_amount = 0;
                //$coupon_amount = ! empty($attendees[0]->coupon_code_price) ? $attendees[0]->coupon_code_price : 0;
                $is_coupon_pct = !empty($attendees[0]->use_percentage) && $attendees[0]->use_percentage == 'Y' ? TRUE : FALSE;
                //printr( $attendees, '$attendees  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                foreach ($attendees as $attendee) {
                    if ($attendee->is_primary) {
                        $primary_attendee_id = $attendee_id = $attendee->id;
                        $coupon_code = $attendee->coupon_code;
                        $event_id = $attendee->event_id;
                        $fname = $attendee->fname;
                        $lname = $attendee->lname;
                        $address = $attendee->address;
                        $city = $attendee->city;
                        $state = $attendee->state;
                        $zip = $attendee->zip;
                        $attendee_email = $attendee->email;
                        $registration_id = $attendee->registration_id;
                    }
                    $final_total += $attendee->final_price;
                    $sub_total += (int) $attendee->quantity * $attendee->orig_price;
                    $discounted_total += (int) $attendee->quantity * $attendee->final_price;
                    $quantity += (int) $attendee->quantity;
                    //echo '<h2>$attendee->id : ' . $attendee->id . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h2>';
                    //echo '<h4>$attendee->orig_price : ' . $attendee->orig_price . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                    //echo '<h4>$attendee->final_price : ' . $attendee->final_price . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                    //echo '<h4>$attendee->quantity : ' . (int)$attendee->quantity . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                    //echo '<h4>$sub_total : ' . $sub_total . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                    //echo '<h4>$discounted_total : ' . $discounted_total . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                }
                $discount_amount = $sub_total - $discounted_total;
                $total_cost = $discounted_total;
                //echo '<h4>$discount_amount : ' . $discount_amount . '  <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>';
                //echo '<h4>$final_total : ' . $final_total . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4><br/>';
                $total_cost = $total_cost < 0 ? 0.0 : (double) $total_cost;
                if (function_exists('espresso_update_attendee_coupon_info') && $primary_attendee_id && !empty($attendee->coupon_code)) {
                    espresso_update_attendee_coupon_info($primary_attendee_id, $attendee->coupon_code);
                }
                if (function_exists('espresso_update_groupon') && $primary_attendee_id && !empty($coupon_code)) {
                    espresso_update_groupon($primary_attendee_id, $coupon_code);
                }
                espresso_update_primary_attendee_total_cost($primary_attendee_id, $total_cost, __FILE__);
                //echo '<h4>$total_cost : ' . $total_cost . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                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>';
                }
                //Post the gateway page with the payment options
                if ($total_cost > 0) {
                    ?>

<div class="espresso_payment_overview event-display-boxes ui-widget" >
  <h3 class="section-heading ui-widget-header ui-corner-top">
		<?php 
                    _e('Payment Overview', 'event_espresso');
                    ?>
  </h3>
	<div class="event-data-display ui-widget-content ui-corner-bottom" >

		<div class="event-messages ui-state-highlight"> <span class="ui-icon ui-icon-alert"></span>
			<p class="instruct">
				<?php 
                    _e('Your registration is not complete until payment is received.', 'event_espresso');
                    ?>
			</p>
		</div>
		<p><?php 
                    echo $org_options['email_before_payment'] == 'Y' ? __('A confirmation email has been sent with additional details of your registration.', 'event_espresso') : '';
                    ?>
</p>
		<table>
			<?php 
                    foreach ($attendees as $attendee) {
                        ?>
			<tr>
				<td width="70%">
					<?php 
                        echo '<strong>' . stripslashes_deep($attendee->event_name) . '</strong>';
                        ?>
&nbsp;-&nbsp;<?php 
                        echo stripslashes_deep($attendee->price_option);
                        ?>
 <?php 
                        echo $attendee->final_price < $attendee->orig_price ? '<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:.8em;">' . $org_options['currency_symbol'] . number_format($attendee->orig_price - $attendee->final_price, 2) . __(' discount per registration', 'event_espresso') . '</span>' : '';
                        ?>
<br/>
					&nbsp;&nbsp;&nbsp;&nbsp;<?php 
                        echo __('Attendee:', 'event_espresso') . ' ' . stripslashes_deep($attendee->fname . ' ' . $attendee->lname);
                        ?>
				</td>
				<td width="10%"><?php 
                        echo $org_options['currency_symbol'] . number_format($attendee->final_price, 2);
                        ?>
</td>
				<td width="10%"><?php 
                        echo 'x ' . (int) $attendee->quantity;
                        ?>
</td>
				<td width="10%" style="text-align:right;"><?php 
                        echo $org_options['currency_symbol'] . number_format($attendee->final_price * (int) $attendee->quantity, 2);
                        ?>
</td>
			</tr>
			<?php 
                    }
                    ?>
			
			<tr>
				<td colspan="3"><?php 
                    _e('Sub-Total:', 'event_espresso');
                    ?>
</td>
				<td colspan="" style="text-align:right"><?php 
                    echo $org_options['currency_symbol'] . number_format($sub_total, 2);
                    ?>
</td>
			</tr>
			<?php 
                    if (!empty($discount_amount)) {
                        ?>
			<tr>
				<td colspan="3"><?php 
                        _e('Total Discounts:', 'event_espresso');
                        ?>
</td>
				<td colspan="" style="text-align:right"><?php 
                        echo '-' . $org_options['currency_symbol'] . number_format($discount_amount, 2);
                        ?>
</td>
			</tr>
			<?php 
                    }
                    ?>
			<tr>
				<td colspan="3"><strong class="event_espresso_name">
					<?php 
                    _e('Total Amount due: ', 'event_espresso');
                    ?>
					</strong></td>
				<td colspan="" style="text-align:right"><?php 
                    echo $org_options['currency_symbol'];
                    echo number_format($total_cost, 2);
                    ?>
</td>
			</tr>
		</table>
		<p class="event_espresso_refresh_total">
			<a href="?page_id=<?php 
                    echo $org_options['event_page_id'];
                    ?>
&regevent_action=show_shopping_cart">
			<?php 
                    _e('Edit Cart', 'event_espresso');
                    ?>
			</a>
			<?php 
                    _e(' or ', 'event_espresso');
                    ?>
			<a href="?page_id=<?php 
                    echo $org_options['event_page_id'];
                    ?>
&registration_id=<?php 
                    echo $registration_id;
                    ?>
&id=<?php 
                    echo $attendee_id;
                    ?>
&regevent_action=edit_attendee&primary=<?php 
                    echo $primary_attendee_id;
                    ?>
&event_id=<?php 
                    echo $event_id;
                    ?>
&attendee_num=1">
			<?php 
                    _e('Edit Registrant Information', 'event_espresso');
                    ?>
			</a> 
		</p>
	</div>
</div>
<br/><br/>
<?php 
                    //Show payment options
                    if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "gateway_display.php")) {
                        require_once EVENT_ESPRESSO_GATEWAY_DIR . "gateway_display.php";
                    } else {
                        require_once EVENT_ESPRESSO_PLUGINFULLPATH . "gateways/gateway_display.php";
                    }
                    //Check to see if the site owner wants to send an confirmation eamil before payment is recieved.
                    if ($org_options['email_before_payment'] == 'Y') {
                        event_espresso_email_confirmations(array('session_id' => $_SESSION['espresso_session']['id'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true', 'multi_reg' => true));
                    }
                } elseif ($total_cost == 0.0) {
                    ?>
<p>
	<?php 
                    _e('Thank you! Your registration is confirmed for', 'event_espresso');
                    ?>
	<strong><?php 
                    echo stripslashes_deep($biz_name);
                    ?>
</strong></p>
<p>
	<?php 
                    _e('A confirmation email has been sent with additional details of your registration.', 'event_espresso');
                    ?>
</p>
<?php 
                    event_espresso_email_confirmations(array('session_id' => $_SESSION['espresso_session']['id'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true', 'multi_reg' => true));
                    event_espresso_clear_session();
                }
            }
        }
    }
/**
 * Returns the "Copy from " dropdown.
 */
function event_espresso_copy_dd($event_id, $meta)
{
    do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
    $events_in_session = isset($_SESSION['espresso_session']['events_in_session']) ? $_SESSION['espresso_session']['events_in_session'] : event_espresso_clear_session(TRUE);
    $count_of_events = count($events_in_session);
    $var = '<div class = "copy_dropdown_wrapper"> ';
    $var .= '<label>Copy from: </label>';
    $var .= '<select id="multi_regis_form_fields-' . $event_id . '" class="event_espresso_copy_info">';
    $var .= "<option value=''></option>";
    /*
     * 1) loop through all the events in the session
     * 2) For each one of the events, loop through the price ids
     * 3) If the attendee quantity is set and is >0,
     * 4) TURNED OFF in P41 -produce the dropdown if it is not the same price id
     */
    foreach ($events_in_session as $k_event_id => $v_event_id) {
        foreach ($v_event_id['price_id'] as $k_price_id => $v_price_id) {
            $event_meta = event_espresso_get_event_meta($v_event_id['id']);
            if (isset($v_price_id['attendee_quantity']) && $v_price_id['attendee_quantity'] > 0) {
                if ($event_meta['additional_attendee_reg_info'] == 1) {
                    $i = 1;
                    $event_name = strlen($v_event_id['event_name']) > 25 ? substr($v_event_id['event_name'], 0, 15) . '... ' : $v_event_id['event_name'];
                    //if too long to display
                    $var .= "<option value='{$event_id}|{$meta['price_id']}|{$meta['attendee_number']}|{$k_event_id}|{$k_price_id}|{$i}'>" . stripslashes_deep($event_name) . ' - ' . stripslashes_deep($v_price_id['price_type']) . ' - Attendee ' . $i . "</option>";
                } else {
                    for ($i = 1; $i <= $v_price_id['attendee_quantity']; $i++) {
                        $event_name = strlen($v_event_id['event_name']) > 25 ? substr($v_event_id['event_name'], 0, 15) . '... ' : $v_event_id['event_name'];
                        //if too long to display
                        $var .= "<option value='{$event_id}|{$meta['price_id']}|{$meta['attendee_number']}|{$k_event_id}|{$k_price_id}|{$i}'>" . stripslashes_deep($event_name) . ' - ' . $v_price_id['price_type'] . ' - Attendee ' . $i . "</option>";
                    }
                }
            }
        }
    }
    $var .= "<option value='{$event_id}|{$meta['price_id']}|{$meta['attendee_number']}'>CLEAR FIELDS</option>";
    $var .= "</select></div>";
    return $var;
    return "<a href='#' class='event_espresso_copy_link' id='event_espresso_copy_link-{$event_id}'> Copy from above</a>";
}