diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php index b483c2c6..fd72a78e 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php @@ -28,43 +28,42 @@ class SP_Meta_Box_Event_Performance { else $split_positions = false; + // Determine if we are splitting teams + if ( 'yes' == get_option( 'sportspress_event_split_players_by_team', 'yes' ) ) + $split_teams = true; + else + $split_teams = false; + + // Determine if columns are auto or manual if ( 'manual' == get_option( 'sportspress_event_performance_columns', 'auto' ) ) $manual = true; else $manual = false; - $i = 0; + // Determine if we need checkboxes + if ( $manual && $i == 0 ) + $has_checkboxes = true; + else + $has_checkboxes = false; - foreach ( $teams as $key => $team_id ): - if ( -1 == $team_id ) continue; + // Get positions + $positions = array(); + if ( taxonomy_exists( 'sp_position' ) ): + $args = array( + 'hide_empty' => false, + 'parent' => 0, + 'include_children' => true, + ); + $positions = get_terms( 'sp_position', $args ); + endif; - // Get results for players in the team - $players = sp_array_between( (array)get_post_meta( $post->ID, 'sp_player', false ), 0, $key ); - $players[] = -1; - $data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) ); + // Get status option + if ( 'yes' == get_option( 'sportspress_event_show_status', 'yes' ) ) + $status = true; + else + $status = false; - // Determine if we need checkboxes - if ( $manual && $i == 0 ) - $has_checkboxes = true; - else - $has_checkboxes = false; - - ?> - -
- -

- -
- - -
- - - - ID, $stats, $labels, $columns, $teams, $has_checkboxes, $split_positions, $split_teams, $positions, $status ); } /** @@ -75,77 +74,73 @@ class SP_Meta_Box_Event_Performance { update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) ); } + /** + * Admin edit tables + */ + public static function tables( $post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $split_positions = false, $split_teams = true, $positions = array(), $status = true ) { + $i = 0; + + if ( $split_teams ) { + foreach ( $teams as $key => $team_id ): + if ( -1 == $team_id ) continue; + + // Get results for players in the team + $players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key ); + $players[] = -1; + $data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) ); + ?> +
+ +

+ +
+ + +
+ +
+ + + + + $team_id ): + if ( -1 == $team_id ) continue; + + // Get results for players in the team + $players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key ); + $players[] = -1; + $data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) ); + + foreach ( $data as $player_id => $player_performance ): + self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status, false, false ); + endforeach; + endforeach; + ?> + +
+
+ false, - 'parent' => 0, - 'include_children' => true, - ); - $positions = get_terms( 'sp_position', $args ); - } + public static function table( $labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false, $split_positions = false, $positions = array(), $status = true ) { ?>
- - - - - - - - - $label ): ?> - - - - - - - - - - - - - - - - - - - $label ): - $player_id = 0; - $player_performance = sp_array_value( $data, $player_id, array() ); - $value = sp_array_value( $player_performance, $column, '' ); - ?> - - - - - + + $player_performance ): - self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ) ); + self::row( $labels, $player_id, $player_performance, $team_id, $data, ! empty( $positions ), $status ); endforeach; ?> @@ -154,20 +149,100 @@ class SP_Meta_Box_Event_Performance { + + + + + + + + + + + + + $label ): ?> + + + + + + + + + + + + + + + + + + + + + + + $label ): + $player_id = 0; + $player_performance = sp_array_value( $data, $player_id, array() ); + $value = sp_array_value( $player_performance, $column, '' ); + ?> + + + + + + + + + - - + + + + + + - + - - - + -
+

@@ -113,9 +117,10 @@ $totals = array(); } ?>
- - - + + + + ' . __( 'Total', 'sportspress' ) . ''; - $row = sp_array_value( $data, 0, array() ); + $row = sp_array_value( $data, 1, array() ); if ( $mode == 'icons' ) echo ''; ?> - - + +
 # - - - - - - - - - - - -
   readonly="readonly"value="" /> 
 # + + + + + + + + + +
   readonly="readonly"value="" /> 
- - + + @@ -198,34 +273,12 @@ class SP_Meta_Box_Event_Performance { - 'sp_outcome', - 'name' => 'sp_players[' . $team_id . '][' . $player_id . '][outcome][]', - 'option_none_value' => '', - 'sort_order' => 'ASC', - 'sort_column' => 'menu_order', - 'selected' => $values, - 'class' => 'sp-outcome', - 'property' => 'multiple', - 'chosen' => true, - 'placeholder' => __( 'None', 'sportspress' ), - ); - sp_dropdown_pages( $args ); - ?> -
'; @@ -155,8 +160,8 @@ $totals = array(); if ( $mode == 'icons' ) echo '
diff --git a/templates/event-performance-table.php b/templates/event-performance-table.php index fe08a9e3..4ca85794 100644 --- a/templates/event-performance-table.php +++ b/templates/event-performance-table.php @@ -155,11 +155,11 @@ if ( ! isset( $class ) ) $class = null; ?> - + <>