Advertisement
Beee

#_ATTENDEESLIST

Sep 2nd, 2016
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.56 KB | None | 0 0
  1. <?php
  2. /*
  3.  * template to show rider list with names
  4.  * avatars = attendees.php
  5.  *
  6.  * 0 => Pending
  7.  * 1 => Approved
  8.  * 2 => Rejected
  9.  * 3 => Cancelled
  10.  * 4 => Awaiting Online Payment
  11.  * 5 => Awaiting Payment
  12.  */
  13.  
  14. $EM_Bookings            = $EM_Event->get_bookings();
  15. $confirmed_places       = $EM_Event->get_bookings()->get_booked_spaces();   // confirmed bookings
  16. // $confirmed_places       = 1; // for testing only
  17. $pending_places         = $EM_Event->get_bookings()->get_pending_spaces();  // pending spaces
  18.  
  19. $one_cat_per_ticket     = array(5380,5400);
  20.  
  21. // print_r($EM_Event->event_end_date);
  22. // print_r(date('Y-m-d'));
  23.  
  24. if ( $confirmed_places > 0 ) {
  25.  
  26.     $event_id       = $EM_Bookings->event_id;
  27.     $event_post_id  = $EM_Event->post_id;
  28.     // count available classes
  29.     $allowed        = get_post_meta($event_post_id, 'Allowed classes', true);
  30.     // $allowed = 2; // test to 'fake' 2 or more classes
  31. ?>
  32.     <div class="hide480 notice">Rotate your screen for a better view.</div>
  33.     <h2>Rider list</h2>
  34.     <table class="table--riderslist">
  35.         <thead>
  36.             <tr class="">
  37.                 <th class="attendee-count">&nbsp;</th>
  38.                 <th class="attendee-name">Name</th>
  39.                 <th class="attendee-country xshow568"><span class="hide640">Nat.</span><span class="show640">Nat.</span></th>
  40.                 <th class="attendee-discipline1">Category <?php if ( $allowed > 1 ) { ?>1<?php } ?></th>
  41.                 <?php if ( $allowed == 2 ) { ?>
  42.                 <th class="attendee-discipline2">Category 2</th>
  43.                 <?php }  ?>
  44.             </tr>
  45.         </thead>
  46. <?php
  47.     $guest_bookings         = get_option('dbem_bookings_registration_disable');
  48.     $guest_booking_user     = get_option('dbem_bookings_registration_user');
  49.     $counter                = 0;
  50.     $people                 = array();
  51.     $nationalities_array    = array();
  52.     $categories_array       = array();
  53.     $stylesheet_dir         = get_stylesheet_directory_uri();
  54.  
  55.     // echo '<pre>'; print_r($EM_Bookings); echo '</pre>';
  56.  
  57.     foreach ( $EM_Bookings as $EM_Booking) {
  58.  
  59.         // if ($EM_Booking->booking_status == 1 && !in_array($EM_Booking->get_person()->ID, $people) ) { // if status = approved
  60.         if ( in_array($EM_Booking->booking_status, array(1)) ) { // if status = approved
  61.  
  62.             $member             = $EM_Booking->get_person()->ID;
  63.             $attendees          = $EM_Booking->booking_meta['attendees'];
  64.             $attendees_list     = "";
  65.  
  66.             $rider_name = $EM_Booking->get_person()->get_name();
  67.  
  68.             // if event is past
  69.             if ( $EM_Event->event_end_date > date('Y-m-d') )
  70.             {
  71.                 // change rider name to "Unpaid IDF member" if unpaid membership
  72.                 if ( get_user_field ('s2member_access_role', $member ) == 'subscriber')
  73.                 {
  74.                     $rider_name = '&rarr; Unpaid IDF member';
  75.                 }
  76.             }
  77.  
  78.             $nationality        = get_user_field ('nationality', $member );
  79.             $member_data        = get_userdata($member);
  80.  
  81.             $counter++;
  82.             $attendees_list     .= '<tr>';
  83.             $attendees_list     .= '<td>'.$counter.'.</td>';
  84.             $attendees_list     .= '<td><a href="'.home_url().'/member/'.$member_data->user_nicename.'/">'.$rider_name.'</a></td>';
  85.             $attendees_list     .= '<td class="xshow568">'.$nationality.'</td>';
  86.             $nationalities_array[] = $nationality;
  87.  
  88.             // if ( in_array($event_post_id, $one_cat_per_ticket) ) {
  89.             if ( $allowed != 2 ) { // if allowed classes is less than 2
  90.                 foreach ( $attendees as $key => $value) {
  91.                     foreach ( $value as $key_attendee => $value_attendee) {
  92.                         $attendees_list .= '<td>'.$value_attendee['attendee_categories'].'</td>';
  93.                         $categories_array[] = $value_attendee['attendee_categories'];
  94.                     }
  95.                     // $attendees_list .= "<td>&nbsp;</td>";
  96.                 }
  97.             } else {
  98.                 foreach ( $attendees as $key => $value) { // if multiple categories per ticket are set (checkbox)
  99.                     foreach ( $value as $key_attendee => $value_attendee) {
  100.                         foreach ( $value_attendee['attendee_categories'] as $category ) {
  101.                             $attendees_list .= '<td>'.$category.'</td>';
  102.                             $categories_array[] = $category;
  103.                         }
  104.                         if ( $allowed > 1 && count($value_attendee['attendee_categories']) == 1 ) {
  105.                             $attendees_list .= "<td>&nbsp;</td>"; // if one category is registrated, add an empty table cell to fill cell for category 2
  106.                         }
  107.                     }
  108.                 }
  109.             }
  110.             $counter = $counter;
  111.  
  112.             echo $attendees_list;
  113.             // var_dump($category_array);
  114.  
  115.         }
  116.  
  117.     } // end foreach
  118.  
  119.     // Freeride list Insul 2016
  120.     $freeride = false;
  121.     if ( $EM_Event->post_id == 5436 ) {
  122.         $freeride = array(
  123.             'Christoph Neubrech',
  124.             'Anouschka Hölscher',
  125.             'Tim Louis Schrumpf',
  126.             'Cyrine Allagi',
  127.             'Simon Schneeberger',
  128.             'Marc Hürstel',
  129.             'Malte Kahmann',
  130.             'Michael Exner',
  131.             'Noël Ohletz',
  132.             // 'Julian Stroppel',
  133.             'Matthias Korte',
  134.             'Julian Paries',
  135.             'Jerome Ries',
  136.             'Liesa Seifert',
  137.             'Wietse Morreau',
  138.             'Dina Miss',
  139.             'Alexander Willhöft',
  140.             'Christian Flore',
  141.             // 'Felix Mayerhofer',
  142.             'Janosch Müller',
  143.             'Robin Zeitler',
  144.             'Miguel De Melo',
  145.             'Tom Bauler',
  146.             'Marco Marques',
  147.             // 'Julio Canchon',
  148.             'Cornelius Kaup',
  149.             'Marcus Plate',
  150.             'Maike Westerich',
  151.             'Reuben Helfenbaum',
  152.             'Michael Kürschner',
  153.             'Jorge Kalau von Hofe',
  154.             // 'Daniel Theis-Heinrich',
  155.             'Felix Laux',
  156.             'Dominique Kohn',
  157.             'Happe Linus',
  158.             // 'Marvin Lorff',
  159.             'Matthias Kirschner',
  160.             'Noah Mayer',
  161.             'Milan Pierau',
  162.             'Clemens Richter',
  163.             // 'Gunnar Peitz',
  164.             'Markus Schuttler',
  165.             // 'Olivier Detry',
  166.             // 'Sebastian Raszke',
  167.             'Andreas Rau',
  168.             'Alessandro Pupillo',
  169.             'Georg Emmerich',
  170.             'Jette Schönefeld',
  171.             'Niklas Szczepaniak',
  172.             // 'Robert Leer',
  173.             'Max Deutsch',
  174.             'Leandro Cordon',
  175.             'Uwe Dederer',
  176.             // 'Janik Loerges',
  177.             'Richie Mac Dermott',
  178.             'Markus Strahlhofer',
  179.             // 'Leon Kürschner',
  180.         );
  181.         if ( $freeride ) {
  182.             $freeride_count = count($freeride);
  183.  
  184.             $freeride_list = '';
  185.             foreach($freeride as $freerider) {
  186.                 $counter++;
  187.                 $freeride_list .= '<tr>';
  188.                     $freeride_list .= '<td>'.$counter.'.</td>';
  189.                     $freeride_list .= '<td>'.$freerider.'</td>';
  190.                     $freeride_list .= '<td>n/a</td>';
  191.                     $freeride_list .= '<td>Freeride</td>';
  192.                 $freeride_list .= '</tr>';
  193.             }
  194.             echo $freeride_list;
  195.         }
  196.     }
  197.  
  198.     echo "\n";
  199. ?>
  200.     </table>
  201. <?php
  202.     asort($nationalities_array);
  203.     // echo '<pre>'; print_r($nationalities_array); echo '</pre>';
  204.  
  205.     $nationality_count = count(array_count_values($nationalities_array));
  206.     if ($nationality_count > 1 ) {
  207.         echo '<div class="riderslist-summary">';
  208.             echo '<h3>Riders p/nationality</h3>';
  209.             $all_nationalities = array_count_values($nationalities_array);
  210.             arsort($all_nationalities);
  211.             echo '<ul>';
  212.             foreach ( $all_nationalities as $nationality => $count ) {
  213.                 echo '<li>';
  214.                     echo '<span class="land"><img src="'.$stylesheet_dir.'/assets/images/flags/'.strtolower($nationality).'.png" class="flag" alt="" /> '.$nationality.'</span> - ';
  215.                     echo '<span class="count">'.$count.'</span>';
  216.                 echo '</li>';
  217.             }
  218.             echo '</ul>';
  219.         echo '</div>';
  220.     }
  221.  
  222.     asort($categories_array);
  223.     $category_count = count(array_count_values($categories_array));
  224.  
  225.     if ($category_count > 1 ) {
  226.         echo '<div class="riderslist-summary">';
  227.             echo '<h3>Riders p/category</h3>';
  228.             $all_categories = array_count_values($categories_array);
  229.             arsort($all_categories);
  230.             echo '<ul>';
  231.             foreach ( $all_categories as $category => $count ) {
  232.                 echo '<li>';
  233.                     echo $category.' - ';
  234.                     echo '<span class="count">'.$count.'</span>';
  235.                 echo '</li>';
  236.             }
  237.             if ( $freeride ) {
  238.                 echo '<li>Freeride - '. $freeride_count .'</li>';
  239.             }
  240.  
  241.             echo '</ul>';
  242.         echo '</div>';
  243.     }
  244.  
  245.     if ($nationality_count > 1 ) {
  246.         echo '<p>There are riders from '.$nationality_count.' different nationalities attending this ';
  247.         if ( $EM_Event->post_id == 5436 ) { echo 'race'; } else { echo 'event'; }
  248.         echo '.</p>';
  249.  
  250.     }
  251.  
  252. } // if confirmed places > 0
  253.  
  254. if ( count($EM_Bookings->bookings) == 0 ) {
  255.     echo '<p>No one registered yet... Will you be the first ?</p>';
  256. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement