Exemplo n.º 1
0
function eme_get_event_by_booking_id($booking_id)
{
    $event_id = eme_get_event_id_by_booking_id($booking_id);
    if ($event_id) {
        $event = eme_get_event($event_id);
    } else {
        $event = eme_new_event();
    }
    return $event;
}
Exemplo n.º 2
0
function eme_get_event_by_booking_id($booking_id)
{
    global $wpdb;
    $bookings_table = $wpdb->prefix . BOOKINGS_TBNAME;
    $sql = $wpdb->prepare("SELECT DISTINCT event_id FROM {$bookings_table} WHERE booking_id = %d", $booking_id);
    $event_id = $wpdb->get_var($sql);
    if ($event_id) {
        $event = eme_get_event($event_id);
    } else {
        $event = eme_new_event();
    }
    return $event;
}
Exemplo n.º 3
0
function eme_event_form($event, $title, $element)
{
    admin_show_warnings();
    global $plugin_page, $eme_timezone;
    $event_status_array = eme_status_array();
    $saved_bydays = array();
    $currency_array = eme_currency_array();
    // let's determine if it is a new event, handy
    // or, in case of validation errors, $event can already contain info, but no $element (=event id)
    // so we create a new event and copy over the info into $event for the elements that do not exist
    if (!$element) {
        $is_new_event = 1;
        $new_event = eme_new_event();
        $event = array_replace_recursive($new_event, $event);
    } else {
        $is_new_event = 0;
    }
    $show_recurrent_form = 0;
    if (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == "edit_recurrence") {
        $pref = "recurrence";
        $form_destination = "admin.php?page=events-manager&eme_admin_action=update_recurrence&recurrence_id=" . $element;
        $saved_bydays = explode(",", $event['recurrence_byday']);
        $show_recurrent_form = 1;
    } else {
        $pref = "event";
        // even for new events, after the 'save' button is clicked, we want to go to the list of events
        // so we use page=events-manager too, not page=eme-new_event
        if ($is_new_event) {
            $form_destination = "admin.php?page=events-manager&eme_admin_action=insert_event";
        } else {
            $form_destination = "admin.php?page=events-manager&eme_admin_action=update_event&event_id=" . $element;
        }
        if (isset($event['recurrence_id']) && $event['recurrence_id']) {
            # editing a single event of an recurrence: don't show the recurrence form
            $show_recurrent_form = 0;
        } else {
            # for single non-recurrent events: we show the form, so we can make it recurrent if we want to
            # but for that, we need to set the recurrence fields, otherwise we get warnings
            $show_recurrent_form = 1;
            $event['recurrence_id'] = 0;
            $event['recurrence_freq'] = '';
            $event['recurrence_start_date'] = $event['event_start_date'];
            $event['recurrence_end_date'] = $event['event_end_date'];
            $event['recurrence_interval'] = '';
            $event['recurrence_byweekno'] = '';
            $event['recurrence_byday'] = '';
            $event['recurrence_specific_days'] = '';
        }
    }
    if (!isset($event['recurrence_start_date'])) {
        $event['recurrence_start_date'] = $event['event_start_date'];
    }
    if (!isset($event['recurrence_end_date'])) {
        $event['recurrence_end_date'] = $event['event_end_date'];
    }
    $freq_options = array("daily" => __('Daily', 'eme'), "weekly" => __('Weekly', 'eme'), "monthly" => __('Monthly', 'eme'), "specific" => __('Specific days', 'eme'));
    $days_names = array(1 => __('Mon'), 2 => __('Tue'), 3 => __('Wed'), 4 => __('Thu'), 5 => __('Fri'), 6 => __('Sat'), 7 => __('Sun'));
    $weekno_options = array("1" => __('first', 'eme'), '2' => __('second', 'eme'), '3' => __('third', 'eme'), '4' => __('fourth', 'eme'), '5' => __('fifth', 'eme'), '-1' => __('last', 'eme'), "0" => __('Start day'));
    $event_RSVP_checked = $event['event_rsvp'] ? "checked='checked'" : "";
    $event_number_spaces = $event['event_seats'];
    $registration_wp_users_only = $event['registration_wp_users_only'] ? "checked='checked'" : "";
    $registration_requires_approval = $event['registration_requires_approval'] ? "checked='checked'" : "";
    $use_paypal_checked = $event['use_paypal'] ? "checked='checked'" : "";
    $use_2co_checked = $event['use_2co'] ? "checked='checked'" : "";
    $use_webmoney_checked = $event['use_webmoney'] ? "checked='checked'" : "";
    $use_fdgg_checked = $event['use_fdgg'] ? "checked='checked'" : "";
    $use_mollie_checked = $event['use_mollie'] ? "checked='checked'" : "";
    $use_sagepay_checked = $event['use_sagepay'] ? "checked='checked'" : "";
    // all properties
    $eme_prop_auto_approve_checked = $event['event_properties']['auto_approve'] ? "checked='checked'" : "";
    $eme_prop_ignore_pending_checked = $event['event_properties']['ignore_pending'] ? "checked='checked'" : "";
    $eme_prop_take_attendance = $event['event_properties']['take_attendance'] ? "checked='checked'" : "";
    $eme_prop_all_day_checked = $event['event_properties']['all_day'] ? "checked='checked'" : "";
    $eme_prop_use_worldpay = $event['event_properties']['use_worldpay'] ? "checked='checked'" : "";
    $eme_date_obj = new ExpressiveDate(null, $eme_timezone);
    // the next javascript will fill in the values for localised-start-date, ... form fields and jquery datepick will fill in also to "to_submit" form fields
    ?>

<script type="text/javascript">
   jQuery(document).ready( function() {
   var dateFormat = jQuery("#localised-start-date").datepick( "option", "dateFormat" );

   var loc_start_date = jQuery.datepick.newDate(<?php 
    echo $eme_date_obj->setTimestampFromString($event['event_start_date'] . " " . $eme_timezone)->format('Y,n,j');
    ?>
);
   jQuery("#localised-start-date").datepick("setDate", jQuery.datepick.formatDate(dateFormat, loc_start_date));

   var loc_end_date = jQuery.datepick.newDate(<?php 
    echo $eme_date_obj->setTimestampFromString($event['event_end_date'] . " " . $eme_timezone)->format('Y,n,j');
    ?>
);
   jQuery("#localised-end-date").datepick("setDate", jQuery.datepick.formatDate(dateFormat, loc_end_date));
   <?php 
    if ($pref == "recurrence" && $event['recurrence_freq'] == 'specific') {
        ?>
      var mydates = [];
      <?php 
        foreach (explode(',', $event['recurrence_specific_days']) as $specific_day) {
            ?>
	      mydates.push(jQuery.datepick.newDate(<?php 
            echo $eme_date_obj->setTimestampFromString($specific_day)->format('Y,n,j');
            ?>
));
      <?php 
        }
        ?>
      jQuery("#localised-rec-start-date").datepick("setDate", mydates);
   <?php 
    } else {
        ?>
      var rec_start_date = jQuery.datepick.newDate(<?php 
        echo $eme_date_obj->setTimestampFromString($event['recurrence_start_date'] . " " . $eme_timezone)->format('Y,n,j');
        ?>
);
      jQuery("#localised-rec-start-date").datepick("setDate", jQuery.datepick.formatDate(dateFormat, rec_start_date));
   <?php 
    }
    ?>
      var rec_end_date = jQuery.datepick.newDate(<?php 
    echo $eme_date_obj->setTimestampFromString($event['recurrence_end_date'] . " " . $eme_timezone)->format('Y,n,j');
    ?>
);
   jQuery("#localised-rec-end-date").datepick("setDate", jQuery.datepick.formatDate(dateFormat, rec_end_date));
 });
</script>

   <form id="eventForm" name="eventForm" method="post" enctype="multipart/form-data" action="<?php 
    echo $form_destination;
    ?>
">
      <div class="wrap">
         <div id="icon-events" class="icon32"><br /></div>
         <h1><?php 
    echo eme_trans_sanitize_html($title);
    ?>
</h1>
         <?php 
    if ($event['recurrence_id']) {
        ?>
         <p id='recurrence_warning'>
            <?php 
        if (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == 'edit_recurrence') {
            _e('WARNING: This is a recurrence.', 'eme');
            ?>
            <br />
            <?php 
            _e('Modifying these data all the events linked to this recurrence will be rescheduled', 'eme');
        } else {
            _e('WARNING: This is a recurring event.', 'eme');
            _e('If you change these data and save, this will become an independent event.', 'eme');
        }
        ?>
         </p>
         <?php 
    }
    ?>
         <div id="poststuff" class="metabox-holder has-right-sidebar">
            <!-- SIDEBAR -->
            <div id="side-info-column" class='inner-sidebar'>
               <div id='side-sortables' class="meta-box-sortables">
                  <?php 
    if (current_user_can(get_option('eme_cap_author_event'))) {
        ?>
                  <!-- status postbox -->
                  <div class="postbox ">
                     <div class="handlediv" title="Click to toggle."><br />
                     </div>
                     <h3 class='hndle'><span>
                        <?php 
        _e('Event Status', 'eme');
        ?>
                        </span></h3>
                     <div class="inside">
                        <p><?php 
        _e('Status', 'eme');
        ?>
                        <select id="event_status" name="event_status">
                        <?php 
        foreach ($event_status_array as $key => $value) {
            if ($event['event_status'] && $event['event_status'] == $key) {
                $selected = "selected='selected'";
            } else {
                $selected = "";
            }
            echo "<option value='{$key}' {$selected}>{$value}</option>";
        }
        ?>
                        </select><br />
                        <?php 
        _e('Private events are only visible for logged in users, draft events are not visible from the front end.', 'eme');
        ?>
                        </p>
                     </div>
                  </div>
                  <?php 
    }
    ?>
                  <?php 
    if (get_option('eme_recurrence_enabled') && $show_recurrent_form) {
        ?>
                  <!-- recurrence postbox -->
                  <div class="postbox ">
                     <div class="handlediv" title="Click to toggle."><br />
                     </div>
                     <h3 class='hndle'><span>
                        <?php 
        _e("Recurrence", 'eme');
        ?>
                        </span></h3>
                     <div class="inside">
                        <?php 
        $recurrence_YES = "";
        if ($event['recurrence_id']) {
            $recurrence_YES = "checked='checked' disabled='disabled'";
        }
        ?>
                        <p>
                           <input id="event-recurrence" type="checkbox" name="repeated_event"
                              value="1" <?php 
        echo $recurrence_YES;
        ?>
 />
                        </p>
                        <div id="event_recurrence_pattern">
                           <p>Frequency:
                              <select id="recurrence-frequency" name="recurrence_freq">
                                 <?php 
        eme_option_items($freq_options, $event['recurrence_freq']);
        ?>
                              </select>
                           </p>
			   <div id="recurrence-intervals">
                           <p>
                              <?php 
        _e('Every', 'eme');
        ?>
                              <input id="recurrence-interval" name='recurrence_interval'
                                size='2' value='<?php 
        if (isset($event['recurrence_interval'])) {
            echo $event['recurrence_interval'];
        }
        ?>
' />
                              <span class='interval-desc' id="interval-daily-singular">
                              <?php 
        _e('day', 'eme');
        ?>
                              </span> <span class='interval-desc' id="interval-daily-plural">
                              <?php 
        _e('days', 'eme');
        ?>
                              </span> <span class='interval-desc' id="interval-weekly-singular">
                              <?php 
        _e('week', 'eme');
        ?>
                              </span> <span class='interval-desc' id="interval-weekly-plural">
                              <?php 
        _e('weeks', 'eme');
        ?>
                              </span> <span class='interval-desc' id="interval-monthly-singular">
                              <?php 
        _e('month', 'eme');
        ?>
                              </span> <span class='interval-desc' id="interval-monthly-plural">
                              <?php 
        _e('months', 'eme');
        ?>
                              </span> </p>
                           <p class="alternate-selector" id="weekly-selector">
                              <?php 
        eme_checkbox_items('recurrence_bydays[]', $days_names, $saved_bydays);
        ?>
                              <br />
                              <?php 
        _e('If you leave this empty, the recurrence start date will be used as a reference.', 'eme');
        ?>
                           </p>
                           <p class="alternate-selector" id="monthly-selector">
                              <?php 
        _e('Every', 'eme');
        ?>
                              <select id="monthly-modifier" name="recurrence_byweekno">
                                 <?php 
        eme_option_items($weekno_options, $event['recurrence_byweekno']);
        ?>
                              </select>
                              <select id="recurrence-weekday" name="recurrence_byday">
                                 <?php 
        eme_option_items($days_names, $event['recurrence_byday']);
        ?>
                              </select>
                              <?php 
        _e('Day of month', 'eme');
        ?>
                              <br />
                              <?php 
        _e('If you use "Start day" as day of the month, the recurrence start date will be used as a reference.', 'eme');
        ?>
                              &nbsp;
                           </p>
                           </div>
                        </div>
                        <p id="recurrence-tip">
                           <?php 
        _e('Check if your event happens more than once.', 'eme');
        ?>
                        </p>
                        <p id="recurrence-tip-2">
                           <?php 
        _e('The event start and end date only define the duration of an event in case of a recurrence.', 'eme');
        ?>
                        </p>
                     </div>
                  </div>
                  <?php 
    }
    ?>

                  <?php 
    if ($event['event_author']) {
        ?>
                  <!-- owner postbox -->
                  <div class="postbox ">
                     <div class="handlediv" title="Click to toggle."><br />
                     </div>
                     <h3 class='hndle'><span>
                        <?php 
        _e('Author', 'eme');
        ?>
                        </span></h3>
                     <div class="inside">
                        <p><?php 
        _e('Author of this event: ', 'eme');
        ?>
                           <?php 
        $owner_user_info = get_userdata($event['event_author']);
        echo eme_sanitize_html($owner_user_info->display_name);
        ?>
                        </p>
                     </div>
                  </div>
                  <?php 
    }
    ?>
                  <div class="postbox ">
                     <div class="handlediv" title="Click to toggle."><br />
                     </div>
                     <h3 class='hndle'><span>
                        <?php 
    _e('Contact Person', 'eme');
    ?>
                        </span></h3>
                     <div class="inside">
                        <p><?php 
    _e('Contact', 'eme');
    ?>
                           <?php 
    wp_dropdown_users(array('name' => 'event_contactperson_id', 'show_option_none' => __("Event author", 'eme'), 'selected' => $event['event_contactperson_id']));
    // if it is not a new event and there's no contact person defined, then the event author becomes contact person
    // So let's display a warning what this means if there's no author (like when submitting via the frontend submission form)
    if (!$is_new_event && $event['event_contactperson_id'] < 1 && $event['event_author'] < 1) {
        print "<br />" . __('Since the author is undefined for this event, any reference to the contact person (like when using #_CONTACTPERSON when sending mails), will use the admin user info.', 'eme');
    }
    ?>
                        </p>
                     </div>
                  </div>
                  <?php 
    if (get_option('eme_rsvp_enabled')) {
        ?>
                  <div class="postbox ">
                     <div class="handlediv" title="Click to toggle."><br />
                     </div>
                     <h3 class='hndle'><span><?php 
        _e('RSVP', 'eme');
        ?>
</span></h3>
                     <div class="inside">
                        <p>
                           <input id="rsvp-checkbox" name='event_rsvp' value='1' type='checkbox' <?php 
        echo $event_RSVP_checked;
        ?>
 />
                           <?php 
        _e('Enable registration for this event', 'eme');
        ?>
                        </p>
                        <div id='rsvp-data'>
                           <p>
                              <input id="approval_required-checkbox" name='registration_requires_approval' value='1' type='checkbox' <?php 
        echo $registration_requires_approval;
        ?>
 />
                              <?php 
        _e('Require approval for registration', 'eme');
        ?>
                           <br />
                              <input id="eme_prop_auto_approve" name='eme_prop_auto_approve' value='1' type='checkbox' <?php 
        echo $eme_prop_auto_approve_checked;
        ?>
 />
                              <?php 
        _e('Auto-approve registration upon payment', 'eme');
        ?>
                           <br />
                              <input id="eme_prop_ignore_pending" name='eme_prop_ignore_pending' value='1' type='checkbox' <?php 
        echo $eme_prop_ignore_pending_checked;
        ?>
 />
                              <?php 
        _e('Consider pending registrations as available seats for new bookings', 'eme');
        ?>
                           <br />
                              <input id="wp_member_required-checkbox" name='registration_wp_users_only' value='1' type='checkbox' <?php 
        echo $registration_wp_users_only;
        ?>
 />
                              <?php 
        _e('Require WP membership for registration', 'eme');
        ?>
                           <br />
                              <input id="eme_prop_take_attendance" name='eme_prop_take_attendance' value='1' type='checkbox' <?php 
        echo $eme_prop_take_attendance;
        ?>
 />
                              <?php 
        _e('Only take attendance (0 or 1 seat) for this event', 'eme');
        ?>
                           <br /><table>
                              <tr>
                              <td><?php 
        _e('Spaces', 'eme');
        ?>
 :</td>
                              <td><input id="seats-input" type="text" name="event_seats" maxlength='125' title="<?php 
        _e('For multiseat events, seperate the values by \'||\'', 'eme');
        ?>
" value="<?php 
        echo $event_number_spaces;
        ?>
" /></td>
                              </tr>
                              <tr>
                              <td><?php 
        _e('Price: ', 'eme');
        ?>
</td>
                              <td><input id="price" type="text" name="price" maxlength='125' title="<?php 
        _e('For multiprice events, seperate the values by \'||\'', 'eme');
        ?>
" value="<?php 
        echo $event['price'];
        ?>
" /></td>
                              </tr>
                              <tr>
                              <td><?php 
        _e('Currency: ', 'eme');
        ?>
</td>
                              <td><select id="currency" name="currency">
                              <?php 
        foreach ($currency_array as $key => $value) {
            if ($event['currency'] && $event['currency'] == $key) {
                $selected = "selected='selected'";
            } elseif (!$event['currency'] && $key == get_option('eme_default_currency')) {
                $selected = "selected='selected'";
            } else {
                $selected = "";
            }
            echo "<option value='{$key}' {$selected}>{$value}</option>";
        }
        ?>
                              </select></td>
                              </tr>
                              <tr>
                              <td><?php 
        _e('Max number of spaces to book', 'eme');
        ?>
</td>
                              <td><input id="eme_prop_max_allowed" type="text" name="eme_prop_max_allowed" maxlength='125' title="<?php 
        echo __('The maximum number of spaces a person can book in one go.', 'eme') . ' ' . __('(is multi-compatible)', 'eme');
        ?>
" value="<?php 
        echo $event['event_properties']['max_allowed'];
        ?>
" /></td>
                              </tr>
                              <tr>
                              <td><?php 
        _e('Min number of spaces to book', 'eme');
        ?>
</td>
                              <td><input id="eme_prop_min_allowed" type="text" name="eme_prop_min_allowed" maxlength='125' title="<?php 
        echo __('The minimum number of spaces a person can book in one go (it can be 0, for e.g. just an attendee list).', 'eme') . ' ' . __('(is multi-compatible)', 'eme');
        ?>
" value="<?php 
        echo $event['event_properties']['min_allowed'];
        ?>
" /></td>
                              </tr></table>
                           <br />
                              <?php 
        _e('Allow RSVP until ', 'eme');
        ?>
                           <br />
                              <input id="rsvp_number_days" type="text" name="rsvp_number_days" maxlength='2' size='2' value="<?php 
        echo $event['rsvp_number_days'];
        ?>
" />
                              <?php 
        _e('days', 'eme');
        ?>
                              <input id="rsvp_number_hours" type="text" name="rsvp_number_hours" maxlength='2' size='2' value="<?php 
        echo $event['rsvp_number_hours'];
        ?>
" />
                              <?php 
        _e('hours', 'eme');
        ?>
                           <br />
                              <?php 
        _e('before the event ', 'eme');
        $eme_rsvp_end_target_list = array('start' => __('starts', 'eme'), 'end' => __('ends', 'eme'));
        echo eme_ui_select($event['event_properties']['rsvp_end_target'], 'eme_prop_rsvp_end_target', $eme_rsvp_end_target_list);
        ?>
                           <br />
                           <br />
                              <?php 
        _e('Payment methods', 'eme');
        ?>
<br />
                              <input id="paypal-checkbox" name='use_paypal' value='1' type='checkbox' <?php 
        echo $use_paypal_checked;
        ?>
 /><?php 
        _e('Paypal', 'eme');
        ?>
<br />
                              <input id="2co-checkbox" name='use_2co' value='1' type='checkbox' <?php 
        echo $use_2co_checked;
        ?>
 /><?php 
        _e('2Checkout', 'eme');
        ?>
<br />
                              <input id="webmoney-checkbox" name='use_webmoney' value='1' type='checkbox' <?php 
        echo $use_webmoney_checked;
        ?>
 /><?php 
        _e('Webmoney', 'eme');
        ?>
<br />
                              <input id="fdgg-checkbox" name='use_fdgg' value='1' type='checkbox' <?php 
        echo $use_fdgg_checked;
        ?>
 /><?php 
        _e('First Data', 'eme');
        ?>
<br />
                              <input id="mollie-checkbox" name='use_mollie' value='1' type='checkbox' <?php 
        echo $use_mollie_checked;
        ?>
 /><?php 
        _e('Mollie', 'eme');
        ?>
<br />
                              <input id="sagepay-checkbox" name='use_sagepay' value='1' type='checkbox' <?php 
        echo $use_sagepay_checked;
        ?>
 /><?php 
        _e('Sage Pay', 'eme');
        ?>
<br />
                              <input id="eme_prop_use_worldpay" name='eme_prop_use_worldpay' value='1' type='checkbox' <?php 
        echo $eme_prop_use_worldpay;
        ?>
 /><?php 
        _e('Worldpay', 'eme');
        ?>
<br />
                           </p>
                           <?php 
        if ($event['event_rsvp'] && $pref != "recurrence") {
            // show the compact bookings table only when not editing a recurrence
            eme_bookings_compact_table($event['event_id']);
        }
        ?>
                        </div>
                     </div>
                  </div>
                  <?php 
    }
    ?>
                  <?php 
    if (get_option('eme_categories_enabled')) {
        ?>
                  <div class="postbox ">
                     <div class="handlediv" title="Click to toggle."><br />
                     </div>
                     <h3 class='hndle'><span>
                        <?php 
        _e('Category', 'eme');
        ?>
                        </span></h3>
                     <div class="inside">
                     <?php 
        $categories = eme_get_categories();
        foreach ($categories as $category) {
            if ($event['event_category_ids'] && in_array($category['category_id'], explode(",", $event['event_category_ids']))) {
                $selected = "checked='checked'";
            } else {
                $selected = "";
            }
            ?>
            <input type="checkbox" name="event_category_ids[]" value="<?php 
            echo $category['category_id'];
            ?>
" <?php 
            echo $selected;
            ?>
 /><?php 
            echo eme_trans_sanitize_html($category['category_name']);
            ?>
<br />
                     <?php 
        }
        ?>
                     </div>
                  </div> 
                  <?php 
    }
    ?>
               </div>
            </div>
            <!-- END OF SIDEBAR -->
            <div id="post-body">
               <div id="post-body-content" class="meta-box-sortables">
               <?php 
    if ($plugin_page === 'eme-new_event' && get_option("eme_fb_app_id")) {
        ?>
                  <div id="fb-root"></div>
                  <script>
                    window.fbAsyncInit = function() {
                      // init the FB JS SDK
                      FB.init({
                        appId      : '<?php 
        echo get_option("eme_fb_app_id");
        ?>
',// App ID from the app dashboard
                        channelUrl : '<?php 
        echo plugins_url("eme_fb_channel.php", __FILE__);
        ?>
', // Channel file for x-domain comms
                        status     : true,  // Check Facebook Login status
                        xfbml      : true   // Look for social plugins on the page
                      });

                      // Additional initialization code such as adding Event Listeners goes here
                     FB.Event.subscribe('auth.authResponseChange', function(response) {
                        if (response.status === 'connected') {
                           jQuery('#fb-import-box').show();
                         } else if (response.status === 'not_authorized') {
                           jQuery('#fb-import-box').hide();
                         } else {
                           jQuery('#fb-import-box').hide();
                         }
                        });
                     };


                     // Load the SDK asynchronously
                     (function(d, s, id){
                       var js, fjs = d.getElementsByTagName(s)[0];
                       if (d.getElementById(id)) {return;}
                       js = d.createElement(s); js.id = id;
                       js.src = "//connect.facebook.net/en_US/all.js";
                       fjs.parentNode.insertBefore(js, fjs);
                     }(document, 'script', 'facebook-jssdk'));

                  </script>
                  <fb:login-button id="fb-login-button" width="200" autologoutlink="true" scope="user_events" max-rows="1"></fb:login-button>
                  <br />
                  <br />
                  <div id='fb-import-box' style='display:none'>
                     Facebook event url : <input type='text' id='fb-event-url' class='widefat' /> 
                     <br />
                     <br />
                     <input type='button' class='button' value='Import' id='import-fb-event-btn' />
                     <br />
                     <br />
                  </div>
               <?php 
    }
    ?>

               <?php 
    $screens = array('events_page_eme-new_event', 'toplevel_page_events-manager');
    foreach ($screens as $screen) {
        if ($event['event_page_title_format'] == "" && $event['event_properties']['event_page_title_format_tpl'] == 0) {
            add_filter('postbox_classes_' . $screen . '_div_event_page_title_format', 'eme_closed');
        }
        if ($event['event_single_event_format'] == "" && $event['event_properties']['event_single_event_format_tpl'] == 0) {
            add_filter('postbox_classes_' . $screen . '_div_event_single_event_format', 'eme_closed');
        }
        if ($event['event_contactperson_email_body'] == "" && $event['event_properties']['event_contactperson_email_body_tpl'] == 0) {
            add_filter('postbox_classes_' . $screen . '_div_event_contactperson_email_body', 'eme_closed');
        }
        if ($event['event_registration_recorded_ok_html'] == "" && $event['event_properties']['event_registration_recorded_ok_html_tpl'] == 0) {
            add_filter('postbox_classes_' . $screen . '_div_event_registration_recorded_ok_html', 'eme_closed');
        }
        if ($event['event_respondent_email_body'] == "" && $event['event_properties']['event_respondent_email_body_tpl'] == 0) {
            add_filter('postbox_classes_' . $screen . '_div_event_respondent_email_body', 'eme_closed');
        }
        if ($event['event_registration_pending_email_body'] == "" && $event['event_properties']['event_registration_pending_email_body_tpl'] == 0) {
            add_filter('postbox_classes_' . $screen . '_div_event_registration_pending_email_body', 'eme_closed');
        }
        if ($event['event_registration_updated_email_body'] == "" && $event['event_properties']['event_registration_updated_email_body_tpl'] == 0) {
            add_filter('postbox_classes_' . $screen . '_div_event_registration_updated_email_body', 'eme_closed');
        }
        if ($event['event_registration_cancelled_email_body'] == "" && $event['event_properties']['event_registration_cancelled_email_body_tpl'] == 0) {
            add_filter('postbox_classes_' . $screen . '_div_event_registration_cancelled_email_body', 'eme_closed');
        }
        if ($event['event_registration_denied_email_body'] == "" && $event['event_properties']['event_registration_denied_email_body_tpl'] == 0) {
            add_filter('postbox_classes_' . $screen . '_div_event_registration_denied_email_body', 'eme_closed');
        }
        if ($event['event_registration_form_format'] == "" && $event['event_properties']['event_registration_form_format_tpl'] == 0) {
            add_filter('postbox_classes_' . $screen . '_div_event_registration_form_format', 'eme_closed');
        }
        if ($event['event_cancel_form_format'] == "" && $event['event_properties']['event_cancel_form_format_tpl'] == 0) {
            add_filter('postbox_classes_' . $screen . '_div_event_cancel_form_format', 'eme_closed');
        }
    }
    // we can only give one parameter to do_meta_boxes, but we don't want to list the templates each time
    // so temporary we store the array in the $event var and unset it afterwards
    $templates_array = eme_get_templates_array_by_id();
    // the first element is something empty or a "no templates" string, but we need to keep the array indexes
    // so we concatenate using "+", not array_merge
    if (is_array($templates_array) && count($templates_array) > 0) {
        $templates_array = array(0 => '') + $templates_array;
    } else {
        $templates_array = array(0 => __('No templates defined yet!', 'eme'));
    }
    $event['templates_array'] = $templates_array;
    if ($is_new_event) {
        // we add the meta boxes only on the page we're currently at, so for duplicate event it is the same as for edit event
        // see the eme_admin_event_boxes function
        if (isset($_GET['eme_admin_action']) && $_GET['eme_admin_action'] == 'duplicate_event') {
            do_meta_boxes('toplevel_page_events-manager', "post", $event);
        } else {
            do_meta_boxes('events_page_eme-new_event', "post", $event);
        }
    } else {
        do_meta_boxes('toplevel_page_events-manager', "post", $event);
    }
    unset($event['templates_array']);
    ?>
               </div>
               <p class="submit">
                  <?php 
    if ($is_new_event) {
        ?>
                     <input type="submit" class="button-primary" id="event_update_button" name="event_update_button" value="<?php 
        _e('Save');
        ?>
 &raquo;" />
                  <?php 
    } else {
        $delete_button_text = __('Are you sure you want to delete this event?', 'eme');
        $deleteRecurrence_button_text = __('Are you sure you want to delete this recurrence?', 'eme');
        ?>
                     <?php 
        if ($pref == "recurrence") {
            ?>
                     <input type="submit" class="button-primary" id="event_update_button" name="event_update_button" value="<?php 
            _e('Update');
            ?>
 &raquo;" />
                     <?php 
        } else {
            ?>
                     <input type="submit" class="button-primary" id="event_update_button" name="event_update_button" value="<?php 
            _e('Update');
            ?>
 &raquo;" />
                     <?php 
        }
        ?>
                     <input type="submit" class="button-primary" id="event_delete_button" name="event_delete_button" value="<?php 
        _e('Delete Event', 'eme');
        ?>
 &raquo;" onclick="return areyousure('<?php 
        echo $delete_button_text;
        ?>
');" />
                     <?php 
        if ($event['recurrence_id']) {
            ?>
                     <input type="submit" class="button-primary" id="event_deleteRecurrence_button" name="event_deleteRecurrence_button" value="<?php 
            _e('Delete Recurrence', 'eme');
            ?>
 &raquo;" onclick="return areyousure('<?php 
            echo $deleteRecurrence_button_text;
            ?>
');" />
                     <?php 
        }
        ?>
 
                  <?php 
    }
    ?>
               </p>
            </div>
         </div>
      </div>
      <?php 
    wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
    ?>
      <?php 
    wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
    ?>
   </form>
<?php 
}