$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"; } $financialyear = new FinancialYear(); if ($financialyear->fetchFinancialYear($financialyearfrom_id)) { $header[2] = $financialyear->financialyear_name; } else { $header[2] = "Unknown"; } $periodrange = $financialyear->getPeriodRange($financialyearfrom_id); /* if($period->fetchPeriod($periodto_id)) $header[2]=$period->period_name; else $header[2]="Unknown"; */ 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 transactionamt FROM {$tabletranssummary} where accounts_id=a.accounts_id and period_id={$periodfrom_id}) is null \r\n\t\tthen 0 else (SELECT transactionamt FROM {$tabletranssummary} where accounts_id=a.accounts_id and period_id={$periodfrom_id}) end\r\n\t\t as transactionamt1,\r\n\t\tcase when (SELECT sum(transactionamt) FROM {$tabletranssummary} where accounts_id=a.accounts_id and period_id in ({$periodrange})) is null \r\n\t\tthen 0 else (SELECT sum(transactionamt) FROM {$tabletranssummary} where accounts_id=a.accounts_id and period_id\r\n\t\tin ({$periodrange})) end\r\n\t\t as transactionamt2 \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 = "";
$orgurl = $org->url; $orgtel1 = $org->tel_1; $orgtel2 = $org->tel_2; $orgfax = $org->fax; $financialyearfrom_id = $_POST['financialyearfrom_id']; $financialyearto_id = $_POST['financialyearto_id']; $reportlevel = $_POST['reportlevel']; $showzero = $_POST['showzero']; $showaccountcode = $_POST['showaccountcode']; $financialyear = new FinancialYear(); if ($financialyear->fetchFinancialYear($financialyearfrom_id)) { $header[1] = $financialyear->financialyear_name; } else { $header[1] = "Unknown"; } $periodrange1 = $financialyear->getPeriodRange($financialyearfrom_id); if ($financialyear->fetchFinancialYear($financialyearto_id)) { $header[2] = $financialyear->financialyear_name; } else { $header[2] = "Unknown"; } $periodrange2 = $financialyear->getPeriodRange($financialyearto_id); 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 ({$periodrange1})) is null \r\n\t\tthen 0 else (SELECT sum(transactionamt) FROM {$tabletranssummary} where accounts_id=a.accounts_id and period_id in ({$periodrange1})) end\r\n\t\t as transactionamt1,\r\n\t\tcase when (SELECT sum(transactionamt) FROM {$tabletranssummary} where accounts_id=a.accounts_id and period_id in ({$periodrange2})) is null \r\n\t\tthen 0 else (SELECT sum(transactionamt) FROM {$tabletranssummary} where accounts_id=a.accounts_id and period_id in ({$periodrange2})) end\r\n\t\t as transactionamt2\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 = "";