????????????????????
??????????????????
ÿØÿà
 JFIF      ÿÛ C      


!"$"$ÿÛ C    
ÿÂ p 
" ÿÄ     
         ÿÄ             ÿÚ 
   ÕÔË®

(%	aA*‚XYD¡(J„¡E¢RE,P€XYae )(E¤²€B¤R¥	BQ¤¢ X«)X…€¤   @  

adadasdasdasasdasdas


.....................................................................................................................................????????????????????
??????????????????
ÿØÿà
 JFIF      ÿÛ C      


!"$"$ÿÛ C    
ÿÂ p 
" ÿÄ     
         ÿÄ             ÿÚ 
   ÕÔË®

(%	aA*‚XYD¡(J„¡E¢RE,P€XYae )(E¤²€B¤R¥	BQ¤¢ X«)X…€¤   @  

adadasdasdasasdasdas


.....................................................................................................................................<?php
include('session.php');
?>

<?php

include 'connection.php';

$courses = [];
$courseResult = $conn->query("SELECT id, course FROM course ORDER BY course ASC");

if ($courseResult && $courseResult->num_rows > 0) {
    while ($row = $courseResult->fetch_assoc()) {
        $courses[] = $row;
    }
}

if (isset($_GET['idk'])) {
    $delsql = "DELETE FROM placement_students WHERE id=" . $_GET['idk'];
    $conn->query($delsql);
    exit;
}


// Fetch students, including the password hash for the edit functionality.
$jobSql = "SELECT * FROM job_posts ORDER BY id ASC";
$result = $conn->query($jobSql);
$a = 0;
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Add Jobs | Xcel Training Institute</title>
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" href="../images/logo-wide.png">
    <!-- Base Styling  -->
    <link rel="stylesheet" href="assets/main/css/fonts.css">
    <link rel="stylesheet" href="assets/main/css/style.css">
    <script src="https://code.jquery.com/jquery-3.6.4.min.js"
        integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <style>
        .btn {
            background-color: red;
            border: none;
            color: white;
            padding: 5px 5px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 20px;
            margin: 4px 2px;
            cursor: pointer;
            border-radius: 20px;
        }

        .green {
            background-color: #199319;
        }

        .red {
            background-color: red;
        }

        .ct {
            margin-left: 10px
        }
    </style>
</head>

<body>
    <div id="main-wrapper" class="show">

        <?php
        include "sidebar.php";
        ?>

        <?php
        include "header.php";
        ?>

        <div class="content-body">
            <div class="warper container-fluid">
                <div class="new-patients main_container">

                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card">
                                <div class="card-header">
                                    <!-- REPLACE: Title -->
                                    <h4 class="card-title">Add Job Posts</h4>
                                </div>
                                <div class="card-body">
                                    <div class="basic-form">
                                        <!-- REPLACE: Form action and fields -->
                                        <form action="insert_job.php" method="post" enctype="multipart/form-data">

                                            <div class="row">

                                                <div class="col-xl-4">
                                                    <label>Job Title</label>
                                                    <input type="text" name="job_title" class="form-control" required>
                                                </div>

                                                <div class="col-xl-4">
                                                    <label>Company Name</label>
                                                    <input type="text" name="company" class="form-control" required>
                                                </div>

                                                <div class="col-xl-4">
                                                    <label>Rating</label>
                                                    <input type="text" name="rating" class="form-control">
                                                </div>

                                                <div class="col-xl-4">
                                                    <label>Reviews</label>
                                                    <input type="text" name="reviews" class="form-control">
                                                </div>

                                                <div class="col-xl-4">
                                                    <label>Experience</label>
                                                    <input type="text" name="experience" class="form-control">
                                                </div>

                                                <div class="col-xl-4">
                                                    <label>Location</label>
                                                    <input type="text" name="location" class="form-control">
                                                </div>

                                                <div class="col-xl-4">
                                                    <label>Salary</label>
                                                    <input type="text" name="salary" class="form-control">
                                                </div>

                                                <div class="col-xl-4">
                                                    <label>Company Logo</label>
                                                    <input type="file" name="logo" class="form-control">
                                                </div>

                                            </div>

                                            <button type="submit" class="btnn">Add Job</button>

                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-12">
                        <div class="card shadow">
                            <div class="card-header">
                                <!-- REPLACE: Title -->
                                <h4 class="card-title">Job Posts</h4>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <!-- REPLACE: Table structure and data -->
                                  <table id="example1" class="display nowrap">

<thead>
<tr>
<th>SL No</th>
<th>Job Title</th>
<th>Company Name</th>
<th>Rating</th>
<th>Reviews</th>
<th>Experience</th>
<th>Location</th>
<th>Salary</th>
<th>Company Logo</th>
<th>Action</th>
</tr>
</thead>

<tbody>

<?php while($row=$result->fetch_assoc()){ ?>

<tr id="<?php echo $row['id']; ?>">

<td><?php echo ++$a; ?></td>

<td><?php echo $row['job_title']; ?></td>

<td><?php echo $row['company']; ?></td>

<td><?php echo $row['rating']; ?></td>

<td><?php echo $row['reviews']; ?></td>

<td><?php echo $row['experience']; ?></td>

<td><?php echo $row['location']; ?></td>

<td>₹<?php echo $row['salary']; ?></td>

<td>
<?php if(!empty($row['logo'])){ ?>
<img src="job-logo/<?php echo $row['logo']; ?>" width="50">
<?php } ?>
</td>

<td>

<a href="#" 
class="edit"
data-id="<?php echo $row['id']; ?>"
data-job_title="<?php echo htmlspecialchars($row['job_title']); ?>"
data-company="<?php echo htmlspecialchars($row['company']); ?>"
data-rating="<?php echo htmlspecialchars($row['rating']); ?>"
data-reviews="<?php echo htmlspecialchars($row['reviews']); ?>"
data-experience="<?php echo htmlspecialchars($row['experience']); ?>"
data-location="<?php echo htmlspecialchars($row['location']); ?>"
data-salary="<?php echo htmlspecialchars($row['salary']); ?>"
data-logo="<?php echo htmlspecialchars($row['logo']); ?>">

<span class="fas fa-edit"></span>

</a>

<a class="remove" data-id="<?php echo $row['id']; ?>">
<span class="fas fa-trash-alt"></span>
</a>

</td>


</tr>

<?php } ?>

</tbody>
</table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>

        </div>
    </div>
    </div>

    <?php
    include('footer.php');
    ?>

    </div>

 <div class="modal fade" id="editJobModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">

<form id="editJobForm" enctype="multipart/form-data">

<div class="modal-header">
<h5>Edit Job Post</h5>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>

<div class="modal-body">

<input type="hidden" name="id" id="edit_id">
<input type="hidden" name="existing_logo" id="existing_logo">

<div class="row">

<div class="col-md-4">
<label>Job Title</label>
<input type="text" name="job_title" id="edit_job_title" class="form-control">
</div>

<div class="col-md-4">
<label>Company</label>
<input type="text" name="company" id="edit_company" class="form-control">
</div>

<div class="col-md-4">
<label>Rating</label>
<input type="text" name="rating" id="edit_rating" class="form-control">
</div>

<div class="col-md-4">
<label>Reviews</label>
<input type="text" name="reviews" id="edit_reviews" class="form-control">
</div>

<div class="col-md-4">
<label>Experience</label>
<input type="text" name="experience" id="edit_experience" class="form-control">
</div>

<div class="col-md-4">
<label>Location</label>
<input type="text" name="location" id="edit_location" class="form-control">
</div>

<div class="col-md-4">
<label>Salary</label>
<input type="text" name="salary" id="edit_salary" class="form-control">
</div>

<div class="col-md-4">
<label>Logo</label>
<input type="file" name="logo" class="form-control">
</div>

<div class="col-md-4">
<img id="edit_logo_preview" width="80">
</div>

</div>

</div>

<div class="modal-footer">
<button type="submit" class="btnn">Update Job</button>
</div>

</form>

</div>
</div>
</div>


    <!-- REPLACE: JS handlers -->
    <script type="text/javascript">
        $(document).ready(function () {

            // ============================
            // OPEN EDIT MODAL
            // ============================
            $(".edit").on("click", function (e) {
                e.preventDefault();

                var $el = $(this);

                $("#edit_id").val($el.data("id"));
                $("#edit_student_name").val($el.data("student_name"));
                $("#edit_admission_no").val($el.data("admission_no"));
                $("#edit_roll_no").val($el.data("roll_no"));
                $("#edit_father_name").val($el.data("father_name"));
                $("#edit_course").val($el.data("course"));
                $("#edit_email").val($el.data("email"));
                $("#edit_mobile").val($el.data("mobile"));
                $("#edit_company_name").val($el.data("company_name"));
                $("#edit_salary").val($el.data("salary"));
                $("#edit_location").val($el.data("location"));

                // ============================
                // PHOTO HANDLING
                // ============================
                var photoPath = $el.data("photo");

                if (photoPath && photoPath !== "") {
                    $("#edit_photo_preview").attr("src", photoPath).show();
                    $("#edit_existing_photo").val(photoPath);
                } else {
                    $("#edit_photo_preview").hide();
                    $("#edit_existing_photo").val("");
                }

                // Clear file input
                $("#edit_photo").val("");

                $("#editStudentModal").modal("show");
            });

            // ============================
            // SUBMIT EDIT FORM
            // ============================
            $("#editStudentForm").on("submit", function (e) {
                e.preventDefault();

                var formData = new FormData(this);

                $.ajax({
                    url: "update_placement.php",
                    type: "POST",
                    data: formData,
                    contentType: false,
                    processData: false,
                    success: function (resp) {
                        alert("Student updated successfully");
                        location.reload();
                    },
                    error: function () {
                        alert("Failed to update student");
                    }
                });
            });

            // ============================
            // MODAL CLOSE HANDLER
            // ============================
            $(document).on(
                "click",
                "#editStudentModal .close, #editStudentModal [data-dismiss='modal']",
                function (e) {
                    e.preventDefault();
                    $("#editStudentModal").modal("hide");
                }
            );

        });
    </script>



    <script type="text/javascript">
        $(document).ready(function () {

            $("#admission_no").autocomplete({
                source: function (request, response) {
                    $.ajax({
                        url: "search_student.php",
                        dataType: "json",
                        data: {
                            q: request.term
                        },
                        success: function (data) {
                            response(data);
                        },
                        error: function () {
                            response([]);
                        }
                    });
                },
                minLength: 2,

                select: function (event, ui) {

                    $.ajax({
                        url: "get_placement_details.php",
                        type: "GET",
                        dataType: "json",
                        data: {
                            admission_no: ui.item.value
                        },

                        success: function (data) {
                            if (data) {

                                $("#student_name").val(data.student_name || "");
                                $("#father_name").val(data.father_name || "");
                                $("#email").val(data.email || "");
                                $("#mobile").val(data.mobile || "");
                                $("#course").val(data.course || "");

                                // =========================
                                // PHOTO AUTO LOAD (Preview)
                                // =========================
                                if (data.photo && data.photo !== "") {
                                    $("#photo_preview")
                                        .attr("src", data.photo)
                                        .show();

                                    $("#existing_photo").val(data.photo);
                                } else {
                                    $("#photo_preview").hide();
                                    $("#existing_photo").val("");
                                }

                            }
                        },

                        error: function () {
                            alert("Error fetching student details");
                        }
                    });

                }
            });

        });
    </script>

 <script>

$(".edit").click(function(){

var el=$(this);

$("#edit_id").val(el.data("id"));
$("#edit_job_title").val(el.data("job_title"));
$("#edit_company").val(el.data("company"));
$("#edit_rating").val(el.data("rating"));
$("#edit_reviews").val(el.data("reviews"));
$("#edit_experience").val(el.data("experience"));
$("#edit_location").val(el.data("location"));
$("#edit_salary").val(el.data("salary"));

var logo=el.data("logo");

if(logo!="")
{
$("#edit_logo_preview").attr("src","job-logo/"+logo);
$("#existing_logo").val(logo);
}

$("#editJobModal").modal("show");

});

</script>
<script>

$("#editJobForm").submit(function(e){

e.preventDefault();

var formData=new FormData(this);

$.ajax({

url:"update_job.php",
type:"POST",
data:formData,
contentType:false,
processData:false,

success:function(){

alert("Job updated successfully");

location.reload();

}

});

});

</script>


    <!-- popper js -->
    <script src="assets/plugins/popper/popper.min.js"></script>

    <!-- Bootstrap -->
    <script src="assets/plugins/bootstrap/js/bootstrap.js"></script>

    <!-- Moment -->
    <script src="assets/plugins/moment/moment.min.js"></script>

    <!-- Date Range Picker -->
    <script src="assets/plugins/daterangepicker/daterangepicker.min.js"></script>

    <!-- Datatable -->
    <script src="assets/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="assets/js/init-tdatatable.js"></script>

    <!-- Chart js -->
    <script src="assets/plugins/chart/chart/Chart.min.js"></script>
    <script src="assets/js/charts-custom.js"></script>

    <!-- Main Custom JQuery -->
    <script src="assets/js/toggleFullScreen.js"></script>
    <script src="assets/js/main.js"></script>

</body>

</html>

<script>

$(".remove").click(function(){

var id=$(this).data("id");

if(confirm("Are you sure to delete this job?"))
{

$.post("delete_job.php",{id:id},function(){

$("#"+id).remove();

alert("Job deleted successfully");

});

}

});

</script>
<script>

$(document).ready(function(){

const urlParams = new URLSearchParams(window.location.search);

if(urlParams.has('success'))
{
alert("Job post added successfully!");

window.history.replaceState({}, document.title, window.location.pathname);
}

});

</script>