			<?php $bil = 0; 
				if($companyTables){
				foreach($companyTables as $datatbl):
				$bil++?>
                	<?php $linePrint = 'C|'.$datatbl->companyName . '|' . $datatbl->companyNo.$datatbl->gstRegisteredNo .  '|' . date("d/m/Y", strtotime($startDate)) .  '|' . date("d/m/Y", strtotime($endDate)); ?>
                	<?php $linePrint .= date("d/m/Y"); ?>
                    <?php echo $linePrint; ?>
            <?php endforeach; }?>
            <?php
					$purchaseCount = 0;
					$purchaseAmount = 0;
					$purchaseGST = 0;
					$salesCount = 0;
					$salesAmount = 0;
					$salesGST = 0;
					$glCount = 0;
					$glDebitAmount = 0;
					$glCreditAmount = 0;
					$glTotalBalance = 0;
				if($datatbls){
				foreach($datatbls as $datatbl):
				$bil++;
				switch ($datatbl->col1) {
					case 'P':
						$purchaseAmount = $purchaseAmount + $datatbl->col9;
						$purchaseCount = $purchaseCount + 1;
					    $purchaseGST = $purchaseGST + $datatbl->col10;
						break;
					case 'S':
						$salesAmount = $salesAmount + $datatbl->col9;
						$salesCount = $salesCount + 1;
					    $salesGST = $salesGST + $datatbl->col10;
						break;
				}
				?>
            		<?php $linePrint = $datatbl->col1. '|' . $datatbl->col2. '|' . $datatbl->col3. '|' . date("d/m/Y", strtotime($datatbl->col4)) . '|' . $datatbl->col5;?>
            		<?php $linePrint .= '|' . $datatbl->col6. '|' . $datatbl->col7. '|' . $datatbl->col8. '|' . number_format($datatbl->col9,2);?>
                    <?php if($datatbl->col1 == 'P'){?>
                			<?php $linePrint .= '|' . number_format($datatbl->col10,2)?> 
                    <?php }else{ ?>
                 			<?php $linePrint .= '|' . $datatbl->col10?> 
                    <?php } ?>
                 	<?php $linePrint .= '|' . $datatbl->col11. '|' . $datatbl->col11. '|' . $datatbl->col12. '|' . number_format($datatbl->col13,2). '|' . number_format($datatbl->col14)?>
                    <?php echo $linePrint; ?>
            <?php endforeach; }?>
			<?php if($glDetails){ ?>
			<?php foreach($glDetails as $datatbl): ?>
            <?php $balance = $datatbl->yeardebit - $datatbl->yearcredit;?>
            <?php $glTotalBalance = $glTotalBalance + $balance;?>
            <?php $tempFlag = '';?>
            <?php if($journalDetails){?>
				<?php foreach($journalDetails as $row): ?>
					<?php if($row->acctCode == $datatbl->ID){ ?>
                    <?php if($tempFlag == ''){?>
                    <?php $glCount++;?>
                    <?php $linePrint = 'L' . '|' . date("d/m/Y", strtotime($startDate)) . '|' . $datatbl->acctCode . '|' . $datatbl->acctName . '|' . 'OPENING BALANCE' ?>
                    <?php $linePrint .= '||||||'  . '|' . number_format($datatbl->yeardebit - $datatbl->yearcredit,2) ?>
                    <?php echo $linePrint; ?>
					<?php 	$tempFlag = '1';?>
					<?php }?>
                    <?php $totalAmount = $row->amount_dr - $row->amount_cr;?>
                    <?php $balance = $balance + $totalAmount;?>
                    <?php $glTotalBalance = $glTotalBalance + $totalAmount;?>
                    <?php $glDebitAmount = $glDebitAmount + $row->amount_dr;?>
                    <?php $glCreditAmount = $glCreditAmount + $row->amount_cr;?>
                    <?php $glCount++;?>
                    <?php $linePrint = 'L' . '|' . date("d/m/Y", strtotime($row->effective_date)) . '|' . $datatbl->acctCode . '|' . $datatbl->acctName . '|' . $row->description?>
                    <?php $linePrint .= '|' . $row->supplier . '|' . $row->journalID . '|' . $row->formNo . '|' . $row->moduleName . '|' . number_format($row->amount_dr,2)?>
                    <?php $linePrint .= '|' . number_format($row->amount_cr,2) . '|' . number_format($balance,2)?>
                     <?php echo $linePrint; ?>
                   <?php } ?>
            	<?php endforeach;?>
                    <?php } ?>
            <?php endforeach;?>
			<?php } ?>
            	<!-- tr>
                    <td>F
                    <td><?php echo number_format($purchaseCount) ?>
                	<td><?php echo number_format($purchaseAmount,2)?>
                	<td><?php echo number_format($purchaseGST,2)?>
                	<td><?php echo number_format($salesCount)?>
                	<td><?php echo number_format($salesAmount,2)?>
                	<td><?php echo number_format($salesGST,2)?>
                	<td><?php echo number_format($glCount)?>
                	<td><?php echo number_format($glDebitAmount,2)?>
                	<td><?php echo number_format($glCreditAmount,2)?>
                	<td><?php echo number_format($glTotalBalance,2)?>
                	<td>
                	<td>
                	<td>
                	<td>
                </tr>
       				 <tbody>
                     </tbody>
                     </table -->
