<?php
session_start();

?>
<!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 Purchase Order</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/pur_ord.js"></script>
</head>
<body>



	<table id="example" class="display" style="width:100%">
		<thead>
			<tr>
			                  <td align="center">PO No</td>
                              <td align="center">Supplier</td>
                              <td align="center">Brand</td>
                              <td align="center">Entry  Date</td>
                              <td align="center">PI No</td>
                              <td align="center">CI No</td>
                              <td align="center">LC/TT No</td>
                              <td align="center">BL No</td>
                              <td align="center">Status</td>
                              
			</tr>
		</thead>
		<tbody>
			<?php
			$stname = "";
			if (isset($_GET['stname'])) {
				$stname = $_GET["stname"];
			}
			?>
			<input type="hidden" value="" id="cur" />

		<?php 
							
							require_once("connectioni.php");
							 
							 
							if ($_SESSION["company"]!="") {          
                                $sql = "select * from s_ordmas where  company='".$_SESSION["company"]."' "; 
                                if($_GET['stname']=="arn"){
							    	$sql .=" and cancel='0'";
    							} 
                            }else{
                                 $sql = "SELECT * from s_ordmas   " ;
                                 if($_GET['stname']=="arn"){
							    	$sql .=" where cancel='0'";
                                 } 
                            }  
            
							
								$sql .=" order by SDATE DESC ";
				// 			echo $sql;
							$result =mysqli_query($GLOBALS['dbinv'],$sql) ; 
							
							while($row = mysqli_fetch_array($result)){
					
							 if($row['cancel'] == "0"){
                                $status="Pending";
                                 $color="";
                            }else if($row['cancel'] == "1"){
                                 $status="Canceld";
                                 $color="red";
                            }else{
                                $color="green";
                                $status="Proceed";
                            }  
                
               	echo "<tr style=\"background-color:$color\">                
                              <td align=\"center\" onclick=\"purord('".$row['REFNO']."', '".$_GET['stname']."');\">".$row['REFNO']."</a></td>
                              <td align=\"left\" onclick=\"purord('".$row['REFNO']."', '".$_GET['stname']."');\">".$row["SUP_NAME"]."</a></td>
                              <td align=\"center\" onclick=\"purord('".$row['REFNO']."', '".$_GET['stname']."');\">".$row["Brand"]."</a></td>
                              <td align=\"center\" onclick=\"purord('".$row['REFNO']."', '".$_GET['stname']."');\">".$row['SDATE']."</a></td>
                              <td align=\"center\" onclick=\"purord('".$row['REFNO']."', '".$_GET['stname']."');\">".$row['pi_no']."</a></td>
                              <td align=\"center\" onclick=\"purord('".$row['REFNO']."', '".$_GET['stname']."');\">".$row['invno']."</a></td>
                              <td align=\"center\" onclick=\"purord('".$row['REFNO']."', '".$_GET['stname']."');\">".$row['LC_No']."</a></td>
                              <td align=\"center\" onclick=\"purord('".$row['REFNO']."', '".$_GET['stname']."');\">".$row['blno']."</a></td>
                              <td align=\"center\" onclick=\"purord('".$row['REFNO']."', '".$_GET['stname']."');\">".$status."</a></td>
                              
                            </tr>";
							}
							  ?>

		</tbody>
		<tfoot>
			<tr>
	                    	  <th align="center">PO No</th>
                              <th align="center">Supplier</th>
                              <th align="center">Brand</th>
                              <th align="center">Entry Date</th>
                              <th align="center">PI No</th>
                              <th align="center">INV No</th>
                              <th align="center">LC No</th>
                              <th align="center">BL No</th>
                              <th align="center">Status</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>


 