Location: PHPKode > projects > E-hris > employees_new.php
<? 
  session_start();
  /*
   * e-hris (E-Human Resource Information System v 2.0 Beta) 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> Employee/Staff Profile</title>
 <link rel="stylesheet" type="text/css" href="ajaxtabs/ajaxtabs.css" />
<link rel="stylesheet" type="text/css" href="css/jqueryslidemenu.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;
}
.style9 {font-size: xx-small}
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("<center><font color=red>You have not yet Logged in.<a href=login.php>Please click here to log in.</a></font></center>");
 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["id"]))
    $id=$_GET["id"];
  
  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["unit"]) ? 'NULL' : "'" . $_POST["unit"] . "'";
    $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"];
	$id=$_POST["id"];
  }
  
  
  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
	  
	
	
    if ($action=="update_go")
    {
	  //check if suspended 
	
      $query="update prmember set 
	  emptitle=$emptitle,
	  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,
	  curr_res=$curr_res,
	  homeres=$homeres,
	  physical=$physical,
	  province=$province,
	  currdescrip=$currdescrip,
	  district=$district,
	  street=$street,
	  division=$division,
	  estate=$estate,
	  location=$location,
	  town=$town,
	  basicpay=$basicpay,
	  sublocation=$sublocation,
	  postaladdr=$padress,
	  phonenum=$phonenum,
	  unit_fk=$unit,
	  dlnum=$dlnum,
	  empstatus_fk=$empstatus,
	  datedlissued=$issuedate,
	  position_fk=$position,
	  dlclasses=$class,
	  dept=$DeptName,
	  bankid_fk=$bank,
	  AccountNo=$accnum,
	  bankcode=$bank,
	  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,
	  updatedby='$username',
	  updatedon='$today',
      memberno=$empnum,
	  jobgroup=$jobgroup
	  where rowid=$rowid";
	
	
    }
    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'>";
	}
  }
 }
  
  
?>
<div id="myslidemenu" class="jqueryslidemenu">
<ul>
<li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</li>
<li>
<a href="#">Admin</a>
  <ul>
  <li><a href="#">User Management</a></li>
  <li><a href="#">Add Banks</a></li>
  <li><a href="#">Add Departments</a></li>
  <li><a href="#">Add Job Titles</a></li>
  <li><a href="#">Add Locations</a></li>
  </ul> 
</li>
<li><a href="#">Employee</a>
  <ul>
  <li><a href="#">Add Employee</a></li>
  <li><a href="#">Employees List</a></li>
  <li><a href="#">Emergency Contact(s)</a></li>
  <li><a href="#">Dependants</a></li>
  </ul>
</li>
<li><a href="#">Training</a>
  <ul>
  <li><a href="#">Qualifications</a></li>
  <li><a href="#">Training</a></li>
  <li><a href="#">Evaluation</a></li>
  </ul>
</li>
<li><a href="#">Conduct</a>
  <ul>
  <li><a href="#">Vacation</a></li>
  <li><a href="#">Attendance</a></li>
  <li><a href="#">Promotion</a></li>
  <li><a href="#">Disciplinary</a></li>
  </ul>
</li>
<li>
<a href="#">Documents</a>
  <ul>
  <li><a href="#">Upload Photo</a></li>
  <li><a href="#">Attach Documents</a></li>
  <li><a href="#">View Attachments</a></li>
  </ul>
</li>
<li><a href="#">Logout</a></li>
<font size="-10" color="#FFFFFF"><div align="right">
</div></font>
</ul>
<br style="clear: left" />
</div>
<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">
<li><a href="general.php" rel="employeesdivcontainer" class="selected">General</a></li>
<? 
if (!empty($id)) echo "<li><a href=\"empothers.php?id=$id&page=oth\" rel=\"employeesdivcontainer\">Employment</a></li>";
if (!empty($id)) echo "<li><a href=\"location.php?employeeid=$id\" rel=\"employeesdivcontainer\">Location</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>
<div align="center" class="style9" >
	Copyright © 2009 E-HRIS | <a href="mailto://hide@address.com">David Muturi</a> | Version 1.2.1 Alpha release
</div>
</body>

</html>



Return current item: E-hris