]> ruin.nu Git - ndwebbie.git/blobdiff - calls.pl
member intel, shows all incoming and outgoing fleets for member planets
[ndwebbie.git] / calls.pl
index 60f6496e1d4013f7d08286d0764293a4b40ad6bf..9c3c3e0a1f68ad714e0a5bcba33bad1aef630272 100644 (file)
--- a/calls.pl
+++ b/calls.pl
@@ -22,10 +22,11 @@ use POSIX;
 our $BODY;
 our $DBH;
 our $LOG;
+my $error;
 
 $ND::TEMPLATE->param(TITLE => 'Defense Calls');
 
-die "You don't have access" unless isBC();
+die "You don't have access" unless isDC();
 
 my $call;
 if (param('call') =~ /^(\d+)$/){
@@ -40,26 +41,28 @@ WHERE c.id = ?});
 }
 if ($call){
        if (param('cmd') eq 'Submit'){
-       }elsif (param('cmd') eq 'Submit'){
                $DBH->begin_work;
                if (param('ctick')){
                        if ($DBH->do(q{UPDATE calls SET landing_tick = ? WHERE id = ?}
                                        ,undef,param('tick'),$call->{id})){
                                $call->{landing_tick} = param('tick');
+                               $LOG->execute($ND::UID,"DC updated landing tick for call $call->{id}");
                        }else{
-                               print "<p> Something went wrong: ".$DBH->errstr."</p>";
+                               $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                        }
                }
-               if (param('info')){
+               if (param('cinfo')){
                        if ($DBH->do(q{UPDATE calls SET info = ? WHERE id = ?}
                                        ,undef,param('info'),$call->{id})){
                                $call->{info} = param('info');
+                               $LOG->execute($ND::UID,"DC updated info for call $call->{id}");
                        }else{
-                               print "<p> Something went wrong: ".$DBH->errstr."</p>";
+                               $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                        }
                }
-               $DBH->commit or print "<p> Something went wrong: ".$DBH->errstr."</p>";
-       }elsif(param('cmd') =~ /^(Cover|Uncover|Ignore|Open) call$/){
+               $DBH->commit or $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
+       }elsif(param('cmd') =~ /^(Cover|Uncover|Ignore|Open|Take) call$/){
+               $error .= "test";
                my $extra_vars = '';
                if (param('cmd') eq 'Cover call'){
                        $extra_vars = ", covered = TRUE, open = FALSE";
@@ -74,8 +77,9 @@ if ($call){
                        ,undef,$ND::UID,$call->{id})){
                        $call->{covered} = (param('cmd') eq 'Cover call');
                        $call->{open} = (param('cmd') =~ /^(Uncover|Open) call$/);
+                       $call->{DC} = $ND::USER;
                }else{
-                       print "<p> Something went wrong: ".$DBH->errstr."</p>";
+                       $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                }
        }elsif(param('cmd') eq 'Remove'){
                $DBH->begin_work;
@@ -85,11 +89,11 @@ if ($call){
                                if($query->execute($1,$call->{id})){
                                        $LOG->execute($ND::UID,"DC deleted fleet: $1, call $call->{id}");
                                }else{
-                                       print "<p> Something went wrong: ".$DBH->errstr."</p>";
+                                       $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                                }
                        }
                }
-               $DBH->commit or print "<p> Something went wrong: ".$DBH->errstr."</p>";
+               $DBH->commit or $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
        }elsif(param('cmd') eq 'Change'){
                $DBH->begin_work;
                my $query = $DBH->prepare(q{UPDATE incomings SET shiptype = ? WHERE id = ? AND call = ?});
@@ -99,11 +103,11 @@ if ($call){
                                if($query->execute($shiptype,$1,$call->{id})){
                                        $LOG->execute($ND::UID,"DC set fleet: $1, call $call->{id} to: $shiptype");
                                }else{
-                                       print "<p> Something went wrong: ".$DBH->errstr."</p>";
+                                       $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                                }
                        }
                }
-               $DBH->commit or print "<p> Something went wrong: ".$DBH->errstr."</p>";
+               $DBH->commit or $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
        }
 }
 
@@ -114,15 +118,16 @@ if ($call){
        $BODY->param(LandingTick => $call->{landing_tick});
        $BODY->param(ETA => $call->{landing_tick}-$ND::TICK);
        $BODY->param(Info => $call->{info});
+       $BODY->param(DC => $call->{dc});
        if ($call->{covered}){
                $BODY->param(Cover => 'Uncover');
        }else{
                $BODY->param(Cover => 'Cover');
        }
        if ($call->{open} && !$call->{covered}){
-               $BODY->param(Cover => 'Ignore');
+               $BODY->param(Ignore => 'Ignore');
        }else{
-               $BODY->param(Cover => 'Open');
+               $BODY->param(Ignore => 'Open');
        }
        my $fleets = $DBH->prepare(q{
 SELECT id,mission,landing_tick,eta, (landing_tick+eta-1) AS back FROM fleets WHERE uid = ? AND (fleet = 0 OR (landing_tick + eta > ? AND landing_tick - eta - 11 < ? ))
@@ -180,8 +185,8 @@ FROM calls c
 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;
+               })or $error .= $DBH->errstr;
+       $query->execute or $error .= $DBH->errstr;
        my @calls;
        my $i = 0;
        while (my $call = $query->fetchrow_hashref){
@@ -191,4 +196,5 @@ ORDER BY c.landing_tick DESC
        }
        $BODY->param(Calls => \@calls);
 }
+$BODY->param(Error => $error);
 1;