/** * 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); }