Location: PHPKode > projects > E-hris > index.php
<? 
  session_start();
  /*
   * e-hris (E-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) 2009  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" />
     <link rel="stylesheet" type="text/css" href="css/employees.css" />
	<link rel="stylesheet" type="text/css" href="css/main.css"/>
	<link rel="stylesheet" href="js/example.css" TYPE="text/css" MEDIA="screen">
	<link href="css/text.css" rel="stylesheet" type="text/css"/>

	<title> E-HRIS Electronic Human Resources Information System.</title>
<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>
 <style type="text/css">
<!--

.style8 {
	font-family: "Bookman Old Style";
	font-size: large;
	font-weight: bold;
}

h2
{
	color:#51790E;
	font-family: "Times New Roman", Times, serif;
	font-size: 30px;
	line-height: 30px;
	padding: 0px;
	margin-top: 20px;
	margin-right: 0px;
	margin-bottom: 20px;
	margin-left: 0px;
}

-->
 </style>
</head>
<body>
<? 

 if (empty($_SESSION["username"]))
    die("<meta http-equiv='refresh' content='1;url=login.php'>");
 else
   $username = $_SESSION["username"];
  
 
  $today=date("Y-m-d h:m:s");
  
  include "includes/functions.php";
  include "includes/config.php";
  require_once "includes/db.php";
  
  $d = new dbC();
  $d->connect($db_host, $db_user, $db_pass, $db); 
   
  if (!empty($_GET["empid"]))
    $id=$_GET["empid"];
  else if (!empty($_POST["empid"]))
    $id=$_POST["empid"];



  if (!empty($_POST["Submit"]))
  { 
    $emptitle = empty($_POST["emptitle"]) ? 'NULL' : "'" . $_POST["emptitle"] . "'";
    $fname = "'".$_POST["fname"]."'";
	$memberno= "'".$_POST["memberno"]."'";
     
	if (empty($_POST["mname"])){
         $fullname ="'".$_POST["fname"]." ".$_POST["lname"]."'";
	 $mname='Null';
	}
	else{
          $mname = "'".$_POST["mname"]." ".$_POST["lname"]."'";
	  $fullname = "'".$_POST["fname"]." ".$_POST["mname"]." ".$_POST["lname"]."'";
	 }
	
 
	
    $prefnames = "'".$_POST["prefnames"]."'";
    $empnum = "'".$_POST["payrollnum"]."'";
    $rowid= $_POST["rowid"];
    $basicpay="'".$_POST["basicpay"]."'";
  
    $dob = "'".datetimeconvert($_POST["dob"],1)."'";
    $placeofbirth="'".$_POST["pbirth"]."'";
    $gender="'".$_POST["gender"]."'";
    $marital_status="'".$_POST["maritalstat"]."'";
    $pin="'".$_POST["pin"]."'";
    $nssfnum="'".$_POST["nssfnum"]."'";
    $nationality="'".$_POST["nationality"]."'";
    $nhifnum=empty($_POST["nhifnum"]) ? 'NULL' : "'" . $_POST["nhifnum"] . "'";
    $empdate="'".datetimeconvert($_POST["empdate"],1)."'";
    $national_idnum="'".$_POST["idnum"]."'";
  
    $curr_res= empty($_POST["curr_res"]) ? 'NULL' : "'" . $_POST["curr_res"] . "'";
    $homeres= empty($_POST["homeres"]) ? 'NULL' : "'" . $_POST["homeres"] . "'";
    $physical=empty($_POST["physical"]) ? 'NULL' : "'" . $_POST["physical"] . "'";
    $currdescrip= empty($_POST["currdescrip"]) ? 'NULL' : "'" . $_POST["currdescrip"] . "'";
  
    $province= empty($_POST["province"]) ? 'NULL' : "'" . $_POST["province"] . "'";
    $district=empty($_POST["district"]) ? 'NULL' : "'" . $_POST["district"] . "'";
    $street= empty($_POST["street"]) ? 'NULL' : "'" . $_POST["street"] . "'";
    $estate= empty($_POST["estate"]) ? 'NULL' : "'" . $_POST["estate"] . "'";
    $division= empty($_POST["division"]) ? 'NULL' : "'" . $_POST["division"] . "'";
  
    $location=empty($_POST["location"]) ? 'NULL' : "'" . $_POST["location"] . "'";
    $town=empty($_POST["town"]) ? 'NULL' : "'" . $_POST["town"] . "'";
    $sublocation=empty($_POST["sublocation"]) ? 'NULL' : "'" . $_POST["sublocation"] . "'";
    $padress=empty($_POST["padress"]) ? 'NULL' : "'" . $_POST["padress"] . "'";
    $phonenum=empty($_POST["phonenum"]) ? 'NULL' : "'" . $_POST["phonenum"] . "'";
   
    $unit = empty($_POST["branch"]) ? 'NULL' : "'" . $_POST["branch"] . "'";
    $dlnum = empty($_POST["dlnum"]) ? 'NULL' : "'" . $_POST["dlnum"] . "'";
    $empstatus = empty($_POST["empstatus"]) ? 'NULL' : "'" . $_POST["empstatus"] . "'";
    $issuedate = empty($_POST["issuedate"]) ? 'NULL' : "'" .dateconvert($_POST["issuedate"],1) . "'";
    $position = empty($_POST["position"]) ? 'NULL' : "'" . $_POST["position"] . "'"; 
  
    $class = empty($_POST["class"]) ? 'NULL' : "'" . $_POST["class"] . "'";
    $DeptName = empty($_POST["DeptName"]) ? 'NULL' : "'" . $_POST["DeptName"] . "'";
	
    $bank="'".$_POST["bank"]."'";
	
    $basicpay="'".$_POST["basicpay"]."'";
    $accnum="'".$_POST["accnum"]."'";
    $jobgroup=empty($_POST["jobgrp"]) ? 'NULL' : "'" . $_POST["jobgrp"] . "'";
    $stationcode= empty($_POST["stationcode"]) ? 'NULL' : "'" . $_POST["stationcode"] . "'";
    $numhrs= empty($_POST["numhrs"]) ? '0' : "'" . $_POST["numhrs"] . "'";
    $monthid= empty($_POST["incmonth"]) ? '0' : "'" . $_POST["incmonth"] . "'";
    $hpayrate=empty($_POST["hpayrate"]) ? '0' : "'" . $_POST["hpayrate"] . "'";
    $housed=empty($_POST["housed"]) ? '0' : "'" . $_POST["housed"] . "'";
    $rentpayemp=empty($_POST["rentpayemp"]) ? '0' : "'" . $_POST["rentpayemp"] . "'";
	
    $actscale=empty($_POST["scale"]) ? 'NULL' : "'" . $_POST["scale"] . "'";
    $acteffdate=empty($_POST["actdate"]) ? 'Null' : "'" .dateconvert($_POST["actdate"],1) . "'";
    $qdate=empty($_POST["qdate"]) ? 'Null' : "'" .dateconvert($_POST["qdate"],1) . "'";
    $actpos=empty($_POST["actpos"]) ? 'NULL' : "'" . $_POST["actpos"] . "'";
	
    $expdate=empty($_POST["expdate"]) ? 'Null' : "'" .dateconvert($_POST["expdate"],1) . "'";
    $endprd= getperiodfromdate($_POST["expdate"]);
	
    $effdate="'".dateconvert($_POST["effdate"],1)."'";
    $termsid="'".$_POST["terms"]."'";
    $action=$_POST["action"];
    $tabfrom=$_POST["tabfrom"];
	
  }
  
  
  if (!empty($_POST["Submit"]))
  {
     
	 //check if suspended suspend from payroll
	 if (stristr($empstatus,'1'))
	   $suspended=0;
	 else
	   $suspended=-1;
	 //check if quit date is null
	  
	//echo $action;
	
    if ($action=="update_go")
    {
	  //check the tab posted from 
	
	 if ($tabfrom=='GEN')
		  $query="update prmember set 
		  lastname=$fname,
		  othernames=$mname,
		  fullname=$fullname,
		  birthdate=$dob,
		  placeofbirth=$placeofbirth,
		  sex=$gender,
		  maritalstatus=$marital_status,
		  PINNumber=$pin,
		  nssfno=$nssfnum,
		  nationality=$nationality,
		  NHIFNO=$nhifnum,
		  empdate=$empdate,
		  IDNumber=$national_idnum,
		  unit_fk=$unit,
		  basicpay=$basicpay,
		  bankid_fk=$bank,
		  AccountNo=$accnum,
		  bankcode=$bank,
		  updatedby='$username',
		  updatedon='$today',
		  memberno=$empnum,
		  position_fk=$position,
		  jobgroup=$jobgroup
		  where rowid=$id";
		  
	  else if ($tabfrom=='RES')
		  $query= "update prmember set 
		  curr_res=$curr_res,
		  homeres=$homeres,
		  physical=$physical,
		  province=$province,
		  currdescrip=$currdescrip,
		  district=$district,
		  street=$street,
		  division=$division,
		  estate=$estate,
		  location=$location,
		  town=$town,
		  sublocation=$sublocation,
		  postaladdr=$padress,
		  phonenum=$phonenum
		  where rowid=$id";
       else if  ($tabfrom=='EMP')	  
	     $query="update prmember set  dlnum=$dlnum,
			  empstatus_fk=$empstatus,
			  datedlissued=$issuedate,
			  dlclasses=$class,
			  dept=$DeptName,
			  quitdate=$expdate,
			  effdate=$effdate,
			  termsid_fk=$termsid,
			  Hr_PayRate=$hpayrate,
			  station=$stationcode,
			  M_days_Hrs=$numhrs,
			  IncrMonth=$monthid,
			  Housed=$housed,
			  HouseCost=$rentpayemp,
			  endprd='$endprd',
			  acteffdate=$acteffdate,
			  actscale=$actscale,
			  actposition=$actpos
			  where rowid=$id";
    }
    else
   { 
     $datetoday=date('d-m-Y');
     $period=getperiodfromdate($datetoday);
	 
      $query="insert into prmember (memberno,emptitle,lastname,fullname,othernames,birthdate,placeofbirth,sex,maritalstatus,PINNumber,nssfno,nationality,
	  NHIFNO,empdate,IDNumber,curr_res,homeres,physical,province,currdescrip,district,street,division,estate,location,town,sublocation,
	  postaladdr,phonenum,unit_fk,dlnum,empstatus_fk,datedlissued,position_fk,dlclasses,dept,bankid_fk,AccountNo,bankcode,
	  effdate,termsid_fk,basicpay,jobgroup,station,M_days_Hrs,IncrMonth,Housed,HouseCost,Hr_PayRate,endprd,period,acteffdate,actscale,actposition,quitdate,suspended,addedby,addedon) values ($empnum,$emptitle,$fname,$fullname,$mname,$dob,$placeofbirth,$gender,$marital_status,$pin,$nssfnum,$nationality,$nhifnum,$empdate,$national_idnum,$curr_res,
	   $homeres,$physical,$province,$currdescrip,$district,$street,$division,$estate,$location,$town,$sublocation,$padress,$phonenum,$unit,$dlnum,
	   $empstatus,$issuedate,$position,$class,$DeptName,$bank,$accnum,$bank,$effdate,$termsid,$basicpay,$jobgroup,$stationcode,$numhrs,$monthid,$housed,$rentpayemp,$hpayrate,'$endprd','$period',$acteffdate,$actscale,$actpos,$qdate,-1,'$username','$today')";
		
  }
    
 //echo $query."<br>";	
  if (!empty($query))
  {
    $result = $d->query($query);

	if (!$result) 
     	die('Invalid query - Record Not Saved: ' . mysql_error());
	else
	{
	   echo "<font face = Tahoma size=1><b>Record Successfully Saved </b></font>";
	   echo "<meta http-equiv='refresh' content='1;url=index.php'>";
	}
  }
 }
  
 createmenu($empid,$username,$d); 
 



?>
<span class="style8">

&nbsp; </span>
<table width="70%" height="50%" cellpadding="0" cellspacing="0"  id="main" align="center" bgcolor="#F7F7F7">
  
	<tr>
    <td width="100%" bgcolor="#FFFFFF" valign="top">
	<ul id="employeestabs" class="shadetabs">

<? 

  echo "<li><a href=\"activeemp.php\" rel=\"employeesdivcontainer\" class=\"selected\">Active</a></li>";
  echo "<li><a href=\"resigned.php\" rel=\"employeesdivcontainer\">Resigned</a></li>";
  echo "<li><a href=\"layoff.php\" rel=\"employeesdivcontainer\">LayOff</a></li>";
  echo "<li><a href=\"retire.php\" rel=\"employeesdivcontainer\">Retired</a></li>";
  echo "<li><a href=\"transfer.php\" rel=\"employeesdivcontainer\">Transferred</a></li>";
  echo "<li><a href=\"terminated.php\" rel=\"employeesdivcontainer\">Terminated</a></li>";
  echo "<li><a href=\"deceased.php\" rel=\"employeesdivcontainer\">Departed</a></li>";
?>
</ul>
<div id="employeesdivcontainer" style="border:1px solid gray; width:870px; margin-bottom: 1em; padding: 5px">
<script type="text/javascript">

var employees=new ddajaxtabs("employeestabs", "employeesdivcontainer")
employees.setpersist(true)
employees.setselectedClassTarget("link") //"link" or "linkparent"
employees.init()

</script>
</div>
</td></tr>
</table>
<? 
 footer();
?>
</body>

</html>



Return current item: E-hris