".$key."\n"; $sql = "SELECT ".institution_match().", COUNT(jobid) AS jobs, SUM(".cpuhours($db,$_POST['system']).") AS cpuhours, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups FROM Jobs WHERE system LIKE '".$_POST['system']."'"; # OSC-specific logic starts here #$sql .= " AND ( username IS NOT NULL AND username REGEXP '[A-z]{3,4}[0-9]{3,4}' AND username NOT LIKE 'osc%' AND username NOT LIKE 'wrk%' )"; # OSC-specific logic ends here $sql .= " AND ( "; if ( isset($pkgmatch[$key]) ) { $sql .= $pkgmatch[$key]; } else { $sql .= "script LIKE '%".$key."%' OR software LIKE '%".$key."%'"; } $sql .= " ) AND ( ".dateselect("start",$_POST['start_date'],$_POST['end_date'])." ) GROUP BY institution"; # OSC-specific logic starts here #$sql .= " UNION SELECT 'osc' AS institution, COUNT(jobid) AS jobs, SUM(".cpuhours($db,$_POST['system']).") AS cpuhours, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups FROM Jobs WHERE system LIKE '".$_POST['system']."' AND ( username IS NOT NULL AND (username NOT REGEXP '[A-z]{3,4}[0-9]{3,4}' OR username LIKE 'osc%' OR username LIKE 'wrk%') ) AND ( "; #if ( isset($pkgmatch[$key]) ) # { # $sql .= $pkgmatch[$key]; # } #else # { # $sql .= "script LIKE '%".$key."%' OR software LIKE '%".$key."%'"; # } #$sql .= " ) AND ( ".dateselect("start",$_POST['start_date'],$_POST['end_date'])." )"; # OSC-specific logic ends here $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 "\n"; while ($result->fetchInto($row)) { $rkeys=array_keys($row); echo ""; foreach ($rkeys as $rkey) { $data[$rkey]=array_shift($row); echo ""; } echo "\n"; ob_flush(); flush(); } $sql = "SELECT 'TOTAL:',COUNT(jobid) AS jobs, SUM(".cpuhours($db,$_POST['system']).") AS cpuhours, COUNT(DISTINCT(username)) AS users, COUNT(DISTINCT(groupname)) AS groups FROM Jobs WHERE system LIKE '".$_POST['system']."' AND username IS NOT NULL AND ( "; if ( isset($pkgmatch[$key]) ) { $sql .= $pkgmatch[$key]; } else { $sql .= "script LIKE '%".$key."%' OR software LIKE '%".$key."%'"; } $sql .= " ) AND ( ".dateselect("start",$_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 ""; } echo "\n"; } echo "
groupnamejobscpuhoursusersgroups
".$data[$rkey]."
".$data[$rkey]."
\n"; } } db_disconnect($db); bookmarkable_url(); } else { begin_form("software-usage-by-institution.php"); system_chooser(); date_fields(); $orders=array("jobs","cpuhours","users","groups"); $defaultorder="cpuhours"; pulldown("order","Order by",$orders,$defaultorder); checkboxes_from_array("Packages",$packages); end_form(); } page_footer(); ?>