X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=calls.pl;h=9c3c3e0a1f68ad714e0a5bcba33bad1aef630272;hb=5af89dd22a075c6652b779ef471bf21cb9965cb6;hp=e063882ec01720443c9f82a8105fbc15f9336770;hpb=e9f12b8d4ba3651c8e78094d84cd825afb816794;p=ndwebbie.git diff --git a/calls.pl b/calls.pl index e063882..9c3c3e0 100644 --- 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,27 +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 "

Something went wrong: ".$DBH->errstr."

"; + $error .= "

Something went wrong: ".$DBH->errstr."

"; } } - 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 "

Something went wrong: ".$DBH->errstr."

"; + $error .= "

Something went wrong: ".$DBH->errstr."

"; } } - $DBH->commit or print "

Something went wrong: ".$DBH->errstr."

"; + $DBH->commit or $error .= "

Something went wrong: ".$DBH->errstr."

"; }elsif(param('cmd') =~ /^(Cover|Uncover|Ignore|Open|Take) call$/){ - print "test"; + $error .= "test"; my $extra_vars = ''; if (param('cmd') eq 'Cover call'){ $extra_vars = ", covered = TRUE, open = FALSE"; @@ -77,7 +79,7 @@ if ($call){ $call->{open} = (param('cmd') =~ /^(Uncover|Open) call$/); $call->{DC} = $ND::USER; }else{ - print "

Something went wrong: ".$DBH->errstr."

"; + $error .= "

Something went wrong: ".$DBH->errstr."

"; } }elsif(param('cmd') eq 'Remove'){ $DBH->begin_work; @@ -87,11 +89,11 @@ if ($call){ if($query->execute($1,$call->{id})){ $LOG->execute($ND::UID,"DC deleted fleet: $1, call $call->{id}"); }else{ - print "

Something went wrong: ".$DBH->errstr."

"; + $error .= "

Something went wrong: ".$DBH->errstr."

"; } } } - $DBH->commit or print "

Something went wrong: ".$DBH->errstr."

"; + $DBH->commit or $error .= "

Something went wrong: ".$DBH->errstr."

"; }elsif(param('cmd') eq 'Change'){ $DBH->begin_work; my $query = $DBH->prepare(q{UPDATE incomings SET shiptype = ? WHERE id = ? AND call = ?}); @@ -101,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 "

Something went wrong: ".$DBH->errstr."

"; + $error .= "

Something went wrong: ".$DBH->errstr."

"; } } } - $DBH->commit or print "

Something went wrong: ".$DBH->errstr."

"; + $DBH->commit or $error .= "

Something went wrong: ".$DBH->errstr."

"; } } @@ -183,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){ @@ -194,4 +196,5 @@ ORDER BY c.landing_tick DESC } $BODY->param(Calls => \@calls); } +$BODY->param(Error => $error); 1;