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 "Time | User | Remarks |
";
$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 $action_user->timestamp;
echo " | ";
echo $action_user->username;
echo " | ";
echo htmlspecialchars(stripslashes($action_user->remarks));
echo " |
";
}
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 "Class | Name | Description | History |
";
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 $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 " |
";
}
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 "Time | Service | Log entry |
";
for ($row = 0; $row < pg_numrows($r); $row++)
{
$p = pg_fetch_object($r, $row);
echo "";
echo $p->object_timestamp;
echo " | ";
echo $p->servicecode;
echo " | ";
echo $p->rawdata;
echo " |
";
}
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 "";
}
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";
echo $note->timestamp;
echo " | ";
echo $note->notificationid;
echo " | ";
echo "";
echo $issue->name;
echo "";
echo " | ";
echo $note->statuscode;
echo " | ";
echo $note->priority;
echo " |
\n";
$row++;
}
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();
?>