Upgrade 4.0.17 clean.
[usit-rt.git] / share / html / Ticket / Elements / Reminders
CommitLineData
84fb5b46
MKG
1%# BEGIN BPS TAGGED BLOCK {{{
2%#
3%# COPYRIGHT:
4%#
403d7b0b 5%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
84fb5b46
MKG
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</%args>
54<%init>
55
56$Ticket = LoadTicket($id) if ($id);
b5747ff2 57my $resolve_status = $Ticket->QueueObj->Lifecycle->ReminderStatusOnResolve;
84fb5b46
MKG
58
59my $count_reminders = RT::Reminders->new($session{'CurrentUser'});
60$count_reminders->Ticket($Ticket->id);
61my $count_tickets = $count_reminders->Collection;
62if (!$ShowCompleted) {
63 # XXX: don't break encapsulation if we can avoid it
b5747ff2 64 $count_tickets->FromSQL(q{Type = "reminder" AND RefersTo = "} . $Ticket->id . qq{" AND Status != "$resolve_status" });
84fb5b46
MKG
65}
66my $has_reminders = $count_tickets->Count;
67
68# We've made changes, let's reload our search
69my $reminder_collection = $count_reminders->Collection;
c36a7e1d 70my $visible = 0;
84fb5b46
MKG
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% if ($has_reminders) {
75<table border="0" cellpadding="1" cellspacing="0" class="collection-as-table"<% $Edit ? ' style="width: auto;"' : '' |n %>>
76<tr>
77% if ( $Edit ) {
78<th class="collection-as-table" colspan="5"><&|/l&>Reminders</&></th>
79% } else {
80<th class="collection-as-table"></th>
81<th class="collection-as-table"><&|/l&>Reminder</&></th>
82<th class="collection-as-table"><&|/l&>Due</&></th>
83<th class="collection-as-table"><&|/l&>Owner</&></th>
84% }
85</tr>
86% my $i = 0;
84fb5b46
MKG
87% while ( my $reminder = $reminder_collection->Next ) {
88% $i++;
b5747ff2 89% if ( $reminder->Status eq $resolve_status && !$ShowCompleted ) {
84fb5b46
MKG
90<tr class="hidden"><td><input type="hidden" class="hidden" name="Complete-Reminder-<% $reminder->id %>" value="1" /></td></tr>
91% $i++;
92% } elsif ($Edit) {
93<& SELF:EditEntry, Reminder => $reminder, Ticket => $Ticket, Index => $i &>
94% $visible++;
95% } else {
96<& SELF:ShowEntry, Reminder => $reminder, Ticket => $Ticket, Index => $i &>
97% $visible++;
98% }
99% }
100</table>
101% if ( $visible > 0 ) {
102<i><&|/l&>(Check box to complete)</&></i><br /><br />
103% }
104% } else {
105
106%# we must always include resolved reminders due to the browser
107%# checkbox-with-false-value issue
108% while ( my $reminder = $reminder_collection->Next ) {
b5747ff2 109% if ( $reminder->Status eq $resolve_status && !$ShowCompleted ) {
84fb5b46
MKG
110<input type="hidden" class="hidden" name="Complete-Reminder-<% $reminder->id %>" value="1" />
111% }
112% }
113% }
114
01e3b242 115% if (lc $Ticket->Status ne "deleted") {
84fb5b46
MKG
116<&|/l&>New reminder:</&>
117<& SELF:NewReminder, Ticket => $Ticket &>
c36a7e1d 118% }
01e3b242 119% return(lc $Ticket->Status ne "deleted" or $visible);
84fb5b46
MKG
120<%method NewReminder>
121<%args>
122$Ticket
123</%args>
124<table>
125<tr>
126<td class="label"><&|/l&>Subject</&>:</td>
127<td class="entry" colspan="3"><input type="text" size="50" name="NewReminder-Subject" id="NewReminder-Subject" /></td>
128</tr>
129<tr>
130<td class="label"><&|/l&>Owner</&>:</td>
131<td class="entry"><& /Elements/SelectOwner, Name => 'NewReminder-Owner', QueueObj => $Ticket->QueueObj, Default=>$session{'CurrentUser'}->id, DefaultValue => 0 &></td>
132</tr>
133<tr>
134<td class="label"><&|/l&>Due</&>:</td>
135<td class="entry"><& /Elements/SelectDate, Name => "NewReminder-Due", Default => "" &></td>
136</tr>
137</table>
138</%method>
139<%method EditEntry>
140<%args>
141$Reminder
142$Ticket
143$Index
144</%args>
145<tr class="<% $Index%2 ? 'oddline' : 'evenline' %>">
b5747ff2 146<td class="entry"><input type="checkbox" value="1" name="Complete-Reminder-<% $Reminder->id %>" <% $Reminder->Status eq $Reminder->QueueObj->Lifecycle->ReminderStatusOnResolve ? 'checked="checked"' : '' |n %> /></td>
84fb5b46
MKG
147<td class="label"><&|/l&>Subject</&>:</td>
148<td class="entry" colspan="3"><input type="text" size="50" name="Reminder-Subject-<% $Reminder->id %>" value="<% $Reminder->Subject %>" /></td>
149</tr>
150<tr class="<% $Index%2 ? 'oddline' : 'evenline' %>">
151<td class="entry">&nbsp;</td>
152<td class="label"><&|/l&>Owner</&>:</td>
153<td class="entry"><& /Elements/SelectOwner, Name => 'Reminder-Owner-'.$Reminder->id, QueueObj => $Ticket->QueueObj, Default => $Reminder->Owner, DefaultValue => 0 &></td>
154<td class="label"><&|/l&>Due</&>:</td>
155<td class="entry"><& /Elements/SelectDate, Name => 'Reminder-Due-'.$Reminder->id &> (<% $Reminder->DueObj->AsString %>)</td>
156</tr>
157</%method>
158<%method ShowEntry>
159<%args>
160$Reminder
161$Ticket
162$Index
163</%args>
164% my $dueobj = $Reminder->DueObj;
165% my $overdue = $dueobj->Unix > 0 && $dueobj->Diff < 0 ? 1 : 0;
166<tr class="<% $Index%2 ? 'oddline' : 'evenline' %>">
b5747ff2 167<td class="collection-as-table"><input type="checkbox" value="1" name="Complete-Reminder-<% $Reminder->id %>" <% $Reminder->Status eq $Reminder->QueueObj->Lifecycle->ReminderStatusOnResolve ? 'checked="checked"' : '' |n %> /></td>
84fb5b46
MKG
168<td class="collection-as-table"><% $Reminder->Subject %></td>
169<td class="collection-as-table"><% $overdue ? '<span class="overdue">' : '' |n %><% $dueobj->AgeAsString || loc('Not set') %><% $overdue ? '</span>' : '' |n %></td>
170<td class="collection-as-table"><& /Elements/ShowUser, User => $Reminder->OwnerObj &></td>
171</tr>
172</%method>