<?php
require_once("../includes/config.php");
if(isset($_REQUEST['product'])){$product=$_REQUEST['product'];}else{$product="";}
if(isset($_REQUEST['location'])){$selrf=$_REQUEST['location'];}else{$selrf="";}
if(isset($_REQUEST['daterange'])){$seldaterng=$_REQUEST['daterange'];}else{$seldaterng="";}

///// 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 = $('#pi-grid').DataTable( {
		"processing": true,
		"serverSide": true,
		"order": [[ 0, "desc" ]],
		"ajax":{
			url :"../pagination/jobcard_iqc-grid_data.php", // json datasource
			data: { "pid": "<?=$_REQUEST['pid']?>", "hid": "<?=$_REQUEST['hid']?>", "icn": "<?=$_REQUEST['icn']?>", "product": "<?=$product?>", "location": "<?=$selrf?>",  "daterange": "<?=$seldaterng?>"},
			type: "post",  // method  , by default get
			error: function(){  // error handling
				$(".pi-grid-error").html("");
                                //alert(html("data"));
				$("#pi-grid").append('<tbody class="pi-grid-error"><tr><th colspan="8" style="text-align:center">No data found in the server</th></tr></tbody>');
				$("#pi-grid_processing").css("display","none");
				
			}
		}
	} );
} );
$(document).ready(function(){
	$('input[name="daterange"]').daterangepicker({
		locale: {
			format: 'YYYY-MM-DD'
		},
		startDate: "<?=date("Y-m-01")?>"
	});
});
////// function for open model to view planning details
function openModel(docid,p_id){
	$.get('job_view_only.php?doc_id=' + docid, function(html){
		 $('#courierModel .modal-body').html(html);
		 $('#courierModel').modal({
			show: true,
			backdrop:"static"
		});
	 });
	 $("#docno").html(docid);
}
</script>
 <!-- Include Date Range Picker -->
  <script type="text/javascript" src="../js/moment.js"></script>
 <script type="text/javascript" src="../js/daterangepicker.js"></script>
 <link rel="stylesheet" type="text/css" href="../css/daterangepicker.css"/>
<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> Job Card IQC</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 custom-select">
			   		<option value=''>All</option>
					<?php
					$res_maploc = mysqli_query($link1,"select location_code,locationname from location_master where statusid='1' and location_code in (".$access_loc.") order by locationname "); 
					while($row_maploc = mysqli_fetch_assoc($res_maploc)){
						?>
					<option value="<?=$row_maploc['location_code']?>" <?php if($selrf == $row_maploc['location_code']) { echo 'selected'; }?>><?=$row_maploc['locationname']." (".$row_maploc['location_code'].")"?></option>
					<?php } ?>
               </select>
            </div>
          </div>
		  <div class="col-md-6">
                       <label class="col-md-5 control-label"> Product</label>	  
			<div class="col-md-6" align="left">
			   <select name="product" id="product" class="form-control custom-select">
               		<option value="">All</option>
               		<?php
                        $res_maploc = mysqli_query($link1,"select partcode,part_name from partcode_master where status='1' and itemtypeid in ('1','4') order by part_name "); 
                        while($row_maploc = mysqli_fetch_assoc($res_maploc)){
                                ?>
                        <option value="<?=$row_maploc['partcode']?>" <?php if($product == $row_maploc['partcode']) { echo 'selected'; }?>><?=$row_maploc['part_name']." (".$row_maploc['partcode'].")"?></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">Date Range</label>	  
			<div class="col-md-6" align="left">
				<input type="text" name="daterange" id="date_rng" class="form-control" value="<?=$seldaterng?>" />
            </div>
          </div>
           <div class="col-md-6"><label class="col-md-5 control-label"></label>
			<div class="col-md-5" align="left">
			   <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']?>"/>
               <button class='btn<?=$btncolor?>' id="Submit" type="submit" name="Submit" value="GO" title="Go!"><i class="fa fa-arrow-circle-right fa-lg"></i>&nbsp;GO</button>
            </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/>
      <!--<div class="form-group table-responsive"  id="page-wrap" style="margin-left:10px;"><br/><br/>-->
       <table  width="100%" id="pi-grid" class="display" align="center" cellpadding="4" cellspacing="0" border="1">
          <thead>
            <tr class="<?=$tableheadcolor?>">
              <th>S.No</th>
              <th>Job No.</th>              
              <th>System Ref. No.</th>
              <th>Location</th>
              <th>Product</th>
              <th>Qty</th>
              <th>Entry Date</th>              
              <th>View</th> 
              <th>IQC View</th>             
            </tr>
            </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-bar-chart faicon'></i> Job Details</h2>
                  <h4 id="docno" align="center"></h4>
                </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>
