<?php
include('session.php');
include('connection.php');
$b=$_GET['srno'];
//echo $b;
mysqli_query($GLOBALS["___mysqli_ston"], "SET NAMES utf8");
//	$my="SELECT * FROM `pdf_upload11` where srno='$b'";
	$my="select sw.dept_sub_category as deptname,dc.dept_name as subdept,dsc.dept_sub_category,pu.Date,pu.Status,
			pu.document1,pu.file_text,pu.srno
			 from sub_welfare sw join pdf_upload11 pu
			 on sw.srno	 = pu.department_name	 left outer join dept_category dc on dc.srno = pu.sub_dep_name left outer join
			 dept_sub_category dsc on pu.sub_of_sub_dept = dsc.srno where pu.srno='$b' ";
		
//echo $my;
$n=mysqli_query($GLOBALS["___mysqli_ston"], $my) or die ("Query Fail:".mysqli_error($GLOBALS["___mysqli_ston"]));
if(mysqli_num_rows($n)>0)
{
while($rw=mysqli_fetch_assoc($n)) 
{
	       $srno=$rw['srno'];
							$department_name=$rw['deptname'];
							$sub_dep_name=$rw['subdept'];
							$sub_of_sub_dept=$rw['dept_sub_category'];
							$Date=$rw['Date'];
							$info1=$rw['document1'];
							$file1=$rw['file_text'];
				  /* $srno=$rw['srno'];
							$department_name=$rw['department_name'];
							$sub_dep_name=$rw['sub_dep_name'];
							$sub_of_sub_dept=$rw['sub_of_sub_dept'];
							$Date=$rw['Date'];
							$info1=$rw['document1'];
							$file1=$rw['file_text'];*/
}
}
?>


<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="samarth10" >

    <title>SB Admin 2 - Bootstrap Admin Theme</title>
 
    <!-- Bootstrap Core CSS -->
            
    <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    
    <!-- MetisMenu CSS -->
    <link href="bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
 
    <!-- Custom CSS -->
     <link href="dist/css/sb-admin-2.css" rel="stylesheet">
 
    <!-- Custom Fonts -->
    <link href="bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"> 
   
 
 <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
 
<script src="dist/js/jquery-1.7.1.min.js"></script>
 
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<link rel="stylesheet" href="dist/css/bootstrap-datepicker.css">

<link rel="stylesheet" href="tinybox/style_tiny.css" />
<script type="text/javascript" src="tinybox/tinybox.js"></script>

<script src="dist/js/bootstrap-datepicker.js"></script>
<script src="dist/js/bootstrap-datepicker.min.js"></script>

        <script type="text/javascript" >

$(function()
{
$('#dp1').datepicker();	
	
	});
	
	function dept_pdf_upload() 
{

document.getElementById('dept_name').innerHTML = "";
document.getElementById('sub_dept_name').innerHTML = "";

var srno=document.getElementById('srno').value;		
//var dept_name1=document.getElementById('dept_name1').value;		
var dept_name = document.getElementById('dept_name1');		
var dept_name1 = dept_name.options[dept_name.selectedIndex].text;
var sub_dept_name=document.getElementById('sub_dept_name').value;		

//alert (dept_name);

	if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4)
		 {

				var msg=xmlhttp.responseText;
				//alert(msg);
			//	document.getElementById('sub_dept_name').innerHTML=msg;
			if(msg!=0)
			{
				document.getElementById('dept').style.display='block';
				}
				document.getElementById('dept_name').innerHTML=msg;

					}
}

			var res ="?dept_name1="+dept_name1; 
//alert(res);
		xmlhttp.open("POST", "dept_upload_insert.php" + res, true); 
		xmlhttp.send(null); 
		//document.getElementById('submit').disabled=true;
					 
			// curr();	
}




function dept_pdf_upload1() 
{
  //alert('hiii'); 
//var vname=document.getElementById('vname').value;

var srno=document.getElementById('srno').value;		
//var dept_name=document.getElementById('dept_name').value;
var dept_name1 = document.getElementById('dept_name');		
var dept_name = dept_name1.options[dept_name1.selectedIndex].text;		
var sub_dept_name=document.getElementById('sub_dept_name').value;		

//alert (dept_name);

	if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4)
		 {

				var msg=xmlhttp.responseText;
				//alert(msg);
			//	document.getElementById('sub_dept_name').innerHTML=msg;
				
			
			if(msg!=0)
			{
				document.getElementById('dept1').style.display='block';
				}
				document.getElementById('sub_dept_name').innerHTML=msg;
     
					}
}

			var res ="?dept_name="+dept_name; 
//alert(res);
		xmlhttp.open("GET", "dept_upload_insert1.php" + res, true); 
		xmlhttp.send(null); 
		//document.getElementById('submit').disabled=true;
					 
			// curr();	
}

</script>
</head>

<body>

    <div id="wrapper">

        <!-- Navigation -->
        <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
            
                    <!-- /.dropdown-tasks -->
                
                <!-- /.dropdown -->
              

        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header"></h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                           Current updates
                        </div>
                        <div class="panel-body">
                            <div class="row">
  <div class="col-lg-6">
     <form role="form" action="updatewelfare.php" method="post"  enctype="multipart/form-data" class="contact_form">
         
          <div class="form-group" >
              <label>srno</label>
              <input class="form-control" placeholder="Enter Number" id="srno" name="srno" value="<?php echo $b;?>" readonly>
          <div class="form-group">
                                             <label>Employee Welfare Department Name:</label>
                                         
                                          <select  class="form-control" id="dept_name1" name="dept_name1" onchange="dept_pdf_upload();" value="<?php echo $department_name;?>"> <option><?php echo 	$department_name;?></option>
                                          <?php
                                          mysqli_query($GLOBALS["___mysqli_ston"], "set NAMES utf8");
                                          $dept="SELECT * FROM `sub_welfare`";
																																						$res=mysqli_query($GLOBALS["___mysqli_ston"], $dept) or die('Query Failed: 4' . mysqli_error($GLOBALS["___mysqli_ston"]));
																																						while($rw = mysqli_fetch_assoc($res))
																																								{
																																									$srno=$rw['srno'];
																																									$dept_sub_category=$rw['dept_sub_category'];
																																									//echo	$deptt_code;
																																									echo '<option value="'.$srno.'">'.$dept_sub_category.'</option>';
																																									}
																																									?> 
                                          </select>
                                          
                                          </div>
                                             <div class="form-group" id="dept" >
                                             <label>Department Name:</label>
                                             <select  class="form-control" id="dept_name" name="dept_name" onchange="dept_pdf_upload1();" value="<?php echo $sub_dep_name;?>" > <option><?php echo $sub_dep_name;?></option>
                                             </select>
                                          
                                          </div>
                                          
                                          
                                       <div class="form-group" id="dept1" >
                                             <label>Sub Department Name:</label>
                                          
                                          <select  class="form-control" id="sub_dept_name" name="sub_dept_name" value="<?php echo $sub_of_sub_dept;?>"><option><?php echo $sub_of_sub_dept;?></option> 
                                          </select>
                                          
                                        </div>
                                        
                                       <div class="form-group">
                                           <label>Date</label>                                             
                                         <input id="dp1" class="span2 form-control" placeholder="Select date" name="dp1" type="text" value="<?php echo $Date;?>" required></div>
          
                <input type="submit"  name="submit" value="submit" /> 
 
       
       </form>
        <!--     <?php $_SERVER['PHP_SELF'];?> -->
  </div>
                                <!-- /.col-lg-6 (nested) -->
                            </div>
                            <!-- /.row (nested) -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                      <div id="search_res" style="width:100%;" >                    
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="../bower_components/jquery/dist/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="../bower_components/metisMenu/dist/metisMenu.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="../dist/js/sb-admin-2.js"></script>

</body>

</html>
