Topic: Is it possible to extend the function get_ctrl in reports_classes.inc?

Is it possible to extend the function get_ctrl in reports_classes.inc?

How can I add a custom report parameter?

I would like a custom report where a GL account range is selected automatically, to the defined gl accounts needed for the report, but the select gl accounts is still available for the user to select a different range of gl accounts.

Currently there is:-

File: \reporting\includes\reports_classes.inc
270:                 case 'ACCOUNTS': // not used
271:                     return gl_account_types_list($name, null, _("No Account Group Filter"), true);
272: 
273:                 case 'ACCOUNTS_NO_FILTER': // not used
274:                     return gl_account_types_list($name);
275: 
276:                 case 'GL_ACCOUNTS':
277:                     return gl_all_accounts_list($name);

I've tried to add parameters to reports_custom.php:-
_('From Account') => 'GL_ACCOUNTS',
_('To Account') => 'GL_ACCOUNTS',
but nothing worked for me - is this possible?

Another alternative would be to delete the gl account selection parameters and hard code the fromacc to the toacc in the report, but I would prefer a solution to the above.

Any help or advice would be much appreciated

Re: Is it possible to extend the function get_ctrl in reports_classes.inc?

I questioned similar doubt before. But no clue from the core developer. I think we have to extend the functionality of these functions. So we can write custom report parameters from extension itself.

Re: Is it possible to extend the function get_ctrl in reports_classes.inc?

Isn't it supported already? I forget how but I remember saw a method to add custom parameter.

Re: Is it possible to extend the function get_ctrl in reports_classes.inc?

@kvvaradha, thinking out loud here, but this may be relevant... a function cannot be extended it seems, but a class can so looking at:-

File: \reporting\includes\reports_classes.inc
458: class Report
459: {
460:     var $id;
461:     var $name;
462:     var $ar_params;
463:     var $controls;
464:     
465:     function __construct($id, $name, $ar_params = null)
466:     {
467:         $this->id = $id;
468:         $this->name = $name;
469:         if ($ar_params) $this->set_controls($ar_params);
470:     }
471:     
472:     function set_controls($ar_params) {
473:         $this->controls = $ar_params;
474:     }
475:     
476:     function get_controls() {
477:         return $this->controls;
478:     }
479:     
480: }

So function get_controls is only used once in:-

File: \reporting\includes\reports_classes.inc
104:                     $st_params .= $this->getOptions($report->get_controls(), $report->id);

And in function getOptions is the line:-

File: \reporting\includes\reports_classes.inc
146:                 $ctrl = $this->get_ctrl('PARAM_'.$cnt, $type);

also in the same function is:-

File: \reporting\includes\reports_classes.inc
136:             foreach($this->ctrl_handlers as $fun) { // first check for non-standard controls
137:

I'm struggling with my php knowledge, but has @joe/@janusz left us something here?

Re: Is it possible to extend the function get_ctrl in reports_classes.inc?

Why don't you look at the HR module by @notrinos. This is already done there

www.boxygen.pk

Re: Is it possible to extend the function get_ctrl in reports_classes.inc?

Yes, your right @boxygen, I'd not looked at it for a while

Thank you