45function report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink =
'', $moreparam = array(), $calcmode =
'', $varlink =
'')
49 print
"\n\n<!-- start banner of report -->\n";
51 if (!empty($varlink)) {
52 $varlink =
'?'.$varlink;
55 $title = $langs->trans(
"Report");
57 print_barre_liste($title, 0,
'',
'',
'',
'',
'', -1,
'',
'generic', 0,
'',
'', -1, 1, 1);
59 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].$varlink.
'">'.
"\n";
60 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
64 foreach ($moreparam as $key => $value) {
65 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">'.
"\n";
68 print
'<table class="border tableforfield centpercent">'.
"\n";
70 $variant = ($periodlink || $exportlink);
74 print
'<td width="150">'.$langs->trans(
"ReportName").
'</td>';
86 print
'<td width="150">'.$langs->trans(
"CalculationMode").
'</td>';
98 print
'<td>'.$langs->trans(
"ReportPeriod").
'</td>';
104 print
'<td class="nowraponall">'.$periodlink.
'</td>';
111 print
'<td>'.$langs->trans(
"ReportDescription").
'</td>';
112 print
'<td>'.$description.
'</td>';
120 print
'<td>'.$langs->trans(
"GeneratedOn").
'</td>';
125 print
'<td>'.($exportlink ? $langs->trans(
"Export").
': '.$exportlink :
'').
'</td>';
129 print
'</table>'.
"\n";
133 print
'<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans(
"Refresh").
'"></div>';
138 print
"\n<!-- end banner of report -->\n\n";
155 $logodir =
$conf->mycompany->dir_output;
156 if (!empty(
$conf->mycompany->multidir_output[
$conf->entity])) {
157 $logodir =
$conf->mycompany->multidir_output[
$conf->entity];
160 $logo = $logodir.
'/logos/thumbs/'.
$mysoc->logo_small;
162 $logo = $logodir.
'/logos/'.
$mysoc->logo;
164 if (!is_readable($logo)) {
165 dol_syslog(__FUNCTION__.
' logo not readable '.$logo, LOG_WARNING);
185 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
187 $outputlangs->loadLangs(array(
"main",
"companies"));
191 if (is_object($hookmanager)) {
192 $parameters = array(
'outputlangs' => $outputlangs,
'lines' => $lines);
194 $reshook = $hookmanager->executeHooks(
'reportBuildCompanyLines', $parameters,
$mysoc, $action);
196 dol_syslog(__FUNCTION__.
' hook error '.$hookmanager->error, LOG_ERR);
197 } elseif ($reshook > 0 && isset($hookmanager->resArray[
'lines']) && is_array($hookmanager->resArray[
'lines'])) {
198 $lines = $hookmanager->resArray[
'lines'];
203 foreach ($lines as $line) {
204 $line = trim((
string) $line);
226 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
229 $pdf =
pdf_getInstance(array($format[
'width'], $format[
'height']),
'mm', ($orientation ==
'L' ?
'l' :
'P'));
234 $pdf->setPrintHeader(
false);
235 $pdf->setPrintFooter(
false);
236 $pdf->SetMargins($margin, $margin, $margin);
237 $pdf->SetAutoPageBreak(
false);
239 $pdf->SetDrawColor(128, 128, 128);
240 $pdf->SetTitle($outputlangs->convToOutputCharset($title));
241 $pdf->SetSubject($outputlangs->convToOutputCharset($subject));
242 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
243 $author = (is_object(
$mysoc) ? (string)
$mysoc->name :
'');
244 if (is_object($user) && $user->id > 0) {
245 $author .= ($author !==
'' ?
' - ' :
'').$user->getFullName($outputlangs);
247 $pdf->SetAuthor($outputlangs->convToOutputCharset($author));
249 $pdf->SetCompression(
false);
254 $pagewidth = (float) $pdf->getPageWidth();
255 $pageheight = (float) $pdf->getPageHeight();
260 'pagewidth' => $pagewidth,
261 'pageheight' => $pageheight,
262 'usablewidth' => $pagewidth - 2 * $margin,
263 'fontsize' => $fontsize
279 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
286 $pdf->Image($logo, $margin, $margin, 0, $height);
287 $bottom = $margin + $height;
291 $posx = (float) $pdf->getPageWidth() - $margin - $w;
292 $pdf->SetTextColor(0, 0, 0);
293 $pdf->SetXY($posx, $margin);
295 $pdf->SetFont(
'',
'B', $fontsize);
296 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset(
$mysoc->name), 0,
'L');
298 $pdf->SetFont(
'',
'', $fontsize - 1);
301 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($line), 0,
'L');
304 return max($bottom, (
float) $pdf->GetY()) + 4;
317 $prefix = trim((
string) preg_replace(
'/_+/',
'_',
dol_sanitizeFileName(str_replace(
' ',
'_', $title),
'_', 0)),
'_');
318 $name = trim((
string) preg_replace(
'/_+/',
'_',
dol_sanitizeFileName(str_replace(
' ',
'_', $name),
'_', 0)),
'_.');
320 return $prefix.($name !==
'' ?
'-'.$name :
'').
'.'.$ext;
333 if ($datestart && $dateend) {
334 return $outputlangs->transnoentitiesnoconv(
"DateFromTo",
dol_print_date($datestart,
'day',
'tzserver', $outputlangs),
dol_print_date($dateend,
'day',
'tzserver', $outputlangs));
335 } elseif ($datestart) {
336 return $outputlangs->transnoentitiesnoconv(
"DateFrom",
dol_print_date($datestart,
'day',
'tzserver', $outputlangs));
337 } elseif ($dateend) {
338 return $outputlangs->transnoentitiesnoconv(
"DateUntil",
dol_print_date($dateend,
'day',
'tzserver', $outputlangs));
352 $title = trim((
string) preg_replace(
'/\s+/u',
' ', str_replace(array(
'[',
']',
':',
'*',
'?',
'/',
'\\'),
' ', $label)),
" '");
353 $title = trim(
dol_substr($title, 0, 31,
'UTF-8'),
" '");
355 return ($title ===
'' ?
'Sheet1' : $title);
370 require_once DOL_DOCUMENT_ROOT.
'/includes/phpoffice/phpspreadsheet/src/autoloader.php';
371 require_once DOL_DOCUMENT_ROOT.
'/includes/Psr/autoloader.php';
372 require_once PHPEXCELNEW_PATH.
'Spreadsheet.php';
374 $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
375 $spreadsheet->getProperties()->setCreator($user->getFullName($outputlangs).
' - '.DOL_APPLICATION_TITLE.
' '.DOL_VERSION);
376 $spreadsheet->getProperties()->setTitle($title);
377 $sheet = $spreadsheet->getActiveSheet();
379 $sheet->getDefaultRowDimension()->setRowHeight(16);
396 $infolines = array();
398 $infolines[] = array((
string)
$mysoc->name,
true);
401 $infolines[] = array($line,
false);
406 $drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
407 $drawing->setPath($logo);
408 $drawing->setCoordinates(
'A1');
409 $drawing->setOffsetX(2);
410 $drawing->setOffsetY(2);
411 $drawing->setHeight(70);
412 $drawing->setWorksheet($sheet);
415 foreach ($infolines as $i => $infoline) {
416 $cell = $firstcol.($i + 1);
417 $sheet->setCellValueExplicit($cell, $infoline[0], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
418 $sheet->mergeCells($cell.
':'.$lastcol.($i + 1));
419 $sheet->getStyle($cell)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT);
421 $sheet->getStyle($cell)->getFont()->setBold(
true);
425 return max(count($infolines), ($logo !==
'' ? 5 : 0));
439 $asciiname = trim((
string) preg_replace(array(
'/_+/',
'/_?-_?/',
'/_?\._?/'), array(
'_',
'-',
'.'), $asciiname),
'_-');
440 if ($asciiname ===
'' || $asciiname[0] ===
'.') {
441 $asciiname =
'export'.$asciiname;
444 header(
'Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
445 header(
'Content-Disposition: attachment; filename="'.$asciiname.
'"; filename*=UTF-8\'\''.rawurlencode($filename));
446 header(
'Cache-Control: max-age=0');
448 $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
449 $writer->save(
'php://output');
450 $spreadsheet->disconnectWorksheets();
466 $langs->load(
"accountancy");
468 $url = $_SERVER[
"PHP_SELF"].
'?action=exportpdf&token='.
newToken().$param;
469 $out =
dolGetButtonTitle($langs->trans(
"ExportToPdf"),
'',
'fa fa-file-pdf', $url, $idprefix.
'exportpdf', $enabled, array(
'attr' => array(
'target' =>
'_blank',
'rel' =>
'noopener')));
470 $url = $_SERVER[
"PHP_SELF"].
'?action=exportxlsx&token='.
newToken().$param;
471 $out .=
dolGetButtonTitle($langs->trans(
"Export").
' (XLSX)',
'',
'fa fa-file-excel', $url, $idprefix.
'exportxlsx', $enabled);
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
reportPeriodLabel($outputlangs, $datestart, $dateend)
Return the label of a filtered period.
reportXlsxCompanyHeader($sheet, $outputlangs, $mysoc, $firstcol, $lastcol)
Write logo (left) and company info (right) at top of a report worksheet.
reportPdfInit($outputlangs, $title, $subject, $orientation='P')
Create a PDF instance for a report, with first page added.
reportGetCompanyLines($outputlangs, $mysoc)
Return our company info lines (without the name) for a report header.
reportGetLogoPath($mysoc)
Return the readable path of our company logo for a report, or '' if none.
reportSheetTitle($label)
Return a valid worksheet title from a free label.
reportFileName($title, $name, $ext)
Return a report export file name.
reportPdfCompanyHeader($pdf, $outputlangs, $mysoc, $margin, $fontsize)
Print our company logo (left) and company info (right) at top of a report PDF page.
reportXlsxInit($outputlangs, $title, $sheetlabel)
Create a spreadsheet for a report.
reportExportButtons($param, $idprefix, $enabled=1)
Return the PDF and XLSX export buttons of a report page.
reportXlsxOutput($spreadsheet, $filename)
Send a report spreadsheet to the browser as an xlsx download.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.