<!--chtml include "//students/incs/sg_breadcrumb.inc"-->
<!--chtml call crumbs(sg_finaid)-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

	<head>
		<title>On Campus Work Study Jobs - Maintenence</title>
		<link rel="stylesheet" href="/home/home.css" type="text/css" />
		<link rel="stylesheet" href="../css/form.css" type="text/css" />
		<script src="sorttable.js" type="text/javascript"></script>
	</head>
	<body>
	<!--chtml include "//home/incs/stuheader.inc"-->
	<h1>Update</h1>	
		<?php
		$db_host = 'uwfinaid.ovid.u.washington.edu:3798';
		$db_user = 'root';
		$db_pwd = '03798';
		$database = 'workstudy';
		$table = 'onCampus';
	
		$con = ($GLOBALS["___mysqli_ston"] = mysqli_connect($db_host,  $db_user,  $db_pwd));
		
		if (!$con)
			die("Can't connect to database");
			
		((bool)mysqli_query( $con, "USE " . $database));
		
		$current = trim($_GET['id']);
		
		if(isset($_POST['update']) || isset($_POST['email'])) {
			echo '<div id="update">
					<p>Row ' . $current . ' updated</p> 
				</div>';
	
			$jobType = sanitizeMySQL($_POST["jobType"]);
			$jobTitle = sanitizeMySQL($_POST["jobTitle"]);
			$orgName = sanitizeMySQL($_POST["orgName"]);
			$location = sanitizeMySQL($_POST["location"]);
			$website = sanitizeMySQL($_POST["website"]);
			$min = sanitizeMySQL($_POST['min']);
			$max = sanitizeMySQL($_POST['max']);
			$employmentPeriod = $_POST["employmentPeriod"];
			$hoursPerWeek = $_POST['hoursPerWeek'];
			$status = sanitizeMySQL($_POST['status']);
			$contactFName = sanitizeMySQL($_POST['contactFName']);
			$contactLName = sanitizeMySQL($_POST['contactLName']);
			$phoneNumber = $_POST['phoneNumber'];
			$emailAddress = sanitizeMySQL($_POST['emailAddress']);
			$boxNumber = sanitizeMySQL($_POST['boxNumber']);
			$nature = sanitizeMySQL($_POST['nature']);
			$duties = sanitizeMySQL($_POST['duties']);
			$qualifications = sanitizeMySQL($_POST['qualifications']);
			$benefits = sanitizeMySQL($_POST['benefits']);
			$apply = sanitizeMySQL($_POST['apply']);
			$jobNumber = sanitizeMySQL($_POST['jobNumber']);
			$category = sanitizeMySQL($_POST['category']);
			$jobClass = sanitizeMySQL($_POST['jobClass']);
			$program = sanitizeMySQL($_POST['program']);
			$classified = sanitizeMySQL($_POST['classified']);
			$date = date('l F dS Y h:i:s A');
	
			if (!($employmentPeriod == '' || $hoursPerWeek == '')) {
				$periodString = sanitizeMySQL(implode(', ', $employmentPeriod));
				$hoursString = sanitizeMySQL(implode(', ', $hoursPerWeek));
			}else{
				$periodString = $employmentPeriod;
				$hoursString = $hoursPerWeek;
			}
					
			$sql="UPDATE onCampus
				SET jobTitle = '$jobTitle', orgName = '$orgName', location = '$location', website = '$website', min = '$min', 
				max = '$max', employmentPeriod = '$periodString', hoursPerWeek = '$hoursString', status = '$status', contactFName = '$contactFName',  contactLName = '$contactLName',
				phoneNumber = '$phoneNumber', emailAddress = '$emailAddress', nature = '$nature', jobClass = '$jobClass', boxNumber = '$boxNumber',
				duties = '$duties', qualifications = '$qualifications', benefits = '$benefits', apply = '$apply', 
				jobNumber = '$jobNumber', category = '$category', program = '$program', classified = '$classified'
				WHERE ID = '$current'";
	
			if(isset($_POST['email'])){	
				$to = $emailAddress;
				$subject = '[WS Job] ' . $jobTitle . ' job description';
				$message = 
				$date . "\n
				Thank you for submitting your job description for $jobTitle.  
				The position description has been approved and if the position is open it will be posted on our site. 
				Please notify our office when the position has been filled so we can remove it from our listing.  
				You can view your listing at:  
				
				http://www.washington.edu/students/osfa/ugaid/workstudy.positions.html
				
				Job title:  $jobTitle
				Job number:  $jobNumber
				Job class code: $jobClass
				Status:  $status
				Program:  $program
				
				For additional information about the Work Study hiring and payment process please review our web pages.
				http://www.washington.edu/students/osfa/ugaid/employer.info.html";
								
				$from = "workstdy@uw.edu";
				$headers = "From:" . $from;
				mail($to,$subject,$message,$headers);
				echo "Email sent to employer from $from to $emailAddress.";
			}
				
			if (!mysqli_query($con, $sql)) {
					  die('Error: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
			}
			
		}
		
		$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM {$table} WHERE ID = $current");
		
		if (!$result) {
			die("Query to show fields from table failed");
		}
		
		$row = mysqli_fetch_array($result);
		
		
		function sanitizeMySQL($var){
			$var = ((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $var) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : ""));
			$var = sanitizeString($var);
			return $var;
		}
	
		function sanitizeString($var)
		{
			$var = htmlentities($var);
			$var = strip_tags($var);
			return $var;
		}
	?>

	<a class="button" href="on.php"><span>Table View</span></a>
	
	<div id="updateForm">
		<form name="update" <?php echo "action='on_update.php?id=$current'"?> method='post'>	
			<fieldset id="infos">
			<legend>Job Information</legend>
				<label for="jobTitle">Job Title:</label>
				<input class="standard" type="text" value="<?php echo $row['jobTitle'];?>" name="jobTitle"/>
				
				<br/>
				
				<label for="orgName">Organization Name:</label>
				<input class="standard" type="text" value="<?php echo $row['orgName'];?>" name="orgName"/>
				
				<br/>
				
				<label for="location">Location:</label>
				<input class="standard" type="text" value="<?php echo $row['location'];?>" name="location"/>
				
				<br/>
				
				<label for="website">Website:</label>
				<input class="standard" type="text" value="<?php echo $row['website'];?>" name="website"/>

				<br/>
				
				<label>Hourly Pay Range:</label>
				<br/>
				<label class="pay" id="min" for="min">Min $</label>
				<input class="required" value="<?php echo $row['min'];?>" id="mid" type="text" maxlength="5" size="5" name="min"/>
				<br/>
				<label class="pay" for="max">Max $</label>
				<input class="required" value="<?php echo $row['max'];?>" type="text" maxlength="5" size="5" name="max"/>
				
				<br/>
				
				<label for="employmentPeriod">Employment Period:</label>
				<br/>
				<input type="checkbox" name="employmentPeriod[]" value="Summer" <?php if ($row['employmentPeriod'] == 'Summer' || $row['employmentPeriod'] == 'Summer, Academic Year'){echo "checked='checked'";}?>/> Summer
				<br/>
				<input type="checkbox" name="employmentPeriod[]" value="Academic Year" <?php if ($row['employmentPeriod'] == 'Academic Year' || $row['employmentPeriod'] == 'Summer, Academic Year'){echo "checked='checked'";}?>/> Academic Year
				
				<br/>
				
				<label for="intrest">Hours Per Week:</label>
				<br/>
				<input type="checkbox" name="hoursPerWeek[]" value="40 hrs/wk" <?php if ($row['hoursPerWeek'] == '40 hrs/wk' || $row['hoursPerWeek'] == '40 hrs/wk, 19 hrs/wk'){echo "checked='checked'";}?>/> 40 hrs/wk (Summer Only)

				<br/> 
				
				<input type="checkbox" name="hoursPerWeek[]" value="19 hrs/wk" <?php if ($row['hoursPerWeek'] == '19 hrs/wk' || $row['hoursPerWeek'] == '40 hrs/wk, 19 hrs/wk'){echo "checked='checked'";}?>/> up to 19 hrs/wk
				
				<br/>
				<br/>
				
				<label for="status">Job Status:</label>
				<input type="radio" value="Open" name="status" <?php if ($row['status'] == 'Open'){echo "checked='checked'";}?> >Open</input>
				<input type="radio" value="Closed" name ="status" <?php if ($row['status'] == 'Closed'){echo "checked='checked'";}?>>Closed </input>
								
				<br/>
				
			</fieldset>
			<fieldset id="contact">
				<legend>Contact Information</legend>
				<label for="contactFName">Contact First Name:</label>
				<input class="standard" type="text" name="contactFName" value="<?php echo $row['contactFName'];?>" />
				
				<br/>
				
				<label for="contactLName">Contact Last Name:</label>
				<input class="standard" type="text" name="contactLName" value="<?php echo $row['contactLName'];?>" />
				
				<br/>
				
				<label for="phoneNumber">Phone Number:</label>
				<input class="standard" type="text" name="phoneNumber" value="<?php echo $row['phoneNumber'];?>" />
				
				<br/>
				
				<label for="emailAddress">Email Address:</label>
				<input class="standard" type="text" name="emailAddress" value="<?php echo $row['emailAddress'];?>" />
				
				<br/>

				<label for="boxNumber" id="boxL">Box Number:</label>
				<input type="text" name="boxNumber" id="boxNumber" value="<?php echo $row['boxNumber'];?>" size="6" maxlength="6"/>
				
			</fieldset>
			<fieldset id="requirements">
				<legend>Requirements</legend>
				<label for="nature">Nature of Organization:</label>
				<textarea name="nature" rows="10" cols="80"><?php echo $row['nature'];?></textarea>
				
				<br/>
				
				<label for="duties">Duties and Responsibilities:</label>
				<textarea name="duties" rows="10" cols="80"><?php echo $row['duties'];?></textarea>
				
				<br/>
				
				<label for="qualifications">Minimum Qualifications:</label>
				<textarea name="qualifications" rows="10" cols="80"><?php echo $row['qualifications'];?></textarea>
				
				<br/>
				
				<label for="benefits">Educational Benefits:</label>
				<textarea name="benefits" rows="10" cols="80"><?php echo $row['benefits'];?></textarea>
				
				<br/>
				
				<label for="apply">How to Apply:</label>
				<textarea name="apply" rows="10" cols="80"><?php echo $row['apply'];?></textarea>
			
			</fieldset>	
			
			<fieldset id="identification">
				<legend>Identification</legend>
				
				<label for="jobNumber">Job Number:</label>
				<input class="standard" type="text" size="8" maxlength="8" value="<?php echo $row['jobNumber'];?>" name="jobNumber"/>
				
				<br/>
				
				<label for="category">Category:</label>
				<select name='category'>
					<option value='<?php if($row['category'] == null){echo '';}else{echo $row['category'];}?>'>
					<?php if($row['category'] == null){echo 'Select One';}else{echo $row['category'];}?></option>
					<option value='Arts &amp; Media'>Arts &amp; Media</option>
					<option value='Grad Appt'>Grad Appt</option>
					<option value='Office &amp; Administrative'>Office &amp; Administrative</option>
					<option value='Science &amp; Health'>Science &amp; Health</option>
					<option value='Technology'>Technology</option>
					<option value='Social Services &amp; Research'>Social Services &amp; Research</option>
					<option value='Student Services'>Student Services</option>
				</select>
				
				<br/>
				
				<label for='jobClass'>Job Class Code:</label>
				<select name='jobClass'>
					<option value='<?php if($row['jobClass'] == null){echo '';}else{echo $row['jobClass'];}?>'>
					<?php if($row['jobClass'] == null){echo 'Select One';}else{echo $row['jobClass'];}?></option>
					<option value='0875'>0875</option>
					<option value='0872'>0872</option>
					<option value='0881'>0881</option>
					<option value='0882'>0882</option>
					<option value='0883'>0883</option>
					<option value='0868'>0868</option>
					<option value='0869'>0869</option>
					<option value='0886'>0886</option>
					<option value='0887'>0887</option>

				</select>
				
				<br/>
		
				<label for='program'>Program:</label>
				<input type="radio" value="Federal" id="onRadio" name="program" <?php if ($row['program'] == 'Federal'){echo "checked='checked'";}?> >Federal</input>
				<input type="radio" value="State" name ="program" <?php if ($row['program'] == 'State'){echo "checked='checked'";}?>>State</input>
				
				<br/>
				
				<label for='classified'>51% Comp to Classified:</label>
				<input type="radio" value="y" name="classified" <?php if ($row['classified'] == 'y'){echo "checked='checked'";}?>>Yes</input>
				<input type="radio" value="n" name ="classified" <?php if ($row['classified'] == 'n'){echo "checked='checked'";}?>>No</input>

				
			</fieldset>
			<fieldset id="submit">
				<input type='submit' name='update' value='Update'/>
				<input type='submit' name='email' value='Update and Email'/>
			</fieldset>
		</form>
	</div>


	<script type="text/javascript">
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." 
	: "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + 
	"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
	</script>
	<script type="text/javascript">
	try {
	var pageTracker = _gat._getTracker("UA-11922437-1");
	pageTracker._trackPageview();
	} catch(err) {}</script>


	<a href= "#top"> Return to Top of Page</a><br>


	<!--chtml include "//home/incs/footer.inc"-->

	
	</body>
</html>
