<?php
    require_once 'dbtools.php';
    
    print("<div class=\"sumtabcontainer\">\n");
    
    include 'todaysum.php';
    
    $result = pg_query("select count(*) as count, receivinghost, action, cast(connectdate as date) as connectdate 
	from history 
	group by cast(connectdate as date), action, receivinghost 
	order by connectdate desc, receivinghost, action;");
    print("<table class=\"sumtable\">\n");
    print("<tr class=\"sumtabhead\"><th>Date</th><th>Host</th><th>Action</th><th>Msgs/Tries</th></tr>");
    $rowcount = 0;
    while ($row = pg_fetch_array($result)) {
	print("<tr class=\"".getrowclass($rowcount,"sumtabrowlite", "sumtabrowdark")."\">
	    <td class=\"sumtabcell\" onclick=\"javascript:document.getElementById('date-".$rowcount."').submit()\">
		<form action=\"history.php\" method=\"post\" id=\"date-$rowcount\">
	                <input type=\"hidden\" name=\"connectdate\" value=\"".$row['connectdate']."\"/>
		</form>".$row['connectdate']."
	    </td>
	    <td class=\"sumtabcell\" onclick=\"javascript:document.getElementById('host-".$rowcount."').submit()\">
		<form action=\"history.php\" method=\"post\" id=\"host-$rowcount\">
	                <input type=\"hidden\" name=\"receivinghost\" value=\"".$row['receivinghost']."\"/>
			<input type=\"hidden\" name=\"connectdate\" value=\"".$row['connectdate']."\"/>
		</form>".$row['receivinghost']."
	    </td>
	    <td class=\"sumtabcell\" onclick=\"javascript:document.getElementById('action-".$rowcount."').submit()\">
		<form action=\"history.php\" method=\"post\" id=\"action-$rowcount\">
	                <input type=\"hidden\" name=\"action\" value=\"".$row['action']."\"/>
			<input type=\"hidden\" name=\"connectdate\" value=\"".$row['connectdate']."\"/>
		</form>".$row['action']."
	    </td>
	    <td class=\"sumtabcellritealigned\">".$row['count']."</td>
	    </tr>\n");
	$rowcount++;
    }
    print("</table>\n");
    print("</div>\n");
?>