Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
antiradionic
/
hirepro
/
admin
:
a_users_view.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php if (session_status() == PHP_SESSION_NONE) { session_start(); } if (isset($_SESSION['company_a_role']) && $_SESSION['company_a_role'] !== "A") { header("location:index.php"); exit(); // Add an exit to stop further execution after redirection } // Include your database connection code include "config.php"; include "menu.php"; // Define competency or heading names for each position $competencies = [ "Junior Level" => [ "Communication Skills", "Problem Solving", "Adaptability", "Loyalty and Ethics", "Short & Long Term Orientation", "Criminal Intent" ], "Mid Level" => [ "Leadership Skills", "Communication Skills", "Team Collaboration", "Loyalty and Ethics", "Short & Long Term Orientation", "Criminal Intent" ], "Senior Level" => [ "Leadership Skills", "Strategic Thinking", "Communication Skills", "Loyalty and Ethics", "Short & Long Term Orientation", "Criminal Intent" ] ]; $user_id = $_GET["id"]; $query = "SELECT * FROM a_questionnaire WHERE id = '{$user_id}'"; $result = mysqli_query($conn, $query); if (mysqli_num_rows($result)) { $row = mysqli_fetch_assoc($result); // Calculate the average rating for each heading $average_ratings = []; $bar_color = ""; // Define $bar_color outside the loop // Added an array to store the heading variables $headings = []; // Fetch the current position level $position_level = $row["position_level"]; $headingNames = $competencies[$position_level]; for ($headingIndex = 1; $headingIndex <= count($headingNames); $headingIndex++) { $heading_key = "heading{$headingIndex}"; $average_rating_heading = 0; // Debugging statements // echo "Heading Index: $headingIndex<br>"; // echo "Total Questions: {$total_questions_per_position[$position_level]}<br>"; $questionsPerIndex = ($position_level === "Junior Level") ? 5 : 3; for ($questionIndex = 1; $questionIndex <= $questionsPerIndex; $questionIndex++) { $question_key = "rating_" . (($headingIndex - 1) * $questionsPerIndex + $questionIndex); // Debugging statements // echo "Question Index: $questionIndex, Question Key: $question_key<br>"; if (isset($row[$question_key])) { $average_rating_heading += $row[$question_key]; } else { // Handle the case when the key is not set in $row // You can choose to skip the question or set a default value echo "No data for key $question_key<br>"; } } $average_ratings[$heading_key] = number_format(($average_rating_heading * 100) / ($questionsPerIndex * 6), 2); // More debugging statements // echo "Average Rating Heading: $average_rating_heading<br>"; // echo "Average Rating: {$average_ratings[$heading_key]}<br>"; // Define bar color based on heading switch ($headingIndex) { case 1: $bar_color = "bg-info"; break; case 2: $bar_color = "bg-success"; break; case 3: $bar_color = "bg-primary"; break; case 4: $bar_color = "bg-warning"; break; case 5: case 6: $bar_color = "bg-danger"; // Add more cases for additional headings break; default: $bar_color = "bg-warning"; } // Store the heading variables in an array, including the index $headings[] = [ 'index' => $headingIndex, 'name' => $headingNames[$headingIndex - 1], 'average_rating' => $average_ratings[$heading_key], 'bar_color' => $bar_color, ]; } ?> <!DOCTYPE html> <html dir="ltr" lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Tell the browser to be responsive to screen width --> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>Hirepro - Admin</title> <!-- Favicon icon --> <link rel="icon" type="image/x-icon" href="../assets//images/big/w2.png" /> <!-- Custom CSS --> <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script> <script src="../assets/extra-libs/knob/jquery.knob.min.js"></script> </head> <style> .page-breadcrumb { padding: 30px 35px 0; } .page-wrapper { position: relative; display: none; box-shadow: none; border-top-left-radius: 0px; border-top-right-radius: 0px; } .col-lg-2.col-md-3.col-sm-6.p-auto.align-self-center { text-align: right; } /* Add styles for elements after the "Scenario" field */ /* Adjust as needed */ .form-actions { text-align: right; } .form-actions button { margin-left: 10px; } .text-right { text-align: right !important; } .card, .card-group { margin-bottom: 30px; } .selecteds { background-color: gray; color: white; } </style> <body> <div id="main-wrapper" data-theme="light" data-layout="vertical" data-navbarbg="skin6" data-sidebartype="full" data-sidebar-position="fixed" data-header-position="fixed" data-boxed-layout="full"> <div class="page-wrapper" style="display: block;"> <!-- ============================================================== --> <!-- Bread crumb and right sidebar toggle --> <!-- ============================================================== --> <div class="page-breadcrumb"> <div class="row mb-4"> <div class="col-lg-10 col-md-9 col-sm-6 align-self-center"> <h4 class="page-title text-truncate text-dark font-weight-medium mb-1">Result view</h4> <div class="d-flex align-items-center"> <nav aria-label="breadcrumb"> <ol class="breadcrumb m-0 p-0"> <li class="breadcrumb-item"><a href="user.php" class="text-muted">Result Details</a></li> <li class="breadcrumb-item text-muted active" aria-current="page"><a href="user_view.php">Result view</a></li> </ol> </nav> </div> </div> <div class="col-lg-2 col-md-3 col-sm-6 p-auto align-self-center"> <div class="customize-input float-right"> <a href="a_users.php"> <button class="btn btn-primary" style="border-radius: 50px; background: linear-gradient(to right,#0052D4, #2B32B2); border: 1px solid #7f72ea"> <span class=" me-3">Result</span><i class="bx bx-arrow-back"></i></button> </a> </div> </div> </div> </div> <div class="container-fluid"> <!-- ============================================================== --> <!-- Start Page Content --> <!-- ============================================================== --> <form action="<?php echo $_SERVER["PHP_SELF"] . "?id=" . $_GET["id"]; ?>" method="POST" enctype="multipart/form-data"> <div class="row "> <div class="col-sm-12 col-md-6 col-lg-12"> <div class="card"> <div class="card-body"> <div class="form-group"> <h6><span>Name:</span> <?php echo $row["name"] ?></h6> <h6><span>Email:</span> <?php echo $row["email"] ?></h6> <h6><span>Designation:</span> <?php echo $row["designation"] ?></h6> <h6><span>Position:</span> <?php echo $row["position_level"] ?></h6> </div> </div> </div> </div> <div class="container"> <div class="row text-start align-items-stretch"> <div class="col-md-6 card p-2"> <h4 class="p-2">Competancies</h4> <?php for ($headingIndex = 1; $headingIndex <= count($headingNames); $headingIndex++) : ?> <?php // Determine the total number of questions for each position $total_questions_per_position = [ "Junior Level" => 30, "Mid Level" => 18, "Senior Level" => 18 ]; $heading_key = "heading{$headingIndex}"; $average_rating_heading = 0; // Determine the total questions for the current heading $total_questions_per_heading = ($position_level === "Junior Level") ? 5 : 3; // Calculate the total rating for each competency dynamically $total_rating_per_competency = $total_questions_per_heading * 3; // Assuming 3 as the rating per question for ($questionIndex = 1; $questionIndex <= $total_questions_per_heading; $questionIndex++) { $question_key = "rating_" . ($headingIndex - 1) * $total_questions_per_heading + $questionIndex; $average_rating_heading += $row[$question_key]; } $average_ratings[$heading_key] = number_format(($average_rating_heading * 100) / $total_rating_per_competency, 2); // echo "Average Rating Heading: $average_rating_heading<br>"; // echo "Total Rating Per Competency: $total_rating_per_competency<br>"; // Define bar color based on heading $bar_color = ""; // Reset $bar_color for each heading switch ($headingIndex) { case 1: $bar_color = "bg-info"; break; case 2: $bar_color = "bg-success"; break; case 3: $bar_color = "bg-primary"; break; case 4: $bar_color = "bg-warning"; break; case 5: case 6: $bar_color = "bg-danger"; // Add more cases for additional headings break; default: $bar_color = "bg-warning"; } ?> <div class="row mb-3 align-items-center mt-1 m-1"> <div class="col-4 text-left"> <span class="text-dark font-14 fw-bold"><?php echo $headingNames[$headingIndex - 1]; ?></span> </div> <div class="col-5"> <div class="progress" style="height: 20px;"> <div class="progress-bar <?php echo $bar_color; ?>" role="progressbar" style="width: <?php echo $average_ratings[$heading_key]; ?>%" aria-valuenow="<?php echo $average_ratings[$heading_key]; ?>" aria-valuemin="0" aria-valuemax="100"></div> </div> </div> <div class="col-3 text-right"> <span class="mb-0 font-14 text-dark font-weight-medium"><?php echo $average_ratings[$heading_key]; ?>%</span> </div> </div> <?php endfor; ?> </div> <div class="col-md-6"> <!-- Total Points --> <div style="height: 380px;" class="card p-2"> <h4 class="p-2">Overall Result</h4> <div class="card-body d-flex flex-column align-items-center justify-content-center"> <?php $total_questions_per_position = [ 'Junior Level' => 30, 'Mid Level' => 18, 'Senior Level' => 18, ]; // User ID $user_id = $_GET["id"]; // Fetch the position level from the database $queryPosition = "SELECT position_level FROM a_questionnaire WHERE id = '{$user_id}'"; $resultPosition = mysqli_query($conn, $queryPosition); if ($resultPosition && mysqli_num_rows($resultPosition) > 0) { $rowPosition = mysqli_fetch_assoc($resultPosition); $position_level = $rowPosition['position_level']; // Assuming total rating for each competency is calculated based on the total questions per competency $total_rating_per_competency = $total_questions_per_position[$position_level]; // Query to calculate the total rating for the specific user $totalRatingQuery = "SELECT SUM(" . implode(" + ", array_map(function ($index) { return "COALESCE(`rating_$index`, 0)"; }, range(1, $total_rating_per_competency))) . ") AS totalRating FROM `a_questionnaire` WHERE id = '{$user_id}'"; $resultTotalRating = mysqli_query($conn, $totalRatingQuery); if ($resultTotalRating && mysqli_num_rows($resultTotalRating) > 0) { $rowTotalRating = mysqli_fetch_assoc($resultTotalRating); $totalRating = $rowTotalRating['totalRating']; // Calculate overall rating percentage $overallRatingPercentage = ($totalRating * 100) / ($total_rating_per_competency * 3); ?> <div class="text-center pb-3"> <input data-plugin="knob" data-width="230" data-height="230" data-linecap="round" data-fgColor="red" value="<?php echo number_format($overallRatingPercentage, 2) ?>" data-skin="tron" data-angleOffset="180" data-readOnly=true data-thickness=".2" /> </div> <h2 class='text-dark mb-1 font-weight-medium'><?php echo number_format($overallRatingPercentage, 2) ?>%</h2> <?php } else { echo "<h2 class='text-dark mb-1 font-weight-medium'>0%</h2>"; } } else { echo "<h2 class='text-dark mb-1 font-weight-medium'>Position level not found</h2>"; } ?> </div> </div> <!-- Total Points --> </div> </div> </div> <!-- ADDITION --> <div class="container "> <hr class="mt-3"> </div> <div class="container"> <div class="row"> <div class="col-md-12"> <h2 class="p-2">Scores:</h2> </div> </div> </div> <?php foreach ($headings as $heading) : ?> <div class="container mb-3"> <div class="row"> <div class="col-lg-12 col-md-12"> <div class="card"> <div class="card-body"> <h4 class="card-title mb-4 text-dark fw-bolder"><?php echo $heading['name']; ?></h4> <?php $total_questions_per_heading = ($position_level === "Junior Level") ? 5 : 3; // Display questions for the current heading for ($i = 1; $i <= $total_questions_per_heading; $i++) : $question_index = ($heading['index'] - 1) * $total_questions_per_heading + $i; $question_key = "question_${question_index}_text"; $averageRating = $row["rating_${question_index}"]; ?> <div class="row mb-3 align-items-center mt-1"> <div class="col-10 text-start"> <span class="font-14 fw-bolder text-dark">Question <?php echo $i; ?>:</span> <span class="text-dark font-14"><?php echo $row[$question_key]; ?></span> </div> <div class="col-2 text-right"> <span class="mb-0 font-14 text-dark bg-dark text-white p-1 font-weight-medium"><?php echo $averageRating; ?> Marks</span> </div> </div> <?php endfor; ?> </div> </div> </div> </div> </div> <?php endforeach; ?> <!-- ADDITION --> <div class="container mb-3"> <hr class="mt-3"> </div> <!-- <div class="form-actions ml-auto"> <div class="text-right"> <button type="submit" class="btn btn-info" style="background: linear-gradient(to right,#0052D4, #2B32B2); border:none;" name="submit">Update</button> </div> </div> --> </div> </form> </div> <!-- ============================================================== --> <!-- End Page wrapper --> <!-- ============================================================== --> </div> <!-- All Jquery --> <!-- ============================================================== --> <script src="../assets/libs/jquery/dist/jquery.min.js"></script> <!-- Bootstrap tether Core JavaScript --> <script src="../assets/libs/popper.js/dist/umd/popper.min.js"></script> <script src="../assets/libs/bootstrap/dist/js/bootstrap.min.js"></script> <!-- apps --> <!-- apps --> <script src="../dist/js/app-style-switcher.js"></script> <script src="dist/js/feather.min.js"></script> <!-- slimscrollbar scrollbar JavaScript --> <script src="../assets/libs/perfect-scrollbar/dist/perfect-scrollbar.jquery.min.js"></script> <script src="../assets/extra-libs/sparkline/sparkline.js"></script> <!--Wave Effects --> <!-- themejs --> <!--Menu sidebar --> <script src="../dist/js/sidebarmenu.js"></script> <!--Custom JavaScript --> <script src="../dist/js/custom.min.js"></script> <script src="../assets/extra-libs/knob/jquery.knob.min.js"></script> <script> $(function() { $('[data-plugin="knob"]').knob(); }); </script> </body> </html> <?php } ?>