import rt 3.8.11
[freeside.git] / rt / 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::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 </div>
119 <div>
120 <h3><&|/l&>New reminder:</&></h3>
121 <& SELF:NewReminder, Ticket => $Ticket &>
122 <%method NewReminder>
123 <%args>
124 $Ticket
125 </%args>
126 <div class="input-row">
127 <label class="horizontal" for="NewReminder-Subject" ><&|/l&>Subject</&>:</label> 
128 <input type="text" size="15" name="NewReminder-Subject" />
129 </div>
130 <div class="input-row">
131 <label class="horizontal" for="NewReminder-Owner" ><&|/l&>Owner</&>:</label> 
132 <& /Elements/SelectOwner, Name => 'NewReminder-Owner', QueueObj => $Ticket->QueueObj, DefaultValue => 0 &>
133 </div>
134 <div class="input-row">
135 <label class="horizontal" for="NewReminder-Due" ><&|/l&>Due</&> <&|/l&>(yyyy/mm/dd)</&>:</label> 
136 <& /Elements/SelectDate, Name => "NewReminder-Due", Default => "" &>
137 </div>
138 </div>
139 </%method>
140 <%method EditEntry>
141 <%args>
142 $Reminder
143 $Ticket
144 </%args>
145 <input
146     type="checkbox" 
147     name="Complete-Reminder-<%$Reminder->id%>" 
148     <% $Reminder->Status eq 'resolved' ? 'CHECKED' : '' %> 
149 /> 
150     <input type="text" size="15" name="Reminder-Subject-<% $Reminder->id %>" value="<%$Reminder->Subject%>" /> &bull; 
151     <& /Elements/SelectOwner, Name => 'Reminder-Owner-'.$Reminder->id, Queue => $Ticket->QueueObj, Default => $Reminder->Owner, DefaultValue => 0  &>
152     <& /Elements/SelectDate, Name => 'Reminder-Due-'.$Reminder->id, Default => $Reminder->DueObj->Date &>
153     (<%$Reminder->DueObj->Unix>0  ? $Reminder->DueObj->AgeAsString : '' %>)<br />
154 </%method>
155 <%method ShowEntry>
156 <%args>
157 $Reminder
158 $Ticket
159 </%args>
160 <input
161     type="checkbox" 
162     name="Complete-Reminder-<%$Reminder->id%>" 
163     <% $Reminder->Status eq 'resolved' ? 'CHECKED' : '' %> 
164 /> 
165     <%$Reminder->Subject%> &bull; 
166     <%$Reminder->OwnerObj->Name%>
167     <%$Reminder->DueObj->Unix>0  ? "&bull; ". $Reminder->DueObj->AgeAsString : '' |n%><br />
168 </%method>