Location: PHPKode > projects > E-hris > appraisal.php
<?
  session_start();
/*
   * e-hris (Electonic-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>
<title>E-HRIS - Staff Evaluation</title>
	<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" />
<style type="text/css">
<!--
.style2 {font-size: x-small}
.style3 {	color: #FFFFFF;
	font-weight: bold;
}
.style4 {color: #FFFFFF}
.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>
 <style type="text/css">
<!--
.style7 {
	color: #FF0000;
	font-size: 9px;
	font-family: "Courier New", Courier, mono;
}
.style8 {
	background-color: transparent;
	color: red;
	font-size: 12px;
}
-->
 </style>
 <link rel="stylesheet" type="text/css" href="css/epoch_styles.css"/>
<style type="text/css">
<!--
.style3 {color: #FFFFFF;
	font-weight: bold;
}
.style4 {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>
 <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">
 
/*You can also place this code in a separate file and link to it like epoch_classes.js*/
	var dob_cal;      
     window.onload = function () {
	 dob_cal  = new Epoch('epoch_popup','popup',document.getElementById('appdate'));
	
};
 function validateOnSubmit() {
	var elem;
    var errs=0;
	// execute all element validations in reverse order, so focus gets
    // set to the first one in error.
	

	if (!validateSelect(document.forms.appraisalfrm.appdate,'inf_appdate',-1))  errs += 1;
	if (!validatePresent(document.forms.appraisalfrm.appyear,'inf_appyear'))  errs += 1; 
    if (!validateSelect(document.forms.appraisalfrm.appraiser,'inf_appraiser',-1))  errs += 1;
	if (!validatePresent(document.forms.appraisalfrm.appresult,'inf_appresult'))  errs += 1; 
	    
	if (errs>1)  alert('There are fields which need correction before submitting');
    if (errs==1) alert('There is a field which needs correction before submitting');
	
  return (errs==0);
 }
 
 </script>
</head>
<body bgcolor="#FFFFFF">
<? 
 if (empty($_SESSION["username"]))
    die("<meta http-equiv='refresh' content='1;url=login.php'>");
 else
    $username = $_SESSION["username"];
   
  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"]))
    $empid=$_GET["empid"];
		
  if (!empty($_POST["empid"]))
   $empid=$_POST["empid"];
    
  if (!empty($empid))
  {
    $sqlstr="select * from prmember left join tbl_titles on tbl_titles.id=emptitle where prmember.rowid=$empid";
    $query=$d->query($sqlstr);
	$row = $d->fetch_object($query);
	
	$dispname="<font face = Verdana size=2><b>Add/Edit evaluation Details for: <a href=employees.php?empid=$row->rowid&action=edit>" . $row->title. $row->FullName."</a>";
	$dispname = $dispname."&nbsp;&nbsp;&nbsp;Payroll Number : ".$row->MemberNo."</b></font>";
    
  }
  
  if (!empty($_GET["action"]))
    $action=$_GET["action"];

  //echo $action;
  
  
  if (!empty($_GET["apprid"]))
  {
    $id=$_GET["apprid"];
    $sqlstr="select * from tbl_appraisals where id=$id";

	$sqlresult=$d->query($sqlstr);
	$row=$d->fetch_object($sqlresult);
	
	//$apprid = $row->id;
    $empid = $row->empid_fk;
   	$appresult=$row->result_fk;
    $appdate = dateconvert($row->appdate,2);
	$appyear=$row->appyear;
	$appraiser = $row->appraiser;
	$appcomments=$row->appcomments;
	$id=  $row->id;
  }
  
  if (!empty($_POST["appresult"]))
  { 
  
    $appresult = "'".$_POST["appresult"]."'";
	$appyear = "'".$_POST["appyear"]."'";
	$appraiser = "'".urlencode($_POST["appraiser"])."'";
    $appdate = empty($_POST["appdate"]) ? 'NULL' : "'" . dateconvert($_POST["appdate"],1) . "'";
	$comments = empty($_POST["appcomments"]) ? 'NULL' : "'" . $_POST["appcomments"] . "'";
   	$empnum=  "'".$_POST["empid"]."'";
   
    $action =$_POST["action"];
	$id= "'".$_POST["id"]."'";
    
   if (!empty($action) && ($action=="edit"))
     $query="update tbl_appraisals set result_fk=$appresult,empid_fk=$empnum,appdate=$appdate,appcomments=$comments,appraiser=$appraiser,appyear=$appyear  where id=$id";
   else
     $query="insert into tbl_appraisals (result_fk,empid_fk,appdate,appcomments,appraiser,appyear) values ($appresult,$empnum,$appdate,$comments,$appraiser,$appyear)";
   
   //echo $query;
   
   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=appraisal.php?empid=$empid'>";
	}
   }
   
   
  }
  
    //process delete
  if ($action=="delete_go")
  {
   $sqlstr="delete from tbl_appraisals where id=$id";
   $d->query($sqlstr);
   echo "<meta http-equiv='refresh' content='1;url=appraisal.php?empid=$empid'>";
  } createmenu($empid,$username,$d);
 ?>
<span>&nbsp;<br><br><? if (!empty($dispname)) echo $dispname; ?></span>
 <table  id="main" cellspacing="0" cellpadding="0" align="center" width="50%" >
   <tr>
     <td   bgcolor="#FFFFFF" ><form name="appraisalfrm" method="post" action="appraisal.php">
         <table width="100%"  border="0"  bgcolor="#F7F7F7">
           <tr>
             <td width="15%"><div align="right">Perfomance Rating</div></td>
             <td width="22%">             <select name="appresult" id="appresult">
               <option value="">--SELECT--</option>
               <? Loadlookup("id","appresult","tbl_appresults",$appresult,$d); ?>
             </select>
              <div class="highlight" id="inf_appresult">&nbsp;</div></td>
             <td width="12%"><div align="right">Appraiser</div></td>
             <td width="51%">
               <select name="appraiser" id="appraiser">
                 <option value="">--SELECT--</option>
                 <? Loadlookup("memberno","fullname","prmember",$appraiser,$d); ?>
               </select>
			    <div class="highlight" id="inf_appraiser">&nbsp;</div>
            </td>
           </tr>
           <tr>
             <td><div align="right">Perfomance Year</div></td>
             <td><select name="appyear">
               <option value="">--SELECT--</option>
               <? Loadlookup("yearlabel","yearlabel","tbl_years",$appyear,$d); ?>
             </select>
             <div class="highlight" id="inf_appyear">&nbsp;</div></td>
             <td><div align="right">Appraisal Date</div></td>
             <td>               <input name="appdate" type="text" id="appdate"  <? if (!empty($appdate)) echo "value=$appdate"; ?>>
               <div class="highlight" id="inf_appdate">&nbsp;</div></td></tr>
           <tr>
             <td><div align="right">Comments</div></td>
             <td colspan="3"><textarea name="appcomments" cols="50" id="appcomments"><?  if (!empty($appcomments)) echo $appcomments?>
             </textarea></td>
           </tr>
           <tr>
             <td colspan="4"><div align="right">
                <input type="hidden" name="empid" <? if (!empty($empid)) echo "value=$empid"; ?>>
                <input type="hidden" name="action" <? if (!empty($action)) echo "value=$action"; ?>>
                <input type="hidden" name="id" <? if (!empty($id)) echo "value=$id"; ?>>
<input type="reset" name="Reset" value="Reset">
                <input type="submit" name="Submit" value="Submit" onClick="return validateOnSubmit()">
             </div></td>
           </tr>
		   
         </table>
     </form></td>
   </tr>
  <tr>
    <td  bgcolor="#FFFFFF" ><table width="100%"  border="0">
        <tr>
        <th width="5%">No.</th>
        <th width="5%">Appraisal Result </th>
		<th width="5%"><span class="style4">Appraisal Year </span></th>
        <th width="5%"><span class="style4">Appraiser </span></th>
		<th width="5%"><span class="style4">Appraisal Date </span></th>
        <th width="10%">Comments</th>
        <th width="10%">Action</th>
      </tr>
	  <?
	    	
		if (!empty($empid))
		{
	      $sqlstr=" select tbl_appraisals.*,appresult from tbl_appraisals inner join tbl_appresults on tbl_appresults.id=tbl_appraisals.result_fk where empid_fk=$empid";
		  $result=$d->query($sqlstr) or die(mysql_error());
				
		  while ($row=$d->fetch_object($result))
		  {
		    echo "<tr>";
		    echo "<td>".$row->id."</td>";
		    echo "<td>".$row->appresult."</td>";	
			echo "<td>".$row->appyear."</td>";	
			
			$fullname=fetchfullname($row->appraiser,$d);
					
		    echo "<td>".$fullname."</td>";
			echo "<td>".dateconvert($row->appdate,2)."</td>";	
			echo "<td>".$row->appcomments."</td>";
					  
		    echo "<td> <a href=appraisal.php?empid=$empid&apprid=$row->id&action=edit>Edit</a>| <a href=appraisal.php?empid=$empid&action=delete_go&apprid=$row->id onClick=\"Javascript:return confirm('Are you sure you want to delete this record?','Confirm Delete')\"> Delete</a></td>";
		    echo "</tr></td>";
		  }
		 }
	  
	  ?>
    </table></td>
  </tr>
  <tr>
    <td  bgcolor="#FFFFFF" >&nbsp;</td>
  </tr>
 </table>
 <?
  $d->close();
  footer();
?>
</body>

</html>



Return current item: E-hris