1 #**************************************************************************
2 # Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
4 # This program is free software; you can redistribute it and/or modify *
5 # it under the terms of the GNU General Public License as published by *
6 # the Free Software Foundation; either version 2 of the License, or *
7 # (at your option) any later version. *
9 # This program is distributed in the hope that it will be useful, *
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 # GNU General Public License for more details. *
14 # You should have received a copy of the GNU General Public License *
15 # along with this program; if not, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
20 package ND::Web::Pages::TargetList;
22 use warnings FATAL => 'all';
24 use CGI qw/:standard/;
27 use base qw/ND::Web::XMLPage/;
29 $ND::Web::Page::PAGES{targetList} = __PACKAGE__;
34 $self->{TITLE} = 'NF Value';
35 my $DBH = $self->{DBH};
37 return $self->noAccess unless $self->isHC;
39 my $order = 'nfvalue';
40 if (local $_ = param('order')){
41 if (/^(size|value|score|xp)$/){
43 }elsif (/^(nfvalue|nfvalue2)$/){
49 if (param('alliances') && param('alliances') =~ /^([\d,]+)$/){
52 my $query = $DBH->prepare(qq{
53 SELECT coords(p.x,p.y,p.z),p.alliance, p.score, p.value, p.size, p.xp,nfvalue, nfvalue - sum(pa.value) AS nfvalue2, p.race
54 FROM current_planet_stats p
55 JOIN (SELECT g.x,g.y, sum(p.value) AS nfvalue
56 FROM galaxies g join current_planet_stats p on g.x = p.x AND g.y = p.y
57 WHERE g.tick = (SELECT max(tick) from galaxies)
58 AND ((planet_status IS NULL OR NOT planet_status IN ('Friendly','NAP')) AND (relationship IS NULL OR NOT relationship IN ('Friendly','NAP')))
60 ) g ON p.x = g.x AND p.y = g.y
61 JOIN current_planet_stats pa ON pa.x = g.x AND pa.y = g.y
62 WHERE p.alliance_id IN ($alliances)
63 AND pa.alliance_id IN ($alliances)
64 GROUP BY p.x,p.y,p.z,p.alliance, p.score, p.value, p.size, p.xp, nfvalue,p.race
70 while (my $alliance = $query->fetchrow_hashref){
72 $alliance->{ODD} = $i % 2;
73 push @alliances,$alliance;
75 $BODY->param(Alliances => \@alliances);