. */ include("./include/include.php"); include("./include/g_accepted.php"); include("./include/AjaxResponse.php"); include("./include/Popup.php"); include("./include/Persons.php"); include("./include/PersonsFields/100Accepted.php"); define("POPUP_HEIGHT", 320); define("POPUP_WIDTH", 330); if( !(in_array("application_accept", $_SESSION['sess_functions']) || in_array("application_confirm", $_SESSION['sess_functions']) || in_array("application_reject", $_SESSION['sess_functions']) || in_array("application_cancel", $_SESSION['sess_functions']) || in_array("application_register", $_SESSION['sess_functions'])) ) { $popup = new Popup("Edit accepted", "You are not authorized to see this page."); $popup->setHeight(POPUP_HEIGHT)->setWidth(POPUP_WIDTH); echo $popup->createPopup(); }else { admin_header(true, true); $query="SELECT `FirstName`, `LastName`, `BodyName`, `ParticipantType`, `ParticipantOrder`, `Accepted` FROM `ab_bodies`, `persons` WHERE `ab_bodies`.`BodyCode`=`persons`.`BodyCode` AND `persons`.`PersonID`=".addslashes(get_int("id")); if( @mysql_num_rows( $res=doquery($query) )==1 ) { $row = mysql_fetch_array($res); if( !isset($_POST['accepted']) ) { // Show form with data $content = "
"; $content .= ""; $popup = new Popup("Edit accepted", $content); $popup->setHeight(POPUP_HEIGHT)->setWidth(POPUP_WIDTH); echo $popup->createPopup(); }else { // Process data if( array_key_exists($_POST['accepted'], $Accepted_img) && canEditAccepted($row['Accepted'], $_POST['accepted']) ) { // valid accepted status entered $query="UPDATE `persons` SET `Accepted`='".addslashes($_POST['accepted'])."', `Log`=CONCAT(`Log`,'\n".date("Y-m-d H:i:s").": set accepted status to ".addslashes($_POST['accepted'])." by ".addslashes($_SESSION['sess_name'])."') WHERE `PersonID`=".addslashes(get_int('id')); if( doquery($query) ) { // query successfull $acceptedField = new PersonsAccepted(); $img = $acceptedField->display($_POST['accepted'], get_int('id')); $response = new AjaxResponse(true); $response->addRefresh("Accepted_".get_int('id'), $img); header("Content-type: text/xml; charset=utf-8"); echo $response->createResponse(); }else { // query failed $response = new AjaxResponse(false); $response->addRefresh("popup_content", "Error: update failed"); header("Content-type: text/xml; charset=utf-8"); echo $response->createResponse(); } }else { // Invalid accepted status entered $response = new AjaxResponse(false); $response->addRefresh("popup_content", "Error: unknown accepted status entered"); header("Content-type: text/xml; charset=utf-8"); echo $response->createResponse(); } } }else { $content = "Error: unable to load the data. The person was not found."; $popup = new Popup("Edit accepted", $content); $popup->setHeight(POPUP_HEIGHT)->setWidth(POPUP_WIDTH); echo $popup->createPopup(); } admin_footer(true, true); } function canEditAccepted($curAccepted, $newAccepted) { switch($newAccepted) { case "-": case "yes": return in_array("application_accept", $_SESSION['sess_functions']); break; case "pending": case "confirmed": return in_array($curAccepted, array('yes', 'pending')) && in_array("application_confirm", $_SESSION['sess_functions']); break; case "no": return in_array("application_reject", $_SESSION['sess_functions']); break; case "cancel": return $curAccepted!="arrived" && in_array("application_cancel", $_SESSION['sess_functions']); break; case "arrived": return in_array($curAccepted, array('yes', 'pending', 'confirmed')) && in_array("application_register", $_SESSION['sess_functions']); break; default: return false; } } ?>