1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
% if ($Assets and $Assets->Count and $ShowFind) {
<p><&|/l&>Add new links to Assets</&>:<br>
<table>
<tr><td>
<&|/l&>Type</&>
</td><td>
<&|/l&>Asset</&>
</td></tr>
% while (my $a = $Assets->Next ) {
<tr><td>
% if ($TicketLinkTypes) {
<&/AssetTracker/Elements/SelectTicketLinkType, Name => "AddLink-Asset-".$a->URI &>
% } else {
<&/AssetTracker/Elements/SelectLinkType, Name => "AddLink-Asset-".$a->URI &>
% }
</td><td>
<a href="<%RT->Config->Get('WebPath')%>/AssetTracker/Asset/Display.html?id=<%$a->Id%>"><%$a->Name%></a>
(<% substr($a->Description,0,35) %>)</td></tr>
% }
</table>
% }
% if (!$SearchOnly) {
<p><&|/l&>Add new links to</&>:<br>
<table>
<tr><td>
<&|/l&>Type</&>
</td><td>
<&|/l&>URI</&>
</td></tr>
<tr><td><&/AssetTracker/Elements/SelectLinkType, Name => "AddLink-Other" &></td> <td><input Name="AddLink-Other-URI"></td></tr>
</table>
% }
<%init>
my ($Assets);
if ($AssetString) {
$Assets = RTx::AssetTracker::Assets->new($session{'CurrentUser'});
if ( $AssetField eq 'Type' ) {
my $Types = RTx::AssetTracker::Types->new($session{'CurrentUser'});
$Types->Limit(FIELD => 'Name', OPERATOR => $AssetOp, VALUE => $AssetString);
while (my $type = $Types->Next) {
$Assets->Limit(FIELD => 'Type', VALUE => $type->Id) if $type->Id;
}
}
elsif (($AssetField eq 'Name') or ($AssetField eq 'Description') or ($AssetField eq 'Status') ) {
$Assets->Limit(FIELD => $AssetField, VALUE => $AssetString, OPERATOR => $AssetOp);
}
else {
$Assets->LimitCustomField(CUSTOMFIELD => $AssetField, VALUE => $AssetString, OPERATOR => $AssetOp );
}
$Assets->Limit(FIELD => 'Status', VALUE => 'retired', OPERATOR => '!=') unless $AllowRetired;
#eliminate the assets own id
$Assets->Limit(FIELD => 'id', VALUE => $AssetObj->Id, OPERATOR => '!=') if ref $AssetObj;
}
</%init>
<%ARGS>
$AssetField => 'Name'
$AssetOp => '='
$AssetString => undef
$AllowRetired => 0
$AssetObj => undef
$ShowFind => 1
$SearchOnly => 0
$TicketLinkTypes => 0
</%ARGS>
|