MT#5879 Start with PDF::WebKit

ipeshinskaya/InvoiceTemplate5
Irina Peshinskaya 11 years ago committed by Victor Seva
parent bb69a3ef5f
commit 21e2f2b38f

@ -17,7 +17,7 @@ use NGCP::Panel::Form::Customer::PbxFieldDevice;
use NGCP::Panel::Form::Customer::PbxFieldDeviceEdit;
use NGCP::Panel::Form::Customer::PbxFieldDeviceSync;
use NGCP::Panel::Form::Customer::InvoiceTemplate;
use PDF::WebKit;
use NGCP::Panel::Model::DB::InvoiceTemplate;
use NGCP::Panel::Utils::Message;
use NGCP::Panel::Utils::Navigation;
@ -875,10 +875,10 @@ sub calls_svg :Chained('base') :PathPart('calls/template') :Args {
return;
}
my $in_validated = $validator->fif;
#use irka;
#use Data::Dumper;
#irka::loglong(Dumper($in));
#irka::loglong(Dumper($in_validated));
use irka;
use Data::Dumper;
irka::loglong(Dumper($in));
irka::loglong(Dumper($in_validated));
#dirty hack 1
$in = $in_validated;
@ -889,6 +889,7 @@ sub calls_svg :Chained('base') :PathPart('calls/template') :Args {
$in->{tt_type} = 'svg';
$in->{tt_output_type} = 'pdf';
}
irka::loglong(Dumper($in));
#model logic
@ -949,9 +950,9 @@ sub calls_svg :Chained('base') :PathPart('calls/template') :Args {
#prepare response
#mess,mess,mess here
if($in->{tt_type} eq 'svg'){
if($in->{tt_output_type} eq 'svg'){
$c->response->content_type('image/svg+xml');
}elsif($in->{tt_type} eq 'pdf'){
}elsif($in->{tt_output_type} eq 'pdf'){
$c->response->content_type('application/pdf');
}
if($in->{tt_viewmode} eq 'raw'){
@ -972,14 +973,19 @@ sub calls_svg :Chained('base') :PathPart('calls/template') :Args {
$c->stash( provider => $contacts->first );
if($in->{tt_type} eq 'svg'){
if($in->{tt_output_type} eq 'svg'){
#$c->response->content_type('image/svg+xml');
$c->stash( template => \$output_string );
$c->detach($c->view('SVG'));
}elsif($in->{tt_type} eq 'pdf'){
#$c->response->content_type('application/pdf');
my $svg = $c->view('SVG')->getTemplateProcessed($c,$output_string);
}elsif($in->{tt_output_type} eq 'pdf'){
$c->response->content_type('application/pdf');
my $svg = $c->view('SVG')->getTemplateProcessed($c,\$output_string, $c->stash );
$c->log->debug($svg);
my $kit = PDF::WebKit->new(\$svg, page_size => 'Letter');
#push @{ $kit->stylesheets }, "/path/to/css/file";
# Get an inline PDF
$output_string = $kit->to_pdf;
}
$c->stash( template => \$output_string );
$c->detach($c->view('SVG'));
}
}

@ -41,7 +41,7 @@ sub process
sub getTemplate{
my ( $self, $c, $template ) = @_;
if(defined $template){
$c->log->debug("getTemplateContent: template=$template;");
$c->log->debug("getTemplate: template=$template;");
}
$template ||= ( $c->stash->{template} || $c->action . $self->config->{TEMPLATE_EXTENSION} );
$c->log->debug("getTemplate: template=$template;");
@ -55,9 +55,9 @@ sub getTemplateContent{
return $self->{template}->context->insert($self->getTemplate($c,$template));
}
sub getTemplateProcessed{
my ( $self, $c, $template ) = @_;
my ( $self, $c, $template, $stash ) = @_;
return $self->{template}->context->process($self->getTemplate($c,$template));
return $self->{template}->context->process($template, $stash);
}
1;
Loading…
Cancel
Save