<?php
require_once("../includes/config.php");
$_SESSION['changeBinToken'] = "";
if(isset($_REQUEST['location'])){$selloc=$_REQUEST['location'];}else{$selloc="";}
if(isset($_REQUEST['stock_type'])){$selstoktyp=$_REQUEST['stock_type'];}else{$selstoktyp="";}
if(isset($_REQUEST['brandname'])){$selbrand=$_REQUEST['brandname'];}else{$selbrand="";}
if(isset($_REQUEST['prod_cat'])){$selpc=$_REQUEST['prod_cat'];}else{$selpc="";}
if(isset($_REQUEST['product_sub_category'])){$selpsc=$_REQUEST['product_sub_category'];}else{$selpsc="";}
////// get operation right
$get_opr_rgts = getOprRights($_SESSION['userid'],$_REQUEST['pid'],$link1);
///// get access location details
$access_loc = getAccessLocation($_SESSION['userid'],$link1);
?>
<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="shortcut icon" href="../images/titleimg.png" type="image/png">
 <script src="../js/jquery.js"></script>
 <?php 
 include("../includes/fontawesome.html");
 include("../includes/main_css.html"); 
 include("../includes/bootstrap.html");
 include("../includes/datatables.html");
 ?>
 <script type="text/javascript" language="javascript" >
$(document).ready(function() {
	var dataTable = $('#inventory-status-grid').DataTable( {
		"processing": true,
		"serverSide": true,
		"order": [[ 2, "asc" ]],
		"ajax":{
			url :"../pagination/inventory-status-grid-data.php", // json datasource
			data: { "pid": "<?=$_REQUEST['pid']?>", "hid": "<?=$_REQUEST['hid']?>", "icn": "<?=$_REQUEST['icn']?>", "location": "<?=$selloc?>", "stock_type": "<?=$selstoktyp?>", "prod_cat": "<?=$selpc?>", "product_sub_category": "<?=$selpsc?>", "brandname": "<?=$selbrand?>"},
			type: "post",  // method  , by default get
			error: function(){  // error handling
				$(".inventory-status-grid-error").html("");
				$("#inventory-status-grid").append('<tbody class="inventory-status-grid-error"><tr><th colspan="11">No data found in the server</th></tr></tbody>');
				$("#inventory-status-grid_processing").css("display","none");
				
			}
		}
	} );
});
/////////// function to get product sub category on the basis of product category
  $(document).ready(function(){
	$('#prod_cat').change(function(){
	  var prod_catid=$('#prod_cat').val();
	  $.ajax({
	    type:'post',
		url:'../includes/getAzaxFields.php',
		data:{get_psc:prod_catid},
		success:function(data){
	    $('#pscdiv').html(data);
	    }
	  });
    });
  });
  	////// function for open model to view bin allocation details
	function openModel_new(docid,p_id){
		
		$.get('bin_allocation_inventory.php?doc_id=' + docid + '&loc_code=' + p_id , function(html){
			 $('#courierModel .modal-body').html(html);
			 $('#courierModel').modal({
				show: true,
				backdrop:"static"
			});
		 });
	}
	////// function for open model to view group details
	function openModel_new(group){
		$.get('same_group_parts.php?group=' + group, function(html){
			 $('#courierModel_new .modal-body').html(html);
			 $('#courierModel_new').modal({
				show: true,
				backdrop:"static"
			});
		 });
	}
</script>
<title><?=siteTitle?></title>
</head>
<body>
<div class="container-fluid">
  <div class="row content">
	<?php 
    include("../includes/leftnav_admin.php");
    ?>
    <div class="<?=$screenwidth?> tab-pane fade in active" id="home">
      <h2 align="center"><i class="fa <?=$fa_icon?>"></i> Inventory Status </h2>
      <?php if(isset($_REQUEST['msg'])){?>
        <div class="alert alert-<?php echo $_REQUEST['chkflag'];?> alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            <strong><?php echo $_REQUEST['chkmsg'];?>!</strong>&nbsp;&nbsp;<?=$_REQUEST['msg']?>.
        </div>
      <?php }?>
	  <form class="form-horizontal" role="form" name="form1" action="" method="get">
       <div class="form-group">
         <div class="col-md-6"><label class="col-md-5 control-label">Location</label>	  
			<div class="col-md-6" align="left">
				 <select name="location" id="location" class="form-control selectpicker show-tick custom-select">
                 	<option value="">--Please Select--</option>
                    <?php
					$sql1 = "SELECT location_code,locationname FROM location_master where statusid= '1' and location_code in (".$access_loc.") order by locationname";
					$res1 = mysqli_query($link1,$sql1);
					while($row1 = mysqli_fetch_array($res1)){
					?>
                    <option value="<?=$row1['location_code']?>"<?php if($selloc==$row1['location_code']){ echo "selected";}?>><?php echo $row1['locationname']?></option>
                    <?php }?>
                 </select>
            </div>
          </div>
		  <div class="col-md-6"><label class="col-md-5 control-label">Stock Type</label>
			<div class="col-md-6" align="left">
			 	<select name="stock_type" id="stock_type" class="form-control selectpicker show-tick custom-select">
                 	<option value="">All</option>
                    <?php
					$res = mysqli_query($link1,"select typeid, parttype from part_type_master order by parttype");
					while($row = mysqli_fetch_assoc($res)){
					?>
                    <option value="<?=$row['typeid']?>"<?php if($selstoktyp==$row['typeid']){ echo "selected";}?>><?php echo $row['parttype'];?></option>
                    <?php
					}
					?>
                 </select>
            </div>
          </div>
	    </div><!--close form group-->
      	<div class="form-group">
         <div class="col-md-6"><label class="col-md-5 control-label">Product Category</label>
			<div class="col-md-6" align="left">
			   <select name="prod_cat" id="prod_cat" class="form-control custom-select">
              	<option value="">All</option>
              	<?php 
				$sql ="select productid,product_name from product_master";
			  	$qry = mysqli_query($link1,$sql) ;
			  	while ($row=mysqli_fetch_array($qry)){?>
              	<option value="<?php echo $row['productid'];?>"<?php if($selpc==$row['productid']){echo "selected";}?>><?php echo $row['product_name']?></option>
              	<?php } ?>
              </select>
            </div>
          </div>
		  <div class="col-md-6"><label class="col-md-5 control-label">Product Sub Category</label>
			<div class="col-md-6" align="left" id="pscdiv">
				<select name="product_sub_category" id="product_sub_category" class="form-control custom-select">
              	  <option value=''>--Please Select--</option>
                    <?php
					$sql_psc = "select psubcatid,prod_sub_cat  from product_sub_category where productid='".$selpc."' and status='1' order by prod_sub_cat";
					$res_psc = mysqli_query($link1,$sql_psc);
					while($row_psc = mysqli_fetch_array($res_psc)){
					?>
					<option value="<?=$row_psc[0]?>"<?php if($selpsc == $row_psc[0]) { echo 'selected'; }?>><?php echo $row_psc[1]?></option>
					<?php }?>
              	</select>
            </div>
          </div>
	    </div><!--close form group-->
        <div class="form-group">
         <div class="col-md-6"><label class="col-md-5 control-label">Brand</label>	  
			<div class="col-md-6" align="left">
				<select name="brandname" id="brandname" class="form-control custom-select" >
              	 <option value="">All</option>
              	 <?php 
				 $sql ="select brand,brandid from brand_master";
			  	 $qry = mysqli_query($link1,$sql) ;
			  	 while ($row=mysqli_fetch_array($qry)){?>
                <option value="<?php echo $row['brandid'];?>"<?php if($selbrand==$row['brandid']){echo "selected";}?>><?php echo $row['brand'];?></option>
                <?php } ?>
              </select>
            </div>
          </div>
		  <div class="col-md-6"><label class="col-md-5 control-label"><!--Partcode--></label>
			<div class="col-md-6" align="left">
			 	<?php /*?><select name="partcode" id="partcode" class="form-control selectpicker show-tick">
                 	<option value="">All</option>
                    <?php
					$res = mysqli_query($link1,"select partcode, part_name from partcode_master where itemtypeid in ('1','4') and status='1' order by part_name");
					while($row = mysqli_fetch_assoc($res)){
					?>
                    <option value="<?=$row['partcode']?>"<?php if($_REQUEST['partcode']==$row['partcode']){ echo "selected";}?>><?php echo $row['part_name']." (".$row['partcode'].")";?></option>
                    <?php
					}
					?>
                 </select><?php */?>
            </div>
          </div>
	    </div><!--close form group-->
        <div class="form-group">
          <div class="col-md-5"><label class="col-md-6 control-label"></label>
            <div class="col-md-6">
               <input name="pid" id="pid" type="hidden" value="<?=$_REQUEST['pid']?>"/>
               <input name="hid" id="hid" type="hidden" value="<?=$_REQUEST['hid']?>"/>
               <input name="icn" id="icn" type="hidden" value="<?=$_REQUEST['icn']?>"/>
               <input name="Submit" type="submit" class="btn<?=$btncolor?>" value="GO"  title="Go!">
            </div>
          </div>
		  <div class="col-md-7">
			<div class="col-md-12" align="center">
               <?php
			    ////// check this user have right to export the excel report
			    if($get_opr_rgts['excel']=="Y"){
			   ?>
               <span style="color:#000066;">Inventory Report</span>  <a href="../excelReports/inventory_status_excel.php?location=<?=base64_encode($selloc)?>&stock_type=<?=base64_encode($selstoktyp)?>&prod_cat=<?=base64_encode($selpc)?>&product_sub_category=<?=base64_encode($selpsc)?>&brandname=<?=base64_encode($selbrand)?>" title="Export Inventory Status in excel"><i class="fa fa-file-excel-o fa-2x faicon excelicon" title="Export Inventory Status in excel"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
			   <span style="color:#000066;">Bin Change History</span>  <a href="../excelReports/bin_cange_history_excel.php?location=<?=base64_encode($selloc)?>&stock_type=<?=base64_encode($selstoktyp)?>&prod_cat=<?=base64_encode($selpc)?>&product_sub_category=<?=base64_encode($selpsc)?>&brandname=<?=base64_encode($selbrand)?>" title="Export Inventory Status in excel"><i class="fa fa-file-excel-o fa-2x faicon excelicon" title="Export Inventory Status in excel"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
			   <span style="color:#000066;">IQC Require List</span>  <a href="../excelReports/iqc_require_list.php?location=<?=base64_encode($selloc)?>" title="Export Inventory Status in excel"><i class="fa fa-file-excel-o fa-2x faicon excelicon" title="Export Inventory Status in excel"></i></a>
               <?php
				}
				?>
            </div>
          </div>
	    </div><!--close form group-->
	  </form>
      <form class="form-horizontal" role="form">
        <div class="form-group"  id="page-wrap" style="margin-left:10px;"><br/>
       <table  width="100%" id="inventory-status-grid" class="display" align="center" cellpadding="4" cellspacing="0" border="1">
          <thead>
            <tr class="<?=$tableheadcolor?>">
              <th>S.No</th>
              <th>Partcode</th>
              <th>Description</th>
			  <th>Stock Type</th>
              <th>Mount</th>
              <th>Fresh</th>
              <th>IQC Rejection</th>
			  <th>Vender Rejection</th>
			  <th>Process Rejection</th>
			  <th>Missing</th>
			  <th>Purchase Unit</th>
			  <th>Group Parts</th>
              <th>Bin location</th>
              <th>Bin Change</th>
			  <th>Barcode Print</th>
            </tr>
          </thead>
          </table>
          </div>
      <!--</div>-->
      </form>
        <!-- Start Model Mapped Modal -->
          <div class="modal modalTH fade" id="courierModel" role="dialog">
          <form class="form-horizontal" role="form" id="frm2" name="frm2">
            <div class="modal-dialog modal-dialogTH modal-lg">
            
              <!-- Modal content-->
              <div class="modal-content">
                <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal">&times;</button>
                  <h2 class="modal-title" align="center"><i class="fa <?=$fa_icon?>"></i> Bin Allocation</h2>
                 
                </div>
                <div class="modal-body modal-bodyTH">
                 <!-- here dynamic task details will show -->
                </div>
                <div class="modal-footer">
                  <button type="button" id="btnCancel" class="btn<?=$btncolor?>" data-dismiss="modal"><i class="fa fa-window-close fa-lg"></i> Close</button>
                </div>
                
              </div>
            </div>
            </form>
          </div><!--close Model Mapped modal-->
		  
		  <!-- Start Model Mapped Modal -->
          <div class="modal modalTH fade" id="courierModel_new" role="dialog">
          <form class="form-horizontal" role="form" id="frm2" name="frm2">
            <div class="modal-dialog modal-dialogTH modal-lg">
            
              <!-- Modal content-->
              <div class="modal-content">
                <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal">&times;</button>
                  <h2 class="modal-title" align="center"><i class="fa <?=$fa_icon?>"></i> Same Group Parts </h2>
                 
                </div>
                <div class="modal-body modal-bodyTH">
                 <!-- here dynamic task details will show -->
                </div>
                <div class="modal-footer">
                  <button type="button" id="btnCancel" class="btn<?=$btncolor?>" data-dismiss="modal"><i class="fa fa-window-close fa-lg"></i> Close</button>
                </div>
                
              </div>
            </div>
            </form>
          </div><!--close Model Mapped modal-->
		  
    </div>
    
  </div>
</div>
<?php
include("../includes/footer.php");
include("../includes/connection_close.php");
?>
</body>
</html>