<?
session_start();
include("test.php");
include("opendb.php");
include("includes/function.php");
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='ind.php' </script>";
  return;
}
$us=mysqli_query($db,"select level from bruser where username='$user'")or die(mysqli_error($db));
$r=mysqli_fetch_row($us);
$user_level=$r[0];
   
?>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Xpress</title>
    <script type="text/javascript" src="scripts/jquery-latest.js"></script>
	<link type="text/css" href="includes/style1.css" rel="stylesheet" />
      <link type="text/css" href="css/form.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        });        
    </script>
	<script type="text/javascript">
    $(document).ready(function() {
        var cont_left = $("#container").position().left;
        $("a img").hover(function() {
            // hover in
            //$(this).parent().parent().css("z-index", 1);
            $(this).animate({
               height: "110",
               width: "110",
              
            }, "fast");
        }, function() {
            // hover out
         //   $(this).parent().parent().css("z-index", 0);
            $(this).animate({
                height: "80",
                width: "80",
                
            }, "fast");
        });
        
        $(".img").each(function(index) {
            var left = (index * 160) + cont_left;
            $(this).css("left", left + "px");
        });
    });




    </script>



<script src="datetimepicker_css1.js"></script>

<!-- js code below for active enter with textfield-->


<script type="text/javascript">

/***********************************************
* Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
                
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      

</script>


<style>
.cont
	{


       background-color:#3b5998;

	//background:url(images/bg-inner.jpg) #e9e0c3 repeat-x;
  	width: 100%;position: absolute ;
	height:99%;
    	/* Optional - just for DIV)*/
    	//border: solid 1px #000000;
	-moz-box-shadow: 0px 5px 5px #888;
	-webkit-box-shadow: 0px 5px 5px #888;
	box-shadow: 0px 5px 10px #888;
    
	}



.pop-up2 {position:absolute; top:10px; left:50px;padding-left:180px;}
.pop-up2:target {position:static; left:0;}

.popBox2 {
  background:#ffffff;

 
  width:75%;
  min-height:100%;



   z-index:1;

  border:1px solid #3a3a3a;


  -moz-border-radius:12px;
  border-radius:12px;
  -webkit-box-shadow:2px 2px 4px #3a3a3a;
  -moz-box-shadow:2px 2px 4px #3a3a3a;
  box-shadow:2px 2px 4px #3a3a3a;
  opacity:0;
 -webkit-transition: opacity 0.5s ease-in-out;
  -moz-transition: opacity 0.5s ease-in-out;
  -o-transition: opacity 0.5s ease-in-out;
  -ms-transition: opacity 0.5s ease-in-out;
  transition: opacity 0.5s ease-in-out;  
}
:target .popBox2 {position:fixed; opacity:1;}

.popBox2:hover {box-shadow:3px 3px 6px #5a5a5a;}



.lightbox {display:none; text-indent:0em; background:#000; opacity:0.0; width:100%; height:100%; position:fixed; top:0; left:0; bottom:0; right:0;}
:target .lightbox {display:block}


.popScroll2 {position:absolute; top:9%; left:3%; right:3%; bottom:9%; overflow-y:auto; *overflow-y:scroll; padding-right:0.5em}



.pop-up211 {position:absolute; top:10px; left:50px;padding-left:180px;}
.pop-up211:target {position:static; left:0;}

.popBox211 {
  background:#ffffff;

 
  width:75%;
  min-height:100%;



   z-index:1;

  border:1px solid #3a3a3a;


  -moz-border-radius:12px;
  border-radius:12px;
  -webkit-box-shadow:2px 2px 4px #3a3a3a;
  -moz-box-shadow:2px 2px 4px #3a3a3a;
  box-shadow:2px 2px 4px #3a3a3a;
  opacity:0;
 -webkit-transition: opacity 0.5s ease-in-out;
  -moz-transition: opacity 0.5s ease-in-out;
  -o-transition: opacity 0.5s ease-in-out;
  -ms-transition: opacity 0.5s ease-in-out;
  transition: opacity 0.5s ease-in-out;  
}
:target .popBox211 {position:fixed; opacity:1;}

.popBox211:hover {box-shadow:3px 3px 6px #5a5a5a;}



.lightbox11 {display:none; text-indent:0em; background:#000; opacity:0.0; width:100%; height:100%; position:fixed; top:0; left:0; bottom:0; right:0;}
:target .lightbox11 {display:block}

.popScroll211 {position:absolute; top:9%; left:3%; right:3%; bottom:9%; overflow-y:auto; *overflow-y:scroll; padding-right:0.5em}
</style>
<style>
th{background-color:steelblue;color:white}
</style>
<script src="css3-dropdown-menu-demo_files/bsa.js" async="" type="text/javascript"></script><script async="async" src="css3-dropdown-menu-demo_files/s_a5f348233fceef06ba365ab392938d10.js" id="_bsap_js_a5f348233fceef06ba365ab392938d10" type="text/javascript"></script><style id="bsa_css" type="text/css">.one{position:relative}.one .bsa_it_ad{display:block;padding:15px;border:1px solid #e1e1e1;background:#f9f9f9;font-family:helvetica,arial,sans-serif;line-height:100%;position:relative}.one .bsa_it_ad a{text-decoration:none}.one .bsa_it_ad a:hover{text-decoration:none}.one .bsa_it_ad .bsa_it_t{display:block;font-size:12px;font-weight:bold;color:#212121;line-height:125%;padding:0 0 5px 0}.one .bsa_it_ad .bsa_it_d{display:block;font-size:11px;color:#434343;font-size:12px;line-height:135%}.one .bsa_it_ad .bsa_it_i{float:left;margin:0 15px 10px 0}.one .bsa_it_p{display:block;text-align:right;position:absolute;bottom:10px;right:15px}.one .bsa_it_p a{font-size:10px;color:#666;text-decoration:none}.one .bsa_it_ad .bsa_it_p a:hover{font-style:italic}</style></head>
<body bgcolor="#0033FF">
<div class='cont'>

<?php include('includes/top.php'); ?>
<br>
<table class="container"><tr><td>


	<link type="text/css" href="css/redmond/jquery-ui-1.8.16.custom.css" rel="stylesheet" />	
		<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
		<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript">
$(function(){

$(".regno").live("keydown.autocomplete",function(){

$regno = $(this);

$row = $regno.parent().parent();
$(this).autocomplete({
		source: function( request, response ) {

		$.ajax({
			url: "search1.php",
			dataType: "json",
			data: "key="+$regno.val(),
			success: function( data ) {
				response( $.map( data, function( item ) {
					return {
						label: item.regno+' | '+  item.chasisno + '| '+ item.make +'|'+item.model    ,
						value: item.regno,
						name:item.chasisno,
						qty:item.make,
						price:item.model,
						


					}
				}));
			}
		});
	}
	
,
	minLength: 2,
	select: function( event, ui ) {

	$row.find('.chasisno').val(ui.item.name);
	$row.find('.make').val(ui.item.qty);
	$row.find('.model').val(ui.item.price);
	
	
	/*log( ui.item ?
	"Selected: " + ui.item.label :
	"Nothing selected, input was " + this.value);
	*/
	 }
	
	});

					
});







});
</script>
<STYLE>

#popup {

  
position: fixed; top: 50%; left: 60%; width: 200px; height: 100px; margin-left: -300px; margin-top: -200px;
  display:none;
}
</STYLE>
<SCRIPT>

function done() { 
    document.getElementById("popup").style.display = "none";
    var pswd= document.getElementById("pass").value;
     var empno= document.getElementById("empno").value;
if (pswd=='user123') {
 	
             if (confirm('do you want to delete '+empno+' ?'))
  	 	document.location='delemp.php?empno='+empno;
  	 }
	else{
 		alert('invalid password'); 
 		
	}
  
}
function showPopup(empno) {
     document.getElementById("popup").style.display = "block";
     document.getElementById("empno").value=empno;

}

</SCRIPT>




<?php echo "<body >\n"; ?>

<link href="css1/xp.css" type="text/css" rel="stylesheet" media="print,screen"  />


<?

if($sv)
{

$dob1=explode('-',$dob);
$dob=$dob1[2].'-'.$dob1[1].'-'.$dob1[0];
$dor1=explode('-',$dor);
$dor=$dor1[2].'-'.$dor1[1].'-'.$dor1[0];

$doj1=explode('-',$doj);
$doj=$doj1[2].'-'.$doj1[1].'-'.$doj1[0];

$visaexpdate1=explode('-',$visaexpdate);
$visaexpdate=$visaexpdate1[2].'-'.$visaexpdate1[1].'-'.$visaexpdate1[0];


$passportexpdate1=explode('-',$passportexpdate);
$passportexpdate=$passportexpdate1[2].'-'.$passportexpdate1[1].'-'.$passportexpdate1[0];


 $sql="insert into empmaster(empcode,empname,dob,sex,dept,design,doj,doret,iceaddr1,mob,icephone1,emp_status,empid,remark,brcode)  values('$empno','$name','$dob','$sex','$dep','$designation','$doj','$dor','$address','$mobile',
'$telephone','$status','$idno','$remarks','$branch')";
 mysqli_query($db,$sql) or die(mysqli_error($db));


}


?>
<title>XCS</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="scripts/jquery-latest.js"></script>
<body background="back_ground.jpg">



<div id="popup">
<table height='100%' width='100%' class='report'>
     <tr> <th>Enter Password:</th></tr>
    <tr> <td><input id="pass" type="password"/></td></tr>
    <tr> <th><input id="empno" type="hidden"/>
  <button onclick="done()">OK</button> </th></tr>   </table>
</div>



<div id="pop211" class="pop-up211" >
  <div class="popBox211">

    <div class="popScroll211" id='popScroll211' >

    </div>
 
  </div>


  <a href="#links11" class="lightbox11"></a>
</div>


<div id="pop2" class="pop-up2" >
  <div class="popBox2">

    <div class="popScroll2" id='popScroll2' >

    </div>
 
  </div>


  <a href="#links" class="lightbox"></a>
</div>


<form name='f1' action='<?print $PHP_SELF?>' onSubmit="return valid()" method='post'> 

<br>
<table class="container" bgcolor="#0033FF"><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;">  &nbsp;&nbsp;Master  >> Employee Master</font>
<br>
<center>
<body bgcolor="#0033FF">
<form action="" method="post">
<table width="100%" border="1" cellpadding="1" cellspacing="1" align="center" bgcolor="#0033FF">
  <tr>
    <th colspan="7" bgcolor="#666"><h3 style="color:#fff"><strong>Employee Master</strong></h3></th>
    </tr>
  <tr>
    <td width="135">Employee Number</td>

<?

 $jcres=mysqli_query($db,"select max(empid) from empmaster where brcode='$brcode'");
 $jcrow=mysqli_fetch_row($jcres);
 if($jcrow[0]<=0)
   $empno=1;
 else
  $empno=($jcrow[0]+1);
?>

    <td colspan="4"><input name="empno"  type="text" id="empno"    size="40" value='<?print $empno?>'  onkeypress="return handleEnter(this, event)"/></td>
    <td width="164">Date of Birth</td>


    <td width="327"><img src="img/cal.gif" onclick="javascript:NewCssCal ('dob','ddMMyyyy','dropdown')"  style="cursor:pointer"/>
<input type="Text" id="dob" name = 'dob' maxlength="25" size="37" readonly/></td>
   
   
  </tr>
  <tr>
    <td >Entry Date</td>
  <td><input type="Text" id="entrydate" name ='entrydate' maxlength="25" size="37" readonly/>
<img src="img/cal.gif" onclick="javascript:NewCssCal ('entrydate','ddMMyyyy','dropdown')"  style="cursor:pointer"/></td><td></td><td></td><td></td>
    <td width="164" >Sex</td>
    <td width="327"><select name="sex" id="instype"  style="width:275px;" onkeypress="return handleEnter(this, event)">
      <option>--SELECT--</option>
      <option>Male</option>
      <option>Female</option>
  

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




  <tr>
    <td width="164"  >Name</td>
    <td colspan="4" width="327"><input name="name" type="text"   id="name"   size="40"  onkeypress="return handleEnter(this, event)" class="regno"/></td>
<td >Telephone </td><td colspan="4"><input name="telephone" type="text" id="telephone" size="40" onkeypress="return handleEnter(this, event)"/></td>
  <tr>

 <tr>
    <td >Address</td>
    <td colspan="4"><textarea name="address" cols="41" id="textarea"></textarea></td>
    <td width="164">Mobile</td>
    <td width="327"><input name="mobile" type="text" id="mobtile" size="40"  onkeypress="return handleEnter(this, event)"/></td>
  </tr>

  <tr>
<td  width="164" >Department</td>
    <td colspan="4" width="327"><select name="dep" id="dep"  style="width:275px;" onkeypress="return handleEnter(this, event)">
      <option>--SELECT--</option>
      <option>Service</option>
      <option> Denting / Painting</option>
      <option> Administration</option>
  

    </select></td>
 <td >Branch </td><td colspan="4"><select name="branch"  id="branch"  style="width:275px;" onkeypress="return handleEnter(this, event)"/>
<?
$sql=mysqli_query($db,"select brname,brcode from branch");
while($sql1=mysqli_fetch_array($sql))
{
 print "\n<option value='$sql1[1]'>$sql1[0]</option>";
 }
?>
</td>
 
  </tr>
 

<tr>
    <td >Designation</td>
    <td colspan="4"><select name='designation'  style="width:275px;" onkeypress="return handleEnter(this, event)">
<option>--SELECT--</option>
<?

$re=mysqli_query($db,"select * from desigmast order by divname");
while($row=mysqli_fetch_array($re))
{
 print "\n<option value='$row[divname]'>$row[divname]</option>";
 

}
?>
</select> </td>
    
<td  width="164" >Status</td>
    <td colspan="4" width="327"><select name="status" id="status" style="width:275px;" onkeypress="return handleEnter(this, event)">
      <option>--SELECT--</option>
      <option>Releaved</option>
      <option> Working</option>
      <option> On-Leave</option>
  

    </select></td>
    </tr>
<tr>
    <td >Joining Date</td>
    <td colspan="4"><input type="Text" id="doj" name ='doj' maxlength="25" size="37" readonly/>
<img src="img/cal.gif" onclick="javascript:NewCssCal ('doj','ddMMyyyy','dropdown')"  style="cursor:pointer"/></td>
    
<td width="164">Releaved on</td>
    <td width="327"><img src="img/cal.gif" onclick="javascript:NewCssCal ('dor','ddMMyyyy','dropdown')"  style="cursor:pointer"/>
<input type="Text" id="dor" name ='dor' maxlength="25" size="37" readonly/></td>
 
    </tr>
<tr>
    <td >Pay Per Day</td>
    <td colspan="4"><input name="payperday" type="text" id="payperday" size="40" onkeypress="return handleEnter(this, event)"/></td>
    
<td width="164">Nationality</td>
    <td width="327"><input name="nationality" type="text" id="others" size="40" onkeypress="return handleEnter(this, event)"/></td>
 
    </tr>
<tr>
    <td >Id no</td>
    <td colspan="4"><input name="idno" type="text" id="idno" size="40" onkeypress="return handleEnter(this, event)"/></td>
    
<td width="164">Passport No </td>
    <td width="327"><input name="passportno" type="text" id="passportno"  size="40" onkeypress="return handleEnter(this, event)"/></td>
 
    </tr>

<tr>
    <td >Visa Expiry date</td>
    <td colspan="4"><input type="Text" id="visaexpdate" name ='visaexpdate' maxlength="25" size="37" readonly/>
<img src="img/cal.gif" onclick="javascript:NewCssCal ('visaexpdate','ddMMyyyy','dropdown')"  style="cursor:pointer"/></td>
    
<td width="164">Passport Expiry date </td>
    <td width="327"><img src="img/cal.gif" onclick="javascript:NewCssCal ('passportexpdate','ddMMyyyy','dropdown')"  style="cursor:pointer"/>
<input type="Text" id="passportexpdate" name ='passportexpdate' maxlength="25" size="37" readonly/></td>
 
    </tr>


  <tr>
    <td >Remarks</td>
    <td colspan="6" ><textarea name="remarks"  cols="41" id="remarks"></textarea></td>
    </tr>




<tr><th colspan='7'><input type=submit value='Save' name='sv'></th></tr>

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

<br><br>

<?
$result=mysqli_query($db,"select empid,empname,dept,design,doj,mob from empmaster where brcode = '$brcode' and doret='0000-00-00' order by empname asc");
//echo "select * from empprofile where brcode='$brcode' order by EmpNo";
print "<table cellspacing=1 cellpadding=5 class='report'>";
?>
<tr>

<input type='hidden' value='<?print $row[0]?>' name='empno' id='empno'>
    <th><strong>Emp.No</strong></th>

    <th  ><strong>Employee Name</strong></th>
    
    <th ><strong>Department </strong></th>
    <th><strong>Designation</strong></th>
    <th ><strong>Joining Date</strong></th>
    <th ><strong>Mobile</strong></th>
    <th colspan='4'><strong>Action</strong></th>
  </tr>
<?
$i=1;
while($row=mysqli_fetch_row($result))
{
?>

  
   <tr>
    <td ><?print $row[0]?></td>
    <td ><?print $row[1]?></td>
  
    <td ><?print $row[2]?></td>
    <td ><?print $row[3]?></td>
    <td ><?print $row[4]?></td>
    
    <td ><?print $row[5]?></td>
    <td ><a href="#pop2" id="links" onclick="showdet('<?print $row[0]; ?>')" style="text-decoration:none;"><input value="View" type="submit" ></a></td>
    <td ><a href="#pop211" id="links11" onclick="editfun('<?print $row[0]; ?>')" style="text-decoration:none;"><input value="Edit" type="submit" ></a></td>
    <td ><input type='button' name='print' value='Print' onclick="print_preview('<?print $row[0]; ?>')"></td>
    <td ><input type=button value='Del' name='del' onclick="showPopup('<? print $row[0]; ?>')"></td>
  </tr>
<? 
}
?>



</body>
</html>
<script>

function showdet(empno)
{

document.getElementById("popScroll2").innerHTML="Loading...";

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 && xmlhttp.status==200)
    {
    document.getElementById("popScroll2").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","view_empdet.php?empno="+empno, true);
xmlhttp.send();
}


function editfun(empno)
{

document.getElementById("popScroll211").innerHTML="Loading...";

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 && xmlhttp.status==200)
    {
    document.getElementById("popScroll211").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","edit_empdet.php?empno="+empno, true);
xmlhttp.send();
}




function print_preview(empno){
   window.open('print_empdet.php?empno='+empno);
}







function valid()
{


if(document.f1.passportno.value.length<=0)
 {
   
alert('Enter PassportNo');
document.f1.regno.focus();
return false; 
}


}
</script>
