import rt 3.8.8
[freeside.git] / rt / html / SelfService / 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, Title => loc("Create a ticket") &>
49
50 <& /Elements/ListActions, actions => \@results &>
51
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" />
54
55 <table>
56 <tr>
57 <td class="label"><&|/l&>Queue</&>:</td>
58 <td class="value">
59     <input type="hidden" class="hidden" name="Queue" value="<% $queue_obj->id %>" />
60     <strong><% $queue_obj->Name %></strong> (<%$queue_obj->Description || ''%>)
61 </td>
62 </tr>
63 <tr>
64 <td class="label"><&|/l&>Requestors</&>:</td>
65 <td class="value">
66 <input name="Requestors" value="<% $ARGS{'Requestors'} || $session{CurrentUser}->EmailAddress %>" size="20" />
67 </td>
68 </tr>
69 <tr>
70 <td class="label"><&|/l&>Cc</&>:</td>
71 <td class="value">
72 <input name="Cc" size="20" value="<% $ARGS{'Cc'} || '' %>" />
73 </td>
74 </tr>
75 <tr>
76 <td class="label"><&|/l&>Subject</&>:</td>
77 <td class="value">
78 <input name="Subject" size="60" maxsize="200" value="<% $ARGS{'Subject'} || '' %>" />
79 </td>
80 </tr>
81 <tr>
82     <td colspan="2">
83         <& /Ticket/Elements/EditCustomFields, QueueObj => $queue_obj &>
84     </td>
85 </tr>
86 <tr>
87 <td class="label"><&|/l&>Attach file</&>:</td>
88 <td class="value">
89 <input name="Attach" type="file" />
90 </td>
91 </tr>
92 <tr>
93 <td colspan="2">
94 <&|/l&>Describe the issue below</&>:<br />
95 % if (exists $ARGS{Content}) {
96 <& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => 0 &>
97 % } else {
98 <& /Elements/MessageBox &>
99 % }
100 </td>
101 </tr>
102 </table>
103 <& /Elements/Submit, Label => loc("Create ticket")&>
104
105
106 </form>
107 <%args>
108 $Queue => undef
109 </%args>
110 <%init>
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."));
114
115 my ($checks_failure, $skip_create, @results) = (0, 0, ());
116 $skip_create = 1 unless ($ARGS{'id'}||'') eq 'new';
117
118 $m->comp('/Elements/Callback',
119     QueueObj => $queue_obj, ARGSRef => \%ARGS,
120     skip_create => \$skip_create, checks_failure => \$checks_failure,
121     results => \@results
122 );
123
124 $skip_create = 1 if exists $ARGS{'AddMoreAttach'};
125
126 # deal with deleting uploaded attachments
127 foreach my $key (keys %ARGS) {
128     if ($key =~ m/^DeleteAttach-(.+)$/) {
129         delete $session{'Attachments'}{$1};
130     }
131     $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
132 }
133
134 # store the uploaded attachment in session
135 if ( $ARGS{'Attach'} ) { # attachment?
136     $session{'Attachments'} = {} unless defined $session{'Attachments'};
137
138     my $subject = "$ARGS{'Attach'}";
139
140     # strip leading directories
141     $subject =~ s#^.*[\\/]##;
142
143     my $attachment = MakeMIMEEntity(
144         Subject             => $subject,
145         Body                => "",
146         AttachmentFieldName => 'Attach'
147     );
148
149     $session{'Attachments'} = { %{$session{'Attachments'} || {}},
150                                 $ARGS{'Attach'} => $attachment };
151 }
152
153 unless (keys %{$session{'Attachments'}} and $ARGS{'id'} eq 'new') {
154     delete $session{'Attachments'};
155 }
156
157 my $CFs = $queue_obj->TicketCustomFields;
158 my $ValidCFs = $m->comp(
159     '/Elements/ValidateCustomFields',
160     CustomFields => $CFs,
161     ARGSRef => \%ARGS
162 );
163 unless ( $ValidCFs ) {
164     $checks_failure = 1;
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';
169     }
170 }
171
172 if ( !$checks_failure && !$skip_create ) {
173     $m->comp('Display.html', %ARGS);
174     $RT::Logger->crit("After display call; error is $@");
175     $m->abort();
176 }
177 </%init>