<!--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>Off 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 = 'offCampus';

	$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 = ($_POST["jobType"]);
		$jobTitle = ($_POST["jobTitle"]);
		$orgName = ($_POST["orgName"]);
		$location = ($_POST["location"]);
		$website = ($_POST["website"]);
		$ein = ($_POST['ein']);
		$min = ($_POST['min']);
		$max = ($_POST['max']);
		$employmentPeriod = $_POST["employmentPeriod"];
		$hoursPerWeek = $_POST['hoursPerWeek'];
		$status = ($_POST['status']);
		$contactFName = ($_POST['contactFName']);
		$contactLName = ($_POST['contactLName']);
		$phoneNumber = $_POST['phoneNumber'];
		$emailAddress = ($_POST['emailAddress']);
		$street = ($_POST['street']);
		$city = ($_POST['city']);
		$state = ($_POST['state']);
		$zip = ($_POST['zip']);
		$nature = ($_POST['nature']);
		$duties = ($_POST['duties']);
		$qualifications = ($_POST['qualifications']);
		$benefits = ($_POST['benefits']);
		$apply = ($_POST['apply']);
		$jobNumber = ($_POST['jobNumber']);
		$category = ($_POST['category']);
		$reimburseRate = ($_POST['reimburseRate']);
		$program = ($_POST['program']);
		$date = date('l F dS Y h:i:s A');

		if (!($employmentPeriod == '' || $hoursPerWeek == '')) {
			$periodString = (implode(', ', $employmentPeriod));
			$hoursString = (implode(', ', $hoursPerWeek));
		}else{
			$periodString = $employmentPeriod;
			$hoursString = $hoursPerWeek;
		}	
				
		$sql="UPDATE offCampus 
			SET jobTitle = '$jobTitle', orgName = '$orgName', location = '$location',  ein = '$ein',  website = '$website', min = '$min', 
			max = '$max', employmentPeriod = '$periodString', hoursPerWeek = '$hoursString', status = '$status', contactFName = '$contactFName', contactLName = '$contactLName',
			phoneNumber = '$phoneNumber', emailAddress = '$emailAddress', nature = '$nature', street = '$street', city = '$city', state = '$state', 
			zip = '$zip', duties = '$duties', qualifications = '$qualifications', benefits = '$benefits', apply = '$apply', 
			jobNumber = '$jobNumber', category = '$category', reimburseRate = '$reimburseRate', program = '$program' 
			WHERE ID = '$current'";

		if(isset($_POST['email'])) {	
			$to = $emailAddress;
			$subject = '[WS Job] ' . $jobTitle . ' job description';
			$message =
			$date . "
		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
		Status:  $status
		Program:  $program
		Reimbursement Percentage: $reimburseRate %
				
		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 = "uworkstu@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="off.php"><span>Table View</span></a>
	
	<div id="updateForm">
		<form name="update" <?php echo "action='off_update.php?id=$current&'"?> method='post'>	
			<fieldset>
			<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="location">EIN:</label>
				<input class="standard" type="text" value="<?php echo $row['ein'];?>" name="ein"/>
				
				<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>
				<legend>Contact Information</legend>
				<label for="">Contact First Name:</label>
				<input class="standard" type="text" name="contactFName" value="<?php echo $row['contactFName'];?>" />
				
				<br/>
				
				<label for="">Contact Last Name:</label>
				<input class="standard" type="text" name="contactLName" value="<?php echo $row['contactLName'];?>" />
				
				<br/>
				
				<label for="">Phone Number:</label>
				<input class="standard" type="text" name="phoneNumber" value="<?php echo $row['phoneNumber'];?>" />
				
				<br/>
				
				<label for="">Email Address:</label>
				<input class="standard" type="text" name="emailAddress" value="<?php echo $row['emailAddress'];?>" />
				
				<br/>

				<label for="street" id="streetL">Street Address:</label>
				<input class="standard" type="text" name="street" id="street" value="<?php echo $row['street'];?>"/>
				
				<br/>

				<label for="city" id="cityL">City:</label>
				<input class="standard" type="text" name="city" id="city" value="<?php echo $row['city'];?>"/>
				
				<br/>

				<label for="state" id="stateL">State:</label>
				<input class="standard" type="text" name="state" id="state" value="<?php echo $row['state'];?>"/>
				
				<br/>

				<label for="zip" id="zipL">Zip Code:</label>
				<input type="text" name="zip" id="zip" size="5" maxlength="5" value="<?php echo $row['zip'];?>"/>
			</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='Office &amp; Administrative'>Office &amp; Administrative</option>
					<option value='Architecture'>Architecture</option>
					<option value='Arts &amp; Media'>Arts &amp; Media</option>
					<option value='Education'>Education</option>
					<option value='Environmental'>Environmental</option>
					<option value='Law'>Law</option>
					<option value='Science &amp; Health'>Science &amp; Health</option>
					<option value='Social Services &amp; Research'>Social Services &amp; Research</option>
					<option value='Technology'>Technology</option>
				</select>	
				
				<br/>
				
				<label for='reimburseRate'>Reimbursement Rate:</label>
				<select name='reimburseRate'>
					<option value='<?php if($row['reimburseRate'] == null){echo '';}else{echo $row['reimburseRate'];}?>'>
					<?php if($row['reimburseRate'] == null){echo 'Select One';}else{echo $row['reimburseRate'] . '%';}?></option>
					<option value='40'>40%</option>
					<option value='60'>60%</option>
					<option value='70'>70%</option>
					<option value='75'>75%</option>
					<option value='100'>100%</option>
				</select>
				
				<br/>
				
				<label for='program'>Program:</label>
				<select name='program'>
					<option value='<?php if($row['program'] == null){echo '';}else{echo $row['program'];}?>'>
					<?php if($row['program'] == null){echo 'Select One';}else{echo $row['program'];}?></option>
					<option value='America Reads'>America Reads</option>
					<option value='Federal'>Federal</option>
					<option value='State'>State</option>
					<option value='Community Service - FED'>Community Service - FED</option>
					<option value='Community Service - STA'>Community Service - STA</option>
				</select>
				
			</fieldset>
			<fieldset id="submit">
				<input type='submit' name='update' value='Update'/>
				<input type='submit' name='email' value='Update and Email.'/>
			</fieldset>
		</form>
	</div>
	
	<!-- MAIN PAGE CONTENT -->				

	<!-- From FOOTER.INC -->

				</div>
			</div>
		</div>	
		<div id="contentFooter"></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>
