improve mandatory fields, #9260
[freeside.git] / rt / share / html / Ticket / ModifyAll.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
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, Title => loc("Ticket #[_1] Jumbo update: [_2]", $Ticket->Id, $Ticket->Subject) &>
49 <& /Ticket/Elements/Tabs, 
50     Ticket => $Ticket, 
51     current_tab => "Ticket/ModifyAll.html?id=".$Ticket->Id, 
52     Title => loc("Ticket #[_1] Jumbo update: [_2]", $Ticket->Id, $Ticket->Subject) &>
53
54 % $m->callback(CallbackName => 'BeforeActionList', Actions => \@results, ARGSRef => \%ARGS, Ticket => $Ticket);
55 <& /Elements/ListActions, actions => \@results &>
56
57 <form method="post" action="ModifyAll.html" enctype="multipart/form-data">
58 % $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS );
59 <input type="hidden" class="hidden" name="id" value="<%$Ticket->Id%>" />
60
61 <&| /Widgets/TitleBox, title => loc('Modify ticket # [_1]', $Ticket->Id), class=>'ticket-info-basics' &>
62 <& Elements/EditBasics, TicketObj => $Ticket &>
63 <& Elements/EditCustomFields, TicketObj => $Ticket &>
64 </&>
65
66 <br />
67
68 <&| /Widgets/TitleBox, title => loc('Dates'), class=>'ticket-info-dates'&>
69 <& Elements/EditDates, TicketObj => $Ticket &>
70 </&>
71
72 <br />
73
74
75 <&| /Widgets/TitleBox, title => loc('People'), class=>'ticket-info-people' &>
76 <& Elements/EditPeople, Ticket => $Ticket, UserField => $UserField, UserString => $UserString, UserOp => $UserOp, GroupString => $GroupString, GroupOp => $GroupOp, GroupField => $GroupField &>
77 </&>
78
79 <br />
80
81 <&| /Widgets/TitleBox, title => loc('Links'), class=>'ticket-info-links' &>
82 <& /Elements/EditLinks, Object => $Ticket, Merge => 1 &>
83 </&>
84
85 <br />
86
87 <&| /Widgets/TitleBox, title => loc('Update ticket') &>
88 <table>
89   <tr>
90     <td class="label"><&|/l&>Update Type</&>:</td>
91     <td class="entry">
92       <select name="UpdateType">
93 % if ($CanComment) {
94         <option value="private" ><&|/l&>Comments (Not sent to requestors)</&></option>
95 % }
96 % if ($CanRespond) {
97         <option value="response"><&|/l&>Reply to requestors</&></option>
98 % }
99       </select> 
100 % $m->callback( %ARGS, CallbackName => 'AfterUpdateType' );
101     </td>
102   </tr>
103   <tr>
104     <td class="label"><&|/l&>Subject</&>:</td>
105     <td class="entry"><input name="UpdateSubject" size="60" value="<%$Ticket->Subject%>" />
106 % $m->callback( %ARGS, CallbackName => 'AfterSubject' );
107     </td>
108   </tr>
109 % if (my $TxnCFs = $Ticket->TransactionCustomFields) {
110 %    while (my $CF = $TxnCFs->Next()) {
111 <tr>
112 <td class="label"><% loc($CF->Name) %>:</td>
113 <td class="entry"><& /Elements/EditCustomField, 
114     CustomField => $CF, 
115     NamePrefix => "Object-RT::Transaction--CustomField-"
116     &><em><% $CF->FriendlyType %></em>
117 </td></tr>
118 %    } # end if while
119 % } # end of if
120 % if (exists $session{'Attachments'}) {
121 <tr><td><&|/l&>Attached file</&>:</td>
122 <td>
123 <&|/l&>Check box to delete</&><br />
124 % foreach my $attach_name (keys %{$session{'Attachments'}}) {
125 <input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
126 % } # end of foreach
127 </td>
128 </tr>
129 % } # end of if
130
131   <tr>
132     <td class="label"><&|/l&>Attach</&>:</td>
133     <td class="entry"><input name="Attach" type="file" />
134     <input type="submit" class="button" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" />
135     <input type="hidden" class="hidden" name="UpdateAttach" value="1" />
136 % $m->callback( %ARGS, CallbackName => 'AfterAttach' );
137     </td>
138   </tr>
139   <tr>
140     <td class="labeltop"><&|/l&>Content</&>:</td>
141     <td class="entry">
142 % if (defined $ARGS{UpdateContent} && length($ARGS{UpdateContent})) {
143     <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0 &>
144 % } else {
145     <& /Elements/MessageBox, Name=>"UpdateContent", QuoteTransaction=>$ARGS{QuoteTransaction} &>
146 % }
147   </td></tr>
148 </table>
149 </&>
150   
151
152 <& /Elements/Submit, 
153     Name    => 'SubmitTicket',
154     Label   => loc('Save Changes'), 
155     Caption => loc("If you've updated anything above, be sure to"), color => "#333399" &>
156 </form>
157
158 <%INIT>
159
160
161
162 my $Ticket = LoadTicket($id);
163 my $CustomFields = $Ticket->CustomFields;
164
165 # call this to show up hints of valid cf values.
166 $m->comp(
167     '/Elements/ValidateCustomFields',
168     CustomFields => $CustomFields,
169     ARGSRef => {},
170 );
171
172 my $CanRespond = 0;
173 my $CanComment = 0;
174
175
176 $CanRespond = 1 if ( $Ticket->CurrentUserHasRight('ReplyToTicket') or
177                      $Ticket->CurrentUserHasRight('ModifyTicket') ); 
178
179 $CanComment = 1 if ( $Ticket->CurrentUserHasRight('CommentOnTicket') or
180                      $Ticket->CurrentUserHasRight('ModifyTicket') );
181
182 # {{{ deal with deleting uploaded attachments
183 foreach my $key (keys %ARGS) {
184     if ($key =~ m/^DeleteAttach-(.+)$/) {
185         delete $session{'Attachments'}{$1};
186     }
187     $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
188 }
189 # }}}
190
191 # {{{ store the uploaded attachment in session
192 if ($ARGS{'Attach'}) {            # attachment?
193     my $attachment = MakeMIMEEntity(
194         AttachmentFieldName => 'Attach'
195     );
196
197     my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
198     $session{'Attachments'} = {
199         %{$session{'Attachments'} || {}},
200         $file_path => $attachment,
201     };
202 }
203 # }}}
204
205 # delete temporary storage entry to make WebUI clean
206 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
207     delete $session{'Attachments'};
208 }
209 # }}}
210
211
212 $m->callback( TicketObj => $Ticket, ARGSRef => \%ARGS );
213 my @results;
214
215 unless ($OnlySearchForPeople or $OnlySearchForGroup or $ARGS{'AddMoreAttach'} ) {
216     # There might be two owners. 
217     if ( ref ($ARGS{'Owner'} )) {
218         my @owners =@{$ARGS{'Owner'}};
219         delete $ARGS{'Owner'};
220         foreach my $owner(@owners){
221             $ARGS{'Owner'} = $owner unless ($Ticket->OwnerObj->id == $owner);
222         }
223
224     }
225
226     push @results, ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS);
227     push @results, ProcessObjectCustomFieldUpdates( Object => $Ticket, ARGSRef => \%ARGS);
228     push @results, ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS);
229     
230     # Add session attachments if any to be processed by ProcessUpdateMessage
231     $ARGS{'UpdateAttachments'} = $session{'Attachments'} if ( $session{'Attachments'} );
232     push @results, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef=>\%ARGS );
233     # Cleanup WebUI
234     delete $session{'Attachments'};
235
236     push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
237     push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
238 }
239     push @results, ProcessTicketStatus( TicketObj => $Ticket, ARGSRef => \%ARGS );
240
241 $Ticket->ApplyTransactionBatch;
242
243 # If they've gone and moved the ticket to somewhere they can't see, etc...
244 # TODO: display the results, even if we can't display the ticket.
245
246 unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
247    Abort("No permission to view ticket");
248 }
249
250
251 </%INIT>
252
253
254
255 <%ARGS>
256 $OnlySearchForPeople => undef
257 $OnlySearchForGroup => undef
258 $UserField => undef
259 $UserOp => undef
260 $UserString => undef
261 $GroupString => undef
262 $GroupOp => undef
263 $GroupField => undef
264 $id => undef
265 </%ARGS>
266