Dev -> 4.0.6. Clean upgrade from 4.0.5-5.
[usit-rt.git] / share / html / Ticket / Elements / Reminders
CommitLineData
84fb5b46
MKG
1%# BEGIN BPS TAGGED BLOCK {{{
2%#
3%# COPYRIGHT:
4%#
5%# This software is Copyright (c) 1996-2012 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</%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;
70</%init>
71<input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
72<input type="hidden" class="hidden" name="update-reminders" value="1" />
73% if ($has_reminders) {
74<table border="0" cellpadding="1" cellspacing="0" class="collection-as-table"<% $Edit ? ' style="width: auto;"' : '' |n %>>
75<tr>
76% if ( $Edit ) {
77<th class="collection-as-table" colspan="5"><&|/l&>Reminders</&></th>
78% } else {
79<th class="collection-as-table"></th>
80<th class="collection-as-table"><&|/l&>Reminder</&></th>
81<th class="collection-as-table"><&|/l&>Due</&></th>
82<th class="collection-as-table"><&|/l&>Owner</&></th>
83% }
84</tr>
85% my $i = 0;
86% my $visible = 0;
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
115<&|/l&>New reminder:</&>
116<& SELF:NewReminder, Ticket => $Ticket &>
117<%method NewReminder>
118<%args>
119$Ticket
120</%args>
121<table>
122<tr>
123<td class="label"><&|/l&>Subject</&>:</td>
124<td class="entry" colspan="3"><input type="text" size="50" name="NewReminder-Subject" id="NewReminder-Subject" /></td>
125</tr>
126<tr>
127<td class="label"><&|/l&>Owner</&>:</td>
128<td class="entry"><& /Elements/SelectOwner, Name => 'NewReminder-Owner', QueueObj => $Ticket->QueueObj, Default=>$session{'CurrentUser'}->id, DefaultValue => 0 &></td>
129</tr>
130<tr>
131<td class="label"><&|/l&>Due</&>:</td>
132<td class="entry"><& /Elements/SelectDate, Name => "NewReminder-Due", Default => "" &></td>
133</tr>
134</table>
135</%method>
136<%method EditEntry>
137<%args>
138$Reminder
139$Ticket
140$Index
141</%args>
142<tr class="<% $Index%2 ? 'oddline' : 'evenline' %>">
b5747ff2 143<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
144<td class="label"><&|/l&>Subject</&>:</td>
145<td class="entry" colspan="3"><input type="text" size="50" name="Reminder-Subject-<% $Reminder->id %>" value="<% $Reminder->Subject %>" /></td>
146</tr>
147<tr class="<% $Index%2 ? 'oddline' : 'evenline' %>">
148<td class="entry">&nbsp;</td>
149<td class="label"><&|/l&>Owner</&>:</td>
150<td class="entry"><& /Elements/SelectOwner, Name => 'Reminder-Owner-'.$Reminder->id, QueueObj => $Ticket->QueueObj, Default => $Reminder->Owner, DefaultValue => 0 &></td>
151<td class="label"><&|/l&>Due</&>:</td>
152<td class="entry"><& /Elements/SelectDate, Name => 'Reminder-Due-'.$Reminder->id &> (<% $Reminder->DueObj->AsString %>)</td>
153</tr>
154</%method>
155<%method ShowEntry>
156<%args>
157$Reminder
158$Ticket
159$Index
160</%args>
161% my $dueobj = $Reminder->DueObj;
162% my $overdue = $dueobj->Unix > 0 && $dueobj->Diff < 0 ? 1 : 0;
163<tr class="<% $Index%2 ? 'oddline' : 'evenline' %>">
b5747ff2 164<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
165<td class="collection-as-table"><% $Reminder->Subject %></td>
166<td class="collection-as-table"><% $overdue ? '<span class="overdue">' : '' |n %><% $dueobj->AgeAsString || loc('Not set') %><% $overdue ? '</span>' : '' |n %></td>
167<td class="collection-as-table"><& /Elements/ShowUser, User => $Reminder->OwnerObj &></td>
168</tr>
169</%method>