Support for separate variable: all_page_header && all_page_footer

This commit is contained in:
Benjamin Beganović 2020-08-27 08:39:14 +02:00
parent 971a723607
commit edbadabab4
4 changed files with 40 additions and 65 deletions

View File

@ -156,10 +156,12 @@ trait PdfMakerUtilities
public function processOptions()
{
if (isset($this->options['repeat_header_and_footer']) && $this->options['repeat_header_and_footer']) {
$this->insertPrintCSS();
$this->wrapIntoTable();
if (!isset($this->options['all_page_header']) && !isset($this->options['all_page_footer'])) {
return;
}
$this->insertPrintCSS();
$this->wrapIntoTable();
}
public function insertPrintCSS()
@ -256,7 +258,12 @@ trait PdfMakerUtilities
$this->document->getElementById('repeat-content')->appendChild($clone);
}
if ($header = $this->document->getElementById('header')) {
if (
$header = $this->document->getElementById('header') &&
isset($this->data['options']['all_page_header']) &&
$this->data['options']['all_page_header']
) {
$header = $this->document->getElementById('header');
$clone = $header->cloneNode(true);
@ -264,7 +271,11 @@ trait PdfMakerUtilities
$this->document->getElementById('repeat-header')->appendChild($clone);
}
if ($footer = $this->document->getElementById('footer')) {
if (
$footer = $this->document->getElementById('footer') &&
isset($this->data['options']['all_page_footer']) &&
$this->data['options']['all_page_footer']
) {
$footer = $this->document->getElementById('footer');
$clone = $footer->cloneNode(true);

View File

@ -50,6 +50,8 @@ class PdfMakerDesignsTest extends TestCase
],
],
];
exec('echo "" > storage/logs/laravel.log');
}
public function testBusiness()
@ -137,16 +139,13 @@ class PdfMakerDesignsTest extends TestCase
], $this->state['variables']),
];
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($state);
$maker
->design(Business::class)
->build();
//exec('echo "" > storage/logs/laravel.log');
exec('echo "" > storage/logs/laravel.log');
info($maker->getCompiledHTML());
@ -250,7 +249,6 @@ class PdfMakerDesignsTest extends TestCase
],
'variables' => array_merge([], $this->state['variables']),
];
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($state);
@ -258,8 +256,6 @@ class PdfMakerDesignsTest extends TestCase
->design(Clean::class)
->build();
//exec('echo "" > storage/logs/laravel.log');
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
@ -366,7 +362,6 @@ class PdfMakerDesignsTest extends TestCase
],
'variables' => array_merge([], $this->state['variables']),
];
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($state);
@ -374,6 +369,8 @@ class PdfMakerDesignsTest extends TestCase
->design(Modern::class)
->build();
info($maker->getCompiledHTML());
//exec('echo "" > storage/logs/laravel.log');
//info($maker->getCompiledHTML(true));
@ -381,7 +378,6 @@ class PdfMakerDesignsTest extends TestCase
$this->assertTrue(true);
}
public function testBold()
{
$state = [
@ -483,7 +479,6 @@ class PdfMakerDesignsTest extends TestCase
],
'variables' => array_merge([], $this->state['variables']),
];
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($state);
@ -491,11 +486,7 @@ class PdfMakerDesignsTest extends TestCase
->design(Bold::class)
->build();
//exec('echo "" > storage/logs/laravel.log');
//info($maker->getCompiledHTML(true));
info($maker->getCompiledHTML());
$this->assertTrue(true);
}
@ -593,7 +584,6 @@ class PdfMakerDesignsTest extends TestCase
],
'variables' => array_merge([], $this->state['variables']),
];
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($state);
@ -601,11 +591,9 @@ class PdfMakerDesignsTest extends TestCase
->design(Plain::class)
->build();
// exec('echo "" > storage/logs/laravel.log');
// info($maker->getCompiledHTML(true));
exec('echo "" > storage/logs/laravel.log');
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
@ -707,7 +695,6 @@ class PdfMakerDesignsTest extends TestCase
],
'variables' => array_merge([], $this->state['variables']),
];
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($state);
@ -715,10 +702,7 @@ class PdfMakerDesignsTest extends TestCase
->design(Hipster::class)
->build();
// exec('echo "" > storage/logs/laravel.log');
// info($maker->getCompiledHTML(true));
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
@ -824,7 +808,6 @@ class PdfMakerDesignsTest extends TestCase
],
'variables' => array_merge([], $this->state['variables']),
];
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($state);
@ -832,10 +815,7 @@ class PdfMakerDesignsTest extends TestCase
->design(Elegant::class)
->build();
// exec('echo "" > storage/logs/laravel.log');
// info($maker->getCompiledHTML(true));
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
@ -941,7 +921,6 @@ class PdfMakerDesignsTest extends TestCase
],
'variables' => array_merge([], $this->state['variables']),
];
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($state);
@ -949,11 +928,8 @@ class PdfMakerDesignsTest extends TestCase
->design(Creative::class)
->build();
// exec('echo "" > storage/logs/laravel.log');
// info($maker->getCompiledHTML(true));
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
@ -1052,7 +1028,6 @@ class PdfMakerDesignsTest extends TestCase
],
'variables' => array_merge([], $this->state['variables']),
];
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($state);
@ -1060,11 +1035,7 @@ class PdfMakerDesignsTest extends TestCase
->design(Playful::class)
->build();
// exec('echo "" > storage/logs/laravel.log');
// info($maker->getCompiledHTML(true));
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}

View File

@ -18,8 +18,6 @@ class PdfMakerTest extends TestCase
public function testDesignLoadsCorrectly()
{
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($this->state);
$maker->design(ExampleDesign::class);
@ -29,8 +27,6 @@ class PdfMakerTest extends TestCase
public function testHtmlDesignLoadsCorrectly()
{
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($this->state);
$maker
@ -42,8 +38,6 @@ class PdfMakerTest extends TestCase
public function testGetSectionUtility()
{
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker($this->state);
$maker
@ -55,8 +49,6 @@ class PdfMakerTest extends TestCase
public function testTableAttributesAreInjected()
{
$this->markTestSkipped('STUB broken tests');
$state = [
'template' => [
'product-table' => [
@ -93,8 +85,6 @@ class PdfMakerTest extends TestCase
public function testVariablesAreReplaced()
{
$this->markTestSkipped('STUB broken tests');
$state = [
'template' => [
@ -133,8 +123,6 @@ class PdfMakerTest extends TestCase
public function testElementContentIsGenerated()
{
$this->markTestSkipped('STUB broken tests');
$state = [
'template' => [
@ -184,8 +172,6 @@ class PdfMakerTest extends TestCase
public function testConditionalRenderingOfElements()
{
$this->markTestSkipped('STUB broken tests');
$maker1 = new PdfMaker([
'template' => [
@ -226,8 +212,6 @@ class PdfMakerTest extends TestCase
public function testOrderingElements()
{
$this->markTestSkipped('STUB broken tests');
$maker = new PdfMaker([
'template' => [
@ -286,8 +270,6 @@ class PdfMakerTest extends TestCase
public function testGeneratingPdf()
{
$this->markTestSkipped('STUB broken tests');
$state = [
'template' => [
@ -375,7 +357,7 @@ class PdfMakerTest extends TestCase
'values' => [],
],
'options' => [
'repeat_header_and_footer' => true,
'all_page_footer' => true,
],
];
@ -385,6 +367,10 @@ class PdfMakerTest extends TestCase
->design(ExampleDesign::class)
->build();
exec('echo "" > storage/logs/laravel.log');
info($maker->getCompiledHTML(true));
$this->assertTrue(true);
}
}

View File

@ -3,6 +3,13 @@
<body class="m-10">
<div id="header">My awesome header! $title</div>
<div>1231
<div>
123123123
</div>
</div>
<component>/dsadas</component>
<span>Hello world</span>
<table id="product-table"></table>
<div id="footer">My awesome footer</div>
</body>