<?php
require_once "../../../config/settings.inc.php";
require_once "../../../include/myview.php";
require_once "../../../include/forms.php";

$network = isset($_REQUEST['network']) ? xssafe($_REQUEST["network"]) : 'IA_COOP';

define("IEM_APPID", 45);
$t = new MyView();
$t->iemss = True;
$t->title = "NWS COOP Raw Observations Download";

$content = <<<EOM
<ol class="breadcrumb">
<li><a href="/COOP/">NWS COOP Network</a></li>
<li class="active">Raw Data Download</li>
</ol>

<p>This form provides access to the raw observations from the NWS COOP network.
<strong>The date presented in the download is the date on which the observation
        was made!</strong> The observations represent a 24 hour period prior
        to the timestamp on the observation.  These observations are typically
        made around 7 AM localtime.</p>
EOM;

$nselect = selectNetworkType("COOP", $network);
$y1 = yearSelect(2000, date("Y"), "year1");
$m1 = monthSelect("", "month1");
$d1 = daySelect("", "day1");
$y2 = yearSelect(2000, date("Y"), "year2");
$m2 = monthSelect("", "month2");
$d2 = daySelect("", "day2");

$west = <<<EOM
<form method="GET" name="chstate">
<p>Select from State:
{$nselect}
<input type="submit" value="Change Network" />
</form>

<p><a href="/cgi-bin/request/coopobs.py?help" class="btn btn-info">Backend documentation</a>
exists for those wishing to script against this service.</p>

<form method="GET" action="/cgi-bin/request/coopobs.py" name='dl'>
<div class="form2url"></div>
<input type='hidden' name='network' value="{$network}" />

<div id="iemss" data-network="{$network}"></div>

<p><h3>2. Select Start/End Date:</h3>
<p>These dates are the date of the observation and do not always represent
a local calendar day!.</p>
<table class="table table-striped">
  <tr>
    <td></td>
    <th>Year</th><th>Month</th><th>Day</th>
  </tr>

  <tr>
    <th>Start:</th>
    <td>{$y1}</td><td>{$m1}</td><td>{$d1}</td>
        </tr>

  <tr>
    <th>End:</th>
    <td>{$y2}</td><td>{$m2}</td><td>{$d2}</td>
  </tr>
</table>

EOM;
$east = <<<EOM
<p><h3>3. How to view?</h3><br>
<select name="what">
  <option value="download">Download to Disk</option>
  <option value="view">View on-line</option>
</select>

<p><h3>4. Data Delimitation:</h3><br>
How shall the output values be seperated?
<br><select name="delim">
    <option value="comma">Comma</option>
    <option value="space">Space</option>
    <option value="tab">Tab</option>
   </select>

<p><h3 class="subtitle">Submit Form:</h3><br>
<input type="submit" value="Process Data Request">
<input type="reset">
</form>

<p><h3>Download variable description</h3>
<pre>
nwsli National Weather Service Location Identifier
date  Date the observation was taken
time  Time (local timezone) the observation was taken
high_F      24 Hour High Temperature [F]
low_F       24 Hour Low Temperature [F]
precip      24 Hour Precipitation [inch]
snow_inch   24 Hour Snowfall [inch]
snowd_inch  Snow Depth [inch] at observation
</pre>

EOM;
$t->content = <<<EOM
$content
<div class="row">
<div class="col-md-6">
$west
</div>
<div class="col-md-6">
$east
</div>
</div>

EOM;

$t->render('single.phtml');
