<?PHP

ob_start();

session_start();

include 'connect.php';

if(isset($_SESSION['adminemail']))

{

$user=$_SESSION['adminemail'];



$gtp=mysqli_query($conn,"select * from admin where username='$user'");

$gtp1=mysqli_fetch_assoc($gtp);



include 'top.php';

?>





<div id="page-wrapper" >
          <div id="page-inner">

			<div class="main-content">

				<div class="main-content-inner">

					<div class="breadcrumbs ace-save-state" id="breadcrumbs">

						<ul class="breadcrumb">

							<li>

								<i class="ace-icon fa fa-home home-icon"></i>

								<a href="#">Home</a>

							</li>

							<li class="active">Employee</li>

						</ul><!-- /.breadcrumb -->

					</div>



					<div class="page-content">

			



						<div class="page-header">

                        

<?php



$aca=mysqli_query($conn,"select * from financial where user='$user' order by ID desc");

$aca1=mysqli_fetch_assoc($aca);



$financial=$aca1['financial'];



?>

                        

                        <table style="width:100%;">

                        

                        <tr><td style="width:50%;">

                        

							<h1>

								Employee			

							</h1>

                            

                            </td>

                            

                            <td style="width:50%; text-align:right; padding-right:15px; font-size:15px;">

                            

                            <i class="fa fa-calendar"></i>&nbsp; <?php echo $financial; ?>

                            

                            </td></tr></table>

                            

						</div><!-- /.page-header -->



						<div class="row">

							<div class="col-xs-12">

                            

								<!-- PAGE CONTENT BEGINS -->



<script src="assets/js/jquery.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
<script>
    $(function() {
    // Initialize the datepicker for all elements with class "datepicker"
    $(".datepicker").datepicker({
        format: "mm/dd/yyyy",
        autoclose: true,
        todayHighlight: true
    });

    // Adjust the positioning of the datepicker dropdown
    $(".datepicker").on("show", function(e) {
        var inputOffset = $(this).offset();
        var inputHeight = $(this).outerHeight();
        var datepickerDropdown = $(".datepicker-dropdown");

        datepickerDropdown.css({
            top: inputOffset.top + inputHeight + 10,
            left: inputOffset.left
        });
    });
});

</script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.min.css">
 <style>
    /* Custom CSS for Chosen select */
    .chosen-container {
      width: 25ch;
    }

    .chosen-container-single .chosen-single {
      border-radius: 4px;
      border: 1px solid #f0f0f0; /* Change the border color here */
      height:34px;
	  margin-bottom:10px;
      background-color: #fff;
      background-image: none;
      box-shadow: 0 0 0 1px #c0c0c0;
    }

    .chosen-container-single .chosen-single span {
      padding: 5px;
      text-transform: uppercase;
    }

    .chosen-container-single .chosen-search input[type="text"] {
      border-radius: 4px;
      border: 1px solid #c0c0c0;
      height: 34px;
    }

    .chosen-container-active .chosen-single {
      border-color: #7f7f7f;
      box-shadow: 0 0 0 1px #7f7f7f;
    }

    .chosen-container-active .chosen-single:hover {
      border-color: #7f7f7f;
      box-shadow: 0 0 0 1px #7f7f7f;
    }

    .chosen-container-active .chosen-search input[type="text"] {
      border-color: #7f7f7f;
    }
  </style>

<script>
  $(document).ready(function() {
    $(".chosen-select").chosen({
      width: '100%',
      disable_search_threshold: 10
    });


    $(".department").change(function() {
      var department = $(this).val();
      var dataString = 'department=' + department;

      $.ajax({
        type: "GET",
        url: "getdesignation.php",
        data: dataString,
        cache: false,
        success: function(resp) {
          $('.designation').html(resp);
          $(".designation").trigger("chosen:updated");
        }
      });
    });
  });
</script>
<script>



function update_gross()

{

	

	var basic=$('.basic').val().replace("Rs.", "");

	var serviceweightage=$('.serviceweightage').val().replace("Rs.", "");

	var hra=$('.hra').val().replace("Rs.", "");

	var cca=$('.cca').val().replace("Rs.", "");

	

	var tot = (basic*1)+(serviceweightage*1)+(hra*1)+(cca*1);

	

	tot=tot.toFixed(2);

	

	$('.gross').val(tot);

	

}



$(document).ready(function(){

	

	

$('.username').blur(function(){

	

		  var username=$('.username').val();

		  var dataString = 'username='+ username;

		  //alert(dataString);

		  $.ajax

		  ({

		  type: "GET",

		  url: "getusername.php",

		  data: dataString,

		  cache: false,

		  success: function(html)

		  {

			

			//alert(html);

			var warn=$(html).filter('#warn').text();

			

			$('.warnn').val(warn);

			

			if(warn>0)

			{

				alert("Sortno already exist.");				

			}

			

		  }

		  });

		

});





$(".department").change(function() {



		  var department=$(this).val();



		  var dataString = 'department='+ department;



		  //alert(dataString);



		  $.ajax



		  ({



		  type: "GET",



		  url: "getdesignation.php",



		  data: dataString,



		  cache: false,



		  success: function(resp)



		  {

			  

			  //alert(resp);

		  

		  $('.designation').html($('#designation',resp).html());

		  

		  }



		  });



});





});



$('.basic').blur(update_gross);

$('.serviceweightage').blur(update_gross);

$('.hra').blur(update_gross);

$('.cca').blur(update_gross);

	







/*

$("input[type=checkbox]").change(function()

    {



        if ($(this).is(":checked")) {



            $(".swt").show();



	    }



        else{



            $(".swt").hide();



        }



    });



    $("input[type=checkbox]").change();

	

	

	

$('.designation').change(function(){

	

	var desig=$('.designation').val();

	var dept=$('.department').val();

	

	if(desig=='2' && dept=='1')

	{

		$('.exctve').show();			

	}

	else

	{

		$('.exctve').hide();

	}

	

});





$('.department').change(function(){

	

	var desig=$('.designation').val();

	var dept=$('.department').val();

	

	if(desig=='2' && dept=='1')

	{

		$('.exctve').show();			

	}

	else

	{

		$('.exctve').hide();

	}

	

});

	

	



});*/



</script>



<script>

	

jQuery(function($){

		   

	// simple jQuery validation script

	$('#course').submit(function(){

		

		var valid = true;

		var errormsg = 'This field is required!';

		var errorcn = 'error';

		

		$('.' + errorcn, this).remove();			

		

		$('#required', this).each(function(){

			var parent = $(this).parent();

			if( $(this).val() == '' ){

				var msg = $(this).attr('title');

				msg = (msg != '') ? msg : errormsg;

				$('<span style="font-size:13px;color:#FF0000; padding-left:3px;" class="'+ errorcn +'">'+ msg +'</span>')

					.appendTo(parent)

					.fadeIn('fast')

					.click(function(){ $(this).remove(); });

				valid = false;

			};

		});

		

		

		/*if($('.chk').attr('checked'))

		{

			

			var utype=$('.utype').val();

			var username=$('.username').val();

			var password=$('.password').val();

			

			if(utype=='')

			{

				alert("Select User Type");

				valid=false;

			}

			else if(username=='')

			{

				alert("Enter Username");

				valid=false;

			}

			else if(password=='')

			{

				alert("Enter Password");

				valid=false;

			}

			

		}*/

		

		

		return valid;

		

		$('button:submit').prop('disabled', true);

		

	});

	

});	



</script>







<?php



if(isset($_POST['submit'])) {



$empid=$_POST['empid'];



$name = $_POST['name'];



$appletterstatus=$_POST['appletterstatus'];



$designation=$_POST['designation'];



$department=$_POST['department'];



$dateofliving=$_POST['dateofliving'];



$doj=$_POST['doj'];



$marriagedate=$_POST['marriagedate'];



$dob=$_POST['dob'];



$age=$_POST['age'];



$sex=$_POST['sex'];



$maritalstatus=$_POST['maritalstatus'];



$bloodgroup=$_POST['bloodgroup'];



$basicqualification=$_POST['basicqualification'];



$skills=$_POST['skills'];



$aadharno=$_POST['aadharno'];



$panno=$_POST['panno'];



$license=$_POST['license'];



$yearsofexperience=$_POST['yearsofexperience'];



$contactno=$_POST['contactno'];



$emergencycontactno=$_POST['emergencycontactno'];



$email=$_POST['email'];



$permanentaddress=$_POST['permanentaddress'];



$communicationaddress=$_POST['communicationaddress'];



$bank=$_POST['bank'];



$accountno=$_POST['accountno'];



$ifsc=$_POST['ifsc'];



$fathername=$_POST['fathername'];



$spouse=$_POST['spouse'];



$spousedob=$_POST['spousedob'];



$spouseage=$_POST['spouseage'];



$child1=$_POST['child1'];



$child1dob=$_POST['child1dob'];



$child1age=$_POST['child1age'];



$child1gender=$_POST['child1gender'];



$child2=$_POST['child2'];



$child2dob=$_POST['child2dob'];



$child2age=$_POST['child2age'];



$child2gender=$_POST['child2gender'];



$basic=$_POST['basic'];



$serviceweightage=$_POST['serviceweightage'];



$hra=$_POST['hra'];



$cca=$_POST['cca'];



$gross=$_POST['gross'];



$description=$_POST['description'];



$username=$_POST['username'];



$password=$_POST['password'];





$password=md5($password);





// now we insert it into the database



$dob=date('Y-m-d',strtotime($dob));

$doj=date('Y-m-d',strtotime($doj));



if($name)

{ 





$chk=mysqli_query($conn,"select * from employee where empid='$empid'");

$chk1=mysqli_fetch_assoc($chk);





if($chk1>0)

{

	header("location:employee.php?s=3");

}



else

{

	

				if($salary!='')

				{

				$addate=date('Y-m-d');

				

				$iny=date("Y",strtotime($doj));

				$inm=date("m",strtotime($doj));

				

				$inf=$iny.'-'.$inm.'-01';

				

				$in="insert into salary(date,empid,month,year,salary,incrementfrom) values('$addate','$empid','$inm','$iny','$gross','$inf')";

				$in1=mysqli_query($conn,$in);

				}

	



if($check==1)

{

	

	$password=md5($password);

	

	$adins=mysqli_query($conn,"insert into admin(name,username,password,type) values('$name','$username','$password','$type')");

	

}





$in= "INSERT INTO employee(empid,name,appletterstatus,designation,department,dateofjoining,dateofliving,marriagedate,dob,age,gender,maritalstatus,bloodgroup,basicqualification,skills,aadharno,panno,license,yearsofexperience,contactno,emergencycontactno,email,bank,accountno,ifsc,fathername,spouse,spousedob,spouseage,child1,child1dob,child1age,child1gender,child2,child2dob,child2age,child2gender,basic,serviceweightage,hra,cca,gross,description,permanentaddress,communicationaddress,username,password)



			VALUES('$empid','$name','$appletterstatus','$designation','$department','$doj','$dateofliving','$marriagedate','$dob','$age','$sex','$maritalstatus','$bloodgroup','$basicqualification','$skills','$aadharno','$panno','$license','$yearsofexperience','$contactno','$emergencycontactno','$email','$bank','$accountno','$ifsc','$fathername','$spouse','$spousedob','$spouseage','$child1','$child1dob','$child1age','$child1gender','$child2','$child2dob','$child2age','$child2gender','$basic','$serviceweightage','$hra','$cca','$gross','$description','$permanentaddress','$communicationaddress','$username','$password')";



$in1 = mysqli_query($conn,$in) or die(mysqli_error($conn));



if($in1)

{



 header("location:employee.php?s=1");



}



}



}



else

{



 header("location:employee.php?s=2");



}



}





else 

{	



 if (isset($_GET['s'])) 	

	{

	 $status=$_GET['s'];

		

		 if($status=='1')

		 {

			 echo'<div class="alert alert-block alert-success">

									<button type="button" class="close" data-dismiss="alert">

										<i class="ace-icon fa fa-times"></i>

									</button>

						Employee Added Successfully.

				  </div>';				  

		 }

		 if($status=='2')

		 {

			 echo'<div class="alert alert-block alert-danger">

									<button type="button" class="close" data-dismiss="alert">

										<i class="ace-icon fa fa-times"></i>

									</button>

						Values Not Inserted. Please try again.

				  </div>';				  

		 }

		 if($status=='3')

		 {

			 echo'<div class="alert alert-block alert-danger">

									<button type="button" class="close" data-dismiss="alert">

										<i class="ace-icon fa fa-times"></i>

									</button>

						Employee ID already exist.

				  </div>';				  

		 }

	}

 

?>





<form id="course" action="employee.php" method="post">



<input type="hidden" class="warnn" />



<table style="margin:auto; line-height:41px;">





<tr><td>Emp.ID <span class="red"></span></td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="empid" id="required" title="*" autocomplete="off" /></td>



<td style="width:100px;"></td><td>Name <span class="red"></span></td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="name" id="required" title="*" autocomplete="off" /></td></tr>





<tr><td>App.Letter Status </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="appletterstatus" autocomplete="off" /></td>



<td></td><td>Department <span class="red"></span></td><td style="padding:0 7px;"></td><td><select style="width: 30ch; margin-bottom:10px; height:34px;border-radius: 5px;border: 1px solid #c0c0c0;" name="department" class="department chosen-select" style="width:220px;" id="required" title="*"><option value="">-- Select --</option>



<?php



$dep=mysqli_query($conn,"select * from department order by ID asc");

while($dep1=mysqli_fetch_assoc($dep))

{

	echo"<option value='".$dep1['ID']."'>".$dep1['department']."</option>";

}



?>



</select></td></tr>





<tr><td>Designation <span class="red"></span></td><td style="padding:0 7px;"></td><td><select style="width: 30ch; margin-bottom:10px; height:34px;border-radius: 5px;border: 1px solid #c0c0c0;" name="designation" class="designation chosen-select" style="width:220px;" id="required" title="*"><option value="" selected="selected">-- Select --</option></select></td>



<td></td><td>Date of joining </td><td style="padding:0 7px;"></td><td><input class="form-control datepicker" style="width: 30ch; margin-bottom:10px margin_top:10px;" type="text" name="doj"   autocomplete="off" /></td></tr>





<tr><td>Date of living </td><td style="padding:0 7px;"></td><td><input class="form-control datepicker" style="width: 30ch; margin-bottom:10px margin-top:10px;"  type="text" name="dateofliving" autocomplete="off" /></td>



<td></td><td>Marriage Date </td><td style="padding:0 7px;"></td><td><input class="form-control datepicker" style="width: 30ch; margin-bottom:10px" type="text" name="marriagedate" class="datepicker1" autocomplete="off" /></td></tr>





<tr><td>Date of Birth </td><td style="padding:0 7px;"></td><td><input class="form-control datepicker" style="width: 30ch; margin-bottom:10px" type="text" name="dob"   autocomplete="off" /></td>



<td></td><td>Age </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="age" autocomplete="off" /></td></tr>





<tr><td>Gender </td><td style="padding:0 7px;"></td><td><select class="form-control" style="width: 30ch; margin-bottom:10px" name="sex" style="width:220px;"><option value="Male">Male</option><option value="Female">Female</option></select></td>



<td></td><td>Marital Status </td><td style="padding:0 7px;"></td><td><select class="form-control" style="width: 30ch; margin-bottom:10px" name="maritalstatus" style="width:220px;"><option value="Married">Married</option><option value="Unmarried">Unmarried</option></select></td></tr>





<tr><td>Blood Group </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="bloodgroup" autocomplete="off" /></td>



<td></td><td>Basic Qualification </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="basicqualification" autocomplete="off" /></td></tr>





<tr><td>Skills </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="skills" autocomplete="off" /></td>



<td></td><td>Aadhar No. </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="aadharno" autocomplete="off" /></td></tr>





<tr><td>Pan No. </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="panno" autocomplete="off" /></td>



<td></td><td>License / Certification held </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="license" autocomplete="off" /></td></tr>





<tr><td>Years of Experience </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="yearsofexperience" autocomplete="off" /></td>



<td></td><td>Contact No. <span class="red"></span></td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="contactno" id="required" title="*" autocomplete="off" /></td></tr>





<tr><td>Emergency Contact No. </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="emergencycontactno" autocomplete="off" /></td>



<td></td><td>Email ID </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="email" autocomplete="off" /></td></tr>





<tr><td>Permanent Address </td><td style="padding:0 7px;"></td><td><textarea class="form-control" style="width: 30ch; margin-bottom:10px" name="permanentaddress" style="width:220px;"></textarea></td>



<td></td><td>Communication Address </td><td style="padding:0 7px;"></td><td><textarea class="form-control" style="width: 30ch;  margin-bottom:10px" name="communicationaddress" style="width:220px;"></textarea></td></tr>





<tr><td>Bank </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="bank" autocomplete="off" /></td>



<td></td><td>Account No. </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="accountno" autocomplete="off" /></td></tr>





<tr><td>IFSC </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="ifsc" autocomplete="off" /></td>



<td></td><td></td><td></td><td></td></tr>





<tr><td>Father Name </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="fathername" autocomplete="off" /></td>



<td></td><td></td><td></td><td></td></tr>





<tr><td>Spouse </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="spouse" autocomplete="off" /></td>



<td></td><td>Spouse DOB </td><td style="padding:0 7px;"></td><td><input class="form-control datepicker" style="width: 30ch; margin-bottom:10px" type="text" name="spousedob" class="datepicker3" autocomplete="off" /></td></tr>





<tr><td>Spouse Age </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="spouseage" autocomplete="off" /></td>



<td></td><td></td><td></td><td></td></tr>





<tr><td>Child 1 </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="child1" autocomplete="off" /></td>



<td></td><td>Child 1 Dob </td><td style="padding:0 7px;"></td><td><input class="form-control datepicker" style="width: 30ch; margin-bottom:10px" type="text" name="child1dob" class="datepicker4" autocomplete="off" /></td></tr>





<tr><td>Child 1 Age </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="child1age" autocomplete="off" /></td>



<td></td><td>Child 1 Gender </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="child1gender" autocomplete="off" /></td></tr>





<tr><td>Child 2 </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="child2" autocomplete="off" /></td>



<td></td><td>Child 2 Dob </td><td style="padding:0 7px;"></td><td><input class="form-control datepicker" style="width: 30ch; margin-bottom:10px" type="text" name="child2dob" class="datepicker5" autocomplete="off" /></td></tr>





<tr><td>Child 2 Age </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="child2age" autocomplete="off" /></td>



<td></td><td>Child 2 Gender </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="child2gender" autocomplete="off" /></td></tr>





<tr><td>Basic </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px; height:34px;border-radius: 5px;border: 1px solid #c0c0c0;"type="text" name="basic" autocomplete="off" class="basic" /></td>



<td></td><td>Service Weightage </td><td style="padding:0 7px;"></td><td><input style="width: 30ch; margin-bottom:10px; height:34px;border-radius: 5px;border: 1px solid #c0c0c0;" margin-bottom:10px" type="text" name="serviceweightage" autocomplete="off" class="serviceweightage" /></td></tr>





<tr><td>HRA </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px; height:34px;border-radius: 5px;border: 1px solid #c0c0c0;" type="text" name="hra" autocomplete="off" class="hra" /></td>



<td></td><td>CCA </td><td style="padding:0 7px;"></td><td><input style="width: 30ch; margin-bottom:10px; height:34px;border-radius: 5px;border: 1px solid #c0c0c0;" type="text" name="cca" autocomplete="off" class="cca" /></td></tr>





<tr><td>Gross </td><td style="padding:0 7px;"></td><td><input style="width: 30ch; margin-bottom:10px; height:34px;border-radius: 5px;border: 1px solid #c0c0c0;background-color: rgb(240, 240, 240);" type="text" name="gross" autocomplete="off" class="gross" readonly="true" /></td>



<td></td><td>Description</td><td style="padding:0 7px;"></td><td><textarea class="form-control" style="width: 30ch;  margin-bottom:10px" name="description" style="width:220px;"></textarea></td></tr>





<tr><td>Username </td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="username" class="username" autocomplete="off" /></td>



<td></td><td>Password</td><td style="padding:0 7px;"></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" type="password" name="password" style="width:220px; height:30px;" /></td></tr>





</table>



<center><button type="submit" name="submit" class="btn btn-sm btn-primary">Submit</button></center>



</form>



<?php



}

	

?>



        

								



										<!-- PAGE CONTENT ENDS -->

									</div><!-- /.col -->

								</div><!-- /.row -->

							</div><!-- /.page-content -->

						</div>

					</div><!-- /.main-content -->
					</div><!-- /.main-content -->
					</div><!-- /.main-content -->





<?php

include 'bottom.php';

}

else

{



 header("location:login.php");

}

ob_flush();

?>