This commit was generated by cvs2svn to compensate for changes in r8690,
[freeside.git] / rt / share / html / Ticket / Elements / Reminders
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %# 
5 %# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
6 %#                                          <jesse@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 $request_args = $m->request_args();
59
60 my $reminder_collection = $Ticket->Reminders->Collection;
61
62 if ( $request_args->{'update-reminders'} ) {
63     while ( my $reminder = $reminder_collection->Next ) {
64         if (   $reminder->Status ne 'resolved' && $request_args->{ 'Complete-Reminder-' . $reminder->id } ) {
65             $Ticket->Reminders->Resolve($reminder);
66         }
67         elsif ( $reminder->Status eq 'resolved' && !$request_args->{ 'Complete-Reminder-' . $reminder->id } ) {
68             $Ticket->Reminders->Open($reminder);
69         }
70
71         if ( exists( $request_args->{ 'Reminder-Subject-' . $reminder->id } ) && ( $reminder->Subject ne $request_args->{ 'Reminder-Subject-' . $reminder->id } )) {
72             $reminder->SetSubject( $request_args->{ 'Reminder-Subject-' . $reminder->id } ) ;
73         }
74
75         if ( exists( $request_args->{ 'Reminder-Owner-' . $reminder->id } ) && ( $reminder->Owner != $request_args->{ 'Reminder-Owner-' . $reminder->id } )) {
76             $reminder->SetOwner( $request_args->{ 'Reminder-Owner-' . $reminder->id } , "Force" ) ;
77         }
78
79         if ( exists( $request_args->{ 'Reminder-Due-' . $reminder->id } ) && ( $reminder->DueObj->Date ne $request_args->{ 'Reminder-Due-' . $reminder->id } )) {
80             $reminder->SetDue( $request_args->{ 'Reminder-Due-' . $reminder->id } ) ;
81         }
82     }
83 }
84
85 if ( $request_args->{'NewReminder-Subject'} ) {
86     my $due_obj = RT::Date->new( $session{'CurrentUser'} );
87     my $date    = Time::ParseDate::parsedate(
88         $request_args->{'NewReminder-Due'},
89         UK            => RT->Config->Get('DateDayBeforeMonth'),
90         PREFER_PAST   => 0,
91         PREFER_FUTURE => 1
92     );
93     $due_obj->Set( Value => $date, Format => 'unix' );
94     my ( $add_id, $msg, $txnid ) = $Ticket->Reminders->Add(
95
96         Subject => $request_args->{'NewReminder-Subject'},
97         Owner   => $request_args->{'NewReminder-Owner'},
98         Due     => $due_obj->ISO
99     );
100 }
101
102 # We've made changes, let's reload our search
103
104 $reminder_collection = $Ticket->Reminders->Collection;
105 </%init>
106 <input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
107 <input type="hidden" class="hidden" name="update-reminders" value="1" />
108 <div>
109 % while (my $reminder = $reminder_collection->Next) {
110 %   if ($reminder->Status eq 'resolved' && !$ShowCompleted) {
111 <input type="hidden" class="hidden" name="Complete-Reminder-<% $reminder->id %>" value="1" />
112 %   } elsif ($Edit) {
113 <& SELF:EditEntry, Reminder => $reminder, Ticket => $Ticket &>
114 %   } else {
115 <& SELF:ShowEntry, Reminder => $reminder, Ticket => $Ticket &>
116 %   }
117 % }
118 % if ($reminder_collection->Count) {
119 <i><&|/l&>(Check box to delete)</&></i><br /><br />
120 % }
121 </div>
122 <div>
123 <&|/l&>New reminder:</&>
124 <& SELF:NewReminder, Ticket => $Ticket &>
125 <%method NewReminder>
126 <%args>
127 $Ticket
128 </%args>
129 <table>
130 <tr class="input-row">
131 <td class="label"><label class="horizontal" for="NewReminder-Subject" ><&|/l&>Subject</&>:</label></td>
132 <td class="value">
133 <input type="text" size="15" name="NewReminder-Subject" id="NewReminder-Subject" />
134 </td>
135 </tr>
136 <tr class="input-row">
137 <td class="label">
138 <label class="horizontal" for="NewReminder-Owner" ><&|/l&>Owner</&>:</label></td><td class="value">
139 <& /Elements/SelectOwner, Name => 'NewReminder-Owner', QueueObj => $Ticket->QueueObj, Default=>$session{'CurrentUser'}->id, DefaultValue => 0 &>
140 </td>
141 </tr>
142 <tr class="input-row">
143 <td class="label"><label class="horizontal" for="NewReminder-Due" ><&|/l&>Due</&>:</label></td>
144 <td class="value">
145 <& /Elements/SelectDate, Name => "NewReminder-Due", Default => "" &>
146 </td>
147 </tr>
148 </table>
149 </%method>
150 <%method EditEntry>
151 <%args>
152 $Reminder
153 $Ticket
154 </%args>
155 <input
156     type="checkbox" 
157     name="Complete-Reminder-<%$Reminder->id%>" 
158     <% $Reminder->Status eq 'resolved' ? 'checked="checked"' : '' %> 
159 /> 
160     <input type="text" size="15" name="Reminder-Subject-<% $Reminder->id %>" value="<%$Reminder->Subject%>" /> &bull; 
161     <& /Elements/SelectOwner, Name => 'Reminder-Owner-'.$Reminder->id, Queue => $Ticket->QueueObj, Default => $Reminder->Owner, DefaultValue => 0  &>
162     <& /Elements/SelectDate, Name => 'Reminder-Due-'.$Reminder->id, Default => $Reminder->DueObj->Date &>
163     (<%$Reminder->DueObj->Unix>0  ? $Reminder->DueObj->AgeAsString : '' %>)<br />
164 </%method>
165 <%method ShowEntry>
166 <%args>
167 $Reminder
168 $Ticket
169 </%args>
170 <input
171     type="checkbox" 
172     name="Complete-Reminder-<%$Reminder->id%>" 
173     <% $Reminder->Status eq 'resolved' ? 'checked="checked"' : '' %> 
174 /> 
175     <%$Reminder->Subject%> &bull; 
176     <%$Reminder->OwnerObj->Name%>
177     <%$Reminder->DueObj->Unix>0  ? "&bull; ". $Reminder->DueObj->AgeAsString : '' |n%><br />
178 </%method>