/**
 * Displays a large graph.
 *
 * This is a development tool, created for the sole purpose of helping me investigate performance issues
 * and prove the performance impact of significant changes in code.
 * It is provided in the hope that it will be useful to others but is provided without any warranty,
 * without even the implied warranty of merchantability or fitness for a particular purpose.
 * This code is provided under GPLv3 or at your discretion any later version.
 *
 * @package moodle-jmeter-perfcomp
 * @copyright 2012 Sam Hemelryk (blackbirdcreative.co.nz)
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once __DIR__ . '/lib.php';
$runs = get_runs();
$before = null;
$after = null;
$width = '800';
$height = '600';
if (!empty($_GET['before']) && array_key_exists($_GET['before'], $runs)) {
    $before = $_GET['before'];
    $beforekey = array_search($before, $runs);
}
if (!empty($_GET['after']) && array_key_exists($_GET['after'], $runs)) {
    $after = $_GET['after'];
    $afterkey = array_search($after, $runs);
}
if (!empty($_GET['property']) && in_array($_GET['property'], $PROPERTIES)) {
    $property = $_GET['property'];
}
<?php

require "../settings.php";
if (isset($_POST["key"])) {
    switch ($_POST["key"]) {
        case "search":
            $OUTPUT = show_runs($_POST);
            break;
        default:
            $OUTPUT = get_runs();
    }
} else {
    $OUTPUT = get_runs();
}
$OUTPUT .= "<br>" . mkQuickLinks(ql("../supp-payment-run.php", "Creditor Payment Run"), ql("supp-payment-list.php", "Creditor Payment Run Listing"));
require "../template.php";
function get_runs()
{
    $display = "\n\t\t<h2>View Credit Runs</h2>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='search'>\n\t\t\t<tr>\n\t\t\t\t<th>By Date Range</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>" . mkDateSelect("from", date("Y"), date("m"), "01") . " To " . mkDateSelect("to") . " <input type='submit' value='Search'></td>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>";
    return $display;
}
function show_runs($_POST)
{
    extract($_POST);
    $from_date = "{$from_year}-{$from_month}-{$from_day}";
    $to_date = "{$to_year}-{$to_month}-{$to_day}";
    db_conn('contract');
    $get_dist = "SELECT distinct(run_id) FROM credit_runs";
    $run_dist = db_exec($get_dist) or errDie("Unable to get creditor run information.");
    if (pg_numrows($run_dist) < 1) {
        return "<li class='err'>No Previous Creditor Runs Found.</li>";