csrtechnew.ohctech.in/save_rrwhs.php

64 lines
2.5 KiB
PHP
Raw Permalink Normal View History

2025-04-14 13:28:09 +05:30
<?php
error_reporting(E_ERROR | E_PARSE);
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
function sanitize_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$update_id = isset($_REQUEST['rrwhs_hidden_id']) ? sanitize_input($_REQUEST['rrwhs_hidden_id']) : null;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$indent_date = sanitize_input($_POST['indent_date0']);
$indent_id = sanitize_input($_POST['indent_id0']);
$beneficiary = sanitize_input($_POST['beneficiary']);
$tank_shape = sanitize_input($_POST['tank_shape']);
$length = sanitize_input($_POST['length']);
$width = sanitize_input($_POST['width']);
$depth = sanitize_input($_POST['depth']);
$capacity = sanitize_input($_POST['capacity']);
$area = sanitize_input($_POST['area']);
$progress_status = sanitize_input($_POST['progress_status']);
$remarks = sanitize_input($_POST['remarks0']);
$tank_no = sanitize_input($_POST['tank_no']);
$date_parts = explode('/', $indent_date);
$formatted_date = $date_parts[2] . '-' . $date_parts[1] . '-' . $date_parts[0];
if ($update_id) {
$query = "UPDATE rrwhs_activity
SET rrwhs_date = '$formatted_date',beneficiary = '$beneficiary',tank_shape = '$tank_shape',length = '$length',width = '$width',depth = '$depth',capacity = '$capacity',area = '$area',progress_status = '$progress_status',tank_no= '$tank_no',remarks = '$remarks',ohc_type_id = '" . $_SESSION['current_ohcttype'] . "',role_type = '" . $_SESSION['role_type'] . "' WHERE id = '$update_id'";
error_log("Updating record: " . $query);
} else {
$query = "INSERT INTO rrwhs_activity
(rrwhs_date, beneficiary, tank_shape, length, width, depth, capacity, area, progress_status,tank_no, remarks, ohc_type_id, role_type)
VALUES
('$formatted_date', '$beneficiary', '$tank_shape', '$length', '$width', '$depth', '$capacity', '$area', '$progress_status', '$tank_no','$remarks',
'" . $_SESSION['current_ohcttype'] . "', '" . $_SESSION['role_type'] . "')";
error_log("Inserting new record: " . $query);
}
if (!$result = @mysqli_query($conn, $query)) {
error_log("Error saving indent: " . mysqli_error($conn) . ": Query Failing: " . $query);
rollback();
exit(error_log(mysqli_error($conn)));
}
}