Example #1
0
    function espresso_event_reminder($event_id, $email_subject = '', $email_text = '', $email_id = 0)
    {
        global $wpdb, $org_options;
        do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
        $count = 0;
        $attendees = $wpdb->get_results("SELECT * FROM " . EVENTS_ATTENDEE_TABLE . " WHERE event_id ='" . $event_id . "'");
        if ($wpdb->num_rows > 0) {
            foreach ($attendees as $attendee) {
                $attendee_id = $attendee->id;
                event_espresso_email_confirmations(array('attendee_id' => $attendee_id, 'send_admin_email' => 'false', 'send_attendee_email' => 'true', 'custom_data' => array('email_type' => 'reminder', 'email_subject' => $email_subject, 'email_text' => $email_text, 'email_id' => $email_id)));
                $count++;
            }
            ?>
			<div id="message" class="updated fade">
				<p><strong>
						<?php 
            _e('Email Sent to ' . $count . ' people sucessfully.', 'event_espresso');
            ?>
					</strong></p>
			</div>
			<?php 
            return;
        } else {
            ?>
			<div id="message" class="error fade">
				<p><strong>
						<?php 
            _e('No attendee records available.', 'event_espresso');
            ?>
					</strong></p>
			</div>
			<?php 
        }
    }
function espresso_confirm_registration($registration_id)
{
    global $wpdb, $org_options;
    //Get the questions for the attendee
    $questions = $wpdb->get_results("SELECT ea.answer, eq.question\n\t\t\t\t\t\tFROM " . EVENTS_ANSWER_TABLE . " ea\n\t\t\t\t\t\tLEFT JOIN " . EVENTS_QUESTION_TABLE . " eq ON eq.id = ea.question_id\n\t\t\t\t\t\tWHERE ea.registration_id = '" . $registration_id . "' AND system_name IS NULL ORDER BY eq.sequence asc ");
    //echo $wpdb->last_query;
    $display_questions = '';
    foreach ($questions as $question) {
        $display_questions .= '<p class="espresso_questions"><strong>' . $question->question . '</strong>:<br /> ' . str_replace(',', '<br />', $question->answer) . '</p>';
    }
    //Get the event information
    $events = $wpdb->get_results("SELECT ed.* FROM " . EVENTS_DETAIL_TABLE . " ed\n\t\t\t\t\t\tJOIN " . EVENTS_ATTENDEE_TABLE . " ea\n\t\t\t\t\t\tON ed.id = ea.event_id\n\t\t\t\t\t\tWHERE ea.registration_id='" . $registration_id . "'");
    foreach ($events as $event) {
        $event_id = $event->id;
        $event_name = stripslashes_deep($event->event_name);
        $event_desc = stripslashes_deep($event->event_desc);
        $display_desc = $event->display_desc;
        $event_identifier = $event->event_identifier;
        $reg_limit = $event->reg_limit;
        $active = $event->is_active;
        $send_mail = $event->send_mail;
        $conf_mail = $event->conf_mail;
        $email_id = $event->email_id;
        $alt_email = $event->alt_email;
        $start_date = event_date_display($event->start_date);
        $end_date = $event->end_date;
        $virtual_url = $event->virtual_url;
        $virtual_phone = $event->virtual_phone;
        $event_address = $event->address;
        $event_address2 = $event->address2;
        $event_city = $event->city;
        $event_state = $event->state;
        $event_zip = $event->zip;
        $event_country = $event->country;
        $location = ($event_address != '' ? $event_address : '') . ($event_address2 != '' ? '<br />' . $event_address2 : '') . ($event_city != '' ? '<br />' . $event_city : '') . ($event_state != '' ? ', ' . $event_state : '') . ($event_zip != '' ? '<br />' . $event_zip : '') . ($event_country != '' ? '<br />' . $event_country : '');
        $location_phone = $event->phone;
        $require_pre_approval = $event->require_pre_approval;
        $google_map_link = espresso_google_map_link(array('address' => $event_address, 'city' => $event_city, 'state' => $event_state, 'zip' => $event_zip, 'country' => $event_country));
    }
    //Build links
    $event_url = espresso_reg_url($event_id);
    $event_link = '<a href="' . $event_url . '">' . $event_name . '</a>';
    $sql = "SELECT * FROM " . EVENTS_ATTENDEE_TABLE;
    if ($registration_id != '') {
        $sql .= " WHERE registration_id = '" . $registration_id . "' ";
    } elseif ($attendee_id != '') {
        $sql .= " WHERE id = '" . $attendee_id . "' ";
    } else {
        _e('No ID Supplied', 'event_espresso');
    }
    $sql .= " ORDER BY id ";
    $sql .= " LIMIT 0,1 ";
    //Get the first attendees details
    $attendees = $wpdb->get_results($sql);
    //global $attendee_id;
    foreach ($attendees as $attendee) {
        $attendee_id = $attendee->id;
        $attendee_email = $attendee->email;
        $lname = $attendee->lname;
        $fname = $attendee->fname;
        $address = $attendee->address;
        $address2 = $attendee->address2;
        $city = $attendee->city;
        $state = $attendee->state;
        $zip = $attendee->zip;
        $payment_status = $attendee->payment_status;
        $txn_type = $attendee->txn_type;
        $amount_pd = $attendee->amount_pd;
        $event_cost = $attendee->amount_pd;
        $payment_date = $attendee->payment_date;
        $phone = $attendee->phone;
        $event_time = $attendee->event_time;
        $end_time = $attendee->end_time;
        $date = $attendee->date;
        $pre_approve = $attendee->pre_approve;
    }
    ####### Added by wp-developers ##############
    $pre_approval_check = is_attendee_approved($event_id, $attendee_id);
    ###########################################
    ###### Modified by wp-developers ###############
    if ($pre_approval_check) {
        //Pull in the "Thank You" page template
        if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "payment_page.php")) {
            require_once EVENT_ESPRESSO_TEMPLATE_DIR . "payment_page.php";
            //This is the path to the template file if available
        } else {
            require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/payment_page.php";
        }
        if ($amount_pd != '0.00') {
            //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('registration_id' => $registration_id, 'send_admin_email' => 'true', 'send_attendee_email' => 'true'));
            }
        } else {
            event_espresso_email_confirmations(array('registration_id' => $registration_id, 'send_admin_email' => 'true', 'send_attendee_email' => 'true'));
        }
    } else {
        if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/process-registration/pending_approval_page.php')) {
            require_once 'pending_approval_page.php';
            echo espresso_pending_registration_approval($registration_id);
            return;
        }
    }
    ################ End ##############################
    //return __('Your Registration Has Been Confirmed', 'event_espresso');
    //unset($_SESSION['espresso_session']['id']);
    //session_destroy();
}
    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();
            }
        }
    }
$verify_result = $alipay->notify_verify();
if ($verify_result) {
    // out_trade_no= $_POST["out_trade_no"]
    // status = $_POST["trade_status"]
    // put the database string here, to update the database
    $payment_status = 'Completed';
    global $wpdb;
    $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET payment_status = '{$payment_status}', txn_type = '{$txn_type}', txn_id = '{$txn_id}', amount_pd = '{$amount_pd}',  payment_date ='{$payment_date}', transaction_details = '" . serialize($_POST) . "' WHERE registration_id ='" . espresso_registration_id($attendee_id) . "' ";
    $wpdb->query($sql);
    $email_before_payment = $org_options['email_before_payment'];
    //Send payment confirmation emails
    event_espresso_send_payment_notification(array('attendee_id' => $attendee_id));
    //Send the email confirmation
    //@params $attendee_id, $send_admin_email, $send_attendee_email
    if ($email_before_payment == 'N') {
        event_espresso_email_confirmations(array('attendee_id' => $attendee_id, 'send_admin_email' => 'true', 'send_attendee_email' => 'true'));
    }
    echo "success";
    log_result("verify_success");
} else {
    echo "fail";
    log_result("verify_failed");
}
function log_result($word)
{
    $fp = fopen("log.txt", "a");
    flock($fp, LOCK_EX);
    fwrite($fp, $word . "��execution date ��" . strftime("%Y%m%d%H%I%S", time()) . "\t\n");
    flock($fp, LOCK_UN);
    fclose($fp);
}
Example #5
0
function event_espresso_manage_events()
{
    global $wpdb, $org_options;
    ?>
	<div id="configure_organization_form" class="wrap meta-box-sortables ui-sortable">
		<div id="event_reg_theme" class="wrap">
			<div id="icon-options-event" class="icon32"></div>
			<h2>
				<?php 
    if ($_REQUEST['page'] == 'events' && isset($_REQUEST['event_admin_reports'])) {
        switch ($_REQUEST['event_admin_reports']) {
            case 'charts':
                _e('Attendee Reports', 'event_espresso');
                break;
            case 'event_list_attendees':
            case 'resend_email':
            case 'list_attendee_payments':
                _e('Attendee Reports', 'event_espresso');
                if (!empty($_REQUEST['event_id']) && $_REQUEST['event_admin_reports'] != 'add_new_attendee') {
                    echo '<a href="admin.php?page=events&amp;event_admin_reports=add_new_attendee&amp;event_id=' . $_REQUEST['event_id'] . '" class="button add-new-h2" style="margin-left: 20px;">' . __('Add New Attendee', 'event_espresso') . '</a>';
                }
                break;
            case 'edit_attendee_record':
                _e('Edit Attendee Data', 'event_espresso');
                break;
            case 'enter_attendee_payments':
                _e('Edit Attendee Payment Record', 'event_espresso');
                break;
            case 'add_new_attendee':
                _e('Add New Attendee', 'event_espresso');
                break;
            case 'event_newsletter':
                _e('Email Event Attendees', 'event_espresso');
                break;
        }
    } else {
        _e('Event Overview', 'event_espresso');
        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'edit' || $_REQUEST['action'] == 'add_new_event')) {
        } else {
            echo '<a href="admin.php?page=events&amp;action=add_new_event" class="button add-new-h2" style="margin-left: 20px;">' . __('Add New Event', 'event_espresso') . '</a>';
        }
    }
    ?>
			</h2>
			<?php 
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'copy_event') {
        require_once "copy_event.php";
        copy_event();
    }
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
        event_espresso_delete_event();
    }
    //Delete recurrence series of events
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete_recurrence_series') {
        $r = $wpdb->get_results("SELECT id FROM " . EVENTS_DETAIL_TABLE . " ed WHERE recurrence_id = " . $_REQUEST['recurrence_id']);
        if ($wpdb->num_rows > 0) {
            foreach ($r as $row) {
                event_espresso_delete_event($row->id);
            }
        }
    }
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'csv_import') {
        require_once 'csv_import.php';
        csv_import();
    }
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
        require_once "insert_event.php";
        add_event_to_db();
    }
    //Update the event
    if (isset($_REQUEST['edit_action']) && $_REQUEST['edit_action'] == 'update') {
        require_once "update_event.php";
        update_event();
    }
    //If we need to add or edit a new event then we show the add or edit forms
    if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'add_new_event' || $_REQUEST['action'] == 'edit')) {
        ?>
				<form id="espresso_event_editor" name="form" method="post" action="<?php 
        echo $_SERVER["REQUEST_URI"];
        ?>
">
					<?php 
        if ($_REQUEST['action'] == 'edit') {
            //show the edit form
            require_once "edit_event.php";
            edit_event($_REQUEST['event_id']);
        } else {
            //Show the add new event form
            require_once "add_new_event.php";
            add_new_event();
        }
        ?>
					<br class="clear" />
				</form>
				<!-- /event_reg_theme -->
				<?php 
    } else {
        //If we are not adding or editing an event then show the list of events
        if (isset($_REQUEST['event_admin_reports'])) {
            switch ($_REQUEST['event_admin_reports']) {
                case 'charts':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/charts.php";
                    espresso_charts();
                    break;
                case 'list_attendee_payments':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    event_list_attendees();
                    break;
                case 'event_list_attendees':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    event_list_attendees();
                    break;
                case 'edit_attendee_record':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/edit_attendee_record.php";
                    edit_attendee_record();
                    break;
                case 'enter_attendee_payments':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/enter_attendee_payments.php";
                    enter_attendee_payments();
                    break;
                case 'add_new_attendee':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/add_new_attendee.php";
                    add_new_attendee($_REQUEST['event_id']);
                    break;
                case 'event_newsletter':
                    if (file_exists(EVENT_ESPRESSO_INCLUDES_DIR . "admin-files/event_newsletter.php")) {
                        require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-files/event_newsletter.php";
                        event_newsletter($_REQUEST['event_id']);
                    } else {
                        require_once "event_newsletter.php";
                    }
                    break;
                case 'resend_email':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "/admin-reports/event_list_attendees.php";
                    echo '<div id="message" class="updated fade"><p><strong>Resending email to attendee.</strong></p></div>';
                    event_espresso_email_confirmations(array('registration_id' => $_REQUEST['registration_id'], 'send_admin_email' => 'false', 'send_attendee_email' => 'true'));
                    event_list_attendees();
                    break;
                default:
                    event_espresso_edit_list();
                    break;
            }
        } else {
            event_espresso_edit_list();
        }
    }
    //Do not remove anything below this line. These are the color box popups.
    ?>
</div>
	</div>
	<div id="email_manager_info" style="display:none">
		<h2><?php 
    _e('Pre-existing Emails', 'event_espresso');
    ?>
</h2>
		<p><?php 
    _e('These emails will override the custom email if a pre-existing email is selected. You must select "Yes" in the "Send custom confirmation emails for this event?" above.', 'event_espresso');
    ?>
</p>
	</div>
	<div id="coupon_code_info" style="display:none">
		<h2><?php 
    _e('Coupon/Promo Code', 'event_espresso');
    ?>
</h2><p><?php 
    _e('This is used to apply discounts to events.', 'event_espresso');
    ?>
</p><p><?php 
    _e('A coupon or promo code could can be anything you want. For example: Say you have an event that costs', 'event_espresso');
    ?>
 <?php 
    echo $org_options['currency_symbol'];
    ?>
200. <?php 
    _e('If you supplied a promo like "PROMO50" and entered 50.00 into the "Discount w/Promo Code" field your event will be discounted', 'event_espresso');
    ?>
  <?php 
    echo $org_options['currency_symbol'];
    ?>
50.00, <?php 
    _e('Bringing the cost of the event to', 'event_espresso');
    ?>
 <?php 
    echo $org_options['currency_symbol'];
    ?>
150. </p>
			<p><?php 
    _e("Note: Promo Codes which are marked to 'apply to all events', although not explicitly enumerated, can also be used for this event, provided it allows promo codes.", "event_espresso");
    ?>
</p>
	</div>
	<div id="unique_id_info" style="display:none">
		<h2><?php 
    _e('Event Identifier', 'event_espresso');
    ?>
</h2><p><?php 
    _e('This should be a unique identifier for the event. Example: "Event1" (without quotes.)</p><p>The unique ID can also be used in individual pages using the', 'event_espresso');
    ?>
 [SINGLEEVENT single_event_id="<?php 
    _e('Unique Event ID', 'event_espresso');
    ?>
"] <?php 
    _e('shortcode', 'event_espresso');
    ?>
.</p>
	</div>
	<div id="secondary_info" style="display:none">
		<h2><?php 
    _e('Waitlist Events', 'event_espresso');
    ?>
</h2>
		<p><?php 
    _e('These types of events can be used as a overflow or waiting list events.', 'event_espresso');
    ?>
</p>
		<p><?php 
    _e('If an event is set up as an "Waitlist Event," it can be set to not appear in your event listings template. You may need to customize your event_listing.php file to make this work. For more information, please', 'event_espresso');
    ?>
 <a href="http://eventespresso.com/forums/?p=512" target="_blank"><?php 
    _e('visit the forums', 'event_espresso');
    ?>
</a>.</p>
	</div>
	<div id="external_URL_info" style="display:none">
		<h2><?php 
    _e('Off-site Registration Page', 'event_espresso');
    ?>
</h2>
		<p><?php 
    _e('If an off-site registration page is entered, it will override your registration page and send attendees to the URL that is entered.', 'event_espresso');
    ?>
</p>
	</div>
	<div id="alt_email_info" style="display:none">
		<h2><?php 
    _e('Alternate Email Address', 'event_espresso');
    ?>
</h2>
		<p><?php 
    _e('If an alternate email address is entered. Admin email notifications wil be sent to this address instead.', 'event_espresso');
    ?>
</p>
	</div>
	<div id="status_types_info" style="display:none;">
		<h2><?php 
    _e('Event Status Types', 'event_espresso');
    ?>
</h2>
		<ul>
			<li><strong><?php 
    _e('Public', 'event_espresso');
    ?>
</strong><br /><?php 
    _e('This type if event will appear in the event listings. It is a live event (not deleted, ongoing or secondary.)', 'event_espresso');
    ?>
</li>
			<li><strong><?php 
    _e('Waitlist', 'event_espresso');
    ?>
</strong><br /><?php 
    _e('This type of event can be hidden and used as a waiting list for a primary event. Template customizations may be required. For more information, please', 'event_espresso');
    ?>
 <a href="http://eventespresso.com/forums/?p=512" target="_blank"><?php 
    _e('visit the forums', 'event_espresso');
    ?>
</a></li>
			<li><strong><?php 
    _e('Ongoing', 'event_espresso');
    ?>
</strong><br /><?php 
    _e('This type of an event can be set to appear in your event listings and display a registration page. Template customizations are required. For more information, please', 'event_espresso');
    ?>
 <a href="http://eventespresso.com/forums/?p=518" target="_blank"><?php 
    _e('visit the forums', 'event_espresso');
    ?>
</a></li>
			<li><strong><?php 
    _e('Deleted', 'event_espresso');
    ?>
</strong><br /><?php 
    _e('This is event type will not appear in the event listings and will not dispaly a registrations page. Deleted events can still be accessed in the', 'event_espresso');
    ?>
 <a href="admin.php?page=events"><?php 
    _e('Attendee Reports', 'event_espresso');
    ?>
</a> <?php 
    _e('page', 'event_espresso');
    ?>
.</li>
		</ul>
	</div>
	<?php 
    echo event_espresso_custom_email_info();
}
function add_new_attendee($event_id)
{
    if (isset($_REQUEST['regevent_action_admin']) && $_REQUEST['regevent_action_admin'] == 'post_attendee') {
        require_once EVENT_ESPRESSO_PLUGINFULLPATH . "includes/functions/attendee_functions.php";
        require_once EVENT_ESPRESSO_PLUGINFULLPATH . "includes/process-registration/add_attendees_to_db.php";
        $attendee_id = event_espresso_add_attendees_to_db();
        if ($attendee_id) {
            // SEND CONFIRMATION EMAIL MESSAGES
            event_espresso_email_confirmations(array('attendee_id' => $attendee_id, 'send_admin_email' => 'true', 'send_attendee_email' => 'true'));
            //echo $attendee_id;
            ?>
			<div id="message" class="updated fade">
			  <p><strong>
			    <?php 
            _e('Added Attendee to Database', 'event_espresso');
            ?>
			    </strong></p>
			</div>
		<?php 
        } else {
            global $notifications;
            $error_msg = implode($notifications['error'], '<br />');
            ?>
			<div id="message" class="error">
				<p>
					<strong><?php 
            echo $error_msg;
            ?>
</strong>
				</p>
			</div>
			<?php 
        }
    }
    wp_register_script('reCopy', EVENT_ESPRESSO_PLUGINFULLURL . "scripts/reCopy.js", false, '1.1.0');
    wp_print_scripts('reCopy');
    global $wpdb;
    $sql = "SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE is_active='Y' AND event_status != 'D' AND id = '" . $event_id . "' LIMIT 0,1";
    //Build the registration page
    if ($wpdb->get_results($sql)) {
        $events = $wpdb->get_results($sql);
        //These are the variables that can be used throughout the regsitration page
        foreach ($events as $event) {
            $event_id = $event->id;
            $event_name = stripslashes($event->event_name);
            $event_desc = stripslashes($event->event_desc);
            $display_desc = $event->display_desc;
            $event_address = $event->address;
            $event_city = $event->city;
            $event_state = $event->state;
            $event_zip = $event->zip;
            $event_description = stripslashes($event->event_desc);
            $event_identifier = $event->event_identifier;
            $event_cost = isset($event->event_cost) ? $event->event_cost : '';
            $member_only = isset($event->member_only) ? $event->member_only : '';
            $reg_limit = isset($event->reg_limit) ? $event->reg_limit : '';
            $allow_multiple = $event->allow_multiple;
            $start_date = $event->start_date;
            $end_date = $event->end_date;
            $reg_limit = $event->reg_limit;
            $additional_limit = $event->additional_limit;
            $is_active = array();
            $question_groups = unserialize($event->question_groups);
            //This function gets the status of the event.
            $is_active = event_espresso_get_is_active($event_id);
            //If the coupon code system is intalled then use it
            if (function_exists('event_espresso_coupon_registration_page')) {
                $use_coupon_code = $event->use_coupon_code;
            }
            //If the groupon code addon is installed, then use it
            if (function_exists('event_espresso_groupon_payment_page')) {
                $use_groupon_code = $event->use_groupon_code;
            }
            //Set a default value for additional limit
            if ($additional_limit == '') {
                $additional_limit = '5';
            }
        }
        //End foreach ($events as $event)
        //This is the start of the registration form. This is where you can start editing your display.
        $num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees');
        //Get the number of attendees
        $available_spaces = get_number_of_attendees_reg_limit($event_id, 'available_spaces');
        //Gets a count of the available spaces
        $number_available_spaces = get_number_of_attendees_reg_limit($event_id, 'number_available_spaces');
        //Gets the number of available spaces
        ?>
<script>$jaer = jQuery.noConflict();
	jQuery(document).ready(function($jaer) {
	jQuery(function(){
		//Registration form validation
		jQuery('#espresso-admin-add-new-attendee-frm').validate();
	});
});

	</script>
<div class="metabox-holder">
  <div class="postbox">
    <div id="espresso-admin-add-new-attendee-dv">

        <form method="post" action="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
" onsubmit="return validateForm(this)"  id="registration_form" class="espresso_form">
			<?php 
        wp_nonce_field('reg_nonce', 'reg_form_nonce');
        ?>
          <h3 class="h3_event_title" id="h3_event_title-<?php 
        echo $event_id;
        ?>
"><?php 
        echo $event_name;
        ?>
</h3>
           <div  class="padding">
     	     <div  class="inside">
				<fieldset>
		 		<h4 class="reg-quest-title section-title"><?php 
        _e('Event Dates and Times', 'event_espresso');
        ?>
</h4>
					<p class="start_date">
						<span class="span_event_date_label"><?php 
        _e('Start Date:', 'event_espresso');
        ?>
</span><span class="span_event_date_value"><?php 
        echo event_date_display($start_date);
        ?>
</span>
					</p>
		          	<p class="event_time">
		            <?php 
        $time_selected = '';
        //This block of code is used to display the times of an event in either a dropdown or text format.
        if (!empty($time_selected) && $time_selected == true) {
            //If the customer is coming from a page where the time was preselected.
            echo event_espresso_display_selected_time($time_id);
            //Optional parameters start, end, default
        } else {
            if ($time_selected == false) {
                echo event_espresso_time_dropdown($event_id);
            }
        }
        //End time selected
        ?>
	          		</p>
	          		<?php 
        // Added for seating chart addon
        do_action('ee_seating_chart_css');
        do_action('ee_seating_chart_js');
        do_action('ee_seating_chart_flush_expired_seats');
        do_action('espresso_seating_chart_select', $event_id);
        ?>
				</fieldset>
			  <?php 
        echo event_espresso_add_question_groups($question_groups, '', null, 0, array('admin_only' => true), 'inline');
        //Coupons
        if (function_exists('event_espresso_coupon_registration_page')) {
            echo event_espresso_coupon_registration_page($use_coupon_code, $event_id);
        }
        //End coupons display
        //Groupons
        if (function_exists('event_espresso_groupon_registration_page')) {
            echo event_espresso_groupon_registration_page($use_groupon_code, $event_id);
        }
        //End groupons display
        ?>


	          <p class="event_form_field">
	            <label for="event_cost" class="inline">
	              <?php 
        _e('Amount Paid:', 'event_espresso');
        ?>
	            </label>
	            <input tabindex="9" type="text" maxlength="10" size="15" name="event_cost" id="event_cost-<?php 
        echo $event_id;
        ?>
" <?php 
        echo $event_cost ? 'value="' . $event_cost . '"' : "";
        ?>
 />
	            <input type="hidden" name="regevent_action_admin" id="regevent_action-<?php 
        echo $event_id;
        ?>
" value="post_attendee" />
	            <input type="hidden" name="event_id" id="event_id-<?php 
        echo $event_id;
        ?>
" value="<?php 
        echo $event_id;
        ?>
" />
	            <input type="hidden" name="admin" value="true" />
	          </p>
			 
			<?php 
        echo event_espresso_additional_attendees($event_id, $additional_limit, $number_available_spaces, __('Number of Tickets', 'event_espresso'), true, 'admin', 'inline');
        ?>
			
	          <p class="event_form_submit" id="event_form_submit-<?php 
        echo $event_id;
        ?>
">
	            <input class="btn_event_form_submit button-primary" id="event_form_field-<?php 
        echo $event_id;
        ?>
" type="submit" name="Submit" value="<?php 
        _e('Submit', 'event_espresso');
        ?>
" />
	          </p>
	      </div>
	      </div>
        </form>
      </div>
    </div>
  </div>
<?php 
        event_list_attendees();
    }
    //End Build the registration page
}
function espresso_email_after_payment($payment_data)
{
    global $org_options;
    if ($payment_data['payment_status'] == 'Completed') {
        event_espresso_send_payment_notification(array('attendee_id' => $payment_data['attendee_id']));
        if ($org_options['email_before_payment'] == 'N') {
            event_espresso_email_confirmations(array('session_id' => $payment_data['attendee_session'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true'));
        }
    }
}
Example #8
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();
                }
            }
        }
    }
function espresso_confirm_registration()
{
    do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
    global $wpdb, $org_options;
    if (!empty($_POST['confirm_registration'])) {
        $registration_id = sanitize_text_field($_POST['registration_id']);
    } else {
        wp_die(__('An error has occured. The registration ID could not be found.', 'event_espresso'));
    }
    echo '<div id="espresso-payment_page-dv" >';
    do_action('action_hook_espresso_confirmation_page_before', $registration_id);
    //Get the questions for the attendee
    $SQL = "SELECT ea.answer, eq.question FROM " . EVENTS_ANSWER_TABLE . " ea ";
    $SQL .= "LEFT JOIN " . EVENTS_QUESTION_TABLE . " eq ON eq.id = ea.question_id ";
    $SQL .= "WHERE ea.registration_id = %s ";
    $SQL .= "AND system_name IS NULL ORDER BY eq.sequence asc ";
    $questions = $wpdb->get_results($wpdb->prepare($SQL, $registration_id));
    //echo $wpdb->last_query;
    $display_questions = '';
    foreach ($questions as $question) {
        $question->question = trim(stripslashes(str_replace('&#039;', "'", $question->question)));
        $question->question = htmlspecialchars($question->question, ENT_QUOTES, 'UTF-8');
        $question->answer = trim(stripslashes(str_replace('&#039;', "'", $question->answer)));
        $question->answer = htmlspecialchars($question->answer, ENT_QUOTES, 'UTF-8');
        $display_questions .= '<p class="espresso_questions"><strong>' . $question->question . '</strong>:<br /> ' . str_replace(',', '<br />', $question->answer) . '</p>';
    }
    //Get the event information
    $SQL = "SELECT ed.*  FROM " . EVENTS_DETAIL_TABLE . " ed ";
    $SQL .= "JOIN " . EVENTS_ATTENDEE_TABLE . " ea ON ed.id = ea.event_id ";
    $SQL .= "WHERE ea.registration_id=%s";
    $events = $wpdb->get_results($wpdb->prepare($SQL, $registration_id));
    foreach ($events as $event) {
        $event_id = $event->id;
        $event_name = stripslashes_deep($event->event_name);
        $event_desc = stripslashes_deep($event->event_desc);
        $display_desc = $event->display_desc;
        $event_identifier = $event->event_identifier;
        $reg_limit = $event->reg_limit;
        $active = $event->is_active;
        $send_mail = $event->send_mail;
        $conf_mail = $event->conf_mail;
        $email_id = $event->email_id;
        $alt_email = $event->alt_email;
        $start_date = event_date_display($event->start_date);
        $end_date = $event->end_date;
        $virtual_url = $event->virtual_url;
        $virtual_phone = $event->virtual_phone;
        $event_address = $event->address;
        $event_address2 = $event->address2;
        $event_city = $event->city;
        $event_state = $event->state;
        $event_zip = $event->zip;
        $event_country = $event->country;
        $location = ($event_address != '' ? $event_address : '') . ($event_address2 != '' ? '<br />' . $event_address2 : '') . ($event_city != '' ? '<br />' . $event_city : '') . ($event_state != '' ? ', ' . $event_state : '') . ($event_zip != '' ? '<br />' . $event_zip : '') . ($event_country != '' ? '<br />' . $event_country : '');
        $location_phone = $event->phone;
        $require_pre_approval = $event->require_pre_approval;
        $google_map_link = espresso_google_map_link(array('address' => $event_address, 'city' => $event_city, 'state' => $event_state, 'zip' => $event_zip, 'country' => $event_country));
    }
    //Build links
    $event_url = espresso_reg_url($event_id);
    $event_link = '<a href="' . $event_url . '">' . $event_name . '</a>';
    $SQL = "SELECT * FROM " . EVENTS_ATTENDEE_TABLE;
    if ($registration_id != '') {
        $SQL .= " WHERE registration_id = '" . $registration_id . "' ";
    } elseif ($attendee_id != '') {
        $SQL .= " WHERE id = '" . $attendee_id . "' ";
    } else {
        _e('No ID Supplied', 'event_espresso');
    }
    $SQL .= " AND is_primary = 1 ";
    $SQL .= " ORDER BY id ";
    $SQL .= " LIMIT 0,1 ";
    //Get the first attendees details
    if (!($attendee = $wpdb->get_row($wpdb->prepare($SQL, NULL)))) {
        wp_die(__('An error occured. The primary attendee could not be found.', 'event_espresso'));
    }
    $attendee_id = $attendee->id;
    $attendee_email = isset($attendee->email) ? $attendee->email : '';
    $lname = isset($attendee->lname) ? htmlspecialchars(stripslashes($attendee->lname), ENT_QUOTES, 'UTF-8') : '';
    $fname = isset($attendee->fname) ? htmlspecialchars(stripslashes($attendee->fname), ENT_QUOTES, 'UTF-8') : '';
    $address = isset($attendee->address) ? htmlspecialchars(stripslashes($attendee->address), ENT_QUOTES, 'UTF-8') : '';
    $address2 = isset($attendee->address2) ? htmlspecialchars(stripslashes($attendee->address2), ENT_QUOTES, 'UTF-8') : '';
    $city = isset($attendee->city) ? htmlspecialchars(stripslashes($attendee->city), ENT_QUOTES, 'UTF-8') : '';
    $state = isset($attendee->state) ? htmlspecialchars(stripslashes($attendee->state), ENT_QUOTES, 'UTF-8') : '';
    $country = isset($attendee->country) ? htmlspecialchars(stripslashes($attendee->country), ENT_QUOTES, 'UTF-8') : '';
    $zip = isset($attendee->zip) ? $attendee->zip : '';
    $payment_status = $attendee->payment_status;
    $txn_type = $attendee->txn_type;
    $amount_pd = (double) $attendee->amount_pd;
    $total_cost = (double) $attendee->total_cost;
    $payment_date = $attendee->payment_date;
    $phone = $attendee->phone;
    $event_time = $attendee->event_time;
    $end_time = $attendee->end_time;
    $date = $attendee->date;
    $pre_approve = $attendee->pre_approve;
    $session_id = $attendee->attendee_session;
    if ($attendee->is_primary) {
        $event_cost = $total_cost;
    }
    $attendee_pre_approved = is_attendee_approved($event_id, $attendee_id);
    if ($attendee_pre_approved) {
        //Pull in the "Payment Overview" page template
        if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "payment_page.php")) {
            require_once EVENT_ESPRESSO_TEMPLATE_DIR . "payment_page.php";
            //This is the path to the template file if available
        } else {
            require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/payment_page.php";
        }
        //Show payment options
        if ($total_cost > 0) {
            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_id, 'send_admin_email' => 'true', 'send_attendee_email' => 'true'));
            }
        } else {
            event_espresso_email_confirmations(array('session_id' => $session_id, 'send_admin_email' => 'true', 'send_attendee_email' => 'true'));
        }
    } else {
        if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/process-registration/pending_approval_page.php')) {
            require_once 'pending_approval_page.php';
            echo espresso_pending_registration_approval($registration_id);
            return;
        }
    }
    echo '</div>';
}
function add_new_attendee($event_id)
{
    if (isset($_REQUEST['regevent_action_admin']) && $_REQUEST['regevent_action_admin'] == 'post_attendee') {
        $attendee_id = event_espresso_add_attendees_to_db();
        // SEND CONFIRMATION EMAIL MESSAGES
        event_espresso_email_confirmations(array('attendee_id' => $attendee_id, 'send_admin_email' => 'true', 'send_attendee_email' => 'true'));
        //echo $attendee_id;
        ?>
<div id="message" class="updated fade">
  <p><strong>
    <?php 
        _e('Added Attendee to Database', 'event_espresso');
        ?>
    </strong></p>
</div>
<?php 
    }
    wp_register_script('reCopy', EVENT_ESPRESSO_PLUGINFULLURL . "scripts/reCopy.js", false, '1.1.0');
    wp_print_scripts('reCopy');
    global $wpdb;
    $sql = "SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE is_active='Y' AND event_status != 'D' AND id = '" . $event_id . "' LIMIT 0,1";
    //Build the registration page
    if ($wpdb->get_results($sql)) {
        $events = $wpdb->get_results($sql);
        //These are the variables that can be used throughout the regsitration page
        foreach ($events as $event) {
            $event_id = $event->id;
            $event_name = stripslashes($event->event_name);
            $event_desc = stripslashes($event->event_desc);
            $display_desc = $event->display_desc;
            $event_address = $event->address;
            $event_city = $event->city;
            $event_state = $event->state;
            $event_zip = $event->zip;
            $event_description = stripslashes($event->event_desc);
            $event_identifier = $event->event_identifier;
            $event_cost = isset($event->event_cost) ? $event->event_cost : '';
            $member_only = isset($event->member_only) ? $event->member_only : '';
            $reg_limit = isset($event->reg_limit) ? $event->reg_limit : '';
            $allow_multiple = $event->allow_multiple;
            $start_date = $event->start_date;
            $end_date = $event->end_date;
            $reg_limit = $event->reg_limit;
            $additional_limit = $event->additional_limit;
            $is_active = array();
            $question_groups = unserialize($event->question_groups);
            //This function gets the status of the event.
            $is_active = event_espresso_get_is_active($event_id);
            //If the coupon code system is intalled then use it
            if (function_exists('event_espresso_coupon_registration_page')) {
                $use_coupon_code = $event->use_coupon_code;
            }
            //If the groupon code addon is installed, then use it
            if (function_exists('event_espresso_groupon_payment_page')) {
                $use_groupon_code = $event->use_groupon_code;
            }
            //Set a default value for additional limit
            if ($additional_limit == '') {
                $additional_limit = '5';
            }
        }
        //End foreach ($events as $event)
        //This is the start of the registration form. This is where you can start editing your display.
        $num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees');
        //Get the number of attendees
        $available_spaces = get_number_of_attendees_reg_limit($event_id, 'available_spaces');
        //Gets a count of the available spaces
        $number_available_spaces = get_number_of_attendees_reg_limit($event_id, 'number_available_spaces');
        //Gets the number of available spaces
        ?>
<script>$jaer = jQuery.noConflict();
	jQuery(document).ready(function($jaer) {
	jQuery(function(){
		//Registration form validation
		jQuery('#registration_form').validate();
	});
});

	</script>
<div class="metabox-holder">
  <div class="postbox">
    <div id="event_espressotration_form">
     
        <form method="post" action="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
" onsubmit="return validateForm(this)"  id="registration_form">
          <h3 class="h3_event_title" id="h3_event_title-<?php 
        echo $event_id;
        ?>
"><?php 
        echo $event_name;
        ?>
</h3>
           <div  class="padding">
          <p class="start_date">
            <?php 
        _e('Start Date:', 'event_espresso');
        ?>
            <?php 
        echo event_date_display($start_date);
        ?>
</p>
          <p class="event_time">
            <?php 
        $time_selected = '';
        //This block of code is used to display the times of an event in either a dropdown or text format.
        if (!empty($time_selected) && $time_selected == true) {
            //If the customer is coming from a page where the time was preselected.
            echo event_espresso_display_selected_time($time_id);
            //Optional parameters start, end, default
        } else {
            if ($time_selected == false) {
                echo event_espresso_time_dropdown($event_id);
            }
        }
        //End time selected
        ?>
          </p>
          <?php 
        /*
         * Added for seating chart addon
         */
        if (defined('ESPRESSO_SEATING_CHART')) {
            $seating_chart_id = seating_chart::check_event_has_seating_chart($event_id);
            if ($seating_chart_id !== false) {
                ?>
								<p class="event_form_field">
									<label>Select a Seat:</label>
                                    <input type="text" name="seat_id" value="" class="ee_s_select_seat required" title="Please select a seat." event_id="<?php 
                echo $event_id;
                ?>
" readonly="readonly"  />
                           <?php 
                $seating_chart = $wpdb->get_row("select * from " . EVENTS_SEATING_CHART_TABLE . " where id = {$seating_chart_id}");
                if (trim($seating_chart->image_name) != "" && file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'seatingchart/images/' . $seating_chart->image_name)) {
                    ?>
                                    <br/>
                                    <a href="<?php 
                    echo EVENT_ESPRESSO_UPLOAD_URL . 'seatingchart/images/' . $seating_chart->image_name;
                    ?>
" target="_blank">Seating chart image</a>		
                            <?php 
                }
                ?>
                                </p>
          			<?php 
            }
        }
        /*
         * End
         */
        ?>
		  <?php 
        echo event_espresso_add_question_groups($question_groups);
        //Coupons
        if (function_exists('event_espresso_coupon_registration_page')) {
            echo event_espresso_coupon_registration_page($use_coupon_code, $event_id);
        }
        //End coupons display
        //Groupons
        if (function_exists('event_espresso_groupon_registration_page')) {
            echo event_espresso_groupon_registration_page($use_groupon_code, $event_id);
        }
        //End groupons display
        ?>
          <p class="event_form_field">
            <label for="event_cost">
              <?php 
        _e('Amount Paid:', 'event_espresso');
        ?>
            </label>
            <input tabindex="9" type="text" maxlength="10" size="15" name="event_cost" id="event_cost-<?php 
        echo $event_id;
        ?>
" <?php 
        echo $event_cost ? 'value="' . $event_cost . '"' : "";
        ?>
 />
            <input type="hidden" name="regevent_action_admin" id="regevent_action-<?php 
        echo $event_id;
        ?>
" value="post_attendee" />
            <input type="hidden" name="event_id" id="event_id-<?php 
        echo $event_id;
        ?>
" value="<?php 
        echo $event_id;
        ?>
" />
            <input type="hidden" name="admin" value="true" />
          </p>
          <p class="event_form_submit" id="event_form_submit-<?php 
        echo $event_id;
        ?>
">
            <input class="btn_event_form_submit" id="event_form_field-<?php 
        echo $event_id;
        ?>
" type="submit" name="Submit" value="<?php 
        _e('Submit', 'event_espresso');
        ?>
" />
          </p>
          <?php 
        echo event_espresso_additional_attendees($event_id, $additional_limit, $number_available_spaces, __('Number of Tickets', 'event_espresso'), true, $event_meta);
        ?>
        </form>
      </div>
    </div>
  </div>
<?php 
        event_list_attendees();
    }
    //End Build the registration page
}