Add full time minutes to events

This commit is contained in:
Brian Miyaji
2014-08-25 00:20:27 +10:00
parent 8320a9f85c
commit d6f185b4fd
6 changed files with 61 additions and 31 deletions

View File

@@ -68,7 +68,7 @@ class SP_League_Table extends SP_Custom_Post{
endforeach;
// Initialize team totals
$totals[ $team_id ] = array( 'eventsplayed' => 0, 'streak' => 0 );
$totals[ $team_id ] = array( 'eventsplayed' => 0, 'eventminutes' => 0, 'streak' => 0 );
foreach ( $result_labels as $key => $value ):
$totals[ $team_id ][ $key . 'for' ] = 0;
@@ -120,6 +120,8 @@ class SP_League_Table extends SP_Custom_Post{
foreach ( $events as $event ):
$results = (array)get_post_meta( $event->ID, 'sp_results', true );
$minutes = get_post_meta( $event->ID, 'sp_minutes', true );
if ( $minutes === '' ) $minutes = get_option( 'sportspress_event_minutes', 90 );
foreach ( $results as $team_id => $team_result ):
@@ -138,8 +140,9 @@ class SP_League_Table extends SP_Custom_Post{
// Increment events played and outcome count
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $outcome, $totals[ $team_id ] ) ):
$totals[ $team_id ]['eventsplayed']++;
$totals[ $team_id ][ $outcome ]++;
$totals[ $team_id ]['eventsplayed'] ++;
$totals[ $team_id ]['eventminutes'] += $minutes;
$totals[ $team_id ][ $outcome ] ++;
endif;
if ( $outcome && $outcome != '-1' ):