 <?php
include "connection_sql.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="style.css" rel="stylesheet" type="text/css" media="screen" />

    
    <title>Ledger View</title> 
  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>  
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css"> 
    <script language="JavaScript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
    <script language="JavaScript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    <script language="JavaScript" src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
</head>
<body>
    <?php
    $stname = "";
    if (isset($_GET['stname'])) {
        $stname = $_GET["stname"];
    }
     
    ?>
    <input type="hidden" value="" id="cur" />
        <div class="modal-body">
                
                
</div></div>
    <div id="filt_table" class="CSSTableGenerator container">
        <table class='table table-striped '  style="border-collapse:collapse;" cellspacing="0" cellpadding="0"> 
    
         
        </table>
    <div class="container-fluid">
         
        <table id="testTable"  class="table table-bordered">
             
   
            
             <?php
  
            echo "<table  class='table table-bordered' style='font-size: 14px;background:#d490cb'>";

            echo "<thead>";  
            echo "<tr><th colspan=\"7\" style=\"text-align:center\"><span  ><b style=\"font-size: 15px;\"><strong> LEDGER TRANSCTIONS - ".$_GET["refno"]." </b></strong></span></th></tr>"; 
            
            echo " <tr>"; 
            echo "<th style=\"text-align:center;\">Account</th>";
             echo "<th style=\"text-align:center;\">Description</th>"; 
            echo "<th style=\"text-align:center;\">Cre</th>";     
            echo "<th style=\"text-align:center;\">Deb</th>";      
            
            echo "</tr></thead><tbody>";
           
               $sql1="select * from a_ledger where L_REFNO='".$_GET["refno"]."' and  L_FLAG1='CRE'";
                foreach ($conn->query($sql1) as $row1) { 
                        $sql_lcode = "SELECT * FROM a_lcodes where C_CODE='".$row1["L_CODE"]."'";
                        $result_lcode = $conn->query($sql_lcode); 
                        $row_lcode = $result_lcode->fetch();
    
                    echo "<tr>               
                    <td align=left><b>".$row1['L_CODE']." | ".$row_lcode['C_NAME']."</a></b></td>
                    <td align=left><b>".$row1['L_LMEM']."</a></b></td> 
                    <td align=right><b>".number_format($row1['L_AMOUNT'] ,2)."</a></b></td>  
                    <td align=center><b></b></td> 
                    </tr>";
                     $CRETOT +=$row1['L_AMOUNT'];
                    
                }
                
                 $sql1="select * from a_ledger where L_REFNO='".$_GET["refno"]."'  and  L_FLAG1='DEB'";
                foreach ($conn->query($sql1) as $row1) { 
                  $sql_lcode = "SELECT * FROM a_lcodes where C_CODE='".$row1["L_CODE"]."'";
                        $result_lcode = $conn->query($sql_lcode); 
                        $row_lcode = $result_lcode->fetch();
    
                    echo "<tr>               
                    <td align=left><b>".$row1['L_CODE']." | ".$row_lcode['C_NAME']."</a></b></td>
                    <td align=left><b>".$row1['L_LMEM']."</a></b></td>
                    <td align=center><b></b></td> 
                    <td align=right><b>".number_format($row1['L_AMOUNT'] ,2)."</a></b></td> 
                    </tr>";
                    
                    $DEBTOT +=$row1['L_AMOUNT'];
                    
                }
                
                 echo "<tr STYLE='background:#e3b4b4'>               
                    <td align=left><b></td>
                    <td align=left><b></td> 
                    <td align=right><b>".number_format($CRETOT ,2)."</a></b></td> 
                    <td align=right><b>".number_format($DEBTOT ,2)."</a></b></td> 
                    </tr>";
						 
             
            ?>
            
        </table> </div>
  
 
 
    </body>
    </html>



 
