I thought I would share a little piece of code that I pulled together to create a VNC file based on a Freetext field to assist an agent in gaining remote access to a machine. Using version 2.4 for the moment, haven't got into 3 yet. Couple of things that need to be setup first:
- You need to have a freetext field as 'PC Name' or 'Equipment Name' and of course have it setup for entry at ticket creation. --->
ZZZAuto.pm
################################################
Code: Select all
$Self->{'TicketFreeKey3'} = {
'Equipment Name/PC Name' => 'Equipment Name/PC Name'
};
$Self->{'Ticket::Frontend::AgentTicketCompose'}->{'TicketFreeText'} = {
'1' => '1',
'10' => '0',
'11' => '0',
'12' => '0',
'13' => '0',
'14' => '0',
'15' => '0',
'16' => '0',
'2' => '1',
'3' => '1',
'4' => '0',
'5' => '0',
'6' => '0',
'7' => '0',
'8' => '0',
'9' => '0'
};
<---- Notice I'm using TicketFreeText3
- Next, you will need to create a download Perl script to generate the VNC file. I'm no Perl programmer, I just found allot of this floating around the net. I'm open to suggestions ---->
vnc.pl
#########################################
Code: Select all
#!c:/strawberry/perl/bin/perl -w
# -- who wherever your perl exec is
use POSIX;
use CGI;
#Directory where the text file will be created.
$directory = 'C:/OTRS/OTRS/var/tmp';
$pc_name = $ARGV[$0];
if (!(-d "$directory")) { #check if directory exists - returns true if doesn't exist.
printf "No directory\n", $? >> 8;
exit (1); #exit because directory doesn't exist.
}
#Dynamic file name, this does not get cleaned up so someone may want to find a easy way of cleaning
#up old VNC files
my $filename=strftime("vnc_%y%M%d.vnc", localtime);
open(FILE, ">$directory/$filename") || die("Couldn't open file");
print FILE "[connection]\nhost=$pc_name\nport=5900";
close(FILE);
my $q = CGI->new;
# Uncomment the next line only for debugging the script
open(my $DLFILE, '<', "$directory/$filename") or die "Can't open file '$directory/$filename' : $!";
# Comment the next line if you uncomment the above line
#open(my $DLFILE, '<', "$directory/$filename") or return(0);
# This prints the download headers with the file size included
# so you get a progress bar in the dialog box that displays during file downlaods.
print $q->header(-type => 'application/x-download',
-attachment => $filename,
'Content-length' => -s "$directory/$filename",
);
binmode $DLFILE;
print while <$DLFILE>;
undef ($DLFILE);
return(1);
exit(0);
------> I put this file in /bin/cgi-bin with index.pl and such.
- Lastly, update your layout to create a link and to pass the freetext field to the perl script. ----->
OTRS/Kernel/Output/HTML/TemplateYourUsing/AgentTicketZoom.dtl
##########################################################
<!-- dtl:block:TicketFreeText3 -->
<tr valign="top">
<td><b>VNC:</b></td>
<td>
<!-- dtl:block:TicketFreeTextPlain3 -->
<div title="Click Here"><a href="http://servername/otrs/vnc.pl?$QData{"TicketFreeText3"}" target="_blank">Click Here</a></div>
<!-- dtl:block:TicketFreeTextPlain3 -->
</td>
</tr>
<!-- dtl:block:TicketFreeText3 -->
###########################################################
--------> That's IT!
I did have a problem where I wanted to display the FreeTextField, and the VNC link at the same time. This took modifying AgentTickeZoom.pm ------->
OTRS/Kernel/Modules/AgentTicketZoom.pm
############################################################
# ticket free text
for my $Count ( 1 .. 16 ) {
if ( $Param{ 'TicketFreeText' . $Count } ) {
$Self->{LayoutObject}->Block(
Name => 'TicketFreeText' . $Count,
Data => { %Param, %AclAction },
);
$Self->{LayoutObject}->Block(
Name => 'TicketFreeText',
Data => {
%Param, %AclAction,
TicketFreeKey => $Param{ 'TicketFreeKey' . $Count },
TicketFreeText => $Param{ 'TicketFreeText' . $Count },
Count => $Count,
},
);
if ( !$Self->{ConfigObject}->Get( 'TicketFreeText' . $Count . '::Link' ) ) {
$Self->{LayoutObject}->Block(
Name => 'TicketFreeTextPlain' . $Count,
Data => { %Param, %AclAction },
);
$Self->{LayoutObject}->Block(
Name => 'TicketFreeTextPlain',
Data => {
%Param, %AclAction,
TicketFreeKey => $Param{ 'TicketFreeKey' . $Count },
TicketFreeText => $Param{ 'TicketFreeText' . $Count },
Count => $Count,
},
);
}
else {
$Self->{LayoutObject}->Block(
Name => 'TicketFreeTextLink' . $Count,
Data => { %Param, %AclAction },
);
$Self->{LayoutObject}->Block(
Name => 'TicketFreeTextLink',
Data => {
%Param, %AclAction,
TicketFreeTextLink => $Self->{ConfigObject}->Get(
'TicketFreeText' . $Count . '::Link'
),
TicketFreeKey => $Param{ 'TicketFreeKey' . $Count },
TicketFreeText => $Param{ 'TicketFreeText' . $Count },
Count => $Count,
},
);
}
}
}
#VNC ticket free text fields
#Custom added by Me
for my $Count ( 1 .. 16 ) {
if ( $Param{ 'TicketFreeText' . $Count } ) {
$Self->{LayoutObject}->Block(
Name => 'TicketFreeText_VNC' . $Count,
Data => { %Param, %AclAction },
);
$Self->{LayoutObject}->Block(
Name => 'TicketFreeText_VNC',
Data => {
%Param, %AclAction,
TicketFreeKey => $Param{ 'TicketFreeKey' . $Count },
TicketFreeText => $Param{ 'TicketFreeText' . $Count },
Count => $Count,
},
);
if ( !$Self->{ConfigObject}->Get( 'TicketFreeText' . $Count . '::Link' ) ) {
$Self->{LayoutObject}->Block(
Name => 'TicketFreeTextPlain_VNC' . $Count,
Data => { %Param, %AclAction },
);
$Self->{LayoutObject}->Block(
Name => 'TicketFreeTextPlain_VNC',
Data => {
%Param, %AclAction,
TicketFreeKey => $Param{ 'TicketFreeKey' . $Count },
TicketFreeText => $Param{ 'TicketFreeText' . $Count },
Count => $Count,
},
);
}
else {
$Self->{LayoutObject}->Block(
Name => 'TicketFreeTextLink' . $Count,
Data => { %Param, %AclAction },
);
$Self->{LayoutObject}->Block(
Name => 'TicketFreeTextLink_VNC',
Data => {
%Param, %AclAction,
TicketFreeTextLink => $Self->{ConfigObject}->Get(
'TicketFreeText' . $Count . '::Link'
),
TicketFreeKey => $Param{ 'TicketFreeKey' . $Count },
TicketFreeText => $Param{ 'TicketFreeText' . $Count },
Count => $Count,
},
);
}
}
}
###################################################################################
And then your .dtl file would look like this ---->
################################################################################
<!-- dtl:block:TicketFreeText_VNC3 -->
<tr valign="top">
<td><b>VNC:</b></td>
<td>
<!-- dtl:block:TicketFreeTextPlain_VNC3 -->
<div title="Click Here"><a href="http://servername/otrs/vnc.pl?$QData{"TicketFreeText3"}" target="_blank">Click Here</a></div>
<!-- dtl:block:TicketFreeTextPlain_VNC3 -->
</td>
</tr>
<!-- dtl:block:TicketFreeText_VNC3 -->
#############################################################################
Enjoy!