Removed parameters are displayed in a shaded style.
[gnucomo.git] / src / web / parameter_compare.php
index ea2e258..9cc64bd 100644 (file)
@@ -9,7 +9,7 @@
 ***********************
 **      FILE NAME      : parameter_compare.php
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.2 $
+**      VERSION NUMBER : $Revision: 1.4 $
 **
 **  DESCRIPTION      : 
 **
 
 /*****************************
    $Log: parameter_compare.php,v $
-   Revision 1.2  2003-02-05 09:47:39  arjen
+   Revision 1.4  2003-07-15 11:06:45  arjen
+   Removed parameters are displayed in a shaded style.
+
+   Revision 1.3  2003/02/13 09:01:29  arjen
+   All web interface pages use the page class.
+
+   Revision 1.2  2003/02/05 09:47:39  arjen
    Display the difference of all package class parameters for two objects
 
 ******************************/
 
-// RCSID = "$Id: parameter_compare.php,v 1.2 2003-02-05 09:47:39 arjen Exp $";
+// RCSID = "$Id: parameter_compare.php,v 1.4 2003-07-15 11:06:45 arjen Exp $";
 
-session_start();
-require_once('classes/gnucomo_config.php');
-?>
+ini_set('include_path', '.:./classes:../phpclasses');
 
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel='stylesheet' href='gnucomo.css' type='text/css'>
-<title>Parameter comparison</title>
+require_once('page.class.php');
 
 
-</head>
-<body>
-<?php
-
 /*  Returns an associative array with all properties of a parameter (pid) */
 
 function param_properties($db, $pid)
@@ -91,8 +86,12 @@ function property_compare($prop, $comp)
 
 /*   Display a parameter in two adjecent table cells  */
 
-function display_parameter($name, $properties, $css_class = "")
+function display_parameter($name, $properties, $css_class = "", $shaded = FALSE)
 {
+   if ($shaded)
+   {
+      $css_class = 'shaded';
+   }
    echo "<td";
    if ($css_class != "")
    {
@@ -113,35 +112,34 @@ function display_parameter($name, $properties, $css_class = "")
    echo "</td>";
 }
 
-if (empty($_SESSION['username']))
-{
-   echo "Please log in first.";
-}
-else
+class param_diff extends page
 {
 
-   $config = new gnucomo_config;
-
-   $config->read("gnucomo");
+   function is_removed($paramid)
+   {
+      $qry ="select change_nature from history where paramid= CAST('";
+      $qry .= $paramid . "' AS BIGINT) order by modified desc";
+      $rhist = pg_exec($this->database, $qry);
+      $hist = pg_fetch_object($rhist, 0);
 
-   //  Connect to the database
-   $conn = pg_connect($config->Database($_SESSION['username'], $_SESSION['password']));
+      return $hist->change_nature == "REMOVED";
+   }
 
+   function Body()
+   {
    if (!empty($_POST['oid']))
    {
-      $res = pg_exec("SELECT objectid, objectname FROM object WHERE objectid=" . $_POST['oid']);
+      $res = pg_exec($this->database, "SELECT objectid, objectname FROM object WHERE objectid=" . $_POST['oid']);
       $obj = pg_fetch_object($res, 0);
       echo "<h1>" . $_POST['class'] . " parameters for " . $obj->objectname;
-      $res = pg_exec("SELECT objectid, objectname FROM object WHERE objectid=" . $_POST['compare_to']);
+      $res = pg_exec($this->database, "SELECT objectid, objectname FROM object WHERE objectid=" . $_POST['compare_to']);
       $cmp_obj = pg_fetch_object($res, 0);
       echo " compared to " . $cmp_obj->objectname . "</h1><hr>";
 
-      $res = pg_exec("SELECT objectid, paramid, name FROM parameter "
+      $res = pg_exec($this->database, "SELECT objectid, paramid, name FROM parameter "
                      . "WHERE objectid=" . $obj->objectid . " OR objectid=" . $cmp_obj->objectid
                      . " AND class='" . $_POST['class'] . "' ORDER BY name, objectid");
       
-     ?>
-     <?php
       echo "<table>\n";
       echo "<tr><th colspan='2'>" . $obj->objectname . "</th>";
       echo "<th colspan='2'>" . $cmp_obj->objectname . "</th></tr>\n";
@@ -162,12 +160,12 @@ else
             /*  Both objects have this parameter */
             $row++;
 
-            $pr = param_properties($conn, $par->paramid);
-            $prnext = param_properties($conn, $nextpar->paramid);
+            $pr = param_properties($this->database, $par->paramid);
+            $prnext = param_properties($this->database, $nextpar->paramid);
             if (property_compare($pr, $prnext))
             {
-               display_parameter($par->name, $pr);
-               display_parameter($nextpar->name, $prnext);
+               display_parameter($par->name, $pr, "", $this->is_removed($par->paramid));
+               display_parameter($nextpar->name, $prnext, "", $this->is_removed($nextpar->paramid));
             }
             else
             {
@@ -176,13 +174,13 @@ else
 
                if ($par->objectid == $obj->objectid)
                {
-                  display_parameter($par->name, $pr, "both");
-                  display_parameter($nextpar->name, $prnext, "both");
+                  display_parameter($par->name, $pr, "both", $this->is_removed($par->paramid));
+                  display_parameter($nextpar->name, $prnext, "both", $this->is_removed($nextpar->paramid));
                }
                else
                {
-                  display_parameter($nextpar->name, $prnext, "both");
-                  display_parameter($par->name, $pr, "both");
+                  display_parameter($nextpar->name, $prnext, "both", $this->is_removed($nextpar->paramid));
+                  display_parameter($par->name, $pr, "both", $this->is_removed($par->paramid));
                }
             }
          }
@@ -190,13 +188,13 @@ else
          {
             /*  Only one of the objects has this parameter */
 
-            $pr = param_properties($conn, $par->paramid);
+            $pr = param_properties($this->database, $par->paramid);
 
             if ($par->objectid == $obj->objectid)
             {
                /*  Parameter belongs to the object on the left */
 
-               display_parameter($par->name, $pr, "left");
+               display_parameter($par->name, $pr, "left", $this->is_removed($par->paramid));
                echo "<td>&nbsp;</td><td>&nbsp;";
             }
             else
@@ -205,7 +203,7 @@ else
 
                echo "<td>";
                echo "&nbsp;</td><td>&nbsp;</td>";
-               display_parameter($par->name, $pr, "right");
+               display_parameter($par->name, $pr, "right", $this->is_removed($par->paramid));
             }
          }
          echo "</tr>\n";
@@ -213,8 +211,11 @@ else
       }
       echo "</table>\n";
    }
+   }
 }
-?>
 
-</body>
-</html>
+$page = new param_diff("Gnucomo Parameter Comparison");
+
+$page->Showpage();
+
+?>