function edit_attendee_record()
{
    global $wpdb, $org_options;
    $attendee_num = 1;
    if ($_REQUEST['form_action'] == 'edit_attendee') {
        $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
        $registration_id = isset($_REQUEST['registration_id']) ? $_REQUEST['registration_id'] : '';
        $multi_reg = false;
        $check = $wpdb->get_row("select * from " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " where registration_id = '{$registration_id}' ");
        if ($check !== NULL) {
            $registration_id = $check->primary_registration_id;
            $registration_ids = $wpdb->get_results("select distinct primary_registration_id, registration_id from " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " where primary_registration_id = '{$registration_id}' ", ARRAY_A);
            $multi_reg = true;
        }
        /*
         * find the primary attendee so we know which form to present
         * since the additional attendees will have a different form
         */
        //Update the payment amount for the attendee
        if (!empty($_REQUEST['attendee_payment']) && $_REQUEST['attendee_payment'] == 'update_payment') {
            $attendee_cost_data = array("attendee_id" => $ext_attendee_id, "quantity" => $attendee_quantity, "cost" => $attendee_cost);
            $wpdb->insert(EVENTS_ATTENDEE_COST_TABLE, $attendee_cost_data);
            $c_sql = "UPDATE " . EVENTS_ATTENDEE_COST_TABLE . " SET cost = '" . $_REQUEST['amount_pd'] . "', quantity = '" . $_REQUEST['quantity'] . "' WHERE attendee_id = '" . $_REQUEST['id'] . "' ";
            $wpdb->query($c_sql);
            /*
             * Calculate total cost from attendee cost table
             */
            $event_cost = 0;
            if ($multi_reg) {
                foreach ($registration_ids as $reg_ids) {
                    $event_cost += $wpdb->get_var($wpdb->prepare("select ea.registration_id, sum(eac.cost * eac.quantity) from " . EVENTS_ATTENDEE_COST_TABLE . " eac inner join " . EVENTS_ATTENDEE_TABLE . " ea on eac.attendee_id = ea.id where ea.registration_id = '%s' group by ea.registration_id ", $reg_ids['registration_id']), 1, 0);
                }
            } else {
                $event_cost = $wpdb->get_var($wpdb->prepare("select ea.registration_id, sum(eac.cost * eac.quantity) from " . EVENTS_ATTENDEE_COST_TABLE . " eac inner join " . EVENTS_ATTENDEE_TABLE . " ea on eac.attendee_id = ea.id where ea.registration_id = '%s' group by ea.registration_id ", $registration_id), 1, 0);
            }
            $a_sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET quantity = '%d' WHERE id = '%d' ";
            $wpdb->query($wpdb->prepare($a_sql, $_REQUEST['quantity'], $_REQUEST['id']));
            /*
             * Get primary attendee id to update the amount_pd
             */
            $primary_attendee_id = $wpdb->get_var($wpdb->prepare("select id from " . EVENTS_ATTENDEE_TABLE . " where registration_id = '%s' order by id limit 1 ", $registration_id));
            $a_sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET amount_pd = '%f' WHERE id = '%d' ";
            $wpdb->query($wpdb->prepare($a_sql, $event_cost, $primary_attendee_id));
        }
        $r = $wpdb->get_row("SELECT id from " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id ='{$registration_id}' ORDER BY id ");
        $primary_attendee = !empty($r->id) ? $r->id : $id;
        $is_additional_attendee = $primary_attendee != $id ? true : false;
        if (!empty($_REQUEST['attendee_action']) && $_REQUEST['attendee_action'] == 'delete_attendee') {
            $sql = " DELETE FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id ='{$id}'";
            $wpdb->query($sql);
            if (defined('ESPRESSO_SEATING_CHART')) {
                $wpdb->query("DELETE FROM " . EVENTS_SEATING_CHART_EVENT_SEAT_TABLE . " where attendee_id = {$id}");
            }
            $wpdb->query("SELECT id from " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id ='{$registration_id}' ");
            if ($wpdb->num_rows == 0) {
                $sql = " UPDATE " . EVENTS_ATTENDEE_TABLE . " SET quantity = IF(quantity IS NULL ,NULL,IF(quantity > 0,IF(quantity-1>0,quantity-1,1),0)) WHERE registration_id ='{$registration_id}'";
                $wpdb->query($sql);
                $sql = " UPDATE " . EVENTS_ATTENDEE_COST_TABLE . " SET quantity = IF(quantity IS NULL ,NULL,IF(quantity > 0,IF(quantity-1>0,quantity-1,1),0)) WHERE attendee_id ='{$id}'";
                $wpdb->query($sql);
                event_espresso_cleanup_multi_event_registration_id_group_data();
                event_espresso_cleanup_attendee_cost_data();
            }
        } else {
            if (!empty($_REQUEST['attendee_action']) && $_REQUEST['attendee_action'] == 'update_attendee') {
                /*
                 * Update the attendee information
                 */
                $update_time = false;
                if (isset($_POST['start_time_id'])) {
                    $times_sql = "SELECT ese.start_time, ese.end_time ";
                    $times_sql .= "FROM " . EVENTS_START_END_TABLE . " ese ";
                    $times_sql .= " WHERE ";
                    $times_sql .= "ese.id='" . $_POST['start_time_id'] . "' ";
                    $times = $wpdb->get_results($times_sql);
                    if ($wpdb->num_rows > 0) {
                        foreach ($times as $time) {
                            $start_time = $time->start_time;
                            $end_time = $time->end_time;
                        }
                        $update_time = true;
                    }
                }
                $fname = isset($_POST['fname']) ? $_POST['fname'] : '';
                $lname = isset($_POST['lname']) ? $_POST['lname'] : '';
                $address = isset($_POST['address']) ? $_POST['address'] : '';
                $address2 = isset($_POST['address2']) ? $_POST['address2'] : '';
                $city = isset($_POST['city']) ? $_POST['city'] : '';
                $state = isset($_POST['state']) ? $_POST['state'] : '';
                $zip = isset($_POST['zip']) ? $_POST['zip'] : '';
                $phone = isset($_POST['phone']) ? $_POST['phone'] : '';
                $email = isset($_POST['email']) ? $_POST['email'] : '';
                $event_id = isset($_POST['event_id']) ? $_POST['event_id'] : '';
                $txn_type = isset($_POST['txn_type']) ? $_POST['txn_type'] : '';
                $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET fname='{$fname}', lname='{$lname}', address='{$address}',address2='{$address2}', city='{$city}', state='{$state}', zip='{$zip}', phone='{$phone}', email='{$email}', txn_type='{$txn_type}' ";
                if ($update_time == true) {
                    $sql .= ", event_time='{$start_time}', end_time='{$end_time}' ";
                }
                $sql .= " WHERE id ='{$id}' ";
                $wpdb->query($sql);
                // Insert Additional Questions From Post Here
                $reg_id = $id;
                $response_source = $_POST;
                $questions = $wpdb->get_row("SELECT question_groups, event_meta FROM " . EVENTS_DETAIL_TABLE . " WHERE id = " . $event_id . " ");
                $question_groups = unserialize($questions->question_groups);
                $event_meta = unserialize($questions->event_meta);
                if ($is_additional_attendee && isset($event_meta['add_attendee_question_groups']) && $event_meta['add_attendee_question_groups'] != NULL) {
                    $question_groups = $event_meta['add_attendee_question_groups'];
                }
                $questions_in = '';
                foreach ($question_groups as $g_id) {
                    $questions_in .= $g_id . ',';
                }
                $questions_in = substr($questions_in, 0, -1);
                $group_name = '';
                $counter = 0;
                //pull the list of questions that are relevant to this event
                $q_sql_1 = "SELECT q.*, q.id q_id, qg.group_name FROM " . EVENTS_QUESTION_TABLE . " q\n\t\t\t\t\t\tJOIN " . EVENTS_QST_GROUP_REL_TABLE . " qgr on q.id = qgr.question_id\n\t\t\t\t\t\tJOIN " . EVENTS_QST_GROUP_TABLE . " qg on qg.id = qgr.group_id\n\t\t\t\t\t\tWHERE qgr.group_id in (" . $questions_in . ")\n\t\t\t\t\t\tORDER BY qg.id, q.sequence ASC";
                $questions = $wpdb->get_results($q_sql_1);
                $a_sql = "SELECT id, question_id, answer FROM " . EVENTS_ANSWER_TABLE . " at WHERE at.attendee_id = '" . $id . "' ";
                $answers = $wpdb->get_results($a_sql, OBJECT_K);
                foreach ($answers as $answer) {
                    $answer_a[] = $answer->question_id;
                }
                if ($questions) {
                    foreach ($questions as $question) {
                        switch ($question->question_type) {
                            case "TEXT":
                            case "TEXTAREA":
                            case "DROPDOWN":
                                $post_val = $question->system_name != '' ? $response_source[$question->system_name] : $response_source[$question->question_type . '_' . $question->q_id];
                                if (in_array($question->q_id, $answer_a)) {
                                    $sql = "UPDATE " . EVENTS_ANSWER_TABLE . " SET answer='{$post_val}' WHERE attendee_id = '{$id}' AND question_id ='{$question->q_id}'";
                                } else {
                                    $sql = "INSERT INTO " . EVENTS_ANSWER_TABLE . " (registration_id, answer,attendee_id,question_id) VALUES ('{$registration_id}','{$post_val}', {$id},{$question->q_id})";
                                }
                                $wpdb->query($sql);
                                break;
                            case "SINGLE":
                                $post_val = $question->system_name != '' ? $response_source[$question->system_name] : $response_source[$question->question_type . '_' . $question->q_id];
                                if (in_array($question->q_id, $answer_a)) {
                                    $sql = "UPDATE " . EVENTS_ANSWER_TABLE . " SET answer='{$post_val}' WHERE attendee_id = '{$id}' AND question_id ='{$question->q_id}'";
                                } else {
                                    $sql = "INSERT INTO " . EVENTS_ANSWER_TABLE . " (registration_id, answer,attendee_id,question_id) VALUES ('{$registration_id}','{$post_val}', {$id},{$question->q_id})";
                                }
                                $wpdb->query($sql);
                                break;
                            case "MULTIPLE":
                                $value_string = '';
                                for ($i = 0; $i < count($response_source[$question->question_type . '_' . $question->id]); $i++) {
                                    $value_string .= trim($response_source[$question->question_type . '_' . $question->id][$i]) . ",";
                                }
                                if (in_array($question->q_id, $answer_a)) {
                                    $sql = "UPDATE " . EVENTS_ANSWER_TABLE . " SET answer='{$value_string}' WHERE attendee_id = '{$id}' AND question_id ='{$question->q_id}'";
                                } else {
                                    $sql = "INSERT INTO " . EVENTS_ANSWER_TABLE . " (registration_id, answer,attendee_id,question_id) VALUES ('{$registration_id}','{$value_string}', {$id}, {$question->q_id})";
                                }
                                $wpdb->query($sql);
                                break;
                        }
                    }
                }
            }
        }
        $counter = 0;
        $additional_attendees = NULL;
        $WHERE = isset($_REQUEST['registration_id']) ? "registration_id ='" . $_REQUEST['registration_id'] . "'" : "id = " . $_REQUEST['id'];
        if (isset($_REQUEST['attendee_num']) && $_REQUEST['attendee_num'] > 1 && isset($_REQUEST['registration_id']) && isset($_REQUEST['id'])) {
            $WHERE = " t1.registration_id ='" . $_REQUEST['registration_id'] . "' AND t1.id = " . $_REQUEST['id'];
        }
        $results = $wpdb->get_results("SELECT t1.*, t2.event_name, t2.question_groups, t2.event_meta FROM " . EVENTS_ATTENDEE_TABLE . " t1\n                 JOIN " . EVENTS_DETAIL_TABLE . " t2\n                 ON t1.event_id = t2.id\n                 WHERE {$WHERE}\n                 ORDER BY t1.id");
        foreach ($results as $result) {
            if ($counter == 0) {
                $id = $result->id;
                $registration_id = $result->registration_id;
                $lname = $result->lname;
                $fname = $result->fname;
                $address = $result->address;
                $address2 = $result->address2;
                $city = $result->city;
                $state = $result->state;
                $zip = $result->zip;
                $email = $result->email;
                $hear = isset($result->hear) ? $result->hear : '';
                $payment = $result->payment;
                $phone = $result->phone;
                $date = $result->date;
                $payment_status = $result->payment_status;
                $txn_type = $result->txn_type;
                $txn_id = $result->txn_id;
                $amount_pd = $result->amount_pd;
                $quantity = $result->quantity;
                $payment_date = $result->payment_date;
                $event_id = $result->event_id;
                $event_name = $result->event_name;
                $question_groups = unserialize($result->question_groups);
                $question_groups = unserialize($result->question_groups);
                $event_meta = unserialize($result->event_meta);
                $coupon_code = $result->coupon_code;
                $quantity = $result->quantity;
                $is_additional_attendee = $primary_attendee != $id ? true : false;
                $start_date = $result->start_date;
                $event_time = $result->event_time;
                $event_date = event_date_display($start_date . ' ' . $event_time, get_option('date_format') . ' g:i a');
                if ($is_additional_attendee && isset($event_meta['add_attendee_question_groups']) && $event_meta['add_attendee_question_groups'] != NULL) {
                    $question_groups = $event_meta['add_attendee_question_groups'];
                }
                $counter = 1;
            } else {
                $additional_attendees[$result->id] = array('full_name' => $result->fname . ' ' . $result->lname, 'email' => $result->email, 'phone' => $result->phone);
            }
        }
        if (!empty($_REQUEST['status']) && $_REQUEST['status'] == 'saved') {
            ?>

			<div id="message" class="updated fade">
			  <p><strong>
			<?php 
            _e('Attendee details saved for ' . $fname . ' ' . $lname . '.', 'event_espresso');
            ?>
			    </strong></p>
			</div>
			<?php 
        }
        ?>
		<div class="metabox-holder">
		  <div class="postbox">
		    <h3>
					<?php 
        _e('Registration Id <a href="admin.php?page=events&event_admin_reports=edit_attendee_record&event_id=' . $event_id . '&registration_id=' . $registration_id . '&form_action=edit_attendee">#' . $registration_id . '</a> | ID #' . $id . ' | Name: ' . $fname . ' ' . $lname . ' | Registered For:', 'event_espresso');
        ?>
		      <a href="admin.php?page=events&event_admin_reports=list_attendee_payments&event_id=<?php 
        echo $event_id;
        ?>
"><?php 
        echo stripslashes_deep($event_name);
        ?>
</a> - <?php 
        echo $event_date;
        ?>
</h3>
		    <div class="inside">
		      <table width="100%">
		        <tr>
		          <td width="50%"><form method="post" action="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
" class="espresso_form">
		              <h4>
		<?php 
        _e('Registration Information', 'event_espresso');
        ?>
		<?php 
        echo $is_additional_attendee == false ? '[ <span class="green_text">' . __('Primary Attendee Record', 'event_espresso') . '</span> ]' : '[ <a href="admin.php?page=events&event_admin_reports=edit_attendee_record&event_id=' . $event_id . '&registration_id=' . $registration_id . '&form_action=edit_attendee">View/Edit Primary Attendee</a> ]';
        ?>
 </h4>
		              <fieldset>
		                <ul>
		                  <li>
		<?php 
        $time_id = 0;
        $sql = "SELECT id FROM " . EVENTS_START_END_TABLE . " WHERE event_id='" . $event_id . "' AND start_time = '" . $event_time . "' ";
        $event_times = $wpdb->get_results($sql);
        if ($wpdb->num_rows > 0) {
            $time_id = $wpdb->last_result[0]->id;
        }
        echo event_espresso_time_dropdown($event_id, $label = 1, $multi_reg = 0, $time_id);
        ?>
		                  </li>
		                  <li>
												<?php 
        if (count($question_groups) > 0) {
            $questions_in = '';
            foreach ($question_groups as $g_id) {
                $questions_in .= $g_id . ',';
            }
            $questions_in = substr($questions_in, 0, -1);
            $group_name = '';
            $counter = 0;
            $FILTER = '';
            if (isset($event_meta['additional_attendee_reg_info']) && $event_meta['additional_attendee_reg_info'] == '2' && isset($_REQUEST['attendee_num']) && $_REQUEST['attendee_num'] > 1) {
                $FILTER .= " AND qg.system_group = 1 ";
            }
            //pull the list of questions that are relevant to this event
            $q_sql_2 = "SELECT q.*, q.id q_id, at.*, qg.group_name, qg.show_group_description, qg.show_group_name FROM " . EVENTS_QUESTION_TABLE . " q\n\t\t\t\t\tLEFT JOIN " . EVENTS_ANSWER_TABLE . " at on q.id = at.question_id\n\t\t\t\t\tJOIN " . EVENTS_QST_GROUP_REL_TABLE . " qgr on q.id = qgr.question_id\n\t\t\t\t\tJOIN " . EVENTS_QST_GROUP_TABLE . " qg on qg.id = qgr.group_id\n\t\t\t\t\tWHERE qgr.group_id in (" . $questions_in . ")\n\t\t\t\t\tAND (at.attendee_id IS NULL OR at.attendee_id = '" . $id . "')\n\t\t\t\t\t" . $FILTER . "\n\t\t\t\t\tORDER BY qg.id, q.id ASC";
            $questions = $wpdb->get_results($q_sql_2);
            $num_rows = $wpdb->num_rows;
            if ($num_rows > 0) {
                //Output the questions
                $question_displayed = array();
                foreach ($questions as $question) {
                    $counter++;
                    if (!in_array($question->id, $question_displayed)) {
                        $question_displayed[] = $question->id;
                        echo '<p>';
                        echo event_form_build_edit($question, empty($question->answer) ? '' : $question->answer, $show_admin_only = true);
                        echo "</p>";
                        echo $counter == $num_rows ? '</fieldset>' : '';
                    }
                }
            }
            //end questions display
        }
        ?>
		                  </li>
		                  <input type="hidden" name="id" value="<?php 
        echo $id;
        ?>
" />
		                  <input type="hidden" name="registration_id" value="<?php 
        echo $registration_id;
        ?>
" />
		                  <input type="hidden" name="event_id" value="<?php 
        echo $event_id;
        ?>
" />
		                  <input type="hidden" name="display_action" value="view_list" />
		                  <input type="hidden" name="form_action" value="edit_attendee" />
		                  <input type="hidden" name="attendee_action" value="update_attendee" />
		                  <li>
		                    <input type="submit" name="Submit" value="<?php 
        _e('Update Record', 'event_espresso');
        ?>
" />
		                  </li>
		                </ul>
		              </fieldset>
		            </form></td>
		          <td  width="50%" valign="top"><?php 
        if (count($additional_attendees) > 0) {
            ?>
			            <h4>
			<?php 
            _e('Additional Attendees', 'event_espresso');
            ?>
			            </h4>
			            <ol>
			<?php 
            foreach ($additional_attendees as $att => $row) {
                $attendee_num++;
                ?>
				              <li><a href="admin.php?page=events&amp;event_admin_reports=edit_attendee_record&amp;event_id=<?php 
                echo $event_id;
                ?>
&amp;id=<?php 
                echo $att;
                ?>
&amp;registration_id=<?php 
                echo $registration_id;
                ?>
&amp;form_action=edit_attendee&amp;attendee_num=<?php 
                echo $attendee_num;
                ?>
" title="<?php 
                _e('Edit Attendee', 'event_espresso');
                ?>
"><strong><?php 
                echo $row['full_name'];
                ?>
</strong> (<?php 
                echo $row['email'];
                ?>
)</a> | <a href="admin.php?page=events&amp;event_admin_reports=edit_attendee_record&amp;event_id=<?php 
                echo $event_id;
                ?>
&amp;registration_id=<?php 
                echo $registration_id;
                ?>
&amp;attendee_id=<?php 
                echo $att;
                ?>
&amp;form_action=edit_attendee&amp;attendee_action=delete_attendee&amp;id=<?php 
                echo $att;
                ?>
" title="<?php 
                _e('Delete Attendee', 'event_espresso');
                ?>
" onclick="return confirmDelete();">
				<?php 
                _e('Delete', 'event_espresso');
                ?>
				                </a></li>
				<?php 
            }
            ?>
			            </ol>
		<?php 
        }
        ?>
									<?php 
        /**
         * Begin Attendee Payment Information
         * */
        $has_seating_chart = false;
        if (defined('ESPRESSO_SEATING_CHART')) {
            $has_seating_chart = seating_chart::check_event_has_seating_chart($event_id);
        }
        /**
         * If attendee was added in old system i.e. before version 3.1.10 and attendee_cost table got introduced then this option can not be used
         * */
        $ice_age = true;
        $ice_row = $wpdb->get_row($wpdb->prepare("select * from " . EVENTS_ATTENDEE_COST_TABLE . " where attendee_id = '%d'", $id));
        if ($ice_row !== NULL) {
            $ice_age = false;
        }
        if (!$has_seating_chart && !$ice_age) {
            ?>
			            <h4>
									<?php 
            _e('Payment Information', 'event_espresso');
            ?>
			            </h4>
			            <form method="POST" action="<?php 
            echo $_SERVER['REQUEST_URI'];
            ?>
&status=saved" class="espresso_form">
			              <fieldset>
			                <ul>
			                  <li>
			                    <p><strong>
									<?php 
            _e('Payment Status:', 'event_espresso');
            ?>
			                      </strong> <?php 
            echo $payment_status;
            ?>
 <?php 
            echo event_espresso_paid_status_icon($payment_status);
            ?>
 [ <a href="admin.php?page=events&amp;attendee_pay=paynow&amp;form_action=payment&amp;registration_id=<?php 
            echo $registration_id;
            ?>
&amp;event_admin_reports=enter_attendee_payments&amp;event_id=<?php 
            echo $event_id;
            ?>
" title="<?php 
            _e('Edit Payment', 'event_espresso');
            ?>
">
									<?php 
            _e('View/Edit Payment', 'event_espresso');
            ?>
			                      </a> ]</p>
			                  </li>
			                  <li>
			                    <p><strong>
									<?php 
            _e('Transaction ID:', 'event_espresso');
            ?>
			                      </strong> <?php 
            echo !empty($txn_id) ? $txn_id : 'N/A';
            ?>
</p>
			                  </li>
			                  <li>
			                    <p><strong>
										<?php 
            _e('Date Paid:', 'event_espresso');
            ?>
			                      </strong> <?php 
            echo !empty($payment_date) ? event_date_display($payment_date) : 'N/A';
            ?>
</p>
			                  </li>
			<?php 
            if ($multi_reg == true) {
                ?>
				                  <li>
				                    <p><strong>
				<?php 
                _e('Multiple Event Total:', 'event_espresso');
                ?>
				                      </strong> <?php 
                echo $org_options['currency_symbol'];
                echo espresso_attendee_price(array('attendee_id' => $id, 'session_total' => true));
                ?>
</p>
				                  </li>
															<?php 
            }
            ?>
			                  <li>
			                    <p><strong>
			<?php 
            _e('This Registration Total:', 'event_espresso');
            ?>
			                      </strong> <?php 
            echo $org_options['currency_symbol'];
            echo espresso_attendee_price(array('attendee_id' => $id, 'reg_total' => true));
            ?>
</p>
			                  </li>
			                  <li> <div  <?php 
            if (isset($_REQUEST['show_payment']) && $_REQUEST['show_payment'] == 'true') {
                echo ' class="yellow_inform"';
            }
            ?>
><strong>
			<?php 
            _e('This Attendee:', 'event_espresso');
            ?>
														</strong>
														<table width="100%" border="0">
															<tr>
																<td width="25%" align="left" valign="top"><label>
			<?php 
            _e('Amount:', 'event_espresso');
            ?>
																	</label></td>
																<td width="25%" align="left" valign="top"><label>
			<?php 
            _e('# Tickets:', 'event_espresso');
            ?>
																	</label></td>
																<td width="50%" align="left" valign="top"><label>
			<?php 
            _e('Total:', 'event_espresso');
            ?>
																	</label></td>
															</tr>
															<tr>
																<td align="left" valign="top"><?php 
            echo $org_options['currency_symbol'];
            ?>
																	<input name="amount_pd" type="text" value ="<?php 
            echo espresso_attendee_price(array('attendee_id' => $id, 'single_price' => true));
            ?>
" /></td>
																<td align="left" valign="top"> X
																	<input name="quantity" type="text" value ="<?php 
            echo !empty($quantity) ? $quantity : 1;
            ?>
"  /></td>
																<td align="left" valign="top"><?php 
            echo $org_options['currency_symbol'];
            echo espresso_attendee_price(array('attendee_id' => $id));
            ?>
</td>
															</tr>
														</table></div>
			                  </li>
			                  <li>
			                    <input type="submit" name="Submit" value="Update Payment" />
			                  </li>
			                </ul>
			              </fieldset>
			              <input type="hidden" name="id" value="<?php 
            echo $id;
            ?>
" />
			              <input type="hidden" name="registration_id" value="<?php 
            echo $registration_id;
            ?>
" />
			              <input type="hidden" name="form_action" value="edit_attendee" />
			              <input type="hidden" name="event_id" value="<?php 
            echo $event_id;
            ?>
" />
			              <input type="hidden" name="attendee_payment" value="update_payment" />
			            </form>
			<?php 
        }
        // !$has_seating_chart
        ?>
</td>
		        </tr>
		      </table>
		      <p> <strong> <a href="admin.php?page=events&event_id=<?php 
        echo $event_id;
        ?>
&event_admin_reports=list_attendee_payments"> &lt;&lt;
		<?php 
        _e('Back to List', 'event_espresso');
        ?>
							</a> </strong> </p>
		    </div>
		  </div>
		</div>
		<?php 
    }
}
Beispiel #2
0
_e('<strong>Program Start Date:</strong>', 'event_espresso');
?>
</span>  <?php 
echo event_date_display($start_date, get_option('date_format'));
?>
 

				<p class="event_time">
	<?php 
//This block of code is used to display the times of an event in either a dropdown or text format.
if (isset($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 {
    echo event_espresso_time_dropdown($event_id);
}
//End time selected
?>
				</p>
				<?php 
echo $venue_title != '' ? '<p style="clear: left;" id="event_venue_name-' . $event_id . '" class="event_venue_name"><strong>Location:</strong> ' . stripslashes_deep($venue_title) . '</p>' : '';
?>

			<?php 
//Add to calendar button
echo apply_filters('filter_hook_espresso_display_ical', $all_meta);
?>
		</p>
		<p><strong>Ages: </strong> <?php 
echo do_shortcode('[EE_META type="event_meta" name="event_age"]');
    function event_espresso_shopping_cart()
    {
        global $wpdb, $org_options;
        //session_destroy();
        //echo "<pre>", print_r( $_SESSION ), "</pre>";
        $events_in_session = $_SESSION['espresso_session']['events_in_session'];
        if (event_espresso_invoke_cart_error($events_in_session)) {
            return false;
        }
        if (count($events_in_session) > 0) {
            foreach ($events_in_session as $event) {
                // echo $event['id'];
                if (is_numeric($event['id'])) {
                    $events_IN[] = $event['id'];
                }
            }
            $events_IN = implode(',', $events_IN);
            $sql = "SELECT e.* FROM " . EVENTS_DETAIL_TABLE . " e ";
            $sql .= " WHERE e.id in ({$events_IN}) ";
            $sql .= " AND e.event_status != 'D' ";
            $sql .= " ORDER BY e.start_date ";
            $result = $wpdb->get_results($sql);
            ?>

<form action='?page_id=<?php 
            echo $org_options['event_page_id'];
            ?>
&regevent_action=load_checkout_page' method='post' id="event_espresso_shopping_cart">

<?php 
            $counter = 1;
            //Counter that will keep track of the first events
            foreach ($result as $r) {
                $num_attendees = get_number_of_attendees_reg_limit($r->id, 'num_attendees');
                //Get the number of attendees
                $available_spaces = get_number_of_attendees_reg_limit($r->id, 'available_spaces');
                //Gets a count of the available spaces
                $number_available_spaces = get_number_of_attendees_reg_limit($r->id, 'number_available_spaces');
                //Gets the number of available spaces
                //echo "<pre>$r->id, $num_attendees,$available_spaces,$number_available_spaces</pre>";
                ?>
		<div class="multi_reg_cart_block event-display-boxes ui-widget"  id ="multi_reg_cart_block-<?php 
                echo $r->id;
                ?>
">

			<h3 class="event_title ui-widget-header ui-corner-top"><?php 
                echo stripslashes_deep($r->event_name);
                ?>
 <span class="remove-cart-item"> <img class="ee_delete_item_from_cart" id="cart_link_<?php 
                echo $r->id;
                ?>
" alt="Remove this item from your cart" src="<?php 
                echo EVENT_ESPRESSO_PLUGINFULLURL;
                ?>
images/icons/remove.gif" /> </span> </h3>
				<div class="event-data-display ui-widget-content ui-corner-bottom">
					<table id="cart-reg-details" class="event-display-tables">
						<thead>
							<tr>
								<th><?php 
                _e('Date', 'event_espresso');
                ?>
</th>
								<th><?php 
                _e('Time', 'event_espresso');
                ?>
</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td><?php 
                echo event_date_display($r->start_date, get_option('date_format'));
                ?>
								<?php 
                /*_e( ' to ', 'event_espresso' ); ?> <?php echo event_date_display( $r->end_date, get_option( 'date_format' ) )*/
                ?>
</td>
								<td><?php 
                echo event_espresso_time_dropdown($r->id, 0, 1, $_SESSION['espresso_session']['events_in_session'][$r->id]['start_time_id']);
                ?>
</td>
							</tr>
							<tr>
								<td colspan="2"><?php 
                echo event_espresso_group_price_dropdown($r->id, 0, 1, $_SESSION['espresso_session']['events_in_session'][$r->id]['price_id']);
                ?>
</td>
							</tr>
					</table>
			<?php 
                //Coupons
                if (function_exists('event_espresso_coupon_registration_page')) {
                    // echo event_espresso_coupon_registration_page( $r->use_coupon_code, $r->id, 1 );
                }
                //End coupons display
                ?>

				<input type="hidden" name="event_name[<?php 
                echo $r->id;
                ?>
]" value="<?php 
                echo $r->event_name;
                ?>
" />
			</div><!-- / .event-data-display -->
		</div><!-- / .event-display-boxes -->

		<?php 
                $counter++;
            }
            ?>
		<div class="event-display-boxes ui-widget">
			<div class="mer-event-submit ui-widget-content ui-corner-all">
				<input type="hidden" name="event_name[<?php 
            echo $r->id;
            ?>
]" value="<?php 
            echo stripslashes_deep($r->event_name);
            ?>
" />
				<input type="hidden" name="regevent_action" value="load_checkout_page" />
			
			<?php 
            //Coupon code display
            //Uncomment the following code at your own risk. Just beware that all coupon codes will work for everyting in the cart.
            ?>
			<?php 
            /*?><div id="event_espresso_coupon_wrapper" class="clearfix event-data-display">
            			<label class="coupon-code" for="event_espresso_coupon_code">
            				<?php _e( 'Enter Coupon Code ', 'event_espresso' ); ?>
            			</label>
            			<input onkeydown="if(event.keyCode==13) {document.getElementById('event_espresso_refresh_total').focus(); return false;}" type="text" name="event_espresso_coupon_code" id ="event_espresso_coupon_code" value="<?php echo $_SESSION['espresso_session']['coupon_code']; ?>"/>
            		</div><?php */
            ?>

			<div id="event_espresso_total_wrapper" class="clearfix event-data-display">
					<a href="#" id="event_espresso_refresh_total"><?php 
            _e('Refresh Total', 'event_espresso');
            ?>
</a>
				<span class="event_total_price">
					<?php 
            _e('Total (' . $org_options['currency_symbol'] . '): <span id="event_total_price">' . $_SESSION['espresso_session']['grand_total'], 'event_espresso') . '</span>';
            ?>
				</span>
			</div>

			<input type="submit" class="submit btn_event_form_submit ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all" name="Continue" id="event_espresso_continue_registration" value="<?php 
            _e('Finish Registration', 'event_espresso');
            ?>
" />
		</div><!-- / .mer-event-submit -->
	</div><!-- / .event-display-boxes -->
</form>
<?php 
        }
    }
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
}
Beispiel #5
0
function edit_attendee_record()
{
    do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
    global $wpdb, $org_options;
    $notifications['success'] = array();
    $notifications['error'] = array();
    $failed_nonce_msg = '
<div id="message" class="error">
	<p>
		<strong>' . __('An Error Occurred. The request failed to pass a security check.', 'event_espresso') . '</strong><br/>
		<span style="font-size:.9em;">' . __('Please press the back button on your browser to return to the previous page.', 'event_espresso') . '</span>
	</p>
</div>';
    $attendee_num = 1;
    $is_additional_attendee = FALSE;
    // **************************************************************************
    // **************************** EDIT ATTENDEE  ****************************
    // **************************************************************************
    if ($_REQUEST['form_action'] == 'edit_attendee') {
        $id = isset($_REQUEST['id']) ? absint($_REQUEST['id']) : '';
        $registration_id = isset($_REQUEST['registration_id']) ? sanitize_text_field($_REQUEST['registration_id']) : '';
        $multi_reg = FALSE;
        // check for multi reg, additional attendees, and verify reg id for primary attendee
        $SQL = "SELECT * FROM " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " WHERE registration_id = %s";
        $check = $wpdb->get_row($wpdb->prepare($SQL, $registration_id));
        if ($check) {
            $registration_id = $check->primary_registration_id;
            $SQL = "SELECT distinct primary_registration_id, registration_id ";
            $SQL .= "FROM " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " ";
            $SQL .= "WHERE primary_registration_id = %s";
            $registration_ids = $wpdb->get_results($wpdb->prepare($SQL, $registration_id), ARRAY_A);
            $multi_reg = TRUE;
        }
        // find the primary attendee id so we know which form to present since the additional attendees will have a different form
        $SQL = "SELECT id FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id =%s AND is_primary = 1 ";
        if ($r = $wpdb->get_row($wpdb->prepare($SQL, $registration_id))) {
            $primary_attendee = !empty($r->id) ? $r->id : $id;
            $is_additional_attendee = $primary_attendee != $id ? TRUE : FALSE;
        } else {
            $primary_attendee = FALSE;
        }
        // **************************************************************************
        // **************************  UPDATE PAYMENT  **************************
        // **************************************************************************
        if (!empty($_REQUEST['attendee_payment']) && $_REQUEST['attendee_payment'] == 'update_price') {
            if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'edit_attendee_' . $registration_id . '_update_price_nonce')) {
                wp_die($failed_nonce_msg);
            }
            $upd_price = (double) number_format(abs(sanitize_text_field($_REQUEST['final_price'])), 2, '.', '');
            $upd_qty = absint($_REQUEST['quantity']);
            $set_cols_and_values = array('final_price' => $upd_price, 'quantity' => $upd_qty);
            $set_format = array('%f', '%d');
            $where_cols_and_values = array('id' => $id);
            $where_format = array('%d');
            // run the update
            $upd_success = $wpdb->update(EVENTS_ATTENDEE_TABLE, $set_cols_and_values, $where_cols_and_values, $set_format, $where_format);
            // if there was an actual error
            if ($upd_success === FALSE) {
                $notifications['error'][] = __('An error occured. Attendee ticket price details could not be updated.', 'event_espresso');
            } else {
                // now we need to gather all the ticket prices for all attendees for the entire registraion and calculate a new total cost
                $upd_total = 0;
                $SQL = "SELECT payment_status, amount_pd, final_price, quantity, is_primary FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id = %s";
                if ($attendee_tickets = $wpdb->get_results($wpdb->prepare($SQL, $registration_id))) {
                    // loop thru tickets
                    foreach ($attendee_tickets as $attendee_ticket) {
                        // calculate total for each attendee and add to total cost
                        $upd_total += $attendee_ticket->final_price * $attendee_ticket->quantity;
                        // grab amount paid by primary attendee
                        if ($attendee_ticket->is_primary) {
                            $amount_pd = (double) $attendee_ticket->amount_pd;
                            $payment_status = $attendee_ticket->payment_status;
                        }
                    }
                }
                // format new total_cost
                $upd_total = (double) number_format($upd_total, 2, '.', '');
                // compare new total_cost with amount_pd
                if ($upd_total == $amount_pd) {
                    $upd_payment_status = __('Completed', 'event_espresso');
                } elseif ($upd_total > $amount_pd) {
                    $upd_payment_status = __('Pending', 'event_espresso');
                } elseif ($upd_total < $amount_pd) {
                    $upd_payment_status = __('Refund', 'event_espresso');
                }
                //				echo '<h4>$amount_pd : ' . $amount_pd . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                //				echo '<h4>$payment_status : ' . $payment_status . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                //				echo '<h4>$upd_total : ' . $upd_total . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                //				echo '<h4>$upd_payment_status : ' . $upd_payment_status . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                // compare old payment status with new payment status and update if things have changed
                if ($upd_payment_status != $payment_status) {
                    // update payment status for ALL attendees for the entire registration
                    $set_cols_and_values = array('payment_status' => $upd_payment_status);
                    $set_format = array('%s');
                    $where_cols_and_values = array('registration_id' => $registration_id);
                    $where_format = array('%s');
                    // run the update
                    $upd_success = $wpdb->update(EVENTS_ATTENDEE_TABLE, $set_cols_and_values, $where_cols_and_values, $set_format, $where_format);
                    // if there was an actual error
                    if ($upd_success === FALSE) {
                        $notifications['error'][] = __('An error occured while attempting to update the payment status for attendeefrom this registration.', 'event_espresso');
                    }
                }
                // now update the primary registrant's total cost field'
                $set_cols_and_values = array('total_cost' => $upd_total);
                $set_format = array('%f');
                $where_cols_and_values = array('id' => $id, 'is_primary' => TRUE);
                $where_format = array('%d', '%d');
                // run the update
                $upd_success = $wpdb->update(EVENTS_ATTENDEE_TABLE, $set_cols_and_values, $where_cols_and_values, $set_format, $where_format);
                // if there was an actual error
                if ($upd_success === FALSE) {
                    $notifications['error'][] = __('An error occured. The primary attendee ticket total could not be updated.', 'event_espresso');
                }
                // let's base our success on the lack of errors
                $notifications['success'][] = empty($notifications['error']) ? __('All attendee ticket price details have been successfully updated.', 'event_espresso') : __('Some attendee ticket price details were successfully updated, but the following error(s) may have prevented others from being updated:', 'event_espresso');
            }
        }
        // **************************************************************************
        // **************************  DELETE ATTENDEE  **************************
        // **************************************************************************
        if (!empty($_REQUEST['attendee_action']) && $_REQUEST['attendee_action'] == 'delete_attendee') {
            if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'edit_attendee_' . $registration_id . '_delete_attendee_nonce')) {
                wp_die($failed_nonce_msg);
            }
            $SQL = "DELETE FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id =%d";
            $del_results = $wpdb->query($wpdb->prepare($SQL, $id));
            if ($del_results === FALSE) {
                $notifications['error'][] = __('An error occured. The attendee could not be deleted.', 'event_espresso');
            } elseif ($del_results === 0) {
                $notifications['error'][] = __('The attendee record in the database could not be found and was therefore not deleted.', 'event_espresso');
            } else {
                if (defined('ESPRESSO_SEATING_CHART')) {
                    $SQL = "DELETE FROM " . EVENTS_SEATING_CHART_EVENT_SEAT_TABLE . " where attendee_id = %d";
                    if ($wpdb->query($wpdb->prepare($SQL, $id)) === FALSE) {
                        $notifications['error'][] = __('An error occured. The attendee seating chart data could not be deleted.', 'event_espresso');
                    }
                }
                // get id's for all attendees from this registration
                $SQL = "SELECT id from " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id = %s";
                $attendees = $wpdb->query($wpdb->prepare($SQL, $registration_id));
                if ($attendees === FALSE) {
                    $notifications['error'][] = __('An error occured while attempting to retrieve additional attendee data from the database.', 'event_espresso');
                } else {
                    // update quantities for attendees
                    $SQL = " UPDATE " . EVENTS_ATTENDEE_TABLE . " SET quantity = IF(quantity IS NULL ,NULL,IF(quantity > 0,IF(quantity-1>0,quantity-1,1),0)) ";
                    $SQL .= "WHERE registration_id =%s";
                    if ($wpdb->update($SQL, $registration_id) === FALSE) {
                        $notifications['error'][] = __('An error occured while attempting to update additional attendee ticket quantities.', 'event_espresso');
                    }
                    event_espresso_cleanup_multi_event_registration_id_group_data();
                }
                // let's base our success on the lack of errors
                $notifications['success'][] = empty($notifications['error']) ? __('All attendee details have been successfully deleted.', 'event_espresso') : __('One or more errors may have prevented some attendee details from being successfully deleted.', 'event_espresso');
            }
            // **************************************************************************
            // **************************  UPDATE ATTENDEE  **************************
            // **************************************************************************
        } else {
            if (!empty($_REQUEST['attendee_action']) && $_REQUEST['attendee_action'] == 'update_attendee') {
                if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'edit_attendee_' . $registration_id . '_update_attendee_nonce')) {
                    wp_die($failed_nonce_msg);
                }
                $event_id = isset($_POST['event_id']) ? $_POST['event_id'] : '';
                $txn_type = isset($_POST['txn_type']) ? $_POST['txn_type'] : '';
                $set_cols_and_values = array('fname' => isset($_POST['fname']) ? $_POST['fname'] : '', 'lname' => isset($_POST['lname']) ? $_POST['lname'] : '', 'address' => isset($_POST['address']) ? $_POST['address'] : '', 'address2' => isset($_POST['address2']) ? $_POST['address2'] : '', 'city' => isset($_POST['city']) ? $_POST['city'] : '', 'state' => isset($_POST['state']) ? $_POST['state'] : '', 'zip' => isset($_POST['zip']) ? $_POST['zip'] : '', 'phone' => isset($_POST['phone']) ? $_POST['phone'] : '', 'email' => isset($_POST['email']) ? $_POST['email'] : '');
                $set_format = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');
                // Update the time ?
                if (isset($_POST['start_time_id'])) {
                    $SQL = "SELECT ese.start_time, ese.end_time FROM " . EVENTS_START_END_TABLE . " ese WHERE ese.id=%d";
                    if ($times = $wpdb->get_results($wpdb->prepare($SQL, absint($_POST['start_time_id'])))) {
                        foreach ($times as $time) {
                            $start_time = $time->start_time;
                            $end_time = $time->end_time;
                        }
                        $set_cols_and_values['event_time'] = $start_time;
                        $set_cols_and_values['end_time'] = $end_time;
                        array_push($set_format, '%s', '%s');
                    }
                }
                //printr( $_POST, '$_POST  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                $where_cols_and_values = array('id' => $id);
                $where_format = array('%d');
                // run the update
                $upd_success = $wpdb->update(EVENTS_ATTENDEE_TABLE, $set_cols_and_values, $where_cols_and_values, $set_format, $where_format);
                // if there was an actual error
                if ($upd_success === FALSE) {
                    $notifications['error'][] = __('An error occured. Attendee details could not be updated.', 'event_espresso');
                }
                // Added for seating chart addon
                $booking_id = 0;
                if (defined('ESPRESSO_SEATING_CHART')) {
                    if (seating_chart::check_event_has_seating_chart($event_id) !== false) {
                        if (isset($_POST['seat_id'])) {
                            $booking_id = seating_chart::parse_booking_info($_POST['seat_id']);
                            if ($booking_id > 0) {
                                seating_chart::confirm_a_seat($booking_id, $id);
                            }
                        }
                    }
                }
                // Insert Additional Questions From Post Here
                $reg_id = $id;
                $SQL = "SELECT question_groups, event_meta FROM " . EVENTS_DETAIL_TABLE . " WHERE id = %d";
                $questions = $wpdb->get_row($wpdb->prepare($SQL, $event_id));
                $question_groups = unserialize($questions->question_groups);
                $event_meta = unserialize($questions->event_meta);
                if ($is_additional_attendee && isset($event_meta['add_attendee_question_groups']) && $event_meta['add_attendee_question_groups'] != NULL) {
                    $question_groups = $event_meta['add_attendee_question_groups'];
                }
                $questions_in = '';
                foreach ($question_groups as $g_id) {
                    $questions_in .= $g_id . ',';
                }
                $questions_in = substr($questions_in, 0, -1);
                $group_name = '';
                $counter = 0;
                //pull the list of questions that are relevant to this event
                $SQL = "SELECT q.*, q.id AS q_id, at.id AS a_id, at.*, qg.group_name, qg.show_group_description, qg.show_group_name ";
                $SQL .= "FROM " . EVENTS_QUESTION_TABLE . " q ";
                $SQL .= "LEFT JOIN " . EVENTS_ANSWER_TABLE . " at on q.id = at.question_id ";
                $SQL .= "JOIN " . EVENTS_QST_GROUP_REL_TABLE . " qgr on q.id = qgr.question_id ";
                $SQL .= "JOIN " . EVENTS_QST_GROUP_TABLE . " qg on qg.id = qgr.group_id ";
                $SQL .= "WHERE qgr.group_id in ( {$questions_in} ) ";
                $SQL .= "AND (at.attendee_id IS NULL OR at.attendee_id = '%d') ";
                $SQL .= "ORDER BY qg.id, q.id ASC";
                $questions = $wpdb->get_results($wpdb->prepare($SQL, $id));
                //			printr( $questions, '$questions  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                $SQL = "SELECT id, question_id, answer FROM " . EVENTS_ANSWER_TABLE . " at WHERE at.attendee_id = %d";
                $answers = $wpdb->get_results($wpdb->prepare($SQL, $id), OBJECT_K);
                foreach ($answers as $answer) {
                    $answer_a[$answer->id] = $answer->question_id;
                }
                if ($questions) {
                    foreach ($questions as $question) {
                        //printr( $question, '$question  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                        switch ($question->question_type) {
                            case "TEXT":
                            case "TEXTAREA":
                            case "SINGLE":
                            case "DROPDOWN":
                                if ($question->system_name != '') {
                                    $post_val = isset($_POST[$question->system_name]) ? $_POST[$question->system_name] : '';
                                } else {
                                    $post_val = isset($_POST[$question->question_type . '_' . $question->a_id]) ? $_POST[$question->question_type . '_' . $question->a_id] : '';
                                }
                                $post_val = sanitize_text_field(stripslashes($post_val));
                                break;
                            case "MULTIPLE":
                                $post_val = '';
                                for ($i = 0; $i < count($_POST[$question->question_type . '_' . $question->a_id]); $i++) {
                                    $post_val .= trim($_POST[$question->question_type . '_' . $question->a_id][$i]) . ",";
                                }
                                $post_val = sanitize_text_field(substr(stripslashes($post_val), 0, -1));
                                break;
                        }
                        //					echo '<h4>$post_val : ' . $post_val . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                        //					echo '<h4>$question->id : ' . $question->q_id . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                        //					printr( $answer_a, '$answer_a  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                        if (in_array($question->q_id, $answer_a)) {
                            // existing answer
                            $set_cols_and_values = array('answer' => html_entity_decode(trim($post_val), ENT_QUOTES, 'UTF-8'));
                            //echo "<pre>".print_r($set_cols_and_values,true)."</pre>";
                            $set_format = array('%s');
                            $where_cols_and_values = array('attendee_id' => $id, 'question_id' => $question->q_id);
                            $where_format = array('%d', '%d');
                            // run the update
                            $upd_success = $wpdb->update(EVENTS_ANSWER_TABLE, $set_cols_and_values, $where_cols_and_values, $set_format, $where_format);
                            //echo '<h4>last_query : ' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                        } else {
                            // new answer
                            $set_cols_and_values = array('registration_id' => $registration_id, 'attendee_id' => $id, 'question_id' => $question->q_id, 'answer' => html_entity_decode(trim($post_val), ENT_QUOTES, 'UTF-8'));
                            $set_format = array('%s', '%d', '%d', '%s');
                            // run the insert
                            $upd_success = $wpdb->insert(EVENTS_ANSWER_TABLE, $set_cols_and_values, $set_format);
                            //echo '<h4>last_query : ' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                        }
                    }
                }
                // let's base our success on the lack of errors
                $notifications['success'][] = empty($notifications['error']) ? __('All attendee details have been successfully updated.', 'event_espresso') : __('One or more errors may have prevented some attendee details from being successfully updated.', 'event_espresso');
            }
        }
        // **************************************************************************
        // *************************  RETRIEVE ATTENDEE  *************************
        // **************************************************************************
        $counter = 0;
        $additional_attendees = NULL;
        $SQL = "SELECT att.*, evt.event_name, evt.question_groups, evt.event_meta, evt.additional_limit FROM " . EVENTS_ATTENDEE_TABLE . " att ";
        $SQL .= "JOIN " . EVENTS_DETAIL_TABLE . " evt ON att.event_id = evt.id ";
        // are we looking for an additional attendee ?
        if (isset($_REQUEST['attendee_num']) && $_REQUEST['attendee_num'] > 1 && isset($_REQUEST['id'])) {
            $SQL .= "WHERE  att.id = " . sanitize_text_field($_REQUEST['id']);
        } else {
            // check for multi reg & additional attendees by first finding primary attendee
            $SQL2 = "SELECT primary_registration_id FROM " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " WHERE registration_id = %s";
            if ($primary_registration_id = $wpdb->get_var($wpdb->prepare($SQL2, sanitize_text_field($_REQUEST['registration_id'])))) {
                // now find all registrations
                $SQL3 = "SELECT registration_id FROM " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " WHERE primary_registration_id = %s";
                $reg_ids = $wpdb->get_col($wpdb->prepare($SQL3, $primary_registration_id));
                $reg_ids = "'" . implode("','", $reg_ids) . "'";
            } else {
                $reg_ids = "'" . sanitize_text_field($_REQUEST['registration_id']) . "'";
            }
            $SQL .= " WHERE registration_id IN ( {$reg_ids} ) ORDER BY att.id";
        }
        $attendees = $wpdb->get_results($wpdb->prepare($SQL, NULL));
        foreach ($attendees as $attendee) {
            if ($counter == 0) {
                $id = $attendee->id;
                $registration_id = $attendee->registration_id;
                $lname = $attendee->lname;
                $fname = $attendee->fname;
                $address = $attendee->address;
                $address2 = $attendee->address2;
                $city = $attendee->city;
                $state = $attendee->state;
                $zip = $attendee->zip;
                $email = $attendee->email;
                $payment = $attendee->payment;
                $phone = $attendee->phone;
                $date = $attendee->date;
                $payment_status = $attendee->payment_status;
                $txn_type = $attendee->txn_type;
                $txn_id = $attendee->txn_id;
                $quantity = $attendee->quantity;
                $payment_date = $attendee->payment_date;
                $event_id = $attendee->event_id;
                $event_name = $attendee->event_name;
                $question_groups = unserialize($attendee->question_groups);
                $event_meta = unserialize($attendee->event_meta);
                $coupon_code = $attendee->coupon_code;
                $is_additional_attendee = $primary_attendee != $id ? true : false;
                $attendee_limit = $attendee->additional_limit;
                $amount_pd = $attendee->amount_pd;
                $total_cost = $attendee->total_cost;
                $orig_price = $attendee->orig_price;
                $final_price = $attendee->final_price;
                $start_date = $attendee->start_date;
                $event_time = $attendee->event_time;
                // Added for seating chart addon
                $booking_info = "";
                if (defined('ESPRESSO_SEATING_CHART')) {
                    $seating_chart_id = seating_chart::check_event_has_seating_chart($event_id);
                    if ($seating_chart_id !== false) {
                        $seat = $wpdb->get_row("select scs.* , sces.id as booking_id from " . EVENTS_SEATING_CHART_SEAT_TABLE . " scs inner join " . EVENTS_SEATING_CHART_EVENT_SEAT_TABLE . " sces on scs.id = sces.seat_id where sces.attendee_id = '" . $id . "' ");
                        if ($seat !== NULL) {
                            $booking_info = $seat->custom_tag . " #booking id: " . $seat->booking_id;
                        }
                    }
                }
                $event_date = event_date_display($start_date . ' ' . $event_time, get_option('date_format') . ' g:i a');
                if ($is_additional_attendee && isset($event_meta['add_attendee_question_groups']) && $event_meta['add_attendee_question_groups'] != NULL) {
                    $question_groups = $event_meta['add_attendee_question_groups'];
                }
                $counter++;
            } else {
                $additional_attendees[$attendee->id] = array('full_name' => $attendee->fname . ' ' . $attendee->lname, 'email' => $attendee->email, 'phone' => $attendee->phone);
            }
        }
        // display success messages
        if (!empty($notifications['success'])) {
            $success_msg = implode($notifications['success'], '<br />');
            ?>
				
<div id="message" class="updated fade">
	<p>
		<strong><?php 
            echo $success_msg;
            ?>
</strong>
	</p>
</div>

		<?php 
        }
        // display error messages
        if (!empty($notifications['error'])) {
            $error_msg = implode($notifications['error'], '<br />');
            ?>
				
<div id="message" class="error">
	<p>
		<strong><?php 
            echo $error_msg;
            ?>
</strong>
	</p>
</div>

		<?php 
        }
        ?>
		
<div>		
	<p>
		<a href="admin.php?page=events&event_id=<?php 
        echo $event_id;
        ?>
&event_admin_reports=list_attendee_payments">
			<strong>&laquo;&nbsp;<?php 
        _e('Back to Attendees List', 'event_espresso');
        ?>
</strong>
		</a>
	</p>
</div>

<div class="metabox-holder">
	<div class="postbox">
		<h3>
			<?php 
        _e('Registration Id <a href="admin.php?page=events&event_admin_reports=edit_attendee_record&event_id=' . $event_id . '&registration_id=' . $registration_id . '&form_action=edit_attendee">#' . $registration_id . '</a> | ID #' . $id . ' | Name: ' . $fname . ' ' . $lname . ' | Registered For:', 'event_espresso');
        ?>
			<a href="admin.php?page=events&event_admin_reports=list_attendee_payments&event_id=<?php 
        echo $event_id;
        ?>
"><?php 
        echo stripslashes_deep($event_name);
        ?>
</a> - <?php 
        echo $event_date;
        ?>
		</h3>
		<div class="inside">
			<table width="100%">
				<tr>
					<td width="50%" valign="top">
						<form method="post" action="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
" class="espresso_form">
							<h4 class="qrtr-margin">
								<?php 
        _e('Registration Information', 'event_espresso');
        ?>
								<?php 
        echo $is_additional_attendee == false ? '[ <span class="green_text">' . __('Primary Attendee Record', 'event_espresso') . '</span> ]' : '[ <a href="admin.php?page=events&event_admin_reports=edit_attendee_record&event_id=' . $event_id . '&registration_id=' . $registration_id . '&form_action=edit_attendee">View/Edit Primary Attendee</a> ]';
        ?>
							</h4>
							<fieldset>
								<ul>
									<li>
										<?php 
        $time_id = 0;
        $SQL = "SELECT id FROM " . EVENTS_START_END_TABLE . " WHERE event_id=%d AND start_time =%s";
        if ($event_time = $wpdb->get_row($wpdb->prepare($SQL, $event_id, $event_time))) {
            $time_id = $event_time->id;
        }
        echo event_espresso_time_dropdown($event_id, $label = 1, $multi_reg = 0, $time_id);
        ?>
									</li>
									<li>
										<?php 
        //Added for seating chart addon.  Creates a field to select a seat from a popup.
        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, $booking_info);
        ?>
									</li>
									<li>
										<?php 
        if (count($question_groups) > 0) {
            $questions_in = '';
            foreach ($question_groups as $g_id) {
                $questions_in .= $g_id . ',';
            }
            $questions_in = substr($questions_in, 0, -1);
            $group_name = '';
            $counter = 0;
            $FILTER = '';
            if (isset($event_meta['additional_attendee_reg_info']) && $event_meta['additional_attendee_reg_info'] == '2' && isset($_REQUEST['attendee_num']) && $_REQUEST['attendee_num'] > 1) {
                $FILTER .= " AND qg.system_group = 1 ";
            }
            //pull the list of questions that are relevant to this event
            $SQL = "SELECT q.*, at.*, qg.group_name, qg.show_group_description, qg.show_group_name ";
            $SQL .= "FROM " . EVENTS_QUESTION_TABLE . " q ";
            $SQL .= "LEFT JOIN " . EVENTS_ANSWER_TABLE . " at on q.id = at.question_id ";
            $SQL .= "JOIN " . EVENTS_QST_GROUP_REL_TABLE . " qgr on q.id = qgr.question_id ";
            $SQL .= "JOIN " . EVENTS_QST_GROUP_TABLE . " qg on qg.id = qgr.group_id ";
            $SQL .= "WHERE qgr.group_id in ( {$questions_in} ) ";
            $SQL .= "AND ( at.attendee_id IS NULL OR at.attendee_id = %d ) ";
            $SQL .= $FILTER . " ";
            $SQL .= "ORDER BY qg.id, q.id ASC";
            $questions = $wpdb->get_results($wpdb->prepare($SQL, $id));
            $num_rows = $wpdb->num_rows;
            if ($num_rows > 0) {
                //Output the questions
                $question_displayed = array();
                foreach ($questions as $question) {
                    $counter++;
                    if (!in_array($question->id, $question_displayed)) {
                        $question_displayed[] = $question->id;
                        //echo '<p>';
                        echo event_form_build_edit($question, $question->answer, $show_admin_only = true);
                        //echo "</p>";
                        #echo $counter == $num_rows ? '</fieldset>' : '';
                    }
                }
            }
            //end questions display
        }
        ?>
									</li>
									<input type="hidden" name="id" value="<?php 
        echo $id;
        ?>
" />
									<input type="hidden" name="registration_id" value="<?php 
        echo $registration_id;
        ?>
" />
									<input type="hidden" name="event_id" value="<?php 
        echo $event_id;
        ?>
" />
									<input type="hidden" name="display_action" value="view_list" />
									<input type="hidden" name="form_action" value="edit_attendee" />
									<input type="hidden" name="attendee_action" value="update_attendee" />
									<?php 
        wp_nonce_field('edit_attendee_' . $registration_id . '_update_attendee_nonce');
        ?>
									<li>
										<input type="submit" name="Submit" class="button-primary action"  value="<?php 
        _e('Update Record', 'event_espresso');
        ?>
" />
									</li>
								</ul>
							</fieldset>
						</form></td>
					<td  width="50%" valign="top">
						<?php 
        if (count($additional_attendees) > 0) {
            ?>
 
						<h4>
							<?php 
            _e('Additional Attendees', 'event_espresso');
            ?>
						</h4>
						<ol>
							<?php 
            foreach ($additional_attendees as $att => $row) {
                $attendee_num++;
                ?>
							<li>
								<?php 
                // create edit link
                $edit_att_url_params = array('event_admin_reports' => 'edit_attendee_record', 'form_action' => 'edit_attendee', 'registration_id' => $registration_id, 'id' => $att, 'attendee_num' => $attendee_num, 'event_id' => $event_id);
                // add url params
                $edit_attendee_link = add_query_arg($edit_att_url_params, 'admin.php?page=events');
                ?>
								
								<a href="<?php 
                echo $edit_attendee_link;
                ?>
" title="<?php 
                _e('Edit Attendee', 'event_espresso');
                ?>
">
									<strong><?php 
                echo $row['full_name'];
                ?>
</strong> (<?php 
                echo $row['email'];
                ?>
)
								</a>
								&nbsp;&nbsp;|&nbsp;&nbsp;
								<?php 
                // create delete link
                $delete_att_url_params = array('event_admin_reports' => 'edit_attendee_record', 'form_action' => 'edit_attendee', 'attendee_action' => 'delete_attendee', 'registration_id' => $registration_id, 'id' => $att, 'attendee_num' => $attendee_num, 'event_id' => $event_id);
                // add url params
                $delete_attendee_link = add_query_arg($delete_att_url_params, 'admin.php?page=events');
                // add nonce
                $edit_attendee_link = wp_nonce_url($delete_attendee_link, 'edit_attendee_' . $registration_id . '_delete_attendee_nonce');
                ?>
								
								<a href="<?php 
                echo $delete_attendee_link;
                ?>
" title="<?php 
                _e('Delete Attendee', 'event_espresso');
                ?>
" onclick="return confirmDelete();">
									<?php 
                _e('Delete', 'event_espresso');
                ?>
								</a>
							</li>
							<?php 
            }
            ?>
						</ol>
						<?php 
        }
        ?>
						
						
						<br/>
						<h4 class="qrtr-margin"><?php 
        _e('Ticket Prices', 'event_espresso');
        ?>
</h4>
						
						<form method="POST" action="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
&status=saved" class="espresso_form">
							<fieldset>
								<ul>
									<li>
											<strong class="att-tckt-prc-lbl"><?php 
        _e('Payment Status:', 'event_espresso');
        ?>
</strong> 
											<?php 
        echo $payment_status;
        ?>
 <?php 
        echo event_espresso_paid_status_icon($payment_status);
        ?>
&nbsp;&nbsp;[&nbsp;<a href="admin.php?page=events&amp;attendee_pay=paynow&amp;form_action=payment&amp;registration_id=<?php 
        echo $registration_id;
        ?>
&amp;event_admin_reports=enter_attendee_payments&amp;event_id=<?php 
        echo $event_id;
        ?>
" title="<?php 
        _e('Edit Payment', 'event_espresso');
        ?>
">
											<?php 
        _e('View/Edit Payment', 'event_espresso');
        ?>
											</a>&nbsp;]
									</li>
									<li>
											<strong class="att-tckt-prc-lbl"><?php 
        _e('Transaction ID:', 'event_espresso');
        ?>
</strong> 
											<?php 
        echo !empty($txn_id) ? $txn_id : 'N/A';
        ?>
									</li>
									<li>
											<strong class="att-tckt-prc-lbl"><?php 
        _e('Date Paid:', 'event_espresso');
        ?>
</strong> 
											<?php 
        echo !empty($payment_date) ? event_date_display($payment_date) : 'N/A';
        ?>
									</li>
									<li>
											<strong class="att-tckt-prc-lbl">
											<?php 
        _e('Total Amount Owing:', 'event_espresso');
        ?>
											</strong>
											<?php 
        echo $org_options['currency_symbol'];
        echo $total_cost;
        ?>
									</li>
									<li>
											<strong class="att-tckt-prc-lbl"><?php 
        _e('Total Amount Paid to Date:', 'event_espresso');
        ?>
</strong> 
											<?php 
        echo $org_options['currency_symbol'] . $amount_pd;
        //echo espresso_attendee_price(array('attendee_id' => $id, 'reg_total' => true));
        ?>
									</li>
									<li>
										<h6 class="qrtr-margin"><strong><?php 
        _e('Attendee Ticket Fees:', 'event_espresso');
        ?>
</strong></h6>
										<div  <?php 
        if (isset($_REQUEST['show_payment']) && $_REQUEST['show_payment'] == 'true') {
            echo ' class="yellow_inform"';
        }
        ?>
>
											<table  border="0">
												<tr>
													<td  align="left" valign="top">
														<label><?php 
        _e('Amount:', 'event_espresso');
        ?>
 ( <?php 
        echo $org_options['currency_symbol'];
        ?>
 )</label>
													</td>
													<td  align="center" valign="top">
														<label><?php 
        _e('# Tickets:', 'event_espresso');
        ?>
</label>
													</td>
													<td  align="right" valign="top">
														<label class="algn-rght"><?php 
        _e('Total:', 'event_espresso');
        ?>
</label>
													</td>
												</tr>
												<tr>
													<td align="left" valign="top">
														<input name="final_price" class="small-text algn-rght" type="text" value ="<?php 
        echo $final_price;
        ?>
" />
													</td>
													<td align="center" valign="top">
														<?php 
        // number of tickets currently purchased
        $quantity = !empty($quantity) ? $quantity : 1;
        // availalbe spaces left for event
        $available_spaces = get_number_of_attendees_reg_limit($event_id, 'number_available_spaces');
        if ($available_spaces != 'Unlimited') {
            // first add our purchased tickets ($quantity) back into available spaces
            // ( becuase a sold out show incluldes these tickets here, so admin should be allowed to play with these numbers - think about it )
            $available_spaces += $quantity;
            $attendee_limit = $attendee_limit <= $available_spaces ? $attendee_limit : $available_spaces;
        }
        // final check to make sure that attendee limit has to at LEAST be the number of tickets this attendee has already purchased
        // otherwise the ticket quantity selector may display less than what this attendee has already purchased
        $attendee_limit = $attendee_limit < $quantity ? $quantity : $attendee_limit;
        ?>
														<select name="quantity" class="price_id">
														<?php 
        for ($i = 0; $i <= $attendee_limit; $i++) {
            $selected = $i == $quantity ? ' selected="selected" ' : '';
            ?>
															<option <?php 
            echo $selected;
            ?>
 value="<?php 
            echo $i;
            ?>
"><?php 
            echo $i;
            ?>
</option>
														<?php 
        }
        ?>
														</select>
														<!--<input name="quantity" type="text" value ="<?php 
        echo !empty($quantity) ? $quantity : 1;
        ?>
"  />-->
													</td>
													<td  align="right" valign="top">
														<?php 
        $ticket_total = (double) ($final_price * $quantity) > 0 ? number_format($final_price * $quantity, 2, '.', '') : 0.0;
        ?>
														<input class="small-text algn-rght" type="text" name="total_owing" disabled="true" value ="<?php 
        echo $ticket_total;
        ?>
" />
													</td>
												</tr>
											</table>
										</div>
									</li>
									<li>
											<strong class="att-tckt-prc-lbl"><?php 
        _e('Original Ticket Price:', 'event_espresso');
        ?>
</strong> 
											<?php 
        echo $org_options['currency_symbol'] . '&nbsp;' . $orig_price;
        ?>
&nbsp;&nbsp;/&nbsp;&nbsp;<?php 
        _e('ticket', 'event_espresso');
        ?>
								
									</li>
									<li>
										<br/>
										<input type="submit" name="submit_ticket_prices" class="button-primary action"  value="Update Price" />
									</li>
								</ul>
							</fieldset>
							<input type="hidden" name="id" value="<?php 
        echo $id;
        ?>
" />
							<input type="hidden" name="registration_id" value="<?php 
        echo $registration_id;
        ?>
" />
							<input type="hidden" name="form_action" value="edit_attendee" />
							<input type="hidden" name="event_id" value="<?php 
        echo $event_id;
        ?>
" />
							<input type="hidden" name="attendee_payment" value="update_price" />
							<?php 
        wp_nonce_field('edit_attendee_' . $registration_id . '_update_price_nonce');
        ?>
						</form>
					</td>
				</tr>
			</table>
		</div>
	</div>
</div>
<?php 
    }
}
Beispiel #6
0
    function event_espresso_shopping_cart()
    {
        global $wpdb, $org_options;
        //session_destroy();
        //echo "<pre>", print_r( $_SESSION ), "</pre>";
        $events_in_session = isset($_SESSION['espresso_session']['events_in_session']) ? $_SESSION['espresso_session']['events_in_session'] : event_espresso_clear_session(TRUE);
        if (event_espresso_invoke_cart_error($events_in_session)) {
            return false;
        }
        if (count($events_in_session) > 0) {
            foreach ($events_in_session as $event) {
                // echo $event['id'];
                if (is_numeric($event['id'])) {
                    $events_IN[] = $event['id'];
                }
            }
            $events_IN = implode(',', $events_IN);
            $sql = "SELECT e.* FROM " . EVENTS_DETAIL_TABLE . " e ";
            $sql = apply_filters('filter_hook_espresso_shopping_cart_SQL_select', $sql);
            $sql .= " WHERE e.id in ({$events_IN}) ";
            $sql .= " AND e.event_status != 'D' ";
            $sql .= " ORDER BY e.start_date ";
            //echo '<h4>$sql : ' . $sql . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
            $result = $wpdb->get_results($sql);
            ?>

<form action='?page_id=<?php 
            echo $org_options['event_page_id'];
            ?>
&regevent_action=load_checkout_page' method='post' id="event_espresso_shopping_cart">

<?php 
            $counter = 1;
            //Counter that will keep track of the first events
            foreach ($result as $r) {
                //Check to see if the Members plugin is installed.
                if (function_exists('espresso_members_installed') && espresso_members_installed() == true && !is_user_logged_in()) {
                    $member_options = get_option('events_member_settings');
                    if ($r->member_only == 'Y' || $member_options['member_only_all'] == 'Y') {
                        event_espresso_user_login();
                        return;
                    }
                }
                //If the event is still active, then show it.
                if (event_espresso_get_status($r->id) == 'ACTIVE') {
                    $num_attendees = get_number_of_attendees_reg_limit($r->id, 'num_attendees');
                    //Get the number of attendees
                    $available_spaces = get_number_of_attendees_reg_limit($r->id, 'available_spaces');
                    //Gets a count of the available spaces
                    $number_available_spaces = get_number_of_attendees_reg_limit($r->id, 'number_available_spaces');
                    //Gets the number of available spaces
                    //echo "<pre>$r->id, $num_attendees,$available_spaces,$number_available_spaces</pre>";
                    ?>
				<div class="multi_reg_cart_block event-display-boxes ui-widget"  id ="multi_reg_cart_block-<?php 
                    echo $r->id;
                    ?>
">
		
					<h3 class="event_title ui-widget-header ui-corner-top"><?php 
                    echo stripslashes_deep($r->event_name);
                    ?>
 <span class="remove-cart-item"> <img class="ee_delete_item_from_cart" id="cart_link_<?php 
                    echo $r->id;
                    ?>
" alt="Remove this item from your cart" src="<?php 
                    echo EVENT_ESPRESSO_PLUGINFULLURL;
                    ?>
images/icons/remove.gif" /> </span> </h3>
						<div class="event-data-display ui-widget-content ui-corner-bottom">
							<table id="cart-reg-details" class="event-display-tables">
								<thead>
									<tr>
										<th><?php 
                    _e('Date', 'event_espresso');
                    ?>
</th>
										<th><?php 
                    _e('Time', 'event_espresso');
                    ?>
</th>
									</tr>
								</thead>
								<tbody>
									<tr>
										<td>
											<?php 
                    echo event_date_display($r->start_date, get_option('date_format'));
                    ?>
											<?php 
                    /*_e( ' to ', 'event_espresso' ); ?> <?php echo event_date_display( $r->end_date, get_option( 'date_format' ) )*/
                    ?>
										</td>
										<td>
											<?php 
                    echo event_espresso_time_dropdown($r->id, 0, 1, $_SESSION['espresso_session']['events_in_session'][$r->id]['start_time_id']);
                    ?>
										</td>
									</tr>
									<tr>
										<td colspan="2">
											<?php 
                    echo event_espresso_group_price_dropdown($r->id, 0, 1, $_SESSION['espresso_session']['events_in_session'][$r->id]['price_id']);
                    ?>
										</td>
									</tr>
								</tbody>
							</table>
		
						<input type="hidden" name="event_name[<?php 
                    echo $r->id;
                    ?>
]" value="<?php 
                    echo $r->event_name;
                    ?>
" />
						<input type="hidden" name="use_coupon[<?php 
                    echo $r->id;
                    ?>
]" value="<?php 
                    echo $r->use_coupon_code;
                    ?>
" />
						<input type="hidden" name="use_groupon[<?php 
                    echo $r->id;
                    ?>
]" value="<?php 
                    echo $r->use_groupon_code;
                    ?>
" />
						<?php 
                    do_action_ref_array('action_hook_espresso_add_to_multi_reg_cart_block', array($r));
                    ?>
						
					</div><!-- / .event-data-display -->
				</div><!-- / .event-display-boxes -->
		
				<?php 
                    $counter++;
                }
            }
            //echo $_SESSION['espresso_session']['groupon_used'];
            //		printr( $_SESSION, '$_SESSION  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
            ?>
		<div class="event-display-boxes ui-widget">
			<div class="mer-event-submit ui-widget-content ui-corner-all">
				<input type="hidden" name="event_name[<?php 
            echo $r->id;
            ?>
]" value="<?php 
            echo stripslashes_deep($r->event_name);
            ?>
" />
				<input type="hidden" name="regevent_action" value="load_checkout_page" />
					
			<?php 
            if (function_exists('event_espresso_coupon_payment_page') && isset($org_options['allow_mer_discounts']) && $org_options['allow_mer_discounts'] == 'Y') {
                //Discount code display
                ?>
			<div id="event_espresso_coupon_wrapper" class="clearfix event-data-display">
				<label class="coupon-code" for="event_espresso_coupon_code"><?php 
                _e('Enter Coupon Code ', 'event_espresso');
                ?>
</label>
				<input type="text" 
							name="event_espresso_coupon_code" 
							id ="event_espresso_coupon_code" 
							value="<?php 
                echo isset($_SESSION['espresso_session']['event_espresso_coupon_code']) ? $_SESSION['espresso_session']['event_espresso_coupon_code'] : '';
                ?>
"
							onkeydown="if(event.keyCode==13) {document.getElementById('event_espresso_refresh_total').focus(); return false;}" 
						/>
			</div>
			<?php 
            }
            ?>
			
			<?php 
            if (function_exists('event_espresso_groupon_payment_page') && isset($org_options['allow_mer_vouchers']) && $org_options['allow_mer_vouchers'] == 'Y') {
                //Voucher code display
                ?>
			<div id="event_espresso_coupon_wrapper" class="clearfix event-data-display" >
				<label class="coupon-code" for="event_espresso_groupon_code"><?php 
                _e('Enter Voucher Code ', 'event_espresso');
                ?>
</label>
				<input type="text" 
							name="event_espresso_groupon_code" 
							id ="event_espresso_groupon_code" 
							value="<?php 
                echo isset($_SESSION['espresso_session']['groupon_code']) ? $_SESSION['espresso_session']['groupon_code'] : '';
                ?>
"
							onkeydown="if(event.keyCode==13) {document.getElementById('event_espresso_refresh_total').focus(); return false;}" 
						/>
			</div>
			<?php 
            }
            ?>
			
             <div id="event_espresso_notifications" class="clearfix event-data-display" style=""></div> 			

			<div id="event_espresso_total_wrapper" class="clearfix event-data-display">	
					
				<?php 
            do_action('action_hook_espresso_shopping_cart_before_total');
            ?>
				
				<span class="event_total_price">
					<?php 
            _e('Total ', 'event_espresso') . $org_options['currency_symbol'];
            ?>
 <span id="event_total_price"><?php 
            echo $_SESSION['espresso_session']['grand_total'];
            ?>
</span>
				</span>
				<?php 
            do_action('action_hook_espresso_shopping_cart_after_total');
            ?>
				<p id="event_espresso_refresh_total">
				<a id="event_espresso_refresh_total" style="cursor:pointer;"><?php 
            _e('Refresh Total', 'event_espresso');
            ?>
</a>
			</p>
			</div>

			
			<p id="event_espresso_submit_cart">
				<input type="submit" class="submit btn_event_form_submit ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all" name="Continue" id="event_espresso_continue_registration" value="<?php 
            _e('Enter Attendee Information', 'event_espresso');
            ?>
&nbsp;&raquo;" />
			</p>
			
		</div><!-- / .mer-event-submit -->
	</div><!-- / .event-display-boxes -->
</form>
<?php 
        }
    }
    function espresso_reg_form_sc($atts)
    {
        global $wpdb, $org_options;
        global $load_espresso_scripts;
        $load_espresso_scripts = true;
        //This tells the plugin to load the required scripts
        extract(shortcode_atts(array('event_id' => '0'), $atts));
        $event_id = "{$event_id}";
        //The following variables are used to get information about your organization
        $event_page_id = $org_options['event_page_id'];
        $Organization = stripslashes_deep($org_options['organization']);
        $Organization_street1 = $org_options['organization_street1'];
        $Organization_street2 = $org_options['organization_street2'];
        $Organization_city = $org_options['organization_city'];
        $Organization_state = $org_options['organization_state'];
        $Organization_zip = $org_options['organization_zip'];
        $contact = $org_options['contact_email'];
        $registrar = $org_options['contact_email'];
        $currency_format = $org_options['currency_format'];
        $message = $org_options['message'];
        $use_captcha = $org_options['use_captcha'];
        $paypal_id = $org_options['paypal_id'];
        $sql = "SELECT * FROM " . EVENTS_DETAIL_TABLE;
        $sql .= " WHERE is_active='Y' ";
        $sql .= " AND event_status != 'D' ";
        $sql .= " AND id = '" . $event_id . "' LIMIT 0,1";
        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_deep($event->event_name);
                $event_desc = stripslashes_deep($event->event_desc);
                $display_desc = $event->display_desc;
                $display_reg_form = $event->display_reg_form;
                $event_address = $event->address;
                $event_address2 = $event->address2;
                $event_city = $event->city;
                $event_state = $event->state;
                $event_zip = $event->zip;
                $event_country = $event->country;
                $event_description = stripslashes_deep($event->event_desc);
                $event_identifier = $event->event_identifier;
                $event_cost = $event->event_cost;
                $member_only = $event->member_only;
                $reg_limit = $event->reg_limit;
                $allow_multiple = $event->allow_multiple;
                $start_date = $event->start_date;
                $end_date = $event->end_date;
                $allow_overflow = $event->allow_overflow;
                $overflow_event_id = $event->overflow_event_id;
                $virtual_url = stripslashes_deep($event->virtual_url);
                $virtual_phone = stripslashes_deep($event->virtual_phone);
                //Address formatting
                $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 : '');
                //Google map link creation
                $google_map_link = espresso_google_map_link(array('address' => $event_address, 'city' => $event_city, 'state' => $event_state, 'zip' => $event_zip, 'country' => $event_country, 'text' => 'Map and Directions', 'type' => 'text'));
                $reg_start_date = $event->registration_start;
                $reg_end_date = $event->registration_end;
                $today = date("Y-m-d");
                $reg_limit = $event->reg_limit;
                $additional_limit = $event->additional_limit;
                $question_groups = unserialize($event->question_groups);
                global $all_meta;
                $all_meta = array('event_name' => stripslashes_deep($event_name), 'event_desc' => stripslashes_deep($event_desc), 'event_address' => $event_address, 'event_address2' => $event_address2, 'event_city' => $event_city, 'event_state' => $event_state, 'event_zip' => $event_zip, 'is_active' => $event->is_active, 'event_status' => $event->event_status, 'start_time' => $event->start_time, 'registration_startT' => $event->registration_startT, 'registration_start' => $event->registration_start, 'registration_endT' => $event->registration_endT, 'registration_end' => $event->registration_end, 'is_active' => $is_active, 'event_country' => $event_country, 'start_date' => event_date_display($start_date, get_option('date_format')), 'end_date' => event_date_display($end_date, get_option('date_format')), 'time' => $event->start_time, 'google_map_link' => $google_map_link, 'price' => $event->event_cost, 'event_cost' => $event->event_cost);
                //This function gets the status of the event.
                $is_active = array();
                $is_active = event_espresso_get_is_active(0, $all_meta);
                //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 registration form.
        //This is a template file for displaying a registration form for an event on a page.
        //There should be a copy of this file in your wp-content/uploads/espresso/ folder.
        ?>
		<div id="event_espresso_registration_form">
			<form method="post" action="<?php 
        echo home_url();
        ?>
/?page_id=<?php 
        echo $event_page_id;
        ?>
" id="registration_form">
				<?php 
        //print_r( event_espresso_get_is_active($event_id));
        switch ($is_active['status']) {
            case 'EXPIRED':
                //only show the event description.
                _e('<h3 class="expired_event">This event has passed.</h3>', 'event_espresso');
                break;
            case 'REGISTRATION_CLOSED':
                //only show the event description.
                // if todays date is after $reg_end_date
                ?>
						<p class="event_full"><strong><?php 
                _e('We are sorry but registration for this event is now closed.', 'event_espresso');
                ?>
</strong></p>
						<p class="event_full"><strong><?php 
                _e('Please <a href="contact" title="contact us">contact us</a> if you would like to know if spaces are still available.', 'event_espresso');
                ?>
</strong></p>
						<?php 
                break;
            case 'REGISTRATION_NOT_OPEN':
                //only show the event description.
                // if todays date is after $reg_end_date
                // if todays date is prior to $reg_start_date
                ?>
						<p class="event_full"><strong><?php 
                _e('We are sorry but this event is not yet open for registration.', 'event_espresso');
                ?>
</strong></p>
						<p class="event_full"><strong><?php 
                _e('You will be able to register starting ', 'event_espresso');
                echo event_espresso_no_format_date($reg_start_date, 'F d, Y');
                ?>
</strong></p>
							<?php 
                break;
            default:
                //If the event is in an active or ongoing status, then show the registration form.
                //echo $is_active['status'];//Show event status
                if ($display_reg_form == 'Y') {
                    ?>
							<p class="event_time">
					<?php 
                    //This block of code is used to display the times of an event in either a dropdown or text format.
                    if ($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>

							<p class="event_prices"><?php 
                    echo event_espresso_price_dropdown($event_id);
                    //Show pricing in a dropdown or text
                    ?>
</p>
							<?php 
                    //Outputs the custom form questions. This function can be overridden using the custom files addon
                    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
                    ?>
							<input type="hidden" name="num_people" id="num_people-<?php 
                    echo $event_id;
                    ?>
" value="1">


							<input type="hidden" name="regevent_action" 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;
                    ?>
">
							<?php 
                    //Recaptcha portion
                    if ($use_captcha == 'Y') {
                        if (!function_exists('recaptcha_get_html')) {
                            require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/recaptchalib.php';
                        }
                        //End require captcha library
                        # the response from reCAPTCHA
                        $resp = null;
                        # the error code from reCAPTCHA, if any
                        $error = null;
                        ?>
								<p class="event_form_field" id="captcha-<?php 
                        echo $event_id;
                        ?>
"><?php 
                        _e('Anti-Spam Measure: Please enter the following phrase', 'event_espresso');
                        ?>
								<?php 
                        echo recaptcha_get_html($org_options['recaptcha_publickey'], $error);
                        ?>
								</p>
							<?php 
                    }
                    //End use captcha
                    ?>
							<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 
                }
                break;
        }
        //End Switch statement to check the status of the event
        ?>
			</form>
		</div><?php 
    }
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
}