1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2009 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/licenses/old-licenses/gpl-2.0.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 }}}
48 <& Elements/Header, Title => loc("Create a ticket") &>
50 <& /Elements/ListActions, actions => \@results &>
52 <form action="<% $RT::WebPath %>/SelfService/Create.html" method="post" enctype="multipart/form-data" name="TicketCreate">
53 <input type="hidden" class="hidden" name="id" value="new" />
57 <td class="label"><&|/l&>Queue</&>:</td>
59 <input type="hidden" class="hidden" name="Queue" value="<% $queue_obj->id %>" />
60 <strong><% $queue_obj->Name %></strong> (<%$queue_obj->Description || ''%>)
64 <td class="label"><&|/l&>Requestors</&>:</td>
66 <input name="Requestors" value="<% $ARGS{'Requestors'} || $session{CurrentUser}->EmailAddress %>" size="20" />
70 <td class="label"><&|/l&>Cc</&>:</td>
72 <input name="Cc" size="20" value="<% $ARGS{'Cc'} || '' %>" />
76 <td class="label"><&|/l&>Subject</&>:</td>
78 <input name="Subject" size="60" maxsize="200" value="<% $ARGS{'Subject'} || '' %>" />
83 <& /Ticket/Elements/EditCustomFields, QueueObj => $queue_obj &>
87 <td class="label"><&|/l&>Attach file</&>:</td>
89 <input name="Attach" type="file" />
94 <&|/l&>Describe the issue below</&>:<br />
95 % if (exists $ARGS{Content}) {
96 <& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => 0 &>
98 <& /Elements/MessageBox &>
103 <& /Elements/Submit, Label => loc("Create ticket")&>
111 my $queue_obj = RT::Queue->new($session{'CurrentUser'});
112 $queue_obj->Load($Queue) || Abort(loc("Queue could not be loaded."));
113 $queue_obj->Disabled && Abort(loc("Cannot create tickets in a disabled queue."));
115 my ($checks_failure, $skip_create, @results) = (0, 0, ());
116 $skip_create = 1 unless ($ARGS{'id'}||'') eq 'new';
118 $m->comp('/Elements/Callback',
119 QueueObj => $queue_obj, ARGSRef => \%ARGS,
120 skip_create => \$skip_create, checks_failure => \$checks_failure,
124 $skip_create = 1 if exists $ARGS{'AddMoreAttach'};
126 # deal with deleting uploaded attachments
127 foreach my $key (keys %ARGS) {
128 if ($key =~ m/^DeleteAttach-(.+)$/) {
129 delete $session{'Attachments'}{$1};
131 $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
134 # store the uploaded attachment in session
135 if ( $ARGS{'Attach'} ) { # attachment?
136 $session{'Attachments'} = {} unless defined $session{'Attachments'};
138 my $subject = "$ARGS{'Attach'}";
140 # strip leading directories
141 $subject =~ s#^.*[\\/]##;
143 my $attachment = MakeMIMEEntity(
146 AttachmentFieldName => 'Attach'
149 $session{'Attachments'} = { %{$session{'Attachments'} || {}},
150 $ARGS{'Attach'} => $attachment };
153 unless (keys %{$session{'Attachments'}} and $ARGS{'id'} eq 'new') {
154 delete $session{'Attachments'};
157 my $CFs = $queue_obj->TicketCustomFields;
158 my $ValidCFs = $m->comp(
159 '/Elements/ValidateCustomFields',
160 CustomFields => $CFs,
163 unless ( $ValidCFs ) {
165 while ( my $CF = $CFs->Next ) {
166 my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
167 push @results, $CF->Name . ': ' . $msg
168 if ($ARGS{'id'}||'') eq 'new';
172 if ( !$checks_failure && !$skip_create ) {
173 $m->comp('Display.html', %ARGS);
174 $RT::Logger->crit("After display call; error is $@");