<?php 
require_once "../../../config/settings.inc.php";
define("IEM_APPID", 118);
require_once "../../../include/myview.php";
require_once "../../../include/forms.php";

$t = new MyView();
$t->title = "NWS COOP Daily Normals";

$year = date("Y");
$network = isset($_REQUEST['network']) ? xssafe($_REQUEST['network']) : 'IACLIMATE';
$nselect = networkSelect($network, "");
$mselect = monthSelect("month");
$dselect = daySelect("day");

$sselect = selectNetworkType("CLIMATE", $network);

$t->content = <<<EOM

<p>With this interface, you can download daily climate normals for NWS COOP
sites.  Please fill out the form below:</p>

<p>Data is available from the following states: 
<form name="sss" method="GET">
{$sselect}
<input type="submit" value="Select State">
</form>

<form method="GET" action="/cgi-bin/request/normals.py" name="dl">
<input type="hidden" name="network" value="{$network}">
<h3>1. Climatology Source:</h3>

<p>The IEM maintains a set of station idenitifers that does not exactly match
what NCEI uses.  When you select the NCEI climatology and an IEM station identifier,
you are getting the cross reference between the two idenitifer sets.  Hopefully, this
is generally one to one, but it could be "nearest station"</p>

<strong>Select Data Source</strong><br />
 <select name="source">
    <option value="climate">IEM Climatology 1893-{$year}</option>
    <option value="climate51">IEM Climatology 1951-{$year}</option>
    <option value="climate71" SELECTED>IEM Climatology 1971-2000</option>
    <option value="ncdc_climate81">NCEI Climatology 1981-2010 *Official*</option>
    <option value="ncei_climate91">NCEI Climatology 1991-2020 *Official*</option>
    <option value="climate81">IEM Climatology 1981-2010</option>
 </select>

<h3>2. Download Type:</h3>

<div class="row">
  <div class="col-md-6">
    <p><b>2a. Select Station:</b><br />

    <input type="radio" name="mode" value="station" checked="CHECKED">Single Station, All Days</input>

    <br>{$nselect}

  </div>
  <div class="col-md-6">
    <p><b>2b. Select Month & Date:</b><br>

    <input type="radio" name="mode" value="day">All Stations, One Day</input>

    <br />Select Month: {$mselect}
    <br />Select Day: {$dselect}
 </div>
</div>

<h3>3. Download Options:</h3>

<select name="fmt">
  <option value="online">View Online</option>
  <option value="csv">Download to Disk (.csv)</option>
  <option value="excel" selected="selected">Download as Microsoft Excel (.xlsx)</option>
  <option value="json">Download as JSON</option>
</select><p>

<h3>4. Submit Form:</h3><br>
<input type="submit" value="Get Data"><input type="reset">

</form><p>

<p><img src="/images/gisready.png"> Data includes Lat/Lon information.
EOM;
$t->render('single.phtml');
