<td colspan="2" >
<p style="text-align: right; margin:0; padding-right: 10px; font-weight: 500; line-height: 2; padding-bottom: 0px; padding-top: 0px; color: black; font-size: 25px;">
	<?php echo $this->lang->line('module');?>
</p>
<p style="text-align:center; font-size:16px;"> 
	<span style=" font-weight:800;"><?php echo $companyInfo->companyName; ?></span> <span style="font-size:10px;"><?php echo "(".$companyInfo->companyNo.")";?></span><br />
	<span style="font-size:10px;"><?php echo "GST Registration No : ".$companyInfo->gstRegisteredNo; ?></span><br />
</p>
<p style="text-align:center; font-size:10px; line-height:1.4; padding:0 0 5px; margin:0; border-bottom:1px solid #eeeeee;">
	<?php if(!empty($companyInfo->line1)): ?><span><?php echo $companyInfo->line1; ?></span><br /><?php endif; ?>
    <?php if(!empty($companyInfo->line2) || !empty($companyInfo->line3)): ?><span><?php echo $companyInfo->line2.", ".$companyInfo->line3; ?></span><br /><?php endif; ?>
    <?php if(!empty($companyInfo->companyPostCode) || !empty($companyInfo->city)): ?><span><?php echo $companyInfo->companyPostCode . '  ' . $companyInfo->city; ?> </span><br /><?php endif; ?>
    <?php if(!empty($companyInfo->fldname) || !empty($companyInfo->fldcountry)): ?><span><?php echo $companyInfo->fldname . '  ' . $companyInfo->fldcountry; ?> </span><br /><?php endif; ?>
    <?php if(!empty($companyInfo->phoneNo) || !empty($companyInfo->faxNo)): ?><span><?php echo 'Phone : ' . $companyInfo->phoneNo . '  Fax : ' . $companyInfo->faxNo; ?> </span><?php endif; ?>
</p>
                            </td>
<table border="0" cellpadding="1" cellspacing="0" width="100%">
        <tr>
            <td align="right" colspan="9"><b><?php echo $this->lang->line('as').":"." ".date('d-m-Y'); ?></b></td>
        </tr>
        <tr>
        	<td></td>
        	<td></td>
            <td></td>
            <td></td>
        	<td></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td colspan="9"><b><?php echo $this->lang->line('taxablePeriod').":"." ".date('d-m-Y', strtotime($dateFrom))." ".$this->lang->line('to')." ".date('d-m-Y', strtotime($dateTo)) ?></b></td>
        </tr>
        <tr>
        	<td></td>
        	<td></td>
            <td></td>
            <td></td>
        	<td></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
</table>
<div>
	<b><?php echo $this->lang->line('supply') ?></b>
</div>
<?php
$count = 0;
echo"
<table cellpadding='0' cellspacing='0' width='100%' id='test' class='editable'>
                                <thead>
                                <tr>
                                    <th class='tac'>#</th>
                                    <th class='tac'>".$this->lang->line('taxCode')."</th>";
									for($i=0; $i<$monthDiff; $i++){
										if($monthDiff > 1){
												if($i == 0){	
													if(date("M", strtotime($i." months", strtotime($dateFrom))) == "Dec"){
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
														$count ++;
													}
													else{
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
													}
												}
												else{
													if(date("M", strtotime($i." months", strtotime($dateFrom))) == "Dec"){
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
														$count ++;
													}
													else{
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
													}
												}
										}
										else{
											echo "<th class='tac'>".date("M", strtotime($dateFrom))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
										}
									}
									echo "<th class='tac'>".$this->lang->line('total')."</th>";
                                "</tr>
                                </thead>
                                <tbody>";
                                    	$bil = 0;
										//$bil2 = 0;
										$totCol = array();
										if($datatbls){
										foreach($datatbls as $datatbl):
										$bil++;
										echo"<tr class='itemList'>
                                            <td class='tac'>".$bil."</td>
                                        	<td class='tac'>".$datatbl->code."</td>";
											//for($i=0; $i<$monthDiff; $i++){
											$total = 0;
											$i = 0;
											
											foreach ($datatbl as $col => $val) {
												if (strtoupper(substr($col,0,5))=='MONTH'){
													echo '<td align="right">'.number_format($val, 2, '.', ',').'</td>';
													$total += $val;
													if($bil == 1)
														$totCol[] += $val;
													else
														$totCol[$i] += $val;	
													$i++;
												}
													//echo "<td class='tac'>".$datatbl->month3."</td>";
											}
											//foreach ($totSales as $totSale) {
												echo '<td align="right"><b>'.number_format($total, 2, '.', ',').'</b></td>';
												//echo '<td align="right">'.number_format($totSales[$bil]->totGstSales, 2, '.', ',').'</td>';
												//$bil2++;
											//}
                                        "</tr>";
										
										
									endforeach;
											}
									$bil = $bil + 1;
									echo"<tr>
											<td class='tac'></td>
											<td class='tar'><b>".$this->lang->line('total')."</b></td>";
											//var_dump($totCol);
											$totAmount = 0;
											if($datatbls){
												for($j=0; $j<$i; $j++){
													$totAmount += $totCol[$j];
													echo '<td align="right"><b>'.number_format($totCol[$j], 2, '.', ',').'</b></td>';
												}
											}
											else{
												for($j=0; $j<$i; $j++){
													echo '<td align="right"><b>'.number_format(0, 2, '.', ',').'</b></td>';
												}
											}
											echo"<td align='right'><b>".number_format($totAmount, 2, '.', ',')."</b></td>";
										"</tr>";
                                echo"</tbody>         
                            </table>
                        </div><!-- content -->";  ?>                            
                    </div><!-- block -->
                    
                    <div>
                    	<b><?php echo $this->lang->line('purchase') ?></b>
                    </div>
                    <div class="block">
                        <?php
						$count = 0;
                        echo "<div class='content np table-sorting'>
                            <table cellpadding='0' cellspacing='0' width='100%' id='test' class='editable'>
                                <thead>
                                <tr>
                                    <th class='tac'>#</th>
                                    <th class='tac'>".$this->lang->line('taxCode')."</th>";
									for($i=0; $i<$monthDiff; $i++){
										if($monthDiff > 1){
												if($i == 0){	
													if(date("M", strtotime($i." months", strtotime($dateFrom))) == "Dec"){
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
														//$count = 0;
														$count ++;
													}
													else{
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
													}
												}
												else{
													if(date("M", strtotime($i." months", strtotime($dateFrom))) == "Dec"){
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
														$count ++;
													}
													else{
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
													}
												}
										}
										else{
											echo "<th class='tac'>".date("M", strtotime($dateFrom))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
										}
									}
									echo "<th class='tac'>".$this->lang->line('total')."</th>";
                                "</tr>
                                </thead>
                                <tbody>";
                                    	$bil = 0;
										//$bil2 = 0;
										$totCol = array();
										if($datatbls2){
										foreach($datatbls2 as $datatbl2):
										$bil++;
										echo"<tr class='itemList'>
                                            <td class='tac'>".$bil."</td>
                                        	<td class='tac'>".$datatbl2->code."</td>";
											//for($i=0; $i<$monthDiff; $i++){
											$total = 0;
											$i = 0;
											
											foreach ($datatbl2 as $col => $val) {
												if (strtoupper(substr($col,0,5))=='MONTH'){
													echo '<td align="right">'.number_format($val, 2, '.', ',').'</td>';
													$total += $val;
													if($bil == 1)
														$totCol[] += $val;
													else
														$totCol[$i] += $val;	
													$i++;
												}
													//echo "<td class='tac'>".$datatbl->month3."</td>";
											}
											//foreach ($totSales as $totSale) {
												echo '<td align="right"><b>'.number_format($total, 2, '.', ',').'</b></td>';
												//echo '<td align="right">'.number_format($totSales[$bil]->totGstSales, 2, '.', ',').'</td>';
												//$bil2++;
											//}
                                        "</tr>";
										
										
									endforeach;
											}
									$bil = $bil + 1;
									echo"<tr>
											<td class='tac'></td>
											<td class='tar'><b>".$this->lang->line('total')."</b></td>";
											//var_dump($totCol);
											$totAmount = 0;
											if($datatbls2){
												for($j=0; $j<$i; $j++){
													$totAmount += $totCol[$j];
													echo '<td align="right"><b>'.number_format($totCol[$j], 2, '.', ',').'</b></td>';
												}
											}
											else{
												for($j=0; $j<$i; $j++){
													echo '<td align="right"><b>'.number_format(0, 2, '.', ',').'</b></td>';
												}
											}
											echo"<td align='right'><b>".number_format($totAmount, 2, '.', ',')."</b></td>";
										"</tr>";
                                echo"</tbody>         
                            </table>";
							?>