<?php
require_once("header.php");
require_once("menu.php");
if(isset($_REQUEST['edit']))
{
    $co_id = base64_decode($_REQUEST['edit']);
    $ex = $obj->get_currentopening_id($co_id);
    $row = mysqli_fetch_array($ex);
}

if(isset($_POST['update']))
{   
  $co_info['co_id'] = $_POST['co_id'];
  $co_info['co_title'] = $_POST['co_title'];
  $co_info['co_open'] = $_POST['co_open'];
  $co_info['co_city'] = $_POST['co_city'];
  $co_info['co_responsibility'] = $_POST['co_responsibility'];
  $co_info['co_skills'] =  $_POST['co_skills'];
  $co_info['co_education'] = str_replace("'","\'", $_POST['co_education']);
     
    $ex = $obj->update_currentopenings_info($co_info);
    echo '<script>window.location="current_openings.php"</script>';
}



if(isset($_POST['submit']))
{
  $co_info['co_title'] = $_POST['co_title'];
  $co_info['co_open'] = $_POST['co_open'];
  $co_info['co_city'] = $_POST['co_city'];
  $co_info['co_responsibility'] =  $_POST['co_responsibility'];
  $co_info['co_skills'] =  $_POST['co_skills'];
  $co_info['co_education'] =  $_POST['co_education'];
  $co_info['co_url'] = str_replace(" ","-",strtolower($co_info['co_title']));
  
   $ex = $obj->insert_currentopenings_info($co_info);
    echo '<script>window.location="current_openings.php"</script>';
}
?>

<div id="layoutSidenav_content">
<main class="mt-4">
    <div class="container-fluid">
        
        <div class="card mb-4">
            <div class="card-header">
                <i class="fas fa-check-square mr-1"></i>Current Openings
                <a href="current_openings.php" class="btn btn-primary btn-sm float-right">Back</a>
            </div>
            <div class="card-body">
                
                
                <form method="POST">
                   <input type="hidden" name="co_id" value="<?php echo $row['co_id'];?>">
                   <p><b>Note:-</b> All * Fields are required </p>
                  
               <div class="form-group">
                 <label>Position Name*</label>
                 <input type="text" name="co_open" class="form-control" value="<?php echo $row['co_open'];?>" required>
               </div>
               <div class="form-group">
                 <label>City*</label>
                 <input type="text" class="form-control" name="co_city" value="<?php echo $row['co_city'];?>" required>
               </div>
                  <div class="form-group">
                 <label>Key Responsibilities*</label>
                  <textarea id="w3review" name="co_responsibility" rows="6" cols="50" class="tinymce" required><?php echo $row['co_responsibility'];?></textarea>
               </div>
                <div class="form-group">
                 <label>Skills Required*</label>
                  <textarea id="w3review" name="co_skills" rows="6" cols="50" class="tinymce"><?php echo $row['co_skills'];?></textarea>
               </div>
                <div class="form-group">
                 <label>Education, Expertise & Experience*</label>
                  <textarea id="w3review" name="co_education" rows="6" cols="50" class="tinymce"><?php echo $row['co_education'];?></textarea>
               </div>
          
          
                    <?php if(isset($_REQUEST['edit']))
                    { ?> 
                        <button type="submit" class="btn btn-primary" name="update">Update</button>
                    <?php } 
                    else
                    { ?>
                    <input type="submit" name="submit" value="submit">
                        
                    <?php } ?>
                </form> 
            </div>
        </div>
    </div>
</main>



<?php require_once("footer.php");?>

