dolibarr 25.0.0-alpha
report.lib.php File Reference

Set of functions for reporting. More...

Go to the source code of this file.

Functions

 report_header ($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
 Show header of a report.
 
 reportGetLogoPath ($mysoc)
 Return the readable path of our company logo for a report, or '' if none.
 
 reportGetCompanyLines ($outputlangs, $mysoc)
 Return our company info lines (without the name) for a report header.
 
 reportPdfInit ($outputlangs, $title, $subject, $orientation='P')
 Create a PDF instance for a report, with first page added.
 
 reportPdfCompanyHeader ($pdf, $outputlangs, $mysoc, $margin, $fontsize)
 Print our company logo (left) and company info (right) at top of a report PDF page.
 
 reportFileName ($title, $name, $ext)
 Return a report export file name.
 
 reportPeriodLabel ($outputlangs, $datestart, $dateend)
 Return the label of a filtered period.
 
 reportSheetTitle ($label)
 Return a valid worksheet title from a free label.
 
 reportXlsxInit ($outputlangs, $title, $sheetlabel)
 Create a spreadsheet for a report.
 
 reportXlsxCompanyHeader ($sheet, $outputlangs, $mysoc, $firstcol, $lastcol)
 Write logo (left) and company info (right) at top of a report worksheet.
 
 reportXlsxOutput ($spreadsheet, $filename)
 Send a report spreadsheet to the browser as an xlsx download.
 
 reportExportButtons ($param, $idprefix, $enabled=1)
 Return the PDF and XLSX export buttons of a report page.
 

Detailed Description

Set of functions for reporting.

Definition in file report.lib.php.

Function Documentation

◆ report_header()

report_header ( $reportname,
$notused,
$period,
$periodlink,
$description,
$builddate,
$exportlink = '',
$moreparam = array(),
$calcmode = '',
$varlink = '' )

Show header of a report.

Parameters
string$reportnameName of report
string$notusedNot used
string$periodPeriod of report
string$periodlinkLink to switch period
string$descriptionDescription
integer$builddateDate generation
string$exportlinkLink for export or ''
array<string,mixed>$moreparam Array with list of params to add into form
string$calcmodeCalculation mode
string$varlinkAdd a variable into the address of the page
Returns
void

Definition at line 45 of file report.lib.php.

References dol_get_fiche_end(), dol_get_fiche_head(), and dol_print_date().

◆ reportExportButtons()

reportExportButtons ( $param,
$idprefix,
$enabled = 1 )

Return the PDF and XLSX export buttons of a report page.

They call the current page with action exportpdf and exportxlsx.

Parameters
string$paramURL parameters to keep, starting with '&'
string$idprefixPrefix of the button ids
int$enabled1 to enable buttons, 0 to show them disabled
Returns
string HTML

Definition at line 462 of file report.lib.php.

References dolGetButtonTitle(), and newToken().

◆ reportFileName()

reportFileName ( $title,
$name,
$ext )

Return a report export file name.

Parameters
string$titleReport title (translated)
string$nameSubject of the report (thirdparty name...), '' for none
string$extFile extension
Returns
string File name

Definition at line 315 of file report.lib.php.

References dol_sanitizeFileName().

◆ reportGetCompanyLines()

reportGetCompanyLines ( $outputlangs,
$mysoc )

Return our company info lines (without the name) for a report header.

Content follows the same setup as the source address of PDF documents. Hook reportBuildCompanyLines can replace the lines: return 1 with results['lines'].

Parameters
Translate$outputlangsOutput language
Societe$mysocOur company
Returns
string[] Non empty lines

Definition at line 181 of file report.lib.php.

References $mysoc, dol_syslog(), and pdf_build_address().

Referenced by reportPdfCompanyHeader(), and reportXlsxCompanyHeader().

◆ reportGetLogoPath()

reportGetLogoPath ( $mysoc)

Return the readable path of our company logo for a report, or '' if none.

Parameters
Societe$mysocOur company
Returns
string Logo path, '' if disabled, not set or not readable

Definition at line 147 of file report.lib.php.

References $conf, $mysoc, dol_syslog(), and getDolGlobalInt().

Referenced by reportPdfCompanyHeader(), and reportXlsxCompanyHeader().

◆ reportPdfCompanyHeader()

reportPdfCompanyHeader ( $pdf,
$outputlangs,
$mysoc,
$margin,
$fontsize )

Print our company logo (left) and company info (right) at top of a report PDF page.

Parameters
TCPDF$pdfPDF instance
Translate$outputlangsOutput language
Societe$mysocOur company
float$marginPage margin
int$fontsizeDefault font size
Returns
float Y position below the header

Definition at line 277 of file report.lib.php.

References $mysoc, getDolGlobalString(), pdf_getHeightForLogo(), reportGetCompanyLines(), and reportGetLogoPath().

◆ reportPdfInit()

reportPdfInit ( $outputlangs,
$title,
$subject,
$orientation = 'P' )

Create a PDF instance for a report, with first page added.

Parameters
Translate$outputlangsOutput language
string$titleDocument title
string$subjectDocument subject
'P'|'L'$orientation 'P' for portrait, 'L' for landscape
Returns
array{pdf:TCPDF,margin:float,pagewidth:float,pageheight:float,usablewidth:float,fontsize:int}

Definition at line 222 of file report.lib.php.

References $mysoc, getDolGlobalString(), pdf_getFormat(), pdf_getInstance(), pdf_getPDFFont(), and pdf_getPDFFontSize().

◆ reportPeriodLabel()

reportPeriodLabel ( $outputlangs,
$datestart,
$dateend )

Return the label of a filtered period.

Parameters
Translate$outputlangsOutput language
int|''$datestart Start date (timestamp), '' for none
int|''$dateend End date (timestamp), '' for none
Returns
string Label, '' if no filter

Definition at line 331 of file report.lib.php.

References dol_print_date().

◆ reportSheetTitle()

reportSheetTitle ( $label)

Return a valid worksheet title from a free label.

Parameters
string$labelLabel
Returns
string Title of max 31 chars without forbidden chars

Definition at line 350 of file report.lib.php.

References dol_substr().

Referenced by reportXlsxInit().

◆ reportXlsxCompanyHeader()

reportXlsxCompanyHeader ( $sheet,
$outputlangs,
$mysoc,
$firstcol,
$lastcol )

Write logo (left) and company info (right) at top of a report worksheet.

Parameters
\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet$sheetWorksheet
Translate$outputlangsOutput language
Societe$mysocOur company
string$firstcolFirst column of the info block
string$lastcolLast column of the info block
Returns
int Number of rows used

Definition at line 394 of file report.lib.php.

References $mysoc, getDolGlobalString(), reportGetCompanyLines(), and reportGetLogoPath().

◆ reportXlsxInit()

reportXlsxInit ( $outputlangs,
$title,
$sheetlabel )

Create a spreadsheet for a report.

Caller must check class ZipArchive exists before.

Parameters
Translate$outputlangsOutput language
string$titleDocument title
string$sheetlabelLabel used for the worksheet title
Returns
\PhpOffice\PhpSpreadsheet\Spreadsheet

Definition at line 366 of file report.lib.php.

References reportSheetTitle().

◆ reportXlsxOutput()

reportXlsxOutput ( $spreadsheet,
$filename )

Send a report spreadsheet to the browser as an xlsx download.

Parameters
\PhpOffice\PhpSpreadsheet\Spreadsheet$spreadsheetSpreadsheet
string$filenameFile name (UTF-8)
Returns
void

Definition at line 435 of file report.lib.php.

References dol_sanitizeFileName().