<?php $tdNoFormat = isset($tdNoFormat)?$tdNoFormat:array(); ?>
<style>
  .table1 th,.table1 td{
    line-height:10px;
    padding:5px;
  }
  
</style>
    <tr><td colspan="2"></td></tr><tr><td colspan="2"></td></tr><tr><td colspan="2"></td></tr>
     <?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" align="right" class="span12">
            <table class="table1 span12" cellpadding="0" cellspacing="0" style="float:right;">                   
                <thead class="thPrint">
                     <tr>
                       <?php   
                            if (isset($tableHeader)){
                                
                                if (!in_array("#",$tableHeader)){
                                    echo " <th style='border: 1px solid #dddddd;'>No.</th>"; 
                                    $p = 0;
                                    foreach ($tableHeader as $value) {
                                        if (isset($tdAmount) && in_array($selectFields[$p++],$tdAmount)) {  
                                            echo " <th style='text-align:right;border: 1px solid #dddddd;'>".$value."</th>";
                                        }else{
                                            echo " <th align='left' style='border: 1px solid #dddddd;'>".$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 align='middle'>".$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 align='left'>".$array[$selectFields[$p]]."</td>";
                                      }
                                  }  else {
                                      $tr .= "<td align='left'>".$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>      
        </td>
    </tr>
     <?php } ?>