Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php acf_form_head(); ?>
- <?php get_header(); ?>
- <?php
- function my_acf_load_value( $value, $post_id, $field ) { // ORDER BY ASSESSMENT DATE
- // vars
- $order = array();
- // bail early if no value
- if( empty($value) ) {
- return $value;
- }
- // populate order
- foreach( $value as $i => $row ) {
- $order[ $i ] = $row['field_5753d72618569'];
- }
- // multisort
- array_multisort( $order, SORT_ASC, $value );
- // return
- return $value;
- }
- add_filter('acf/load_value/name=assessments', 'my_acf_load_value', 10, 3);
- ?>
- <div id="placeholder"></div>
- <div id="legend"></div>
- <div class="wrap">
- <h1 class="main-header">Booking Matrix</h1>
- <?php global $bp; //Gobal BuddyPress?>
- <div id="filtrify" class="filtrify">
- <?php
- global $wpdb, $current_user, $EM_Notices, $EM_Person;
- $people = array();
- $events = EM_Events::get(array('scope'=>'all','order'=>'DESC','orderby'=>'event_end_date,event_end_time'));
- $pass = array(2,3,4,5); // Check if assessment passed
- //echo '<pre>' . var_export($events, true) . '</pre>';
- $args = array(
- 'role' => 'technician',
- 'numberposts' => -1,
- 'order' => 'DESC',
- 'orderby' => 'meta_value',
- 'meta_key' => 'assessment_date',
- );
- $techs = new WP_User_Query( $args );
- foreach($techs->results as $tech) :
- setup_postdata( $post );
- endforeach;
- foreach($events as $event ) :
- setup_postdata( $post );
- endforeach;
- $previous_course_date = "";
- foreach ( $events as $event ) {
- $EM_Bookings = $event->get_bookings();
- $current_course_date = $event->event_start_date;
- if (($current_course_date != $previous_course_date) && (count($EM_Bookings->bookings) > 0)) { ?>
- <h5 class="adf-header"><strong><?php echo date("d M Y",strtotime($event->event_start_date)) . " - " . date("d M Y",strtotime($event->event_end_date)); ?></strong>
- <?php
- $approved = 0;
- $pending = 0;
- foreach($EM_Bookings->bookings as $book) { // Check if transaction exists
- if(($book->previous_status) == 1) {
- $approved = $approved + 1;
- } elseif(($book->previous_status) != 1) {
- $pending = $pending + 1;
- };
- };
- /* echo highlight_string("<?php\n\$book =\n" . var_export($book, true) . ";\n?>") ; */
- echo "<span class=\"booking-stats\">";
- echo $approved . " <i class=\"fa fa-thumbs-o-up\" aria-hidden=\"true\"></i> | " . $pending . " <i class=\"fa fa-thumbs-o-down\" aria-hidden=\"true\"></i>";
- echo "</span>";
- ?></h5>
- <table class="booking-matrix">
- <tr class="table-header">
- <td>Name</td>
- <td>Email</td>
- <td>Contact</td>
- <td>Status</td>
- <td>Notes</td>
- <td class="icons"><a href="<?php echo site_url(); ?>/wp-admin/edit.php?post_type=event&page=events-manager-bookings&event_id=<?php echo $event->event_id; ?>&action=manual_booking" target="_blank"><i class="fa fa-plus-square" aria-hidden="true"></i></a> <a href="<?php echo site_url(); ?>/wp-admin/post.php?post=<?php echo $event->post_id; ?>&action=edit" target="_blank"><i class="fa fa-pencil-square" aria-hidden="true"></i></a> <a href="<?php echo site_url(); ?>/wp-admin/edit.php?post_type=event&page=events-manager-bookings&event_id=<?php echo $event->event_id; ?>" target="_blank"><i class="fa fa-eye" aria-hidden="true"></i></a></td>
- </tr>
- <?php
- $guest_bookings = get_option('dbem_bookings_registration_disable');
- $guest_booking_user = get_option('dbem_bookings_registration_user');
- foreach( $EM_Bookings as $EM_Booking){
- $people[] = $EM_Booking->get_person()->ID;
- $person = $EM_Booking->get_person()->ID;
- $user_info = get_userdata($person); //Default WP data
- $user = 'user_' . $person; // Dispayed User ID
- $b_status = $EM_Booking->booking_meta['gateway']; //transaction status
- // Current Level
- if(get_field('assessments',$user)):
- $assessments_repeater = array_reverse(get_field('assessments',$user)); // Assessments Repeater
- $ass_latest = end($assessments_repeater); // Last row of repeater
- $ass_latest_rating = $ass_latest['ass_rating']; // Rating
- $ass_at = $ass_latest['assessed_at']; // Assessed at
- $latest_doc_dispatch = $ass_latest['docs_dispatched'];
- // $current_level = get_field('current_level',$user); // Current level
- $current_level = "N/A"; // Check if assessment
- $pass = array("2","3","4","5");
- foreach($assessments_repeater as $ass) {
- if (in_array($ass["ass_rating"], $pass)) {
- $ass_at = $ass["assessed_at"];
- $current_level = $ass_at;
- break;
- } else {
- $current_level = "N/A";
- }
- }
- endif; // Current Level
- ?>
- <?php if(1 == 1): // Check transaction status ?>
- <tr>
- <td><a class="pop details-<?php echo $person ?>"><?php echo $EM_Booking->get_person()->get_name(); ?></a></td>
- <td><?php echo $user_info->user_email; ?></td>
- <td><?php echo the_field('contact_number', $user); ?></td>
- <td><?php if($EM_Booking->previous_status == 1) {
- echo "Paid";
- } else {
- echo "Awaiting Payment";
- }; ?></td>
- <form id="all-bookings" class="acf-form" action="" method="post">
- <?php
- add_action( 'wp_print_styles', 'tsm_deregister_admin_styles', 999 );
- /**
- * Add edit post toggle button
- */
- add_action( 'loop_start', 'tsm_do_acf_form_edit_toggle', 5 );
- /**
- * Add the acf_form
- * @uses Advanced Custom Fields Pro
- */
- add_action( 'loop_end', 'tsm_do_acf_form_content' );
- /**
- * Load existing post title
- * @uses Advanced Custom Fields Pro
- */
- add_filter( 'acf/load_value/key=field_54dfc93e35ec4', 'tsm_load_post_title', 10, 3 );
- /**
- * Load existing post content
- * @uses Advanced Custom Fields Pro
- */
- add_filter( 'acf/load_value/key=field_54dfc94e35ec5', 'tsm_load_post_content', 10, 3 );
- /**
- * Load existing email
- * @uses Advanced Custom Fields Pro
- */
- add_filter( 'acf/load_value/key=field_54dfc94e35ec5', 'tsm_load_post_content', 10, 3 );
- /**
- * Load existing post thumbnail
- * @uses Advanced Custom Fields Pro
- */
- add_filter( 'acf/load_value/key=field_54dfcd4278d63', 'tsm_load_post_thumbnail', 10, 3 );
- /**
- * Load existing post author
- * @uses Advanced Custom Fields Pro
- */
- add_filter( 'acf/load_value/key=field_55fd4e421dfb6', 'tsm_load_post_author', 10, 3 );
- /**
- * Update existing post data
- * @uses Advanced Custom Fields Pro
- */
- add_action( 'acf/save_post', 'tsm_update_existing_post_data', 10 );
- // acf/update_value/name={$field_name} - filter for a specific field based on it's key
- ?>
- <?php
- $edit_post = array(
- 'id' => 'all-bookings',
- 'post_id' => $user, // Get the post ID
- 'field_groups' => array(10), // Create post field group ID(s)
- 'field_el' => 'td',
- 'fields' => array(
- 'field_584fe30107cd9', //Notes
- ),
- 'form' => false,
- 'return' => add_query_arg( 'details', 'updated', get_permalink() ),
- 'html_before_fields' => '',
- 'submit_value' => "Save",
- );
- //load acf_form based on POST TYPES
- acf_form( $edit_post );
- ?>
- <td class="acf-form-submit">
- <input type="submit" class="acf-button button button-primary button-large" value="Update">
- <span class="acf-spinner"></span>
- </td>
- </tr>
- </form>
- <div
- data-Assessment-Date="<?php echo date("d F Y",strtotime(get_field('assessment_date', $user)))?>"
- <?php if(get_field('assessments',$user)){ ?>
- data-Level="Level <?php echo $current_level; ?>"
- <?php } ?>
- data-Referral-Code="<?php echo "Code:" . do_shortcode('[affiliates_affiliate_id_by_user id="' . $person . '" /]') ?>"
- data-Name="<?php echo $EM_Booking->get_person()->get_name() ?>"
- >
- <!-- PopUp container -->
- <div class="popup details-container-<?php echo $person;?>">
- <h5><?php echo $EM_Booking->get_person()->get_name(); ?></h5>
- <!-- Profile Picture -->
- <div class="pop-inner details-<?php echo $person;?>">
- <a href="<?php echo bp_core_get_user_domain( $person );?>profile" target="_blank" class="view-profile-link">
- <?php echo bp_core_fetch_avatar ( array( 'item_id' => $person, 'type' => 'full', 'style' => 'margin: 0; border: 1px solid #ccc; padding: 3px; border-radius: 5px padding: 3px; height: 150px' ) ); ?>
- </a>
- </div>
- <!-- Personal Details -->
- <h6>Personal Details</h6>
- <div class="icon phone"><i class="fa fa-phone" aria-hidden="true"></i> <?php echo get_field('contact_number', $user); ?></div>
- <div class="icon email"><i class="fa fa-envelope" aria-hidden="true"></i> <?php echo $user_info->user_email; ?></div>
- <!-- IRATA Details -->
- <h6>IRATA Details</h6>
- <div class="icon irata-number"><i class="fa fa-user" aria-hidden="true"></i> <?php echo get_field('irata_number', $user); ?></div>
- <?php if(get_field('assessments',$user)){ ?>
- <div class="icon level"><i class="fa fa-trophy" aria-hidden="true"></i> <?php echo $current_level;?></div>
- <?php } ?>
- <?php if( have_rows('assessments', $user)): ?>
- <?php while( have_rows('assessments', $user)): the_row();
- endwhile;
- $dates = get_field('assessments', $user);
- $latest_date = array_shift($dates);
- $date_ass_before = $latest_date['ass_date'];
- $date_ass = str_replace('/', '-', $date_ass_before); // strtotime doesn't work with /d/m/y format
- $now = time();
- $exp_date = strtotime('+3 year', strtotime($date_ass));
- $exp_date_new = strtotime('-1 day', $exp_date);
- $datediff = $exp_date_new - $now;
- $remaining = floor($datediff/(60*60*24));
- ?>
- <div class="icon expiration">
- <i class="fa fa-clock-o" aria-hidden="true"></i> <?php echo $remaining . " days left (" . date('d F Y', $exp_date_new) . ")"; ?>
- </div>
- <?php endif;?>
- <!-- Address -->
- <h6>Address:</h6>
- <?php
- if(get_field('address_line_1', $user)){
- echo get_field('address_line_1', $user);
- echo "<br/>";
- }
- if(get_field('address_line_2', $user)){
- echo get_field('address_line_2', $user);
- echo "<br/>";
- }
- if(get_field('address_line_3', $user)){
- echo get_field('address_line_3', $user);
- echo "<br/>";
- }
- if(get_field('city', $user)){
- echo get_field('city', $user);
- echo "<br/>";
- }
- if(get_field('state-province', $user)){
- echo get_field('state-province', $user);
- echo "<br/>";
- }
- if(get_field('country', $user)){
- echo get_field('country', $user);
- echo "<br/>";
- }
- if(get_field('post_code', $user)){
- echo get_field('post_code', $user);
- } ?>
- </div> <!-- PopUp Container -->
- </div> <!-- tech -->
- <?php endif; //booking status check ?>
- <?php
- // }elseif($EM_Booking->booking_status == 1 && $guest_bookings && $EM_Booking->get_person()->ID == $guest_booking_user ){
- // echo '<li>'. $EM_Booking->get_person()->get_name() .'</li>';
- // }
- }
- ?>
- </table>
- <?php
- }
- }
- wp_reset_postdata();
- ?>
- </div>
- </div>
- <script>
- jQuery(document).ready(function(){
- jQuery.filtrify("filtrify", "placeholder", {
- close : true,
- callback : function( query, match, mismatch ) {
- if ( !mismatch.length ) {
- jQuery("h1").removeClass('filtered').html("Technicians");
- jQuery('.tech').removeClass('tech-view');
- } else {
- jQuery('.tech').addClass('tech-view');
- var category, tags, i, tag, legend = "<strong>Currently filtered by:</strong><br/>";
- for ( category in query ) {
- tags = query[category];
- if ( tags.length ) {
- legend += "";
- for ( i = 0; i < tags.length; i++ ) {
- tag = tags[i];
- legend += "<br/>" + tag ;
- };
- legend += "";
- };
- };
- jQuery("h1").addClass('filtered').html( legend );
- };
- }
- });
- });
- </script>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement