Location: PHPKode > projects > E-hris > layoff.php
<?
session_start();
/*
   * e-hris (Electronic-Human Resource Information System v 1.3.0 Alpha) Is an open source human resource information management system
   * developed to automate all aspects of human resource management, with the dual benefits of reducing the workload of the HR department as well as increasing the efficiency of the department by standardising
   * HR processes for any organization from small-enterprises to large scale organizations.
   * Copyright (C) 2008  David Muturi

   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.

   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.

   * You should have received a copy of the GNU General Public License
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
?>
<!DOCTYPE html
	PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="description" content="Electronic Human Resource Information Management System">


    <link rel="stylesheet" href="js/example.css" TYPE="text/css" MEDIA="screen">
	<link rel="stylesheet" type="text/css" href="css/employees.css" />
	<link rel="stylesheet" type="text/css" href="css/main.css"/>
    <link href="css/text.css" rel="stylesheet" type="text/css"/>
	<title>E-hris Electronic Human Resource information system</title>
<style type="text/css">
<!--
.copysmall {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #3B3B3B; font-size: 12px; margin-top:3px; margin-bottom:11px; margin-left:0px; margin-right:0px }
.copy {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #3B3B3B; font-size: 13px; margin-top:3px; margin-bottom:11px; margin-left:0px; margin-right:0px }
.copymed {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #3B3B3B; font-size: 14px; margin-top:3px; margin-bottom:11px; margin-left:0px; margin-right:0px }
.copylarge {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #3B3B3B; font-size: 15px; margin-top:3px; margin-bottom:11px; margin-left:0px; margin-right:0px }
.copymedred {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #FF0000; font-size: 14px; margin-top:3px; margin-bottom:11px; margin-left:0px; margin-right:0px }
.copyheader {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #2778CB; font-size: 14px; margin-top:3px; margin-bottom:0px; margin-left:0px; margin-right:0px }
.copyheaderwhite {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #FFFFFF; font-size: 14px; margin-top:3px; margin-bottom:0px; margin-left:0px; margin-right:0px }
.header7, h7 {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #2778CB; font-size: 15px; font-weight: bold }
.copysmalltitle {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #2778CB; font-size: 15px; font-weight: bold }
.copysubtitle {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #2778CB; font-size: 15px }
.copyfooter {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #000000; font-size: 13px }
.copydownload {  font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif; color: #3B3B3B; font-size: 13px }
.info   { color: black; background-color: transparent; font-weight: normal; }
  .warn   { color: rgb(120,0,0); background-color: transparent; font-weight: normal; }
  .error  { color: red; background-color: transparent; font-weight: bold }
-->
</style>

 <link rel="stylesheet" type="text/css" href="css/epoch_styles.css"/>
 <link rel="stylesheet" type="text/css" href="ajaxtabs/ajaxtabs.css" />
 
 <script type="text/javascript" src="css/epoch_classes.js"></script>
 <script type="text/javascript" src="js/formval.js"></script> 
 <script language="JavaScript" src="js/calendar1.js"></script>
<script type="text/javascript" src="js/tabber.js">
</script>
<style type="text/css">
<!--
.style5 {font-size: 14px}
.style6 {color: #000000}
-->
</style>
 <link rel="stylesheet" type="text/css" href="css/epoch_styles.css"/>
 <link rel="stylesheet" type="text/css" href="css/jqueryslidemenu.css" />
 <link rel="stylesheet" type="text/css" href="ajaxtabs/ajaxtabs.css" />


<!--[if lte IE 7]>
<style type="text/css">
html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/
</style>
<![endif]-->

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jqueryslidemenu.js"></script>
<script type="text/javascript" src="ajaxtabs/ajaxtabs.js">

/***********************************************
* Ajax Tabs Content script v2.2- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

</script>
</head>
<body bgcolor="#FFFFFF">
<? 
  include "includes/config.php";
	
  if (empty($_SESSION["username"]))
    die("<meta http-equiv='refresh' content='1;url=login.php'>");

  
  include "includes/functions.php";

  require_once "includes/db.php";
  
  $d = new dbC();
  $d->connect($db_host, $db_user, $db_pass, $db); 
  
  $username = $_SESSION["username"];
  $sqlstr="select * from hrusers  where username like '%".$username."%'";
  $data=$d->query($sqlstr);
  $row=$d->fetch_object($data);
  $fullname=$row->name; 
  $userid=$row->id;

 //check for contract expiry,leave due,retirement and alert.
  $sqlstr="select * from hrsettings order by id desc";
  $result =$d->query($sqlstr);
  $row=$d->fetch_object($result);
  
  $contract=$row->contract;
  $leave=$row->leave;
  $retirement=$row->retirement;
  $retage=$row->retage;
  
  if (!empty($contract))
  {
    $sqlstr="select count(memberno) as totalexp from prmember where (datediff(quitdate,now()) div 30) < $contract and (datediff(quitdate,now()) div 30) >= 0 and suspended=0 and empstatus_fk=7";
    $result=$d->query($sqlstr);
	$row=$d->fetch_object($result);
	
	if ($row->totalexp > 1)
	  $contexpmsg = "<b>There are $row->totalexp employees whose contracts are due to expire in $contract months time. <a href=\"contractexprpt.php\">Please click Here to view the list.</a></b>";
    else if ($row->totalexp == 1)
	  $contexpmsg = "<b>There is $row->totalexp employee whose contract is due to expire in $contract months time. <a href=\"contractexprpt.php\">Please click Here to view the record.</a></b>";
  }

  //retirement 
  if (!empty($retirement))
  {
    //get retirement age - retirement notification difference
	if (!empty($retage))
	  $agediff=$retage-$retirement;
	else
	  $agediff=55-$retirement;
	  
	//sql count  
	 $sqlstr="select count(memberno) as totalret from prmember where (datediff(now(),BirthDate) div 365) >= $agediff and suspended=0 and empstatus_fk=7";
	 $result=$d->query($sqlstr);
	 $row=$d->fetch_object($result);
  
     if ($row->totalret > 1)
	   $retmsg = "<b>There are $row->totalret employees who are due to retire in $retirement years time. <a href=\"retirerpt.php\">Please click Here to view the list.</a></b>";
	 else if ($row->totalret==1)
	   $retmsg = "<b>There is $row->totalret employee who is due to retire in $retirement years time. <a href=\"retirerpt.php\">Please click Here to view the list.</a></b>";
  } 
  
    
 if (hasaccess($d,1,$userid))
   $hasaccess=1;
  
 ?>


	<form name="form1" method="post" action="index.php">
	
	<table width="100%"  border="0">
      <tr  bgcolor="#F0F0F0">
        <td width="15%"><div align="right" class="style6">Search By
          </div>
        </td>
        <td>
          <select name="searchcrit" id="searchcrit">
            <option value="fname">Full Name</option>
            <option value="lname">Last Name</option>
            <option value="pnumber">Payroll Number</option>
           
            <option value="desig">designation</option>
            <option value="depart">Department</option>
            <option value="status">Status</option>
           
          </select>
        </td>
        <td><div align="right" class="style6">Search Value </div></td>
        <td><input type="text" name="searchval"></td>
        <td><input name="Search" type="submit" id="Search" <?  if (!empty($_POST["searchval"])) echo "value=\"Show All\""; else echo "value=\"Search\""; ?>></td>
      </tr>
    </table> 
	</form>  
	<?
	  if (!empty($contexpmsg))
	    echo $contexpmsg."<br>";
	  
	  if (!empty($retmsg))
	    echo $retmsg."<br>";
	  
	?>  
      <h1>&nbsp;</h1>
   </td>
  </tr>
 
	  <?
	   	
		
	    if (!empty($_POST["searchcrit"]))
		{
		  switch ($_POST["searchcrit"]) {
			case "fname":
   			   $sqlstr="select prmember.memberno,status,fullname,rowid,prmember.suspended,othernames,station,designation.designation,Dept,sex as gender,idnumber as national_idnum,nationality,countryname from prmember
               left join tbl_countries1 on tbl_countries1.id=prmember.nationality
               left join designation on designation.id=position_fk
			   left join tbl_empstatus on empstatus_fk=tbl_empstatus.id
               left join prdept on prdept.deptcode=prmember.dept where empstatus_fk=7 and fullname like '%".$_POST["searchval"]."%'";
			   break;
			case "lname":
			    $sqlstr="select prmember.memberno,status,fullname,rowid,prmember.suspended,othernames,station,designation.designation,Dept,sex as gender,idnumber as national_idnum,nationality,countryname from prmember
                left join tbl_countries1 on tbl_countries1.id=prmember.nationality
                left join designation on designation.id=position_fk
				left join tbl_empstatus on empstatus_fk=tbl_empstatus.id
                left join prdept on prdept.deptcode=prmember.dept where empstatus_fk=7 and lastname like '%".$_POST["searchval"]."%'";
			   break;
			case "pnumber":
			    $sqlstr="select prmember.memberno,status,fullname,rowid,prmember.suspended,othernames,station,designation.designation,Dept,sex as gender,idnumber as national_idnum,nationality,countryname from prmember
                left join tbl_countries1 on tbl_countries1.id=prmember.nationality
                left join designation on designation.id=position_fk
				left join tbl_empstatus on empstatus_fk=tbl_empstatus.id
                left join prdept on prdept.deptcode=prmember.dept where empstatus_fk=7 and memberno like '%".$_POST["searchval"]."%'";
			   break;
			case "idnum":
			   $sqlstr="select prmember.memberno,status,fullname,rowid,prmember.suspended,othernames,station,designation.designation,Dept,sex as gender,idnumber as national_idnum,nationality,countryname from prmember
               left join tbl_countries1 on tbl_countries1.id=prmember.nationality
               left join designation on designation.id=position_fk
			   left join tbl_empstatus on empstatus_fk=tbl_empstatus.id
               left join prdept on prdept.deptcode=prmember.dept where empstatus_fk=7 and idnumber like '%".$_POST["searchval"]."%'";
			   break;
		    case "desig":
			   $sqlstr="select prmember.memberno,status,fullname,rowid,prmember.suspended,othernames,station,designation.designation,Dept,sex as gender,idnumber as national_idnum,nationality,countryname from prmember
               left join tbl_countries1 on tbl_countries1.id=prmember.nationality
               left join designation on designation.id=position_fk
			   left join tbl_empstatus on empstatus_fk=tbl_empstatus.id
               left join prdept on prdept.deptcode=prmember.dept where empstatus_fk=7 and designation like '%".$_POST["searchval"]."%'";
			   break;
			 case "depart":
			   $sqlstr="select prmember.memberno,status,rowid,fullname,prmember.suspended,othernames,station,designation.designation,Dept,sex as gender,idnumber as national_idnum,nationality,countryname from prmember
                left join tbl_countries1 on tbl_countries1.id=prmember.nationality
                left join designation on designation.id=position_fk
				left join tbl_empstatus on empstatus_fk=tbl_empstatus.id
                left join prdept on prdept.deptcode=prmember.dept where empstatus_fk=7 and Dept like '%".$_POST["searchval"]."%'";
			   break;
			  case "status":
			   $sqlstr="select prmember.memberno,status,rowid,fullname,rowid,prmember.suspended,othernames,station,designation.designation,Dept,sex as gender,idnumber as national_idnum,nationality,countryname from prmember
               left join tbl_countries1 on tbl_countries1.id=prmember.nationality
               left join designation on designation.id=position_fk
			   left join tbl_empstatus on empstatus_fk=tbl_empstatus.id
               left join prdept on prdept.deptcode=prmember.dept  
			   where empstatus_fk=7 and status like '%".$_POST["searchval"]."%' ";
			   break;
             }    
		 }
		else
	      $sqlstr="select prmember.memberno,status,fullname,rowid,prmember.suspended,othernames,station,designation.designation,Dept,sex as gender,idnumber as national_idnum,nationality,countryname from prmember
         left join tbl_countries1 on tbl_countries1.id=prmember.nationality
         left join designation on designation.id=position_fk
		 left join tbl_empstatus on empstatus_fk=tbl_empstatus.id
         left join prdept on prdept.deptcode=prmember.dept where empstatus_fk=7 order by memberno";
		
		
		$result=$d->query($sqlstr) or die(mysql_error());
		$numrows=$d->numrows($result);
		
		 if (!empty($_POST["searchval"]))
		   echo "Search  Returned $numrows Records";
		 else
		   echo "Total No. of Records : $numrows";
		//header
		//<th  width=\"10\"><div class=\"highlight style4\" id=\"inf_lname\">ID/PassPort Number</div></th>
		 echo "<tr>
          <td  bgcolor=\"#FFFFFF\" ><table width=\"100%\"  border=\"0\">
          <tr>
          <th><span class=\"style6\">No.</span></th>
          <th><span class=\"style6\">Employee</span>        
        <th><span class=\"highlight style6\">&nbsp;Gender</span>
        <th><span class=\"highlight style6\">Dept</span></th>
		<th><span class=\"highlight style6\">Station</span></th>
        <th><span class=\"highlight style6\">Designation</span></th>       
        
        <th><span class=\"highlight style6\">Nationality</span></th>
        <th><span class=\"highlight style6\">Status</span></th>
		 <th><span class=\"highlight style6\">Suspended</span></th>
		<th><span class=\"highlight style6\">Action</span></th>
      </tr>";
		while ($row=$d->fetch_object($result))
		{
		  if (($j%2)==0)
		    echo "<tr bgcolor=\"F0F0F0\">";
		  else
		    echo "<tr bgcolor=\"FFFFFF\">";
		  echo "<td>".$row->memberno."</td>";
		  echo "<td>".$row->fullname."</td>";
		  echo "<td>".$row->gender."</td>";
		  echo "<td>".$row->Dept."</td>";
		  echo "<td>".$row->station."</td>";
		  echo "<td>".$row->designation."</td>";
		  echo "<td>".$row->countryname."</td>";
		  echo "<td>".$row->status."</td>";
		  
		  if ($row->suspended==-1)
		    echo "<td>Yes</td>";
		  else
		    echo "<td>No</td>";
			
		  if ($hasaccess==1) 
		    echo "<td> <a href=employees.php?empid=$row->rowid&action=edit>Edit</a> | <a href=\"javascript:viewemp($row->memberno)\">View</a> </td>";
		  else
		    echo "<td> <a href=\"javascript:viewemp($row->rowid)\">View</a></td>";
			 
		  echo "</tr></td>";
		  $j++;
		}
		
	  
	  ?>
    </table>


<?
  $d->close();

?>
<script language="javascript">
  function viewemp(empid)
	 {
        var url = "viewemp.php?empid="+empid;
   
        newwin = window.open(url,'View','width=300,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=3');
        newwin.focus();
     }
</script>
<script language="javascript">
  function ChangePass()
	 {
        var url = "changepass.php";
   
        newwin = window.open(url,'View','width=500,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=3');
        newwin.focus();
     }
</script>
</body>

</html>



Return current item: E-hris