. */ include("./include/include.php"); admin_header(); if( !in_array("candidate_viewpositions", $_SESSION['sess_functions']) ) { echoln("You are not authorized to see this page."); }else { echoln("

Candidates setup

"); $Cancel_process=false; if( !in_array("candidate_editpositions", $_SESSION['sess_functions']) ) { $_REQUEST['cmd'] = ""; } $id = get_int('id'); $Position = stripslashes(get_var('position')); $Places = get_int('places'); $Deadline = stripslashes(get_var('deadline')); if( isset($_REQUEST['cmd']) && $_REQUEST['cmd']=="new" ) { ########### ### New ### ########### $id = ""; $Position = ""; $Places = 1; $Deadline = "auto"; } if( isset($_REQUEST['cmd']) && ($_REQUEST['cmd']=="edit" || $_REQUEST['cmd']=="delete") && !$Cancel_process ) { ################# ### Load Data ### ################# $query="SELECT `position`, `places`, `deadline` FROM `candidatepost` WHERE `id`=".addslashes($id); if( @mysql_num_rows( $res=doquery($query) )==1 ) { // Ok, load data $row = mysql_fetch_array($res); $Position = $row['position']; $Places = $row['places']; $Deadline = $row['deadline']; }else { // Query failed echoln("

Error: unable to load the data. Please try again later.

"); $Cancel_process=true; } } if( isset($_REQUEST['cmd']) && $_REQUEST['cmd']=="delete" && !$Cancel_process ) { ############## ### DELETE ### ############## $query = "SELECT `Position` FROM `candidates` WHERE `Position`=".addslashes($id); if( @mysql_num_rows( doquery($query) )==0 ) { if( isset($_GET['confirm']) && $_GET['confirm']=="yes" ) { // Delete this user $query="DELETE FROM `candidatepost` WHERE `id`=".addslashes($id); if( doquery($query) ) { // Successfull echoln("Successfully deleted '".$Position."'.

"); }else { // Error echoln("Unable to delete position. Please try again.

"); } $_REQUEST['cmd']=""; }else { // Ask for confirmation echoln("Are you sure you want to delete '".$Position."'?"); echoln("

Yes  "); echoln("No

"); } }else { echoln("There is already candidates for this position, you cannot delete it any more.

"); debug("Number: ".mysql_num_rows( doquery($query) )); $_REQUEST['cmd']=""; } } if( isset($_REQUEST['cmd']) && $_REQUEST['cmd']=="save" && !$Cancel_process ) { ################### ### ERROR CHECK ### ################### echoln("

"); if( !$Error[0] ) { ################# ### SAVE DATA ### ################# if( $id>0 ) { // Edited entry, update $query="UPDATE `candidatepost` SET `position`='".addslashes($Position)."', `places`=".addslashes($Places).", `deadline`='".addslashes($Deadline)."' WHERE `id`=".addslashes($id); if( doquery($query) ) { // Saving succeeded echoln("Position saved successfully.

"); }else { // Saving failed echoln("Saving of position failed. Please try again.

"); } }else { // New entry, insert and mail password $query="INSERT INTO `candidatepost` (`position`, `places`, `deadline`) VALUES ('".addslashes($Position)."', ".addslashes($Places).", '".addslashes($Deadline)."')"; if( doquery($query) ) { $id = mysql_insert_id(); // Saving succeeded echoln("New position saved successfully.

"); }else { // Saving failed echoln("Saving of new position failed. Please try again.

"); } } }else { // Error found, reshow form if( $id>0 ) { $_REQUEST['cmd']="edit"; // id avail, so this was an edit }else { $_REQUEST['cmd']="new"; // id unavailable, so this was a new entry } } }elseif( !$Cancel_process ) { // Not save action, so there were no errors $Error[0]=false; } if( isset($_REQUEST['cmd']) && ($_REQUEST['cmd']=="new" OR $_REQUEST['cmd']=="edit") AND !$Cancel_process ) { ################# ### Show form ### ################# echoln("Back

"); echoln("

"); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln("
Position:
Vacant places:
Deadline:"); echoln("   "); echoln("   "); echoln(" "); echoln("

"); echoln(" "); ///// Show buttons ///// if( $_REQUEST['cmd']=="new" ) { echoln("   "); echoln(" "); }else { echoln("   "); echoln(" "); } echoln("

"); }elseif( !isset($_REQUEST['cmd']) || ($_REQUEST['cmd']!="delete" || ( $_REQUEST['cmd']=="delete" && isset($_GET['confirm']) && $_GET['confirm']=="yes" )) ) { ################# ### Show list ### ################# echoln("Add new position"); $query="SELECT `id`, `position`, `places`, `deadline` FROM `candidatepost` ORDER BY `position`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { echoln("

"); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); $i=0; while( $row=mysql_fetch_array($res) ) { $i++; if( ($i%2)==1 ) echoln(" "); else echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); } echoln("
PositionVacant placesDeadline 
".$row['position']."".$row['places']."".$row['deadline']."edit   delete
"); } } } admin_footer(); ?>