<?php
session_start();

if ($_SESSION['company'] == "") { 
    exit("Please Login");
}
if ($_SESSION['CURRENT_USER'] == "") { 
    exit("Please Login");
}
?>
<!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 Cutomer</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/inv.js?v1"></script>
</head>
<body>


<td><div id='stat'></div></td>
	<table id="example" class="display" style="width:100%">
		<thead>
			<tr>
				<th align="center">Customer Code</th>
				<th align="center">Customer Name</th>
				<th align="center">Address</th>
				<th align="center">Tel</th>
				<th align="center">Sub Cus Code</th> 
			</tr>
		</thead>
		<tbody>
			<?php
			$stname = "";
			if (isset($_GET['stname'])) {
				$stname = $_GET["stname"];
			}
			?>
			<input type="hidden" value="" id="cur" />

			<?php
		 require_once ("connection_sql.php");
                $sql = "SELECT * from vendor where CANCELL='0' AND CAT<>'X' order by CODE ";   //- new sub table
                // if (($_SESSION["CURRENT_USER"] == 'sarath' or $_SESSION["CURRENT_USER"] == 'SARATH') and $_GET['stname'] == "item_claim") {
                //     $sql = "SELECT * from sarath_salma  order by c_code1  desc ";
                // } else {
                //     $sql = "SELECT * from view_vendor where CAT<>'X' order by CODE   desc";
                // }

                // echo $_SESSION["company"];
                foreach ($conn->query($sql) as $row) {
                    
                $cuscode = $row["CODE"];
 
                    if (($_SESSION["CURRENT_USER"] == 'sarath' or $_SESSION["CURRENT_USER"] == 'SARATH') and $_GET['stname'] == "item_claim") {
                        echo "<tr>
		<td align=\"center\" onclick=\"custno('$cuscode', '$stname');\">" . $row['C_CODE'] . "</a></td>
		<td align=\"left\" onclick=\"custno('$cuscode', '$stname');\">" . $row['CUS_NAME'] . "</a></td>
		<td align=\"left\" onclick=\"custno('$cuscode', '$stname');\">" . $row['C_ADD1'] . "</a></td>
		<td align=\"left\" onclick=\"custno('$cuscode', '$stname');\">" . $row['C_ADD1'] . "</a></td>
		<td align=\"center\" onclick=\"custno('$cuscode', '$stname');\">" . $row['c_code1'] . "</a></td>
		</tr>";
                    } else {
                        echo "<tr>
		<td align=\"center\" onclick=\"custno('$cuscode', '$stname');\">" . $row['CODE'] . "</a></td>
		<td align=\"left\" onclick=\"custno('$cuscode', '$stname');\">" . $row['NAME'] . "</a></td>
		<td align=\"left\" onclick=\"custno('$cuscode', '$stname');\">" . $row['ADD1'] . "</a></td>
		<td align=\"left\" onclick=\"custno('$cuscode', '$stname');\">" . $row['TELE1'] . "</a></td>
		<td align=\"center\" onclick=\"custno('$cuscode', '$stname');\">" . $row['c_code'] . "</a></td>
		</tr>";
                    }
                }
			?>

		</tbody>
		<tfoot>
			<tr>
				<th>Customer Code</th>
				<th>Customer Name</th>
				<th>Address</th>
				<th>Tel</th>
				<th>Sub Cus Code</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": [[ 1, 'asc' ]],
    	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>






