Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
notification if responsible changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDunko committed Oct 15, 2019
1 parent 14d53c1 commit b21a696
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions private/subs_request/details_post_updatereq.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,36 @@
$request['responsible'] = $_POST['responsible'] ?? '';
$request['status'] = $_POST['status'] ?? '';
$request['note'] = $_POST['note'] ?? '';
if(FEATURE_NOTIFICATIONS && $request['status'] == 4) {
// get old status
$requestOld = find_request_by_kp($key);
$statusOld = $requestOld['status'];
}


// get old version
$requestOld = find_request_by_kp($key);
$statusOld = $requestOld['status'];
$responsibleOld = $requestOld['responsible'];
// update request
$result = update_request($request);

if( $result === true ) {
$_SESSION['message'] = 'Das Ticket wurde geändert.';

if(FEATURE_NOTIFICATIONS && $request['status'] <> 4 && $responsibleOld != $request['responsible']) {
// send mail to responsible if changed
$to = find_useremail_by_kp($request['responsible']);
$sender = find_useremail_by_kp($request['source']);
if(FEATURE_MESSAGESERVICE) {
$mail = new Mail();
$mail->recipient = $to;
$mail->replyto = $sender;
$mail->subject = "Neues Ticket [" . SUBDOMAIN . " " . $key . "]";
$mail->body = $request['description'] . "\nhttps://" . SUBDOMAIN . ".requestx.ch/details?key=" . $new_key . "&action=show";
$mail->send();
} else {
$subject = "Neues Ticket [" . SUBDOMAIN . " " . $key . "]";
$message = $request['description'] . "\nhttps://" . SUBDOMAIN . ".requestx.ch/details?key=" . $new_key . "&action=show";
$headers = 'From: Request X <benachrichtigung@requestx.ch>' . "\r\n";
mail($to, $subject, $message, $headers);
}
}

if(FEATURE_NOTIFICATIONS && $request['status'] == 4 && $statusOld != 4) {
// send mail to requester if status changes to erledigt
$to = find_useremail_by_kp($request['source']);
Expand Down

0 comments on commit b21a696

Please sign in to comment.