<?php
require_once "../../config/settings.inc.php";
require_once "../../include/myview.php";
$t = new MyView();
require_once "../../include/forms.php";
$t->title = "Climatology by Year";

$year = get_int404("year", date("Y") - 1);
$prod = get_int404("prod", 1);

$products = array(
    1 => array(
        "name" => "Total Precipitation",
        "tpl" => "/archive/data/%Y/summary/total_precip.png"
    ),
    2 => array(
        "name" => "Days with Precipitation",
        "tpl" => "/archive/data/%Y/summary/precip_days.png"
    ),
    20 => array(
        "name" => "Average High Temperature",
        "tpl" => "/archive/data/%Y/summary/avg_high.png"
    ),
    21 => array(
        "name" => "Average Low Temperature",
        "tpl" => "/archive/data/%Y/summary/avg_low.png"
    ),
    22 => array(
        "name" => "Average Temperature",
        "tpl" => "/archive/data/%Y/summary/avg_temp.png"
    ),

);

$ts = new DateTime("{$year}-01-01");
$imgurl = str_replace("%Y", $ts->format("Y"), $products[$prod]["tpl"]);

$a = "";
foreach ($products as $key => $ar) {
    $a .= sprintf(
        "<option value=\"%s\" %s>%s",
        $key,
        ($prod == $key) ? "SELECTED" : "",
        $ar["name"]
    );
}
$ys = yearSelect(1893, $year);

$t->content = <<<EOM
<h3>Yearly Summaries</h3>
<p>Please select from the following menu to view an analysis map of your 
choice.  Some of these maps are generated by a griding of once daily NWS COOP 
observations.  Data quality is always an issue, so please exercise caution
when using these plots.</p>

<div style="border: 1px solid #000; padding: 5px;">
<form name="selector" action="year.phtml">
<strong>Year:</strong> {$ys} 
<strong>Product:</strong> <select name="prod">{$a}</select>
<input type="submit" value="Request Plot">
<br />
<img src="{$imgurl}" alt="plot" />
</form>
</div>
EOM;
$t->render('single.phtml');
