diff --git a/assets/css/admin.css b/assets/css/admin.css
index df5e6e22..b0b29558 100644
--- a/assets/css/admin.css
+++ b/assets/css/admin.css
@@ -146,6 +146,7 @@
}
.sp-data-table-container {
+ clear: both;
overflow: auto;
}
diff --git a/assets/js/admin/sportspress-admin.js b/assets/js/admin/sportspress-admin.js
index 7883a71b..efa67d3d 100644
--- a/assets/js/admin/sportspress-admin.js
+++ b/assets/js/admin/sportspress-admin.js
@@ -145,6 +145,7 @@ jQuery(document).ready(function($){
placeholder = parseFloat($el.attr("data-placeholder"));
current_adjustment = parseFloat($el.attr("data-adjustment"));
adjustment = parseFloat($(this).val());
+ if(isNaN(placeholder)) placeholder = 0;
if(isNaN(current_adjustment)) current_adjustment = 0;
if(isNaN(adjustment)) adjustment = 0;
placeholder += adjustment - current_adjustment;
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php
index d6c1a084..c549ca0f 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-data.php
@@ -21,7 +21,7 @@ class SP_Meta_Box_List_Data {
public static function output( $post ) {
$list = new SP_Player_List( $post );
list( $columns, $usecolumns, $data, $placeholders, $merged ) = $list->data( true );
- $adjustments = get_post_meta( $post->ID, 'sp_adjustments', true );
+ $adjustments = $list->adjustments;
self::table( $columns, $usecolumns, $data, $placeholders, $adjustments );
}
@@ -37,11 +37,15 @@ class SP_Meta_Box_List_Data {
/**
* Admin edit table
*/
- public static function table( $columns = array(), $usecolumns = null, $data = array(), $placeholders = array() ) {
+ public static function table( $columns = array(), $usecolumns = null, $data = array(), $placeholders = array(), $adjustments = array() ) {
if ( is_array( $usecolumns ) )
$usecolumns = array_filter( $usecolumns );
?>
-
+
+
@@ -55,6 +59,66 @@ class SP_Meta_Box_List_Data {
+
+ 0 ):
+ $i = 0;
+ foreach ( $data as $player_id => $player_stats ):
+ if ( !$player_id ) continue;
+ $div = get_term( $player_id, 'sp_season' );
+ $number = get_post_meta( $player_id, 'sp_number', true );
+
+ $default_name = sp_array_value( $player_stats, 'name', '' );
+ if ( $default_name == null )
+ $default_name = get_the_title( $player_id );
+ ?>
+
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+ $label ):
+ $value = sp_array_value( $player_stats, $column, '' );
+ $placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
+ ?>
+ |
+
+
+
+
+ |
+
+ |
+
+
+
+
+
+
+
+
+
+ | # |
+ |
+ $label ): ?>
+ |
+
+
+
0 ):
@@ -70,10 +134,9 @@ class SP_Meta_Box_List_Data {
$label ):
- $value = sp_array_value( $player_stats, $column, '' );
- $placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
+ $value = sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $column, '' );
?>
- |
+ |
ID );
// Add equation to object
- $stat->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, 0 );
+ $stat->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, null );
$stat->precision = sp_array_value( sp_array_value( $meta, 'sp_precision', array() ), 0, 0 );
// Add column name to columns
@@ -253,11 +253,18 @@ class SP_League_Table extends SP_Custom_Post{
foreach ( $stats as $stat ):
if ( sp_array_value( $placeholders[ $team_id ], $stat->post_name, '' ) == '' ):
- // Solve
- $placeholder = sp_solve( $stat->equation, sp_array_value( $totals, $team_id, array() ), $stat->precision );
+ if ( $stat->equation == null ):
+ $placeholder += sp_array_value( sp_array_value( $adjustments, $team_id, array() ), $stat->post_name, null );
+ if ( $placeholder == null ):
+ $placeholder = '-';
+ endif;
+ else:
+ // Solve
+ $placeholder = sp_solve( $stat->equation, sp_array_value( $totals, $team_id, array() ), $stat->precision );
- // Adjustments
- $placeholder += sp_array_value( sp_array_value( $adjustments, $team_id, array() ), $stat->post_name, 0 );
+ // Adjustments
+ $placeholder += sp_array_value( sp_array_value( $adjustments, $team_id, array() ), $stat->post_name, 0 );
+ endif;
$placeholders[ $team_id ][ $stat->post_name ] = $placeholder;
endif;
diff --git a/includes/class-sp-player-list.php b/includes/class-sp-player-list.php
index f5aa0731..2c1a6baa 100644
--- a/includes/class-sp-player-list.php
+++ b/includes/class-sp-player-list.php
@@ -83,6 +83,11 @@ class SP_Player_List extends SP_Custom_Post {
// Get metrics
$metrics = get_post_meta( $player_id, 'sp_metrics', true );
+ foreach ( $metrics as $key => $value ):
+ $adjustment = sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $key, null );
+ if ( $adjustment != null )
+ $metrics[ $key ] += $adjustment;
+ endforeach;
// Get static stats
$static = get_post_meta( $player_id, 'sp_statistics', true );
@@ -255,7 +260,10 @@ class SP_Player_List extends SP_Custom_Post {
if ( sp_array_value( $placeholders[ $player_id ], $stat->post_name, '' ) == '' ):
if ( $stat->equation == null ):
- $placeholder = '-';
+ $placeholder = sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $stat->post_name, null );
+ if ( $placeholder == null ):
+ $placeholder = '-';
+ endif;
else:
// Solve
$placeholder = sp_solve( $stat->equation, sp_array_value( $totals, $player_id, array() ), $stat->precision );