Master to 4.2.8
[usit-rt.git] / share / html / Ticket / Elements / Reminders
CommitLineData
84fb5b46
MKG
1%# BEGIN BPS TAGGED BLOCK {{{
2%#
3%# COPYRIGHT:
4%#
320f0092 5%# This software is Copyright (c) 1996-2014 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
af59614d 53$ShowSave => 1
84fb5b46
MKG
54</%args>
55<%init>
56
57$Ticket = LoadTicket($id) if ($id);
af59614d 58my $resolve_status = $Ticket->LifecycleObj->ReminderStatusOnResolve;
84fb5b46
MKG
59
60my $count_reminders = RT::Reminders->new($session{'CurrentUser'});
61$count_reminders->Ticket($Ticket->id);
62my $count_tickets = $count_reminders->Collection;
63if (!$ShowCompleted) {
64 # XXX: don't break encapsulation if we can avoid it
b5747ff2 65 $count_tickets->FromSQL(q{Type = "reminder" AND RefersTo = "} . $Ticket->id . qq{" AND Status != "$resolve_status" });
84fb5b46
MKG
66}
67my $has_reminders = $count_tickets->Count;
68
69# We've made changes, let's reload our search
70my $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" />
af59614d 74% my $editable = 0;
84fb5b46
MKG
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;
84fb5b46
MKG
88% while ( my $reminder = $reminder_collection->Next ) {
89% $i++;
b5747ff2 90% if ( $reminder->Status eq $resolve_status && !$ShowCompleted ) {
84fb5b46
MKG
91<tr class="hidden"><td><input type="hidden" class="hidden" name="Complete-Reminder-<% $reminder->id %>" value="1" /></td></tr>
92% $i++;
af59614d
MKG
93% }
94% else {
95% $editable = 1 if !$editable && $reminder->CurrentUserHasRight( 'ModifyTicket' );
96% if ($Edit) {
84fb5b46 97<& SELF:EditEntry, Reminder => $reminder, Ticket => $Ticket, Index => $i &>
af59614d 98% } else {
84fb5b46 99<& SELF:ShowEntry, Reminder => $reminder, Ticket => $Ticket, Index => $i &>
af59614d 100% }
84fb5b46
MKG
101% }
102% }
103</table>
af59614d 104% if ( $editable ) {
84fb5b46
MKG
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 ) {
b5747ff2 112% if ( $reminder->Status eq $resolve_status && !$ShowCompleted ) {
84fb5b46
MKG
113<input type="hidden" class="hidden" name="Complete-Reminder-<% $reminder->id %>" value="1" />
114% }
115% }
116% }
117
af59614d 118% if (lc $Ticket->Status ne "deleted" and $Ticket->QueueObj->CurrentUserHasRight('CreateTicket') and $Ticket->CurrentUserHasRight('ModifyTicket') ) {
84fb5b46
MKG
119<&|/l&>New reminder:</&>
120<& SELF:NewReminder, Ticket => $Ticket &>
af59614d
MKG
121% $editable = 1;
122% }
123
124% if ( $editable && $ShowSave ) {
125<div align="right"><input type="submit" class="button" value="<&|/l&>Save</&>" /></div>
c36a7e1d 126% }
84fb5b46
MKG
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>
af59614d
MKG
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"
156value=<% $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') ) {
161disabled="disabled"
162% }
163/></td>
84fb5b46 164<td class="label"><&|/l&>Subject</&>:</td>
af59614d
MKG
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') ) {
168readonly="readonly"
169% }
170/>
171</td>
84fb5b46
MKG
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>
af59614d
MKG
178<td class="entry">
179% if ( $Reminder->CurrentUserHasRight('ModifyTicket') ) {
180<& /Elements/SelectDate, Name => 'Reminder-Due-'.$Reminder->id &>
181% }
182(<% $Reminder->DueObj->AsString %>)
183</td>
84fb5b46
MKG
184</tr>
185</%method>
186<%method ShowEntry>
187<%args>
188$Reminder
189$Ticket
190$Index
191</%args>
192% my $dueobj = $Reminder->DueObj;
c33a4027 193% my $overdue = $dueobj->IsSet && $dueobj->Diff < 0 ? 1 : 0;
af59614d
MKG
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"
199value=<% $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') ) {
203disabled="disabled"
204% }
205/></td>
206<td class="collection-as-table"><label for="Complete-Reminder-<% $Reminder->id %>"><% $Reminder->Subject %></label></td>
84fb5b46
MKG
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>