Scenario: I am building a simple report with a list page and a detail page. List page will contain a listing on invoices and each invoice number will be a link on clicking which i will go to a new page that displays the details of the Invoice.

Solution:

That easy. Here is the guide:

You will create two reports, ListInvoice and DetailInvoice. In the ListInvoice, you query all invoices and put into Table as normal. I guess you know how to do it. Now how we can make a link to DetailInvoice. Assume that each invoice has invoiceId, in the Table widget you do:

<?php
Table::create(array(
    "columns"=>array(
        "invoiceId"=>array(
            "formatValue"=>function($invoiceId)
            {
                return "<a href='detail.php?invoiceId=$invoiceId'>View detail</a>";
            }
        ),
        ...
    )
))
?>

As you can see, the invoiceId column now will contain the link View details pointing to detail.php. The detail.php contains initiation of DetailInvoice like this:

$detail = new DetailInvoice(array(
    "invoiceId" = $_GET["invoiceId"]
));
$detail->run()->render();

You see that we catch the invoiceId from GET and input to params of DetailInvoice. In the DetailInvoice setup() function, you do;

$this->src("database")->query("SELECT * from invoices where invoiceId=:invoiceId")
->params(array(
    ":invoiceId"=>$this->params["invoiceId"]
))
->pipe(..)
...
->pipe($this->dataStore("invoice"))

As you can see we query the detail invoice here. In the view file of DetailInvoice you can get data by

$this->dataStore("invoice")->get(0,"payerName");

payerName is column name and 0 is the row number. You can query any related data to the invoice to display on the view of _DetailInvoice report.

Regards,

KoolPHP Inc