[Module] Reportico Report Writer

Hi there

I do much of the development on Reportico (open source php report writer) at reportico.org

I recently needed to incorporate this into a Yii application I have been involved with, so I thought I’d write a module for it. I have developed a first cut of this, and i’d appreciate any comments.

I have added a Yii page to the Reportico web site where you can download this module. It also provides getting started information and examples. It is here:-


I hope this is useful … Please let me know what you think.

Peter Deed

First of let me say I REALLY love reportico! It is well written and extremely useful. I was trying to just the regular version of reportico and ran into some issues with relative URLS to my project when I tried to embed it into a page. It looked great inside the project suite, however all the images where gone and I had to manually add the css links when I embeded a report in a page. Once I saw that you had a Yii module I was very excited because I figured that these issues would be addressed in said module.

So I installed the module and started through the steps to update the admin password when I discovered an issue that I’m not exactly sure how to resolve. My site uses the ‘path’ style of URL instead of the ‘get’ style. That is to say that URLS come in the flavor of “index.php/controller/action” instead of “index.php?r=controller/action”. Many of the URL components are hard-coded into the module and in their current state it seems they are incompatible with path style urls.

Thanks very much for the information…

i must admit im not the most experienced with yii and wasnt really too aware of the path method

Ive just changed my setup to path method and it seems like you say to be very broken :-(…

Im hoping its not too difficult to fix … ill see how i get on


Awesome, please let me know how it comes out. I’ll let you know if I run into any other issues!

Hi enotirab

Ive put a new version of the module up on the site at the same location :-


This now should work in both "path" and "get" modes … fingers crossed!

Also ive fixed it up so it works better with yii-bootstrap if thats of any use.

Please let me know how you get on if you try it …

Good Luck!


Works exceptionally well! This module also got ride of some issues I was experience with regular version of Reportico and Yii sessions conflicting. Excellent work.

Okay, follow up question for you. Not sure if you want these here or on the reportico forums.

One thing I really like about your setup is that you can include criteria with an [] to have it conditionally added to a query if it is included; this is SUPER handy. I am in a situation where I need the exact same behavior on a PreSQL query, but with user parameters. I’m using an embedded report with a custom interface so I have need to pass criteria that the user enters into Reportico. User parameters serve this purpose but if I do something like have a PreSQL that looks like:

SELECT trans_id, amount, date FROM transactions WHERE

amount > 50

[AND date >= {USER_PARAM,sDate}]

ect I get an error if sDate is not set or is set to NULL. I’d like to be able pass sDate to Reportico in such a way that it will conditionally add the parameter to the query if it is set.

I can imagine doing this in one of three ways.

  1. If user parameters are conditionally added based upon them being set, like criteria is.

  2. Manually pass in criteria on the page the embeds the report.

  3. Have access to the PreSql code on that page to problematically alter it based on user input.

Is there a way to already do this that I am missing?

Ok thats an interesting one…

I think the ability to make the user_parameters conditional would be the best way as per your suggestion…

I just got it working by passing the whole Where clause in the parameter … so

SELECT trans_id, amount, date FROM transactions WHERE

amount > 50


and pass in with

$q->user_parameters[“sDate”] = “WHERE date > ‘2013-10-01’”;

I know its not ideal but does that help?

Well I’m a little embarrassed that I didn’t even think of that. It also occurred to me that I could last night that I could just build the temp-table from the PreSql in the custom code and to the whole thing programmatically also.

Thanks for the provided solution. I realize I’m using Reportico slightly out of the scope it was probably designed for; your help if greatly appreciated.

Oh, one final issue. Since I’m embedding just the output for a report, if I enter criteria that returns no data set, it takes me back to the criteria entry section with a message displaying that there is no data returned, which would be fine if I wasn’t using a custom interface. Is there a way to suppress this behavior and instead either just show the header columns with no data, or perhaps just get a message only without switching mode when in output only mode?

Nevermind on that last one. Found your suggestion

here. Works fine.

wow amazed you found that… glad it solved your problem.

Hi Reportico,

Firstly, thanks for your efforts to bring Reportico to Yii.

I’m trying to get reportico set up on my Yii application (as per your install instructions). When I try to navigate to <my application>/index.php/reportico I get an error: Call to undefined method reportico::getIsInitialized()

Is this something you’ve come across before? Any suggestions?

I resolved my issue by adding:

function getIsInitialized(){

            return true;


to class reportico (reportico.php)

Thanks for finding this… I havent seen that error come up in my tests, so im interested in what is causing it. I notice that the function is required if a component is derived from a CApplicationComponent or implements IApplicatonComponent, but reportico doesnt. So im guessing that some other yii configuration is causing the reportico component inside the reportico module to be treated as behaving like an Application Component?

Do you have any ideas?

On the basis that this can easily happen elsewhere, I have actually done what you said and uploaded a newer version with that method defined in the reportico class!

I just installed YiiReportico, and am so far VERY impressed.

I do have a question: I have built a very robust user/group security model for my application. Is there a simple way to bypass the admin/project passwords so that I can pass in whether a user is authenticated and at what level? This would let my users have SSO access to do what they need without a shared project password.

In my application controllers I have code that looks something like this:

public function accessRules()



return array(



		'expression'=&gt;&quot;&#036;{_permissions['canRead']} === 1&quot;,




		'expression'=&gt;&quot;&#036;{_permissions['canUpdate']} === 1&quot;,




		'expression'=&gt;&quot;&#036;{_permissions['canAdmin']} === 1&quot;,




If you modify protected/modules/reportico/ReporticoModule.php you can add some extra parameters which can be picked in reports…

so if you find the text …

        $this->engine->embedded_report = true;

        $this->engine->allow_debug = true;

        $this->engine->framework_parent = "yii";

        $this->engine->external_user = Yii::app()->user->id;

        $this->engine->url_path_to_assets = $this->getAssetsUrl();

Add some more

        $this->engine->user_parameters = array();

        $this->engine->user_parameters["authenticated"] = isauthenticatedtest();

        $this->engine->user_parameters["authentication_level"] = isauthenticatedtest();

then you can pick this up in report SQL using something like


       SELECT x 

       FROM y

       WHERE 1 = 1

       AND {USER_PARAM,authenticated} = '1'

       AND {USER_PARAM,authentication_level} = 'admin'

You can pass in any value in using the user_parameter array.

When you press Ok to store the SQL it may report a syntax error but just ignore this … it should work when you run it

Peter Deed

i love just about everything about Reportico, but i am pulling my hair out trying to pass user parameters. i’m using identical syntax to what’s used below, in an embedded yii report, and i am CONSTANTLY getting the “[size=2]Main Query - Error: User parameter fid, specified but not provided to reportico.[/size][size=2]” what on earth could i be doing wrong? i’ve even done a print_r of the reportico object and i can see that the value is being passed.[/size]



[size=2]sorry for the frustration but i’ve spend several hours on this over the weekend and this really should be a no brainer.[/size]

Hi there

Sorry you are having such a problem…

Im suspecting that although your values are being passed, they may not be saved properly in the session…

Do you know if you are using the version 3.2 from a few months ago ( where i know there is a problem )

or the version 4.1 i released about a week ago which should work?

If you are using the 3.2 version then you could try adding code to store the user_parameters through the session…

on around line 3427 of modules/reportico/components/reportico.php there is a line

$this->access_mode = session_item("access_mode", $this->access_mode );

if you after this

$this->user_parameters = session_item("user_parameters", $this->user_parameters );

If you are using new 4.1 it should work already, so let me know and i can debug it but at line modules/reportico/components/reportico.php there is a line :-

$this->user_parameters = register_session_param("user_parameters", $this->user_parameters);

you could put a check of print_r after this.

Anymay let me know some more and i can look further