<?php
require_once "../../../config/settings.inc.php";
define("IEM_APPID", 87);
require_once "../../../include/forms.php";
require_once "../../../include/myview.php";
$t = new MyView();
$t->title = "SCAN Plotting";

$station = isset($_GET["station"]) ? xssafe($_GET["station"]) : "S2031";
$year = get_int404("year", date("Y", time() - 1 * 86400));
$month = get_int404("month", date("m", time() - 1 * 86400));
$day = get_int404("day", date("d", time() - 1 * 86400));
$plot = get_int404("plot", 0);

$u = array("radn5temps.php", "radn5temps2.php", "smv.php", "winds.php", "precip.php");
$ulabel = array(
    "Soil Temps + Solar Rad",
    "Soil/Air Temps + Solar Rad",
    "Soil Moisture + Solar Rad",
    "Wind Speed + Direction",
    "Precipitation"
);
$myu = $u[$plot];

$ploturl = "$myu?station=$station&amp;year=$year&amp;month=$month&amp;day=$day";

$sselect = networkSelect("SCAN", $station);
$yselect = yearSelect(2004, $year, "year");
$mselect = monthSelect($month, "month");
$dselect = daySelect($day, "day");
$pselect = "<select name=\"plot\">";
foreach ($u as $key => $val) {
    $pselect .= sprintf(
        "<option value=\"%s\"%s>%s</option>",
        $key,
        ($key == $plot) ? ' selected="selected"' : '',
        $ulabel[$key]
    );
}
$pselect .= "</select>";
$t->content = <<<EOM
<ol class="breadcrumb">
<li><a href="/scan/">SCAN</a></li>
<li class="active">Current/Historical Data Traces</li>
</ol>

<p>This application generates a single day time series plot of SCAN data.</p>

<form method="GET" action="index.phtml" name="control">
<table class="table table-striped">
<thead>
<tr>
  <th>SCAN Site:</th>
  <th>Plot Type:</th>
  <th>Year:</th>
  <th>Month:</th>
  <th>Day:</th></tr>
</thead>
<tbody>
<tr>
  <td>{$sselect}</td>
  <td>{$pselect}</td>
  <td>{$yselect}</td>
  <td>{$mselect}</td>
  <td>{$dselect}</td>
  <td><input type="submit" value="Make Plot!"></td>
</tr>
</tbody>
</table></form>

<img src="{$ploturl}">
EOM;
$t->render("single.phtml");
