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 #**************************************************************************/
26 $ND::TEMPLATE->param(TITLE => 'Defense Calls');
28 die "You don't have access" unless isBC();
32 if (param('call') =~ /^(\d+)$/){
33 my $query = $DBH->prepare(q{});
34 $call = $DBH->selectrow_hashref($query,undef,$1);
39 my $where = 'open AND c.landing_tick-6 > tick()';
40 if (param('show') eq 'covered'){
42 }elsif (param('show') eq 'all'){
44 }elsif (param('show') eq 'uncovered'){
45 $where = 'not covered';
47 my $query = $DBH->prepare(qq{
48 SELECT c.id, coords(p.x,p.y,p.z), u.defense_points, c.landing_tick,
49 TRIM('/' FROM concat(p2.race||'/')) AS race, TRIM('/' FROM concat(i.amount||'/')) AS amount,
50 TRIM('/' FROM concat(i.eta||'/')) AS eta, TRIM('/' FROM concat(i.shiptype||'/')) AS shiptype,
51 TRIM('/' FROM concat(c.landing_tick - tick() ||'/')) AS curreta,
52 TRIM('/' FROM concat(p2.alliance ||'/')) AS alliance,
53 TRIM('/' FROM concat(coords(p2.x,p2.y,p2.z) ||'/')) AS attackers
55 JOIN incomings i ON i.call = c.id
56 JOIN users u ON c.member = u.uid
57 JOIN current_planet_stats p ON u.planet = p.id
58 JOIN current_planet_stats p2 ON i.sender = p2.id
60 GROUP BY c.id, p.x,p.y,p.z, u.username, c.landing_tick, c.info,u.defense_points
61 ORDER BY c.landing_tick DESC
62 })or print $DBH->errstr;
63 $query->execute or print $DBH->errstr;
66 while (my $call = $query->fetchrow_hashref){
67 $call->{ODD} = $i % 2;
71 $BODY->param(Calls => \@calls);