74 lines
3.6 KiB
PHP
74 lines
3.6 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
include('log_entry.php');
|
|
|
|
error_log("Start Printing Request Attributes");
|
|
|
|
// Build request string for logging
|
|
$requestStr = "";
|
|
foreach ($_REQUEST as $key => $value) {
|
|
$requestStr .= $key . " : " . $value . "\n";
|
|
error_log($key . " : " . $value . "<br />\r\n");
|
|
}
|
|
|
|
// Optional logging of request attributes
|
|
// save_log($requestStr, 'Placement Feedback Management', 'SAVE', 'placement_feedback_save.php');
|
|
|
|
// Retrieve and sanitize POST data
|
|
$feedback_id = isset($_POST['feedback_id']) ? mysqli_real_escape_string($conn, $_POST['feedback_id']) : '';
|
|
$batch_name = isset($_POST['batch_name']) ? mysqli_real_escape_string($conn, $_POST['batch_name']) : '';
|
|
$follow_up_routine = isset($_POST['follow_up_routine']) ? mysqli_real_escape_string($conn, $_POST['follow_up_routine']) : '';
|
|
$placement_name = isset($_POST['placement_name']) ? mysqli_real_escape_string($conn, $_POST['placement_name']) : '';
|
|
$location = isset($_POST['location']) ? mysqli_real_escape_string($conn, $_POST['location']) : '';
|
|
$staff_id = isset($_POST['staff_id']) ? mysqli_real_escape_string($conn, $_POST['staff_id']) : '';
|
|
$beneficiary = isset($_POST['beneficiary']) ? mysqli_real_escape_string($conn, $_POST['beneficiary']) : '';
|
|
$salary = isset($_POST['salary']) ? mysqli_real_escape_string($conn, $_POST['salary']) : '';
|
|
$new_salary = isset($_POST['new_salary']) ? mysqli_real_escape_string($conn, $_POST['new_salary']) : '';
|
|
if($new_salary > 0){
|
|
$salary = $new_salary;
|
|
}
|
|
$promotion = isset($_POST['promotion']) ? mysqli_real_escape_string($conn, $_POST['promotion']) : '';
|
|
$remark = isset($_POST['post']) ? mysqli_real_escape_string($conn, $_POST['post']) : '';
|
|
$remark = isset($_POST['remark']) ? mysqli_real_escape_string($conn, $_POST['remark']) : '';
|
|
$modified_by = isset($_SESSION['user_id']) ? mysqli_real_escape_string($conn, $_SESSION['user_id']) : '';
|
|
$ohc_type_id = $_SESSION['current_ohcttype'];
|
|
|
|
error_log("FEEDBACK ID **------------" . $feedback_id);
|
|
error_log("check_batch_name : ".$batch_name);
|
|
|
|
// Construct SQL query
|
|
if (!empty($feedback_id)) {
|
|
// Update existing record
|
|
$query = "UPDATE placement_feedback
|
|
SET batch_id = '$batch_name',
|
|
follow_up_routine = '$follow_up_routine',
|
|
placement_id = '$placement_name',
|
|
location = '$location',
|
|
coardinator = '$staff_id',
|
|
beneficiary = '$beneficiary',
|
|
salary = '$salary',
|
|
performance = '$performance',
|
|
promotion = '$promotion',
|
|
post = '$post',
|
|
remark = '$remark',
|
|
ohc_type_id='$ohc_type_id',
|
|
modified_by = '$modified_by',
|
|
last_modified_by = CURRENT_TIMESTAMP
|
|
WHERE feedback_id = '$feedback_id'";
|
|
} else {
|
|
// Insert new record
|
|
$query = "INSERT INTO placement_feedback (batch_id, follow_up_routine, placement_id,location,coardinator, beneficiary, salary,promotion,post, remark,ohc_type_id, modified_by, last_modified_by)
|
|
VALUES ('$batch_name', '$follow_up_routine', '$placement_name','$location','$staff_id','$beneficiary', '$salary', '$promotion','$post', '$remark','$ohc_type_id' ,'$modified_by', CURRENT_TIMESTAMP)";
|
|
}
|
|
error_log("Check_followup_query : ".$query);
|
|
|
|
// Execute query and handle errors
|
|
if (!$result = mysqli_query($conn, $query)) {
|
|
error_log("Query Error: " . mysqli_error($conn));
|
|
exit("Error executing query: " . mysqli_error($conn));
|
|
}
|
|
|
|
error_log("Query executed successfully.");
|
|
?>
|