mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Remove deprecated code for repeating header and footer in PDFs
This commit is contained in:
parent
e589d5a60f
commit
fcffafea9d
@ -77,8 +77,6 @@ class PdfMaker
|
||||
$this->updateVariables($this->data['variables']);
|
||||
}
|
||||
|
||||
$this->processOptions();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -163,144 +163,6 @@ trait PdfMakerUtilities
|
||||
return $element;
|
||||
}
|
||||
|
||||
public function processOptions()
|
||||
{
|
||||
if (!isset($this->options['all_pages_header']) || $this->options['all_pages_header'] == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($this->options['all_pages_footer']) || $this->options['all_pages_footer'] == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->insertPrintCSS();
|
||||
$this->wrapIntoTable();
|
||||
}
|
||||
|
||||
public function insertPrintCSS()
|
||||
{
|
||||
$css = <<<'EOT'
|
||||
table.page-container {
|
||||
page-break-after: always;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
thead.page-header {
|
||||
display: table-header-group;
|
||||
}
|
||||
|
||||
tfoot.page-footer {
|
||||
display: table-footer-group;
|
||||
}
|
||||
EOT;
|
||||
|
||||
$css_node = $this->document->createTextNode($css);
|
||||
|
||||
$style = $this->document->getElementsByTagName('style')->item(0);
|
||||
|
||||
if ($style) {
|
||||
return $style->appendChild($css_node);
|
||||
}
|
||||
|
||||
$head = $this->document->getElementsByTagName('head')->item(0);
|
||||
|
||||
if ($head) {
|
||||
$style_node = $this->document->createElement('style', $css);
|
||||
|
||||
return $head->appendChild($style_node);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function wrapIntoTable()
|
||||
{
|
||||
$markup = <<<'EOT'
|
||||
<table class="page-container" id="page-container">
|
||||
<thead class="page-report">
|
||||
<tr>
|
||||
<th class="page-report-cell" id="repeat-header">
|
||||
<!-- Repeating header goes here.. -->
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot class="report-footer">
|
||||
<tr>
|
||||
<td class="report-footer-cell" id="repeat-footer">
|
||||
<!-- Repeating footer goes here -->
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody class="report-content">
|
||||
<tr>
|
||||
<td class="report-content-cell" id="repeat-content">
|
||||
<!-- Rest of the content goes here -->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
EOT;
|
||||
|
||||
$document = new DOMDocument();
|
||||
$document->loadHTML($markup);
|
||||
|
||||
$table = $document->getElementById('page-container');
|
||||
|
||||
$body = $this->document->getElementsByTagName('body')
|
||||
->item(0);
|
||||
|
||||
$body->appendChild(
|
||||
$this->document->importNode($table, true)
|
||||
);
|
||||
|
||||
for ($i = 0; $i < $body->childNodes->length; $i++) {
|
||||
$element = $body->childNodes->item($i);
|
||||
|
||||
if ($element->nodeType !== 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
$element->getAttribute('id') == 'header' ||
|
||||
$element->getAttribute('id') == 'footer' ||
|
||||
$element->getAttribute('id') === 'page-container'
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$clone = $element->cloneNode(true);
|
||||
$element->parentNode->removeChild($element);
|
||||
|
||||
$this->document->getElementById('repeat-content')->appendChild($clone);
|
||||
}
|
||||
|
||||
// info($this->data['options']);
|
||||
|
||||
if (
|
||||
$header = $this->document->getElementById('header') &&
|
||||
isset($this->data['options']['all_pages_header']) &&
|
||||
$this->data['options']['all_pages_header']
|
||||
) {
|
||||
$header = $this->document->getElementById('header');
|
||||
$clone = $header->cloneNode(true);
|
||||
|
||||
$header->parentNode->removeChild($header);
|
||||
$this->document->getElementById('repeat-header')->appendChild($clone);
|
||||
}
|
||||
|
||||
if (
|
||||
$footer = $this->document->getElementById('footer') &&
|
||||
isset($this->data['options']['all_pages_footer']) &&
|
||||
$this->data['options']['all_pages_footer']
|
||||
) {
|
||||
$footer = $this->document->getElementById('footer');
|
||||
$clone = $footer->cloneNode(true);
|
||||
|
||||
$footer->parentNode->removeChild($footer);
|
||||
$this->document->getElementById('repeat-footer')->appendChild($clone);
|
||||
}
|
||||
}
|
||||
|
||||
public function getEmptyElements(array &$elements, array $variables)
|
||||
{
|
||||
foreach ($elements as &$element) {
|
||||
|
Loading…
Reference in New Issue
Block a user