--- /dev/null
+#**************************************************************************
+# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
+# *
+# This program is free software; you can redistribute it and/or modify *
+# it under the terms of the GNU General Public License as published by *
+# the Free Software Foundation; either version 2 of the License, or *
+# (at your option) any later version. *
+# *
+# This program is distributed in the hope that it will be useful, *
+# but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# GNU General Public License for more details. *
+# *
+# You should have received a copy of the GNU General Public License *
+# along with this program; if not, write to the *
+# Free Software Foundation, Inc., *
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+#**************************************************************************/
+
+use strict;
+use POSIX;
+our $BODY;
+our $DBH;
+our $LOG;
+
+$ND::TEMPLATE->param(TITLE => 'Defense Calls');
+
+die "You don't have access" unless isBC();
+
+
+my $call;
+if (param('call') =~ /^(\d+)$/){
+ my $query = $DBH->prepare(q{});
+ $call = $DBH->selectrow_hashref($query,undef,$1);
+}
+
+if ($call){
+}else{
+ my $where = 'open AND c.landing_tick-6 > tick()';
+ if (param('show') eq 'covered'){
+ $where = 'covered';
+ }elsif (param('show') eq 'all'){
+ $where = 'true';
+ }elsif (param('show') eq 'uncovered'){
+ $where = 'not covered';
+ }
+ my $query = $DBH->prepare(qq{
+SELECT c.id, coords(p.x,p.y,p.z), u.defense_points, c.landing_tick,
+ TRIM('/' FROM concat(p2.race||'/')) AS race, TRIM('/' FROM concat(i.amount||'/')) AS amount,
+ TRIM('/' FROM concat(i.eta||'/')) AS eta, TRIM('/' FROM concat(i.shiptype||'/')) AS shiptype,
+ TRIM('/' FROM concat(c.landing_tick - tick() ||'/')) AS curreta,
+ TRIM('/' FROM concat(p2.alliance ||'/')) AS alliance,
+ TRIM('/' FROM concat(coords(p2.x,p2.y,p2.z) ||'/')) AS attackers
+FROM calls c
+ JOIN incomings i ON i.call = c.id
+ JOIN users u ON c.member = u.uid
+ JOIN current_planet_stats p ON u.planet = p.id
+ JOIN current_planet_stats p2 ON i.sender = p2.id
+WHERE $where
+GROUP BY c.id, p.x,p.y,p.z, u.username, c.landing_tick, c.info,u.defense_points
+ORDER BY c.landing_tick DESC
+ })or print $DBH->errstr;
+ $query->execute or print $DBH->errstr;
+ my @calls;
+ my $i = 0;
+ while (my $call = $query->fetchrow_hashref){
+ $call->{ODD} = $i % 2;
+ push @calls, $call;
+ $i++;
+ }
+ $BODY->param(Calls => \@calls);
+}
+1;
--- /dev/null
+<TMPL_IF Call>
+<TMPL_ELSE>
+<table>
+ <tr><th>Call</th><th>Member (def points)</th><th>Landing tick</th><th>Races</th><th>Amount</th><th>Shiptypes</th><th>Current eta</th><th>Inital eta</th><th>Alliance</th><th>Attackers</th></tr>
+<TMPL_LOOP Calls>
+ <tr align="center" class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
+ <td><a href="index.pl?page=calls&call=<TMPL_VAR NAME=Id>"><TMPL_VAR NAME=Id></a></td>
+ <td><TMPL_VAR NAME=Coords> (<TMPL_VAR NAME=Defense_points>)</td>
+ <td><TMPL_VAR NAME=Landing_tick></td>
+ <td><TMPL_VAR NAME=Race></td>
+ <td><TMPL_VAR NAME=Amount></td>
+ <td><TMPL_VAR NAME=Shiptype></td>
+ <td><TMPL_VAR NAME=Curreta></td>
+ <td><TMPL_VAR NAME=Eta></td>
+ <td><TMPL_VAR NAME=Alliance></td>
+ <td><TMPL_VAR NAME=Attackers></td>
+ </tr>
+</TMPL_LOOP>
+</table>
+</TMPL_IF>