<? include("si_confi.php"); ?>
<? include("ad_head.php"); ?>

  <div class="container">
  <? include("mn_option.php");?>

<?
if(isset($_REQUEST['submit_emp']))
{
	$emp_id=$_REQUEST['emp_id'];
	$name=$_REQUEST['name'];
	$department=$_REQUEST['department'];
	$work_emailid=$_REQUEST['work_emailid'];
	$email_password=$_REQUEST['email_password'];
	$personal_emailid=$_REQUEST['personal_emailid'];
	$mobileno=$_REQUEST['mobileno'];
	$second_mobileno=$_REQUEST['second_mobileno'];
	$dob=$_REQUEST['dob'];
	$doj=$_REQUEST['doj'];
	$esi_no=$_REQUEST['esi_no'];
	$pf_no=$_REQUEST['pf_no'];
	$pan_no=$_REQUEST['pan_no'];
	$passport_no=$_REQUEST['passport_no'];
	$address=$_REQUEST['address'];
	$username=$_REQUEST['username'];
	$password=$_REQUEST['password'];
	
	//$cur_date=date("Y-m-d");
	//$cur_time=date("g:i a");
	
	$filen=$_FILES['filen']['name'];
	$select_macid=mysql_query("select max(id) AS ID from `employee_mng`");
	$get_maxid=mysql_fetch_array($select_macid);
	$maxidd=$get_maxid['ID']+1;
	$upload_directory="emp_certificate/";
	$filenamee="$upload_directory$maxidd$filen";
	move_uploaded_file($_FILES['filen']['tmp_name'],$filenamee);
	$advance=$_REQUEST['advance'];
	
	
	$select_count_emp_id=mysql_query("select count(*) as num from `employee_mng` where `emp_id`='$emp_id'");
	$fetch_count_empid=mysql_fetch_array($select_count_emp_id);
	if($fetch_count_empid['num']==0)
	{
	
	$insert_employeee_details=mysql_query("insert into `employee_mng` (`emp_id`,`name`,`department`,`work_emailid`,`email_password`,`personal_emailid`,`mobileno`,`second_mobileno`,`dob`,`doj`,`esi_no`,`pf_no`,`pan_no`,`passport_no`,`address`,`username`,`password`,`photo`) values ('$emp_id','$name','$department','$work_emailid','$email_password','$personal_emailid','$mobileno','$second_mobileno','$dob','$doj','$esi_no','$pf_no','$pan_no','$passport_no','$address','$username','$password','$filenamee')");
	
	
	 $daset=date_default_timezone_set('Asia/Kolkata');
	 $mnth=date('F');
	 $crddate=date('Y-m-d');
	 $year=date('Y');
	$insert_employeee_details=mysql_query("insert into `advance` (`empid`,`name`,`amount`,`advance`,`month`,`year`,`date`,`status`)values('$emp_id','$name','$advance','$advance','$mnth','$year','$crddate','1')");

	
	
	?><script>window.location="ad_empploe.php?ad=suc";</script><?
} else {
	
	?><script>window.location="ad_empploe.php?al=exist";</script><?
	
}



}

 ?>


<link type="text/css" href="calender/jquery.datepick.css" rel="stylesheet">
<script type="text/javascript" src="calender/jquery.min.js"></script>
<script type="text/javascript" src="calender/jquery.datepick.js"></script>
<script type="text/javascript">
$nocal=$.noConflict();
$nocal(function() {
	$nocal('#popupDatepicker').datepick();
	$nocal('#inlineDatepicker').datepick({onSelect: showDate});
});
function showDate(date) {
	alert('The date chosen is ' + date);
}
</script>
<script type="text/javascript">
$nocal(function() {
	$nocal('#popupDatepicker2').datepick();
	$nocal('#inlineDatepicker2').datepick({onSelect: showDate});
});
function showDate(date) {
	alert('The date chosen is ' + date);
}
</script>


<? if($_REQUEST['ad']=='suc'){ ?>
  <div class="success" style="width:92%;margin:0 auto;margin-top:9px;">One Employee Details Added successfully.</div><? } ?>
  
  
  <? if($_REQUEST['al']=='exist'){ ?>
  <div class="warning" style="width:92%;margin:0 auto;margin-top:9px;">This Employee Details Already Exists.</div><? } ?>
  
  

   <div style="border:groove;margin-top:10px;border-width:thin;padding:20px;border-radius:4px;border-color:#cccccc;box-shadow: 10px 9px 90px #000;">
   <h2>Add Employee Details</h2>
  <form method="post" enctype="multipart/form-data" id="add_employee" onSubmit="return confirm('Are you sure you want to confirm add this Employee Details ?');" autocomplete="off" action="<?php echo $_SERVER['PHP_SELF']; ?>">
        <script type="text/javascript" src="prototype.js"></script>
        <script type="text/javascript" src="validation.js"></script>
        <table cellpadding="9" id="add_employee">
        <? $select_emp_id=mysql_query("select max(`id`) as ID from `employee_mng`");
		$efetch_emp_id=mysql_fetch_array($select_emp_id);
		$maxempid=$efetch_emp_id[0]+1;
		$maxempid123="EMP".$maxempid.""; ?>
        <tr>
        <td valign="top">Employee ID</td>
        <td><input type="text" value="<? echo $maxempid123; ?>" readonly style="background:#CCC;" name="emp_id" class="required" placeholder="Employee ID"></td>
        </tr>
         <tr>
        <td valign="top">Employee Name</td>
        <td><input type="text" name="name" class="required" placeholder="Employee Name"></td>
        </tr>
         <tr>
        <td valign="top">Department<span style="font-size:11px;font-weight:bold;color:#03C;"></span></td>
        <td>
         <select name="department" class="validate-selection" style="width:360px; height:30px;" >
        
        <option value="" hidden="">Select</option>
        <? $seleect_employee3=mysql_query("select * from `department`");
		while($fetch_employee3=mysql_fetch_array($seleect_employee3)){ ?>
        <option value="<? echo $fetch_employee3['department']; ?>"><? echo ucwords($fetch_employee3['department']); ?></option>
		<? } ?>
        </select>
        
       <!-- <input type="text" name="department" placeholder="Name of Department (Optional) ">--></td>
        </tr>
         <tr>
        <td valign="top">Email ID<span style="font-size:11px;font-weight:bold;color:#930;">&nbsp;(Office)</span></td>
        <td>
        
        
        
        <input type="text" name="work_emailid" class="required validate-email" placeholder="Office Email ID"></td>
        </tr>
         <tr>
        <td valign="top">Password</td>
        <td><input type="text" name="email_password" class="required" placeholder="Office Email Password"></td>
        </tr>
         <tr>
        <td valign="top">Personal Email ID</td>
        <td><input type="text" name="personal_emailid" class="required validate-email" placeholder="Employee Personal Email ID"></td>
        </tr>
         <tr>
        <td valign="top">Primary Mobile No</td>
        <td><input type="text" name="mobileno" class="required" maxlength="12" placeholder="Primary Mobile No"></td>
        </tr>
         <tr>
        <td valign="top">Secondary Mobile No <span style="font-size:11px;font-weight:bold;color:#03C;">(Optional)</span></td>
        <td><input type="text" name="second_mobileno" maxlength="12" placeholder="Secondary Mobile No (Optional)"></td>
        </tr>
         <tr>
        <td valign="top">Date of Birth</td>
        <td><input type="text" name="dob" class="required" id="popupDatepicker" value="<? echo date("Y-m-d"); ?>"></td>
        </tr>
         <tr>
        <td valign="top">Date of Joining</td>
        <td><input type="text" name="doj" class="required" id="popupDatepicker2" value="<? echo date("Y-m-d"); ?>"></td>
        </tr>
         <tr>
        <td valign="top">ESI No</td>
        <td><input type="text" name="esi_no" class="required" placeholder="ESI No"></td>
        </tr>
         <tr>
        <td valign="top">PF No</td>
        <td><input type="text" name="pf_no" class="required" placeholder="PF No"></td>
        </tr>
         <tr>
        <td valign="top">PAN No<span style="font-size:11px;font-weight:bold;color:#03C;">&nbsp;(Optional)</span></td>
        <td><input type="text" name="pan_no" placeholder="PAN No"></td>
        </tr>
        <tr>
        <td valign="top">Passport No<span style="font-size:11px;font-weight:bold;color:#03C;">&nbsp;(Optional)</span></td>
        <td><input type="text" name="passport_no" placeholder="Passport No"></td>
        </tr>
        <tr>
        <td valign="top">Address</td>
        <td><textarea class="required" name="address" placeholder="Home Address"></textarea></td>
        </tr>
        
        
        <!-- <tr>
        <td valign="top">Username</td>
        <td><input type="text" name="username" class="required" placeholder="Username"></td>
        </tr>
        <tr>
        <td valign="top">Password</td>
        <td><input type="password" name="password" class="required" placeholder="Password"></td>
        </tr>-->
        
        <tr>
        <td valign="top">Photo</td>
        <td><input type="file" name="filen" class="required"></td>
        </tr>

       <td valign="top">Advance Amount<span style="font-size:11px;font-weight:bold;color:#03C;"></span></td>
        <td><input type="text" name="advance" placeholder="Advance Amount"></td>
        </tr>


        <tr>
        <td valign="top">&nbsp;</td>
        <td><input type="submit" name="submit_emp"></td>
        </tr>
        </table>
			
		</form>
         <script type="text/javascript">
						function formCallback(result, form) 
						{window.status = "valiation callback for form '" + form.id + "': result = " + result;}
						var valid = new Validation('add_employee', {immediate : true, onFormValidate : formCallback});
					</script>
  
  
  </div>
  
 
</div><!-- container -->
  </body>
</html>
