This commit was generated by cvs2svn to compensate for changes in r8690,
[freeside.git] / rt / share / html / Ticket / Create.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %# 
5 %# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
6 %#                                          <jesse@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(document.getElementById('Ticket-Create-details')) }" &>
51 <& /Elements/Tabs, 
52     current_toptab => "Ticket/Create.html", 
53     Title => $title,
54     actions => $actions &>
55 <& /Elements/ListActions, actions => \@results &>
56 <form action="<% RT->Config->Get('WebPath') %>/Ticket/Create.html" method="post" enctype="multipart/form-data" name="TicketCreate">
57 <input type="hidden" class="hidden" name="id" value="new" />
58 % $m->callback( CallbackName => 'FormStart', QueueObj => $QueueObj, ARGSRef => \%ARGS );
59 % if ($gnupg_widget) {
60 <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
61 % }
62 <div id="Ticket-Create-basics">
63 <a name="basics"></a>
64 <&| /Widgets/TitleBox, title => $title &>
65 <table border="0" cellpadding="0" cellspacing="0">
66 <tr><td class="label"><&|/l&>Queue</&>:</td>
67 <td class="value"><& Elements/ShowQueue, QueueObj => $QueueObj &>
68 <input type="hidden" class="hidden" name="Queue" value="<% $QueueObj->Name %>" />
69 </td>
70 <td class="label"><&|/l&>Status</&>:
71 </td>
72 <td class="value">
73 <& /Elements/SelectStatus, Name => "Status", Default => $ARGS{Status}||'new', DefaultValue => 0, SkipDeleted => 1 &>
74 </td>
75 <td class="label">
76 <&|/l&>Owner</&>:
77 </td>
78 <td class="value">
79 <& /Elements/SelectOwner, Name => "Owner", QueueObj => $QueueObj, Default => $ARGS{Owner}||$RT::Nobody->Id, DefaultValue => 0 &>
80 </td>
81 % $m->callback( CallbackName => 'AfterOwner', ARGSRef => \%ARGS );
82 </tr>
83 <tr>
84 <td class="label">
85 <&|/l&>Requestors</&>:
86 </td>
87 <td class="value" colspan="5">
88 <& /Elements/EmailInput, Name => 'Requestors', Size => '40', Default => $ARGS{Requestors} || $session{CurrentUser}->EmailAddress &>
89 </td>
90 </tr>
91 <tr>
92 <td class="label">
93 <&|/l&>Cc</&>:
94 </td>
95 <td class="value" colspan="3"><& /Elements/EmailInput, Name => 'Cc', Size => '40', Default => $ARGS{Cc} &></td>
96 <td class="comment" colspan="2"><i><font size="-2">
97 <&|/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>
98 </td>
99 </tr>
100 <tr>
101 <td class="label">
102 <&|/l&>Admin Cc</&>:
103 </td>
104 <td class="value" colspan="3"><& /Elements/EmailInput, Name => 'AdminCc', Size => '40', Default => $ARGS{AdminCc} &></td>
105 <td class="comment" colspan="2"><i><font size="-2">
106 <&|/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>
107 </td>
108 </tr>
109 <tr>
110 <td class="label">
111 <&|/l&>Subject</&>:
112 </td>
113 <td class="value" colspan="5">
114 <input name="Subject" size="60" maxsize="200" value="<%$ARGS{Subject} || ''%>" />
115 </td>
116 </tr>
117 <tr>
118 <td colspan="6">
119 <& /Ticket/Elements/EditCustomFields, %ARGS, QueueObj => $QueueObj &>
120 </td>
121 </tr>
122 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj &>
123 <tr>
124 % if (exists $session{'Attachments'}) {
125 <td class="label">
126 <&|/l&>Attached file</&>:
127 </td>
128 <td colspan="5">
129 <&|/l&>Check box to delete</&><br />
130 % foreach my $attach_name (keys %{$session{'Attachments'}}) {
131 <input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
132 % } # end of foreach
133 </td>
134 </tr>
135 <tr>
136 % } # end of if
137 <td class="label">
138 <&|/l&>Attach file</&>:
139 </td>
140 <td class="value" colspan="5">
141 <input type="file" name="Attach" />
142 <input type="submit" class="button" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" />
143 </td>
144 </tr>
145
146 % if ( $gnupg_widget ) {
147 <tr><td>&nbsp;</td><td colspan="5">
148 <& /Elements/GnuPG/SignEncryptWidget, self => $gnupg_widget, QueueObj => $QueueObj &>
149 </td></tr>
150 % }
151
152 <tr>
153 <td colspan="6">
154 <&|/l&>Describe the issue below</&>:<br />
155 % $m->callback( %ARGS, QueueObj => $QueueObj, CallbackName => 'BeforeMessageBox' );
156 % if (exists $ARGS{Content}) {
157 <& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => 0 &>
158 % } else {
159 <& /Elements/MessageBox, QuoteTransaction => $QuoteTransaction &>
160 %}
161
162 <br />
163 </td>
164 </tr>
165 </table>
166 </&>
167 <& /Elements/Submit, Label => loc("Create")&>
168 </div>
169
170 <div id="Ticket-Create-details">
171 <a name="details"></a>
172 <table width="100%" border="0">
173 <tr>
174 <td width="50%" valign="top" class="boxcontainer">
175     <div class="ticket-info-basics">
176           <&| /Widgets/TitleBox, title => loc('The Basics'), 
177                 title_class=> 'inverse',  
178                 color => "#993333" &>
179 <table border="0">
180 <tr><td class="label"><&|/l&>Priority</&>:</td>
181 <td><& /Elements/SelectPriority,
182     Name => "InitialPriority",
183     Default => $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->InitialPriority,
184 &></td></tr>
185 <tr><td class="label"><&|/l&>Final Priority</&>:</td>
186 <td><& /Elements/SelectPriority,
187     Name => "FinalPriority",
188     Default => $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->FinalPriority,
189 &></td></tr>
190 <tr><td class="label"><&|/l&>Time Estimated</&>:</td>
191 <td>
192 <& /Elements/EditTimeValue, Name => 'TimeEstimated', Default => $ARGS{TimeEstimated} || '', InUnits => $ARGS{'TimeEstimated-TimeUnits'} &>
193
194 </td></tr>
195 <tr><td class="label"><&|/l&>Time Worked</&>:</td>
196 <td>
197 <& /Elements/EditTimeValue, Name => 'TimeWorked', Default => $ARGS{TimeWorked} || '', InUnits => $ARGS{'TimeWorked-TimeUnits'} &>
198 </td></tr>
199 <tr>
200 <td class="label"><&|/l&>Time Left</&>:</td>
201 <td>
202 <& /Elements/EditTimeValue, Name => 'TimeLeft', Default => $ARGS{TimeLeft} || '', InUnits => $ARGS{'TimeLeft-TimeUnits'} &>
203 </td></tr>
204 </table>
205 </&>
206 <br />
207 <div class="ticket-info-dates">
208 <&|/Widgets/TitleBox, title => loc("Dates"),
209                 title_class=> 'inverse',  
210                  color => "#663366" &>
211
212 <table>
213 <tr><td class="label"><&|/l&>Starts</&>:</td><td><& /Elements/SelectDate, Name => "Starts", Default => $ARGS{Starts} || '' &></td></tr>
214 <tr><td class="label"><&|/l&>Due</&>:</td><td><& /Elements/SelectDate, Name => "Due", Default => $ARGS{Due} || '' &></td></tr>
215 </table>
216 </&>
217 </div>
218 </div>
219 <br />
220 </td>
221
222 <td valign="top" class="boxcontainer">
223 <div class="ticket-info-links">
224 <&| /Widgets/TitleBox, title => loc('Links'), title_class=> 'inverse' &>
225
226 <em><&|/l&>(Enter ticket ids or URLs, separated with spaces)</&></em>
227 <table border="0">
228 <tr><td class="label"><&|/l&>Depends on</&></td><td><input size="10" name="new-DependsOn" value="<% $ARGS{'new-DependsOn'} || '' %>" /></td></tr>
229 <tr><td class="label"><&|/l&>Depended on by</&></td><td><input size="10" name="DependsOn-new" value="<% $ARGS{'DependsOn-new'} || '' %>" /></td></tr>
230 <tr><td class="label"><&|/l&>Parents</&></td><td><input size="10" name="new-MemberOf" value="<% $ARGS{'new-MemberOf'} || '' %>" /></td></tr>
231 <tr><td class="label"><&|/l&>Children</&></td><td><input size="10" name="MemberOf-new" value="<% $ARGS{'MemberOf-new'} || '' %>" /></td></tr>
232 <tr><td class="label"><&|/l&>Refers to</&></td><td><input size="10" name="new-RefersTo" value="<% $ARGS{'new-RefersTo'} || '' %>" /></td></tr>
233 <tr><td class="label"><&|/l&>Referred to by</&></td><td><input size="10" name="RefersTo-new" value="<% $ARGS{'RefersTo-new'} || '' %>" /></td></tr>
234
235
236 </table>
237 </&>
238 </div>
239 <br />
240
241 </td>
242 </tr>
243 </table>
244 <& /Elements/Submit, Label => loc("Create") &>
245 </div>
246 </form>
247
248 <%INIT>
249 $m->callback( CallbackName => "Init", ARGSRef => \%ARGS );
250 my $Queue = $ARGS{Queue};
251
252 my $CloneTicketObj;
253 if ($CloneTicket) {
254     $CloneTicketObj = RT::Ticket->new( $session{CurrentUser} );
255     $CloneTicketObj->Load($CloneTicket)
256         or Abort( loc("Ticket could not be loaded") );
257
258     my $clone = {
259         Requestors => join( ',', $CloneTicketObj->RequestorAddresses ),
260         Cc         => join( ',', $CloneTicketObj->CcAddresses ),
261         AdminCc    => join( ',', $CloneTicketObj->AdminCcAddresses ),
262         InitialPriority => $CloneTicketObj->Priority,
263     };
264
265     $clone->{$_} = $CloneTicketObj->$_()
266         for qw/Owner Subject FinalPriority TimeEstimated TimeWorked
267         Status TimeLeft/;
268
269     $clone->{$_} = $CloneTicketObj->$_->AsString
270         for grep { $CloneTicketObj->$_->Unix }
271         map      { $_ . "Obj" } qw/Starts Started Due Resolved/;
272
273     my $members = $CloneTicketObj->Members;
274     my ( @members, @members_of, @refers, @refers_by, @depends, @depends_by );
275     my $refers = $CloneTicketObj->RefersTo;
276     while ( my $refer = $refers->Next ) {
277         push @refers, $refer->LocalTarget;
278     }
279     $clone->{'new-RefersTo'} = join ' ', @refers;
280
281     my $refers_by = $CloneTicketObj->ReferredToBy;
282     while ( my $refer_by = $refers_by->Next ) {
283         push @refers_by, $refer_by->LocalBase;
284     }
285     $clone->{'RefersTo-new'} = join ' ', @refers_by;
286     if (0) {    # Temporarily disabled
287         my $depends = $CloneTicketObj->DependsOn;
288         while ( my $depend = $depends->Next ) {
289             push @depends, $depend->LocalTarget;
290         }
291         $clone->{'new-DependsOn'} = join ' ', @depends;
292
293         my $depends_by = $CloneTicketObj->DependedOnBy;
294         while ( my $depend_by = $depends_by->Next ) {
295             push @depends_by, $depend_by->LocalBase;
296         }
297         $clone->{'DependsOn-new'} = join ' ', @depends_by;
298
299         while ( my $member = $members->Next ) {
300             push @members, $member->LocalBase;
301         }
302         $clone->{'MemberOf-new'} = join ' ', @members;
303
304         my $members_of = $CloneTicketObj->MemberOf;
305         while ( my $member_of = $members_of->Next ) {
306             push @members_of, $member_of->LocalTarget;
307         }
308         $clone->{'new-MemberOf'} = join ' ', @members_of;
309
310     }
311
312     my $cfs = $CloneTicketObj->QueueObj->TicketCustomFields();
313     while ( my $cf = $cfs->Next ) {
314         my $cf_id     = $cf->id;
315         my $cf_values = $CloneTicketObj->CustomFieldValues( $cf->id );
316         my @cf_values;
317         while ( my $cf_value = $cf_values->Next ) {
318             push @cf_values, $cf_value->Content;
319         }
320         $clone->{"Object-RT::Ticket--CustomField-$cf_id-Value"} = join "\n",
321             @cf_values;
322     }
323
324     for ( keys %$clone ) {
325         $ARGS{$_} = $clone->{$_} if not defined $ARGS{$_};
326     }
327
328 }
329
330 my @results;
331
332 my $title = loc("Create a new ticket");
333
334 my $QueueObj = new RT::Queue($session{'CurrentUser'});
335 $QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
336
337 $m->callback( QueueObj => $QueueObj, title => \$title, results => \@results, ARGSRef => \%ARGS );
338
339 $QueueObj->Disabled && Abort(loc("Cannot create tickets in a disabled queue."));
340
341 my $CFs = $QueueObj->TicketCustomFields();
342
343 my $ValidCFs = $m->comp(
344     '/Elements/ValidateCustomFields',
345     CustomFields => $CFs,
346     ARGSRef => \%ARGS
347 );
348
349 # {{{ deal with deleting uploaded attachments
350 foreach my $key (keys %ARGS) {
351     if ($key =~ m/^DeleteAttach-(.+)$/) {
352         delete $session{'Attachments'}{$1};
353     }
354     $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
355 }
356 # }}}
357
358 # {{{ store the uploaded attachment in session
359 if ($ARGS{'Attach'}) {                  # attachment?
360     my $attachment = MakeMIMEEntity(
361         AttachmentFieldName => 'Attach'
362     );
363
364     my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
365     $session{'Attachments'} = {
366         %{$session{'Attachments'} || {}},
367         $file_path => $attachment,
368     };
369 }
370 # }}}
371
372 # delete temporary storage entry to make WebUI clean
373 unless (keys %{$session{'Attachments'}} and $ARGS{'id'} eq 'new') {
374     delete $session{'Attachments'};
375 }
376
377 my $checks_failure = 0;
378
379 my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
380 $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
381     self      => $gnupg_widget,
382     QueueObj  => $QueueObj,
383 );
384
385
386 if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' ) {
387     my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
388         self      => $gnupg_widget,
389         Operation => 'Create',
390         QueueObj  => $QueueObj,
391     );
392     $checks_failure = 1 unless $status;
393 }
394
395 my $skip_create = 0;
396 $m->callback( CallbackName => 'BeforeCreate', ARGSRef => \%ARGS, skip_create => \$skip_create, 
397               checks_failure => $checks_failure, results => \@results );
398
399 if ((!exists $ARGS{'AddMoreAttach'}) and (defined($ARGS{'id'}) and $ARGS{'id'} eq 'new')) { # new ticket?
400     if ( $ValidCFs && !$checks_failure && !$skip_create ) {
401         $m->comp('Display.html', %ARGS);
402         $RT::Logger->crit("After display call; error is $@");
403         $m->abort();
404     }
405     elsif ( !$ValidCFs ) {
406         # Invalid CFs
407         while (my $CF = $CFs->Next) {
408             my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
409             push @results, $CF->Name . ': ' . $msg;
410         }
411     }
412 }
413
414 my $actions = {
415     A => {
416         html => q[<a href="#basics" onclick="return switchVisibility('Ticket-Create-basics','Ticket-Create-details');">] . loc('Show basics') . q[</a>],
417     },
418     B => {
419         html => q[<a href="#details" onclick="return switchVisibility('Ticket-Create-details','Ticket-Create-basics');">] . loc('Show details') . q[</a>],
420     },
421 };
422 </%INIT>
423
424 <%ARGS>
425 $DependsOn => undef
426 $DependedOnBy => undef
427 $MemberOf => undef
428 $QuoteTransaction => undef
429 $CloneTicket => undef
430 </%ARGS>