<?php include('experience.php'); ?>

<?php
include('server.php');
if(!$_SESSION['loggedin']) {
    header("location: index.php");
}

if(isset($_GET['id'])) {
    $id = $_GET['id'];
    $_SESSION['posts_id'] = $id;
    // echo "$id";
    // die;

    $sql = "SELECT * FROM posts WHERE id = $id";

    $result = mysqli_query($db, $sql);

    $row = mysqli_fetch_assoc($result);

    // echo "<pre/>";
    // print_r($row);

    $round = explode(",", $row['roundprovided']);
    $roundcleared = explode(",", $row['roundcleared']);
    $row['story'] = str_replace("<br/>", "\n", $row['story']);
}




?>
<html lang="en">
  <head>
    <title>Placement Experience | Share</title>
    <!-- Bootstrap -->
    <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <!--user icon -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    
    <!-- Google Font -->
    <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700&display=swap" rel="stylesheet"> 
    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@800&family=Roboto+Mono&display=swap" rel="stylesheet"> 
    <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap" rel="stylesheet"> 
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

  </head>
<body>
   <div class="row">

    <div class="col-sm-3" style="left:0px;">
      <div class="container-fluid sidenav">
        <a href="mainpage.php"><img src="img/logoo.png" style="width:100px; margin-top:15px;"></a>
        <br><br>

      <div id="cse">
        <a style="text-decoration: none;" href="https://www.cse.iitb.ac.in" target="_blank">
          <h6 style="text-align: center;">Department of</h6>
          <h6 style="text-align: center;">Computer Science and Engineering</h6>
          <h5 style="text-align: center;">IIT Bombay</h5> 
        </a>
      </div>
      <br><br>
        <ul>
          <li><a href="mainpage.php"> HOME </a></li>
          <li><a href="posts.php"> POSTS </a></li>
          <li><a href="exp_form.php">SHARE</a></li>
          <li><a href="profile.php"> PROFILE </a></li>
        </ul>
        <br><br>
        <div id="iLinks">
        <h5>Important Links</h5>
        <ul>
          <li style="font-size:10px;"><a href="http://www.iitb.ac.in/" target=_blank> IITB Home</a></li>
          <li style="font-size:10px;"><a href="https://www.cse.iitb.ac.in/"> CSE@IITB </a></li>
          <li style="font-size:10px;"><a href="https://asc.iitb.ac.in/"> ASC </a></li>
        </ul>
      </div>
        <br><br>
      </div>
    </div>

    <div class="container-fluid col-md-8 whole" style="margin-top:0px;"> 

      <div class="row">
        <div class="col-sm-8 main" id="title">
          <img src="img/heading_trans.png" alt="placementExperience" style="align-content: center; margin-left: 25%; margin-right: 25%;">
        </div>
        <div class="col-sm-4" style="left:0px; padding-top:20px; vertical-align: center;">
          <button id="logout" type="button" class="btn btn-info btn-round" style="float:right;">
          Logout
          </button> 
          <a href="profile.php"><i class="fa fa-user-circle-o" style="font-size:36px; float:right; padding-right:10px;" ></i></a>
        </div>
      </div>

      <hr class="lineform">

    <div class="container pt-5">
        
        <h2 style="text-align: center;"><b>Experience Form</b></h2>
        <br>
        <div class="bg-white p-5 mb-5">
         <form action="edit_exp_db.php?posts_id=<?= $id; ?>" method="post">
            <div class="form-group">
                <label for="name">Name:</label>
                <input type="hidden" name="id" value="<?= ($row['id']) ?: $row['id'] ?>">
                <input type="hidden" name="student_id" value="<?= ($row['student_id']) ?: $row['student_id'] ?>">
                <input type="text" class="form-control" placeholder="Enter full name" id="name" name="name" required value="<?= ($row['name']) ?: $row['name'] ?>" readonly>
            </div>
             <div class="form-group">
                <label for="roll">Roll No:</label>
                <input type="text" class="form-control" placeholder="Enter CSE Roll number" id="roll" name="roll" required value="<?= ($row['roll']) ?: $row['roll'] ?>" readonly>
            </div>
            <div class="form-group">
                <label for="email">Email address:</label>
                <input type="email" class="form-control" placeholder="Enter email" id="email" name="email" required value="<?= ($row['email']) ?: $row['email'] ?>" readonly>
             </div>
             <div class="form-group">
                <label for="course">Courses Taken (all semesters):</label>
                <input type="text" class="form-control" placeholder="Enter comma separated course codes ( eg: CS601,CS725 )" id="course" name="coursetaken" required value="<?= ($row['coursetaken']) ?: $row['coursetaken'] ?>">
             </div>
             <div class="form-group">
                <label for="company">Company Name:</label>
                <input type="text" class="form-control" placeholder="Enter company's official name" id="company" name="companyname" required value="<?= ($row['companyname']) ?: $row['companyname'] ?>">
             </div>
             <br>
             <h5>Rounds provided by company:</h5>

             <div class="custom-control custom-checkbox mb-3">
                 <input type="checkbox" <?php if(in_array('Written/Aptitude Round', $round)) { echo "checked"; } ?> class="custom-control-input" value="Written/Aptitude Round" id="written" name="roundprovided[]">
                 <label class="custom-control-label" for="written">Written/Aptitude Round</label>
             </div>
             <div class="custom-control custom-checkbox mb-3">
                 <input type="checkbox" class="custom-control-input" <?php if(in_array('Coding Round', $round)) { echo "checked"; } ?> id="coding" name="roundprovided[]" value="Coding Round">
                  <label class="custom-control-label" for="coding">Coding Round</label>
             </div>
             <div class="custom-control custom-checkbox mb-3">
                 <input type="checkbox" class="custom-control-input" <?php if(in_array('Group Discussion', $round)) { echo "checked"; } ?> id="gd" name="roundprovided[]" value="Group Discussion">
                  <label class="custom-control-label" for="gd">Group Discussion</label>
             </div>
             <div class="custom-control custom-checkbox mb-3">
                 <input type="checkbox" class="custom-control-input" <?php if(in_array('1st Interview Round', $round)) { echo "checked"; } ?> id="int1" name="roundprovided[]" value="1st Interview Round">
                  <label class="custom-control-label" for="int1">1st Interview Round</label>
             </div>
             <div class="custom-control custom-checkbox mb-3">
                 <input type="checkbox" class="custom-control-input" <?php if(in_array('2nd Interview (HR) Round', $round)) { echo "checked"; } ?> id="int2" name="roundprovided[]" value="2nd Interview (HR) Round">
                  <label class="custom-control-label" for="int2">2nd Interview (HR) Round</label>
            </div>
             <br>
             <h5>Rounds you have cleared:</h5>
             <div class="custom-control custom-checkbox mb-3">
                 <input type="checkbox" class="custom-control-input" <?php if(in_array('Written/Aptitude Round', $roundcleared)) { echo "checked"; } ?> id="written2" name="roundcleared[]" value="Written/Aptitude Round">
                 <label class="custom-control-label" for="written2">Written/Aptitude Round</label>
             </div>
             <div class="custom-control custom-checkbox mb-3">
                 <input type="checkbox" class="custom-control-input" <?php if(in_array('Coding Round', $roundcleared)) { echo "checked"; } ?> id="coding2" name="roundcleared[]" value="Coding Round">
                  <label class="custom-control-label" for="coding2">Coding Round</label>
             </div>
             <div class="custom-control custom-checkbox mb-3">
                 <input type="checkbox" class="custom-control-input" <?php if(in_array('Group Discussion', $roundcleared)) { echo "checked"; } ?> id="gd2" name="roundcleared[]" value="Group Discussion">
                  <label class="custom-control-label" for="gd2">Group Discussion</label>
             </div>
             <div class="custom-control custom-checkbox mb-3">
                 <input type="checkbox" class="custom-control-input" <?php if(in_array('1st Interview Round', $roundcleared)) { echo "checked"; } ?> id="int12" name="roundcleared[]" value="1st Interview Round">
                  <label class="custom-control-label" for="int12">1st Interview Round</label>
             </div>
             <div class="custom-control custom-checkbox mb-3">
                 <input type="checkbox" class="custom-control-input" <?php if(in_array('2nd Interview (HR) Round', $roundcleared)) { echo "checked"; } ?> id="int22" name="roundcleared[]" value="2nd Interview (HR) Round">
                  <label class="custom-control-label" for="int22">2nd Interview (HR) Round</label>
            </div>
             <br>
             <div class="md-form mb-4 green-textarea active-green-textarea">
                 <label for="story">Your Story/Experience:</label>
                  <textarea id="story" class="md-textarea form-control" rows="12" placeholder="Please restrict yourself to 100 words . . ." name="story" required><?= ($row['story']) ?: $row['story'] ?></textarea>
             </div>
             <input class="btn btn-primary" type="submit" name="update" value="Update">
        </form> 
        </div>
        </div>
    </div>
    </div>

    <div class="footer">
      <p style="color:#e88924">&#9400; Copyright@IITB</p>
    </div>




    <!-- Login popup scripts -->
    <script src='https://code.jquery.com/jquery-3.3.1.slim.min.js'></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js'></script>
    <script src='https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js'></script>
    <script  src="js/script.js"></script>
</body>
</html>