Location: PHPKode > projects > phprofession job board > phProfession_SA/admin.php
<?PHP
#####################################
#   phprofession   September 2005      #
#   by Aidan Peiser	    	    #
#   Recruitment module for PN.712   #
#   www.galore.co.za	    #
#	.,.,.,,			    #
#	C 'C' C			    #
#	 > * <			    #
#####################################

//include("header.php");


//must change this to link to your config.php file for this module
include("config.php");
include("functions.php");
echo"<html><title>Phprofession $Version</title><head><link rel=\"STYLESHEET\" type=\"text/css\" href=\"style.css\"></head><body>";

phprofession_language();

// check user is logged in
if (verify_session($authok) == "FALSE") 
	{
		OpenTable();
		echo "<a href=post.php?create_login=true>create an account</a>&nbsp;|&nbsp;";
		echo "<a href=post.php?login=true>login</a><br><br>";
		$user_id = verify_session($authok);

		// this lets you display login box or create login box
		if ($login == "true")
		{
			draw_login_box("Login Here", "200", $ModuleDirName);
		}
		if ($create_login == "true")
		{
			draw_create_login_box("Create Login Here", "200", $ModuleDirName);
		}
		CloseTable();
		exit;
	}
	else
	{//start of login code
		OpenTable();
		$user_id = verify_session($authok);
		
		$query = "SELECT usertype,
					user
			FROM {$prefix}_jobaccounts
                   	WHERE user = '$user_id'";
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
		if (mysql_num_rows($result) <= 0)
		{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
        		exit;
		}
		else 
		{
			list($usertype,
                 $user )= mysql_fetch_row($result);
			mysql_free_result($result);

		if (!$usertype == '1')
		{	
			OpenTable();
			echo "You are not authorised to view admin section $user_id";
			CloseTable();
			exit;
		}
		Admin_menu($user_id);
		}
			CloseTable();
if ((!isset($cmd)) || ($cmd == ""))
{
	$cmd = "BrowseJobs";
}

/* Do not alter the following code unless you are a proficient PHP coder. Altering the code incorrectly may result in corrupting the entire script.*/
	# if($cmd == "Admin") line 62
	# if($cmd == "Administrator") line 101
	# if($cmd == "DeleteAdmin") line 139
	# if($cmd == "NewAdmin") line 174
	# if($cmd == "browse") line 243
	# if($cmd == "RecruitingClient") line 271
	# if($cmd == "Add") line 306
	# if($cmd == "Edit") line 554
	# if($cmd == "Delete") line 807
	# if($cmd == "Deleteclient") line 844
	# if($cmd == "Search") line 882
	# if($cmd == "Resume_Details") line 1012
	# if($cmd == "Departments") line 1212
	# if($cmd == "DeleteDepartment") line 1253
	# if($cmd == "EditDepartment") line 1293
	# if($cmd == "NewDepartment") line 1384
	# if($cmd == "salary") line 1446
	# if($cmd == "Deletesalary") line 1487
	# if($cmd == "Editsalary") line 1527
	# if($cmd == "Newsalary") line 1617
	# if($cmd == "location") line 1677
	# if($cmd == "Deletelocation") line 1719
	# if($cmd == "Editlocation") line 1758
	# if($cmd == "Newlocation") line 1843
	# if($cmd == "DisplayConfig") line 1902
	# if($cmd == "ResumeUploads") line 1961
	# if($cmd == "Waiting")line 
	# if($cmd == "Error") line 1982

#####################
# Job Listing Admin #
#####################
if($cmd == "Admin")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Job Directory Admin </font></center>";
	CloseTable();
	OpenTable();

	mysql_select_db($database, $connection) or die('Database Not Found');
        $query = "SELECT DISTINCT id,department
                         FROM     {$prefix}_jobdepartment,
                                  {$prefix}_joblisting
                         WHERE    {$prefix}_jobdepartment.id = {$prefix}_joblisting.fk_department";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
		
	echo "<table border=0 cellspacing=2 cellpadding=2 width=100%>";

	while(list($id, $department) = mysql_fetch_row($result))
        {
		echo "<tr><td colspan=6><font class=\"pn-normal\"><b>Department:</b> $department</font></td></tr>\n";
		$query2 = "SELECT {$prefix}_joblisting.jcode,
				  {$prefix}_joblisting.designation,
				  {$prefix}_joblisting.posted,
				  {$prefix}_joblisting.hits
			  FROM    {$prefix}_joblisting
			  WHERE   {$prefix}_joblisting.fk_department = '$id'";
          	$result2 = mysql_query($query2) or die ("Error in query: $query. " . mysql_error());
		while(list($jcode, $dsg, $posted,$hits ) = mysql_fetch_row($result2))
		{
		echo "<tr><td><a href=\"index.php?cmd=Details&jcode=$jcode\"><font class=\"pn-normal\"><b>$dsg</b></font></a></td><td>[ $jcode ]</td><td>$hits</td><td>";
		echo fixDate($posted);
		echo"</td><td><a href=\"admin.php?cmd=Edit&jcode=$jcode\"><img src=\"lang/".$currentlang."/edit".$currentlang.".gif\" border=0 alt=\"edit\"></a></td><td><a href=\"admin.php?cmd=Re-Add&jcode=$jcode\"><img src=\"lang/".$currentlang."/readd".$currentlang.".gif\" border=0 alt=\"re-add\"></a></td><td><a href=\"admin.php?cmd=Delete&jcode=$jcode\"><img src=\"lang/".$currentlang."/delete".$currentlang.".gif\" border=0 alt=\"delete\"></td></tr>\n";
        }
        }
        echo "</table>";
}

#####################
# Job Listing Admin #
#####################
if (($cmd =="BrowseJobs")||($cmd =="BrowseJobs2"))
{
	OpenTable();
	Echo "<center><font class=\"pn-Title\">"._JOBLIST."</font></center>";
	CloseTable();
	OpenTable();
// set this $limit in config file
	if ($cmd == "BrowseJobs") 
	{
		$limit=$listings;
	}
	else 
	{
		$limit = $maxlisting;
	}

	if (!$offset) $offset=0; 
	mysql_select_db($database, $connection) or die('Database Not Found');
	$query = "select count(*) from {$prefix}_joblisting WHERE {$prefix}_joblisting.checked=1";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

	list($numrec)=mysql_fetch_row($result);

	$numpage=intval($numrec/$limit);
	if ($numrec%$limit) 
	{
		$numpage++;
	} // add one page if remainder
	print("<table width=100% border=0 cellspacing=2><tr bgcolor=whitesmoke><td>&nbsp;&nbsp;<b>"._JOBTITLETXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBCODETXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBVIEWS."</b></td><td>&nbsp;&nbsp;<b>"._JOBPOSTED."</b></td><td>&nbsp;&nbsp;<b>"._JOBEDIT."</b></td><td>&nbsp;&nbsp;<b>"._JOBREADD."</b></td><td>&nbsp;&nbsp;<b>"._JOBDELETE."</b></td></tr>");
        mysql_select_db($database, $connection) or die('Database Not Found');
		$query = "SELECT {$prefix}_joblisting.jcode,
				  {$prefix}_joblisting.designation,
				  {$prefix}_joblisting.posted,
				  {$prefix}_joblisting.hits,
				  {$prefix}_joblisting.cname
			  FROM   {$prefix}_joblisting
			  order by posted desc limit $offset,$limit";

	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	while (list($jcode, $dsg, $posted, $hits, $cname )  = mysql_fetch_row($result)) 
	{
		echo "<tr><td><a href=\"index.php?cmd=Details&jcode=$jcode\"><font class=\"pn-normal\"><b>$dsg</b></font></a></td><td>[ $jcode ]</td><td>$hits</td><td>";
		echo fixDate($posted);
		echo"</td><td align=\"center\"><a href=\"admin.php?cmd=Edit&jcode=$jcode\"><img src=\"lang/".$currentlang."/edit".$currentlang.".gif\" border=0 alt=\"edit $jcode\"></a></td><td align=\"center\"><a href=\"admin.php?cmd=Re-Add&jcode=$jcode\"><img src=\"lang/".$currentlang."/readd".$currentlang.".gif\" border=0 alt=\"re-add $jcode\"></a></td><td align=\"center\"><a href=\"admin.php?cmd=Delete&jcode=$jcode\"><img src=\"lang/".$currentlang."/delete".$currentlang.".gif\" border=0 alt=\"delete $jcode\"></td></tr>\n";
	}
	mysql_close($connection);
	print("</table>");

//<!-- result display loop next prev buttons-->
	if ($numpage>1) 
	{
		pagenav('admin');
	}
}


#####################
# users	Admin 	    #
#####################
if($cmd == "Administrator")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Job Directory Admin </font></center>";
	CloseTable();
		OpenTable();
		
		echo "<a href=\"admin.php?cmd=NewAdmin\">Create Admin</a><br><br>";
		echo "<table width=\"100%\" border=0>";
		echo "<tr><td>&nbsp;<b>ID</b>&nbsp;&nbsp;&nbsp;<b>Username</b>:</td><td>&nbsp;<b>Email</b></td><td>&nbsp;<b>Company </b></td><td>&nbsp;<b>Phone</b> </td><td>&nbsp;<b>Loged in</b></td><td>&nbsp;<b>Posts</b></td><td>&nbsp;<b>level</b></td><td>&nbsp;&nbsp;&nbsp;<b>Delete</b></td></tr>";
		$query = "SELECT {$prefix}_jobaccounts.user,
				 {$prefix}_jobaccounts.email,
				 {$prefix}_jobaccounts.company,
				 {$prefix}_jobaccounts.phone,
				 {$prefix}_jobaccounts.usertype,
				 {$prefix}_jobaccounts.count
			  FROM   {$prefix}_jobaccounts
				  order by count desc";
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
		while (list($adminuser, $email, $company, $phone, $usertype, $count) = mysql_fetch_row($result))
		{
			$id++;
			echo "<tr><td>$id &nbsp;&nbsp;$adminuser </td><td>&nbsp;<a href=\"mailto:$email\">$email</a></td><td>&nbsp;$company </td><td>&nbsp;$phone </td><td>&nbsp;$count&nbsp;Times </td><td>&nbsp;";
			
			$query_count = "select count(*) from {$prefix}_joblisting where cname='$adminuser'";
			$result_count = mysql_query($query_count) or die ("Error in query: $query_count. " . mysql_error());
			while (list($job_count) = mysql_fetch_row($result_count))
			{
				echo "$job_count";	
			}
			
			echo " </td><td>&nbsp;$usertype</td><td align=\"right\"><a href=\"admin.php?cmd=DeleteAdmin&deleteuser=$adminuser\"><img src=\"lang/".$currentlang."/delete".$currentlang.".gif\" border=0></a></td></tr>";
		}
	echo "</table>";
}

################
# delete admin #
################
if($cmd == "DeleteAdmin")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Job Directory Admin </font></center>";
	CloseTable();
	OpenTable();
		

		if (!$deleteuser || $deleteuser == "")
		{
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='admin.php?cmd=Error'";
		echo "</SCRIPT>";
		exit;
    	}
        $query = "DELETE FROM {$prefix}_jobaccounts WHERE user = '$deleteuser'";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        mysql_close($connection);
		echo "<font class=\"pn-normal\"><b>$deleteuser Entry successfully deleted.<p>";
}
#############
# Add admin #
#############
if($cmd == "NewAdmin")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Create New Admin </font></center>";
	CloseTable();
			OpenTable();
			

			if (!$submit)
			{
			echo "You re currently loged in as : $user_id\n<br>";
			echo "<a href=\"admin.php?cmd=Administrator\">view all users and admins</a><br><br>";
			draw_create_admin_login_box("Create Admin Login Here", "200", $ModuleDirName);
			}
}

######################
# browse all resumes #
######################

if($cmd == "browseuser")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Browse Users </font></center>";
	CloseTable();
	OpenTable();
	echo "<table border=\"0\" width=\"100%\">";
    mysql_select_db($database, $connection) or die('Database Not Found');
	$query = "SELECT {$prefix}_jobuser.rid,
			 {$prefix}_jobuser.lname,
			 {$prefix}_jobuser.fname,
			 {$prefix}_jobuser.city,
			 {$prefix}_jobuser.phone,
			 {$prefix}_jobuser.email
		FROM	 {$prefix}_jobuser ";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

		while (list($rid, $lname, $fname, $city, $phone, $email) = mysql_fetch_row($result))
		{
			echo "<tr><td><li><a href=admin.php?cmd=Resume_Details&rid=$rid>$fname &nbsp;$lname</a></td><td>$city</td><td>$phone</td><td>$email</td></tr>";	
		}
	echo "</table>";
}

####################
#browse all clients#
####################

if($cmd == "RecruitingClient")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Recruiting Client</font></center>";
	CloseTable();
		OpenTable();
		

		$query = "SELECT {$prefix}_jobclient.id, {$prefix}_jobclient.clientname, {$prefix}_jobclient.clientcompany, {$prefix}_jobclient.clientphone, {$prefix}_jobclient.clientemail, {$prefix}_jobclient.clientcomments FROM {$prefix}_jobclient order by id desc";
    	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
		echo "<table>";
		while (list($id, $clientname, $clientcompany, $clientphone, $clientemail, $clientcomments) = mysql_fetch_row($result))
		{
			echo "<tr bgcolor=\"#CCCCCC\"><td>Client $id </td><td><b>Name</b>:&nbsp;$clientname </td><td><b>Company</b>:&nbsp;$clientcompany</td><td><b>Phone</b>:&nbsp;$clientphone</td><td><b>Email</b>:<a href=mailto:$clientemail><b>$clientemail</b></a></td></tr><tr><td>&nbsp;</td><td colspan=3><b>Comments</b>:<br>$clientcomments<br></td><td valign=\"top\" align=\"right\">&nbsp;<a href=\"$nukeurl/admin.php?cmd=Deleteclient&Aid=$id\">"._ADMINDELETE." $id</a></td></tr>";	
	  	}
		echo "</table>";
}

####################
# Adding a listing #
####################

if($cmd == "Add")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Add New Job </font></center>";
	CloseTable();
	OpenTable();

	if (!$submit)
	{
		echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">";
		echo"<form action=\"admin.php?cmd=Add\" method=\"POST\">"; 
?>
<SCRIPT language=Javascript>
<!--
function CountCharacters() {
var sLimit = <? echo "$limit"; ?>;
if (sLimit < (document.forms[0].txtSkills.value).length) {
SkillsMSG.innerHTML = "<font class=small size=1 face=Arial>Characters exceeded by: " + ((document.forms[0].txtSkills.value).length - sLimit) + "</font>";
} else {
SkillsMSG.innerHTML = "<font class=small size=1 face=Arial>Characters remaining: " + (<? echo "$limit"; ?>- (document.forms[0].txtSkills.value).length) + "</font>";
	}
}

function CountCharacters2() {
var sLimit = <? echo "$limit"; ?>;
if (sLimit < (document.forms[0].txtSkills.value).length) {
SkillsMSG2.innerHTML = "<font class=small size=1 face=Arial>Characters exceeded by: " + ((document.forms[0].txtSkills2.value).length - sLimit) + "</font>";
} else {
SkillsMSG2.innerHTML = "<font class=small size=1 face=Arial>Characters remaining: " + (<? echo "$limit"; ?>- (document.forms[0].txtSkills2.value).length) + "</font>";
	}
}
//-->
</SCRIPT>
<!--            Input job details        -->

            <tr>
                <td><font class="pn-normal"><b>Designation</b></font><font color="red">*</font></td>
                <td width=50>&nbsp;</td>
                <td><font class="pn-normal"><b>Department</b></font><font color="red">*</font></td>
            </tr>
            <tr>
                <td><input type="text" name="dsg" size="25"></td>
                <td width=50>&nbsp;</td>
                <td>
                    <select name="dpt">
<?

//Get department list
	$query = "SELECT id, department from {$prefix}_jobdepartment";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        while (list($id, $department) = mysql_fetch_row($result))
        {
		echo "<option value=$id>$department</option>";
        }
        mysql_free_result($result);
?>
            </select></td>
            </tr>
            <tr>
                <td><font class="pn-normal"><b>Location</b></font><font color="red">*</font></td>
                <td width=50>&nbsp;</td>
                <td><font class="pn-normal"><b>Salary</b></font><font color="red">*</font></td>
            </tr>
            <tr>
                <td>
            <select name="loc">
<?
//Get location list
    $query = "SELECT id, location from {$prefix}_joblocation";
    $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        while (list($id, $location) = mysql_fetch_row($result))
        {
            echo "<option value=$id>$location</option>";
        }
        mysql_free_result($result);
?>
                </select></td>
                <td width=50>&nbsp;</td>
                <td>
                    <select name="sal">
<?
//Get salary list
    $query = "SELECT id, salary from {$prefix}_jobsalary";
    $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
    while (list($id, $salary) = mysql_fetch_row($result))
    {
        echo "<option value=$id>$salary</option>";
    }
    mysql_free_result($result);
?>
            </select></td>
            </tr>
            <tr>
                <td><font class="pn-normal"><b>Responsibilities</b></font><font color="red">*</font></td>
                <td width=50>&nbsp;</td>
                <td><font class="pn-normal"><b>Qualifications</b></font><font color="red">*</font></td>
            </tr>
            <tr>
                <td><textarea name="rsp" cols="30" rows="6" wrap=true onKeyUp="CountCharacters();" onBlur="CountCharacters();" onFocus="CountCharacters();" id=txtSkills></textarea><br><SPAN id=SkillsMSG>&nbsp;</SPAN></td>
                <td width=50>&nbsp;</td>
                <td><textarea name="qlf" cols="30" rows="6" wrap=true onKeyUp="CountCharacters2();" onBlur="CountCharacters2();" onFocus="CountCharacters2();" id=txtSkills2></textarea><br><SPAN id=SkillsMSG2>&nbsp;</SPAN></td>
            </tr>
            <tr>
                <td><font class="pn-normal"><b>Contact person</b></font><font color="red">*</font></td>
                <td width=50><font class="pn-normal"><b> 1=show<br>0=dont</b></font><font color="red">*</font></td>
                <td><font class="pn-normal"><b>Email address</b></font><font color="red">*</font></td>
            </tr>
            <tr>
                <td><select name="cname">
<?
        echo "<option value=$user_id>$user_id</option>";
?>
	</select></td>
	<td width=50><select name="checked">
	<option value=1>1</option>
	<option value=0>0</option>
	</select></td>
	<td><input type="text" name="cmail">
	</td>
	            </tr>
	            <tr>
	                <td align=center colspan=3>
			<input type=submit name=submit value="Add Listing">
	                </td>
	            </tr>
	        </table>
	</form>

<?

}else{

//Set up error list array
    $errorList = array();
    $count = 0;

//Validate text fields
    if (empty($dsg)) 
    {
        $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Designation</b></font>"; $count++;
    }

    if (empty($rsp)) 
    {
        $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Responsibilities</b></font>"; $count++;
    }

    if (empty($qlf)) 
    {
        $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Qualifications</b></font>"; $count++;
    }

    if (empty($cname)) 
    {
        $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Contact name</b></font>"; $count++;
    }

    if (empty($cmail) || isEmailInvalid($cmail)) 
    {
        $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Email address</b></font>"; $count++;
    }

        if (sizeof($errorList) == 0)
        {
		mysql_select_db($database, $connection) or die('Database Not Found');
		$query = "INSERT INTO {$prefix}_joblisting (
                                        jcode,
                                        designation,
                                        responsibilities,
                                        qualifications,
                                        cname, cmail,
                                        posted,
                                        fk_department,
                                        fk_location,
                                        fk_salary,
					checked)
                             VALUES 	('',
                                         '$dsg',
                                         '$rsp',
                                         '$qlf',
                                         '$cname',
                                         '$cmail',
                                         NOW(),
                                         '$dpt',
                                         '$loc',
                                         '$sal',
										 '$checked')";
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

		echo "<font class=\"pn-normal\"><b>Entry successfully added.<p><a href=\"admin.php?cmd=Add\">Add another entry</a>, or <a href=\"admin.php?cmd=Admin\">return to job listings</a></b></font>";
		}
		else
		{
		listErrors();
		}
	}
}

####################
# Re - Add job	   #
####################

//this is still undergoing work it should be here so that a user can replace a exsisting add after its been up for a few days.
if($cmd == "Re-Add")
{
	if (!$jcode || $jcode == "")
	{
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='admin.php?cmd=Error'";
		echo "</SCRIPT>";
		exit;
	}
    $query = "UPDATE {$prefix}_joblisting
                      SET posted=NOW()
                          WHERE jcode='$jcode'";
				
	$result = mysql_db_query($database, $query, $connection) or die ("Re - Add error: $query. " . mysql_error());
	
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Re Added Job Listing </font></center>";
	CloseTable();
	OpenTable();
    echo "<font class=\"pn-normal\"><b>Entry successfully updated.<p></font>";

}

#####################
# Editing a listing #
#####################

if($cmd == "Edit")
{
	OpenTable();
	Echo "<br><center><font class=\"pn-Title\"> Edit Job Listing </font></center>";
	CloseTable();
	OpenTable();

        if (!$jcode || $jcode == "")
        {
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='admin.php?cmd=Error'";
		echo "</SCRIPT>";
        	exit;
        }

        if (!$submit)
        {
	mysql_select_db($database, $connection) or die('Database Not Found');
        $query = "SELECT designation,
                        jcode,
                        fk_department,
                        fk_location,
                        fk_salary,
                        responsibilities,
                        qualifications,
                        cname,
                        cmail,
			checked,
			posted
                   from {$prefix}_joblisting
                   WHERE jcode = '$jcode'";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

		if (mysql_num_rows($result) <= 0)
		{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
        		exit;
		}
		else 
		{
			list($designation,
                        $jcode,
                        $department,
                        $location,
                        $salary,
                        $description,
                        $qualification,
                        $cname,
			$cmail,
			$checked,
                        $posted) = mysql_fetch_row($result);
			mysql_free_result($result);

	echo "<table border=\"0\" cellspacing=\"5\" cellpadding=\"2\">";
	echo "<form action=\"admin.php?cmd=Edit&jcode=$jcode\" method=\"POST\">"; 
?>
<SCRIPT language=Javascript>
<!--
function CountCharacters() {
var sLimit = <? echo "$limit"; ?>;
if (sLimit < (document.forms[0].txtSkills.value).length) {
SkillsMSG.innerHTML = "<font class=small size=1 face=Arial>Characters exceeded by: " + ((document.forms[0].txtSkills.value).length - sLimit) + "</font>";
} else {
SkillsMSG.innerHTML = "<font class=small size=1 face=Arial>Characters remaining: " + (<? echo "$limit"; ?>- (document.forms[0].txtSkills.value).length) + "</font>";
	}
}

function CountCharacters2() {
var sLimit = <? echo "$limit"; ?>;
if (sLimit < (document.forms[0].txtSkills.value).length) {
SkillsMSG2.innerHTML = "<font class=small size=1 face=Arial>Characters exceeded by: " + ((document.forms[0].txtSkills2.value).length - sLimit) + "</font>";
} else {
SkillsMSG2.innerHTML = "<font class=small size=1 face=Arial>Characters remaining: " + (<? echo "$limit"; ?>- (document.forms[0].txtSkills2.value).length) + "</font>";
	}
}
//-->
</SCRIPT><tr>
                <td><font class="pn-normal"><b>Job Code</b></font></td>
                <td width=30>&nbsp;</td>
                <td><font class="pn-normal"><b>Date posted</b></font><font color="red">*</font></td>
                </tr>
				<tr>
				<td><? echo $jcode; ?></td>
				<td width=30>&nbsp;</td>
				<td><input type=text name="posted" value="<? echo $posted; ?>"></td>
				</tr>
                         <!--                    Job details                -->
                    <tr>
                        <td><font class="pn-normal"><b>Designation</b></font><font color="red">*</font></td>
                        <td width=30>&nbsp;</td>
                        <td><font class="pn-normal"><b>Department</b></font><font color="red">*</font></td>
                    </tr>
                    <tr>
                        <td><input type="text" name="dsg" size="25" value="<? echo $designation; ?>"></td>
                        <td width=30>&nbsp;</td>
                        <td>
                            <select name="dpt">
<?
//Get department list
            $query = "SELECT id, department from {$prefix}_jobdepartment";
            $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	            while (list($id, $dpt) = mysql_fetch_row($result))
	            {
	                echo "<option value=$id";
	                    if ($id == $department)
	                    {
	                        echo " selected";
	                    }
	                    echo ">$dpt</option>";
	            }
	            mysql_free_result($result);
?>
                    </select></td>
                    </tr>
                    <tr>
                        <td><font class="pn-normal"><b>Location</b></font><font color="red">*</font></td>
                        <td width=30>&nbsp;</td>
                        <td><font class="pn-normal"><b>Salary</b></font><font color="red">*</font></td>
                    </tr>
                    <tr>
                        <td>
                    <select name="loc">
<?
//Get location list
            $query = "SELECT id, location from {$prefix}_joblocation";
    		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	            while (list($id, $loc) = mysql_fetch_row($result))
	            {
	                echo "<option value=$id";
	                    if ($id == $location)
	                    {
	                        echo " selected";
	                    }
	                    echo ">$loc</option>";
	            }
	            mysql_free_result($result);
?>
                        <select></td>
                        <td width=30>&nbsp;</td>
                        <td>
                        <select name="sal">
<?
//Get salary list
            $query = "SELECT id, salary from {$prefix}_jobsalary";
            $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	            while (list($id, $sal) = mysql_fetch_row($result))
	            {
	                echo "<option value=$id";
	                    if ($id == $salary)
	                    {
	                        echo " selected";
	                    }
	                    echo ">$sal</option>";
	            }
	            mysql_free_result($result);
?>
                    </select></td>
                    </tr>
                    <tr>
                        <td><font class="pn-normal"><b>Responsibilities</b></font><font color="red">*</font></td>
                        <td width=30>&nbsp;</td>
                        <td><font class="pn-normal"><b>Qualifications</b></font><font color="red">*</font></td>
                    </tr>
                    <tr>
                        <td><textarea name="rsp" cols="30" rows="6" wrap=true onKeyUp="CountCharacters();" onBlur="CountCharacters();" onFocus="CountCharacters();" id=txtSkills><? echo $description; ?></textarea><br><SPAN id=SkillsMSG>&nbsp;</SPAN></td>
                        <td width=10>&nbsp;</td>
                        <td><textarea name="qlf" cols="30" rows="6" wrap=true onKeyUp="CountCharacters2();" onBlur="CountCharacters2();" onFocus="CountCharacters2();" id=txtSkills2><? echo $qualification; ?></textarea><br><SPAN id=SkillsMSG2>&nbsp;</SPAN></td>
                    </tr>
                    <tr>
                        <td><font class="pn-normal"><b>Contact person<font color="red">*</font></td>
                        <td width=30><font class="pn-normal"><b> 1=show<br>0=dont</b></font><font color="red">*</font></td>
                        <td><font class="pn-normal"><b>Email address<font color="red">*</font></td>
                    </tr>
                    <tr>
                        <td><select name="cname">
<?
	                echo "<option value=$user_id>$user_id</option>";
?>
                    </select></td>
                        <td width=30><input type="text" name="checked" size="2" value="<? echo $checked; ?>"></td>
                        <td><input type="text" name="cmail" size="25" value="<? echo $cmail; ?>"></td>
                    </tr>
                    <tr>
                        <td align=center colspan=3><input type=submit name=submit value="Update Listing"></td>
                    </tr>
                </table>
            </form>
<?
		}
	}
	else 
	{
//Set up error list array
        $errorList = array();
        $count = 0;

//Validate text input fields
        if (empty($jcode)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Job code</b></font>"; $count++;
        }

        if (empty($dsg)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Designation</b></font>"; $count++;
        }

        if (empty($rsp)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Responsibilities</b></font>"; $count++;
        }

        if (empty($qlf)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Qualifications</b></font>"; $count++;
        }

        if (empty($cname)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Contact name</b></font>"; $count++;
        }

        if (empty($cmail) || isEmailInvalid($cmail)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Email address</b></font>"; $count++;
        }

        if (sizeof($errorList) == 0)
        {
		$query = "UPDATE {$prefix}_joblisting
                            SET designation='$dsg',
                                responsibilities='$rsp',
                                qualifications='$qlf',
                                cname='$cname',
                                cmail='$cmail',
				posted='$posted',
                                fk_department='$dpt',
                                fk_location='$loc',
                                fk_salary='$sal',
				checked='$checked'
                          WHERE jcode='$jcode'";
                $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

        echo "<font class=\"pn-normal\"><b>Entry successfully edited.<p><a href=\"admin.php?cmd=Admin\">Edit another entry</a> or <a href=\"admin.php?cmd=Add\">Add another entry</a></b></font>";
        }
        else
        {
        listErrors();
        }
	}
}
######################
# Deleting a listing #
######################

if($cmd == "Delete")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Delete Job Listing </font></center>";
	CloseTable();
     		OpenTable();

		if (!$jcode || $jcode == "")
		{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
			exit;
		}

	$query = "DELETE FROM {$prefix}_joblisting WHERE jcode = '$jcode'";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	mysql_close($connection);

        echo "<font class=\"pn-normal\"><b>Entry successfully deleted.<p>";
}
######################
# Deleting a client  #
######################
if($cmd == "Deleteclient")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Delete Client </font></center>";
	CloseTable();

		OpenTable();
		

		if (!$Aid || $Aid == "")
		{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
			exit;
		}
        	$query = "DELETE FROM {$prefix}_jobclient WHERE id = '$Aid'";
 			$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        	mysql_close($connection);
		echo "<font class=\"pn-normal\"><b>Entry successfully deleted.<p>";
		CloseTable();
}

###########################
# Searching for a listing #
###########################
if($cmd == "Search")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Search Applicantions </font></center>";
	CloseTable();
	OpenTable();

	if(!$submit)
	{
		echo "<form action=\"admin.php?cmd=Search\" method=\"post\">"; 
		echo "<font class=\"pn-normal\"><b> Display all applications for the post </b></font>";
		echo "<select name=\"jcode\">";

		mysql_select_db($database, $connection) or die('Database Not Found');
        	$query = "SELECT DISTINCT jcode, designation from {$prefix}_joblisting";
        	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

                while(list($jcode, $designation) = mysql_fetch_row($result))
                {
			echo "<option value=$jcode>$designation ($jcode)</option>";
                }
        mysql_free_result($result);
?>
            </select>
            <p><ul>
            <li><font class="pn-normal"><b>with skills matching the keywords</b></font>
            <input type=text name=skills size=35>
            <p>
            <font class="pn-normal"><b> and experience </b></font>
            <select name=exp_modifier>
            <option value="">&lt;unspecified&gt;</option>
            <option value="=">equal to</option>
            <option value=">=">greater than or equal to</option>
            <option value="<=">less than or equal to</option>
            </select>
            <input type=text name=years size=2 maxlength=2>years<p>
            <li><font class="pn-normal"><b>with educational qualifications equivalent to</b><br>
            <select name="degree">
            <option value="">&lt;unspecified&gt;</option>
<?
//Get list of degrees
        $query = "SELECT id, degree from {$prefix}_jobdegree";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
            while(list($id, $degree) = mysql_fetch_row($result))
            {
                echo "<option value=$id>$degree</option>";
            }
        mysql_free_result($result);
?>
            </select> in <select name=subject>
            <option value="">&lt;unspecified&gt;</option>
<?
//Get list of subjects
        $query = "SELECT id, subject from {$prefix}_jobsubject";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
            while(list($id, $subject) = mysql_fetch_row($result))
            {
                echo "<option value=$id>$subject</option>";
            }
        mysql_free_result($result);
?>
            </select>
            </ul>
            <center>
                <input type="submit" name="submit" value="Search">
            </center>
        </form>
<?
	} 
	else 
	{
//Form submitted, search entries  Check for missing parameters 
        	if (!$jcode || $jcode == "")
        	{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
		        exit;
        	}

//Set up basic query and joins
	mysql_select_db($database, $connection) or die('Database Not Found');
	$query = "SELECT DISTINCT
		{$prefix}_jobuser.rid,
		{$prefix}_jobuser.lname,
		{$prefix}_jobuser.fname,
		{$prefix}_jobuser.email
	from    {$prefix}_jobuser,
		{$prefix}_jobskill,
		{$prefix}_jobeducation
	WHERE   {$prefix}_jobuser.jcode = '$jcode'";

//If skills criteria selected 
		if(!empty($skills) && !empty($exp_modifier) && !empty($years))
		{
			$query .= " AND {$prefix}_jobuser.rid = {$prefix}_jobskill.rid  AND (";
			$keywords = split(" ", $skills);
			for ($x=0; $x<sizeof($keywords); $x++)
			{
				trim($keywords[$x]);
				if($x != 0)
				{
					$query .= " AND";
                                }
			$query .= " ({$prefix}_jobskill.skill LIKE '%" . $keywords[$x] ."%' AND {$prefix}_jobskill.experience " .  $exp_modifier . $years . " )";
			}
                        $query .= ")";
		}

                if(!empty($degree) && !empty($subject))
                {
			$query .= " AND {$prefix}_jobuser.rid = {$prefix}_jobeducation.rid AND {$prefix}_jobeducation.fk_degree = '$degree' AND {$prefix}_jobeducation.fk_subject = '$subject'";
                }

        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	$count = mysql_num_rows($result);

	echo "<font class=\"pn-normal\"><b>Your search returned   $count match(es)</b></font><p><ul>";
	
		while (list($rid, $lname, $fname, $email) = mysql_fetch_row($result))
		{
			echo "<li><a href=\"admin.php?cmd=Resume_Details&rid=$rid\">$lname, $fname &lt;$email&gt;</a>";
        	}
	echo "<ul>";
	}
}

#####################
# Building a resume #
#####################
if($cmd == "Resume_Details")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Resume Details </font></center>";
	CloseTable();
	OpenTable();

        if (!$rid || $rid == "")
        {
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='admin.php?cmd=Error'";
		echo "</SCRIPT>";
 	       exit;
        }

	mysql_select_db($database, $connection) or die('Database Not Found');
        $query = "SELECT fname,
                        lname,
                        dob,
                        addr1,
                        addr2,
                        city,
                        state,
                        zip,
                        country,
                        phone,
                        email,
                        url,
                        relo,
                        posted
                FROM    {$prefix}_jobuser,
                        {$prefix}_jobcountry
                WHERE   {$prefix}_jobuser.fk_country = {$prefix}_jobcountry.id
                AND     rid = '$rid'";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

	if (mysql_num_rows($result) <= 0)
	{
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='admin.php?cmd=Error'";
		echo "</SCRIPT>";
		exit;
	}
	else
	{
//Obtain data from query
            list(
                $fname,
                $lname,
                $dob,
                $addr1,
                $addr2,
                $city,
                $state,
                $zip,
                $country,
                $phone,
                $email,
                $url,
                $relo,
                $posted) = mysql_fetch_row($result);

	echo "<br><br><img src=\"lang/".$currentlang."/Personal".$currentlang.".gif\" border=\"1\">"; ?>
    <br><font class="pn-normal">
    <b>Name:</b></font>
<? 	echo $fname . " " . $lname; ?>
    <p><b><font class="pn-normal"><b>Date of birth:</b></font>
<? 	echo "$dob"; ?>
    <p><font class="pn-normal">
    <b>Address:</b><br></font>
<? 	echo "<font class=\"pn-normal\"><b>$addr1<br></b></font>";
	if($addr2)
	{
                echo "<font class=\"pn-normal\"><b>$addr2<br></b></font>";
	}
		echo "<font class=\"pn-normal\"><b>$city $zip<br>$state, $country</b></font>"; ?>
    <p><b><font class="pn-normal"><b>Phone:</b>
<? 	echo $phone; ?>
    <p><font class="pn-normal"><b>Email address: </b><a href="mailto:<? echo $email; ?>"><? echo $email; ?></a>
    <p><font class="pn-normal"><b>Comments:</b></font>
<? 	if($url)
	{
		echo "<font class=\"pn-normal\">$url</font>";
	}
	else 
	{
           	echo "<font class=\"pn-normal\">None</font>";
	}
?>
<p>
<?
//Get education history
        $query = "SELECT institute,
                         degree,
                         subject,
                         year
                  FROM   {$prefix}_jobeducation,
                         {$prefix}_jobdegree,
                         {$prefix}_jobsubject
                  WHERE  {$prefix}_jobeducation.fk_degree = {$prefix}_jobdegree.id
                  AND    {$prefix}_jobeducation.fk_subject = {$prefix}_jobsubject.id
                  AND    rid = '$rid'
                  ORDER BY year";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

            if(mysql_num_rows($result) > 0){
                echo "<br><br><img src=\"lang/".$currentlang."/Education".$currentlang.".gif\" border=\"1\"><br>";

                while (list($institute, $degree, $subject, $year ) = mysql_fetch_row($result)){
                    echo "<font class=\"pn-normal\"><b>Institute:</b> $institute<br></font>";
                    echo "<font class=\"pn-normal\"><b>Degree:</b> $degree ($subject, $year)<p></font>";
                }
            }

//Get employment history
        $query = "SELECT employer,
                         industry,
                         start_year,
                         end_year,
                         responsibilities
                   FROM  {$prefix}_jobemployment,
                         {$prefix}_jobindustry
                   WHERE {$prefix}_jobemployment.fk_industry = {$prefix}_jobindustry.id
                   AND   rid = '$rid'
                   ORDER BY end_year";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

            if(mysql_num_rows($result) > 0){
                echo "<br><br><img src=\"lang/".$currentlang."/Employment".$currentlang.".gif\" border=\"1\"><br>";
                while (list($employer, $industry, $start_year, $end_year, $responsibilities) = mysql_fetch_row($result))
                {
			echo "<font class=\"pn-normal\"><b>Employer</b>: $employer ($start_year-$end_year)<br></font>";
			echo "<font class=\"pn-normal\"><b>Industry</b>: $industry<br></font>";
			echo "<font class=\"pn-normal\"><b>Responsibilities</b>: <br>$responsibilities<p></font>";
                }
	}

//Get skills
        $query = "SELECT skill,experience
		FROM   {$prefix}_jobskill
		WHERE  rid = '$rid' 
		ORDER BY experience";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

	if(mysql_num_rows($result) > 0)
	{
		echo "<br><br><img src=\"lang/".$currentlang."/Skills".$currentlang.".gif\" border=\"1\"><br>";
                while (list($skill, $experience) = mysql_fetch_row($result))
                {
			echo "<font class=\"pn-normal\"><b>$skill</b><br></font>";
			echo "<font class=\"pn-normal\"><b>$experience years experience<p></b></font>";
		}
	}

//Get references
        $query = "SELECT name,
		phone,
		email 
	FROM   {$prefix}_jobreference
	WHERE rid = '$rid'";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	if(mysql_num_rows($result) > 0)
	{
		echo "<br><br><img src=\"lang/".$currentlang."/References".$currentlang.".gif\" border=\"1\"><br>";
                while (list($name, $phone, $ref_email) = mysql_fetch_row($result))
                {
			echo "<font class=\"pn-normal\"><b>Name:</b> $name<br></font>";
			echo "<font class=\"pn-normal\"><b>Phone:</b> $phone<br></font>";
			if ($ref_email) 
			{
				echo "<font class=\"pn-normal\"><b>Email address:</b> <a href=mailto:$ref_email>$ref_email</a><p></font>";
			} 
			else 
			{
                        echo "<p>";
			}
		}
	}
	echo "<img src=\" lang/".$currentlang."/Miscellaneous".$currentlang.".gif\" border=\"1\">";?>
	<br><font class=\"pn-normal\"><b>Willing to relocate:</b></font>
<?
	if($relo == 1) 
	{
		echo "<font class=\"pn-normal\"><b>Yes</b></font>";
	} 
	else 
	{
		echo "<font class=\"pn-normal\"><b>No</b></font>";
	}
	echo "<p>Resume posted on <b>";
	fixDate($posted);
	echo "</b><p>";

	}
}

#####################
# departments Admin #
#####################
if($cmd == "Departments")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Departments Admin </font></center>";
	CloseTable();

		OpenTable();
		

		echo "Departments :<table width=\"100%\">";
		$query = "SELECT {$prefix}_jobdepartment.id,
			{$prefix}_jobdepartment.department
		FROM    {$prefix}_jobdepartment 
		ORDER by department asc";
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	
		while (list($id, $department) = mysql_fetch_row($result))
		{
			echo "<tr><td>$id&nbsp;-&nbsp;&nbsp;$department </td><td align=\"right\">&nbsp;<a href=\"admin.php?cmd=EditDepartment&id=$id\">"._ADMINEDIT."</a>&nbsp;&nbsp;<a href=\"admin.php?cmd=DeleteDepartment&id=$id\">"._ADMINDELETE."</a>&nbsp;$id</td></tr>";	
		}

		echo "</table><br>";
		echo "Create a new Department <br><br>";
		echo "<form action=\"admin.php?cmd=NewDepartment\" method=\"post\">";
		echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\"><tr><td><input type=\"text\" name=\"department\"></td><td><input type=submit name=submit value=\"Submit\"></td></tr></table></form>";
}

######################
# delete departments #
######################
if($cmd == "DeleteDepartment")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Delete Job Department </font></center>";
	CloseTable();

		OpenTable();
		OpenTable();
		

	if (!$id || $id == "")
	{
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='admin.php?cmd=Error'";
		echo "</SCRIPT>";
		exit;
	}

        $query = "DELETE FROM {$prefix}_jobdepartment WHERE id = '$id'";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        mysql_close($connection);

        echo "<font class=\"pn-normal\"><b>Department [ $id ] successfully deleted.<p><a href=\"admin.php?cmd=Departments\">View Department's</a>";
}
######################
# Edit   departments #
######################
if($cmd == "EditDepartment")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Edit Job Departments </font></center>";
	CloseTable();

        OpenTable();
		

		if (!$id || $id == "")
		{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
        	exit;
        }

	        if (!$submit)
	        {
	   		mysql_select_db($database, $connection) or die('Database Not Found');
        		$query = "SELECT department
                            FROM {$prefix}_jobdepartment
                            WHERE id = '$id'";
    			$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

			if (mysql_num_rows($result) <= 0)
			{
				echo "<SCRIPT LANGUAGE='JavaScript'>";
				echo "document.location.href='admin.php?cmd=Error'";
				echo "</SCRIPT>";
				exit;
			}
			else
			{
//Obtain data from query
				list($department) = mysql_fetch_row($result);

				mysql_free_result($result);
?>
			<table><tr><td>
			<table border="0" cellspacing="2" cellpadding="0">
			<tr><td><? echo "<form action=\"admin.php?cmd=EditDepartment\" method=\"post\">"; ?>Department</td></tr>
			<tr><td><input type="hidden" name="id" value="<? echo"$id";?>"><input type="text" name="department" value="<? echo"$department";?>"></td></tr>
			<tr><td><input type=submit name=submit value="Submit"></form></td></tr>
			</table></td><td></td></tr></table>
<?
        		}
    		} 
    		else 
    		{
//Set up error list array
        		$errorList = array();
        		$count = 0;

//Validate text input fields
        		if (empty($department)) 
        		{
			$errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: department</b></font>"; $count++;
        		}


        		if (sizeof($errorList) == 0)
        		{
                		$query = "UPDATE {$prefix}_jobdepartment
					SET department='$department'
					WHERE id='$id'";
				$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

				echo "<font class=\"pn-normal\"><b>Department successfully edited.<p><a href=\"admin.php?cmd=Departments\">Department another entry</a> or <a href=\"admin.php?cmd=NewDepartment\">Add another entry</a></b></font>";
				}
				else
				{
				listErrors();
				}
			}
}
##################
# Add Department #
##################
if($cmd == "NewDepartment")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Create New Department</font></center>";
	CloseTable();

		OpenTable();
		

// form not yet submitted
		if (!$submit)
		{
?>
		<table><tr><td>
		<table border="0" cellspacing="2" cellpadding="0">
		<tr><td><? echo "<form action=\"admin.php?cmd=NewDepartment\" method=\"post\">"; ?>Department</td></tr>
		<tr><td><input type="text" name="department"></td></tr>
		<tr><td><input type=submit name=submit value="Submit"></form></td></tr>
		</table></td><td></td></tr></table>
<?
		}
// form submitted, process it
		else
		{

// set up error list array
			$errorList = array();
			$count = 0;

// validate text input fields
			if (empty($department)) { $errorList[$count] = "Invalid entry: department"; $count++; }

			if (sizeof($errorList) == 0)
			{
				$query = "INSERT INTO {$prefix}_jobdepartment (department) VALUES ('$department')";
				$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
				mysql_close($connection);
				echo "Your new department has been created.<p><a href=\"admin.php?cmd=Departments\">View Department's</a>";

			}
			else
			{
			listErrors();
	  		}
		}
}

################
# salary Admin #
################
if($cmd == "salary")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\">Salary Admin </font></center>";
	CloseTable();

    		OpenTable();
			

		$query = "SELECT {$prefix}_jobsalary.id,
			{$prefix}_jobsalary.salary
		FROM    {$prefix}_jobsalary
		ORDER by salary asc";
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
		echo "<table>";
		while (list($id, $salary) = mysql_fetch_row($result))
		{
			echo "<tr><td>$id&nbsp;-&nbsp;&nbsp;$salary </td><td align=\"right\">&nbsp;<a href=\"admin.php?cmd=Editsalary&id=$id\">"._ADMINEDIT."</a>&nbsp;&nbsp;<a href=\"admin.php?cmd=Deletesalary&id=$id\">"._ADMINDELETE."</a>&nbsp;$id</td></tr>";	
		}
		echo "</table><br>";
		echo "Create a new salary <br><br>";
 		echo "<form action=\"admin.php?cmd=Newsalary\" method=\"post\">"; 
		echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\"><tr><td><input type=\"text\" name=\"salary\"></td><td><input type=submit name=submit value=\"Submit\"></td></tr></table></form>";
}
#################
# delete salary #
#################
if($cmd == "Deletesalary")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Delete Job Salary </font></center>";
	CloseTable();

		OpenTable();
		
		
		if (!$id || $id == "")
		{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
			exit;
		}

        $query = "DELETE FROM {$prefix}_jobsalary WHERE id = '$id'";
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
		mysql_close($connection);

        echo "<font class=\"pn-normal\"><b>Salary [ $id ] successfully deleted.<p><a href=\"admin.php?cmd=salary\">View Salary's</a>";
		CloseTable();	
}
#################
# Edit   salary #
#################
if($cmd == "Editsalary")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Edit Job Salary </font></center>";
	CloseTable();

		OpenTable();
		

		if (!$id || $id == "")
		{
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='admin.php?cmd=Error'";
		echo "</SCRIPT>";
        	exit;
        	}

        if (!$submit)
        {
		mysql_select_db($database, $connection) or die('Database Not Found');
        	$query = "SELECT salary
			from {$prefix}_jobsalary
			WHERE id = '$id'";
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

		if (mysql_num_rows($result) <= 0)
		{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
			exit;
		} 
		else 
		{
			list($salary) = mysql_fetch_row($result);
			mysql_free_result($result);
?>
		<table><tr><td>
		<table border="0" cellspacing="2" cellpadding="0">
			<tr><td><? echo "<form action=\"admin.php?cmd=Editsalary\" method=\"post\">"; ?>Department</td></tr>
			<tr><td><input type="hidden" name="id" value="<? echo"$id";?>"><input type="text" name="salary" value="<? echo"$salary";?>"></td></tr>
			<tr><td><input type=submit name=submit value="Submit"></form></td></tr>
		</table></td><td></td></tr></table>
<?
		}
    		} 
    		else 
    		{
//Set up error list array 
        		$errorList = array();
        		$count = 0;

//Validate text input fields
        		if (empty($salary))
        		{
            			$errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: salary</b></font>"; $count++;
        		}


        		if (sizeof($errorList) == 0)
        		{
                		$query = "UPDATE {$prefix}_jobsalary
                            		SET salary='$salary'
                                    	WHERE id='$id'";
    				$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

        			echo "<font class=\"pn-normal\"><b>Salary successfully edited.<p><a href=\"admin.php?cmd=salary\">Salary another entry</a> or <a href=\"admin.php?cmd=Newsalary\">Add another entry</a></b></font>";
        		}
        		else
        		{
        			listErrors();
      			}
    		}
}
##################
# Add Salary	 #
##################
if($cmd == "Newsalary")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Create New salary</font></center>";
	CloseTable();

		OpenTable();
		

		if (!$submit)
		{
?>
		<table><tr><td>
		<table border="0" cellspacing="2" cellpadding="0">
			<tr><td><? echo "<form action=\"admin.php?cmd=Newsalary\" method=\"post\">"; ?>Salary</td></tr>
			<tr><td><input type="text" name="salary"></td></tr>
			<tr><td><input type=submit name=submit value="Submit"></form></td></tr>
		</table></td><td></td></tr></table>
<?
		}
		else
		{
// set up error list array
			$errorList = array();
			$count = 0;
// validate text input fields
			if (empty($salary)) { $errorList[$count] = "Invalid entry: salary"; $count++; }

			if (sizeof($errorList) == 0)
			{
				$query = "INSERT INTO {$prefix}_jobsalary (salary) VALUES ('$salary')";
    				$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	
				mysql_close($connection);
				echo "Your new salary has been created.<p><a href=\"admin.php?cmd=salary\">View salary's</a>";
			}
			else
			{
			listErrors();
	  		}
		}
}


##################
# Location Admin #
##################
if($cmd == "location")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\">Location Admin </font></center>";
	CloseTable();
		OpenTable();
		

		$query = "SELECT {$prefix}_joblocation.id,
					{$prefix}_joblocation.location
		FROM   			 {$prefix}_joblocation
		ORDER by location asc";
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
		echo "<table>";
		while (list($id, $location) = mysql_fetch_row($result))	
		{
			echo "<tr><td>$id&nbsp;-&nbsp;&nbsp;$location </td><td align=\"right\">&nbsp;<a href=\"admin.php?cmd=Editlocation&id=$id\">"._ADMINEDIT."</a>&nbsp;&nbsp;<a href=\"admin.php?cmd=Deletelocation&id=$id\">"._ADMINDELETE."</a>&nbsp;$id</td></tr>";	
		}
		mysql_free_result($result);
	
		echo "</table><br>";
		echo "Create a new location <br><br>";
		echo "<form action=\"admin.php?cmd=Newlocation\" method=\"post\">";
		echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\"><tr><td><input type=\"text\" name=\"location\"></td><td><input type=submit name=submit value=\"Submit\"></td></tr></table></form>";
}
###################
# delete location #
###################
if($cmd == "Deletelocation")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Delete Job Location </font></center>";
	CloseTable();
		OpenTable();
		
		
		if (!$id || $id == "")
		{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
			exit;
		}

        $query = "DELETE FROM {$prefix}_joblocation WHERE id = '$id'";
    	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        mysql_close($connection);

        echo "<font class=\"pn-normal\"><b>location [ $id ] successfully deleted.<p><a href=\"admin.php?cmd=location\">View location's</a>";
}
#################
# Edit location #
#################
if($cmd == "Editlocation")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Edit Job location </font></center>";
	CloseTable();

		OpenTable();
		
	
		if (!$id || $id == "")
		{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
        		exit;
        	}
	
	        if (!$submit)
	        {
			$query = "SELECT location
			from {$prefix}_joblocation
			WHERE id = '$id'";
			$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	
			if (mysql_num_rows($result) <= 0)
			{
				echo "<SCRIPT LANGUAGE='JavaScript'>";
				echo "document.location.href='admin.php?cmd=Error'";
				echo "</SCRIPT>";
				exit;
			} 
			else 
			{
				list($location) = mysql_fetch_row($result);
				mysql_free_result($result);
?>
	<table><tr><td>
	<table border="0" cellspacing="2" cellpadding="0">
	<tr><td><? echo "<form action=\"admin.php?cmd=Editlocation\" method=\"post\">"; ?>location</td></tr>
	<tr><td><input type="hidden" name="id" value="<? echo"$id";?>"><input type="text" name="location" value="<? echo"$location";?>"></td></tr>
	<tr><td><input type=submit name=submit value="Submit"></form></td></tr>
	</table></td><td></td></tr></table>
<?
			}
	    	} 
	    	else 
	    	{
	
	        	$errorList = array();
	        	$count = 0;
			if (empty($location)) 
			{
				$errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: location</b></font>"; $count++;
		        }
	
	
	        	if (sizeof($errorList) == 0)
	        	{
	                	$query = "UPDATE {$prefix}_joblocation SET location='$location' WHERE id='$id'";
	                	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
			        echo "<font class=\"pn-normal\"><b>location successfully edited.<p><a href=\"admin.php?cmd=location\">Go to location's</a> or <a href=\"admin.php?cmd=Newsalary\">Add another entry</a></b></font>";
	        	}
	        	else
	        	{
	        		listErrors();
	      		}
	    	}
}
##################
# Add Salary	 #
##################

if($cmd == "Newlocation")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Create New location</font></center>";
	CloseTable();

		OpenTable();
		
		if (!$submit)
		{
?>
	<table><tr><td>
	<table border="0" cellspacing="2" cellpadding="0">
	<tr><td><? echo "<form action=\"admin.php?cmd=Newlocation\" method=\"post\">"; ?>location</td></tr>
	<tr><td><input type="text" name="location"></td></tr>
	<tr><td><input type=submit name=submit value="Submit"></form></td></tr>
	</table></td><td></td></tr></table>
<?
		}
		else
		{

// set up error list array
			$errorList = array();
			$count = 0;

// validate text input fields
			if (empty($location)) { $errorList[$count] = "Invalid entry: location"; $count++; }

			if (sizeof($errorList) == 0)
			{
				$query = "INSERT INTO {$prefix}_joblocation (location) VALUES ('$location')";
    				$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

				mysql_close($connection);
				echo "Your new location has been created.<p><a href=\"admin.php?cmd=location\">View location's</a>";
			}
			else
			{
				listErrors();
	  		}
		}
}
#################
# DisplayConfig #
#################
if($cmd == "DisplayConfig")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Configuration </font></center>";
	CloseTable();

		OpenTable();
		
		// display details of phprofession configuration.
		echo "<table cellpadding=\"2\" border=\"0\">";
		echo "<tr><td colspan=\"2\"><b>$ModuleDirName config details</b></td></tr>";
		echo "<tr><td colspan=\"2\"> Loged in as : $user</td></tr>";
		echo "<tr><td>Your database</td><td bgcolor=\"c0c0c0\">			$database</td></tr>";
		echo "<tr><td>Database host</td><td bgcolor=\"c0c0c0\">			$hostname</td></tr>";
		echo "<tr><td>Prefix</td><td bgcolor=\"c0c0c0\">			$prefix</td></tr>";
		echo "<tr><td>Start page</td><td bgcolor=\"c0c0c0\">			$startpage</td></tr>";
		echo "<tr><td>Admin Email</td><td bgcolor=\"c0c0c0\">  			$Admin_Email</td></tr>";
		echo "<tr><td>Phprofession version</td><td bgcolor=\"c0c0c0\">		$Version</td></tr>";
		echo "<tr><td>Phprofession language</td><td bgcolor=\"c0c0c0\">		$language</td></tr>";
		echo "<tr><td>Website Url</td><td bgcolor=\"c0c0c0\">	  		$websiteurl</td></tr>";
		echo "<tr><td>Accept files types</td><td bgcolor=\"c0c0c0\">		$acceptable_file_types</td></tr>";
		echo "<tr><td>Resume Upload Path</td><td bgcolor=\"c0c0c0\">		$path</td></tr>";
		echo "<tr><td>Default uploaded file extention</td><td bgcolor=\"c0c0c0\">$default_extension</td></tr>";
		echo "<tr><td>File Upload Mode</td><td bgcolor=\"c0c0c0\">		$mode</td></tr>";
		echo "<tr><td>Height of pop up box</td><td bgcolor=\"c0c0c0\">		$height</td></tr>";
		echo "<tr><td>Width of pop up box</td><td bgcolor=\"c0c0c0\">		$width</td></tr>";
		echo "<tr><td>Logo path for pop up box</td><td bgcolor=\"c0c0c0\">	$logopath</td></tr>";
		echo "<tr><td>Min Number of jobs listed per page</td><td bgcolor=\"c0c0c0\">	$listings</td></tr>";
		echo "<tr><td>Max Number of jobs listed per page</td><td bgcolor=\"c0c0c0\">	$maxlisting</td></tr>";
		echo "<tr><td>Number of days till job expires</td><td bgcolor=\"c0c0c0\">	$days</td></tr>";
		echo "<tr><td>Limit of chariters in job form</td><td bgcolor=\"c0c0c0\">	$limit</td></tr>";
		echo "<tr><td colspan=\"2\"><b>User options 0=off 1=on</b><br></td>";
		echo "<tr><td>Allow members accounts</td><td bgcolor=\"c0c0c0\">	$allowpost </td></tr>";
		echo "<tr><td>Waiting content</td><td bgcolor=\"c0c0c0\">		$WaitingContent </td></tr>";
		echo "<tr><td>Error redirect </td><td bgcolor=\"c0c0c0\">		$redirect_error </td></tr>";
		echo "<tr><td>create login sucess url </td><td bgcolor=\"c0c0c0\">	$create_login_success </td></tr>";
		echo "<tr><td>login sucess </td><td bgcolor=\"c0c0c0\">$login_success </td></tr>";
		echo "<tr><td>terms for user accounts </td><td bgcolor=\"c0c0c0\">$terms </td></tr>";
		echo "<tr><td colspan=\"2\"><b>Apply form display options</b><br></td>";
		echo "<tr><td>Fields to display in Education section</td><td bgcolor=\"c0c0c0\">		$Education_Section</td></tr>";
		echo "<tr><td>Fields to display in Employment History section</td><td bgcolor=\"c0c0c0\">	$Employment_History</td></tr>";
		echo "<tr><td>Fields to display in Skills section</td><td bgcolor=\"c0c0c0\">			$Skills_Section</td></tr>";
		echo "<tr><td>Fields to display in References section</td><td bgcolor=\"c0c0c0\">		$References</td></tr>";
		echo "<tr><td colspan=\"2\"> <b>module url links</b><br></td>";
		echo "<tr><td>Module Dir Name</td><td bgcolor=\"c0c0c0\">		$ModuleDirName</td></tr>";
		echo "<tr><td>Admin Dir Name</td><td bgcolor=\"c0c0c0\">		$AdminDirName</td></tr>";
		echo "<tr><td>Module Base Path</td><td bgcolor=\"c0c0c0\">		$ModuleBasePath</td></tr>";
		echo "<tr><td>Module Base Url</td><td bgcolor=\"c0c0c0\">	 	$ModuleBaseUrl </td></tr>";
		echo "<tr><td>Module Admin Url</td><td bgcolor=\"c0c0c0\">		$ModuleAdminUrl</td></tr>";
		echo "<tr><td>Module Upload Url</td><td bgcolor=\"c0c0c0\">		$ModuleUploadUrl</td></tr>";
		echo "</tr></table>";
}

#################
# ResumeUploads #
#################
if($cmd == "ResumeUploads")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Resume Uploads </font></center>";
	CloseTable();
	OpenTable();
	mysql_select_db($database, $connection) or die('Database Not Found');
	$query = "SELECT {$prefix}_jobresume.id, {$prefix}_jobresume.cvname, {$prefix}_jobresume.cvphone, {$prefix}_jobresume.cvemail, {$prefix}_jobresume.source_name, {$prefix}_jobresume.jcode, {$prefix}_jobresume.ip_address, {$prefix}_jobresume.host FROM {$prefix}_jobresume order by id desc";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	echo "<table width=\"100%\"><tr><td><b>ID</b></td><td><b>Name</b></td><td><b>Phone</b>:</td><td><b>File Name</b></td><td><b>Email</b></td><td><b>Job Code</b></td><td><b>IP Address</b></td><td><b>Host</b></td></tr>";
	
	while (list($id, $cvname, $cvphone, $cvemail, $source_name, $jcode, $ip_address, $host) = mysql_fetch_row($result))
	{
		echo "<tr bgcolor=\"#CCCCCC\"><td>$id </td><td>$cvname </td><td>$cvphone</td><td><a href=\"upload/$source_name\">$source_name</a></td><td><a href=mailto:$cvemail><b>$cvemail</b></a></td><td><a href=\"admin.php?cmd=Details&jcode=$jcode\">$jcode</a></td><td>$ip_address</td><td>$host</td></tr>";	
	}
		echo "</table>";
}
/*
// this section will only be in place if the file of the server is deleted as well.
#################
# DeleteUploads #
#################
if($cmd == "DeleteUploads")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Delete Upload </font></center>";
	CloseTable();

		OpenTable();
		

		if (!$id || $id == "")
		{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
			exit;
		}
        	$query = "DELETE FROM {$prefix}_jobresume WHERE id = '$id'";
 			$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        	mysql_close($connection);
		echo "<font class=\"pn-normal\"><b>Entry successfully deleted.<p>";
		CloseTable();
}
*/
#################
# Waiting       #
#################
if($cmd == "Waiting")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Waiting Content </font></center>";
	CloseTable();
		OpenTable();
		
	if (!$offset) $offset=0; 
	mysql_select_db($database, $connection) or die('Database Not Found');
	$query = "select count(*) from {$prefix}_joblisting WHERE {$prefix}_joblisting.checked=1";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

	list($numrec)=mysql_fetch_row($result);

	$numpage=intval($numrec/$limit);
	if ($numrec%$limit) 
	{
		$numpage++;
	} // add one page if remainder
	print("<table width=100% border=0 cellspacing=2><tr bgcolor=whitesmoke><td>&nbsp;&nbsp;<b>"._JOBTITLETXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBLOCATIONTXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBSALARYTXT."</b></td><td>&nbsp;&nbsp;<b>"._JOBPOSTED."</b></td><td>&nbsp;</td></tr>");
        mysql_select_db($database, $connection) or die('Database Not Found');
   	$query = "SELECT {$prefix}_jobtemplisting.designation,
			 {$prefix}_jobtemplisting.jcode,
			 {$prefix}_joblocation.location,
			 {$prefix}_jobsalary.salary,
			 {$prefix}_jobtemplisting.posted
		from	 {$prefix}_jobtemplisting,
			 {$prefix}_joblocation,
			 {$prefix}_jobsalary
		WHERE {$prefix}_joblocation.id = {$prefix}_jobtemplisting.fk_location
		AND	 {$prefix}_jobsalary.id = {$prefix}_jobtemplisting.fk_salary
		order by posted desc limit $offset,$limit";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	while (list($designation, $jcode, $location, $salary, $posted) = mysql_fetch_row($result)) 
	{
		print ("<tr height=16>\n".
		"<td>&nbsp;&nbsp;<a href=\"admin.php?cmd=TempDetails&jcode=$jcode\"><b>$designation</b></a></td><td>&nbsp;&nbsp;$location</td><td>&nbsp;&nbsp;$salary</td><td>&nbsp;&nbsp;".fixDate($posted).
		"</td><td>&nbsp;&nbsp;<a href=\"admin.php?cmd=DeleteTemp\">".
		"<img src=lang/".$currentlang."/delete".$currentlang.".gif border=0 alt=\""._JOBAPPLYALT."\"></a></td></tr>\n");
	}
	mysql_close($connection);
	print("</table>");

//<!-- result display loop next prev buttons-->
	if ($numpage>1) 
		{
		pagenav();
		}
}

#################
#  TempDetails  #
#################
if($cmd == "TempDetails")
{
	OpenTable();
	Echo "<br><center><font class=\"pn-Title\">Review This Availiable Position</font></center>";
	CloseTable();
		OpenTable();
		
        if (!$jcode || $jcode == "")
        {
		echo "<SCRIPT LANGUAGE='JavaScript'>";
		echo "document.location.href='admin.php?cmd=Error'";
		echo "</SCRIPT>";
        	exit;
        }

        if (!$submit)
        {
	mysql_select_db($database, $connection) or die('Database Not Found');
        $query = "SELECT designation,
                        jcode,
                        fk_department,
                        fk_location,
                        fk_salary,
                        responsibilities,
                        qualifications,
                        cname,
                        cmail,
			checked,
			posted
                   from {$prefix}_jobtemplisting
                   WHERE jcode = '$jcode'";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

		if (mysql_num_rows($result) <= 0)
		{
			echo "<SCRIPT LANGUAGE='JavaScript'>";
			echo "document.location.href='admin.php?cmd=Error'";
			echo "</SCRIPT>";
        		exit;
		}
		else 
		{
			list($designation,
                        $jcode,
                        $department,
                        $location,
                        $salary,
                        $description,
                        $qualification,
                        $cname,
						$cmail,
						$checked,
                        $posted) = mysql_fetch_row($result);
			mysql_free_result($result);

	echo "<table border=\"0\" cellspacing=\"5\" cellpadding=\"2\">";
	echo "<form action=\"admin.php?cmd=TempDetails&jcode=$jcode\" method=\"POST\">"; 
?>
<SCRIPT language=Javascript>
<!--
function CountCharacters() {
var sLimit = <? echo "$limit"; ?>;
if (sLimit < (document.forms[0].txtSkills.value).length) {
SkillsMSG.innerHTML = "<font class=small size=1 face=Arial>Characters exceeded by: " + ((document.forms[0].txtSkills.value).length - sLimit) + "</font>";
} else {
SkillsMSG.innerHTML = "<font class=small size=1 face=Arial>Characters remaining: " + (<? echo "$limit"; ?>- (document.forms[0].txtSkills.value).length) + "</font>";
	}
}

function CountCharacters2() {
var sLimit = <? echo "$limit"; ?>;
if (sLimit < (document.forms[0].txtSkills.value).length) {
SkillsMSG2.innerHTML = "<font class=small size=1 face=Arial>Characters exceeded by: " + ((document.forms[0].txtSkills2.value).length - sLimit) + "</font>";
} else {
SkillsMSG2.innerHTML = "<font class=small size=1 face=Arial>Characters remaining: " + (<? echo "$limit"; ?>- (document.forms[0].txtSkills2.value).length) + "</font>";
	}
}
//-->
</SCRIPT><tr>
                <td><font class="pn-normal"><b>Job Code</b></font></td>
                <td width=30>&nbsp;</td>
                <td><font class="pn-normal"><b>Date posted</b></font><font color="red">*</font></td>
                </tr>
				<tr>
				<td><? echo $jcode; ?></td>
				<td width=30>&nbsp;</td>
				<td><input type=text name="posted" value="<? echo $posted; ?>"></td>
				</tr>
                         <!--                    Job details                -->
                    <tr>
                        <td><font class="pn-normal"><b>Designation</b></font><font color="red">*</font></td>
                        <td width=30>&nbsp;</td>
                        <td><font class="pn-normal"><b>Department</b></font><font color="red">*</font></td>
                    </tr>
                    <tr>
                        <td><input type="text" name="dsg" size="25" value="<? echo $designation; ?>"></td>
                        <td width=30>&nbsp;</td>
                        <td>
                            <select name="dpt">
<?
//Get department list
            $query = "SELECT id, department from {$prefix}_jobdepartment";
            $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	            while (list($id, $dpt) = mysql_fetch_row($result))
	            {
	                echo "<option value=$id";
	                    if ($id == $department)
	                    {
	                        echo " selected";
	                    }
	                    echo ">$dpt</option>";
	            }
	            mysql_free_result($result);
?>
                    </select></td>
                    </tr>
                    <tr>
                        <td><font class="pn-normal"><b>Location</b></font><font color="red">*</font></td>
                        <td width=30>&nbsp;</td>
                        <td><font class="pn-normal"><b>Salary</b></font><font color="red">*</font></td>
                    </tr>
                    <tr>
                        <td>
                    <select name="loc">
<?
//Get location list
            $query = "SELECT id, location from {$prefix}_joblocation";
    		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	            while (list($id, $loc) = mysql_fetch_row($result))
	            {
	                echo "<option value=$id";
	                    if ($id == $location)
	                    {
	                        echo " selected";
	                    }
	                    echo ">$loc</option>";
	            }
	            mysql_free_result($result);
?>
                        <select></td>
                        <td width=30>&nbsp;</td>
                        <td>
                        <select name="sal">
<?
//Get salary list
            $query = "SELECT id, salary from {$prefix}_jobsalary";
            $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	            while (list($id, $sal) = mysql_fetch_row($result))
	            {
	                echo "<option value=$id";
	                    if ($id == $salary)
	                    {
	                        echo " selected";
	                    }
	                    echo ">$sal</option>";
	            }
	            mysql_free_result($result);
?>
                    </select></td>
                    </tr>
                    <tr>
                        <td><font class="pn-normal"><b>Responsibilities</b></font><font color="red">*</font></td>
                        <td width=30>&nbsp;</td>
                        <td><font class="pn-normal"><b>Qualifications</b></font><font color="red">*</font></td>
                    </tr>
                    <tr>
                        <td><textarea name="rsp" cols="30" rows="6" wrap=true onKeyUp="CountCharacters();" onBlur="CountCharacters();" onFocus="CountCharacters();" id=txtSkills><? echo $description; ?></textarea><br><SPAN id=SkillsMSG>&nbsp;</SPAN></td>
                        <td width=10>&nbsp;</td>
                        <td><textarea name="qlf" cols="30" rows="6" wrap=true onKeyUp="CountCharacters2();" onBlur="CountCharacters2();" onFocus="CountCharacters2();" id=txtSkills2><? echo $qualification; ?></textarea><br><SPAN id=SkillsMSG2>&nbsp;</SPAN></td>
                    </tr>
                    <tr>
                        <td><font class="pn-normal"><b>Contact person<font color="red">*</font></td>
                        <td width=30><font class="pn-normal"><b> 1=show<br>0=dont</b></font><font color="red">*</font></td>
                        <td><font class="pn-normal"><b>Email address<font color="red">*</font></td>
                    </tr>
                    <tr>
                        <td><input type="text" name="cname" size="25" value="<? echo $cname; ?>"></td>
                        <td width=30><input type="text" name="checked" size="2" value="<? echo $checked; ?>"></td>
                        <td><input type="text" name="cmail" size="25" value="<? echo $cmail; ?>"></td>
                    </tr>
                    <tr>
                        <td align=center colspan=3><input type="checkbox" name="delete" value="1">Check to delete otherwise it will be added<br><input type=submit name=submit value="Update Listing"></td>
                    </tr>
                </table>
            </form>
<?
		}
	}
	else 
	{
//Set up error list array
        $errorList = array();
        $count = 0;

//Validate text input fields
        if (empty($jcode)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Job code</b></font>"; $count++;
        }

        if (empty($dsg)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Designation</b></font>"; $count++;
        }

        if (empty($rsp)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Responsibilities</b></font>"; $count++;
        }

        if (empty($qlf)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Qualifications</b></font>"; $count++;
        }

        if (empty($cname)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Contact name</b></font>"; $count++;
        }

        if (empty($cmail) || isEmailInvalid($cmail)) 
        {
            $errorList[$count] = "<font class=\"pn-normal\"><b>Invalid entry: Email address</b></font>"; $count++;
        }

		if (sizeof($errorList) == 0)
        {
			if (!$delete)
			{
				mysql_select_db($database, $connection) or die('Database Not Found');
				$query = "INSERT INTO {$prefix}_joblisting (
                                        jcode,
                                        designation,
                                        responsibilities,
                                        qualifications,
                                        cname, cmail,
                                        posted,
                                        fk_department,
                                        fk_location,
                                        fk_salary,
										checked)
                             VALUES 	('$jcode',
                                         '$dsg',
                                         '$rsp',
                                         '$qlf',
                                         '$cname',
                                         '$cmail',
                                         NOW(),
                                         '$dpt',
                                         '$loc',
                                         '$sal',
										 '$checked')";
				$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
				echo "<font class=\"pn-normal\"><b>Entry successfully added to live job listing.<p>";
            	if($result)
				{
					$query = "delete from {$prefix}_jobtemplisting WHERE jcode='$jcode'";
            		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        			echo "<font class=\"pn-normal\"><b>Entry successfully deleted from temp database.<p><a href=\"admin.php?cmd=Waiting\">View next temp Entry</a> or <a href=\"admin.php?cmd=Add\">Add another entry</a></b></font>";
				}
			}
			elseif($delete)
			{
				$query = "delete from {$prefix}_jobtemplisting WHERE jcode='$jcode'";
            	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

        		echo "<font class=\"pn-normal\"><b>Entry successfully deleted from temp database.<p><a href=\"admin.php?cmd=Waiting\">View next temp Entry</a> or <a href=\"admin.php?cmd=Add\">Add another entry</a></b></font>";
        	}
		}
        else
        {
        listErrors();
        }
	}
}


#################
# Generic Error #
#################
if($cmd == "Error")
{
	OpenTable();
	echo "<br><center><font class=\"pn-Title\"> Error </font></center>";
	CloseTable();
	OpenTable();

	echo "There was an error accessing the page you requested. Please <a href=\"admin.php?cmd=List\">return to the main page</a> and try again.";
}

	echo "<div align=\"center\"><br><a href=\"https://sourceforge.net/projects/profession/\" target=\"_blank\"><img src=\"logo-X.gif\" border=\"0\"></a></div><br>";

	}//end of login code

CloseTable();

//include("footer.php");
?>
Return current item: phprofession job board