#!/usr/bin/perl

$bin = qw( /usr/home/tukey/bin );
require qq($bin/common2.pl);
unshift @INC,$bin;
$ENV{PATH} = "$bin:$ENV{PATH}" unless($ENV{PATH} =~ m($bin));
($C) = ($0 =~ m|([^/]*)$|);
$C =~ s/[?&#].*//;
use subs ("DE"."BUG", qw(Usage Die Warn Print));
# ChDir("/usr/www/users/tukey/acs/marmacs.org/surveys");
 &RunMeAsOwner;
# %FORM = &cgiVals;
# require My::Margin;
&ContentType;

#================ config:bgn ================= {

$file     = "pharmresults.txt";
$PgTitle  = "Pharmaceutics Workshop Planners Admin Page";
$back     = "../Pharmaceutics_Workshop_for_MARM_2007_v2.htm";

$People   = <<EOF4;
<li>
Session Chair: 
<b>Zelleka Getahun</b>,
301-827-5794, 
<a href="mailto:zelleka.getahun@fda.hhs.gov">zelleka.getahun@fda.hhs.gov</a>
</li>

<li>
Webmaster:  <b>Paul Tukey</b>,  h:908-273-7889, w:732-699-2681, mobile:908-591-4759,
<a href="mailto:webmaster\@marmacs.org">webmaster\@marmacs.org</a>
</li>
EOF4

#================ config:end ================= }

$template = $C;
$show     = "showtable1.pl";
$base     = $file;
$base     =~ s/\.[a-z0-9]*$//;
unless(-f "$base.xls") {
    `ln -s $file "$base.xls"`;
}

#{
print <<EOF1;
<html>
<head>
<title>$PgTitle</title>
<link href="common.css" rel="stylesheet" type="text/css">
<link href="marm.css" rel="stylesheet" type="text/css">
<style>
body {
	background:gainsboro;
}
li, .li  {
    margin-top:6pt;
    margin-bottom:6pt;
}
a:link, .a:link, a:visited, .a:visited {
    text-decoration:underline;
}
</style>
</head>
<body bgcolor=lightyellow>

<center><a href="$back" ><img src="../graf/ptr-up.gif" width=16 height=9 border=0 alt="Back" title="Back"></a></center>
<p class=subhead12 align=center>$PgTitle</p>
<hr>

<ul style="margin-top:0pt;margin-bottom:6pt;" >

<li>
Survey results:
&nbsp;[&nbsp; <a href="$base.txt">as txt</a>
&nbsp;|&nbsp; <a href="$base.xls">as xls</a>
&nbsp;|&nbsp; <a href="$show?file=$base.txt&template=$template">as table</a>
&nbsp;|&nbsp; <a href="$show?file=$base.txt&template=$template&as=textarea">as textarea</a>
&nbsp;]&nbsp;
&nbsp;
</li>

<li> <a href="$show?file=$base.txt&template=$template&action=timestamp" >
Time-stamp the grid</a>
</li>

<li> <a href="$show?file=$base.txt&template=$template&action=clear" >Clear the grid</a>, leaving only a timestamp&nbsp; (but making a backup first!)
</li>

</ul>
<table><tr><td cellpadding=0 cellspacing=0 border=0 height=2></td></tr></table x=halfspace>
<hr style="margin-top:0pt;margin-bottom:0pt;" >
<ul style="margin-top:0pt;margin-bottom:0pt;" >

$People

</ul>
EOF1
#}

## Look for and list recent past months:

## Change this to look for BAK/ files less than 90 days old. 
## Set up the usual four views for each hit.
## Hide the section with a toggle
## It would be nice to include counts of non-# non-blank lines
## It would be nice to offer a diff operator!

($DOW,$Month,$day,$Time,$Year) = (split / +/, "".(localtime time));
(@Months) = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Aug Nov Dec);
$i = -1;
for $m (0..11) {
    $i = $m if($Months[$m] eq $Month);
}
$hr = "<hr>\n";
for $j (0..3) {
    $k = ($i - $j) %12;
    $Mon = $Months[$k];
    $txt = "$base-$Mon.txt";
    $xls = "$base-$Mon.xls";
    next unless(-f $txt);
    $mtime = mtime($txt);
    $now = time;
    $daysold = int(($now - $mtime)/(60*60*24));
    next if($daysold > 180);
    `ln -s $txt $xls` unless(-f $xls);

#{
print <<EOF2;
$hr
<ul style="margin-top:0pt;margin-bottom:0pt;" >
<li>
Online registration results from $Mon:
&nbsp;[&nbsp; <a href="$txt">$txt</a>
&nbsp;|&nbsp; <a href="$xls">$xls</a>
&nbsp;|&nbsp; <a href="$show?file=$txt&template=$template">as table</a>
&nbsp;|&nbsp; <a href="$show?file=$txt&template=$template&as=textarea">as textarea</a>
&nbsp;]&nbsp;
&nbsp;
</li>
</ul>
EOF2

#}

    $hr = "";
}

print <<EOF3;
<hr>
</body>
<html>
EOF3

1;

