1

(19 replies, posted in Modules Add-on's)

kvvaradha wrote:

There is a small change in the core of pdf_report.inc will  give us a good way to add template form from the module itself.

from the reporting/includes/pdf_report.inc:

function NewPage() 
    {
        global $installed_extensions, $path_to_root;
    
    
        if ($this->pageNumber==0)
        {
            // check if there is pdf header template for this report
            // and set if it is found
            $tmpl_pdf = find_custom_file("/reporting/forms/".$this->headerTmpl.".pdf");
            if ($tmpl_pdf) {
                $this->tmplSize = $this->setSourceFile($tmpl_pdf);
            } else {
                // include reports installed inside extension modules
                if (count($installed_extensions) > 0)
                {
                    $extensions = $installed_extensions;
                    foreach ($extensions as $ext)
                        if (($ext['active'] && $ext['type'] == 'extension')) {
                            $tmpl_pdf = find_custom_file($path_to_root.'/'.$ext['path']."/reporting/forms/".$this->headerTmpl.".pdf");
                            if ($tmpl_pdf) {
                                $this->tmplSize = $this->setSourceFile($tmpl_pdf);
                            }
                        }
                }
            }
        }

        $this->pageNumber++;
        parent::newPage();

        if ($this->tmplSize) {
            $this->row = $this->pageHeight - $this->topMargin; // reset row
            $id = $this->importPage(min($this->pageNumber, $this->tmplSize));
            $this->useTemplate($id);
        }

        // include related php file if any
        $tmpl_php = find_custom_file("/reporting/forms/".$this->headerTmpl.".php");
        if ($tmpl_php) {
            include($tmpl_php);
        }  else {
                // include reports installed inside extension modules
                if (count($installed_extensions) > 0)
                {
                    $extensions = $installed_extensions;
                    foreach ($extensions as $ext)
                        if (($ext['active'] && $ext['type'] == 'extension')) {
                            $tmpl_php = find_custom_file($path_to_root.'/'.$ext['path']."/reporting/forms/".$this->headerTmpl.".php");
                            if ($tmpl_php) {
                                $this->tmplSize = $this->setSourceFile($tmpl_php);
                            }
                        }
                }
            }

        if (method_exists($this, $this->headerTmpl))    // draw predefined page layout if any
            $this->{$this->headerTmpl}();
    }

This would help us to hook from the modules template to work on.

howto use this header template ?