]> ruin.nu Git - ndwebbie.git/commitdiff
Change the calls and incomings structure
authorMichael Andreen <harv@ruin.nu>
Thu, 30 Jul 2009 15:27:10 +0000 (17:27 +0200)
committerMichael Andreen <harv@ruin.nu>
Fri, 21 Aug 2009 14:00:48 +0000 (16:00 +0200)
Rename the call id to call, and the incoming id to inc, so it is unique
within the database and thus can be used in natural join and join ..
using.

Remove covered and open variables and replace with a status. Different
statuses can be added to call_statuses table, but at the moment only
Open, Covered and Ignored is supported.

database/calls.sql [new file with mode: 0644]
lib/NDWeb/Controller/Alliances.pm
lib/NDWeb/Controller/Calls.pm
lib/NDWeb/Controller/Intel.pm
lib/NDWeb/Controller/Members.pm
root/src/calls/edit.tt2
root/src/calls/list.tt2
root/src/members/index.tt2

diff --git a/database/calls.sql b/database/calls.sql
new file mode 100644 (file)
index 0000000..0cd2410
--- /dev/null
@@ -0,0 +1,60 @@
+DROP VIEW IF EXISTS full_defcalls;
+DROP VIEW IF EXISTS defcalls;
+
+CREATE TABLE call_statuses (
+       status TEXT PRIMARY KEY
+);
+
+INSERT INTO call_statuses VALUES('Open'),('Covered'),('Ignored');
+
+ALTER TABLE calls ADD COLUMN status TEXT NOT NULL REFERENCES call_statuses(status)
+DEFAULT 'Open';
+
+UPDATE calls SET status = (CASE WHEN covered THEN 'Covered' WHEN NOT OPEN THEN
+       'Ignored' ELSE 'Open' END);
+
+ALTER TABLE calls DROP COLUMN open;
+ALTER TABLE calls DROP COLUMN covered;
+ALTER TABLE calls DROP COLUMN shiptypes;
+ALTER TABLE calls RENAME id TO call;
+ALTER TABLE calls RENAME member TO uid;
+ALTER TABLE incomings RENAME id TO inc;
+
+CREATE OR REPLACE VIEW defcalls AS
+SELECT call, status,c.uid, c.landing_tick
+       ,dc.username AS dc, (c.landing_tick - tick()) AS curreta
+       ,array_agg(COALESCE(race::text,'')) AS race
+       ,array_agg(COALESCE(amount,0)) AS amount
+       ,array_agg(COALESCE(eta,0)) AS eta
+       ,array_agg(COALESCE(shiptype,'')) AS shiptype
+       ,array_agg(COALESCE(alliance,'?')) AS alliance
+       ,array_agg(coords(p2.x,p2.y,p2.z)) AS attackers
+FROM calls c
+       LEFT OUTER JOIN incomings i USING (call)
+       LEFT OUTER JOIN current_planet_stats p2 USING (pid)
+       LEFT OUTER JOIN users dc ON c.dc = dc.uid
+GROUP BY call,c.uid,dc.username, c.landing_tick, status;
+
+CREATE OR REPLACE VIEW full_defcalls AS
+SELECT call,status,x,y,z,pid,landing_tick,dc,curreta
+       ,defprio, c.race, amount, c.eta, shiptype, c.alliance, attackers
+       ,COUNT(NULLIF(f.back = f.landing_tick + f.eta - 1, FALSE)) AS fleets
+FROM users_defprio u
+       JOIN current_planet_stats p USING (pid)
+       JOIN defcalls c USING (uid)
+       LEFT OUTER JOIN launch_confirmations f USING (pid,landing_tick)
+GROUP BY call, x,y,z,pid,landing_tick,dc,curreta,defprio,c.race,amount,c.eta,shiptype,c.alliance,attackers, status
+;
+
+CREATE OR REPLACE FUNCTION add_call() RETURNS trigger
+       AS $_X$
+DECLARE
+       thread INTEGER;
+BEGIN
+       INSERT INTO forum_threads (fbid,subject,uid)
+               VALUES(-3,NEW.uid || ': ' || NEW.landing_tick,-3) RETURNING ftid
+               INTO STRICT thread;
+       NEW.ftid = thread;
+       RETURN NEW;
+END;
+$_X$ LANGUAGE plpgsql;
index efec3dd6f955ca6f58d845f15ffdf7577843533e..348884acaa1893c1b18335c37d42f8d10c79f79b 100644 (file)
@@ -189,12 +189,12 @@ sub hostile : Local {
        }
 
        my $query = $dbh->prepare(q{
-               SELECT s.alliance_id AS id,s.alliance AS name,count(*) AS hostile_count
+               SELECT s.aid AS id,s.alliance AS name,count(*) AS hostile_count
 FROM calls c 
-       JOIN incomings i ON i.call = c.id
-       JOIN current_planet_stats s ON i.sender = s.id
+       JOIN incomings i USING (call)
+       JOIN current_planet_stats s USING (pid)
 WHERE c.landing_tick - i.eta > $1 and c.landing_tick - i.eta < $2
-GROUP BY s.alliance_id,s.alliance
+GROUP BY s.aid,s.alliance
 ORDER BY hostile_count DESC
                });
        $query->execute($begintick,$endtick);
index 5c3298a675dddc5581c770c3751c0b11b4dee33d..467c7321fc40451ba6056754c25c852b996e76f9 100644 (file)
@@ -34,17 +34,17 @@ sub list : Local {
        my ( $self, $c, $type ) = @_;
        my $dbh = $c->model;
 
-       my $where = q{open AND landing_tick-6 > tick()};
+       my $where = q{status = 'Open' AND landing_tick-6 > tick()};
        my $order = q{landing_tick DESC, defprio DESC};
        if (defined $type){
                if ($type eq 'covered'){
-                       $where = 'covered';
+                       $where = q{status = 'Covered'};
                }elsif ($type eq 'all'){
                        $where = 'true';
                }elsif ($type eq 'uncovered'){
-                       $where = 'not covered';
+                       $where = q{status <> 'Covered'};
                }elsif ($type eq 'recent'){
-                       $where = q{landing_tick > tick()};
+                       $where = q{landing_tick >= tick()};
                        $order = q{x,y,z};
                }
        }
@@ -90,6 +90,7 @@ sub edit : Local {
                        mission = 'Full fleet'
                        OR tick >= $2 - 12
                )
+       ORDER BY mission,name,tick DESC
 ) UNION (
        SELECT 2 AS type, MAX(fid) AS fid,mission,name,landing_tick AS tick, eta, amount
                , coords(x,y,z), pid AS planet, back
@@ -114,7 +115,7 @@ sub edit : Local {
        my $ships = $dbh->prepare(q{SELECT ship,amount FROM fleet_ships
                WHERE fid = ? ORDER BY num
                });
-       $outgoings->execute($call->{planet},$call->{landing_tick});
+       $outgoings->execute($call->{pid},$call->{landing_tick});
        my @fleets;
        while (my $fleet = $outgoings->fetchrow_hashref){
                if (defined $fleet->{back} &&
@@ -136,7 +137,7 @@ sub edit : Local {
        my $available = $dbh->prepare(q{
 SELECT ship,amount from ships_home WHERE planet = $1 AND tick = $2
                });
-       $available->execute($call->{planet}, $call->{landing_tick});
+       $available->execute($call->{pid}, $call->{landing_tick});
        my $fleet = {fid => $call->{member}, mission => 'Available'
                , name => 'At home', ships => $available->fetchall_arrayref({})
        };
@@ -159,7 +160,7 @@ WHERE mission = 'Defend'
 ORDER BY x,y,z
        });
 
-       $defenders->execute($call->{planet},$call->{landing_tick});
+       $defenders->execute($call->{pid},$call->{landing_tick});
        my @defenders;
        while (my $fleet = $defenders->fetchrow_hashref){
                $ships->execute($fleet->{fid});
@@ -176,16 +177,16 @@ ORDER BY x,y,z
 
        my $attackers = $dbh->prepare(q{
                SELECT coords(p.x,p.y,p.z), p.planet_status, p.race,i.eta,i.amount
-                       ,i.fleet,i.shiptype,p.relationship,p.alliance,i.id,pid AS planet
+                       ,i.fleet,i.shiptype,p.relationship,p.alliance,inc,pid
                FROM incomings i
                        JOIN current_planet_stats p USING (pid)
                WHERE i.call = ?
                ORDER BY p.x,p.y,p.z
        });
-       $attackers->execute($call->{id});
+       $attackers->execute($call->{call});
        my @attackers;
        while(my $attacker = $attackers->fetchrow_hashref){
-               $outgoings->execute($attacker->{planet},$call->{landing_tick});
+               $outgoings->execute($attacker->{pid},$call->{landing_tick});
                my @missions;
                while (my $mission = $outgoings->fetchrow_hashref){
                        if ($mission->{fid}){
@@ -205,24 +206,30 @@ ORDER BY x,y,z
        $c->stash(attackers => \@attackers);
 
        $c->forward('/forum/findPosts',[$call->{ftid}]);
+
+       my $statuses = $dbh->prepare(q{
+SELECT status FROM call_statuses
+               });
+       $statuses->execute;
+       $c->stash(statuses => $statuses->fetchall_arrayref({}));
 }
 
 sub defleeches : Local {
        my ( $self, $c, $type ) = @_;
        my $dbh = $c->model;
 
-       my $query = $dbh->prepare(q{SELECT username,defense_points,count(id) AS calls
+       my $query = $dbh->prepare(q{SELECT username,defense_points,count(call) AS calls
                , SUM(fleets) AS fleets, SUM(recalled) AS recalled
                ,count(NULLIF(fleets,0)) AS defended_calls
-               FROM (SELECT username,defense_points,c.id,count(f.back) AS fleets
+               FROM (SELECT username,defense_points,call,count(f.back) AS fleets
                        , count(NULLIF(f.landing_tick + f.eta -1 = f.back,TRUE)) AS recalled
-                       FROM users u JOIN calls c ON c.member = u.uid
+                       FROM users u JOIN calls c USING (uid)
                                LEFT OUTER JOIN (
                                        SELECT lc.pid,landing_tick,eta,back
                                        FROM launch_confirmations lc JOIN fleets f USING (fid)
                                        WHERE mission = 'Defend'
                                ) f USING (pid,landing_tick)
-                       GROUP BY username,defense_points,c.id
+                       GROUP BY username,defense_points,call
                ) d
                GROUP BY username,defense_points ORDER BY fleets DESC, defense_points
                });
@@ -238,7 +245,7 @@ sub postcallcomment : Local {
        $call = $c->stash->{call};
 
        $c->forward('/forum/insertPost',[$call->{ftid}]);
-       $c->res->redirect($c->uri_for('edit',$call->{id}));
+       $c->res->redirect($c->uri_for('edit',$call->{call}));
 }
 
 sub postcallupdate : Local {
@@ -254,42 +261,39 @@ sub postcallupdate : Local {
 
        $dbh->begin_work;
        if ($c->req->param('cmd') eq 'Submit'){
+               my $logmess = '';
                if ($c->req->param('ctick')){
-                       $dbh->do(q{UPDATE calls SET landing_tick = ? WHERE id = ?}
-                               ,undef,$c->req->param('tick'),$call->{id});
-                       $log->execute($c->user->id,$call->{ftid}
-                               ,"Updated landing tick from [B] $call->{landing_tick} [/B]");
+                       $dbh->do(q{UPDATE calls SET landing_tick = ? WHERE call = ?}
+                               ,undef,$c->req->param('tick'),$call->{call});
+                       $logmess .= "Updated landing tick from [B] $call->{landing_tick} [/B]\n";
                }
                if ($c->req->param('cinfo')){
-                       $dbh->do(q{UPDATE calls SET info = ? WHERE id = ?}
-                               ,undef,$c->req->param('info'),$call->{id});
-                       $log->execute($c->user->id,$call->{ftid},"Updated info");
+                       $dbh->do(q{UPDATE calls SET info = ? WHERE call = ?}
+                               ,undef,$c->req->param('info'),$call->{call});
+                       $logmess .= "Updated info\n";
                }
                if ($c->req->param('ccalc')){
                        my $calc = $c->req->param('calc');
-                       $dbh->do(q{UPDATE calls SET calc = ? WHERE id = ?}
-                               ,undef,$calc,$call->{id});
-                       $log->execute($c->user->id,$call->{ftid},html_escape('Updated calc to: [URL]'.$calc.'[/URL]'));
+                       $dbh->do(q{UPDATE calls SET calc = ? WHERE call = ?}
+                               ,undef,$calc,$call->{call});
+                       $logmess .= html_escape('Updated calc to: [URL]'.$calc."[/URL]\n");
                }
-       }elsif($c->req->param('cmd') =~ /^(Cover|Uncover|Ignore|Open|Take) call$/){
-               my $extra_vars = '';
-               if ($1 eq 'Cover'){
-                       $extra_vars = ", covered = TRUE, open = FALSE";
-               }elsif ($1 eq 'Uncover'){
-                       $extra_vars = ", covered = FALSE, open = TRUE";
-               }elsif ($1 eq 'Ignore'){
-                       $extra_vars = ", covered = FALSE, open = FALSE";
-               }elsif ($1 eq 'Open'){
-                       $extra_vars = ", covered = FALSE, open = TRUE";
+               if ($c->req->param('cstatus')){
+                       $dbh->do(q{UPDATE calls SET status = $1, dc = $2 WHERE call = $3}
+                               ,undef,$c->req->param('status'),$c->user->id,$call->{call});
+                       $logmess .= "Changed status to: ".$c->req->param('status')."\n";
                }
-               $dbh->do(qq{UPDATE calls SET dc = ? $extra_vars WHERE id = ?},
-                       ,undef,$c->user->id,$call->{id});
+               $log->execute($c->user->id,$call->{ftid},$logmess) if $log;
+       }elsif($c->req->param('cmd') =~ /^Take call$/){
+               my $extra_vars = '';
+               $dbh->do(q{UPDATE calls SET dc = ? WHERE call = ?},
+                       ,undef,$c->user->id,$call->{call});
                $log->execute($c->user->id,$call->{ftid}
                        ,'Changed status to: [B]'.$c->req->param('cmd').'[/B]');
        }
        $dbh->commit;
 
-       $c->res->redirect($c->uri_for('edit',$call->{id}));
+       $c->res->redirect($c->uri_for('edit',$call->{call}));
 }
 
 
@@ -306,24 +310,24 @@ sub postattackerupdate : Local {
 
        $dbh->begin_work;
        if($c->req->param('cmd') eq 'Remove'){
-               my $query = $dbh->prepare(q{DELETE FROM incomings WHERE id = ? AND call = ?});
-               my $inc = $dbh->prepare(q{SELECT sender,eta,amount FROM incomings WHERE id = $1});
+               my $query = $dbh->prepare(q{DELETE FROM incomings WHERE inc = ? AND call = ?});
+               my $inc = $dbh->prepare(q{SELECT pid,eta,amount FROM incomings WHERE inc = $1});
                for my $param ($c->req->param()){
                        if ($param =~ /^change:(\d+)$/){
                                my ($planet,$eta,$amount) = $dbh->selectrow_array($inc,undef,$1);
-                               $query->execute($1,$call->{id});
+                               $query->execute($1,$call->{call});
                                $log->execute($c->user->id,$call->{ftid}
                                        ,"Deleted fleet: [B] $1 [/B] ($planet:$eta:$amount)");
                        }
                }
        }elsif($c->req->param('cmd') eq 'Change'){
                my $query = $dbh->prepare(q{UPDATE incomings SET shiptype = ?
-                       WHERE id = ? AND call = ?
+                       WHERE inc = ? AND call = ?
                });
                for my $param ($c->req->param()){
                        if ($param =~ /^change:(\d+)$/){
                                my $shiptype = html_escape($c->req->param("shiptype:$1"));
-                               $query->execute($shiptype,$1,$call->{id});
+                               $query->execute($shiptype,$1,$call->{call});
                                $log->execute($c->user->id,$call->{ftid}
                                        ,"set fleet: [B] $1 [/B] to: [B] $shiptype [/B]");
                        }
@@ -331,7 +335,7 @@ sub postattackerupdate : Local {
        }
        $dbh->commit;
 
-       $c->res->redirect($c->uri_for('edit',$call->{id}));
+       $c->res->redirect($c->uri_for('edit',$call->{call}));
 }
 
 sub findCall : Private {
@@ -339,14 +343,14 @@ sub findCall : Private {
        my $dbh = $c->model;
 
        my $query = $dbh->prepare(q{
-               SELECT c.id, coords(p.x,p.y,p.z), c.landing_tick, c.info, covered
-                       ,open, dc.username AS dc, u.defense_points,c.member AS uid
-                       ,p.pid AS planet, u.username AS member, u.sms,c.ftid,calc
-               FROM calls c 
-               JOIN users u ON c.member = u.uid
+               SELECT call, coords(p.x,p.y,p.z), c.landing_tick, c.info, status
+                       ,dc.username AS dc, u.defense_points,c.uid
+                       ,p.pid, u.username AS member, u.sms,c.ftid,calc
+               FROM calls c
+               JOIN users u USING (uid)
                JOIN current_planet_stats p USING (pid)
                LEFT OUTER JOIN users dc ON c.dc = dc.uid
-               WHERE c.id = ?
+               WHERE call = ?
                });
        $call = $dbh->selectrow_hashref($query,undef,$call);
 
index 388204bd5a74a583b74a6395b255c62949fbc563..64fe55aa21e3f23fa37bdba5a1e1606aac8f2bae 100644 (file)
@@ -227,15 +227,15 @@ sub members : Local {
                ,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
-               ,count(CASE WHEN i.mission = 'Defend' OR i.mission = 'AllyDef' THEN NULLIF(i.ingal OR (t.alliance_id = 1),TRUE) ELSE NULL END) AS bad_def
+               ,count(CASE WHEN i.mission = 'Defend' OR i.mission = 'AllyDef' THEN NULLIF(i.ingal OR (t.alliance = 'NewDawn'),TRUE) ELSE NULL END) AS bad_def
                FROM users u
                JOIN groupmembers gm USING (uid)
-               LEFT OUTER JOIN (SELECT DISTINCT ON (planet) planet,tick from scans where type = 'News' ORDER BY planet,tick DESC) n USING (planet)
-               LEFT OUTER JOIN (SELECT DISTINCT name,eta,tick,sender,target,mission,ingal FROM intel WHERE amount IS NULL) i ON i.sender = u.planet
-               LEFT OUTER JOIN current_planet_stats t ON i.target = t.id
-               LEFT OUTER JOIN (SELECT rt.id,planet,tick FROM raids r 
-                               JOIN raid_targets rt ON r.id = rt.raid) rt ON rt.planet = i.target 
-                       AND (rt.tick + 12) > i.tick AND rt.tick <= i.tick 
+               LEFT OUTER JOIN (SELECT DISTINCT ON (pid) pid,tick from scans where type = 'News' ORDER BY pid,tick DESC) n USING (pid)
+               LEFT OUTER JOIN (SELECT DISTINCT name,eta,tick,sender,target,mission,ingal FROM intel WHERE amount IS NULL) i ON i.sender = u.pid
+               LEFT OUTER JOIN current_planet_stats t ON i.target = t.pid
+               LEFT OUTER JOIN (SELECT rt.id,pid,tick FROM raids r
+                               JOIN raid_targets rt ON r.id = rt.raid) rt ON rt.pid = i.target
+                       AND (rt.tick + 12) > i.tick AND rt.tick <= i.tick
                LEFT OUTER JOIN raid_claims rc ON rt.id = rc.target AND rc.uid = u.uid AND i.tick = rt.tick + rc.wave - 1
                WHERE gm.gid = 2
                GROUP BY u.uid,u.username,u.attack_points, u.defense_points,n.tick
@@ -251,16 +251,16 @@ sub member : Local {
        my $query = $dbh->prepare(q{
                SELECT coords(t.x,t.y,t.z), i.eta, i.tick, rt.id AS ndtarget, rc.launched, inc.landing_tick
                FROM users u
-               LEFT OUTER JOIN (SELECT DISTINCT eta,tick,sender,target,mission,name FROM intel WHERE amount IS NULL) i ON i.sender = u.planet
-               LEFT OUTER JOIN current_planet_stats t ON i.target = t.id
-               LEFT OUTER JOIN (SELECT rt.id,planet,tick FROM raids r 
-                               JOIN raid_targets rt ON r.id = rt.raid) rt ON rt.planet = i.target 
-                       AND (rt.tick + 12) > i.tick AND rt.tick <= i.tick 
+               LEFT OUTER JOIN (SELECT DISTINCT eta,tick,sender,target,mission,name FROM intel WHERE amount IS NULL) i ON i.sender = u.pid
+               LEFT OUTER JOIN current_planet_stats t ON i.target = t.pid
+               LEFT OUTER JOIN (SELECT rt.id,pid,tick FROM raids r
+                               JOIN raid_targets rt ON r.id = rt.raid) rt ON rt.pid = i.target
+                       AND (rt.tick + 12) > i.tick AND rt.tick <= i.tick
                LEFT OUTER JOIN raid_claims rc ON rt.id = rc.target AND rc.uid = u.uid AND i.tick = rt.tick + rc.wave - 1
-               LEFT OUTER JOIN (SELECT sender, eta, landing_tick FROM calls c 
-                                       JOIN incomings i ON i.call = c.id) inc ON inc.sender = i.target 
+               LEFT OUTER JOIN (SELECT pid, eta, landing_tick FROM calls c
+                                       JOIN incomings i USING (call)) inc ON inc.pid = i.target
                                AND (inc.landing_tick + inc.eta) >= i.tick 
-                               AND (inc.landing_tick - inc.eta - 1) <= (i.tick - i.eta) 
+                               AND (inc.landing_tick - inc.eta - 1) <= (i.tick - i.eta)
                WHERE u.uid = $1 AND i.mission = 'Attack'
                ORDER BY (i.tick - i.eta)
                });
@@ -286,10 +286,10 @@ sub member : Local {
        $c->stash(attacks => \@attacks);
 
        $query = $dbh->prepare(q{
-               SELECT coords(t.x,t.y,t.z),t.alliance_id, t.alliance, i.eta, i.tick, i.ingal
+               SELECT coords(t.x,t.y,t.z),t.aid, t.alliance, i.eta, i.tick, i.ingal
                FROM users u
-               JOIN (SELECT DISTINCT name,eta,tick,sender,target,mission,ingal FROM intel WHERE amount IS NULL) i ON i.sender = u.planet
-               LEFT OUTER JOIN current_planet_stats t ON i.target = t.id
+               JOIN (SELECT DISTINCT name,eta,tick,sender,target,mission,ingal FROM intel WHERE amount IS NULL) i ON i.sender = u.pid
+               LEFT OUTER JOIN current_planet_stats t ON i.target = t.pid
                WHERE u.uid = $1 AND (i.mission = 'Defend' OR i.mission = 'AllyDef')
                ORDER BY (i.tick - i.eta)
                });
@@ -299,7 +299,7 @@ sub member : Local {
        my @other_def;
        while (my $intel = $query->fetchrow_hashref){
                my $def = {target => $intel->{coords}, other => $intel->{alliance}, tick => $intel->{tick}};
-               if (defined $intel->{alliance_id} && $intel->{alliance_id} == 1){
+               if ($intel->{alliance} ~~ 'NewDawn'){
                        push @nd_def, $def;
                }elsif($intel->{ingal}){
                        push @ingal_def, $def;
index 10e8fbddd616fc22475570ab0e4f57578ef17d00..fc440a343313e0d9efaa5b163a5abc21fabf4e82 100644 (file)
@@ -61,6 +61,7 @@ sub index : Path : Args(0) {
        my $calls = $dbh->prepare(q{
 SELECT * FROM defcalls
 WHERE uid = $1 AND landing_tick >= tick()
+ORDER BY landing_tick DESC
                });
        $calls->execute($c->user->id);
        $c->stash(calls => $calls->fetchall_arrayref({}) );
@@ -423,8 +424,8 @@ sub postconfirmation : Local {
                        WHERE c.uid = ? AND r.tick+c.wave-1 = ? AND t.pid = ?
                                AND r.open AND not r.removed
                        });
-               my $finddefensetarget = $dbh->prepare(q{SELECT c.id FROM calls c
-                               JOIN users u ON c.member = u.uid
+               my $finddefensetarget = $dbh->prepare(q{SELECT call FROM calls c
+                               JOIN users u USING (uid)
                        WHERE u.pid = $1 AND c.landing_tick = $2
                });
                my $informDefChannel = $dbh->prepare(q{INSERT INTO defense_missions
@@ -524,7 +525,7 @@ sub postconfirmation : Local {
                                }
                        }elsif ($mission eq 'Defend'){
                                my $call = $findtarget->fetchrow_hashref;
-                               $informDefChannel->execute($fleet,$call->{id});
+                               $informDefChannel->execute($fleet,$call->{call});
                        }
 
                        $log->execute($c->user->id,"Pasted confirmation for $mission mission to $x:$y:$z, landing tick $tick");
index 7a809c8d2401a208fb822b8b1fb8c3af74ac51d2..9779a0cdb0e81adac681849632cf45ab87ff602b 100644 (file)
@@ -1,7 +1,7 @@
 [% META title = 'Edit call' %]
 
-<form action="[% c.uri_for('postcallupdate',call.id) %]" method="post">
-<fieldset> <legend>Call details, call# [% call.id %]</legend>
+<form action="[% c.uri_for('postcallupdate',call.call) %]" method="post">
+<fieldset> <legend>Call details, call# [% call.call %]</legend>
 <table>
 <tr>
 <td>
        <li>Calc: <input type="text" name="calc" value="[% call.calc | html %]">
                <input type="checkbox" name="ccalc"></li>
        <li>Change Notes? <input type="checkbox" name="cinfo"></li>
+       <li>Status: <select name="status">[% FOR s IN statuses %]
+               <option value="[% s.status %]"[% IF s.status == call.status %] selected[% END %]>[% s.status %]</option>
+               [% END %]</select><input type="checkbox" name="cstatus"></li>
        <li><input type="submit" name="cmd" value="Submit"></li>
        <li><input type="submit" name="cmd" value="Take call"></li>
-       <li><input type="submit" name="cmd" value="[% cover %] call"></li>
-       <li><input type="submit" name="cmd" value="[% ignore %] call"></li>
 </ul></td>
 </tr>
 </table>
 </fieldset>
 </form>
 <fieldset><legend>Attackers:</legend>
-<form action="[% c.uri_for('postattackerupdate',call.id) %]" method="post">
+<form action="[% c.uri_for('postattackerupdate',call.call) %]" method="post">
        <table>
        <tr>
        <th></th>
        </tr>
 [% FOR a IN attackers %]
        <tr class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
-               <td><input type="button" onclick="$('#attacker[% a.id %]').toggle()" value="&dArr;" title="Show fleets"></td>
+               <td><input type="button" onclick="$('#attacker[% a.inc %]').toggle()" value="&dArr;" title="Show fleets"></td>
                <td><a href="[% c.uri_for('/stats/planet',a.planet) %]">[% a.coords %]</a></td>
                <td class="[% a.planet_status %]">[% a.planet_status %]</td>
                <td class="[% a.relationship %]">[% a.alliance %] ([% a.relationship %])</td>
                <td>[% a.race %]</td>
                <td>[% a.eta %]</td>
                <td>[% a.amount %]</td>
-               <td><input class="coord" type="text" name="shiptype:[% a.id %]" value="[% a.shiptype %]"></td>
+               <td><input class="coord" type="text" name="shiptype:[% a.inc %]" value="[% a.shiptype %]"></td>
                <td>[% a.fleet %]</td>
-               <td><input type="checkbox" name="change:[% a.id %]"></td>
+               <td><input type="checkbox" name="change:[% a.inc %]"></td>
        </tr>
-       <tr id="attacker[% a.id %]" class="hidden">
+       <tr id="attacker[% a.inc %]" class="hidden">
        <td></td>
        <td colspan="8">
        [% PROCESS inc/missionlist.tt2 missions=a.missions %]
@@ -88,7 +89,7 @@
 </fieldset>
 [% END %]
 
-<form action="[% c.uri_for('postcallcomment', call.id) %]" method="post"><fieldset class="forum-post"> <legend>New Reply</legend>
+<form action="[% c.uri_for('postcallcomment', call.call) %]" method="post"><fieldset class="forum-post"> <legend>New Reply</legend>
        <textarea rows="10" cols="60" name="message"></textarea>
        <input type="submit" value="Submit">
 </fieldset></form>
index 2a4aa45fa7b7ca2ac73785a8c356b638a9dcf1fe..ada4f76e78f9906a0510d5b997c5930864921850 100644 (file)
@@ -1,6 +1,6 @@
 [% META title = 'Defense calls' %]
 <table>
-       <tr><th>Call</th><th>DC</th><th>Def Fleets</th><th>Member (defprio)</th><th>Landing tick</th><th>Races</th><th>Amount</th><th>Shiptypes</th><th>ETA</th><th>Alliance</th><th>Attackers</th></tr>
+       <tr><th>Call</th><th>Status</th><th>DC</th><th>Def Fleets</th><th>Member (defprio)</th><th>Landing tick</th><th>Races</th><th>Amount</th><th>Shiptypes</th><th>ETA</th><th>Alliance</th><th>Attackers</th></tr>
 [% newday = game.tick %]
 [% FOR call IN calls %]
        [% WHILE newday - 24 > call.landing_tick %]
@@ -8,7 +8,8 @@
        <tr align="center"><td colspan="4">New day</td></tr>
        [% END %]
        <tr align="center" class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
-               <td class="[% UNLESS call.dc %]Hostile[%END%]"><a href="[% c.uri_for('edit',call.id) %]">[% call.id %]</a></td>
+               <td class="[% UNLESS call.dc %]Hostile[%END%]"><a href="[% c.uri_for('edit',call.call) %]">[% call.call %]</a></td>
+               <td>[% call.status %]</td>
                <td>[% call.dc %]</td>
                <td>[% call.fleets %]</td>
                [% prio = call.defprio < minprio ? 'LowestPrio' :
index 2120afe12ade5fba015d015d90275abdd930cf3a..7f1bc7df92858f2020c13c02bc69f24fe6d698f8 100644 (file)
 [% END %]
 [% IF calls %]
 <table>
-       <tr><th>Call</th><th>DC</th><th>Landing tick</th><th>Races</th><th>Amount</th><th>Shiptypes</th><th>Current eta</th><th>Inital eta</th><th>Attackers</th></tr>
+       <tr><th>Call</th><th>Status</th><th>DC</th><th>Landing tick</th><th>Races</th><th>Amount</th><th>Shiptypes</th><th>Current eta</th><th>Inital eta</th><th>Attackers</th></tr>
        [% FOR call IN calls %]
        <tr align="center" class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
-               <td class="[% UNLESS call.dc %]Hostile[%END%]"><a href="[% c.uri_for('/calls/edit',call.id) %]">[% call.id %]</a></td>
+               <td class="[% UNLESS call.dc %]Hostile[%END%]"><a href="[% c.uri_for('/calls/edit',call.call) %]">[% call.call %]</a></td>
+               <td>[% call.status %]</td>
                <td>[% call.dc %]</td>
                <td>[% call.landing_tick %]</td>
                <td>[% call.race.unique.join('/') %]</td>