Example #1
0
function portal_incident_table($sql)
{
    global $CONFIG, $showclosed;
    $result = mysql_query($sql);
    if (mysql_error()) {
        trigger_error(mysql_error(), E_USER_WARNING);
    }
    $numincidents = mysql_num_rows($result);
    if ($numincidents >= 1) {
        $shade = 'shade1';
        $html .= "<table align='center' width='70%'>";
        $html .= "<tr>";
        $html .= colheader('id', $GLOBALS['strID']);
        $html .= colheader('title', $GLOBALS['strTitle']);
        $html .= colheader('owner', $GLOBALS['strOwner']);
        $html .= colheader('lastupdated', $GLOBALS['strLastUpdated']);
        $html .= colheader('contact', $GLOBALS['strContact']);
        $html .= colheader('status', $GLOBALS['strStatus']);
        if ($showclosed != "true") {
            $html .= colheader('actions', $GLOBALS['strOperation']);
        }
        $html .= "</tr>\n";
        while ($incident = mysql_fetch_object($result)) {
            $html .= "<tr class='{$shade}'><td align='center'>";
            $html .= "<a href='incident.php?id={$incident->id}'>{$incident->id}</a></td>";
            $html .= "<td>";
            if (!empty($incident->softwareid)) {
                $html .= software_name($incident->softwareid) . "<br />";
            }
            $html .= "<strong><a href='incident.php?id={$incident->id}'>{$incident->title}</a></strong></td>";
            $html .= "<td align='center'>" . user_realname($incident->owner) . "</td>";
            $html .= "<td align='center'>" . ldate($CONFIG['dateformat_datetime'], $incident->lastupdated) . "</td>";
            $html .= "<td align='center'><a href='contactdetails.php?id={$incident->contactid}'>";
            $html .= "{$incident->forenames} {$incident->surname}</a></td>";
            $html .= "<td align='center'>" . incidentstatus_name($incident->status, external) . "</td>";
            if ($showclosed != "true") {
                $html .= "<td align='center'><a href='update.php?id={$incident->id}'>{$GLOBALS['strUpdate']}</a> | ";
                //check if the customer has requested a closure
                $lastupdate = list($update_userid, $update_type, $update_currentowner, $update_currentstatus, $update_body, $update_timestamp, $update_nextaction, $update_id) = incident_lastupdate($incident->id);
                if ($lastupdate[1] == "customerclosurerequest") {
                    $html .= "{$GLOBALS['strClosureRequested']}</td>";
                } else {
                    $html .= "<a href='close.php?id={$incident->id}'>{$GLOBALS['strRequestClosure']}</a></td>";
                }
            }
            $html .= "</tr>";
            if ($shade == 'shade1') {
                $shade = 'shade2';
            } else {
                $shade = 'shade1';
            }
        }
        $html .= "</table>";
    } else {
        $html .= "<p class='info'>{$GLOBALS['strNoIncidents']}</p>";
    }
    return $html;
}
function dashboard_watch_incidents_display($dashletid)
{
    global $CONFIG, $sit;
    $html = "<script type='text/javascript'>\n    //<![CDATA[\n    function statusform_submit(user)\n    {\n        URL = \"incidents.php?status=\" + window.document.statusform.status.options[window.document.statusform.status.selectedIndex].value + \"&amp;user=\" + user;\n        window.confirm(URL);\n        window.location.href = URL;\n    }\n    //]]>\n    </script>";
    // FIXME, commented out the queue selector, needs recoding to work with one-file dashboards - Ivan 22May08
    //     $html .= "<form action='{$_SERVER['PHP_SELF']}' style='text-align: center;'>";
    //     $html .= "{$GLOBALS['strQueue']}: <select class='dropdown' name='queue' onchange='window.location.href=this.options[this.selectedIndex].value'>\n";
    //     $html .= "<option ";
    //     if ($queue == 5)
    //     {
    //         $html .= "selected='selected' ";
    //     }
    //     $html .= "value=\"javascript:get_and_display('display_watch_incidents.inc.php?queue=5','watch_incidents_windows');\">{$GLOBALS['strAll']}</option>\n";
    //     $html .= "<option ";
    //     if ($queue == 1)
    //     {
    //         $html .= "selected='selected' ";
    //     }
    //     $html .= "value=\"javascript:get_and_display('display_watch_incidents.inc.php?queue=1','watch_incidents_windows');\">{$GLOBALS['strActionNeeded']}</option>\n";
    //     $html .= "<option ";
    //     if ($queue == 3)
    //     {
    //         $html .= "selected='selected' ";
    //     }
    //     $html .= "value=\"javascript:get_and_display('display_watch_incidents.inc.php?queue=3','watch_incidents_windows');\">{$GLOBALS['strAllOpen']}</option>\n";
    //     $html .= "</select>\n";
    //     $html .= "</form>";
    $sql = "SELECT type, id FROM `{$CONFIG['db_tableprefix']}dashboard_watch_incidents` WHERE userid = {$sit[2]} ORDER BY type";
    $result = mysql_query($sql);
    if (mysql_error()) {
        trigger_error(mysql_error() . $sql, E_USER_WARNING);
    }
    if (mysql_num_rows($result) > 0) {
        $header_printed = FALSE;
        $previous = 0;
        while ($obj = mysql_fetch_object($result)) {
            if ($obj->type != 3 and $previous == 3) {
                $html .= "</table>";
            }
            if ($obj->type == 3 and !$header_printed) {
                $html .= "<table>";
            } else {
                if ($obj->type != 3) {
                    $html .= "<table>";
                }
            }
            switch ($obj->type) {
                case '0':
                    //Site
                    $sql = "SELECT i.id, i.title, i.status, i.servicelevel, i.maintenanceid, i.priority, c.forenames, c.surname, c.siteid ";
                    $sql .= "FROM `{$GLOBALS['dbIncidents']}` AS i, `{$GLOBALS['dbContacts']}`  AS c ";
                    $sql .= "WHERE i.contact = c.id AND c.siteid = {$obj->id} ";
                    $sql .= "AND i.status != " . STATUS_CLOSED . " AND i.status != " . STATUS_CLOSING . " ";
                    $lsql = "SELECT name FROM `{$GLOBALS['dbSites']}` WHERE id = {$obj->id}";
                    $lresult = mysql_query($lsql);
                    if (mysql_error()) {
                        trigger_error(mysql_error(), E_USER_WARNING);
                    }
                    $lobj = mysql_fetch_object($lresult);
                    $html .= "<tr><th colspan='3'>{$lobj->name} ({$GLOBALS['strSite']})</th></tr>";
                    break;
                case '1':
                    //contact
                    $sql = "SELECT i.id, i.title, i.status, i.servicelevel, i.maintenanceid, i.priority, c.forenames, c.surname, c.siteid ";
                    $sql .= "FROM `{$GLOBALS['dbIncidents']}` AS i, `{$GLOBALS['dbContacts']}`  AS c ";
                    $sql .= "WHERE i.contact = c.id AND i.contact = {$obj->id} ";
                    $sql .= "AND i.status != " . STATUS_CLOSED . " AND i.status != " . STATUS_CLOSING . " ";
                    $lsql = "SELECT forenames, surname FROM `{$GLOBALS['dbContacts']}` WHERE id = {$obj->id} ";
                    $lresult = mysql_query($lsql);
                    if (mysql_error()) {
                        trigger_error(mysql_error(), E_USER_WARNING);
                    }
                    $lobj = mysql_fetch_object($lresult);
                    $html .= "<tr><th colspan='3'>{$lobj->forenames} {$lobj->surname} ({$GLOBALS['strContact']})</th></tr>";
                    break;
                case '2':
                    //engineer
                    $sql = "SELECT i.id, i.title, i.status, i.servicelevel, i.maintenanceid, i.priority, c.forenames, c.surname, c.siteid ";
                    $sql .= "FROM `{$GLOBALS['dbIncidents']}` AS i, `{$GLOBALS['dbContacts']}`  AS c ";
                    $sql .= "WHERE i.contact = c.id AND (i.owner = {$obj->id} OR i.towner = {$obj->id}) ";
                    $sql .= "AND i.status != " . STATUS_CLOSED . " AND i.status != " . STATUS_CLOSING . " ";
                    $lsql = "SELECT realname FROM `{$GLOBALS['dbUsers']}` WHERE id = {$obj->id}";
                    $lresult = mysql_query($lsql);
                    if (mysql_error()) {
                        trigger_error(mysql_error(), E_USER_WARNING);
                    }
                    $lobj = mysql_fetch_object($lresult);
                    $html .= "<tr><th colspan='3'>";
                    $html .= sprintf($GLOBALS['strIncidentsForEngineer'], $lobj->realname);
                    $html .= "</th></tr>";
                    break;
                case '3':
                    //incident
                    $sql = "SELECT i.id, i.title, i.status, i.servicelevel, i.maintenanceid, i.priority ";
                    $sql .= "FROM `{$GLOBALS['dbIncidents']}` AS i ";
                    $sql .= "WHERE i.id = {$obj->id} ";
                    //$sql .= "AND incidents.status != 2 AND incidents.status != 7";
                    break;
                default:
                    $sql = '';
            }
            if (!empty($sql)) {
                switch ($queue) {
                    case 1:
                        // awaiting action
                        $sql .= "AND ((timeofnextaction > 0 AND timeofnextaction < {$now}) 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} ) ";
                        break;
                    case 3:
                        // All Open
                        $sql .= "AND status!='2' ";
                        break;
                    case 5:
                        // ALL
                    // ALL
                    default:
                        break;
                }
                $iresult = mysql_query($sql);
                if (mysql_error()) {
                    trigger_error(mysql_error(), E_USER_WARNING);
                }
                if (mysql_num_rows($iresult) > 0) {
                    if ($obj->type == 3 and !$header_printed) {
                        $html .= "<tr><th colspan='4'>{$GLOBALS['strIncidents']}</th></tr>";
                        $html .= "<tr>";
                        $html .= colheader('id', $GLOBALS['strID']);
                        $html .= colheader('title', $GLOBALS['strTitle']);
                        //$html .= colheader('customer', $GLOBALS['strCustomer']);
                        $html .= colheader('status', $GLOBALS['strStatus']);
                        $html .= "</tr>\n";
                        $header_printed = TRUE;
                    } else {
                        if ($obj->type != 3) {
                            $html .= "<tr>";
                            $html .= colheader('id', $GLOBALS['strID']);
                            $html .= colheader('title', $GLOBALS['strTitle']);
                            //$html .= colheader('customer', $GLOBALS['strCustomer']);
                            $html .= colheader('status', $GLOBALS['strStatus']);
                            $html .= "</tr>\n";
                        }
                    }
                    $shade = 'shade1';
                    while ($incident = mysql_fetch_object($iresult)) {
                        $html .= "<tr class='{$shade}'>";
                        $html .= "<td>{$incident->id}</td>";
                        $html .= "<td><a href='javascript:incident_details_window({$incident->id}) '  class='info'>" . $incident->title;
                        $html .= "<span><strong>{$GLOBALS['strCustomer']}:</strong> " . sprintf($GLOBALS['strXofX'], "{$incident->forenames} {$incident->surname}", site_name($incident->siteid));
                        list($update_userid, $update_type, $update_currentowner, $update_currentstatus, $update_body, $update_timestamp, $update_nextaction, $update_id) = incident_lastupdate($incident->id);
                        $update_body = parse_updatebody($update_body);
                        if (!empty($update_body) and $update_body != '...') {
                            $html .= "<br />{$update_body}";
                        }
                        $html .= "</span></a></td>";
                        $html .= "<td>" . incidentstatus_name($incident->status) . "</td>";
                        $html .= "</tr>\n";
                        if ($shade == 'shade1') {
                            $shade = 'shade2';
                        } else {
                            $shade = 'shade1';
                        }
                    }
                } else {
                    if ($obj->type == 3 and !$header_printed) {
                        $html .= "<tr><th colspan='3'>{$GLOBALS['strIncidents']}</th></tr>";
                        $html .= "<tr><td colspan='3'>{$GLOBALS['strNoIncidents']}</td></tr>\n";
                        $header_printed = TRUE;
                    } else {
                        if ($obj->type != 3) {
                            $html .= "<tr><td colspan='3'>{$GLOBALS['strNoIncidents']}</td></tr>\n";
                        }
                    }
                }
            }
            if ($obj->type == 3 and !$header_printed) {
                $html .= "</table>\n";
            }
            $previous = $obj->type;
        }
    } else {
        $html .= "<p align='center'>{$GLOBALS['strNoRecords']}</p>";
    }
    return $html;
}
function dashboard_user_incidents_display($dashletid)
{
    global $user;
    global $sit;
    global $now;
    global $GLOBALS;
    global $CONFIG;
    global $iconset;
    global $dbIncidents, $dbContacts, $dbPriority;
    $user = "******";
    // Create SQL for chosen queue
    // If you alter this SQL also update the function user_activeincidents($id)
    if ($user == 'current') {
        $user = $sit[2];
    }
    // If the user is passed as a username lookup the userid
    if (!is_number($user) and $user != 'current' and $user != 'all') {
        $usql = "SELECT id FROM `{$dbUsers}` WHERE username='******' LIMIT 1";
        $uresult = mysql_query($usql);
        if (mysql_error()) {
            trigger_error(mysql_error(), E_USER_WARNING);
        }
        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 = "WHERE i.contact = c.id AND i.priority = p.id ";
    if ($user != 'all') {
        $sql .= "AND (owner='{$user}' OR towner='{$user}') ";
    }
    $queue = 1;
    //we still need this for the included page so the incidents are coloured correctly
    //the only case we're really interested in
    $sql .= "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 ";
    $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} ) ";
    $selectsql = "SELECT i.id, externalid, title, owner, towner, priority, status, siteid, forenames, surname, email, i.maintenanceid, ";
    $selectsql .= "servicelevel, softwareid, lastupdated, timeofnextaction, ";
    $selectsql .= "(timeofnextaction - {$now}) AS timetonextaction, opened, ({$now} - opened) AS duration, closed, (closed - opened) AS duration_closed, type, ";
    $selectsql .= "({$now} - lastupdated) AS timesincelastupdate ";
    $selectsql .= "FROM `{$dbIncidents}` AS i, `{$dbContacts}` AS c, `{$dbPriority}` AS p ";
    // Create SQL for Sorting
    switch ($sort) {
        case 'id':
            $sql .= " ORDER BY id {$sortorder}";
            break;
        case 'title':
            $sql .= " ORDER BY title {$sortorder}";
            break;
        case 'contact':
            $sql .= " ORDER BY c.surname {$sortorder}, c.forenames {$sortorder}";
            break;
        case 'priority':
            $sql .= " ORDER BY priority {$sortorder}, lastupdated ASC";
            break;
        case 'status':
            $sql .= " ORDER BY status {$sortorder}";
            break;
        case 'lastupdated':
            $sql .= " ORDER BY lastupdated {$sortorder}";
            break;
        case 'duration':
            $sql .= " ORDER BY duration {$sortorder}";
            break;
        case 'nextaction':
            $sql .= " ORDER BY timetonextaction {$sortorder}";
            break;
        default:
            $sql .= " ORDER BY priority DESC, lastupdated ASC";
            break;
    }
    $sql = $selectsql . $sql;
    $result = mysql_query($sql);
    if (mysql_error()) {
        trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING);
    }
    $rowcount = mysql_num_rows($result);
    // Toggle Sorting Order
    if ($sortorder == 'ASC') {
        $newsortorder = 'DESC';
    } else {
        $newsortorder = 'ASC';
    }
    // build querystring for hyperlinks
    $querystring = "?user={$user}&amp;queue={$queue}&amp;type={$type}&amp;";
    if ($user == 'all') {
        //echo "<p align='center'>There are <strong>{$rowcount}</strong> incidents in this list.</p>";
        echo "<p align='center'>" . sprintf($strThereAreXIncidentsInThisList, $rowcount) . "</p>";
    }
    $mode = "min";
    // Print message if no incidents were listed
    if (mysql_num_rows($result) >= 1) {
        // Incidents Table
        $incidents_minimal = true;
        //include ('incidents_table.inc.php');
        $shade = 'shade1';
        echo "<table summary=\"{$strIncidents}\">";
        while ($row = mysql_fetch_array($result)) {
            list($update_userid, $update_type, $update_currentowner, $update_currentstatus, $update_body, $update_timestamp, $update_nextaction, $update_id) = incident_lastupdate($row['id']);
            $update_body = parse_updatebody($update_body);
            echo "<tr><td class='{$shade}'>";
            echo "<a href='javascript:incident_details_window({$row['id']})' class='info'>";
            echo "{$row['id']} - {$row['title']} {$GLOBALS['strFor']} {$row['forenames']}   {$row['surname']}";
            if (!empty($update_body) and $update_body != '...') {
                echo "<span>{$update_body}</span>";
            }
            echo "</a></td></tr>\n";
            if ($shade == 'shade1') {
                $shade = 'shade2';
            } else {
                $shade = 'shade1';
            }
        }
        echo "</table>";
    } else {
        echo "<p align='center'>{$GLOBALS['strNoRecords']}</p>";
    }
}
Example #4
0
        $origtag[] = "</{$keeptag}>";
        $origtag[] = "<'.strtoupper({$keeptag}).'>";
        $origtag[] = "</'.strtoupper({$keeptag}).'>";
        $temptag[] = "[[{$keeptag}]]";
        $temptag[] = "[[/{$keeptag}]]";
        $temptag[] = "[['.strtoupper({$keeptag}).']]";
        $temptag[] = "[[/'.strtoupper({$keeptag}).']]";
    }
}
echo "<div id='portalleft'>";
echo "<h3>{$strActions}</h3>";
if ($user->status != 2) {
    echo "<p>" . icon('note', 16, $strUpdate);
    echo " <a href='update.php?id={$incidentid}'>{$strUpdate}</a></p>";
    //check if the customer has requested a closure
    $lastupdate = list($update_userid, $update_type, $update_currentowner, $update_currentstatus, $update_body, $update_timestamp, $update_nextaction, $update_id) = incident_lastupdate($incidentid);
    if ($lastupdate[1] == "customerclosurerequest") {
        echo "{$strClosureRequested}</td>";
    } else {
        echo "<p>" . icon('close', 16, $strRequestClosure);
        echo " <a href='close.php?id={$incidentid}'>";
        echo "{$strRequestClosure}</a></p>";
    }
}
echo "<h3>{$strFiles}</h3>";
$filesql = "SELECT *, f.id AS fileid, u.id AS updateid, f.userid AS userid\n            FROM `{$dbFiles}` AS f, `{$dbLinks}` AS l, `{$dbUpdates}` AS u\n            WHERE f.category='public'\n            AND l.linktype='5'\n            AND l.linkcolref=f.id\n            AND l.origcolref=u.id\n            AND u.incidentid='{$incidentid}'\n            ORDER BY f.filedate DESC";
$fileresult = mysql_query($filesql);
if (mysql_error()) {
    trigger_error("MySQL Query Error {$sql}" . mysql_error(), E_USER_WARNING);
}
$delim = $fsdelim;