<?php
	include(''. $config['LocalPath'] . '/includes/.sql_con.php');


if(isset($_POST['name'])){
	$new_task_name=$_POST['name'];
	$new_task_sop=$_POST['sop'];
	$new_job_time=$_POST['time'];
		$insert_task ="INSERT INTO JOB (JOB_NAME, SOP_URL, COMPLETE_TIME) VALUES ('$new_task_name' , '$new_task_sop', '$new_job_time')";
			mysql_query($insert_task)or die ('Add Failed</br>'.mysql_error());
}
?>
<div class="row">
	<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
		<div class="card card-mini">
			<div class="card-header">
				<div class="card-title"><b><center>Add a Job</center></b></div>
			</div>
		<div class="card-body">

			<form class="form form-horizontal" method="post">
				<div class="form-group">
					<label class="col-md-3 control-label"><b>Job Name</b></label>
					<div class="col-md-8">
						<input type="text" name="name" class="form-control" placeholder="Job to be Added">
					</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-8">
				<input type="text"  name="sop" class="form-control" placeholder="http://mission.hostiran.com/">
			</div>
		</div>
		<div class="form-group">
			<label class="col-md-3 control-label"><b>Estimated Time to Complete</b></label>
			<div class="col-md-3">
				<div class="input-group">
					<input type="text" name="time" class="form-control" aria-label="Esitmated Time to Complete">
					<span class="input-group-addon">Mins</span>
				</div>
			</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-group">
			<label class="col-md-3 control-label">Cover</label>
			<div class="col-md-4">
				<div class="input-group">
					<select class="select2">
						<option value="1">1</option>
						<option value="2">2</option>
						<option value="3">3</option>
						<option value="4">4</option>
					</select>
					<span class="input-group-addon">Years</span>
				</div>
			</div>
		</div>-->
<div class="form-footer">
	<div class="form-group">
		<div class="col-md-6 col-md-offset-3">
			<center>	<button type="submit" class="btn btn-primary">Save</button>
			<button type="button" class="btn btn-default">Cancel</button> </center>
		</div>
	</div>
</div>
</form>
</div>
</div>
</div>
<div class="row">
	<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5">
		<div class="card card-mini">
      <div class="card-header">
        <div class="card-title"><b>Active Jobs</b></div>
        <ul class="card-action">
          <li>
            <a href="#" onClick="MyFunction();">
              <i class="fa fa-refresh"></i>
            </a>
		<script>
			function MyFunction() {
				location.reload();
			}
		</script>
          </li>
        </ul>
      </div>
      <div class="card-body no-padding table-responsive">
        <table class="table card-table">
          <thead>
            <tr>
              <th><b>Task</b></th>
              <th><b>SOP URL</b></th>
	      <th><b>Time To Complete</b></th>
            </tr>
          </thead>
          <tbody>
<?php


$tasks_result = mysql_query('SELECT JOB_NAME, SOP_URL, COMPLETE_TIME  FROM JOB ');

while ($row=mysql_fetch_array($tasks_result)){
        $job_name=$row['JOB_NAME'];
        $sop=$row['SOP_URL'];
	$job_time=$row['COMPLETE_TIME'];
        


?>
            <tr>
              <td><?php echo $job_name;?></td>
              <td><a target="_blank" href="<?php echo $sop;?>"><?php echo $sop;?></a> </td>
	      <td><?php if ($job_time == ''){
                                echo " Not Set";
                        }
                        else{
                                echo "$job_time Mins";
                        }
                ?></td>

            </tr>
<?php
}
?>
          </tbody>
        </table>
      </div>
    </div>

	</div>
</div>	
