delete_employee.php000064400000010206150211465200010411 0ustar00 false, 'message' => '']; try { if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Get the raw POST data $data = json_decode(file_get_contents('php://input'), true); if (isset($data['empid'])) { $empId = $data['empid']; // Include the Database class include('../config/database.php'); // Create a new instance of the Database class and get the connection $database = new Database(); $db = $database->getConnection(); // Start a transaction $db->beginTransaction(); // Get the file details from the database first $fileQuery = "SELECT doc_adhar, doc_polveri, doc_other, emppic FROM acts_emp WHERE empid = :empid"; $fileStmt = $db->prepare($fileQuery); $fileStmt->bindParam(':empid', $empId); $fileStmt->execute(); $fileResult = $fileStmt->fetch(PDO::FETCH_ASSOC); // Delete doc_adhar file if it exists if ($fileResult && isset($fileResult['doc_adhar']) && $fileResult['doc_adhar'] !== '') { $filePath = '../uploads/adhar/' . $fileResult['doc_adhar']; if (file_exists($filePath)) { unlink($filePath); // Delete the file } } // Delete doc_polveri file if it exists if (isset($fileResult['doc_polveri']) && $fileResult['doc_polveri'] !== '') { $filePath = '../uploads/police_verification/' . $fileResult['doc_polveri']; if (file_exists($filePath)) { unlink($filePath); // Delete the file } } // Delete doc_other file if it exists if (isset($fileResult['doc_other']) && $fileResult['doc_other'] !== '') { $filePath = '../uploads/other_documents/' . $fileResult['doc_other']; if (file_exists($filePath)) { unlink($filePath); // Delete the file } } // Delete emppic (employee image) file if it exists if (isset($fileResult['emppic']) && $fileResult['emppic'] !== '') { $filePath = '../uploads/images/' . $fileResult['emppic']; if (file_exists($filePath)) { unlink($filePath); // Delete the file } } // After deleting the files, delete the bank details $bankQuery = "DELETE FROM acts_emp_bank WHERE empid = :empid"; $bankStmt = $db->prepare($bankQuery); $bankStmt->bindParam(':empid', $empId); if ($bankStmt->execute()) { // Now, delete the employee record $query = "DELETE FROM acts_emp WHERE empid = :empid"; $stmt = $db->prepare($query); $stmt->bindParam(':empid', $empId); if ($stmt->execute()) { // Commit the transaction if everything is successful $db->commit(); $response['success'] = true; $response['message'] = 'Record and associated data successfully deleted.'; } else { // If failed to delete the employee record, rollback $db->rollBack(); $response['message'] = 'Failed to delete the employee record.'; } } else { // If failed to delete bank details, rollback $db->rollBack(); $response['message'] = 'Failed to delete the bank details.'; } } else { $response['message'] = 'Invalid request.'; } } else { $response['message'] = 'Invalid request method.'; } } catch (Exception $e) { // In case of any error, rollback transaction and catch the exception $db->rollBack(); $response['message'] = 'Error: ' . $e->getMessage(); } // Return JSON response echo json_encode($response); ?> fileUpload/adharUpload.php000064400000003604150211465200011564 0ustar00 false, 'message' => '']; if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle Aadhar file upload if (isset($_FILES['fileToUpload']) && isset($_POST['aadhaarNumber'])) { $aadhaarNumber = preg_replace('/\s+/', '', $_POST['aadhaarNumber']); // Sanitize Aadhaar number $file = $_FILES['fileToUpload']; $fileName = basename($file["name"]); $targetDir = "../../uploads/adhar/"; // Generate the file name using Aadhaar number $currentTimestamp = date("Ymd"); // Current date and time (e.g., 20250212_121530) $fileExtension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); $uniqueFileName = "A_" . $currentTimestamp."_".$aadhaarNumber . "." . $fileExtension; $targetFile = $targetDir . $uniqueFileName; // Check if there was an error with the file upload if ($file['error'] !== UPLOAD_ERR_OK) { $response['message'] = 'File upload error: ' . $file['error']; echo json_encode($response); exit; } // Validate file type if (!in_array($fileExtension, ['pdf', 'jpg', 'jpeg', 'png'])) { $response['message'] = "Sorry, only PDF, JPG, JPEG, and PNG files are allowed."; echo json_encode($response); exit; } // Try to upload the file if (move_uploaded_file($file["tmp_name"], $targetFile)) { $response['success'] = true; $response['message'] = "The Aadhar file has been uploaded."; $response['fileName'] = $uniqueFileName; // Optionally, return the file name } else { $response['message'] = "Sorry, there was an error uploading your Aadhar file."; } } echo json_encode($response); // Return the response to the JavaScript } ?> fileUpload/policeUpload.php000064400000004055150211465200011761 0ustar00 false, 'message' => '']; if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle Police Verification file upload if (isset($_FILES['fileToUploadPolice']) && isset($_POST['aadhaarNumber'])) { $aadhaarNumber = preg_replace('/\s+/', '', $_POST['aadhaarNumber']); // Sanitize Aadhaar number $file = $_FILES['fileToUploadPolice']; $originalFileName = basename($file["name"]); $targetDir = "../../uploads/police_verification/"; // Generate the file name using Aadhaar number $currentTimestamp = date("Ymd"); $fileExtension = strtolower(pathinfo($originalFileName, PATHINFO_EXTENSION)); $uniqueFileName = "P_" . $currentTimestamp . "_" . $aadhaarNumber . "." . $fileExtension; $targetFile = $targetDir . $uniqueFileName; // Check if there was an error with the file upload if ($file['error'] !== UPLOAD_ERR_OK) { $response['message'] = 'File upload error: ' . $file['error']; echo json_encode($response); exit; } // Validate file type if (!in_array($fileExtension, ['pdf', 'jpg', 'jpeg', 'png'])) { $response['message'] = "Sorry, only PDF, JPG, JPEG, and PNG files are allowed."; echo json_encode($response); exit; } // Try to upload the file if (move_uploaded_file($file["tmp_name"], $targetFile)) { $response['success'] = true; $response['message'] = "The Police Verification file has been uploaded successfully."; $response['fileName'] = $uniqueFileName; // Optionally, return the file name } else { $response['message'] = "Sorry, there was an error uploading your Police Verification file."; } } else { $response['message'] = "Aadhaar number or file is missing."; } echo json_encode($response); // Return the response to the JavaScript } ?>fileUpload/otherUpload.php000064400000003751150211465200011631 0ustar00 false, 'message' => '']; if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle Aadhar file upload if (isset($_FILES['fileToUploadOther']) && isset($_POST['aadhaarNumber'])) { $aadhaarNumber = preg_replace('/\s+/', '', $_POST['aadhaarNumber']); // Sanitize Aadhaar number $file = $_FILES['fileToUploadOther']; $originalFileName = basename($file["name"]); $targetDir = "../../uploads/other_documents/"; // Generate the file name using Aadhaar number $currentTimestamp = date("Ymd"); $fileExtension = strtolower(pathinfo($originalFileName, PATHINFO_EXTENSION)); $uniqueFileName = "O_". $currentTimestamp . "_" . $aadhaarNumber . "." . $fileExtension; $targetFile = $targetDir . $uniqueFileName; // Check if there was an error with the file upload if ($file['error'] !== UPLOAD_ERR_OK) { $response['message'] = 'File upload error: ' . $file['error']; echo json_encode($response); exit; } // Validate file type if (!in_array($fileExtension, ['pdf', 'jpg', 'jpeg', 'png'])) { $response['message'] = "Sorry, only PDF, JPG, JPEG, and PNG files are allowed."; echo json_encode($response); exit; } // Try to upload the file if (move_uploaded_file($file["tmp_name"], $targetFile)) { $response['success'] = true; $response['message'] = "The Other file has been uploaded successfully."; $response['fileName'] = $uniqueFileName; // Optionally, return the file name } else { $response['message'] = "Sorry, there was an error uploading your Other file."; } } else { $response['message'] = "Aadhaar number or file is missing."; } echo json_encode($response); // Return the response to the JavaScript } ?>fileDelete/polveriDelete.php000064400000002446150211465200012124 0ustar00 false, 'message' => '']; $data = json_decode(file_get_contents('php://input'), true); // Get JSON payload if (isset($data['fileName'])) { $fileName = basename($data['fileName']); // Sanitize file name $filePath = "../../uploads/police_verification/" . $fileName; // Initialize database connection $database = new Database(); $db = $database->getConnection(); if ($db === null) { $response['message'] = "Database connection failed."; echo json_encode($response); exit; } if (file_exists($filePath)) { if (unlink($filePath)) { // Clear `doc_polveri` column for matching file name $query = "UPDATE acts_emp SET doc_polveri = NULL WHERE doc_polveri = :fileName"; $stmt = $db->prepare($query); $stmt->bindParam(':fileName', $fileName); $stmt->execute(); $response['success'] = true; $response['message'] = 'Police Verification File deleted successfully.'; } else { $response['message'] = 'Failed to delete the file.'; } } else { $response['message'] = 'File not found.'; } } else { $response['message'] = 'No file name provided.'; } echo json_encode($response); ?>fileDelete/adharDelete.php000064400000002660150211465200011521 0ustar00 false, 'message' => '']; $data = json_decode(file_get_contents('php://input'), true); // Get JSON payload if (isset($data['fileName'])) { $fileName = basename($data['fileName']); $filePath = "../../uploads/adhar/" .$fileName; // Assuming the file is uploaded to this directory // Initialize database connection $database = new Database(); $db = $database->getConnection(); if ($db === null) { $response['message'] = "Database connection failed."; echo json_encode($response); exit; } // Check if file exists before attempting to delete if (file_exists($filePath)) { if (unlink($filePath)) { // Clear `doc_adhar` column for matching file name $query = "UPDATE acts_emp SET doc_adhar = NULL WHERE doc_adhar = :fileName"; $stmt = $db->prepare($query); $stmt->bindParam(':fileName', $fileName); $stmt->execute(); $response['success'] = true; $response['message'] = 'Adhar File deleted successfully'; } else { $response['message'] = 'Error deleting file'; } } else { $response['message'] = 'File not found'; } } else { $response['message'] = 'No file name provided'; } echo json_encode($response); ?> fileDelete/otherDelete.php000064400000002260150211465200011557 0ustar00 false, 'message' => '']; $data = json_decode(file_get_contents('php://input'), true); // Get JSON payload if (isset($data['fileName'])) { $fileName = basename($data['fileName']); $filePath = "../../uploads/other_documents/" . $fileName; // Initialize database connection $database = new Database(); $db = $database->getConnection(); if ($db === null) { $response['message'] = "Database connection failed."; echo json_encode($response); exit; } if (file_exists($filePath)) { if (unlink($filePath)) { // Clear `doc_adhar` column for matching file name $query = "UPDATE acts_emp SET doc_other = NULL WHERE doc_other = :fileName"; $stmt = $db->prepare($query); $stmt->bindParam(':fileName', $fileName); $stmt->execute(); $response['success'] = true; $response['message'] = 'Other Documnet File deleted successfully'; } else { $response['message'] = 'Error deleting file'; } } else { $response['message'] = 'File not found'; } } else { $response['message'] = 'No file name provided'; } echo json_encode($response); ?>