\n"; echo "packagejobscpuhourschargesusersgroups\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(username)) AS users, COUNT(DISTINCT(groupname)) AS groups FROM Jobs WHERE sw_app IS NOT NULL AND system LIKE '".$_POST['system']."' AND account LIKE '".$_POST['account']."' 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","users","groups"); result_as_csv($csvresult,$columns,$_POST['system']."-".$_POST['groupname']."-software_usage-".$_POST['start_date']."-".$_POST['end_date']); } if ( isset($_POST['xls']) ) { $xlsresult = db_query($db,$sql); $columns = array("package","jobs","cpuhours","users","groups"); result_as_xls($xlsresult,$columns,$_POST['system']."-".$_POST['groupname']."-software_usage-".$_POST['start_date']."-".$_POST['end_date']); } if ( isset($_POST['ods']) ) { $odsresult = db_query($db,$sql); $columns = array("package","jobs","cpuhours","users","groups"); result_as_ods($odsresult,$columns,$_POST['system']."-".$_POST['groupname']."-software_usage-".$_POST['start_date']."-".$_POST['end_date']); } db_disconnect($db); page_timer(); bookmarkable_url(); } else { begin_form("account-software.php"); text_field("Account","account",16); system_chooser(); date_fields(); $orders=array("jobs","cpuhours","charges","users"); $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(); } page_footer(); ?>