Location: PHPKode > projects > Employee Scheduling System > essv1-2/editPos.php
<?php require_once('common.php'); 
// $Id: editPos.php,v 1.2 2005/04/02 09:16:52 atrommer Exp $
checkUser($_SESSION['USERTYPE'], 2);

// check for postback and handle a delete
if ($_POST['isPostback']){
	// do updates
	addPos($_POST, $_SESSION['USERID']);

if ($_POST['confirmDelete']){

// if request is empty, make user select area first
if (!$_REQUEST['area']){ accessDenied("Please go through Manage Schedules to edit positions!");}

// grab area details
$oAreaDetails = getAreas($_SESSION['USERID'],$_REQUEST['area']);

// kick user out if details don't exist
if (!$oAreaDetails){ accessDenied("You do not have access to this function!");}

// now that we are clean, grab the pos
$oAreaPos = getAreaPos($_REQUEST['area']);

// prompts user for del confirm
function deleteConfirm($iArea, $iPos){
	$oPosDetails = getPosDetails($iPos);
	Warning! <b>Deleting</b> a position will orphan any assignments using this position.
	Do this only as a last resort!<br>
	<form id="frmDelete" name="frmDelete" method="post" action="<?=$_SERVER['PHP_SELF'] ?>">
		<input type="hidden" name="area" value="<?=$iArea ?>">
		<input type="hidden" name="pos" value="<?=$iPos ?>">
		<input type="hidden" name="confirmDelete" value="1">
		<input type="submit" name="delete" value="Click here to delete the <?=$oPosDetails->pos_name ?> position">

doHeader("Editing Positions for ".$oAreaDetails[0]->area_name);
// catch delete request and prompt
if ($_REQUEST['del']){
	deleteConfirm($_REQUEST['area'], $_REQUEST['pos']);

This page allows you to create, edit, and delete positions for the <b><?=$oAreaDetails[0]->area_name?></b> area.
<br>Simply make the changes and additions that you want and click <b>Update</b>.

<form name="frmPos" action="editPos.php" method="post">
	<input type="hidden" name="hdArea" value="<?=$_REQUEST['area']?>">
	<input type="hidden" name="isPostback" value="1">
<? foreach($oAreaPos as $Pos){ ?>
	<hr align="left">
	<table width="100%" border="0" cellpadding="2" class="contactInfo">
			<td class="contactInfoName"><input type="text" name="tbName<?=$Pos->pos_id?>" value="<?=$Pos->pos_name?>"></td>
				<a href="editPos.php?pos=<?=$Pos->pos_id ?>&area=<?=$_REQUEST['area'] ?>&del=1">Delete Position?</a>
			<td colspan=2><textarea name="taDesc<?=$Pos->pos_id?>" cols="30" rows="4"><?
<? } ?>
Add New Position:
<table width="100%" border="0" cellpadding="0" class="contactInfo">
	<tr class="contactInfoName">
		<td>Position Name:</td><td><input type="text" name="tbNName" maxlenght="20"></td>
		<td>Description:</td><td><textarea name="taNDesc" cols="30" rows="4"></textarea></td>
<center><input type="submit" value="Update?" name="submit"></center>
<? doFooter(); ?>
Return current item: Employee Scheduling System