<?php
include_once 'shikanisha.kts.php';


// Get the data from the AJAX request
$full_name = $_POST['fullname'];
$phone = $_POST['phone_number'];
$salary = $_POST['salary'];
$username = $_POST['username'];
$password = $_POST['password'];
$type = $_POST['type'];
$date = date('Y-m-d');
// Insert the data into the database
$sql = "INSERT INTO employees (name, registration_date, salary_amount, username, password, type, phone_number)
VALUES ('$full_name', '$date', '$salary', '$username', '$password', '$type', '$phone')";

if ($conn->query($sql) === TRUE) {
  echo "Employee Registered successfully";
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}



?>


<?php
include_once('shikanisha.kts.php');

if(isset($_POST['receipt_id'])) {

// Get the receipt ID from the Ajax request
$receipt_id = $_POST['receipt_id'];

// Fetch order details from the database
$sql = "SELECT * FROM employees WHERE employee_id = $receipt_id";
$result = mysqli_query($conn, $sql);

// Check if there are any results
if (mysqli_num_rows($result) > 0) {
    // Loop through the results and store them in an array
    while ($row = mysqli_fetch_assoc($result)) {
        $order_details[] = $row;
    }

    // Return the order details as JSON
    echo json_encode($order_details);
} else {
    // If there are no results, return an error message
    echo json_encode(['error' => 'No order details found']);
}}
?>



