public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     foreach ($this->performance_data as $performance) {
         $current_value = $performance["wickets"];
         if ($current_value != $last_value) {
             $pos = $i;
             $last_value = $current_value;
         } else {
             $pos = "=";
         }
         $i++;
         $fields = array();
         $position = new XhtmlCell(false, $pos);
         $position->SetCssClass("position");
         $fields[] = $position;
         $bowler = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["bowler_url"] . '">' . $performance["bowler_name"] . "</a>");
         $bowler->SetCssClass("player");
         $bowler->AddAttribute("typeof", "schema:Person");
         $bowler->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $performance["bowler_url"]);
         $fields[] = $bowler;
         $catcher = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["catcher_url"] . '">' . $performance["catcher_name"] . "</a>");
         $catcher->SetCssClass("player");
         $catcher->AddAttribute("typeof", "schema:Person");
         $catcher->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $performance["catcher_url"]);
         $fields[] = $catcher;
         $team = new XhtmlCell(false, $performance["team_name"]);
         $team->SetCssClass("team");
         $fields[] = $team;
         $matches = new XhtmlCell(false, $performance["total_matches"]);
         $matches->SetCssClass("numeric");
         $fields[] = $matches;
         $wickets = new XhtmlCell(false, $performance["wickets"]);
         $wickets->SetCssClass("numeric");
         $fields[] = $wickets;
         $row = new XhtmlRow($fields);
         $this->AddRow($row);
     }
     parent::OnPreRender();
 }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     foreach ($this->bowling_data as $bowling) {
         $current_value = $bowling["wickets"] . "/" . $bowling["runs_conceded"];
         if ($current_value != $last_value) {
             # If 11th value is not same as 10th, stop. This can happen because DB query sees selects all performances with the same number of wickets as the tenth.
             if (!is_null($this->max_results) and $i > $this->max_results) {
                 break;
             }
             $pos = $i;
             $last_value = $current_value;
         } else {
             $pos = "=";
         }
         $i++;
         $position = new XhtmlCell(false, $pos);
         $position->SetCssClass("position");
         $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $bowling["player_url"] . '">' . $bowling["player_name"] . "</a>");
         $player->SetCssClass("player");
         $player->AddAttribute("typeof", "schema:Person");
         $player->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $bowling["player_url"]);
         if ($this->display_team) {
             $team = new XhtmlCell(false, $bowling["team_name"]);
             $team->SetCssClass("team");
         }
         $opposition = new XhtmlCell(false, $bowling["opposition_name"]);
         $opposition->SetCssClass("team");
         $date = new XhtmlCell(false, Date::BritishDate($bowling["match_time"], false, true, $this->display_team));
         $date->SetCssClass("date");
         $wickets = new XhtmlCell(false, $bowling["wickets"]);
         $wickets->SetCssClass("numeric");
         $runs = new XhtmlCell(false, $bowling["runs_conceded"]);
         $runs->SetCssClass("numeric");
         if ($this->display_team) {
             $row = new XhtmlRow(array($position, $player, $team, $opposition, $date, $wickets, $runs));
         } else {
             $row = new XhtmlRow(array($position, $player, $opposition, $date, $wickets, $runs));
         }
         $this->AddRow($row);
     }
     parent::OnPreRender();
 }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     foreach ($this->batting_data as $batting) {
         $current_value = $batting["runs_scored"];
         $not_out = ($batting["how_out"] == Batting::NOT_OUT or $batting["how_out"] == Batting::RETIRED or $batting["how_out"] == Batting::RETIRED_HURT);
         if ($not_out) {
             $current_value .= "*";
         }
         if ($current_value != $last_value) {
             # If 11th value is not same as 10th, stop. This can happen because DB query sees 40* and 40 as equal, but they're not.
             if (!is_null($this->max_results) and $i > $this->max_results) {
                 break;
             }
             $pos = $i;
             $last_value = $current_value;
         } else {
             $pos = "=";
         }
         $i++;
         $position = new XhtmlCell(false, $pos);
         $position->SetCssClass("position");
         $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $batting["player_url"] . '">' . $batting["player_name"] . "</a>");
         $player->SetCssClass("player");
         $player->AddAttribute("typeof", "schema:Person");
         $player->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $batting["player_url"]);
         if ($this->display_team) {
             $team = new XhtmlCell(false, $batting["team_name"]);
             $team->SetCssClass("team");
         }
         $opposition = new XhtmlCell(false, $batting["opposition_name"]);
         $opposition->SetCssClass("team");
         $date = new XhtmlCell(false, Date::BritishDate($batting["match_time"], false, true, $this->display_team));
         $date->SetCssClass("date");
         $runs = new XhtmlCell(false, $current_value);
         $runs->SetCssClass("numeric");
         if (!$not_out) {
             $runs->AddCssClass("out");
         }
         $balls_faced = is_null($batting["balls_faced"]) ? "&#8211;" : '<span class="balls-faced">' . $batting["balls_faced"] . '</span>';
         $balls = new XhtmlCell(false, $balls_faced);
         $balls->SetCssClass("numeric");
         if ($this->display_team) {
             $row = new XhtmlRow(array($position, $player, $team, $opposition, $date, $runs, $balls));
         } else {
             $row = new XhtmlRow(array($position, $player, $opposition, $date, $runs, $balls));
         }
         $this->AddRow($row);
     }
     parent::OnPreRender();
 }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     if (is_array($this->data)) {
         foreach ($this->data as $performance) {
             $current_value = $performance["statistic"];
             if ($current_value !== $last_value) {
                 $pos = $i;
                 $last_value = $current_value;
             } else {
                 $pos = "=";
             }
             $i++;
             $fields = array();
             $position = new XhtmlCell(false, $pos);
             $position->SetCssClass("position");
             $fields[] = $position;
             $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["player_url"] . '">' . $performance["player_name"] . "</a>");
             $player->SetCssClass("player");
             $player->AddAttribute("typeof", "schema:Person");
             $player->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $performance["player_url"]);
             $fields[] = $player;
             if ($this->display_team) {
                 $team = new XhtmlCell(false, $performance["team_name"]);
                 $team->SetCssClass("team");
                 $fields[] = $team;
             }
             if (array_key_exists("total_matches", $performance)) {
                 $matches = new XhtmlCell(false, $performance["total_matches"]);
                 $matches->SetCssClass("numeric");
                 $fields[] = $matches;
             }
             $aggregate = new XhtmlCell(false, $current_value);
             $aggregate->SetCssClass("numeric");
             $fields[] = $aggregate;
             $row = new XhtmlRow($fields);
             $this->AddRow($row);
         }
     }
     parent::OnPreRender();
 }
 /**
  * Creates a bowling scorecard for one innings with as much data as is available
  * @param Match $match
  * @param bool $is_home_innings
  * @return void
  */
 private function CreateBowlingCard(Match $match, $is_home_innings)
 {
     $overs_data = $is_home_innings ? $match->Result()->AwayOvers() : $match->Result()->HomeOvers();
     $bowling_data = $is_home_innings ? $match->Result()->AwayBowling() : $match->Result()->HomeBowling();
     $bowling_team = $is_home_innings ? $match->GetAwayTeam() : $match->GetHomeTeam();
     # First, bowler's figures
     if ($bowling_data->GetCount()) {
         $bowling_table = new XhtmlTable();
         $bowling_table->SetCaption(htmlentities($bowling_team->GetName() . "'s bowlers", ENT_QUOTES, "UTF-8", false));
         $bowling_table->SetCssClass("bowling scorecard");
         $over_header = new XhtmlCell(true, '<abbr title="Overs" class="small">Ov</abbr><span class="large">Overs</span>');
         $over_header->SetCssClass("numeric");
         $maidens_header = new XhtmlCell(true, '<abbr title="Maiden overs" class="small">Md</abbr><abbr title="Maiden overs" class="large">Mdns</abbr>');
         $maidens_header->SetCssClass("numeric");
         $runs_header = new XhtmlCell(true, "Runs");
         $runs_header->SetCssClass("numeric");
         $wickets_header = new XhtmlCell(true, '<abbr title="Wickets" class="small">Wk</abbr><abbr title="Wickets" class="large">Wkts</abbr>');
         $wickets_header->SetCssClass("numeric");
         $economy_header = new XhtmlCell(true, '<abbr title="Economy" class="small">Econ</abbr><span class="large">Economy</span>');
         $economy_header->SetCssClass("numeric");
         $average_header = new XhtmlCell(true, '<abbr title="Average" class="small">Avg</abbr><span class="large">Average</span>');
         $average_header->SetCssClass("numeric");
         $strike_header = new XhtmlCell(true, '<abbr title="Strike rate" class="small">S/R</abbr><span class="large">Strike rate</span>');
         $strike_header->SetCssClass("numeric");
         $bowling_headings = new XhtmlRow(array("Bowler", $over_header, $maidens_header, $runs_header, $wickets_header, $economy_header, $average_header, $strike_header));
         $bowling_headings->SetIsHeader(true);
         $bowling_table->AddRow($bowling_headings);
         $bowling_data->ResetCounter();
         while ($bowling_data->MoveNext()) {
             $bowling = $bowling_data->GetItem();
             /* @var $bowling Bowling */
             $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . htmlentities($bowling->GetPlayer()->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($bowling->GetPlayer()->GetName(), ENT_QUOTES, "UTF-8", false) . '</a>');
             $player->AddCssClass("bowler");
             $player->AddAttribute("typeof", "schema:Person");
             $player->AddAttribute("about", $bowling->GetPlayer()->GetLinkedDataUri());
             $over_data = new XhtmlCell(false, htmlentities($bowling->GetOvers(), ENT_QUOTES, "UTF-8", false));
             $over_data->SetCssClass("numeric");
             $maidens_data = new XhtmlCell(false, htmlentities($bowling->GetMaidens(), ENT_QUOTES, "UTF-8", false));
             $maidens_data->SetCssClass("numeric");
             $runs_data = new XhtmlCell(false, htmlentities($bowling->GetRunsConceded(), ENT_QUOTES, "UTF-8", false));
             $runs_data->SetCssClass("numeric");
             $wickets_data = new XhtmlCell(false, htmlentities($bowling->GetWickets(), ENT_QUOTES, "UTF-8", false));
             $wickets_data->SetCssClass("numeric");
             $economy = StoolballStatistics::BowlingEconomy($bowling->GetOvers(), $bowling->GetRunsConceded());
             $economy_data = new XhtmlCell(false, is_null($economy) ? "&#8211;" : htmlentities($economy, ENT_QUOTES, "UTF-8", false));
             $economy_data->SetCssClass("numeric");
             $average = StoolballStatistics::BowlingAverage($bowling->GetRunsConceded(), $bowling->GetWickets());
             $average_data = new XhtmlCell(false, is_null($average) ? "&#8211;" : htmlentities($average, ENT_QUOTES, "UTF-8", false));
             $average_data->SetCssClass("numeric");
             $strike = StoolballStatistics::BowlingStrikeRate($bowling->GetOvers(), $bowling->GetWickets());
             $strike_data = new XhtmlCell(false, is_null($strike) ? "&#8211;" : htmlentities($strike, ENT_QUOTES, "UTF-8", false));
             $strike_data->SetCssClass("numeric");
             $bowling_row = new XhtmlRow(array($player, $over_data, $maidens_data, $runs_data, $wickets_data, $economy_data, $average_data, $strike_data));
             $bowling_row->GetFirstCell()->SetCssClass("bowler");
             $bowling_table->AddRow($bowling_row);
         }
         $this->AddControl($bowling_table);
     }
     # Now over-by-over
     if ($overs_data->GetCount()) {
         $overs_table = new XhtmlTable();
         $overs_table->SetCaption(htmlentities($bowling_team->GetName() . "'s bowling, over-by-over", ENT_QUOTES, "UTF-8", false));
         $overs_table->SetCssClass("scorecard bowling-scorecard bowling overs");
         $balls_header = new XhtmlCell(true, "Balls");
         $balls_header->SetCssClass("numeric");
         $wides_header = new XhtmlCell(true, "Wides");
         $wides_header->SetCssClass("numeric");
         $no_balls_header = new XhtmlCell(true, "No balls");
         $no_balls_header->SetCssClass("numeric");
         $runs_in_over_header = new XhtmlCell(true, "Runs");
         $runs_in_over_header->SetCssClass("numeric");
         $total_header = new XhtmlCell(true, "Total");
         $total_header->SetCssClass("numeric");
         $overs_headings = new XhtmlRow(array("Bowler", $balls_header, $wides_header, $no_balls_header, $runs_in_over_header, $total_header));
         $overs_headings->SetIsHeader(true);
         $overs_table->AddRow($overs_headings);
         $overs_data->ResetCounter();
         $total = 0;
         while ($overs_data->MoveNext()) {
             $bowling = $overs_data->GetItem();
             /* @var $bowling Over */
             $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . htmlentities($bowling->GetPlayer()->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($bowling->GetPlayer()->GetName(), ENT_QUOTES, "UTF-8", false) . '</a>');
             $player->AddCssClass("bowler");
             $player->AddAttribute("typeof", "schema:Person");
             $player->AddAttribute("about", $bowling->GetPlayer()->GetLinkedDataUri());
             $balls_data = new XhtmlCell(false, htmlentities($bowling->GetBalls(), ENT_QUOTES, "UTF-8", false));
             $balls_data->SetCssClass("numeric");
             $wides_data = new XhtmlCell(false, htmlentities($bowling->GetWides(), ENT_QUOTES, "UTF-8", false));
             $wides_data->SetCssClass("numeric");
             $no_balls_data = new XhtmlCell(false, htmlentities($bowling->GetNoBalls(), ENT_QUOTES, "UTF-8", false));
             $no_balls_data->SetCssClass("numeric");
             $runs_in_over_data = new XhtmlCell(false, htmlentities($bowling->GetRunsInOver(), ENT_QUOTES, "UTF-8", false));
             $runs_in_over_data->SetCssClass("numeric");
             $total += $bowling->GetRunsInOver();
             $total_data = new XhtmlCell(false, htmlentities($total, ENT_QUOTES, "UTF-8", false));
             $total_data->SetCssClass("numeric");
             $bowling_row = new XhtmlRow(array($player, $balls_data, $wides_data, $no_balls_data, $runs_in_over_data, $total_data));
             $bowling_row->GetFirstCell()->SetCssClass("bowler");
             $overs_table->AddRow($bowling_row);
         }
         $this->AddControl($overs_table);
     }
 }
 /**
  * Sets up controls for pages 2/3 of the wizard
  * @param Match $match
  * @param Team $batting_team
  * @param Collection $batting_data
  * @param Team $bowling_team
  * @param Collection $bowling_data
  * @param int $total
  * @param int $wickets_taken
  * @return void
  */
 private function CreateScorecardControls(Match $match, Team $batting_team, Collection $batting_data, Team $bowling_team, Collection $bowling_data, $total, $wickets_taken)
 {
     require_once "xhtml/tables/xhtml-table.class.php";
     $batting_table = new XhtmlTable();
     $batting_table->SetCaption($batting_team->GetName() . "'s batting");
     $batting_table->SetCssClass("scorecard scorecardEditor batting");
     $out_by_header = new XhtmlCell(true, '<span class="small">Fielder</span><span class="large">Caught<span class="wrapping-hair-space"> </span>/<span class="wrapping-hair-space"> </span><span class="nowrap">run-out by</span></span>');
     $out_by_header->SetCssClass("dismissedBy");
     $bowler_header = new XhtmlCell(true, "Bowler");
     $bowler_header->SetCssClass("bowler");
     $score_header = new XhtmlCell(true, "Runs");
     $score_header->SetCssClass("numeric");
     $balls_header = new XhtmlCell(true, "Balls");
     $balls_header->SetCssClass("numeric");
     $batting_headings = new XhtmlRow(array("Batsman", "How out", $out_by_header, $bowler_header, $score_header, $balls_header));
     $batting_headings->SetIsHeader(true);
     $batting_table->AddRow($batting_headings);
     $batting_data->ResetCounter();
     $byes = null;
     $wides = null;
     $no_balls = null;
     $bonus = null;
     # Loop = max players + 4, because if you have a full scorecard you have to keep looping to get the 4 extras players
     for ($i = 1; $i <= $match->GetMaximumPlayersPerTeam() + 4; $i++) {
         $batting = $batting_data->MoveNext() ? $batting_data->GetItem() : null;
         /* @var $batting Batting */
         # Grab the scores for extras players to use later
         if (!is_null($batting)) {
             switch ($batting->GetPlayer()->GetPlayerRole()) {
                 case Player::BYES:
                     $byes = $batting->GetRuns();
                     break;
                 case Player::WIDES:
                     $wides = $batting->GetRuns();
                     break;
                 case Player::NO_BALLS:
                     $no_balls = $batting->GetRuns();
                     break;
                 case Player::BONUS_RUNS:
                     $bonus = $batting->GetRuns();
                     break;
             }
         }
         # Don't write a table row for the last four loops, we'll do that next because they're different
         if ($i <= $match->GetMaximumPlayersPerTeam()) {
             $player = new TextBox("batName{$i}", (is_null($batting) or !$batting->GetPlayer()->GetPlayerRole() == Player::PLAYER) ? "" : $batting->GetPlayer()->GetName(), $this->IsValidSubmit());
             $player->SetMaxLength(100);
             $player->AddAttribute("autocomplete", "off");
             $player->AddCssClass("player batsman team" . $batting_team->GetId());
             $how = new XhtmlSelect("batHowOut{$i}", null, $this->IsValidSubmit());
             $how->SetCssClass("howOut");
             $how->AddOptions(array(Batting::DID_NOT_BAT => Batting::Text(Batting::DID_NOT_BAT), Batting::NOT_OUT => Batting::Text(Batting::NOT_OUT), Batting::CAUGHT => Batting::Text(Batting::CAUGHT), Batting::BOWLED => Batting::Text(Batting::BOWLED), Batting::CAUGHT_AND_BOWLED => str_replace(" and ", "/", Batting::Text(Batting::CAUGHT_AND_BOWLED)), Batting::RUN_OUT => Batting::Text(Batting::RUN_OUT), Batting::BODY_BEFORE_WICKET => "bbw", Batting::HIT_BALL_TWICE => Batting::Text(Batting::HIT_BALL_TWICE), Batting::TIMED_OUT => Batting::Text(Batting::TIMED_OUT), Batting::RETIRED_HURT => Batting::Text(Batting::RETIRED_HURT), Batting::RETIRED => Batting::Text(Batting::RETIRED), Batting::UNKNOWN_DISMISSAL => Batting::Text(Batting::UNKNOWN_DISMISSAL)), null);
             if (!is_null($batting) and $batting->GetPlayer()->GetPlayerRole() == Player::PLAYER and $this->IsValidSubmit()) {
                 $how->SelectOption($batting->GetHowOut());
             }
             $out_by = new TextBox("batOutBy{$i}", (is_null($batting) or is_null($batting->GetDismissedBy()) or !$batting->GetDismissedBy()->GetPlayerRole() == Player::PLAYER) ? "" : $batting->GetDismissedBy()->GetName(), $this->IsValidSubmit());
             $out_by->SetMaxLength(100);
             $out_by->AddAttribute("autocomplete", "off");
             $out_by->AddCssClass("player team" . $bowling_team->GetId());
             $bowled_by = new TextBox("batBowledBy{$i}", (is_null($batting) or is_null($batting->GetBowler()) or !$batting->GetBowler()->GetPlayerRole() == Player::PLAYER) ? "" : $batting->GetBowler()->GetName(), $this->IsValidSubmit());
             $bowled_by->SetMaxLength(100);
             $bowled_by->AddAttribute("autocomplete", "off");
             $bowled_by->AddCssClass("player team" . $bowling_team->GetId());
             $runs = new TextBox("batRuns{$i}", (is_null($batting) or $batting->GetPlayer()->GetPlayerRole() != Player::PLAYER) ? "" : $batting->GetRuns(), $this->IsValidSubmit());
             $runs->SetCssClass("numeric runs");
             $runs->AddAttribute("type", "number");
             $runs->AddAttribute("min", "0");
             $runs->AddAttribute("autocomplete", "off");
             $balls = new TextBox("batBalls{$i}", (is_null($batting) or $batting->GetPlayer()->GetPlayerRole() != Player::PLAYER) ? "" : $batting->GetBallsFaced(), $this->IsValidSubmit());
             $balls->SetCssClass("numeric balls");
             $balls->AddAttribute("type", "number");
             $balls->AddAttribute("min", "0");
             $balls->AddAttribute("autocomplete", "off");
             $batting_row = new XhtmlRow(array($player, $how, $out_by, $bowled_by, $runs, $balls));
             $batting_row->GetFirstCell()->SetCssClass("batsman");
             $batting_table->AddRow($batting_row);
         }
     }
     $batting_table->AddRow($this->CreateExtrasRow("batByes", "Byes", "extras", "numeric runs", $byes));
     $batting_table->AddRow($this->CreateExtrasRow("batWides", "Wides", "extras", "numeric runs", $wides));
     $batting_table->AddRow($this->CreateExtrasRow("batNoBalls", "No balls", "extras", "numeric runs", $no_balls));
     $batting_table->AddRow($this->CreateExtrasRow("batBonus", "Bonus or penalty runs", "extras", "numeric runs", $bonus));
     $batting_table->AddRow($this->CreateExtrasRow("batTotal", "Total", "totals", "numeric", $total));
     $batting_table->AddRow($this->CreateWicketsRow($match, $wickets_taken));
     $this->AddControl($batting_table);
     $total_batsmen = new TextBox("batRows", $match->GetMaximumPlayersPerTeam(), $this->IsValidSubmit());
     $total_batsmen->SetMode(TextBoxMode::Hidden());
     $this->AddControl($total_batsmen);
     $bowling_table = new XhtmlTable();
     $bowling_table->SetCaption($bowling_team->GetName() . "'s bowling, over-by-over");
     $bowling_table->SetCssClass("scorecard scorecardEditor bowling-scorecard bowling");
     $over_header = new XhtmlCell(true, 'Balls bowled <span class="qualifier">(excluding extras)</span>');
     $over_header->SetCssClass("numeric balls");
     $wides_header = new XhtmlCell(true, "Wides");
     $wides_header->SetCssClass("numeric");
     $no_balls_header = new XhtmlCell(true, "No balls");
     $no_balls_header->SetCssClass("numeric");
     $runs_header = new XhtmlCell(true, "Over total");
     $runs_header->SetCssClass("numeric");
     $bowling_headings = new XhtmlRow(array("Bowler", $over_header, $wides_header, $no_balls_header, $runs_header));
     $bowling_headings->SetIsHeader(true);
     $bowling_table->AddRow($bowling_headings);
     $bowling_data->ResetCounter();
     for ($i = 1; $i <= $match->GetOvers(); $i++) {
         $bowling = $bowling_data->MoveNext() ? $bowling_data->GetItem() : null;
         /* @var $bowling Over */
         $blank_row = (is_null($bowling) or is_null($bowling->GetOverNumber()));
         // don't list records generated from batting card to record wickets taken
         $player = new TextBox("bowlerName{$i}", $blank_row ? "" : $bowling->GetPlayer()->GetName(), $this->IsValidSubmit());
         $player->SetMaxLength(100);
         $player->AddAttribute("autocomplete", "off");
         $player->AddCssClass("player team" . $bowling_team->GetId());
         $balls = new TextBox("bowlerBalls{$i}", $blank_row ? "" : $bowling->GetBalls(), $this->IsValidSubmit());
         $balls->AddAttribute("autocomplete", "off");
         $balls->AddAttribute("type", "number");
         $balls->AddAttribute("min", "0");
         $balls->AddAttribute("max", "10");
         $balls->SetCssClass("numeric balls");
         $wides = new TextBox("bowlerWides{$i}", $blank_row ? "" : $bowling->GetWides(), $this->IsValidSubmit());
         $wides->AddAttribute("autocomplete", "off");
         $wides->AddAttribute("type", "number");
         $wides->AddAttribute("min", "0");
         $wides->SetCssClass("numeric wides");
         $no_balls = new TextBox("bowlerNoBalls{$i}", $blank_row ? "" : $bowling->GetNoBalls(), $this->IsValidSubmit());
         $no_balls->AddAttribute("autocomplete", "off");
         $no_balls->AddAttribute("type", "number");
         $no_balls->AddAttribute("min", "0");
         $no_balls->SetCssClass("numeric no-balls");
         $runs = new TextBox("bowlerRuns{$i}", $blank_row ? "" : $bowling->GetRunsInOver(), $this->IsValidSubmit());
         $runs->AddAttribute("autocomplete", "off");
         $runs->AddAttribute("type", "number");
         $runs->AddAttribute("min", "0");
         $runs->SetCssClass("numeric runs");
         $bowling_row = new XhtmlRow(array($player, $balls, $wides, $no_balls, $runs));
         $bowling_row->GetFirstCell()->SetCssClass("bowler");
         $bowling_table->AddRow($bowling_row);
     }
     $this->AddControl($bowling_table);
     $total_overs = new TextBox("bowlerRows", $match->GetOvers(), $this->IsValidSubmit());
     $total_overs->SetMode(TextBoxMode::Hidden());
     $this->AddControl($total_overs);
     if ($match->GetLastAudit() != null) {
         require_once "data/audit-control.class.php";
         $this->AddControl(new AuditControl($match->GetLastAudit(), "match"));
     }
     $home_batted_first = "";
     if (!is_null($match->Result()->GetHomeBattedFirst())) {
         $home_batted_first = (int) $match->Result()->GetHomeBattedFirst();
     }
     $teams = new TextBox("teams", $home_batted_first . ScorecardEditControl::DATA_SEPARATOR . $match->GetHomeTeamId() . ScorecardEditControl::DATA_SEPARATOR . $match->GetHomeTeam()->GetName() . ScorecardEditControl::DATA_SEPARATOR . $match->GetAwayTeamId() . ScorecardEditControl::DATA_SEPARATOR . $match->GetAwayTeam()->GetName() . ScorecardEditControl::DATA_SEPARATOR . $match->GetTitle());
     $teams->SetMode(TextBoxMode::Hidden());
     $this->AddControl($teams);
 }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     foreach ($this->performance_data as $performance) {
         $current_value = "";
         if (array_key_exists("runs_scored", $performance)) {
             $current_batting_value = $performance["runs_scored"];
             $not_out = ($performance["how_out"] == Batting::NOT_OUT or $performance["how_out"] == Batting::RETIRED or $performance["how_out"] == Batting::RETIRED_HURT);
             if ($not_out) {
                 $current_batting_value .= "*";
             }
             $current_value .= $current_batting_value;
         }
         if (array_key_exists("wickets", $performance)) {
             $current_bowling_value = $performance["wickets"] . "/" . $performance["runs_conceded"];
             $current_value .= $current_bowling_value;
         }
         if (array_key_exists("catches", $performance)) {
             $current_value .= $performance["catches"];
         }
         if (array_key_exists("run_outs", $performance)) {
             $current_value .= $performance["run_outs"];
         }
         if ($current_value != $last_value) {
             $pos = $i;
             $last_value = $current_value;
         } else {
             $pos = "=";
         }
         $i++;
         $fields = array();
         if ($this->show_position) {
             $position = new XhtmlCell(false, $pos);
             $position->SetCssClass("position");
             $fields[] = $position;
         }
         $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["player_url"] . '">' . $performance["player_name"] . "</a>");
         $player->SetCssClass("player");
         $player->AddAttribute("typeof", "schema:Person");
         $player->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $performance["player_url"]);
         $fields[] = $player;
         $match = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["match_url"] . '">' . $performance["match_title"] . "</a>");
         $match->AddAttribute("typeof", "schema:SportsEvent");
         $match->AddAttribute("about", "https://www.stoolball.org.uk/id/match" . $performance["match_url"]);
         $match->SetCssClass("match");
         $fields[] = $match;
         $date = new XhtmlCell(false, Date::BritishDate($performance["match_time"], false, true, true));
         $date->SetCssClass("date");
         $fields[] = $date;
         if (array_key_exists("runs_scored", $performance)) {
             $runs = new XhtmlCell(false, $current_batting_value == "" ? "&#8211;" : $current_batting_value);
             $runs->SetCssClass("numeric");
             if (!$not_out) {
                 $runs->AddCssClass("out");
             }
             $fields[] = $runs;
         }
         if (array_key_exists("wickets", $performance)) {
             $bowling = new XhtmlCell(false, $current_bowling_value == "/" ? "&#8211;" : $current_bowling_value);
             $bowling->SetCssClass("numeric");
             $fields[] = $bowling;
         }
         if (array_key_exists("catches", $performance)) {
             $catches = new XhtmlCell(false, $performance["catches"] == "0" ? "&#8211;" : $performance["catches"]);
             $catches->SetCssClass("numeric");
             $fields[] = $catches;
         }
         if (array_key_exists("run_outs", $performance)) {
             $runouts = new XhtmlCell(false, $performance["run_outs"] == "0" ? "&#8211;" : $performance["run_outs"]);
             $runouts->SetCssClass("numeric");
             $fields[] = $runouts;
         }
         $row = new XhtmlRow($fields);
         $this->AddRow($row);
     }
     parent::OnPreRender();
 }
 public function OnPreRender()
 {
     if ($this->matches_with_run_data < 1) {
         $this->SetVisible(false);
         return;
     }
     # Add table of runs
     $this->SetCssClass('runTable');
     $this->SetCaption("Team runs");
     $total_header = new XhtmlCell(true, "Total");
     $total_header->SetCssClass("numeric");
     $run_header = new XhtmlRow(array(new XhtmlCell(true, "Statistic"), $total_header));
     $run_header->SetIsHeader(true);
     $this->AddRow($run_header);
     $matches_cell = new XhtmlCell(false, $this->matches_with_run_data);
     $matches_cell->SetCssClass('numeric');
     $matches_row = new XhtmlRow(array(new XhtmlCell(false, "matches with runs recorded"), $matches_cell));
     $this->AddRow($matches_row);
     if (!is_null($this->runs_scored)) {
         $scored_cell = new XhtmlCell(false, $this->runs_scored);
         $scored_cell->SetCssClass('numeric');
         $scored_row = new XhtmlRow(array(new XhtmlCell(false, "runs scored"), $scored_cell));
         $this->AddRow($scored_row);
     }
     if (!is_null($this->runs_conceded)) {
         $conceded_cell = new XhtmlCell(false, $this->runs_conceded);
         $conceded_cell->SetCssClass('numeric');
         $this->AddRow(new XhtmlRow(array(new XhtmlCell(false, "runs conceded"), $conceded_cell)));
     }
     if (!is_null($this->runs_scored) and !is_null($this->runs_conceded)) {
         $run_difference = $this->runs_scored - $this->runs_conceded;
         if ($run_difference > 0) {
             $run_difference = "+" . $run_difference;
         }
         $difference_cell = new XhtmlCell(false, $run_difference);
         $difference_cell->SetCssClass('numeric');
         $this->AddRow(new XhtmlRow(array(new XhtmlCell(false, "run difference"), $difference_cell)));
     }
     if (!is_null($this->highest_innings)) {
         $best_cell = new XhtmlCell(false, $this->highest_innings);
         $best_cell->SetCssClass('numeric');
         $scored_row = new XhtmlRow(array(new XhtmlCell(false, "highest innings"), $best_cell));
         $this->AddRow($scored_row);
     }
     if (!is_null($this->lowest_innings)) {
         $worst_cell = new XhtmlCell(false, $this->lowest_innings);
         $worst_cell->SetCssClass('numeric');
         $scored_row = new XhtmlRow(array(new XhtmlCell(false, "lowest innings"), $worst_cell));
         $this->AddRow($scored_row);
     }
     if (!is_null($this->average_innings)) {
         $average_cell = new XhtmlCell(false, round($this->average_innings, 0));
         $average_cell->SetCssClass('numeric');
         $average_row = new XhtmlRow(array(new XhtmlCell(false, "average innings"), $average_cell));
         $this->AddRow($average_row);
     }
     parent::OnPreRender();
 }