<?php
	include(''. $config['LocalPath'] . '/includes/.sql_con.php');
include($_SERVER['DOCUMENT_ROOT'] .'/modules/header.php');
include(''. $config['LocalPath'] .'/modules/sidebar.php');
include(''. $config['LocalPath'] .'/modules/nav.php');
$_SESSION['current_page'] = "Management -- Edit Job";
include(''. $config['LocalPath'] .'/modules/help-module.php');
//include(''. $config['LocalPath'] .'/manage/modules/edit-job.php');



if(isset($_POST['new_job_name'])){

	$edit_job_name=$_POST['new_job_name'];
	$edit_job_sop=$_POST['new_job_sop'];
	$edit_job_id=$_POST['edit_job_id'];

		$update_job = "UPDATE `JOB` SET `JOB_NAME='$edit_job_name', `SOP_URL`='$edit_job_sop' WHERE `JOB_ID`='$edit_job_id'";
			mysql_query($update_job)or die ('Update Failed</br>'.mysql_error());
}
else{
if(isset($_POST['job_id'])){
        $posted_job_id=$_POST['job_id'];
		
		$get_job_info = mysql_query("SELECT JOB_NAME, SOP_URL FROM JOB WHERE JOB_ID='$posted_job_id'");
			while ($rowinfo=mysql_fetch_array($get_job_info)){
					$posted_job_name=$rowinfo['JOB_NAME'];
					$posted_job_sop=$rowinfo['SOP_URL'];
			}

?>

<div class="row">
	<div class="col-lg-5 col-lg-offset-3 col-md-5 col-md-offset-3 col-sm-6 col-sm-offset-3 col-xs-5 col-xs-offset-3">
		<div class="card card-mini">
			<div class="card-header">
				<div class="card-title"><b><center>Edit Job</center></b></div>
			</div>
		<div class="card-body">

			<form class="form form-horizontal" method="post" id="form">
				<div class="form-group">
					<label class="col-md-3 control-label"><b>Job Name</b></label>
					<div class="col-md-5">
						<input type="text" name="new_job_name" class="form-control" Value="<?php echo $posted_job_name;?>">
					</div>
				</div>
		<div class="form-group">
			<div class="col-md-3">
				<label class="control-label"><b>SOP URL</b></label>
			</div>
			<div class="col-md-5">
				<input type="text"  name="new_job_sop" class="form-control" Value="<?php echo $posted_job_sop;?>">
				<input type="hidden" name="edit_job_id" value="<?php echo $posted_job_id;?>"/>
			</div>
		</div>
		<!--<div class="form-group">
			<label class="col-md-3 control-label">Type</label>
			<div class="col-md-9">
				<div class="radio radio-inline">
					<input type="radio" name="radio4" id="radio10" value="option10">
					<label for="radio10">
					Global
					</label>
				</div>
				<div class="radio radio-inline">
					<input type="radio" name="radio4" id="radio11" value="option11" checked>
					<label for="radio11">
					Local
					</label>
				</div>
			</div>
		</div>-->
<div class="form-footer">
	<div class="form-group">
		<div class="col-md-5 col-md-offset-3">
			<center>	<button type="submit" class="btn btn-primary">Edit Job</button>
			<button type="button" class="btn btn-default" onclick="resetForm()">Clear</button> </center>
				<script>
					function resetForm() {
						document.getElementById("form").reset();
					}
				</script>
		</div>
	</div>
</div>
</form>
</div>
</div>
</div>
</div>
<?php
}
}
?> 
