Exemple #1
0
/**
 * Creates an incident based on an 'tempincoming' table entry
 * @author Kieran Hogg
 * @param int $incomingid the ID of the tempincoming entry
 * @return int|bool returns either the ID of the contract or FALSE if none
 */
function create_incident_from_incoming($incomingid)
{
    global $dbTempIncoming, $dbMaintenance, $dbServiceLevels, $dbSoftwareProducts, $CONFIG;
    $rtn = TRUE;
    $incomingid = intval($incomingid);
    $sql = "SELECT * FROM `{$dbTempIncoming}` ";
    $sql .= "WHERE id = '{$incomingid}'";
    $result = mysql_query($sql);
    if (mysql_error()) {
        trigger_error(mysql_error(), E_USER_ERROR);
    }
    $row = mysql_fetch_object($result);
    $contact = $row->contactid;
    $contract = guess_contract_id($contact);
    if (!$contract) {
        // we have no contract to log against, update stays in incoming
        return TRUE;
    }
    $subject = $row->subject;
    $update = $row->updateid;
    $sql = "SELECT servicelevelid, tag, product, softwareid ";
    $sql .= "FROM `{$dbMaintenance}` AS m, `{$dbServiceLevels}` AS s, ";
    $sql .= "`{$dbSoftwareProducts}` AS sp ";
    $sql .= "WHERE m.id = '{$contract}' ";
    $sql .= "AND m.servicelevelid = s.id ";
    $sql .= "AND m.product = sp.productid LIMIT 1";
    $result = mysql_query($sql);
    if (mysql_error()) {
        trigger_error(mysql_error(), E_USER_ERROR);
        $rtn = FALSE;
    }
    $row = mysql_fetch_object($result);
    $sla = $row->tag;
    $product = $row->product;
    $software = $row->softwareid;
    $incident = create_incident($subject, $contact, $row->tag, $contract, $product, $software);
    if (!move_update_to_incident($update, $incident)) {
        $rtn = FALSE;
    }
    if ($CONFIG['auto_assign_incidents']) {
        $user = suggest_reassign_userid($incident);
        if (!reassign_incident($incident, $user)) {
            $rtn = FALSE;
        }
    }
    return $rtn;
}
Exemple #2
0
     if (mysql_error()) {
         trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR);
     }
     // Insert the first Review update, this indicates the review period of an incident has started
     // 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', 'reviewmet', '{$now}', '0', '1', 'hide', 'opened','')";
     mysql_query($sql);
     if (mysql_error()) {
         trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR);
     }
     trigger('TRIGGER_INCIDENT_CREATED', array('incidentid' => $incidentid, 'sendemail' => 1));
     if ($CONFIG['auto_assign_incidents']) {
         $suggest_user = suggest_reassign_userid($incidentid);
         if ($suggest_user > 0) {
             reassign_incident($incidentid, $suggest_user);
         }
     }
     $_SESSION['formdata']['portaladdincident'] = NULL;
     $_SESSION['formerrors']['portaladdincident'] = NULL;
     html_redirect("index.php", TRUE, $strIncidentAdded);
 } else {
     $contact_id = intval($_SESSION['contactid']);
     $contact_name = contact_realname($_SESSION['contactid']);
     $contact_email = contact_email($_SESSION['contactid']);
     create_temp_incoming($update_id, $contact_name, $incidenttitle, $contact_email, $_SESSION['contactid']);
     $_SESSION['formdata']['portaladdincident'] = NULL;
     $_SESSION['formerrors']['portaladdincident'] = NULL;
     html_redirect("index.php", TRUE, $strRequestSent);
 }
 exit;