$qa
$routeparams
</%args>
-<&| script &>
- da_pageload= Date.now();
-</&script>
+<& query_age:pageload &>
<%perl>
% } # ========== OPTIMISATION ==========
+% if (!printable($m)) {
<h2>Contents</h2>
<ul>
% if ($optimise) {
<li><a href="#plan">Voyage trading plan</a>
<ul>
<li><a href="#summary">Summary statistics</a>
+ <li>Printable:
+ <input type=submit name=printable_pdf value="PDF">
+ <input type=submit name=printable_html value="HTML">
+ <input type=submit name=printable_ps value="PostScript">
</ul>
% }
+ <li><a href="#dataage">Data age summary</a>
<li><a href="#trades">Relevant trades</a>
</ul>
+% }
% if ($optimise) { # ========== TRADING PLAN ==========
%
%
% } # ========== TRADING PLAN ==========
-% my %ts_sortkeys;
-% {
+% if (!printable($m)) {
+<h2><a name="dataage">Data age summary</a></h2>
+<%perl>
+ my $sth_i= $dbh->prepare(<<END);
+ SELECT archipelago, islandid, islandname, timestamp
+ FROM uploads NATURAL JOIN islands
+ WHERE islandid = ?
+END
+ my $sth_a= $dbh->prepare(<<END);
+ SELECT archipelago, islandid, islandname, timestamp
+ FROM uploads NATURAL JOIN islands
+ WHERE archipelago = ?
+ ORDER BY islandname
+END
+ my $ix=$#islandids;
+ my $sth_current;
+ my %idone;
+ my $fetchrow= sub {
+ for (;;) {
+ if ($sth_current) {
+ my $row= $sth_current->fetchrow_hashref();
+ if ($row) {
+ next if $idone{$row->{'islandid'}}++;
+ return $row;
+ }
+ }
+ return undef if $ix < 0;
+ my $iid= $islandids[$ix];
+ if (defined $iid) {
+ $sth_i->execute($iid);
+ $sth_current= $sth_i;
+ } else {
+ my $arch= $archipelagoes[$ix];
+ die unless defined $arch && length $arch;
+ $sth_a->execute($arch);
+ $sth_current= $sth_a;
+ }
+ $ix--;
+ }
+ };
+</%perl>
+<&| query_age:agestable, now => $now, fetchrow => $fetchrow &>
+Islands shown in reverse order of visits.<br>
+</&>
+% } else {
+% my @tl= gmtime $now or die $!;
+<p>
+Generated by YARRG at <strong><%
+ sprintf "%04d-%02d-%02d %02d:%02d:%02d UTC",
+ $tl[5]+1900, @tl[4,3,2,1,0]
+ |h %></strong>.
+%#
+% }
+
+% if (!printable($m)) {
+% my %ts_sortkeys;
+% {
% my $cdspan= $qa->{ShowStalls} ? ' colspan=2' : '';
% my $cdstall= $qa->{ShowStalls} ? '<th>Stall</th>' : '';
<h2><a name="trades">Relevant trades</a></h2>
<th>Capital
<th>Profit
% }
-% }
+% }
<tr id="trades_sort">
-% foreach my $col (@cols) {
+% foreach my $col (@cols) {
<th>
-% }
+% }
-% foreach my $flowix (0..$#flows) {
+% foreach my $flowix (0..$#flows) {
% my $flow= $flows[$flowix];
% my $rowid= "id_row_$flow->{UidShort}";
<tr id="<% $rowid %>" class="datarow<% $flowix & 1 %>">
%>><% exists $spec->{String} ? $spec->{String} : $v |h %>
% $ci += $spec->{Span};
% }
-% }
+% }
<tr id="trades_total">
<th>
<th colspan=2>Total
-% foreach my $ci (3..$#cols) {
+% foreach my $ci (3..$#cols) {
% my $col= $cols[$ci];
<td align=right>
% if (defined $col->{Total}) {
<% $col->{Total} |h %>
% }
-% }
+% }
</table>
<&| tabsort, cols => \@cols, table => 'trades', rowclass => 'datarow',
<input type=submit name=update value="Update">
+% } # !printable
+
<%init>
use CommodsWeb;
use Commods;