# ties all these subroutines together. sub PrintForm { # calling from improve if ($method eq "query"){ $user = $query{'user'}; $station = $query{'topstation'}; $topgraph = $query{'topgraph'}; $bottomstation = $query{'bottomstation'}; $bottomgraph = $query{'bottomoption'}; $topfrom = $query{'topfrom'}; $topto = $query{'topto'}; $botfrom = $query{'botfrom'}; $botto = $query{'botto'}; } # calling from map link if ($method eq "map"){ $user = $query{'user'}; $station = $query{'map'}; $topgraph = "nitrogen"; $bottomstation = $query{'map'}; $bottomgraph = "precip"; $topfrom = $query{'topfrom'}; $topto = $query{'topto'}; $botfrom = $query{'botfrom'}; $botto = $query{'botto'}; } # calling from submit on form elsif ($method eq "form"){ $user = $form{'user'}; $station = $form{'topstation'}; $topgraph = $form{'topgraph'}; $bottomstation = $form{'bottomstation'}; $bottomgraph = $form{'bottomoption'}; $topfrom = $form{'topfrom'}; $topto = $form{'topto'}; $botfrom = $form{'botfrom'}; $botto = $form{'botto'}; } if ($topgraph eq 'nitrogen'){ $stationtitle = "Nitrogen Concentration (mg/L)"; } elsif ($topgraph eq 'phosphorus'){ $stationtitle = "Phosphorus (Mg/L)"; } elsif ($topgraph eq 'sediments'){ $stationtitle = "Sediments (Mg/L)"; } elsif ($topgraph eq 'heavymetal'){ $stationtitle = "Heavy Metal (Mg/L)"; } elsif ($topgraph eq 'toxins'){ $stationtitle = "Toxins (Mg/L)"; } elsif ($topgraph eq 'watertemp'){ $stationtitle = "Water Temperature (Degrees Celsius)"; } elsif ($topgraph eq 'temperature'){ $stationtitle = "Air Temperature (Degrees Celsius)"; } elsif ($topgraph eq 'precip'){ $stationtitle = "Precipitation (Inches)"; } elsif ($topgraph eq 'ph'){ $stationtitle = "pH"; } elsif ($topgraph eq 'do'){ $stationtitle = "Dissolved Oxygen (Mg/L)"; } elsif ($topgraph eq 'bod'){ $stationtitle = "BOD (Mg/L)"; } elsif ($topgraph eq 'saturateddo'){ $stationtitle = "Saturated DO (Mg/L)"; } elsif ($topgraph eq 'runoff'){ $stationtitle = "Runoff (Inches)"; } if ($bottomgraph eq 'nitrogen'){ $bottomstationtitle = "Nitrogen Concentration (mg/L)"; } elsif ($bottomgraph eq 'phosphorus'){ $bottomstationtitle = "Phosphorus (Mg/L)"; } elsif ($bottomgraph eq 'sediments'){ $bottomstationtitle = "Sediments (Mg/L)"; } elsif ($bottomgraph eq 'heavymetal'){ $bottomstationtitle = "Heavy Metal (Mg/L)"; } elsif ($bottomgraph eq 'toxins'){ $bottomstationtitle = "Toxins (Mg/L)"; } elsif ($bottomgraph eq 'watertemp'){ $bottomstationtitle = "Water Temperature"; } elsif ($bottomgraph eq 'temperature'){ $bottomstationtitle = "Air Temperature"; } elsif ($bottomgraph eq 'precip'){ $bottomstationtitle = "Precipitation (Inches)"; } elsif ($bottomgraph eq 'ph'){ $bottomstationtitle = "pH (Mg/L)"; } elsif ($bottomgraph eq 'do'){ $bottomstationtitle = "Dissolved Oxygen"; } elsif ($bottomgraph eq 'bod'){ $bottomstationtitle = "BOD (Mg/L)"; } elsif ($bottomgraph eq 'saturateddo'){ $bottomstationtitle = "Saturated DO (Mg/L)"; } elsif ($bottomgraph eq 'runoff'){ $bottomstationtitle = "Runoff (Inches)"; } PrintHtmlHeader(); PrintLeftColumn(); PrintLeftColumnLinks(); PrintTopGraph(); PrintBottomGraph(); PrintHtmlFooter(); } sub PrintHtmlHeader { # $html = 0; print "Content-type: text/html\n\n"; # print 'test'; print <<"HTML"; Station Comparison Page
HTML } sub PrintLeftColumn { print <<"HTML";
HTML print "\n"; if ($station eq "0"){ print "\n";} else { print "\n";} if ($station eq "1"){ print "\n";} else { print "\n";} if ($station eq "2"){ print "\n";} else { print "\n";} if ($station eq "3"){ print "\n";} else { print "\n";} print "\n"; print "\n"; if ($station eq "4"){ print "\n";} else { print "\n";} if ($station eq "5"){ print "\n";} else { print "\n";} if ($station eq "6"){ print "\n";} else { print "\n";} if ($station eq "7"){ print "\n";} else { print "\n";} print "\n"; print <<"HTML"; HTML print "\n"; print "\n"; print "\n"; print "\n"; # print <<"HTML"; HTML print ""; if ($bottomstation eq "0"){ print "\n";} else { print "\n";} if ($bottomstation eq "1"){ print "\n";} else { print "\n";} if ($bottomstation eq "2"){ print "\n";} else { print "\n";} if ($bottomstation eq "3"){ print "\n";} else { print "\n";} print ""; print ""; if ($bottomstation eq "4"){ print "\n";} else { print "\n";} if ($bottomstation eq "5"){ print "\n";} else { print "\n";} if ($bottomstation eq "6"){ print "\n";} else { print "\n";} if ($bottomstation eq "7"){ print "\n";} else { print "\n";} print ""; print <<"HTML"; HTML print "\n"; print "\n"; print "\n"; print "\n"; print "


Top Display:
Select a Station
00112233
44556677
Select Indicator
Dayto
 
Bottom Display:
Select a Station
00112233
44556677
Select Indicator
Dayto
"; } sub PrintLeftColumnLinks { print <<"HTML";

Display Assignment
Display Map

ImageMap - turn on images!!!
       HTML } sub PrintTopGraph { print "Station $station: $stationtitle
"; $changed = 0; # HasImprovementBeenMade sets $changed to 1 if changed HasImprovementBeenMade($bottomstation); $bottomch = $changed; $changed = 0; HasImprovementBeenMade($station); $alen = ($topto - $topfrom); $blen = ($botto - $botfrom); # print "ALEN: $alen. BLEN: $blen"; if (($alen == $blen) && ($changed == $bottomch)){ print "scatter plots of current parameters"; print " Help"; } else { print "Scatter Plot Help"; } print " Notepad

"; print "\n"; $locale = "top"; DecideAsssignmentHeader("top"); if (($station != '7') && ($station != '0')){ DecideImproveOrRetract("top"); } PrintGraphLocation("top"); CanImprovementsBeMade("top"); $locale = 0; } sub PrintBottomGraph { $changed = 0; # HasImprovementBeenMade sets $changed to 1 if changed HasImprovementBeenMade($bottomstation); $locale = "bottom"; PrintGraphLocation("bottom"); DecideAsssignmentHeader("bottom"); # generalinfo.pl if (($bottomstation != '7') && ($bottomstation != '0')){ DecideImproveOrRetract("bottom"); } CanImprovementsBeMade("bottom"); $locale = 0; } sub PrintHtmlFooter { print <<"HTML";
  
HTML } sub DecideImproveOrRetract { if ($changed == 0){ # we need to print implement best management link print "Implement Improvement"; } elsif ($changed == 1){ # we need to print retract best management link print "Retract Improvement
"; } } sub PrintGraphLocation { if ("@_" eq "top"){ # if display is either Air Temp or Precip, Station 0 # display existing plotted graph (easy, easy) # we're not using this section right now. precipitation is # plotted on the fly by the model if ($topgraph eq "notprecip"){ print <<"HTML";
$graphtitle


View Data
HTML } # else we need to plot the graphic on the fly.. else { # define variables for GenerateGraph # $changed, @_, #$orderforplot = ; if ($topgraph eq "nitrogen"){ $parameter = '1';} elsif ($topgraph eq "phosphorus"){ $parameter = '2';} elsif ($topgraph eq "sediments"){ $parameter = '3';} elsif ($topgraph eq "heavymetal"){ $parameter = '4';} elsif ($topgraph eq "toxins"){ $parameter = '5';} elsif ($topgraph eq "watertemp"){ $parameter = '6';} elsif ($topgraph eq "temperature"){ $parameter = '11';} elsif ($topgraph eq "ph"){ $parameter = '7';} elsif ($topgraph eq "do"){ $parameter = '8';} elsif ($topgraph eq "bod"){ $parameter = '9';} elsif ($topgraph eq "saturateddo"){ $parameter = '10';} elsif ($topgraph eq "precip"){ $parameter = '12';} elsif ($topgraph eq "runoff"){ $parameter = '13';} $orderforplot = ''; $aa = 0; $skip = 0; while ($aa < 6){ if ("$order[$aa]"){ $orderforplot = ("$orderforplot" . "$order[$aa]"); $skip++; } else { $orderforplot = ("$orderforplot" . "0"); } $aa++; } $start = $topfrom; $end = $topto; if ($skip == 6){$changed = 1;} $region = $station; $pid = $$; $topgraphic = GenerateGraph(); if ($topgraphic){ print "

\n"; print "
\n"; # print "
\n"; print "

\n"; if ($changed == 0){ print "View pre-implementation Data
\n"; } elsif ($changed == 1){ print "View pre-implementation Data | \n"; print "View post-implementation Data
\n"; } print "
\n"; } else { print "
\n"; print "
\n"; print "Unable to create Graphic for Parameter: $error\n
\n"; } } } elsif ("@_" eq "bottom"){ if ($bottomgraph eq "notprecip"){ print <<"HTML";
$bottomgraphtitle


View pre-implementation Data
HTML } # else we need to plot the graphic on the fly.. else { # define variables for GenerateGraph # $changed, @_, #$orderforplot = ; if ($bottomgraph eq "nitrogen"){ $parameter = '1';} elsif ($bottomgraph eq "phosphorus"){ $parameter = '2';} elsif ($bottomgraph eq "sediments"){ $parameter = '3';} elsif ($bottomgraph eq "heavymetal"){ $parameter = '4';} elsif ($bottomgraph eq "toxins"){ $parameter = '5';} elsif ($bottomgraph eq "watertemp"){ $parameter = '6';} elsif ($bottomgraph eq "precip"){ $parameter = '12';} elsif ($bottomgraph eq "temperature"){ $parameter = '11';} elsif ($bottomgraph eq "ph"){ $parameter = '7';} elsif ($bottomgraph eq "do"){ $parameter = '8';} elsif ($bottomgraph eq "bod"){ $parameter = '9';} elsif ($bottomgraph eq "saturateddo"){ $parameter = '10';} elsif ($bottomgraph eq "runoff"){ $parameter = '13';} $region = $bottomstation; $skip =0; $orderforplot = ''; $aa = 0; while ($aa < 6){ if ("$order[$aa]"){ $orderforplot = ("$orderforplot" . "$order[$aa]"); $skip++; } else { $orderforplot = ("$orderforplot" . "0"); } $aa++; } $start = $botfrom; $end = $botto; if ($skip == 6){$changed = 1;} $pid = ($$ + 1); $bottomgraphic = GenerateGraph(); if ($bottomgraphic){ # print "
\n"; print "
\n"; print "Station $bottomstation: $bottomstationtitle\n"; print "

\n"; # print "\n"; print "

\n"; if ($changed == 0){ print "View pre-implementation Data
\n"; } elsif ($changed == 1){ print "View pre-implementation Data | \n"; print "View post-implementation Data
\n"; } #print " Notepad

"; print "
\n"; } else { print "
\n"; print "
\n"; print "Unable to create Graphic for Parameter: $error\n"; } } } } sub CanImprovementsBeMade { if ("@_" eq "top"){ $noprinttwice = "no"; if (($station eq '7') && ($done eq "no")){ print <<"HTML";
Improvements can still be made to the watershed.
To display changed water conditions for Station 7,
Improve all of the stations.
HTML $noprinttwice = "yes"; } } elsif ("@_" eq "bottom"){ if (($bottomstation eq '7') && ($done eq "no") && ($noprinttwice eq "no")){ print <<"HTML";
Improvements can still be made to the watershed.
To display changed water conditions for Station 7,
Improve all of the stations.
HTML } } } 1;