  <?php
session_start();
include './connection_sql.php';
if ($_SESSION["CURRENT_USER"] == "") { 
    exit('Please Logging Again..');
} 
if ($_SESSION['company'] == "") { 
    exit('Please Logging Again..');
} 
?>
<!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" />
	<title>Search Balance</title> 
	<style type="text/css">
		tfoot input {
			width: 100%;
			padding: 3px;
			box-sizing: border-box;
		}
	</style>
	<link  href="../new/vendor/new/multi/jquery.dataTables.min.css" rel="stylesheet" type="text/css"> 
	<script src="../new/vendor/new/multi/jquery-3.5.1.js" ></script>
	<script src="../new/vendor/new/multi/jquery.dataTables.min.js" ></script>
 
    <script language="JavaScript" src="js/payment.js"></script> 
    
</head>
 
<body>
 
    <table id="example" class="display" style="width:100%">
        <thead>
            <tr>            
              <td align="center">Ref No</td>
              <td align="center">Date</td>
              <td align="center">Inv No</td>
              <td align="center">Supplier</td>
              <td align="center">Amount</td>
              <td align="center">Balance</td>    
              <td align="center">P.Deb.Value</td>           
            </tr>
        </thead>
        <tbody>
            <?php
            $stname = "";
            if (isset($_GET['stname'])) {
                $stname = $_GET["stname"];
            }
            ?>

            <?php  
 
                $sql .= "select REFNO, SDATE,CUSCODE,name,BALANCE,ID,pi_no,AMOUNT,DEBITNOTE_BAL from view_cbal where  company='" . $_SESSION["company"] . "'  and trn_type='ARN' and BALANCE > 1  and cancell=0  ";
                if ($_GET['c_code']  !='') {
                   $sql .= "  AND  CUSCODE = '".$_GET["c_code"]."'";
                }
                 $sql .= "  ORDER BY ID desc";
                foreach ($conn->query($sql) as $row) {
                    $cuscode = $row["REFNO"];
    
    
                    echo "<tr>               
                          <td onclick=\"balview('$cuscode', '$stname');\">" . $row['REFNO'] . "</a></td>
                          <td onclick=\"balview('$cuscode', '$stname');\">" . $row['SDATE'] . "</a></td>
                          <td onclick=\"balview('$cuscode', '$stname');\">" . $row['pi_no'] . "</a></td>
                          <td onclick=\"balview('$cuscode', '$stname');\">" . $row['NAME'] . "</a></td>
                          <td onclick=\"balview('$cuscode', '$stname');\">" . $row['AMOUNT'] . "</a></td>
                          <td onclick=\"balview('$cuscode', '$stname');\">" . $row['BALANCE'] . "</a></td>
                          <td onclick=\"balview('$cuscode', '$stname');\">" . $row['DEBITNOTE_BAL'] . "</a></td>
                        </tr>";
                }
            ?>

        </tbody>
        
          
        <tfoot>
            <tr>
                <th align="center">Ref No</th>
              <th align="center">Date</th>
              <th align="center">Inv No</th>
              <th align="center">Supplier</th>
              <th align="center">Amount</th>
              <th align="center">Balance</th>      
              <th align="center">P.Deb.Value</th>           
            </tr>
        </tfoot>
    </table>
</body>
</html>

<script type="text/javascript">
	$(document).ready(function() {
    // Setup - add a text input to each footer cell
    $('#example tfoot th').each( function () {
    	var title = $(this).text();
    	$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
    } );

    // DataTable
    var table = $('#example').DataTable({
    	
    	lengthChange: true,
    	fixedHeader: true,
    	responsive: true,
    	"deferRender": true,
    	"order": [[ 0, 'desc' ]],
    	lengthMenu: [[ 15, 25, 50,100, -1 ],[ '15 rows', '25 rows', '50 rows', '100 rows', 'Show all' ]],
    	initComplete: function () {
            // Apply the search
            this.api().columns().every( function () {
            	var that = this;

            	$( 'input', this.footer() ).on( 'keyup change clear', function () {
            		if ( that.search() !== this.value ) {
            			that
            			.search( this.value )
            			.draw();
            		}
            	} );
            } );
        }
    });

} );
</script>


 
  
   