Version Date Notes By
1.0 2023-06-21 Initial release ROB

Introduction

PDF reports use wkhtmltopdf to convert blade templates into a pdf report. In order to do so, there are a few blade components that match the corresponding interface system components, and all together form the template for the pdf report (some components are containers for more components themselves).

The report is exported when the export{Case|Process}AsPdf function is called in the CaseReport model. Internally this function uses PDFExporter class and the processes-engine-module::cases.pdf.report-{case|process}-pdf as the body blade to export. Inside the body blade, the correspondence is made between the interface system components in this report and blades present in the backend:

// Folder structure inside ProcessesEngine\resources\views

|--\ cases
    |--\ pdf
        |--\ report-interface-components
            |--- chart-process
            |--- first-element-simple-vertical-table
            |--- formatted-text
            |--- pdf-column
            |--- pdf-container
            |--- pdf-row
            |--- simple-process-grid
            |--- simple-text-area
            |--- simple-vertical-table
        |--- report-case
        |--- report-custom-footer
        |--- report-custom-header
        |--- report-process-pdf
        |--- simple-pdf // standard template (allways available even without defining a report)

// all files are `.blade.php`

If there is a need to create a new pdf component, then a new corresponding blade must be created with the exact same name as the component slug.

Inside the blade, the various component options are accessible like so:

@php

// get options
$gridElements = $interfaceComponent->componentOptions->where('option_name', '=', 'grid_elements')->first()->value;
$visualQuery  = $interfaceComponent->componentOptions->where('option_name', '=', 'visual_query')->first()->value;

$title        = $interfaceComponent->componentOptions->where('option_name', '=', 'title')->first()->value;
$chartType    = $interfaceComponent->componentOptions->where('option_name', '=', 'chart_type')->first()->value;

@endphp

If the new component is a container, then the following code should be placed where it makes sense for the component (each component is very diferent as far as placement of sub components):

@foreach($interfaceComponent->childComponents->sortBy('order') as $childInterfaceComponent)
    @if(isset($case))
        @include('processes-engine-module::cases.pdf.report-interface-components.' . $childInterfaceComponent->component, [
            'request'            => $request,
            'report'             => $report,
            'case'               => $case,
            'interfaceComponent' => $childInterfaceComponent
        ])
    @else
        @include('processes-engine-module::cases.pdf.report-interface-components.' . $childInterfaceComponent->component, [
            'request'            => $request,
            'report'             => $report,
            'process'            => $process,
            'cases'              => $cases,
            'interfaceComponent' => $childInterfaceComponent
        ])
    @endif
@endforeach