Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( class_exists('EM_Events') ) { // if EM events is enabled
- /**
- * Adds a page in the settings menu
- */
- function race_overview_menu_page() {
- add_submenu_page( 'edit.php?post_type=event', 'Race Overview', 'Race Overview', 'publish_events', 'race-overview', 'race_overview' );
- }
- add_action( 'admin_menu', 'race_overview_menu_page' );
- /**
- * Content for the settings page
- */
- function race_overview() {
- if ( ! current_user_can( 'publish_events' ) ) {
- wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
- }
- // Display the settings editing screen
- echo '<div class="wrap">';
- echo '<div id="icon-options-general" class="icon32"><br /></div>';
- echo "<h2>Races summary</h2>";
- echo "<p>This shows all events of the current year, sorted by date (best viewed with chrome and sidebar collapsed).</p>";
- $dump = 0;
- $format_header = '
- <table class="eventslist" cellspacing="5" border="0">
- <thead>
- <tr>
- <th class="edit"> </th>
- <th class="eventname">Event</th>
- <th class="status">St.</th>
- <th class="sdate">Start</th>
- <th class="edate">End</th>
- <th class="country">Country</th>
- <th class="event-type">Type</th>
- <th class="bookingsstart">Rego</th>
- <th class="bookings hide">Reg.</th>
- <th class="event-class-open class">OS</th>
- <th class="event-class-women class">WO</th>
- <th class="event-class-juniors class">JR</th>
- <th class="event-class-luge class">LU</th>
- <th class="event-class-masters class">MA</th>
- <th class="event-class-micro-juniors class">MJ</th>
- <th class="spaces">Tot.</th>
- <th class="available">Avail.</th>
- <th class="">% Reg.</th>
- <th class="aantalcl">#</th>
- <th class="note">Note</th>
- <th class="paypal">PP</th>
- <th class="merchant">M.id</th>
- <th class="findhills">FH</th>
- <th class="fbe">FBE</th>
- <th class="fbp">FBP</th>
- <th class="owner">Owner</th>
- <th class=""> </th>
- </tr>
- </thead>
- <tbody>';
- $format_footer = '
- <tr>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- </tbody></table>';
- $event_args = array(
- 'year' => date( 'Y' ),
- 'orderby' => 'event_start_date,event_name',
- 'order' => 'ASC',
- 'posts_per_page' => 99,
- );
- $get_events = EM_Events::get( $event_args );
- if ( $get_events ) {
- if ( $dump == 1 ) {
- foreach ( $get_events as $event ) {
- echo '<pre>'; var_dump( $event ); echo '</pre>';
- }
- } else {
- echo $format_header;
- foreach ( $get_events as $event ) {
- $event_id = $event->post_id;
- $status = get_post_status( $event_id );
- $spaces = $event->event_spaces;
- $bookings = $event->get_bookings()->get_booked_spaces();
- $available = $spaces - $bookings;
- $percentage = false;
- $percentage = ( $bookings / $spaces );
- echo do_shortcode('[event post_id="' . $event_id . '"]
- <tr>
- <td class="edit">#_EVENTEDIT</td>
- <td class="eventname"><a href="#_EVENTURL">#_RACENAMENOYEAR</a></td>
- <td class="status ' . $status . '"> </td>
- <td class="sdate">#M #j</td>
- <td class="edate">#@_{M j}</td>
- <td class="country">{has_location}<a href="#_LOCATIONURL">#_LOCATIONCOUNTRY</a>{/has_location}{no_location}<span class="enter">ADD</span>{/no_location}</td>
- <td class="event-type">{has_category_world-cup}WC{/has_category_world-cup}{has_category_world-qualifying-series}WQS{/has_category_world-qualifying-series}</td>
- <td class="bookingsstart{no_bookings} enter{/no_bookings}">{has_bookings}#_BOOKINGSSTART{/has_bookings}{no_bookings} {/no_bookings}</td>
- <td class="bookings hide">{has_bookings}<a href="/wp/wp-admin/edit.php?post_type=event&page=events-manager-bookings&event_id=#_EVENTID">X</a>{/has_bookings}</td>
- <td class="event-class-open class">{has_tag_skateboard-open}✓{/has_tag_skateboard-open}{no_tag_skateboard-open} {/no_tag_skateboard-open}</td>
- <td class="event-class-women class">{has_tag_skateboard-women}✓{/has_tag_skateboard-women}{no_tag_skateboard-women} {/no_tag_skateboard-women}</td>
- <td class="event-class-juniors class">{has_tag_skateboard-juniors}✓{/has_tag_skateboard-juniors}{no_tag_skateboard-juniors} {/no_tag_skateboard-juniors}</td>
- <td class="event-class-luge class">{has_tag_luge}✓{/has_tag_luge}{no_tag_luge} {/no_tag_luge}</td>
- <td class="event-class-masters class">{has_tag_skateboard-masters}✓{/has_tag_skateboard-masters}{no_tag_skateboard-masters} {/no_tag_skateboard-masters}</td>
- <td class="event-class-micro-juniors class">{has_tag_skateboard-micro-juniors}✓{/has_tag_skateboard-micro-juniors}{no_tag_skateboard-micro-juniors} {/no_tag_skateboard-micro-juniors}</td>
- <td class="spaces">{has_bookings}<a href="/wp/wp-admin/edit.php?post_type=event&page=events-manager-bookings&event_id=#_EVENTID">' . $spaces . '</a>{/has_bookings}{no_bookings}X{/no_bookings}</td>
- <td class="available">{has_bookings}' . $available . '{/has_bookings}</td>
- <td class="">' . number_format( $percentage, 2, ',', '.' ) . ' %</td>
- <td class="aantalcl">#_ATT{Allowed classes}</td>
- <td class="note">{has_notice}<span class="done">X</span>{/has_notice}</td>
- <td class="paypal">{has_paypal}<span class="done">X</span>{/has_paypal}</td>
- <td class="merchant">{has_merchantid}<span class="done">X</span>{/has_merchantid}</td>
- <td class="findhills">{has_findhills}<a href="#_ATT{Findhills}"><span class="done">X</span></a>{/has_findhills}</td>
- <td class="fbe">{has_fbe}<a href="#_ATT{Facebook event}"><span class="done">X</span></a>{/has_fbe}</td>
- <td class="fbp">{has_fbp}<a href="#_ATT{Facebook page}"><span class="done">X</span></a>{/has_fbp}</td>
- <td class="owner">#_CONTACTNAME</td>
- <td class=""> </td>
- </tr>
- [/event]');
- }
- echo $format_footer;
- echo '<div class="legend">';
- echo '<strong>Legend</strong><br />';
- echo '<span class="publish">X</span> Event is published<br />';
- // echo '<span class="draft">X</span> Event is not published yet<br />';
- echo '<span class="pending">X</span> Event is pending review<br />';
- echo '<span class="publish set">X</span> Value is set<br />';
- //echo '<br />';
- echo 'Column rego: registration status (if set). Red means not activated/set yet.<br />';
- echo 'Column #: allowed classes.<br />';
- echo 'Column PP: is Paypal account set<br />';
- echo 'Column M.id: is Paypal Merchant ID set<br />';
- echo 'Column FH: is Findhills set ?<br />';
- echo 'Column FBE: is a Facebook event set ?<br />';
- echo 'Column FBP: is a Facbeook page set ?<br />';
- echo '</div>';
- }
- }
- ?>
- </div><!-- end .wrap -->
- <?php } // end race_overview - content for settings page
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement