refactoring

This commit is contained in:
Roland Gruber 2017-10-22 10:32:56 +02:00
parent c5a0be924c
commit 21a305bf4f
1 changed files with 21 additions and 8 deletions

View File

@ -56,14 +56,6 @@ include_once('pdfstruct.inc');
* @return String PDF file name * @return String PDF file name
*/ */
function createModulePDF($accounts, $pdf_structure="default", $returnAsString = false) { function createModulePDF($accounts, $pdf_structure="default", $returnAsString = false) {
/** PDF generator class */
include_once("fpdf-lam.inc");
/** Unicode support for FPDF */
include_once("ufpdf.php");
/** LAM PDF generator class */
include_once("lamPDF.inc");
$account_type = $accounts[0]->get_type(); $account_type = $accounts[0]->get_type();
// Get PDF structure from xml file // Get PDF structure from xml file
$reader = new PDFStructureReader(); $reader = new PDFStructureReader();
@ -82,6 +74,27 @@ function createModulePDF($accounts, $pdf_structure="default", $returnAsString =
} }
} }
$pdfKeys = array_unique($pdfKeys); $pdfKeys = array_unique($pdfKeys);
return createPdfFpdf($structure, $accounts, $pdfKeys, $account_type, $returnAsString);
}
/**
* This function creates the PDF output of one or more accounts using FPDF.
*
* @param array $accounts A numbered array containing all accounts the PDF page should
* be created for. The entries of the array must be AccountContainer objects.
* @param string $pdf_structure The filename of the structure definition that should be used
* to create the PDF page. If not submitted the 'default.user' structure definition
* for the appropriate account type.
* @param $returnAsString returns the PDF output as String value instead of writing it to a file
* @return String PDF file name
*/
function createPdfFpdf($structure, $accounts, $pdfKeys, $account_type, $returnAsString) {
/** PDF generator class */
include_once("fpdf-lam.inc");
/** Unicode support for FPDF */
include_once("ufpdf.php");
/** LAM PDF generator class */
include_once("lamPDF.inc");
// The decimal separator must be a dot in order to write pdf-files // The decimal separator must be a dot in order to write pdf-files
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");