<?php include 'includes/session.php'; 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include 'includes/db.php'; // Database connection
// Session to check if user is logged in


if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $kra_name = $_POST['kra_name'];
    $measure_of_success = $_POST['measure_of_success'];
    $weightage = $_POST['weightage'];

      $stmt = $conn->prepare("INSERT INTO PMS_Template (kra_name, measure_of_success, weightage) VALUES (:kra_name, :measure_of_success, :weightage)");

        // Bind parameters
        $stmt->bindParam(':kra_name', $kra_name);
        $stmt->bindParam(':measure_of_success', $measure_of_success);
        $stmt->bindParam(':weightage', $weightage, PDO::PARAM_STR);

    if ($stmt->execute()) {
        echo json_encode(['status' => 'success', 'message' => 'KRA Template added successfully.']);
    } else {
        echo json_encode(['status' => 'error', 'message' => 'Failed to add KRA Template.']);
    }
}
?>
