Location: PHPKode > projects > E-hris > soptraining.php
   * 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
   * 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">
<title>E-HRIS Training</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 type="text/css">
.style7 {
	color: #FF0000;
	font-size: 9px;
	font-family: "Courier New", Courier, mono;
.style8 {
	background-color: transparent;
	color: red;
	font-size: 12px;
 <link rel="stylesheet" type="text/css" href="css/epoch_styles.css"/>
<style type="text/css">
.style3 {color: #FFFFFF;
	font-weight: bold;
.style4 {color: #000000}
 <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*/

<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 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,train_cal;      
     window.onload = function () {
	 dob_cal  = new Epoch('epoch_popup','popup',document.getElementById('trainingdate'));
	 train_cal  = new Epoch('epoch_popup','popup',document.getElementById('trainingsdate'));
 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.qualificationsfrm.qlevel,'inf_qlevel',-1))  errs += 1;
	if (!validateSelect(document.forms.qualificationsfrm.trainingdate,'inf_trainingdate',-1))  errs += 1;
	if (!validateSelect(document.forms.qualificationsfrm.trainingsdate,'inf_trainingsdate',-1))  errs += 1;
	if (!validateSelect(document.forms.qualificationsfrm.compachieved,'inf_compechieved',-1))  errs += 1;
	if (!validatePresent(document.forms.qualificationsfrm.trainer,'inf_trainerid'))  errs += 1;
	if (!validatePresent(document.forms.qualificationsfrm.course,'inf_course'))  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);

<body bgcolor="#FFFFFF">

 if (empty($_SESSION["username"]))
    die("<meta http-equiv='refresh' content='1;url=login.php'>");
   $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($_REQUEST["empid"]))
  if (!empty($_POST["empid"]))
  if (!empty($empid))
    $sqlstr="select * from prmember left join tbl_titles on tbl_titles.id=emptitle where prmember.rowid=$empid";
	$row = $d->fetch_object($query);
	$dispname="<font face = Verdana size=2><b>Add/Edit Training 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($_REQUEST["action"]))
  if (!empty($_REQUEST["qualid"]))

 if (!empty($id) && $action=="edit")
    $sqlstr="select * from tbl_training where id=$id";
	$course = $row->course;
    $empid = $row->employeeid;
    $trainingdate = dateconvert($row->trainingdate,2);
    $trainingsdate = dateconvert($row->trainingsdate,2);
    $compechieved = $row->compechieved;
	$comments = stripslashes($row->comments);
	$trainer = stripslashes($row->trainer);
	$trainerid = $row->trainerid;
    $id=  $row->id;
  if (!empty($_POST["course"]))

    $course = "'".addslashes($_POST["course"])."'";
    $trainer = empty($_POST["trainer"]) ? 'NULL' : "'" . addslashes($_POST["trainer"]) . "'";
    $trainingdate = "'".dateconvert($_POST["trainingdate"],1) ."'";
	$trainingsdate = "'".dateconvert($_POST["trainingsdate"],1) ."'";
    //$trainenddate = empty($_POST["trainenddate"]) ? 'NULL' : "'" . dateconvert($_POST["trainenddate"],1) . "'";
    $compechieved = empty($_POST["compachieved"]) ? 'NULL' : "'" .  $_POST["compachieved"]. "'";
	$empid =  $_POST["empid"];
	//$qlevel = empty($_POST["qlevel"]) ? 'NULL' : "'" . $_POST["qlevel"] . "'";
	$comments = empty($_POST["comments"]) ? 'NULL' : "'" . addslashes($_POST["comments"]) . "'";
    $action =$_POST["action"];
	$id= "'".$_POST["id"]."'";
   if (!empty($action) && ($action=="edit"))
     $query="update tbl_training set course=$course,trainingdate=$trainingdate,compechieved=$compechieved,
	 employeeid=$empid,comments=$comments,trainer=$trainer,trainingsdate=$trainingsdate where id=$id";
      $query="insert into tbl_training(course,trainingdate,compechieved,employeeid,comments,trainer,trainingsdate)
	  values ($course,$trainingdate,$compechieved,$empid,$comments,$trainer,$trainingsdate)";
  // echo $query;
   if (!empty($query))
    $result = $d->query($query);

	if (!$result) 
     	die('Invalid query - Record Not Saved: ' . mysql_error());
	   echo "<font face = Tahoma size=1><b>Record Successfully Saved </b></font>";
	   echo "<meta http-equiv='refresh' content='1;url=soptraining.php?empid=$empid'>";
   //process delete
  if ($action=="delete_go")
   $sqlstr="delete from tbl_training where id=$id";
   echo "<font face = Tahoma size=1><b>Record Successfully Deleted.</b></font>";
   echo "<meta http-equiv='refresh' content='1;url=soptraining.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%" >
     <td   bgcolor="#FFFFFF" ><form name="qualificationsfrm" method="post" action="soptraining.php">
         <table width="100%"  border="0"  bgcolor="#F7F7F7">
             <td width="19%"><div align="right">Course Trained </div></td>
             <td colspan="3"><input name="course" type="text" id="course" size="50" <? if (!empty($course)) echo "value='$course'";?>>
               <div class="highlight" id="inf_course">&nbsp;</div></td>
             <td><div align="right">Trainer</div></td>
             <td width="35%"><input name="trainer" type="text" id="trainer" size="50" <? if (!empty($trainer)) echo "value='$trainer'";?>>
               <div class="highlight" id="inf_trainerid">&nbsp;</div></td>
             <td width="27%"><div align="right">Competency Achieved</div></td>
             <td width="19%">
               <select name="compachieved" id="compachieved">
                 <option value="">--SELECT--</option>
                 <? Loadlookup("id","qlevel","tbl_qlevels",$compechieved,$d); ?>
               <div class="highlight" id="inf_compechieved">&nbsp;</div></td>
             <td><div align="right">Training Start Date </div></td>
               <input name="trainingsdate" type="text" id="trainingsdate" <? if (!empty($trainingsdate)) echo "value=$trainingsdate" ?>>
               <div class="highlight" id="inf_trainingsdate">&nbsp;</div></td>
             <td><div align="right">Training End Date </div></td>
               <input name="trainingdate" type="text" id="trainingdate" <? if (!empty($trainingdate)) echo "value=$trainingdate" ?>>
             <div class="highlight" id="inf_trainingdate">&nbsp;</div></td>
             <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()">
    <td  bgcolor="#FFFFFF" ><table width="100%"  border="0">
        <th width="5%">No.</th>
        <th width="5%"><span class="style4">Training course </span></th>
        <th width="10%">Trainer</th>
		 <th width="5%"><span class="style4">Training Start Date </span></th>
        <th width="5%"><span class="style4">Training End Date </span></th>
        <th width="5%">Competency Achieved</th>
        <th width="5%">Action</th>  
		if (!empty($empid)){
	      //$sqlstr="select * from tbl_training where employeeid=$empid";
		 $sqlstr="select tbl_training.id,tbl_training.employeeid,tbl_training.course,tbl_training.trainerid,tbl_training.trainer,trainingsdate,tbl_training.trainingdate,tbl_training.compechieved,
         tbl_training.comments,tbl_qlevels.qlevel from tbl_training left join tbl_qlevels on tbl_training.compechieved = tbl_qlevels.id where employeeid=$empid";
		 // echo $sqlstr;
		  $result=$d->query($sqlstr) or die(mysql_error());;
		  while ($row=$d->fetch_object($result))
		    echo "<tr>";
		    echo "<td>".$row->id."</td>";
		    echo "<td>".$row->course."</td>";
		    echo "<td>".$row->trainer."</td>";
			echo "<td>".dateconvert($row->trainingsdate,2)."</td>";
		    echo "<td>".dateconvert($row->trainingdate,2)."</td>";
		    echo "<td>".$row->qlevel."</td>";
		    echo "<td> <a href=soptraining.php?empid=$empid&qualid=$row->id&action=edit>Edit</a> | <a href=soptraining.php?empid=$empid&action=delete_go&qualid=$row->id onClick=\"Javascript:return confirm('Are you sure you want to delete this record?','Confirm Delete')\"> Delete</a></td>";
		    echo "</tr></td>";
    <td  bgcolor="#FFFFFF" >&nbsp;</td>


Return current item: E-hris