kuriousagency / bigreports
Run reports on large data sets.
Installs: 963
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 0
Type:craft-plugin
Requires
- craftcms/cms: ^3.3.0
- league/csv: ^8.2
- vova07/yii2-console-runner-extension: ^0.1.2
README
Big Reports is a plugin that allows you to create reports using Twig and have the results emailed to you as a CSV. Ideal for large data sets.
Requirements
This plugin requires Craft CMS 3.0.0 or later.
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require kuriousagency/bigreports
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Craft Reports.
Craft Reports Overview
Set your columns by using the craft.bigreports.service.columns()
method, then add your row data by using the craft.bigreports.service.row()
.
Last thing to do is to use the craft.bigreports.service.data()
method to output the data.
Here is an example report in Twig:
{% do craft.bigreports.service.columns(["Firstname", "Lastname", "email"]) %} {% for user in craft.users.limit(null).all() %} {% do craft.bigreports.service.row([ user.firstName, user.lastName, user.email ]) %} {% endfor %} {{ craft.bigreports.service.data }}
Options
Big Reports can have options that are based on Craft CP forms macro.
{{ craft.forms('dateField', { id: 'startDate', label: "Start Date"|t, name: 'options[startDate]', value: options.startDate }) }}
These options can then be accessed in the results. Here's an example that lists all users that have registered between two dates
{% set users = craft.users. dateCreated(['and','>= ' ~ options.startDate|date('c'),'<= '~ options.endDate|date('Y-m-d 23:59:59')|date('c')]) .all() %} {% do craft.bigreports.service.columns(["Firstname","LastName","Email"]) %} {% for user in users %} {% do craft.bigreports.service.row([ user.firstName, user.lastName, user.email, ]) %} {% endfor %} {{ craft.bigreports.service.data }}
The results are sent as a CSV attachment to the email address specifed on the report
Configuring Big Reports
Reports Template Path
Set the directory to find report templates
Here's an example folder structure
templates _reports users results.twig settings.twig
In the above case you would enter _reports as the template path
Email Template Path
If you would like to use your own email template to send the report you can set it here
Example files
Examples can be found here: https://github.com/KuriousAgency/craft-bigreports/tree/master/examples
Brought to you by Kurious Agency