Embedding Reports

You can easily embed reportico within your web pages by inserting code within to include Reportico and settimg the appropriate parameters. With this approach you can embed anything from a report suite to individual report output.

In the examples below, note the use of access modes through the access_mode parameter, and the start mode set through the initial_execute_mode parameter.

The access mode allows you to limit whether the web visitor is able to access the administrator page, a single project menu or a single report either with or without access to criteria entry. The following access modes are allowed :-

  • FULL - ability to access administrator page and access to report design if the admin password is entered
  • ONEPROJECT - ability to run a report project suite with access to all reports in that project
  • ONEREPORT - ability to run a single report choose crtieria and show report output
  • REPORTOUTPUT - ability to view a single report output but with no access to criteria entry

The initial_execute_mode parameter indicates what view you give on the loading the page :-

  • ADMIN - access to the administrator page
  • MENU - load a project menu - an initial project must be provided
  • PREPARE - show the criteria screen and output selection screen for a report - an initial report must be provided
  • EXECUTE - show report output

See the Reportico documentation section embedding a report within a web page for all the options available for embedding, including suppressing elements of report output, specifiying criteria to reports, specifying external parameters to reportico ( like user, role and other session parameters ).

Examples are below :-

Embedding Reportico in Administrator mode

To embed in admin mode, your web page might look something like:-

<html>
<body>
        .... Start of html page ..

        <?php
        require_once("path/to/reportico.php");        // Include Reportico
        $q = new reportico();                         // Create instance
        $q->access_mode = "FULL";                     // Allows access to all Reportico pages
        $q->initial_execute_mode = "ADMIN";           // Starts user in administration page
        $q->initial_project = "admin";                // Required for access to admin mode
        $q->bootstrap_styles = "3";                   // Set to "3" for bootstrap v3, "2" for V2 or false for no bootstrap
        $q->force_reportico_mini_maintains = true;    // Often required
        $q->bootstrap_preloaded = true;               // true if you dont need Reportico to load its own bootstrap
        $q->clear_reportico_session = true;           // Normally required
        $q->execute();                                // Run Reportico
        ?>

        .... End of html page ..
<body>
<html>
See this in action >>

Embedding a Project Menu

To embed a project menu, include the following :-

        require_once("path/to/reportico.php");        // Include Reportico
        $q = new reportico();                         // Create instance
        $q->access_mode = "ONEPROJECT";               // Allows access to all Reportico pages
        $q->initial_execute_mode = "MENU";            // Starts user in administration page
        $q->initial_project = "northwind";            // Name of report project folder
        $q->bootstrap_styles = "3";                   // Set to "3" for bootstrap v3, "2" for V2 or false for no bootstrap
        $q->force_reportico_mini_maintains = true;    // Often required
        $q->bootstrap_preloaded = true;               // true if you dont need Reportico to load its own bootstrap
        $q->clear_reportico_session = true;           // Normally required
        $q->execute();    
See this in action >>

Embedding a Report in Criteria Entry Mode

To embed a report in criteria entry mode :-

        require_once("path/to/reportico.php");        // Include Reportico
        $q = new reportico();                         // Create instance
        $q->access_mode = "ONEREPORT";                // Allows access to single specified report
        $q->initial_execute_mode = "PREPARE";         // Starts user in report criteria selection mode
        $q->initial_project = "northwind";            // Name of report project folder    
        $q->initial_report = "salestotals";           // Name of report to run
        $q->bootstrap_styles = "3";                   // Set to "3" for bootstrap v3, "2" for V2 or false for no bootstrap
        $q->force_reportico_mini_maintains = true;    // Often required
        $q->bootstrap_preloaded = true;               // true if you dont need Reportico to load its own bootstrap
        $q->clear_reportico_session = true;           // Normally required
        $q->execute();  
See this in action >>

Embedding Report Ouput

To embed the output of a report :-

        require_once("path/to/reportico.php");        // Include Reportico
        $q = new reportico();                         // Create instance
        $q->access_mode = "REPORTOUTPUT";             // Allows access to report output only
        $q->initial_execute_mode = "EXECUTE";         // Just executes specified report
        $q->initial_project = "northwind";            // Name of report project folder    
        $q->initial_report = "salestotals";           // Name of report to run
        $q->bootstrap_styles = "3";                   // Set to "3" for bootstrap v3, "2" for V2 or false for no bootstrap
        $q->force_reportico_mini_maintains = true;    // Often required
        $q->bootstrap_preloaded = true;               // true if you dont need Reportico to load its own bootstrap
        $q->clear_reportico_session = true;           // Normally required
        $q->execute();  
See this in action >>

Embedding SQL Results without a Report

You can run report output without having to create a report. Just set the reportico project that relates to the database you want to run against (using the initial_project parameter) and use the initial_sql parameter to provide the SQL query. Note you cannot use the SELECT * notation in Reportico, you have to specify report columns.
Notice how column aliases in the SQL are used to set column titles.

    require_once("path/to/reportico.php");        // Include Reportico
    $q = new reportico();                         // Create instance
    $q->initial_execute_mode = "EXECUTE";
    $q->access_mode = "REPORTOUTPUT";
    $q->initial_project = "northwind";
    $q->initial_project_password = "password"; // If project password required
    $q->initial_sql = "SELECT CustomerID AS Id, companyname as company, contactname as contact_name FROM customers";
    $q->set_attribute("ReportTitle","Customer List");
    $q->clear_reportico_session = true;
    $q->execute();
See this in action >>

Creating links to reports >>