em-pending.php
7.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
* Generates a "widget" table of pending bookings with some quick admin operation options.
* If event id supplied then only pending bookings for that event will show.
*
* @param int $event_id
*/
function em_bookings_pending_table($event_id = false){
global $EM_Event, $EM_Ticket, $wpdb, $current_user;
if( get_option('dbem_bookings_approval') == 0 ){
return false;
}
$action_scope = ( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_pending_table' );
$action = ( $action_scope && !empty($_GET ['action']) ) ? $_GET ['action']:'';
$order = ( $action_scope && !empty($_GET ['order']) ) ? $_GET ['order']:'ASC';
$limit = ( $action_scope && !empty($_GET['limit']) ) ? $_GET['limit'] : 20;//Default limit
$page = ( $action_scope && !empty($_GET['pno']) ) ? $_GET['pno']:1;
$offset = ( $action_scope && $page > 1 ) ? ($page-1)*$limit : 0;
if( is_object($EM_Ticket) ){
$EM_Bookings = $EM_Ticket->get_bookings()->get_pending_bookings();
}else{
if( is_object($EM_Event) ){
$EM_Bookings = $EM_Event->get_bookings()->get_pending_bookings();
}else{
//To optimize performance, we can do one query here for all pending bookings to show.
$EM_Bookings = EM_Bookings::get(array('status'=>0));
$events = array();
//Now let's create events and bookings for this:
foreach($EM_Bookings->bookings as $EM_Booking){
//create event
if( !array_key_exists($EM_Booking->event_id,$events) ){
$events[$EM_Booking->event_id] = new EM_Event($EM_Booking->event_id);
}
}
}
}
$bookings_count = (is_array($EM_Bookings->bookings)) ? count($EM_Bookings->bookings):0;
?>
<div class='wrap em_bookings_pending_table em_obj'>
<form id='bookings-filter' method='get' action='<?php bloginfo('wpurl') ?>/wp-admin/edit.php'>
<input type="hidden" name="em_obj" value="em_bookings_pending_table" />
<!--
<ul class="subsubsub">
<li>
<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
</li>
</ul>
<p class="search-box">
<label class="screen-reader-text" for="post-search-input"><?php _e('Search', 'events-manager'); ?>:</label>
<input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_GET['em_search'])) ? esc_attr($_GET['em_search']):''; ?>" />
<input type="submit" value="<?php _e('Search', 'events-manager'); ?>" class="button" />
</p>
-->
<?php if ( $bookings_count >= $limit ) : ?>
<div class='tablenav'>
<!--
<div class="alignleft actions">
<select name="action">
<option value="-1" selected="selected">
<?php _e('Bulk Actions', 'events-manager'); ?>
</option>
<option value="approve">
<?php _e('Approve', 'events-manager'); ?>
</option>
<option value="decline">
<?php _e('Decline', 'events-manager'); ?>
</option>
</select>
<input type="submit" id="post-query-submit" value="Filter" class="button-secondary" />
</div>
-->
<!--
<div class="view-switch">
<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>
</div>
-->
<?php
if ( $bookings_count >= $limit ) {
$bookings_nav = em_admin_paginate( $bookings_count, $limit, $page, array('em_ajax'=>0, 'em_obj'=>'em_bookings_pending_table'));
echo $bookings_nav;
}
?>
<div class="clear"></div>
</div>
<?php endif; ?>
<div class="clear"></div>
<?php if( $bookings_count > 0 ): ?>
<div class='table-wrap'>
<table id='dbem-bookings-table' class='widefat post '>
<thead>
<tr>
<th class='manage-column column-cb check-column' scope='col'>
<input class='select-all' type="checkbox" value='1' />
</th>
<th class='manage-column' scope='col'><?php _e('Booker', 'events-manager'); ?></th>
<?php if( !is_object($EM_Event) && !is_object($EM_Ticket) ): ?>
<th class='manage-column' scope="col"><?php _e('Event', 'events-manager'); ?></th>
<?php endif; ?>
<th class='manage-column' scope='col'><?php _e('E-mail', 'events-manager'); ?></th>
<th class='manage-column' scope='col'><?php _e('Phone number', 'events-manager'); ?></th>
<th class='manage-column' scope='col'><?php _e('Spaces', 'events-manager'); ?></th>
<th class='manage-column' scope='col'> </th>
</tr>
</thead>
<tbody>
<?php
$rowno = 0;
$event_count = 0;
foreach ($EM_Bookings->bookings as $EM_Booking) {
if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
$rowno++;
?>
<tr>
<th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->booking_id ?>' name='bookings[]'/></th>
<td><a href="<?php echo EM_ADMIN_URL; ?>&page=events-manager-bookings&person_id=<?php echo $EM_Booking->person->ID; ?>"><?php echo $EM_Booking->person->get_name() ?></a></td>
<?php if( !is_object($EM_Event) && !is_object($EM_Ticket) ): ?>
<td><a href="<?php echo EM_ADMIN_URL; ?>&page=events-manager-bookings&event_id=<?php echo $EM_Booking->event_id; ?>"><?php echo $events[$EM_Booking->event_id]->name ?></a></td>
<?php endif; ?>
<td><?php echo $EM_Booking->person->user_email ?></td>
<td><?php echo $EM_Booking->person->phone ?></td>
<td><?php echo $EM_Booking->get_spaces() ?></td>
<td>
<?php
$approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_approve', 'booking_id'=>$EM_Booking->booking_id));
$reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_reject', 'booking_id'=>$EM_Booking->booking_id));
$delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action'=>'bookings_delete', 'booking_id'=>$EM_Booking->booking_id));
?>
<a class="em-bookings-approve" href="<?php echo $approve_url ?>"><?php _e('Approve','events-manager'); ?></a> |
<a class="em-bookings-reject" href="<?php echo $reject_url ?>"><?php _e('Reject','events-manager'); ?></a> |
<span class="trash"><a class="em-bookings-delete" href="<?php echo $delete_url ?>"><?php _e('Delete','events-manager'); ?></a></span> |
<a class="em-bookings-edit" href="<?php echo EM_ADMIN_URL; ?>&page=events-manager-bookings&booking_id=<?php echo $EM_Booking->booking_id; ?>"><?php _e('Edit/View','events-manager'); ?></a>
</td>
</tr>
<?php
}
$event_count++;
}
?>
</tbody>
</table>
</div>
<?php else: ?>
<?php _e('No pending bookings.', 'events-manager'); ?>
<?php endif; ?>
</form>
<?php if( !empty($bookings_nav) && $EM_Bookings >= $limit ) : ?>
<div class='tablenav'>
<?php echo $bookings_nav; ?>
<div class="clear"></div>
</div>
<?php endif; ?>
</div>
<?php
}
?>