/**
  * (non-PHPdoc)
  * @see IModel::getTemplateParameters()
  */
 public function getTemplateParameters()
 {
     $matchId = (int) $this->_websoccer->getRequestParameter("id");
     if ($matchId < 1) {
         throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND));
     }
     $match = MatchesDataService::getMatchById($this->_websoccer, $this->_db, $matchId, FALSE, TRUE);
     $home_players = MatchesDataService::getMatchReportPlayerRecords($this->_websoccer, $this->_db, $matchId, $match["match_home_id"]);
     $guest_players = MatchesDataService::getMatchReportPlayerRecords($this->_websoccer, $this->_db, $matchId, $match["match_guest_id"]);
     // check if any player is member of team of the day
     if ($match["match_simulated"]) {
         $result = $this->_db->querySelect("player_id", $this->_websoccer->getConfig("db_prefix") . "_teamoftheday", "season_id = %d AND matchday = %d", array($match["match_season_id"], $match["match_matchday"]));
         $topPlayerIds = array();
         while ($topmember = $result->fetch_array()) {
             $topPlayerIds[] = $topmember["player_id"];
         }
         $result->free();
         if (count($topPlayerIds)) {
             for ($playerIndex = 0; $playerIndex < count($home_players); $playerIndex++) {
                 if (in_array($home_players[$playerIndex]["id"], $topPlayerIds)) {
                     $home_players[$playerIndex]["is_best_player_of_day"] = TRUE;
                 }
             }
             for ($playerIndex = 0; $playerIndex < count($guest_players); $playerIndex++) {
                 if (in_array($guest_players[$playerIndex]["id"], $topPlayerIds)) {
                     $guest_players[$playerIndex]["is_best_player_of_day"] = TRUE;
                 }
             }
         }
     }
     return array("match" => $match, "home_players" => $home_players, "guest_players" => $guest_players);
 }
 public function getTemplateParameters()
 {
     $matchId = (int) $this->_websoccer->getRequestParameter("id");
     if ($matchId < 1) {
         throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND));
     }
     $match = MatchesDataService::getMatchById($this->_websoccer, $this->_db, $matchId);
     // get statistics
     $columns["SUM(shoots)"] = "shoots";
     $columns["SUM(ballcontacts)"] = "ballcontacts";
     $columns["SUM(wontackles)"] = "wontackles";
     $columns["SUM(passes_successed)"] = "passes_successed";
     $columns["SUM(passes_failed)"] = "passes_failed";
     $fromTable = $this->_websoccer->getConfig("db_prefix") . "_spiel_berechnung";
     $whereCondition = "spiel_id = %d AND team_id = %d";
     // home team
     $parameters = array($matchId, $match["match_home_id"]);
     $result = $this->_db->querySelect($columns, $fromTable, $whereCondition, $parameters);
     $homeStatistics = $result->fetch_array();
     $result->free();
     // guest team
     $parameters = array($matchId, $match["match_guest_id"]);
     $result = $this->_db->querySelect($columns, $fromTable, $whereCondition, $parameters);
     $guestStatistics = $result->fetch_array();
     $result->free();
     return array("match" => $match, "homeStatistics" => $homeStatistics, "guestStatistics" => $guestStatistics);
 }
 /**
  * (non-PHPdoc)
  * @see IModel::getTemplateParameters()
  */
 public function getTemplateParameters()
 {
     $matchId = (int) $this->_websoccer->getRequestParameter('id');
     if ($matchId < 1) {
         throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND));
     }
     $match = MatchesDataService::getMatchById($this->_websoccer, $this->_db, $matchId);
     if (!isset($match['match_id'])) {
         throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND));
     }
     $allowTacticChanges = FALSE;
     $reportmessages = array();
     if ($match['match_minutes'] > 0) {
         $reportmessages = MatchesDataService::getMatchReportMessages($this->_websoccer, $this->_db, $this->_i18n, $matchId);
         $userTeamId = $this->_websoccer->getUser()->getClubId($this->_websoccer, $this->_db);
         $userNationalTeamId = NationalteamsDataService::getNationalTeamManagedByCurrentUser($this->_websoccer, $this->_db);
         if (!$match['match_simulated'] && $this->_websoccer->getConfig('sim_allow_livechanges') && ($match['match_home_id'] == $userTeamId || $match['match_guest_id'] == $userTeamId || $match['match_home_id'] == $userNationalTeamId || $match['match_guest_id'] == $userNationalTeamId)) {
             $allowTacticChanges = TRUE;
         }
     }
     // collect strikers
     $homeStrikerMessages = array();
     $guestStrikerMessages = array();
     foreach ($reportmessages as $reportMessage) {
         $type = $reportMessage['type'];
         if ($type == 'Tor' || $type == 'Tor_mit_vorlage' || $type == 'Elfmeter_erfolg' || $type == 'Freistoss_treffer') {
             if ($reportMessage['active_home']) {
                 array_unshift($homeStrikerMessages, $reportMessage);
             } else {
                 array_unshift($guestStrikerMessages, $reportMessage);
             }
         }
     }
     return array('match' => $match, 'reportmessages' => $reportmessages, 'allowTacticChanges' => $allowTacticChanges, 'homeStrikerMessages' => $homeStrikerMessages, 'guestStrikerMessages' => $guestStrikerMessages);
 }
 public function __construct($db, $i18n, $websoccer)
 {
     $this->_db = $db;
     $this->_i18n = $i18n;
     $this->_websoccer = $websoccer;
     $matchId = (int) $this->_websoccer->getRequestParameter('id');
     $this->_match = MatchesDataService::getMatchById($this->_websoccer, $this->_db, $matchId);
 }
  useful, but WITHOUT ANY WARRANTY; without even the implied
  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
  See the GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public 
  License along with OpenWebSoccer-Sim.  
  If not, see <http://www.gnu.org/licenses/>.

******************************************************/
echo "<h1>" . $i18n->getMessage("match_manage_reportitems") . "</h1>";
if (!$admin["r_admin"] && !$admin["r_demo"] && !$admin["r_spiele"]) {
    throw new Exception($i18n->getMessage("error_access_denied"));
}
echo "<p><a href=\"?site=manage&entity=match\" class=\"btn\">" . $i18n->getMessage("back_label") . "</a></p>";
$matchId = isset($_REQUEST["match"]) && is_numeric($_REQUEST["match"]) ? $_REQUEST["match"] : 0;
$match = MatchesDataService::getMatchById($website, $db, $matchId, FALSE, FALSE);
if (!count($match)) {
    throw new Exception("illegal match id");
}
// ******** action: delete player from match
if ($action == "delete") {
    if ($admin["r_demo"]) {
        throw new Exception($i18n->getMessage("validationerror_no_changes_as_demo"));
    }
    $itemId = (int) $_REQUEST["itemid"];
    $db->queryDelete($website->getConfig("db_prefix") . "_matchreport", "id = %d", array($itemId));
    echo createSuccessMessage($i18n->getMessage("manage_success_delete"), "");
} elseif ($action == "create") {
    if ($admin["r_demo"]) {
        throw new Exception($i18n->getMessage("validationerror_no_changes_as_demo"));
    }