<?PHP

ob_start();

session_start();

include 'connect.php';

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

{

$user=$_SESSION['adminemail'];



$gtp=mysql_query("select * from admin where username='$user'");

$gtp1=mysql_fetch_array($gtp);



include 'top.php';

?>







			<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=mysql_query("select * from financial where user='$user' order by ID desc");

$aca1=mysql_fetch_array($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>



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(){

	

	

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

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

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

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

	



$(".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());

		  

		  }



		  });



});







/*

$("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;

			};

		});

		

		return valid;

		

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

		

	});

	

});	



</script>   

								

										

                                        

<?php



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

{



$id=$_GET['id'];



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

{



$id=$_POST['id'];



$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'];



// now we insert it into the database



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

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



if($name)

{ 



$chk=mysql_query("select count(ID) from employee where empid='$empid' and ID!='$id'");

$chk1=mysql_result($chk,0);



if($chk1>0)

{

	header("location:viewemployee.php?s=4");

}



else

{

				if($month!='' && $year!='' && $salary!='')

				{

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

				$inf=date($year.'-'.$month.'-01');

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

				$in1=mysql_query($in);

				}





$in="update employee set empid='$empid',name='$name',appletterstatus='$appletterstatus',designation='$designation',department='$department',dateofjoining='$doj',dateofliving='$dateofliving',marriagedate='$marriagedate',dob='$dob',age='$age',gender='$sex',maritalstatus='$maritalstatus',bloodgroup='$bloodgroup',basicqualification='$basicqualification',skills='$skills',aadharno='$aadharno',panno='$panno',license='$license',yearsofexperience='$yearsofexperience',contactno='$contactno',emergencycontactno='$emergencycontactno',email='$email',permanentaddress='$permanentaddress',communicationaddress='$communicationaddress',bank='$bank',accountno='$accountno',ifsc='$ifsc',fathername='$fathername',spouse='$spouse',spousedob='$spousedob',spouseage='$spouseage',child1='$child1',child1dob='$child1dob',child1age='$child1age',child1gender='$child1gender',child2='$child2',child2dob='$child2dob',child2age='$child2age',child2gender='$child2gender',basic='$basic',serviceweightage='$serviceweightage',hra='$hra',cca='$cca',gross='$gross',description='$description',username='$username' where ID='$id'";



$in1 = mysql_query($in) or die(mysql_error());



if($in1)

{



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



}



}



}



else

{



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



}



}



else

{



$ex=mysql_query("select * from employee where ID='".$id."'");

$ex1=mysql_fetch_array($ex);



$lif=mysql_query("select * from salary where empid='$g1[empid]' order by ID desc limit 1");

$lif1=mysql_fetch_array($lif);



echo'<form id="course" action="viewemployee.php?id='.$id.'" method="post">



<input type="hidden" name="id" value="'.$id.'" />



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





<tr><td>Emp.ID <span class="red">*</span></td><td style="padding:0 7px;">:</td><td><input type="text" name="empid" id="required" title="*" value="'.$ex1['empid'].'" autocomplete="off" /></td>



<td style="width:100px;"></td><td>Name <span class="red">*</span></td><td style="padding:0 7px;">:</td><td><input type="text" name="name" id="required" title="*" value="'.$ex1['name'].'" autocomplete="off" /></td></tr>





<tr><td>App.Letter Status </td><td style="padding:0 7px;">:</td><td><input type="text" name="appletterstatus" value="'.$ex1['appletterstatus'].'" autocomplete="off" /></td>



<td></td><td>Department <span class="red">*</span></td><td style="padding:0 7px;">:</td><td><select name="department" class="department chosen" style="width:220px;" id="required" title="*"><option value="">-- Select --</option>';



$dep=mysql_query("select * from department order by ID asc");

while($dep1=mysql_fetch_array($dep))

{

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

	$sdep=str_replace("<option value='".$ex1['department']."'","<option value='".$ex1['department']."' selected",$sdep);

	echo $sdep;

}



echo'</select></td></tr>





<tr><td>Designation <span class="red">*</span></td><td style="padding:0 7px;">:</td><td><select name="designation" class="designation chosen" style="width:220px;" id="required" title="*"><option value="">-- Select --</option>';



$desig=mysql_query("select * from employee_designation where department='$ex1[department]' order by ID asc");

while($desig1=mysql_fetch_array($desig))

{

	$ll="<option value='".$desig1['ID']."'>".$desig1['designation']."</option>";

	$ll=str_replace("<option value='".$ex1['designation']."'","<option value='".$ex1['designation']."' selected",$ll);

	echo $ll;

}



echo'</select></td>



<td></td><td>Date of joining </td><td style="padding:0 7px;">:</td><td><input type="text" name="doj" value="'.$ex1['dateofjoining'].'" class="datepicker" autocomplete="off" /></td></tr>





<tr><td>Date of living </td><td style="padding:0 7px;">:</td><td><input type="text" name="dateofliving" value="'.$ex1['dateofliving'].'" autocomplete="off" /></td>



<td></td><td>Marriage Date </td><td style="padding:0 7px;">:</td><td><input type="text" name="marriagedate" value="'.$ex1['marriagedate'].'" class="datepicker1" autocomplete="off" /></td></tr>





<tr><td>Date of Birth </td><td style="padding:0 7px;">:</td><td><input type="text" name="dob" value="'.$ex1['dob'].'" class="datepicker2" autocomplete="off" /></td>



<td></td><td>Age </td><td style="padding:0 7px;">:</td><td><input type="text" name="age" value="'.$ex1['age'].'" autocomplete="off" /></td></tr>





<tr><td>Gender </td><td style="padding:0 7px;">:</td><td>';



?>



<select name="sex" style="width:220px;">

<option value="Male" <?php if($ex1['gender']!='Male'){ echo'selected="selected"'; } ?>>Male</option>

<option value="Female" <?php if($ex1['gender']!='Female'){ echo'selected="selected"'; } ?>>Female</option>

</select>



<?php



echo'</td>



<td></td><td>Marital Status </td><td style="padding:0 7px;">:</td><td>';



?>



<select name="maritalstatus" style="width:220px;">

<option value="Married" <?php if($ex1['maritalstatus']=='Married'){ echo'selected="selected"'; } ?>>Married</option>

<option value="Unmarried" <?php if($ex1['maritalstatus']=='Unmarried'){ echo'selected="selected"'; } ?>>Unmarried</option>

</select>



<?php



echo'</td></tr>





<tr><td>Blood Group </td><td style="padding:0 7px;">:</td><td><input type="text" name="bloodgroup" value="'.$ex1['bloodgroup'].'" autocomplete="off" /></td>



<td></td><td>Basic Qualification </td><td style="padding:0 7px;">:</td><td><input type="text" name="basicqualification" value="'.$ex1['basicqualification'].'" autocomplete="off" /></td></tr>





<tr><td>Skills </td><td style="padding:0 7px;">:</td><td><input type="text" name="skills" value="'.$ex1['skills'].'" autocomplete="off" /></td>



<td></td><td>Aadhar No. </td><td style="padding:0 7px;">:</td><td><input type="text" name="aadharno" value="'.$ex1['aadharno'].'" autocomplete="off" /></td></tr>





<tr><td>Pan No. </td><td style="padding:0 7px;">:</td><td><input type="text" name="panno" value="'.$ex1['panno'].'" autocomplete="off" /></td>



<td></td><td>License / Certification held </td><td style="padding:0 7px;">:</td><td><input type="text" name="license" value="'.$ex1['license'].'" autocomplete="off" /></td></tr>





<tr><td>Years of Experience </td><td style="padding:0 7px;">:</td><td><input type="text" name="yearsofexperience" value="'.$ex1['yearsofexperience'].'" autocomplete="off" /></td>



<td></td><td>Contact No. <span class="red">*</span></td><td style="padding:0 7px;">:</td><td><input type="text" name="contactno" value="'.$ex1['contactno'].'" id="required" title="*" autocomplete="off" /></td></tr>





<tr><td>Emergency Contact No. </td><td style="padding:0 7px;">:</td><td><input type="text" name="emergencycontactno" value="'.$ex1['emergencycontactno'].'" autocomplete="off" /></td>



<td></td><td>Email ID </td><td style="padding:0 7px;">:</td><td><input type="text" name="email" value="'.$ex1['email'].'" autocomplete="off" /></td></tr>





<tr><td>Permanent Address </td><td style="padding:0 7px;">:</td><td><textarea name="permanentaddress" style="width:220px;">'.$ex1['permanentaddress'].'</textarea></td>



<td></td><td>Communication Address </td><td style="padding:0 7px;">:</td><td><textarea name="communicationaddress" style="width:220px;">'.$ex1['communicationaddress'].'</textarea></td></tr>





<tr><td>Bank </td><td style="padding:0 7px;">:</td><td><input type="text" name="bank" value="'.$ex1['bank'].'" autocomplete="off" /></td>



<td></td><td>Account No. </td><td style="padding:0 7px;">:</td><td><input type="text" name="accountno" value="'.$ex1['accountno'].'" autocomplete="off" /></td></tr>





<tr><td>IFSC </td><td style="padding:0 7px;">:</td><td><input type="text" name="ifsc" value="'.$ex1['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 type="text" name="fathername" value="'.$ex1['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 type="text" name="spouse" value="'.$ex1['spouse'].'" autocomplete="off" /></td>



<td></td><td>Spouse DOB </td><td style="padding:0 7px;">:</td><td><input type="text" name="spousedob" value="'.$ex1['spousedob'].'" class="datepicker3" autocomplete="off" /></td></tr>





<tr><td>Spouse Age </td><td style="padding:0 7px;">:</td><td><input type="text" name="spouseage" value="'.$ex1['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 type="text" name="child1" value="'.$ex1['child1'].'" autocomplete="off" /></td>



<td></td><td>Child 1 Dob </td><td style="padding:0 7px;">:</td><td><input type="text" name="child1dob" value="'.$ex1['child1dob'].'" class="datepicker4" autocomplete="off" /></td></tr>





<tr><td>Child 1 Age </td><td style="padding:0 7px;">:</td><td><input type="text" name="child1age" value="'.$ex1['child1age'].'" autocomplete="off" /></td>



<td></td><td>Child 1 Gender </td><td style="padding:0 7px;">:</td><td><input type="text" name="child1gender" value="'.$ex1['child1gender'].'" autocomplete="off" /></td></tr>





<tr><td>Child 2 </td><td style="padding:0 7px;">:</td><td><input type="text" name="child2" value="'.$ex1['child2'].'" autocomplete="off" /></td>



<td></td><td>Child 2 Dob </td><td style="padding:0 7px;">:</td><td><input type="text" name="child2dob" value="'.$ex1['child2dob'].'" class="datepicker5" autocomplete="off" /></td></tr>





<tr><td>Child 2 Age </td><td style="padding:0 7px;">:</td><td><input type="text" name="child2age" value="'.$ex1['child2age'].'" autocomplete="off" /></td>



<td></td><td>Child 2 Gender </td><td style="padding:0 7px;">:</td><td><input type="text" name="child2dob" value="'.$ex1['child2dob'].'" autocomplete="off" /></td></tr>





<tr><td>Basic </td><td style="padding:0 7px;">:</td><td><input type="text" name="basic" value="'.$ex1['basic'].'" autocomplete="off" class="basic" /></td>



<td></td><td>Service Weightage </td><td style="padding:0 7px;">:</td><td><input type="text" name="serviceweightage" value="'.$ex1['serviceweightage'].'" autocomplete="off" class="serviceweightage" /></td></tr>





<tr><td>HRA </td><td style="padding:0 7px;">:</td><td><input type="text" name="hra" value="'.$ex1['hra'].'" autocomplete="off" class="hra" /></td>



<td></td><td>CCA</td><td style="padding:0 7px;">:</td><td><input type="text" name="cca" value="'.$ex1['cca'].'" class="cca" /></td></tr>





<tr><td>Gross </td><td style="padding:0 7px;">:</td><td><input type="text" name="gross" value="'.$ex1['gross'].'" autocomplete="off" class="gross" /></td>



<td></td><td>Description</td><td style="padding:0 7px;">:</td><td><textarea name="description" style="width:220px;">'.$ex1['description'].'</textarea></td></tr>





<tr><td>Username </td><td style="padding:0 7px;">:</td><td><input type="text" name="username" value="'.$ex1['username'].'" autocomplete="off" /></td>



<td></td><td></td><td style="padding:0 7px;"></td><td></td></tr>





</table>



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



</form>';



}



}



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>

						Values Edited Successfully.

				  </div>';				  

		 }

		 if($status=='4')

		 {

			 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 alrady exist.

				  </div>';				  

		 }

		 if($status=='6')

		 {

			 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>

						Password changed successfully.

				  </div>';				  

		 }

		 if($status=='7')

		 {

			 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>

						Values Deleted Successfully.

				  </div>';				  

		 }

		 if($status=='11')

		 {

			 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>

						Values updated successfully.

				  </div>';

		 }

		 if($status=='12')

		 {

			 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>

						Values not updated. please try again.

				  </div>';

		 }

	}





echo'<table style="width:99%; margin:11px auto 10px auto;">

                                        

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

                                        <a href="employee.php"><button class="btn btn-minier btn-info">+ Add Employee</button></a>

                                        </td>

                                        

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

                                        

                                        <td style="width:30%;">

                                        

                                        </td>

                                        

                                        </tr>

                                        

                                        </table>';



	echo"<table id='dynamic-table' class='table table-striped table-bordered table-hover'>



	<thead><th width='15%'>Name</th><th width='15%'>Address</th>

	<th width='15%'>Contact</th><th width='15%'>Department</th><th width='15%'>Designation</th>

	<th style='width:13%;'>Edit</th></thead>";



	$getsite3="select * from employee order by name asc";

	$getsite4=mysql_query($getsite3) or die("Could not get");

	$sno=0;

	while($getsite5=mysql_fetch_array($getsite4))

	{

		$sno=$sno+1;

		

		$dept=mysql_query("select * from department where ID='$getsite5[department]'");

		$dept1=mysql_fetch_array($dept);

		

		$desig=mysql_query("select * from employee_designation where ID='$getsite5[designation]'");

		$desig1=mysql_fetch_array($desig);

		

		$depc=mysql_query("select * from department where ID='$getsite5[department]'");

		$depc1=mysql_fetch_array($depc);

		

		echo"<tr><td>".$getsite5['name']."</td><td>".$getsite5['permanentaddress']."</td>

		<td>".$getsite5['contactno']."</td><td>".$dept1['department']."</td><td>".$desig1['designation']."</td><td>

		

														<div class='hidden-sm hidden-xs btn-group'>";

																

															if($gtp1['type']=='admin')

															{

															echo"<a href='viewemployee.php?id=".$getsite5['ID']."' title='Edit'>

																<i class='ace-icon fa fa-pencil bigger-100 green'></i></a> &nbsp;

																

															<a href='del.php?id=".$getsite5['ID']."&desc=employee' title='Delete'>

																<i class='ace-icon fa fa-trash-o bigger-100 grey'></i></a>";

																

															if($getsite5['status']=='')

															{

															echo" &nbsp; <a href='resign.php?id=".$getsite5['ID']."' title='Edit'>

																<img src='assets/images/w.png' width='11' height='11' /></a>";

															}

															

															echo" &nbsp;<a href='changepass1.php?id=".$getsite5['ID']."' title='Delete'>

																Pass</a>



																&nbsp;<a href='menu_control.php?user=".$getsite5['ID']."' title='Delete'>

																Menu</a>";

															

															if($depc1['crm']=='1')

															{

																

																echo" &nbsp; <a href='customerreallocate.php?id=".$getsite5['ID']."' title='Reallocate'>RA</a>";

																

															}

															

															}

															

														 echo"</div>

		</td></tr>";



		}



		echo "</table>";



	}



?>









										<!-- PAGE CONTENT ENDS -->

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

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

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

						</div>

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





<?php

include 'bottom.php';

}

else

{



 header("location:login.php");

}

ob_flush();



?>