\n"; echo "packagejobscpuhoursaccounts\n"; ob_flush(); flush(); $first=1; $sql = "SELECT * FROM ( \n"; foreach ( $packages as $pkg ) { if ( $first==1 ) { $first=0; } else { $sql .= "UNION\n"; } $sql .= "SELECT '".$pkg."', COUNT(jobid) AS jobs, SUM(".cpuhours($db,$_POST['system']).") AS cpuhours, COUNT(DISTINCT(account)) AS accounts FROM Jobs WHERE system LIKE '".$_POST['system']."' AND username LIKE '".$_POST['username']."' AND ( "; if ( isset($pkgmatch[$pkg]) ) { $sql .= $pkgmatch[$pkg]; } else { $sql .= "script LIKE '%".$pkg."%' OR software LIKE '%".$package."%'"; } $sql .= " ) AND ( ".dateselect("start",$_POST['start_date'],$_POST['end_date'])." )"; $sql .= "\n"; } $sql .= " ) AS usrsofttmp WHERE jobs > 0 ORDER BY ".$_POST['order']." DESC"; #echo "
\n".$sql."
\n"; $result = db_query($db,$sql); 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","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","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","accounts"); result_as_ods($odsresult,$columns,$_POST['system']."-".$_POST['username']."-software_usage-".$_POST['start_date']."-".$_POST['end_date']); } db_disconnect($db); bookmarkable_url(); } else { begin_form("user-software.php"); text_field("User","username",16); system_chooser(); date_fields(); $orders=array("jobs","cpuhours","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(); } page_footer(); ?>