$periodto_id = $_POST['periodto_id'];
 $reportlevel = $_POST['reportlevel'];
 $showzero = $_POST['showzero'];
 $showaccountcode = $_POST['showaccountcode'];
 $period = new Period();
 if ($period->fetchPeriod($periodfrom_id)) {
     $header[1] = $period->period_name;
 } else {
     $header[1] = "Unknown";
 }
 if ($period->fetchPeriod($periodto_id)) {
     $header_to = $period->period_name;
 } else {
     $header_to = "Unknown";
 }
 $period_list = getPeriodList($header[1], $header_to);
 $header[1] = $header[1] . " to " . $header_to;
 if ($showaccountcode == "on") {
     $orderby = "ORDER BY ac.classtype,a.accountcode_full";
 } else {
     $orderby = "ORDER BY ac.classtype,a.accountcode_full,a.placeholder desc,a.accounts_name";
 }
 $sql = "SELECT a.accountcode_full,a.accounts_id,a.accounts_name,ac.classtype, a.treelevel,a.placeholder,a.parentaccounts_id,\r\n\t\tcase when (SELECT sum(transactionamt) FROM {$tabletranssummary} where accounts_id=a.accounts_id and period_id in ({$period_list})) is null\r\n\t\tthen 0 else  (SELECT sum(transactionamt) FROM {$tabletranssummary} where accounts_id=a.accounts_id and period_id in ({$period_list})) end\r\n\t\t as transactionamt\r\n\t\tFROM {$tableaccounts} a \r\n\t\tINNER JOIN {$tableaccountgroup} ag on ag.accountgroup_id=a.accountgroup_id\r\n\t\tINNER JOIN {$tableaccountclass} ac on ag.accountclass_id=ac.accountclass_id\r\n\t\tWHERE ac.classtype in ('1S','2C','3O','4X') and a.treelevel<={$reportlevel} \r\n\t\t{$orderby} ";
 $query = $xoopsDB->query($sql);
 $pdf->AddPage();
 $prefix = "";
 $currentcategory = "1S";
 $grossprofit = 0;
 $totalsales = 0;
 $totalcost = 0;
 $totalexpenses = 0;
$tpl->assign("headerMenu_options", _("Options"));
/*
 * List of elements - Depends on different criteria
 */
$rq = "SELECT * FROM pdfreports_reports {$SearchTool} ORDER BY name LIMIT " . $num * $limit . ", " . $limit;
$DBRESULT =& $pearDB->query($rq);
$form = new HTML_QuickForm('form', 'POST', "?p=" . $p);
/*
 * Different style between each lines
 */
$style = "one";
require_once "./include/reporting/dashboard/common-Func.php";
/*
 * Getting period table list to make the form period selection (today, this week etc.)
 */
$periodList = getPeriodList();
/*
 * Fill a tab with a mutlidimensionnal Array we put in $tpl
 */
$elemArr = array();
for ($i = 0; $report =& $DBRESULT->fetchRow(); $i++) {
    $moptions = "";
    $selectedElements =& $form->addElement('checkbox', "select[" . $report['report_id'] . "]");
    $moptions .= "<a href='main.php?p=" . $p . "&report_id=" . $report['report_id'] . "&o=rn'><img src='img/icones/16x16/gears_run.gif' border='0' alt='" . _("Run now") . "'></a>&nbsp;&nbsp;";
    if ($report["activate"]) {
        $moptions .= "<a href='main.php?p=" . $p . "&report_id=" . $report['report_id'] . "&o=u&limit=" . $limit . "&num=" . $num . "&search=" . $search . "'><img src='img/icones/16x16/element_previous.gif' border='0' alt='" . _("Disabled") . "'></a>&nbsp;&nbsp;";
    } else {
        $moptions .= "<a href='main.php?p=" . $p . "&report_id=" . $report['report_id'] . "&o=s&limit=" . $limit . "&num=" . $num . "&search=" . $search . "'><img src='img/icones/16x16/element_next.gif' border='0' alt='" . _("Enabled") . "'></a>&nbsp;&nbsp;";
    }
    $moptions .= "&nbsp;&nbsp;&nbsp;";
    $moptions .= "<input onKeypress=\"if(event.keyCode > 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . $report['report_id'] . "]'></input>";