Display staff in event performance section
This commit is contained in:
@@ -23,22 +23,53 @@ class SP_Event extends SP_Custom_Post{
|
||||
return $post_status;
|
||||
}
|
||||
|
||||
public function performance() {
|
||||
public function results( $admin = false ) {
|
||||
$teams = (array)get_post_meta( $this->ID, 'sp_team', false );
|
||||
$results = (array)get_post_meta( $this->ID, 'sp_results', true );
|
||||
|
||||
// Get columns from result variables
|
||||
$columns = sp_get_var_labels( 'sp_result' );
|
||||
|
||||
// Get result columns to display
|
||||
$usecolumns = get_post_meta( $this->ID, 'sp_result_columns', true );
|
||||
|
||||
// Get results for all teams
|
||||
$data = sp_array_combine( $teams, $results );
|
||||
|
||||
if ( $admin ):
|
||||
return array( $columns, $usecolumns, $data );
|
||||
else:
|
||||
// Add outcome to result columns
|
||||
$columns['outcome'] = __( 'Outcome', 'sportspress' );
|
||||
if ( ! is_array( $usecolumns ) )
|
||||
$usecolumns = array();
|
||||
foreach ( $columns as $key => $label ):
|
||||
if ( ! in_array( $key, $usecolumns ) ):
|
||||
unset( $columns[ $key ] );
|
||||
endif;
|
||||
endforeach;
|
||||
$data[0] = $columns;
|
||||
return $data;
|
||||
endif;
|
||||
}
|
||||
|
||||
public function performance( $admin = false ) {
|
||||
$teams = (array)get_post_meta( $this->ID, 'sp_team', false );
|
||||
$performance = (array)get_post_meta( $this->ID, 'sp_players', true );
|
||||
$performance_labels = sp_get_var_labels( 'sp_performance' );
|
||||
$labels = sp_get_var_labels( 'sp_performance' );
|
||||
$columns = get_post_meta( $this->ID, 'sp_columns', true );
|
||||
$output = array();
|
||||
foreach( $teams as $i => $team_id ):
|
||||
$players = sp_array_between( (array)get_post_meta( $this->ID, 'sp_player', false ), 0, $i );
|
||||
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
|
||||
|
||||
$totals = array();
|
||||
foreach( $performance_labels as $key => $label ):
|
||||
foreach( $labels as $key => $label ):
|
||||
$totals[ $key ] = 0;
|
||||
endforeach;
|
||||
|
||||
foreach( $data as $player_id => $player_performance ):
|
||||
foreach( $performance_labels as $key => $label ):
|
||||
foreach( $labels as $key => $label ):
|
||||
if ( array_key_exists( $key, $totals ) ):
|
||||
$totals[ $key ] += sp_array_value( $player_performance, $key, 0 );
|
||||
endif;
|
||||
@@ -74,7 +105,21 @@ class SP_Event extends SP_Custom_Post{
|
||||
);
|
||||
endforeach;
|
||||
|
||||
return $output;
|
||||
if ( $admin ):
|
||||
return array( $labels, $columns, $performance, $teams );
|
||||
else:
|
||||
// Add status to performance labels
|
||||
$labels['status'] = __( 'Status', 'sportspress' );
|
||||
if ( ! is_array( $columns ) )
|
||||
$columns = array();
|
||||
foreach ( $labels as $key => $label ):
|
||||
if ( ! in_array( $key, $columns ) ):
|
||||
unset( $labels[ $key ] );
|
||||
endif;
|
||||
endforeach;
|
||||
$performance[0] = $labels;
|
||||
return $performance;
|
||||
endif;
|
||||
}
|
||||
|
||||
public function lineup_filter( $v ) {
|
||||
|
||||
Reference in New Issue
Block a user