Exemple #1
0
function _showmatch($vmkey, $eventid)
{
    #//select gid,ggameid,gmatchid,gvereinid,vname,gplayerid,pfname,plname from tblgame,tverein,tplayer where gvereinid=vid and gplayerid=pid
    # // display a typical matchcard
    # // adminmode = selectboxes and input fields
    # // usermode = readonly controls
    # // v1 bh 1.2006 initial version read only
    # // v2 using the matchkey and eventID
    # // v3 corrected gamewon counter to respect event - sgllegs/dbllegs
    # // v4 corrected bug in sending eventid to purge proc
    # // v4.1 changed code to use the input sub
    # // v4.2 added the vereins-access layer
    # // v43 complete rework: changed to codesharing with the lsdb backend , added POSTback buttons
    global $dbi, $event, $redpic, $greenpic, $LS_LEVEL;
    $editmode = 0;
    $thismatcheditmode = 0;
    $hometeam = 0;
    $awayteam = 0;
    # // v4.2 team-access-layer ...
    # we dont give full access in here just make sure the DETAIL links are in place ... and the MatchSave does work
    $thismatcheditmode = retAccessThisMatchKey($vmkey);
    if ($LS_LEVEL > 1 || $thismatcheditmode == 1) {
        $editmode = 1;
        # (can be 2,3,4)
        echo '<script type="text/javascript" src="code/MatchCode.js"></script>';
    }
    echo setPageTitle('Resultat der Begegnung');
    echo '<div id="maincontent">';
    $precord = sql_query('select mid,mkey,mround,mdate,mlocation,mthome,mstatus,mcomment,T.id,T.tname' . ' FROM tblmatch M,tblmatchteam MT,tblteam T' . ' WHERE M.MKEY=MT.MTMKEY and MT.MTTID=T.ID and M.MKEY="' . $vmkey . '" order by MT.MTHOME desc', $dbi);
    $lastmid = 0;
    $matchdate = '';
    while (list($mid, $mkey, $mround, $mdate, $mlocation, $mthome, $mstatus, $mcomment, $tid, $tname) = sql_fetch_row($precord, $dbi)) {
        if ($lastmid != $mid) {
            $hometeam = $tid;
            $hometeamName = $tname;
        } else {
            $awayteam = $tid;
            $awayteamName = $tname;
        }
        $lastmid = $mid;
        $matchdate = $mdate;
        $match_round = $mround;
        $match_comment = $mcomment;
    }
    /*
     * OUTPUT HEADER Section,make header box with 40:10:10:40
     */
    OpenTable('mhead');
    echo '<tr><td colspan="4" align="center">' . $event['evname'] . 'Saison ' . $event['evyear'] . ' Runde ' . $match_round . '</td></tr><tr><td width="40%"><h3>' . $hometeamName . '</h3></td><td width="10%"></td>';
    echo '<td width="10%"></td><td width="40%"><h3>' . $awayteamName . '</h3></td></tr>';
    CloseTable();
    echo _input(0, 'mkey', $vmkey) . _input(0, 'eid', $eventid) . '<br/>';
    /*
     * SECTION Explanations, legend, and Quicklinks ...
     */
    if ($editmode == 1) {
        // this is accessible by LigaAdmins + Vereinsaccounts ...
        OpenTable('mcontrol');
        echo '<table><tr><td>-- Player unknown/missing -- </td><td>Dieser Eintrag ist zu w&auml;hlen wenn das Spiel stattgefunden hat, der betreffende Spieler jedoch nicht in der Teamliste oder im System aufscheint.</td></tr>';
        echo '<tr><td>-- #WO (nicht angetreten) --</td><td>Dieser Eintrag ist zu w&auml;hlen wenn kein Spieler anwesend war (zB Unterzahl). Das Spiel wird dann automatisch mit zu null f&uuml;r den anwesenden Gegner gewertet. Sind beide Spieler nicht anwesend, so sind beide mit WO zu markieren, dieses Spiel wird dann &uuml;berhaupt nicht gewertet.</td></tr>';
        echo '<tr><td colspan="2"><table width="100%"><tr>' . '<td width="50%" align="center">';
        echo renderWOMatchForm($eventid, $vmkey, $hometeam, $awayteam, $hometeamName);
        echo '</td><td width="50%" align="center"><form action="ls_system.php" method="post">';
        echo renderWOMatchForm($eventid, $vmkey, $awayteam, $hometeam, $awayteamName);
        echo '</td></tr></table></td></tr></table>';
        CloseTable();
        echo '<br/>';
    }
    /*
     * REPLACE in v5 by reading the event.config.blocks
     */
    OpenTable('mbody');
    # // ===============================================
    # // =========    SINGLES     ======================
    # // ===============================================
    $precord = sql_query('select gid,gmkey,gtype,gstatus,gpid,gppid,pfname,plname' . ' FROM tblgame G,tblgameplayer GP left join tplayer P on GP.gppid=P.pid' . ' WHERE G.gid=GP.gpgid and G.gmkey="' . $vmkey . '" and gtype=1 order by gid,gpid', $dbi);
    $lastgameid = 0;
    while (list($gid, $gmkey, $gtype, $gstatus, $gpid, $gppid, $pfname, $plname) = sql_fetch_row($precord, $dbi)) {
        if ($lastgameid != $gid) {
            $PH = array($gid, $gmkey, $gtype, $gstatus, $gpid, $gppid, $pfname, $plname, $hometeam);
        } else {
            $PA = array($gid, $gmkey, $gtype, $gstatus, $gpid, $gppid, $pfname, $plname, $awayteam);
            echo '<tr><td><div id="trg' . $gid . '">';
            echo _LS_renderSingleGameRow($event, $editmode, $matchdate, $PH, $PA);
            echo '</div><div id="trged' . $gid . '"></div></td><td valign="top">';
            if ($editmode == 1) {
                echo '<table cellpadding=0><tr><td>' . _imgButton('save', 'saveGame(' . $gid . ')') . '</td>';
                echo '<td>' . _imgButton('edit', 'editGame(' . $gid . ')') . '</td>';
                echo '<td>' . _imgButton('detail', 'getGame(' . $gid . ')') . '</td>' . '<td>' . _imgButton('cancel', 'resetGame(' . $gid . ')') . '</td></tr></table>';
            }
            echo '</td></tr><tr><td align="right"><div id="msg' . $gid . '"></div></td></tr>';
            // close the game Table + Game DIV and the Tablerow
        }
        $lastgameid = $gid;
    }
    // END WHILE singles ...
    # // ===============================================
    # // =========    PAIRS     ========================
    # // ===============================================
    #
    #
    $precord = sql_query('select G.gid,G.gmkey,G.gtype,G.gstatus,GP.gpid,GP.gppid,P.pfname,P.plname' . ' FROM tblgame G,tblgameplayer GP left JOIN tplayer P on GP.gppid=P.pid' . ' WHERE G.gid=GP.gpgid AND G.gmkey="' . $vmkey . '" and G.gtype=2 order by G.gid,GP.gpid', $dbi);
    $aAllGames = array();
    while (list($gid, $gmkey, $gtype, $gstatus, $gpid, $gppid, $pfname, $plname) = sql_fetch_row($precord, $dbi)) {
        $aAllGames[] = array($gid, $gmkey, $gtype, $gstatus, $gpid, $gppid, $pfname, $plname);
    }
    /*
     * since we have pairs - we split Recordset into chunks of 4
     */
    $aAllGames = array_chunk($aAllGames, 4);
    foreach ($aAllGames as $aThisGame) {
        /*
         * for every chunk we have this should be a pairs game 
         * assign the team ID and => lets render
         */
        $aThisGame[0][8] = $hometeam;
        $aThisGame[1][8] = $hometeam;
        $aThisGame[2][8] = $awayteam;
        $aThisGame[3][8] = $awayteam;
        $gid = $aThisGame[0][0];
        echo '<tr><td><div id="trg' . $gid . '">';
        echo _LS_renderPairsGameRow($event, $editmode, $matchdate, $aThisGame);
        echo '</div><br/><div id="trged' . $gid . '"></div></td><td valign="top">';
        if ($editmode == 1) {
            echo '<table><tr><td>' . _imgButton('save', 'saveGameD(' . $gid . ')') . '</td>';
            #echo '<td>'._imgButton('edit','editGame('.$gid.')').'</td>';
            echo '<td>' . _imgButton('detail', 'getGame(' . $gid . ')') . '</td>';
            echo '<td>' . _imgButton('cancel', 'resetGame(' . $gid . ')') . '</td></tr></table>';
        }
        echo '</td></tr><tr><td align="right"><div id="msg' . $gid . '"></div></td></tr>';
        // close the game Table + Game DIV and the Tablerow
    }
    /*
     * Can we somehow have a summary ROW ??? with generated values ???
     */
    $setshometeam = 0;
    $setsawayteam = 0;
    $legshometeam = 0;
    $legsawayteam = 0;
    #echo '<tr><td align="center"><h3>'.$setshometeam.':'.$setsawayteam.'<br/>('.$legshometeam.'):('.$legsawayteam.')</h3></td></tr>';
    CloseTable();
    /**
     * =========== END of the Match Sheet Body ===========
     **/
    /**
     * =========== START Admin Section ===========
     * a) create this match -->generates the empty tblgameplayer entries ...
     * b) save this match --> updates the tblmatchteam with results and sets status according to the userType
     */
    echo '<br/>';
    if ($LS_LEVEL > 1 || $editmode == 1) {
        // now this is for ADMINS only .....
        OpenTable('madmin');
        echo '<table><tr><td colspan=3>';
        echo '<div id="mcomment">';
        echo '<table><tr><td valign="top"><image src="images/detail.png" align="left">Speichere einen Kommentar</br>zu diesem Match (max 200)</td>';
        echo '<td valign="top">' . _input(1, 'f23', $match_comment, 90) . '</td>';
        echo '<td valign="top">' . _button('Speichern', 'savemcomment()') . '<div id="resp4"></div>';
        echo '</td></tr></table></div></td></tr><tr>';
        // render save section here in RW mode
        echo '<td valign="top" width="250px"><div id="msum">';
        echo _LS_renderSaveMatchBox($LS_LEVEL, $setshometeam, $setsawayteam, $legshometeam, $legsawayteam, 0);
        echo '</div><div>' . _button('1. Addieren', 'calcResult()') . _button('2. Resultat Speichern', 'saveMatchA()') . '</div>';
        echo '</td>';
        if ($LS_LEVEL > 1) {
            // history button
            echo '<td valign="top" width="33%"><div id="mhist">';
            echo '<image src="images/detail.png" align="left">Lade die Bearbeitungs Historie f&uuml;r dieses Match. Die Anzeige erfolgt unterhalb.<br/>' . _button('Show History', 'historymatch()');
            echo '</div>';
            echo '</td>';
        }
        if ($LS_LEVEL > 2) {
            // delete button
            $STROUT = '<td valign="top" width="33%"><div id="mdel"><form action="ls_system.php" method="post">' . _input(0, 'func', 'purgematch') . _input(0, 'vmkey', $vmkey) . _input(0, 'eventid', $eventid) . '<table><tr><td><image src="images/stop.gif" align="left"><b>Achtung</b> Mit dem Button L&Ouml;SCHEN kannst du dieses Spiel neu anlegen, dabei werden s&auml;mtliche Spieldaten und Resultate <b>gel&ouml;scht</b>. Diese Aktion ist unwiederbringlich ...</td></tr>' . '<tr><td>' . _button('L&ouml;schen') . '</td></tr></table></form></div></td>';
            echo $STROUT;
        }
        echo '</tr></table>';
        CloseTable();
        echo '<br/><div id="hmatch"></div>';
    }
    /**
     * =========== END of the Match ADMIN Section ===========
     **/
    echo '</div>';
    # close maincontent-div
}
Exemple #2
0
/**
*	purpose	sum up the stored leg/game results an render Summary Box
*	params		matchkey
*	returns		summary box to be placed into DIV on matchSheet
*/
function _summaryBox($match_key)
{
    global $dbi, $usertoken, $aMkey;
    /*
     * get the accumulatedGame/Leg/results from the DB and try to determine the status
     * GP.gptid,GP.gppid,GP.gpsetswon,GP.gplegswon,G.gid,M.mid,M.mkey
     * order is by team / Game thus we can filter the pairs which are stored twice
     * pass all values to the _LS_renderSaveMatchBox function
     * all Accounts(Verein) do not feature the status selector ...
     */
    if ($usertoken['usertype_id'] == 2) {
        $LS_LEVEL = 1;
    } else {
        $LS_LEVEL = 2;
    }
    $event = reteventconfig($aMkey['event']);
    $RS = DB_getMatchGameResults($dbi, $match_key);
    $sH = 0;
    $lH = 0;
    $sA = 0;
    $lA = 0;
    $lastgame = 0;
    foreach ($RS as $rec) {
        if ($lastgame != $rec[4]) {
            if ($rec[0] == $aMkey['home']) {
                $sH += $rec[2];
                $lH += $rec[3];
            } elseif ($rec[0] == $aMkey['away']) {
                $sA += $rec[2];
                $lA += $rec[3];
            }
        }
        $lastgame = $rec[4];
    }
    /*
     * now we try to determine a sensible status
     */
    if ($lH + $lA == 0) {
        $mstat = 0;
    } else {
        $mstat = 2;
    }
    return _LS_renderSaveMatchBox($LS_LEVEL, $sH, $sA, $lH, $lA, $mstat);
}