$tpl = new rpts_Template();
$tpl->set_file(array(report => "collectionReport2Form.htm"));
global $auth;
$this->sess = $sess;
$this->user = $auth->auth;
$this->formArray["uid"] = $auth->auth["uid"];
$this->user = $auth->auth;
$tpl->set_var("uname", $this->user["uname"]);
$tpl->set_var("today", date("F j, Y"));
// must have atleast TM-VIEW access
$pageType = "%%%%1%%%%%";
if (!checkPerms($this->user["userType"], $pageType)) {
    header("Location: Unauthorized.php" . $this->sess->url(""));
    exit;
}
$tpl->set_block(report, LGUBLK, lguBlk);
$db = new DB_RPTS();
$sql = "select * from MunicipalityCity order by description;";
$db->query($sql);
for ($i = 0; $db->next_record(); $i++) {
    $tpl->set_var($db->Record);
    $tpl->parse(lguBlk, LGUBLK, true);
}
if ($municipalityCityID) {
    $tpl->set_var("selected_municipalityCityID_" . $municipalityCityID, "selected");
} else {
    $tpl->set_var("selected_municipalityCityID_" . $municipalityCityID, "");
}
if ($startMM) {
    $tpl->set_var("selected_startMM_" . $startMM, "selected");
} else {
<?
include_once("web/prepend.php");
 include_once('web/panachart.php');

$tpl=new rpts_Template();
$tpl->set_file(array(report=>"Form.htm"));

$db = new DB_SelectLGU("erpts-test");
$db->query("SELECT * FROM Barangay ORDER BY description");
$tpl->set_block(report,BRGY,bBlk);
if($db->num_rows()>0){
	for($r=0;$db->next_record();$r++){
		$tpl->set_var(barangayID,$db->f("barangayID"));
		$tpl->set_var(barangayName,$db->f("description"));
		$tpl->parse(bBlk,BRGY,true);
	}
}
$tpl->set_var(fileName,$PHP_SELF);

if($isSubmit){

  
 $db = new DB_SelectLGU("erpts-test");

if($brgyID==0)
 $sql ="SELECT ".ucwords($classification)."ActualUses.code as description, sum( ".ucwords($classification).".marketValue ) as total
		FROM AFS
		INNER JOIN ".ucwords($classification)."
		USING ( afsID ) 
		INNER  JOIN ".ucwords($classification)."ActualUses ON ".ucwords($classification).".actualUse = ".ucwords($classification)."ActualUses.".$classification."ActualUsesID
		GROUP  BY ( ".$classification."ActualUsesID )";
//$tpl->set_file(array(report=>"collectionReport2.htm"));
$tpl->set_file(array(report => "report2Asoa.xml"));
$tpl->set_var(lgu, $lguName);
$tpl->set_var(startDate, $startDate);
$tpl->set_var(endDate, $endDate);
$tpl->set_var(rpuClass, $rpuClassDesc);
$ypos = 424;
$ypos1 = 416;
$yposx = 428;
$yposx1 = 420;
$iStart = 0;
$jStart = 0;
$rowPerPage = 16;
//echo count($buffer)."<br>";
//echo ceil(count($buffer)/$rowPerPage)."<br>";
$tpl->set_block(report, PAGE, pageBlk);
$tpl->set_block(PAGE, ROW, rowBlk);
$tpl->set_block(PAGE, ROW1, row1Blk);
$pages = ceil(count($buffer) / $rowPerPage);
$tpl->set_var("pages", $pages * 2);
for ($h = 1; $h <= $pages; $h++) {
    $tpl->set_var("sheet1", ($h - 1) * 2 + 1);
    $tpl->set_var("sheet2", ($h - 1) * 2 + 2);
    for ($i = $iStart; $i < count($buffer) && floor($i / $h) < $rowPerPage; $i++) {
        $ypos = $ypos - 18;
        $ypos1 = $ypos1 - 18;
        $tpl->set_var($buffer[$i]);
        $tpl->set_var(ypos, $ypos);
        $tpl->set_var(ypos1, $ypos1);
        $tpl->parse(rowBlk, ROW, true);
    }