]> git.uio.no Git - usit-rt.git/blame - share/html/Ticket/Create.html
Upgrade to 4.0.13
[usit-rt.git] / share / html / Ticket / Create.html
CommitLineData
84fb5b46
MKG
1%# BEGIN BPS TAGGED BLOCK {{{
2%#
3%# COPYRIGHT:
4%#
403d7b0b 5%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
84fb5b46
MKG
6%# <sales@bestpractical.com>
7%#
8%# (Except where explicitly superseded by other copyright notices)
9%#
10%#
11%# LICENSE:
12%#
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
16%# from www.gnu.org.
17%#
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.
22%#
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/licenses/old-licenses/gpl-2.0.html.
28%#
29%#
30%# CONTRIBUTION SUBMISSION POLICY:
31%#
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.)
37%#
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.
46%#
47%# END BPS TAGGED BLOCK }}}
48<& /Elements/Header,
49 Title => $title,
50 onload => "function () { hide('Ticket-Create-details') }" &>
51<& /Elements/Tabs &>
52
53<& /Elements/ListActions, actions => \@results &>
54
55<form action="<% RT->Config->Get('WebPath') %>/Ticket/Create.html" method="post" enctype="multipart/form-data" name="TicketCreate">
56 <input type="hidden" class="hidden" name="id" value="new" />
57
58% $m->callback( CallbackName => 'FormStart', QueueObj => $QueueObj, ARGSRef => \%ARGS );
59
60% if ($gnupg_widget) {
61 <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
62% }
63
64<div id="Ticket-Create-basics">
65<a name="basics"></a>
66
67<div id="ticket-create-metadata">
68 <&| /Widgets/TitleBox, title => loc("Basics"), class=>'ticket-info-basics' &>
69 <input type="hidden" class="hidden" name="Queue" value="<% $QueueObj->Id %>" />
70 <table width="100%" border="0">
71 <& /Ticket/Elements/EditBasics,
72 InTable => 1,
73 fields => [
74 { name => 'Queue',
75 comp => '/Ticket/Elements/ShowQueue',
76 args => {
77 QueueObj => $QueueObj,
78 },
79 },
80 { name => 'Status',
81 comp => '/Elements/SelectStatus',
82 args => {
83 Name => "Status",
84 Default => $ARGS{Status} || $QueueObj->Lifecycle->DefaultOnCreate,
85 DefaultValue => 0,
86 SkipDeleted => 1,
87 QueueObj => $QueueObj,
88 },
89 },
90 { name => 'Owner',
91 comp => '/Elements/SelectOwner',
92 args => {
93 Name => "Owner",
94 Default => $ARGS{Owner} || RT->Nobody->Id,
95 DefaultValue => 0,
96 QueueObj => $QueueObj,
97 },
98 }
99 ]
100 &>
101
102% $m->callback( CallbackName => 'AfterOwner', ARGSRef => \%ARGS );
103
104 <& /Ticket/Elements/EditCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1 &>
105 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1 &>
106 </table>
107 </&>
b5747ff2 108% $m->callback( CallbackName => 'AfterBasics', QueueObj => $QueueObj, ARGSRef => \%ARGS );
84fb5b46
MKG
109</div>
110
111<div id="ticket-create-message">
112 <&| /Widgets/TitleBox, title => $title, class => 'messagedetails' &>
113<table border="0" cellpadding="0" cellspacing="0">
114<tr>
115<td class="label">
116<&|/l&>Requestors</&>:
117</td>
118<td class="value" colspan="5">
119<& /Elements/EmailInput, Name => 'Requestors', Size => undef, Default => $ARGS{Requestors} || $session{CurrentUser}->EmailAddress &>
120% $m->callback( CallbackName => 'AfterRequestors', QueueObj => $QueueObj, ARGSRef => \%ARGS );
121</td>
122</tr>
123<tr>
124<td class="label">
125<&|/l&>Cc</&>:
126</td>
127<td class="value" colspan="5"><& /Elements/EmailInput, Name => 'Cc', Size => undef, Default => $ARGS{Cc} &></td>
128</tr>
129
130<tr>
131 <td class="label">&nbsp;</td>
132 <td class="comment" colspan="5">
133 <i><font size="-2">
134 <&|/l&>(Sends a carbon-copy of this update to a comma-delimited list of email addresses. These people <strong>will</strong> receive future updates.)</&>
135 </font></i>
136 </td>
137</tr>
138
139<tr>
140<td class="label">
141<&|/l&>Admin Cc</&>:
142</td>
143<td class="value" colspan="5"><& /Elements/EmailInput, Name => 'AdminCc', Size => undef, Default => $ARGS{AdminCc} &></td>
144</tr>
145
146<tr>
147 <td class="label">&nbsp;</td>
148 <td class="comment" colspan="5">
149 <i><font size="-2">
150 <&|/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.)</&>
151 </font></i>
152 </td>
153</tr>
154
155<tr>
156<td class="label">
157<&|/l&>Subject</&>:
158</td>
159<td class="value" colspan="5">
160<input type="text" name="Subject" maxsize="200" value="<%$ARGS{Subject} || ''%>" />
161% $m->callback( %ARGS, CallbackName => 'AfterSubject' );
162</td>
163</tr>
164
165% if ( $gnupg_widget ) {
166<tr><td>&nbsp;</td><td colspan="5">
167<& /Elements/GnuPG/SignEncryptWidget, self => $gnupg_widget, QueueObj => $QueueObj &>
168</td></tr>
169% }
170
171<tr>
172<td colspan="6">
173<&|/l&>Describe the issue below</&>:<br />
174% if ( RT->Config->Get('ArticleOnTicketCreate')) {
175<& /Articles/Elements/BeforeMessageBox, %ARGS, QueueObj => $QueueObj &>
176% }
177% $m->callback( %ARGS, QueueObj => $QueueObj, CallbackName => 'BeforeMessageBox' );
178% if (exists $ARGS{Content}) {
179<& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => 0 &>
180% } else {
181<& /Elements/MessageBox, QuoteTransaction => $QuoteTransaction &>
182%}
183% $m->callback( %ARGS, QueueObj => $QueueObj, CallbackName => 'AfterMessageBox' );
184
185<br />
186</td>
187</tr>
188
189 <& /Ticket/Elements/AddAttachments, %ARGS, QueueObj => $QueueObj &>
190 </table>
191 </&>
192 <& /Elements/Submit, Label => loc("Create"), id => 'SubmitTicket' &>
193 </div>
194</div>
195
196<div id="Ticket-Create-details">
197<a name="details"></a>
198<table width="100%" border="0">
199<tr>
200<td width="50%" valign="top" class="boxcontainer">
201 <div class="ticket-info-basics">
202 <&| /Widgets/TitleBox, title => loc('The Basics'),
203 title_class=> 'inverse',
204 color => "#993333" &>
205<table border="0">
206<tr><td class="label"><&|/l&>Priority</&>:</td>
207<td><& /Elements/SelectPriority,
208 Name => "InitialPriority",
209 Default => $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->InitialPriority,
210&></td></tr>
211<tr><td class="label"><&|/l&>Final Priority</&>:</td>
212<td><& /Elements/SelectPriority,
213 Name => "FinalPriority",
214 Default => $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->FinalPriority,
215&></td></tr>
216<tr><td class="label"><&|/l&>Time Estimated</&>:</td>
217<td>
218<& /Elements/EditTimeValue, Name => 'TimeEstimated', Default => $ARGS{TimeEstimated} || '', InUnits => $ARGS{'TimeEstimated-TimeUnits'} &>
219
220</td></tr>
221<tr><td class="label"><&|/l&>Time Worked</&>:</td>
222<td>
223<& /Elements/EditTimeValue, Name => 'TimeWorked', Default => $ARGS{TimeWorked} || '', InUnits => $ARGS{'TimeWorked-TimeUnits'} &>
224</td></tr>
225<tr>
226<td class="label"><&|/l&>Time Left</&>:</td>
227<td>
228<& /Elements/EditTimeValue, Name => 'TimeLeft', Default => $ARGS{TimeLeft} || '', InUnits => $ARGS{'TimeLeft-TimeUnits'} &>
229</td></tr>
230</table>
231</&>
232<br />
233<div class="ticket-info-dates">
234<&|/Widgets/TitleBox, title => loc("Dates"),
235 title_class=> 'inverse',
236 color => "#663366" &>
237
238<table>
239<tr><td class="label"><&|/l&>Starts</&>:</td><td><& /Elements/SelectDate, Name => "Starts", Default => $ARGS{Starts} || '' &></td></tr>
240<tr><td class="label"><&|/l&>Due</&>:</td><td><& /Elements/SelectDate, Name => "Due", Default => $ARGS{Due} || '' &></td></tr>
241</table>
242</&>
243</div>
244</div>
245<br />
246</td>
247
248<td valign="top" class="boxcontainer">
249<div class="ticket-info-links">
250<&| /Widgets/TitleBox, title => loc('Links'), title_class=> 'inverse' &>
251
252<em><&|/l&>(Enter ticket ids or URLs, separated with spaces)</&></em>
253<table border="0">
254<tr><td class="label"><&|/l&>Depends on</&></td><td><input size="10" name="new-DependsOn" value="<% $ARGS{'new-DependsOn'} || '' %>" /></td></tr>
255<tr><td class="label"><&|/l&>Depended on by</&></td><td><input size="10" name="DependsOn-new" value="<% $ARGS{'DependsOn-new'} || '' %>" /></td></tr>
256<tr><td class="label"><&|/l&>Parents</&></td><td><input size="10" name="new-MemberOf" value="<% $ARGS{'new-MemberOf'} || '' %>" /></td></tr>
257<tr><td class="label"><&|/l&>Children</&></td><td><input size="10" name="MemberOf-new" value="<% $ARGS{'MemberOf-new'} || '' %>" /></td></tr>
258<tr><td class="label"><&|/l&>Refers to</&></td><td><input size="10" name="new-RefersTo" value="<% $ARGS{'new-RefersTo'} || '' %>" /></td></tr>
259<tr><td class="label"><&|/l&>Referred to by</&></td><td><input size="10" name="RefersTo-new" value="<% $ARGS{'RefersTo-new'} || '' %>" /></td></tr>
260
261
262</table>
263</&>
264</div>
265<br />
266
267</td>
268</tr>
269</table>
270<& /Elements/Submit, Label => loc("Create") &>
271</div>
272</form>
273
274<%INIT>
275$m->callback( CallbackName => "Init", ARGSRef => \%ARGS );
276my $Queue = $ARGS{Queue};
277$session{DefaultQueue} = $Queue;
278
279if ($CloneTicket) {
280 my $CloneTicketObj = RT::Ticket->new( $session{CurrentUser} );
281 $CloneTicketObj->Load($CloneTicket)
282 or Abort( loc("Ticket could not be loaded") );
283
284 my $clone = {
285 Requestors => join( ',', $CloneTicketObj->RequestorAddresses ),
286 Cc => join( ',', $CloneTicketObj->CcAddresses ),
287 AdminCc => join( ',', $CloneTicketObj->AdminCcAddresses ),
288 InitialPriority => $CloneTicketObj->Priority,
289 };
290
291 $clone->{$_} = $CloneTicketObj->$_()
292 for qw/Owner Subject FinalPriority TimeEstimated TimeWorked
293 Status TimeLeft/;
294
295 $clone->{$_} = $CloneTicketObj->$_->AsString
296 for grep { $CloneTicketObj->$_->Unix }
297 map { $_ . "Obj" } qw/Starts Started Due Resolved/;
298
299 my $members = $CloneTicketObj->Members;
300 my ( @members, @members_of, @refers, @refers_by, @depends, @depends_by );
301 my $refers = $CloneTicketObj->RefersTo;
b5747ff2
MKG
302 my $get_link_value = sub {
303 my ($link, $type) = @_;
304 my $uri_method = $type . 'URI';
305 my $local_method = 'Local' . $type;
306 my $uri = $link->$uri_method;
307 return if $uri->IsLocal and
308 $uri->Object and
309 $uri->Object->isa('RT::Ticket') and
310 $uri->Object->Type eq 'reminder';
311
312 return $link->$local_method || $uri->URI;
313 };
84fb5b46 314 while ( my $refer = $refers->Next ) {
b5747ff2
MKG
315 my $refer_value = $get_link_value->($refer, 'Target');
316 push @refers, $refer_value if defined $refer_value;
84fb5b46
MKG
317 }
318 $clone->{'new-RefersTo'} = join ' ', @refers;
319
320 my $refers_by = $CloneTicketObj->ReferredToBy;
321 while ( my $refer_by = $refers_by->Next ) {
b5747ff2
MKG
322 my $refer_by_value = $get_link_value->($refer_by, 'Base');
323 push @refers_by, $refer_by_value if defined $refer_by_value;
84fb5b46
MKG
324 }
325 $clone->{'RefersTo-new'} = join ' ', @refers_by;
84fb5b46
MKG
326
327 my $cfs = $CloneTicketObj->QueueObj->TicketCustomFields();
328 while ( my $cf = $cfs->Next ) {
329 my $cf_id = $cf->id;
330 my $cf_values = $CloneTicketObj->CustomFieldValues( $cf->id );
331 my @cf_values;
332 while ( my $cf_value = $cf_values->Next ) {
333 push @cf_values, $cf_value->Content;
334 }
335 $clone->{"Object-RT::Ticket--CustomField-$cf_id-Value"} = join "\n",
336 @cf_values;
337 }
338
339 for ( keys %$clone ) {
340 $ARGS{$_} = $clone->{$_} if not defined $ARGS{$_};
341 }
342
343}
344
345my @results;
346
347my $title = loc("Create a new ticket");
348
349my $QueueObj = RT::Queue->new($session{'CurrentUser'});
350$QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
351
352$m->callback( QueueObj => $QueueObj, title => \$title, results => \@results, ARGSRef => \%ARGS );
353
354$QueueObj->Disabled && Abort(loc("Cannot create tickets in a disabled queue."));
355
356my $CFs = $QueueObj->TicketCustomFields();
357
358my $ValidCFs = $m->comp(
359 '/Elements/ValidateCustomFields',
360 CustomFields => $CFs,
361 ARGSRef => \%ARGS
362);
363
5b0d0914 364ProcessAttachments(ARGSRef => \%ARGS);
84fb5b46
MKG
365
366my $checks_failure = 0;
367
368my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
369$m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
370 self => $gnupg_widget,
371 QueueObj => $QueueObj,
372);
373
374
375if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' ) {
376 my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
377 self => $gnupg_widget,
378 Operation => 'Create',
379 QueueObj => $QueueObj,
380 );
381 $checks_failure = 1 unless $status;
382}
383
384# check email addresses for RT's
385{
386 foreach my $field ( qw(Requestors Cc AdminCc) ) {
387 my $value = $ARGS{ $field };
388 next unless defined $value && length $value;
389
390 my @emails = Email::Address->parse( $value );
391 foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
392 push @results, loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email->format, loc($field =~ /^(.*?)s?$/) );
393 $checks_failure = 1;
394 $email = undef;
395 }
396 $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
397 }
398}
399
400my $skip_create = 0;
401$m->callback( CallbackName => 'BeforeCreate', ARGSRef => \%ARGS, skip_create => \$skip_create,
402 checks_failure => $checks_failure, results => \@results );
403
404$m->comp( '/Articles/Elements/CheckSkipCreate', ARGSRef => \%ARGS, skip_create => \$skip_create,
405 checks_failure => $checks_failure, results => \@results );
406
407if ((!exists $ARGS{'AddMoreAttach'}) and (defined($ARGS{'id'}) and $ARGS{'id'} eq 'new')) { # new ticket?
408 if ( $ValidCFs && !$checks_failure && !$skip_create ) {
409 $m->comp('Display.html', %ARGS);
410 $RT::Logger->crit("After display call; error is $@");
411 $m->abort();
412 }
413 elsif ( !$ValidCFs ) {
414 # Invalid CFs
415 while (my $CF = $CFs->Next) {
416 my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
417 push @results, $CF->Name . ': ' . $msg;
418 }
419 }
420}
421PageMenu->child( basics => raw_html => q[<a href="#basics" onclick="return switchVisibility('Ticket-Create-basics','Ticket-Create-details');">] . loc('Basics') . q[</a>]);
422PageMenu->child( details => raw_html => q[<a href="#details" onclick="return switchVisibility('Ticket-Create-details','Ticket-Create-basics');">] . loc('Details') . q[</a>]);
423</%INIT>
424
425<%ARGS>
426$DependsOn => undef
427$DependedOnBy => undef
428$MemberOf => undef
429$QuoteTransaction => undef
430$CloneTicket => undef
431</%ARGS>