示例#1
0
文件: index.php 项目: jevkid/OnTarget
function userLeaderboard($club, $discipline)
{
    $disciplines = getDisciplines();
    $users = getTable("SELECT u.id AS uid, u.fname AS fname, u.sname AS sname, u.sex AS sex, SUM(t.score) AS score, AVG(t.score) AS avg\r\n\t\t\t\t\t\t\tFROM users AS u, timeline AS t, rounds AS r\r\n\t\t\t\t\t\t\tWHERE u.clubid='" . $club['cid'] . "' AND u.id = t.userid AND r.id = t.roundid " . $disciplines[$discipline] . "\r\n\t\t\t\t\t\t\tGROUP BY u.id\r\n\t\t\t\t\t\t\tORDER BY score DESC");
    $output = "<h2>Leaderboard:</h2>" . "<table class='leaderboard'>" . "<tr><td>Name</td><td>Total Score</td><td>Average Score</td></tr>";
    for ($i = 0; $i < count($users); $i++) {
        $output .= "<tr><td><a href='/group3/dashboard?uid=" . $users[$i]['uid'] . "'>" . $users[$i]['fname'] . " " . $users[$i]['sname'] . "</a></td><td>" . $users[$i]['score'] . "</td><td>" . round($users[$i]['avg'], 2) . "</td></tr>";
    }
    $output .= "</table>";
    return $output;
}
示例#2
0
for ($i = 3; $i <= 278; $i += 5) {
    $total15 = $objWorksheet15->getCell('AI' . $i)->getCalculatedValue();
    $total16 = $objWorksheet16->getCell('AI' . $i)->getCalculatedValue();
    if ($total15 == 0 && $total16 == 0) {
        continue;
    }
    $industry = new StdClass();
    $industry->name = $objWorksheet15->getCell('A' . $i)->getValue();
    // 2015
    $industry->y15 = new StdClass();
    $industry->y15->total = $total15;
    $industry->y15->disciplines = getDisciplines($cellConfig, $objWorksheet15, $i);
    // 2016
    $industry->y16 = new StdClass();
    $industry->y16->total = $total16;
    $industry->y16->disciplines = getDisciplines($cellConfig, $objWorksheet16, $i);
    $list[] = $industry;
}
function getDisciplines($cellConfig, $objWorksheet, $i)
{
    $disciplines = array();
    foreach ($cellConfig as $c) {
        $discipline = new StdClass();
        $discipline->name = explode("\n", $objWorksheet->getCell($c->totalCell . '1')->getValue())[0];
        $discipline->value = $objWorksheet->getCell($c->totalCell . $i)->getValue();
        $discipline->isvalid = true;
        $discipline->type = $c->percentType;
        $discipline->detail = new StdClass();
        // find detail
        switch ($discipline->type) {
            case 1: