import of rt 3.0.4
[freeside.git] / rt / html / Approvals / Elements / ShowDependency
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 % my $approving = $Ticket->DependedOnBy();
25 % if ($approving->Count) {
26 <h3><&|/l&>Tickets which depend on this approval:</&></h3>
27
28 <table width=100%>
29 <TR>
30 <TD WIDTH="25" bgcolor="#999999">&nbsp;</TD><TD>
31 <%PERL>
32 my %show;
33 while (my $link = $approving->Next()) {
34     next unless ($link->BaseURI->IsLocal());
35     my $text = '<a name="' . $link->BaseObj->Id . '">';
36     my $head = '';
37     my $type = $link->BaseObj->Type;
38     my $dep  = $m->scomp('ShowDependency', Ticket => $link->BaseObj, _seen => $_seen);
39
40     if ($type eq 'approval') {
41         $head .= $m->scomp('/Elements/TitleBoxStart', title => loc("Approval #[_1]: [_2]", $link->BaseObj->Id, $link->BaseObj->Subject));
42         $text .= $head;
43         $text .= $m->scomp('/Ticket/Elements/ShowCustomFields', Ticket => $link->BaseObj);
44     } elsif ($type eq 'ticket') {
45         $head .= $m->scomp('/Elements/TitleBoxStart', title => loc("Ticket #[_1]: [_2]", $link->BaseObj->Id, $link->BaseObj->Subject));
46         $text .= $head;
47         $text .= $m->scomp('/Ticket/Elements/ShowSummary', Ticket => $link->BaseObj);
48     } else {
49         $head .= $m->scomp('/Elements/TitleBoxStart', title => loc("#[_1]: [_2]", $link->BaseObj->Id, $link->BaseObj->Subject));
50         $text .= $head;
51     }
52
53     $text .= $m->scomp('/Ticket/Elements/ShowHistory' , Ticket => $link->BaseObj, Collapsed => ($type ne 'ticket'), ShowTitle => 0, ShowHeaders => 0, ShowDisplayModes => 0, ShowTitleBarCommands => 0);
54
55     $head .= $m->scomp('/Elements/TitleBoxEnd');
56     $text .= $m->scomp('/Elements/TitleBoxEnd');
57     $text .= $dep;
58     $text .= '</a>';
59     $show{$link->BaseObj->Id} = {
60         text => $text,
61         head => $head,
62     };
63 }
64
65 my $refer;
66 foreach my $id (sort keys %show) {
67     if ($_seen->{$id}++) {
68         $refer .= "<a href='#txn-$id'>" . $show{$id}{head} . "</a>";
69         next;
70     }
71
72     $m->print($show{$id}{text});
73 }
74 $m->print($refer);
75
76 </%PERL>
77 </TD>
78 </TR>
79 </TABLE>
80
81 % }
82 <%ARGS>
83 $Ticket
84 $_seen => {}
85 </%ARGS>