diff --git a/portal/index.php b/portal/index.php index b795175d9..55ef4d2b5 100644 --- a/portal/index.php +++ b/portal/index.php @@ -655,10 +655,20 @@ function DisplayRequestDetails($oP, UserRequest $oRequest) } $oP->Details($aDetails); - // Case log - $oP->add('
'.MetaModel::GetLabel('UserRequest', 'ticket_log').''); - $oP->add(GetFieldAsHtml($oRequest, 'ticket_log')); + // Case log... editable so that users can post comments + $oP->add("
\n"); + $oP->add("GetKey()."\">"); + $oP->add(""); + $oP->add("\n"); + $oP->add(""); + $oP->add('
'.MetaModel::GetLabel('UserRequest', 'ticket_log').''); + $oAttDef = MetaModel::GetAttributeDef(get_class($oRequest), 'ticket_log'); + $oValue = $oRequest->Get('ticket_log'); + $oP->add($oRequest->GetFormElementForField($oP, get_class($oRequest), 'ticket_log', $oAttDef, $oValue, $sDisplayValue = '', $iId = 'att_ticket_log')); + //$oP->add(GetFieldAsHtml($oRequest, 'ticket_log')); $oP->add('
'); + $oP->p(''); + $oP->add('
'); $oP->add(''); } @@ -845,9 +855,58 @@ function RequestDetails(WebPage $oP, $id) case 2: DoCloseRequest($oP, $oRequest); break; + + case 3: + AddComment($oP, $oRequest); + break; + + default: + // Should never happen + DisplayMainMenu($oP); } } +/** + * Adds a comment to the specified UserRequest and displays the main menu + * @param WebPage $oP The current web page for the output + * @param $id ID of the object to update + * @return void + */ +function AddComment($oP, $id) +{ + $oRequest = FindRequest($id); + if (!is_object($oRequest)) + { + DisplayMainMenu($oP); + return; + } + $sTransactionId = utils::ReadPostedParam('transaction_id', ''); + if (!utils::IsTransactionValid($sTransactionId)) + { + $oP->add("

".Dict::S('UI:Error:ObjectAlreadyUpdated')."

\n"); + DisplayMainMenu($oP); + return; + } + $sComment = trim(utils::ReadPostedParam('attr_ticket_log')); + if (!empty($sComment)) + { + $oRequest->Set('ticket_log', $sComment); + + $oMyChange = MetaModel::NewObject("CMDBChange"); + $oMyChange->Set("date", time()); + $sUserString = CMDBChange::GetCurrentUserName(); + $oMyChange->Set("userinfo", $sUserString); + $iChangeId = $oMyChange->DBInsert(); + $oRequest->DBUpdateTracked($oMyChange); + $oP->p("

".Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oRequest)), $oRequest->GetName())."

\n"); + } + else + { + $oP->p("

".Dict::Format('UI:Class_Object_NotUpdated', MetaModel::GetName(get_class($oRequest)), $oRequest->GetName())."

\n"); + } + DisplayMainMenu($oP); +} + /** * Get The organization of the current user (i.e. the organization of its contact) * @param WebPage $oP The current page, for errors output diff --git a/portal/portal.css b/portal/portal.css index ff38a6c58..2b4b9b62a 100644 --- a/portal/portal.css +++ b/portal/portal.css @@ -114,6 +114,9 @@ a.button span { width:800px; text-align: left; } +#request_details_log { + width:774px; +} #request_details table { border: #f1f1f6 2px solid; text-align: left;