import rt 3.8.9
[freeside.git] / rt / share / html / Ticket / Elements / Reminders
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2011 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 $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 </div>
126 <%method NewReminder>
127 <%args>
128 $Ticket
129 </%args>
130 <table>
131 <tr class="input-row">
132 <td class="label"><label class="horizontal" for="NewReminder-Subject" ><&|/l&>Subject</&>:</label></td>
133 <td class="value">
134 <input type="text" size="15" name="NewReminder-Subject" id="NewReminder-Subject" />
135 </td>
136 </tr>
137 <tr class="input-row">
138 <td class="label">
139 <label class="horizontal" for="NewReminder-Owner" ><&|/l&>Owner</&>:</label></td><td class="value">
140 <& /Elements/SelectOwner, Name => 'NewReminder-Owner', QueueObj => $Ticket->QueueObj, Default=>$session{'CurrentUser'}->id, DefaultValue => 0 &>
141 </td>
142 </tr>
143 <tr class="input-row">
144 <td class="label"><label class="horizontal" for="NewReminder-Due" ><&|/l&>Due</&>:</label></td>
145 <td class="value">
146 <& /Elements/SelectDate, Name => "NewReminder-Due", Default => "" &>
147 </td>
148 </tr>
149 </table>
150 </%method>
151 <%method EditEntry>
152 <%args>
153 $Reminder
154 $Ticket
155 </%args>
156 <input
157     type="checkbox" 
158     name="Complete-Reminder-<%$Reminder->id%>" 
159     <% $Reminder->Status eq 'resolved' ? 'checked="checked"' : '' %> 
160 /> 
161     <input type="text" size="15" name="Reminder-Subject-<% $Reminder->id %>" value="<%$Reminder->Subject%>" /> &bull; 
162     <& /Elements/SelectOwner, Name => 'Reminder-Owner-'.$Reminder->id, Queue => $Ticket->QueueObj, Default => $Reminder->Owner, DefaultValue => 0  &>
163     <& /Elements/SelectDate, Name => 'Reminder-Due-'.$Reminder->id, Default => $Reminder->DueObj->Date &>
164     (<%$Reminder->DueObj->Unix>0  ? $Reminder->DueObj->AgeAsString : '' %>)<br />
165 </%method>
166 <%method ShowEntry>
167 <%args>
168 $Reminder
169 $Ticket
170 </%args>
171 <input
172     type="checkbox" 
173     name="Complete-Reminder-<%$Reminder->id%>" 
174     <% $Reminder->Status eq 'resolved' ? 'checked="checked"' : '' %> 
175 /> 
176     <%$Reminder->Subject%> &bull; 
177     <& /Elements/ShowUser, User => $Reminder->OwnerObj &>
178     <%$Reminder->DueObj->Unix>0  ? "&bull; ". $Reminder->DueObj->AgeAsString : '' |n%><br />
179 </%method>