<?php include 'header.php';
error_reporting(0);
date_default_timezone_set('Asia/Calcutta');

$today = date("Y-m-d");

$month = date("m");



$time = date("h:i A"); 

$currentyear = date("Y");





$querylogin = "select * from  mst_users where user_name = '". $_SESSION["LOGIN_NAME"]."' AND password = '".$_SESSION["EMPLOYEE_PASSWORD"]."'";

$resultlogin = mysqli_query($conn,$querylogin);

while($row=mysqli_fetch_array($resultlogin))

{

$user_name = $row['user_name'];

$user_id = $row['user_id'];

$first_name = $row['first_name'];
$login_type=$row['login_type'];

$login_type_admin=$row['login_type'];

}

?>
<?php
	require_once("perpage.php");	
	require_once("dbcontroller.php");
	$db_handle = new DBController();
	
	
	$datepicker = "";
	$datepicker1 = "";
	$challan_no = "";
	$material_name="";
	
	$queryCondition = "";
	if(!empty($_POST["search"])) {
		foreach($_POST["search"] as $k=>$v){
			if(!empty($v)) {

$queryCases = array("datepicker","datepicker1","material_name","challan_no");
				if(in_array($k,$queryCases)) {
					if(!empty($queryCondition)) {
						$queryCondition .= " AND ";
						
					} else {
						$queryCondition .= " WHERE ";
					}
				}
				switch($k) {
					
						case "material_name":
						$material_name = $v;
						$queryCondition .= "material_name LIKE '%" . $v . "%'";
						break;
						
						
						case "challan_no":
						$challan_no = $v;
						$queryCondition .= "challan_no LIKE '%" . $v . "%'";
						break;
						
						
						case "datepicker":
						$datepicker = $v;
						$queryCondition .= "challan_date BETWEEN";
						case "datepicker1":
						$datepicker1 = $v;
						$queryCondition .= "'" . $v . "'";
						break;
						
						
						
						
				}
			}
		}
	}
	if(!empty($queryCondition)) {
	
	$orderby = " ORDER BY cust_more_row_id   "; 
	$sql = "SELECT * FROM  customer_po_more_product_02   " . $queryCondition ." " ;
	}else{
	 $sql= "SELECT * FROM  customer_po_more_product_02";
	}
	 $sql ;
	$href = 'customer_po_more_product.php';					
	
	$perPage = 5000; 
	$page = 1;
	if(isset($_POST['page'])){
		$page = $_POST['page'];
	}
	$start = ($page-1)*$perPage;
	if($start < 0) $start = 0;
		
	$query =  $sql . $orderby .  " limit " . $start . "," . $perPage; 
	$result = $db_handle->runQuery($query);
	
	if(empty($result)) {
		
	$result["perpage"] = showperpage($sql, $perPage, $href);
	}
	else{ 
	$result["perpage"] = showperpage($sql, $perPage, $href); }
	
?>

<div class="content-page">
<div class="content">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="page-header-title">

<div class="clearfix"></div>
</div>
</div>
</div>


<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">View All Inward</h3>
</div>
<div class="panel-body">
     
	            <table  id="datatable-buttons" class="table table-striped table-bordered">
<thead>
<tr>
<th>No.</th>
<th>Sr.No.</th>
<th>Item Code</th>
<th>Description</th>
<th>Material Name</th>
<th>Bar Size</th>
<th>Category Name</th>
<th>PO No</th>
<th>Qty</th>
<th>Bal Qty</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
					$i=1;
					 foreach($result as $k=>$v) {
						if(is_numeric($k)) {
						
$cust_po_more_product_id = $result[$k]["cust_po_more_product_id"];


?>
<tr>
<td><?php echo $k+1?></td>
<td><?php echo $result[$k]["sr_no"]?></td>

<td><?php echo $result[$k]["item_code"]?></td>
<td><?php echo $result[$k]["description"]?></td>
<td><?php echo $result[$k]["material_name"]?></td>
<td><?php echo $result[$k]["bar_size"]?></td>
<td><?php echo $result[$k]["category_name"]?></td>
<td><?php echo $result[$k]["po_number"]?></td>
<td><?php echo $result[$k]["qty"]?></td>
<td><?php echo $result[$k]["bal_po_qty"]?></td>

<td><?php /*?><a href="delete_poitem.php?cust_po_more_product_id=<?php echo $result[$k]["cust_po_more_product_id"]?>" class="btn btn-danger btn-xs waves-effect waves-light" style="float:right">DELETE</a><?php */?><?php echo $result[$k]["WORK_ORDER_NO"]?></td>
</tr>
<?php } }?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include 'footer1.php';?>
