RT mobile UI, #11630
[freeside.git] / rt / share / html / m / ticket / reply
1 <&|/m/_elements/wrapper, title => loc('Update ticket #[_1]', $t->id) &>
2 <& /m/_elements/ticket_menu, ticket => $t &>
3 <& /Elements/ListActions, actions => \@results &>
4 <div class="ticket-reply">
5 <&|/Widgets/TitleBox &>
6 <form action="reply" id="update"
7     method="post" enctype="multipart/form-data">
8 <input type="hidden" class="hidden" name="DefaultStatus" value="<% $DefaultStatus ||''%>" />
9 <input type="hidden" class="hidden" name="Action" value="<% $ARGS{Action}||'' %>" />
10
11 <div class="entry"><span class="label"><&|/l&>Status</&>:</span>
12 <div class="value">
13 <& /Elements/SelectStatus, Name=>"Status", DefaultLabel => loc("[_1] (Unchanged)", loc($t->Status)), Default => $ARGS{'Status'} || ($t->Status eq $DefaultStatus ? undef : $DefaultStatus)&>
14 </div></div>
15
16 <div class="entry"><span class="label"><&|/l&>Owner</&>:</span>
17 <div class="value">
18 <& /Elements/SelectOwner,
19     Name         => "Owner",
20     TicketObj    => $t,
21     QueueObj     => $t->QueueObj,
22     DefaultLabel => loc("[_1] (Unchanged)", $t->OwnerObj->Name),
23     Default      => $ARGS{'Owner'}
24 &>
25 </div></div>
26 <div class="entry timefield"><span class="label"><&|/l&>Worked</&>:</span><span class="value">
27 <& /Elements/EditTimeValue,
28     Name => 'UpdateTimeWorked',
29     Default => $ARGS{UpdateTimeWorked}||'',
30     InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
31 &>
32 </span></div>
33 <input type="hidden" class="hidden" name="id" value="<%$t->Id%>" /><br />
34 <div class="entry"><span class="label"><&|/l&>Update Type</&>:</span>
35 <div class="value"><select name="UpdateType">
36 % if ($CanComment) {
37 <option value="private" <% ($ARGS{'UpdateType'} &&  $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
38 % }
39 % if ($CanRespond) {
40 <option value="response" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "response") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$ResponseDefault |n %>><&|/l&>Reply to requestors</&></option>
41 % }
42 </select> 
43 </div></div>
44 <div class="entry"><span class="label"><&|/l&>Subject</&>:</span><div class="value"> <input name="UpdateSubject" size="60" value="<% $ARGS{UpdateSubject} || $t->Subject()%>" />
45 % $m->callback( %ARGS, CallbackName => 'AfterSubject' );
46 </div></div>
47
48 <div class="entry"><span class="label"><&|/l&>One-time Cc</&>:</span><span class="value"><& /Elements/EmailInput, Name => 'UpdateCc', Size => '60', Default => $ARGS{UpdateCc} &></span></div>
49
50 <div class="entry"><span class="label"><&|/l&>One-time Bcc</&>:</span><span class="value"><& /Elements/EmailInput, Name => 'UpdateBcc', Size => '60', Default => $ARGS{UpdateBcc} &></span></div>
51
52 <div class="entry"><span class="label" ><&|/l&>Message</&>:</span><div class="value">
53 % if (exists $ARGS{UpdateContent}) {
54 % # preserve QuoteTransaction so we can use it to set up sane references/in/reply to
55 % my $temp = $ARGS{'QuoteTransaction'};
56 % delete $ARGS{'QuoteTransaction'};
57 <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
58 % $ARGS{'QuoteTransaction'} = $temp;
59 % } else {
60 % my $IncludeSignature = 1;
61 % $IncludeSignature = 0 if $Action ne 'Respond' && !RT->Config->Get('MessageBoxIncludeSignatureOnComment');
62 <& /Elements/MessageBox, Name=>"UpdateContent", IncludeSignature => $IncludeSignature, %ARGS &>
63 % }
64 </div></div>
65 <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket' &>
66 </form>
67 </&>
68 </div>
69 </&>
70 <%INIT>
71 my $CanRespond = 0;
72 my $CanComment = 0;
73 my $checks_failure = 0;
74 my $title;
75
76 my $t = LoadTicket($id);
77
78 my @results;
79
80 $m->callback( Ticket => $t, ARGSRef => \%ARGS, results => \@results, CallbackName => 'Initial' );
81
82 unless($DefaultStatus){
83     $DefaultStatus=($ARGS{'Status'} ||$t->Status());
84 }
85
86 if ($DefaultStatus eq 'new'){
87     $DefaultStatus='open';
88 }
89
90 if ($DefaultStatus eq 'resolved') {
91     $title = loc("Resolve ticket #[_1] ([_2])", $t->id, $t->Subject);
92 } else {
93     $title = loc("Update ticket #[_1] ([_2])", $t->id, $t->Subject);
94 }
95
96 # Things needed in the template - we'll do the processing here, just
97 # for the convenience:
98
99 my ($CommentDefault, $ResponseDefault);
100 if ($Action ne 'Respond') {
101     $CommentDefault = qq[ selected="selected"]; 
102     $ResponseDefault = "";
103 } else {
104     $CommentDefault = ""; 
105     $ResponseDefault = qq[ selected="selected"];
106 }
107
108
109
110 $CanRespond = 1 if ( $t->CurrentUserHasRight('ReplyToTicket') or
111                      $t->CurrentUserHasRight('ModifyTicket') ); 
112
113 $CanComment = 1 if ( $t->CurrentUserHasRight('CommentOnTicket') or
114                      $t->CurrentUserHasRight('ModifyTicket') ); 
115
116
117 # {{{ deal with deleting uploaded attachments
118 foreach my $key (keys %ARGS) {
119     if ($key =~ m/^DeleteAttach-(.+)$/) {
120         delete $session{'Attachments'}{$1};
121     }
122     $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
123 }
124 # }}}
125
126 # {{{ store the uploaded attachment in session
127 if ($ARGS{'Attach'}) {            # attachment?
128     my $attachment = MakeMIMEEntity(
129         AttachmentFieldName => 'Attach'
130     );
131
132     my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
133     $session{'Attachments'} = {
134         %{$session{'Attachments'} || {}},
135         $file_path => $attachment,
136     };
137 }
138 # }}}
139
140 # delete temporary storage entry to make WebUI clean
141 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
142     delete $session{'Attachments'};
143 }
144 # }}}
145
146 # check email addresses for RT's
147 {
148     foreach my $field ( qw(UpdateCc UpdateBcc) ) {
149         my $value = $ARGS{ $field };
150         next unless defined $value && length $value;
151
152         my @emails = Email::Address->parse( $value );
153         foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
154             push @results, loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email->format, loc(substr($field, 6)) );
155             $checks_failure = 1;
156             $email = undef;
157         }
158         $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
159     }
160 }
161
162 if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
163     return $m->comp('/m/ticket/show', TicketObj => $t, %ARGS);
164 }
165 </%INIT>
166
167 <%ARGS>
168 $id => undef
169 $Action => 'reply'
170 $DefaultStatus => undef
171 </%ARGS>