Commit 4eecd881 authored by Timmer, Marius's avatar Timmer, Marius

Bugfix: Export each ticket in its own file

parent d0c44c6f
This diff is collapsed.
......@@ -3,6 +3,8 @@ package Kernel::System::TicketExport;
use strict;
use warnings;
use Kernel::Modules::AgentTicketPrint;
our @ObjectDependencies = (
'Kernel::Modules::AgentTicketPrintIntern',
'Kernel::System::DB',
......@@ -62,19 +64,51 @@ sub Run {
my @TicketList = $Self->GetTicketList(
QueueID => $QueueID
);
my $SucceedTickets;
for my $TicketID (@TicketList) {
my %TicketData = $Self->{TicketObject}->TicketGet(
TicketID => $TicketID,
UserID => $Self->{UserID}
);
my $Filename = sprintf('%s%s_%d_%d.pdf', $Filepath, $QueueName, $TicketID, $TicketData{TicketNumber});
print "Writing \"". $Filename ."\"\n";
my $PrintStatus = ' OK ';
if ($Param{Print} && $Param{Print} == 1) {
print STDOUT sprintf("Writing %\ 30s ", $Filename);
}
# Create the PDF data string
my $PDFString = $Self->CreatePDF(
TicketID => $TicketID
);
if (!$PDFString) {
# Could not create the PDF string for unknown reasons. We assume the
# system has informed the user about the certian problem already so we do
# not need to do it here. Just write that the file could not been written.
$PrintStatus = 'FAILED';
} else {
# We have a pdf string so we have to write it into the file.
# Use the main object of OTRS to do this.
my $WritingStatus = $Kernel::OM->Get('Kernel::System::Main')->FileWrite(
Location => $Filename,
Content => \$PDFString,
Mode => 'binmode',
Permission => '644'
);
if (!$WritingStatus) {
# The FileWrite method returned undef which is a hint that an error has
# occured while writing the file. Just set the PrintStatus for output
# to inform the user and continue.
$PrintStatus = 'FAILED';
} else {
# File was written successfull.
$SucceedTickets++;
}
}
if ($Param{Print} && $Param{Print} == 1) {
print STDOUT "[". $PrintStatus ."]\r\n";
}
}
return $SucceedTickets;
}
sub CreatePDF {
......@@ -91,13 +125,12 @@ sub CreatePDF {
# Just call a new instance of our modified version of the pdf printer
my $TicketPrinter = $Kernel::OM->Get('Kernel::Modules::AgentTicketPrintIntern');
$TicketPrinter->{GroupObject} = $Self->{GroupObject};
$TicketPrinter->{UserObject} = $Self->{UserObject};
$TicketPrinter->{TicketID} = $Param{TicketID};
$TicketPrinter->{UserID} = $RootUserData{UserID};
$TicketPrinter->{UserFirstname} = $RootUserData{UserFirstname};
$TicketPrinter->{UserLastname} = $RootUserData{UserLastname};
$TicketPrinter->{UserEmail} = $RootUserData{UserEmail};
$TicketPrinter->{Action} = 'AgentTicketPrint';
return $TicketPrinter->Run();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment