SiT! Bugs

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001785SiT!incidentspublic2012-05-11 02:242013-02-04 20:48
Reporterpaulvh 
Assigned ToTomse 
PrioritylowSeveritytweakReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version3.65 LTS 
Target VersionFixed in Version 
Summary0001785: All Incidents Filter
DescriptionAdd a filter to the All Incidents list to show incidents for a specific user.
Additional Information*** /var/sit-3.65/incidents.php Sun Sep 4 12:51:21 2011
--- /var/www/incidents.php Thu May 10 21:01:48 2012
***************
*** 223,228 ****
--- 223,244 ----
              echo "value='{$_SERVER['PHP_SELF']}?user=$user&type=$type&queue=4'>{$strAllClosed}</option>\n";
          }
          echo "</select>\n";
+
+ // show dropdown of users
+ $usersql = "SELECT id, realname FROM `{$dbUsers}` WHERE status = 1";
+ $userresult = mysql_query($usersql);
+ if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
+ echo "{$strUser}: <select class='dropdown' name='user' onchange='window.location.href=this.options[this.select
edIndex].value'>\n";
+ echo "<option ";
+ if ($user == 'all') echo "selected='selected' ";
+ echo "value='{$_SERVER['PHP_SELF']}?user=all&type=$type&queue=$queue'>All</option>\n";
+ while ($theuser = mysql_fetch_object($userresult)) {
+ echo "<option ";
+ if ($user == $theuser->id) echo "selected='selected' ";
+ echo "value='{$_SERVER['PHP_SELF']}?user={$theuser->id}&type=$type&queue=$queue'>{$theuser->real
name}</option>\n";
+ }
+ echo "</select>\n";
+
          echo "</form>";

          if ($queue == 4 AND $CONFIG['hide_closed_incidents_older_than'] != -1 AND $_GET['show'] != 'all')
Tagspatch
Attached Files

- Relationships

-  Notes
(0004546)
paulvh (reporter)
2012-10-13 18:55

More filters

--- /root/sit-3.67/incidents.php 2012-08-18 10:40:26.000000000 -0400
+++ /var/www/incidents.php 2012-10-11 08:38:32.336262308 -0400
@@ -25,6 +25,8 @@ require (APPLICATION_LIBPATH . 'auth.inc
 $type = cleanvar($_REQUEST['type']);
 if (cleanvar($_REQUEST['user']) == 'current') $user = clean_int($sit[2]);
 else $user = cleanvar($_REQUEST['user']);
+$site = cleanvar($_REQUEST['site']);
+$contact = cleanvar($_REQUEST['contact']);
 $softwareid = clean_int($_REQUEST['softwareid']);
 $queue = clean_int($_REQUEST['queue']);
 $sort = clean_fixed_list($_REQUEST['sort'], array('','id','title','contact','priority','status','lastupdated','duration','nextaction'));
@@ -34,6 +36,8 @@ $title = $strIncidentsList;

 // Defaults
 if (empty($type)) $type = 'support';
+if (empty($site)) $site = 'all';
+if (empty($contact)) $contact = 'all';
 if (empty($user)) $user = 'current';
 if (empty($sort)) $sort = 'priority';
 if (empty($queue)) $queue = 1;
@@ -81,6 +85,8 @@ $selectsql .= "(timeofnextaction - $now)
 $selectsql .= "($now - lastupdated) AS timesincelastupdate ";
 $selectsql .= "FROM `{$dbIncidents}` AS i, `{$dbContacts}` AS c, `{$dbPriority}` AS pr ";

+$filtersql = "";
+
 echo "<div id='incidentqueues'>";

 switch ($type)
@@ -98,12 +104,14 @@ switch ($type)
             if (mysql_num_rows($uresult) >= 1) list($user) = mysql_fetch_row($uresult);
             else $user = $sit[2]; // force to current user if username not found
         }
- $sql = $selectsql . "WHERE contact = c.id AND i.priority = pr.id ";
- $sql .= "AND owner > 0 "; // We always need to have an owner which is not sit
- if ($user != 'all') $sql .= "AND (owner='{$user}' OR towner='{$user}') ";
- if (!empty($softwareid)) $sql .= "AND softwareid='$softwareid' ";
+ $filtersql = "WHERE contact = c.id AND i.priority = pr.id ";
+ $filtersql .= "AND owner > 0 "; // We always need to have an owner which is not sit
+ if ($site != 'all') $filtersql .= "AND (i.maintenanceid='{$site}') ";
+ if ($user != 'all') $filtersql .= "AND (owner='{$user}' OR towner='{$user}') ";
+ if ($contact != 'all') $filtersql .= "AND (c.id='{$contact}') ";
+ if (!empty($softwareid)) $filtersql .= "AND softwareid='$softwareid' ";

- if (!empty($maintexclude)) $sql .= "AND i.maintenanceid != '{$maintexclude}' ";
+ if (!empty($maintexclude)) $filtersql .= "AND i.maintenanceid != '{$maintexclude}' ";

         echo "<h2>".icon('support', 32, $strSupport)." ";

@@ -120,31 +128,34 @@ switch ($type)
         {
             case 1: // Action Needed
                 echo "<span class='actionqueue'>{$strActionNeeded}</span>";
- $sql .= "AND (status!='2') "; // not closed
+ $filtersql .= "AND (status!='2') "; // not closed
                 // the "1=2" obviously false else expression is to prevent records from showing unless the IF condition is true
- $sql .= "AND ((timeofnextaction > 0 AND timeofnextaction < {$now}) OR ";
+ $filtersql .= "AND ((timeofnextaction > 0 AND timeofnextaction < {$now}) OR ";
                 if ($user != 'all') $sql .= "(status='5' AND towner=$user) OR ";
- $sql .= "(IF ((status >= 5 AND status <=8), ({$now} - lastupdated) > ({$CONFIG['regular_contact_days']} * 86400), 1=2 ) "; // awaiting
- $sql .= "OR IF (status='1' OR status='3' OR status='4', 1=1 , 1=2) "; // active, research, left message - show all
- $sql .= ") AND timeofnextaction < $now ) ";
+ $filtersql .= "(IF ((status >= 5 AND status <=8), ({$now} - lastupdated) > ({$CONFIG['regular_contact_days']} * 86400), 1=2 ) "; // awaiting
+ $filtersql .= "OR IF (status='1' OR status='3' OR status='4', 1=1 , 1=2) "; // active, research, left message - show all
+ $filtersql .= ") AND timeofnextaction < $now ) ";
                 break;
             case 2: // Waiting
                 echo "<span class='waitingqueue'>{$strWaiting}</span>";
- $sql .= "AND ((status >= 4 AND status <= 8) OR (timeofnextaction > 0 AND timeofnextaction > {$now})) ";
+ $filtersql .= "AND ((status >= 4 AND status <= 8) OR (timeofnextaction > 0 AND timeofnextaction > {$now})) ";
                 break;
             case 3: // All Open
                 echo "<span class='openqueue'>{$strAllOpen}</span>";
- $sql .= "AND status!='2' ";
+ $filtersql .= "AND status!='2' ";
                 break;
             case 4: // All Closed
                 echo "<span class='closedqueue'>{$strAllClosed}</span>";
- $sql .= "AND status='2' ";
+ $filtersql .= "AND status='2' ";
                 if ($CONFIG['hide_closed_incidents_older_than'] > -1 AND $_GET['show'] != 'all')
                 {
                     $old = $now - ($CONFIG['hide_closed_incidents_older_than'] * 86400);
                     $sql .= "AND closed >= {$old} ";
                 }
                 break;
+ case 5: // All
+ echo "<span class='openqueue'>{$strAllIncidents}</span>";
+ break;
             default:
                 trigger_error("Invalid queue ($queue) on query string",E_USER_NOTICE);
                 break;
@@ -158,35 +169,36 @@ switch ($type)
             switch ($sort)
             {
                 case 'id':
- $sql .= " ORDER BY id $sortorder";
+ $sortsql .= " ORDER BY id $sortorder";
                     break;
                 case 'title':
- $sql .= " ORDER BY title $sortorder";
+ $sortsql .= " ORDER BY title $sortorder";
                     break;
                 case 'contact':
- $sql .= " ORDER BY c.surname $sortorder, c.forenames $sortorder";
+ $sortsql .= " ORDER BY c.surname $sortorder, c.forenames $sortorder";
                     break;
                 case 'priority':
- $sql .= " ORDER BY priority $sortorder, lastupdated ASC";
+ $sortsql .= " ORDER BY priority $sortorder, lastupdated ASC";
                     break;
                 case 'status':
- $sql .= " ORDER BY status $sortorder";
+ $sortsql .= " ORDER BY status $sortorder";
                     break;
                 case 'lastupdated':
- $sql .= " ORDER BY lastupdated $sortorder";
+ $sortsql .= " ORDER BY lastupdated $sortorder";
                     break;
                 case 'duration':
- $sql .= " ORDER BY duration $sortorder";
+ $sortsql .= " ORDER BY duration $sortorder";
                     break;
                 case 'nextaction':
- $sql .= " ORDER BY timetonextaction $sortorder";
+ $sortsql .= " ORDER BY timetonextaction $sortorder";
                     break;
                 default:
- $sql .= " ORDER BY priority DESC, lastupdated ASC";
+ $sortsql .= " ORDER BY priority DESC, lastupdated ASC";
                     break;
             }
         }
-
+ $sql = $selectsql . $filtersql . $sortsql;
+// echo $sql;
         $result = mysql_query($sql);
         if (mysql_error()) trigger_error("MySQL Query Error ".mysql_error(), E_USER_WARNING);
         $rowcount = mysql_num_rows($result);
@@ -202,7 +214,7 @@ switch ($type)
         }

         // build querystring for hyperlinks
- $querystring = "?user=$user&queue=$queue&type=$type&";
+ $querystring = "?user=$user&queue=$queue&type=$type&site=$site&";

         // show drop down of incident status
         echo "<form action='{$_SERVER['PHP_SELF']}'>";
@@ -222,7 +234,60 @@ switch ($type)
             if ($queue == 4) echo "selected='selected' ";
             echo "value='{$_SERVER['PHP_SELF']}?user=$user&type=$type&queue=4'>{$strAllClosed}</option>\n";
         }
+ echo "<option ";
+ if ($queue == 5) echo "selected='selected' ";
+ echo "value='{$_SERVER['PHP_SELF']}?user=$user&type=$type&queue=5'>{$strAllIncidents}</option>\n";
         echo "</select>\n";
+
+ // show dropdown of Contact Sites
+ $sitesql = "SELECT id, name FROM `{$dbSites}`";
+ $siteresult = mysql_query($sitesql);
+ if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
+ echo "{$strSite}: <select class='dropdown' name='site' onchange='window.location.href=this.options[this.selectedIndex].value'>\n";
+ echo "<option ";
+ if ($site == 'all') echo "selected='selected' ";
+ echo "value='{$_SERVER['PHP_SELF']}?user=all&type=$type&queue=$queue&site=all'>All</option>\n";
+ while ($thesite = mysql_fetch_object($siteresult)) {
+ echo "<option ";
+ if ($site == $thesite->id) echo "selected='selected' ";
+ echo "value='{$_SERVER['PHP_SELF']}?user=$user&type=$type&queue=$queue&site={$thesite->id}'>{$thesite->name}</option>\n";
+ }
+ echo "</select>\n";
+
+ // show dropdown of users
+ $usersql = "SELECT id, realname FROM `{$dbUsers}` WHERE status = 1 ORDER BY realname ";
+ $userresult = mysql_query($usersql);
+ if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
+ echo "{$strUser}: <select class='dropdown' name='user' onchange='window.location.href=this.options[this.selectedIndex].value'>\n";
+ echo "<option ";
+ if ($user == 'all') echo "selected='selected' ";
+ echo "value='{$_SERVER['PHP_SELF']}?user=all&type=$type&queue=$queue&site=$site'>All</option>\n";
+ while ($theuser = mysql_fetch_object($userresult)) {
+ echo "<option ";
+ if ($user == $theuser->id) echo "selected='selected' ";
+ echo "value='{$_SERVER['PHP_SELF']}?user={$theuser->id}&type=$type&queue=$queue&site=$site'>{$theuser->realname}</option>\n";
+ }
+ echo "</select>\n";
+
+ // show dropdown of contacts
+ $contactsql = "SELECT distinct(c.id) AS contactid, forenames, surname ";
+ $contactsql .= "FROM `{$dbIncidents}` AS i, `{$dbContacts}` AS c, `{$dbPriority}` AS pr ";
+ $contactsql .= $filtersql;
+ $contactsql .= "ORDER BY surname, forenames";
+ $contactresult = mysql_query($contactsql);
+ if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
+ echo "{$strContact}: <select class='dropdown' name='contact' onchange='window.location.href=this.options[this.selectedIndex].value'>\n";
+ echo "<option ";
+ if ($contact == 'all') echo "selected='selected' ";
+ echo "value='{$_SERVER['PHP_SELF']}?user=$user&type=$type&queue=$queue&site=$site&contact=all'>All</option>\n";
+ while ($thecontact = mysql_fetch_object($contactresult)) {
+ echo "<option ";
+ if ($contact == $thecontact->contactid) echo "selected='selected' ";
+ echo "value='{$_SERVER['PHP_SELF']}?user=$user&type=$type&queue=$queue&site=$site&contact={$thecontact->contactid}'>{$thecontact->forenames} {$thecontact->surname}</option>\n";
+ }
+ echo "</select>\n";
+// echo $contactsql;
+
         echo "</form>";

         if ($queue == 4 AND $CONFIG['hide_closed_incidents_older_than'] != -1 AND $_GET['show'] != 'all')
@@ -371,4 +436,4 @@ switch ($type)
         echo "</div>";
 }
 include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
-?>
\ No newline at end of file
+?>

- Issue History
Date Modified Username Field Change
2012-05-11 02:24 paulvh New Issue
2012-07-06 08:43 Tomse Assigned To => Tomse
2012-07-06 08:43 Tomse Status new => acknowledged
2012-10-13 18:55 paulvh Note Added: 0004546
2013-02-04 20:48 paulh Tag Attached: patch


Copyright © 2000 - 2019 MantisBT Team
Powered by Mantis Bugtracker