rt 4.2.16
[freeside.git] / rt / share / html / Ticket / Elements / Reminders
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2019 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 <%args>
49 $Ticket => undef
50 $id => undef
51 $ShowCompleted => 0
52 $Edit => 0
53 $ShowSave => 1
54 </%args>
55 <%init>
56
57 $Ticket = LoadTicket($id) if ($id);
58 my $resolve_status = $Ticket->LifecycleObj->ReminderStatusOnResolve;
59
60 my $count_reminders = RT::Reminders->new($session{'CurrentUser'});
61 $count_reminders->Ticket($Ticket->id);
62 my $count_tickets = $count_reminders->Collection;
63 if (!$ShowCompleted) {
64     # XXX: don't break encapsulation if we can avoid it
65     $count_tickets->FromSQL(q{Type = "reminder" AND RefersTo = "} .  $Ticket->id . qq{" AND Status != "$resolve_status" });
66 }
67 my $has_reminders = $count_tickets->Count;
68
69 # We've made changes, let's reload our search
70 my $reminder_collection = $count_reminders->Collection;
71 </%init>
72 <input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
73 <input type="hidden" class="hidden" name="update-reminders" value="1" />
74 % my $editable = 0;
75 % if ($has_reminders) {
76 <table border="0" cellpadding="1" cellspacing="0" class="collection-as-table"<% $Edit ? ' style="width: auto;"' : '' |n %>>
77 <tr>
78 % if ( $Edit ) {
79 <th class="collection-as-table" colspan="5"><&|/l&>Reminders</&></th>
80 % } else {
81 <th class="collection-as-table"></th>
82 <th class="collection-as-table"><&|/l&>Reminder</&></th>
83 <th class="collection-as-table"><&|/l&>Due</&></th>
84 <th class="collection-as-table"><&|/l&>Owner</&></th>
85 % }
86 </tr>
87 % my $i = 0;
88 % while ( my $reminder = $reminder_collection->Next ) {
89 % $i++;
90 % if ( $reminder->Status eq $resolve_status && !$ShowCompleted ) {
91 <tr class="hidden"><td><input type="hidden" class="hidden" name="Complete-Reminder-<% $reminder->id %>" value="1" /></td></tr>
92 % $i++;
93 % }
94 % else {
95 %   $editable = 1 if !$editable && $reminder->CurrentUserHasRight( 'ModifyTicket' );
96 %   if ($Edit) {
97 <& SELF:EditEntry, Reminder => $reminder, Ticket => $Ticket, Index => $i &>
98 %   } else {
99 <& SELF:ShowEntry, Reminder => $reminder, Ticket => $Ticket, Index => $i &>
100 %   }
101 % }
102 % }
103 </table>
104 % if ( $editable ) {
105 <i><&|/l&>(Check box to complete)</&></i><br /><br />
106 % }
107 % } else {
108
109 %# we must always include resolved reminders due to the browser
110 %# checkbox-with-false-value issue
111 % while ( my $reminder = $reminder_collection->Next ) {
112 % if ( $reminder->Status eq $resolve_status && !$ShowCompleted ) {
113 <input type="hidden" class="hidden" name="Complete-Reminder-<% $reminder->id %>" value="1" />
114 % }
115 % }
116 % }
117
118 % if (lc $Ticket->Status ne "deleted" and $Ticket->QueueObj->CurrentUserHasRight('CreateTicket') and $Ticket->CurrentUserHasRight('ModifyTicket') ) {
119 <&|/l&>New reminder:</&>
120 <& SELF:NewReminder, Ticket => $Ticket &>
121 % $editable = 1;
122 % }
123
124 % if ( $editable && $ShowSave ) {
125 <div align="right"><input type="submit" class="button" value="<&|/l&>Save</&>" /></div>
126 % }
127 <%method NewReminder>
128 <%args>
129 $Ticket
130 </%args>
131 <table>
132 <tr>
133 <td class="label"><&|/l&>Subject</&>:</td>
134 <td class="entry" colspan="3"><input type="text" size="50" name="NewReminder-Subject" id="NewReminder-Subject" /></td>
135 </tr>
136 <tr>
137 <td class="label"><&|/l&>Owner</&>:</td>
138 <td class="entry"><& /Elements/SelectOwner, Name => 'NewReminder-Owner', QueueObj => $Ticket->QueueObj, Default=>$session{'CurrentUser'}->id, DefaultValue => 0 &></td>
139 </tr>
140 <tr>
141 <td class="label"><&|/l&>Due</&>:</td>
142 <td class="entry"><& /Elements/SelectDate, Name => "NewReminder-Due", Default => "" &></td>
143 </tr>
144 </table>
145 </%method>
146 <%method EditEntry>
147 <%args>
148 $Reminder
149 $Ticket
150 $Index
151 </%args>
152 <tr class="<% $Index%2 ? 'oddline' : 'evenline' %>" id="reminder-<% $Reminder->id %>">
153 <td class="entry">
154 % unless ( $Reminder->CurrentUserHasRight('ModifyTicket') ) {
155 <input name="Complete-Reminder-<% $Reminder->id %>" type="hidden" 
156 value=<% $Reminder->Status eq $Reminder->LifecycleObj->ReminderStatusOnResolve ? 1 : 0 %> />
157 % }
158
159 <input type="checkbox" value="1" name="Complete-Reminder-<% $Reminder->id %>" <% $Reminder->Status eq $Reminder->LifecycleObj->ReminderStatusOnResolve ? 'checked="checked"' : '' |n %>
160 % unless ( $Reminder->CurrentUserHasRight('ModifyTicket') ) {
161 disabled="disabled" 
162 % }
163 /></td>
164 <td class="label"><&|/l&>Subject</&>:</td>
165 <td class="entry" colspan="3">
166 <input type="text" size="50" name="Reminder-Subject-<% $Reminder->id %>" value="<% $Reminder->Subject %>" 
167 % unless ( $Reminder->CurrentUserHasRight('ModifyTicket') ) {
168 readonly="readonly" 
169 % }
170 />
171 </td>
172 </tr>
173 <tr class="<% $Index%2 ? 'oddline' : 'evenline' %>">
174 <td class="entry">&nbsp;</td>
175 <td class="label"><&|/l&>Owner</&>:</td>
176 <td class="entry"><& /Elements/SelectOwner, Name => 'Reminder-Owner-'.$Reminder->id, QueueObj => $Ticket->QueueObj, Default => $Reminder->Owner, DefaultValue => 0  &></td>
177 <td class="label"><&|/l&>Due</&>:</td>
178 <td class="entry">
179 % if ( $Reminder->CurrentUserHasRight('ModifyTicket') ) {
180 <& /Elements/SelectDate, Name => 'Reminder-Due-'.$Reminder->id &>
181 % }
182 (<% $Reminder->DueObj->AsString %>)
183 </td>
184 </tr>
185 </%method>
186 <%method ShowEntry>
187 <%args>
188 $Reminder
189 $Ticket
190 $Index
191 </%args>
192 % my $dueobj = $Reminder->DueObj;
193 % my $overdue = $dueobj->IsSet && $dueobj->Diff < 0 ? 1 : 0;
194 <tr class="<% $Index%2 ? 'oddline' : 'evenline' %>" id="reminder-<% $Reminder->id %>">
195
196 <td class="collection-as-table">
197 % unless ( $Reminder->CurrentUserHasRight('ModifyTicket') ) {
198 <input name="Complete-Reminder-<% $Reminder->id %>" type="hidden" 
199 value=<% $Reminder->Status eq $Reminder->LifecycleObj->ReminderStatusOnResolve ? 1 : 0 %> />
200 % }
201 <input type="checkbox" value="1" id="Complete-Reminder-<% $Reminder->id %>" name="Complete-Reminder-<% $Reminder->id %>" <% $Reminder->Status eq $Reminder->LifecycleObj->ReminderStatusOnResolve ? 'checked="checked"' : '' |n %>
202 % unless ( $Reminder->CurrentUserHasRight('ModifyTicket') ) {
203 disabled="disabled" 
204 % }
205 /></td>
206 <td class="collection-as-table"><label for="Complete-Reminder-<% $Reminder->id %>"><% $Reminder->Subject %></label></td>
207 <td class="collection-as-table"><% $overdue ? '<span class="overdue">' : '' |n %><% $dueobj->AgeAsString || loc('Not set') %><% $overdue ? '</span>' : '' |n %></td>
208 <td class="collection-as-table"><& /Elements/ShowUser, User => $Reminder->OwnerObj &></td>
209 </tr>
210 </%method>