3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 %# (Except where explictly superceded by other copyright notices)
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
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.
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.
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
32 % $class = ($i%2) ? "oddline" : "evenline";
33 <& Approve, ticket => $ticket, class => $class &>
38 <& /Elements/TitleBoxStart, title => loc("Search for approvals") &>
39 <input type=checkbox value="1" name="ShowPending"
40 <%((!$ARGS{'ShowRejected'} && !$ARGS{'ShowResolved'}) ||
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>
47 <&|/l,"<input size='15' value='".($created_before->Unix > 0 &&$created_before->ISO)."' name='CreatedBefore'>"&>Only show approvals for requests created before [_1]</&><br>
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 &>
53 my $tickets = RT::Tickets->new( $session{'CurrentUser'} );
54 $tickets->LimitOwner( VALUE => $session{'CurrentUser'}->Id );
56 # also consider AdminCcs as potential approvers.
57 my $group_tickets = RT::Tickets->new( $session{'CurrentUser'} );
59 my $created_before = RT::Date->new( $session{'CurrentUser'} );
60 my $created_after = RT::Date->new( $session{'CurrentUser'} );
62 foreach ($tickets, $group_tickets) {
63 $_->Limit( FIELD => 'Type', VALUE => 'approval' );
65 if ( $ARGS{'ShowResolved'} ) {
66 $_->LimitStatus( VALUE => 'resolved' );
68 if ( $ARGS{'ShowRejected'} ) {
69 $_->LimitStatus( VALUE => 'rejected' );
71 if ( $ARGS{'ShowPending'} || ( !$ARGS{'ShowRejected'} && !$ARGS{'Resolved'} ) ) {
72 $_->LimitStatus( VALUE => 'open' );
73 $_->LimitStatus( VALUE => 'new' );
74 $_->LimitStatus( VALUE => 'stalled' );
77 if ( $ARGS{'CreatedBefore'} ) {
78 $created_before->Set( Format => 'unknown', Value => $ARGS{'CreatedBefore'} );
79 $_->LimitCreated( OPERATOR => "<=", VALUE => $created_before->ISO );
81 if ( $ARGS{'CreatedAfter'} ) {
82 $created_after->Set( Format => 'unknown', Value => $ARGS{'CreatedAfter'} );
83 $_->LimitCreated( OPERATOR => ">=", VALUE => $created_after->ISO );