<?php
#######################################
#                                                                                                                #
#  adaptetion for AntiSlaed  42 Vladimir Sulatskov aka Sulla_l_k   #
#                                                                                                                #
#######################################
if (!defined('ADMIN_FILE') || !is_admin_modul("vakancy")) die("Illegal File Access");

get_lang($conf['name']);
require_once("config/config_vakancy.php");
require_once("modules/vakancy/comment.php");

function boardmenu() {
	global $prefix, $db, $admin_file;
	$new = $db->sql_numrows($db->sql_query("SELECT lid FROM ".$prefix."_vakancy WHERE status = '0'"));
	panel();
	open();
    echo "<center><font class=\"title\">"._WORK14."</font><br><br>"
		."[ <a href=\"".$admin_file.".php?op=vakancy\">"._HOME."</a>"
		." | <a href=\"".$admin_file.".php?op=vakancy_moder\">"._WORK46." ($new)</a>"
		." | <a href=\"".$admin_file.".php?op=vakancy_cat\">"._CATEGORIES."</a>"
		." | <a href=\"".$admin_file.".php?op=vakancy_conf\">"._PREFERENCES."</a> ]</center>";
	close();
}


function vakancy() {
    global $prefix, $db, $admin_file, $paga, $num, $conf;
    head();
	boardmenu();
	$storynum = $paga;
	$num = (!intval($num)) ? 1 : intval($num);
	$offset = ($num-1) * $storynum;
	$offset = intval($offset);
	$result = $db->sql_query("SELECT a.lid, a.cid, a.author, a.authormail, a.title, a.description, a.offer, a.ip, a.hits, a.date, a.status, a.expire, b.cid, b.title FROM ".$prefix."_vakancy AS a LEFT JOIN ".$prefix."_vakancy_categories AS b ON (a.cid=b.cid) WHERE status ='1' ORDER BY lid DESC LIMIT $offset, $storynum");
	if ($db->sql_numrows($result) > 0) {
	open();
		echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"javascripts/SortTable.js\"></script><table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"sort\" id=\"sort_id\"><tr>
			<th width=\"5%\">"._ID."</th><th width=\"10%\">"._WORK10."</th><th width=\"25%\">"._WORK11."</th><th width=\"50%\">"._WORK12."</th><th width=\"10%\">"._FUNCTIONS."</th></tr>";
		while (list($lid, $cid, $author, $authormail, $title, $description, $offer, $ip, $hits, $date, $status, $expire, $bcid, $btitle) = $db->sql_fetchrow($result)) {
			echo "<tr class=\"bgcolor1\"><td align=\"center\">".$lid."</td>"
				."<td>".$author."</td>"
				."<td>".cutstr($title, 25)."</td>"
				."<td>".cutstr(bb_decode($description, $conf['name']), 250)."</td>"
				."<td align=\"center\"><a href=\"".$admin_file.".php?op=edit_vakancy&lid=$lid&num=$num\" title=\""._EDIT."\"><img src=images/edit.gif border=\"0\" alt=\""._EDIT."\"></a> <a href=\"".$admin_file.".php?op=delit_vakancy&lid=$lid&num=$num\" title=\""._DELETE."\"><img src=images/delete.gif border=\"0\" alt=\""._DELETE."\"></a></td></tr>";
		}
		echo "</table>";
	close();
	list($numstories) = $db->sql_fetchrow($db->sql_query("SELECT Count(lid) FROM ".$prefix."_vakancy "));
	$numpages = ceil($numstories / $storynum);
	num_page($module_name, $numstories, $numpages, $storynum, "op=vakancy&");
	}
	foot();
}

function vakancy_moder() {
    global $prefix, $db, $admin_file, $paga, $num, $conf;
    head();
	boardmenu();
	$storynum = $paga;
	$num = (!intval($num)) ? 1 : intval($num);
	$offset = ($num-1) * $storynum;
	$offset = intval($offset);
	$result = $db->sql_query("SELECT a.lid, a.cid, a.author, a.authormail, a.title, a.description, a.offer, a.ip, a.hits, a.date, a.status, a.expire, b.cid, b.title FROM ".$prefix."_vakancy AS a LEFT JOIN ".$prefix."_vakancy_categories AS b ON (a.cid=b.cid) WHERE status ='0' ORDER BY lid DESC LIMIT $offset, $storynum");
	if ($db->sql_numrows($result) > 0) {
	open();
	echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"javascripts/SortTable.js\"></script><table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"sort\" id=\"sort_id\"><tr>
		<th width=\"5%\">"._ID."</th><th width=\"10%\">"._WORK10."</th><th width=\"25%\">"._WORK11."</th><th width=\"50%\">"._WORK12."</th><th width=\"10%\">"._FUNCTIONS."</th></tr>";
	while (list($lid, $cid, $author, $authormail, $title, $description, $offer, $ip, $hits, $date, $status, $expire, $bcid, $btitle) = $db->sql_fetchrow($result)) {

		echo "<tr class=\"bgcolor1\"><td align=\"center\">".$lid."</td>"
			."<td>".$author."</td>"
			."<td>".cutstr($title, 25)."</td>"
			."<td>".cutstr(bb_decode($description, $conf['name']), 250)."</td>"
			."<td align=\"center\"><a href=\"".$admin_file.".php?op=edit_vakancy&lid=$lid&num=$num\" title=\""._EDIT."\"><img src=images/edit.gif border=\"0\" alt=\""._EDIT."\"></a> <a href=\"".$admin_file.".php?op=delit_vakancy&lid=$lid&num=$num\" title=\""._DELETE."\"><img src=images/delete.gif border=\"0\" alt=\""._DELETE."\"></a></td></tr>";
	}
	echo "</table>";
	close();
	list($numstories) = $db->sql_fetchrow($db->sql_query("SELECT Count(lid) FROM ".$prefix."_vakancy "));
	$numpages = ceil($numstories / $storynum);
	num_page($module_name, $numstories, $numpages, $storynum, "op=vakancy&");
	}
	foot();
}

function boardwork($parentid, $title) {
	global $prefix, $db;
    $result = $db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_vakancy_categories WHERE cid='$parentid'");
		list($cid, $ptitle, $pparentid) = $db->sql_fetchrow($result);
		if ($ptitle != "") $title = "".$ptitle."/".$title."";
		if ($pparentid != 0) $title = boardwork($pparentid,$title);
    return $title;
}

function vakancy_cat() {
    global $prefix, $db, $admin_file;
    head();
	boardmenu();
	open();
	echo "<center><font class=\"option\">"._CATEGORIES."</font></center><br />";
	echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"3\" width=\"100%\" class=\"bgcolor4\"><tr><th>"._ID."</th><th width=\"40%\">"._CATEGORY."</th><th width=\"40%\">"._WORK48."</th><th>"._FUNCTIONS."</th></tr>";
	$result = $db->sql_query("SELECT a.cid, a.title, a.parentid, b.cid, b.title FROM ".$prefix."_vakancy_categories AS a LEFT JOIN ".$prefix."_vakancy_categories AS b ON a.parentid=b.cid");
	while(list($cid, $title, $parentid, $bcid, $btitle) = $db->sql_fetchrow($result)) {
		echo "<tr class=\"bgcolor1\"><td align=\"center\">$cid</td><td>$title</td><td>$btitle</td><td align=\"center\" class=\"bgcolor1\"><a href=\"".$admin_file.".php?op=edit_vakancy_cat&cid=$cid\" title=\""._EDIT."\"><img src=images/edit.gif border=\"0\" alt=\""._EDIT."\"></a> <a href=\"".$admin_file.".php?op=delite_vakancy_cat&cid=$cid\" title=\""._DELETE."\"><img src=images/delete.gif border=\"0\" alt=\""._DELETE."\"></a></td></td></tr>";
	}
	echo "</table>";
	close();
	open();
    echo "<center><font class=\"option\"><b>"._ADDCATEGORY."</b></font></center><br>"
		."<form name=\"post\" action=\"".$admin_file.".php\" method=\"post\">"
		."<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\">"
		."<tr><td>"._TITLE.":</td><td><input type=\"text\" name=\"title\" size=\"65\" style=\"width:400px\"></td></tr>"
		."<tr><td colspan=\"2\" align=\"center\"><input type=\"hidden\" name=\"op\" value=\"add_vakancy_cat\">"
		."<input type=\"submit\" value=\""._ADD."\"></td></tr></form></table>";
    close();
	$result = $db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_vakancy_categories ORDER BY parentid,title");
    if ($numrows = $db->sql_numrows($result) > 0) {
		open();
		echo "<center><font class=\"option\"><b>"._ADDSUBCATEGORY."</b></font></center><br>"
			."<form name=\"post2\" action=\"".$admin_file.".php\" method=\"post\">"
	        ."<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\">"
			."<tr><td>"._TITLE.":</td><td><input type=\"text\" name=\"title\" maxlength=\"100\" size=\"65\" style=\"width:400px\"></td></tr>"
			."<tr><td>"._INCAT.":</td><td>"
	        ."<select name=\"cid\" style=\"width:400px\">";
			while (list($cid2, $title, $parentid2) = $db->sql_fetchrow($result)) {
				if ($parentid2 != 0) $title = boardwork($parentid2,$title);
				echo "<option value=\"$cid2\">$title</option>";
			}
		echo "</select></td></tr>"
			."<tr><td colspan=\"2\" align=\"center\"><input type=\"hidden\" name=\"op\" value=\"add_vakancy_cat_sub\">"
			."<input type=\"submit\" value=\""._ADD."\"></td></tr></form></table>";
		close();
	}

	foot();
}

function edit_vakancy($lid, $num) {
	global $prefix, $db, $admin_file, $stop;
			//############################################
		    $cid = $_POST['cid'];
		    $title = $_POST['title'];
		    $description = $_POST['description'];
		    $offer = $_POST['offer'];
		    $author = $_POST['author'];
		    $authormail = $_POST['authormail'];
		    $telefone = $_POST['telefone'];
		    $address = $_POST['address'];
		    $contact = $_POST['contact'];
		    $salary = $_POST['salary'];
		    $information = $_POST['information'];
			//############################################
		head();
		boardmenu();
		$result = $db->sql_query("SELECT * FROM ".$prefix."_vakancy WHERE lid = '$lid'");
	    $row = $db->sql_fetchrow($result);
		    $description = $row[description];
		    $w_cid = $row[cid];
		    $author = $row[author];
		    $authormail = $row[authormail];
		    $title = $row[title];
		    $description = $row[description];
		    $offer = $row[offer];
		    $telefone  = $row[telefone];
		    $address = $row[address];
		    $contact = $row[contact];
		    $salary = $row[salary];
		    $information = $row[information];
		    $status = $row[status];
		    $expire =$row[expire];
	    if ($stop) warning($stop, "", "", 1);
	    open();
	    echo "<form name=\"post\" action=\"".$admin_file.".php?op=edit_vakancy&lid=$lid&num=$num\" method=\"post\">"
		    ."<table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" align=\"center\" class=\"bgcolor4\">"
		    ."<tr><th colspan=\"2\">"._WORK36."</th></tr>"
		    ."<tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK17.":<font color=\"red\">*</div></font></td>
			<td class=\"bgcolor1\"><input type=\"text\" name=\"title\" value=\"$title\" maxlength=\"100\" size=\"65\" style=\"width:400px;\"></td></tr>"
		    ."<tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK19.":<font color=\"red\">*</div></font></td>
			<td class=\"bgcolor1\">".textarea("1", "description", replace_break($description),  "vakancy", "5")."</td></tr>"
	        ."<tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK18.":<font color=\"red\">*</div></font></td>
			<td class=\"bgcolor1\"><select name=\"cid\" style=\"width:400px;\"><option value=\"\">"._WORK14."</option>";
	    $result = $db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_vakancy_categories ORDER BY parentid, title");
		    while (list($cid2, $ctitle, $parentid2) = $db->sql_fetchrow($result)) {
				if ($parentid2 != 0) $ctitle = boardwork($parentid2, $ctitle);
				if ($cid2 == $w_cid) echo "<option value=\"$cid2\" selected>$ctitle</option>";
				echo "<option value=\"$cid2\">$ctitle</option>";
		    }
	    echo "</select></td></tr>";
	    echo"<tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK21.":</div></td>"
			."<td class=\"bgcolor1\"><select name=\"add_expire\" style=\"width:400px;\">"
		    ."<option value=\"3\">"._WORK22."</option>"
		    ."<option value=\"5\">"._WORK23."</option>"
		    ."<option value=\"7\">"._WORK24."</option>"
		    ."<option value=\"15\">"._WORK25."</option>"
		    ."<option value=\"30\">"._WORK26."</option>"
		    ."</select></td></tr>";
	    echo "</td></tr><tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK20."<font color=\"red\">*</div></font></td><td class=\"bgcolor1\">";

	    if ($offer == 0) {
	        echo "<input type='radio' name='offer' value='0' checked>&nbsp;"._WORK16." &nbsp;<input type='radio' name='offer' value='1'>&nbsp;"._WORK15."";
        } else {
            echo "<input type='radio' name='offer' value='0'>&nbsp;"._WORK16." &nbsp;<input type='radio' name='offer' value='1' checked>&nbsp;"._WORK15."";
        }
        echo "<tr><th colspan=\"2\">"._WORK27."</th></tr>"
	        ."<tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK28.":<font color=\"red\">*</font></div></td><td class=\"bgcolor1\"><input type=\"text\" name=\"author\"  value=\"$author\" size=\"65\" style=\"width:400px;\"></td></tr>"
		    ."<tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK29.":<font color=\"red\">*</font></div></td><td class=\"bgcolor1\"><input type=\"text\" name=\"authormail\"  value=\"$authormail\" size=\"65\" style=\"width:400px;\"></td></tr>"
		    ."<tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK30.":</div></td><td class=\"bgcolor1\"><input type=\"text\" name=\"telefone\" value=\"$telefone\" size=\"65\" style=\"width:400px;\"></td></tr>"
		    ."<tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK31.":</div></td><td class=\"bgcolor1\"><input type=\"text\" name=\"address\" value=\"$address\" size=\"65\" style=\"width:400px;\"></td></tr>"
		    ."<tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK32.":</div></td><td class=\"bgcolor1\"><input type=\"text\" name=\"contact\" value=\"$contact\" size=\"65\" style=\"width:400px;\"></td></tr>";
        echo"<tr><th colspan=\"2\">"._WORK33."</th></tr>"
	        ."<tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK34.":</div></td><td class=\"bgcolor1\"><input type=\"text\" name=\"salary\"  value=\"$salary\" size=\"65\" style=\"width:400px;\"></td></tr>"
		    ."<tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK35.":</div></td><td class=\"bgcolor1\"><textarea name=\"information\" cols=\"65\" rows=\"3\" style=\"width:400px;\">$information</textarea></td></tr>";
        echo "</td></tr><tr><td class=\"bgcolor1\"><div align=\"right\">"._WORK47."</div></td><td class=\"bgcolor1\">";

	    if ($status == 0) {
	        echo "<input type='radio' name='status' value='0' checked>&nbsp;"._NO." &nbsp;<input type='radio' name='status' value='1'>&nbsp;"._YES."";
        } else {
            echo "<input type='radio' name='status' value='0'>&nbsp;"._NO." &nbsp;<input type='radio' name='status' value='1' checked>&nbsp;"._YES."";
        }
	    echo "<tr><td colspan=\"2\" class=\"bgcolor1\"><center>"
		    ."<input type=\"hidden\" name=\"num\" value=\"$num\">"
		    ."<input type=\"hidden\" name=\"lid\" value=\"$lid\">"
		    ."<input type=\"hidden\" name=\"op\" value=\"vakancy_update\">"
		    ."<input type=\"submit\" value=\""._SAVE."\"></center></td></tr></form></table>";

	    close();
	    foot();
}

function vakancy_update($num, $lid, $cid, $title, $description, $offer,  $author, $authormail, $telefone, $address, $contact, $salary, $information, $status, $add_expire) {
global $prefix, $db,  $admin_file, $stop;
		$time = time() + ($TIME_DIFFERENCE * 3600);
		$author = text_filter($author);
		$title  = text_filter($title);
		$description  = text_filter($description);
		$address  = text_filter($address);
		$contact = text_filter($contact);
		$salary = text_filter($salary);
		$information = text_filter($information);
		$ip = getenv("REMOTE_ADDR");
		if ($add_expire == "" || $add_expire == 0) {
			$add_expire = 0;
	    } else {
			$add_expire = time() + ($add_expire * 86400);
	    }
		if ($title == "") $stop = ""._WORK40."!";
	    if ($description == "") $stop = ""._WORK41."!";
        if ($cid == "") $stop = ""._WORK42."!";
        if ($author == "") $stop = ""._WORK43."!";
        if ($authormail == "") {
			$stop = ""._WORK44."!";
		}else{
			checkemail($authormail);
		}
        if ($offer == "") $stop = ""._WORK45."!";
		
			if (!$stop) {
				$db->sql_query("UPDATE ".$prefix."_vakancy SET cid='$cid', author='$author', authormail='$authormail', title='$title', description='$description', offer='$offer', telefone='$telefone', address='$address', contact='$contact', salary='$salary', information='$information', status='$status', expire='$add_expire' WHERE lid='$lid'");
				Header("Location: ".$admin_file.".php?op=vakancy&num=$num");
			} else {
				edit_vakancy($lid, $num);
			}

 }

function edit_vakancy_cat($cid) {
    global $prefix, $db, $admin_file;
    head();
	boardmenu();
	open();
    $result = $db->sql_query("SELECT title, parentid FROM ".$prefix."_vakancy_categories WHERE cid='$cid'");
    list($title, $parentid) = $db->sql_fetchrow($result);
	echo "<center><font class=\"option\"><b>"._EDITCATEGORY."</b></font></center><br>"
		."<form action=\"".$admin_file.".php\" method=\"post\">"
		."<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\">"
		."<tr><td>"._TITLE.":</td><td><input type=\"text\" name=\"title\" value=\"$title\" size=\"65\" style=\"width:400px\"></td></tr>";
	if ($parentid != 0) {
        $result2 = $db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_vakancy_categories WHERE parentid != '$parentid'");
        echo "<tr><td>"._INCAT.":</td><td><select name=\"parentid\" style=\"width:400px\">";
        while (list($cid2, $ctitle2, $parentid2) = $db->sql_fetchrow($result2)) {
			if ($parentid2 != 0) $ctitle2 = boardwork($parentid2, $ctitle2);
			$sel = ($cid2 == $parentid) ? "selected" : "";
			echo "<option value=\"$cid2\" $sel>$ctitle2</option>";
		}
		echo "</select></td></tr>";
	} else {
		echo "<input type=\"hidden\" name=\"parentid\" value=\"0\">";
	}
	echo "<tr><td align=\"center\" colspan=\"2\"><table><tr><td><input type=\"hidden\" name=\"cid\" value=\"$cid\"><input type=\"hidden\" name=\"op\" value=\"save_vakancy_cat\"><input type=\"submit\" value=\""._SAVECHANGES."\"></td></form>"
	."<form action=\"".$admin_file.".php\" method=\"post\"><td><input type=\"hidden\" name=\"cid\" value=\"$cid\"><input type=\"hidden\" name=\"op\" value=\"delite_vakancy_cat\"><input type=\"submit\" value=\""._DELETE."\"></td></tr></form></table></tr></td></table>";
	close();
    foot();
}

function save_vakancy_cat($cid, $title, $parentid) {
    global $prefix, $db, $admin_file;
    $db->sql_query("UPDATE ".$prefix."_vakancy_categories SET title='$title', parentid='$parentid' where cid='$cid'");
    Header("Location: ".$admin_file.".php?op=vakancy_cat");
}

function add_vakancy_cat($title) {
    global $prefix, $db, $admin_file;
	if ($title!=""){
		$db->sql_query("INSERT INTO ".$prefix."_vakancy_categories (cid, title) VALUES (NULL, '$title')");
	}
    Header("Location: ".$admin_file.".php?op=vakancy_cat");
}

function add_vakancy_cat_sub($cid, $title) {
    global $prefix, $db, $admin_file;
	if ($title!="" AND $cid){
		$db->sql_query("INSERT INTO ".$prefix."_vakancy_categories (cid, title, parentid) VALUES (NULL, '$title', '$cid')");
	}
    Header("Location: ".$admin_file.".php?op=vakancy_cat");
}

function delit_vakancy($lid, $num) {
    global $prefix, $db, $admin_file;
    $result = $db->sql_query("SELECT lid FROM ".$prefix."_vakancy WHERE lid='$lid'");
        while (list($lid) = $db->sql_fetchrow($result)) {
			$db->sql_query("DELETE FROM ".$prefix."_vakancy_comment WHERE cid='$lid'");
        }
        $db->sql_query("DELETE FROM ".$prefix."_vakancy WHERE lid='$lid'");
		
    Header("Location: ".$admin_file.".php?op=vakancy&num=$num");
}

function delite_vakancy_cat($cid, $ok=0) {
    global $prefix, $db, $admin_file;
    if ($ok == 1) {
        $db->sql_query("DELETE FROM ".$prefix."_vakancy_categories WHERE cid='$cid'");
        $db->sql_query("DELETE FROM ".$prefix."_vakancy_categories WHERE parentid='$cid'");
        $result = $db->sql_query("SELECT lid FROM ".$prefix."_vakancy WHERE cid='$cid'");
	        while (list($lid) = $db->sql_fetchrow($result)) {
				$db->sql_query("DELETE FROM ".$prefix."_vakancy_comment WHERE cid='$lid'");
	        }
        $db->sql_query("DELETE FROM ".$prefix."_vakancy WHERE cid='$cid'");
		Header("Location: ".$admin_file.".php?op=vakancy_cat");
    } else {
		head();
		boardmenu();
	        open();
			list($title) = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_vakancy_categories WHERE cid='$cid'"));
			echo "<center><font class=\"option\">"._DELCATEGORY.": $title</font><br /><br />"
			.""._DELFCATNOTE."<br /><br />[ <a href=\"".$admin_file.".php?op=vakancy_cat\">"._NO."</a> | <a href=\"".$admin_file.".php?op=delite_vakancy_cat&cid=$cid&ok=1\">"._YES."</a> ]</center>";
			close();
		foot();
    }
}

function vakancy_conf() {
	global $prefix, $db, $admin_file;
	head();
	boardmenu();
	include("config/config_vakancy.php");
	$permtest = end_chmod("config/config_vakancy.php", 666);
	if ($permtest) warning($permtest, "", "", 1);
	open();
	$file_t = intval($file_t / 86400);
	echo "<center><font class='option'><b>"._GENSITEINFO."</b></font></center><br>"
    ."<form action='".$admin_file.".php' method='post'>"
	."<table border='0' align='center' cellpadding='3' cellspacing='0'>"
	."<tr><td>"._WORK.":</td><td><input type='text' name='xpagh' value='$pagh' maxlength='45' size='45' style='width:300px'></td></tr>"
	."<tr><td>"._WORK0.":</td><td><input type='text' name='xpag' value='$pag' maxlength='45' size='45' style='width:300px'></td></tr>"
	."<tr><td>"._WORK1.":</td><td><input type='text' name='xpaga' value='$paga' maxlength='45' size='45' style='width:300px'></td></tr>"
	."<tr><td>"._WORK2.":</td><td><input type='text' name='xtabcolumn' value='$tabcolumn' maxlength='25' size='45' style='width:300px'></td></tr>";
	echo "<tr><td>"._WORK3."</td><td>";
	if ($add == 1) {
		echo "<input type='radio' name='xadd' value='1' checked>"._YES." &nbsp;<input type='radio' name='xadd' value='0'>"._NO."";
    } else {
        echo "<input type='radio' name='xadd' value='1'>"._YES." &nbsp;<input type='radio' name='xadd' value='0' checked>"._NO."";
    }
	echo "<tr><td>"._WORK4."</td><td>";
	if ($addquest == 1) {
		echo "<input type='radio' name='xaddquest' value='1' checked>"._YES." &nbsp;<input type='radio' name='xaddquest' value='0'>"._NO."";
    } else {
        echo "<input type='radio' name='xaddquest' value='1'>"._YES." &nbsp;<input type='radio' name='xaddquest' value='0' checked>"._NO."";
    }
	echo "</td></tr><tr><td>"._WORK5."</td><td>";
	if ($delwork == 1) {
		echo "<input type='radio' name='xdelwork' value='1' checked>"._YES." &nbsp;<input type='radio' name='xdelwork' value='0'>"._NO."";
    } else {
        echo "<input type='radio' name='xdelwork' value='1'>"._YES." &nbsp;<input type='radio' name='xdelwork' value='0' checked>"._NO."";
    }
	echo "</td></tr><tr><td>"._WORK6."</td><td>";
	if ($editwork == 1) {
		echo "<input type='radio' name='xeditwork' value='1' checked>"._YES." &nbsp;<input type='radio' name='xeditwork' value='0'>"._NO."";
    } else {
        echo "<input type='radio' name='xeditwork' value='1'>"._YES." &nbsp;<input type='radio' name='xeditwork' value='0' checked>"._NO."";
    }
	echo "</td></tr><tr><td>"._WORK7."</td><td>";
	if ($moder == 1) {
		echo "<input type='radio' name='xmoder' value='1' checked>"._YES." &nbsp;<input type='radio' name='xmoder' value='0'>"._NO."";
    } else {
        echo "<input type='radio' name='xmoder' value='1'>"._YES." &nbsp;<input type='radio' name='xmoder' value='0' checked>"._NO."";
    }
    echo "</td></tr><tr><td>"._WORK8."</td><td>";
	if ($comment == 1) {
		echo "<input type='radio' name='xcomment' value='1' checked>"._YES." &nbsp;<input type='radio' name='xcomment' value='0'>"._NO."";
    } else {
        echo "<input type='radio' name='xcomment' value='1'>"._YES." &nbsp;<input type='radio' name='xcomment' value='0' checked>"._NO."";
    }
	echo "</td></tr><tr><td>"._WORK9."</td><td>";
	if ($showsubkat == 1) {
		echo "<input type='radio' name='xshowsubkat' value='1' checked>"._YES." &nbsp;<input type='radio' name='xshowsubkat' value='0'>"._NO."";
    } else {
        echo "<input type='radio' name='xshowsubkat' value='1'>"._YES." &nbsp;<input type='radio' name='xshowsubkat' value='0' checked>"._NO."";
    }

	echo "</td></tr></table>";
	echo "<center><br><input type='hidden' name='op' value='vakancy_confsave'><input type='submit' value='" . _SAVECHANGES . "'></center></form>";
	close();
	foot();
}

function vakancy_confsave($xpagh, $xpag, $xpaga, $xtabcolumn, $xadd, $xaddquest, $xdelwork, $xeditwork, $xmoder, $xcomment, $xshowsubkat) {
	global $admin_file;
	$content = "\$pagh = \"$xpagh\";\n";
	$content .= "\$pag = \"$xpag\";\n";
	$content .= "\$paga = \"$xpaga\";\n";
	$content .= "\$tabcolumn = \"$xtabcolumn\";\n";
	$content .= "\$add = \"$xadd\";\n";
	$content .= "\$addquest = \"$xaddquest\";\n";
	$content .= "\$delwork = \"$xdelwork\";\n";
	$content .= "\$editwork = \"$xeditwork\";\n";
	$content .= "\$moder = \"$xmoder\";\n";
	$content .= "\$comment = \"$xcomment\";\n";
	$content .= "\$showsubkat = \"$xshowsubkat\";\n";
	save_conf("config/config_vakancy.php", $content);
	Header("Location: ".$admin_file.".php?op=vakancy_conf");
}

switch ($op) {
	case "vakancy":
    vakancy();
    break;

	case "vakancy_moder":
    vakancy_moder();
    break;

    case "vakancy_cat":
    vakancy_cat();
    break;

    case "add_vakancy":
    add_vakancy();
    break;

    case "add_vakancy_cat":
		$title = $_POST['title'];
		add_vakancy_cat($title);
    break;

    case "add_vakancy_cat_sub":
		$cid = $_POST['cid'];
		$title = $_POST['title'];
		add_vakancy_cat_sub($cid, $title);
    break;

    case "delite_vakancy_cat":
		$cid = isset($_POST['cid'])? $_POST['cid']: $_GET['cid'];
		$ok = $_GET['ok'];
    delite_vakancy_cat($cid, $ok);
    break;

    case "edit_vakancy":
		//############################################
		$num = $_GET['num'];
		$lid = $_GET['lid'];
		edit_vakancy($lid, $num);
    break;

    case "vakancy_update":
	// для точного получения данных
		$num = $_POST['num'];
		$lid = $_POST['lid'];
		$cid = $_POST['cid'];
		$title = $_POST['title'];
		$description = $_POST['description'];
		$offer = $_POST['offer'];
		$author = $_POST['author'];
		$authormail = $_POST['authormail'];
		$telefone = $_POST['telefone'];
		$address = $_POST['address'];
		$contact = $_POST['contact'];
		$salary = $_POST['salary'];
		$information = $_POST['information'];
		$status = $_POST['status'];
		$add_expire = $_POST['add_expire'];
	//=============================
    vakancy_update($num, $lid, $cid, $title, $description, $offer,  $author, $authormail, $telefone, $address, $contact, $salary, $information, $status, $add_expire);
    break;

    case "edit_vakancy_cat":
		$cid = $_GET['cid'];
		edit_vakancy_cat($cid);
    break;

    case "delit_vakancy":
		$lid = $_GET['lid'];
		$num = $_GET['num'];
		delit_vakancy($lid, $num);
    break;

    case "save_vakancy_cat":
		$cid = $_POST['cid'];
		$title = $_POST['title'];
		$parentid = $_POST['parentid'];
		save_vakancy_cat($cid, $title, $parentid);
    break;

    case "vakancy_conf":
		vakancy_conf();
    break;

    case "vakancy_confsave":
		$xpagh=$_POST['xpagh'];
		$xpag = $_POST['xpag'];
		$xpaga = $_POST['xpaga'];
		$xtabcolumn = $_POST['xtabcolumn'];
		$xadd = $_POST['xadd'];
		$xaddquest = $_POST['xaddquest'];
		$xdelwork = $_POST['xdelwork'];
		$xeditwork = $_POST['xeditwork'];
		$xmoder = $_POST['xmoder'];
		$xcomment = $_POST['xcomment'];
		$xshowsubkat = $_POST['xshowsubkat'];
		
		vakancy_confsave($xpagh, $xpag, $xpaga, $xtabcolumn, $xadd, $xaddquest, $xdelwork, $xeditwork, $xmoder, $xcomment, $xshowsubkat);
    break;
	
}
?>