Added an option to perform one action on multiple notifications at once.
authorarjen <arjen>
Mon, 10 Dec 2007 16:27:33 +0000 (16:27 +0000)
committerarjen <arjen>
Mon, 10 Dec 2007 16:27:33 +0000 (16:27 +0000)
src/web/notification.php

index 09edc5c..efbd958 100644 (file)
@@ -9,7 +9,7 @@
 ***********************
 **      FILE NAME      : notification.php
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.5 $
+**      VERSION NUMBER : $Revision: 1.6 $
 **
 **  DESCRIPTION      : Display and handle notifications.
 **                     There are two major views to this page: either a list of
 
 /*****************************
    $Log: notification.php,v $
-   Revision 1.5  2007-11-21 14:38:06  arjen
+   Revision 1.6  2007-12-10 16:27:33  arjen
+   Added an option to perform one action on multiple notifications at once.
+
+   Revision 1.5  2007/11/21 14:38:06  arjen
    The buttonbar at the top of each page is now a fixed 'div' element
    instead of a framed page.
    Contributed by Edwin Nadorp.
@@ -57,7 +60,7 @@
 
 ******************************/
 
-// RCSID = "$Id: notification.php,v 1.5 2007-11-21 14:38:06 arjen Exp $";
+// RCSID = "$Id: notification.php,v 1.6 2007-12-10 16:27:33 arjen Exp $";
 
 ini_set('include_path', '.:./classes:../phpclasses');
 
@@ -136,7 +139,7 @@ class notification_page extends page
       echo "<table>";
       echo '<tr><th>Time</th><th>Number</th><th>Issue</th><th>Status</th><th>Priority</th></tr>';
       $row = 0;
-      while ($row < pg_numrows($res))
+      while ($row < pg_num_rows($res))
       {
          $note = pg_fetch_object($res, $row);
          $r = pg_exec($this->database, "SELECT name from type_of_issue WHERE type_of_issueid = CAST('"
@@ -321,6 +324,7 @@ class notification_page extends page
          echo " value='$act'>" . $action->description . "<br>";
       }
 
+      echo "<input type='checkbox' name='act_on_all'>Perform this action on all notifications with the same issue.<br>";
       echo "<input type='submit' value='Submit action'>";
       echo "</form>";
    }
@@ -412,7 +416,29 @@ class notification_page extends page
                                           WHERE notificationid=" . $_GET['notid']);
          $note = pg_fetch_object($res, 0);
 
-         $note->statuscode = add_action($this->database, $note, $_POST['actionid'], $_POST['remark']);
+         if (!empty($_POST['act_on_all']))
+         {
+            //   Perform the action on all notifications with the same object and issue.
+            $res = pg_exec($this->database, "SELECT notificationid, timestamp, type_of_issueid, statuscode
+                                       FROM notification WHERE objectid= CAST ('" 
+                               . $note->objectid ."' AS BIGINT) AND statuscode != 'cls'
+                                  AND type_of_issueid = '" . $note->type_of_issueid
+                                       . "' ORDER BY notificationid");
+            for ($row = 0; $row < pg_num_rows($res); $row++)
+            {
+               $similar_note = pg_fetch_object($res, $row);
+               $new_statuscode = add_action($this->database, $similar_note,
+                                                 $_POST['actionid'], $_POST['remark']);
+               if ($similar_note->notificationid == $note->notificationid)
+               {
+                  $note->statuscode = $new_statuscode;
+               }
+            }
+         }
+         else
+         {
+            $note->statuscode = add_action($this->database, $note, $_POST['actionid'], $_POST['remark']);
+         }
          $this->display_notification($note);
          echo "<hr>";
          $this->notification_form($note);