<style type="text/css">
<!--
table
{
    width:  100%;
}

</style>

    <body>
        
        <table  style="width:97%; margin-top:20px; margin:auto;" class="printTbl">
            <tbody>
                        <tr>
                            <td colspan="2"  style="overflow:hidden; padding-bottom:10px;">
                                <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 if(isset($rptTitle)) echo $rptTitle; ?>
                                </p>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" class="container-fluid">
                            	<div class="col-lg-4 col-md-4 col-sm-4 text-center">
                            		<img class="compLogo img-circle" src="<?php echo base_url(). 'dist/companyProfile/'.element('compID', $this->session->userdata('logged_in')).".jpg";?>" style="width:100px;" />
                            	</div>
                            	<div class="col-lg-4 col-md-4 col-sm-4">
                                <?php
                                if (isset($company)) {
                                    foreach ($company as $rowC) {
                                        ?>

                                        <?php if(isset($pdf417)): ?>
                                            <div class="fr">
                                                <?php 
                                                    echo $pdf417;
                                                ?>
                                            </div>
                                        <?php endif; ?>
                                        <p style="text-align:center; font-size:16px; width:355px;margin:0 auto;"> 
                                            <span style=" font-weight:800;"><?php echo $rowC->companyName; ?></span><br />
                                        </p>
                                        <p style="width: 355px; text-align:center; font-size:10px; line-height:1.4; padding:0 0 5px; margin:0 auto; ">
                                            
                                            <?php if(!empty($rowC->line1)): ?><span><?php echo $rowC->line1; ?></span><br /><?php endif; ?>
                                            <?php if(!empty($rowC->line2) || !empty($rowC->line3)): ?><span><?php echo $rowC->line2.", ".$rowC->line3; ?></span><br /><?php endif; ?>
                                            <?php if(!empty($rowC->companyPostCode) || !empty($rowC->city)): ?><span><?php echo $rowC->companyPostCode . '  ' . $rowC->city; ?> </span><br /><?php endif; ?>
                                            <?php if(!empty($rowC->fldname) || !empty($rowC->fldcountry)): ?><span><?php echo $rowC->fldname . '  ' . $rowC->fldcountry; ?> </span><br /><?php endif; ?>
                                            <?php if(!empty($rowC->phoneNo) || !empty($rowC->faxNo)): ?><span><?php echo 'Phone : ' . $rowC->phoneNo . '  Fax : ' . $rowC->faxNo; ?> </span><?php endif; ?>
                                        </p>
                                    <?php }
                                }
                                ?>
                                </div>
                                <div class="col-lg-4 col-md-4 col-sm-4">
                                </div>

                            </td>
                        </tr>
                        <?php if(isset($leftContentHeader) || isset($leftContent) || isset($rightContentHeader) || isset($rightContent)): ?>
                        <tr>
                            <td>
                                <?php
                                if (isset($leftContentHeader)){
                                    echo "<p class='modPrint' style='padding-left:10px; margin:0; font-size:11px; '>"
                                    . "<strong>".$leftContentHeader."</strong></p>";
                                }
                                 
                                 if (isset($leftContent)){
                                   echo '<p style="padding-left:10px; margin:0; line-height:1.4;">';
                                    foreach ($leftContent as $value) {
                                         echo $value != ''?"<span>".$value."</span><br />":'';
                                     }
                                      if (isset($sale_invoice_date)){
                                   echo '<div class="div_paid modPrint" style="padding-left: 10px; line-height: 1.4; position: relative; width: 100px; height: 0px; float: right; margin-top: -80px; margin-right: 30%;">';
                                        echo '<div class="paid_paid">PAID</div><div class="paid_date">'.$sale_invoice_date.'</div>';
                                  echo '</div>';
                                 }
                                  echo '</p>';
                                 }
                                 
                                 
                                
                                ?>
                                
                            </td>
                                
                            <td valign="top" align="right">
                                <?php if(isset($rightContentHeader) || isset($rightContent)): ?>
                                    <?php
                                        if (isset($rightContentHeader)){
                                        	echo "<p class='modPrint' style='padding-right:10px; margin:0; font-size:11px; '>"
                                        			. "<strong>".$rightContentHeader."</strong></p>";
                                        } 
                                        if (isset($rightContent)){
                                             foreach ($rightContent as $value) {
                                                echo $value != ''?"<span>".$value."</span><br />":'';
                                            }
                                        }
                                    ?>
                                <?php endif; ?>
                              </td>
                        </tr>
                        <?php endif; ?>
                        <?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;">
       		
                <table style="width:97%; margin-top:20px; margin:auto;" class="printTbl">
                   <col style="width: 5%">
                   <col style="width: 25%">
                   <col style="width: 30%">
                   <col style="width: 40%">
                    <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>       
      </td>
    </tr>
     <?php } ?>
     <tr>
    <td colspan="2">
        <table>
        <col style="width: 0%">
        <col style="width: 100%">
            <tr class="tr_amnt">
                <td class='text-left'>
                    <?php
                    if (isset($amountWord)) {
                        ?>
                        <p style="font-weight:300;"><?php echo $amountWord; ?></p>
                        <?php
                    }
                    ?>            
                </td>

                <td class="text-right">
                    <?php
                    if (isset($amountCount)) {
                        foreach ($amountCount as $value) {
                            $temp = explode(":", $value);
                            echo "<table align='right'><tr>
                                            <td styl class='field'>" . $temp[0] . ": </td>
                                            <td style='min-width: 120px; ' class='value'>" . $temp[1] . "</td>
                                          </tr></table>";
                        }
                    }
                    ?>
                </td>
            </tr>
            <?php 
            if(isset($remark) && $remark !==""){
            ?>
            <tr>
                <td colspan="2">
                    <p style="padding-top: 50px; padding-bottom: 20px;">
                        <?php  echo $remark; ?>
                    </p>
                </td>
            </tr>
            <?php 
           }
            ?>
            
            <?php 
            if(isset($signature)){
            ?>
            <tr>
                <td colspan="2">
                    <div  style="width: 200px; border-top: 1px solid rgb(0, 0, 0); text-align: center; margin-top: 100px; padding-top: 10px;" >
                         <?php  echo $signature; ?>
                    </div>
                   
                </td>
            </tr>
            <?php 
           }
            ?>
            
        </table>
    </td>
</tr>
<tr>
    <td colspan="2">
        <p>
        </p>
    </td>
</tr>


</tbody>
</table>

<?php

$content = ob_get_clean();
		
        require_once(dirname(__FILE__).'/fad/html2pdf.class.php');
        try
        {
            $html2pdf = new HTML2PDF('P', 'A4', 'fr');
            $html2pdf->writeHTML($content);
            $html2pdf->Output('exemple09.pdf');
            exit;
        }
        catch(HTML2PDF_exception $e) {
            echo $e;
            exit;
        }

?>