<?php 
  include_once('../../config/config.php');
  $type='';
  if(isset($_GET['type'])){
    $type=$_GET['type'];
  }

  //if form type is for adding vacancies
  if($type=='add_vacancy'){
?>
    <div class="d-flex justify-content-between flex-wrap flex-md-nowrap  pb-2 mb-3 border-bottom" style="width: 100%; text-align: left;">
      <div class="col-md-12 order-md-1">
    <h4 class="mb-3">New Job Opening
      <button style="float: right;" id="hide" class="btn btn-md btn-primary">Close</button>
    </h4>
    
    <form class="needs-validation" id="new_job" method="post" action="sql_statements.php">
      <input type="hidden" name="add_vacancy">
      <div class="row">
        <div class="col-md-3 mb-3">                
          <label for="firstName">Job Type</label>
          <select class="form-control" name="type" id="type">
            <option >Choose</option>
            <?php 
              $sql=$db->query("select * from job_types order by type_name asc");
              if($sql){
                while ($row=$sql->fetch()) {
                  echo "<option value='".$row['type_id']."'>".$row['type_name']."</option>";
                }
              }
            ?>
          </select>
        </div>
        <div class="col-md-3 mb-3">
          <label for="firstName">Job Category</label>
           <select class="form-control" name="category" id="category">
            <option value="">Choose</option>
            <?php 
              $sql=$db->query("select * from job_categories order by category_name asc");
              if($sql){
                while ($row=$sql->fetch()) {
                  echo "<option value='".$row['category_id']."'>".$row['category_name']."</option>";
                }
              }
            ?>
             
          </select>
        </div>
        <div class="col-md-3 mb-3">
          <label for="Username">Location</label>
          <input type="text" class="form-control" id="location" name="location" required>
        </div>
        <div class="col-md-3 mb-3">
          <label for="Password">Closing Date</label>
          <input type="text" class="form-control" id="closing_date" name="closing_date" required>
          
        </div>
        
      </div>
      <div class="row">
        <div class="col-md-4 mb-3">
          <label for="lastName">Company/Individual</label>
          <input type="text" class="form-control" id="company" name="company" required>
          
        </div>
        
        <div class="col-md-8 mb-3">
          <label for="Password">Job Title</label>
          <input type="text" class="form-control" id="job_title" name="job_title" required>
          
        </div>
      </div>

      <div class="row">
        <div class="col-md-12 mb-3">
          <label for="Password">Job Details</label><br>               
          <textarea class="form-control" name="job_details" id="textbox" rows="9"></textarea>
          
        </div>
      </div>

      <button class="btn btn-primary btn-md" type="reset" name="reset" id="reset" style="float: right;">
         Clear Form   
      </button>
      <button class="btn btn-primary btn-md" type="submit" name="create_vacancy" id="create_vacancy" style="float: right; margin-right: 5px;">
         Create User
      </button>
    </form>
  </div>
</div>

<?php } ?>