public static function correct()
 {
     Controller::requirePermissions(["AdminAccessDashboard", "AdminMatches"]);
     $report = MatchReport::get($_GET["report"])[0];
     $match = $report->getMatch();
     if ($match->status == MatchModel::STATUS_MISMATCH) {
         $match->correctReports($report->id);
         Controller::addAlert(new Alert("success", "Correction completed"));
     } else {
         Controller::addAlert(new Alert("danger", "This match cannot be corrected as it is not currently in a mismatched state"));
     }
     Controller::redirect("/acp/match/manage?id=" . $match->id);
 }
<?php

/**
 * Sports Match Administrator
 *
 * Copyright © 2014-2015, Jack P. Harley, jackpharley.com
 * All Rights Reserved
 */
require_once __DIR__ . "/Init.php";
use sma\Database;
use sma\query\SelectQuery;
use sma\models\MatchReport;
echo "Beginning cleanup...";
$mrs = MatchReport::get();
foreach ($mrs as $report) {
    if (!$report->getMatch()->id) {
        $report->delete();
        echo "Report #" . $report->id . " deleted as it did not belong to a valid match";
    }
    $match = $report->getMatch();
    if ($report->teamId == $match->homeTeamId) {
        if (!$match->getHomeTeamPlayers()) {
            $report->delete();
            echo "Report #" . $report->id . " deleted as it did not have any attached players";
        }
    } else {
        if ($report->teamId == $match->awayTeamId) {
            if (!$match->getAwayTeamPlayers()) {
                $report->delete();
                echo "Report #" . $report->id . " deleted as it did not have any attached players";
            }
 /**
  * Correct the reports so that they match
  *
  * @param int $correctReportId id of the correct report
  * @param bool $reconcile when set to true, attempts to reconcile the reports after correcting them
  */
 public function correctReports($correctReportId, $reconcile = true)
 {
     $correctReport = current(MatchReport::get($correctReportId));
     $reports = $this->getMatchReports();
     foreach ($reports as $report) {
         if ($report->id != $correctReportId) {
             (new UpdateQuery(Database::getConnection()))->table("match_reports")->where("id = ?", $report->id)->set("home_score = ?", $correctReport->homeScore)->set("away_score = ?", $correctReport->awayScore)->prepare()->execute();
         }
     }
     // invalidate quick cache
     $this->matchReports = null;
     if ($reconcile) {
         $this->attemptReportReconciliation();
     }
 }
 public static function submitted()
 {
     Controller::requirePermissions(["SubmitMatchReports"]);
     $visitor = User::getVisitor();
     $teams = Team::get(null, $visitor->organizationId);
     $teamIds = [];
     foreach ($teams as $team) {
         $teamIds[] = $team->id;
     }
     $reports = MatchReport::get(null, null, null, $teamIds, 25);
     View::load("match/submitted.twig", ["organizationReports" => $reports, "userReports" => MatchReport::get(null, null, $visitor->id, null, 25)]);
 }