<?php
include('session.php');
include('connection.php');
//include('lock.php');

header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html>
<html lang="en">

<head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <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();	
	
	});
</script>

<script type="text/javascript" >
        
        
 function newsub()
{
	//alert('hjhgj');
		//var srno=document.getElementById('srno').value;
		var head=document.getElementById('head').value;
		var head1=document.getElementById('head1').value;
	//alert(sno);
	var info=document.getElementById('info').value;
	var info1=document.getElementById('info1').value;
//alert(info);
var dp1=document.getElementById('dp1').value;

//alert(date1);
var file1=document.getElementById('file1').value;
var file2=document.getElementById('file2').value;
var file3=document.getElementById('file3').value;
var title1=document.getElementById('title1').value;
var title2=document.getElementById('title2').value;

var path=document.getElementById('path').value;
//alert(path);
//var video=document.getElementById('video').value;
//alert(video);

if(head==''||head1==''||info==''||info1==''||dp1=='')
{
alert('Please enter all details..?');
	}
	else
	{  	
  	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) 
	{
  //  alert(xmlhttp.responseText);
      if(xmlhttp.responseText==1)	   {

	   alert("Inserted Successfully");
       window.location.reload();
		
  }
  	  
  }
  }
var  res="&head="+head+"&head1="+head1+"&info="+info+"&info1="+info1+"&dp1="+dp1+"&path="+path;
	// alert(res);
  xmlhttp.open("POST","submitfile.php?"+res,true);
  xmlhttp.send(null); 
	 
}
}


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

//var srno=document.getElementById('srno').value;		
var dept_name=document.getElementById('dept_name').value;		
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);
					if(msg!=0)
			{
				document.getElementById('dept').style.display='block';
				}
				document.getElementById('sub_dept_name').innerHTML=msg;

					}
}

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




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

var category=document.getElementById('category').value;		
//var dept_name=document.getElementById('dept_name').value;		
var sub_dept_name=document.getElementById('sub_dept_name').value;		
//alert(sub_dept_name);
//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);
				if(msg!=0)
			{
				document.getElementById('dept1').style.display='block';
				}
				document.getElementById('category').innerHTML=msg;

					}
}

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



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

var emp_welf_sub=document.getElementById('emp_welf_sub').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_welfemp_dept').innerHTML=msg;

					}
}

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




 function view5(i)
{
//alert(i);


	{  	
  	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) 
	{
 // alert(xmlhttp.responseText);
      if(xmlhttp.responseText==1)	   {

	 // alert("Inserted Successfully");
       window.location.reload();
		
  }
  	  
  }
  }
//var res="&srno="+srno+"&date="+date+"&option="+option;
	//alert(res);
  xmlhttp.open("GET","disablee.php?srno="+i,true);
  xmlhttp.send(null); 
	 
}
}

function sub_of_department()
				{
						var type1="city";
						if(str!="")
								{
												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)
									 												{
																						respo=xmlhttp.responseText;
																						document.getElementById("city_id").innerHTML=respo;
								    										}
															} 	
				     	 						
															var res ="&id="+str+"&type="+type1;
															xmlhttp.open("GET", "address.php?"+res , true); 
															xmlhttp.send(null);
									}
			}
			
function see()
{
//alert('hi');
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)
		 {
		 	
	//alert(xmlhttp.responseText);
		//window.location.href="Update_EmpRecord_Design.php";
				var msg=xmlhttp.responseText;
				document.getElementById('search_res').innerHTML=msg;
		 }
	}

	//		var res ="?uname="+uname;
//alert(res);

		xmlhttp.open("POST", "viewdept.php" , true); 
				xmlhttp.send(null); 
		//document.getElementById('submit').disabled=true;
					 	
	}
	
function update_company(i)
{
		var Sr=i;
		TINY.box.show({iframe:"updation_dept.php?srno="+i,boxid:'frameless',width:660,height:550,fixed:false,maskid:'bluemask',maskopacity:40,closejs:function(){closeJS()}});	
}
			
			
 function view5(i)
{
//alert(i);


	{  	
  	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) 
	{
 // alert(xmlhttp.responseText);
      if(xmlhttp.responseText==1)	   {

	 // alert("Inserted Successfully");
       window.location.reload();
		
  }
  	  
  }
  }
//var res="&srno="+srno+"&date="+date+"&option="+option;
	//alert(res);
  xmlhttp.open("GET","disable_dept.php?srno="+i,true);
  xmlhttp.send(null); 
	 
}
}

</script>
<script>
(function($) {
    $.fn.checkFileType = function(options) {
        var defaults = {
            allowedExtensions: [],
            success: function() {},
            error: function() {}
        };
        options = $.extend(defaults, options);

        return this.each(function() {

            $(this).on('change', function() {
                var value = $(this).val(),
                    file = value.toLowerCase(),
                    extension = file.substring(file.lastIndexOf('.') + 1);

                if ($.inArray(extension, options.allowedExtensions) == -1) {
                    options.error();
                    $(this).focus();
                } else {
                    options.success();

                }

            });

        });
    };

})(jQuery);

$(function() {
    $('#file1').checkFileType({
        allowedExtensions: ['jpg', 'jpeg', 'pdf' ,'png'],
        success: function() {
        //    alert('Success');
        },
        error: function() {
            alert('File Format is not supported..!!!');
                    document.getElementById('file1').value='';
        }
    });

});

$(function() {
    $('#file2').checkFileType({
        allowedExtensions: ['jpg', 'jpeg','pdf'],
        success: function() {
         //   alert('Success');
        },
        error: function() {
            alert('File Format is not supported..!!!');
                    document.getElementById('file2').value='';
        }
    });

});

$(function() {
    $('#file3').checkFileType({
        allowedExtensions: ['jpg', 'jpeg','pdf'],
        success: function() {
           // alert('Success');

        },
        error: function() {
            alert('File Format is not supported..!!!');
        document.getElementById('file3').value='';
        }
    });

});


$(document).ready(function(){
    $('#dept_name2').on('change', function() {
      if ( this.value == '1')
      {
      		$("#sub_dept_name1").empty();
      		$("#sub_dept_name1").append('<option value="">---select---</option><option value="मूळ आढावा">मूळ आढावा </option><option value="योजना आढावा">योजना आढावा </option>');
        $("#dept1").show();
      }
      else if(this.value == '4')
      {
      			$("#sub_dept_name1").empty();
      			$("#sub_dept_name1").append('<option value="">---select---</option><option value="स्थायी समिती सभा">स्थायी समिती सभा </option><option value="सर्वसाधारण समिती सभा">सर्वसाधारण समिती सभा </option>');
      			$("#dept1").show();
      }
      else
      {
      		$("#sub_dept_name1").empty();
        $("#dept1").hide();
      }
    });
});


function getsubdept(val)
{
				var xmlhttp = new XMLHttpRequest();
		  xmlhttp.onreadystatechange = function() 
		  {
		      if (this.readyState == 4 && this.status == 200) 
		      {
		      				var msg = this.responseText;
		      				//alert(msg);
		      				apendsubdept(msg);
		          //document.getElementById("txtHint").innerHTML = this.responseText;
		      }
		  };
		  xmlhttp.open("GET", "getsubdept.php?q=" + val, true);
		  xmlhttp.send();
}

function apendsubdept(msg)
{
			var val = msg.split('#');
			var id = "";
			var names = "";
			$("#dept_name2").empty();
			$("#dept_name2").append("<option value=''>---Select---</option>");
			for(var i = 0; i< val.length; i++)
			{
						var val1 = 	val[i].split(',');
						id = val1[0];
						names = val1[1];
						$("#dept_name2").append("<option value='"+id+"'>"+names+"</option>");
			}
}

function myFunction()
{
			var x = document.getElementById("file1");
			var filesize = x.files.item(0).size / 1000000;
			if(filesize > 1)
			{
						alert("File Size More then 3 mb.");	
						x.value = "";
						return false;
			}
}

</script>

</head>

<body>

    <div id="wrapper">

                 <?php include("menu22.php"); ?>
<!--             </div> -->
                                 <?php include("header.php"); ?> 
<!--         </nav> -->

        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">Departments and Planning</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                        Departments and Planning
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-6">
                                
                                    <form role="form" action="main_pdf_insert.php" method="post" id="yourElem"  enctype="multipart/form-data" class="contact_form">
                                       
                                     
                                            <div class="form-group">
                                           <label>Department Name:</label>
                                           <select  class="form-control" id="dept_name" name="dept_name" onchange="getsubdept(this.value);" required> 
                                           	<option value="">---select--- </option>
																													            	<?php
                                              $dept="SELECT * FROM `main_dept_category`";
                                             	$res = mysqli_query($GLOBALS["___mysqli_ston"], "SET NAMES utf8");	
																																									$res=mysqli_query($GLOBALS["___mysqli_ston"], $dept) or die('Query Failed: 4' . mysqli_error($GLOBALS["___mysqli_ston"]));
																																										while($rw = mysqli_fetch_assoc($res))
																																									 {
																																									    	$ddept_id=$rw['dept_id'];
																																												 $dept_name=$rw['dept_name'];
																																													echo '<option value="'.$ddept_id.'">'.$dept_name.'</option>';	
																																																																											
																																										} 
																																									?>     
                                           </select>
                                          
                                          </div>
                                          <div class="form-group">
                                             <label>Sub Department Name:</label>
                                           <select  class="form-control" id="dept_name2" name="dept_name2" required> 
                                           <option value="">---select--- </option>
																																								<!-- <?php
                                              $dept="SELECT * FROM `main_sub_dept_cat1`  where sub_dept_code != 3";
                                             
																																									$res = mysqli_query($GLOBALS["___mysqli_ston"], "SET NAMES utf8");	
																																									$res=mysqli_query($GLOBALS["___mysqli_ston"], $dept) or die('Query Failed: 4' . mysqli_error($GLOBALS["___mysqli_ston"]));
																																								
																																									while($rw = mysqli_fetch_assoc($res))
																																								 {
																																											 $dept_sub_category=$rw['dept_sub_category'];
																																											 $sub_dept_code	= $rw['sub_dept_code'];
																																												echo '<option value="'.$sub_dept_code.'">'.$dept_sub_category.'</option>';
																																																																																							
																																									} 
																																									?>  -->
											                                          
                                          </select>
                                          
                                          </div>
                                                                         
                                        <div class="form-group" id="dept1" style="display:none">
                                             <label>Sub Of Sub Department Name:</label>                                     
                                              <select class="form-control" id="sub_dept_name1" name="sub_dept_name1">
                                              <option value="">---select--- </option>
                                              </select>
                                       </div>
                                        
                                                                             
                                     
                                       <div class="form-group">
                                           <label>Date</label> 
                                            
                                         <input id="dp1" class="span2 form-control" placeholder="Select date" name="dp1" type="text" required></div>
                                        
                                  
                                  <div class="form-group"> 
                                   <label> Enter Text: </label><input class="form-control" type="text" name="file_text" id="file_text" required></div>
                                                                             
                                         
                                         
                                        
	                                 <div class="form-group"> 
	                          							<label> File: </label><input class="form-control" type="file" name="file1" id="file1" onchange="return myFunction();" required><br><b>NOTE:- PDF file will not be accepted more than 1MB.</b></div>

                                    <input type="submit"  name="submit" value="submit" />
                                    <button type="button" onclick="see();" class="submit">View</button>
                                         
                                    </form>

                                  </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>
