]> ruin.nu Git - ndwebbie.git/blob - NDWeb/Pages/MemberIntel.pm
476c35ed62dc93ae6047f0470fe01a6ea8e77b28
[ndwebbie.git] / NDWeb / Pages / MemberIntel.pm
1 #**************************************************************************
2 #   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
3 #                                                                         *
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.                                   *
8 #                                                                         *
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.                          *
13 #                                                                         *
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 #**************************************************************************/
19
20 package ND::Web::Pages::MemberIntel;
21 use strict;
22 use warnings FATAL => 'all';
23 use CGI qw/:standard/;
24 use ND::Web::Include;
25
26 use base qw/ND::Web::XMLPage/;
27
28 $ND::Web::Page::PAGES{memberIntel} = __PACKAGE__;
29
30 sub render_body {
31         my $self = shift;
32         my ($BODY) = @_;
33         $self->{TITLE} = 'Member Intel';
34         my $DBH = $self->{DBH};
35         my $error;
36
37         return $self->noAccess unless $self->isHC;
38
39         my $showticks = 'AND i.tick > tick()';
40         if (defined param('show')){
41                 if (param('show') eq 'all'){
42                         $showticks = '';
43                 }elsif (param('show') =~ /^(\d+)$/){
44                         $showticks = "AND (i.tick - i.eta) > (tick() - $1)";
45                 }
46         }
47
48
49         my $query = $DBH->prepare(intelquery('o.alliance AS oalliance,coords(o.x,o.y,o.z) AS origin, coords(t.x,t.y,t.z) AS target, t.nick',"t.alliance_id = 1 $showticks"));
50         $query->execute() or $error .= $DBH->errstr;
51         my @intellists;
52         my @incomings;
53         my $i = 0;
54         while (my $intel = $query->fetchrow_hashref){
55                 if ($intel->{ingal}){
56                         $intel->{missionclass} = 'ingal';
57                 }else{
58                         $intel->{missionclass} = $intel->{mission};
59                 }
60                 $intel->{oalliance} = ' ' unless $intel->{oalliance};
61                 $i++;
62                 $intel->{ODD} = $i % 2;
63                 push @incomings,$intel;
64         }
65         push @intellists,{Message => 'Incoming fleets', Intel => \@incomings, Origin => 1};
66
67         $query = $DBH->prepare(intelquery('o.nick,coords(o.x,o.y,o.z) AS origin,t.alliance AS talliance,coords(t.x,t.y,t.z) AS target',"o.alliance_id = 1 $showticks"));
68         $query->execute() or $error .= $DBH->errstr;
69         my @outgoings;
70         $i = 0;
71         while (my $intel = $query->fetchrow_hashref){
72                 if ($intel->{ingal}){
73                         $intel->{missionclass} = 'ingal';
74                 }else{
75                         $intel->{missionclass} = $intel->{mission};
76                 }
77                 $intel->{talliance} = ' ' unless $intel->{talliance};
78                 $i++;
79                 $intel->{ODD} = $i % 2;
80                 push @outgoings,$intel;
81         }
82         push @intellists,{Message => 'Outgoing Fleets', Intel => \@outgoings, Target => 1};
83
84         $BODY->param(IntelLIsts => \@intellists);
85
86         $BODY->param(Error => $error);
87         return $BODY;
88 }
89 1;