custom print
Moderator: crythias
custom print
Hello!
I want to create a new CUSTOM print template (let's call it print2) and a new button that will call "print2". "print2" will get custom info from the ticket and print them based on the newly created template. What is the proper way to create this new "print2" template and button since i don't want to change the default print functionality.
I want to create a new CUSTOM print template (let's call it print2) and a new button that will call "print2". "print2" will get custom info from the ticket and print them based on the newly created template. What is the proper way to create this new "print2" template and button since i don't want to change the default print functionality.
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: custom print
You would need two things:
1) A custom (or extended) .xml file in ~otrs/Kernel/Config/Files/ which has a modified entry like the original one found in Ticket.xml:
2) A modified perl module that gathers all the needed data, like the original one here:
~otrs/Kernel/Modules/CustomerTicketPrint.pm
In that perl module, the "layout" is defined and renders the pdf. You can see some of the "hardcoded" line movement with commands like these:
1) A custom (or extended) .xml file in ~otrs/Kernel/Config/Files/ which has a modified entry like the original one found in Ticket.xml:
Code: Select all
<ConfigItem Name="CustomerFrontend::Module###CustomerTicketPrint" Required="0" Valid="1">
<Description Translatable="1">Frontend module registration for the customer interface.</Description>
<Group>Ticket</Group>
<SubGroup>Frontend::Customer::ModuleRegistration</SubGroup>
<Setting>
<FrontendModuleReg>
<Description Translatable="1">Customer Ticket Print Module.</Description>
<NavBarName></NavBarName>
<Title Translatable="1">Print</Title>
</FrontendModuleReg>
</Setting>
</ConfigItem>
~otrs/Kernel/Modules/CustomerTicketPrint.pm
In that perl module, the "layout" is defined and renders the pdf. You can see some of the "hardcoded" line movement with commands like these:
Code: Select all
# set new position
$PDFObject->PositionSet(
Move => 'relativ',
Y => -15,
);
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: custom print
Thank you for that but i have 1 more question.
How will i create the button that will call the .xml file for this custom print?
How will i create the button that will call the .xml file for this custom print?
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: custom print
The .xml will be parsed as soon as otrs rebuilds its sysconfig (easy to do so, when you click on "SysConfig" in the Admin tab).
If written correctly, the new button should appear in the menu module.
If written correctly, the new button should appear in the menu module.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: custom print
I have created a new entry in Ticket.xml called "Print 2" but there is no button available. We tried to create a new ticket as a customer and there wants a new button... In Frontend:Customer:ModuleRegistration i can see the entry as defined it in the Ticket.xlm file, see attached. (i think i am missing something like link between the new Print and the the menus)
You do not have the required permissions to view the files attached to this post.
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: custom print
You are right. I assumed the customer frontend is built similar to the agent one. But the print button is hardcoded.
Take a look here:
https://github.com/OTRS/otrs/blob/maste ... m.pm#L1481
You'd need to copy that block a second time, e.g.:
Then add a new block here:
https://github.com/OTRS/otrs/blob/maste ... oom.tt#L34
e.g.:
Clicking on that new button will redirect you to the CustomerTicketPrint2.pm module where you can modify the layout.
Take a look here:
https://github.com/OTRS/otrs/blob/maste ... m.pm#L1481
You'd need to copy that block a second time, e.g.:
Code: Select all
# print option
if ( $ConfigObject->Get('CustomerFrontend::Module')->{CustomerTicketPrint2} )
{
$LayoutObject->Block(
Name => 'Print2',
Data => \%Param,
);
}
https://github.com/OTRS/otrs/blob/maste ... oom.tt#L34
e.g.:
Code: Select all
[% RenderBlockStart("Print2") %]
<li>
<a href="[% Env("Baselink") %]Action=CustomerTicketPrint2;TicketID=[% Data.TicketID | uri %]" class="Print AsPopup" title="[% Translate("Print") | html %]">
<i class="fa fa-print"></i>
<span>[% Translate("Print (Custom)") | html %]</span>
</a>
</li>
[% RenderBlockEnd("Print2") %]
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: custom print
i also need the print2 button on the agent interface. Same Steps but for the agent files?
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: custom print
Slightly different from what I see. Take a look into AgentTicketZoom, where you will find this block:
You could simple copy the last (the push one) block again:
Then of course you need a "AgentTicketPrint2.pm and AgentTicketPrint2.tt
Code: Select all
# check if print link should be shown
if (
$ConfigObject->Get('Frontend::Module')->{AgentTicketPrint}
&& $AclActionLookup{AgentTicketPrint}
)
{
my $OK = $TicketObject->TicketPermission(
Type => 'ro',
TicketID => $Ticket{TicketID},
UserID => $Self->{UserID},
LogNo => 1,
);
if ($OK) {
push @MenuItems, {
ItemType => 'Link',
Description => Translatable('Print this article'),
Name => Translatable('Print'),
Class => 'AsPopup PopupType_TicketAction',
Link =>
"Action=AgentTicketPrint;TicketID=$Ticket{TicketID};ArticleID=$Article{ArticleID};ArticleNumber=$Article{Count}"
};
}
}
Code: Select all
push @MenuItems, {
ItemType => 'Link',
Description => Translatable('Print (2) this article'),
Name => Translatable('Print (2)'),
Class => 'AsPopup PopupType_TicketAction',
Link =>
"Action=AgentTicketPrint2;TicketID=$Ticket{TicketID};ArticleID=$Article{ArticleID};ArticleNumber=$Article{Count}"
};
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: custom print
Can you please make a summary with the files i need to change (eg. A -> B -> C. Just the files, not the changes i need to make in the files) ? 1 for the customer interface and 1 for the agent cause i tried all of the above and they are not working which means i am missing something and i think its on the files i need to change manually.
Thanks for your time.
Thanks for your time.
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: custom print
Where do you fail? On the agent interface or on the customer interface?
Are there errors in the log?
Are there errors in the log?
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: custom print
There are no errors in the log file relevant to the changes i made and none of the changes i made, work. so, if you please, make me a summary cause i am a bit lost (only the files that need changes). Thank you.
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: custom print
For the customer frontend as described in my previous post you need:
1) Modified "Kernel/Modules/CustomerTicketZoom.pm", where you add this block below the existing "print" block:
2) Modified "Kernel/Output/HTML/Templates/Standard/CustomerTicketZoom.tt" where you add this block below the existing "Print" block:
3) A copy of "Kernel/Modules/CustomerTicketPrint.pm" which you have to rename (in the file and the filename) to Kernel/Modules/CustomerTicketPrint2.pm
4) Register the CustomerTicketPrint2.pm in a .xml file in Kernel/Config/Files
1) Modified "Kernel/Modules/CustomerTicketZoom.pm", where you add this block below the existing "print" block:
Code: Select all
$LayoutObject->Block(
Name => 'Print2',
Data => \%Param,
);
Code: Select all
[% RenderBlockStart("Print2") %]
<li>
<a href="[% Env("Baselink") %]Action=CustomerTicketPrint2;TicketID=[% Data.TicketID | uri %]" class="Print AsPopup" title="[% Translate("Print") | html %]">
<i class="fa fa-print"></i>
<span>[% Translate("Print2") | html %]</span>
</a>
</li>
[% RenderBlockEnd("Print") %]
4) Register the CustomerTicketPrint2.pm in a .xml file in Kernel/Config/Files
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: custom print
and what about the agent interface?
Re: custom print
i made all the changes in the files you told me to change, but it doesn't work. No errors are logged and no buttons are created.
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: custom print
That is weird, because I tested it on my server and it works there :/
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: custom print
i think we are missing something important. I dont know where the button is supposed to be.
Re: custom print
I forgot to mention we are using KIX4OTRS module. We tried changing the same files as you mentioned above but KIX4OTRS (KIX4OTRS/Kernel/..) was missing CustomerTicketPrint and thse modules in Ticket.pm. Is there a possibility KIX4OTRS is the problem?
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: custom print
Oh, that might be. I think KIX adds alot of new templates that "overwrite" the default (or even custom) ones.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: custom print
do you know what i need to do if i am using KIX?
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: custom print
No sorry - don't have KIX. You could check if the files I mentioned are also in the folder KIX4OTRS/[ SamePathStructure ] and change them there.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS