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