<? include("Ms_@dmin/si_confi.php"); ?>
<? include("Ms_@dmin/ad_head.php"); ?>

  <div class="container">
  
<? include("mn_option.php");
  date_default_timezone_set("Asia/Kolkata");
?>
<?
if(isset($_REQUEST['submit_emp']))
{  
     $salary=$_REQUEST['salary'];
	 $emid=$_REQUEST['username'];
	 
$selcmadv33=mysql_query("select * from employee_mng where emp_id='$emid'");
$fecg45=mysql_fetch_array($selcmadv33);
$balance=$fecg45['balance'];
$emname=$fecg45['name'];
		
	 $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`,`req`,`status`)values('$emid','$emname','$salary','$salary','$mnth','$year','$crddate','1','0')");


if($salary>=$balance)
{
$selcmadv33=mysql_query("update `employee_mng` set `balance`='0' where emp_id='$emid'");
}
else
{
$bal=$balance-$salary;
$selcmadv33=mysql_query("update `employee_mng` set `balance`='$bal' where emp_id='$emid'");	
}
?>
<script>window.location="ad_advance.php?ad=suc";</script>
<?
}
?>
<? if($_REQUEST['ad']=='suc'){ ?>
<div class="success" style="width:92%;margin:0 auto;margin-top:9px;">Advance details added successfully...</div><? } ?>

<link type="text/css" href="Ms_@dmin/calender/jquery.datepick.css" rel="stylesheet">
<script type="text/javascript" src="Ms_@dmin/calender/jquery.min.js"></script>
<script type="text/javascript" src="Ms_@dmin/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>

  <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 Advance Details</h2>
 
   <form method="post" enctype="multipart/form-data" name="form" id="add_certi" autocomplete="off" action="<?php echo $_SERVER['Ms_@dmin/PHP_SELF']; ?>">
   <script type="text/javascript" src="Ms_@dmin/prototype.js"></script>
   <script type="text/javascript" src="Ms_@dmin/validation.js"></script>
        
        <table cellpadding="9" id="add_certi">
        <tr>
        <td valign="top">Employee ID</td>
        <td>
        <input type="text" name="username" class="required"  value="<? echo $vel_empl_id; ?>" readonly  >
       
        </td>  
        </tr>
        <tr>
        <td valign="top">Advance</td>
        <td><input type="text" name="salary" class="required" ></td>
        </tr>
        <!-- <tr>
        <td valign="top">Time</td>
        <td><input type="text" name="time_allocation" value="<? echo date("g:i a"); ?>" readonly style="background:#CCC;" class="required"></td>
        </tr>-->
        <td valign="top">&nbsp;</td>
        <td><input type="submit" name="submit_emp" onClick="return confirm('Are you sure you want to confirm add Details ?');"></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_certi', {immediate : true, onFormValidate : formCallback});
					</script>
  </div>
</div><!-- container -->
  </body>
</html>