tech4biz/admin/job-listing.php
2024-10-25 17:11:31 +05:30

340 lines
20 KiB
PHP

<?PHP
require_once "./db/config.php";
require_once "./includes/functions.php";
if (!isset($_SESSION["loggedAdmin"]) || empty($_SESSION["loggedAdmin"])) {
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
header("location: login.php?redirect_to=$actual_link");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tech4Biz - Category Manage</title>
<?PHP include "./includes/links.php"; ?>
<link href="https://fonts.googleapis.com/css?family=Rubik:400,400i,500,500i,700,700i&amp;display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i,900&amp;display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./assets/css/font-awesome.css">
<!-- ico-font-->
<link rel="stylesheet" type="text/css" href="./assets/css/vendors/icofont.css">
<!-- Themify icon-->
<link rel="stylesheet" type="text/css" href="./assets/css/vendors/themify.css">
<!-- Flag icon-->
<link rel="stylesheet" type="text/css" href="./assets/css/vendors/flag-icon.css">
<!-- Feather icon-->
<link rel="stylesheet" type="text/css" href="./assets/css/vendors/feather-icon.css">
<!-- Plugins css start-->
<link rel="stylesheet" type="text/css" href="./assets/css/vendors/scrollbar.css">
<link rel="stylesheet" type="text/css" href="./assets/css/vendors/datatables.css">
<!-- Plugins css Ends-->
<!-- Bootstrap css-->
<link rel="stylesheet" type="text/css" href="./assets/css/vendors/bootstrap.css">
<!-- App css-->
<link rel="stylesheet" type="text/css" href="./assets/css/style.css">
<link id="color" rel="stylesheet" href="./assets/css/color-1.css" media="screen">
<!-- Responsive css-->
<link rel="stylesheet" type="text/css" href="./assets/css/responsive.css">
<style>
.flex-justify-column {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
</style>
<script src="./assets/js/ckeditor.js"></script>
</head>
<body>
<!-- loader starts-->
<?PHP include "./includes/loader.php"; ?>
<!-- loader ends-->
<!-- tap on top starts-->
<div class="tap-top"><i data-feather="chevrons-up"></i></div>
<!-- tap on tap ends-->
<!-- page-wrapper Start-->
<div class="page-wrapper compact-wrapper" id="pageWrapper">
<!-- Page Header Start-->
<?PHP include "./includes/header.php"; ?>
<!-- Page Header Ends -->
<!-- Page Body Start-->
<div class="page-body-wrapper">
<!-- Page Sidebar Start-->
<?PHP include "./includes/sidebar.php"; ?>
<!-- Page Sidebar Ends-->
<div class="page-body">
<!-- <div class="container-fluid">
<div class="page-title">
<div class="row">
<div class="col-6">
<h3>Job List</h3>
</div>
<div class="col-6">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index-2.html" data-bs-original-title="" title="">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home">
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
<polyline points="9 22 9 12 15 12 15 22"></polyline>
</svg>
</a></li>
<li class="breadcrumb-item">Job List</li>
<li class="breadcrumb-item active">Job List</li>
</ol>
</div>
</div>
</div>
</div> -->
<!-- Container-fluid starts-->
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<div class="card mt-3">
<div class="job-title-admin">
<h3 >Job List</h3>
<!-- <button>Add Job</button> -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal" >Add Job</button>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="display" id="advance-1">
<thead>
<tr>
<th>Job Title</th>
<th>Employment Type</th>
<th>Industry</th>
<th>Employee Status</th>
<th>Shift</th>
<th>Job Posted Date</th>
<th>Job Location</th>
<!-- <th>Job Description</th> -->
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$careersData = $connection->query("SELECT * FROM `job_list_add` ");
foreach ($careersData as $val) {
?>
<tr>
<td><?php echo $val['job_title']; ?></td>
<td><?php echo $val['employment_type']; ?></td>
<td><?php echo $val['industry']; ?></td>
<td><?php echo $val['employee_status']; ?></td>
<td><?php echo $val['shift']; ?></td>
<td>
<?php
$timestamp = strtotime($val['job_posted_date']);
echo date('d-n-Y', $timestamp);
?>
</td>
<td class="text-center">
<?php echo $val['job_location']; ?>
</td>
<td>
<div class="job-list-action">
<span class="job-list-action-icon" >
<svg onclick='editModel(<?php echo json_encode($val);?>)' xmlns="http://www.w3.org/2000/svg" width="41.4" height="41.45" viewBox="0 0 41.4 41.45">
<path id="edit_square_FILL0_wght400_GRAD0_opsz48" d="M9,47.4a2.878,2.878,0,0,1-2.1-.9A2.878,2.878,0,0,1,6,44.4v-30a2.878,2.878,0,0,1,.9-2.1A2.878,2.878,0,0,1,9,11.4H29.25l-3,3H9v30H39V27l3-3V44.4a3.076,3.076,0,0,1-3,3ZM24,29.4Zm9.1-17.6,2.15,2.1L21,28.1v4.3h4.25l14.3-14.3,2.1,2.1L26.5,35.4H18V26.9Zm8.55,8.4L33.1,11.8l5-5a2.883,2.883,0,0,1,2.125-.85,2.8,2.8,0,0,1,2.125.9l4.2,4.25a2.992,2.992,0,0,1,.85,2.125,2.746,2.746,0,0,1-.9,2.075Z" transform="translate(-6 -5.95)"/>
</svg>
</span>
<span class="job-list-action-icon">
<svg onclick='deleteModel(<?php echo json_encode($val['ref_id']);?>)' xmlns="http://www.w3.org/2000/svg" width="32" height="36" viewBox="0 0 32 36">
<path id="Path_1" data-name="Path 1" d="M13.05,42a2.988,2.988,0,0,1-3-3V10.5H8v-3h9.4V6H30.6V7.5H40v3H37.95V39a3.076,3.076,0,0,1-3,3Zm21.9-31.5H13.05V39h21.9ZM18.35,34.7h3V14.75h-3Zm8.3,0h3V14.75h-3ZM13.05,10.5v0Z" transform="translate(-8 -6)"/>
</svg>
</span>
</div>
</td>
</tr>
<?php }?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Container-fluid Ends-->
</div>
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-width">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add Job</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="addJobListForm" name="addJobListForm" method="post" autocomplete="off">
<div class="mb-3 form-group">
<label for="job_title" class="col-form-label">Job Title <span>*</span></label>
<input type="text" class="form-control" name="job_title" id="job_title" />
<input type="hidden" class="form-control" name="ref_id" id="ref_id" />
<div class="help-block with-errors"></div>
</div>
<div class="mb-3 d-flex justify-content-between">
<div class="w-48 form-group">
<label for="employment_type" class="col-form-label">Employment Type <span>*</span></label>
<input type="text" class="form-control" name="employment_type" id="employment_type" />
<div class="help-block with-errors"></div>
</div>
<div class="w-48 form-group">
<label for="industry" class="col-form-label">Industry <span>*</span></label>
<input type="text" class="form-control" name="industry" id="industry" />
<div class="help-block with-errors"></div>
</div>
</div>
<div class="mb-3 d-flex justify-content-between">
<div class="w-48 form-group">
<label for="job_location" class="col-form-label">Job Location <span>*</span></label>
<input type="text" class="form-control" name="job_location" id="job_location" />
<div class="help-block with-errors"></div>
</div>
<div class="w-48 form-group">
<label for="employee_status" class="col-form-label">Employee Status <span>*</span></label>
<input type="text" class="form-control" name="employee_status" id="employee_status" />
<div class="help-block with-errors"></div>
</div>
</div>
<div class="mb-3 d-flex justify-content-between">
<div class="w-48 form-group">
<label for="shift" class="col-form-label">Shift <span>*</span></label>
<input type="text" class="form-control" name="shift" id="shift" />
<div class="help-block with-errors"></div>
</div>
<div class="w-48 form-group">
<label for="job_posted_date" class="col-form-label">Job Posted Date <span>*</span></label>
<input type="date" class="form-control" name="job_posted_date" id="job_posted_date" />
<div class="help-block with-errors"></div>
</div>
</div>
<div class="mb-3 form-group">
<label for="job_description" class="col-form-label">Job Description <span>*</span></label>
<!-- <textarea class="form-control" name="job_description" id="job_description" rows="8"></textarea> -->
<textarea class="form-control" id="editor" name="job_description" rows="8">
<!-- <p>This is some sample content.</p> -->
</textarea>
<div class="help-block with-errors"></div>
</div>
<div class="modal-footer form-group">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button class="btn btn-primary" type="submit" name="sendJobListForm" id="sendJobListForm">Submit</button>
</div>
<div id="msgSubmit" class="h3 text-center hidden"></div>
</form>
</div>
</div>
</div>
</div>
<!-- footer start-->
<?PHP include './includes/footer.php'; ?>
<!-- footer end-->
</div>
</div>
<?PHP include './includes/scripts.php'; ?>
<!-- latest jquery-->
<script src="./assets/js/jquery-3.5.1.min.js"></script>
<!-- Bootstrap js-->
<script src="./assets/js/bootstrap/bootstrap.bundle.min.js"></script>
<!-- feather icon js-->
<script src="./assets/js/icons/feather-icon/feather.min.js"></script>
<script src="./assets/js/icons/feather-icon/feather-icon.js"></script>
<!-- scrollbar js-->
<script src="./assets/js/scrollbar/simplebar.js"></script>
<script src="./assets/js/scrollbar/custom.js"></script>
<!-- Sidebar jquery-->
<script src="./assets/js/config.js"></script>
<!-- Plugins JS start-->
<script src="./assets/js/sidebar-menu.js"></script>
<script src="./assets/js/datatable/datatables/jquery.dataTables.min.js"></script>
<script src="./assets/js/datatable/datatables/datatable.custom.js"></script>
<!-- Plugins JS Ends-->
<!-- Theme js-->
<script src="./assets/js/script.js"></script>
<!-- <script src="./assets/js/theme-customizer/customizer.js"></script> -->
<!-- login js-->
<!-- Plugin used-->
<script>
var editor1;
ClassicEditor
.create( document.querySelector( '#editor' ) ).then(editor => {
editor1 = editor;
})
.catch( error => {
console.error( error );
} );
function editModel(params) {
$("#job_title").val(params.job_title);
$("#ref_id").val(params.ref_id);
$("#employment_type").val(params.employment_type);
$("#industry").val(params.industry);
$("#job_location").val(params.job_location);
$("#employee_status").val(params.employee_status);
$("#shift").val(params.shift);
$("#job_posted_date").val(params.job_posted_date.split(" ")[0]);
// $("#editor").html(params.job_description);
$("#exampleModal").modal('show');
editor1.setData(params.job_description);
var modalTitle = exampleModal.querySelector('.modal-title')
var modalBodyInput = exampleModal.querySelector('.modal-body input')
modalTitle.textContent = 'Edit Job Post ' // + recipient
}
function deleteModel(ref_id){
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
type: "POST",
url: "./api/job-listing-add-data.php",
data: "api_type=delete&ref_id=" + ref_id,
success: function (text) {
let data = JSON.parse(text)
if (data.status == 200) {
Swal.fire(
'Deleted!',
'Your job has been deleted.',
'success'
)
setTimeout(() => {
window.location.reload();
}, 1000);
} else {
formError();
submitMSG(false, text);
}
}
});
}
})
}
var exampleModal = document.getElementById('exampleModal')
exampleModal.addEventListener('show.bs.modal', function (event) {
// Button that triggered the modal
var button = event.relatedTarget
// Extract info from data-bs-* attributes
var recipient = button.getAttribute('data-bs-whatever')
// If necessary, you could initiate an AJAX request here
// and then do the updating in a callback.
//
// Update the modal's content.
var modalTitle = exampleModal.querySelector('.modal-title')
var modalBodyInput = exampleModal.querySelector('.modal-body input')
modalTitle.textContent = 'Add Job Post ' // + recipient
modalBodyInput.value = recipient
})
</script>
</body>
</html>