File "positions.php"
Full Path: /home/humancap/cl.humancap.com.my/assessment/cl-admin/positions.php
File size: 8.49 KB
MIME-type: text/x-php
Charset: utf-8
<?php
require_once "../include/config.php";
// Start a session to manage user authentication
session_start();
// Check if the user is not authenticated (no session variable)
if (!isset($_SESSION["authenticated"]) || $_SESSION["authenticated"] !== true) {
// Redirect to the login page
header("Location: index.php");
exit;
}
// Create a database connection
$conn = new mysqli($host, $username, $password, $database);
// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// GET PROJECT DATA
$sql = "SELECT name, nama, username FROM project where id = ".$_SESSION["project_id"];
$project_data = $conn->query($sql);
$row = $project_data->fetch_assoc();
$projectname = $row["name"];
$projectnama = $row["nama"];
$projectusername = $row["username"];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>Competency Assessment : Positions to Assess</title>
<meta content="" name="description">
<meta content="" name="keywords">
<!-- Favicons -->
<link href="assets/img/favicon.png" rel="icon">
<link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
<!-- Google Fonts -->
<link href="https://fonts.gstatic.com" rel="preconnect">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
<!-- Vendor CSS Files -->
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
<link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
<link href="assets/vendor/quill/quill.snow.css" rel="stylesheet">
<link href="assets/vendor/quill/quill.bubble.css" rel="stylesheet">
<link href="assets/vendor/remixicon/remixicon.css" rel="stylesheet">
<link href="assets/vendor/simple-datatables/style.css" rel="stylesheet">
<!-- Template Main CSS File -->
<link href="assets/css/style.css" rel="stylesheet">
</head>
<body>
<?php require_once "../include/header.php"; ?>
<?php require_once "../include/sidebar.php"; ?>
<main id="main" class="main">
<section class="section">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col">
<h5 class="card-title float-start">Positions List for <?php echo $projectname;?></h5>
</div>
<div class="col text-end">
<button type="button" class="btn btn-primary mt-3" onclick="window.location.href = 'add_position.php';"><i class="bi bi-plus me-1"></i> Add Position</button>
</div>
</div>
<p>The purpose of this <code>list</code> is to add, edit and delete positions. Positions are defined by associating the name of the position with its relevant competencies and behavioral indicators.</p>
<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Both</a> | <a href="?lang=en">EN</a> | <a href="?lang=bm">BM</a></p>
<!-- Table with stripped rows -->
<table class="table datatable">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Position</th>
<th scope="col">Behavioral Indicators</th>
</tr>
</thead>
<tbody>
<?php
// Start to get data from DB here
// Create a database connection
$conn = new mysqli($host, $username, $password, $database);
// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sqllist = "SELECT a.name as name, a.id FROM assessment as a inner join project as p on a.project_id = p.id where p.id = " . $_SESSION["project_id"] ;
$resultlist = $conn->query($sqllist);
// Display assessment data
for ($i = 1; $i <= $resultlist->num_rows; $i++) {
$rows = $resultlist->fetch_assoc();
?>
<tr>
<th scope="row"><?php echo $i?></th>
<td scope="row"><?php echo $rows["name"]?></td>
<td scope="row">
<?php
$sqlbi = "SELECT abi.bi_id, bi.name as bi_name, bi.nama as bi_nama, c.name as competency, c.nama as kompetensi
FROM assess_bi as abi
INNER JOIN assessment as a on a.id = abi.assessment_id
INNER JOIN behavioral_indicator as bi on bi.id = abi.bi_id
INNER JOIN competency as c on bi.competency_id = c.id
WHERE abi.assessment_id = " . $rows["id"] ;
$bilist = $conn->query($sqlbi);
if (isset($_GET['lang'])) {
$lang = $_GET['lang'];
} else {
$lang = 'both';
}
echo "<table style='font-size: 8px; border-collapse: collapse;'>";
if ($lang != 'both') {
if ($lang == 'en') {
echo "<tr><th>Competency</th><th>ENG</th></tr>";
} else {
echo "<tr><th>Kompetensi</th><th>BM</th></tr>";
}
} else {
echo "<tr><th>Competency</th><th>ENG</th><th>Kompetensi</th><th>BM</th></tr>";
}
for ($b = 1; $b <= $bilist->num_rows; $b++) {
$birows = $bilist->fetch_assoc();
echo "<tr>";
if ($lang != 'both') {
if ($lang == 'en') {
echo "<td>". $birows["competency"] ." </td> ";
echo "<td>". $birows["bi_name"] ." </td> ";
} else {
echo "<td>". $birows["kompetensi"] ." </td> ";
echo "<td>". $birows["bi_nama"] ." </td> ";
}
}
else {
echo "<td>". $birows["competency"] ." </td> ";
echo "<td>". $birows["bi_name"] ." </td> ";
echo "<td>". $birows["kompetensi"] ." </td> ";
echo "<td>". $birows["bi_nama"] ." </td> ";
}
echo "</tr>";
}
echo "</table>";
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<!-- End Table with stripped rows -->
</div>
</div>
</div>
</div>
</section>
</main><!-- End #main -->
<!-- ======= Footer ======= -->
<footer id="footer" class="footer">
</footer><!-- End Footer -->
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
<!-- Vendor JS Files -->
<script src="assets/vendor/apexcharts/apexcharts.min.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/chart.js/chart.umd.js"></script>
<script src="assets/vendor/echarts/echarts.min.js"></script>
<script src="assets/vendor/quill/quill.min.js"></script>
<script src="assets/vendor/simple-datatables/simple-datatables.js"></script>
<script src="assets/vendor/tinymce/tinymce.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
<script type="text/javascript">
function confirmDelete(hash) {
if (confirm("Are you sure you want to delete this item?")) {
window.location.href = "<?php echo $_SERVER['PHP_SELF']; ?>?h=" + hash + "&act=del";
}
}
</script>
</body>
</html>