$incidentClient = new SoapClient($soapurl, array('trace' => 1, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_MEMORY, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'login' => $netID, 'password' => $passy));
    $updateResponse = $incidentClient->update(array('sys_id' => $sysId, 'short_description' => $_POST['subject'], 'u_work_log' => "(Internal Comment)" . html2text($ticketEntry)));
    if (isset($updateResponse->sys_id)) {
        echo "<h2> Ticket's work-log has been updated successfully. </h2>";
    } else {
        echo "<h2> Updating the work-log for the ticket failed. Please attempt to do so manually. </h2>";
    }
} catch (Exception $E) {
    if ($env == 2) {
        $errorInfo = '';
    } else {
        $errorInfo = "ERROR " . print_r($E, true);
    }
    echo "<h2> Unable to connect to service-now to insert your update to the work-log. Please attempt to do so manually. <br><br>{$errorInfo}</h2>";
}
$emailBody = formEmail($_POST);
$subject = getEmailType($type) . $_POST['subject'];
if ($env == 2) {
    $recipient = '';
    try {
        $notificationMemberQuery = $db->prepare("SELECT * FROM `notificationMember` WHERE `memberId` IN (SELECT `memberId` FROM `notificationGroupMember` WHERE `groupName` = 'Executive Notification')");
        $notificationMemberQuery->execute();
    } catch (PDOException $e) {
        exit("error in query");
    }
    while ($execNoteRecipient = $notificationMemberQuery->fetch(PDO::FETCH_ASSOC)) {
        if ($recipient === '') {
            $recipient = $execNoteRecipient['email'];
        } else {
            $recipient .= ', ' . $execNoteRecipient['email'];
        }
            if ($type == "Resolve") {
                return "RESOLVED -- ";
            } else {
                if ($type == "New/Resolve") {
                    return "NEW/RESOLVED -- ";
                } else {
                    if ($type == "Re-open") {
                        return "RE-OPENED -- ";
                    }
                }
            }
        }
    }
}
?>

<h2>Preview of Executive Notification Email</h2>
<a href='execNoteForm.php'>Return</a><br/>
<form method='post' action='sendEmail.php'>
<textarea id='email' name='email' cols=100 rows=10>
<?php 
formEmail($_POST);
?>
</textarea>
<br/>
<input type='submit' id='submit' name='submit' value="Send Email" />
</form>


<?php 
require '../includes/includeAtEnd.php';