Exemple #1
0
/**
	# this calculates the ranking points of all players who belong
	# to a specific LEAGUE-Group $fedagroup FEDA (MIXED or DAMEN)
	# a) retrieve all legs belonging to this listnumber form all events for the specified period
	# b) check on legacy table and include data
	# v2.6 incl current league in report
	*	v3 changed to fit into ls_statsadmin - produce minimal output ...
	*	v4 changed and removed the team - event strings ...
	*			includes all events of this statgroup not only active events
	* v5  extended by the API_RS model
	* v5 reM: works only on 501 legs !!
	**/
function generateStaticFEDAStatisticEntries($feda_stat_group, $indexdate, $writeToDB = 'no')
{
    global $user, $dbi;
    $fromdate = fnc_date_calc($indexdate, -365);
    /*
     * Rangliste berechnet aus allen Spielen von $fromdate bis $indexdate
     * we query after all players from all events belonging to this statgroup ...
     * this returns really ALL players who have ever played in this group (active + non-active events ..)
     * No sense to include the teams+events here, since there could be multiple ...
     * this returns multiple records for each player ....
     */
    $RS = DB_listEventStatGroupPlayers($dbi, $feda_stat_group);
    $aTH = array("Vorname", "Nachname", "Scorezahl", "Checkzahl", "Gesamtzahl", "Legs", "Spiele");
    debug("Calculating actual stat values for " . count($RS) . " Players");
    OpenTable();
    echo ArrayToTableHead($aTH);
    foreach ($RS as $p) {
        #
        # get legs per player - calc - and sum up, att. here we can have multiple player entries
        #	the recordset is sorted by PID ...
        #
        $sumScore = 0;
        $sumCheck = 0;
        $CountScore = 0;
        $CountCheck = 0;
        $scoreindex = 0;
        $checkindex = 0;
        #######################
        # LEGACY data from pre system times
        #######################
        $legqry = "select lxid,lxdate,lxrscore,lxrest,lxrcheck from tbllegx where lxpid={$p['0']} and lxevlist={$feda_stat_group} and lxdate<'{$indexdate}' and lxdate>'{$fromdate}' and lxrscore>0 order by lxdate asc";
        $Lrecord = sql_query($legqry, $dbi);
        while (list($lxid, $lxdate, $lxrscore, $lxrest, $lxrcheck) = sql_fetch_row($Lrecord, $dbi)) {
            $idx = "";
            $idx = retFEDAIndexZahlperLeg(501, $lxrscore, $lxrest, $lxrcheck, $iTEST);
            list($a, $b, $c) = split(":", $idx);
            # values of -1 indicate failure
            if ($a > -1) {
                $sumScore = $sumScore + $a;
                $CountScore = $CountScore + 1;
            }
            if ($b > -1) {
                $sumCheck = $sumCheck + $b;
                $CountCheck = $CountCheck + 1;
            }
        }
        #######################
        # structured data from League-System
        #######################
        $LEGS = DB_listLegsFromPeriod($dbi, 0, 0, $feda_stat_group, $fromdate, $indexdate, $p[0]);
        #debug(count($LEGS));
        # lid,lroundscore,lscore,lroundcheck,gid,mid,mround,mdate ##
        $gamecount = 0;
        $lastgid = 0;
        foreach ($LEGS as $L) {
            if ($lastgid != $L[4]) {
                $gamecount = $gamecount + 1;
            }
            $idx = "";
            $idx = retFEDAIndexZahlperLeg(501, $L[1], 501 - $L[2], $L[3]);
            list($a, $b, $c) = split(":", $idx);
            # values of -1 indicate failure
            if ($a > -1) {
                $sumScore = $sumScore + $a;
                $CountScore = $CountScore + 1;
            }
            if ($b > -1) {
                $sumCheck = $sumCheck + $b;
                $CountCheck = $CountCheck + 1;
            }
            $lastgid = $L[4];
        }
        /*
         * calculate index by division with countvalues
         */
        if ($CountScore > 0) {
            $scoreindex = $sumScore / $CountScore;
        }
        if ($CountCheck > 0) {
            $checkindex = $sumCheck / $CountCheck;
        }
        /*
         * Finally Output into TABLEROW or OUTVAR
         */
        /*
         * V3.1 change, since we have ALL players here we have a lot of cases where no actual statval is compiled in this case its zero and
         * we cont store anything ..
         */
        if ($gamecount > 0) {
            echo "<tr><td>{$p['1']}</td><td>{$p['2']}</td><td>" . number_format($scoreindex, 2, '.', '') . "</td><td>" . number_format($checkindex, 2, '.', '') . "</td><td>" . number_format($scoreindex + $checkindex, 2, '.', '') . "</td><td>{$CountScore}</td><td>{$gamecount}</td></tr>";
            if ($writeToDB == 'yes') {
                $qry = "insert into tblstat(statid,statdate,statcode,statval,statpid,statgames,statlegs) values(0,'{$indexdate}',{$feda_stat_group}," . number_format($scoreindex + $checkindex, 2, '.', '') . ",{$p['0']},{$gamecount},{$CountScore})";
                $res = sql_query($qry, $dbi);
            }
        } else {
            echo "<tr style=\"color:#ff0000;\"><td>{$p['1']}</td><td>{$p['2']}</td><td>NO DATA</td><td>NO DATA</td><td>NO DATA</td><td></td><td></td></tr>";
        }
    }
    #//  END FOR EACH PLAYER
    CloseTable();
}
Exemple #2
0
/**
*	purpose:	show a personal detail listing ALL legs for a period of 1 year 
* 						for the FEDA Stat  for the passed event
* 	params:	$eventid,$indexdate,$pid
*	returns:	PageView: js-graph + detail listing
*/
function _showPersonStatListeDetail($eventid, $indexdate = '', $pid = 0)
{
    global $dbi, $tdbg, $event, $fedadefaultdate;
    if ($pid == 0) {
        return;
    }
    if (strlen($indexdate) < 5) {
        $indexdate = $fedadefaultdate;
    }
    $evstatcode = $event['evstatcode_id'];
    $fromdate = fnc_date_calc($indexdate, -365);
    # // we use a very general person query here ...
    $playerqry = "select pid,pfname,plname from tplayer where pid={$pid}";
    $precord = sql_query($playerqry, $dbi);
    $aPLAYER = sql_fetch_array($precord, $dbi);
    $aTH = array("Datum", "Runde", "Scorerunde", "Rest", "Checkrunde", "Scorezahl", "Checkzahl");
    echo _MakeStatPageHeader($eventid, $evstatcode);
    echo "<h3>Auflistung aller Spiele / Legs " . $aPLAYER["pfname"] . " " . $aPLAYER["plname"] . " von {$fromdate} bis {$indexdate}</h3>";
    # GRAPH ###############
    echo "<script language=\"JavaScript\" src=\"code/legdatagraph.js\"></script>";
    echo "<div id=\"JG\" style=\"position:relative;height:300px;width:700px\"></div>";
    # we need here to pass date constraints - dont pass event-id !!
    echo "<script>window.onLoad=perfgraph({$pid},{$evstatcode},0,'{$fromdate}','{$indexdate}')</script>";
    # GRAPH ###############
    OpenTable();
    #
    # get legs per player - calc - and sum up
    #
    ####################
    # Legacy Data from pre league system -> tbllegx
    ####################
    $legqry = "select lxid,lxpcnum,lxdate,lxrscore,lxrest,lxrcheck from tbllegx where lxpid={$pid} and lxevlist={$evstatcode} and lxdate<'{$indexdate}' and lxdate>'{$fromdate}' and lxrscore>0 order by lxdate asc";
    $Lrecord = sql_query($legqry, $dbi);
    echo ArrayToTableHead($aTH);
    while (list($lxid, $lxpcnum, $lxdate, $lxrscore, $lxrest, $lxrcheck) = sql_fetch_row($Lrecord, $dbi)) {
        $idx = "";
        $idx = retFEDAIndexZahlperLeg($event['evsgldist'], $lxrscore, $lxrest, $lxrcheck);
        list($a, $b, $c) = split(":", $idx);
        echo "<tr><td>{$lxdate}</td><td>n/a</td><td>{$lxrscore}</td><td>{$lxrest}</td><td>{$lxrcheck}</td><td>{$a}</td><td>{$b}</td></tr>";
    }
    ####################
    # official League system Data
    ####################
    $legqry = "select lid,lroundscore,lscore,lroundcheck,gid,gmkey,mround,mdate from tbllegrounds,tblgame,tblmatch,tblevent E where lpid = {$pid} and lgid=gid and gmkey=mkey and mevid=E.id and E.evstatcode_id={$evstatcode} and mdate<'{$indexdate}' and mdate>'{$fromdate}' and lroundscore>0 order by mdate asc,lid asc";
    $Lrecord = sql_query($legqry, $dbi);
    echo ArrayToTableHead($aTH);
    while (list($lid, $lroundscore, $lscore, $lroundcheck, $gid, $gmkey, $mround, $mdate) = sql_fetch_row($Lrecord, $dbi)) {
        $idx = "";
        $idx = retFEDAIndexZahlperLeg($event['evsgldist'], $lroundscore, $event['evsgldist'] - $lscore, $lroundcheck);
        list($a, $b, $c) = split(":", $idx);
        echo "<tr><td>{$mdate}</td><td>{$mround}</td><td>{$lroundscore}</td><td>" . ($event['evsgldist'] - $lscore) . "</td><td>{$lroundcheck}</td><td>{$a}</td><td>{$b}</td></tr>";
    }
    CloseTable();
}