public static function alter()
 {
     Controller::requirePermissions(["AdminAccessDashboard", "AdminMatches"]);
     $id = $_POST["id"];
     $match = current(MatchModel::get($_POST["id"]));
     if (array_key_exists("date", $_POST)) {
         try {
             $id = $match->correctDate($match->id, $_POST["date"]);
             Controller::addAlert(new Alert("success", "Correction completed"));
         } catch (DuplicateException $e) {
             Controller::addAlert(new Alert("danger", "The report cannot be moved to the specified date as there is already another report filed for the team for the match on that date"));
         }
     } else {
         if (array_key_exists("home_team_id", $_POST)) {
             try {
                 $homeTeamId = $_POST["home_team_id"] != 0 ? $_POST["home_team_id"] : null;
                 $awayTeamId = $_POST["away_team_id"] != 0 ? $_POST["away_team_id"] : null;
                 $id = $match->correctTeams($match->id, $homeTeamId, $awayTeamId);
                 Controller::addAlert(new Alert("success", "Correction completed"));
             } catch (DuplicateException $e) {
                 Controller::addAlert(new Alert("danger", "The report cannot be updated with those team(s) as there is already another report filed for the team for the match on that date"));
             }
         }
     }
     Controller::redirect("/acp/match/manage?id=" . $id);
 }
 /**
  * Get match record
  *
  * @return \sma\models\Match match
  */
 public function getMatch()
 {
     if (!$this->match) {
         $this->match = current(Match::get($this->matchId));
     }
     return $this->match;
 }
 public static function index()
 {
     Controller::requirePermissions(["AdminAccessDashboard"]);
     if (!empty($_POST)) {
         Setting::set("info_box_content", $_POST["info"]);
     }
     View::load("acp/index.twig", ["organizationCount" => count(Organization::get()), "teamCount" => count(Team::get()), "unassignedTeams" => Team::get(null, null, null, false, false), "info" => Setting::get("info_box_content"), "mismatches" => Match::get(null, null, null, null, null, Match::STATUS_MISMATCH)]);
 }
 public static function index()
 {
     $league = current(LeagueModel::get($_GET["id"]));
     View::load("league.twig", ["league" => $league, "fixtures" => $league->constructFixtures(), "matches" => Match::get(null, null, $league->id, null, null, Match::STATUS_RECONCILED, 10)]);
 }
 /**
  * Get matches played
  *
  * @param bool $mustBeReconciled set to true to only retrieve reconciled (finalised) matches
  * @return \sma\models\Match[] match
  */
 public function getMatches($order = "DESC", $mustBeReconciled = false)
 {
     $status = $mustBeReconciled === true ? Match::STATUS_RECONCILED : null;
     return Match::get(null, null, null, null, null, $status, null, $this->id, $order);
 }
<?php

/**
 * Sports Match Administrator
 *
 * Copyright © 2014-2015, Jack P. Harley, jackpharley.com
 * All Rights Reserved
 */
require_once __DIR__ . "/Init.php";
$matches = \sma\models\Match::get(null, null, null, null, null, \sma\models\Match::STATUS_PENDING);
foreach ($matches as $match) {
    echo "Attempting reconciliation of match #" . $match->id . "...";
    $status = $match->attemptReportReconciliation();
    if ($status) {
        echo "good.\n";
    } else {
        echo "mismatch!\n";
    }
}
 public static function record()
 {
     $match = current(MatchModel::get($_GET["id"]));
     View::load("match/record.twig", ["match" => $match]);
 }