echo "</select>";
echo "</div>";
echo "</div>";
echo FormBuilder::createFormGroup($i18n, "message_id", array("type" => "foreign_key", "jointable" => "spiel_text", "entity" => "matchtext", "labelcolumns" => "aktion,nachricht"), "", "match_manage_reportmsg_");
echo FormBuilder::createFormGroup($i18n, "playernames", array("type" => "text"), "", "match_manage_reportmsg_");
echo FormBuilder::createFormGroup($i18n, "minute", array("type" => "number"), "", "match_manage_reportmsg_");
echo FormBuilder::createFormGroup($i18n, "intermediateresult", array("type" => "text"), "", "match_manage_reportmsg_");
echo "</fieldset>";
echo "<div class=\"form-actions\">";
echo "<button type=\"submit\" class=\"btn btn-primary\">" . $i18n->getMessage("button_save") . "</button>";
echo "</div></form>";
// ******** list items
$reportItems = MatchesDataService::getMatchReportMessages($website, $db, $i18n, $matchId);
// no items
if (!count($reportItems)) {
    echo createInfoMessage("", $i18n->getMessage("match_manage_reportitems_noitems"));
    // list items
} else {
    echo "<table class=\"table table-bordered table-striped table-hover\">";
    echo "<thead>";
    echo "<tr>";
    echo "<th>" . $i18n->getMessage("match_manage_reportmsg_minute") . "</th>";
    echo "<th>" . $i18n->getMessage("entity_matchtext_aktion") . "</th>";
    echo "<th>" . $i18n->getMessage("entity_matchtext_nachricht") . "</th>";
    echo "<th>" . $i18n->getMessage("match_manage_reportmsg_playernames") . "</th>";
    echo "<th>" . $i18n->getMessage("match_manage_reportmsg_intermediateresult") . "</th>";
    echo "</tr>";
    echo "</thead>";
    echo "<tbody>";
    $homeTeam = escapeOutput($match["match_home_name"]);
    $guestTeam = escapeOutput($match["match_guest_name"]);
foreach ($teamPrefixes as $teamPrefix) {
    echo "<h2><a href=\"" . $website->getInternalUrl("team", "id=" . $match["match_" . $teamPrefix . "_id"]) . "\" target=\"_blank\">" . escapeOutput($match["match_" . $teamPrefix . "_name"]) . "</a></h2>";
    // tactic
    echo "<div class=\"form-horizontal\">";
    echo FormBuilder::createFormGroup($i18n, $teamPrefix . "_offensive", array("type" => "number", "value" => $match["match_" . $teamPrefix . "_offensive"]), $match["match_" . $teamPrefix . "_offensive"], "formation_");
    echo FormBuilder::createFormGroup($i18n, $teamPrefix . "_longpasses", array("type" => "boolean", "value" => $match["match_" . $teamPrefix . "_longpasses"]), $match["match_" . $teamPrefix . "_longpasses"], "formation_");
    echo FormBuilder::createFormGroup($i18n, $teamPrefix . "_counterattacks", array("type" => "boolean", "value" => $match["match_" . $teamPrefix . "_counterattacks"]), $match["match_" . $teamPrefix . "_counterattacks"], "formation_");
    echo "</div>";
    // get existing players
    $playerTable = $website->getConfig("db_prefix") . "_spiel_berechnung SB";
    $playerTable .= " INNER JOIN " . $website->getConfig("db_prefix") . "_spieler S ON S.id = SB.spieler_id";
    $result = $db->querySelect("SB.*", $playerTable, "spiel_id = %d AND team_id = %d ORDER BY feld ASC, field(SB.position_main, 'T', 'LV', 'IV', 'RV', 'DM', 'LM', 'ZM', 'RM', 'OM', 'LS', 'MS', 'RS')", array($matchId, $match["match_" . $teamPrefix . "_id"]));
    $playersCount = $result->num_rows;
    // no player records
    if (!$playersCount) {
        echo createInfoMessage("", $i18n->getMessage("match_manage_playerstatistics_noitems"));
        // check if any formation is available
        $fresult = $db->querySelect("COUNT(*) AS hits", $website->getConfig("db_prefix") . "_aufstellung", "verein_id = %d", $match["match_" . $teamPrefix . "_id"]);
        $formationCount = $fresult->fetch_array();
        $fresult->free();
        if ($formationCount && $formationCount["hits"]) {
            echo "<p><a href=\"?site={$site}&match={$matchId}&team={$teamPrefix}&action=generate\" class=\"btn\"><i class=\"icon-hand-right\"></i> " . $i18n->getMessage("match_manage_playerstatistics_createfromfrmation") . "</a></p>";
        } else {
            echo "<p><i class=\"icon-warning-sign\"></i> " . $i18n->getMessage("match_manage_playerstatistics_noformationavailable") . "</p>";
        }
        // list player records
    } else {
        $players = array();
        echo "<table class=\"table table-bordered table-striped table-hover\">";
        echo "<thead>";
        echo "<tr>";
        if (!empty($_POST['lastlogindays'])) {
            $whereCondition .= ' OR U.lastonline < %d';
            $parameters[] = $website->getNowAsTimestamp() - $_POST['lastlogindays'] * 24 * 3600;
        }
        if (!empty($_POST['maxplayers'])) {
            $whereCondition .= ' OR (SELECT COUNT(*) FROM ' . $website->getConfig('db_prefix') . '_spieler AS PlayerTab WHERE PlayerTab.verein_id = C.id AND status = \'1\') < %d';
            $parameters[] = $_POST['maxplayers'];
        }
        if (!empty($_POST['userid']) && $_POST['userid']) {
            $whereCondition .= ' OR U.id = %d';
            $parameters[] = $_POST['userid'];
        }
        $whereCondition .= ')';
        $result = $db->querySelect($columns, $fromTable, $whereCondition, $parameters, 50);
        if (!$result->num_rows) {
            echo createInfoMessage($i18n->getMessage('firemanagers_search_nohits'), '');
        } else {
            ?>
			<form action='<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
' method='post' class='form-horizontal' id='frmMain' name='frmMain'>
				<input type='hidden' name='site' value='<?php 
            echo $site;
            ?>
'>
				<input type='hidden' name='show' value='selectoptions'>
				<table class='table table-striped table-hover'>
					<thead>
						<tr>
							<th></th>
$wherePart = "1=1";
$parameters = array();
foreach ($filterFields as $filterFieldId => $filterFieldInfo) {
    if (strlen(trim($filterFieldInfo["value"]))) {
        $searchValue = strtoupper(trim($filterFieldInfo["value"]));
        $wherePart .= " AND UCASE(" . $filterFieldInfo["field"] . ") LIKE '%%%s%%'";
        $parameters[] = $searchValue;
    }
}
// count records
$columns = "COUNT(*) AS hits";
$result = $db->querySelect($columns, $fromTable, $wherePart, $parameters);
$rows = $result->fetch_array();
$result->free();
if (!$rows['hits']) {
    echo createInfoMessage($i18n->getMessage("manage_no_records_found"), "");
} else {
    // enable pagination
    $seite = isset($_REQUEST[PARAM_PAGE]) ? (int) $_REQUEST[PARAM_PAGE] : 1;
    $eps = 20;
    if ($rows['hits'] % $eps) {
        $seiten = floor($rows['hits'] / $eps) + 1;
    } else {
        $seiten = $rows['hits'] / $eps;
    }
    $start = ($seite - 1) * $eps;
    $firstNo = $start + 1;
    $lastNo = min($start + $eps, $rows['hits']);
    echo "<p>" . sprintf($i18n->getMessage("manage_number_of_records"), $rows['hits'], $firstNo, $lastNo) . "</p>";
    // ordering
    if ($sortColumn) {