Events Manager - Version 3.0.91

Version Description

  • Documentation finally up to date now!
  • widget bug fixed
  • added event permissions, so users can manage their own events/locations/categories
  • improved event booking UI and management tools
  • export CSV of bookings
  • booking approvals added
  • bookings can have individual notes
  • calendar widget shows selected month if clicked on
  • custom attributes field, for atts that don't need to be in a template (e.g. pdf file url)
  • time limit for main events list and events widget (e.g. show events that occur within x months)
  • default location
  • default category
  • added extra validation so event start date/times can't be after end date/time
  • calendar navigation will pass on all arguments for following month (e.g. category, etc)
  • small map balloon fix for some rare js conflicts
Download this release

Release Info

Developer netweblogic
Plugin Icon 128x128 Events Manager
Version 3.0.91
Comparing to
See all releases

Code changes from version 3.0.9 to 3.0.91

Files changed (47) hide show
  1. admin/bookings/em-cancelled.php +133 -0
  2. admin/bookings/em-confirmed.php +133 -0
  3. admin/bookings/em-events.php +179 -0
  4. admin/bookings/em-pending.php +155 -0
  5. admin/bookings/em-person.php +150 -0
  6. admin/bookings/em-rejected.php +133 -0
  7. admin/em-admin.php +73 -21
  8. admin/em-bookings.php +264 -63
  9. admin/em-categories.php +49 -50
  10. admin/em-docs.php +14 -3
  11. admin/em-event.php +61 -63
  12. admin/em-events.php +135 -112
  13. admin/em-locations-search.php +2 -3
  14. admin/em-locations.php +113 -82
  15. admin/em-options.php +129 -8
  16. admin/em-people.php +117 -48
  17. classes/em-booking.php +263 -33
  18. classes/em-bookings.php +317 -65
  19. classes/em-calendar.php +44 -16
  20. classes/em-categories.php +154 -0
  21. classes/em-category.php +142 -9
  22. classes/em-event.php +117 -45
  23. classes/em-events.php +43 -11
  24. classes/em-location.php +28 -5
  25. classes/em-locations.php +7 -1
  26. classes/em-object.php +42 -9
  27. classes/em-person.php +43 -5
  28. em-ajax.php +88 -30
  29. em-bookings.php +162 -162
  30. em-events.php +17 -13
  31. em-functions.php +66 -9
  32. em-install.php +106 -23
  33. events-manager.php +44 -10
  34. includes/css/events_manager.css +2 -1
  35. includes/css/events_manager_admin.css +15 -0
  36. includes/js/em_admin.js +272 -221
  37. includes/js/em_calendar_ajax.js +13 -6
  38. includes/js/em_maps.js +1 -1
  39. includes/langs/dbem-nl_NL.mo +0 -0
  40. includes/langs/dbem-nl_NL.po +1577 -0
  41. includes/langs/events-manager.pot +1508 -803
  42. includes/sample-placeholers/booking-email.html +31 -0
  43. includes/sample-placeholers/event-single.html +29 -14
  44. readme.txt +25 -11
  45. widgets/em-calendar.php +9 -1
  46. widgets/em-events.php +33 -21
  47. widgets/em-locations.php +1 -1
admin/bookings/em-cancelled.php ADDED
@@ -0,0 +1,133 @@
1
+ <?php
2
+ /**
3
+ * Generates a "widget" table of confirmed bookings for a specific event.
4
+ *
5
+ * @param int $event_id
6
+ */
7
+ function em_bookings_cancelled_table(){
8
+ global $EM_Event, $wpdb, $current_user;
9
+
10
+ $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_cancelled_table' );
11
+ $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
12
+ $order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
13
+ $limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
14
+ $page = ( $action_scope && !empty($_GET['p']) ) ? $_GET['p']:1;
15
+ $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
16
+
17
+ if( is_object($EM_Event) ){
18
+ $bookings = $EM_Event->get_bookings()->get_cancelled_bookings();
19
+ }else{
20
+ return false;
21
+ }
22
+ $bookings_count = (is_array($bookings)) ? count($bookings):0;
23
+ ?>
24
+ <div class='wrap em_bookings_pending_table em_obj'>
25
+ <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
26
+ <input type="hidden" name="em_obj" value="em_bookings_pending_table" />
27
+ <!--
28
+ <ul class="subsubsub">
29
+ <li>
30
+ <a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
31
+ </li>
32
+ </ul>
33
+ <p class="search-box">
34
+ <label class="screen-reader-text" for="post-search-input"><?php _e('Search'); ?>:</label>
35
+ <input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
36
+ <input type="submit" value="<?php _e('Search'); ?>" class="button" />
37
+ </p>
38
+ -->
39
+ <?php if ( $bookings_count >= $limit ) : ?>
40
+ <div class='tablenav'>
41
+ <!--
42
+ <div class="alignleft actions">
43
+ <select name="action">
44
+ <option value="-1" selected="selected">
45
+ <?php _e('Bulk Actions'); ?>
46
+ </option>
47
+ <option value="approve">
48
+ <?php _e('Approve', 'dbem'); ?>
49
+ </option>
50
+ <option value="decline">
51
+ <?php _e('Decline', 'dbem'); ?>
52
+ </option>
53
+ </select>
54
+ <input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
55
+ </div>
56
+ -->
57
+ <!--
58
+ <div class="view-switch">
59
+ <a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
60
+ </div>
61
+ -->
62
+ <?php
63
+ if ( $bookings_count >= $limit ) {
64
+ $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('p'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
65
+ $bookings_nav .= em_admin_paginate( $page_link_template, $bookings_count, $limit, $page, 5);
66
+ echo $bookings_nav;
67
+ }
68
+ ?>
69
+ <div class="clear"></div>
70
+ </div>
71
+ <?php endif; ?>
72
+ <div class="clear"></div>
73
+ <?php if( $bookings_count > 0 ): ?>
74
+ <div class='table-wrap'>
75
+ <table id='dbem-bookings-table' class='widefat post fixed'>
76
+ <thead>
77
+ <tr>
78
+ <th class='manage-column column-cb check-column' scope='col'>
79
+ <input class='select-all' type="checkbox" value='1' />
80
+ </th>
81
+ <th class='manage-column' scope='col'>Booker</th>
82
+ <th class='manage-column' scope='col'>E-mail</th>
83
+ <th class='manage-column' scope='col'>Phone number</th>
84
+ <th class='manage-column' scope='col'>Spaces</th>
85
+ <th class='manage-column' scope='col'>&nbsp;</th>
86
+ </tr>
87
+ </thead>
88
+ <tbody>
89
+ <?php
90
+ $rowno = 0;
91
+ $event_count = 0;
92
+ foreach ($bookings as $EM_Booking) {
93
+ if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
94
+ $rowno++;
95
+ ?>
96
+ <tr>
97
+ <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
98
+ <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person->id; ?>"><?php echo $EM_Booking->person->name ?></a></td>
99
+ <td><?php echo $EM_Booking->person->email ?></td>
100
+ <td><?php echo $EM_Booking->person->phone ?></td>
101
+ <td><?php echo $EM_Booking->seats ?></td>
102
+ <td>
103
+ <?php
104
+ $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->id));
105
+ $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->id));
106
+ ?>
107
+ <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
108
+ <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit'); ?></a> |
109
+ <a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a>
110
+ </td>
111
+ </tr>
112
+ <?php
113
+ }
114
+ $event_count++;
115
+ }
116
+ ?>
117
+ </tbody>
118
+ </table>
119
+ </div>
120
+ <?php else: ?>
121
+ <?php _e('No cancelled bookings.', 'dbem'); ?>
122
+ <?php endif; ?>
123
+ </form>
124
+ <?php if( $bookings >= $limit ) : ?>
125
+ <div class='tablenav'>
126
+ <?php echo $bookings_nav; ?>
127
+ <div class="clear"></div>
128
+ </div>
129
+ <?php endif; ?>
130
+ </div>
131
+ <?php
132
+ }
133
+ ?>
admin/bookings/em-confirmed.php ADDED
@@ -0,0 +1,133 @@
1
+ <?php
2
+
3
+ /**
4
+ * Generates a "widget" table of confirmed bookings for a specific event.
5
+ *
6
+ * @param int $event_id
7
+ */
8
+ function em_bookings_confirmed_table(){
9
+ global $EM_Event, $wpdb, $current_user;
10
+
11
+ $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
12
+ $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
13
+ $order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
14
+ $limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
15
+ $page = ( $action_scope && !empty($_GET['p']) ) ? $_GET['p']:1;
16
+ $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
17
+
18
+ if( is_object($EM_Event) ){
19
+ $bookings = $EM_Event->get_bookings()->get_bookings();
20
+ }else{
21
+ return false;
22
+ }
23
+ $bookings_count = (is_array($bookings)) ? count($bookings):0;
24
+ ?>
25
+ <div class='wrap em_bookings_pending_table em_obj'>
26
+ <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
27
+ <input type="hidden" name="em_obj" value="em_bookings_pending_table" />
28
+ <!--
29
+ <ul class="subsubsub">
30
+ <li>
31
+ <a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
32
+ </li>
33
+ </ul>
34
+ <p class="search-box">
35
+ <label class="screen-reader-text" for="post-search-input"><?php _e('Search'); ?>:</label>
36
+ <input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
37
+ <input type="submit" value="<?php _e('Search'); ?>" class="button" />
38
+ </p>
39
+ -->
40
+ <?php if ( $bookings_count >= $limit ) : ?>
41
+ <div class='tablenav'>
42
+ <!--
43
+ <div class="alignleft actions">
44
+ <select name="action">
45
+ <option value="-1" selected="selected">
46
+ <?php _e('Bulk Actions'); ?>
47
+ </option>
48
+ <option value="approve">
49
+ <?php _e('Approve', 'dbem'); ?>
50
+ </option>
51
+ <option value="decline">
52
+ <?php _e('Decline', 'dbem'); ?>
53
+ </option>
54
+ </select>
55
+ <input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
56
+ </div>
57
+ -->
58
+ <!--
59
+ <div class="view-switch">
60
+ <a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
61
+ </div>
62
+ -->
63
+ <?php
64
+ if ( $bookings_count >= $limit ) {
65
+ $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('p'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
66
+ $bookings_nav .= em_admin_paginate( $page_link_template, $bookings_count, $limit, $page, 5);
67
+ echo $bookings_nav;
68
+ }
69
+ ?>
70
+ <div class="clear"></div>
71
+ </div>
72
+ <?php endif; ?>
73
+ <div class="clear"></div>
74
+ <?php if( $bookings_count > 0 ): ?>
75
+ <div class='table-wrap'>
76
+ <table id='dbem-bookings-table' class='widefat post fixed'>
77
+ <thead>
78
+ <tr>
79
+ <th class='manage-column column-cb check-column' scope='col'>
80
+ <input class='select-all' type="checkbox" value='1' />
81
+ </th>
82
+ <th class='manage-column' scope='col'>Booker</th>
83
+ <th class='manage-column' scope='col'>E-mail</th>
84
+ <th class='manage-column' scope='col'>Phone number</th>
85
+ <th class='manage-column' scope='col'>Spaces</th>
86
+ <th class='manage-column' scope='col'>&nbsp;</th>
87
+ </tr>
88
+ </thead>
89
+ <tbody>
90
+ <?php
91
+ $rowno = 0;
92
+ $event_count = 0;
93
+ foreach ($bookings as $EM_Booking) {
94
+ if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
95
+ $rowno++;
96
+ ?>
97
+ <tr>
98
+ <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
99
+ <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person_id; ?>"><?php echo $EM_Booking->person->name ?></a></td>
100
+ <td><?php echo $EM_Booking->person->email ?></td>
101
+ <td><?php echo $EM_Booking->person->phone ?></td>
102
+ <td><?php echo $EM_Booking->seats ?></td>
103
+ <td>
104
+ <?php
105
+ $unapprove_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_unapprove', 'booking_id'=>$EM_Booking->id));
106
+ ?>
107
+ <a class="em-bookings-unapprove" href="<?php echo $unapprove_url ?>"><?php _e('Unapprove','dbem'); ?></a> |
108
+ <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit'); ?></a>
109
+ </td>
110
+ </tr>
111
+ <?php
112
+ }
113
+ $event_count++;
114
+ }
115
+ ?>
116
+ </tbody>
117
+ </table>
118
+ </div>
119
+ <?php else: ?>
120
+ <?php _e('No confirmed bookings.', 'dbem'); ?>
121
+ <?php endif; ?>
122
+ </form>
123
+ <?php if( $bookings >= $limit ) : ?>
124
+ <div class='tablenav'>
125
+ <?php echo $bookings_nav; ?>
126
+ <div class="clear"></div>
127
+ </div>
128
+ <?php endif; ?>
129
+ </div>
130
+ <?php
131
+
132
+ }
133
+ ?>
admin/bookings/em-events.php ADDED
@@ -0,0 +1,179 @@
1
+ <?php
2
+
3
+ /**
4
+ * Determines whether to show event page or events page, and saves any updates to the event or events
5
+ * @return null
6
+ */
7
+ function em_bookings_events_table() {
8
+ //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
9
+ global $wpdb;
10
+ global $EM_Event;
11
+
12
+ $scope_names = array (
13
+ 'past' => __ ( 'Past events', 'dbem' ),
14
+ 'all' => __ ( 'All events', 'dbem' ),
15
+ 'future' => __ ( 'Future events', 'dbem' )
16
+ );
17
+
18
+ $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_events_table' );
19
+ $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
20
+ $order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
21
+ $limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
22
+ $page = ( $action_scope && !empty($_GET['p']) ) ? $_GET['p']:1;
23
+ $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
24
+ $scope = ( $action_scope && !empty($_GET ['scope']) && array_key_exists($_GET ['scope'], $scope_names) ) ? $_GET ['scope']:'future';
25
+
26
+ // No action, only showing the events list
27
+ switch ($scope) {
28
+ case "past" :
29
+ $title = __ ( 'Past Events', 'dbem' );
30
+ break;
31
+ case "all" :
32
+ $title = __ ( 'All Events', 'dbem' );
33
+ break;
34
+ default :
35
+ $title = __ ( 'Future Events', 'dbem' );
36
+ $scope = "future";
37
+ }
38
+ $events = EM_Events::get( array('scope'=>$scope, 'limit'=>0, 'order'=>$order, 'rsvp'=>true ) );
39
+ $events_count = count ( $events );
40
+
41
+ $use_events_end = get_option ( 'dbem_use_event_end' );
42
+ ?>
43
+ <div class="wrap em_bookings_events_table em_obj">
44
+ <form id="posts-filter" action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="get">
45
+ <input type="hidden" name="em_obj" value="em_bookings_events_table" />
46
+ <?php if(!empty($_GET['page'])): ?>
47
+ <input type='hidden' name='page' value='events-manager-bookings' />
48
+ <?php endif; ?>
49
+ <ul class="subsubsub">
50
+ <li><a href='#' class="current"><?php _e ( 'Total', 'dbem' ); ?> <span class="count">(<?php echo (count ( $events )); ?>)</span></a></li>
51
+ </ul>
52
+ <div class="tablenav">
53
+ <div class="alignleft actions">
54
+ <!--
55
+ <select name="action">
56
+ <option value="-1" selected="selected"><?php _e ( 'Bulk Actions' ); ?></option>
57
+ <option value="deleteEvents"><?php _e ( 'Delete selected','dbem' ); ?></option>
58
+ </select>
59
+ <input type="submit" value="<?php _e ( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
60
+ -->
61
+ <select name="scope">
62
+ <?php
63
+ foreach ( $scope_names as $key => $value ) {
64
+ $selected = "";
65
+ if ($key == $scope)
66
+ $selected = "selected='selected'";
67
+ echo "<option value='$key' $selected>$value</option> ";
68
+ }
69
+ ?>
70
+ </select>
71
+ <input id="post-query-submit" class="button-secondary" type="submit" value="<?php _e ( 'Filter' )?>" />
72
+ </div>
73
+ <!--
74
+ <div class="view-switch">
75
+ <a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
76
+ </div>
77
+ -->
78
+ <?php
79
+ if ( $events_count >= $limit ) {
80
+ $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('p'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_events_table'));
81
+ $events_nav .= em_admin_paginate( $page_link_template, $events_count, $limit, $page, 5);
82
+ echo $events_nav;
83
+ }
84
+ ?>
85
+ <br class="clear" />
86
+ </div>
87
+
88
+ <?php
89
+ if (empty ( $events )) {
90
+ // TODO localize
91
+ _e ( 'no events','dbem' );
92
+ } else {
93
+ ?>
94
+ <div class='table-wrap'>
95
+ <table class="widefat">
96
+ <thead>
97
+ <tr>
98
+ <th class='manage-column column-cb check-column' scope='col'>
99
+ <input class='select-all' type="checkbox" value='1' />
100
+ </th>
101
+ <th><?php _e ( 'Event', 'dbem' ); ?></th>
102
+ <th><?php _e ( 'Date and time', 'dbem' ); ?></th>
103
+ </tr>
104
+ </thead>
105
+ <tbody>
106
+ <?php
107
+ $rowno = 0;
108
+ $event_count = 0;
109
+ foreach ( $events as $event ) {
110
+ /* @var $event EM_Event */
111
+ if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
112
+ $rowno++;
113
+ $class = ($rowno % 2) ? ' class="alternate"' : '';
114
+ // FIXME set to american
115
+ $localised_start_date = date_i18n('D d M Y', $event->start);
116
+ $localised_end_date = date_i18n('D d M Y', $event->end);
117
+ $style = "";
118
+ $today = date ( "Y-m-d" );
119
+
120
+ if ($event->start_date < $today && $event->end_date < $today){
121
+ $style = "style ='background-color: #FADDB7;'";
122
+ }
123
+ ?>
124
+ <tr <?php echo "$class $style"; ?>>
125
+
126
+ <td>
127
+ <input type='checkbox' class='row-selector' value='<?php echo $event->id; ?>' name='events[]' />
128
+ </td>
129
+ <td>
130
+ <strong>
131
+ <a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $event->id ?>"><?php echo ($event->name); ?></a>
132
+ </strong>
133
+ &ndash;
134
+ <?php _e("Booked Seats",'dbem') ?>: <?php echo $event->get_bookings()->get_booked_seats()."/".$event->seats ?>
135
+ <?php if( get_option('dbem_bookings_approval') == 1 ) : ?>
136
+ | <?php _e("Pending",'dbem') ?>: <?php echo $event->get_bookings()->get_pending_seats(); ?>
137
+ <?php endif; ?>
138
+ </td>
139
+
140
+ <td>
141
+ <?php echo $localised_start_date; ?>
142
+ <?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
143
+ &ndash;
144
+ <?php
145
+ //TODO Should 00:00 - 00:00 be treated as an all day event?
146
+ echo substr ( $event->start_time, 0, 5 ) . " - " . substr ( $event->end_time, 0, 5 );
147
+ ?>
148
+ </td>
149
+ </tr>
150
+ <?php
151
+ }
152
+ $event_count++;
153
+ }
154
+ ?>
155
+ </tbody>
156
+ </table>
157
+ </div>
158
+ <?php
159
+ } // end of table
160
+ ?>
161
+ <div class='tablenav'>
162
+ <div class="alignleft actions">
163
+ <br class='clear' />
164
+ </div>
165
+ <?php if ( $events_count >= $limit ) : ?>
166
+ <div class="tablenav-pages">
167
+ <?php
168
+ echo $events_nav;
169
+ ?>
170
+ </div>
171
+ <?php endif; ?>
172
+ <br class='clear' />
173
+ </div>
174
+ </form>
175
+ </div>
176
+ <?php
177
+ }
178
+
179
+ ?>
admin/bookings/em-pending.php ADDED
@@ -0,0 +1,155 @@
1
+ <?php
2
+
3
+ /**
4
+ * Generates a "widget" table of pending bookings with some quick admin operation options.
5
+ * If event id supplied then only pending bookings for that event will show.
6
+ *
7
+ * @param int $event_id
8
+ */
9
+ function em_bookings_pending_table($event_id = false){
10
+ global $EM_Event, $wpdb, $current_user;
11
+
12
+ if( get_option('dbem_bookings_approval') == 0 ){
13
+ return false;
14
+ }
15
+
16
+ $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_pending_table' );
17
+ $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
18
+ $order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
19
+ $limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
20
+ $page = ( $action_scope && !empty($_GET['p']) ) ? $_GET['p']:1;
21
+ $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
22
+
23
+ if( is_object($EM_Event) ){
24
+ $bookings = $EM_Event->get_bookings()->get_pending();
25
+ }else{
26
+ //To optimize performance, we can do one query here for all pending bookings to show.
27
+ $bookings = EM_Bookings::get(array('status'=>0));
28
+ $events = array();
29
+ //Now let's create events and bookings for this:
30
+ foreach($bookings as $EM_Booking){
31
+ //create event
32
+ if( !array_key_exists($EM_Booking->event_id,$events) ){
33
+ $events[$EM_Booking->event_id] = new EM_Event($EM_Booking->event_id);
34
+ }
35
+ }
36
+ }
37
+ $bookings_count = (is_array($bookings)) ? count($bookings):0;
38
+ ?>
39
+ <div class='wrap em_bookings_pending_table em_obj'>
40
+ <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
41
+ <input type="hidden" name="em_obj" value="em_bookings_pending_table" />
42
+ <!--
43
+ <ul class="subsubsub">
44
+ <li>
45
+ <a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
46
+ </li>
47
+ </ul>
48
+ <p class="search-box">
49
+ <label class="screen-reader-text" for="post-search-input"><?php _e('Search'); ?>:</label>
50
+ <input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
51
+ <input type="submit" value="<?php _e('Search'); ?>" class="button" />
52
+ </p>
53
+ -->
54
+ <?php if ( $bookings_count >= $limit ) : ?>
55
+ <div class='tablenav'>
56
+ <!--
57
+ <div class="alignleft actions">
58
+ <select name="action">
59
+ <option value="-1" selected="selected">
60
+ <?php _e('Bulk Actions'); ?>
61
+ </option>
62
+ <option value="approve">
63
+ <?php _e('Approve', 'dbem'); ?>
64
+ </option>
65
+ <option value="decline">
66
+ <?php _e('Decline', 'dbem'); ?>
67
+ </option>
68
+ </select>
69
+ <input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
70
+ </div>
71
+ -->
72
+ <!--
73
+ <div class="view-switch">
74
+ <a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
75
+ </div>
76
+ -->
77
+ <?php
78
+ if ( $bookings_count >= $limit ) {
79
+ $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('p'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_pending_table'));
80
+ $bookings_nav .= em_admin_paginate( $page_link_template, $bookings_count, $limit, $page, 5);
81
+ echo $bookings_nav;
82
+ }
83
+ ?>
84
+ <div class="clear"></div>
85
+ </div>
86
+ <?php endif; ?>
87
+ <div class="clear"></div>
88
+ <?php if( $bookings_count > 0 ): ?>
89
+ <div class='table-wrap'>
90
+ <table id='dbem-bookings-table' class='widefat post fixed'>
91
+ <thead>
92
+ <tr>
93
+ <th class='manage-column column-cb check-column' scope='col'>
94
+ <input class='select-all' type="checkbox" value='1' />
95
+ </th>
96
+ <th class='manage-column' scope='col'>Booker</th>
97
+ <?php if( !is_object($EM_Event) ): ?>
98
+ <th class='manage-column' scope="col">Event</th>
99
+ <?php endif; ?>
100
+ <th class='manage-column' scope='col'>E-mail</th>
101
+ <th class='manage-column' scope='col'>Phone number</th>
102
+ <th class='manage-column' scope='col'>Spaces</th>
103
+ <th class='manage-column' scope='col'>&nbsp;</th>
104
+ </tr>
105
+ </thead>
106
+ <tbody>
107
+ <?php
108
+ $rowno = 0;
109
+ $event_count = 0;
110
+ foreach ($bookings as $EM_Booking) {
111
+ if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
112
+ $rowno++;
113
+ ?>
114
+ <tr>
115
+ <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
116
+ <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person->id; ?>"><?php echo $EM_Booking->person->name ?></a></td>
117
+ <?php if( !is_object($EM_Event) ): ?>
118
+ <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $EM_Booking->event_id; ?>"><?php echo $events[$EM_Booking->event_id]->name ?></a></td>
119
+ <?php endif; ?>
120
+ <td><?php echo $EM_Booking->person->email ?></td>
121
+ <td><?php echo $EM_Booking->person->phone ?></td>
122
+ <td><?php echo $EM_Booking->seats ?></td>
123
+ <td>
124
+ <?php
125
+ $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->id));
126
+ $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->id));
127
+ ?>
128
+ <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
129
+ <a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','dbem'); ?></a> |
130
+ <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit'); ?></a>
131
+ </td>
132
+ </tr>
133
+ <?php
134
+ }
135
+ $event_count++;
136
+ }
137
+ ?>
138
+ </tbody>
139
+ </table>
140
+ </div>
141
+ <?php else: ?>
142
+ <?php _e('No pending bookings.', 'dbem'); ?>
143
+ <?php endif; ?>
144
+ </form>
145
+ <?php if( $bookings >= $limit ) : ?>
146
+ <div class='tablenav'>
147
+ <?php echo $bookings_nav; ?>
148
+ <div class="clear"></div>
149
+ </div>
150
+ <?php endif; ?>
151
+ </div>
152
+ <?php
153
+
154
+ }
155
+ ?>
admin/bookings/em-person.php ADDED
@@ -0,0 +1,150 @@
1
+ <?php
2
+
3
+ /**
4
+ * Generates a "widget" table of confirmed bookings for a specific event.
5
+ *
6
+ * @param int $event_id
7
+ */
8
+ function em_bookings_person_table(){
9
+ global $wpdb, $current_user,$EM_Person;
10
+ if(!is_object($EM_Person)){
11
+ return false;
12
+ }
13
+ $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
14
+ $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
15
+ $order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
16
+ $limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
17
+ $page = ( $action_scope && !empty($_GET['p']) ) ? $_GET['p']:1;
18
+ $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
19
+
20
+ $bookings = $EM_Person->get_bookings();
21
+ $bookings_count = (is_array($bookings)) ? count($bookings):0;
22
+ if($bookings_count > 0){
23
+ //Get events here in one query to speed things up
24
+ foreach($bookings as $EM_Booking){
25
+ $event_ids[] = $EM_Booking->event_id;
26
+ }
27
+ $events = EM_Events::get($event_ids);
28
+ }
29
+ ?>
30
+ <div class='wrap em_bookings_pending_table em_obj'>
31
+ <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
32
+ <input type="hidden" name="em_obj" value="em_bookings_pending_table" />
33
+ <!--
34
+ <ul class="subsubsub">
35
+ <li>
36
+ <a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
37
+ </li>
38
+ </ul>
39
+ <p class="search-box">
40
+ <label class="screen-reader-text" for="post-search-input"><?php _e('Search'); ?>:</label>
41
+ <input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
42
+ <input type="submit" value="<?php _e('Search'); ?>" class="button" />
43
+ </p>
44
+ -->
45
+ <?php if ( $bookings_count >= $limit ) : ?>
46
+ <div class='tablenav'>
47
+ <!--
48
+ <div class="alignleft actions">
49
+ <select name="action">
50
+ <option value="-1" selected="selected">
51
+ <?php _e('Bulk Actions'); ?>
52
+ </option>
53
+ <option value="approve">
54
+ <?php _e('Approve', 'dbem'); ?>
55
+ </option>
56
+ <option value="decline">
57
+ <?php _e('Decline', 'dbem'); ?>
58
+ </option>
59
+ </select>
60
+ <input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
61
+ </div>
62
+ -->
63
+ <!--
64
+ <div class="view-switch">
65
+ <a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
66
+ </div>
67
+ -->
68
+ <?php
69
+ if ( $bookings_count >= $limit ) {
70
+ $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('p'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
71
+ $bookings_nav .= em_admin_paginate( $page_link_template, $bookings_count, $limit, $page, 5);
72
+ echo $bookings_nav;
73
+ }
74
+ ?>
75
+ <div class="clear"></div>
76
+ </div>
77
+ <?php endif; ?>
78
+ <div class="clear"></div>
79
+ <?php if( $bookings_count > 0 ): ?>
80
+ <div class='table-wrap'>
81
+ <table id='dbem-bookings-table' class='widefat post fixed'>
82
+ <thead>
83
+ <tr>
84
+ <th class='manage-column column-cb check-column' scope='col'>
85
+ <input class='select-all' type="checkbox" value='1' />
86
+ </th>
87
+ <th class='manage-column' scope='col'>Event</th>
88
+ <th class='manage-column' scope='col'>Spaces</th>
89
+ <th class='manage-column' scope='col'>Status</th>
90
+ <th class='manage-column' scope='col'>&nbsp;</th>
91
+ </tr>
92
+ </thead>
93
+ <tbody>
94
+ <?php
95
+ $rowno = 0;
96
+ $event_count = 0;
97
+ foreach ($bookings as $EM_Booking) {
98
+ $EM_Event = $events[$EM_Booking->event_id];
99
+ if( $EM_Event->can_manage() && ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
100
+ $rowno++;
101
+ ?>
102
+ <tr>
103
+ <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
104
+ <td><a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $EM_Event->id ?>"><?php echo ($EM_Event->name); ?></a></td>
105
+ <td><?php echo $EM_Booking->seats ?></td>
106
+ <td><?php echo $EM_Booking->status_array[$EM_Booking->status]; ?>
107
+ </td>
108
+ <td>
109
+ <?php
110
+ $unapprove_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_unapprove', 'bookings'=>$EM_Booking->id));
111
+ $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'bookings'=>$EM_Booking->id));
112
+ $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'bookings'=>$EM_Booking->id));
113
+ $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'bookings'=>$EM_Booking->id));
114
+ ?>
115
+ <?php if( $EM_Booking->status == 0 || $EM_Booking->status == 2 ): ?>
116
+ <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
117
+ <?php endif; ?>
118
+ <?php if( $EM_Booking->status == 2 ): ?>
119
+ <a class="em-bookings-unapprove" href="<?php echo $unapprove_url ?>"><?php _e('Unapprove','dbem'); ?></a> |
120
+ <?php endif; ?>
121
+ <?php if( $EM_Booking->status == 0 || $EM_Booking->status == 1 ): ?>
122
+ <a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','dbem'); ?></a> |
123
+ <?php endif; ?>
124
+ <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit'); ?></a> |
125
+ <a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a>
126
+ </td>
127
+ </tr>
128
+ <?php
129
+ }
130
+ $event_count++;
131
+ }
132
+ ?>
133
+ </tbody>
134
+ </table>
135
+ </div>
136
+ <?php else: ?>
137
+ <?php _e('No confirmed bookings.', 'dbem'); ?>
138
+ <?php endif; ?>
139
+ </form>
140
+ <?php if( $bookings >= $limit ) : ?>
141
+ <div class='tablenav'>
142
+ <?php echo $bookings_nav; ?>
143
+ <div class="clear"></div>
144
+ </div>
145
+ <?php endif; ?>
146
+ </div>
147
+ <?php
148
+
149
+ }
150
+ ?>
admin/bookings/em-rejected.php ADDED
@@ -0,0 +1,133 @@
1
+ <?php
2
+ /**
3
+ * Generates a "widget" table of confirmed bookings for a specific event.
4
+ *
5
+ * @param int $event_id
6
+ */
7
+ function em_bookings_rejected_table(){
8
+ global $EM_Event, $wpdb, $current_user;
9
+
10
+ $action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table' );
11
+ $action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
12
+ $order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
13
+ $limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
14
+ $page = ( $action_scope && !empty($_GET['p']) ) ? $_GET['p']:1;
15
+ $offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
16
+
17
+ if( is_object($EM_Event) ){
18
+ $bookings = $EM_Event->get_bookings()->get_rejected_bookings();
19
+ }else{
20
+ return false;
21
+ }
22
+ $bookings_count = (is_array($bookings)) ? count($bookings):0;
23
+ ?>
24
+ <div class='wrap em_bookings_pending_table em_obj'>
25
+ <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
26
+ <input type="hidden" name="em_obj" value="em_bookings_pending_table" />
27
+ <!--
28
+ <ul class="subsubsub">
29
+ <li>
30
+ <a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
31
+ </li>
32
+ </ul>
33
+ <p class="search-box">
34
+ <label class="screen-reader-text" for="post-search-input"><?php _e('Search'); ?>:</label>
35
+ <input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? $_GET['em_search']:''; ?>" />
36
+ <input type="submit" value="<?php _e('Search'); ?>" class="button" />
37
+ </p>
38
+ -->
39
+ <?php if ( $bookings_count >= $limit ) : ?>
40
+ <div class='tablenav'>
41
+ <!--
42
+ <div class="alignleft actions">
43
+ <select name="action">
44
+ <option value="-1" selected="selected">
45
+ <?php _e('Bulk Actions'); ?>
46
+ </option>
47
+ <option value="approve">
48
+ <?php _e('Approve', 'dbem'); ?>
49
+ </option>
50
+ <option value="decline">
51
+ <?php _e('Decline', 'dbem'); ?>
52
+ </option>
53
+ </select>
54
+ <input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
55
+ </div>
56
+ -->
57
+ <!--
58
+ <div class="view-switch">
59
+ <a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a>
60
+ </div>
61
+ -->
62
+ <?php
63
+ if ( $bookings_count >= $limit ) {
64
+ $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('p'=>'%PAGE%', 'em_ajax'=>0, 'em_obj'=>'em_bookings_confirmed_table'));
65
+ $bookings_nav .= em_admin_paginate( $page_link_template, $bookings_count, $limit, $page, 5);
66
+ echo $bookings_nav;
67
+ }
68
+ ?>
69
+ <div class="clear"></div>
70
+ </div>
71
+ <?php endif; ?>
72
+ <div class="clear"></div>
73
+ <?php if( $bookings_count > 0 ): ?>
74
+ <div class='table-wrap'>
75
+ <table id='dbem-bookings-table' class='widefat post fixed'>
76
+ <thead>
77
+ <tr>
78
+ <th class='manage-column column-cb check-column' scope='col'>
79
+ <input class='select-all' type="checkbox" value='1' />
80
+ </th>
81
+ <th class='manage-column' scope='col'>Booker</th>
82
+ <th class='manage-column' scope='col'>E-mail</th>
83
+ <th class='manage-column' scope='col'>Phone number</th>
84
+ <th class='manage-column' scope='col'>Spaces</th>
85
+ <th class='manage-column' scope='col'>&nbsp;</th>
86
+ </tr>
87
+ </thead>
88
+ <tbody>
89
+ <?php
90
+ $rowno = 0;
91
+ $event_count = 0;
92
+ foreach ($bookings as $EM_Booking) {
93
+ if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
94
+ $rowno++;
95
+ ?>
96
+ <tr>
97
+ <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></th>
98
+ <td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person->id; ?>"><?php echo $EM_Booking->person->name ?></a></td>
99
+ <td><?php echo $EM_Booking->person->email ?></td>
100
+ <td><?php echo $EM_Booking->person->phone ?></td>
101
+ <td><?php echo $EM_Booking->seats ?></td>
102
+ <td>
103
+ <?php
104
+ $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->id));
105
+ $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->id));
106
+ ?>
107
+ <a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','dbem'); ?></a> |
108
+ <a class="em-bookings-edit" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;booking_id=<?php echo $EM_Booking->id; ?>"><?php _e('Edit'); ?></a> |
109
+ <a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','dbem'); ?></a>
110
+ </td>
111
+ </tr>
112
+ <?php
113
+ }
114
+ $event_count++;
115
+ }
116
+ ?>
117
+ </tbody>
118
+ </table>
119
+ </div>
120
+ <?php else: ?>
121
+ <?php _e('No rejected bookings.', 'dbem'); ?>
122
+ <?php endif; ?>
123
+ </form>
124
+ <?php if( $bookings >= $limit ) : ?>
125
+ <div class='tablenav'>
126
+ <?php echo $bookings_nav; ?>
127
+ <div class="clear"></div>
128
+ </div>
129
+ <?php endif; ?>
130
+ </div>
131
+ <?php
132
+ }
133
+ ?>
admin/em-admin.php CHANGED
@@ -7,33 +7,85 @@
7
function em_admin_warnings() {
8
//If we're editing the events page show hello to new user
9
$events_page_id = get_option ( 'dbem_events_page' );
10
- if (isset ( $_GET ['disable_hello_to_user'] ) && $_GET ['disable_hello_to_user'] == 'true'){
11
- // Disable Hello to new user if requested
12
- update_option ( 'dbem_hello_to_user', 0 );
13
- }else{
14
- if ( preg_match( '/(post|page).php/', $_SERVER ['SCRIPT_NAME']) && isset ( $_GET ['action'] ) && $_GET ['action'] == 'edit' && isset ( $_GET ['post'] ) && $_GET ['post'] == "$events_page_id") {
15
- $message = sprintf ( __ ( "This page corresponds to <strong>Events Manager</strong> events page. Its content will be overriden by <strong>Events Manager</strong>. If you want to display your content, you can can assign another page to <strong>Events Manager</strong> in the the <a href='%s'>Settings</a>. ", 'dbem' ), 'admin.php?page=events-manager-options' );
16
- $notice = "<div class='error'><p>$message</p></div>";
17
- echo $notice;
18
- }
19
- }
20
- //If events page couldn't be created
21
- if( !empty($_GET['em_dismiss_events_page']) ){
22
- update_option('dbem_dismiss_events_page',1);
23
- }else{
24
- if ( !get_page($events_page_id) && !get_option('dbem_dismiss_events_page') ){
25
- $dismiss_link_joiner = ( count($_GET) > 0 ) ? '&amp;':'?';
26
- $advice = sprintf ( __( 'Uh Oh! For some reason wordpress could not create an events page for you (or you just deleted it). Not to worry though, all you have to do is create an empty page, name it whatever you want, and select it as your events page in your <a href="%s">options page</a>. Sorry for the extra step! If you know what you are doing, you may have done this on purpose, if so <a href="%s">ignore this message</a>', 'dbem'), get_bloginfo ( 'url' ) . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'].$dismiss_link_joiner.'em_dismiss_events_page=1' );
27
?>
28
- <div id="em_page_error" class="updated">
29
- <p><?php echo $advice; ?></p>
30
</div>
31
- <?php
32
}
33
}
34
}
35
add_action ( 'admin_notices', 'em_admin_warnings' );
36
37
/**
38
* Called by admin_print_scripts-(hook|page) action, created when adding menu items in events-manager.php
39
*/
@@ -202,7 +254,7 @@ function em_admin_general_script() {
202
}
203
return true;
204
}
205
- $('#eventForm').bind("submit", validateEventForm);
206
});
207
//]]>
208
</script>
7
function em_admin_warnings() {
8
//If we're editing the events page show hello to new user
9
$events_page_id = get_option ( 'dbem_events_page' );
10
+ $dismiss_link_joiner = ( count($_GET) > 0 ) ? '&amp;':'?';
11
+
12
+ if( em_verify_admin() ){
13
+ //New User Intro
14
+ if (isset ( $_GET ['disable_hello_to_user'] ) && $_GET ['disable_hello_to_user'] == 'true'){
15
+ // Disable Hello to new user if requested
16
+ update_option ( 'dbem_hello_to_user', 0 );
17
+ }elseif ( get_option ( 'dbem_hello_to_user' ) == 1 && $_GET['page'] == 'events-manager-events' ) {
18
+ $current_user = wp_get_current_user ();
19
+ //FIXME update welcome msg with good links
20
+ $advice = sprintf ( __ ( "<p>Hey, <strong>%s</strong>, welcome to <strong>Events Manager</strong>! We hope you like it around here.</p>
21
+ <p>Now it's time to insert events lists through <a href='%s' title='Widgets page'>widgets</a>, <a href='%s' title='Template tags documentation'>template tags</a> or <a href='%s' title='Shortcodes documentation'>shortcodes</a>.</p>
22
+ <p>By the way, have you taken a look at the <a href='%s' title='Change settings'>Settings page</a>? That's where you customize the way events and locations are displayed.</p>
23
+ <p>What? Tired of seeing this advice? I hear you, <a href='%s' title='Don't show this advice again'>click here</a> and you won't see this again!</p>", 'dbem' ), $current_user->display_name, get_bloginfo ( 'url' ) . '/wp-admin/widgets.php', 'http://wp-events-plugin.com/documentation/template-tags/', 'http://wp-events-plugin.com/documentation/shortcodes/', get_bloginfo ( 'url' ) . '/wp-admin/admin.php?page=events-manager-options', get_bloginfo ( 'url' ) . '/wp-admin/admin.php?page=events-manager&disable_hello_to_user=true' );
24
?>
25
+ <div id="message" class="updated">
26
+ <?php echo $advice; ?>
27
</div>
28
+ <?php
29
+ }
30
+
31
+ //If events page couldn't be created
32
+ if( !empty($_GET['em_dismiss_admin_notice']) ){
33
+ delete_option('dbem_admin_notice_'.$_GET['em_dismiss_admin_notice']);
34
+ }else{
35
+ if ( get_option('dbem_admin_notice_3.0.91') ){
36
+ ?>
37
+ <div class="updated">
38
+ <p><?php echo sprintf ( __( '<strong>Events Manager has some new features!</strong><ul><li>Bookings can now be approved before they count towards your event\'s space allocations.</li><li>Events now have owners, and you can restrict users so they can only manage events/locations/categories they create.<br/><br/>These new permissions are enabled by default, but since you upgraded it has been disabled to maintain the previous plugin behaviour. You can re-enable it from the <a href="%s">settings page</a>. <a href="%s">Dismiss</a>', 'dbem'), get_bloginfo ( 'url' ) . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'].$dismiss_link_joiner.'em_dismiss_admin_notice=3.0.91' ); ?></p>
39
+ </div>
40
+ <?php
41
+ }
42
+ }
43
+
44
+ //If events page couldn't be created
45
+ if( !empty($_GET['em_dismiss_events_page']) ){
46
+ update_option('dbem_dismiss_events_page',1);
47
+ }else{
48
+ if ( !get_page($events_page_id) && !get_option('dbem_dismiss_events_page') ){
49
+ ?>
50
+ <div id="em_page_error" class="updated">
51
+ <p><?php echo sprintf ( __( 'Uh Oh! For some reason wordpress could not create an events page for you (or you just deleted it). Not to worry though, all you have to do is create an empty page, name it whatever you want, and select it as your events page in your <a href="%s">settings page</a>. Sorry for the extra step! If you know what you are doing, you may have done this on purpose, if so <a href="%s">ignore this message</a>', 'dbem'), get_bloginfo ( 'url' ) . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'].$dismiss_link_joiner.'em_dismiss_events_page=1' ); ?></p>
52
+ </div>
53
+ <?php
54
+ }
55
}
56
}
57
+ //Warn about EM page edit
58
+ if ( preg_match( '/(post|page).php/', $_SERVER ['SCRIPT_NAME']) && isset ( $_GET ['action'] ) && $_GET ['action'] == 'edit' && isset ( $_GET ['post'] ) && $_GET ['post'] == "$events_page_id") {
59
+ $message = sprintf ( __ ( "This page corresponds to <strong>Events Manager</strong> events page. Its content will be overriden by <strong>Events Manager</strong>. If you want to display your content, you can can assign another page to <strong>Events Manager</strong> in the the <a href='%s'>Settings</a>. ", 'dbem' ), 'admin.php?page=events-manager-options' );
60
+ $notice = "<div class='error'><p>$message</p></div>";
61
+ echo $notice;
62
+ }
63
+
64
}
65
add_action ( 'admin_notices', 'em_admin_warnings' );
66
67
+ /**
68
+ * Creates a wp-admin style navigation. All this does is wrap some html around the em_paginate function result to make it style correctly in the admin area.
69
+ * @param string $link
70
+ * @param int $total
71
+ * @param int $limit
72
+ * @param int $page
73
+ * @param int $pagesToShow
74
+ * @return string
75
+ * @uses em_paginate()
76
+ */
77
+ function em_admin_paginate($link, $total, $limit, $page=1, $pagesToShow=5){
78
+ $return = '<div class="tablenav-pages">';
79
+ $return .= sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>',
80
+ number_format_i18n( ( $page - 1 ) * $limit + 1 ),
81
+ number_format_i18n( min( $page * $limit, $total ) ),
82
+ number_format_i18n( $total )
83
+ );
84
+ $return .= em_paginate($link, $total, $limit, $page, $pagesToShow);
85
+ $return .= '</div>';
86
+ return $return;
87
+ }
88
+
89
/**
90
* Called by admin_print_scripts-(hook|page) action, created when adding menu items in events-manager.php
91
*/
254
}
255
return true;
256
}
257
+ $('#event-form').bind("submit", validateEventForm);
258
});
259
//]]>
260
</script>
admin/em-bookings.php CHANGED
@@ -1,82 +1,283 @@
1
<?php
2
/**
3
- * Check if there's any actions to take for bookings
4
* @return null
5
*/
6
function em_admin_actions_bookings() {
7
global $dbem_form_add_message;
8
global $dbem_form_delete_message;
9
- global $wpdb;
10
-
11
- //DELETE Bookings
12
- if( isset($_POST['secondaryAction']) && $_POST['secondaryAction'] == 'delete_bookings' ){
13
- if( EM_Object::array_is_numeric($_GET['bookings']) && count($_GET['bookings']) > 0 ){
14
- $bookings = $_GET['bookings'];
15
- $sql = "DELETE FROM ". $wpdb->prefix.EM_BOOKINGS_TABLE ." WHERE booking_id = ". implode(' OR booking_id = ', $bookings);
16
- $wpdb->query($sql);
17
- $dbem_form_delete_message = __('Bookings deleted', 'dbem');
18
}
19
}
20
}
21
- add_action('init','em_admin_actions_bookings');
22
23
/**
24
- * Shows table of bookings for an event
25
- * @return null
26
*/
27
- function em_bookings_table() {
28
- global $EM_Event;
29
?>
30
- <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
31
- <input type='hidden' name='page' value='events-manager-bookings'/>
32
- <input type='hidden' name='event_id' value='<?php echo $EM_Event->id ?>'/>
33
- <input type='hidden' name='action' value='delete'/>
34
- <div class='wrap'>
35
- <h2>Bookings</h2>
36
- <table id='dbem-bookings-table' class='widefat post fixed'>
37
- <thead>
38
- <tr>
39
- <th class='manage-column column-cb check-column' scope='col'>&nbsp;</th>
40
- <th class='manage-column ' scope='col'>Booker</th>
41
- <th scope='col'>E-mail</th>
42
- <th scope='col'>Phone number</th>
43
- <th scope='col'>Seats</th>
44
- </tr>
45
- </thead>
46
- <tbody>
47
- <?php
48
- foreach ($EM_Event->get_bookings()->bookings as $EM_Booking) {
49
- ?>
50
- <tr>
51
- <td><input type='checkbox' value='<?php echo $EM_Booking->id ?>' name='bookings[]'/></td>
52
- <td><?php echo $EM_Booking->name ?></td>
53
- <td><?php echo $EM_Booking->email ?></td>
54
- <td><?php echo $EM_Booking->phone ?></td>
55
- <td><?php echo $EM_Booking->seats ?></td>
56
- </tr>
57
- <?php
58
- }
59
- ?>
60
- </tbody>
61
- <tfoot>
62
- <tr>
63
- <th scope='row' colspan='4'>Booked seats:</th>
64
- <td class='booking-result' id='booked-seats'><?php echo $EM_Event->get_bookings()->get_booked_seats() ?></td>
65
- </tr>
66
- <tr>
67
- <th scope='row' colspan='4'>Available seats:</th>
68
- <td class='booking-result' id='available-seats'><?php echo $EM_Event->get_bookings()->get_booked_seats() ?></td>
69
- </tr>
70
- </tfoot>
71
- </table>
72
</div>
73
- <div class='tablenav'>
74
- <div class='alignleft actions'>
75
- <input class='button-secondary action' type='submit' name='doaction2' value='Delete'/>
76
- <br class='clear'/>
77
</div>
78
- <br class='clear'/>
79
- </div>
80
</form>
81
<?php
82
}
1
<?php
2
/**
3
+ * Check if there's any admin-related actions to take for bookings. All actions are caught here.
4
* @return null
5
*/
6
function em_admin_actions_bookings() {
7
global $dbem_form_add_message;
8
global $dbem_form_delete_message;
9
+ global $wpdb, $EM_Booking, $EM_Event;
10
+
11
+ if( current_user_can(EM_MIN_CAPABILITY) && is_object($EM_Booking) && !empty($_REQUEST['action']) ) {
12
+ if( $_REQUEST['action'] == 'bookings_delete' ){
13
+ //Delete
14
+ if( isset($_POST['booking_id']) ){
15
+ $EM_Booking = new EM_Booking($_POST['booking_id']);
16
+ $EM_Booking->delete();
17
+ }
18
+ }elseif( $_REQUEST['action'] == 'bookings_edit' ){
19
+ //Edit Booking
20
+ $validation = $EM_Booking->get_post();
21
+ if ( $validation ) { //EM_Event gets the event if submitted via POST and validates it (safer than to depend on JS)
22
+ //Save
23
+ if( $EM_Booking->save() ) {
24
+ function em_booking_save_notification(){ global $EM_Booking; ?><div class="updated"><p><strong><?php echo $EM_Booking->feedback_message; ?></strong></p></div><?php }
25
+ }else{
26
+ function em_booking_save_notification(){ global $EM_Booking; ?><div class="error"><p><strong><?php echo $EM_Booking->feedback_message; ?></strong></p></div><?php }
27
+ }
28
+ }else{
29
+ //TODO make errors clearer when saving person
30
+ function em_booking_save_notification(){ global $EM_Booking; ?><div class="error"><p><strong><?php echo $EM_Booking->feedback_message; ?></strong></p></div><?php }
31
+ }
32
+ add_action ( 'admin_notices', 'em_booking_save_notification' );
33
+ }elseif( $_REQUEST['action'] == 'bookings_approve' || $_REQUEST['action'] == 'bookings_reject' || $_REQUEST['action'] == 'bookings_unapprove' ){
34
+ //Booking Approvals
35
+ $status_array = array('bookings_unapprove' => 0,'bookings_approve' => 1,'bookings_reject' => 2, 'bookings_cancel' => 3);
36
+ if( $EM_Booking->set_status( $status_array[$_REQUEST['action']] ) ) {
37
+ function em_booking_save_notification(){ global $EM_Booking; ?><div class="updated"><p><strong><?php echo $EM_Booking->feedback_message; ?></strong></p></div><?php }
38
+ }else{
39
+ function em_booking_save_notification(){ global $EM_Booking; ?><div class="error"><p><strong><?php echo $EM_Booking->feedback_message; ?></strong></p></div><?php }
40
+ }
41
+ add_action ( 'admin_notices', 'em_booking_save_notification' );
42
+ }elseif( $_REQUEST['action'] == 'bookings_add_note' ){
43
+ $EM_Booking->add_note($_REQUEST['booking_note']);
44
+ function em_booking_save_notification(){ global $EM_Booking; ?><div class="updated"><p><strong><?php echo $EM_Booking->feedback_message; ?></strong></p></div><?php }
45
+ add_action ( 'admin_notices', 'em_booking_save_notification' );
46
+ }
47
+ }elseif( current_user_can(EM_MIN_CAPABILITY) && is_object($EM_Event) && !empty($_REQUEST['action']) ){
48
+ if( $_REQUEST['action'] == 'export_csv' ){
49
+ $EM_Event->get_bookings()->export_csv();
50
+ exit();
51
}
52
}
53
}
54
+ add_action('admin_init','em_admin_actions_bookings',100);
55
56
/**
57
+ * Decide what content to show in the bookings section.
58
+ */
59
+ function em_bookings_page(){
60
+ //First any actions take priority
61
+ if( !empty($_REQUEST['booking_id']) ){
62
+ em_bookings_single();
63
+ }elseif( !empty($_REQUEST['person_id']) ){
64
+ em_bookings_person();
65
+ }elseif( !empty($_REQUEST['event_id']) ){
66
+ em_bookings_event();
67
+ }else{
68
+ em_bookings_dashboard();
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Generates the bookings dashboard, showing information on all events
74
+ */
75
+ function em_bookings_dashboard(){
76
+ ?>
77
+ <div class='wrap'>
78
+ <div id='icon-users' class='icon32'>
79
+ <br/>
80
+ </div>
81
+ <h2>
82
+ <?php _e('Event Bookings Dashboard', 'dbem'); ?>
83
+ </h2>
84
+ <h2><?php _e('Pending Bookings','dbem'); ?></h2>
85
+ <?php em_bookings_pending_table(); ?>
86
+ <h2><?php _e('Events With Bookings Enabled','dbem'); ?></h2>
87
+ <?php em_bookings_events_table(); ?>
88
+ </div>
89
+ <?php
90
+ }
91
+
92
+ /**
93
+ * Shows all booking data for a single event
94
*/
95
+ function em_bookings_event(){
96
+ global $EM_Event,$EM_Person;
97
+ //check that user can access this page
98
+ if( is_object($EM_Event) && !$EM_Event->can_manage() ){
99
+ ?>
100
+ <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
101
+ <?php
102
+ return false;
103
+ }
104
+ $localised_start_date = date_i18n('D d M Y', $EM_Event->start);
105
+ $localised_end_date = date_i18n('D d M Y', $EM_Event->end);
106
?>
107
+ <div class='wrap'>
108
+ <div id='icon-users' class='icon32'>
109
+ <br/>
110
+ </div>
111
+ <h2>
112
+ <?php echo sprintf(__('Manage %s Bookings', 'dbem'), "'{$EM_Event->name}'"); ?>
113
+ <a href="admin.php?page=events-manager-event&event_id=<?php echo $EM_Event->id; ?>" class="button add-new-h2"><?php _e('View/Edit Event','dbem') ?></a>
114
+ </h2>
115
+ <div><a href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=export_csv&event_id=".$EM_Event->id ?>'><?php _e('export csv','dbem')?></a></div>
116
+ <div>
117
+ <p><strong><?php _e('Event Name','dbem'); ?></strong> : <?php echo ($EM_Event->name); ?></p>
118
+ <p><strong>Availability :</strong> <?php echo $EM_Event->get_bookings()->get_booked_seats() . '/'. $EM_Event->seats ." ". __('Seats confirmed','dbem'); ?></p>
119
+ <p>
120
+ <strong><?php _e('Date','dbem'); ?></strong> :
121
+ <?php echo $localised_start_date; ?>
122
+ <?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
123
+ <?php echo substr ( $EM_Event->start_time, 0, 5 ) . " - " . substr ( $EM_Event->end_time, 0, 5 ); ?>
124
+ </p>
125
+ <p>
126
+ <strong><?php _e('Location','dbem'); ?></strong> :
127
+ <a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-locations&amp;location_id=<?php echo $EM_Event->location->id ?>"><?php echo ($EM_Event->location->name); ?></a>
128
+ </p>
129
</div>
130
+ <h2><?php _e('Pending Bookings','dbem'); ?></h2>
131
+ <?php em_bookings_pending_table(); ?>
132
+ <h2><?php _e('Confirmed Bookings','dbem'); ?></h2>
133
+ <?php em_bookings_confirmed_table(); ?>
134
+ <h2><?php _e('Rejected Bookings','dbem'); ?></h2>
135
+ <?php em_bookings_rejected_table(); ?>
136
+ <h2><?php _e('Cancelled Bookings','dbem'); ?></h2>
137
+ <?php em_bookings_cancelled_table(); ?>
138
+ </div>
139
+ <?php
140
+ }
141
+
142
+ /**
143
+ * Shows a single booking for a single person.
144
+ */
145
+ function em_bookings_single(){
146
+ global $EM_Booking;
147
+ //check that user can access this page
148
+ if( is_object($EM_Booking) && !$EM_Booking->can_manage() ){
149
+ ?>
150
+ <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
151
+ <?php
152
+ return false;
153
+ }
154
+ ?>
155
+ <div class='wrap'>
156
+ <div id='icon-users' class='icon32'>
157
+ <br/>
158
+ </div>
159
+ <h2>
160
+ <?php _e('Edit Booking', 'dbem'); ?>
161
+ </h2>
162
+ <div id="poststuff" class="metabox-holder has-right-sidebar">
163
+ <div id="post-body">
164
+ <div id="post-body-content">
165
+ <div id="event_name" class="stuffbox">
166
+ <h3>
167
+ <?php _e ( 'Booking Details', 'dbem' ); ?>
168
+ </h3>
169
+ <div class="inside">
170
+ <?php em_bookings_edit_form(); ?>
171
+ </div>
172
+ </div>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ <br style="clear:both;" />
177
+ <div id="poststuff" class="metabox-holder has-right-sidebar">
178
+ <div id="post-body">
179
+ <div id="post-body-content">
180
+ <div id="event_name" class="stuffbox">
181
+ <h3>
182
+ <?php _e ( 'Booking Notes', 'dbem' ); ?>
183
+ </h3>
184
+ <div class="inside">
185
+ <p><?php _e('You can add private notes below for internal reference that only event managers will see.','dbem'); ?></p>
186
+ <?php foreach( $EM_Booking->notes as $note ):
187
+ $user = get_userdata($note['author']);
188
+ ?>
189
+ <div>
190
+ <?php echo date(get_option('date_format'), $note['timestamp']) .' - '. $user->display_name; ?> <?php _e('wrote','dbem'); ?>:
191
+ <p style="background:#efefef; padding:5px;"><?php echo nl2br($note['note']); ?></p>
192
+ </div>
193
+ <?php endforeach; ?>
194
+ <form method="post" action="" style="padding:5px;">
195
+ <textarea class="widefat" rows="5" name="booking_note"></textarea>
196
+ <input type="hidden" name="action" value="bookings_add_note" />
197
+ <input type="submit" value="Add Note" />
198
+ </form>
199
+ </div>
200
+ </div>
201
+ </div>
202
</div>
203
+ </div>
204
+ <br style="clear:both;" />
205
+ <?php do_action('em_bookings_single_footer'); ?>
206
+ </div>
207
+ <?php
208
+
209
+ }
210
+
211
+ /**
212
+ * Shows all bookings made by one person.
213
+ */
214
+ function em_bookings_person(){
215
+ global $EM_Person;
216
+ ?>
217
+ <div class='wrap'>
218
+ <div id='icon-users' class='icon32'>
219
+ <br/>
220
+ </div>
221
+ <h2>
222
+ <?php _e('Manage Person\'s Booking', 'dbem'); ?>
223
+ <a href="admin.php?page=events-manager-bookings&action=person_delete&person_id=<?php echo $EM_Person->id; ?>" onclick="if( !confirm('<?php _e('Are you sure you want to delete this person? All bookings corresponding to this person will be deleted and this is not reversible.','dbem') ?>') ){ return false; }" class="button add-new-h2"><?php _e('Delete Person','dbem') ?></a>
224
+ </h2>
225
+ <div id="poststuff" class="metabox-holder has-right-sidebar">
226
+ <div id="post-body">
227
+ <div id="post-body-content">
228
+ <div id="event_name" class="stuffbox">
229
+ <h3>
230
+ <?php _e ( 'Personal Details', 'dbem' ); ?>
231
+ </h3>
232
+ <div class="inside">
233
+ <?php em_person_edit_form(); ?>
234
+ </div>
235
+ </div>
236
+ </div>
237
+ </div>
238
+ </div>
239
+ <br style="clear:both;" />
240
+ <h3><?php _e('Past And Present Bookings','dbem'); ?></h3>
241
+ <?php em_bookings_person_table(); ?>
242
+ </div>
243
+ <?php
244
+ }
245
+
246
+ function em_bookings_edit_form(){
247
+ global $EM_Booking;
248
+ $EM_Event = new EM_Event($EM_Booking->event_id);
249
+ $localised_start_date = date_i18n('D d M Y', $EM_Event->start);
250
+ $localised_end_date = date_i18n('D d M Y', $EM_Event->end);
251
+ ?>
252
+ <form action="" method="post" id="em-person-form">
253
+ <h4>Event Details</h4>
254
+ <table>
255
+ <tr><td><strong><?php _e('Name','dbem'); ?></strong></td><td><a class="row-title" href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php echo $EM_Event->id ?>"><?php echo ($EM_Event->name); ?></a></td></tr>
256
+ <tr>
257
+ <td><strong><?php _e('Date/Time','dbem'); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td>
258
+ <td>
259
+ <?php echo $localised_start_date; ?>
260
+ <?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
261
+ <?php echo substr ( $EM_Event->start_time, 0, 5 ) . " - " . substr ( $EM_Event->end_time, 0, 5 ); ?>
262
+ </td>
263
+ </tr>
264
+ </table>
265
+ <h4>Personal Details</h4>
266
+ <table>
267
+ <tr><td><strong><?php _e('Name','dbem'); ?> </strong></td><td><a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-bookings&amp;person_id=<?php echo $EM_Booking->person_id; ?>"><?php echo $EM_Booking->person->name ?></a></td></tr>
268
+ <tr><td><strong><?php _e('Phone','dbem'); ?> </strong></td><td><?php echo $EM_Booking->person->phone; ?></td></tr>
269
+ <tr><td><strong><?php _e('E-mail','dbem'); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td><td><?php echo $EM_Booking->person->email; ?></td></tr>
270
+ </table>
271
+ <h4>Booking Details</h4>
272
+ <table>
273
+ <tr><td><strong><?php _e('Spaces','dbem'); ?> </strong></td><td><input type="text" name="booking_seats" value="<?php echo $EM_Booking->seats; ?>" /></td></tr>
274
+ <tr><td><strong><?php _e('Comment','dbem'); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td><td><textarea name="booking_comment"><?php echo $EM_Booking->comment; ?></textarea></td></tr>
275
+ </table>
276
+ <p class="submit">
277
+ <input type="submit" name="events_update" value="<?php _e ( 'Save' ); ?> &raquo;" />
278
+ </p>
279
+ <input type="hidden" name="action" value="bookings_edit" />
280
+ <input type="hidden" name="booking_id" value="<?php echo $EM_Booking->id; ?>" />
281
</form>
282
<?php
283
}
admin/em-categories.php CHANGED
@@ -1,52 +1,42 @@
1
<?php
2
function em_admin_categories_page() {
3
- global $wpdb;
4
5
- if(isset($_GET['action']) && $_GET['action'] == "edit") {
6
- // edit category
7
- em_categories_edit_layout();
8
- } else {
9
- // Insert/Update/Delete Record
10
- $categories_table = $wpdb->prefix.EM_CATEGORIES_TABLE;
11
- if( isset($_POST['action']) && $_POST['action'] == "edit" ) {
12
- // category update required
13
- $category = array();
14
- $category['category_name'] = $_POST['category_name'];
15
- $validation_result = $wpdb->update( $categories_table, $category, array('category_id' => $_POST['category_ID']) );
16
- } elseif( isset($_POST['action']) && $_POST['action'] == "add" ) {
17
- // Add a new category
18
- $category = array();
19
- $category['category_name'] = $_POST['category_name'];
20
- $validation_result = $wpdb->insert($categories_table, $category);
21
- } elseif( isset($_POST['action']) && $_POST['action'] == "delete" ) {
22
- // Delete category or multiple
23
- $categories = $_POST['categories'];
24
- if(is_array($categories)){
25
- //Run the query if we have an array of category ids with at least one value
26
- if( EM_Object::array_is_numeric($categories) ){
27
- $validation_result = $wpdb->query( "DELETE FROM $categories_table WHERE category_id =". implode(" OR category_id =", $categories) );
28
- }else{
29
- $validation_result = false;
30
- $message = "Couldn't delete the categories. Incorrect category IDs supplied. Please try agian.";
31
- }
32
}
33
- }
34
- //die(print_r($_POST));
35
- if ( isset($validation_result) && is_numeric($validation_result) ) {
36
- $message = (isset($message)) ? $message : __("Successfully {$_POST['action']}ed category", "dbem");
37
- em_categories_table_layout($message);
38
- } elseif ( isset($validation_result) && $validation_result === false ) {
39
- $message = (isset($message)) ? $message : __("There was a problem {$_POST['action']}ing your category, please try again.");
40
- em_categories_table_layout($message);
41
- } else {
42
- // no action, just a categories list
43
- em_categories_table_layout();
44
}
45
}
46
}
47
48
function em_categories_table_layout($message = "") {
49
- $categories = EM_Category::get();
50
$destination = get_bloginfo('url')."/wp-admin/admin.php";
51
?>
52
<div class='wrap nosubsub'>
@@ -84,11 +74,11 @@ function em_categories_table_layout($message = "") {
84
</tr>
85
</tfoot>
86
<tbody>
87
- <?php foreach ($categories as $this_category) : ?>
88
<tr>
89
- <td><input type='checkbox' class ='row-selector' value='<?php echo $this_category['category_id'] ?>' name='categories[]'/></td>
90
- <td><a href='<?php echo get_bloginfo('wpurl') ?>/wp-admin/admin.php?page=events-manager-categories&amp;action=edit&amp;category_ID=<?php echo $this_category['category_id'] ?>'><?php echo htmlspecialchars($this_category['category_id'], ENT_QUOTES); ?></a></td>
91
- <td><a href='<?php echo get_bloginfo('wpurl') ?>/wp-admin/admin.php?page=events-manager-categories&amp;action=edit&amp;category_ID=<?php echo $this_category['category_id'] ?>'><?php echo htmlspecialchars($this_category['category_name'], ENT_QUOTES); ?></a></td>
92
</tr>
93
<?php endforeach; ?>
94
</tbody>
@@ -117,7 +107,7 @@ function em_categories_table_layout($message = "") {
117
<div id='ajax-response'>
118
<h3><?php echo __('Add category', 'dbem') ?></h3>
119
<form name='add' id='add' method='post' action='admin.php?page=events-manager-categories' class='add:the-list: validate'>
120
- <input type='hidden' name='action' value='add' />
121
<div class='form-field form-required'>
122
<label for='category_name'><?php echo __('Category name', 'dbem') ?></label>
123
<input id='category-name' name='category_name' id='category_name' type='text' size='40' />
@@ -137,8 +127,17 @@ function em_categories_table_layout($message = "") {
137
138
139
function em_categories_edit_layout($message = "") {
140
- $category_id = $_GET['category_ID'];
141
- $category = EM_Category::get($category_id);
142
?>
143
<div class='wrap'>
144
<div id='icon-edit' class='icon32'>
@@ -156,13 +155,13 @@ function em_categories_edit_layout($message = "") {
156
<div id='ajax-response'></div>
157
158
<form name='editcat' id='editcat' method='post' action='admin.php?page=events-manager-categories' class='validate'>
159
- <input type='hidden' name='action' value='edit' />
160
- <input type='hidden' name='category_ID' value='<?php echo $category['category_id'] ?>'/>
161
162
<table class='form-table'>
163
<tr class='form-field form-required'>
164
<th scope='row' valign='top'><label for='category_name'><?php echo __('Category name', 'dbem') ?></label></th>
165
- <td><input name='category_name' id='category-name' type='text' value='<?php echo $category['category_name'] ?>' size='40' /><br />
166
<?php echo __('The name of the category', 'dbem') ?></td>
167
</tr>
168
</table>
1
<?php
2
function em_admin_categories_page() {
3
+ global $wpdb, $EM_Category;
4
5
+ if( !empty($_REQUEST['action']) ){
6
+ if( $_REQUEST['action'] == "save") {
7
+ // save (add/update) category
8
+ if( empty($EM_Category) || !is_object($EM_Category) ){
9
+ $EM_Category = new EM_Category(); //blank category
10
+ $success_message = __('The category has been added.', 'dbem');
11
+ }else{
12
+ $success_message = __('The category has been updated.', 'dbem');
13
}
14
+ $EM_Category->get_post();
15
+ if ( $EM_Category->validate() ) {
16
+ $EM_Category->save(); //FIXME better handling of db write fails when saving category
17
+ $message = $success_message;
18
+ } else {
19
+ ?>
20
+ <div id='message' class='error '>
21
+ <p>
22
+ <strong><?php _e( "Ach, there's a problem here:", "dbem" ) ?></strong><br /><br /><?php echo implode('<br />', $EM_Category->errors); ?>
23
+ </p>
24
+ </div>
25
+ <?php
26
+ unset($EM_Category);
27
+ }
28
+ } elseif( $_REQUEST['action'] == "delete" ){
29
+ //delelte category
30
+ EM_Categories::delete($_REQUEST['categories']);
31
+ //FIXME no result verification when deleting various categories
32
+ $message = __('Categories Deleted', "dbem" );
33
}
34
}
35
+ em_categories_table_layout($message);
36
}
37
38
function em_categories_table_layout($message = "") {
39
+ $categories = EM_Categories::get();
40
$destination = get_bloginfo('url')."/wp-admin/admin.php";
41
?>
42
<div class='wrap nosubsub'>
74
</tr>
75
</tfoot>
76
<tbody>
77
+ <?php foreach ($categories as $EM_Category) : ?>
78
<tr>
79
+ <td><input type='checkbox' class ='row-selector' value='<?php echo $EM_Category->id ?>' name='categories[]'/></td>
80
+ <td><a href='<?php echo get_bloginfo('wpurl') ?>/wp-admin/admin.php?page=events-manager-categories&amp;action=edit&amp;category_id=<?php echo $EM_Category->id ?>'><?php echo htmlspecialchars($EM_Category->id, ENT_QUOTES); ?></a></td>
81
+ <td><a href='<?php echo get_bloginfo('wpurl') ?>/wp-admin/admin.php?page=events-manager-categories&amp;action=edit&amp;category_id=<?php echo $EM_Category->id ?>'><?php echo htmlspecialchars($EM_Category->name, ENT_QUOTES); ?></a></td>
82
</tr>
83
<?php endforeach; ?>
84
</tbody>
107
<div id='ajax-response'>
108
<h3><?php echo __('Add category', 'dbem') ?></h3>
109
<form name='add' id='add' method='post' action='admin.php?page=events-manager-categories' class='add:the-list: validate'>
110
+ <input type='hidden' name='action' value='save' />
111
<div class='form-field form-required'>
112
<label for='category_name'><?php echo __('Category name', 'dbem') ?></label>
113
<input id='category-name' name='category_name' id='category_name' type='text' size='40' />
127
128
129
function em_categories_edit_layout($message = "") {
130
+ global $EM_Category;
131
+ if( !is_object($EM_Category) ){
132
+ $EM_Category = new EM_Category();
133
+ }
134
+ //check that user can access this page
135
+ if( is_object($EM_Category) && !$EM_Category->can_manage() ){
136
+ ?>
137
+ <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
138
+ <?php
139
+ return false;
140
+ }
141
?>
142
<div class='wrap'>
143
<div id='icon-edit' class='icon32'>
155
<div id='ajax-response'></div>
156
157
<form name='editcat' id='editcat' method='post' action='admin.php?page=events-manager-categories' class='validate'>
158
+ <input type='hidden' name='action' value='save' />
159
+ <input type='hidden' name='category_ID' value='<?php echo $EM_Category->id ?>'/>
160
161
<table class='form-table'>
162
<tr class='form-field form-required'>
163
<th scope='row' valign='top'><label for='category_name'><?php echo __('Category name', 'dbem') ?></label></th>
164
+ <td><input name='category_name' id='category-name' type='text' value='<?php echo $EM_Category->name ?>' size='40' /><br />
165
<?php echo __('The name of the category', 'dbem') ?></td>
166
</tr>
167
</table>
admin/em-docs.php CHANGED
@@ -54,9 +54,15 @@ function em_docs_init(){
54
'#_NAME' => array( 'desc' => 'Displays the name of the event.' ),
55
'#_NOTES' => array( 'desc' => 'Shows the description of the event.' ),
56
'#_EXCERPT' => array( 'desc' => 'If you added a <a href="http://en.support.wordpress.com/splitting-content/more-tag/">more tag</a> to your event description, only the content before this tag will show (currently, no read more link is added).' ),
57
- '#_CATEGORY' => array( 'desc' => 'Shows the category name of the event.' )
58
)
59
),
60
'Time' => array(
61
'desc' => '',
62
'placeholders' => array(
@@ -101,9 +107,13 @@ function em_docs_init(){
101
'desc' => 'The values here are taken from the chosen contact for the specific event, or the default contact in the settings page.',
102
'placeholders' => array(
103
'#_CONTACTNAME' => array( 'desc' => 'Name of the contact person for this event (as shown in the dropdown when adding an event).' ),
104
'#_CONTACTEMAIL' => array( 'desc' => 'E-mail of the contact person for this event.' ),
105
'#_CONTACTPHONE' => array( 'desc' => 'Phone number of the contact person for this event. Can be set in the user profile page.' ),
106
- '#_CONTACTAVATAR' => array( 'desc' => 'Contact person\'s avatar.' )
107
)
108
),
109
),
@@ -117,7 +127,8 @@ function em_docs_init(){
117
'#_LOCATIONMAP' => array( 'desc' => 'Displays a google map showing where the event is located (Will not show if maps are disabled in the settings page)' ),
118
'#_LOCATIONNOTES' => array( 'desc' => 'Shows the location description.' ),
119
'#_LOCATIONEXCERPT' => array( 'desc' => 'If you added a <a href="http://en.support.wordpress.com/splitting-content/more-tag/">more tag</a> to your location description, only the content before this tag will show (currently, no read more link is added).' ),
120
- '#_LOCATIONIMAGE' => array( 'desc' => 'Shows the location image.' )
121
)
122
),
123
'Links' => array(
54
'#_NAME' => array( 'desc' => 'Displays the name of the event.' ),
55
'#_NOTES' => array( 'desc' => 'Shows the description of the event.' ),
56
'#_EXCERPT' => array( 'desc' => 'If you added a <a href="http://en.support.wordpress.com/splitting-content/more-tag/">more tag</a> to your event description, only the content before this tag will show (currently, no read more link is added).' ),
57
+ '#_EVENTID' => array( 'desc' => 'Shows the event\'s corresponding ID number in the database table.' )
58
)
59
),
60
+ 'Category Details' => array(
61
+ 'placeholders' => array(
62
+ '#_CATEGORYNAME' => array( 'desc' => 'Shows the category name of the event.' ),
63
+ '#_CATEGORYID' => array( 'desc' => 'Shows the category ID of the event.' )
64
+ )
65
+ ),
66
'Time' => array(
67
'desc' => '',
68
'placeholders' => array(
107
'desc' => 'The values here are taken from the chosen contact for the specific event, or the default contact in the settings page.',
108
'placeholders' => array(
109
'#_CONTACTNAME' => array( 'desc' => 'Name of the contact person for this event (as shown in the dropdown when adding an event).' ),
110
+ '#_CONTACTUSERNAME' => array( 'desc' => 'Contact person\'s username.' ),
111
'#_CONTACTEMAIL' => array( 'desc' => 'E-mail of the contact person for this event.' ),
112
'#_CONTACTPHONE' => array( 'desc' => 'Phone number of the contact person for this event. Can be set in the user profile page.' ),
113
+ '#_CONTACTAVATAR' => array( 'desc' => 'Contact person\'s avatar.' ),
114
+ '#_CONTACTPROFILELINK' => array( 'desc' => 'Contact person\'s "Profile" link. Only works with BuddyPress enabled.' ),
115
+ '#_CONTACTPROFILEURL' => array( 'desc' => 'Contact person\'s profile url. Only works with BuddyPress enabled.' ),
116
+ '#_CONTACTID' => array( 'desc' => 'Contact person\'s wordpress user ID.')
117
)
118
),
119
),
127
'#_LOCATIONMAP' => array( 'desc' => 'Displays a google map showing where the event is located (Will not show if maps are disabled in the settings page)' ),
128
'#_LOCATIONNOTES' => array( 'desc' => 'Shows the location description.' ),
129
'#_LOCATIONEXCERPT' => array( 'desc' => 'If you added a <a href="http://en.support.wordpress.com/splitting-content/more-tag/">more tag</a> to your location description, only the content before this tag will show (currently, no read more link is added).' ),
130
+ '#_LOCATIONIMAGE' => array( 'desc' => 'Shows the location image.' ),
131
+ '#_LOCATIONID' => array( 'desc' => 'Displays the location ID number.' )
132
)
133
),
134
'Links' => array(
admin/em-event.php CHANGED
@@ -45,8 +45,16 @@ add_action('admin_init', 'em_admin_event_actions');
45
* @return null
46
*/
47
function em_admin_event_page() {
48
- global $EM_Event;
49
- global $localised_date_formats;
50
51
if( is_object($EM_Event) && $EM_Event->id > 0 ){
52
if($EM_Event->is_recurring()){
@@ -55,8 +63,19 @@ function em_admin_event_page() {
55
$title = __ ( "Edit Event", 'dbem' ) . " '" . $EM_Event->name . "'";
56
}
57
} else {
58
- $EM_Event = new EM_Event();
59
$title = __ ( "Insert New Event", 'dbem' );
60
}
61
62
$use_select_for_locations = get_option('dbem_use_select_for_locations');
@@ -64,7 +83,7 @@ function em_admin_event_page() {
64
$pref = "event_";
65
66
$locale_code = substr ( get_locale (), 0, 2 );
67
- $localised_date_format = $localised_date_formats [$locale_code];
68
69
//FIXME time useage is very flimsy imho
70
$hours_locale_regexp = "H:i";
@@ -89,7 +108,7 @@ function em_admin_event_page() {
89
<p><?php echo !empty($EM_Event->feedback_message) ? $EM_Event->feedback_message : $_GET['message']; ?></p>
90
</div>
91
<?php endif; ?>
92
- <form id="eventForm" method="post" action="">
93
<div class="wrap">
94
<div id="icon-events" class="icon32"><br /></div>
95
<h2><?php echo $title; ?></h2>
@@ -185,7 +204,7 @@ function em_admin_event_page() {
185
<p>
186
<?php echo $EM_Event->get_recurrence_description(); ?>
187
<br />
188
- <a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/edit.php?page=events-manager&amp;action=edit_event&amp;event_id=<?php echo $EM_Event->recurrence_id; ?>">
189
<?php _e ( 'Reschedule', 'dbem' ); ?>
190
</a>
191
<input type="hidden" name="recurrence_id" value="<?php echo $EM_Event->recurrence_id; ?>" />
@@ -199,6 +218,7 @@ function em_admin_event_page() {
199
<?php endif; ?>
200
<?php if(get_option('dbem_rsvp_enabled')) : ?>
201
<!-- START RSVP -->
202
<div class="postbox ">
203
<div class="handlediv" title="Fare clic per cambiare."><br />
204
</div>
@@ -207,10 +227,15 @@ function em_admin_event_page() {
207
</span></h3>
208
<div class="inside">
209
<p><?php _e('Contact','dbem'); ?>
210
- <?php wp_dropdown_users ( array ('name' => 'event_contactperson_id', 'show_option_none' => __ ( "Select...", 'dbem' ), 'selected' => $EM_Event->contactperson_id ) ); ?>
211
</p>
212
</div>
213
</div>
214
<div class="postbox ">
215
<div class="handlediv" title="Fare clic per cambiare."><br />
216
</div>
@@ -241,52 +266,18 @@ function em_admin_event_page() {
241
if ( count($EM_Event->get_bookings()->bookings) > 0 ) {
242
?>
243
<div class='wrap'>
244
- <h4><?php echo $booked_seats ?> <?php echo __('responses so far') ?></h4>
245
-
246
- <table id='dbem-bookings-table-<?php echo $EM_Event->id ?>' class='widefat post fixed'>
247
- <thead>
248
- <tr>
249
- <th class='manage-column column-cb check-column' scope='col'>&nbsp;</th>
250
- <th class='manage-column ' scope='col'><?php _e('Responder', 'dbem') ?></th>
251
- <th scope='col'><?php _e('Spaces', 'dbem') ?></th>
252
- </tr>
253
- </thead>
254
- <tbody>
255
- <?php
256
- foreach ($EM_Event->get_bookings()->bookings as $EM_Booking) {
257
- ?>
258
- <tr id='booking-<?php echo $EM_Booking->id ?>'>
259
- <td>
260
- <?php if($EM_Booking->comment) : ?>
261
- <img src='../wp-content/plugins/events-manager/includes/images/baloon.png' title='<?php _e('Comment:','dbem'); ?> <?php echo $EM_Booking->comment ?>' alt='comment'/>
262
- <?php endif; ?>
263
- <a id='booking-check-<?php echo $EM_Booking->id ?>' class='bookingdelbutton'>X</a>
264
- </td>
265
- <td><a title='<?php echo $EM_Booking->person->email ?> - <?php echo $EM_Booking->person->phone ?>'><?php echo $EM_Booking->person->name ?></a></td>
266
- <td><?php echo $EM_Booking->seats ?></td>
267
- </tr>
268
- <?php
269
- }
270
- ?>
271
- </tbody>
272
- <tfoot>
273
- <tr>
274
- <th scope='row' colspan='2'><?php _e('Booked spaces','dbem') ?>:</th>
275
- <td class='booking-result' id='booked-seats'><?php echo $booked_seats ?></td>
276
- </tr>
277
- <tr>
278
- <th scope='row' colspan='2'><?php _e('Available spaces','dbem') ?>:</th>
279
- <td class='booking-result' id='available-seats'><?php echo $available_seats ?></td>
280
- </tr>
281
- </tfoot>
282
- </table>
283
</div>
284
285
<br class='clear'/>
286
287
<div id='major-publishing-actions'>
288
<div id='publishing-action'>
289
- <a id='printable' target='_blank' href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-people&action=printable&event_id=".$EM_Event->id ?>'><?php _e('Printable view','dbem')?></a>
290
<br class='clear'/>
291
</div>
292
<br class='clear'/>
@@ -314,20 +305,26 @@ function em_admin_event_page() {
314
<?php _e ( 'Category', 'dbem' ); ?>
315
</span></h3>
316
<div class="inside">
317
- <p><?php _e ( 'Category:', 'dbem' ); ?>
318
- <select name="event_category_id">
319
- <?php
320
- $categories = EM_Category::get();
321
- foreach ( $categories as $category ){
322
- $selected = ($category['category_id'] == $EM_Event->category_id) ? "selected='selected'": '';
323
?>
324
- <option value="<?php echo $category['category_id'] ?>" <?php echo $selected ?>>
325
- <?php echo $category['category_name'] ?>
326
- </option>
327
- <?php
328
- } ?>
329
- </select>
330
- </p>
331
</div>
332
</div>
333
<!-- END Categories -->
@@ -342,7 +339,7 @@ function em_admin_event_page() {
342
<?php _e ( 'Name', 'dbem' ); ?>
343
</h3>
344
<div class="inside">
345
- <input type="text" name="event_name" value="<?php echo htmlspecialchars($EM_Event->name,ENT_QUOTES); ?>" />
346
<br />
347
<?php _e ( 'The event name. Example: Birthday party', 'dbem' )?>
348
</div>
@@ -496,7 +493,8 @@ function em_admin_event_page() {
496
get_option ( 'dbem_rss_description_format' ).
497
get_option ( 'dbem_rss_title_format' ).
498
get_option ( 'dbem_single_event_format' ).
499
- get_option ( 'dbem_single_location_format' );
500
//We now have one long string of formats, get all the attribute placeholders
501
preg_match_all('/#_ATT\{.+?\}(\{.+?\})?/', $formats, $placeholders);
502
//Now grab all the unique attributes we can use in our event.
@@ -604,7 +602,7 @@ function em_admin_event_page() {
604
jQuery(document).ready( function($) {
605
<?php if( $EM_Event->is_recurring() ): ?>
606
//Recurrence Warnings
607
- $('#eventForm').submit( function(event){
608
confirmation = confirm('<?php _e('Are you sure you want to reschedule this recurring event? If you do this, you will lose all booking information and the old recurring events will be deleted.', 'dbem'); ?>');
609
if( confirmation == false ){
610
event.preventDefault();
45
* @return null
46
*/
47
function em_admin_event_page() {
48
+ global $EM_Event, $current_user;
49
+ global $localised_date_formats;
50
+
51
+ //check that user can access this page
52
+ if( is_object($EM_Event) && !$EM_Event->can_manage() ){
53
+ ?>
54
+ <div class="wrap"><h2><?php _e('Unauthorized Access','dbem'); ?></h2><p><?php _e('You do not have the rights to manage this event.','dbem'); ?></p></div>
55
+ <?php
56
+ return false;
57
+ }
58
59
if( is_object($EM_Event) && $EM_Event->id > 0 ){
60
if($EM_Event->is_recurring()){
63
$title = __ ( "Edit Event", 'dbem' ) . " '" . $EM_Event->name . "'";
64
}
65
} else {
66
+ $EM_Event = ( is_object($EM_Event) && get_class($EM_Event) == 'EM_Event') ? $EM_Event : new EM_Event();
67
$title = __ ( "Insert New Event", 'dbem' );
68
+ //Give a default location & category
69
+ $default_cat = get_option('dbem_default_category');
70
+ $default_loc = get_option('dbem_default_location');
71
+ if( is_numeric($default_cat) && $default_cat > 0 ){
72
+ $EM_Event->category_id = $default_cat;
73
+ $EM_Event->category = new EM_Category($default_cat);
74
+ }
75
+ if( is_numeric($default_loc) && $default_loc > 0 && ( empty($EM_Event->location->id) && empty($EM_Event->location->name) && empty($EM_Event->location->address) && empty($EM_Event->location->town) ) ){
76
+ $EM_Event->location_id = $default_loc;
77
+ $EM_Event->location = new EM_Location($default_loc);
78
+ }
79
}
80
81
$use_select_for_locations = get_option('dbem_use_select_for_locations');
83
$pref = "event_";
84
85
$locale_code = substr ( get_locale (), 0, 2 );
86
+ $localised_date_format = $localised_date_formats[$locale_code];
87
88
//FIXME time useage is very flimsy imho
89
$hours_locale_regexp = "H:i";
108
<p><?php echo !empty($EM_Event->feedback_message) ? $EM_Event->feedback_message : $_GET['message']; ?></p>
109
</div>
110
<?php endif; ?>
111
+ <form id="event-form" method="post" action="">
112
<div class="wrap">
113
<div id="icon-events" class="icon32"><br /></div>
114
<h2><?php echo $title; ?></h2>
204
<p>
205
<?php echo $EM_Event->get_recurrence_description(); ?>
206
<br />
207
+ <a href="<?php bloginfo ( 'wpurl' )?>/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php echo $EM_Event->recurrence_id; ?>">
208
<?php _e ( 'Reschedule', 'dbem' ); ?>
209
</a>
210
<input type="hidden" name="recurrence_id" value="<?php echo $EM_Event->recurrence_id; ?>" />
218
<?php endif; ?>
219
<?php if(get_option('dbem_rsvp_enabled')) : ?>
220
<!-- START RSVP -->
221
+ <?php if ( em_verify_admin() ): ?>
222
<div class="postbox ">
223
<div class="handlediv" title="Fare clic per cambiare."><br />
224
</div>
227
</span></h3>
228
<div class="inside">
229
<p><?php _e('Contact','dbem'); ?>
230
+ <?php
231
+ wp_dropdown_users ( array ('name' => 'event_contactperson_id', 'show_option_none' => __ ( "Select...", 'dbem' ), 'selected' => $EM_Event->contactperson_id ) );
232
+ ?>
233
</p>
234
</div>
235
</div>
236
+ <?php else: ?>
237
+ <input type="hidden" name="event_contactperson_id" value="<?php get_current_user_id() ?>" />
238
+ <?php endif; ?>
239
<div class="postbox ">
240
<div class="handlediv" title="Fare clic per cambiare."><br />
241
</div>
266
if ( count($EM_Event->get_bookings()->bookings) > 0 ) {
267
?>
268
<div class='wrap'>
269
+ <p><strong><?php echo __('Available Spaces','dbem').': '.$EM_Event->get_bookings()->get_available_seats(); ?></strong></p>
270
+ <p><strong><?php echo __('Confirmed Spaces','dbem').': '.$EM_Event->get_bookings()->get_booked_seats(); ?></strong></p>
271
+ <p><strong><?php echo __('Pending Spaces','dbem').': '.$EM_Event->get_bookings()->get_pending_seats(); ?></strong></p>
272
</div>
273
274
<br class='clear'/>
275
276
<div id='major-publishing-actions'>
277
<div id='publishing-action'>
278
+ <a id='printable' href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&event_id=".$EM_Event->id ?>'><?php _e('manage bookings','dbem')?></a><br />
279
+ <a target='_blank' href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=bookings_report&event_id=".$EM_Event->id ?>'><?php _e('printable view','dbem')?></a>
280
+ <a href='<?php echo get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&action=export_csv&event_id=".$EM_Event->id ?>'><?php _e('export csv','dbem')?></a>
281
<br class='clear'/>
282
</div>
283
<br class='clear'/>
305
<?php _e ( 'Category', 'dbem' ); ?>
306
</span></h3>
307
<div class="inside">
308
+ <?php $categories = EM_Categories::get(array('orderby'=>'category_name')); ?>
309
+ <?php if( count($categories) > 0 ): ?>
310
+ <p><?php _e ( 'Category:', 'dbem' ); ?>
311
+ <select name="event_category_id">
312
+ <option value="" <?php echo ($EM_Event->category_id == '') ? "selected='selected'":'' ?>><?php _e('no category','dbem') ?></option>
313
+ <?php
314
+ foreach ( $categories as $EM_Category ){
315
+ $selected = ($EM_Category->id == $EM_Event->category_id) ? "selected='selected'": '';
316
+ ?>
317
+ <option value="<?php echo $EM_Category->id ?>" <?php echo $selected ?>>
318
+ <?php echo $EM_Category->name ?>
319
+ </option>
320
+ <?php
321
+ }
322
?>
323
+ </select>
324
+ </p>
325
+ <?php else: ?>
326
+ <p><?php sprintf(__('No categories available, <a href="%s">create one here first</a>','dbem'), get_bloginfo('wpurl').'/wp-admin/admin.php?page=events-manager-categories'); ?></p>
327
+ <?php endif; ?>
328
</div>
329
</div>
330
<!-- END Categories -->
339
<?php _e ( 'Name', 'dbem' ); ?>
340
</h3>
341
<div class="inside">
342
+ <input type="text" name="event_name" id="event-name" value="<?php echo htmlspecialchars($EM_Event->name,ENT_QUOTES); ?>" />
343
<br />
344
<?php _e ( 'The event name. Example: Birthday party', 'dbem' )?>
345
</div>
493
get_option ( 'dbem_rss_description_format' ).
494
get_option ( 'dbem_rss_title_format' ).
495
get_option ( 'dbem_single_event_format' ).
496
+ get_option ( 'dbem_single_location_format' ).
497
+ get_option ( 'dbem_placeholders_custom' );
498
//We now have one long string of formats, get all the attribute placeholders
499
preg_match_all('/#_ATT\{.+?\}(\{.+?\})?/', $formats, $placeholders);
500
//Now grab all the unique attributes we can use in our event.
602
jQuery(document).ready( function($) {
603
<?php if( $EM_Event->is_recurring() ): ?>
604
//Recurrence Warnings
605
+ $('#event_form').submit( function(event){
606
confirmation = confirm('<?php _e('Are you sure you want to reschedule this recurring event? If you do this, you will lose all booking information and the old recurring events will be deleted.', 'dbem'); ?>');
607
if( confirmation == false ){
608
event.preventDefault();
admin/em-events.php CHANGED
@@ -38,7 +38,11 @@ function em_admin_events_page() {
38
$title = __ ( 'Future Events', 'dbem' );
39
$scope = "future";
40
}
41
- $events = EM_Events::get( array('scope'=>$scope, 'limit'=>0, 'order'=>$order ) );
42
$events_count = count ( $events );
43
44
$use_events_end = get_option ( 'dbem_use_event_end' );
@@ -48,11 +52,9 @@ function em_admin_events_page() {
48
</div>
49
<h2>
50
<?php echo $title; ?>
51
- <a href="admin.php?page=events-manager-event" class="button add-new-h2"><?php _e('Add New') ?></a>
52
</h2>
53
- <?php
54
- em_hello_to_new_user ();
55
-
56
$link = array ();
57
$link ['past'] = "<a href='" . get_bloginfo ( 'wpurl' ) . "/wp-admin/admin.php?page=events-manager&amp;scope=past&amp;order=desc'>" . __ ( 'Past events', 'dbem' ) . "</a>";
58
$link ['all'] = " <a href='" . get_bloginfo ( 'wpurl' ) . "/wp-admin/admin.php?page=events-manager&amp;scope=all&amp;order=desc'>" . __ ( 'All events', 'dbem' ) . "</a>";
@@ -72,7 +74,11 @@ function em_admin_events_page() {
72
<ul class="subsubsub">
73
<li><a href='#' class="current"><?php _e ( 'Total', 'dbem' ); ?> <span class="count">(<?php echo (count ( $events )); ?>)</span></a></li>
74
</ul>
75
-
76
<div class="tablenav">
77
78
<div class="alignleft actions">
@@ -92,122 +98,139 @@ function em_admin_events_page() {
92
?>
93
</select>
94
<input id="post-query-submit" class="button-secondary" type="submit" value="<?php _e ( 'Filter' )?>" />
95
- <?php
96
- //Pagination (if needed/requested)
97
- if( $events_count >= $limit ){
98
- //Show the pagination links (unless there's less than 10 events
99
- $page_link_template = preg_replace('/(&|\?)p=\d+/i','',$_SERVER['REQUEST_URI']);
100
- $page_link_template = em_add_get_params($page_link_template, array('p'=>'%PAGE%'));
101
- $events_nav = em_paginate( $page_link_template, $events_count, $limit, $page);
102
- echo $events_nav;
103
- }
104
- ?>
105
</div>
106
<br class="clear" />
107
108
- <?php
109
- if (empty ( $events )) {
110
- // TODO localize
111
- _e ( 'no events','dbem' );
112
- } else {
113
- ?>
114
-
115
- <table class="widefat">
116
- <thead>
117
- <tr>
118
- <th class='manage-column column-cb check-column' scope='col'>
119
- <input class='select-all' type="checkbox" value='1' />
120
- </th>
121
- <th><?php _e ( 'Name', 'dbem' ); ?></th>
122
- <th>&nbsp;</th>
123
- <th><?php _e ( 'Location', 'dbem' ); ?></th>
124
- <th colspan="2"><?php _e ( 'Date and time', 'dbem' ); ?></th>
125
- </tr>
126
- </thead>
127
- <tbody>
128
- <?php
129
- $rowno = 0;
130
- $event_count = 0;
131
- foreach ( $events as $event ) {
132
- if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0)