Coder Social home page Coder Social logo

grizk / php-reports Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jdorn/php-reports

0.0 1.0 0.0 3.55 MB

A PHP framework for displaying reports from any data source, including SQL and MongoDB

Home Page: http://jdorn.github.com/php-reports

License: GNU Lesser General Public License v3.0

ApacheConf 0.03% PHP 39.04% CSS 6.62% JavaScript 54.18% Stata 0.12%

php-reports's Introduction

Php Reports

A reporting framework for managing and displaying nice looking, exportable reports from any data source, including SQL and MongoDB.

Major features include:

  • Display a report from any data source that can output tabular data (SQL, MongoDB, PHP, etc.)
  • Output reports in HTML, XML, CSV, JSON, or your own custom format
  • Add customizable parameters to a report (e.g. start date and end date)
  • Add graphs and charts with the Google Data Visualization API
  • Supports multiple database environments (e.g. Production, Staging, and Dev)
  • Fully extendable and customizable

For installation instructions and documentation, check out http://jdorn.github.io/php-reports/

If you have a question, post on the official forum - http://ost.io/@jdorn/php-reports

Basic Introduction

Reports are organized and grouped in directories. Each report is it's own file.

A report consists of headers containing meta-data (e.g. name and description) and the actual report (SQL queries, javascript, or PHP code).

All reports return rows of data which are then displayed in a sortable/searchable HTML table.

Reports can be exported to a number of formats including CSV, XLS, JSON, and XML.

The Php Reports framework ties together all these different report types, output formats, and meta-data into a consistent interface.

Example Reports

Here's an example SQL report:

-- Products That Cost At Least $X
-- VARIABLE: {"name": "min_price"}

SELECT Name, Price FROM Products WHERE Price > "{{min_price}}"

The set of SQL comments at the top are the report headers. The first row is always the report name.

The VARIABLE header tells the report framework to prompt the user for a value before running the report. Once provided it will be passed into the report body ("{{min_price}}" in this example) and executed.

Here's a MongoDB report:

// List of All Foods
// MONGODATABASE: MyDatabase
// VARIABLE: {
//   "name": "include_inactive", 
//   "display": "Include Inactive?", 
//   "type": "select",
//   "options": ["yes","no"]
// }

var query = {'type': 'food'};

if(include_inactive == 'no') {
    query.status = 'active';
}

var result = db.Products.find(query);

printjson(result);

As you can see, the structure is very similar. MongoDB reports use javascript style comments for the headers, but everything else remains the same.

The MONGODATABASE header, if specified, will populate the 'db' variable.

Here's a PHP Report:

<?php
//List of Payment Charges
//This connects to the Stripe Payments api and shows a list of charges
//INCLUDE: /stripe.php
//VARIABLE: {"name": "count", "display": "Number to Display"}

if($count > 100 || $count < 1) throw new Exception("Count must be between 1 and 100");

$charges = Stripe_Charge::all(array("count" => $count));

$rows = array();
foreach($charges as $charge) {
    $rows[] = array(
        'Charge Id'=>$charge->id,
        'Amount'=>number_format($charge->amount/100,2),
        'Date'=>date('Y-m-d',$charge->created)
    );
}

echo json_encode($rows);
?>

Again, the header format is very similar.

The INCLUDE header includes another report within the running one. Below is example content of /stripe.php:

<?php
//Stripe PHP Included Report
//You can have headers here too; even nested INCLUDE headers!
//Some headers will even bubble up to the parent, such as the VARIABLE header

//include the Stripe API client
require_once('lib/Stripe/Stripe.php');

//set the Stripe api key
Stripe::setApiKey("123456");
?>

Hopefully, you can begin to see the power of Php Reports.

For full documentation and information on getting started, check out http://jdorn.github.io/php-reports/

php-reports's People

Contributors

jdorn avatar uded avatar stanlemon avatar brandom avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.