import rt 3.6.4
[freeside.git] / rt / html / Ticket / Create.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2007 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/copyleft/gpl.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 => loc("Create a new ticket"),
50     onload => "hide(document.getElementById('Ticket-Create-details'));" &>
51 <& /Elements/Tabs, 
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 &>
59
60 <div id="Ticket-Create-basics">
61 <a name="basics"></a>
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"><% $QueueObj->Name %>
66 <input type="hidden" class="hidden" name="Queue" value="<%$QueueObj->Name%>" />
67 </td>
68 <td class="label"><&|/l&>Status</&>:
69 </td>
70 <td class="value">
71 <& /Elements/SelectStatus, Name => "Status", Default => $ARGS{Status}||'new', DefaultValue => 0 &>
72 </td>
73 <td class="label">
74 <&|/l&>Owner</&>:
75 </td>
76 <td class="value">
77 <& /Elements/SelectOwner, Name => "Owner", QueueObj => $QueueObj, Default => $ARGS{Owner}||$RT::Nobody->Id, DefaultValue => 0 &>
78 </td>
79 </tr>
80 <tr>
81 <td class="label">
82 <&|/l&>Requestors</&>:
83 </td>
84 <td class="value" colspan="5">
85 <input name="Requestors" value="<% ($ARGS{Requestors}) || $session{CurrentUser}->EmailAddress %>" size="40" />
86 </td>
87 </tr>
88 <tr>
89 <td class="labeltop">
90 <&|/l&>Cc</&>:
91 </td>
92 <td class="value" colspan="5">
93 <input name="Cc" size="40" value="<% $ARGS{Cc} %>" /><br />
94 <i><font size="-2">
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>
96 </td>
97 </tr>
98 <tr>
99 <td class="labeltop">
100 <&|/l&>Admin Cc</&>:
101 </td>
102 <td class="value" colspan="5">
103 <input name="AdminCc" size="40" value="<% $ARGS{AdminCc} %>" /><br />
104 <i><font size="-2">
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>
106 </td>
107 </tr>
108 <tr>
109 <td class="label">
110 <&|/l&>Subject</&>:
111 </td>
112 <td class="value" colspan="5">
113 <input name="Subject" size="60" maxsize="200" value="<%$ARGS{Subject} || ''%>" />
114 </td>
115 </tr>
116 <tr>
117 <td colspan="6">
118 <& /Ticket/Elements/EditCustomFields, QueueObj => $QueueObj &>
119 </td>
120 </tr>
121 % if ($TxnCFs->Count) {
122 % while (my $CF = $TxnCFs->Next()) {
123 <tr>
124 <td align="right"><% $CF->Name %>:</td>
125 <td><& /Elements/EditCustomField, CustomField => $CF, NamePrefix =>
126     "Object-RT::Transaction--CustomField-" &><em><% $CF->FriendlyType %></em></td>
127 </td></tr>
128 % }
129 % }
130 <tr>
131 % if (exists $session{'Attachments'}) {
132 <td class="label">
133 <&|/l&>Attached file</&>:
134 </td>
135 <td colspan="5">
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 />
139 % } # end of foreach
140 </td>
141 </tr>
142 <tr>
143 % } # end of if
144 <td>
145 <&|/l&>Attach file</&>:
146 </td>
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</&>" />
150 </td>
151 </tr>
152 <tr>
153 <td colspan="6">
154 <&|/l&>Describe the issue below</&>:<br />
155 % if (exists $ARGS{Content}) {
156 <& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => 0 &>
157 % } else {
158 <& /Elements/MessageBox, QuoteTransaction => $QuoteTransaction &>
159 %}
160
161 <br />
162 </td>
163 </tr>
164 <tr>
165 <td align="right" colspan="2">
166 </td>
167 </tr>
168 </table>
169 </&>
170 <& /Elements/Submit, Label => loc("Create")&>
171 </div>
172
173 <div id="Ticket-Create-details">
174 <a name="details"></a>
175 <table width="100%" border="0">
176 <tr>
177 <td width="50%" valign="top">
178
179           <&| /Widgets/TitleBox, title => loc('The Basics'), 
180                 title_class=> 'inverse',  
181                 color => "#993333" &>
182 <table border="0">
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>
186 <td>
187 <input size="3" name="TimeEstimated" value="<%$ARGS{TimeEstimated}%>" />
188 <& /Elements/SelectTimeUnits, Name =>'TimeEstimated' &>
189
190 </td></tr>
191 <tr><td align="right"><&|/l&>Time Worked</&>:</td>
192 <td>
193 <input size="3" name="TimeWorked" value="<%$ARGS{TimeWorked}%>" />
194 <& /Elements/SelectTimeUnits, Name =>'TimeWorked' &>
195
196 </td></tr>
197 <tr>
198 <td align="right"><&|/l&>Time Left</&>:</td>
199 <td><input size="3" name="TimeLeft" value="<%$ARGS{TimeLeft}%>" />
200 <& /Elements/SelectTimeUnits, Name =>'TimeLeft' &>
201 </td></tr>
202 </table>
203 </&>
204 <br />
205 <&|/Widgets/TitleBox, title => loc("Dates"),
206                 title_class=> 'inverse',  
207                  color => "#663366" &>
208
209 <table>
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>
212 </table>
213 </&>
214 <br />
215 </td>
216
217 <td valign="top">
218 <&| /Widgets/TitleBox, title => loc('Links'), title_class=> 'inverse' &>
219
220 <em><&|/l&>(Enter ticket ids or URLs, separated with spaces)</&></em>
221 <table border="0">
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>
228
229
230 </table>
231 </&>
232 <br />
233
234 </td>
235 </tr>
236 </table>
237 <& /Elements/Submit, Label => loc("Create") &>
238 </div>
239 </form>
240
241 <%INIT>
242
243
244 my @results;
245 my $QueueObj = new RT::Queue($session{'CurrentUser'});
246 $QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
247 my $CFs = $QueueObj->TicketCustomFields();
248 my $TxnCFs = $QueueObj->TicketTransactionCustomFields();
249
250 my $ValidCFs = $m->comp(
251     '/Elements/ValidateCustomFields',
252     CustomFields => $CFs,
253     ARGSRef => \%ARGS
254 );
255
256 # if no due date has been set explicitly, then use the
257 # queue's default if it exists
258 if ($QueueObj->DefaultDueIn && !$ARGS{'Due'}) {
259     my $default_due = RT::Date->new($session{'CurrentUser'});
260     $default_due->SetToNow();
261     $default_due->AddDays($QueueObj->DefaultDueIn);
262     $ARGS{'Due'} = $default_due->ISO();
263 }
264
265 # {{{ deal with deleting uploaded attachments
266 foreach my $key (keys %ARGS) {
267     if ($key =~ m/^DeleteAttach-(.+)$/) {
268         delete $session{'Attachments'}{$1};
269     }
270     $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
271 }
272
273 # {{{ store the uploaded attachment in session
274 if ($ARGS{'Attach'}) {                  # attachment?
275     $session{'Attachments'} = {} unless defined $session{'Attachments'};
276
277     my $subject = "$ARGS{'Attach'}";
278
279     # strip leading directories
280     $subject =~ s#^.*[\\/]##;
281
282     my $attachment = MakeMIMEEntity(
283         Subject             => $subject,
284         Body                => "",
285         AttachmentFieldName => 'Attach'
286     );
287
288     $session{'Attachments'} = { %{$session{'Attachments'} || {}},
289                                 $ARGS{'Attach'} => $attachment };
290 }
291 # }}}
292
293 # delete temporary storage entry to make WebUI clean
294 unless (keys %{$session{'Attachments'}} and $ARGS{'id'} eq 'new') {
295     delete $session{'Attachments'};
296 }
297
298
299 # }}}
300
301 if ((!exists $ARGS{'AddMoreAttach'}) and ($ARGS{'id'} eq 'new')) { # new ticket?
302     if ($ValidCFs) {
303         $m->comp('Display.html', %ARGS);
304         $RT::Logger->crit("After display call; error is $@");
305         $m->abort();
306     }
307     else {
308         # Invalid CFs
309         while (my $CF = $CFs->Next) {
310             my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
311             push @results, $CF->Name . ': ' . $msg;
312         }
313     }
314 }
315
316 my $actions = {
317     A => {
318         html => q[<a href="#basics" onclick="return switchVisibility('Ticket-Create-basics','Ticket-Create-details');">] . loc('Show basics') . q[</a>],
319     },
320     B => {
321         html => q[<a href="#details" onclick="return switchVisibility('Ticket-Create-details','Ticket-Create-basics');">] . loc('Show details') . q[</a>],
322     },
323 };
324 </%INIT>
325
326 <%ARGS>
327 $DependsOn => undef
328 $DependedOnBy => undef
329 $MemberOf => undef
330 $QuoteTransaction => undef
331 $Queue => undef
332 </%ARGS>