".$key."
\n";
$sql = "SELECT ".institution_match().", COUNT(jobid) AS jobs, SUM(".cpuhours($db,$_POST['system'],$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']).") AS cpuhours, SUM(".charges($db,$_POST['system'],$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']).") AS charges, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups, COUNT(DISTINCT(accounts)) AS accounts FROM Jobs WHERE system LIKE '".$_POST['system']."'";
$sql .= " AND ( ";
$sql .= "sw_app='".$key."'";
$sql .= " ) AND ( ".dateselect($_POST['datelogic'],$_POST['start_date'],$_POST['end_date'])." ) GROUP BY institution";
$sql ." ORDER BY ".$_POST['order']." DESC";
#echo "".htmlspecialchars($sql)."
";
$result = db_query($db,$sql);
if ( PEAR::isError($result) )
{
echo "".$result->getMessage()."
\n";
}
echo "\n";
echo "institution | jobs | cpuhours | charges | users | groups | accounts |
\n";
while ($result->fetchInto($row))
{
$rkeys=array_keys($row);
echo "";
foreach ($rkeys as $rkey)
{
$data[$rkey]=array_shift($row);
echo "".$data[$rkey]." | ";
}
echo "
\n";
ob_flush();
flush();
}
$sql = "SELECT 'TOTAL:',COUNT(jobid) AS jobs, SUM(".cpuhours($db,$_POST['system'],$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']).") AS cpuhours, SUM(".charges($db,$_POST['system'],$_POST['start_date'],$_POST['end_date'],$_POST['datelogic']).") AS charges, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups, COUNT(DISTINCT(account)) AS accounts FROM Jobs WHERE system LIKE '".$_POST['system']."' AND username IS NOT NULL AND ( ";
$sql .= "sw_app='".$key."'";
$sql .= " ) AND ( ".dateselect($_POST['datelogic'],$_POST['start_date'],$_POST['end_date'])." )";
$result = db_query($db,$sql);
if ( PEAR::isError($result) )
{
echo "".$result->getMessage()."
\n";
}
while ($result->fetchInto($row))
{
$rkeys=array_keys($row);
echo "";
foreach ($rkeys as $rkey)
{
$data[$rkey]=array_shift($row);
echo "".$data[$rkey]." | ";
}
echo "
\n";
ob_flush();
flush();
}
echo "
\n";
}
}
page_timer();
bookmarkable_url();
}
else
{
# list of software packages
$packages=software_list($db);
begin_form("software-usage-by-institution.php");
system_chooser();
date_fields();
$orders=array("jobs","cpuhours","charges","users","groups","accounts");
$defaultorder="cpuhours";
pulldown("order","Order by",$orders,$defaultorder);
checkboxes_from_array("Packages",$packages);
end_form();
}
db_disconnect($db);
page_footer();
?>