# NAME

report.php - produce MRBS reports

# SYNOPSIS

`report.php [args]`

where args is a space separated list of arguments of the form `param1=value1&param2=value2`. Spaces in the value string and ampersands can normally be escaped with the backslash character ('\'), depending on the shell. Array parameters can be sent by using the '[]' notation, eg `param1[]=valueA&param1[]=valueB`. Array parameters must all appear in the same argument.

# DESCRIPTION

This page describes how to use MRBS reporting from the command line (CLI). Report.php can either be called directly or as a cron job. The script report.php should be called as a parameter to the PHP interpreter. The output of report.php is sent to STDOUT.

The language and locale used for the reports is specified by the config variable $cli_language. The script can only be run from the command line if the MRBS config variable $allow_cli is set to TRUE.

# OPTIONS

`summarize` | The type of report to produce. Permitted values are:
`5` | HTML report
`6` | HTML summary
`7` | HTML report and summary
`9` | CSV report (default)
`10` | CSV summary
`17` | iCalendar (.ics file) report - excluding periods
`day` | The day (1..31) to use as the base date for the reporting period. If any of day, week and month are not specified then today's date will be used as the base date.
`month` | The month (1..12) to use as the base date for the reporting period. If any of day, week and month are not specified then today's date will be used as the base date.
`year` | The year (4 digits) to use as the base date for the reporting period. If any of day, week and month are not specified then today's date will be used as the base date.
`from_day` | The start day (1..31) of the reporting period. If from_day, from_month and from_year are not specified then the base date will be used.
`from_month` | The start month (1..12) of the reporting period. If from_day, from_month and from_year are not specified then the base date will be used.
`from_year` | The start year (4 digits) of the reporting period. If from_day, from_month and from_year are not specified then the base date will be used.
`to_day` | The end day (1..31) of the reporting period. If to_day, to_month and to_year are not specified then the base date + $default_report_days (specified in systemdefaults.inc.php and optionally over-ridden in config.in.php) will be used. Note that the reporting period ends at 0000 on the to_day, so if for example you want a report for all bookings in 2011 the to_date should be 1 Jan 2012.
`to_month` | The end month (1..12) of the reporting period. If to_day, to_month and to_year are not specified then the base date + $default_report_days (specified in systemdefaults.inc.php and optionally over-ridden in config.in.php) will be used.
`to_year` | The end year (4 digits) of the reporting period. If to_day, to_month and to_year are not specified then the base date + $default_report_days (specified in systemdefaults.inc.php and optionally over-ridden in config.in.php) will be used.
`creatormatch` | Limit the report to entries where the creator's user name contains the string.
`areamatch` | Limit the report to entries where the area name contains the string.
`roommatch` | Limit the report to entries where the room name contains the string.
`namematch` | Limit the report to entries where the entry name contains the string.
`descrmatch` | Limit the report to entries where the description contains the string.
`typematch[]` | Limit the report to entries of types X,Y,Z (eg typematch[]=X&typematch[]=Y&typematch[]=Z). Default: all types.
`sortby` | Permitted values are:
`r` | (default) sort by room name
`s` | sort by start time
`display` | Permitted values are:
`d` | (default) show start time and duration
`e` | show start time and end time
`sumby` | The field to use for the first column of the summary table. Permitted values are:
`d` | (default) brief description
`c` | creator's user name
`t` | type
`phase` | The phase of report production. Phase 1 is the gathering of user input from the web page form; Phase 2 is the production of the report or summary. When running from the command line it is not necessary to set this option as it is automatically set to 2 by MRBS. However when running report.php from the web browser or by using wget, setting phase=2 will force report.php to go straight to the production of a report.
custom | Custom fields can be searched for using the same syntax as above.

# RETURN VALUES

Returns 0 on success.

# EXAMPLES

To produce a summary in CSV format of all bookings for 2011, arranged by the creator's name, and send the summary to the file summary.csv:

`/usr/local/bin/php /home/mrbs/report.php summarize=10 from_day=1&from_month=1&from_year=2011 to_day=1&to_month=1&to_year=2012 sumby=c > summary.csv`

The CLI output can be simulated in a browser by putting the parameters in a query string. But note that the parameter `phase=2` must be added to tell MRBS that it is on the second phase of report production (the first phase is gathering the user input from the form; if report.php is called from the command line the phase is automatically set to 2). For example, to simulate the CLI command above enter into the browser:

`report.php?phase=2&summarize=10&from_day=1&from_month=1&from_year=2011&to_day=1&to_month=1&to_year=2012&sumby=c`

When using wget, don't forget to escape ampersands with a backslash. For example:

`wget -O myreport.csv http://localhost/mrbs/report.php?phase=2\&summarize=10\&sumby=c`