lines[] = $line; } function appendLines($lines) { foreach ($lines as $l) { $this->lines[] = $l; } } function appendHeader(ReceiptLine $line) { $this->header[] = $line; } function appendFooter(ReceiptLine $line) { $this->footer[] = $line; } function appendBreak() { $this->lines[] = new ReceiptLine("", "", "", ReceiptLine::LINEFORMAT_HR); } function appendBlank() { $this->lines[] = new ReceiptLine("", "", "", ReceiptLine::LINEFORMAT_BLANK); } function getHtml($title = "") { global $SECURE_NONCE; $html = << $title END; if (count($this->header) > 0) { foreach ($this->header as $line) { $html .= $line->getHtml() . "\n"; } $html .= (new ReceiptLine("", "", "", ReceiptLine::LINEFORMAT_HR))->getHtml(); } foreach ($this->lines as $line) { $html .= $line->getHtml() . "\n"; } if (count($this->footer) > 0) { $html .= (new ReceiptLine("", "", "", ReceiptLine::LINEFORMAT_HR))->getHtml(); foreach ($this->footer as $line) { $html .= $line->getHtml() . "\n"; } } return $html; } function getPlainText($width) { $lines = []; if (count($this->header) > 0) { foreach ($this->header as $line) { $lines[] = $line->getPlainText($width); } $lines[] = (new ReceiptLine("", "", "", ReceiptLine::LINEFORMAT_HR))->getPlainText($width); } foreach ($this->lines as $line) { $lines[] = $line->getPlainText($width); } if (count($this->footer) > 0) { $lines[] = (new ReceiptLine("", "", "", ReceiptLine::LINEFORMAT_HR))->getPlainText($width); foreach ($this->footer as $line) { $lines[] = $line->getPlainText($width); } } return implode("\n", $lines); } function getArray($width = 64) { $header = []; $lines = []; $footer = []; foreach ($this->header as $line) { $header[] = $line->getArray($width); } foreach ($this->lines as $line) { $lines[] = $line->getArray($width); } foreach ($this->footer as $line) { $footer[] = $line->getArray($width); } return ["header" => $header, "lines" => $lines, "footer" => $footer]; } function getJson($width = 64) { return json_encode($this->getArray($width)); } }