} else { // Create a new update from details entered $sql = "INSERT INTO `{$dbUpdates}` (incidentid, userid, type, bodytext, timestamp, currentowner, "; $sql .= "currentstatus, customervisibility, nextaction) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'opening', '{$updatetext}', '{$now}', '{$sit[2]}', "; $sql .= "'1', '{$customervisibility}', '{$nextaction}')"; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } } // get the service level // find out when the initial response should be according to the service level if (empty($servicelevel) or $servicelevel == 0) { // FIXME: for now we use id but in future use tag, once maintenance uses tag $servicelevel = maintenance_servicelevel($maintid); $sql = "SELECT * FROM `{$dbServiceLevels}` WHERE id='{$servicelevel}' AND priority='{$priority}' "; } else { $sql = "SELECT * FROM `{$dbServiceLevels}` WHERE tag='{$servicelevel}' AND priority='{$priority}' "; } $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } $level = mysql_fetch_object($result); $targetval = $level->initial_response_mins * 60; $initialresponse = $now + $targetval; // Insert the first SLA update, this indicates the start of an incident // This insert could possibly be merged with another of the 'updates' records, but for now we keep it seperate for clarity $sql = "INSERT INTO `{$dbUpdates}` (incidentid, userid, type, timestamp, currentowner, currentstatus, customervisibility, sla, bodytext) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'slamet', '{$now}', '{$sit[2]}', '1', 'show', 'opened','{$_SESSION['syslang']['strIncidentIsOpen']}.')";
mysql_query($pisql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } } } } else { $incidentid = 0; } $update_id = new_update($incidentid, $updatetext, 'opening'); if ($CONFIG['portal_creates_incidents']) { // get the service level // find out when the initial response should be according to the service level if (empty($servicelevel) or $servicelevel == 0) { // FIXME: for now we use id but in future use tag, once maintenance uses tag $servicelevel = maintenance_servicelevel($contractid); $sql = "SELECT * FROM `{$dbServiceLevels}` WHERE id='{$servicelevel}' AND priority='{$priority}' "; } else { $sql = "SELECT * FROM `{$dbServiceLevels}` WHERE tag='{$servicelevel}' AND priority='{$priority}' "; } $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } $level = mysql_fetch_object($result); $targetval = $level->initial_response_mins * 60; $initialresponse = $now + $targetval; // Insert the first SLA update, this indicates the start of an incident // This insert could possibly be merged with another of the 'updates' records, but for now we keep it seperate for clarity $sql = "INSERT INTO `{$dbUpdates}` (incidentid, userid, type, timestamp, currentowner, currentstatus, customervisibility, sla, bodytext) "; $sql .= "VALUES ('{$incidentid}', '0', 'slamet', '{$now}', '0', '1', 'hide', 'opened','The incident is open and awaiting action.')";
$site_notes = ''; } unset($site); if (!empty($incident->contactnotes)) { $contact_notes = icon('contact', 16) . " <strong>{$strContactNotes}</strong><br />" . nl2br($incident->contactnotes); } else { $contact_notes = ''; } $product_name = product_name($incident->product); if ($incident->softwareid > 0) { $software_name = software_name($incident->softwareid); } $servicelevel_id = maintenance_servicelevel($incident->maintenanceid); $servicelevel_tag = $incident->servicelevel; if ($servicelevel_tag == '') { $servicelevel_tag = servicelevel_id2tag(maintenance_servicelevel($incident->maintenanceid)); } $servicelevel_name = servicelevel_name($servicelevelid); if ($incident->closed == 0) { $closed = time(); } else { $closed = $incident->closed; } $opened_for = format_seconds($closed - $incident->opened); $priority = $incident->priority; // Lookup the service level times $slsql = "SELECT * FROM `{$dbServiceLevels}` WHERE tag='{$servicelevel_tag}' AND priority='{$incident->priority}' "; $slresult = mysql_query($slsql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); }
$updated = "<em class='updatedveryrecently'>" . sprintf($strAgo, format_seconds($now - $incidents['lastupdated'])) . "</em>"; } elseif ($incidents['lastupdated'] > $now - 3600) { $updated = "<em class='updatedrecently'>" . sprintf($strAgo, format_seconds($now - $incidents['lastupdated'])) . "</em>"; } elseif (date('dmy', $incidents['lastupdated']) == date('dmy', $now)) { $updated = "{$strToday} @ " . ldate($CONFIG['dateformat_time'], $incidents['lastupdated']); } elseif (date('dmy', $incidents['lastupdated']) == date('dmy', $now - 86400)) { $updated = "{$strYesterday} @ " . ldate($CONFIG['dateformat_time'], $incidents['lastupdated']); } elseif ($incidents['lastupdated'] < $now - 86400 and $incidents['lastupdated'] > $now - 86400 * 6) { $updated = ldate('l', $incidents['lastupdated']) . " @ " . ldate($CONFIG['dateformat_time'], $incidents['lastupdated']); } else { $updated = ldate($CONFIG['dateformat_datetime'], $incidents["lastupdated"]); } // Fudge for old ones $tag = $incidents['servicelevel']; if ($tag == '') { $tag = servicelevel_id2tag(maintenance_servicelevel($incidents['maintenanceid'])); } $slsql = "SELECT * FROM `{$dbServiceLevels}` WHERE tag='{$tag}' AND priority='{$incidents['priority']}' "; $slresult = mysql_query($slsql); if (mysql_error()) { trigger_error("mysql query error " . mysql_error(), E_USER_WARNING); } $servicelevel = mysql_fetch_object($slresult); if (mysql_num_rows($slresult) < 1) { trigger_error("could not retrieve service level ({$slsql})", E_USER_WARNING); } // Get Last Update list($update_userid, $update_type, $update_currentowner, $update_currentstatus, $update_body, $update_timestamp, $update_nextaction, $update_id) = incident_lastupdate($incidents['id']); // Get next target $target = incident_get_next_target($incidents['id']); $working_day_mins = ($CONFIG['end_working_day'] - $CONFIG['start_working_day']) / 60;