Embedding Reports

You can easily embed reportico within your web pages by inserting code within your site views. To embed Reportico you just import the Reportico module, set properties and run it.

In the examples below, note the use of access modes through the access_mode parameter and starting view 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, include the following :-

        $reportico = \Yii::$app->getModule('reportico');
        $engine = $reportico->getReporticoEngine();        // Fetches reportico engine
        $engine->access_mode = "FULL";                     // Allows access to all Reportico pages
        $engine->initial_execute_mode = "ADMIN";           // Starts user in administration page
        $engine->initial_project = "admin";                // Required for access to admin mode
        $engine->bootstrap_styles = "3";                   // Set to "3" for bootstrap v3, "2" for V2 or false for no bootstrap
        $engine->force_reportico_mini_maintains = true;    // Often required
        $engine->bootstrap_preloaded = true;               // true if you dont need Reportico to load its own bootstrap
        $engine->clear_reportico_session = true;           // Normally required
        $engine->execute();                                // Run Reportico
See this in action >>

Embedding a Project Menu

To embed a project menu, include the following :-

        $reportico = \Yii::$app->getModule('reportico');
        $engine = $reportico->getReporticoEngine();        // Fetches reportico engine
        $engine->access_mode = "ONEPROJECT";               // Allows access to all Reportico pages
        $engine->initial_execute_mode = "MENU";            // Starts user in administration page
        $engine->initial_project = "northwind";            // Name of report project folder
        $engine->bootstrap_styles = "3";                   // Set to "3" for bootstrap v3, "2" for V2 or false for no bootstrap
        $engine->force_reportico_mini_maintains = true;    // Often required
        $engine->bootstrap_preloaded = true;               // true if you dont need Reportico to load its own bootstrap
        $engine->clear_reportico_session = true;           // Normally required
        $engine->execute();    
See this in action >>

Embedding a Report in Criteria Entry Mode

To embed a report in criteria entry mode :-

        $reportico = \Yii::$app->getModule('reportico');
        $engine = $reportico->getReporticoEngine();        // Fetches reportico engine
        $engine->access_mode = "ONEREPORT";                // Allows access to single specified report
        $engine->initial_execute_mode = "PREPARE";         // Starts user in report criteria selection mode
        $engine->initial_project = "northwind";            // Name of report project folder    
        $engine->initial_report = "salestotals";           // Name of report to run
        $engine->bootstrap_styles = "3";                   // Set to "3" for bootstrap v3, "2" for V2 or false for no bootstrap
        $engine->force_reportico_mini_maintains = true;    // Often required
        $engine->bootstrap_preloaded = true;               // true if you dont need Reportico to load its own bootstrap
        $engine->clear_reportico_session = true;           // Normally required
        $engine->execute();  
See this in action >>

Embedding Report Ouput

To embed the output of a report :-

        $reportico = \Yii::$app->getModule('reportico');
        $engine = $reportico->getReporticoEngine();        // Fetches reportico engine
        $engine->access_mode = "REPORTOUTPUT";             // Allows access to report output only
        $engine->initial_execute_mode = "EXECUTE";         // Just executes specified report
        $engine->initial_project = "northwind";            // Name of report project folder    
        $engine->initial_report = "salestotals";           // Name of report to run
        $engine->bootstrap_styles = "3";                   // Set to "3" for bootstrap v3, "2" for V2 or false for no bootstrap
        $engine->force_reportico_mini_maintains = true;    // Often required
        $engine->bootstrap_preloaded = true;               // true if you dont need Reportico to load its own bootstrap
        $engine->clear_reportico_session = true;           // Normally required
        $engine->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.

    $engine = App::make("getReporticoEngine");
    $engine->initial_execute_mode = "EXECUTE";
    $engine->access_mode = "REPORTOUTPUT";
    $engine->initial_project = "northwind";
    $engine->initial_project_password = "password"; // If project password required
    $engine->initial_sql = "SELECT CustomerID AS Id, companyname as company, contactname as contact_name FROM customers";
    $engine->set_attribute("ReportTitle","Customer List");
    $engine->clear_reportico_session = true;
    $engine->execute();
See this in action >>

Creating links to reports >>