53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
include('log_entry.php');
|
|
|
|
// Start logging request attributes
|
|
error_log("Start Printing Request Attributes");
|
|
$requestStr = "";
|
|
|
|
foreach ($_REQUEST as $key => $value) {
|
|
$requestStr .= $key . " : " . $value . "\n";
|
|
error_log($key . " : " . $value);
|
|
}
|
|
|
|
error_log("End Printing Request Attributes");
|
|
save_log($requestStr, 'delete Leave Application', 'DELETE', 'delete_leave.php');
|
|
|
|
// Check if pid is provided in the request
|
|
if (!empty($_REQUEST['pid'])) {
|
|
$pid = mysqli_real_escape_string($conn, $_REQUEST['pid']);
|
|
|
|
// Construct the delete queries
|
|
$query1 = "DELETE FROM leave_primary WHERE pid = '$pid'";
|
|
$query2 = "DELETE FROM leave_child WHERE pid = '$pid'";
|
|
|
|
// Log the queries for debugging
|
|
error_log('Delete Query 1: ' . $query1);
|
|
error_log('Delete Query 2: ' . $query2);
|
|
|
|
// Execute the first query and handle errors
|
|
if (!@mysqli_query($conn, $query1)) {
|
|
// Log the error
|
|
error_log('Query Error: ' . mysqli_error($conn));
|
|
echo json_encode(["status" => "FAILURE", "message" => mysqli_error($conn)]);
|
|
exit;
|
|
}
|
|
|
|
// Execute the second query and handle errors
|
|
if (!@mysqli_query($conn, $query2)) {
|
|
// Log the error
|
|
error_log('Query Error: ' . mysqli_error($conn));
|
|
echo json_encode(["status" => "FAILURE", "message" => mysqli_error($conn)]);
|
|
exit;
|
|
}
|
|
|
|
// If both queries succeed, return SUCCESS response
|
|
echo json_encode(["status" => "SUCCESS"]);
|
|
} else {
|
|
// If pid is not provided, return an error response
|
|
echo json_encode(["status" => "FAILURE", "message" => "pid parameter is required."]);
|
|
}
|
|
?>
|