Location: PHPKode > projects > PACSPulse > chartgen.php
<?php

/* 
PAC Pulse (PACS Perfomance optimization tool)
Copyright (C) 2001 Medical College of Wisconsin

This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

//Include the code
include ("globalvars.php");
include ("pagefunctions.php");

//querystring variables Typ,V,Dir,T,P
if (IsSet($Dir)){
 if ($Dir=='tx')
 {$direction='Outgoing';
 $dirsql=" and txrx='$Dir' ";}
 else
 {$direction='Incoming';
 $dirsql=" and txrx='$Dir' ";}
}
//page request type (network/device/modality)
switch ($P)
{
    case "N":
    $filtsql=" reverse(right(reverse(ip),length(ip)-locate('.',reverse(ip))))='$V' ";
    break;
    case "D":
    $filtsql=" nameMod='$V' ";
    break;
    case "M":
    $filtsql=" typeMod='$V' ";
    break;
}

switch ($Typ)
{
    case 0:
      gentop("Log Report","$PHP_SELF");
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select * from test where $filtsql $dirsql order by timestamp DESC limit 100";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      echo "<table border=1 cellspacing=1 cellpadding=1>";
      echo "<tr><td colspan=10 align=middle><b>Latest $direction log report for $V</b></td></tr>";
      echo "<tr><td align=middle>Timestamp</td><td>Tx/Rx</td><td>Name)</td><td>IP Address</td><td>Rate(KB/S)</td><td>Size(MB)</td>";
      echo "<td>NumObjs</td><td align=middle>Study Unique Identifier</td><td>Modality</td><td>NumAssoc</td></tr>";
      while ($row = mysql_fetch_array($sql_result)) {
        echo "<tr>";
        for ($x=0;$x<10;$x++){	
          echo "<td nowrap align=middle>$row[$x]</td>";
        }
        echo "</tr>";
      } 
      echo "</table>";
      genbottom();
    break;

    case 1:
      gentop("Study Trending","$PHP_SELF");
      echo "<table>";
      echo "<TR><TD><table border=1 cellspacing=1 cellpadding=1><tr><td>";
      echo "<img src='chart.php?P=$P&V=$V&Dir=$Dir&Typ=$Typ'></td></tr></table></td></tr>";
      echo "<tr><td align=middle><table border=1 cellspacing=1 cellpadding=1>";
      echo "<tr><td colspan=2 align=middle>Chart Data</td></tr>";
      echo "<Tr><td>Week Number</td><td>Number of Studies</td></tr>";
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),count(distinct StudyUID) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      while ($row = mysql_fetch_array($sql_result)) {
        $example_data[]=array($row[0],$row[1]);
        echo "<tr><td align=middle>$row[0]</td><td align=middle>$row[1]</td></tr>";
      }
      echo "</table></td></tr></table>";
      genbottom();
    break;

    case 2:
      gentop("Study Volume (GB) Trending","$PHP_SELF");
      echo "<table>";
      echo "<TR><TD><table border=1 cellspacing=1 cellpadding=1><tr><td>";
      echo "<img src='chart.php?P=$P&V=$V&Dir=$Dir&Typ=$Typ'></td></tr></table></td></tr>";
      echo "<tr><td align=middle><table border=1 cellspacing=1 cellpadding=1>";
      echo "<tr><td colspan=2 align=middle>Chart Data</td></tr>";
      echo "<Tr><td>Week Number</td><td>Volume of Data (GB)</td></tr>";
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format(avg(size)/1000,1) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      while ($row = mysql_fetch_array($sql_result)) {
          $example_data[]=array($row[0],$row[1]);
          echo "<tr><td align=middle>$row[0]</td><td align=middle>$row[1]</td></tr>";
      }
      echo "</table></td></tr></table>";
      genbottom();
    break;

    case 3:
      gentop("Image per Study Trending","$PHP_SELF");
      echo "<table>";
      echo "<TR><TD><table border=1 cellspacing=1 cellpadding=1><tr><td>";
      echo "<img src='chart.php?P=$P&V=$V&Dir=$Dir&Typ=$Typ'></td></tr></table></td></tr>";
      echo "<tr><td align=middle><table border=1 cellspacing=1 cellpadding=1>";
      echo "<tr><td colspan=2 align=middle>Chart Data</td></tr>";
      echo "<Tr><td>Week Number</td><td>Images per Study</td></tr>";
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format(sum(numObj)/count(distinct StudyUID),0) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      while ($row = mysql_fetch_array($sql_result)) {
          $example_data[]=array($row[0],$row[1]);
          echo "<tr><td align=middle>$row[0]</td><td align=middle>$row[1]</td></tr>";
      }
      echo "</table></td></tr></table>";
      genbottom();
    break;

    case 4:
      gentop("Image Size (MB) Trending","$PHP_SELF");
      echo "<table>";
      echo "<TR><TD><table border=1 cellspacing=1 cellpadding=1><tr><td>";
      echo "<img src='chart.php?P=$P&V=$V&Dir=$Dir&Typ=$Typ'></td></tr></table></td></tr>";
      echo "<tr><td align=middle><table border=1 cellspacing=1 cellpadding=1>";
      echo "<tr><td colspan=2 align=middle>Chart Data</td></tr>";
      echo "<Tr><td>Week Number</td><td>Images Size (KB)</td></tr>";
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format(sum(size)/sum(numObj),0) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      while ($row = mysql_fetch_array($sql_result)) {
          $example_data[]=array($row[0],$row[1]);
          echo "<tr><td align=middle>$row[0]</td><td align=middle>$row[1]</td></tr>";
      }
      echo "</table></td></tr></table>";
      genbottom();
    break;

    case 5:
      gentop("Transfer Rate Trending","$PHP_SELF");
      echo "<table>";
      echo "<TR><TD><table border=1 cellspacing=1 cellpadding=1><tr><td>";
      echo "<img src='chart.php?P=$P&V=$V&Dir=$Dir&Typ=$Typ'></td></tr></table></td></tr>";
      echo "<tr><td align=middle><table border=1 cellspacing=1 cellpadding=1>";
      echo "<tr><td colspan=2 align=middle>Chart Data</td></tr>";
      echo "<Tr><td>Week Number</td><td>Transfer Rate (KB/S)</td></tr>";
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format(avg(rate),1) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      while ($row = mysql_fetch_array($sql_result)) {
          $example_data[]=array($row[0],$row[1]);
          echo "<tr><td align=middle>$row[0]</td><td align=middle>$row[1]</td></tr>";
      }
      echo "</table></td></tr></table>";
      genbottom();
    break;

    case 6:
      gentop("Transfer Time Trending","$PHP_SELF");
      echo "<table>";
      echo "<TR><TD><table border=1 cellspacing=1 cellpadding=1><tr><td>";
      echo "<img src='chart.php?P=$P&V=$V&Dir=$Dir&Typ=$Typ'></td></tr></table></td></tr>";
      echo "<tr><td align=middle><table border=1 cellspacing=1 cellpadding=1>";
      echo "<tr><td colspan=2 align=middle>Chart Data</td></tr>";
      echo "<Tr><td>Week Number</td><td>Transfer Time Per Image (S)</td></tr>";
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format(avg(size/(numObj*rate)),1) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      while ($row = mysql_fetch_array($sql_result)) {
          $example_data[]=array($row[0],$row[1]);
          echo "<tr><td align=middle>$row[0]</td><td align=middle>$row[1]</td></tr>";
      }
      echo "</table></td></tr></table>";
      genbottom();
    break;

    case 7:
      gentop("Transfer Time Trending","$PHP_SELF");
      echo "<table>";
      echo "<TR><TD><table border=1 cellspacing=1 cellpadding=1><tr><td>";
      echo "<img src='chart.php?P=$P&V=$V&Dir=$Dir&Typ=$Typ'></td></tr></table></td></tr>";
      echo "<tr><td align=middle><table border=1 cellspacing=1 cellpadding=1>";
      echo "<tr><td colspan=2 align=middle>Chart Data</td></tr>";
      echo "<Tr><td>Week Number</td><td>Transfer Time (S)</td></tr>";
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format(avg(size/rate),1) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      while ($row = mysql_fetch_array($sql_result)) {
          $example_data[]=array($row[0],$row[1]);
          echo "<tr><td align=middle>$row[0]</td><td align=middle>$row[1]</td></tr>";
      }
      echo "</table></td></tr></table>";
      genbottom();
    break;
}
?>
Return current item: PACSPulse