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 
    }
}
示例#2
0
function espresso_prepare_email_data($attendee_id, $multi_reg, $custom_data = '')
{
    global $wpdb, $org_options;
    do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
    $data = new stdClass();
    $data->multi_reg = $multi_reg;
    //print_r($custom_data);
    //Create vars for the custom data
    if (!empty($custom_data)) {
        extract($custom_data, EXTR_PREFIX_ALL, 'custom_data');
    }
    //echo $custom_data_email_type;
    //Get the event record
    if (empty($custom_data_email_type)) {
        $custom_data_email_type = '';
    }
    $sql = "SELECT ed.* ";
    isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' ? $sql .= ", v.name venue_name, v.address venue_address, v.address2 venue_address2, v.city venue_city, v.state venue_state, v.zip venue_zip, v.country venue_country, v.meta venue_meta " : '';
    $sql .= " FROM " . EVENTS_DETAIL_TABLE . " ed ";
    isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' ? $sql .= " LEFT JOIN " . EVENTS_VENUE_REL_TABLE . " r ON r.event_id = ed.id LEFT JOIN " . EVENTS_VENUE_TABLE . " v ON v.id = r.venue_id " : '';
    $sql .= " JOIN " . EVENTS_ATTENDEE_TABLE . " ea ON ea.event_id=ed.id ";
    $sql .= " WHERE ea.id = '" . $attendee_id . "' ";
    $data->event = $wpdb->get_row($sql, OBJECT);
    //Get the attendee record
    $sql = "SELECT ea.* FROM " . EVENTS_ATTENDEE_TABLE . " ea WHERE ea.id = '" . $attendee_id . "' ";
    $data->attendee = $wpdb->get_row($sql, OBJECT);
    //Get the primary/first attendee
    $data->primary_attendee = espresso_is_primary_attendee($data->attendee->id) == true ? true : false;
    $data->event->event_meta = unserialize($data->event->event_meta);
    //Venue variables
    if (isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y') {
        $data->event->venue_meta = unserialize($data->event->venue_meta);
        //Debug
        //echo "<pre>".print_r($data->event->venue_meta,true)."</pre>";
        $data->event->venue_url = $data->event->venue_meta['website'];
        $data->event->venue_phone = $data->event->venue_meta['phone'];
        $data->event->venue_image = '<img src="' . $data->event->venue_meta['image'] . '" />';
        $data->event->venue_name = $data->event->venue_name;
        $data->event->address = $data->event->venue_address;
        $data->event->address2 = $data->event->venue_address2;
        $data->event->city = $data->event->venue_city;
        $data->event->state = $data->event->venue_state;
        $data->event->zip = $data->event->venue_zip;
        $data->event->country = $data->event->venue_country;
    } else {
        $data->event->venue_name = $data->event->venue_title;
    }
    //Build the table to hold the event and attendee info
    $data->table_open = '<table width="100%" border="1" cellpadding = "5" cellspacing="5" style="border-collapse:collapse;">';
    $data->table_heading = "<tr><th>" . __('Event Name', 'event_espresso') . "</th><th>" . __('Date', 'event_espresso') . "</th><th>" . __('Time', 'event_espresso') . "</th><th>" . __('Location', 'event_espresso') . "</th></tr>";
    $data->table_close = "</table>";
    //Clear ticket data
    $data->qr_code = '';
    $data->ticket_link = '';
    $data->admin_ticket_link = '';
    //Old ticketing system
    if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/template.php")) {
        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/functions.php")) {
            include_once EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/functions.php";
            $data->qr_code = espresso_qr_code(array('attendee_id' => $data->attendee->id, 'event_name' => stripslashes_deep($data->event->event_name), 'attendee_first' => $data->attendee->fname, 'attendee_last' => $data->attendee->lname, 'registration_id' => $data->attendee->registration_id, 'event_code' => $data->event->event_code, 'ticket_type' => $data->attendee->price_option, 'event_time' => $data->attendee->event_time, 'amount_pd' => espresso_attendee_price(array('registration_id' => $data->attendee->registration_id, 'reg_total' => true))));
        }
        $data->ticket_link = espresso_ticket_links($data->attendee->registration_id, $data->attendee->id);
        $data->admin_ticket_link = $data->ticket_link;
    }
    //New ticketing system version 2.0
    if (function_exists('espresso_ticket_launch')) {
        $data->qr_code = espresso_ticket_qr_code(array('attendee_id' => $data->attendee->id, 'event_name' => stripslashes_deep($data->event->event_name), 'attendee_first' => $data->attendee->fname, 'attendee_last' => $data->attendee->lname, 'registration_id' => $data->attendee->registration_id, 'event_code' => $data->event->event_code, 'ticket_type' => $data->attendee->price_option, 'event_time' => $data->attendee->event_time, 'amount_pd' => espresso_attendee_price(array('registration_id' => $data->attendee->registration_id, 'reg_total' => true))));
        $data->ticket_link = espresso_ticket_links($data->attendee->registration_id, $data->attendee->id);
        $data->admin_ticket_link = $data->ticket_link;
    }
    //certificate system
    if (function_exists('espresso_certificate_launch')) {
        $data->certificate_link = espresso_certificate_links($data->attendee->registration_id, $data->attendee->id);
        $data->admin_certificate_link = $data->certificate_link;
    }
    //Build the address
    $data->location = ($data->event->address != '' ? $data->event->address : '') . ($data->event->address2 != '' ? '<br />' . $data->event->address2 : '') . ($data->event->city != '' ? '<br />' . $data->event->city : '') . ($data->event->state != '' ? ', ' . $data->event->state : '') . ($data->event->zip != '' ? '<br />' . $data->event->zip : '') . ($data->event->country != '' ? '<br />' . $data->event->country : '');
    //Build Google map link
    $data->google_map_link = espresso_google_map_link(array('address' => $data->event->address, 'city' => $data->event->city, 'state' => $data->event->state, 'zip' => $data->event->zip, 'country' => $data->event->country));
    //Registration URL
    $data->event_url = espresso_reg_url($data->event->id);
    $data->event_link = '<a href="' . $data->event_url . '">' . stripslashes_deep($data->event->event_name) . '</a>';
    //Venue name
    if (!isset($data->event->venue_name)) {
        $data->event->venue_name = '';
    }
    //Table of events registered for
    $data->event_table .= "\n\t\t<tr>\n\t\t\t<td>" . stripslashes_deep($data->event->event_name) . " | " . $data->attendee->price_option . "</td>\n\t\t\t<td>" . event_date_display($data->attendee->start_date) . ' - ' . event_date_display($data->attendee->end_date) . "</td>\n\t\t\t<td>" . event_date_display($data->attendee->event_time, get_option('time_format')) . " - " . event_date_display($data->attendee->end_time, get_option('time_format')) . "</td>\n\t\t\t<td>" . $data->event->venue_name . "<br />{$data->location} <br />{$data->google_map_link}</td>" . ($data->attendee->quantity > 0 ? '<td>' . $data->attendee->quantity . __(' attendees', 'event_espresso') . '</td>' : '') . "</tr>";
    //Output custom questions
    if (function_exists('event_espresso_custom_questions_output')) {
        //Create the question display
        $email_questions_r = event_espresso_custom_questions_output(array('attendee_id' => $data->attendee->id, 'all_questions' => TRUE));
        if ($email_questions_r != '') {
            $data->email_questions = '<tr><td colspan = "6">' . $email_questions_r . '</td></tr>';
        }
        $data->event_table .= $data->email_questions;
    }
    //Payment URL
    $payment_url = get_option('siteurl') . "/?page_id=" . $org_options['return_url'] . "&amp;registration_id=" . $data->attendee->registration_id;
    $data->payment_link = '<a href="' . $payment_url . '">' . __('View Your Payment Details') . '</a>';
    // download link
    $data->invoice_link = '<a href="' . home_url() . '/?download_invoice=true&amp;attendee_id=' . $data->attendee->id . '&amp;registration_id=' . $data->attendee->registration_id . '" target="_blank">' . __('Download PDF Invoice', 'event_espresso') . '</a>';
    //Edit attendee link
    $data->edit_attendee = espresso_edit_attendee($data->attendee->registration_id, $data->attendee->id, $data->attendee->event_id, 'attendee', 'Edit Registration Details');
    $data->email_subject = !$data->multi_reg ? $data->event->event_name : $org_options['organization'] . __(' registration confirmation', 'event_espresso');
    //Build invoice email
    if ($custom_data_email_type == 'invoice') {
        $data->email_subject = $custom_data_invoice_subject;
        $data->event->conf_mail = $custom_data_invoice_message;
        $data->event->send_mail = 'Y';
        $data->event->email_id = empty($_REQUEST['email_name']) ? '' : $_REQUEST['email_name'];
    }
    //Build payment email
    if ($custom_data_email_type == 'payment') {
        $data->email_subject = $custom_data_payment_subject;
        $data->event->conf_mail = $custom_data_payment_message;
        $data->event->send_mail = 'Y';
    }
    //Build reminder email
    if ($custom_data_email_type == 'reminder') {
        $data->email_subject = $custom_data_email_subject;
        $data->event->conf_mail = $custom_data_email_text;
        $data->event->send_mail = 'Y';
        $data->event->email_id = $custom_data_email_id > 0 ? $custom_data_email_id : '';
    }
    return $data;
}
    function event_espresso_my_events()
    {
        global $espresso_premium;
        if ($espresso_premium != true) {
            return;
        }
        global $wpdb, $org_options;
        global $ticketing_installed;
        require_once 'user_vars.php';
        if (!is_user_logged_in()) {
            if ($login_page != '') {
                printf('<p>Please <a href="%s">log in</a> to view the events you are registered to attend.</p>', $login_page);
            } else {
                echo '<p>You must be logged in to view this page.</p>';
                return;
            }
        }
        ?>
		
		<div id="configure_organization_form" class="wrap meta-box-sortables ui-sortable">
		<div id="event_reg_theme" class="wrap">
		<div id="icon-options-event" class="icon32"></div><h2><?php 
        echo _e('My Events Management', 'event_espresso');
        ?>
</h2>
		<div id="poststuff" class="metabox-holder">
	<?php 
        if (isset($_POST['cancel_registration'])) {
            if (is_array($_POST['checkbox'])) {
                while (list($key, $value) = each($_POST['checkbox'])) {
                    $del_attendee = $wpdb->prepare("DELETE FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id = %d", $key);
                    $wpdb->query($del_attendee);
                    $del_attendee_member_rel = $wpdb->prepare("DELETE FROM " . EVENTS_MEMBER_REL_TABLE . " WHERE attendee_id = %d and user_id = %d", $key, $userid);
                    $wpdb->query($del_attendee_member_rel);
                }
            }
            ?>
		<div id="message" class="updated fade"><p><strong><?php 
            _e('The event(s) have been successfully removed from your account.', 'event_espresso');
            ?>
</strong></p></div>
	<?php 
        }
        ?>
	<form id="form1" name="form1" method="post" action="<?php 
        echo $_SERVER["REQUEST_URI"];
        ?>
">
	<div style="clear:both; margin-bottom:30px;"></div>
	<table id="table" class="widefat my_events_table" width="100%"> 
		<thead>
			<tr>
			  <th class="manage-column column-cb check-column" id="cb" scope="col" style="width:5%;"></th>
			  <th class="manage-column column-title" id="name" scope="col" title="Click to Sort" style="width:10%;"><span><?php 
        _e('Event Name', 'event_espresso');
        ?>
</span><span class="sorting-indicator"></span></th>
			  <th class="manage-column column-title" id="event" scope="col" title="Click to Sort" style="width: 10%;">
				<span><?php 
        _e('Type', 'event_espresso');
        ?>
</span>
				<span class="sorting-indicator"></span>
			  </th>
			  <th class="manage-column column-author" id="start" scope="col" title="Click to Sort" style="width:10%;"><span><?php 
        _e('Date', 'event_espresso');
        ?>
</span><span class="sorting-indicator"></span></th>
			  <th class="manage-column column-date" id="begins" scope="col" title="Click to Sort" style="width:5%;"><span><?php 
        _e('Time', 'event_espresso');
        ?>
</span><span class="sorting-indicator"></span></th>
			  <th class="manage-column column-date" id="status" scope="col" title="Click to Sort" style="width:5%;"><span><?php 
        _e('Status', 'event_espresso');
        ?>
</span><span class="sorting-indicator"></span></th>
			  <th class="manage-column column-date" id="attendees" scope="col" title="Click to Sort" style="width:5%;"><span><?php 
        _e('Cost', 'event_espresso');
        ?>
</span><span class="sorting-indicator"></span></th>
			  <th class="manage-column column-date" id="invoice" scope="col" style="width:5%;"><?php 
        _e('Invoice', 'event_espresso');
        ?>
</th>
			  <?php 
        echo $ticketing_installed == true ? '<th class="manage-column column-author" id="ticket" scope="col" style="width:10%;">' . __('Ticket', 'event_espresso') . '</th>' : '';
        ?>
			</tr>
	</thead>
		<tbody>
	<?php 
        $wpdb->get_results("SELECT id FROM " . EVENTS_MEMBER_REL_TABLE . " WHERE user_id = '" . $current_user->ID . "'");
        if ($wpdb->num_rows > 0) {
            $events = $wpdb->get_results("SELECT e.id event_id, e.event_name, e.event_code, e.start_date, e.event_desc, e.display_desc, a.id attendee_id, a.event_time start_time, a.payment_status, a.payment_date, a.amount_pd, u.user_id user_id, a.registration_id, a.fname, a.lname, a.price_option, a.event_time\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . EVENTS_ATTENDEE_TABLE . " a\n\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN " . EVENTS_MEMBER_REL_TABLE . " u ON u.attendee_id = a.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN " . EVENTS_DETAIL_TABLE . " e ON e.id = u.event_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.user_id = '" . $current_user->ID . "'");
            foreach ($events as $event) {
                $event_id = $event->event_id;
                $event_code = $event->event_code;
                $attendee_id = $event->attendee_id;
                $registration_id = $event->registration_id;
                $lname = $event->lname;
                $fname = $event->fname;
                $event_name = $event->event_name;
                $start_date = $event->start_date;
                $start_time = $event->start_time;
                $event_desc = $event->event_desc;
                $display_desc = $event->display_desc;
                $payment_status = $event->payment_status;
                $amount_pd = espresso_attendee_price(array('attendee_id' => $attendee_id));
                $payment_date = $event->payment_date;
                $ticket_type = $event->price_option;
                if ($payment_status == '') {
                    $payment_link = get_option('siteurl') . "/?page_id=" . $org_options['return_url'] . "&id=" . $attendee_id;
                    $payment_status = '<a href="' . $payment_link . '">Pay Now</a>';
                }
                $event_url = home_url() . "/?page_id=" . $org_options['event_page_id'] . "&regevent_action=register&event_id=" . $event_id;
                $event_link = '<a class="row-title" href="' . $event_url . '">' . stripslashes_deep($event->event_name) . '</a>';
                //Build the payment link
                $payment_url = home_url() . "/?page_id=" . $org_options['return_url'] . "&amp;registration_id=" . $registration_id;
                //$payment_link = '<a href="' . $payment_url . '" title="'.__('View Your Payment Details').'">' . event_espresso_paid_status_icon( $payment_status ) . '</a>';
                //Deprecated ticketing system support
                //If the custom ticket is available, load the template file
                if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/template.php")) {
                    if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/functions.php")) {
                        include_once EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/functions.php";
                        $qr_code = espresso_qr_code(array('attendee_id' => $attendee_id, 'event_name' => stripslashes_deep($event_name), 'attendee_first' => $fname, 'attendee_last' => $lname, 'registration_id' => $registration_id, 'event_code' => $event_code, 'ticket_type' => $ticket_type, 'event_time' => $event_time, 'amount_pd' => $amount_pd));
                    }
                    //Build the ticket link
                    $ticket_url = home_url() . "/?download_ticket=true&amp;id=" . $attendee_id . "&amp;registration_id=" . $registration_id;
                    $ticket_link = '<a href="' . $ticket_url . '">' . __('Download Ticket Now!') . '</a>';
                }
                //New ticketing system suport
                if (function_exists('espresso_ticket_launch')) {
                    $ticket_link = espresso_ticket_links($registration_id, $attendee_id);
                }
                ?>
		<tr>
		<td><input name="checkbox[<?php 
                echo $attendee_id;
                ?>
]" type="checkbox"  title="Cancel registration for <?php 
                echo $event_name;
                ?>
"></td>
				  <td class="post-title page-title column-title"><strong><?php 
                echo $event_link;
                ?>
</strong> </td>
				  <td class="post-title page-title column-title"><?php 
                echo $ticket_type;
                ?>
</td>
				  <td class="date column-date"><?php 
                echo event_date_display($start_date);
                ?>
</td>
				  <td class="date column-date"><?php 
                echo $start_time;
                ?>
</td>
				  <td class="date column-date"><?php 
                echo '<a target="_blank" href="' . $payment_url . '" title="' . __('View Your Payment Details') . '">';
                event_espresso_paid_status_icon($payment_status) . '</a>';
                ?>
</td>
				  <td class="date column-date"><?php 
                echo $org_options['currency_symbol'];
                echo $amount_pd;
                ?>
</td>
				  <td class="date column-date"><a href="<?php 
                echo home_url();
                ?>
/?download_invoice=true&amp;admin=true&amp;registration_id=<?php 
                echo $registration_id;
                ?>
" target="_blank"  title="<?php 
                _e('Download Invoice', 'event_espresso');
                ?>
"><img src="<?php 
                echo EVENT_ESPRESSO_PLUGINFULLURL;
                ?>
images/icons/page_white_acrobat.png" width="16" height="16" alt="<?php 
                _e('Download Invoice', 'event_espresso');
                ?>
" /></a></td>
				  <?php 
                echo $ticketing_installed == true ? '<td class="post-title page-title column-title">' . $ticket_link . '</td>' : '';
                ?>
				  </tr>
		<?php 
            }
        }
        ?>
			  </tbody>
			  </table>
			  <div class="bottom_settings" style="clear:both; margin-bottom:30px;">
			<input type="checkbox" name="sAll" onclick="selectAll(this)" /> <strong><?php 
        _e('Check All', 'event_espresso');
        ?>
</strong> 
			<input name="cancel_registration" type="submit" class="button-secondary" id="cancel_registration" value="<?php 
        _e('Cancel Registration', 'event_espresso');
        ?>
" onclick="return confirmDelete();"> <a style="margin-left:20px" class="button-primary"  onclick="window.location='<?php 
        echo admin_url();
        ?>
profile.php#event_espresso_profile'"><?php 
        _e('Your Profile', 'event_espresso');
        ?>
</a>
		</div>
			</form>
	   </div>
	</div>       
			 </div> 
	
	<script>
	jQuery(document).ready(function($) {						
			
		/* show the table data */
		var mytable = $('#table').dataTable( {
				"bStateSave": true,
				"sPaginationType": "full_numbers",
	
				"oLanguage": {	"sSearch": "<strong><?php 
        _e('Live Search Filter', 'event_espresso');
        ?>
:</strong>",
								"sZeroRecords": "<?php 
        _e('No Records Found!', 'event_espresso');
        ?>
" },
				"aoColumns": [
								{ "bSortable": false },
								 null,
								 null,
								 null,
								 null,
								 null,
								 null,
								 { "bSortable": false },
								<?php 
        echo $ticketing_installed == true ? '{ "bSortable": false }' : '';
        ?>
							]
	
		} );
		
	} );
	</script>	
	<?php 
    }
function enter_attendee_payments()
{
    global $wpdb, $org_options;
    $event_id = $_REQUEST['event_id'];
    $today = date("d-m-Y");
    //Added by Imon
    $multi_reg = false;
    $registration_id = $_REQUEST['registration_id'];
    $registration_ids = array();
    $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 * from " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " where primary_registration_id = '{$registration_id}' ", ARRAY_A);
        $multi_reg = true;
    }
    switch ($_REQUEST['form_action']) {
        //Add payment info
        case 'payment':
            if (isset($_REQUEST['attendee_action']) && $_REQUEST['attendee_action'] == 'post_payment') {
                //Added by Imon
                $primary_row = $wpdb->get_row("select id from " . EVENTS_ATTENDEE_TABLE . " where registration_id = '{$registration_id}' order by id limit 0,1 ");
                $primary_attendee_id = $primary_row->id;
                // GET the primary attendee id because amount paid info is kept with the primary attendee
                $payment_status = isset($_REQUEST['payment_status']) ? $_REQUEST['payment_status'] : '';
                $txn_type = isset($_REQUEST['txn_type']) ? $_REQUEST['txn_type'] : '';
                $txn_id = isset($_REQUEST['txn_id']) ? $_REQUEST['txn_id'] : '';
                //$quantity = isset($_REQUEST[ 'quantity' ]) ? $_REQUEST[ 'quantity' ]:'';
                $amount_pd = isset($_REQUEST['amount_pd']) ? $_REQUEST['amount_pd'] : '';
                $payment_date = isset($_REQUEST['payment_date']) ? $_REQUEST['payment_date'] : '';
                $coupon_code = isset($_REQUEST['coupon_code']) ? $_REQUEST['coupon_code'] : '';
                //Added/updated by Imon
                //Update payment status information for primary attendee
                $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET payment_status = '{$payment_status}', txn_type = '{$txn_type}', txn_id = '{$txn_id}', amount_pd = '{$amount_pd}', payment_date ='{$payment_date}',  coupon_code ='{$coupon_code}' WHERE registration_id ='" . $registration_id . "' and id = {$primary_attendee_id} ";
                $wpdb->query($sql);
                if (count($registration_ids) > 0) {
                    foreach ($registration_ids as $reg_id) {
                        // Update payment status information for all attendees
                        $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET payment_status = '{$payment_status}', txn_type = '{$txn_type}', txn_id = '{$txn_id}', payment_date ='{$payment_date}', coupon_code ='{$coupon_code}' WHERE registration_id ='" . $reg_id['registration_id'] . "' ";
                        $wpdb->query($sql);
                    }
                } else {
                    // Update payment status information for all attendees
                    $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET payment_status = '{$payment_status}', txn_type = '{$txn_type}', txn_id = '{$txn_id}', payment_date ='{$payment_date}', coupon_code ='{$coupon_code}' WHERE registration_id ='" . $registration_id . "' ";
                    $wpdb->query($sql);
                }
                //Send Payment Recieved Email
                if ($_REQUEST['send_payment_rec'] == "send_message") {
                    /*
                     * @todo Do we send an email to each attendee in a group or just the main?
                     */
                    //event_espresso_send_payment_notification( $id );
                    //Added by Imon
                    if (count($registration_ids) > 0) {
                        foreach ($registration_ids as $reg_id) {
                            event_espresso_send_payment_notification(array('registration_id' => $reg_id['registration_id']));
                        }
                    } else {
                        event_espresso_send_payment_notification(array('registration_id' => $registration_id));
                    }
                }
            }
            break;
            //Send Invoice
        //Send Invoice
        case 'send_invoice':
            //Added by Imon
            if ($org_options["use_attendee_pre_approval"] == "Y") {
                $pre_approve = $_REQUEST['pre_approve'];
                if (count($registration_ids) > 0) {
                    foreach ($registration_ids as $reg_id) {
                        $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET pre_approve = '{$pre_approve}' WHERE registration_id ='" . $reg_id['registration_id'] . "'";
                        $wpdb->query($sql);
                    }
                } else {
                    $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET pre_approve = '{$pre_approve}' WHERE registration_id ='" . $registration_id . "'";
                    $wpdb->query($sql);
                }
            } else {
                $pre_approve = 0;
            }
            if ($pre_approve == "0") {
                if (count($registration_ids) > 0) {
                    foreach ($registration_ids as $reg_id) {
                        event_espresso_send_invoice($reg_id['registration_id'], $_REQUEST['invoice_subject'], $_REQUEST['invoice_message']);
                    }
                } else {
                    event_espresso_send_invoice($registration_id, $_REQUEST['invoice_subject'], $_REQUEST['invoice_message']);
                }
                echo '<div id="message" class="updated fade"><p><strong>' . __('Invoice Sent', 'event_espresso') . '</strong></p></div>';
            }
            break;
    }
    //Show the forms.
    // $id = $registration_id ;
    $attendees = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id ='%s' ORDER BY ID LIMIT 1", $registration_id));
    foreach ($attendees as $attendee) {
        $id = $attendee->id;
        //$registration_id = $attendee->registration_id;//Removed by Imon
        $lname = $attendee->lname;
        $fname = $attendee->fname;
        $address = $attendee->address;
        $city = $attendee->city;
        $state = $attendee->state;
        $zip = $attendee->zip;
        $email = $attendee->email;
        $phone = $attendee->phone;
        $date = $attendee->date;
        $payment_status = $attendee->payment_status;
        $txn_type = $attendee->txn_type;
        $txn_id = $attendee->txn_id;
        $amount_pd = $attendee->amount_pd;
        $quantity = $attendee->quantity;
        $payment_date = $attendee->payment_date;
        $event_id = $attendee->event_id;
        $coupon_code = $attendee->coupon_code;
        $pre_approve = $attendee->pre_approve;
        $start_date = $attendee->start_date;
        $event_time = $attendee->event_time;
    }
    $events = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE id='%d'", $event_id));
    foreach ($events as $event) {
        $event_id = $event->id;
        $event_name = $event->event_name;
        $event_desc = $event->event_desc;
        $event_description = $event->event_desc;
        $event_identifier = $event->event_identifier;
        $cost = isset($event->event_cost) ? $event->event_cost : 0;
        $active = $event->is_active;
    }
    $event_date = event_date_display($start_date . ' ' . $event_time, get_option('date_format') . ' g:i a');
    $total_paid = espresso_attendee_price(array('registration_id' => $_REQUEST['registration_id'], 'session_total' => true));
    if (isset($_REQUEST['status']) && $_REQUEST['status'] == 'saved') {
        ?>

        <div id="message" class="updated fade">
          <p><strong>
            <?php 
        _e('Payment details saved for', 'event_espresso');
        ?>
            <?php 
        echo $fname;
        ?>
 <?php 
        echo $lname;
        ?>
.
            <?php 
        if (isset($_REQUEST['send_payment_rec']) && $_REQUEST['send_payment_rec'] == "send_message") {
            ?>
            <?php 
            _e('Payment notification has been sent.', 'event_espresso');
            ?>
            <?php 
        }
        ?>
            </strong></p>
        </div>
<?php 
    }
    ?>
<div class="metabox-holder">
<div class="postbox">
<?php 
    if (!$multi_reg) {
        ?>
      <h3>
      <?php 
        _e('Name:', 'event_espresso');
        ?>
        <?php 
        echo $fname;
        ?>
 <?php 
        echo $lname;
        ?>
 |
        <?php 
        _e('ID:', 'event_espresso');
        ?>
 <?php 
        echo $id;
        ?>
 |

        <?php 
        _e('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>
<?php 
    } else {
        ?>
  <h3>
    <?php 
        echo __('Multiple Registration Payment 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>
  <?php 
    }
    ?>
  <div class="inside">
    <table width="100%" border="0">
      <tr>
        <td><strong>
          <?php 
    _e('Payment Details', 'event_espresso');
    ?>
          </strong></td>
        <td><strong>
          <?php 
    _e('Invoice/Payment Reminder', 'event_espresso');
    ?>
          </strong></td>
      </tr>
      <tr>
        <td valign="top">
        <?php 
    if (count($registration_ids) > 0) {
        echo '<p><strong>' . __('Registration Ids:', 'event_espresso') . '</strong></p>';
        echo '<ul>';
        foreach ($registration_ids as $reg_id) {
            //TODO:Display cost per registration id. At the moment it is not possible to display price per registration id because discount is calculated for total amount [IMON]
            echo '<li># ' . $reg_id['registration_id'] . ' [ <a href="admin.php?page=events&event_admin_reports=edit_attendee_record&event_id=' . $event_id . '&registration_id=' . $reg_id['registration_id'] . '&form_action=edit_attendee">' . __('View/Edit Registration', 'event_espresso') . '</a> ]</li>';
        }
    } else {
        echo '<p><strong>' . __('Registration Id:', 'event_espresso') . '</strong></p>';
        //TODO:Display cost per registration id. At the moment it is not possible to display price per registration id because discount is calculated for total amount [IMON]
        echo '<p># ' . $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">' . __('View/Edit Registration', 'event_espresso') . '</a> ]</p>';
    }
    echo '</ul><hr style="width:90%; margin:20px 0;" align="left" />';
    ?>
        <form method="POST" action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
&status=saved" class="espresso_form">
            <fieldset>
              <ul>
                <li>
                <label for="payment_status">
                  <?php 
    _e('Payment Status:', 'event_espresso');
    ?>
                </label>
<?php 
    $values = array(array('id' => '', 'text' => __('None', 'event_espresso')), array('id' => 'Completed', 'text' => __('Completed', 'event_espresso')), array('id' => 'Pending', 'text' => __('Pending', 'event_espresso')), array('id' => 'Payment Declined', 'text' => __('Payment Declined', 'event_espresso')), array('id' => 'Incomplete', 'text' => __('Incomplete', 'event_espresso')));
    echo select_input('payment_status', $values, $payment_status);
    ?>
                </li>
                <li>
                  <label for="txn_type">
                    <?php 
    _e('Transaction Type:', 'event_espresso');
    ?>
                  </label>
                  <?php 
    $txn_values = array(array('id' => '', 'text' => __('N/A', 'event_espresso')), array('id' => 'web_accept', 'text' => espresso_payment_type('web_accept')), array('id' => 'CC', 'text' => __('Credit Card', 'event_espresso')), array('id' => 'INV', 'text' => espresso_payment_type('INV')), array('id' => 'OFFLINE', 'text' => espresso_payment_type('OFFLINE')));
    echo select_input('txn_type', $txn_values, $txn_type);
    ?>
                </li>
                <li>
                  <label>
                    <?php 
    _e('Transaction ID:', 'event_espresso');
    ?>
                  </label>
                  <input type="text" name="txn_id" size="45" value ="<?php 
    echo $txn_id;
    ?>
" />
                </li>
                <li>
                  <label>
                    <?php 
    _e('Amount:', 'event_espresso');
    ?>
                  </label>
                  <?php 
    //TODO:Need to check this after pricing module is done [IMON]
    echo $org_options['currency_symbol'];
    ?>
                    <input style="width:100px;" readonly="true" type="text" name="amount_pd" size="20" value ="<?php 
    echo $total_paid;
    ?>
" /> <?php 
    echo ' [ <a href="admin.php?page=events&event_admin_reports=edit_attendee_record&event_id=' . $event_id . '&registration_id=' . $registration_id . '&form_action=edit_attendee&show_payment=true">' . __('Edit Payment', 'event_espresso') . '</a> ] ';
    ?>
                </li>
                <li>
                  <label>
                    <?php 
    _e('Coupon Code:', 'event_espresso');
    ?>
                    </label>
                  <input type="text" name="coupon_code" size="45" value ="<?php 
    echo $coupon_code;
    ?>
" />
                </li>
                <?php 
    /*?><li>
        <label>
          <?php _e( 'How Many People:', 'event_espresso' ); ?>
        </label>
        <input type="text" name="quantity" size="45" value ="<?php echo espresso_count_attendees_for_registration($id); ?>" />
      </li><?php */
    ?>
                <li>
					<label><?php 
    _e('Date Paid:', 'event_espresso');
    ?>
</label>
					<input type="text" name="payment_date" size="45" value ="<?php 
    echo !empty($payment_date) ? event_date_display($payment_date) : event_date_display($today);
    ?>
" />
                </li>
                <li>
                  <label>
                    <?php 
    _e('Do you want to send a payment recieved notice to registrant?', 'event_espresso');
    ?>
                  </label>
                  <input type="radio" name="send_payment_rec" value="send_message">
                  <?php 
    _e('Yes', 'event_espresso');
    ?>
                  <input type="radio" name="send_payment_rec" checked value="N">
                  <?php 
    _e('No', 'event_espresso');
    ?>
                </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="form_action" value="payment">
                <input type="hidden" name="attendee_pay" value="paynow">
                <input type="hidden" name="event_id" value="<?php 
    echo $event_id;
    ?>
">
                <input type="hidden" name="attendee_action" value="post_payment">
                <li>
                  <input type="submit" name="Submit" value="Update Payment">
                </li>
              </ul>
            </fieldset>
          </form></td>
        <td valign="top"><form method='post' action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
&status=invoiced">
            <input type="hidden" name="id" value="<?php 
    echo $id;
    ?>
">
            <input type="hidden" name="form_action" value="send_invoice">
            <input type="hidden" name="event_id" value="<?php 
    echo $event_id;
    ?>
">
            <ul>
              <li>
                <?php 
    _e('Use a ', 'event_espresso');
    ?>
                <a href="admin.php?page=event_emails" target="_blank">
                <?php 
    _e('pre-existing email', 'event_espresso');
    ?>
                </a>? <?php 
    echo espresso_db_dropdown('id', 'email_name', EVENTS_EMAIL_TABLE, 'email_name', '', 'desc') . ' <a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=email_manager_info"><img src="' . EVENT_ESPRESSO_PLUGINFULLURL . '/images/question-frame.png" width="16" height="16" /></a>';
    ?>
 </li>
              <li>
                <?php 
    _e('OR', 'event_espresso');
    ?>
              </li>
              <li>
                <?php 
    _e('Create a custom email:', 'event_espresso');
    ?>
              </li>
              <li>
                <?php 
    _e('Invoice Subject', 'event_espresso');
    ?>
                :
                <input type="text" name="invoice_subject" size="45" value="<?php 
    _e('Payment Reminder for [event]', 'event_espresso');
    ?>
" />
              </li>
              <li>
                <p>
                  <?php 
    _e('Message:', 'event_espresso');
    ?>
                </p>
               
				<div class="postbox">
									 <?php 
    $email_content = __('Dear [fname] [lname], <p>Our records show that we have not received your payment of [cost] for [event_link].</p> <p>Please visit [payment_url] to view your payment options.</p><p>[invoice_link]</p><p>Sincerely,<br />' . ($Organization = $org_options['organization'] . '</p>'), 'event_espresso');
    if (function_exists('wp_editor')) {
        $args = array("textarea_rows" => 5, "textarea_name" => "invoice_message", "editor_class" => "my_editor_custom");
        wp_editor(espresso_admin_format_content($email_content), "invoice_message", $args);
    } else {
        echo '<textarea name="invoice_message" class="theEditor" id="invoice_message">' . espresso_admin_format_content($email_content) . '</textarea>';
        espresso_tiny_mce();
    }
    ?>
										<table id="email-confirmation-form" cellspacing="0">
											<tbody>
												<tr>
													<td class="aer-word-count"></td>
													<td class="autosave-info"><span>&nbsp;</span></td>
												</tr>
											</tbody>
										</table>
										<p><a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=custom_email_info">
														<?php 
    _e('View Custom Email Tags', 'event_espresso');
    ?>
</a> | <a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=custom_email_example">
														<?php 
    _e('Email Example', 'event_espresso');
    ?>
</a></p>
									</div>
									
              </li>
              <?php 
    if ($org_options["use_attendee_pre_approval"] == "Y") {
        $pre_approve = is_attendee_approved($event_id, $id) == true ? 1 : 0;
        ?>
              <li>
                <?php 
        _e("Attendee approved?", "event_espresso");
        ?>
                :
                <?php 
        $pre_approval_values = array(array('id' => '0', 'text' => __('Yes', 'event_espresso')), array('id' => '1', 'text' => __('No', 'event_espresso')));
        echo select_input("pre_approve", $pre_approval_values, $pre_approve);
        ?>
                <br />
                <?php 
        _e("(If not approved then invoice will not be sent.)", "event_espresso");
        ?>
              </li>
              <?php 
    }
    ?>
              <li>
                <input type="submit" name="Submit" value="Send Invoice">
              </li>
            </ul>
          </form></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>
<?php 
    //This show what tags can be added to a custom email.
    event_espresso_custom_email_info();
    //event_list_attendees();
}
function event_espresso_my_events()
{
    global $espresso_premium;
    if ($espresso_premium != true) {
        return;
    }
    global $wpdb, $org_options;
    global $ticketing_installed;
    //$wpdb->show_errors();
    require_once 'user_vars.php';
    ?>
    
	<div id="configure_organization_form" class="wrap meta-box-sortables ui-sortable">
  	<div id="event_reg_theme" class="wrap">
	<div id="icon-options-event" class="icon32"></div><h2><?php 
    echo _e('My Events Management', 'event_espresso');
    ?>
</h2>
    <div id="poststuff" class="metabox-holder">
<?php 
    if ($_POST['cancel_registration']) {
        if (is_array($_POST['checkbox'])) {
            while (list($key, $value) = each($_POST['checkbox'])) {
                $del_id = $key;
                //Delete discount data
                $sql = "DELETE FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id='{$del_id}'";
                $wpdb->query($sql);
                $sql = "DELETE FROM " . EVENTS_MEMBER_REL_TABLE . " WHERE attendee_id='{$del_id}'";
                $wpdb->query($sql);
            }
        }
        ?>
	<div id="message" class="updated fade"><p><strong><?php 
        _e('Your event(s) have been successfully removed from your account.', 'event_espresso');
        ?>
</strong></p></div>
<?php 
    }
    ?>
<form id="form1" name="form1" method="post" action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
">

<table id="table" class="widefat fixed" width="100%"> 
	<thead>
		<tr>
		  <th class="manage-column column-cb check-column" id="cb" scope="col" style="width:5%;"></th>
		  <th class="manage-column column-title" id="name" scope="col" title="Click to Sort" style="width:10%;"><span><?php 
    _e('Event Name', 'event_espresso');
    ?>
</span><span class="sorting-indicator"></span></th>
          <th class="manage-column column-title" id="event" scope="col" title="Click to Sort" style="width: 10%;">
		  	<span><?php 
    _e('Option', 'event_espresso');
    ?>
</span>
            <span class="sorting-indicator"></span>
          </th>
		  <th class="manage-column column-author" id="start" scope="col" title="Click to Sort" style="width:10%;"><span><?php 
    _e('Start Date', 'event_espresso');
    ?>
</span><span class="sorting-indicator"></span></th>
          <th class="manage-column column-date" id="begins" scope="col" title="Click to Sort" style="width:10%;"><span><?php 
    _e('Start Time', 'event_espresso');
    ?>
</span><span class="sorting-indicator"></span></th>
          <th class="manage-column column-date" id="status" scope="col" title="Click to Sort" style="width:10%;"><span><?php 
    _e('Payment Status', 'event_espresso');
    ?>
</span><span class="sorting-indicator"></span></th>
          <th class="manage-column column-date" id="attendees" scope="col" title="Click to Sort" style="width:10%;"><span><?php 
    _e('Cost', 'event_espresso');
    ?>
</span><span class="sorting-indicator"></span></th>
          <?php 
    echo $ticketing_installed == true ? '<th class="manage-column column-author" id="ticket" scope="col" title="Click to Sort" style="width:20%;">' . __('Ticket', 'event_espresso') . '</th>' : '';
    ?>
		</tr>
</thead>
    <tbody>
<?php 
    $wpdb->get_results("SELECT id FROM " . EVENTS_MEMBER_REL_TABLE . " WHERE user_id = '" . $current_user->ID . "'");
    if ($wpdb->num_rows > 0) {
        $events = $wpdb->get_results("SELECT e.id event_id, e.event_name, e.event_code, e.start_date, e.event_desc, e.display_desc, a.id attendee_id, a.event_time start_time, a.payment_status, a.payment_date, a.amount_pd, u.user_id user_id, a.registration_id, a.lname, a.lname, a.price_option, a.event_time\n\t\t\t\t\t\t\t\t\t\t\t \tFROM " . EVENTS_ATTENDEE_TABLE . " a\n\t\t\t\t\t\t\t\t\t\t\t\tJOIN " . EVENTS_MEMBER_REL_TABLE . " u ON u.attendee_id = a.id\n\t\t\t\t\t\t\t\t\t\t\t\tJOIN " . EVENTS_DETAIL_TABLE . " e ON e.id = u.event_id\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.user_id = '" . $current_user->ID . "'");
        foreach ($events as $event) {
            $event_id = $event->event_id;
            $event_code = $event->event_code;
            $attendee_id = $event->attendee_id;
            $registration_id = $event->registration_id;
            $lname = $attendee->lname;
            $fname = $attendee->fname;
            $event_name = $event->event_name;
            $start_date = $event->start_date;
            $start_time = $event->start_time;
            $event_desc = $event->event_desc;
            $display_desc = $event->display_desc;
            $payment_status = $event->payment_status;
            $amount_pd = espresso_attendee_price(array('attendee_id' => $attendee_id));
            $payment_date = $event->payment_date;
            $ticket_type = $event->price_option;
            if ($payment_status == '') {
                $payment_link = get_option('siteurl') . "/?page_id=" . $org_options['return_url'] . "&id=" . $attendee_id;
                $payment_status = '<a href="' . $payment_link . '">Pay Now</a>';
            }
            $event_url = home_url() . "/?page_id=" . $org_options['event_page_id'] . "&regevent_action=register&event_id=" . $event_id;
            $event_link = '<a class="row-title" href="' . $event_url . '">' . stripslashes_deep($event->event_name) . '</a>';
            //Build the payment link
            $payment_url = home_url() . "/?page_id=" . $org_options['return_url'] . "&amp;registration_id=" . $registration_id;
            //$payment_link = '<a href="' . $payment_url . '" title="'.__('View Your Payment Details').'">' . event_espresso_paid_status_icon( $payment_status ) . '</a>';
            //If the custom ticket is available, load the template file
            if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/template.php")) {
                if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/functions.php")) {
                    include_once EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/functions.php";
                    $qr_code = espresso_qr_code(array('attendee_id' => $attendee_id, 'event_name' => stripslashes_deep($event_name), 'attendee_first' => $fname, 'attendee_last' => $lname, 'registration_id' => $registration_id, 'event_code' => $event_code, 'ticket_type' => $ticket_type, 'event_time' => $event_time, 'amount_pd' => $amount_pd));
                }
                //Build the ticket link
                $ticket_url = home_url() . "/?download_ticket=true&amp;id=" . $attendee_id . "&amp;registration_id=" . $registration_id;
                $ticket_link = '<strong><a href="' . $ticket_url . '">' . __('Download Ticket Now!') . '</a></strong>';
            }
            ?>
	<tr>
	<td><input name="checkbox[<?php 
            echo $attendee_id;
            ?>
]" type="checkbox"  title="Cancel registration for <?php 
            echo $event_name;
            ?>
"></td>
			  <td class="post-title page-title column-title"><strong><?php 
            echo $event_link;
            ?>
</strong> </td>
              <td class="post-title page-title column-title"><?php 
            echo $ticket_type;
            ?>
</td>
			  <td class="date column-date"><?php 
            echo event_date_display($start_date);
            ?>
</td>
              <td class="date column-date"><?php 
            echo $start_time;
            ?>
</td>
              <td class="date column-date"><?php 
            echo '<a target="_blank" href="' . $payment_url . '" title="' . __('View Your Payment Details') . '">';
            event_espresso_paid_status_icon($payment_status) . '</a>';
            ?>
</td>
              <td class="date column-date"><?php 
            echo $org_options['currency_symbol'];
            echo $amount_pd;
            ?>
</td>
              <?php 
            echo $ticketing_installed == true ? '<td>' . $ticket_link . '</td>' : '';
            ?>
			  </tr>
              <div id="event_info_<?php 
            echo $attendee_id;
            ?>
" style="display:none">
              <?php 
            _e('<h2>Event Information</h2>', 'event_espresso');
            ?>
				<ul>
                <li><h3 class="h3_event_title" id="h3_event_title-<?php 
            echo $event_id;
            ?>
"><?php 
            echo $event_name;
            ?>
</h3>
					<p class="p_start_date"><?php 
            _e('Start Date:', 'event_espresso');
            ?>
 <?php 
            echo event_date_display($start_date);
            ?>
</p></li>
				<li><p class="p_event_time"><?php 
            _e('Start Time:', 'event_espresso');
            ?>
 <?php 
            echo $start_time;
            ?>
</p></li>
                <li><?php 
            if ($display_desc == "Y") {
                ?>
					<strong><?php 
                _e('Description:', 'event_espresso');
                ?>
</strong>
					<?php 
                echo htmlspecialchars_decode($event_desc);
                ?>
					<?php 
            }
            //End display description
            ?>
</li>
                
                </ul>
            </div>
	<?php 
        }
    }
    ?>
          </tbody>
          </table>
          <div style="clear:both; margin-bottom:30px;">
		<input type="checkbox" name="sAll" onclick="selectAll(this)" /> <strong><?php 
    _e('Check All', 'event_espresso');
    ?>
</strong> 
    	<input name="cancel_registration" type="submit" class="button-secondary" id="cancel_registration" value="<?php 
    _e('Cancel Registration', 'event_espresso');
    ?>
" style="margin-left:100px;" onclick="return confirmDelete();"> <a style="margin-left:20px" class="button-primary"  onclick="window.location='profile.php#event_espresso_profile'">
    <?php 
    _e('Your Profile', 'event_espresso');
    ?>
    </a>
    </div>
		</form>
   </div>
</div>       
         </div> 

<script>
jQuery(document).ready(function($) {						
		
	/* show the table data */
	var mytable = $('#table').dataTable( {
			"bStateSave": true,
			"sPaginationType": "full_numbers",

			"oLanguage": {	"sSearch": "<strong><?php 
    _e('Live Search Filter', 'event_espresso');
    ?>
:</strong>",
						 	"sZeroRecords": "<?php 
    _e('No Records Found!', 'event_espresso');
    ?>
" },
			"aoColumns": [
							{ "bSortable": false },
							 null,
							 null,
							 null,
							 null,
							 null,
							<?php 
    echo $ticketing_installed == true ? 'null,' : '';
    ?>
							 null
						]

	} );
	
} );
</script>	
<?php 
}