From: arjen Date: Wed, 5 Feb 2003 09:48:14 +0000 (+0000) Subject: Added display and handling of notifications X-Git-Tag: V0_0_4~6 X-Git-Url: http://www.andromeda.nl/gitweb/?p=gnucomo.git;a=commitdiff_plain;h=16c72b28d2b4562777765d82fb998c6b928525ce Added display and handling of notifications --- diff --git a/src/web/notification.php b/src/web/notification.php new file mode 100644 index 0000000..57a3c04 --- /dev/null +++ b/src/web/notification.php @@ -0,0 +1,349 @@ + + + + +statuscode != "" && $note->statuscode != $action->statuscode) + { + // Update the status of the notification. + + $note->statuscode = $action->statuscode; + + pg_exec($db, "UPDATE notification SET statuscode='" . $note->statuscode + . "' WHERE notificationid = " . $note->notificationid); + } + + // Add the action to the action_user table. + + pg_exec($db, "INSERT INTO action_user (actionid, username, notificationid, + timestamp, statuscode, remarks) values ('$actionid', '" + . $_SESSION['username'] . "', '" . $note->notificationid + . "', '" . date('Y-m-d H:i:s') . "', '" . $note->statuscode + . "', '" . $remark . "')"); + + return $note->statuscode; +} + +class notification_page extends page +{ + + function display_notification($note) + { + $res = pg_exec($this->database, "SELECT objectname FROM object WHERE objectid=" . $note->objectid); + $obj = pg_fetch_object($res, 0); + echo "

Notification " . $note->notificationid . " for " . $obj->objectname . "


"; + + $r = pg_exec($this->database, "SELECT description from type_of_issue WHERE type_of_issueid =" + . $note->type_of_issueid); + $issue = pg_fetch_object($r, 0); + + $r = pg_exec($this->database, "SELECT statusname FROM status + WHERE statuscode = '" . $note->statuscode . "'"); + + $status = pg_fetch_object($r, 0); + + echo "Issue : " . $issue->description . ", Priority " . $note->priority . "
"; + echo "Creation time : " . $note->timestamp . "
"; + echo "Current status : " . $status->statusname . "
"; + + // List all actions that occurred on this notification + + echo "

Action history for notification " . $note->notificationid . "

"; + echo ""; + echo ""; + + $r = pg_exec($this->database, "SELECT actionid, username, timestamp, remarks + FROM action_user WHERE notificationid=" . $note->notificationid + ." ORDER BY timestamp"); + for ($row = 0; $row < pg_numrows($r); $row++) + { + $action_user = pg_fetch_object($r, $row); + + echo ""; + } + echo "
TimeUserRemarks
"; + echo $action_user->timestamp; + echo ""; + echo $action_user->username; + echo ""; + echo htmlspecialchars(stripslashes($action_user->remarks)); + echo "
"; + + // See if we can list any parameters for this notification + + $r = pg_exec($this->database, "SELECT * FROM parameter WHERE paramid IN + ( SELECT paramid FROM parameter_notification + WHERE notificationid = " . $note->notificationid . ")"); + if (pg_numrows($r) > 0) + { + echo "

Parameters involved in this notification

"; + echo ""; + echo ""; + + for ($row = 0; $row < pg_numrows($r); $row++) + { + $p = pg_fetch_object($r, $row); + $res = pg_exec($this->database, "SELECT * from history WHERE paramid=" . $p->paramid + . " ORDER BY modified"); + + echo ""; + + } + echo "
ClassNameDescriptionHistory
"; + echo $p->class; + echo ""; + echo $p->name; + echo ""; + echo $p->description; + echo ""; + for ($hrow = 0; $hrow < pg_numrows($res); $hrow++) + { + $hist = pg_fetch_object($res, $hrow); + echo $hist->modified . " "; + echo $hist->change_nature . " "; + echo $hist->changed_property . " "; + echo $hist->new_value; + echo "
"; + } + echo "
"; + } + + // See if we can list any log entries for this notification + + $r = pg_exec($this->database, "SELECT * FROM log WHERE logid IN + ( SELECT logid FROM log_notification + WHERE notificationid = " . $note->notificationid . ")"); + if (pg_numrows($r) > 0) + { + echo "

Log entries involved in this notification

"; + echo ""; + echo ""; + + for ($row = 0; $row < pg_numrows($r); $row++) + { + $p = pg_fetch_object($r, $row); + + echo ""; + + } + echo "
TimeServiceLog entry
"; + echo $p->object_timestamp; + echo ""; + echo $p->servicecode; + echo ""; + echo $p->rawdata; + echo "
"; + } + + } + + function notification_form($note) + { + /* + * Depending on the state of the notification, specific actions + * are possible. One such actions determines a transition to + * the next state. The array $possible_action lists the state transitions + * for each state. + */ + + $possible_action = array + ( + "opn" => array (3, 6, 7), + "pen" => array (3, 6, 7, 8, 11, 18), + "inv" => array (3, 9), + "vrf" => array (12, 13), + "cls" => array (19) + ); + + echo "

Enter a remark for the next action

"; + echo "
"; + echo "
"; + + /* Display a list of possible actions */ + + echo "

Select on of the actions to take below

"; + + $first = true; + + foreach ($possible_action[$note->statuscode] as $act) + { + $action = pg_fetch_object(pg_exec("SELECT description FROM action WHERE actionid=$act"),0); + echo "" . $action->description . "
"; + } + + echo ""; + echo "
"; + } + + function Body() + { + + if ($_SERVER['REQUEST_METHOD'] == 'GET' && !empty($_GET['oid'])) + { + + // Display a list of all notifications for this object['oid'] + + $res = pg_exec($this->database, "SELECT objectname FROM object WHERE objectid=" . $_GET['oid']); + $obj = pg_fetch_object($res, 0); + echo "

Notifications for " . $obj->objectname . "


"; + + $res = pg_exec($this->database, "SELECT notificationid, timestamp, type_of_issueid, + statuscode, priority + FROM notification WHERE objectid=" . $_GET['oid'] + . " ORDER BY notificationid"); + + echo ""; + $row = 0; + while ($row < pg_numrows($res)) + { + $note = pg_fetch_object($res, $row); + $r = pg_exec($this->database, "SELECT name from type_of_issue WHERE type_of_issueid =" + . $note->type_of_issueid); + $issue = pg_fetch_object($r, 0); + echo "\n"; + $row++; + } + echo "
\n"; + echo $note->timestamp; + echo ""; + echo $note->notificationid; + echo ""; + echo ""; + echo $issue->name; + echo ""; + echo ""; + echo $note->statuscode; + echo ""; + echo $note->priority; + echo "
"; + } + else if ($_SERVER['REQUEST_METHOD'] == 'GET' && !empty($_GET['notid'])) + { + clientscripts(); + + // Display all information about a single notification['notid'] + + $res = pg_exec($this->database, "SELECT * from notification + WHERE notificationid=" . $_GET['notid']); + $note = pg_fetch_object($res, 0); + + if ($note->statuscode == 'new') + { + $note->statuscode = add_action($this->database, $note, 2, "Displayed through web interface"); + } + + $this->display_notification($note); + echo "
"; + $this->notification_form($note); + } + else if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_GET['notid'])) + { + clientscripts(); + + // Display all information about a single notification['notid'] + + $res = pg_exec($this->database, "SELECT * from notification + WHERE notificationid=" . $_GET['notid']); + $note = pg_fetch_object($res, 0); + + $note->statuscode = add_action($this->database, $note, $_POST['actionid'], $_POST['remark']); + $this->display_notification($note); + echo "
"; + $this->notification_form($note); + } + else + { + echo "

Insufficient input to create page

"; + phpinfo(); + } + } +} + +$notif_page = new notification_page("Gnucomo Notifications"); + +$notif_page->Showpage(); + +?> diff --git a/src/web/objects.php b/src/web/objects.php index 27cd03c..33a90e0 100644 --- a/src/web/objects.php +++ b/src/web/objects.php @@ -1,16 +1,40 @@ count; + + $r = pg_exec ($conn, "SELECT count(notificationid) FROM notification WHERE objectid='" + . $u->objectid . "'"); + $r = pg_fetch_object($r, 0); + + $nr_notifications = $r->count; ?>
objectname ?> @@ -101,6 +131,8 @@ else Parameters + Notifications +