function edit_event($event_id = 0)
{
    global $wpdb, $org_options, $espresso_premium;
    ob_start();
    $SQL = "SELECT e.*, ev.id as venue_id\n\t    FROM " . EVENTS_DETAIL_TABLE . " e\n\t    LEFT JOIN " . EVENTS_VENUE_REL_TABLE . " vr ON e.id = vr.event_id\n\t    LEFT JOIN " . EVENTS_VENUE_TABLE . " ev ON vr.venue_id = ev.id\n\t    WHERE e.id = %d";
    $events = $wpdb->get_results($wpdb->prepare($SQL, $event_id));
    if (!is_array($events) || count($events) <= 0) {
        event_espresso_edit_list();
        #echo "<div class='updated fade below-h2'><p>";
        #_e("Event is not available any more!","eventespresso");
        #echo "</p></div>";
        return 1;
    }
    foreach ($events as $event) {
        $event_id = $event->id;
        $event_name = htmlentities(stripslashes($event->event_name), ENT_QUOTES, 'UTF-8');
        $event_desc = htmlentities(stripslashes($event->event_desc), ENT_QUOTES, 'UTF-8');
        $display_desc = $event->display_desc;
        $display_reg_form = $event->display_reg_form;
        $member_only = $event->member_only;
        $phone = stripslashes_deep($event->phone);
        $externalURL = stripslashes_deep($event->externalURL);
        //Early discounts
        $early_disc = stripslashes_deep($event->early_disc);
        $early_disc_date = stripslashes_deep($event->early_disc_date);
        $early_disc_percentage = stripslashes_deep($event->early_disc_percentage);
        $post_id = $event->post_id;
        $post_type = $event->post_type;
        $event_identifier = stripslashes_deep($event->event_identifier);
        $registration_start = $event->registration_start;
        $registration_end = $event->registration_end;
        $registration_startT = $event->registration_startT;
        $resitration_endT = $event->registration_endT;
        $timezone_string = $event->timezone_string;
        $start_date = $event->start_date;
        $end_date = $event->end_date;
        $tax_percentage = $event->tax_percentage;
        $tax_mode = $event->tax_mode;
        $start_time = isset($event->start_time) ? $event->start_time : '';
        $end_time = isset($event->end_time) ? $event->end_time : '';
        $reg_limit = $event->reg_limit;
        $additional_limit = $event->additional_limit;
        $allow_overflow = $event->allow_overflow;
        $overflow_event_id = $event->overflow_event_id;
        $allow_multiple = $event->allow_multiple;
        $event_cost = unserialize(isset($event->event_cost) ? $event->event_cost : '');
        $is_active = $event->is_active;
        $status = array();
        $status = event_espresso_get_is_active($event_id);
        $event_status = $event->event_status;
        $conf_mail = stripslashes_deep($event->conf_mail);
        $send_mail = stripslashes_deep($event->send_mail);
        $use_coupon_code = $event->use_coupon_code;
        $alt_email = $event->alt_email;
        $address = stripslashes_deep($event->address);
        $address2 = stripslashes_deep($event->address2);
        $city = stripslashes_deep($event->city);
        $state = stripslashes_deep($event->state);
        $zip = stripslashes_deep($event->zip);
        $country = stripslashes_deep($event->country);
        $venue_id = stripslashes_deep($event->venue_id);
        $venue_title = stripslashes_deep($event->venue_title);
        $venue_url = stripslashes_deep($event->venue_url);
        $venue_phone = stripslashes_deep($event->venue_phone);
        $venue_image = stripslashes_deep($event->venue_image);
        $email_id = $event->email_id;
        $ticket_id = $event->ticket_id;
        $wp_user = $event->wp_user;
        $date_submitted = $event->submitted != '0000-00-00 00:00:00' ? empty($event->submitted) ? '' : event_date_display($event->submitted, get_option('date_format')) : 'N/A';
        $google_map_link = espresso_google_map_link(array('address' => $address, 'city' => $city, 'state' => $state, 'zip' => $zip, 'country' => $country));
        //Virtual location
        $virtual_url = stripslashes_deep($event->virtual_url);
        $virtual_phone = stripslashes_deep($event->virtual_phone);
        $question_groups = unserialize($event->question_groups);
        global $event_meta;
        $event_meta = unserialize($event->event_meta);
        $recurrence_id = $event->recurrence_id;
        $visible_on = $event->visible_on;
        $require_pre_approval = $event->require_pre_approval;
        if (function_exists('event_espresso_edit_event_groupon')) {
            $use_groupon_code = $event->use_groupon_code;
        }
    }
    $values = array(array('id' => 'Y', 'text' => __('Yes', 'event_espresso')), array('id' => 'N', 'text' => __('No', 'event_espresso')));
    //If user is an event manager, then show only their events
    if (function_exists('espresso_is_my_event') && espresso_is_my_event($event_id) != true) {
        echo '<h2>' . __('Sorry, you do not have permission to edit this event.', 'event_espresso') . '</h2>';
        return;
    }
    ?>
	<!--Update event display-->
	<div id="submitdiv" class="postbox">
		<div class="handlediv" title="Click to toggle"><br />
		</div>
		<h3 class='hndle'> <span>
	<?php 
    _e('Quick Overview', 'event_espresso');
    ?>
			</span> </h3>
		<div class="inside">
			<div class="submitbox" id="submitpost">
				<div id="minor-publishing">
					<div id="minor-publishing-actions" class="clearfix">
						<div id="preview-action"> <a class="preview button" href="<?php 
    echo espresso_reg_url($event_id);
    ?>
" target="_blank" id="event-preview" tabindex="5">
	<?php 
    _e('View Event', 'event_espresso');
    ?>
							</a>
							<input type="hidden" name="event-preview" id="event-preview" value="" />
						</div>
						<div id="copy-action"> <a class="preview button" href="admin.php?page=events&amp;action=copy_event&event_id=<?php 
    echo $event_id;
    ?>
" id="post-copy" tabindex="4" onclick="return confirm('<?php 
    _e('Are you sure you want to copy ' . $event_name . '?', 'event_espresso');
    ?>
')">
	<?php 
    _e('Duplicate Event', 'event_espresso');
    ?>
							</a>
							<input  type="hidden" name="event-copy" id="event-copy" value="" />
						</div>
					</div>
					<!-- /minor-publishing-actions -->

					<div id="misc-publishing-actions">
						<div class="misc-pub-section curtime" id="visibility"> <span id="timestamp">
	<?php 
    _e('Start Date', 'event_espresso');
    ?>
								<b> <?php 
    echo event_date_display($start_date);
    ?>
 <?php 
    echo event_date_display($start_time, get_option('time_format'));
    ?>
</b> </span> </div>
						<div class="misc-pub-section">
							<label for="post_status">
	<?php 
    _e('Current Status:', 'event_espresso');
    ?>
							</label>
							<span id="post-status-display"> <?php 
    echo $status['display'];
    ?>
</span> </div>
						<div class="misc-pub-section" id="visibility"> <img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/group.png" width="16" height="16" alt="<?php 
    _e('View Attendees', 'event_espresso');
    ?>
" /> <?php 
    echo !empty($number_attendees) ? __('Attendees', 'event_espresso') : '<a href="admin.php?page=events&amp;event_admin_reports=list_attendee_payments&amp;event_id=' . $event_id . '">' . __('Attendees', 'event_espresso') . '</a>';
    ?>
: <?php 
    echo get_number_of_attendees_reg_limit($event_id, 'num_attendees_slash_reg_limit');
    ?>
 </div>
						<div class="misc-pub-section <?php 
    echo function_exists('espresso_is_admin') && espresso_is_admin() == true && $espresso_premium == true ? '' : 'misc-pub-section-last';
    ?>
" id="visibility2"> <a href="admin.php?page=events&amp;event_admin_reports=event_newsletter&amp;event_id=<?php 
    echo $event_id;
    ?>
" title="<?php 
    _e('Email Event Attendees', 'event_espresso');
    ?>
"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/email_go.png" width="16" height="16" alt="<?php 
    _e('Newsletter', 'event_espresso');
    ?>
" /></a> <a href="admin.php?page=events&amp;event_admin_reports=event_newsletter&amp;event_id=<?php 
    echo $event_id;
    ?>
" title="<?php 
    _e('Email Event Attendees', 'event_espresso');
    ?>
">
						<?php 
    _e('Email Event Attendees', 'event_espresso');
    ?>
							</a></div>
						<?php 
    if (function_exists('espresso_is_admin') && espresso_is_admin() == true && $espresso_premium == true) {
        $user_name = espresso_user_meta($wp_user, 'user_firstname') != '' ? espresso_user_meta($wp_user, 'user_firstname') . ' ' . espresso_user_meta($wp_user, 'user_lastname') . ' (<a href="user-edit.php?user_id=' . $wp_user . '">' . espresso_user_meta($wp_user, 'user_nicename') . '</a>)' : espresso_user_meta($wp_user, 'display_name') . ' (<a href="user-edit.php?user_id=' . $wp_user . '">' . espresso_user_meta($wp_user, 'user_nicename') . '</a>)';
        $user_company = espresso_user_meta($wp_user, 'company') != '' ? espresso_user_meta($wp_user, 'company') : '';
        $user_organization = espresso_user_meta($wp_user, 'organization') != '' ? espresso_user_meta($wp_user, 'organization') : '';
        $user_co_org = $user_company != '' ? $user_company : $user_organization;
        echo '<div class="misc-pub-section misc-pub-section-last" id="visibility3">';
        echo '<ul>';
        echo '<li><strong>' . __('Submitted By:', 'event_espresso') . '</strong> ' . $user_name . '</li>';
        echo '<li><strong>' . __('Email:', 'event_espresso') . '</strong> ' . espresso_user_meta($wp_user, 'user_email') . '</li>';
        echo $user_co_org != '' ? '<li><strong>' . __('Organization:', 'event_espresso') . '</strong> ' . espresso_user_meta($wp_user, 'company') . '</li>' : '';
        echo '<li><strong>' . __('Date Submitted:', 'event_espresso') . '</strong> ' . $date_submitted . '</li>';
        echo '</ul>';
        echo '</div>';
    }
    ?>
					</div>
					<!-- /misc-publishing-actions -->
				</div>
				<!-- /minor-publishing -->

				<div id="major-publishing-actions" class="clearfix">
							<?php 
    if ($recurrence_id > 0) {
        ?>
						<div id="delete-action"> &nbsp; <a class="submitdelete deletion" href="admin.php?page=events&amp;action=delete_recurrence_series&recurrence_id=<?php 
        echo $recurrence_id;
        ?>
" onclick="return confirm('<?php 
        _e('Are you sure you want to delete ' . $event_name . '?', 'event_espresso');
        ?>
')">
						<?php 
        _e('Delete all events in this series', 'event_espresso');
        ?>
							</a> </div>
							<?php 
    } else {
        ?>
						<div id="delete-action"> <a class="submitdelete deletion" href="admin.php?page=events&amp;action=delete&event_id=<?php 
        echo $event_id;
        ?>
" onclick="return confirm('<?php 
        _e('Are you sure you want to delete ' . $event_name . '?', 'event_espresso');
        ?>
')">
						<?php 
        _e('Delete Event', 'event_espresso');
        ?>
							</a> </div>
	<?php 
    }
    ?>
					<div id="publishing-action">
						<input class="button-primary" type="submit" name="Submit" value="<?php 
    _e('Update Event', 'event_espresso');
    ?>
" id="save_event_setting" />
					</div>
					<!-- /publishing-action -->
				</div>
				<!-- /major-publishing-actions -->
			</div>
			<!-- /submitpost -->
		</div>
		<!-- /inside -->
	</div>
	<!-- /submitdiv -->

	<?php 
    if ($espresso_premium == true) {
        do_action('action_hook_espresso_edit_event_right_column_top', $event_id);
    }
    $advanced_options = '';
    if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/event-management/advanced_settings.php')) {
        require_once EVENT_ESPRESSO_PLUGINFULLPATH . "includes/admin-files/event-management/advanced_settings.php";
    } else {
        //Display Lite version options
        $status = array(array('id' => 'A', 'text' => __('Active', 'event_espresso')), array('id' => 'D', 'text' => __('Deleted', 'event_espresso')));
        $advanced_options = '<p><strong>' . __('Advanced Options:', 'event_espresso') . '</strong></p>' . '<p><label>' . __('Is this an active event? ', 'event_espresso') . '</label>' . __(select_input('is_active', $values, $is_active)) . '</p>' . '<p><label>' . __('Display  description? ', 'event_espresso') . '</label>' . select_input('display_desc', $values, $display_desc) . '</p>' . '<p><label>' . __('Display  registration form? ', 'event_espresso') . '</label>' . select_input('display_reg_form', $values, $display_reg_form) . '</p>';
    }
    //Display Lite version options - End
    espresso_postbox('event-status', 'Event Options', '<p><label for"reg-limit">' . __('Attendee Limit', 'event_espresso') . ': </label><input name="reg_limit" id="reg-limit" size="10" type="text" value="' . $reg_limit . '" /><br />' . '<span>(' . __('leave blank for unlimited', 'event_espresso') . ')</span></p>' . '<p><label>' . __('Allow group registrations?', 'event_espresso') . '</label> ' . select_input('allow_multiple', $values, $allow_multiple) . '</p>' . '<p><label for="addit-limit">' . __('Max Group Registrants', 'event_espresso') . ':</label> <input type="text" id="addit-limit" name="additional_limit" value="' . $additional_limit . '" size="4" />' . '</p>' . $advanced_options);
    if (function_exists('espresso_ticket_dd') && $espresso_premium == true) {
        ?>
		<div id="event-category" class="postbox">
			<div class="handlediv" title="Click to toggle"><br>
			</div>
			<h3 class="hndle"> <span>
				<?php 
        _e('Custom Tickets', 'event_espresso');
        ?>
				</span> </h3>
			<div class="inside"> <?php 
        echo espresso_ticket_dd($ticket_id);
        ?>
 </div>
		</div>
	<?php 
    }
    if ($espresso_premium == true) {
        ?>
		<div id="featured-image-options" class="postbox">
				<div class="handlediv" title="Click to toggle"><br />
				</div>
				<h3 class="hndle"> <span>
					<?php 
        _e('Featured Image', 'event_espresso');
        ?>
					</span> </h3>
		<div class="inside">
			<div id="featured-image">
				<?php 
        if (!empty($event_meta['event_thumbnail_url'])) {
            $event_thumb = $event_meta['event_thumbnail_url'];
        } else {
            $event_thumb = '';
        }
        ?>
				<label for="upload_image">
					<?php 
        _e('Add Featured Image', 'event_espresso');
        ?>
				</label>
				<input id="upload_image" type="hidden" size="36" name="upload_image" value="<?php 
        echo $event_thumb;
        ?>
" />
				<input id="upload_image_button" type="button" value="<?php 
        _e('Upload Image', 'event_espresso');
        ?>
" />
				<?php 
        if ($event_thumb) {
            ?>
					<p class="event-featured-thumb"><img style="width: 100%;"  src="<?php 
            echo $event_thumb;
            ?>
" alt="" /></p>
					<a id='remove-image' href='#' title='<?php 
            _e('Remove Image', 'event_espresso');
            ?>
' onclick='return false;'><?php 
            _e('Remove Image', 'event_espresso');
            ?>
</a>
				<?php 
        }
        ?>
			</div>
			
		</div>
		</div>
	<?php 
    }
    /*
     * Added for seating chart addon
     */
    if (defined('ESPRESSO_SEATING_CHART')) {
        $seating_chart_id = 0;
        $seating_chart_event = $wpdb->get_row("select * from " . EVENTS_SEATING_CHART_EVENT_TABLE . " where event_id = {$event_id}");
        if ($seating_chart_event !== NULL) {
            $seating_chart_id = $seating_chart_event->seating_chart_id;
        }
        ?>
		<div style="display: block;" id="seating_chart-options" class="postbox">
			<div class="handlediv" title="Click to toggle"><br />
			</div>
			<h3 class="hndle"><span>
		<?php 
        _e('Seating chart', 'event_espresso');
        ?>
				</span></h3>
			<div class="inside">
				<p>
					<select name="seating_chart_id" id="seating_chart_id" style="float:none;">
						<option value="0" <?php 
        if ($seating_chart_id == 0) {
            echo 'selected="selected"';
        }
        ?>
 ><?php 
        _e('None', 'event_espresso');
        ?>
</option>
						<?php 
        $seating_charts = $wpdb->get_results("select * from " . EVENTS_SEATING_CHART_TABLE . " order by name");
        foreach ($seating_charts as $seating_chart) {
            ?>
							<option value="<?php 
            echo $seating_chart->id;
            ?>
" <?php 
            if ($seating_chart_id == $seating_chart->id) {
                echo 'selected="selected"';
            }
            ?>
 ><?php 
            echo $seating_chart->name;
            ?>
</option>
			<?php 
        }
        ?>
					</select>
					<?php 
        do_action('espresso_seating_chart_select', $event_id);
        ?>
					<?php 
        do_action('ee_seating_chart_js');
        ?>
					<?php 
        do_action('ee_seating_chart_css');
        ?>
					<?php 
        do_action('ee_seating_chart_flush_expired_seats');
        ?>
				</p>
			</div>
		</div>
		<?php 
    }
    /*
     * End
     */
    ###### Modification by wp-developers to introduce attendee pre-approval requirement ##########
    if (isset($org_options['use_attendee_pre_approval']) && $org_options['use_attendee_pre_approval'] == 'Y' && $espresso_premium == true) {
        ?>
		<div id="attendee-pre-approval-options" class="postbox">
			<div class="handlediv" title="Click to toggle"><br />
			</div>
			<h3 class="hndle"> <span>
					<?php 
        _e('Attendee pre-approval required?', 'event_espresso');
        ?>
				</span> </h3>
			<div class="inside">
				<p class="pre-approve">
		<?php 
        $pre_approval_values = array(array('id' => '1', 'text' => __('Yes', 'event_espresso')), array('id' => '0', 'text' => __('No', 'event_espresso')));
        echo select_input("require_pre_approval", $pre_approval_values, $require_pre_approval);
        ?>
				</p>
			</div>
		</div>
		<?php 
    }
    ########## END #################################
    if (defined('EVENT_ESPRESSO_MEMBERS_DIR') && $espresso_premium == true) {
        ?>
		<div  id="member-options" class="postbox">
			<div class="handlediv" title="Click to toggle"><br>
			</div>
			<h3 class="hndle"> <span>
		<?php 
        _e('Member Options', 'event_espresso');
        ?>
				</span> </h3>
			<div class="inside">
				<p><?php 
        echo event_espresso_member_only($member_only);
        ?>
</p>
			</div>
		</div>
		<!-- /member-options -->
		<?php 
    }
    if (defined('EVENTS_MAILCHIMP_ATTENDEE_REL_TABLE') && $espresso_premium == true) {
        MailChimpView::event_list_selection();
    }
    ?>
	
	<div  id="event-categories" class="postbox">
		<div class="handlediv" title="Click to toggle"><br>
		</div>
		<h3 class="hndle"> <span>
	<?php 
    _e('Event Category', 'event_espresso');
    ?>
			</span> </h3>
		<div class="inside"> <?php 
    echo event_espresso_get_categories($event_id);
    ?>
 </div>
	</div>
	<!-- /event-category -->

	<?php 
    if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/event-management/promotions_box.php')) {
        require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/event-management/promotions_box.php';
    }
    ?>
	<!-- /event-promotions -->

	<?php 
    echo espresso_event_question_groups($question_groups, $event_meta['add_attendee_question_groups'], $event);
    ?>
	<!-- /event-questions -->

	<?php 
    do_action('action_hook_espresso_staff_cb', $event_id, $recurrence_id);
    if (defined('EVENTS_GROUPON_CODES_TABLE') && $espresso_premium == true) {
        ?>
		<div id="groupon-options" class="postbox">
			<div class="handlediv" title="Click to toggle"><br>
			</div>
			<h3 class="hndle"> <span>
		<?php 
        _e('Groupon Options', 'event_espresso');
        ?>
				</span> </h3>
			<div class="inside">
				<p><?php 
        echo event_espresso_edit_event_groupon($use_groupon_code);
        ?>
</p>
			</div>
		</div>
		<!-- /groupon-options -->
			<?php 
    }
    if ($espresso_premium == true) {
        do_action('action_hook_espresso_edit_event_right_column_bottom', $event_id);
    }
    $sidebar_content = ob_get_clean();
    ob_start();
    ?>
	<div id="titlediv"> <strong>
	<?php 
    _e('Event Title', 'event_espresso');
    ?>
		</strong>
		<div id="titlewrap">
			<label class="screen-reader-text" for="title">
	<?php 
    _e('Event Title', 'event_espresso');
    ?>
			</label>
			<input type="text" name="event" size="30" tabindex="1" value="<?php 
    echo $event_name;
    ?>
" id="title" autocomplete="off" />
		</div>
		<!-- /titlewrap -->
		<div class="inside">
			<div id="edit-slug-box"> <strong>
	<?php 
    _e('Unique Event Identifier:', 'event_espresso');
    ?>
				</strong>
				<input disabled="disabled" type="text" size="30" tabindex="2" name="event_identifier" id="event_identifier" value ="<?php 
    echo $event_identifier;
    ?>
" />
	<?php 
    echo '<a href="#" class="button" onclick="prompt(&#39;Event Shortcode:&#39;, \'[SINGLEEVENT single_event_id=&#34;\' + jQuery(\'#event_identifier\').val() + \'&#34;]\'); return false;">' . __('Shortcode') . '</a>';
    ?>
 <?php 
    echo '<a href="#" class="button" onclick="prompt(&#39;Short URL:&#39;, \'' . espresso_reg_url($event_id) . '\'); return false;">' . __('Short URL') . '</a>';
    ?>
 <?php 
    echo '<a href="#" class="button" onclick="prompt(&#39;Full URL:&#39;, \'' . home_url() . '/?page_id=' . $org_options['event_page_id'] . '&amp;regevent_action=register&amp;event_id=' . $event_id . '\'); return false;">' . __('Full URL') . '</a>';
    ?>
 </div>
			<!-- /edit-slug-box -->
		</div>
		<!-- /.inside -->
	</div>
	<!-- /titlediv -->

	<div id="descriptiondivrich" class="postarea"> <strong>
		<?php 
    _e('Event Description', 'event_espresso');
    ?>
		</strong>
		<?php 
    if (function_exists('wp_editor')) {
        $args = array("textarea_rows" => 5, "textarea_name" => "event_desc", "editor_class" => "my_editor_custom");
        wp_editor(espresso_admin_format_content($event_desc), "event_desc", $args);
    } else {
        /*
         This is the editor used by WordPress. It is very very hard to find documentation for this thing, so I pasted everything I could find below.
         param: string $content Textarea content.
         param: string $id Optional, default is 'content'. HTML ID attribute value.
         param: string $prev_id Optional, default is 'title'. HTML ID name for switching back and forth between visual editors.
         param: bool $media_buttons Optional, default is true. Whether to display media buttons.
         param: int $tab_index Optional, default is 2. Tabindex for textarea element.
        */
        //the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2)
        //the_editor(espresso_admin_format_content($event_desc), $id = 'event_desc'/* , $prev_id = 'title', $media_buttons = true, $tab_index = 3 */);
        the_editor(espresso_admin_format_content($event_desc), $id = 'event_desc');
    }
    ?>
		<table id="post-status-info" cellspacing="0">
			<tbody>
				<tr>
					<td id="wp-word-count"></td>
					<td class="autosave-info"><span id="autosave">&nbsp;</span></td>
				</tr>
			</tbody>
		</table>
	</div>
	<!-- /postdivrich -->
	<?php 
    $main_post_content = ob_get_clean();
    ob_start();
    ?>
	<div id="normal-sortables" class="meta-box-sortables ui-sortable">
		<div style="display: block;" id="event-date-time" class="postbox">
			<div class="handlediv" title="Click to toggle"><br>
			</div>
			<h3 class="hndle"> <span>
	<?php 
    _e('Event Date/Times', 'event_espresso');
    ?>
				</span> </h3>
			<div class="inside">
				<table width="100%" border="0" cellpadding="5">
					<tr valign="top">
						<td class="a"><fieldset id="add-reg-dates">
								<legend>
	<?php 
    _e('Registration Dates', 'event_espresso');
    ?>
								</legend>
								<p>
									<label for="registration_start"> <?php 
    echo __('Registration Start:', 'event_espresso');
    ?>
</label>
									<input type="text" class="datepicker" size="15" id="registration_start" name="registration_start"  value="<?php 
    echo $registration_start;
    ?>
" />
								</p>
								<p>
									<label for="registration_end"><?php 
    echo __('Registration End:', 'event_espresso');
    ?>
</label>
									<input type="text" class="datepicker" size="15" id="registration_end" name="registration_end"  value="<?php 
    echo $registration_end;
    ?>
" />
								</p>
							</fieldset>
							<fieldset>
								<legend>
	<?php 
    _e('Event Dates', 'event_espresso');
    ?>
								</legend>
								<p>
									<label for="start_date"><?php 
    echo __('Event Start Date', 'event_espresso');
    ?>
</label>
									<input type="text" class="datepicker" size="15" id="start_date" name="start_date" value="<?php 
    echo $start_date;
    ?>
" />
								</p>
								<p>
									<label for="end_date"><?php 
    echo __('Event End Date', 'event_espresso');
    ?>
</label>
									<input type="text" class="datepicker" size="15" id="end_date" name="end_date" value="<?php 
    echo $end_date;
    ?>
" />
								</p>
							</fieldset>
										<?php 
    if (isset($org_options['use_event_timezones']) && $org_options['use_event_timezones'] == 'Y' && $espresso_premium == true) {
        ?>
								<fieldset id="event-timezone">
									<p>
										<label>
								<?php 
        _e('Event Timezone', 'event_espresso');
        ?>
											:</label>
		<?php 
        echo eventespresso_ddtimezone($event_id);
        ?>
</p>
								</fieldset>
									<?php 
    }
    ?>
</td>
								<?php 
    // ADD TIME REGISTRATION
    ?>
						<td class="b"><fieldset id="add-register-times">
								<legend>
	<?php 
    _e('Registration Times', 'event_espresso');
    ?>
								</legend>
									<?php 
    echo event_espresso_timereg_editor($event_id);
    ?>
							</fieldset>
							<fieldset id="add-event-times">
								<legend>
							<?php 
    _e('Event Times', 'event_espresso');
    ?>
								</legend>
									<?php 
    echo event_espresso_time_editor($event_id);
    ?>
							</fieldset>
									<?php 
    if ((!isset($org_options['use_event_timezones']) || $org_options['use_event_timezones'] != 'Y') && $espresso_premium == true) {
        ?>
								<p><span class="run-in">
								<?php 
        _e('Current Time', 'event_espresso');
        ?>
										:</span> <span class="current-date"> <?php 
        echo date(get_option('date_format')) . ' ' . date(get_option('time_format'));
        ?>
</span> <a class="change-date-time" href="options-general.php" target="_blank">
		<?php 
        _e('Change timezone and date format settings?', 'event_espresso');
        ?>
									</a></p>
		<?php 
    }
    ?>
</td>
					</tr>
				</table>
			</div>
		</div>
		<?php 
    /**
     * Load the recurring events form if the add-on has been installed.	*
     */
    if (defined('EVENT_ESPRESSO_RECURRENCE_TABLE') && $espresso_premium == true) {
        require_once EVENT_ESPRESSO_RECURRENCE_FULL_PATH . "functions/re_view_functions.php";
        //For now, only the recurring events will show the form
        if ($recurrence_id > 0) {
            event_espresso_re_form($recurrence_id);
        }
    }
    ?>
		<div id="event-pricing" class="postbox">
					<?php 
    defined('EVENT_ESPRESSO_MEMBERS_DIR') ? $members_active = 'class="members-active"' : ($members_active = '');
    ?>
			<div class="handlediv" title="Click to toggle"><br>
			</div>
			<h3 class="hndle"> <span>
	<?php 
    _e('Event Pricing', 'event_espresso');
    ?>
				</span> </h3>
			<div class="inside">
				<table <?php 
    echo $members_active;
    ?>
width="100%" border="0" cellpadding="5">
					<tr valign="top">
						<td id="standard-pricing" class="a"><?php 
    event_espresso_multi_price_update($event_id);
    //Standard pricing
    ?>
</td>
						<?php 
    //If the members addon is installed, define member only event settings
    if (defined('EVENT_ESPRESSO_MEMBERS_DIR') && $espresso_premium == true) {
        ?>
							<td id="member-pricing" class="b"><?php 
        echo event_espresso_member_only_pricing($event_id);
        //Show the the member only pricing options.
        ?>
</td>
	<?php 
    }
    ?>
					</tr>
				</table>
			</div>
		</div>
		<h2>
	<?php 
    _e('Advanced Options', 'event_espresso');
    ?>
		</h2>
		<?php 
    if ($espresso_premium == true) {
        do_action('action_hook_espresso_edit_event_left_column_advanced_options_top', $event_id);
    }
    ?>
		<div id="event-location" class="postbox">
			<div class="handlediv" title="Click to toggle"><br />
			</div>
			<h3 class="hndle"> <span>
	<?php 
    _e('Additional Event/Venue Information', 'event_espresso');
    ?>
				</span> </h3>
			<div class="inside">
				<table width="100%" border="0" cellpadding="5">
					<tr valign="top">

	<?php 
    if (function_exists('espresso_venue_dd') && $org_options['use_venue_manager'] == 'Y' && $espresso_premium == true) {
        $ven_type = 'class="use-ven-manager"';
        ?>
							<td <?php 
        echo $ven_type;
        ?>
><fieldset id="venue-manager">
									<legend><?php 
        echo __('Venue Information', 'event_espresso');
        ?>
</legend>
									<?php 
        if (!espresso_venue_dd()) {
            ?>
										<p class="info"><b>
										<?php 
            _e('You have not created any venues yet.', 'event_espresso');
            ?>
											</b></p>
										<p><a href="admin.php?page=event_venues"><?php 
            echo __('Add venues to the Venue Manager', 'event_espresso');
            ?>
</a></p>
							<?php 
        } else {
            ?>
								<?php 
            echo espresso_venue_dd($venue_id);
            ?>
							<?php 
        }
        ?>
								</fieldset></td>
		<?php 
    } else {
        $ven_type = 'class="manual-venue"';
        ?>
							<td <?php 
        echo $ven_type;
        ?>
><fieldset>
									<legend>
											<?php 
        _e('Physical Location', 'event_espresso');
        ?>
									</legend>
									<p>
										<label for="phys-addr">
		<?php 
        _e('Address:', 'event_espresso');
        ?>
										</label>
										<input size="20" id="phys-addr" tabindex="100"  type="text"  value="<?php 
        echo $address;
        ?>
" name="address" />
									</p>
									<p>
										<label for="phys-addr-2">
		<?php 
        _e('Address 2:', 'event_espresso');
        ?>
										</label>
										<input size="20" id="phys-addr-2" tabindex="101"  type="text"  value="<?php 
        echo $address2;
        ?>
" name="address2" />
									</p>
									<p>
										<label for="phys-city">
		<?php 
        _e('City:', 'event_espresso');
        ?>
										</label>
										<input size="20" id="phys-city" tabindex="102"  type="text"  value="<?php 
        echo $city;
        ?>
" name="city" />
									</p>
									<p>
										<label for="phys-state">
		<?php 
        _e('State:', 'event_espresso');
        ?>
										</label>
										<input size="20" id="phys-state" tabindex="103"  type="text"  value="<?php 
        echo $state;
        ?>
" name="state" />
									</p>
									<p>
										<label for="zip-postal">
		<?php 
        _e('Zip/Postal Code:', 'event_espresso');
        ?>
										</label>
										<input size="20" id="zip-postal"  tabindex="104"  type="text"  value="<?php 
        echo $zip;
        ?>
" name="zip" />
									</p>
									<p>
										<label for="phys-country">
										<?php 
        _e('Country:', 'event_espresso');
        ?>
										</label>
										<input size="20" id="phys-country" tabindex="105"  type="text"  value="<?php 
        echo $country;
        ?>
" name="country" />
									</p>
									<p>
		<?php 
        _e('Google Map Link (for email):', 'event_espresso');
        ?>
										<br />
		<?php 
        echo $google_map_link;
        ?>
 </p>
								</fieldset></td>
							<td <?php 
        echo $ven_type;
        ?>
>

								<fieldset>

									<legend>
											<?php 
        _e('Venue Information', 'event_espresso');
        ?>
									</legend>
									<p>
										<label for="ven-title">
		<?php 
        _e('Title:', 'event_espresso');
        ?>
										</label>
										<input size="20"id="ven-title" tabindex="106"  type="text"  value="<?php 
        echo $venue_title;
        ?>
" name="venue_title" />
									</p>
									<p>
										<label for="ven-website">
		<?php 
        _e('Website:', 'event_espresso');
        ?>
										</label>
										<input size="20" id="ven-website" tabindex="107"  type="text"  value="<?php 
        echo $venue_url;
        ?>
" name="venue_url" />
									</p>
									<p>
										<label for="ven-phone">
		<?php 
        _e('Phone:', 'event_espresso');
        ?>
										</label>
										<input size="20" id="ven-phone" tabindex="108"  type="text"  value="<?php 
        echo $venue_phone;
        ?>
" name="venue_phone" />
									</p>
									<p>
										<label for="ven-image">
									<?php 
        _e('Image:', 'event_espresso');
        ?>
										</label>
										<input size="20" id="ven-image" tabindex="110"  type="text"  value="<?php 
        echo $venue_image;
        ?>
" name="venue_image" />
									</p>
									<?php 
    }
    ?>
						</td>

						<td <?php 
    echo $ven_type;
    ?>
><fieldset id="virt-location">
								<legend>
										<?php 
    _e('Virtual Location', 'event_espresso');
    ?>
								</legend>
								<p>
									<label for="virt-phone">
	<?php 
    _e('Phone:', 'event_espresso');
    ?>
									</label>
									<input size="20" id="virt-phone" type="text" tabindex="111" value="<?php 
    echo $phone;
    ?>
" name="phone" />
								</p>
								<p>
									<label for="url-event">
	<?php 
    _e('URL of Event:', 'event_espresso');
    ?>
									</label>
									<textarea id="url-event" cols="30" rows="4" tabindex="112"  name="virtual_url"><?php 
    echo $virtual_url;
    ?>
</textarea>
								</p>
								<p>
									<label for="call-in-num">
	<?php 
    _e('Call in Number:', 'event_espresso');
    ?>
									</label>
									<input id="call-in-num" size="20" tabindex="113"  type="text"  value="<?php 
    echo $virtual_phone;
    ?>
" name="virtual_phone" />
								</p>
							</fieldset></td>
					</tr>

				</table>
			</div>
		</div>
		<!-- /event-location-->
					<?php 
    if ($espresso_premium == true) {
        ?>
			<div id="event-meta" class="postbox">
				<div class="handlediv" title="Click to toggle"><br>
				</div>
				<h3 class="hndle"> <span>
		<?php 
        _e('Event Meta', 'event_espresso');
        ?>
					</span> </h3>
				<div class="inside">
		<?php 
        event_espresso_meta_edit($event_meta);
        ?>
				</div>
			</div>
	<?php 
    }
    ?>
		<!-- /event-meta-->
		<div id="confirmation-email" class="postbox">
			<div class="handlediv" title="Click to toggle"><br />
			</div>
			<h3 class="hndle"> <span>
	<?php 
    _e('Email Confirmation:', 'event_espresso');
    ?>
				</span> </h3>
			<div class="inside">
				<div id="emaildescriptiondivrich" class="postarea">
					<div class="email-conf-opts">
						<p><?php 
    echo __('Send custom confirmation emails for this event?', 'event_espresso') . ' ' . select_input('send_mail', $values, $send_mail);
    ?>
 <?php 
    echo '<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=custom_email_info"><img src="' . EVENT_ESPRESSO_PLUGINFULLURL . '/images/question-frame.png" width="16" height="16" /></a>';
    ?>
</p>
								<?php 
    if ($espresso_premium == true) {
        ?>
							<p>
		<?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', $email_id, '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>';
        ?>
 </p>
							<br />
							<em>OR</em>
	<?php 
    }
    ?>
						<p>
						<?php 
    _e('Create a custom email:', 'event_espresso');
    ?>
  <?php 
    echo '<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=event_custom_emails"><img src="' . EVENT_ESPRESSO_PLUGINFULLURL . '/images/question-frame.png" width="16" height="16" /></a>';
    ?>
						</p>
					</div>

					<div class="postbox">
						<?php 
    //echo '<p>version_compare ='.(version_compare($wp_version, $wp_min_version) >= 0).'</p>';
    if (function_exists('wp_editor')) {
        $args = array("textarea_rows" => 5, "textarea_name" => "conf_mail", "editor_class" => "my_editor_custom");
        wp_editor(espresso_admin_format_content($conf_mail), "conf_mail", $args);
    } else {
        echo '<textarea name="conf_mail" class="theEditor" id="conf_mail">' . espresso_admin_format_content($conf_mail) . '</textarea>';
        espresso_tiny_mce();
    }
    ?>
											<?php 
    /* ?>  <textarea name="conf_mail" class="theEditor" id="conf_mail"><?php echo espresso_admin_format_content($conf_mail); ?></textarea><?php */
    ?>
						<table id="email-confirmation-form" cellspacing="0">
							<tr>
								<td class="aer-word-count"></td>
								<td class="autosave-info"><span><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></span></td>
							</tr>
						</table>
					</div>
				</div>
			</div>
		</div>
		<!-- /confirmation-email-->
	<?php 
    if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/event-management/edit_event_post.php')) {
        require_once EVENT_ESPRESSO_PLUGINFULLPATH . "includes/admin-files/event-management/edit_event_post.php";
    }
    ?>
	</div>
	<!-- /normal-sortables-->
	<?php 
    $center_metabox_content = ob_get_clean();
    espresso_choose_layout($main_post_content, $sidebar_content, $center_metabox_content);
    include_once 'create_events_help.php';
    ?>
	<?php 
    wp_nonce_field('espresso_verify_update_event_nonce', 'nonce_verify_update_event');
    //Security check using nonce
    ?>
	<input type="hidden" name="edit_action" value="update">
	<input type="hidden" name="date_submitted" value="<?php 
    echo $date_submitted;
    ?>
">
	<input type="hidden" name="recurrence_id" value="<?php 
    echo $recurrence_id;
    ?>
">
	<input type="hidden" name="action" value="edit">
	<input type="hidden" name="event_id" value="<?php 
    echo $event_id;
    ?>
">
	<script type="text/javascript" charset="utf-8">
		//<![CDATA[
		jQuery(document).ready(function() {

			postboxes.add_postbox_toggles('events');

			jQuery(".datepicker" ).datepicker({
				changeMonth: true,
				changeYear: true,
				dateFormat: "yy-mm-dd",
				showButtonPanel: true
			});
	
			//Image upload		
			var header_clicked = false;
			jQuery('#upload_image_button').click(function() {
				formfield = jQuery('#upload_image').attr('name');
				tb_show('', 'media-upload.php?type=image&amp;TB_iframe=1');
				jQuery('p.event-featured-thumb').addClass('old');
				header_clicked = true;
				return false;
			});		
					
			window.original_send_to_editor = window.send_to_editor;
		
			window.send_to_editor = function(html) {
				if(header_clicked) {
					imgurl = jQuery('img',html).attr('src');
					jQuery('#' + formfield).val(imgurl);
					jQuery('#featured-image').append("<p id='image-display'><img class='show-selected-image' src='"+imgurl+"' alt='' /></p>");
					header_clicked = false;
					tb_remove();
			
				} else {
					window.original_send_to_editor(html);
				}
			}
		
			// process the remove link in the metabox
			jQuery('#remove-image').click(function(){
				var answer = confirm("<?php 
    _e("Do you really want to delete this image? Please remember to update your event to complete the removal.", 'event_espresso');
    ?>
");
				if (answer){
					jQuery("#upload_image").val('');
					jQuery("p.event-featured-thumb").remove();
					jQuery("p#image-display").remove();
					jQuery('#remove-image').remove();
					jQuery("#show_thumb_in_lists, #show_on_calendar, #show_thumb_in_regpage").val(false);
				}
				return false;
			});
	
	
		});
		//]]>
	</script>
	<?php 
}
Esempio n. 2
0
function organization_config_mnu()
{
    global $org_options, $espresso_premium, $espresso_check_for_updates;
    if (isset($_POST['update_org'])) {
        $org_options['organization'] = isset($_POST['org_name']) && !empty($_POST['org_name']) ? stripslashes_deep($_POST['org_name']) : '';
        $org_options['organization_street1'] = isset($_POST['org_street1']) && !empty($_POST['org_street1']) ? $_POST['org_street1'] : '';
        $org_options['organization_street2'] = isset($_POST['org_street2']) && !empty($_POST['org_street2']) ? $_POST['org_street2'] : '';
        $org_options['organization_city'] = isset($_POST['org_city']) && !empty($_POST['org_city']) ? $_POST['org_city'] : '';
        $org_options['organization_state'] = isset($_POST['org_state']) && !empty($_POST['org_state']) ? $_POST['org_state'] : '';
        $org_options['organization_zip'] = isset($_POST['org_zip']) && !empty($_POST['org_zip']) ? $_POST['org_zip'] : '';
        $org_options['organization_country'] = isset($_POST['org_country']) && !empty($_POST['org_country']) ? $_POST['org_country'] : '';
        $org_options['contact_email'] = isset($_POST['email']) && !empty($_POST['email']) ? $_POST['email'] : '';
        $org_options['expire_on_registration_end'] = isset($_POST['expire_on_registration_end']) && !empty($_POST['expire_on_registration_end']) ? $_POST['expire_on_registration_end'] : '';
        $org_options['event_page_id'] = isset($_POST['event_page_id']) && !empty($_POST['event_page_id']) ? $_POST['event_page_id'] : '';
        $org_options['return_url'] = isset($_POST['return_url']) && !empty($_POST['return_url']) ? $_POST['return_url'] : '';
        $org_options['cancel_return'] = isset($_POST['cancel_return']) && !empty($_POST['cancel_return']) ? $_POST['cancel_return'] : '';
        $org_options['notify_url'] = isset($_POST['notify_url']) && !empty($_POST['notify_url']) ? $_POST['notify_url'] : '';
        $org_options['events_in_dasboard'] = isset($_POST['events_in_dasboard']) && !empty($_POST['events_in_dasboard']) ? $_POST['events_in_dasboard'] : '';
        $org_options['default_mail'] = isset($_POST['default_mail']) && !empty($_POST['default_mail']) ? $_POST['default_mail'] : '';
        $org_options['payment_subject'] = isset($_POST['payment_subject']) && !empty($_POST['payment_subject']) ? $_POST['payment_subject'] : '';
        $org_options['payment_message'] = isset($_POST['payment_message']) && !empty($_POST['payment_message']) ? esc_html($_POST['payment_message']) : '';
        $org_options['message'] = isset($_POST['success_message']) && !empty($_POST['success_message']) ? esc_html($_POST['success_message']) : '';
        $org_options['email_before_payment'] = isset($_POST['email_before_payment']) && !empty($_POST['email_before_payment']) ? $_POST['email_before_payment'] : '';
        $org_options['email_fancy_headers'] = isset($_POST['email_fancy_headers']) && !empty($_POST['email_fancy_headers']) ? $_POST['email_fancy_headers'] : '';
        $org_options['use_captcha'] = isset($_POST['use_captcha']) && !empty($_POST['use_captcha']) ? $_POST['use_captcha'] : '';
        $org_options['recaptcha_publickey'] = isset($_POST['recaptcha_publickey']) && !empty($_POST['recaptcha_publickey']) ? $_POST['recaptcha_publickey'] : '';
        $org_options['recaptcha_privatekey'] = isset($_POST['recaptcha_privatekey']) && !empty($_POST['recaptcha_privatekey']) ? $_POST['recaptcha_privatekey'] : '';
        $org_options['recaptcha_theme'] = isset($_POST['recaptcha_theme']) && !empty($_POST['recaptcha_theme']) ? $_POST['recaptcha_theme'] : '';
        $org_options['recaptcha_width'] = isset($_POST['recaptcha_width']) && !empty($_POST['recaptcha_width']) ? $_POST['recaptcha_width'] : '';
        $org_options['recaptcha_language'] = isset($_POST['recaptcha_language']) && !empty($_POST['recaptcha_language']) ? $_POST['recaptcha_language'] : '';
        $org_options['espresso_dashboard_widget'] = isset($_POST['espresso_dashboard_widget']) && !empty($_POST['espresso_dashboard_widget']) ? $_POST['espresso_dashboard_widget'] : '';
        $org_options['time_reg_limit'] = isset($_POST['time_reg_limit']) && !empty($_POST['time_reg_limit']) ? $_POST['time_reg_limit'] : '';
        $org_options['skip_confirmation_page'] = isset($_POST['skip_confirmation_page']) ? $_POST['skip_confirmation_page'] : 'N';
        $org_options['allow_mer_discounts'] = isset($_POST['allow_mer_discounts']) ? $_POST['allow_mer_discounts'] : 'N';
        $org_options['allow_mer_vouchers'] = isset($_POST['allow_mer_vouchers']) ? $_POST['allow_mer_vouchers'] : 'N';
        $org_options['use_attendee_pre_approval'] = isset($_POST['use_attendee_pre_approval']) && !empty($_POST['use_attendee_pre_approval']) ? $_POST['use_attendee_pre_approval'] : '';
        if (!empty($_POST['event_ssl_active'])) {
            $org_options['event_ssl_active'] = isset($_POST['event_ssl_active']) && !empty($_POST['event_ssl_active']) ? $_POST['event_ssl_active'] : '';
        }
        $org_options['show_pending_payment_options'] = isset($_POST['show_pending_payment_options']) && !empty($_POST['show_pending_payment_options']) ? $_POST['show_pending_payment_options'] : '';
        $org_options['use_venue_manager'] = isset($_POST['use_venue_manager']) && !empty($_POST['use_venue_manager']) ? $_POST['use_venue_manager'] : '';
        $org_options['use_personnel_manager'] = isset($_POST['use_personnel_manager']) && !empty($_POST['use_personnel_manager']) ? $_POST['use_personnel_manager'] : '';
        $org_options['use_event_timezones'] = isset($_POST['use_event_timezones']) && !empty($_POST['use_event_timezones']) ? $_POST['use_event_timezones'] : '';
        $org_options['full_logging'] = isset($_POST['full_logging']) && !empty($_POST['full_logging']) ? $_POST['full_logging'] : '';
        $org_options['surcharge'] = isset($_POST['surcharge']) && !empty($_POST['surcharge']) ? $_POST['surcharge'] : '';
        $org_options['surcharge_type'] = isset($_POST['surcharge_type']) && !empty($_POST['surcharge_type']) ? $_POST['surcharge_type'] : '';
        $org_options['surcharge_text'] = isset($_POST['surcharge_text']) && !empty($_POST['surcharge_text']) ? $_POST['surcharge_text'] : '';
        $org_options['show_reg_footer'] = isset($_POST['show_reg_footer']) && !empty($_POST['show_reg_footer']) ? $_POST['show_reg_footer'] : '';
        $org_options['affiliate_id'] = isset($_POST['affiliate_id']) && !empty($_POST['affiliate_id']) ? $_POST['affiliate_id'] : '';
        $org_options['site_license_key'] = isset($_POST['site_license_key']) && !empty($_POST['site_license_key']) ? $_POST['site_license_key'] : '';
        $org_options['default_payment_status'] = isset($_POST['default_payment_status']) && !empty($_POST['default_payment_status']) ? $_POST['default_payment_status'] : '';
        $org_options['default_logo_url'] = isset($_REQUEST['upload_image']) && !empty($_REQUEST['upload_image']) ? $_REQUEST['upload_image'] : '';
        $currency_format = getCountryFullData($org_options['organization_country']);
        switch ($currency_format['iso_code_3']) {
            case 'USA':
                $org_options['currency_symbol'] = '$';
                // US Dollar
                break;
            case 'CHE':
                $org_options['currency_symbol'] = 'Fr.';
                // Swiss Franc
                break;
            case 'AUS':
                $org_options['currency_symbol'] = 'A$';
                // Australian Dollar
                break;
            case 'GBR':
                $org_options['currency_symbol'] = '&pound;';
                // British Pound
                break;
            case 'NOR':
                $org_options['currency_symbol'] = 'kr';
                // Norwegian Krone
                break;
            case 'BRA':
                $org_options['currency_symbol'] = 'R$';
                // Brazillian Real
                break;
            case 'CAN':
                $org_options['currency_symbol'] = 'C$';
                // Canadian Dollar
                break;
            case 'JPN':
                $org_options['currency_symbol'] = '&yen;';
                // Japanese Yen
                break;
            case 'SWE':
                $org_options['currency_symbol'] = 'kr';
                // Swedish Krona
                break;
            case 'DNK':
                $org_options['currency_symbol'] = 'kr';
                // Danish Krone
                break;
            case 'ZAF':
                $org_options['currency_symbol'] = 'R';
                // South African Rand
                break;
            case 'IND':
                $org_options['currency_symbol'] = 'Rs';
                // Indian Rupee
                break;
            case 'TUR':
                $org_options['currency_symbol'] = 'TL';
                // Turkish Lira
                break;
            case 'NZL':
                $org_options['currency_symbol'] = 'NZ$';
                // New Zealand Dollar
                break;
            case 'HKG':
                $org_options['currency_symbol'] = 'HK$';
                // Hong Kong Dollar
                break;
            case 'SGP':
                $org_options['currency_symbol'] = 'S$';
                // Singapore Dollar
                break;
            case 'POL':
                $org_options['currency_symbol'] = 'zl';
                // Polish Zloty (hex code: z&#x0142;)
                break;
            case 'HUN':
                $org_options['currency_symbol'] = 'Ft';
                // Hungarian Forint
                break;
            case 'CZE':
                $org_options['currency_symbol'] = 'Kc';
                // Czech Koruna (hex code: K&#x10D;)
                break;
            case 'ISR':
                $org_options['currency_symbol'] = 'ILS';
                // Israeli Shekel (hex code: &#8362;)
                break;
            case 'MEX':
                $org_options['currency_symbol'] = 'Mex$';
                // Mexican Peso
                break;
            case 'MYS':
                $org_options['currency_symbol'] = 'RM';
                // Malaysian Ringgit
                break;
            case 'PHL':
                $org_options['currency_symbol'] = 'PhP';
                // Phillipine Peso (hex code: &#x20b1;)
                break;
            case 'TWN':
                $org_options['currency_symbol'] = 'NT$';
                // New Taiwan Dollar
                break;
            case 'THA':
                $org_options['currency_symbol'] = 'THB';
                // Thai Baht (hex code: &#xe3f;)
                break;
            case 'AUT' || 'BEL' || 'CYP' || 'EST' || 'FIN' || 'FRA' || 'DEU' || 'GRC' || 'IRL' || 'ITA' || 'LUX' || 'MLT' || 'NLD' || 'PRT' || 'SVK' || 'SVN' || 'ESP' || 'AND' || 'MCO' || 'SMR' || 'VAT' | 'MYT' || 'MNE' || 'XKV' || 'SPM':
                $org_options['currency_symbol'] = 'EUR';
                // use the Euro for all eurozone countries
                break;
            default:
                $org_options['currency_symbol'] = '$';
                break;
        }
        /* if (getCountryZoneId($org_options['organization_country']) == '2') {
        	  $org_options['currency_symbol'] = 'Euro: '; //Creates the symbol for the Euro
        	  } */
        update_option('events_organization_settings', $org_options);
        echo '<div id="message" class="updated fade"><p><strong>' . __('Organization details saved.', 'event_espresso') . '</strong></p></div>';
    }
    $org_options = get_option('events_organization_settings');
    $values = array(array('id' => 'Y', 'text' => __('Yes', 'event_espresso')), array('id' => 'N', 'text' => __('No', 'event_espresso')));
    ?>
	<div class="wrap columns-2">
		<div id="icon-options-event" class="icon32"> </div>
		<h2>
			<?php 
    _e('General Settings', 'event_espresso');
    ?>
		</h2>
		<?php 
    ob_start();
    ?>
		<div class="meta-box-sortables ui-sortable">
			<form class="espresso_form" method="post" action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
">
				<ul id="event_espresso-sortables">
					<li>
						<div class="metabox-holder">
							<div class="postbox">
								<div title="Click to toggle" class="handlediv"><br />
								</div>
								<h3 class="hndle">
									<?php 
    _e('Organization Settings', 'event_espresso');
    ?>
								</h3>
								<div class="inside">
									<div class="padding">
									<h4>
											<?php 
    _e('Company Logo', 'event_espresso');
    ?>
										</h4>
											<ul>
												<li><label for="upload_image">
															<?php 
    _e('Add a Default Logo', 'event_espresso');
    ?>
															<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=espresso_default_logo_info"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a></label>
															<div id="default-logo-image">
															<?php 
    $org_options['default_logo_url'] = isset($org_options['default_logo_url']) ? $org_options['default_logo_url'] : '';
    ?>
															<input id="upload_image" type="hidden" size="36" name="upload_image" value="<?php 
    echo $org_options['default_logo_url'];
    ?>
" />
															<input id="upload_image_button" type="button" value="Upload Image" />
															<?php 
    if ($org_options['default_logo_url'] != '') {
        ?>
																<p class="default-logo-thumb"><img src="<?php 
        echo $org_options['default_logo_url'];
        ?>
" alt="" /><br />
																<a id="remove-image" href="#" title="Remove this image" onclick="return false;"><?php 
        _e('Remove Image', 'event_espresso');
        ?>
</a></p>
															<?php 
    }
    ?>
														</div>
														<div id="espresso_default_logo_info" class="pop-help" style="display:none">
															<h2>
																<?php 
    _e('Default Logo', 'event_espresso');
    ?>
															</h2>
															<p><?php 
    echo __('The default logo will be used in your custom invoice, ticketing, certificates, and payment templates.', 'event_espresso');
    ?>
</p>
														</div>
														</li>
														<li><h4><?php 
    _e('Contact Information', 'event_espresso');
    ?>
</h4></li>									
											<li>
												<label for="org_name">
													<?php 
    _e('Organization Name:', 'event_espresso');
    ?>
												</label>
												<input type="text" name="org_name" size="45" value="<?php 
    echo stripslashes_deep($org_options['organization']);
    ?>
" />
											</li>
											<li>
												<label for="org_street1">
													<?php 
    _e('Organization Street 1:', 'event_espresso');
    ?>
												</label>
												<input type="text" name="org_street1" size="45" value="<?php 
    echo $org_options['organization_street1'];
    ?>
" />
											</li>
											<li>
												<label for="org_street2">
													<?php 
    _e('Organization Street 2:', 'event_espresso');
    ?>
												</label>
												<input type="text" name="org_street2" size="45" value="<?php 
    echo $org_options['organization_street2'];
    ?>
" />
											</li>
											<li>
												<label for="org_city">
													<?php 
    _e('Organization City:', 'event_espresso');
    ?>
												</label>
												<input type="text" name="org_city" size="45" value="<?php 
    echo $org_options['organization_city'];
    ?>
" />
											</li>
											<li>
												<label for="org_state">
													<?php 
    _e('Organization State:', 'event_espresso');
    ?>
												</label>
												<input type="text" name="org_state" size="45" value="<?php 
    echo $org_options['organization_state'];
    ?>
" />
											</li>
											<li>
												<label for="org_zip">
													<?php 
    _e('Organization Zip/Postal Code:', 'event_espresso');
    ?>
												</label>
												<input type="text" name="org_zip" size="10" value="<?php 
    echo $org_options['organization_zip'];
    ?>
" />
											</li>
											<li>
												<label for="org_country">
													<?php 
    _e('Organization Country:', 'event_espresso');
    ?>
												</label>
												<?php 
    printCountriesSelector("org_country", $org_options['organization_country']);
    ?>
 (<?php 
    echo $org_options['currency_symbol'];
    ?>
)</li>
											<li>
												<label for="email">
													<?php 
    _e('Primary contact email:', 'event_espresso');
    ?>
												</label>
												<input type="text" name="email" size="45" value="<?php 
    echo $org_options['contact_email'];
    ?>
" />
											</li>
											<li>
												<h4>
													<?php 
    _e('Time and Date Settings', 'event_espresso');
    ?>
												</h4>
											</li >
											<li class="time-date">
												<p> <span class="run-in">
														<?php 
    _e('Current Time: ', 'event_espresso');
    ?>
													</span><span class="current-date"> <?php 
    echo date(get_option('date_format') . ' ' . get_option('time_format'));
    ?>
 </span><a class="change-date-time" href="options-general.php" target="_blank">
														<?php 
    _e('Change timezone and date format settings?', 'event_espresso');
    ?>
													</a> </p>
												<p> <span class="important">
														<?php 
    _e('Note:', 'event_espresso');
    ?>
													</span>
													<?php 
    _e('You must set the time zone for your city, or the city closest to you. UTC time will not work.', 'event_espresso');
    ?>
													<a href="http://ee-updates.s3.amazonaws.com/images/time-zone-settings-example.jpg" class="thickbox">View an example?</a> </p>
											</li>
											
										</ul>
										
										<p>
											<input class="button-primary" type="submit" name="Submit" value="<?php 
    _e('Save Options', 'event_espresso');
    ?>
" id="save_organization_saetting_1" />
										</p>
									</div>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="metabox-holder">
							<div class="postbox">
								<div title="Click to toggle" class="handlediv"><br />
								</div>
								<h3 class="hndle">
									<?php 
    _e('Page Settings', 'event_espresso');
    ?>
								</h3>
								<div class="inside">
									<div class="padding"> <a name="page_settings" id="page_settings"></a>
										<?php 
    if (empty($org_options['event_page_id']) || empty($org_options['return_url']) || empty($org_options['notify_url']) || empty($org_options['cancel_return'])) {
        espresso_create_default_pages();
    }
    //Check to see if we are using the deprecated SSL option. If we are, recommend updating to WordPress HTTPS (SSL).
    if (!empty($org_options['event_ssl_active']) && $espresso_premium == true && $org_options['event_ssl_active'] == 'Y') {
        echo '<div id="ssl-reg" style="background-color: #ffffe0; border: #e6db55 1px solid; padding:4px;">';
        echo '<p><strong>' . __('Attention!', 'event_espresso') . '</strong><br />' . __('The Secure Payment System has been removed.', 'event_espresso') . '</p>';
        echo '<p>' . __('If your site uses SSL to handle secure transactions. Please install the <a href="http://ee-updates.s3.amazonaws.com/espresso-https.1.0.zip" title="Download Now">Event Espresso SSL/HTTPS</a> plugin now.', 'event_espresso') . ' ' . __('<a href="http://eventespresso.com/forums/2011/09/use-wordpress-https-for-ssl-encryption-on-your-event-espresso-site/" target="_blank">More information here</a>.', 'event_espresso') . '</p>';
        $ssl_values = array(array('id' => 'N', 'text' => __('Yes', 'event_espresso')), array('id' => 'Y', 'text' => __('No', 'event_espresso')));
        ?>
											<label for="event_ssl_active">
												<?php 
        _e('Turn off this message?', 'event_espresso');
        ?>
											</label>
											<br />
											<?php 
        echo select_input('event_ssl_active', $ssl_values, $org_options['event_ssl_active']);
        echo '</div>';
    }
    ?>
										<p>
											<?php 
    _e('The following shortcodes and page settings are required for Event Espresso to function properly. These shortcodes should not be replaced with any other shortcodes. Please view <a href="admin.php?page=support#shortcodes">this page</a> for a list of optional shortcodes.', 'event_espresso');
    ?>
										</p>
										<p>
											<label for="event_page_id">
												<?php 
    _e('Main registration page:', 'event_espresso');
    ?>
											</label>
											<select name="event_page_id">
												<option value="0">
													<?php 
    _e('Main page', 'event_espresso');
    ?>
												</option>
												<?php 
    parent_dropdown($default = $org_options['event_page_id']);
    ?>
											</select>
											<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=registration_page_info"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a><br />
											<span class="messages"><?php 
    echo sprintf(__("This page should contain the %s shortcode. <br />This page can be hidden from navigation if desired, <br />but should always contain the %s shortcode.", 'event_espresso'), '<span class="highlight">[ESPRESSO_EVENTS]</span>', '[ESPRESSO_EVENTS]');
    ?>
)</span></p>
										<?php 
    ###### Popup help box #######
    ?>
										<div id="registration_page_info" class="pop-help" style="display:none">
											<h2>
												<?php 
    _e('Main Events Page', 'event_espresso');
    ?>
											</h2>
											<p><?php 
    echo sprintf(__('This is the page that displays your events and doubles as your registration page. It is very important that this page always contains the %s shortcode.', 'event_espresso'), '<strong>[ESPRESSO_EVENTS]</strong>');
    ?>
</p>
											<p><?php 
    echo sprintf(__("This page should ALWAYS contain the %s shortcode.", 'event_espresso'), '<strong>[ESPRESSO_EVENTS]</strong>');
    ?>
</p>
										</div>
										<?php 
    ###### close popup help box ######
    ?>
										<p>
											<label for="return_url">
												<?php 
    _e('Auto Return URL (Thank You and Return Payment page):', 'event_espresso');
    ?>
											</label>
											<select name="return_url">
												<option value="0">
													<?php 
    _e('Main page', 'event_espresso');
    ?>
												</option>
												<?php 
    parent_dropdown($default = $org_options['return_url']);
    ?>
											</select>
											<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=return_url_info" target="_blank"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a><br />
											<span class="messages">(<?php 
    echo sprintf(__("This page should contain the %s shortcode.<br />This page should hidden from your navigation,<br />but still viewable to the public (not password protected.)", 'event_espresso'), '<span class="highlight">[ESPRESSO_PAYMENTS]</span>');
    ?>
 </span></p>
										<?php 
    ##### Popup help box #####
    ?>
										<div id="return_url_info" class="pop-help" style="display:none">
											<h2>
												<?php 
    _e('Auto Return URL', 'event_espresso');
    ?>
											</h2>
											<p>
												<?php 
    _e('The URL to which the payer\'s browser is redirected after completing the payment; for example, a URL on your site that displays a "Thank you for your payment" page.', 'event_espresso');
    ?>
											</p>
											<p><?php 
    echo sprintf(__("This page should contain the %s shortcode.", 'event_espresso'), '<strong>[ESPRESSO_PAYMENTS]</strong>');
    ?>
</p>
											<p><em class="important"><b>
														<?php 
    _e('ATTENTION:', 'event_espresso');
    ?>
													</b><br />
													<?php 
    _e('This page should be hidden from from your navigation menu. Exclude pages by using the "Exclude Pages" plugin from http://wordpress.org/extend/plugins/exclude-pages/ or using the "exclude" parameter in your "wp_list_pages" template tag. Please refer to http://codex.wordpress.org/Template_Tags/wp_list_pages for more inforamation about excluding pages.', 'event_espresso');
    ?>
												</em> </p>
										</div>
										<?php 
    ##### close popup help #####
    ?>
										<p>
											<label for="cancel_return">
												<?php 
    _e('Cancel Return URL (used for cancelled payments):', 'event_espresso');
    ?>
											</label>
											<select name="cancel_return">
												<option value="0">
													<?php 
    _e('Main page', 'event_espresso');
    ?>
												</option>
												<?php 
    parent_dropdown($default = $org_options['cancel_return']);
    ?>
											</select>
											<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=cancel_return_info"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a><br />
											<span class="messages">(
												<?php 
    echo sprintf(__("This should be a page on your website that contains a cancelled message %s and the %s shortcode. This page should hidden %s from your navigation, but still viewable to the public (not password protected.)", 'event_espresso'), '<br />', '<span class="highlight">[ESPRESSO_CANCELLED]</span>', '<br />');
    ?>
												)</span></p>
										<?php 
    ##### popup help box #####
    ?>
										<div id="cancel_return_info" class="pop-help" style="display:none">
											<h2>
												<?php 
    _e('Cancel Return URL', 'event_espresso');
    ?>
											</h2>
											<p>
												<?php 
    _e('A URL to which the payer\'s browser is redirected if payment is cancelled; for example, a URL on your website that displays a "Payment Canceled" page.', 'event_espresso');
    ?>
											</p>
											<p>
												<?php 
    echo sprintf(__("This should be a page on your website that contains a cancelled message and the %s shortcode.", 'event_espresso'), '<strong>[ESPRESSO_CANCELLED]</strong>');
    ?>
											</p>
											<p><em class="important"><b>
														<?php 
    _e('ATTENTION:', 'event_espresso');
    ?>
													</b><br />
													<?php 
    _e('This page should be hidden from from your navigation menu. Exclude pages by using the "Exclude Pages" plugin from http://wordpress.org/extend/plugins/exclude-pages/ or using the "exclude" parameter in your "wp_list_pages" template tag. Please refer to http://codex.wordpress.org/Template_Tags/wp_list_pages for more inforamation about excluding pages.', 'event_espresso');
    ?>
												</em></p>
										</div>
										<?php 
    ##### close popup help box #####
    ?>
										<p>
											<label for="notify_url">
												<?php 
    _e('Notify URL (used to process payments):', 'event_espresso');
    ?>
											</label>
											<select name="notify_url">
												<option value="0">
													<?php 
    _e('Main page', 'event_espresso');
    ?>
												</option>
												<?php 
    parent_dropdown($default = $org_options['notify_url']);
    ?>
											</select>
											<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=notify_url_info"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a><br />
											<span class="messages">(<?php 
    echo sprintf(__("This page should contain the %s shortcode.<br />This page should hidden from your navigation, <br />but still viewable to the public (not password protected.)", 'event_espresso'), '<span class="highlight">[ESPRESSO_TXN_PAGE]</span>');
    ?>
</span></p>
										<?php 
    ##### popup help box #####
    ?>
										<div id="notify_url_info" class="pop-help" style="display:none">
											<h2>
												<?php 
    _e('Notify URL', 'event_espresso');
    ?>
											</h2>
											<p>
												<?php 
    _e('The URL to which PayPal posts information about the transaction, in the form of Instant Payment Notification messages.', 'event_espresso');
    ?>
											</p>
											<p> <?php 
    echo sprintf(__('This page should contain the %s shortcode.', 'event_espresso'), '<strong>[ESPRESSO_TXN_PAGE]</strong>');
    ?>
 </p>
											<p><em class="important"><b>
														<?php 
    _e('ATTENTION:', 'event_espresso');
    ?>
													</b><br />
													<?php 
    _e('This page should be hidden from from your navigation menu. Exclude pages by using the "Exclude Pages" plugin from http://wordpress.org/extend/plugins/exclude-pages/ or using the "exclude" parameter in your "wp_list_pages" template tag. Please refer to http://codex.wordpress.org/Template_Tags/wp_list_pages for more inforamation about excluding pages.', 'event_espresso');
    ?>
												</em> </p>
										</div>
										<p>
											<input class="button-primary" type="submit" name="Submit" value="<?php 
    _e('Save Options', 'event_espresso');
    ?>
" id="save_organization_saetting_2" />
										</p>
									</div>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="metabox-holder">
							<div class="postbox">
								<div title="Click to toggle" class="handlediv"><br />
								</div>
								<h3 class="hndle">
									<?php 
    _e('Email Settings', 'event_espresso');
    ?>
								</h3>
								<div class="inside">
									<div class="padding"><a name="email-settings" id="email-settings"></a>
										<?php 
    $values = array(array('id' => 'Y', 'text' => __('Yes', 'event_espresso')), array('id' => 'N', 'text' => __('No', 'event_espresso')));
    ?>
										<p>
											<?php 
    _e('Send payment confirmation emails?', 'event_espresso');
    echo select_input('default_mail', $values, $org_options['default_mail']);
    ?>
										</p>
										<p>
											<?php 
    _e('Send registration confirmation emails before payment is received?', 'event_espresso');
    echo select_input('email_before_payment', $values, $org_options['email_before_payment']);
    ?>
										</p>
										<p>
	<?php 
    _e('Use fancy email headers?', 'event_espresso');
    echo select_input('email_fancy_headers', $values, $org_options['email_fancy_headers']);
    ?>
											<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=fancyemailheaders"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a>
										</p>
												<?php 
    ###### Popup help box #######
    ?>
										<div id="fancyemailheaders" class="pop-help" style="display:none">
											<h2>
	<?php 
    _e('Fancy Email Headers', 'event_espresso');
    ?>
											</h2>
											<p><?php 
    echo sprintf(__("This option enables the use of the email header format %s From: name %s %s Reply-to: name %s %s.", 'event_espresso'), '<br />', '&lt;email@address.com&gt;', '<br />', '&lt;email@address.com&gt;', '<br />');
    ?>
</p>
											<p><?php 
    _e("You should only use this if you know it will not cause email delivery problems. Some servers will not send emails that use this format.", 'event_espresso');
    ?>
</p>
										</div>
										<h4>
												<?php 
    _e('Payment Confirmation Email:', 'event_espresso');
    ?>
										</h4>
										<p>
											<label for="payment_subject">
	<?php 
    _e('Email Subject:', 'event_espresso');
    ?>
											</label>
											<input id="payment_subject" name="payment_subject" size="50" type="text" value="<?php 
    echo stripslashes_deep($org_options['payment_subject']);
    ?>
" />
										</p>

										<div id="payment-conf-email" class="postbox">
											<?php 
    if (function_exists('wp_editor')) {
        $args = array("textarea_rows" => 5, "textarea_name" => "payment_message", "editor_class" => "my_editor_custom");
        wp_editor(espresso_admin_format_content($org_options['payment_message']), "payment_message", $args);
    } else {
        echo '<textarea class="theEditor std-textarea" id="payment_message" name="payment_message">' . espresso_admin_format_content($org_options['payment_message']) . '</textarea>';
    }
    ?>
	<?php 
    /* ?><textarea class="theEditor std-textarea" id="payment_message" name="payment_message"><?php echo espresso_admin_format_content($org_options['payment_message']); ?></textarea><?php */
    ?>
											<table id="payment-confirmation-form" cellspacing="0">
												<tbody>
													<tr>
														<td class="aer-word-count"></td>
														<td class="autosave-info"><span><a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=custom_email_info">
	<?php 
    _e('View Custom Email Tags', 'event_espresso');
    ?>
																</a></span></td>
													</tr>
												</tbody>
											</table>
										</div>
										<h4>
											<?php 
    _e('Default Registration Confirmation Email:', 'event_espresso');
    ?>
										</h4>

										<div id="reg-conf-email" class="postbox">
											<?php 
    if (function_exists('wp_editor')) {
        $args = array("textarea_rows" => 5, "textarea_name" => "success_message", "editor_class" => "my_editor_custom");
        wp_editor(espresso_admin_format_content($org_options['message']), "success_message", $args);
    } else {
        echo '<textarea class="theEditor std-textarea" id="success_message" name="success_message">' . espresso_admin_format_content($org_options['message']) . '</textarea>';
    }
    ?>
	<?php 
    /* ?><textarea class="theEditor std-textarea"  id="reg-conf-email-mce" name="success_message"><?php echo espresso_admin_format_content($org_options['message']); ?></textarea><?php */
    ?>
											<table id="email-confirmation-form" cellspacing="0">
												<tbody>
													<tr>
														<td class="aer-word-count"></td>
														<td class="autosave-info"><span><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('Example', 'event_espresso');
    ?>
																</a></span></td>
													</tr>
												</tbody>
											</table>
										</div>
										<p>
											<input class="button-primary" type="submit" name="Submit" value="<?php 
    _e('Save Options', 'event_espresso');
    ?>
" id="save_organization_saetting_5" />
										</p>
									</div>
								</div>
							</div>
						</div>
						<div style="clear:both;"></div>
					</li>
					<li>
						<h2>
					<?php 
    _e('Advanced Features', 'event_espresso');
    ?>
						</h2>
						<hr />
					</li>
					<?php 
    if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/recaptcha_form.php') || file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/optional_event_settings.php')) {
        if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/optional_event_settings.php')) {
            echo '<li>';
            require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/optional_event_settings.php';
            echo '</li>';
        }
        if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/recaptcha_form.php')) {
            echo '<li>';
            require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/recaptcha_form.php';
            echo '</li>';
        }
    } else {
        ?>
						<li>
							<div class="metabox-holder">
								<div class="postbox">
									<div title="Click to toggle" class="handlediv"><br />
									</div>
									<h3 class="hndle">
		<?php 
        _e('Optional Event Settings', 'event_espresso');
        ?>
									</h3>
									<div class="inside">
										<div class="padding">
											<p><?php 
        echo __('Please purchase a', 'event_espresso');
        ?>
 <a href="http://eventespresso.com/download/" target="_blank"><?php 
        echo __('support license', 'event_espresso');
        ?>
</a> <?php 
        echo __('to gain access to these features.', 'event_espresso');
        ?>
</p>
											<p>
													<?php 
        _e('Additional features include:', 'event_espresso');
        ?>
											</p>
											<ol>
												<li>
													<?php 
        _e('Upcoming events widget in the admin dashboard', 'event_espresso');
        ?>
												</li>
												<li>
													<?php 
        _e('Registration limits on time slots', 'event_espresso');
        ?>
												</li>
												<li>
													<?php 
        _e('Ability to display short descriptions in the event listings', 'event_espresso');
        ?>
												</li>
												<li>
													<?php 
        _e('Custom post types for events', 'event_espresso');
        ?>
												</li>
												<li>
													<?php 
        _e('Attendee pre-approval feature', 'event_espresso');
        ?>
												</li>
												<li>
													<?php 
        _e('Event Venue/Staff Manager', 'event_espresso');
        ?>
												</li>
												<li>
		<?php 
        _e('Graphical Reports', 'event_espresso');
        ?>
												</li>
											</ol>
										</div>
									</div>
								</div>
							</div>
						</li>
						<li>
							<div class="metabox-holder">
								<div class="postbox">
									<div title="Click to toggle" class="handlediv"><br />
									</div>
									<h3 class="hndle">
		<?php 
        _e('reCAPTCHA Settings', 'event_espresso');
        ?>
									</h3>
									<div class="inside">
										<div class="padding">
											<p><?php 
        echo __('Please purchase a', 'event_espresso');
        ?>
 <a href="http://eventespresso.com/download/" target="_blank"><?php 
        echo __('support license', 'event_espresso');
        ?>
</a> <?php 
        echo __('to gain access to this feature.', 'event_espresso');
        ?>
</p>
											<p> <?php 
        echo sprintf(__('reCAPTCHA helps prevent automated abuse of your site (such as comment spam or bogus registrations) by using a %s to ensure that only humans perform certain actions.', 'event_espresso'), '<a href="http://recaptcha.net/captcha.html">CAPTCHA</a>');
        ?>
 </p>
										</div>
									</div>
								</div>
							</div>
						</li>
						<?php 
    }
    if ($espresso_check_for_updates == true && $espresso_premium == true) {
        ?>

						<li><a name="license_key" id="license_key"></a>
							<div class="metabox-holder">
								<div class="postbox">
									<div title="Click to toggle" class="handlediv"><br />
									</div>
									<h3 class="hndle">
		<?php 
        _e('Support License', 'event_espresso');
        ?>
									</h3>
									<div class="inside">
										<div class="padding">
											<ul>
												<li>
													<label for="site_license_key">
		<?php 
        _e('Site License Key:', 'event_espresso');
        ?>
													</label>
													<input type="text" name="site_license_key" size="45" value="<?php 
        echo isset($org_options['site_license_key']) ? stripslashes_deep($org_options['site_license_key']) : '';
        ?>
" />
												</li>

											</ul>
											<p>
												<input class="button-primary" type="submit" name="Submit" value="<?php 
        _e('Save Options', 'event_espresso');
        ?>
" id="save_organization_saetting_5" />
											</p>
										</div>
									</div>
								</div>
							</div>
						</li>
	<?php 
    }
    ?>
				</ul>
				<input type="hidden" name="update_org" value="update" />
			</form>
		</div>
		<?php 
    $post_content = ob_get_clean();
    espresso_choose_layout($post_content, event_espresso_display_right_column());
    ?>
	</div>
	<script type="text/javascript" charset="utf-8">
		//<![CDATA[
		jQuery(document).ready(function() {
			postboxes.add_postbox_toggles('event_espresso');

			//Logo uploader
			var header_clicked = false;
			jQuery('#upload_image_button').click(function() {
				formfield = jQuery('#upload_image').attr('name');
				tb_show('', 'media-upload.php?type=image&amp;TB_iframe=1');
				jQuery('p.default-logo-thumb').addClass('old');
				header_clicked = true;
				return false;
			});
			window.original_send_to_editor = window.send_to_editor;

			window.send_to_editor = function(html) {
				if(header_clicked) {
					//Remove old image
					jQuery("#upload_image").val('');
					jQuery("p.default-logo-thumb").remove();
					jQuery("p#image-display").remove();
					jQuery('#remove-image').remove();
					
					//Add new image
					imgurl = jQuery('img',html).attr('src');
					jQuery('#' + formfield).val(imgurl);
					jQuery('#default-logo-image').append("<p id='image-display'><img src='"+imgurl+"' alt='' /></p>");
					header_clicked = false;
					tb_remove();
				} else {
					window.original_send_to_editor(html);
				}
			}
			
			// process the remove link in the metabox
			jQuery('#remove-image').click(function(){
				var answer = confirm('<?php 
    _e('Do you really want to delete this image? Please remember to save your settings to complete the removal.', 'event_espresso');
    ?>
');
				if (answer){
					jQuery("#upload_image").val('');
					jQuery("p.default-logo-thumb").remove();
					jQuery("p#image-display").remove();
					jQuery('#remove-image').remove();
				}
				return false;
			});

		});
		//]]>
	</script>
	<?php 
    echo event_espresso_custom_email_info();
    if (!function_exists('wp_editor')) {
        espresso_tiny_mce();
    }
}
function add_new_event()
{
    global $wpdb, $org_options, $espresso_premium;
    ob_start();
    if (empty($event_name)) {
        $event_name = '';
    }
    ?>
<!--New event display-->
		<div id="submitdiv" class="postbox">
			<div class="handlediv" title="Click to toggle"><br />
			</div>
			<h3 class="hndle"> <span>
				<?php 
    _e('New Event', 'event_espresso');
    ?>
				</span> </h3>
			<div class="inside">
				<div class="submitbox" id="submitpost"><!-- /minor-publishing -->
					<div id="major-publishing-actions" class="clearfix">
						<div id="delete-action"> <a class="submitdelete deletion" href="admin.php?page=events" onclick="return confirm('<?php 
    _e('Are you sure you want to cancel ' . $event_name . '?', 'event_espresso');
    ?>
')">
							<?php 
    _e('Cancel', 'event_espresso');
    ?>
							</a> </div>
						<div id="publishing-action">
							<input class="button-primary" type="submit" name="Submit" value="<?php 
    _e('Submit New Event', 'event_espresso');
    ?>
" id="add_new_event" />
						</div>
						<!-- /publishing-action --> 
					</div>
					<!-- /major-publishing-actions --> 
				</div>
				<!-- /submitpost --> 
			</div>
			<!-- /inside --> 
		</div>
		<!-- /submitdiv -->
		
<?php 
    if ($espresso_premium == true) {
        do_action('action_hook_espresso_new_event_right_column_top');
    }
    $values = array(array('id' => 'Y', 'text' => __('Yes', 'event_espresso')), array('id' => 'N', 'text' => __('No', 'event_espresso')));
    $event_meta = isset($event_meta) ? $event_meta : array();
    $advanced_options = '';
    if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/event-management/advanced_settings.php')) {
        require_once EVENT_ESPRESSO_PLUGINFULLPATH . "includes/admin-files/event-management/advanced_settings.php";
    } else {
        //Display Lite version options
        $status = array(array('id' => 'A', 'text' => __('Active', 'event_espresso')), array('id' => 'D', 'text' => __('Deleted', 'event_espresso')));
        $advanced_options = '<p><strong>' . __('Advanced Options:', 'event_espresso') . '</strong></p>' . '<p>' . __('Is this an active event? ', 'event_espresso') . __(select_input('is_active', $values, $is_active)) . '</p>' . '<p>' . __('Display  description? ', 'event_espresso') . select_input('display_desc', $values, $display_desc) . '</p>' . '<p>' . __('Display  registration form? ', 'event_espresso') . select_input('display_reg_form', $values, $display_reg_form) . '</p>';
    }
    //Display Lite version options - End
    $reg_limit = isset($reg_limit) ? $reg_limit : '';
    $additional_limit = isset($additional_limit) ? $additional_limit : '';
    espresso_postbox('event-status', 'Event Options', '<p>' . __('Attendee Limit', 'event_espresso') . ': <input name="reg_limit" size="10" type="text" value="' . $reg_limit . '"><br />' . '(' . __('leave blank for unlimited', 'event_espresso') . ')</p>' . '<p>' . __('Allow group registrations?', 'event_espresso') . ' ' . select_input('allow_multiple', $values, 'N') . '<p>' . __('Max Group Registrants', 'event_espresso') . ': <input type="text" name="additional_limit" value="' . $additional_limit . '" size="4">' . $advanced_options);
    if (function_exists('espresso_ticket_dd') && $espresso_premium == true) {
        ?>
		<div id="event-category" class="postbox">
			<div class="handlediv" title="Click to toggle"><br>
			</div>
			<h3 class="hndle"> <span>
				<?php 
        _e('Custom Tickets', 'event_espresso');
        ?>
				</span> </h3>
			<div class="inside"> <?php 
        echo espresso_ticket_dd(0);
        ?>
 </div>
		</div>
	<?php 
    }
    //Custom ticket selector
    if ($espresso_premium == true) {
        ?>
		<div id="featured-image-options" class="postbox">
				<div class="handlediv" title="Click to toggle"><br />
				</div>
				<h3 class="hndle"> <span>
					<?php 
        _e('Featured Image', 'event_espresso');
        ?>
					</span> </h3>
		<div class="inside">
			<div id="featured-image">
				<?php 
        if (!empty($event_meta['event_thumbnail_url'])) {
            $event_thumb = $event_meta['event_thumbnail_url'];
        } else {
            $event_thumb = '';
        }
        ?>
				<label for="upload_image">
					<?php 
        _e('Add Featured Image', 'event_espresso');
        ?>
				</label>
				<input id="upload_image" type="hidden" size="36" name="upload_image" value="<?php 
        echo $event_thumb;
        ?>
" />
				<input id="upload_image_button" type="button" value="Upload Image" />
				<?php 
        if ($event_thumb) {
            ?>
					<p class="event-featured-thumb"><img  src="<?php 
            echo $event_thumb;
            ?>
" alt="" /></p>
					<a id='remove-image' href='#' title='Remove this image' onclick='return false;'><?php 
            _e('Remove Image', 'event_espresso');
            ?>
</a>
				<?php 
        }
        ?>
			</div>
		</div>
		</div>
	<?php 
    }
    /*
     * Added for seating chart addon
     */
    if (defined('ESPRESSO_SEATING_CHART')) {
        ?>
		<div style="display: block;" id="seating_chart-options" class="postbox">
			<div class="handlediv" title="Click to toggle"><br />
			</div>
			<h3 class="hndle"><span>
				<?php 
        _e('Seating chart', 'event_espresso');
        ?>
				</span></h3>
			<div class="inside">
				<p>
					<select name="seating_chart_id" id="seating_chart_id" style="float:none;">
						<option value="0" ><?php 
        _e('None', 'event_espresso');
        ?>
</option>
						<?php 
        $seating_charts = $wpdb->get_results("select * from " . EVENTS_SEATING_CHART_TABLE . " order by name");
        foreach ($seating_charts as $seating_chart) {
            ?>
						<option value="<?php 
            echo $seating_chart->id;
            ?>
"><?php 
            echo $seating_chart->name;
            ?>
</option>
						<?php 
        }
        ?>
					</select>
				</p>
			</div>
		</div>
		<?php 
    }
    /*
     * End
     */
    ###### Modification by wp-developers to introduce attendee pre-approval requirement ##########
    if (isset($org_options['use_attendee_pre_approval']) && $org_options['use_attendee_pre_approval'] == 'Y' && $espresso_premium == true) {
        ?>
		<div id="attendee-pre-approval-options" class="postbox">
			<div class="handlediv" title="Click to toggle"><br />
			</div>
			<h3 class="hndle"> <span>
				<?php 
        _e('Attendee pre-approval required?', 'event_espresso');
        ?>
				</span> </h3>
			<div class="inside">
				<p class="pre-approve">
					<?php 
        $pre_approval_values = array(array('id' => '1', 'text' => __('Yes', 'event_espresso')), array('id' => '0', 'text' => __('No', 'event_espresso')));
        echo select_input("require_pre_approval", $pre_approval_values, "0");
        ?>
				</p>
			</div>
		</div>
		<?php 
    }
    ########## END #################################
    if (defined('EVENTS_MEMBER_REL_TABLE') && $espresso_premium == true) {
        ?>
		<div id="member-options" class="postbox">
			<div class="handlediv" title="Click to toggle"><br />
			</div>
			<h3 class="hndle"> <span>
				<?php 
        _e('Member Options', 'event_espresso');
        ?>
				</span> </h3>
			<div class="inside">
				<p><?php 
        echo event_espresso_member_only('N');
        ?>
</p>
			</div>
		</div>
		<!-- /event-category -->
		<?php 
    }
    if (defined('EVENTS_MAILCHIMP_ATTENDEE_REL_TABLE') && $espresso_premium == true) {
        MailChimpView::event_list_selection();
    }
    ?>
		
		<div  id="event-categories" class="postbox">
			<div class="handlediv" title="Click to toggle"><br />
			</div>
			<h3 class="hndle"> <span>
				<?php 
    _e('Event Category', 'event_espresso');
    ?>
				</span> </h3>
			<div class="inside"> <?php 
    echo event_espresso_get_categories();
    ?>
 </div>
		</div>
		<!-- /event-category -->
		
		<?php 
    if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/event-management/promotions_box.php')) {
        require_once EVENT_ESPRESSO_PLUGINFULLPATH . "includes/admin-files/event-management/promotions_box.php";
    }
    ?>
		<?php 
    echo espresso_event_question_groups(empty($question_groups) ? array() : $question_groups);
    ?>
 
		<!-- /event-questions -->
		
		<?php 
    do_action('action_hook_espresso_staff_cb');
    if (defined('EVENTS_GROUPON_CODES_TABLE') && $espresso_premium == true) {
        ?>
		<div id="groupon-options" class="postbox">
			<div class="handlediv" title="Click to toggle"><br />
			</div>
			<h3 class="hndle"> <span>
				<?php 
        _e('Groupon Options', 'event_espresso');
        ?>
				</span> </h3>
			<div class="inside">
				<p><?php 
        echo event_espresso_add_new_event_groupon();
        ?>
</p>
			</div>
		</div>
		<!-- /groupon-options -->
	<?php 
    }
    if ($espresso_premium == true) {
        do_action('action_hook_espresso_new_event_right_column_bottom');
    }
    $sidebar_content = ob_get_clean();
    ob_start();
    ?>
<!-- Left Column-->
		<div id="titlediv"> <strong>
			<?php 
    _e('Event Title', 'event_espresso');
    ?>
			</strong>
			<div id="titlewrap">
				<label class="screen-reader-text" for="title">
					<?php 
    _e('Event Title', 'event_espresso');
    ?>
				</label>
				<input type="text" name="event" size="30" tabindex="1" value="<?php 
    echo isset($event_name) ? $event_name : '';
    ?>
" id="title" autocomplete="off" />
			</div>
			<!-- /titlewrap -->
			<div class="inside">
				<div id="edit-slug-box"> <strong>
					<?php 
    _e('Unique Event Identifier:', 'event_espresso');
    ?>
					</strong>
					<input type="text" size="30" tabindex="2" name="event_identifier" id="event_identifier" value ="<?php 
    echo isset($event_identifier) ? $event_identifier : '';
    ?>
" />
					<?php 
    echo '<a href="#" class="button" onclick="prompt(&#39;Event Shortcode:&#39;, \'[SINGLEEVENT single_event_id=&#34;\' + jQuery(\'#event_identifier\').val() + \'&#34;]\'); return false;">' . __('Get Shortcode') . '</a>';
    ?>
					<?php 
    $org_options['event_page_id'] = isset($org_options['event_page_id']) ? $org_options['event_page_id'] : '';
    $event_id = isset($event_id) ? $event_id : '';
    echo '<a href="#" class="button" onclick="prompt(&#39;Event URL:&#39;, \'' . espresso_reg_url($event_id) . '\'); return false;">' . __('Get URL') . '</a>';
    ?>
				</div>
			</div>
			<!-- /edit-slug-box --> 
		</div>
		<!-- /titlediv -->
		<div id="descriptiondivrich" class="postarea"> <strong>
			<?php 
    _e('Event Description', 'event_espresso');
    ?>
			</strong>
			<?php 
    /*
    This is the editor used by WordPress. It is very very hard to find documentation for this thing, so I pasted everything I could find below.
    param: string $content Textarea content.
    param: string $id Optional, default is 'content'. HTML ID attribute value.
    param: string $prev_id Optional, default is 'title'. HTML ID name for switching back and forth between visual editors.
    param: bool $media_buttons Optional, default is true. Whether to display media buttons.
    param: int $tab_index Optional, default is 2. Tabindex for textarea element.
    */
    //the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2)
    //
    if (function_exists('wp_editor')) {
        $args = array("textarea_rows" => 5, "textarea_name" => "event_desc", "editor_class" => "my_editor_custom");
        wp_editor("", "event_desc", $args);
    } else {
        the_editor('', $id = 'event_desc', $prev_id = 'title', $media_buttons = true, $tab_index = 3);
    }
    ?>
			<table id="post-status-info" cellspacing="0">
				<tbody>
					<tr>
						<td id="wp-word-count"></td>
						<td class="autosave-info"><span id="autosave">&nbsp;</span></td>
					</tr>
				</tbody>
			</table>
		</div>
		<!-- /postdivrich -->
		<?php 
    $main_post_content = ob_get_clean();
    ob_start();
    ?>
		<div id="normal-sortables" class="meta-box-sortables ui-sortable">
			<div  id="event-date-time" class="postbox">
				<div class="handlediv" title="Click to toggle"><br />
				</div>
				<h3 class="hndle"> <span>
					<?php 
    _e('Event Date/Times', 'event_espresso');
    ?>
					</span> </h3>
				<div class="inside">
					<table width="100%" border="0" cellpadding="5">
						<tr valign="top">
							<td class="a"><fieldset id="add-reg-dates">
									<legend>
									<?php 
    _e('Registration Dates', 'event_espresso');
    ?>
									</legend>
									<p>
										<label for="registration_start"><?php 
    echo __('Registration Start:', 'event_espresso');
    ?>
 </label>
										<input type="text" size="10" id="registration_start" class="datepicker" name="registration_start" value="" />
									</p>
									<p>
										<label for="registration_end"> <?php 
    echo __('Registration End:', 'event_espresso');
    ?>
</label>
										<input type="text" size="10" id="registration_end" class="datepicker" name="registration_end" value="" />
									</p>
									<p><span class="description">
									<?php 
    _e('All events <strong>require</strong> registration start/end dates and start/end times in order to display properly on your pages.', 'event_espresso');
    ?>
									</span></p>
								</fieldset>
								<fieldset id="add-event-dates">
									<legend>
									<?php 
    _e('Event Dates', 'event_espresso');
    ?>
									</legend>
									<p>
										<label for="start_date">
											<?php 
    _e('Event Start Date:', 'event_espresso');
    ?>
										</label>
										<input type="text" size="10" id="start_date" class="datepicker" name="start_date" value="" />
									</p>
									<p>
										<label for="end_date">
											<?php 
    _e('Event End Date:', 'event_espresso');
    ?>
										</label>
										<input type="text" size="10" id="end_date" class="datepicker" name="end_date" value="" />
									</p>
									
								</fieldset><p><span class="description">
									<?php 
    _e('All events <strong>require</strong> a start and end date in order to display properly on your pages.', 'event_espresso');
    ?>
									</span></p>
								<?php 
    if (isset($org_options['use_event_timezones']) && $org_options['use_event_timezones'] == 'Y' && $espresso_premium == true) {
        ?>
								<fieldset id="event-timezone">
									<p>
										<label>
											<?php 
        _e('Event Timezone:', 'event_espresso');
        ?>
											</label>
										<?php 
        echo eventespresso_ddtimezone($event_id);
        ?>
</p>
								</fieldset>
								<?php 
    }
    ?>
								<?php 
    /* ?> <p>
       <br /> <?php echo __('Event Visible On:','event_espresso') . ' <input type="text" size="15" id="visible_on" class="datepicker" name="visible_on" value="" />'; ?> <br />
                         </p><?php */
    ?>
								<?php 
    echo defined('EVENT_ESPRESSO_RECURRENCE_TABLE') ? '' : '<p class="recurring-available"><a class="inform" href="http://eventespresso.com/product/espresso-recurring/?utm_source=ee_plugin_admin&utm_medium=link&utm_content=Recurring+Event+Manager+Now+Available+ee_version_' . EVENT_ESPRESSO_VERSION . '&utm_campaign=add_new_event_tab" target="_blank" title="Visit eventespresso.com for full details">' . __('Recurring Event Manager Now Available!', 'event_espresso') . '</a></p>';
    ?>
</td>
							<?php 
    // ADDED TIME REGISTRATION LIMITS
    ?>
							<td class="b"><fieldset id="add-register-times">
									<legend>
									<?php 
    _e('Registration Times', 'event_espresso');
    ?>
									</legend>
									<?php 
    echo event_espresso_timereg_editor();
    ?>
								</fieldset>
								<fieldset id="add-event-times">
									<legend>
									<?php 
    _e('Event Times', 'event_espresso');
    ?>
									</legend>
									<?php 
    echo event_espresso_time_editor();
    ?>
								</fieldset>
								<?php 
    if ((isset($org_options['use_event_timezones']) || ($org_options['use_event_timezones'] = 'Y')) && $espresso_premium == true) {
        ?>
								<p><span class="run-in">
									<?php 
        _e('Current Time:', 'event_espresso');
        ?>
									</span> <span class="current-date"> <?php 
        echo date(get_option('date_format')) . ' ' . date(get_option('time_format'));
        ?>
</span> <a class="change-date-time" href="options-general.php" target="_blank">
									<?php 
        _e('Change timezone and date format settings?', 'event_espresso');
        ?>
									</a> </p>
								<?php 
    }
    ?>
</td>
						</tr>
					</table>
				</div>
			</div>
			<?php 
    /**
     * Load the recurring events form if the add-on has been installed and activated.
     */
    if (defined('EVENT_ESPRESSO_RECURRENCE_TABLE') && $espresso_premium == true) {
        require_once EVENT_ESPRESSO_RECURRENCE_FULL_PATH . "functions/re_view_functions.php";
        event_espresso_re_form();
    }
    ?>
			<div id="event-pricing" class="postbox">
				<?php 
    defined('EVENTS_MEMBER_REL_TABLE') ? $members_active = 'class="members-active"' : ($members_active = '');
    ?>
				<div class="handlediv" title="Click to toggle"><br />
				</div>
				<h3 class="hndle"> <span>
					<?php 
    _e('Event Pricing', 'event_espresso');
    ?>
					</span> </h3>
				<div class="inside">
					<table <?php 
    echo $members_active;
    ?>
width="100%" border="0" cellpadding="5">
						<tr valign="top">
							<td id="standard-pricing" class="a"><?php 
    event_espresso_multi_price_update($event_id);
    //Standard pricing
    ?>
</td>
							<?php 
    //If the members addon is installed, define member only event settings
    if (defined('EVENTS_MEMBER_REL_TABLE') && $espresso_premium == true) {
        ?>
							<td id="member-pricing" class="b"><?php 
        echo event_espresso_member_only_pricing();
        //Show the the member only pricing options.
        ?>
</td>
<?php 
    }
    ?>
						</tr>
					</table>
				</div>
			</div>
			<h2>
				<?php 
    _e('Advanced Options', 'event_espresso');
    ?>
			</h2>
			<?php 
    if ($espresso_premium == true) {
        do_action('action_hook_espresso_new_event_left_column_advanced_options_top');
    }
    ?>
			<div id="event-location" class="postbox">
				<div class="handlediv" title="Click to toggle"><br />
				</div>
				<h3 class="hndle"> <span>
					<?php 
    _e('Additional Event/Venue Information', 'event_espresso');
    ?>
					</span> </h3>
				<div class="inside">
					<table width="100%" border="0" cellpadding="5">
							<tr>
						
						<?php 
    if (function_exists('espresso_venue_dd') && isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' && $espresso_premium == true) {
        $ven_type = 'class="use-ven-manager"';
        ?>
						<td <?php 
        echo $ven_type;
        ?>
><fieldset id="venue-manager">
								<legend><?php 
        echo __('Venue Information', 'event_espresso');
        ?>
</legend>
								<?php 
        if (!espresso_venue_dd()) {
            ?>
								<p class="info"><b>
									<?php 
            _e('You have not created any venues yet.', 'event_espresso');
            ?>
									<input id="phys-addr" type="hidden"  value="" name="address" />
									<input id="phys-addr-2" type="hidden"  value="" name="address2" />
									<input id="phys-city" type="hidden"  value="" name="city" />
									<input id="phys-state" type="hidden"  value="" name="state" />
									<input id="zip-postal" type="hidden"  value="" name="zip" />
									<input id="phys-country" type="hidden"  value="" name="country" />
									<input id="ven-title"  type="hidden"  value="" name="venue_title" />
									<input id="ven-website" type="hidden"  value="" name="venue_url" />
									<input id="ven-phone" type="hidden"  value="" name="venue_phone" />
									<input id="ven-image" type="hidden"  value="" name="venue_image" />
									</b></p>
								<p><a href="admin.php?page=event_venues"><?php 
            echo __('Add venues to the Venue Manager', 'event_espresso');
            ?>
</a></p>
								<?php 
        } else {
            ?>
								<?php 
            echo espresso_venue_dd();
            ?>
								<?php 
        }
        ?>
							</fieldset></td>
						<?php 
    } else {
        $ven_type = 'class="manual-venue"';
        ?>
						<td <?php 
        echo $ven_type;
        ?>
><fieldset id="phys-location">
								<legend>
								<?php 
        _e('Physical Location', 'event_espresso');
        ?>
								</legend>
								<p>
									<label for="phys-addr">
										<?php 
        _e('Address:', 'event_espresso');
        ?>
									</label>
									<input id="phys-addr" size="20" tabindex="101"  type="text"  value="" name="address" />
								</p>
								<p>
									<label for="phys-addr-2">
										<?php 
        _e('Address 2:', 'event_espresso');
        ?>
									</label>
									<input id="phys-addr-2" size="20" tabindex="102"  type="text"  value="" name="address2" />
								</p>
								<p>
									<label for="phys-city">
										<?php 
        _e('City:', 'event_espresso');
        ?>
									</label>
									<input id="phys-city" size="20" tabindex="103"  type="text"  value="" name="city" />
								</p>
								<p>
									<label for="phys-state">
										<?php 
        _e('State:', 'event_espresso');
        ?>
									</label>
									<input id="phys-state" size="20" tabindex="104"  type="text"  value="" name="state" />
								</p>
								<p>
									<label for="zip-postal">
										<?php 
        _e('Zip/Postal Code:', 'event_espresso');
        ?>
									</label>
									<input size="20" id="zip-postal" tabindex="105"  type="text"  value="" name="zip" />
								</p>
								<p>
									<label for="phys-country">
										<?php 
        _e('Country:', 'event_espresso');
        ?>
									</label>
									<input id="phys-country" size="20" tabindex="106"  type="text"  value="" name="country" />
								</p>
							</fieldset></td>
							<td <?php 
        echo $ven_type;
        ?>
>
						
							<fieldset id="venue-info">
						
						<legend>
						<?php 
        _e('Venue Information', 'event_espresso');
        ?>
						</legend>
						<p>
							<label for="ven-title">
								<?php 
        _e('Title:', 'event_espresso');
        ?>
							</label>
							<input id="ven-title" size="20" tabindex="106"  type="text"  value="<?php 
        echo isset($venue_title) ? $venue_title : '';
        ?>
" name="venue_title" />
						</p>
						<p>
							<label for="ven-website">
								<?php 
        _e('Website:', 'event_espresso');
        ?>
							</label>
							<input id="ven-website" size="20" tabindex="107"  type="text"  value="<?php 
        echo isset($venue_url) ? $venue_url : '';
        ?>
" name="venue_url" />
						</p>
						<p>
							<label for="ven-phone">
								<?php 
        _e('Phone:', 'event_espresso');
        ?>
							</label>
							<input id="ven-phone"  size="20" tabindex="108"  type="text"  value="<?php 
        echo isset($venue_phone) ? $venue_phone : '';
        ?>
" name="venue_phone" />
						</p>
						<p>
							<label for="ven-image">
								<?php 
        _e('Image:', 'event_espresso');
        ?>
							</label>
							<input id="ven-image" size="20" tabindex="110"  type="text"  value="<?php 
        echo isset($venue_image) ? $venue_image : '';
        ?>
" name="venue_image" />
						</p>
							</td>
						
						<?php 
    }
    ?>
						<td <?php 
    echo $ven_type;
    ?>
><fieldset id="virt-location">
								<legend>
								<?php 
    _e('Virtual Location', 'event_espresso');
    ?>
								</legend>
								<p>
									<label for="virt-phone">
										<?php 
    _e('Phone:', 'event_espresso');
    ?>
									</label>
									<input id="virt-phone" size="20"  type="text" tabindex="107" value="" name="phone" />
								</p>
								<p>
									<label for="url-event">
										<?php 
    _e('URL of Event:', 'event_espresso');
    ?>
									</label>
									<textarea id="url-event" cols="30" rows="4" tabindex="108"  name="virtual_url"></textarea>
								</p>
								<p>
									<label for="call-in-num">
										<?php 
    _e('Call in Number:', 'event_espresso');
    ?>
									</label>
									<input id="call-in-num" size="20" tabindex="109"  type="text"  value="" name="virtual_phone" />
							</fieldset></td>
							</tr>
						
					</table>
				</div>
			</div>
			
			<!-- /event-location-->
			<?php 
    if ($espresso_premium == true) {
        ?>
			<div  id="event-meta" class="postbox">
				<div class="handlediv" title="Click to toggle"><br>
				</div>
				<h3 class="hndle"> <span>
					<?php 
        _e('Event Meta', 'event_espresso');
        ?>
					</span> </h3>
				<div class="inside">
					<?php 
        event_espresso_meta_edit(empty($event_meta) ? '' : $event_meta);
        ?>
				</div>
			</div>
			<?php 
    }
    ?>
			<!-- /event-meta-->
			<div id="confirmation-email" class="postbox">
				<div class="handlediv" title="Click to toggle"><br />
				</div>
				<h3 class="hndle"> <span>
					<?php 
    _e('Email Confirmation:', 'event_espresso');
    ?>
					</span> </h3>
				<div class="inside">
					<div id="emaildescriptiondivrich" class="postarea">
						<div class="email-conf-opts">
							<p><?php 
    echo __('Send custom confirmation emails for this event?', 'event_espresso') . ' ' . select_input('send_mail', $values, 'N');
    ?>
 <?php 
    echo '<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=custom_email_info"><img src="' . EVENT_ESPRESSO_PLUGINFULLURL . '/images/question-frame.png" width="16" height="16" /></a>';
    ?>
</p>
							<?php 
    if ($espresso_premium == true) {
        ?>
							<p>
								<?php 
        $email_id = isset($email_id) ? $email_id : '';
        _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', $email_id, '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>';
        ?>
 </p>
							<br />
							<em>OR</em>
							<?php 
    }
    ?>
							<p class="section-heading">
								<?php 
    _e('Create a custom email:', 'event_espresso');
    ?>
								<?php 
    echo '<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=event_custom_emails"><img src="' . EVENT_ESPRESSO_PLUGINFULLURL . '/images/question-frame.png" width="16" height="16" /></a>';
    ?>
 </p>
						</div>
						<div class="postbox">
							<?php 
    //echo '<p>version_compare ='.(version_compare($wp_version, $wp_min_version) >= 0).'</p>';
    if (function_exists('wp_editor')) {
        $args = array("textarea_rows" => 5, "textarea_name" => "conf_mail", "editor_class" => "my_editor_custom");
        wp_editor("", "conf_mail", $args);
    } else {
        echo '<textarea name="conf_mail" class="theEditor" id="conf_mail"></textarea>';
        espresso_tiny_mce();
    }
    ?>
							<table id="email-confirmation-form" cellspacing="0">
								<tbody>
									<tr>
										<td class="aer-word-count"></td>
										<td class="autosave-info"><span><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></span></td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
			<!-- /confirmation-email-->
			<?php 
    if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/event-management/new_event_post.php')) {
        require_once EVENT_ESPRESSO_PLUGINFULLPATH . "includes/admin-files/event-management/new_event_post.php";
    }
    ?>
		</div>
		<!-- /normal-sortables--> 
	<?php 
    $center_metabox_content = ob_get_clean();
    espresso_choose_layout($main_post_content, $sidebar_content, $center_metabox_content);
    include_once 'create_events_help.php';
    ?>
<input type="hidden" name="action" value="add" />
<?php 
    wp_nonce_field('espresso_verify_insert_event_nonce', 'nonce_verify_insert_event');
    //Security check using nonce
    //wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false );
    //wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false );
    ?>
<script type="text/javascript" charset="utf-8">
	//<![CDATA[
 jQuery(document).ready(function() {

			postboxes.add_postbox_toggles('events');

			jQuery(".datepicker" ).datepicker({
				changeMonth: true,
				changeYear: true,
				dateFormat: "yy-mm-dd",
				showButtonPanel: true
			});
			jQuery("#start_date").change(function(){
				jQuery("#end_date").val(jQuery(this).val());
			});
	var header_clicked = false;
			jQuery('#upload_image_button').click(function() {
				formfield = jQuery('#upload_image').attr('name');
				tb_show('', 'media-upload.php?type=image&amp;TB_iframe=1');
				jQuery('p.event-featured-thumb').addClass('old');
				header_clicked = true;
				return false;
			});		
			window.original_send_to_editor = window.send_to_editor;

	window.send_to_editor = function(html) {
	if(header_clicked) {
	imgurl = jQuery('img',html).attr('src');
	jQuery('#' + formfield).val(imgurl);
	jQuery('#featured-image').append("<p id='image-display'><img class='show-selected-image' src='"+imgurl+"' alt='' /></p>");
	header_clicked = false;
	tb_remove();

	} else {
	window.original_send_to_editor(html);
	}
	}

	// process the remove link in the metabox
	jQuery('#remove-image').click(function(){
	confirm('Do you really want to delete this image? Please remember to update your event to complete the removal.');
	jQuery("#upload_image").val('');
	jQuery("p.event-featured-thumb").remove();
	jQuery("p#image-display").remove();
	jQuery('#remove-image').remove();
	jQuery("#show_thumb_in_lists, #show_on_calendar, #show_thumb_in_regpage").val(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 enter_attendee_payments()
{
    global $wpdb, $org_options;
    require_once EVENT_ESPRESSO_PLUGINFULLPATH . "includes/functions/attendee_functions.php";
    $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>';
    $multi_reg = FALSE;
    $event_id = isset($_POST['event_id']) ? absint($_POST['event_id']) : isset($_REQUEST['event_id']) ? absint($_REQUEST['event_id']) : '';
    $registration_id = isset($_POST['registration_id']) ? sanitize_text_field($_POST['registration_id']) : isset($_REQUEST['registration_id']) ? sanitize_text_field($_REQUEST['registration_id']) : FALSE;
    $registration_ids = array();
    //echo '<h4>$registration_id : ' . $registration_id . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
    $SQL = "SELECT * FROM " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " WHERE registration_id =%s LIMIT 1";
    if ($check = $wpdb->get_row($wpdb->prepare($SQL, $registration_id))) {
        //printr( $check, '$check  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
        $registration_id = $check->primary_registration_id;
        $SQL = "SELECT * FROM " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " WHERE primary_registration_id =%s";
        $registration_ids = $wpdb->get_results($wpdb->prepare($SQL, $registration_id), ARRAY_A);
        $registration_ids = $registration_ids !== FALSE ? $registration_ids : array();
        $multi_reg = TRUE;
    }
    //echo '<h4>$registration_id : ' . $registration_id . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
    //printr( $registration_ids, '$registration_ids  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
    switch ($_REQUEST['form_action']) {
        //Add payment info
        case 'payment':
            if (isset($_POST['attendee_action']) && $_POST['attendee_action'] == 'post_payment') {
                if (!wp_verify_nonce($_POST['_wpnonce'], 'payment_' . $registration_id . '_post_payment_nonce')) {
                    wp_die($failed_nonce_msg);
                }
                $attendees_to_email = array();
                // get the primary attendee id because amount paid info is kept with the primary attendee
                $SQL = "SELECT id, payment_status FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id =%s AND is_primary = 1 ORDER BY id LIMIT 0,1 ";
                $primary_att = $wpdb->get_row($wpdb->prepare($SQL, $registration_id));
                if (!$primary_att) {
                    $notifications['error'][] = __('An error occured. The primary attendee details could not be retrieved from the database.', 'event_espresso');
                } else {
                    $txn_type = isset($_POST['txn_type']) ? $_POST['txn_type'] : apply_filters('filter_hook_event_espresso_enter_attendee_payments_remove_require_txn_type', FALSE);
                    $txn_id = isset($_POST['txn_id']) ? $_POST['txn_id'] : apply_filters('filter_hook_event_espresso_enter_attendee_payments_remove_require_txn_id', FALSE);
                    $payment_date = isset($_POST['payment_date']) ? date_i18n(get_option('date_format'), strtotime($_POST['payment_date'])) : FALSE;
                    $coupon_code = isset($_POST['coupon_code']) ? $_POST['coupon_code'] : '';
                    $total_owing = isset($_POST['total_owing']) ? (double) number_format(sanitize_text_field($_POST['total_owing']), 2, '.', '') : 0.0;
                    $amount_pd = isset($_POST['amount_pd']) ? (double) number_format(sanitize_text_field($_POST['amount_pd']), 2, '.', '') : 0.0;
                    $new_payment = isset($_POST['new_payment']) && $_POST['new_payment'] != '' ? (double) number_format(sanitize_text_field($_POST['new_payment']), 2, '.', '') : 0.0;
                    $upd_payment_status = isset($_POST['payment_status']) ? $_POST['payment_status'] : 'Pending';
                    // if making a payment, we are going to require the txn type and txn id
                    if ($new_payment != 0.0) {
                        $fail = FALSE;
                        if (!$txn_type) {
                            $notifications['error'][] = __('You must enter a Transaction Type when making a payment.', 'event_espresso');
                            $fail = TRUE;
                        }
                        if (!$txn_id) {
                            $notifications['error'][] = __('You must enter a Transaction ID when making a payment.', 'event_espresso');
                            $fail = TRUE;
                        }
                        if ($fail) {
                            break;
                        }
                        $upd_total = $amount_pd + $new_payment;
                    } else {
                        $upd_total = $amount_pd;
                    }
                    // compare new total_cost with amount_pd
                    if ($new_payment != 'Cancelled') {
                        if ($new_payment == $total_owing) {
                            $upd_payment_status = 'Completed';
                        } elseif ($new_payment < $total_owing) {
                            $upd_payment_status = isset($_POST['payment_status']) && $_POST['payment_status'] == 'Incomplete' ? 'Incomplete' : 'Pending';
                        } elseif ($new_payment > $total_owing) {
                            $upd_payment_status = 'Refund';
                        }
                    }
                    //Update payment status information for primary attendee
                    $set_cols_and_values = array('payment_status' => $upd_payment_status, 'txn_type' => $txn_type, 'txn_id' => $txn_id, 'payment_date' => $payment_date, 'coupon_code' => $coupon_code, 'amount_pd' => $upd_total);
                    $set_format = array('%s', '%s', '%s', '%s', '%s', '%f');
                    $where_cols_and_values = array('id' => $primary_att->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. The attendee payment details could not be updated.', 'event_espresso');
                    } else {
                        $attendee_data = array('attendee_id' => $primary_att->id, 'payment_status' => $upd_payment_status, 'registration_id' => $registration_id, 'total_cost' => $upd_total, 'txn_type' => __('Manual Website Payment', 'event_espresso'), 'txn_id' => $txn_id);
                        do_action('action_hook_espresso_update_attendee_payment_status', $attendee_data);
                        if (count($registration_ids) > 0) {
                            foreach ($registration_ids as $reg_id) {
                                // Update payment status information for all attendees
                                // remove amount_pd from update data, since that only applies to the primary attendee
                                unset($set_cols_and_values['amount_pd']);
                                $set_format = array('%s', '%s', '%s', '%s', '%s');
                                $where_cols_and_values = array('registration_id' => $reg_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. The payment details for the additional attendees could not be updated.', 'event_espresso');
                                }
                                $attendees_to_email[] = array('registration_id' => $reg_id['registration_id']);
                            }
                        } else {
                            // Update payment status information for all attendees
                            // remove amount_pd from update data, since that only applies to the primary attendee
                            unset($set_cols_and_values['amount_pd']);
                            $set_format = array('%s', '%s', '%s', '%s', '%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. The payment details for the additional attendees could not be updated.', 'event_espresso');
                            }
                        }
                        //Send Payment Recieved Email
                        $send_payment_rec = isset($_POST['send_payment_rec']) ? $_POST['send_payment_rec'] : FALSE;
                        if ($send_payment_rec == "send_message") {
                            //event_espresso_send_payment_notification( $id );
                            if (count($attendees_to_email) > 0) {
                                //printr( $attendees_to_email, '$attendees_to_email  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); wp_die();
                                foreach ($attendees_to_email as $attendee_to_email) {
                                    $result = event_espresso_send_payment_notification($attendee_to_email);
                                    if (!empty($result)) {
                                        $notifications['error'][] = $result;
                                    }
                                }
                            } else {
                                $result = event_espresso_send_payment_notification(array('registration_id' => $registration_id));
                                if (!empty($result)) {
                                    $notifications['error'][] = $result;
                                }
                            }
                        }
                    }
                    // let's base our success on the lack of errors
                    $notifications['success'][] = empty($notifications['error']) ? __('All attendee payment details have been successfully updated.', 'event_espresso') : __('Some attendee payment details were successfully updated, but the following error(s) may have prevented others from being updated:', 'event_espresso');
                }
            }
            break;
            //Send Invoice
        //Send Invoice
        case 'send_invoice':
            if (!wp_verify_nonce($_POST['_wpnonce'], 'send_invoice_' . $registration_id . '_nonce')) {
                wp_die($failed_nonce_msg);
            }
            if ($org_options["use_attendee_pre_approval"] == "Y") {
                $pre_approve = $_POST['pre_approve'];
                if (count($registration_ids) > 0) {
                    foreach ($registration_ids as $reg_id) {
                        $SQL = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET pre_approve = %s WHERE registration_id = %s";
                        $wpdb->query($wpdb->prepare($SQL, $pre_approve, $reg_id['registration_id']));
                    }
                } else {
                    $SQL = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET pre_approve = %s WHERE registration_id = %s";
                    $wpdb->query($wpdb->prepare($SQL, $pre_approve, $registration_id));
                }
            } else {
                $pre_approve = 0;
            }
            if ($pre_approve == "0") {
                if (count($registration_ids) > 0) {
                    $reg_attendees = array();
                    foreach ($registration_ids as $reg_id) {
                        $SQL = 'SELECT * FROM ' . EVENTS_ATTENDEE_TABLE . ' WHERE registration_id =%s';
                        $more_reg_attendees = $wpdb->get_results($wpdb->prepare($SQL, $reg_id['registration_id']), 'OBJECT_K');
                        foreach ($more_reg_attendees as $another_reg_attendee) {
                            $reg_attendees[$another_reg_attendee->email] = $another_reg_attendee;
                        }
                    }
                    foreach ($reg_attendees as $reg_attendee) {
                        event_espresso_send_invoice($reg_attendee->registration_id, $_POST['invoice_subject'], $_POST['invoice_message']);
                    }
                } else {
                    event_espresso_send_invoice($registration_id, $_POST['invoice_subject'], $_POST['invoice_message']);
                }
                $notifications['success'][] = __('Invoice Sent.', 'event_espresso');
            }
            break;
    }
    $SQL = "SELECT * FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id ='%s' ORDER BY id LIMIT 1";
    $attendee = $wpdb->get_row($wpdb->prepare($SQL, $registration_id));
    if ($attendee === FALSE) {
        echo '<div id="message" class="error"><p><strong>' . __('An error occured. The requested attendee data could not be found.', 'event_espresso') . '</strong></p></div>';
        exit;
    }
    $id = $attendee->id;
    $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;
    $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;
    $amount_pd = $attendee->amount_pd;
    $total_cost = $attendee->total_cost;
    $orig_price = $attendee->orig_price;
    $final_price = $attendee->final_price;
    $SQL = "SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE id='%d'";
    $event = $wpdb->get_row($wpdb->prepare($SQL, $event_id));
    if ($event === FALSE) {
        echo '<div id="message" class="error"><p><strong>' . __('An error occured. The event data for this registration could not be found.', 'event_espresso') . '</strong></p></div>';
        exit;
    }
    $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));
    // 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><span class="laquo big-text">&laquo;&nbsp;</span><?php 
    _e('Back to Attendees List', 'event_espresso');
    ?>
</strong>
		</a>				
	</p>
</div>		
		
<div class="metabox-holder">
	<div class="postbox">
		<?php 
    // create attendee list link
    $list_att_url_params = array('event_admin_reports' => 'list_attendee_payments', 'event_id' => $event_id);
    // add url params
    $list_attendee_link = add_query_arg($list_att_url_params, 'admin.php?page=events');
    ?>
		<?php 
    if (!$multi_reg) {
        ?>
		<h3>
			<?php 
        _e('Name:', 'event_espresso');
        ?>
			<b><?php 
        echo $fname;
        ?>
 <?php 
        echo $lname;
        ?>
</b>&nbsp;&nbsp;|&nbsp;&nbsp;
			<?php 
        _e('ID:', 'event_espresso');
        ?>
			<?php 
        echo $id;
        ?>
&nbsp;&nbsp;|&nbsp;&nbsp;
			<?php 
        _e('Registered For:', 'event_espresso');
        ?>
			<a href="<?php 
        echo $list_attendee_link;
        ?>
"><?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="<?php 
        echo $list_attendee_link;
        ?>
"><?php 
        echo stripslashes_deep($event_name);
        ?>
</a> - <?php 
        echo $event_date;
        ?>
		</h3>
		
		<?php 
    }
    ?>
		
		<div class="inside">
			<table width="100%" border="0">
				<tr>
					<td>
						<h4 class="qrtr-margin"><strong><?php 
    _e('Payment Details', 'event_espresso');
    ?>
</strong></h4>
					</td>
					<td>
						<h4 class="qrtr-margin"><strong><?php 
    _e('Invoice/Payment Reminder', 'event_espresso');
    ?>
</strong></h4>
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php 
    // create edit attendee link
    $edit_att_url_params = array('event_admin_reports' => 'edit_attendee_record', 'form_action' => 'edit_attendee', 'registration_id' => $registration_id, 'event_id' => $event_id);
    // add url params
    $edit_attendee_link = add_query_arg($edit_att_url_params, 'admin.php?page=events');
    ?>
						
						<?php 
    if (count($registration_ids) > 0) {
        ?>
				
						<p>
							<strong><?php 
        _e('Registration Ids:', 'event_espresso');
        ?>
</strong>
						</p>
						<ul>
							<?php 
        foreach ($registration_ids as $reg_id) {
            ?>
					
		                		<li>
								#&nbsp;<?php 
            echo $reg_id['registration_id'];
            ?>
&nbsp;&nbsp;
								<a href="<?php 
            echo $edit_attendee_link;
            ?>
"><?php 
            _e('View / Edit Registration', 'event_espresso');
            ?>
</a>
							</li>				
							<?php 
        }
        ?>
						</ul>
						
						<?php 
    } else {
        ?>
				
						<p>
							<strong><?php 
        _e('Registration Id:', 'event_espresso');
        ?>
</strong>
						</p>
						<p>
							#&nbsp;<?php 
        echo $registration_id;
        ?>
&nbsp;&nbsp;<a href="<?php 
        echo $edit_attendee_link;
        ?>
"><?php 
        _e('View/Edit Registration', 'event_espresso');
        ?>
</a>
						</p>
						
						<?php 
    }
    ?>
				
						<hr style="width:90%; margin:20px 0;" align="left" />

						<form method="POST" action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
" class="espresso_form">
							<fieldset>
								<ul>
									<li>
										<label>
											<?php 
    _e('Payment Date:', 'event_espresso');
    ?>
										</label>
										<input type="text" class="medium-text" name="payment_date" size="45" value ="<?php 
    echo !empty($payment_date) ? event_date_display($payment_date) : event_date_display(date("d-m-Y"));
    ?>
" />
									</li>
									<li>
										<label for="payment_status">
											<?php 
    _e('Payment Status:', 'event_espresso');
    ?>
										</label>
										<?php 
    $values = array(array('id' => '', 'text' => __('- please select -', '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' => 'Cancelled', 'text' => __('Cancelled', 'event_espresso')), array('id' => 'Incomplete', 'text' => __('Incomplete', 'event_espresso')), array('id' => 'Refund', 'text' => __('Overpaid', 'event_espresso')));
    echo select_input('payment_status', $values, $payment_status);
    ?>
									</li>
									<li>
										<label>
											<?php 
    _e('Total Amount Owing:', 'event_espresso');
    ?>
 ( <?php 
    echo $org_options['currency_symbol'];
    ?>
 )
										</label>
										<?php 
    $amount_owing = number_format($total_cost - $amount_pd, 2, '.', '');
    if ($amount_owing == 0.0) {
        $amnt_class = ' full-payment';
    } elseif ($amount_owing < $total_cost || $amount_owing > $total_cost) {
        $amnt_class = ' part-payment';
    } elseif ($amount_owing == $total_cost) {
        $amnt_class = ' no-payment';
    }
    ?>
									
										<input class="small-text algn-rght<?php 
    echo $amnt_class;
    ?>
" type="text" name="ttl_ow" disabled="true" value ="<?php 
    echo $amount_owing;
    ?>
" />
										<input type="hidden" name="total_owing" value ="<?php 
    echo $amount_owing;
    ?>
" />&nbsp;&nbsp;
										<a href="admin.php?page=events&event_admin_reports=edit_attendee_record&event_id=<?php 
    echo $event_id;
    ?>
&registration_id=<?php 
    echo $registration_id;
    ?>
&form_action=edit_attendee&show_payment=true">
											<?php 
    _e('Edit Ticket Price(s)', 'event_espresso');
    ?>
										</a>
									</li>
									<li>
										<label>
											<?php 
    _e('Total Amount Paid to Date:', 'event_espresso');
    ?>
 ( <?php 
    echo $org_options['currency_symbol'];
    ?>
 )
										</label>										
										<input class="small-text algn-rght<?php 
    echo $amnt_class;
    ?>
" type="text" name="amnt_pd" disabled="true" value ="<?php 
    echo $amount_pd;
    ?>
" />
										<input type="hidden" name="amount_pd" value ="<?php 
    echo $amount_pd;
    ?>
" />
									</li>
									<li>
										<label>
											<?php 
    _e('Enter New Payment Amount:', 'event_espresso');
    ?>
 ( <?php 
    echo $org_options['currency_symbol'];
    ?>
 )
										</label>										
										<input class="small-text algn-rght" type="text" name="new_payment" value ="" />
									</li>
									<li>
										<label>
											<?php 
    _e('Coupon Code:', 'event_espresso');
    ?>
										</label>
										<input type="text" class="medium-text" name="coupon_code" size="45" value ="<?php 
    echo $coupon_code;
    ?>
" />
									</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);
    ?>
											<input type="text" class="medium-text" name="txn_type" size="45" value ="<?php 
    echo stripslashes_deep(htmlentities($txn_type));
    ?>
" />
										</li>
									<li>
										<label>
											<?php 
    _e('Transaction ID: ', 'event_espresso');
    ?>
 <span class="smaller-text"><?php 
    _e('( or cheque #, gateway response, etc )', 'event_espresso');
    ?>
</span>
										</label>
										<input type="text" name="txn_id" size="45" value ="<?php 
    echo $txn_id;
    ?>
" />
									</li>
									<li>
										<label>
											<h4><?php 
    _e('Email Notice', 'event_espresso');
    ?>
</h4>
											<?php 
    _e('Do you want to send a payment received notice to registrant?', 'event_espresso');
    ?>
										</label>
										<label class="radio-btn-lbl">
											<input type="radio" name="send_payment_rec" value="send_message">
											<span class="big-text"><?php 
    _e('Yes', 'event_espresso');
    ?>
</span>
										</label>
										<label class="radio-btn-lbl">
											<input type="radio" name="send_payment_rec" checked value="N">
											<span class="big-text"><?php 
    _e('No', 'event_espresso');
    ?>
</span>
										</label>
									</li>
									<li>
										<p><br/><input type="submit" name="Submit" class="button-primary action"   value="Update Payment"></p>
									</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="payment">
							<input type="hidden" name="event_id" value="<?php 
    echo $event_id;
    ?>
">
							<input type="hidden" name="attendee_action" value="post_payment">
							<?php 
    wp_nonce_field('payment_' . $registration_id . '_post_payment_nonce');
    ?>
						</form>
					</td>
					<td valign="top">
						<form class="espresso_form" method='post' action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
">
							<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;
    ?>
">
							<input type="hidden" name="registration_id" value="<?php 
    echo $registration_id;
    ?>
">
							<?php 
    wp_nonce_field('send_invoice_' . $registration_id . '_nonce');
    ?>
							<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" => 8, "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>
									<br/>
									<input type="submit" class="button-primary action"   name="Submit" value="Send Invoice">
								</li>
							</ul>
						</form>
					</td>
				</tr>
			</table>

		</div>
	</div>
</div>
<?php 
    //This show what tags can be added to a custom email.
    event_espresso_custom_email_info();
    //event_list_attendees();
}