rt 4.0.23
[freeside.git] / rt / share / html / Ticket / Elements / BulkLinks
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2015 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 <table width="100%">
49   <tr>
50     <td valign="top" width="50%">
51       <h3><&|/l&>Current Links</&></h3>
52 <table>
53   <tr>
54     <td class="labeltop"><&|/l&>Depends on</&>:</td>
55     <td class="value">
56 % if ( $hash{DependsOn} ) {
57 % for my $link ( values %{$hash{DependsOn}} ) {
58       <input type="checkbox" class="checkbox" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
59         <& /Elements/ShowLink, URI => $link->TargetURI &><br />
60 % } }
61     </td>
62   </tr>
63   <tr>
64     <td class="labeltop"><&|/l&>Depended on by</&>:</td>
65     <td class="value">
66 % if ( $hash{DependedOnBy} ) {
67 % for my $link ( values %{$hash{DependedOnBy}} ) {
68       <input type="checkbox" class="checkbox" name="DeleteLink-<%$link->Base%>-<%$link->Type%>-" value="1" />
69         <& /Elements/ShowLink, URI => $link->BaseURI &><br />
70 % } }
71     </td>
72   </tr>
73   <tr>
74     <td class="labeltop"><&|/l&>Parents</&>:</td>
75     <td class="value">
76 % if ( $hash{MemberOf} ) {
77 % for my $link ( values %{$hash{MemberOf}} ) {
78       <input type="checkbox" class="checkbox" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
79         <& /Elements/ShowLink, URI => $link->TargetURI &><br />
80 % } }
81     </td>
82   </tr>
83   <tr>
84     <td class="labeltop"><&|/l&>Children</&>:</td>
85     <td class="value">
86 % if ( $hash{Members} ) {
87 % for my $link ( values %{$hash{Members}} ) {
88       <input type="checkbox" class="checkbox" name="DeleteLink-<%$link->Base%>-<%$link->Type%>-" value="1" />
89         <& /Elements/ShowLink, URI => $link->BaseURI &><br />
90 % } }
91     </td>
92   </tr>
93   <tr>
94     <td class="labeltop"><&|/l&>Refers to</&>:</td>
95     <td class="value">
96 % if ( $hash{RefersTo} ) {
97 % for my $link ( values %{$hash{RefersTo}} ) {
98       <input type="checkbox" class="checkbox" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
99         <& /Elements/ShowLink, URI => $link->TargetURI &><br />
100 % } }
101     </td>
102   </tr>
103   <tr>
104     <td class="labeltop"><&|/l&>Referred to by</&>:</td>
105     <td class="value">
106 % if ( $hash{ReferredToBy} ) {
107 % for my $link ( values %{$hash{ReferredToBy}} ) {
108 % # Skip reminders
109 % next if (UNIVERSAL::isa($link->BaseObj, 'RT::Ticket')  && $link->BaseObj->Type eq 'reminder');
110       <input type="checkbox" class="checkbox" name="DeleteLink-<%$link->Base%>-<%$link->Type%>-" value="1" />
111         <& /Elements/ShowLink, URI => $link->BaseURI &><br />
112 % } }
113     </td>
114   </tr>
115   <tr>
116     <td></td>
117     <td><i><&|/l&>(Check box to delete)</&></i></td>
118   </tr>
119 </table>
120 </td>
121 <td valign="top">
122 <h3><&|/l&>New Links</&></h3>
123 <i><&|/l&>Enter tickets or URIs to link tickets to. Separate multiple entries with spaces.</&>
124 </i><br />
125 <table>
126   <tr>
127     <td class="label"><&|/l&>Merge into</&>:</td>
128     <td class="entry"><input name="Ticket-MergeInto" value="<% $ARGS{'Ticket-MergeInto'} || '' %>" /> <i><&|/l&>(only one ticket)</&></i></td>
129   </tr>
130   <tr>
131     <td class="label"><&|/l&>Depends on</&>:</td>
132     <td class="entry"><input name="Ticket-DependsOn" value="<% $ARGS{'Ticket-DependsOn'} || '' %>" /></td>
133   </tr>
134   <tr>
135     <td class="label"><&|/l&>Depended on by</&>:</td>
136     <td class="entry"><input name="DependsOn-Ticket" value="<% $ARGS{'DependsOn-Ticket'} || '' %>" /></td>
137   </tr>
138   <tr>
139     <td class="label"><&|/l&>Parents</&>:</td>
140     <td class="entry"><input name="Ticket-MemberOf" value="<% $ARGS{'Ticket-MemberOf'} || '' %>" /></td>
141   </tr>
142   <tr>
143     <td class="label"><&|/l&>Children</&>:</td>
144     <td class="entry"> <input name="MemberOf-Ticket" value="<% $ARGS{'MemberOf-Ticket'} || '' %>" /></td>
145   </tr>
146   <tr>
147     <td class="label"><&|/l&>Refers to</&>:</td>
148     <td class="entry"><input name="Ticket-RefersTo" value="<% $ARGS{'Ticket-RefersTo'} || '' %>" /></td>
149   </tr>
150   <tr>
151     <td class="label"><&|/l&>Referred to by</&>:</td>
152     <td class="entry"> <input name="RefersTo-Ticket" value="<% $ARGS{'RefersTo-Ticket'} || '' %>" /></td>
153   </tr>
154 </table>
155 </td>
156 </tr>
157 </table>
158
159 <%ARGS>
160 $Tickets => undef
161 </%ARGS>
162
163 <%INIT>
164 my %hash;
165 if ( $Tickets && $Tickets->Count ) {
166     my $first_ticket = $Tickets->Next or last; #avoid errors on bulk delete
167     # we only show current links that eixst on all the tickets
168     for my $type ( qw/DependsOn DependedOnBy Members MemberOf RefersTo
169             ReferredToBy/ ) {
170         my $target_or_base =
171             $type =~ /DependsOn|MemberOf|RefersTo/ ? 'Target' : 'Base';
172         while ( my $link = $first_ticket->$type->Next ) {
173             $hash{$type}{$link->$target_or_base} = $link;
174         }
175     }
176
177     while ( my $ticket = $Tickets->Next ) {
178         for my $type ( qw/DependsOn DependedOnBy Members MemberOf RefersTo
179                 ReferredToBy/ ) {
180             my $target_or_base =
181                 $type =~ /DependsOn|MemberOf|RefersTo/ ? 'Target' : 'Base';
182             # if $hash{$type} is empty, no need to check any more
183             next unless $hash{$type} && keys %{$hash{$type}};
184             my %exists;
185             while ( my $link = $ticket->$type->Next ) {
186                 $exists{$link->$target_or_base}++;
187             }
188
189             for ( keys %{$hash{$type}} ) {
190                 delete $hash{$type}{$_} unless $exists{$_};
191             }
192         }
193     }
194 }
195 </%INIT>