<?php
session_start();
require_once "main.php";
require_once('tcpdf/tcpdf.php');
ini_set('display_errors', 0);
error_reporting(0);
Logger::configure('log4php.xml');
$log = Logger::getLogger('printbatch');
global $db;
$stdate = date('Y-m-01',strtotime($_GET['reportdate']));
$endate = date('Y-m-t',strtotime($_GET['reportdate']));
$month1 = date("F, Y",strtotime($_GET['reportdate']));
$comname = bill_get_company($_SESSION['comnum']);
if ($_GET['submitType']=='totals') {
$group0 = bill_get_tot_group0($_SESSION['comnum'],$stdate,$endate);
$resultz = bill_get_cust_aging($_SESSION['comnum']);
$today = $endate;
$b=0;
$k=0;
$cnt3 = 0;
$cnt6 = 0;
$cnt9 = 0;
$cntc = 0;
$totc = 0;
$tot3 = 0;
$tot6 = 0;
$tot = 0;
$td = idate('z', strtotime($_GET['reportdate']));
for ($j=0;$j<count($resultz);$j++){
      if (!($k==$resultz[$j]['account'])) {
          $k=$resultz[$j]['account'];
          $cbal = 0;
          $lbal = 0;
          $rlbal = 0;
          $b++;
          $fnx = 0;
      }
      //print_r($result[$j]);
      //echo '<Br />';
      if ($resultz[$j]['last']<>1) {
          $d = idate('z',strtotime($resultz[$j]['date']));
          //echo $d . ' -- ' . $td . '<br /r>';
          if ($d>($td-30)) {
              $cbal = $cbal + $resultz[$j]['bamount'];
              $cnt3++;
          } else if ($d>($td-60)) {
              $lbal = $lbal + $resultz[$j]['bamount'];
              $cnt6++;
          } else if ($d>($td-90)) {
              $rlbal = $rlbal + $resultz[$j]['bamount'];
              $cnt9++;
          }
      } else {
          if ($fnx==0) {
              $d = idate('z',strtotime($resultz[$j]['date']));
                //echo $d . ' -x- ' . $td . '<br /r>';
                if ($d>($td-30)) {
                    $cbal = $cbal + $resultz[$j]['bamount'] + $resultz[$j]['xbal'];
                    $cnt3++;
                } else if ($d>($td-60)) {
                    $lbal = $lbal + $resultz[$j]['bamount'] + $resultz[$j]['xbal'];
                    $cnt6++;
                } else if ($d>($td-90)) {
                    $rlbal = $rlbal + $resultz[$j]['bamount'] + $resultz[$j]['xbal'];
                    $cnt9++;
                }
               //$cbal = $cbal + $result[$j]['bamount'] + $result[$j]['x'];
               $fnx = 1;
          }
      }
      $res1[$b]['id'] = $k;
      $res1[$b]['name'] = $resultz[$j]['name'];
      $res1[$b]['account'] = $resultz[$j]['account'];
      $res1[$b]['cbal'] = $cbal;
      $res1[$b]['lbal'] = $lbal;
      $res1[$b]['rlbal'] = $rlbal;
      $res1[$b]['abal'] = $resultz[$j]['abalance'];
}
for ($b=0;$b<count($res1);$b++){
    $res2[$b]['id'] = $res1[$b+1]['id'];
    $res2[$b]['name'] = $res1[$b+1]['name'];
    $res2[$b]['account'] = $res1[$b+1]['account'];
    $res2[$b]['cbal'] = $res1[$b+1]['cbal'];
    $res2[$b]['lbal'] = $res1[$b+1]['lbal'];
    $res2[$b]['rlbal'] = $res1[$b+1]['rlbal'];
    $res2[$b]['abal'] = $res1[$b+1]['abal'];
    $cntc++;
}
for ($i=0;$i<count($res2);$i++) {
$totc = $totc + floatval(testx($res2[$i]['cbal']));
$tot3 = $tot3 + floatval(testx($res2[$i]['lbal']));
$tot6 = $tot6 + floatval(testx($res2[$i]['rlbal']));
$tot = $tot + floatval(testx($res2[$i]['abal']));
}
$tot9 = $tot - ($totc + $tot3 +$tot6);
$log->info($_GET['submitType'].' - user = '.$_SESSION['user'].' - '.$_SESSION['comnum']);
$zzzz = ob_get_clean();
$pdf = new TCPDF("P", "pt", "USLETTER", true, 'UTF-8', false);
$pdf->SetAutoPageBreak("true");
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('WtrBill');
$pdf->SetTitle('Director Report');
$pdf->SetSubject('Director Report');
$pdf->SetKeywords('WtrBill');
$style = array(
	'position' => '',
	'align' => 'L',
	'stretch' => false,
	'fitwidth' => false,
	'cellfitalign' => '',
	'border' => true,
	'hpadding' => 'auto',
	'vpadding' => 'auto',
	'fgcolor' => array(0,0,0),
	'bgcolor' => false, //array(255,255,255),
	'text' => false,
	'font' => 'helvetica',
	'fontsize' => 10,
	'stretchtext' => 4
);
$pdf->setFontSubsetting(true);
$pdf->SetFont('helvetica', '', 6);
$resolution= array(792, 612);//array(792, 612);
$pdf->AddPage("P", $resolution);


$rep1 = '<center><h2>Directors Report for '.$month1.'</h2></center>
    <center><h3>'.$comname[0]['name'].'</h3></center>
    <table cellpadding="1" border="0" style="text-align:right;">
    <tr>
        <td></td>
        <td></td>
        <td><b># of Accounts</b></td>
        <td><b>Amount($)</b></td>
    </tr>
    <tr>
        <td>Total Water</td>
        <td></td>
        <td><b>'.$group0[11]['cnt1'].'</b></td>
        <td><b>$'.number_format($group0[11]['sale1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td>Total Return Check Fee</td>
        <td></td>
        <td><b>'.$group0[14]['cnt1'].'</b></td>
        <td><b>$'.number_format($group0[14]['sale1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td>Total Late Charge</td>
        <td></td>
        <td><b>'.$group0[12]['cnt1'].'</b></td>
        <td><b>$'.number_format($group0[12]['sale1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td>Total Reconnect Fee</td>
        <td></td>
        <td><b>'.$group0[18]['cnt1'].'</b></td>
        <td><b>$'.number_format($group0[18]['sale1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td>Total Disconnect Fee</td>
        <td></td>
        <td><b>'.$group0[17]['cnt1'].'</b></td>
        <td><b>$'.number_format($group0[17]['sale1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td>Total Credit Card Fees</td>
        <td></td>
        <td><b>'.$group0[13]['cnt1'].'</b></td>
        <td><b>$'.number_format($group0[13]['sale1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td>Other Bank Charges</td>
        <td></td>
        <td><b>'.$group0[15]['cnt1'].'</b></td>
        <td><b>$'.number_format($group0[15]['sale1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td>Total Adjustments Etc</td>
        <td></td>
        <td style="border-bottom: .75px solid black;"><b>'.$group0[16]['cnt1'].'</b></td>
        <td style="border-bottom: .75px solid black;"><b>$'.number_format($group0[16]['sale1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td><b>Total Current Charges</b></td>
        <td></td>
        <td><b>'.$group0[20]['cnt1'].'</b></td>
        <td><b>$'.number_format($group0[20]['sale1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr><td colspan="4" style="text-align:right;"> </td>
    </tr>
    <tr>
        <td>Current Balance</td>
        <td></td>
        <td><b>'.$cntc.'</b></td>
        <td><b>$'.number_format($totc,2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td>Past Due 1-30 Days</td>
        <td></td>
        <td><b>'.$cnt6.'</b></td>
        <td><b>$'.number_format($tot3,2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td>Past Due 31-60 Days</td>
        <td></td>
        <td style="border-bottom: .75px solid black;"><b>'.$cnt9.'</b></td>
        <td style="border-bottom: .75px solid black;"><b>$'.number_format($tot6,2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td><b>Total Recievables</b></td>
        <td></td>
        <td><b>'.$cntc.'</b></td>
        <td><b>$'.number_format($tot,2 , '.' , ',' ).'</b></td>
    </tr>
    <tr><td colspan="4" style="text-align:right;"> </td>
    </tr>
    <tr>
        <td>Total Payments Received</td>
        <td></td>
        <td><b>'.$group0[21]['cnt1'].'</b></td>
        <td><b>$'.number_format($group0[21]['sale1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td>Active Accounts</td>
        <td></td>
        <td><b>'.$group0[11]['cnt1'].'</b></td>
        <td><b>$'.number_format($group0[11]['sale1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr><td colspan="4" style="text-align:right;"> </td>
    </tr>
    <tr>
        <td>Average Usage in gallons</td>
        <td></td>
        <td><b>'.$group0[11]['cnt1'].'</b></td>
        <td><b>'.number_format($group0[11]['use1']/$group0[11]['cnt1'],0 , '.' , ',' ).'</b></td>
    </tr>
    <tr>
        <td>Average Water Charge</td>
        <td></td>
        <td><b>'.$group0[11]['cnt1'].'</b></td>
        <td><b>$'.number_format($group0[11]['sale1']/$group0[11]['cnt1'],2 , '.' , ',' ).'</b></td>
    </tr>
    <tr><td colspan="4" style="text-align:right;"> </td>
    </tr>
    <tr>
        <td>Water Produced</td>
        <td></td>
        <td><b># of Accounts</b></td>
        <td><b></b></td>
    </tr>
    <tr>
        <td>Water Purchased</td>
        <td></td>
        <td><b># of Accounts</b></td>
        <td><b></b></td>
    </tr>
    <tr>
        <td>Water Sold</td>
        <td></td>
        <td><b>'.number_format ($group0[11]['use1'],0 , '.' , ',' ).'</b></td>
        <td></td>
    </tr>
    <tr>
        <td style="border-bottom: .75px solid black;">Accountable Loss</td>
        <td style="border-bottom: .75px solid black;"></td>
        <td style="border-bottom: .75px solid black;"><b># of Accounts</b></td>
        <td style="border-bottom: .75px solid black;"><b></b></td>
    </tr>
    <tr>
        <td><b>Water Loss</b></td>
        <td></td>
        <td><b># of Accounts</b></td>
        <td><b></b></td>
    </tr>
    </table>
    <table style="text-align:right;">
    <tr><td colspan="6" style="text-align:right;"> </td>
    </tr>
    <tr>
        <td style="border-bottom: .5px solid black; text-align:left;"><b>Usage Groups</b></td>
        <td style="border-bottom: .5px solid black;"><b># of Accounts</b></td>
        <td style="border-bottom: .5px solid black;"><b>Usage</b></td>
        <td style="border-bottom: .5px solid black;"><b>Sales</b></td>
        <td style="border-bottom: .5px solid black;"><b>% Usage</b></td>
        <td style="border-bottom: .5px solid black;"><b>% Sales</b></td>
    </tr>
        <tr>
        <td style="text-align:left;">0 Usage</td>
        <td>'.number_format ($group0[0]['cnt1'],0 , '.' , ',' ).'</td>
        <td>'.number_format ($group0[0]['use1'],0 , '.' , ',' ).'</td>
        <td>$'.number_format ($group0[0]['sale1'],2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[0]['u1']*100),2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[0]['s1']*100),2 , '.' , ',' ).'</td>
    </tr>
        <tr>
        <td style="text-align:left;">1-2,000</td>
        <td>'.number_format ($group0[1]['cnt1'],0 , '.' , ',' ).'</td>
        <td>'.number_format ($group0[1]['use1'],0 , '.' , ',' ).'</td>
        <td>$'.number_format ($group0[1]['sale1'],2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[1]['u1']*100),2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[1]['s1']*100),2 , '.' , ',' ).'</td>
    </tr>
        <tr>
        <td style="text-align:left;">2,001-4,000</td>
        <td>'.number_format ($group0[2]['cnt1'],0 , '.' , ',' ).'</td>
        <td>'.number_format ($group0[2]['use1'],0 , '.' , ',' ).'</td>
        <td>$'.number_format ($group0[2]['sale1'],2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[2]['u1']*100),2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[2]['s1']*100),2 , '.' , ',' ).'</td>
    </tr>
        <tr>
        <td style="text-align:left;">4,001-6,000</td>
        <td>'.number_format ($group0[3]['cnt1'],0 , '.' , ',' ).'</td>
        <td>'.number_format ($group0[3]['use1'],0 , '.' , ',' ).'</td>
        <td>$'.number_format ($group0[3]['sale1'],2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[3]['u1']*100),2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[3]['s1']*100),2 , '.' , ',' ).'</td>
    </tr>
        <tr>
        <td style="text-align:left;">6,001-8,000</td>
        <td>'.number_format ($group0[4]['cnt1'],0 , '.' , ',' ).'</td>
        <td>'.number_format ($group0[4]['use1'],0 , '.' , ',' ).'</td>
        <td>$'.number_format ($group0[4]['sale1'],2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[4]['u1']*100),2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[4]['s1']*100),2 , '.' , ',' ).'</td>
    </tr>
        <tr>
        <td style="text-align:left;">8,001-10,000</td>
        <td>'.number_format ($group0[5]['cnt1'],0 , '.' , ',' ).'</td>
        <td>'.number_format ($group0[5]['use1'],0 , '.' , ',' ).'</td>
        <td>$'.number_format ($group0[5]['sale1'],2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[5]['u1']*100),2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[5]['s1']*100),2 , '.' , ',' ).'</td>
    </tr>
        <tr>
        <td style="text-align:left;">10,001-20,000</td>
        <td>'.number_format ($group0[6]['cnt1'],0 , '.' , ',' ).'</td>
        <td>'.number_format ($group0[6]['use1'],0 , '.' , ',' ).'</td>
        <td>$'.number_format ($group0[6]['sale1'],2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[6]['u1']*100),2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[6]['s1']*100),2 , '.' , ',' ).'</td>
    </tr>
    <tr>
        <td style="text-align:left;">20,001-30,000</td>
        <td>'.number_format ($group0[7]['cnt1'],0 , '.' , ',' ).'</td>
        <td>'.number_format ($group0[7]['use1'],0 , '.' , ',' ).'</td>
        <td>$'.number_format ($group0[7]['sale1'],2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[7]['u1']*100),2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[7]['s1']*100),2 , '.' , ',' ).'</td>
    </tr>
    <tr>
        <td style="text-align:left;">30,001-40,000</td>
        <td>'.number_format ($group0[8]['cnt1'],0 , '.' , ',' ).'</td>
        <td>'.number_format ($group0[8]['use1'],0 , '.' , ',' ).'</td>
        <td>$'.number_format ($group0[8]['sale1'],2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[8]['u1']*100),2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[8]['s1']*100),2 , '.' , ',' ).'</td>
    </tr>
    <tr>
        <td style="text-align:left;">40,001-50,000</td>
        <td>'.number_format ($group0[9]['cnt1'],0 , '.' , ',' ).'</td>
        <td>'.number_format ($group0[9]['use1'],0 , '.' , ',' ).'</td>
        <td>$'.number_format ($group0[9]['sale1'],2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[9]['u1']*100),2 , '.' , ',' ).'</td>
        <td>'.number_format (($group0[9]['s1']*100),2 , '.' , ',' ).'</td>
    </tr>
    <tr>
        <td style="border-bottom: .75px solid black; text-align:left;">Over 50,000</td>
        <td style="border-bottom: .75px solid black;">'.number_format ($group0[10]['cnt1'],0 , '.' , ',' ).'</td>
        <td style="border-bottom: .75px solid black;">'.number_format ($group0[10]['use1'],0 , '.' , ',' ).'</td>
        <td style="border-bottom: .75px solid black;">$'.number_format ($group0[10]['sale1'],2 , '.' , ',' ).'</td>
        <td style="border-bottom: .75px solid black;">'.number_format (($group0[10]['u1']*100),2 , '.' , ',' ).'</td>
        <td style="border-bottom: .75px solid black;">'.number_format (($group0[10]['s1']*100),2 , '.' , ',' ).'</td>
    </tr>
    <tr>
        <td style="text-align:left;"><b>Total Meters</b></td>
        <td>'.$group0[11]['cnt1'].'</td>
        <td>'.$group0[11]['use1'].'</td>
        <td>$'.number_format ($group0[11]['sale1'],2 , '.' , ',' ).'</td>
        <td>100.00</td>
        <td>100.00</td>
    </tr>
    </table>';

$rep3=$rep1;
        $pdf->SetFont('helvetica', '', 10);
        $pdf->writeHTML($rep3, true, false, true, false, '');
        //$pdf->writeHTML($rep2, true, false, true, false, '');
        //$pdf->writeHTMLcell(0,0,5,5,$rep1, false, true, false, false, false, '');//address
        $pdf->lastPage();
$pdf->Output('DirectorReport.pdf', 'I');
} else if ($_GET['submitType']=='reread') {
$result = bill_get_reread($_SESSION['comnum'], $_SESSION['batch']);
//print_r($result);
$zzzz = ob_get_clean();
$log->info($_GET['submitType'].' - user = '.$_SESSION['user'].' - '.$_SESSION['comnum'].' = '.$_GET['id']);
$pdf = new TCPDF("P", "pt", "USLETTER", true, 'UTF-8', false);
$pdf->SetAutoPageBreak("true");
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('WtrBill');
$pdf->SetTitle('Meter Reread');
$pdf->SetSubject($_GET['id']);
$pdf->SetKeywords('WtrBill');
$style = array(
	'position' => '',
	'align' => 'L',
	'stretch' => false,
	'fitwidth' => false,
	'cellfitalign' => '',
	'border' => true,
	'hpadding' => 'auto',
	'vpadding' => 'auto',
	'fgcolor' => array(0,0,0),
	'bgcolor' => false, //array(255,255,255),
	'text' => false,
	'font' => 'helvetica',
	'fontsize' => 10,
	'stretchtext' => 4
);
$pdf->setFontSubsetting(true);
$pdf->SetFont('helvetica', '', 6);
$resolution= array(792,612);//array(792, 612);
$pdf->AddPage("P", $resolution);


$rep1 = '<center><h2>ReRead Worksheet for batch # : '.testx($_SESSION['batch']).'</h2></center>
    <table cellpadding="3" cellspacing="1" border="1" style="text-align:center;">
    <thead>
    <tr>
        <th>Account</th>
        <th>Name</th>
        <th>Address</th>
        <th>2M Reading</th>
        <th>Last Reading</th>
        <th>Reading</th>
    </tr>
    </thead>';
$rep2 = '';
for ($i=0;$i<count($result);$i++) {
$rep2 = $rep2 .'
    <tr>
       <td>'.testx($result[$i]['account']).'</td>
       <td>'.testx($result[$i]['name']).'</td>
       <td>'.testx($result[$i]['maddr']).'</td>
       <td>'.testx($result[$i]['lmread']).'</td>
       <td>'.testx($result[$i]['lread']).'</td>
       <td></td>
    </tr>';
}
$rep3=$rep1.$rep2.'</table>';
        $pdf->SetFont('helvetica', '', 10);
        $pdf->writeHTML($rep3, true, false, true, false, '');
        //$pdf->writeHTML($rep2, true, false, true, false, '');
        //$pdf->writeHTMLcell(0,0,5,5,$rep1, false, true, false, false, false, '');//address
        $pdf->lastPage();

$pdf->Output('MeterReadWKSHT.pdf', 'I');
} else if ($_GET['submitType']=='billing') {
    $result = bill_get_billing1($_SESSION['comnum'],$stdate,$endate);

$zzzz = ob_get_clean();
$log->info($_GET['submitType'].' - user = '.$_SESSION['user'].' - '.$_SESSION['comnum']);
$pdf = new TCPDF("L", "pt", "USLETTER", true, 'UTF-8', false);
$pdf->SetAutoPageBreak("true");
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('WtrBill');
$pdf->SetTitle('Billing Report');
$pdf->SetSubject('Billing Report');
$pdf->SetKeywords('WtrBill');
$style = array(
	'position' => '',
	'align' => 'L',
	'stretch' => false,
	'fitwidth' => false,
	'cellfitalign' => '',
	'border' => true,
	'hpadding' => 'auto',
	'vpadding' => 'auto',
	'fgcolor' => array(0,0,0),
	'bgcolor' => false, //array(255,255,255),
	'text' => false,
	'font' => 'helvetica',
	'fontsize' => 10,
	'stretchtext' => 4
);
$pdf->setFontSubsetting(true);
$pdf->SetFont('helvetica', '', 6);
$resolution= array(792,612);//array(792, 612);
$pdf->AddPage("L", $resolution);


$rep1 = '<center><h2>Monthly Billing Report for '.$month1.'</h2></center>
<table width="700" cell-padding="3" align="center">
<thead>
 <tr>
    <th><b>Account</b></th>
    <th><b>Name</b></th>
    <th><b>Service</b></th>
    <th><b>Billing Date</b></th>
    <th><b>Prev Reading</b></th>
    <th><b>Current Reading</b></th>
    <th><b>Use</b></th>
    <th><b>Current Bill Amount</b></th>
 </tr>
 <thead>';
 $totx = 0;
 $cntx = 0;
$mtbl1 = '';
$rep2 = '';
for ($i=0;$i<count($result);$i++) {
$rep2 = $rep2 .'
    <tr>
       <td>'.$result[$i]['account'].'</td>
       <td>'.$result[$i]['name'].'</td>
       <td>'.$result[$i]['maddr'].'</td>
       <td>'.$result[$i]['date'].'</td>
       <td>'.$result[$i]['begread'].'</td>
       <td>'.$result[$i]['endread'].'</td>
       <td>'.$result[$i]['ref1'].'</td>
       <td>$'.number_format($result[$i]['bamount'], 2, '.', '').'</td>
    </tr>';
    $totx = $totx + floatval($result[$i]['bamount']);
    $cntx++;
}
$rep3=$rep1.$rep2.'<tr><td></td><td></td><td></td><td></td><td><b>Charge Count:</b></td><td><b>'.$cntx.'</b></td>
    <td><b>Total Charges</b></td><td><b>$'.number_format($totx, 2, '.', '').'</b></td></tr></table>';
        $pdf->SetFont('helvetica', '', 10);
        $pdf->writeHTML($rep3, true, false, true, false, '');
        //$pdf->writeHTML($rep2, true, false, true, false, '');
        //$pdf->writeHTMLcell(0,0,5,5,$rep1, false, true, false, false, false, '');//address
        $pdf->lastPage();

$pdf->Output('BillingReport.pdf', 'I');
}
?>
