report.pdf
component receives a command line parameters that are passed on to the Reportman or to the ODT Report library which in turn generate a report. report
variable. If there is no suffix the utility is chosen based on value of the DefaultReportEngine
variable from the Apache config file. report
is originally passed to the printSelected() function.
On this page:
report.pdf
component prepares a command line options that are passed to a Reportman
scripts and prints the produced report file to the specified output.
Argument Name or Parameter Name![]() |
Description | Default Value |
---|---|---|
$send_pdf |
If Cups printer is not defined print the produced report file to output using $m->out(...) If both $cups_printer and $send_pdf are not defined the report file is produced but is not printed. |
1 |
$report_ids |
Is used by the ODT Reportman to select the records from which to generate the report. | Not defined. |
$report |
The file name of the Reportman configuration file without extension. | Not defined. |
$path_pdf |
The filepath of the output report file in .pdf format. |
$r->dir_config('TmpDir')."/report.$$.pdf" |
$GROUP_ID |
Is used by the Reportman to select the records from which to generate the report. | Not defined. |
$cups_printer |
If defined, instead of sending the file with $m->out(...) ,send the file to the indicated Cups printer. The Cups printer is called with the commandline: /usr/bin/lp -d $cups_printer $PDF |
Not defined. |
$base |
The directory that contains the Reportman configuration files (.rep ). |
$r->dir_config('DataBaseUrl') |
$ARGS{PROTECT} |
If this option is defined the produced output report file is encrypted. The commandline that encrypts the report file is: /usr/bin/qpdf --linearize --encrypt $ARGS{PROTECT} 40 --modify=n --annotate=n -- $file_orig $PDF |
Not defined. |
$ARGS |
Each of the remaining parameters is passed to the Repotman as the -paramParamName=<param_value> option or to the ODT Reportman as the param_name='param_value' option. |
apt-get -y install libxml-simple-perl cpan XML::Simple::Sorted cpan IPC::Run::SafeHandles cpan Text::Balanced
ODF::lpOD
incompatibility with the Perl version 5.14
, used by MasonSQL in some deployments, the Perlbrew must be installed to use a newer version of Perl. root
user:
sudo /opt/masonsql/utility/perlbrew-deploy.sh
# Proceed with root privileges. sudo su - # Install latest System.LibreOffice (5.0 or later). # Ubuntu Precise (12.04) apt-get install python-software-properties # Ubuntu Trusty (14.04) # apt-get install software-properties-common sudo add-apt-repository ppa:libreoffice/ppa sudo apt-get update apt-get install openjdk-9-jre libreoffice-writer # Se si utilizzano anche i file ODS apt-get install libreoffice-calc # Install pdftk. apt-get install pdftk
.odt
files to .pdf
format.OdtConvEngine
environment variable must be configured with "OdtConvEngine" as an alternative to "libreoffice".
# Proceed with root privileges. sudo su - # Install latest Unoconv. cd /tmp apt-get install git git clone https://github.com/dagwieers/unoconv cd unoconv/ make install cd ../ rm -rf unoconv/ # Ubuntu Trusty (14.04) - You must use python3 sed -i~ 's/^#!\/usr\/bin\/env python$/#!\/usr\/bin\/env python3/' /usr/bin/unoconv # Install and start Unoconv daemon. ln -s /opt/masonsql/etc/unoconvd /etc/init.d/unoconvd update-rc.d unoconvd defaults service unoconvd start
/opt/masonsql/utility/sql/odt_report_tables.mql
file.
Before applying the queries the owner name postgres
must be changed to the new owner name my_db_owner_name
.
/opt/my_app_name/etc/apache2.my_app_name-devel.my_domain_name.conf
file:
# Path of this apache configuration file PerlSetVar ConfigPath /opt/my_app_name/etc/apache2.my_app_name-devel.my_domain_name.conf # Temporary directory PerlSetVar TmpDir /opt/my_app_name/tmp # Default report engine configuration: # rep = old Report Manager # odt = new ODT Report printed in odt format # pdf = new ODT Report printed in pdf format PerlSetVar DefaultReportEngine "pdf" # ODT Reportman's access to DB PerlSetVar ReportDBIconnect "dbi:Pg:dbname=my_db_name;user=report;password=MyReportPassword" # Archive for templates PerlSetVar InputFilesArchive "/opt/my_app_name/archive"The
InputFilesArchive
is used by Files Component. The component stores its files in the sub-directories which must be created:
cd /opt/my_app_name/archive mkdir public chown www-data:www-data public mkdir odt_reports chown root:www-data odt_reports chmod 775 odt_reportsWithout correct access permissions for the application's Apache config file the ODT Report Manager returns an error. Example of correctly set permissions:
-rw-r----- 1 root www-data 10182 Aug 19 12:13 /opt/my_app_name/etc/apache2.labs.leader.it.confIn order to apply changes, Apache configuration file must be reloaded:
/etc/init.d/apache2 reload
public.odt_reports
table which can be managed by users with ODT Reports
web interface.
public.odt_reports
table. For application specific reports the name of the report must also have app_schema_name.
prefix. [Stampa]
or [St.sel]
buttons or with customarily created buttons.
The buttons must then call the report with printSelected() function, which triggers the generation of the report.
The application composes the report name by using the PRINT_FORM method in combination with parameters passed to the printSelected()
function.
The report name is then searched in the database and report is generated from the provided input parameters.
The report name is composed in the following order: PRINT_FORM
(not null for security).
report_suffic
parameter passed to the printSelected()
function.
report_suffix
parameter contains a suffix that indicates the report method (.pdf ...), the suffix is excluded from the report name.
report
parameter, to determine which report method to use.
The only possible report methods are pdf
, odt
and rep
.
In consequence the application will report an error if it finds any other suffix after the dot character;
Thus in case the report
parameter contains dots the suffix after the last dot must be a valid report method. The report method suffix will not get included in the report name.
[Stampa]
and [St.sel]
buttons should automatically become enabled.
The user must also have the Print
and PrintSel
permissions.
For example for the public.anagrafiche
table it is sufficient to set the name of the report to anagrafiche
:
Config->Anagrafiche
menu has [St.sel]
and [Stampa]
buttons enabled:
sel
type and report
name concatenated with .pdf
suffix:
<button onclick="<%$Display%>.printSelected('sel', '_my_report.pdf');">Example</button>The report name could be complete report name but also it can be part of the report name. When the PRINT_FORM is defined its first argument can additionally define
schema_name/table_name
:
<%method PRINT_FORM>my_schema/my_table, PORTRAIT, PARAM1=3 %></%method>In case of such
PRINT_FORM
definition, the actual report name in the public.odt_reports
table must be my_schema.my_report
.
Config->Gruppi
form from the MasonSQL framework. Previous Reportman report exists for this form, so the new ODT version can be compared to the old Wine version. Final report in the example will look like this: gruppi.pdf
Report Name
field must have a correct name. In this example the report is intended for the public.gruppi
table and the default PRINT_FORM is used, so its sufficient to name the report gruppi
. See: How to Correctly Configure a Report Name for more comprehensive explanation.
gruppi
(but in other cases also with a parameter to be passed to a database function).
Here's the father query:
select gruppi.* from gruppi where {{ ARGV.REPORT_ID }} > 0 and gruppi.id = {{ ARGV.REPORT_ID }}The command-line parameter
REPORT_ID
is provided by the framework although its test value can be set in the Test parameters:
input field:
id | nome | descrizione | commento ----+------------+---------------------------+---------- 5 | Gas_admins | Gruppo amministratori GAS | (1 riga)
{{ G.id }}
. G
reference is declared in the Portion Name of the portion. The tag is rendered before the query gets executed. The query marks each authorized privilege of a function with capital X
:
select distinct funzioni.nome , (select distinct case when id_autorizzazioni is not null then 'X' else '' end from gruppi_funzioni gf where gf.id_funzioni = gg.id_funzioni and gf.id_autorizzazioni = 1) as m_menu, (select distinct case when id_autorizzazioni is not null then 'X' else '' end from gruppi_funzioni gf where gf.id_funzioni = gg.id_funzioni and gf.id_autorizzazioni = 2) as m_select, (select distinct case when id_autorizzazioni is not null then 'X' else '' end from gruppi_funzioni gf where gf.id_funzioni = gg.id_funzioni and gf.id_autorizzazioni = 3) as m_update, (select distinct case when id_autorizzazioni is not null then 'X' else '' end from gruppi_funzioni gf where gf.id_funzioni = gg.id_funzioni and gf.id_autorizzazioni = 4) as m_delete, (select distinct case when id_autorizzazioni is not null then 'X' else '' end from gruppi_funzioni gf where gf.id_funzioni = gg.id_funzioni and gf.id_autorizzazioni = 5) as m_print, (select distinct case when id_autorizzazioni is not null then 'X' else '' end from gruppi_funzioni gf where gf.id_funzioni = gg.id_funzioni and gf.id_autorizzazioni = 6) as m_printsel, (select distinct case when id_autorizzazioni is not null then 'X' else '' end from gruppi_funzioni gf where gf.id_funzioni = gg.id_funzioni and gf.id_autorizzazioni = 7) as m_insert from funzioni inner join gruppi_funzioni gg on gg.id_funzioni = funzioni.id inner join autorizzazioni on gg.id_autorizzazioni = autorizzazioni.id where gg.id_gruppi= {{ G.id }} order by funzioni.nome
{{ G.id }}
which is passed to the sub-query from the father query:
select anagrafiche.* from anagrafiche, anagrafiche_gruppi ag where ag.id_gruppi = {{ G.id }} and ag.id_anagrafiche = anagrafiche.id order by nome;
Filename
field of the corresponding base template portion:
Portion Name
must be added. The corresponding DTL tag can be used in the gruppi.odt as: {{ my_portion_name.my_field_name }}
Obj.Reference
field must correspond to its section or table name in the gruppi.odt
.
Obj.Reference
since a group information can be printed in the TabellaGruppo
table header. The father section prints both child portions, a pair for each group from the father query.
Here's the described father-children configuration:
gruppi.odt
:
Report Fields
table. This mapping makes possible other practical uses as well. While the standard usage of the ODF variables in the ODT template documents remains intact.
A simple variable (opposed to an user variable) can be added to the document template by choosing: [Insert] --> [Field] --> [More Fields] --> [Variables] --> [Set variable]
or by pressing CTRL+F2
.
Available types of a simple variable are: string
float
currency
percentage
boolean
date
time
date
and time
types are converted internally, by the ODT Reportman, to the string
type. For additional information about ODT variables see also: ODT Variables User's Guide.
A DTL tag can be utilized in a simple variable in two ways. Firstly, it can be added to the variable name. In such a case the variable content is rendered directly with DTL tag value. For example like this:
{{ AZ.m_menu }}Using the DTL tag name as the variable name in the
gruppi.odt
template:
Value
field of the Report Fields
table. The following example shows mapping of the variable name to the Value
string containing only one DTL tag:
Formatting
field in the Report Fields
table. The Formatting
field can be applied to date
, time
and even to string
variable types. The field is used as a formatting string for the sprintf statement. An example of a formatting string of a string
type variable is:
{% if F.d.0 %}€ %.2f{% endif %}In case the
Formatting
field is rendered as an empty string, the variable's value is equal to the content of the Value
field thus the sprintf is not used. This last fact is useful with the string
type variables: When the Value
and the Formatting
fields are rendered empty the variable value will become empty string, which is not possible to achieve with other types of variables.
.rep
suffix for the report name.
report.pdf
component prepares a commandline options that are passed to the Reportman
and prints the produced report file to the specified output. SERVER, DATABASE, USER
and PASSWORD
values in the ADOConnectionString
from the .rep
configuration file with values from the Apache configuration file.