I wish create a bouton link to a perl method in my perl module in the template.
Thanks in advance!!!
how to create a bouton link to a perl method in template
Moderator: crythias
-
- Znuny guru
- Posts: 5018
- Joined: 13 Mar 2011, 09:54
- Znuny Version: 6.0.x
- Real Name: Renée Bäcker
- Company: Perl-Services.de
- Contact:
Re: how to create a bouton link to a perl method in template
Can you describe more detailed what you want to achieve? Where should be the button (which page, where on that page)? Is your module an OTRS frontend module?
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Re: how to create a bouton link to a perl method in template
I want add this button on the action bar on the template Agent Ticket Zoom for change the owner for a specific owner. I have already a functional script for the task:
Code: Select all
#get queue name
my $QueueID = $TicketObject->TicketQueueID(
TicketID => $Param{TicketID},
);
my $Queue = $QueueObject->QueueLookup(
QueueID => $QueueID
);
#get level 1 user
my $RoleID = $GroupObject->RoleLookup(
Role => "assistant $Queue niveau 2",
);
my %User = $GroupObject->PermissionRoleUserGet(
RoleID => $RoleID
);
my $UserLevelOne = (values %User)[0];
#change ticketOwner
my $Success = $TicketObject->TicketOwnerSet(
TicketID => $Param{TicketID},
NewUser => $UserLevelOne,
UserID => $OwnerID,
);
-
- Znuny guru
- Posts: 5018
- Joined: 13 Mar 2011, 09:54
- Znuny Version: 6.0.x
- Real Name: Renée Bäcker
- Company: Perl-Services.de
- Contact:
Re: how to create a bouton link to a perl method in template
You need those files (replace the MySetOwner with a name you choose, e.g. ):
* Kernel/Config/Files/MySetOwner.xml
* Kernel/Modules/AgentTicketMySetOwner.pm
The config file is needed to create the "button" in the ticket menu.
Then the frontend module:
After copying those files (but don't forget to copy those files on an OTRS upgrade) run
Maybe this helps.
* Kernel/Config/Files/MySetOwner.xml
* Kernel/Modules/AgentTicketMySetOwner.pm
The config file is needed to create the "button" in the ticket menu.
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<otrs_config version="2.0" init="Config">
<Setting Name="Ticket::Frontend::MenuModule###101-SetOwner" Required="0" Valid="1">
<Description Translatable="1">Shows a link in the menu to set the level1 owner</Description>
<Navigation>Frontend::Agent::View::TicketZoom::MenuModule</Navigation>
<Value>
<Hash>
<Item Key="Module">Kernel::Output::HTML::TicketMenu::Generic</Item>
<Item Key="Name" Translatable="1">Set level 1 owner</Item>
<Item Key="Description" Translatable="1">Set level 1 owner</Item>
<Item Key="Action">AgentTicketMySetOwner;TicketID=[% Data.TicketID | html %]</Item>
<Item Key="Target"></Item>
<Item Key="ClusterName" Translatable="1">People</Item>
<Item Key="ClusterPriority">005</Item>
</Hash>
</Value>
</Setting>
<Setting Name="Frontend::Module###AgentTicketMySetOwner" Required="0" Valid="1">
<Description Translatable="1">Frontend module registration for the agent interface.</Description>
<Navigation>Frontend::Agent::ModuleRegistration</Navigation>
<Value>
<Item ValueType="FrontendRegistration">
<Hash>
<Item Key="Group">
</Item>
<Item Key="GroupRo">
</Item>
<Item Key="Description" Translatable="1">Set level1 owner.</Item>
<Item Key="Title" Translatable="1">Set level1 owner</Item>
<Item Key="NavBarName">Ticket</Item>
</Hash>
</Item>
</Value>
</Setting>
</otrs_config>
Code: Select all
package Kernel::Modules::AgentTicketMySetOwner;
use strict;
use warnings;
use Kernel::Language qw(Translatable);
our $ObjectManagerDisabled = 1;
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {%Param};
bless( $Self, $Type );
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
my $QueueObject = $Kernel::OM->Get('Kernel::System::Queue');
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
my $TicketID = $ParamObject->GetParam( Param => 'TicketID' );
# HINT: YOU SHOULD CHECK PERMISSIONS HERE
#get queue name
my $QueueID = $TicketObject->TicketQueueID(
TicketID => $TicketID,
);
my $Queue = $QueueObject->QueueLookup(
QueueID => $QueueID
);
#get level 1 user
my $RoleID = $GroupObject->RoleLookup(
Role => "assistant $Queue niveau 2",
);
my %User = $GroupObject->PermissionRoleUserGet(
RoleID => $RoleID
);
my $UserLevelOne = (values %User)[0];
#change ticketOwner
my $Success = $TicketObject->TicketOwnerSet(
TicketID => $TicketID,
NewUser => $UserLevelOne,
UserID => $OwnerID,
);
return $LayoutObject->Redirect(
OP => 'Action=AgentTicketZoom&TicketID=' . $TicketID,
);
}
1;
Code: Select all
perl bin/otrs.Console.pl Maint::Config::Rebuild
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de