]> ruin.nu Git - ndwebbie.git/commitdiff
Possible to change order
authorMichael Andreen <harv@ruin.nu>
Tue, 11 Sep 2007 19:58:07 +0000 (21:58 +0200)
committerMichael Andreen <harv@ruin.nu>
Tue, 11 Sep 2007 19:58:07 +0000 (21:58 +0200)
NDWeb/Pages/MemberIntel.pm
templates/memberIntel.tmpl

index 2ec5785ac6f129b5aacefe351e939bc23c13dd2e..0f585edd2a6cb0961909785fdfcb011b67f0b266 100644 (file)
@@ -130,7 +130,12 @@ sub render_body {
                $BODY->param(Defenses => \@defenses);
 
        }else{
-               my $query = $DBH->prepare(q{SELECT u.uid,u.username,u.attack_points, u.defense_points, n.tick
+               my $order = "attacks";
+               if (defined param('order') && param('order') =~ /^(attacks|defenses|attack_points|defense_points|solo|bad_def)$/){
+                       $order = $1;
+               }
+
+               my $query = $DBH->prepare(qq{SELECT u.uid,u.username,u.attack_points, u.defense_points, n.tick
                        ,count(CASE WHEN i.mission = 'Attack' THEN 1 ELSE NULL END) AS attacks
                        ,count(CASE WHEN (i.mission = 'Defend' OR i.mission = 'AllyDef') THEN 1 ELSE NULL END) AS defenses
                        ,count(CASE WHEN i.mission = 'Attack' AND rt.id IS NULL THEN 1 ELSE NULL END) AS solo
@@ -146,7 +151,7 @@ sub render_body {
                        LEFT OUTER JOIN raid_claims rc ON rt.id = rc.target AND rc.uid = u.uid
                        WHERE gm.gid = 2
                        GROUP BY u.uid,u.username,u.attack_points, u.defense_points,n.tick
-                       ORDER BY attacks DESC,defenses DESC, attack_points DESC, defense_points DESC});
+                       ORDER BY $order DESC});
                $query->execute() or $error .= $DBH->errstr;
                my @members;
                my $i = 0;
index c6fae519d0d1880e136cfbe394fd0fd6a9fec1ff..b00a42f49c1f341973d2de345d1c1ac8b8171e53 100644 (file)
 <TMPL_ELSE>
 <table>
        <tr>
-               <th>Member</th><th>Attacks</th><th>Defenses</th><th>Attack Points</th><th>Defense Points</th>
-               <th>Solo attacks</th><th>Def outside ND/Gal</th>
+               <th>Member</th>
+               <th><a href="<TMPL_VAR NAME=PAGE>?order=attacks">Attacks</a></th>
+               <th><a href="<TMPL_VAR NAME=PAGE>?order=defenses">Defenses</a></th>
+               <th><a href="<TMPL_VAR NAME=PAGE>?order=attack_points">Attack Points</a></th>
+               <th><a href="<TMPL_VAR NAME=PAGE>?order=defense_points">Defense Points</a></th>
+               <th><a href="<TMPL_VAR NAME=PAGE>?order=solo">Solo attacks</a></th>
+               <th><a href="<TMPL_VAR NAME=PAGE>?order=bad_def">Def outside ND/Gal</a></th>
        </tr>
        <TMPL_LOOP Members>
-       <tr class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
-               <td class="<TMPL_VAR NAME=OLD>"><a href="<TMPL_VAR NAME=PAGE>?uid=<TMPL_VAR NAME=uid>"><TMPL_VAR NAME=username></a></td>
+       <tr align="right" class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
+               <td align="left" class="<TMPL_VAR NAME=OLD>"><a href="<TMPL_VAR NAME=PAGE>?uid=<TMPL_VAR NAME=uid>"><TMPL_VAR NAME=username></a></td>
                <td><TMPL_VAR NAME=attacks></td>
                <td><TMPL_VAR NAME=defenses></td>
                <td><TMPL_VAR NAME=attack_points></td>