SlideShare a Scribd company logo
1 of 19
Generating reports with
the Forena module
Session topics

Intro

The Forena module itself

RCN2: project to create reports for

Real life samples

Q&A
Introducton

Forena: one of hidden gems

Could be an alternative for Views

Version 7.x

Session outcome for visitors
The Forena Reports module

Allows to generate reports when you have SQL to get data
from DB;

Actually, this might be not only Drupal DB;

… and even not only database;

Report consists from 2 parts — SQL and kind of extended
HTML;

Included nice sample reports in the package;

Have a several video screencasts in English;

About ¾ of potentially custom reports can be done with
Forena
Sample report
Data
SQL
Format
Sample report
Data
SQL
Format
--ACCESS=access demo reports
select * from states
ORDER BY name
Data
SQL
Data
SQL
Data
SQL
Format
<body>
<div frx:block="sampledb/states" id="forena-1">
<table>
<thead>
<tr>
<th>code</th>
<th>name</th>
</tr>
</thead>
<tbody>
<tr frx:foreach="*" id="forena-2" class="test {code}">
<td>{code}</td>
<td>{name}</td>
</tr>
</tbody>
</table>
</div>
</body>
Need more?
1) Field modifiers:
<frx:field id="date"
format="iso_date"
format-string="Y-m-d"/>
<frx:field id="total_cost"
format="php"
format-string="return
RcnFormats::currency_format($value);"/>
2) Parameters;
3) Formatters
Need more?
1) Field modifiers;
2) Parameters in SQL:
... WHERE j.job_id_pk = :job_id
3) Formatters
Need more?
1) Field modifiers;
2) Parameters in SQL;
3) Formatters:
natively provided export to popular formats like
CSV, XML, … :
<frx:docgen>
<frx:doc type="..."/>
</frx:docgen>
RCN2: a few words about the
applied project

Intranet ERP system;

Complex business logic;

Shared database with a few other systems;

Reporting is one of crucial parts;
RCN2: Postgres related info

Datasets aren't huge but diversed — there's
many specialized heavily linked tables;

Active usage of Postgres-specific features;
Solution

Views/Custom pages/Forena reports —
approximately 20% - 20% - 60%;

About 80 *.frx files on production website;
Real life report SQLs – 1/3
Your SQL can be complicated: i.e. some kinky WITH()
--ACCESS=can access reports
WITH base_model_info as (
SELECT m.model_desc base_model
,m.model_id_pk estimate_model_id
,mc.model_component_id_pk model_component_id_pk
FROM model_components mc JOIN models m
ON(mc.model_id_fk = m.model_id_pk)
WHERE model_component_type = 'Base'
)
SELECT
c.composite_id_pk Composite_ID
,c.composite_desc Composite_Description
,bmi.base_model Base_Model
...
Real life report SQLs – 2/3
Mighty WHEN-THEN-ELSE, JOINS and GROUP BY's
... FROM v_job_latest_status
INNER JOIN v_jobs_no_contract_value j ON v_job_latest_status.job_id_fk =
j.job_id_pk
LEFT JOIN v_jobmst jm ON j.rdms_job_number = jm.job_number
LEFT JOIN (
SELECT job_id,
SUM(
COALESCE(amount, 0) *
CASE
WHEN amount_key_name = 'debit_nett_amount' OR
amount_key_name = 'amount_excl_gst'
THEN 1
WHEN amount_key_name = 'credit_nett_amount' OR
amount_key_name = 'credit_net_amount' THEN -1
ELSE 0
END
) AS expenditure
FROM v_job_order_expenditure
GROUP BY job_id
) AS e ON e.job_id = j.job_id_pk
LEFT JOIN ( ...
Real life report SQLs – 3/3
Brutal UNION and all that jazz together
... from v_cost_report
where group_id = :gl_group
union
select cast(category_id as text) as ordering , 'header' as
rowtype, null as job_number, null as supplier_name,
null as invoice_number, null as invoice_date, category_name as
transaction_description, cast(null as numeric) as amount
from v_cost_report
where group_id = :gl_group
and effective_date > :from_date
and effective_date < :to_date
union
select category_id||'-z' as ordering , 'cat total' as
rowtype,null as job_number, null as supplier_name, ...
Hints and links

http://drupal.org/project/forena

7.x-3.4 is out, we've spoken about 7.x-2.x
(supporting SVGGraph, etc)

Could be a good step from 7.x to 8.x
About me

Area of interests and expertise:

Backend programming;

Drupal as a CMF;

Aegir, Mediamosa;

Troubleshooting.
Questions?
dennis.povshedny@gmail.com
+38 096 2323 346
http://drupal.org/user/117896
www.slideshare.net/workingday
www.linkedin.com/in/1dennis1

More Related Content

Similar to Drupal CMS: generating reports with the Forena module.

MySQL Administration and Monitoring
MySQL Administration and MonitoringMySQL Administration and Monitoring
MySQL Administration and Monitoring
Mark Leith
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
InSync Conference
 
Database Foundation Training
Database Foundation TrainingDatabase Foundation Training
Database Foundation Training
Franky Lao
 

Similar to Drupal CMS: generating reports with the Forena module. (20)

Sql Nexus
Sql NexusSql Nexus
Sql Nexus
 
]po[ Developers: Reporting, Indicators & Dashboards
]po[ Developers: Reporting, Indicators & Dashboards]po[ Developers: Reporting, Indicators & Dashboards
]po[ Developers: Reporting, Indicators & Dashboards
 
MSBI Online Training in India
MSBI Online Training in IndiaMSBI Online Training in India
MSBI Online Training in India
 
MSBI Online Training in Hyderabad
MSBI Online Training in HyderabadMSBI Online Training in Hyderabad
MSBI Online Training in Hyderabad
 
MySQL Administration and Monitoring
MySQL Administration and MonitoringMySQL Administration and Monitoring
MySQL Administration and Monitoring
 
web programming using html,css, JavaScript ,php etc
web programming using html,css, JavaScript ,php etcweb programming using html,css, JavaScript ,php etc
web programming using html,css, JavaScript ,php etc
 
Evolutionary db development
Evolutionary db development Evolutionary db development
Evolutionary db development
 
Raybiztech Guide To Backbone Javascript Library
Raybiztech Guide To Backbone Javascript LibraryRaybiztech Guide To Backbone Javascript Library
Raybiztech Guide To Backbone Javascript Library
 
Create Components in TomatoCMS
Create Components in TomatoCMSCreate Components in TomatoCMS
Create Components in TomatoCMS
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
 
Euclid Data Model 101 - Episode 01: Overview
Euclid Data Model 101 - Episode 01: OverviewEuclid Data Model 101 - Episode 01: Overview
Euclid Data Model 101 - Episode 01: Overview
 
Generating Code with Oracle SQL Developer Data Modeler
Generating Code with Oracle SQL Developer Data ModelerGenerating Code with Oracle SQL Developer Data Modeler
Generating Code with Oracle SQL Developer Data Modeler
 
Data Tracking: On the Hunt for Information about Your Database
Data Tracking: On the Hunt for Information about Your DatabaseData Tracking: On the Hunt for Information about Your Database
Data Tracking: On the Hunt for Information about Your Database
 
Workload Management with MicroStrategy Software and IBM DB2 9.5
Workload Management with MicroStrategy Software and IBM DB2 9.5Workload Management with MicroStrategy Software and IBM DB2 9.5
Workload Management with MicroStrategy Software and IBM DB2 9.5
 
A
AA
A
 
Analysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptxAnalysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptx
 
Database Foundation Training
Database Foundation TrainingDatabase Foundation Training
Database Foundation Training
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructured
 
Terraform Modules Restructured
Terraform Modules RestructuredTerraform Modules Restructured
Terraform Modules Restructured
 
Top Ten Siemens S7 Tips and Tricks
Top Ten Siemens S7 Tips and TricksTop Ten Siemens S7 Tips and Tricks
Top Ten Siemens S7 Tips and Tricks
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 

Drupal CMS: generating reports with the Forena module.

  • 2. Session topics  Intro  The Forena module itself  RCN2: project to create reports for  Real life samples  Q&A
  • 3. Introducton  Forena: one of hidden gems  Could be an alternative for Views  Version 7.x  Session outcome for visitors
  • 4. The Forena Reports module  Allows to generate reports when you have SQL to get data from DB;  Actually, this might be not only Drupal DB;  … and even not only database;  Report consists from 2 parts — SQL and kind of extended HTML;  Included nice sample reports in the package;  Have a several video screencasts in English;  About ¾ of potentially custom reports can be done with Forena
  • 6. Sample report Data SQL Format --ACCESS=access demo reports select * from states ORDER BY name Data SQL Data SQL
  • 7. Data SQL Format <body> <div frx:block="sampledb/states" id="forena-1"> <table> <thead> <tr> <th>code</th> <th>name</th> </tr> </thead> <tbody> <tr frx:foreach="*" id="forena-2" class="test {code}"> <td>{code}</td> <td>{name}</td> </tr> </tbody> </table> </div> </body>
  • 8. Need more? 1) Field modifiers: <frx:field id="date" format="iso_date" format-string="Y-m-d"/> <frx:field id="total_cost" format="php" format-string="return RcnFormats::currency_format($value);"/> 2) Parameters; 3) Formatters
  • 9. Need more? 1) Field modifiers; 2) Parameters in SQL: ... WHERE j.job_id_pk = :job_id 3) Formatters
  • 10. Need more? 1) Field modifiers; 2) Parameters in SQL; 3) Formatters: natively provided export to popular formats like CSV, XML, … : <frx:docgen> <frx:doc type="..."/> </frx:docgen>
  • 11. RCN2: a few words about the applied project  Intranet ERP system;  Complex business logic;  Shared database with a few other systems;  Reporting is one of crucial parts;
  • 12. RCN2: Postgres related info  Datasets aren't huge but diversed — there's many specialized heavily linked tables;  Active usage of Postgres-specific features;
  • 13. Solution  Views/Custom pages/Forena reports — approximately 20% - 20% - 60%;  About 80 *.frx files on production website;
  • 14. Real life report SQLs – 1/3 Your SQL can be complicated: i.e. some kinky WITH() --ACCESS=can access reports WITH base_model_info as ( SELECT m.model_desc base_model ,m.model_id_pk estimate_model_id ,mc.model_component_id_pk model_component_id_pk FROM model_components mc JOIN models m ON(mc.model_id_fk = m.model_id_pk) WHERE model_component_type = 'Base' ) SELECT c.composite_id_pk Composite_ID ,c.composite_desc Composite_Description ,bmi.base_model Base_Model ...
  • 15. Real life report SQLs – 2/3 Mighty WHEN-THEN-ELSE, JOINS and GROUP BY's ... FROM v_job_latest_status INNER JOIN v_jobs_no_contract_value j ON v_job_latest_status.job_id_fk = j.job_id_pk LEFT JOIN v_jobmst jm ON j.rdms_job_number = jm.job_number LEFT JOIN ( SELECT job_id, SUM( COALESCE(amount, 0) * CASE WHEN amount_key_name = 'debit_nett_amount' OR amount_key_name = 'amount_excl_gst' THEN 1 WHEN amount_key_name = 'credit_nett_amount' OR amount_key_name = 'credit_net_amount' THEN -1 ELSE 0 END ) AS expenditure FROM v_job_order_expenditure GROUP BY job_id ) AS e ON e.job_id = j.job_id_pk LEFT JOIN ( ...
  • 16. Real life report SQLs – 3/3 Brutal UNION and all that jazz together ... from v_cost_report where group_id = :gl_group union select cast(category_id as text) as ordering , 'header' as rowtype, null as job_number, null as supplier_name, null as invoice_number, null as invoice_date, category_name as transaction_description, cast(null as numeric) as amount from v_cost_report where group_id = :gl_group and effective_date > :from_date and effective_date < :to_date union select category_id||'-z' as ordering , 'cat total' as rowtype,null as job_number, null as supplier_name, ...
  • 17. Hints and links  http://drupal.org/project/forena  7.x-3.4 is out, we've spoken about 7.x-2.x (supporting SVGGraph, etc)  Could be a good step from 7.x to 8.x
  • 18. About me  Area of interests and expertise:  Backend programming;  Drupal as a CMF;  Aegir, Mediamosa;  Troubleshooting.
  • 19. Questions? dennis.povshedny@gmail.com +38 096 2323 346 http://drupal.org/user/117896 www.slideshare.net/workingday www.linkedin.com/in/1dennis1