
<?php $tdNoFormat = isset($tdNoFormat)?$tdNoFormat:array(); ?>

     <?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;">
       			<img class="image" style="position:absolute;left:0;top:0;z-index: -1000;height:41px;" alt="" src="<?php echo base_url() ?>img/rptPaymentAdvice.png" />
                <table class="table" style="z-index: 100" cellpadding="0" cellspacing="0" width="80%">
                   
                    <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; max-width:300px'>".number_format($array[$selectFields[$p]],2)."</td>";
                                    }elseif (in_array($selectFields[$p],$tdAmount) && in_array($selectFields[$p],$tdNoFormat)){
                                        $tr .= "<td style='text-align:right; max-width:300px'>".$array[$selectFields[$p]]."</td>";
                                    }else{
                                        $tr .= "<td style='max-width:300px;'>".$array[$selectFields[$p]]."</td>";
                                    }
                                }  else {
                                    $tr .= "<td style='max-width:300px;'>".$array[$selectFields[$p]]."</td>";
                                }
                              
                            }
                            $tr .= "</tr>";
                            echo $tr;
                        }
                        endif;
                    ?>
                    	
                    
                        <?php 
                            if (isset($tableFooter)){
                                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 "<p>".$value."</p>";
                              }
                              echo "</td></tr>";
                            }
                        ?>
                </tbody>
            </table>
               <?php// $rptDataDetail[] = $rptDataDetail[0]; echo count((array)$rptDataDetail); echo "hsssssssdakjdnaldkmaldkmad"; ?>        
      </td>
    </tr>
     <?php } ?>