\n";
echo "
package | jobs | cpuhours | charges | accounts |
\n";
ob_flush();
flush();
$sql = "SELECT sw_app, 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(account)) AS accounts FROM Jobs WHERE sw_app IS NOT NULL AND system LIKE '".$_POST['system']."' AND username LIKE '".$_POST['username']."' AND ( ".dateselect($_POST['datelogic'],$_POST['start_date'],$_POST['end_date'])." ) GROUP BY sw_app ORDER BY ".$_POST['order']." DESC";
#echo "\n".$sql."
\n";
$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";
if ( isset($_POST['csv']) )
{
$csvresult = db_query($db,$sql);
$columns = array("package","jobs","cpuhours","charges","accounts");
result_as_csv($csvresult,$columns,$_POST['system']."-".$_POST['username']."-software_usage-".$_POST['start_date']."-".$_POST['end_date']);
}
if ( isset($_POST['xls']) )
{
$xlsresult = db_query($db,$sql);
$columns = array("package","jobs","cpuhours","charges","accounts");
result_as_xls($xlsresult,$columns,$_POST['system']."-".$_POST['username']."-software_usage-".$_POST['start_date']."-".$_POST['end_date']);
}
if ( isset($_POST['ods']) )
{
$odsresult = db_query($db,$sql);
$columns = array("package","jobs","cpuhours","charges","accounts");
result_as_ods($odsresult,$columns,$_POST['system']."-".$_POST['username']."-software_usage-".$_POST['start_date']."-".$_POST['end_date']);
}
page_timer();
bookmarkable_url();
}
else
{
begin_form("user-software.php");
text_field("User","username",16);
system_chooser();
date_fields();
$orders=array("jobs","cpuhours","charges","accounts");
$defaultorder="cpuhours";
pulldown("order","Order results by",$orders,$defaultorder);
checkbox("Generate CSV file","csv");
checkbox("Generate Excel file","xls");
checkbox("Generate ODF file","ods");
end_form();
}
db_disconnect($db);
page_footer();
?>