Beispiel #1
0
/**
 * Generates a "widget" table of confirmed bookings for a specific event.
 * 
 * @param int $event_id
 */
function em_bookings_person_table()
{
    global $wpdb, $current_user, $EM_Person;
    if (!is_object($EM_Person)) {
        return false;
    }
    $action_scope = !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_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;
    $bookings = $EM_Person->get_bookings();
    $bookings_count = count($bookings);
    if ($bookings_count > 0) {
        //Get events here in one query to speed things up
        foreach ($bookings as $EM_Booking) {
            $event_ids[] = $EM_Booking->event_id;
        }
        $events = EM_Events::get($event_ids);
    }
    ?>
		<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');
    ?>
:</label>
					<input type="text" id="post-search-input" name="em_search" value="<?php 
    echo !empty($_GET['em_search']) ? $_GET['em_search'] : '';
    ?>
" />
					<input type="submit" value="<?php 
    _e('Search');
    ?>
" 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');
        ?>
							</option>
							<option value="approve">
								<?php 
        _e('Approve', 'dbem');
        ?>
							</option>
							<option value="decline">
								<?php 
        _e('Decline', 'dbem');
        ?>
							</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_confirmed_table'));
            echo $bookings_nav;
        }
        ?>
					<div class="clear"></div>
				</div>
				<?php 
    }
    ?>
				<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'>Event</th>
							<th class='manage-column' scope='col'>Spaces</th>
							<th class='manage-column' scope='col'>Status</th>
							<th class='manage-column' scope='col'>&nbsp;</th>
						</tr>
					</thead>
					<tbody>
						<?php 
        $rowno = 0;
        $event_count = 0;
        foreach ($bookings as $EM_Booking) {
            $EM_Event = $events[$EM_Booking->event_id];
            if ($EM_Event->can_manage('edit_events', 'edit_others_events') && ($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->id;
                ?>
' name='bookings[]'/></th>
									<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>
									<td><?php 
                echo $EM_Booking->get_spaces();
                ?>
</td>
									<td><?php 
                echo $EM_Booking->status_array[$EM_Booking->status];
                ?>
									</td>
									<td>
										<?php 
                $unapprove_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_unapprove', 'bookings' => $EM_Booking->id));
                $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_approve', 'bookings' => $EM_Booking->id));
                $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_reject', 'bookings' => $EM_Booking->id));
                $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_delete', 'bookings' => $EM_Booking->id));
                ?>
										<?php 
                if (get_option('dbem_bookings_approval') && $EM_Booking->status == 0) {
                    ?>
										<a class="em-bookings-approve" href="<?php 
                    echo $approve_url;
                    ?>
"><?php 
                    _e('Approve', 'dbem');
                    ?>
</a> |
										<?php 
                }
                ?>
										<?php 
                if (get_option('dbem_bookings_approval') && $EM_Booking->status == 1) {
                    ?>
										<a class="em-bookings-unapprove" href="<?php 
                    echo $unapprove_url;
                    ?>
"><?php 
                    _e('Unapprove', 'dbem');
                    ?>
</a> |
										<?php 
                }
                ?>
										<?php 
                if ($EM_Booking->status == 2) {
                    ?>
										<a class="em-bookings-approve" href="<?php 
                    echo $approve_url;
                    ?>
"><?php 
                    _e('Restore', 'dbem');
                    ?>
</a> |
										<?php 
                }
                ?>
										<?php 
                if ($EM_Booking->status == 0 || $EM_Booking->status == 1) {
                    ?>
										<a class="em-bookings-reject" href="<?php 
                    echo $reject_url;
                    ?>
"><?php 
                    _e('Reject', 'dbem');
                    ?>
</a> |
										<?php 
                }
                ?>
										<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/View', 'dbem');
                ?>
</a> |
										<span class="trash"><a class="em-bookings-delete" href="<?php 
                echo $delete_url;
                ?>
"><?php 
                _e('Delete', 'dbem');
                ?>
</a></span>
									</td>
								</tr>
								<?php 
            }
            $event_count++;
        }
        ?>
					</tbody>
				</table>
				</div>
				<?php 
    } else {
        ?>
					<?php 
        _e('No confirmed bookings.', 'dbem');
        ?>
				<?php 
    }
    ?>
			</form>
			<?php 
    if (!empty($bookings_nav) && $bookings >= $limit) {
        ?>
			<div class='tablenav'>
				<?php 
        echo $bookings_nav;
        ?>
				<div class="clear"></div>
			</div>
			<?php 
    }
    ?>
		</div>	
	<?php 
}
Beispiel #2
0
/**
 * Generates a "widget" table of confirmed bookings for a specific event.
 * 
 * @param int $event_id
 */
function em_bookings_rejected_table()
{
    global $EM_Event, $EM_Ticket, $wpdb, $current_user;
    $action_scope = !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_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_rejected_bookings();
    } else {
        if (is_object($EM_Event)) {
            $EM_Bookings = $EM_Event->get_bookings()->get_rejected_bookings();
        } else {
            return false;
        }
    }
    $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_confirmed_table'));
            echo $bookings_nav;
        }
        ?>
					<div class="clear"></div>
				</div>
				<?php 
    }
    ?>
				<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>
							<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'>&nbsp;</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;
                ?>
&amp;page=events-manager-bookings&amp;person_id=<?php 
                echo $EM_Booking->person->ID;
                ?>
"><?php 
                echo $EM_Booking->person->get_name();
                ?>
</a></td>
									<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));
                $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_delete', 'booking_id' => $EM_Booking->booking_id));
                $edit_url = em_add_get_params($_SERVER['REQUEST_URI'], array('booking_id' => $EM_Booking->booking_id, 'em_ajax' => null, 'em_obj' => null));
                ?>
										<a class="em-bookings-approve" href="<?php 
                echo $approve_url;
                ?>
"><?php 
                _e('Approve', 'events-manager');
                ?>
</a> |
										<a class="em-bookings-edit" href="<?php 
                echo $edit_url;
                ?>
"><?php 
                _e('Edit/View', 'events-manager');
                ?>
</a> |
										<span class="trash"><a class="em-bookings-delete" href="<?php 
                echo $delete_url;
                ?>
"><?php 
                _e('Delete', 'events-manager');
                ?>
</a></span>
									</td>
								</tr>
								<?php 
            }
            $event_count++;
        }
        ?>
					</tbody>
				</table>
				</div>
				<?php 
    } else {
        ?>
					<?php 
        _e('No rejected bookings.', 'events-manager');
        ?>
				<?php 
    }
    ?>
			</form>
			<?php 
    if (!empty($bookings_nav) && $EM_Bookings >= $limit) {
        ?>
			<div class='tablenav'>
				<?php 
        echo $bookings_nav;
        ?>
				<div class="clear"></div>
			</div>
			<?php 
    }
    ?>
		</div>	
	<?php 
}
Beispiel #3
0
    ?>
		<div class='em-my-bookings'>
				<!--
				<ul class="subsubsub">
					<li>
						<a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> |
					</li>
				</ul>
				-->
				<?php 
    if ($bookings_count >= $limit) {
        ?>
				<div class='tablenav'>
					<?php 
        if ($bookings_count >= $limit) {
            $bookings_nav = em_admin_paginate($bookings_count, $limit, $page, array('em_ajax' => 0, 'em_obj' => 'em_bookings_confirmed_table'));
            echo $bookings_nav;
        }
        ?>
					<div class="clear"></div>
				</div>
				<?php 
    }
    ?>
				<div class="clear"></div>
				<?php 
    if ($bookings_count > 0) {
        ?>
				<div class='table-wrap'>
				<table id='dbem-bookings-table' class='widefat post fixed'>
					<thead>
    function output_table()
    {
        $EM_Ticket = $this->get_ticket();
        $EM_Event = $this->get_event();
        $EM_Person = $this->get_person();
        $this->get_bookings(true);
        //get bookings and refresh
        ?>
		<div class='em-bookings-table em_obj' id="em-bookings-table">
			<form class='bookings-filter' method='post' action='<?php 
        bloginfo('wpurl');
        ?>
/wp-admin/edit.php'>
				<?php 
        if ($EM_Event !== false) {
            ?>
				<input type="hidden" name="event_id" value='<?php 
            echo $EM_Event->event_id;
            ?>
' />
				<?php 
        }
        ?>
				<?php 
        if ($EM_Ticket !== false) {
            ?>
				<input type="hidden" name="ticket_id" value='<?php 
            echo $EM_Ticket->ticket_id;
            ?>
' />
				<?php 
        }
        ?>
				<?php 
        if ($EM_Person !== false) {
            ?>
				<input type="hidden" name="person_id" value='<?php 
            echo $EM_Person->ID;
            ?>
' />
				<?php 
        }
        ?>
				<input type="hidden" name="is_public" value="<?php 
        echo !empty($_REQUEST['is_public']) || !is_admin() ? 1 : 0;
        ?>
" />
				<input type="hidden" name="pno" value='<?php 
        echo $this->page;
        ?>
' />
				<input type="hidden" name="order" value='<?php 
        echo $this->order;
        ?>
' />
				<input type="hidden" name="orderby" value='<?php 
        echo $this->orderby;
        ?>
' />
				<input type="hidden" name="_wpnonce" value="<?php 
        echo !empty($_REQUEST['_wpnonce']) ? esc_attr($_REQUEST['_wpnonce']) : wp_create_nonce('em_bookings_table');
        ?>
" />
				<input type="hidden" name="action" value="em_bookings_table" />
				<input type="hidden" name="cols" value="<?php 
        echo implode(',', $this->cols);
        ?>
" />
				
				<div class='tablenav'>
					<div class="alignleft actions">
						<a href="#" class="em-bookings-table-export" id="em-bookings-table-export-trigger" rel="#em-bookings-table-export" title="<?php 
        _e('Export these bookings.', 'dbem');
        ?>
"></a>
						<a href="#" class="em-bookings-table-settings" id="em-bookings-table-settings-trigger" rel="#em-bookings-table-settings"></a>
						<?php 
        if ($EM_Event === false) {
            ?>
						<select name="scope">
							<?php 
            foreach (em_get_scopes() as $key => $value) {
                $selected = "";
                if ($key == $this->scope) {
                    $selected = "selected='selected'";
                }
                echo "<option value='{$key}' {$selected}>{$value}</option>  ";
            }
            ?>
						</select>
						<?php 
        }
        ?>
						<select name="limit">
							<option value="<?php 
        echo $this->limit;
        ?>
"><?php 
        echo sprintf(__('%s Rows', 'dbem'), $this->limit);
        ?>
</option>
							<option value="5">5</option>
							<option value="10">10</option>
							<option value="25">25</option>
							<option value="50">50</option>
							<option value="100">100</option>
						</select>
						<select name="status">
							<?php 
        foreach ($this->statuses as $key => $value) {
            $selected = "";
            if ($key == $this->status) {
                $selected = "selected='selected'";
            }
            echo "<option value='{$key}' {$selected}>{$value['label']}</option>  ";
        }
        ?>
						</select>
						<input id="post-query-submit" class="button-secondary" type="submit" value="<?php 
        _e('Filter');
        ?>
" />
						<?php 
        if ($EM_Event !== false) {
            ?>
						<?php 
            _e('Displaying Event', 'dbem');
            ?>
 : <?php 
            echo $EM_Event->name;
            ?>
						<?php 
        } elseif ($EM_Person !== false) {
            ?>
						<?php 
            _e('Displaying User', 'dbem');
            echo ' : ' . $EM_Person->get_name();
            ?>
						<?php 
        }
        ?>
					</div>
					<?php 
        if ($this->bookings_count >= $this->limit) {
            $bookings_nav = em_admin_paginate($this->bookings_count, $this->limit, $this->page, array(), '#%#%', '#');
            echo $bookings_nav;
        }
        ?>
				</div>
				<div class="clear"></div>
				<div class='table-wrap'>
				<table id='dbem-bookings-table' class='widefat post '>
					<thead>
						<tr>
							<?php 
        /*						
        <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 
        echo implode("</th><th class='manage-column' scope='col'>", $this->get_headers());
        ?>
</th>
						</tr>
					</thead>
					<?php 
        if ($this->bookings_count > 0) {
            ?>
					<tbody>
						<?php 
            $rowno = 0;
            $event_count = !empty($event_count) ? $event_count : 0;
            foreach ($this->bookings->bookings as $EM_Booking) {
                ?>
							<tr>
								<?php 
                /*
                <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->booking_id ?>' name='bookings[]'/></th>
                */
                /* @var $EM_Booking EM_Booking */
                /* @var $EM_Ticket_Booking EM_Ticket_Booking */
                if ($this->show_tickets) {
                    foreach ($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking) {
                        ?>
<td><?php 
                        echo implode('</td><td>', $this->get_row($EM_Ticket_Booking));
                        ?>
</td><?php 
                    }
                } else {
                    ?>
<td><?php 
                    echo implode('</td><td>', $this->get_row($EM_Booking));
                    ?>
</td><?php 
                }
                ?>
							</tr>
							<?php 
            }
            ?>
					</tbody>
					<?php 
        } else {
            ?>
						<tbody>
							<tr><td scope="row" colspan="<?php 
            echo count($this->cols);
            ?>
"><?php 
            _e('No bookings.', 'dbem');
            ?>
</td></tr>
						</tbody>
					<?php 
        }
        ?>
				</table>
				</div>
				<?php 
        if (!empty($bookings_nav) && $this->bookings_count >= $this->limit) {
            ?>
				<div class='tablenav'>
					<?php 
            echo $bookings_nav;
            ?>
					<div class="clear"></div>
				</div>
				<?php 
        }
        ?>
			</form>
		</div>
		<?php 
    }
Beispiel #5
0
    echo esc_attr($_REQUEST['view']);
    ?>
" />
				<?php 
}
?>

				<input type="submit" value="<?php 
_e('Search Events', 'dbem');
?>
" class="button" />
			</p>
			<div class="tablenav">
				<?php 
if ($events_count >= $limit) {
    $events_nav = em_admin_paginate($events_count, $limit, $page);
    echo $events_nav;
}
?>

				<br class="clear" />
			</div>
				
			<?php 
if (empty($EM_Events)) {
    echo get_option('dbem_no_events_message');
} else {
    ?>

					
			<table class="widefat events-table">
Beispiel #6
0
/**
 * 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, $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_Event)) {
        $bookings = $EM_Event->get_bookings()->get_pending();
    } else {
        //To optimize performance, we can do one query here for all pending bookings to show.
        $bookings = EM_Bookings::get(array('status' => 0));
        $events = array();
        //Now let's create events and bookings for this:
        foreach ($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($bookings) ? count($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');
    ?>
:</label>
					<input type="text" id="post-search-input" name="em_search" value="<?php 
    echo !empty($_GET['em_search']) ? $_GET['em_search'] : '';
    ?>
" />
					<input type="submit" value="<?php 
    _e('Search');
    ?>
" 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');
        ?>
							</option>
							<option value="approve">
								<?php 
        _e('Approve', 'dbem');
        ?>
							</option>
							<option value="decline">
								<?php 
        _e('Decline', 'dbem');
        ?>
							</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) {
            $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno' => '%PAGE%', 'em_ajax' => 0, 'em_obj' => 'em_bookings_pending_table'));
            $bookings_nav = em_admin_paginate($page_link_template, $bookings_count, $limit, $page, 5);
            echo $bookings_nav;
        }
        ?>
					<div class="clear"></div>
				</div>
				<?php 
    }
    ?>
				<div class="clear"></div>
				<?php 
    if ($bookings_count > 0) {
        ?>
				<div class='table-wrap'>
				<table id='dbem-bookings-table' class='widefat post fixed'>
					<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'>Booker</th>
							<?php 
        if (!is_object($EM_Event)) {
            ?>
							<th class='manage-column' scope="col">Event</th>
							<?php 
        }
        ?>
							<th class='manage-column' scope='col'>E-mail</th>
							<th class='manage-column' scope='col'>Phone number</th>
							<th class='manage-column' scope='col'>Spaces</th>
							<th class='manage-column' scope='col'>&nbsp;</th>
						</tr>
					</thead>
					<tbody>
						<?php 
        $rowno = 0;
        $event_count = 0;
        foreach ($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->id;
                ?>
' name='bookings[]'/></th>
									<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>
									<?php 
                if (!is_object($EM_Event)) {
                    ?>
									<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>
									<?php 
                }
                ?>
									<td><?php 
                echo $EM_Booking->person->email;
                ?>
</td>
									<td><?php 
                echo $EM_Booking->person->phone;
                ?>
</td>
									<td><?php 
                echo $EM_Booking->seats;
                ?>
</td>
									<td>
										<?php 
                $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_approve', 'booking_id' => $EM_Booking->id));
                $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_reject', 'booking_id' => $EM_Booking->id));
                ?>
										<a class="em-bookings-approve" href="<?php 
                echo $approve_url;
                ?>
"><?php 
                _e('Approve', 'dbem');
                ?>
</a> |
										<a class="em-bookings-reject" href="<?php 
                echo $reject_url;
                ?>
"><?php 
                _e('Reject', 'dbem');
                ?>
</a> |
										<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>
									</td>
								</tr>
								<?php 
            }
            $event_count++;
        }
        ?>
					</tbody>
				</table>
				</div>
				<?php 
    } else {
        ?>
					<?php 
        _e('No pending bookings.', 'dbem');
        ?>
				<?php 
    }
    ?>
			</form>
			<?php 
    if (!empty($bookings_nav)) {
        ?>
			<div class='tablenav'>
				<?php 
        echo $bookings_nav;
        ?>
				<div class="clear"></div>
			</div>
			<?php 
    }
    ?>
		</div>	
	<?php 
}
Beispiel #7
0
/**
 * Determines whether to show event page or events page, and saves any updates to the event or events
 * @return null
 */
function em_bookings_events_table()
{
    //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
    global $wpdb;
    global $EM_Event;
    $scope_names = array('past' => __('Past events', 'dbem'), 'all' => __('All events', 'dbem'), 'future' => __('Future events', 'dbem'));
    $action_scope = !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_events_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;
    $scope = $action_scope && !empty($_GET['scope']) && array_key_exists($_GET['scope'], $scope_names) ? $_GET['scope'] : 'future';
    // No action, only showing the events list
    switch ($scope) {
        case "past":
            $title = __('Past Events', 'dbem');
            break;
        case "all":
            $title = __('All Events', 'dbem');
            break;
        default:
            $title = __('Future Events', 'dbem');
            $scope = "future";
    }
    $events = EM_Events::get(array('scope' => $scope, 'limit' => 0, 'order' => $order, 'rsvp' => true));
    $events_count = count($events);
    $use_events_end = get_option('dbem_use_event_end');
    ?>
	<div class="wrap em_bookings_events_table em_obj">
		<form id="posts-filter" action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
" method="get">
			<input type="hidden" name="em_obj" value="em_bookings_events_table" />
			<?php 
    if (!empty($_GET['page'])) {
        ?>
			<input type='hidden' name='page' value='events-manager-bookings' />
			<?php 
    }
    ?>
			<ul class="subsubsub">
				<li><a href='#' class="current"><?php 
    _e('Total', 'dbem');
    ?>
 <span class="count">(<?php 
    echo count($events);
    ?>
)</span></a></li>
			</ul>			
			<div class="tablenav">			
				<div class="alignleft actions">
					<!--
					<select name="action">
						<option value="-1" selected="selected"><?php 
    _e('Bulk Actions');
    ?>
</option>
						<option value="deleteEvents"><?php 
    _e('Delete selected', 'dbem');
    ?>
</option>
					</select> 
					<input type="submit" value="<?php 
    _e('Apply');
    ?>
" name="doaction2" id="doaction2" class="button-secondary action" />
					 --> 
					<select name="scope">
						<?php 
    foreach ($scope_names as $key => $value) {
        $selected = "";
        if ($key == $scope) {
            $selected = "selected='selected'";
        }
        echo "<option value='{$key}' {$selected}>{$value}</option>  ";
    }
    ?>
					</select>
					<input id="post-query-submit" class="button-secondary" type="submit" value="<?php 
    _e('Filter');
    ?>
" />
				</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 ($events_count >= $limit) {
        $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno' => '%PAGE%', 'em_ajax' => 0, 'em_obj' => 'em_bookings_events_table'));
        $events_nav = em_admin_paginate($page_link_template, $events_count, $limit, $page, 5);
        echo $events_nav;
    }
    ?>
				<br class="clear" />
			</div>
				
			<?php 
    if (empty($events)) {
        // TODO localize
        _e('no events', 'dbem');
    } else {
        ?>
			<div class='table-wrap'>	
			<table class="widefat">
				<thead>
					<tr>
						<th class='manage-column column-cb check-column' scope='col'>
							<input class='select-all' type="checkbox" value='1' />
						</th>
						<th><?php 
        _e('Event', 'dbem');
        ?>
</th>
						<th><?php 
        _e('Date and time', 'dbem');
        ?>
</th>
					</tr>
				</thead>
				<tbody>
					<?php 
        $rowno = 0;
        $event_count = 0;
        foreach ($events as $event) {
            /* @var $event EM_Event */
            if (($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0)) {
                $rowno++;
                $class = $rowno % 2 ? ' class="alternate"' : '';
                // FIXME set to american
                $localised_start_date = date_i18n('D d M Y', $event->start);
                $localised_end_date = date_i18n('D d M Y', $event->end);
                $style = "";
                $today = date("Y-m-d");
                if ($event->start_date < $today && $event->end_date < $today) {
                    $style = "style ='background-color: #FADDB7;'";
                }
                ?>
							<tr <?php 
                echo "{$class} {$style}";
                ?>
>
				
								<td>
									<input type='checkbox' class='row-selector' value='<?php 
                echo $event->id;
                ?>
' name='events[]' />
								</td>
								<td>
									<strong>
										<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>
									</strong>
									&ndash; 
									<?php 
                _e("Booked Seats", 'dbem');
                ?>
: <?php 
                echo $event->get_bookings()->get_booked_seats() . "/" . $event->seats;
                ?>
									<?php 
                if (get_option('dbem_bookings_approval') == 1) {
                    ?>
										| <?php 
                    _e("Pending", 'dbem');
                    ?>
: <?php 
                    echo $event->get_bookings()->get_pending_seats();
                    ?>
									<?php 
                }
                ?>
								</td>
						
								<td>
									<?php 
                echo $localised_start_date;
                ?>
									<?php 
                echo $localised_end_date != $localised_start_date ? " - {$localised_end_date}" : '';
                ?>
									&ndash;
									<?php 
                //TODO Should 00:00 - 00:00 be treated as an all day event?
                echo substr($event->start_time, 0, 5) . " - " . substr($event->end_time, 0, 5);
                ?>
								</td>
							</tr>
							<?php 
            }
            $event_count++;
        }
        ?>
				</tbody>
			</table>
			</div>
			<?php 
    }
    // end of table
    ?>
			<div class='tablenav'>
				<div class="alignleft actions">
				<br class='clear' />
				</div>
			<?php 
    if (!empty($events_nav)) {
        ?>
				<div class="tablenav-pages">
					<?php 
        echo $events_nav;
        ?>
				</div>
				<?php 
    }
    ?>
				<br class='clear' />
			</div>
		</form>
	</div>
	<?php 
}
Beispiel #8
0
/**
 * Determines whether to show event page or events page, and saves any updates to the event or events
 * @return null
 */
function em_bookings_events_table()
{
    //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
    global $wpdb;
    global $EM_Event;
    $scope_names = array('past' => __('Past events', 'dbem'), 'all' => __('All events', 'dbem'), 'future' => __('Future events', 'dbem'));
    $action_scope = !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_events_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;
    $scope = $action_scope && !empty($_GET['scope']) && array_key_exists($_GET['scope'], $scope_names) ? $_GET['scope'] : 'future';
    // No action, only showing the events list
    switch ($scope) {
        case "past":
            $title = __('Past Events', 'dbem');
            break;
        case "all":
            $title = __('All Events', 'dbem');
            break;
        default:
            $title = __('Future Events', 'dbem');
            $scope = "future";
    }
    $owner = !current_user_can('manage_others_bookings') ? get_current_user_id() : false;
    $events = EM_Events::get(array('scope' => $scope, 'limit' => $limit, 'offset' => $offset, 'order' => $order, 'bookings' => true, 'owner' => $owner));
    $events_count = EM_Events::count(array('scope' => $scope, 'limit' => 0, 'order' => $order, 'bookings' => true, 'owner' => $owner));
    $use_events_end = get_option('dbem_use_event_end');
    ?>

	<div class="wrap em_bookings_events_table em_obj">
		<form id="posts-filter" action="" method="get">
			<input type="hidden" name="em_obj" value="em_bookings_events_table" />
			<?php 
    if (!empty($_GET['page'])) {
        ?>

			<input type='hidden' name='page' value='events-manager-bookings' />
			<?php 
    }
    ?>
		
			<div class="tablenav">			
				<div class="alignleft actions">
					<!--
					<select name="action">
						<option value="-1" selected="selected"><?php 
    esc_html_e('Bulk Actions');
    ?>
</option>
						<option value="deleteEvents"><?php 
    esc_html_e('Delete selected', 'dbem');
    ?>
</option>
					</select> 
					<input type="submit" value="<?php 
    esc_html_e('Apply');
    ?>
" name="doaction2" id="doaction2" class="button-secondary action" />
					 --> 
					<select name="scope">
						<?php 
    foreach ($scope_names as $key => $value) {
        $selected = "";
        if ($key == $scope) {
            $selected = "selected='selected'";
        }
        echo "<option value='{$key}' {$selected}>{$value}</option>  ";
    }
    ?>

					</select>
					<input id="post-query-submit" class="button-secondary" type="submit" value="<?php 
    esc_html_e('Filter');
    ?>
" />
				</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 ($events_count >= $limit) {
        $events_nav = em_admin_paginate($events_count, $limit, $page, array('em_ajax' => 0, 'em_obj' => 'em_bookings_events_table'));
        echo $events_nav;
    }
    ?>

			</div>
				
			<?php 
    if (empty($events)) {
        // TODO localize
        _e('no events', 'dbem');
    } else {
        ?>

			<div class='table-wrap'>	
			<table class="widefat">
				<thead>
					<tr>
						<th><?php 
        esc_html_e('Event', 'dbem');
        ?>
</th>
						<th><?php 
        esc_html_e('Date and time', 'dbem');
        ?>
</th>
					</tr>
				</thead>
				<tbody>
					<?php 
        $rowno = 0;
        foreach ($events as $event) {
            /* @var $event EM_Event */
            $rowno++;
            $class = $rowno % 2 ? ' class="alternate"' : '';
            // FIXME set to american
            $localised_start_date = date_i18n(get_option('date_format'), $event->start);
            $localised_end_date = date_i18n(get_option('date_format'), $event->end);
            $style = "";
            $today = date("Y-m-d");
            if ($event->start_date < $today && $event->end_date < $today) {
                $style = "style ='background-color: #FADDB7;'";
            }
            ?>

						<tr <?php 
            echo "{$class} {$style}";
            ?>
>
							<td>
								<strong>
									<?php 
            echo $event->output('#_BOOKINGSLINK');
            ?>

								</strong>
								&ndash; 
								<?php 
            esc_html_e("Booked Spaces", 'dbem');
            ?>
: <?php 
            echo $event->get_bookings()->get_booked_spaces() . "/" . $event->get_spaces();
            ?>

								<?php 
            if (get_option('dbem_bookings_approval') == 1) {
                ?>

									| <?php 
                esc_html_e("Pending", 'dbem');
                ?>
: <?php 
                echo $event->get_bookings()->get_pending_spaces();
                ?>

								<?php 
            }
            ?>

							</td>
					
							<td>
								<?php 
            echo $localised_start_date;
            ?>

								<?php 
            echo $localised_end_date != $localised_start_date ? " - {$localised_end_date}" : '';
            ?>

								&ndash;
								<?php 
            //TODO Should 00:00 - 00:00 be treated as an all day event?
            echo substr($event->start_time, 0, 5) . " - " . substr($event->end_time, 0, 5);
            ?>

							</td>
						</tr>
						<?php 
        }
        ?>

				</tbody>
			</table>
			</div>
			<?php 
    }
    // end of table
    ?>

			<div class='tablenav'>
				<div class="alignleft actions">
				<br class='clear' />
				</div>
				<?php 
    if (!empty($events_nav) && $events_count >= $limit) {
        ?>

				<div class="tablenav-pages">
					<?php 
        echo $events_nav;
        ?>

				</div>
				<?php 
    }
    ?>

				<br class='clear' />
			</div>
		</form>
	</div>
	<?php 
}
Beispiel #9
0
			<input type="submit" value="<?php 
        _e('Apply');
        ?>
" id="doaction2" class="button-secondary action" /> 
		</div>
		<?php 
    } else {
        $hide_checkboxes = true;
        /* @todo this and the first condition of this if statement will need to change when other bulk actions are added */
        ?>
		<?php 
    }
    ?>
		<?php 
    if ($locations_count >= $limit) {
        $locations_nav = em_admin_paginate($locations_count, $limit, $page);
        echo $locations_nav;
    }
    ?>
	</div>
	<table class='widefat'>
		<thead>
			<tr>
				<?php 
    if (empty($hide_checkboxes)) {
        ?>
				<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
				<?php 
    }
    ?>
				<th><?php 
    static function view_page()
    {
        global $EM_Notices, $EM_Coupon, $wpdb;
        //check that user can access this page
        if (is_object($EM_Coupon) && !$EM_Coupon->can_manage('manage_bookings', 'manage_others_bookings')) {
            ?>
			<div class="wrap"><h2><?php 
            esc_html_e_emp('Unauthorized Access', 'dbem');
            ?>
</h2><p><?php 
            echo sprintf(esc_html__emp('You do not have the rights to manage this %s.', 'dbem'), __('coupon', 'em-pro'));
            ?>
</p></div>
			<?php 
            return false;
        } elseif (!is_object($EM_Coupon)) {
            $EM_Coupon = new EM_Coupon();
        }
        $limit = !empty($_GET['limit']) ? $_GET['limit'] : 20;
        //Default limit
        $page = !empty($_GET['pno']) ? $_GET['pno'] : 1;
        $offset = $page > 1 ? ($page - 1) * $limit : 0;
        //a bit hacky, but this is the only way at least for now
        $coupon_search = str_replace('a:1:{', '', serialize(array('coupon_code' => $EM_Coupon->coupon_code)));
        $coupon_search = substr($coupon_search, 0, strlen($coupon_search) - 1);
        $bookings = $wpdb->get_col('SELECT booking_id FROM ' . EM_BOOKINGS_TABLE . " WHERE booking_meta LIKE '%{$coupon_search}%' LIMIT {$limit} OFFSET {$offset}");
        //FIXME : coupon count not syncing correctly, using this as a fallback
        $coupons_count = $wpdb->get_var('SELECT COUNT(*) FROM ' . EM_BOOKINGS_TABLE . " WHERE booking_meta LIKE '%{$coupon_search}%'");
        $bookings_count = 0;
        $EM_Bookings = array();
        foreach ($bookings as $booking_id) {
            $EM_Booking = em_get_booking($booking_id);
            if (!empty($EM_Booking->booking_meta['coupon'])) {
                $coupon = new EM_Coupon($EM_Booking->booking_meta['coupon']);
                if ($EM_Coupon->coupon_code == $coupon->coupon_code && $EM_Coupon->coupon_id == $coupon->coupon_id) {
                    $bookings_count++;
                    $EM_Bookings[] = $EM_Booking;
                }
            }
        }
        ?>
		<div class='wrap nosubsub'>
			<div class="icon32" id="icon-bookings"><br></div>
			<h2><?php 
        _e('Coupon Usage History', 'em-pro');
        ?>
</h2>
			<?php 
        echo $EM_Notices;
        ?>
			<p><?php 
        echo sprintf(__('You are viewing the details of coupon %s - <a href="%s">edit</a>', 'em-pro'), '<code>' . $EM_Coupon->coupon_code . '</code>', add_query_arg(array('action' => 'edit')));
        ?>
</p>
			<p>
				<strong><?php 
        echo __('Uses', 'em-pro');
        ?>
:</strong> 
				<?php 
        if (!empty($EM_Coupon->coupon_max)) {
            echo esc_html($coupons_count . ' / ' . $EM_Coupon->coupon_max);
        } else {
            echo esc_html($coupons_count . '/' . __('Unlimited', 'em-pro'));
        }
        ?>
			</p>
			<?php 
        if ($coupons_count >= $limit) {
            ?>
			<div class='tablenav'>
				<?php 
            $bookings_nav = em_admin_paginate($coupons_count, $limit, $page, array());
            echo $bookings_nav;
            ?>
				<div class="clear"></div>
			</div>
			<?php 
        }
        ?>
			<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' scope='col'><?php 
            esc_html_e_emp('Event', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Booker', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Spaces', 'dbem');
            ?>
</th>
							<th><?php 
            _e('Original Total Price', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Coupon Discount', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Final Price', 'em-pro');
            ?>
</th>
							<th>&nbsp;</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Event', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Booker', 'dbem');
            ?>
</th>
							<th class='manage-column' scope='col'><?php 
            esc_html_e_emp('Spaces', 'dbem');
            ?>
</th>
							<th><?php 
            _e('Original Total Price', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Coupon Discount', 'em-pro');
            ?>
</th>
							<th><?php 
            _e('Final Price', 'em-pro');
            ?>
</th>
							<th>&nbsp;</th>
						</tr>
					</tfoot>
					<tbody>
						<?php 
            foreach ($EM_Bookings as $EM_Booking) {
                ?>
							<tr>
								<td><?php 
                echo $EM_Booking->output('#_BOOKINGSLINK');
                ?>
</td>
								<td><a href="<?php 
                echo EM_ADMIN_URL;
                ?>
&amp;page=events-manager-bookings&amp;person_id=<?php 
                echo $EM_Booking->person_id;
                ?>
"><?php 
                echo $EM_Booking->person->get_name();
                ?>
</a></td>
								<td><?php 
                echo $EM_Booking->get_spaces();
                ?>
</td>
								<td><?php 
                echo em_get_currency_formatted($EM_Booking->booking_meta['original_price']);
                ?>
</td>
								<td><?php 
                echo em_get_currency_formatted($EM_Booking->booking_meta['original_price'] - $EM_Booking->get_price());
                ?>
 <em>(<?php 
                echo $EM_Coupon->get_discount_text();
                ?>
)</em></td>
								<td><?php 
                echo em_get_currency_formatted($EM_Booking->get_price());
                ?>
</td>
								<td>										
									<?php 
                $edit_url = em_add_get_params($_SERVER['REQUEST_URI'], array('booking_id' => $EM_Booking->booking_id, 'em_ajax' => null, 'em_obj' => null));
                ?>
									<?php 
                if ($EM_Booking->can_manage()) {
                    ?>
									<a class="em-bookings-edit" href="<?php 
                    echo $edit_url;
                    ?>
"><?php 
                    esc_html_e_emp('Edit/View', 'dbem');
                    ?>
</a>
									<?php 
                }
                ?>
								</td>
							</tr>
							<?php 
            }
            ?>
					</tbody>
				</table>
			</div> <!-- table-wrap -->
			<?php 
        } else {
            ?>
			<p><?php 
            _e('Your coupon hasn\'t been used yet!', 'em-pro');
            ?>
</p>
			<?php 
        }
        ?>
		</div> <!-- wrap -->
		<?php 
    }
Beispiel #11
0
function em_admin_locations($message = '', $fill_fields = false)
{
    global $EM_Notices;
    $limit = !empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 20;
    //Default limit
    $page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
    $offset = $page > 1 ? ($page - 1) * $limit : 0;
    if (!empty($_REQUEST['owner']) && current_user_can('read_others_locations')) {
        $locations = EM_Locations::get(array('owner' => false));
        $locations_mine_count = EM_Locations::count(array('owner' => get_current_user_id()));
        $locations_all_count = count($locations);
    } else {
        $locations = EM_Locations::get(array('owner' => get_current_user_id(), 'blog' => false));
        $locations_mine_count = count($locations);
        $locations_all_count = current_user_can('read_others_locations') ? EM_Locations::count(array('blog' => false)) : 0;
    }
    $locations_count = count($locations);
    ?>
		<div class='wrap'>
			<div id='icon-edit' class='icon32'>
				<br/>
			</div>
 	 		<h2>
 	 			<?php 
    _e('Locations', 'dbem');
    ?>
 	 			<a href="admin.php?page=events-manager-locations&action=add" class="button add-new-h2"><?php 
    _e('Add New', 'dbem');
    ?>
</a>
 	 		</h2>  

			<?php 
    echo $EM_Notices;
    ?>
  
			  
		 	 <form id='locations-filter' method='post' action=''>
				<input type='hidden' name='page' value='locations'/>
				<input type='hidden' name='limit' value='<?php 
    echo $limit;
    ?>
' />	
				<input type='hidden' name='p' value='<?php 
    echo $page;
    ?>
' />	
				<div class="subsubsub">
					<a href='admin.php?page=events-manager-locations' <?php 
    echo empty($_REQUEST['owner']) ? 'class="current"' : '';
    ?>
><?php 
    echo sprintf(__('My %s', 'dbem'), __('Locations', 'dbem'));
    ?>
 <span class="count">(<?php 
    echo $locations_mine_count;
    ?>
)</span></a>
					<?php 
    if (current_user_can('read_others_locations')) {
        ?>
					&nbsp;|&nbsp;
					<a href='admin.php?page=events-manager-locations&amp;owner=all' <?php 
        echo !empty($_REQUEST['owner']) ? 'class="current"' : '';
        ?>
><?php 
        echo sprintf(__('All %s', 'dbem'), __('Locations', 'dbem'));
        ?>
 <span class="count">(<?php 
        echo $locations_all_count;
        ?>
)</span></a>
					<?php 
    }
    ?>
				</div>										
				<?php 
    if ($locations_count > 0) {
        ?>
				<div class='tablenav'>					
					<div class="alignleft actions">
						<select name="action">
							<option value="" selected="selected"><?php 
        _e('Bulk Actions');
        ?>
</option>
							<option value="location_delete"><?php 
        _e('Delete selected', 'dbem');
        ?>
</option>
						</select> 
						<input type="submit" value="<?php 
        _e('Apply');
        ?>
" id="doaction2" class="button-secondary action" /> 
					</div>
						<?php 
        if ($locations_count >= $limit) {
            $locations_nav = em_admin_paginate($locations_count, $limit, $page);
            echo $locations_nav;
        }
        ?>
				</div>
				<table class='widefat'>
					<thead>
						<tr>
							<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
							<th><?php 
        _e('Name', 'dbem');
        ?>
</th>
							<th><?php 
        _e('Address', 'dbem');
        ?>
</th>
							<th><?php 
        _e('Town', 'dbem');
        ?>
</th>  
							<th><?php 
        _e('State', 'dbem');
        ?>
</th>    
							<th><?php 
        _e('Country', 'dbem');
        ?>
</th>                
						</tr> 
					</thead>
					<tfoot>
						<tr>
							<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
							<th><?php 
        _e('Name', 'dbem');
        ?>
</th>
							<th><?php 
        _e('Address', 'dbem');
        ?>
</th>
							<th><?php 
        _e('Town', 'dbem');
        ?>
</th>    
							<th><?php 
        _e('State', 'dbem');
        ?>
</th>    
							<th><?php 
        _e('Country', 'dbem');
        ?>
</th>     
						</tr>             
					</tfoot>
					<tbody>
						<?php 
        $i = 1;
        ?>
						<?php 
        foreach ($locations as $EM_Location) {
            ?>
	
							<?php 
            if ($i >= $offset && $i <= $offset + $limit) {
                ?>
								<tr>
									<td><input type='checkbox' class ='row-selector' value='<?php 
                echo $EM_Location->id;
                ?>
' name='locations[]'/></td>
									<td><a href='admin.php?page=events-manager-locations&amp;action=edit&amp;location_id=<?php 
                echo $EM_Location->id;
                ?>
'><?php 
                echo $EM_Location->name;
                ?>
</a></td>
									<td><?php 
                echo $EM_Location->address;
                ?>
</td>
									<td><?php 
                echo $EM_Location->town;
                ?>
</td>     
									<td><?php 
                echo $EM_Location->state;
                ?>
</td>  
									<td><?php 
                echo $EM_Location->get_country();
                ?>
</td>                      
								</tr>
							<?php 
            }
            ?>
							<?php 
            $i++;
            ?>
 
						<?php 
        }
        ?>
					</tbody>
				</table>
				<?php 
    } else {
        ?>
				<p><?php 
        _e('No venues have been inserted yet!', 'dbem');
        ?>
</p>
				<?php 
    }
    ?>
			</form>
		</div>
  	<?php 
}
Beispiel #12
0
/**
 * Determines whether to show event page or events page, and saves any updates to the event or events
 * @return null
 */
function em_admin_events_page()
{
    //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
    global $wpdb, $EM_Notices, $EM_Event;
    $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
    $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'ASC';
    $limit = !empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 20;
    //Default limit
    $page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
    $offset = $page > 1 ? ($page - 1) * $limit : 0;
    $search = !empty($_REQUEST['em_search']) ? $_REQUEST['em_search'] : '';
    $scope_names = em_get_scopes();
    $scope = !empty($_REQUEST['scope']) && array_key_exists($_REQUEST['scope'], $scope_names) ? $_REQUEST['scope'] : 'future';
    $selectedEvents = !empty($_REQUEST['events']) ? $_REQUEST['events'] : '';
    $args = array('scope' => $scope, 'limit' => 0, 'order' => $order, 'search' => $search);
    if (!current_user_can('edit_others_events')) {
        $args['owner'] = get_current_user_id();
    }
    //Figure out what status to search for
    $args['status'] = isset($_REQUEST['status']) && is_numeric($_REQUEST['status']) ? $_REQUEST['status'] : false;
    $events = EM_Events::get($args);
    $events_count = count($events);
    $pending_count = EM_Events::count(array('status' => 0, 'scope' => $scope));
    $approved_count = EM_Events::count(array('status' => 1, 'scope' => $scope));
    $total_count = EM_Events::count(array('status' => false, 'scope' => $scope));
    $use_events_end = get_option('dbem_use_event_end');
    echo $EM_Notices;
    ?>
	<div class="wrap">
		<div id="icon-events" class="icon32"><br />
		</div>
		<h2>	
			<?php 
    echo $scope_names[$scope];
    ?>
 	 		<a href="admin.php?page=events-manager-event" class="button add-new-h2"><?php 
    _e('Add New', 'dbem');
    ?>
</a>
 	 	</h2>
		<?php 
    $link = array();
    $link['past'] = "<a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&amp;scope=past&amp;order=desc'>" . __('Past events', 'dbem') . "</a>";
    $link['all'] = " <a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&amp;scope=all&amp;order=desc'>" . __('All events', 'dbem') . "</a>";
    $link['future'] = "  <a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&amp;scope=future'>" . __('Future events', 'dbem') . "</a>";
    ?>
 
		<?php 
    if (!empty($_REQUEST['error'])) {
        ?>
		<div id='message' class='error'>
			<p><?php 
        echo $_REQUEST['error'];
        ?>
</p>
		</div>
		<?php 
    }
    ?>
		<?php 
    if (!empty($_REQUEST['message'])) {
        ?>
		<div id='message' class='updated fade'>
			<p><?php 
        echo $_REQUEST['message'];
        ?>
</p>
		</div>
		<?php 
    }
    ?>
		<form id="posts-filter" action="" method="get"><input type='hidden' name='page' value='events-manager' />
			<ul class="subsubsub">
				<li><a href='<?php 
    bloginfo('wpurl');
    ?>
/wp-admin/admin.php?page=events-manager&amp;scope=<?php 
    echo $scope;
    ?>
' <?php 
    echo !isset($_REQUEST['status']) ? 'class="current"' : '';
    ?>
><?php 
    _e('Total', 'dbem');
    ?>
 <span class="count">(<?php 
    echo $total_count;
    ?>
)</span></a></li>
				<?php 
    if (current_user_can('publish_events')) {
        ?>
				<li>| <a href='<?php 
        bloginfo('wpurl');
        ?>
/wp-admin/admin.php?page=events-manager&amp;scope=<?php 
        echo $scope;
        ?>
&amp;status=1' <?php 
        echo isset($_REQUEST['status']) && $_REQUEST['status'] == '1' ? 'class="current"' : '';
        ?>
><?php 
        _e('Approved', 'dbem');
        ?>
 <span class="count">(<?php 
        echo $approved_count;
        ?>
)</span></a></li>
				<li>| <a href='<?php 
        bloginfo('wpurl');
        ?>
/wp-admin/admin.php?page=events-manager&amp;scope=<?php 
        echo $scope;
        ?>
&amp;status=0' <?php 
        echo isset($_REQUEST['status']) && $_REQUEST['status'] == '0' ? 'class="current"' : '';
        ?>
><?php 
        _e('Pending', 'dbem');
        ?>
 <span class="count">(<?php 
        echo $pending_count;
        ?>
)</span></a></li>
				<?php 
    }
    ?>
			</ul>
			<p class="search-box">
				<label class="screen-reader-text" for="post-search-input"><?php 
    _e('Search Events', 'dbem');
    ?>
:</label>
				<input type="text" id="post-search-input" name="em_search" value="<?php 
    echo !empty($_REQUEST['em_search']) ? $_REQUEST['em_search'] : '';
    ?>
" />
				<input type="submit" value="<?php 
    _e('Search Events', 'dbem');
    ?>
" class="button" />
			</p>			
			<div class="tablenav">
			
				<div class="alignleft actions">
					<select name="action">
						<option value="-1" selected="selected"><?php 
    _e('Bulk Actions');
    ?>
</option>
						<option value="event_delete"><?php 
    _e('Delete selected', 'dbem');
    ?>
</option>
					</select> 
					<input type="submit" value="<?php 
    _e('Apply');
    ?>
" name="doaction2" id="doaction2" class="button-secondary action" /> 
					<select name="scope">
						<?php 
    foreach ($scope_names as $key => $value) {
        $selected = "";
        if ($key == $scope) {
            $selected = "selected='selected'";
        }
        echo "<option value='{$key}' {$selected}>{$value}</option>  ";
    }
    ?>
					</select> 
					<input id="post-query-submit" class="button-secondary" type="submit" value="<?php 
    _e('Filter');
    ?>
" />
				</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 ($events_count >= $limit) {
        $events_nav = em_admin_paginate($events_count, $limit, $page);
        echo $events_nav;
    }
    ?>
				<br class="clear" />
			</div>
				
			<?php 
    if (empty($events)) {
        // TODO localize
        _e('no events', 'dbem');
    } else {
        ?>
					
			<table class="widefat events-table">
				<thead>
					<tr>
						<th class='manage-column column-cb check-column' scope='col'>
							<input class='select-all' type="checkbox" value='1' />
						</th>
						<th><?php 
        _e('Name', 'dbem');
        ?>
</th>
						<th>&nbsp;</th>
						<th><?php 
        _e('Location', 'dbem');
        ?>
</th>
						<th colspan="2"><?php 
        _e('Date and time', 'dbem');
        ?>
</th>
					</tr>
				</thead>
				<tbody>
					<?php 
        $rowno = 0;
        $event_count = 0;
        foreach ($events as $event) {
            /* @var $event EM_Event */
            if (($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0)) {
                $rowno++;
                $class = $rowno % 2 ? 'alternate' : '';
                // FIXME set to american
                $localised_start_date = date_i18n('D d M Y', $event->start);
                $localised_end_date = date_i18n('D d M Y', $event->end);
                $style = "";
                $today = date("Y-m-d");
                $location_summary = "<b>" . $event->location->name . "</b><br/>" . $event->location->address . " - " . $event->location->town;
                if ($event->start_date < $today && $event->end_date < $today) {
                    $class .= " past";
                }
                //Check pending approval events
                if (!$event->status) {
                    $class .= " pending";
                }
                ?>
							<tr class="event <?php 
                echo trim($class);
                ?>
" <?php 
                echo $style;
                ?>
 id="event_<?php 
                echo $event->id;
                ?>
">
								<td>
									<input type='checkbox' class='row-selector' value='<?php 
                echo $event->id;
                ?>
' name='events[]' />
								</td>
								<td>
									<strong>
										<a class="row-title" href="<?php 
                bloginfo('wpurl');
                ?>
/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php 
                echo $event->id;
                ?>
&amp;scope=<?php 
                echo $scope;
                ?>
&amp;pno=<?php 
                echo $page;
                ?>
"><?php 
                echo $event->name;
                ?>
</a>
									</strong>
									<?php 
                if (get_option('dbem_rsvp_enabled') == 1 && $event->rsvp == 1) {
                    ?>
										<br/>
										<a href="<?php 
                    bloginfo('wpurl');
                    ?>
/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php 
                    echo $event->id;
                    ?>
"><?php 
                    echo __("Bookings", 'dbem');
                    ?>
</a> &ndash;
										<?php 
                    _e("Booked", 'dbem');
                    ?>
: <?php 
                    echo $event->get_bookings()->get_booked_spaces() . "/" . $event->get_spaces();
                    ?>
										<?php 
                    if (get_option('dbem_bookings_approval') == 1) {
                        ?>
											| <?php 
                        _e("Pending", 'dbem');
                        ?>
: <?php 
                        echo $event->get_bookings()->get_pending_spaces();
                        ?>
										<?php 
                    }
                }
                ?>
									<div class="row-actions">
										<span class="trash"><a href="<?php 
                bloginfo('wpurl');
                ?>
/wp-admin/admin.php?page=events-manager&amp;action=event_delete&amp;event_id=<?php 
                echo $event->id;
                ?>
&amp;scope=<?php 
                echo $scope;
                ?>
&amp;pno=<?php 
                echo $page;
                ?>
" class="em-event-delete"><?php 
                _e('Delete', 'dbem');
                ?>
</a></span>
										<?php 
                if (!$event->status && current_user_can('publish_events')) {
                    ?>
										| <a href="<?php 
                    bloginfo('wpurl');
                    ?>
/wp-admin/admin.php?page=events-manager&amp;action=event_approve&amp;event_id=<?php 
                    echo $event->id;
                    ?>
&amp;scope=<?php 
                    echo $scope;
                    ?>
&amp;pno=<?php 
                    echo $page;
                    ?>
" class="em-event-approve" style="color:green"><?php 
                    _e('Approve', 'dbem');
                    ?>
</a>
										<?php 
                }
                ?>
									</div>
								</td>
								<td>
									<a href="<?php 
                bloginfo('wpurl');
                ?>
/wp-admin/admin.php?page=events-manager-event&amp;action=event_duplicate&amp;event_id=<?php 
                echo $event->id;
                ?>
&amp;scope=<?php 
                echo $scope;
                ?>
&amp;pno=<?php 
                echo $page;
                ?>
" title="<?php 
                _e('Duplicate this event', 'dbem');
                ?>
">
										<strong>+</strong>
									</a>
								</td>
								<td>
									<?php 
                echo $location_summary;
                ?>
								</td>
						
								<td>
									<?php 
                echo $localised_start_date;
                ?>
									<?php 
                echo $localised_end_date != $localised_start_date ? " - {$localised_end_date}" : '';
                ?>
									<br />
									<?php 
                //TODO Should 00:00 - 00:00 be treated as an all day event?
                echo substr($event->start_time, 0, 5) . " - " . substr($event->end_time, 0, 5);
                ?>
								</td>
								<td>
									<?php 
                if ($event->is_recurrence()) {
                    $recurrence_delete_confirm = __('WARNING! You will delete ALL recurrences of this event, including booking history associated with any event in this recurrence. To keep booking information, go to the relevant single event and save it to detach it from this recurrence series.', 'dbem');
                    ?>
										<strong>
										<?php 
                    echo $event->get_recurrence_description();
                    ?>
 <br />
										<a href="<?php 
                    bloginfo('wpurl');
                    ?>
/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php 
                    echo $event->recurrence_id;
                    ?>
&amp;scope=<?php 
                    echo $scope;
                    ?>
&amp;pno=<?php 
                    echo $page;
                    ?>
"><?php 
                    _e('Reschedule', 'dbem');
                    ?>
</a> |
										<span class="trash"><a href="<?php 
                    bloginfo('wpurl');
                    ?>
/wp-admin/admin.php?page=events-manager&amp;action=event_delete&amp;event_id=<?php 
                    echo $event->recurrence_id;
                    ?>
&amp;scope=<?php 
                    echo $scope;
                    ?>
&amp;pno=<?php 
                    echo $page;
                    ?>
" class="em-event-rec-delete" onclick ="if( !confirm('<?php 
                    echo $recurrence_delete_confirm;
                    ?>
') ){ return false; }"><?php 
                    _e('Delete', 'dbem');
                    ?>
</a></span>
										</strong>
										<?php 
                }
                ?>
								</td>
							</tr>
							<?php 
            }
            $event_count++;
        }
        ?>
				</tbody>
			</table>  
			<?php 
    }
    // end of table
    ?>
			<div class='tablenav'>
				<div class="alignleft actions">
				<br class='clear' />
				</div>
				<?php 
    if ($events_count >= $limit) {
        ?>
				<div class="tablenav-pages">
					<?php 
        echo $events_nav;
        ?>
				</div>
				<?php 
    }
    ?>
				<br class='clear' />
			</div>
		</form>
	</div>
	<?php 
}
        function mytransactions($context = false)
        {
            global $EM_Person;
            $transactions = $this->get_transactions($context);
            $total = $this->total_transactions;
            $columns = array();
            $columns['event'] = __('Event', 'em-pro');
            $columns['user'] = __('User', 'em-pro');
            $columns['date'] = __('Date', 'em-pro');
            $columns['amount'] = __('Amount', 'em-pro');
            $columns['transid'] = __('Transaction id', 'em-pro');
            $columns['gateway'] = __('Gateway', 'em-pro');
            $columns['status'] = __('Status', 'em-pro');
            $columns['note'] = __('Notes', 'em-pro');
            $columns['actions'] = '';
            $trans_navigation = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'total' => ceil($total / 20), 'current' => $this->page));
            ?>
		<div id="em-transactions-table" class="em_obj">
		<form id="em-transactions-table-form" class="transactions-filter" action="" method="post">
			<?php 
            if (is_object($context) && get_class($context) == "EM_Event") {
                ?>
			<input type="hidden" name="event_id" value='<?php 
                echo $context->event_id;
                ?>
' />
			<?php 
            } elseif (is_object($context) && get_class($context) == "EM_Person") {
                ?>
			<input type="hidden" name="person_id" value='<?php 
                echo $context->person_id;
                ?>
' />
			<?php 
            }
            ?>
			<input type="hidden" name="pno" value='<?php 
            echo $this->page;
            ?>
' />
			<input type="hidden" name="order" value='<?php 
            echo $this->order;
            ?>
' />
			<input type="hidden" name="orderby" value='<?php 
            echo $this->orderby;
            ?>
' />
			<input type="hidden" name="_wpnonce" value="<?php 
            echo !empty($_REQUEST['_wpnonce']) ? esc_attr($_REQUEST['_wpnonce']) : wp_create_nonce('em_transactions_table');
            ?>
" />
			<input type="hidden" name="action" value="em_transactions_table" />
			
			<div class="tablenav">
				<div class="alignleft actions">
					<select name="limit">
						<option value="<?php 
            echo $this->limit;
            ?>
"><?php 
            echo sprintf(esc_html__emp('%s Rows', 'dbem'), $this->limit);
            ?>
</option>
						<option value="5">5</option>
						<option value="10">10</option>
						<option value="25">25</option>
						<option value="50">50</option>
						<option value="100">100</option>
					</select>
					<select name="gateway">
						<option value="">All</option>
						<?php 
            global $EM_Gateways;
            foreach ($EM_Gateways as $EM_Gateway) {
                ?>
<option value='<?php 
                echo $EM_Gateway->gateway;
                ?>
' <?php 
                if ($EM_Gateway->gateway == $this->gateway) {
                    echo "selected='selected'";
                }
                ?>
><?php 
                echo $EM_Gateway->title;
                ?>
</option><?php 
            }
            ?>
					</select>
					<input id="post-query-submit" class="button-secondary" type="submit" value="<?php 
            _e('Filter');
            ?>
" />
					<?php 
            if (is_object($context) && get_class($context) == "EM_Event") {
                ?>
					<?php 
                esc_html_e_emp('Displaying Event', 'dbem');
                ?>
 : <?php 
                echo $context->event_name;
                ?>
					<?php 
            } elseif (is_object($context) && get_class($context) == "EM_Person") {
                ?>
					<?php 
                esc_html_e_emp('Displaying User', 'dbem');
                echo ' : ' . $context->get_name();
                ?>
					<?php 
            }
            ?>
				</div>
				<?php 
            if ($this->total_transactions >= $this->limit) {
                echo em_admin_paginate($this->total_transactions, $this->limit, $this->page, array(), '#%#%', '#');
            }
            ?>
			</div>

			<div class="table-wrap">
			<table cellspacing="0" class="widefat">
				<thead>
				<tr>
				<?php 
            foreach ($columns as $key => $col) {
                ?>
						<th style="" class="manage-column column-<?php 
                echo $key;
                ?>
" id="<?php 
                echo $key;
                ?>
" scope="col"><?php 
                echo $col;
                ?>
</th>
						<?php 
            }
            ?>
				</tr>
				</thead>

				<tfoot>
				<tr>
					<?php 
            reset($columns);
            foreach ($columns as $key => $col) {
                ?>
							<th style="" class="manage-column column-<?php 
                echo $key;
                ?>
" id="<?php 
                echo $key;
                ?>
" scope="col"><?php 
                echo $col;
                ?>
</th>
							<?php 
            }
            ?>
				</tr>
				</tfoot>

				<tbody>
					<?php 
            echo $this->print_transactions($transactions);
            ?>

				</tbody>
			</table>
			</div>
		</form>
		</div>
		<?php 
        }
Beispiel #14
0
/**
 * Determines whether to show event page or events page, and saves any updates to the event or events
 * @return null
 */
function em_admin_events_page()
{
    //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
    global $wpdb;
    global $EM_Event;
    $action = !empty($_GET['action']) ? $_GET['action'] : '';
    $order = !empty($_GET['order']) ? $_GET['order'] : 'ASC';
    $limit = !empty($_GET['limit']) ? $_GET['limit'] : 20;
    //Default limit
    $page = !empty($_GET['pno']) ? $_GET['pno'] : 1;
    $offset = $page > 1 ? ($page - 1) * $limit : 0;
    $scope_names = array('past' => __('Past events', 'dbem'), 'all' => __('All events', 'dbem'), 'future' => __('Future events', 'dbem'));
    $scope = !empty($_GET['scope']) && array_key_exists($_GET['scope'], $scope_names) ? $_GET['scope'] : 'future';
    $selectedEvents = !empty($_GET['events']) ? $_GET['events'] : '';
    // DELETE action
    if ($action == 'deleteEvents' && EM_Object::array_is_numeric($selectedEvents)) {
        EM_Events::delete($selectedEvents);
    }
    // No action, only showing the events list
    switch ($scope) {
        case "past":
            $title = __('Past Events', 'dbem');
            break;
        case "all":
            $title = __('All Events', 'dbem');
            break;
        default:
            $title = __('Future Events', 'dbem');
            $scope = "future";
    }
    $args = array('scope' => $scope, 'limit' => 0, 'order' => $order);
    if (!get_option('dbem_permissions_events') && !em_verify_admin()) {
        $args['owner'] = get_current_user_id();
    }
    $events = EM_Events::get($args);
    $events_count = count($events);
    $use_events_end = get_option('dbem_use_event_end');
    ?>
	<div class="wrap">
		<div id="icon-events" class="icon32"><br />
		</div>
		<h2>	
			<?php 
    echo $title;
    ?>
 	 		<a href="admin.php?page=events-manager-event" class="button add-new-h2"><?php 
    _e('Add New', 'dbem');
    ?>
</a>
 	 	</h2>
		<?php 
    $link = array();
    $link['past'] = "<a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&amp;scope=past&amp;order=desc'>" . __('Past events', 'dbem') . "</a>";
    $link['all'] = " <a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&amp;scope=all&amp;order=desc'>" . __('All events', 'dbem') . "</a>";
    $link['future'] = "  <a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&amp;scope=future'>" . __('Future events', 'dbem') . "</a>";
    ?>
 
		<?php 
    if (!empty($_GET['error'])) {
        ?>
		<div id='message' class='error'>
			<p><?php 
        echo $_GET['error'];
        ?>
</p>
		</div>
		<?php 
    }
    ?>
		<?php 
    if (!empty($_GET['message'])) {
        ?>
		<div id='message' class='updated fade'>
			<p><?php 
        echo $_GET['message'];
        ?>
</p>
		</div>
		<?php 
    }
    ?>
		<form id="posts-filter" action="" method="get"><input type='hidden' name='page' value='events-manager' />
			<ul class="subsubsub">
				<li><a href='#' class="current"><?php 
    _e('Total', 'dbem');
    ?>
 <span class="count">(<?php 
    echo count($events);
    ?>
)</span></a></li>
			</ul>
			<p class="search-box">
				<label class="screen-reader-text" for="post-search-input"><?php 
    _e('Search Events', 'dbem');
    ?>
:</label>
				<input type="text" id="post-search-input" name="em_search" value="<?php 
    echo !empty($_GET['em_search']) ? $_GET['em_search'] : '';
    ?>
" />
				<input type="submit" value="<?php 
    _e('Search Events', 'dbem');
    ?>
" class="button" />
			</p>			
			<div class="tablenav">
			
				<div class="alignleft actions">
					<select name="action">
						<option value="-1" selected="selected"><?php 
    _e('Bulk Actions');
    ?>
</option>
						<option value="deleteEvents"><?php 
    _e('Delete selected', 'dbem');
    ?>
</option>
					</select> 
					<input type="submit" value="<?php 
    _e('Apply');
    ?>
" name="doaction2" id="doaction2" class="button-secondary action" /> 
					<select name="scope">
						<?php 
    foreach ($scope_names as $key => $value) {
        $selected = "";
        if ($key == $scope) {
            $selected = "selected='selected'";
        }
        echo "<option value='{$key}' {$selected}>{$value}</option>  ";
    }
    ?>
					</select> 
					<input id="post-query-submit" class="button-secondary" type="submit" value="<?php 
    _e('Filter');
    ?>
" />
				</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 ($events_count >= $limit) {
        $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno' => '%PAGE%'));
        $events_nav = em_admin_paginate($page_link_template, $events_count, $limit, $page, 5);
        echo $events_nav;
    }
    ?>
				<br class="clear" />
			</div>
				
			<?php 
    if (empty($events)) {
        // TODO localize
        _e('no events', 'dbem');
    } else {
        ?>
					
			<table class="widefat">
				<thead>
					<tr>
						<th class='manage-column column-cb check-column' scope='col'>
							<input class='select-all' type="checkbox" value='1' />
						</th>
						<th><?php 
        _e('Name', 'dbem');
        ?>
</th>
						<th>&nbsp;</th>
						<th><?php 
        _e('Location', 'dbem');
        ?>
</th>
						<th colspan="2"><?php 
        _e('Date and time', 'dbem');
        ?>
</th>
					</tr>
				</thead>
				<tbody>
					<?php 
        $rowno = 0;
        $event_count = 0;
        foreach ($events as $event) {
            /* @var $event EM_Event */
            if (($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0)) {
                $rowno++;
                $class = $rowno % 2 ? ' class="alternate"' : '';
                // FIXME set to american
                $localised_start_date = date_i18n('D d M Y', $event->start);
                $localised_end_date = date_i18n('D d M Y', $event->end);
                $style = "";
                $today = date("Y-m-d");
                $location_summary = "<b>" . $event->location->name . "</b><br/>" . $event->location->address . " - " . $event->location->town;
                $category = new EM_Category($event->category_id);
                if ($event->start_date < $today && $event->end_date < $today) {
                    $style = "style ='background-color: #FADDB7;'";
                }
                ?>
							<tr <?php 
                echo "{$class} {$style}";
                ?>
>
				
								<td>
									<input type='checkbox' class='row-selector' value='<?php 
                echo $event->id;
                ?>
' name='events[]' />
								</td>
								<td>
									<strong>
										<a class="row-title" href="<?php 
                bloginfo('wpurl');
                ?>
/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php 
                echo $event->id;
                ?>
&amp;scope=<?php 
                echo $scope;
                ?>
&amp;p=<?php 
                echo $page;
                ?>
"><?php 
                echo $event->name;
                ?>
</a>
									</strong>
									<?php 
                if (is_object($category)) {
                    ?>
									<br/><span title='<?php 
                    echo __('Category', 'dbem') . ": " . $category->name;
                    ?>
'><?php 
                    echo $category->name;
                    ?>
</span>
									<?php 
                }
                ?>
									<?php 
                if (get_option('dbem_rsvp_enabled') == 1 && $event->rsvp == 1) {
                    ?>
										<br/>
										<a href="<?php 
                    bloginfo('wpurl');
                    ?>
/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=<?php 
                    echo $event->id;
                    ?>
"><?php 
                    echo __("Bookings", 'dbem');
                    ?>
</a> &ndash;
										<?php 
                    _e("Booked", 'dbem');
                    ?>
: <?php 
                    echo $event->get_bookings()->get_booked_seats() . "/" . $event->seats;
                    ?>
										<?php 
                    if (get_option('dbem_bookings_approval') == 1) {
                        ?>
											| <?php 
                        _e("Pending", 'dbem');
                        ?>
: <?php 
                        echo $event->get_bookings()->get_pending_seats();
                        ?>
										<?php 
                    }
                }
                ?>
								</td>
								<td>
									<a href="<?php 
                bloginfo('wpurl');
                ?>
/wp-admin/admin.php?page=events-manager-event&amp;action=duplicate&amp;event_id=<?php 
                echo $event->id;
                ?>
&amp;scope=<?php 
                echo $scope;
                ?>
&amp;p=<?php 
                echo $page;
                ?>
" title="<?php 
                _e('Duplicate this event', 'dbem');
                ?>
">
										<strong>+</strong>
									</a>
								</td>
								<td>
									<?php 
                echo $location_summary;
                ?>
								</td>
						
								<td>
									<?php 
                echo $localised_start_date;
                ?>
									<?php 
                echo $localised_end_date != $localised_start_date ? " - {$localised_end_date}" : '';
                ?>
									<br />
									<?php 
                //TODO Should 00:00 - 00:00 be treated as an all day event?
                echo substr($event->start_time, 0, 5) . " - " . substr($event->end_time, 0, 5);
                ?>
								</td>
								<td>
									<?php 
                if ($event->is_recurrence()) {
                    ?>
										<strong>
										<?php 
                    echo $event->get_recurrence_description();
                    ?>
 <br />
										<a href="<?php 
                    bloginfo('wpurl');
                    ?>
/wp-admin/admin.php?page=events-manager-event&amp;event_id=<?php 
                    echo $event->recurrence_id;
                    ?>
&amp;scope=<?php 
                    echo $scope;
                    ?>
&amp;p=<?php 
                    echo $page;
                    ?>
"><?php 
                    _e('Reschedule', 'dbem');
                    ?>
</a>
										</strong>
										<?php 
                }
                ?>
								</td>
							</tr>
							<?php 
            }
            $event_count++;
        }
        ?>
				</tbody>
			</table>  
			<?php 
    }
    // end of table
    ?>
			<div class='tablenav'>
				<div class="alignleft actions">
				<br class='clear' />
				</div>
				<?php 
    if ($events_count >= $limit) {
        ?>
				<div class="tablenav-pages">
					<?php 
        echo $events_nav;
        ?>
				</div>
				<?php 
    }
    ?>
				<br class='clear' />
			</div>
		</form>
	</div>
	<?php 
}