Пример #1
0
     $mailed_subject = $updaterow['subject'];
     echo "<tr><td><label for='incidenttitle'>{$strIncidentTitle}</label><br />";
     echo "<input class='required' maxlength='200' id='incidenttitle' ";
     echo "name='incidenttitle' size='50' type='text' value=\"" . htmlspecialchars($mailed_subject, ENT_QUOTES) . "\" />";
     echo " <span class='required'>{$strRequired}</span></td>\n";
     echo "<td>";
     if ($type == 'free') {
         echo "<th>{$strServiceLevel}</th><td>" . serviceleveltag_drop_down('servicelevel', $CONFIG['default_service_level'], TRUE) . "</td>";
         echo "<th>{$strSkill}</th><td>" . skill_drop_down('software', 0) . "</td></tr>";
     } else {
         echo "<label for='software'>{$strSkill}</label><br />" . softwareproduct_drop_down('software', 1, $productid);
     }
     echo "</td></tr>";
     echo "<tr><td colspan='2'>&nbsp;</td></tr>\n";
     echo "<tr><th>{$strProblemDescription}<br /><span style='font-weight: normal'>{$strReceivedByEmail}</span></th>";
     echo "<td>" . parse_updatebody($mailed_body_text) . "</td></tr>\n";
     echo "<tr><td class='shade1' colspan='2'>&nbsp;</td></tr>\n";
 }
 echo "<tr><td><strong>{$strNextAction}</strong><br />";
 //     echo "<input type='text' name='nextaction' maxlength='50' size='30' value='Initial Response' /><br /><br />";
 echo show_next_action();
 echo "</td>";
 echo "<td colspan='2'>";
 echo "<strong>{$strVisibleToCustomer}</strong><br />\n";
 echo "<label><input name='cust_vis' type='checkbox' checked='checked' /> {$strVisibleToCustomer}</label>";
 echo help_link('VisibleToCustomer') . "<br />";
 echo "<label><input name='send_email' type='checkbox' checked='checked' /> ";
 echo "{$strSendOpeningEmailDesc}</label><br />";
 echo "<strong>{$strPriority}</strong><br />" . priority_drop_down("priority", 1, 4, FALSE) . " </td></tr>";
 echo "</table>\n";
 echo "<input type='hidden' name='win' value='{$win}' />";
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>";
    }
}
Пример #3
0
                echo "Final Solution by <strong>" . user_realname($updates['userid'], TRUE) . "</strong>";
                break;
            default:
                echo "Updated by <strong>" . user_realname($updates['userid'], TRUE) . "</strong>";
                if ($updates['customervisibility'] == 'show') {
                    echo " (Customer Visible)";
                }
                break;
        }
        if ($updates['nextaction'] != '') {
            echo " Next Action: <strong>" . $updates['nextaction'] . '</strong>';
        }
        echo " - {$update_timestamp_string}</th></tr>";
        echo "<tr><td class='shade2' width='100%'>";
        $updatecounter++;
        echo parse_updatebody($updates['bodytext']);
        echo "</td></tr>";
        echo "</table>";
        include APPLICATION_INCPATH . 'htmlfooter.inc.php';
    }
} else {
    // check that the incident is still open.  i.e. status not = closed
    if (incident_status($incidentid) != STATUS_CLOSED) {
        $moved_attachments = TRUE;
        // update the incident record, change the incident status to active
        $sql = "UPDATE `{$dbIncidents}` SET status='1', lastupdated='{$now}', timeofnextaction='0' WHERE id='{$incidentid}'";
        mysql_query($sql);
        if (mysql_error()) {
            trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR);
        }
        $old_path = $CONFIG['attachment_fspath'] . 'updates' . $fsdelim;
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;
}
Пример #5
0
/**
    * @author Tom Gerrard
*/
function generate_row($update)
{
    global $CONFIG, $sit;
    if (empty($update['fromaddr']) and !empty($update['from'])) {
        $update['fromaddr'] = $update['from'];
    }
    $update['fromaddr'] = strtolower($update['fromaddr']);
    if (strlen($update['bodytext']) > 1003) {
        $updatebodytext = substr($update['bodytext'], 0, 1000) . '&hellip;';
    } else {
        $updatebodytext = $update['bodytext'];
    }
    $search = array('<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '&lt;', '&gt;');
    $replace = '';
    $updatebodytext = htmlspecialchars(str_replace($search, $replace, $updatebodytext));
    if ($updatebodytext == '') {
        $updatebodytext = '&nbsp;';
    }
    $shade = 'shade1';
    if ($update['contactid'] != 0) {
        $shade = 'idle';
    } else {
        if (!empty($update['fromaddr'])) {
            // Have a look if we've got a user with this email address
            $sql = "SELECT COUNT(id) FROM `{$GLOBALS['dbUsers']}` WHERE email LIKE '%{$update['fromaddr']}%'";
            $result = mysql_query($sql);
            if (mysql_error()) {
                trigger_error(mysql_error(), E_USER_WARNING);
            }
            list($contactmatches) = mysql_fetch_row($result);
            if ($contactmatches > 0) {
                $shade = 'notice';
            }
        }
    }
    $pluginshade = plugin_do('holdingqueue_rowshade', $update);
    $shade = $pluginshade ? $pluginshade : $shade;
    $html_row = "<tr class='{$shade}'>";
    $html_row .= "<td style='text-align: center'>";
    if ($update['locked'] == $sit[2] or empty($update['locked'])) {
        $html_row .= "<input type='checkbox' name='selected[]' value='" . $update['updateid'] . "' />";
    }
    $html_row .= "</td>";
    $html_row .= "<td align='center' width='20%'>" . date($CONFIG['dateformat_datetime'], $update['timestamp']) . '</td>';
    $html_row .= "<td width='20%'>";
    if (!empty($update['contactid']) and $update['fromaddr'] == contact_email($update['contactid'])) {
        $html_row .= gravatar($update['fromaddr'], 16) . ' ';
        $contact_realname = contact_realname($update['contactid']);
        $html_row .= "<a href='contact_details.php?id={$update['contactid']}' class='info'>";
        $html_row .= "{$contact_realname}<span>" . htmlentities($update['fromaddr'], ENT_QUOTES, $GLOBALS['i18ncharset']) . "</span></a>";
        $html_row .= " of " . contact_site($update['contactid']);
        if ($update['emailfrom'] != $contact_realname) {
            $html_row .= "<br />\n";
            $html_row .= htmlentities($update['emailfrom'], ENT_QUOTES, $GLOBALS['i18ncharset']);
        }
    } else {
        $html_row .= gravatar($update['fromaddr'], 16) . ' ';
        $html_row .= "<a href=\"mailto:{$update['fromaddr']}\">{$update['fromaddr']}</a><br />\n";
        $html_row .= htmlentities($update['emailfrom'], ENT_QUOTES, $GLOBALS['i18ncharset']);
    }
    $html_row .= "</td>";
    $html_row .= "<td width='20%'><a href=\"javascript:incident_details_window('{$update['tempid']}','incomingview');\" id='update{$update['id']}' class='info'>";
    //     $html_row.="<td width='20%'><a href=\"javascript:void(0);\" id='update{$update['id']}' class='info' style='cursor:help;'>";
    if (empty($update['subject'])) {
        $update['subject'] = $GLOBALS['strUntitled'];
    }
    $html_row .= htmlentities($update['subject'], ENT_QUOTES, $GLOBALS['i18ncharset']);
    $html_row .= '<span>' . parse_updatebody($updatebodytext) . '</span></a></td>';
    $span = sprintf($GLOBALS['strByX'], user_realname($update['reason_user'])) . "<br />";
    $span .= sprintf($GLOBALS['strOnxAtY'], ldate($CONFIG['dateformat_date'], mysql2date($update['reason_time'])), ldate($CONFIG['dateformat_time'], mysql2date($update['reason_time'])));
    $html_row .= "<td align='center' width='20%'><a class='info'>{$update['reason']}<span>{$span}</span></a></td>";
    $html_row .= "<td align='center' width='20%'>";
    if ($update['locked'] != $sit[2] && $update['locked'] > 0) {
        $html_row .= sprintf($strLockedByX, user_realname($update['locked'], TRUE));
    } else {
        if ($update['locked'] == $sit[2]) {
            $html_row .= "<a href='{$_SERVER['PHP_SELF']}?unlock={$update['tempid']}'";
            $html_row .= " title='{$strUnlockThisToBeModifiedByOther}'> {$GLOBALS['strUnlock']}</a> | ";
        } else {
            $html_row .= "<a href=\"javascript:incident_details_window('{$update['tempid']}'";
            $html_row .= ",'incomingview');\" id='update{$update['id']}' class='info'";
            $html_row .= " title='View and lock this held e-mail'>{$GLOBALS['strView']}</a> | ";
        }
        if ($update['reason_id'] == 2) {
            $html_row .= "<a href='incident_reopen.php?id={$update['incident_id']}&updateid={$update['updateid']}'>{$GLOBALS['strReopen']}</a> | ";
        }
        $html_row .= "<a href='delete_update.php?updateid=" . $update['id'] . "&amp;tempid=" . $update['tempid'] . "&amp;timestamp=" . $update['timestamp'] . "' title='{$strRemoveThisPermanently}' onclick=\"return confirm_action('{$GLOBALS['strAreYouSureDelete']}');\"> {$GLOBALS['strDelete']}</a>";
    }
    $html_row .= "</td></tr>\n";
    return $html_row;
}
Пример #6
0
            trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING);
        }
        $update = mysql_fetch_object($uresult);
        echo "<div class='detailhead'>";
        echo "<div class='detaildate'>";
        if (!empty($update->timestamp)) {
            echo date($CONFIG['dateformat_datetime'], $update->timestamp);
        }
        echo "</div>";
        echo icon('email', 16);
        echo " {$incoming->subject}";
        if (empty($_REQUEST['reply'])) {
            echo " &mdash; <a href='{$_SERVER['PHP_SELF']}?id={$displayid}&reply=true'>{$strReply}</a>";
        }
        echo "</div>";
        echo "<div class='detailentry'>\n";
        if (!empty($_REQUEST['reply'])) {
            echo "{$strSubject}: <input type='text' value=\"Re: {$incoming->subject}\" size='40' />";
            echo "<textarea style='width: 98%' rows='30'>";
            echo quote_message($update->bodytext);
            echo "</textarea>";
        } else {
            echo parse_updatebody($update->bodytext, FALSE);
        }
        echo "</div>";
        echo "<p><a href='{$_SERVER['PHP_SELF']}'>&lt; {$strBackToList}</a></p>";
    } else {
        echo "<p class='warning'>{$strNoRecords}</p>";
    }
}
include APPLICATION_INCPATH . 'htmlfooter.inc.php';
    echo "<div class='detailinfo'>";
    if ($lockedbyname == "you") {
        echo "<div class='detaildate'>";
        echo "<form method='post' action='{$_SERVER['PHP_SELF']}?id={$incomingid}&win=incomingview&action=updatereason'>";
        echo "{$strMessage}: <input name='newreason' type='text' value=\"{$incoming->reason}\" size='25' maxlength='100' />";
        echo "<input type='submit' value='{$strSave}' />";
        echo "</form>";
        echo "</div>";
    } else {
        echo "<div class='detaildate'>{$incoming->reason}</div>";
    }
    echo icon('locked', 16, $strLocked);
    echo " " . sprintf($strLockedByX, $lockedbyname) . "</div>";
    //echo "<pre>".print_r($incoming,true)."</pre>";
    $usql = "SELECT * FROM `{$dbUpdates}` WHERE id='{$incoming->updateid}'";
    $uresult = mysql_query($usql);
    while ($update = mysql_fetch_object($uresult)) {
        $updatetime = readable_date($update->timestamp);
        $updatebody = preg_replace("/\\[\\[att=(.*?)\\]\\](.*?)\\[\\[\\/att\\]\\]/s", "<a href='download.php?id=\$1'>\$2</a>", $update->bodytext);
        echo "<div class='detailhead'><div class='detaildate'>{$updatetime}</div>";
        echo icon('emailin', 16);
        echo " {$strFrom} <strong>{$incoming->emailfrom}</strong></div>";
        echo "<div class='detailentry'>";
        echo parse_updatebody($updatebody, FALSE);
        echo "</div>";
    }
} else {
    echo user_alert($strNoRecords, E_USER_WARNING);
}
unset($result);
unset($uresult);
     $slaremain = $slatarget - $target->since;
 } else {
     $slaremain = 0;
 }
 // Get next review time
 $reviewsince = incident_get_next_review($incidents['id']);
 // time since last review in minutes
 $reviewtarget = $servicelevel->review_days * 1440;
 // how often reviews should happen in minutes
 if ($reviewtarget > 0) {
     $reviewremain = $reviewtarget - $reviewsince;
 } else {
     $reviewremain = 0;
 }
 // Remove Tags from update Body
 $update_body = parse_updatebody($update_body);
 $update_user = user_realname($update_userid, TRUE);
 // ======= Row Colors / Shading =======
 // Define Row Shading lowest to highest priority so that unimportant colors are overwritten by important ones
 switch ($queue) {
     case 1:
         // Action Needed
         $class = 'shade2';
         $explain = '';
         if ($slaremain >= 1) {
             if ($slaremain - $slatarget * ((100 - $CONFIG['notice_threshold']) / 100) < 0) {
                 $class = 'notice';
             }
             if ($slaremain - $slatarget * ((100 - $CONFIG['urgent_threshold']) / 100) < 0) {
                 $class = 'urgent';
             }