From fcffafea9d96e2322007ec436d5bfc4f6c3502c8 Mon Sep 17 00:00:00 2001 From: Joshua Dwire Date: Tue, 5 Oct 2021 17:42:14 -0400 Subject: [PATCH] Remove deprecated code for repeating header and footer in PDFs --- app/Services/PdfMaker/PdfMaker.php | 2 - app/Services/PdfMaker/PdfMakerUtilities.php | 138 -------------------- 2 files changed, 140 deletions(-) diff --git a/app/Services/PdfMaker/PdfMaker.php b/app/Services/PdfMaker/PdfMaker.php index 2f50f9882d..55c600fe44 100644 --- a/app/Services/PdfMaker/PdfMaker.php +++ b/app/Services/PdfMaker/PdfMaker.php @@ -77,8 +77,6 @@ class PdfMaker $this->updateVariables($this->data['variables']); } - $this->processOptions(); - return $this; } diff --git a/app/Services/PdfMaker/PdfMakerUtilities.php b/app/Services/PdfMaker/PdfMakerUtilities.php index c90005e43b..ab72d76d37 100644 --- a/app/Services/PdfMaker/PdfMakerUtilities.php +++ b/app/Services/PdfMaker/PdfMakerUtilities.php @@ -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' - - - - - - - - - - - - - - - - -
- -
- -
- 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) {