import of rt 3.0.4
[freeside.git] / rt / html / Approvals / Elements / PendingMyApproval
1 %# BEGIN LICENSE BLOCK
2 %# 
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4 %# 
5 %# (Except where explictly superceded by other copyright notices)
6 %# 
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
10 %# from www.gnu.org.
11 %# 
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 %# General Public License for more details.
16 %# 
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
21 %# 
22 %# 
23 %# END LICENSE BLOCK
24 <table width="100%">
25 % my ($i, $class);
26 % my %done;
27 % foreach ($tickets, $group_tickets) {
28 %   while (my $ticket = $_->Next() ) {
29 %     next if !$ARGS{'ShowDependent'} and $ticket->HasUnresolvedDependencies( Type => 'approval' );
30 %     next if $done{$ticket->Id}++; # don't show duplicate tickets
31 %     $i++; 
32 %     $class = ($i%2) ?  "oddline" : "evenline";
33 <& Approve, ticket => $ticket, class => $class &>
34 %   }
35 % }
36 </table>
37
38 <& /Elements/TitleBoxStart, title => loc("Search for approvals") &>
39 <input type=checkbox value="1" name="ShowPending"
40         <%((!$ARGS{'ShowRejected'} && !$ARGS{'ShowResolved'}) ||
41          $ARGS{'ShowPending'})
42         && "checked"%>> <&|/l&>Show pending requests</&><br>
43 <input type=checkbox value="1" name="ShowResolved" <%$ARGS{'ShowResolved'} && "checked"%>> <&|/l&>Show approved requests</&><br>
44 <input type=checkbox value="1" name="ShowRejected" <%$ARGS{'ShowRejected'} && "checked"%>> <&|/l&>Show denied requests</&><br>
45 <input type=checkbox value="1" name="ShowDependent" <%$ARGS{'ShowDependent'} && "checked"%>> <&|/l&>Show requests awaiting other approvals</&><br>
46
47 <&|/l,"<input size='15' value='".($created_before->Unix > 0 &&$created_before->ISO)."' name='CreatedBefore'>"&>Only show approvals for requests created before [_1]</&><br>
48
49 <&|/l, "<input size='15' value='".( $created_after->Unix >0 && $created_after->ISO)."' name='CreatedAfter'>"&>Only show approvals for requests created after [_1]</&>
50 <& /Elements/TitleBoxEnd &>
51
52 <%init>
53 my $tickets = RT::Tickets->new( $session{'CurrentUser'} );
54 $tickets->LimitOwner( VALUE => $session{'CurrentUser'}->Id );
55
56 # also consider AdminCcs as potential approvers.
57 my $group_tickets = RT::Tickets->new( $session{'CurrentUser'} );
58
59 my $created_before = RT::Date->new( $session{'CurrentUser'} );
60 my $created_after = RT::Date->new( $session{'CurrentUser'} );
61
62 foreach ($tickets, $group_tickets) {
63     $_->Limit( FIELD      => 'Type', VALUE => 'approval' );
64
65     if ( $ARGS{'ShowResolved'} ) {
66         $_->LimitStatus( VALUE => 'resolved' );
67     }
68     if ( $ARGS{'ShowRejected'} ) {
69         $_->LimitStatus( VALUE => 'rejected' );
70     }
71     if ( $ARGS{'ShowPending'} || ( !$ARGS{'ShowRejected'} && !$ARGS{'Resolved'} ) ) {
72         $_->LimitStatus( VALUE => 'open' );
73         $_->LimitStatus( VALUE => 'new' );
74         $_->LimitStatus( VALUE => 'stalled' );
75     }
76
77     if ( $ARGS{'CreatedBefore'} ) {
78         $created_before->Set( Format => 'unknown', Value => $ARGS{'CreatedBefore'} );
79         $_->LimitCreated( OPERATOR => "<=", VALUE => $created_before->ISO );
80     }
81     if ( $ARGS{'CreatedAfter'} ) {
82         $created_after->Set( Format => 'unknown', Value => $ARGS{'CreatedAfter'} );
83         $_->LimitCreated( OPERATOR => ">=", VALUE => $created_after->ISO );
84     }
85 }
86
87 </%init>