<?php
$today = (!empty($created_on)) ? date("d/m/Y",strtotime($created_on)) : date("d/m/Y");
$tel_html = ( !empty( $settings['contact_no'] ) ? 'Tel: '.$settings['contact_no'] : '' ).'&nbsp;&nbsp;'. (!empty( $settings['fax'] ) ? 'Fax: '.$settings['fax'] : '');

?>
    <div class="page" style="<?php echo $status == "2" || IS_DEMO ? 'background: url('. BASE_URL .'assets/images/watermark'. ( IS_SHORT ? '-short' : '' ) . ( IS_DEMO ? '-demo' : '' ) .'.png) no-repeat center;' : ''; ?>" >
	<table width="<?php echo WIDTH; ?>" border="0" style="<?php echo IS_SHORT ? 'font-size:12px;' . ( $type != 5 ? ' border-bottom: 1px solid #999; ' : '' ) : 'font-size:14px;font-weight:bold;'; ?> font-family:Verdana, Geneva, sans-serif;">
        <tr>
            <td>
                <table width="<?php echo WIDTH; ?>">
                    
                    <?php if( IS_SHORT ) : ?>
                        <tr>
                            <td width="37.5%"></td>
                            <td width="37.5%"></td>
                            <td width="15%"></td>
                            <td width="10%"></td>
                        </tr>
                        
                        <tr>
                            <td colspan="2" width="75%"><?php echo !empty( $rec_no ) ? 'No: <strong>' . (is_array( $rec_no ) ? $rec_no[0] : $rec_no) . '</strong>' : '&nbsp;'; ?></td>
                            <td width="15%" rowspan="2" style="font-size:24px;" align="right"><?php echo $total_qty; ?></td>
                            <td width="10%">&nbsp;</td>
                        </tr>
                    
                        <tr>
                            <td colspan="2">Date: <strong><?php echo $today.($type != '5' ? ' '.date("h:i A") : ''); ?></strong></td>
                            <td>&nbsp;</td>
                        </tr>
                        
                        <tr>
                                <td colspan="4" style="font-weight:bold; font-size:13px; font-family:Amudham; font-size:25px; text-shadow: 1px 0px #000;" align="center"><strong><?php echo $settings['tamil_name']; ?></strong></td>
                        </tr>
                        <tr>
                                <td colspan="4" style="font-weight:bold; text-transform:uppercase;" align="center"><?php echo $settings['temple_name']; ?></td>
                        </tr>
                        <?php     
                        /*
                        <tr>
                                <td colspan="4" align="center"><?php echo nl2br($settings['address']); ?></td>
                        </tr>
                        <tr>
                                <td colspan="4" align="center"><?php echo $tel_html; ?></td>
                        </tr>*/
                        
                        if( !empty( $title ) ) : 
                        ?>
                            
                            <tr>
                                <td colspan="4" style="font-weight:bold; text-transform:uppercase;" align="center"><?php echo $title; ?></td>
                            </tr>
                        <?php 
                        endif;
                        
                    else:
                        
                        // Large
                        $logo_url = !empty( $settings['logo'] ) && file_exists( DIR_COMPANY_LOGO . $settings['logo'] ) ?  DIR_COMPANY_LOGO . $settings['logo'] : 'assets/images/logo.png';
                    ?>    
                        <tr>
                            <td width="5%"><div style="min-width: 115px;">
							<!--<img src="<?php // echo BASE_URL.$logo_url; ?>" style="max-width: 100%;" /> -->
							</div></td>
                            <td width="70%">
                                <table border="0" width="100%">
                                    <tr>
                                        <td align="center">
										<!--<strong><?php echo tamil($settings['tamil_name'], 'font-weight:bold; font-family:Amudham; font-size:25px; text-shadow: 1px 0px #000; border: none; width: 100%; text-align: center;'); ?></strong> -->
										
										</td>
                                    </tr>
                                    <tr>
                                        <td align="center" style="font-size:18px;">
										<?php // echo $settings['temple_name']; ?></td>
                                    </tr>
                                    <tr>
                                        <td align="center"><?php // echo nl2br($settings['address']); ?></td>
                                    </tr>
                                    <tr>
                                        <td align="center"><?php // echo $tel_html; ?></td>
                                    </tr>

                                    <?php // if( !empty( $settings['contact_email'] ) ) : ?>
                                        <tr>
                                            <td align="center"><?php // echo $settings['contact_email'] . ( !empty( $settings['website_url'] ) ? ' | ' . $settings['website_url'] : ' | www.holytreebalasubramaniar.com.sg' ); ?></td>
                                        </tr>
                                    <?php // endif; #if( !empty( $settings['website_url'] ) ) : ?>
                                        <!--<tr>
                                            <td align="center"><?php // echo $settings['website_url']; ?></td>
                                        </tr>-->
                                    <?php #endif; ?>
                                </table>
                           </td>


                           <td width="20%">
                                <?php if(!IS_KSK_CMS) {  ?>
                                    <table border="0" width="100%">
                                        <?php if(!empty($rec_no)) : ?>
                                        <tr>
                                            <td align="left" valign="middle"> <strong>Receipt No: <span style="font-weight:bold; font-size:20px;"> <?php echo $rec_no; ?> </span></strong></td>
                                        </tr>
                                        <tr height="5"></tr>

                                        <?php endif; // if( $is_copy ): ?>
                                        <tr>
                                            <td align="left" valign="middle" data-copy="Official's copy">Devotee's Copy</td>
                                        </tr>
                                        <tr height="5"></tr>
                                        <?php // endif; ?>

                                        <!--<tr>
                                            <td align="left" valign="middle" style="font-family:Amudham; font-size:15px;"><strong>தேதி</strong><span style="font-family:Verdana, Geneva, sans-serif; font-size:14px;">: <?php echo $today; ?></span></td>
                                        </tr>
                                        <tr height="5"></tr>-->
                                        <tr>
                                            <td align="left" valign="middle"><strong>Date: <span style="font-weight:bold; font-size:15px;"><?php echo $today; ?></strong></span></td>
                                        </tr>
                                        <!-- <tr>
                                            <td>&nbsp;</td>
                                        </tr> -->
                                    </table>
                                <?php } ?>
                            </td>
                        </tr>
                    <?php endif; ?>    
                    
                </table>
				
				
				<?php if( $type=='11' ){ $hght = "600"; } else if($type=='10'){ $hght = "480"; } //560
				else if( $type=='13' or  $type=='15' or $type=='16' ) { $hght= "440"; } else if( $type=='1'){ $hght= "460"; } //430
				else if($type=='12'){ $hght = "430"; } else if($type=='9'){ $hght = "570"; } else if($type=='14' or $type=='17'){ $hght= "440"; }?>
				
                <table width="<?php echo WIDTH; ?>" height="<?php echo $hght; ?>" >
                    <tr style="vertical-align:top">
                        <td>
                            <table border="0" width="100%" cellpadding="5">
                                <?php if(!IS_SHORT) : ?>
                                <tr height="20" ><td></td></tr>  <!--class="auto-adj"-->
                                <tr>
                                    <td align="center" colspan="7" style="font-weight:bold; font-size:18px;"><?php echo $title; ?></td>
                                </tr>
                                <?php endif; ?>
                                <tr height="5"></tr>







<?php

/* 
 * Author       : Jai K
 * Purpose      : View for Print Format 6 (Common purposes)
 * Created On   : 2016-09-22 18:14
 */

$amount = is_array($amount) ? $amount[0] : $amount;
?>
<tr><td colspan="7">
<table width="100%">
<tr><td width="50%">
<table width="100%">
                                
                                <?php 
                                    $k = 0;
                                    if(count($data['fields']) > 0) {
                                    foreach( $data['fields'] as $label => $value ) :
                                            
                                ?>
                                        <tr>
                                        <td width="18%" class="lbl" style="font-size: 14px;"><?php echo $label; ?></td>
                                        <td width="1%">:</td>
                                        <td width="36%" style="<?php echo !IS_SHORT ? 'border-bottom:2px dotted #000;' : ''; ?> font-size: 14px;"><?php echo $value; ?></td>
                                        <td width="1%">&nbsp;</td>
										</tr> <tr height="5"></tr><tr>
                                <?php 
                                       // echo ++$k % 2 == 0 || IS_SHORT ? '</tr><tr height="5"></tr><tr>' : '';
                                    endforeach; 
                                    }
                                ?>                                
                                       
                            </table>
                        </td>
						
						<td width="50%">
						<table width="100%" border="1" style="border-collapse:collapse;" cellpadding="5"> 
						
						<?php
                    if( !empty( $data['tables'] ) ) :
                        $tables = !empty( $data['tables']['head'] ) ? array($data['tables']) : $data['tables'];
                        #echo '<pre>';print_r($tables);
                        foreach( $tables as $k => $table ) :
                            ?>
                                <div class="auto-adj" style="width: 100%; min-height: 10px;">&nbsp;</div>
                                <table width="100%" id="tdhgt" height="100%" border="1" style="border-collapse:collapse; margin-top: 10px 0px;" cellpadding="5" <?php echo $table['attr']; ?> > <?php // echo WIDTH; ?>
                                    <tr>
                                    <?php 
                                      unset($table['attr']);
                                    
                                      $sno = $table['head']['sno'];
                                      unset($table['head']['sno']);
                                    if(!(empty($sno)) && !$sno) : ?>
                                        <th>S.No</th>
                                    <?php endif;
                                    
                                        $attr = $table['head']['attr'];
                                        unset($table['head']['attr']);
                                        foreach( $table['head'] as $h => $th ) : ?>
                                        <?php if(!empty($th)) { ?>
                                            <th style="font-size: 14px;" <?php echo $attr; ?>><?php echo $th; ?></th>
                                        <?php } ?>
                                    <?php endforeach; ?>
                                    </tr> 
                                    
                                    <?php if(count($table['body']) > 0) {
                                        foreach( $table['body'] as $b => $row ) : 
                                            //$row = explode(',', $row);
                                        //echo "<pre>Data: "; print_r($row[0]); die;

                                            ?>
                                            <tr class="tbl-row">
                                                <?php if(!(empty($sno)) && !$sno) : ?>
                                                    <td style="font-size: 14px;" align="center"><?php echo ++$b; ?></td>
                                                <?php endif;?>
                                            <?php $length = count($row);
                                            foreach( $row as $t => $td ) :
                                            if(!empty($td) || $td == 0) {
                                                if(!IS_KSK_CMS) {
                                                    if($length == ($t + 1)) :
                                                        $align = "align=right";
                                                    else :
                                                        $align = "align=left";
                                                    endif; 
                                                } else {
                                                    if(empty($sno) && $sno) {
                                                        if((($length - 1 ) == ($t + 1)) || (($length - 2 ) == ($t + 1)) || (($length ) == ($t + 1))) {
                                                            $align = "align=right";
                                                        } elseif((($length - 3 ) == ($t + 1)) || (($length - 4 ) == ($t + 1))) {
                                                            $align = "align=center";
                                                        }else {
                                                            $align = "align=left";
                                                        }
                                                    } else {
                                                        $align = "align=left";
                                                    }
                                                }
                                                ?><td style="font-size: 14px;" <?php echo $align;?>><?php echo $td; ?></td><?php
                                            }
                                            endforeach;
                                            ?>
                                            </tr>
                                    <?php endforeach;

                                        } else { ?>
                                            <tr>
                                                <td colspan="<?php echo (count($table['head']) + 1);?>"><center>No Records Found!</center></td>
                                            </tr> 
                                    <?php } ?>
                                        
                                </table>
                                <div class="auto-adj" style="width: 100%; min-height: 10px;">&nbsp;</div>
                                
                            <?php
                        endforeach;
                    endif; 
                ?>
						
                    </tr>
                </table>
				</td></tr></table>
                
                
                <?php
                    if( !empty( $data['sub_tables'] ) ) :
                        $sub_tables = !empty( $data['sub_tables']['head'] ) ? array($data['sub_tables']) : $data['sub_tables'];
                    
                        foreach( $sub_tables as $k => $table ) :
                            ?>  
                                <div class="auto-adj" id="subtable" style="width: 100%;">&nbsp;</div>
                                <table width="50%" border="1" id="subhht" style="border-collapse:collapse; margin: 0px 0px;" cellpadding="5" align="right">
                                    <?php
                                        foreach( $table['body'] as $b => $row ) : 
                                            //$row = explode(',', $row);
                                        //echo "<pre>Data: "; print_r($row[0]); die;

                                            ?>
                                            <tr>
                                            <?php $length = count($row);
                                            foreach( $row as $t => $td ) :
                                                if($length == ($t + 1)) :
                                                    $align = "align=right";
                                                else :
                                                    $align = "align=left";
                                                endif; 
                                                ?><td style="font-size: 15px;" <?php echo $align;?>><?php echo $td; ?></td><?php
                                            endforeach;
                                            ?>
                                            </tr>
                                    <?php endforeach; ?>
                                </table>
                            <?php
                            
                        endforeach;
                    endif; 
                ?>
                
                
                <table width="<?php echo WIDTH; ?>">
                    <tr>
                        <td>
                            <table border="0" width="100%" cellpadding="5">
                            <tr height="55" ></tr>							
							   <?php if(!empty( $amount )) : ?>
                                <tr>
                                    <td colspan="2" style="font-weight:bold; font-size: 18px;">S$ <?php echo number_format($amount,2,'.',''); ?>/- <?php echo ($gst == 1 ? '(Inclusive of GST)' : '') . $pay_mode_str;?></td>
                                </tr>
                                <tr height="5" class="no-copy"></tr>
                                <tr>
                                    <td style="font-weight:bold; font-size: 14px;" width="20%">Amount in Words (S$):</td>
                                    <td width="80%"><?php echo convert_amount_to_word( $amount ); ?></td>
                                </tr>
                               <!-- <tr height="5" class="no-copy"></tr> -->
                                <?php endif; ?>
                
				
				
				<table><tr><td height="200px;">&nbsp;</td></tr></table>
				
				
				
				<?php
$today = date("d/m/Y");
$tel_html = ( !empty( $settings['contact_no'] ) ? 'Tel: '.$settings['contact_no'] : '' ).'&nbsp;&nbsp;'. (!empty( $settings['fax'] ) ? 'Fax: '.$settings['fax'] : '');

?>
    <div class="page" style="<?php echo $status == "2" || IS_DEMO ? 'background: url('. BASE_URL .'assets/images/watermark'. ( IS_SHORT ? '-short' : '' ) . ( IS_DEMO ? '-demo' : '' ) .'.png) no-repeat center;' : ''; ?>" >
	<table width="<?php echo WIDTH; ?>" border="0" style="<?php echo IS_SHORT ? 'font-size:12px;' . ( $type != 5 ? ' border-bottom: 1px solid #999; ' : '' ) : 'font-size:14px;font-weight:bold;'; ?> font-family:Verdana, Geneva, sans-serif;">
        <tr>
            <td>
                <table width="<?php echo WIDTH; ?>">
                    
                    <?php if( IS_SHORT ) : ?>
                        <tr>
                            <td width="37.5%"></td>
                            <td width="37.5%"></td>
                            <td width="15%"></td>
                            <td width="10%"></td>
                        </tr>
                        
                        <tr>
                            <td colspan="2" width="75%"><?php echo !empty( $rec_no ) ? 'No: <strong>' . (is_array( $rec_no ) ? $rec_no[0] : $rec_no) . '</strong>' : '&nbsp;'; ?></td>
                            <td width="15%" rowspan="2" style="font-size:24px;" align="right"><?php echo $total_qty; ?></td>
                            <td width="10%">&nbsp;</td>
                        </tr>
                    
                        <tr>
                            <td colspan="2">Date: <strong><?php echo $today.($type != '5' ? ' '.date("h:i A") : ''); ?></strong></td>
                            <td>&nbsp;</td>
                        </tr>
                        
                        <tr>
                                <td colspan="4" style="font-weight:bold; font-size:13px; font-family:Amudham; font-size:25px; text-shadow: 1px 0px #000;" align="center"><strong><?php echo $settings['tamil_name']; ?></strong></td>
                        </tr>
                        <tr>
                                <td colspan="4" style="font-weight:bold; text-transform:uppercase;" align="center"><?php echo $settings['temple_name']; ?></td>
                        </tr>
                        <?php     
                        /*
                        <tr>
                                <td colspan="4" align="center"><?php echo nl2br($settings['address']); ?></td>
                        </tr>
                        <tr>
                                <td colspan="4" align="center"><?php echo $tel_html; ?></td>
                        </tr>*/
                        
                        if( !empty( $title ) ) : 
                        ?>
                            
                            <tr>
                                <td colspan="4" style="font-weight:bold; text-transform:uppercase;" align="center"><?php echo $title; ?></td>
                            </tr>
                        <?php 
                        endif;
                        
                    else:
                        
                        // Large
                        $logo_url = !empty( $settings['logo'] ) && file_exists( DIR_COMPANY_LOGO . $settings['logo'] ) ?  DIR_COMPANY_LOGO . $settings['logo'] : 'assets/images/logo.png';
                    ?>    
                        <tr>
                            <td width="5%"><div style="min-width: 115px;">
							<!--<img src="<?php // echo BASE_URL.$logo_url; ?>" style="max-width: 100%;" /> -->
							</div></td>
                            <td width="70%">
                                <table border="0" width="100%">
                                    <tr>
                                        <td align="center">
										<!--<strong><?php echo tamil($settings['tamil_name'], 'font-weight:bold; font-family:Amudham; font-size:25px; text-shadow: 1px 0px #000; border: none; width: 100%; text-align: center;'); ?></strong> -->
										
										</td>
                                    </tr>
                                    <tr>
                                        <td align="center" style="font-size:18px;">
										<?php // echo $settings['temple_name']; ?></td>
                                    </tr>
                                    <tr>
                                        <td align="center"><?php // echo nl2br($settings['address']); ?></td>
                                    </tr>
                                    <tr>
                                        <td align="center"><?php // echo $tel_html; ?></td>
                                    </tr>

                                    <?php // if( !empty( $settings['contact_email'] ) ) : ?>
                                        <tr>
                                            <td align="center"><?php // echo $settings['contact_email'] . ( !empty( $settings['website_url'] ) ? ' | ' . $settings['website_url'] : ' | www.holytreebalasubramaniar.com.sg' ); ?></td>
                                        </tr>
                                    <?php // endif; #if( !empty( $settings['website_url'] ) ) : ?>
                                        <!--<tr>
                                            <td align="center"><?php // echo $settings['website_url']; ?></td>
                                        </tr>-->
                                    <?php #endif; ?>
                                </table>
                           </td>


                           <td width="20%">
                                <?php if(!IS_KSK_CMS) {  ?>
                                    <table border="0" width="100%">
                                        <?php if(!empty($rec_no)) : ?>
                                        <tr>
                                            <td align="left" valign="middle"> <strong>Receipt No: <span style="font-weight:bold; font-size:20px;"> <?php echo $rec_no; ?> </span></strong></td>
                                        </tr>
                                        <tr height="5"></tr>

                                        <?php endif; // if( $is_copy ): ?>
                                        <tr>
                                            <td align="left" valign="middle" data-copy="Official's copy">Official's Copy</td>
                                        </tr>
                                        <tr height="5"></tr>
                                        <?php // endif; ?>

                                        <!--<tr>
                                            <td align="left" valign="middle" style="font-family:Amudham; font-size:15px;"><strong>தேதி</strong><span style="font-family:Verdana, Geneva, sans-serif; font-size:14px;">: <?php echo $today; ?></span></td>
                                        </tr>
                                        <tr height="5"></tr>-->
                                        <tr>
                                            <td align="left" valign="middle"><strong>Date: <span style="font-weight:bold; font-size:15px;"><?php echo $today; ?></strong></span></td>
                                        </tr>
                                        <!-- <tr>
                                            <td>&nbsp;</td>
                                        </tr> -->
                                    </table>
                                <?php } ?>
                            </td>
                        </tr>
                    <?php endif; ?>    
                    
                </table>
				
				
				<?php if( $type=='11' ){ $hght = "600"; } else if($type=='10'){ $hght = "480"; } //560
				else if( $type=='13' or  $type=='15' or $type=='16' ) { $hght= "440"; } else if( $type=='1'){ $hght= "460"; } //430
				else if($type=='12'){ $hght = "430"; } else if($type=='9'){ $hght = "570"; } else if($type=='14' or $type=='17'){ $hght= "440"; }?>
				
                <table width="<?php echo WIDTH; ?>" height="<?php echo $hght; ?>" >
                    <tr style="vertical-align:top">
                        <td>
                            <table border="0" width="100%" cellpadding="5">
                                <?php if(!IS_SHORT) : ?>
                                <tr height="20" ><td></td></tr>  <!--class="auto-adj"-->
                                <tr>
                                    <td align="center" colspan="7" style="font-weight:bold; font-size:18px;"><?php echo $title; ?></td>
                                </tr>
                                <?php endif; ?>
                                <tr height="5"></tr>
								
								
								
								

<?php

/* 
 * Author       : Jai K
 * Purpose      : View for Print Format 6 (Common purposes)
 * Created On   : 2016-09-22 18:14
 */

$amount = is_array($amount) ? $amount[0] : $amount;
?>
<tr><td colspan="7">
<table width="100%">
<tr><td width="50%">
<table width="100%">
                                
                                <?php 
                                    $k = 0;
                                    if(count($data['fields']) > 0) {
                                    foreach( $data['fields'] as $label => $value ) :
                                            
                                ?>
                                        <tr>
                                        <td width="18%" class="lbl" style="font-size: 14px;"><?php echo $label; ?></td>
                                        <td width="1%">:</td>
                                        <td width="36%" style="<?php echo !IS_SHORT ? 'border-bottom:2px dotted #000;' : ''; ?> font-size: 14px;"><?php echo $value; ?></td>
                                        <td width="1%">&nbsp;</td>
										</tr> <tr height="5"></tr><tr>
                                <?php 
                                       // echo ++$k % 2 == 0 || IS_SHORT ? '</tr><tr height="5"></tr><tr>' : '';
                                    endforeach; 
                                    }
                                ?>                                
                                       
                            </table>
                        </td>
						
						<td width="50%">
						<table width="100%" border="1" style="border-collapse:collapse;" cellpadding="5"> 
						
						<?php
                    if( !empty( $data['tables'] ) ) :
                        $tables = !empty( $data['tables']['head'] ) ? array($data['tables']) : $data['tables'];
                        #echo '<pre>';print_r($tables);
                        foreach( $tables as $k => $table ) :
                            ?>
                                <div class="auto-adj" style="width: 100%; min-height: 10px;">&nbsp;</div>
                                <table width="100%" id="tdhgt" height="100%" border="1" style="border-collapse:collapse; margin-top: 10px 0px;" cellpadding="5" <?php echo $table['attr']; ?> > <?php // echo WIDTH; ?>
                                    <tr>
                                    <?php 
                                      unset($table['attr']);
                                    
                                      $sno = $table['head']['sno'];
                                      unset($table['head']['sno']);
                                    if(!(empty($sno)) && !$sno) : ?>
                                        <th>S.No</th>
                                    <?php endif;
                                    
                                        $attr = $table['head']['attr'];
                                        unset($table['head']['attr']);
                                        foreach( $table['head'] as $h => $th ) : ?>
                                        <?php if(!empty($th)) { ?>
                                            <th style="font-size: 14px;" <?php echo $attr; ?>><?php echo $th; ?></th>
                                        <?php } ?>
                                    <?php endforeach; ?>
                                    </tr> 
                                    
                                    <?php if(count($table['body']) > 0) {
                                        foreach( $table['body'] as $b => $row ) : 
                                            //$row = explode(',', $row);
                                        //echo "<pre>Data: "; print_r($row[0]); die;

                                            ?>
                                            <tr class="tbl-row">
                                                <?php if(!(empty($sno)) && !$sno) : ?>
                                                    <td style="font-size: 14px;" align="center"><?php echo ++$b; ?></td>
                                                <?php endif;?>
                                            <?php $length = count($row);
                                            foreach( $row as $t => $td ) :
                                            if(!empty($td) || $td == 0) {
                                                if(!IS_KSK_CMS) {
                                                    if($length == ($t + 1)) :
                                                        $align = "align=right";
                                                    else :
                                                        $align = "align=left";
                                                    endif; 
                                                } else {
                                                    if(empty($sno) && $sno) {
                                                        if((($length - 1 ) == ($t + 1)) || (($length - 2 ) == ($t + 1)) || (($length ) == ($t + 1))) {
                                                            $align = "align=right";
                                                        } elseif((($length - 3 ) == ($t + 1)) || (($length - 4 ) == ($t + 1))) {
                                                            $align = "align=center";
                                                        }else {
                                                            $align = "align=left";
                                                        }
                                                    } else {
                                                        $align = "align=left";
                                                    }
                                                }
                                                ?><td style="font-size: 14px;" <?php echo $align;?>><?php echo $td; ?></td><?php
                                            }
                                            endforeach;
                                            ?>
                                            </tr>
                                    <?php endforeach;

                                        } else { ?>
                                            <tr>
                                                <td colspan="<?php echo (count($table['head']) + 1);?>"><center>No Records Found!</center></td>
                                            </tr> 
                                    <?php } ?>
                                        
                                </table>
                                <div class="auto-adj" style="width: 100%; min-height: 10px;">&nbsp;</div>
                                
                            <?php
                        endforeach;
                    endif; 
                ?>
						
                    </tr>
                </table>
				</td></tr></table>
                
                
                <?php
                    if( !empty( $data['sub_tables'] ) ) :
                        $sub_tables = !empty( $data['sub_tables']['head'] ) ? array($data['sub_tables']) : $data['sub_tables'];
                    
                        foreach( $sub_tables as $k => $table ) :
                            ?>  
                                <div class="auto-adj" id="subtable" style="width: 100%;">&nbsp;</div>
                                <table width="50%" border="1" id="subhht" style="border-collapse:collapse; margin: 0px 0px;" cellpadding="5" align="right">
                                    <?php
                                        foreach( $table['body'] as $b => $row ) : 
                                            //$row = explode(',', $row);
                                        //echo "<pre>Data: "; print_r($row[0]); die;

                                            ?>
                                            <tr>
                                            <?php $length = count($row);
                                            foreach( $row as $t => $td ) :
                                                if($length == ($t + 1)) :
                                                    $align = "align=right";
                                                else :
                                                    $align = "align=left";
                                                endif; 
                                                ?><td style="font-size: 15px;" <?php echo $align;?>><?php echo $td; ?></td><?php
                                            endforeach;
                                            ?>
                                            </tr>
                                    <?php endforeach; ?>
                                </table>
                            <?php
                            
                        endforeach;
                    endif; 
                ?>
                
                
                <table width="<?php echo WIDTH; ?>">
                    <tr>
                        <td>
                            <table border="0" width="100%" cellpadding="5">
                            <tr height="55" ></tr>							
							   <?php if(!empty( $amount )) : ?>
                                <tr>
                                    <td colspan="2" style="font-weight:bold; font-size: 18px;">S$ <?php echo number_format($amount,2,'.',''); ?>/- <?php echo ($gst == 1 ? '(Inclusive of GST)' : '') . $pay_mode_str;?></td>
                                </tr>
                                <tr height="5" class="no-copy"></tr>
                                <tr>
                                    <td style="font-weight:bold; font-size: 14px;" width="20%">Amount in Words (S$):</td>
                                    <td width="80%"><?php echo convert_amount_to_word( $amount ); ?></td>
                                </tr>
                               <!-- <tr height="5" class="no-copy"></tr> -->
                                <?php endif; ?>
                