QuickCreate

From Request Tracker Wiki
Jump to navigation Jump to search

Many weeks ago i found somewhere at the maillinglist something about enhance RT QuickCreate to make it more usable for a helpdesk/call center.

This small patch add's to the QuickCreate a Message Text (was already prepared by BPS) and puts the text as body for a new ticket.

We need to patch two files.

1. /html/Elements/QuickCreate

--- /opt/rt3/share/html/Elements/QuickCreate    2007-06-11 10:10:42.000000000 +0200
+++ /opt/rt3/local/html/Elements/QuickCreate    2007-06-11 11:25:12.000000000 +0200
@@ -49,22 +49,39 @@
 <&| /Widgets/TitleBox, title => loc('Quick ticket creation') &>
 <form method="post" action="<%$RT::WebPath%>/index.html">
 <input type="hidden" class="hidden" name="QuickCreate" value="1" />
-<table>
-<tr><td>
-<&|/l&>Subject</&>:<br /><input size="15" name="Subject" />
-</td><td>
-<&|/l&>Queue</&>:<br /><& /Elements/SelectNewTicketQueue, Name => 'Queue', ShowNullOption => 0 &>
-</td><td>
-<&|/l&>Owner</&>:<br />
+
+<table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0">
+<tbody>
+<tr>
+<td style="text-align: right; width: 70px;"><font size="-2"><&|/l&>Requestor</&>:<br /></font></td>
+<td><input class="input_quick" name="Requestor"></td>
+</tr>
+<tr>
+<td style="text-align: right; width: 70px;"><font size="-2"><&|/l&>Queue</&>:</font></td>
+<td><& /Elements/SelectNewTicketQueue, Name => 'Queue', ShowNullOption => 0 &></td>
+</tr>
+<tr>
+<td style="text-align: right; width: 70px;"><font size="-2"><&|/l&>Owner</&>:</font></td>
+<td>
 <select type="select" name="Owner">
-<option value="<%$session{'CurrentUser'}->id%>" selected><%$session{'CurrentUser'}->Name %></option>
-<option value="<%$RT::Nobody->id%>"><%loc('Nobody')%></option>
+<option value="<%$session{'CurrentUser'}->id%>"><%$session{'CurrentUser'}->Name %></option>
+<option value="<%$RT::Nobody->id%>" selected><%loc('Nobody')%></option>
 </select>
 </td>
 </tr>
-%#<tr><td colspan="3"><textarea cols="50" rows="3"></textarea></td></tr>
+<tr>
+<td style="text-align: right; width: 70px;"><font size="-2"><&|/l&>Subject</&>:</font></td>
+<td><input class="input_quick" name="Subject" /></td>
+</tr>
+<tr>
+<td style="text-align: right; width: 70px;"><font size="-2"><&|/l&>Message</&>:</font></td>
+<td><textarea cols="80" rows="4" name="Tickettext"></textarea></td>
+</tr>
+<tr>
+<td style="padding: 0;" align="right" colspan="2"><input type="submit" class="button" value="<%loc('Create')%>" /></td>
+</tr>
+</tbody>
</table>
-<div align="right"><input type="submit" class="button" value="<%loc('Create')%>" /></div>
 </form>
 </&>
 </div>

And a second file under /html/index.html

--- /opt/rt3/share/html/index.html      2007-06-11 10:10:42.000000000 +0200
+++ /opt/rt3/local/html/index.html      2007-06-11 10:58:46.000000000 +0200
@@ -84,13 +84,21 @@
 my @results;

 if ($ARGS{'QuickCreate'} ) {
+    my $txt = $ARGS{'Tickettext'};
+    $RT::Logger->debug("the TText is :".$txt);
+    my $Mime = MIME::Entity->build(
+                        Type => 'text/plain',
+                        Data => $txt
+                        );
+    my $MimeMessage = $Mime->stringify();
+    my $parser = RT::EmailParser->new();
+    $parser->ParseMIMEEntityFromScalar($MimeMessage);
     my $ticket = RT::Ticket->new($session{'CurrentUser'});
     my ($tid, $trans, $tmsg) = $ticket->Create(Queue => $ARGS{'Queue'},
                     Owner => $ARGS{'Owner'},
-                    Requestor => $session{'CurrentUser'}->UserObj->EmailAddress,
-                    Subject => $ARGS{'Subject'});
-
-
+                    Requestor => $ARGS{'Requestor'} || $session{'CurrentUser'}->UserObj->EmailAddress,
+                    Subject => $ARGS{'Subject'},
+                    MIMEObj => $parser->Entity);
     push (@results, $tmsg);
 }

Now you can easy create a ticket from the frontpage with main information.