<?php $tdNoFormat = isset($tdNoFormat)?$tdNoFormat:array(); ?>
<style>
	.table th,.table td{
		line-height:10px;
	}
</style>
     <?php if (!empty($rptDataDetail)) { ?>
	<?php if(isset($headerLeft)): ?>
    <tr>
    	<td colspan="2">
        	<?php 
				echo "<p style='padding-left:10px; margin:0; font-size:11px; '>"
								. "<strong>".$headerLeft."</strong></p>"
			?>
        </td>
    </tr>
    <?php endif; ?>
    <tr>
       <td colspan="2" style="position: relative">
                <table class="table" style="z-index: 100" cellpadding="0" cellspacing="0" width="100%">
                    <thead class="thPrint">
                        <tr> <?php /*style="background:url(<?php echo base_url() ?>img/rptPaymentAdvice.png)" */ ?>
                            <?php 
                                if (isset($tableHeader)){
                                    
                                 if (!in_array("#",$tableHeader))
                                     echo " <th>No.</th>"; 
									 $p = 0;
								foreach ($tableHeader as $value) {
                                	if (isset($tdAmount) && in_array($selectFields[$p++],$tdAmount)) {	
										echo " <th style='text-align:right;'>".$value."</th>";
									}else{
										echo " <th>".$value."</th>";
									}
								}
                            }
                            ?>

                        </tr>
                    </thead>
                    <tbody class="tbPrint">
                        <?php
                        $i = 1;
                        $total = 0;
                        $nHeader = 0;
                         if (isset($tableHeader))
                              $nHeader =  sizeof($tableHeader);
							  $i = 1;
                        if(!empty($rptDataDetail)):
                        foreach ($rptDataDetail as $row1) {
                          
                            $tr ="<tr><td>".$i++."</td>";
							
                            for ($p=0; $p<$nHeader; $p++){
                               $array = get_object_vars( $row1);
                              // var_dump($array);
                               if (in_array("lineNo",$selectFields))
                                   $tr ="<tr><td>".$array[$selectFields["lineNo"]]."</td>";
                                if (isset($tdAmount)) {
                                    if (in_array($selectFields[$p],$tdAmount) && !in_array($selectFields[$p],$tdNoFormat)){
                                        $tr .= "<td style='text-align:right;'>".number_format($array[$selectFields[$p]],2)."</td>";
                                    }elseif (in_array($selectFields[$p],$tdAmount) && in_array($selectFields[$p],$tdNoFormat)){
                                        $tr .= "<td style='text-align:right;'>".$array[$selectFields[$p]]."</td>";
                                    }else{
                                        $tr .= "<td>".$array[$selectFields[$p]]."</td>";
                                    }
                                }  else {
                                    $tr .= "<td>".$array[$selectFields[$p]]."</td>";
                                }
                              
                            }
                            $tr .= "</tr>";
                            echo $tr;
                        }
                        endif;
                    ?>
                    	
                    
                        <?php 
                            if (isset($tableFooter)){
                                $colHdr = sizeof($tableHeader);
                                $colFtr = sizeof($tableFooter);
                                echo '<tr><td style="border:none" colspan="'.($colHdr-$colFtr+1).'"></td>';
                                /*if (in_array("#",$tableHeader))
                                    echo " <tr><td style='text-align:right;' colspan='".sizeof($tableHeader)."'>";
                                else 
                                    echo " <tr><td style='text-align:right;' colspan='".(sizeof($tableHeader)+1)."'>";
                                */
                                 foreach ($tableFooter as $value) {
                                    echo "<td class='tar'' style='border-top:1px solid #424242;'><b>".$value."</b></td>";
                              }
                              echo "</tr>";
                            }
                        ?>
                        <?php
                        if (isset($grandTotal)){
                            $colHdr = sizeof($tableHeader);
                            $colFtr = sizeof($grandTotal);
                            echo '<tr><td style="border:none;" colspan="'.($colHdr-$colFtr+1).'"></td>';
                            foreach ($grandTotal as $value) {
                                echo "<td class='tar'' style='border-top:1px solid #424242;border-bottom:3px double #424242;'><b>".$value."</b></td>";
                            }
                            echo "</tr>";
                        }
                        ?>
                        <?php
                        if (isset($finalTotal)){
                            $colHdr = sizeof($tableHeader);
                            $colFtr = sizeof($finalTotal);
                            echo '<tr><td style="border:none;" colspan="'.($colHdr-$colFtr+1).'"></td>';
                            foreach ($finalTotal as $value) {
                                echo "<td class='tar'' style='border-top:1px solid #424242;border-bottom:3px double #424242;'><b>".$value."</b></td>";
                            }
                            echo "</tr>";
                        }
                        ?>
                </tbody>
            </table>
               <?php// $rptDataDetail[] = $rptDataDetail[0]; echo count((array)$rptDataDetail); echo "hsssssssdakjdnaldkmaldkmad"; ?>        
        </td>
    </tr>
     <?php } ?>