1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
6 %# <jesse@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/copyleft/gpl.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
49 Title => loc("Create a new ticket"),
50 onload => "hide(document.getElementById('Ticket-Create-details'));" &>
52 current_toptab => "Ticket/Create.html",
53 Title => loc("Create a new ticket"),
54 actions => $actions &>
55 <& /Elements/ListActions, actions => \@results &>
56 <form action="<%$RT::WebPath%>/Ticket/Create.html" method="post" enctype="multipart/form-data" name="TicketCreate">
57 <input type="hidden" class="hidden" name="id" value="new" />
58 <& /Elements/Callback, _CallbackName => 'FormStart',ARGSRef =>\%ARGS &>
60 <div id="Ticket-Create-basics">
62 <&| /Widgets/TitleBox, title => loc("Create a new ticket") &>
63 <table border="0" cellpadding="0" cellspacing="0">
64 <tr><td class="label"><&|/l&>Queue</&>:</td>
65 <td class="value"><& Elements/ShowQueue, QueueObj => $QueueObj &>
66 <input type="hidden" class="hidden" name="Queue" value="<% $QueueObj->Name %>" />
68 <td class="label"><&|/l&>Status</&>:
71 <& /Elements/SelectStatus, Name => "Status", Default => $ARGS{Status}||'new', DefaultValue => 0 &>
77 <& /Elements/SelectOwner, Name => "Owner", QueueObj => $QueueObj, Default => $ARGS{Owner}||$RT::Nobody->Id, DefaultValue => 0 &>
82 <&|/l&>Requestors</&>:
84 <td class="value" colspan="5">
85 <input name="Requestors" value="<% ($ARGS{Requestors}) || $session{CurrentUser}->EmailAddress %>" size="40" />
92 <td class="value" colspan="5">
93 <input name="Cc" size="40" value="<% $ARGS{Cc} %>" /><br />
95 <&|/l&>(Sends a carbon-copy of this update to a comma-delimited list of email addresses. These people <strong>will</strong> receive future updates.)</&></font></i>
102 <td class="value" colspan="5">
103 <input name="AdminCc" size="40" value="<% $ARGS{AdminCc} %>" /><br />
105 <&|/l&>(Sends a carbon-copy of this update to a comma-delimited list of administrative email addresses. These people <strong>will</strong> receive future updates.)</&></font></i>
112 <td class="value" colspan="5">
113 <input name="Subject" size="60" maxsize="200" value="<%$ARGS{Subject} || ''%>" />
118 <& /Ticket/Elements/EditCustomFields, QueueObj => $QueueObj &>
121 % if ($TxnCFs->Count) {
122 % while (my $CF = $TxnCFs->Next()) {
124 <td align="right"><% $CF->Name %>:</td>
125 <td><& /Elements/EditCustomField, CustomField => $CF, NamePrefix =>
126 "Object-RT::Transaction--CustomField-" &><em><% $CF->FriendlyType %></em></td>
131 % if (exists $session{'Attachments'}) {
133 <&|/l&>Attached file</&>:
136 <&|/l&>Check box to delete</&><br />
137 % foreach my $attach_name (keys %{$session{'Attachments'}}) {
138 <input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
145 <&|/l&>Attach file</&>:
147 <td class="value" colspan="5">
148 <input type="file" name="Attach" />
149 <input type="submit" class="button" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" />
154 <&|/l&>Describe the issue below</&>:<br />
155 % if (exists $ARGS{Content}) {
156 <& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => 0 &>
158 <& /Elements/MessageBox, QuoteTransaction => $QuoteTransaction &>
165 <td align="right" colspan="2">
170 <& /Elements/Submit, Label => loc("Create")&>
173 <div id="Ticket-Create-details">
174 <a name="details"></a>
175 <table width="100%" border="0">
177 <td width="50%" valign="top">
179 <&| /Widgets/TitleBox, title => loc('The Basics'),
180 title_class=> 'inverse',
181 color => "#993333" &>
183 <tr><td align="right"><&|/l&>Priority</&>:</td><td><input size="3" name="InitialPriority" value="<% $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->InitialPriority %>" /></td></tr>
184 <tr><td align="right"><&|/l&>Final Priority</&>:</td><td><input size="3" name="FinalPriority" value="<% $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->FinalPriority %>" /></td></tr>
185 <tr><td align="right"><&|/l&>Time Estimated</&>:</td>
187 <input size="3" name="TimeEstimated" value="<%$ARGS{TimeEstimated}%>" />
188 <& /Elements/SelectTimeUnits, Name =>'TimeEstimated' &>
191 <tr><td align="right"><&|/l&>Time Worked</&>:</td>
193 <input size="3" name="TimeWorked" value="<%$ARGS{TimeWorked}%>" />
194 <& /Elements/SelectTimeUnits, Name =>'TimeWorked' &>
198 <td align="right"><&|/l&>Time Left</&>:</td>
199 <td><input size="3" name="TimeLeft" value="<%$ARGS{TimeLeft}%>" />
200 <& /Elements/SelectTimeUnits, Name =>'TimeLeft' &>
205 <&|/Widgets/TitleBox, title => loc("Dates"),
206 title_class=> 'inverse',
207 color => "#663366" &>
210 <tr><td class="label"><&|/l&>Starts</&>:</td><td><& /Elements/SelectDate, Name => "Starts", Default => $ARGS{Starts} || '' &></td></tr>
211 <tr><td class="label"><&|/l&>Due</&>:</td><td><& /Elements/SelectDate, Name => "Due", Default => $ARGS{Due} || '' &></td></tr>
218 <&| /Widgets/TitleBox, title => loc('Links'), title_class=> 'inverse' &>
220 <em><&|/l&>(Enter ticket ids or URLs, separated with spaces)</&></em>
222 <tr><td align="right"><&|/l&>Depends on</&></td><td><input size="10" name="new-DependsOn" value="<% $ARGS{'new-DependsOn'} %>" /></td></tr>
223 <tr><td align="right"><&|/l&>Depended on by</&></td><td><input size="10" name="DependsOn-new" value="<% $ARGS{'DependsOn-new'} %>" /></td></tr>
224 <tr><td align="right"><&|/l&>Parents</&></td><td><input size="10" name="new-MemberOf" value="<% $ARGS{'new-MemberOf'} %>" /></td></tr>
225 <tr><td align="right"><&|/l&>Children</&></td><td><input size="10" name="MemberOf-new" value="<% $ARGS{'MemberOf-new'} %>" /></td></tr>
226 <tr><td align="right"><&|/l&>Refers to</&></td><td><input size="10" name="new-RefersTo" value="<% $ARGS{'new-RefersTo'} %>" /></td></tr>
227 <tr><td align="right"><&|/l&>Referred to by</&></td><td><input size="10" name="RefersTo-new" value="<% $ARGS{'RefersTo-new'} %>" /></td></tr>
237 <& /Elements/Submit, Label => loc("Create") &>
244 if ( $CloneTicket ) {
245 $CloneTicketObj = RT::Ticket->new( $session{CurrentUser} );
246 $CloneTicketObj->Load($CloneTicket) or Abort(loc("Ticket could not be loaded"));
249 Requestors => join( ',', $CloneTicketObj->RequestorAddresses ),
250 Cc => join( ',', $CloneTicketObj->CcAddresses),
251 AdminCc => join( ',', $CloneTicketObj->AdminCcAddresses),
252 InitialPriority => $CloneTicketObj->Priority,
255 $clone->{$_} = $CloneTicketObj->$_()
256 for qw/Owner Subject FinalPriority TimeEstimated TimeWorked
257 Status TimeLeft Starts Started Due Resolved/;
259 my $members = $CloneTicketObj->Members;
260 my ( @members, @members_of, @refers, @refers_by, @depends, @depends_by );
261 while ( my $member = $members->Next ) {
262 push @members, $member->LocalBase;
264 $clone->{'MemberOf-new'} = join ' ', @members;
266 my $members_of = $CloneTicketObj->MemberOf;
267 while ( my $member_of = $members_of->Next ) {
268 push @members_of, $member_of->LocalTarget;
270 $clone->{'new-MemberOf'} = join ' ', @members_of;
272 my $refers = $CloneTicketObj->RefersTo;
273 while ( my $refer = $refers->Next ) {
274 push @refers, $refer->LocalTarget;
276 $clone->{'new-RefersTo'} = join ' ', @refers;
278 my $refers_by = $CloneTicketObj->ReferredToBy;
279 while ( my $refer_by = $refers_by->Next ) {
280 push @refers_by, $refer_by->LocalBase;
282 $clone->{'RefersTo-new'} = join ' ', @refers_by;
284 my $depends = $CloneTicketObj->DependsOn;
285 while ( my $depend = $depends->Next ) {
286 push @depends, $depend->LocalTarget;
288 $clone->{'new-DependsOn'} = join ' ', @depends;
290 my $depends_by = $CloneTicketObj->DependedOnBy;
291 while ( my $depend_by = $depends_by->Next ) {
292 push @depends_by, $depend_by->LocalBase;
294 $clone->{'DependsOn-new'} = join ' ', @depends_by;
298 my $cfs = $CloneTicketObj->QueueObj->TicketCustomFields();
299 while ( my $cf = $cfs->Next ) {
301 my $cf_values = $CloneTicketObj->CustomFieldValues( $cf->id );
303 while ( my $cf_value = $cf_values->Next ) {
304 push @cf_values, $cf_value->Content;
306 $clone->{"Object-RT::Ticket--CustomField-$cf_id-Value"}
307 = join "\n", @cf_values;
310 for ( keys %$clone ) {
311 $ARGS{$_} = $clone->{$_} if not defined $ARGS{$_};
317 my $QueueObj = new RT::Queue($session{'CurrentUser'});
318 $QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
319 my $CFs = $QueueObj->TicketCustomFields();
320 my $TxnCFs = $QueueObj->TicketTransactionCustomFields();
322 my $ValidCFs = $m->comp(
323 '/Elements/ValidateCustomFields',
324 CustomFields => $CFs,
328 # if no due date has been set explicitly, then use the
329 # queue's default if it exists
330 if ($QueueObj->DefaultDueIn && !$ARGS{'Due'}) {
331 my $default_due = RT::Date->new($session{'CurrentUser'});
332 $default_due->SetToNow();
333 $default_due->AddDays($QueueObj->DefaultDueIn);
334 $ARGS{'Due'} = $default_due->ISO();
337 # {{{ deal with deleting uploaded attachments
338 foreach my $key (keys %ARGS) {
339 if ($key =~ m/^DeleteAttach-(.+)$/) {
340 delete $session{'Attachments'}{$1};
342 $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
345 # {{{ store the uploaded attachment in session
346 if ($ARGS{'Attach'}) { # attachment?
347 $session{'Attachments'} = {} unless defined $session{'Attachments'};
349 my $subject = "$ARGS{'Attach'}";
351 # strip leading directories
352 $subject =~ s#^.*[\\/]##;
354 my $attachment = MakeMIMEEntity(
357 AttachmentFieldName => 'Attach'
360 $session{'Attachments'} = { %{$session{'Attachments'} || {}},
361 $ARGS{'Attach'} => $attachment };
365 # delete temporary storage entry to make WebUI clean
366 unless (keys %{$session{'Attachments'}} and $ARGS{'id'} eq 'new') {
367 delete $session{'Attachments'};
373 if ((!exists $ARGS{'AddMoreAttach'}) and ($ARGS{'id'} eq 'new')) { # new ticket?
375 $m->comp('Display.html', %ARGS);
376 $RT::Logger->crit("After display call; error is $@");
381 while (my $CF = $CFs->Next) {
382 my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
383 push @results, $CF->Name . ': ' . $msg;
390 html => q[<a href="#basics" onclick="return switchVisibility('Ticket-Create-basics','Ticket-Create-details');">] . loc('Show basics') . q[</a>],
393 html => q[<a href="#details" onclick="return switchVisibility('Ticket-Create-details','Ticket-Create-basics');">] . loc('Show details') . q[</a>],
400 $DependedOnBy => undef
402 $QuoteTransaction => undef
404 $CloneTicket => undef