<?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 Customer</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/search_cheq.js"></script>
</head>
<body>



	<table id="example" class="display" style="width:100%">
		<thead>
		     <tr>
                <td ><input type="radio" name="radio" id="Option1" value="Option1" checked="checked" onclick="select_list('all');" />Save</td>
                <td ><input type="radio" name="radio" id="Option2" value="Option2"  onclick="select_list('all');" />Not Approved</td>
                <td ><input type="radio" name="radio" id="Option3" value="Option3" onclick="select_list('all');" />Not Posted</td>
                <td ><input type="radio" name="radio" id="Option4" value="Option4"  onclick="select_list('all');" />Complete</td>
                <td >  </td>
            </tr>
		<?php
                if ($_GET["stname"] == "extend") {
                    echo "<tr>
                              <td >Cheque No</td>
                              <td >Cheque Date</td>
                              <td >Cheque Amount</td>
                              <td >Bank</td>
                              <td >Customer</td>
</tr>";
                } else {
                    echo "<tr>
                              <td >Cheque No</td>
                              <td>Cheque Date</td>
                              <td >Cheque Amount</td>
                              <td >Bank</td>
                               <td >Customer</td>
							  
</tr>";
                }
                ?>
		</thead>
		<tbody>
			<?php
			$stname = "";
			if (isset($_GET['stname'])) {
				$stname = $_GET["stname"];
			}
			?>
			<input type="hidden" value="" id="cur" />
<?php 
		 require_once("connectioni.php");


                $sql = "select * from s_invcheq where ID <> '' ";
                
                if ($_SESSION["txt_cuscode"] != "") {
                    $sql .= "and cus_code='" . $_SESSION["txt_cuscode"] . "'  ";
                }
                
                // if ($_GET["stname"] == "ret_cheque_entry") {
                //     $sql .= "and (ret_refno = '' OR ret_refno IS NULL) ";
                // }
                
                $sql .= "ORDER BY che_date desc limit 5000 ";

                echo $sql;
                $result = mysqli_query($GLOBALS['dbinv'], $sql);
                while ($row = mysqli_fetch_array($result)) {

                    if ($_GET["stname"] == "extend") { 
                        echo "<tr>               
                              <td onclick=\"chq_extn('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "', '" . $row['cus_code'] . "', '" . $row['bank'] . "');\">" . $row['cheque_no'] . "</a></td>
                              <td onclick=\"chq_extn('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "', '" . $row['cus_code'] . "', '" . $row['bank'] . "');\">" . $row['che_date'] . "</a></td>
                              <td onclick=\"chq_extn('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "', '" . $row['cus_code'] . "', '" . $row['bank'] . "');\">" . $row['che_amount'] . "</a></td>
                              <td onclick=\"chq_extn('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "', '" . $row['cus_code'] . "', '" . $row['bank'] . "');\">" . $row['bank'] . "</a></td>
                              <td onclick=\"chq_extn('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "', '" . $row['cus_code'] . "', '" . $row['bank'] . "');\">" . $row['CUS_NAME'] . "</a></td>
                            </tr>";
                    }else if ($_GET["stname"] == "modify") { 
                        echo "<tr>               
                              <td onclick=\"chq_mod('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "', '" . $row['cus_code'] . "', '" . $row['bank'] . "');\">" . $row['cheque_no'] . "</a></td>
                              <td onclick=\"chq_mod('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "', '" . $row['cus_code'] . "', '" . $row['bank'] . "');\">" . $row['che_date'] . "</a></td>
                              <td onclick=\"chq_mod('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "', '" . $row['cus_code'] . "', '" . $row['bank'] . "');\">" . $row['che_amount'] . "</a></td>
                                <td onclick=\"chq_mod('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "', '" . $row['cus_code'] . "', '" . $row['bank'] . "');\">" . $row['bank'] . "</a></td>
                                <td onclick=\"chq_mod('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "', '" . $row['cus_code'] . "', '" . $row['bank'] . "');\">" . $row['CUS_NAME'] . "</a></td>
                            </tr>";
                    } else { 
                        echo "<tr>               
                              <td onclick=\"ret_chq('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "');\">" . $row['cheque_no'] . "</a></td>
                              <td onclick=\"ret_chq('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "');\">" . $row['che_date'] . "</a></td>
                              <td onclick=\"ret_chq('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "');\">" . $row['che_amount'] . "</a></td>
		                        <td onclick=\"ret_chq('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "');\">" . $row['bank'] . "</a></td>
		                        <td onclick=\"ret_chq('" . $row['cheque_no'] . "', '" . $row['che_date'] . "', '" . $row['che_amount'] . "', '" . $_GET['stname'] . "');\">" . $row['CUS_NAME'] . "</a></td>
                            </tr>";
                    }
                }
                ?>

		</tbody>
		<tfoot>
		<?php
                if ($_GET["stname"] == "extend") {
                    echo "<tr>
                              <th >Cheque No</th>
                              <th >Cheque Date</th>
                              <th >Cheque Amount</th>
                              <th >Bank</th>
							  <th >Customer</th>
</tr>";
                } else {
                    echo "<tr>
                              <th >Cheque No</th>
                              <th>Cheque Date</th>
                              <th >Cheque Amount</th>
                              <th >Bank</th>
							  <th >Customer</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>






