Added editing of detailed object information.
authorarjen <arjen>
Thu, 14 Aug 2003 10:35:07 +0000 (10:35 +0000)
committerarjen <arjen>
Thu, 14 Aug 2003 10:35:07 +0000 (10:35 +0000)
src/web/objects.php

index 7222e7b..90cdafd 100644 (file)
@@ -9,11 +9,11 @@
 ***********************
 **      FILE NAME      : objects.php
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.7 $
+**      VERSION NUMBER : $Revision: 1.8 $
 **
 **  DESCRIPTION      : Objects Administration page.
 **                     Input parameters: action (POST) : empty, 'Create'
-**                                      objname (POST) : name of the object to create or remove
+**                              objname (POST) : name of the object to create or remove
 **
 **  EXPORTED OBJECTS : 
 **  LOCAL    OBJECTS : 
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Dec 04, 2002
-**      LAST UPDATE     : Feb 14, 2003
+**      LAST UPDATE     : Aug 04, 2003
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: objects.php,v $
-   Revision 1.7  2003-07-15 11:02:25  arjen
+   Revision 1.8  2003-08-14 10:35:07  arjen
+   Added editing of detailed object information.
+
+   Revision 1.7  2003/07/15 11:02:25  arjen
    Use the new object_statistics table.
 
    Revision 1.6  2003/02/21 08:46:58  arjen
@@ -52,7 +55,7 @@
 
 ******************************/
 
-// RCSID = "$Id: objects.php,v 1.7 2003-07-15 11:02:25 arjen Exp $";
+// RCSID = "$Id: objects.php,v 1.8 2003-08-14 10:35:07 arjen Exp $";
 
 ini_set('include_path', '.:./classes:../phpclasses');
 
@@ -134,8 +137,6 @@ class object_page extends page
    {
       clientscripts();
 
-   echo "<h1>Objects Administration</h1><hr>";
-
    if (isset($_POST['action']) && $_POST['action'] == 'Create' && !empty($_POST['objectname']))
    {
       pg_exec($this->database, "INSERT INTO object (objectname, log_count, parameter_count, notification_count)
@@ -147,64 +148,113 @@ class object_page extends page
       pg_exec($this->database, "DELETE FROM object WHERE objectname='" . $_POST['objectname'] . "'");
    }
 
-   $res = pg_exec($this->database, "SELECT objectid,objectname, log_count, notification_count
-                                    FROM object ORDER BY objectname");
+   if (isset($_GET['oid']))
+   {
+      echo "<h1>Detailed information for object " . $_GET['oid'] . "</h1><hr>";
+
+      if (isset($_POST['action']) && $_POST['action'] == 'Save Changes')
+      {
+         $qry = "UPDATE object SET objectname='" . $_POST['oname'] . "'";
+         $qry .= ", objectcode='" . $_POST['ocode'] . "'";
+         $qry .= ", object_description='" . $_POST['odescription'] . "'";
+         $qry .= ", object_owner='" . $_POST['oowner'] . "'";
+         $qry .= ", physical_location='" . $_POST['olocation'] . "'";
+         $qry .= ", remark='" . $_POST['oremark'] . "'";
+         $qry .= ", timezone='" . $_POST['otimezone'] . "'";
+         $qry .= " WHERE objectid=" . $_GET['oid'];
+
+         pg_exec($this->database, $qry);
+      }
+
+      $res = pg_exec($this->database, "SELECT * FROM object
+                                       WHERE objectid='" . $_GET['oid'] . "'");
+      $obj = pg_fetch_object($res, 0);
+
+      echo "<form action='objects.php?oid=" . $obj->objectid . "' method='POST'>";
+      echo "<table>";
+
+      echo "<tr><td>Name</td><td><input name='oname' type='text' value='";
+      echo $obj->objectname . "'></td></tr>";
+      echo "<tr><td>Identification code</td><td><input name='ocode' type='text' value='";
+      echo $obj->objectcode . "'></td></tr>";
+      echo "<tr><td>Description</td><td><textarea name='odescription'>";
+      echo $obj->object_description . "</textarea></td></tr>";
+      echo "<tr><td>Owner</td><td><textarea name='oowner'>";
+      echo $obj->object_owner . "</textarea></td></tr>";
+      echo "<tr><td>Physical location</td><td><textarea name='olocation'>";
+      echo $obj->physical_location . "</textarea></td></tr>";
+      echo "<tr><td>Remarks</td><td><textarea name='oremark'>";
+      echo $obj->remark . "</textarea></td></tr>";
+      echo "<tr><td>Timezone</td><td><input name='otimezone' type='text' value='";
+      echo $obj->timezone . "'></td></tr>";
+
+      echo "</table>";
+      echo "<input type='submit' name='action' value='Save Changes'>";
+      echo "</form>";
+   }
+   else
+   {
+      echo "<h1>Objects Administration</h1><hr>";
+
+      $res = pg_exec($this->database, "SELECT * FROM object ORDER BY objectname");
 ?>
 
-   <table>
-   <tr><th>Object</th><th>Log entries</th>
-       <th>Parameters</th><th>Notifications</th>
-   </tr>
+      <table>
+      <tr><th>Object</th><th>Description</th><th>Log entries</th>
+          <th>Parameters</th><th>Notifications</th></tr>
 
 <?php
-   $obj = 0;
-
-   //The counters are set to zero
-   $count_logs = 0;
-   $count_notifications = 0;
-   $closed_notifications = 0;
-   $count_parameters = 0;
-   $removed_parameters = 0;
-
-   while ($obj < pg_numrows($res))
-   {
-      $u = pg_fetch_object($res, $obj);
-
-      $this->GatherStatistics($u->objectid);
-
-      $count_parameters += $this->nr_parameters;
-      $removed_parameters += $this->removed_parameters;
-      $count_logs = $count_logs + $this->nr_logs;
-
-      //$nr_notifications = $u->notification_count;
-      $count_notifications += $this->nr_notifications;
-      $closed_notifications += $this->closed_notifications;
-      ?>
-      <tr><td><center><img src='server.png'><br>
-             <b><?php echo $u->objectname ?></b></center>
-      </td><td class='number'>
-          <?php echo "<a href='log.php?oid=$u->objectid'> $this->nr_logs </a>" ?>
-      </td><td class='number'>
-          <?php echo "<a href='parameter.php?oid=$u->objectid'>" . $this->nr_parameters
-                   . " (" . $this->removed_parameters . " removed)</a>" ?>
-      </td><td class='number'>
-          <?php echo "<a href='notification.php?oid=$u->objectid'>" . $this->nr_notifications . " (" . $this->closed_notifications . " closed)</a>" ?>
-      </td><td>
-          <form action='objects.php' method='post' onSubmit='return CheckRemove(this)'>
-              <input type='hidden' name='objectname' value='<?php echo $u->objectname ?>'>
-              <input type='submit' name='action' value='Remove'>
-          </form>
-      </td></tr>
-      <?php
-      $obj++;
-   }
-
-   //Show the totals
-   echo "<tr><td><strong><B><br><br>TOTALS</B></strong></td>";
-   echo "<td class='number'>$count_logs</td>";
-   echo "<td class='number'>$count_parameters ($removed_parameters removed)</td>";
-   echo "<td class='number'>$count_notifications ($closed_notifications closed)</td></tr>";
-   echo "</table>";
+      $obj = 0;
+
+      //The counters are set to zero
+      $count_logs = 0;
+      $count_notifications = 0;
+      $closed_notifications = 0;
+      $count_parameters = 0;
+      $removed_parameters = 0;
+
+      while ($obj < pg_numrows($res))
+      {
+         $u = pg_fetch_object($res, $obj);
+
+         $this->GatherStatistics($u->objectid);
+
+         $count_parameters += $this->nr_parameters;
+         $removed_parameters += $this->removed_parameters;
+         $count_logs = $count_logs + $this->nr_logs;
+
+         $count_notifications += $this->nr_notifications;
+         $closed_notifications += $this->closed_notifications;
+         ?>
+         <tr><td><center><a href='objects.php?oid=<?php echo $u->objectid?>'<img src='server.png'></a><br>
+                <b><?php echo $u->objectname ?></b></center>
+         </td><td>
+               <?php echo nl2br($u->object_description) ?>
+         </td><td class='number'>
+             <?php echo "<a href='log.php?oid=$u->objectid'> $this->nr_logs </a>" ?>
+         </td><td class='number'>
+             <?php echo "<a href='parameter.php?oid=$u->objectid'>" . $this->nr_parameters
+                      . " (" . $this->removed_parameters . " removed)</a>" ?>
+         </td><td class='number'>
+             <?php echo "<a href='notification.php?oid=$u->objectid'>" . $this->nr_notifications
+                      . " (" . $this->closed_notifications . " closed)</a>" ?>
+         </td><td>
+             <form action='objects.php' method='post' onSubmit='return CheckRemove(this)'>
+                 <input type='hidden' name='objectname' value='<?php echo $u->objectname ?>'>
+                 <input type='submit' name='action' value='Remove'>
+             </form>
+         </td></tr>
+         <?php
+         $obj++;
+      }
+
+      //Show the totals
+      echo "<tr><td><strong><B><br><br>TOTALS</B></strong></td>";
+      echo "<td>&nbsp;</td>";
+      echo "<td class='number'>$count_logs</td>";
+      echo "<td class='number'>$count_parameters ($removed_parameters removed)</td>";
+      echo "<td class='number'>$count_notifications ($closed_notifications closed)</td></tr>";
+      echo "</table>";
 
 ?>
 
@@ -217,9 +267,11 @@ Object's name (FQDN): <input name='objectname' type='text'>
 <input type='submit' name='action' value='Create'>
 </form>
 </p>
+
 <?php
 
    }
+   }
 }
 
 $obj_page = new object_page("Gnucomo Objects Administration");