103 lines
5.4 KiB
PHP
103 lines
5.4 KiB
PHP
|
|
<?php
|
||
|
|
error_reporting(E_ERROR | E_PARSE);
|
||
|
|
include('includes/config/config.php');
|
||
|
|
include('includes/functions.php');
|
||
|
|
include('log_entry.php');
|
||
|
|
|
||
|
|
|
||
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||
|
|
$bene_detail_id = $_REQUEST['bnid'];
|
||
|
|
error_log('jiji' . $bene_detail_id);
|
||
|
|
|
||
|
|
if ($bene_detail_id) {
|
||
|
|
// Fetch Beneficiary Details
|
||
|
|
$sql_pri = "SELECT * FROM beneficiary_drip_add_details WHERE id = $bene_detail_id";
|
||
|
|
error_log($sql_pri);
|
||
|
|
$beneDetails = mysqli_query($conn, $sql_pri);
|
||
|
|
$beneData = mysqli_fetch_assoc($beneDetails);
|
||
|
|
|
||
|
|
// Fetch Checkup Parameters and their values
|
||
|
|
$sql_child = "SELECT * FROM beneficiary_drip_form_key_value WHERE bene_detail_id = $bene_detail_id";
|
||
|
|
error_log($sql_child);
|
||
|
|
$paramValues = mysqli_query($conn, $sql_child);
|
||
|
|
$paramData = [];
|
||
|
|
while ($param = mysqli_fetch_assoc($paramValues)) {
|
||
|
|
$paramData[$param['bene_form_key']] = $param['checkup_form_value'];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$programValue = isset($_POST['program_value']) ? $_POST['program_value'] : null;
|
||
|
|
error_log("Check_progran_ids : " . $programValue);
|
||
|
|
// Convert to array and sanitize
|
||
|
|
$idsArray = array_map('intval', $programValue); // Sanitize input
|
||
|
|
$ids = implode(',', $idsArray); // Prepare a comma-separated list
|
||
|
|
|
||
|
|
$counter = 0;
|
||
|
|
$parameters_key = mysqli_query($conn, "SELECT * FROM beneficiary_key_param_master");
|
||
|
|
|
||
|
|
while ($row_key = mysqli_fetch_assoc($parameters_key)) {
|
||
|
|
|
||
|
|
error_log("Check_beneficiary_key_paramiter : ".$row_key['key_param_name']);
|
||
|
|
|
||
|
|
// Join the conditions with OR
|
||
|
|
error_log("Check_end_Query : ".$end_query);
|
||
|
|
$parameters = mysqli_query($conn, "SELECT *
|
||
|
|
FROM beneficiary_checkup_parameter
|
||
|
|
WHERE key_health_map_name='" . $row_key["key_param_id"] . "'
|
||
|
|
AND activity IN ($ids) ");
|
||
|
|
error_log("Check_progran_ids_query : " . "SELECT *
|
||
|
|
FROM beneficiary_checkup_parameter
|
||
|
|
WHERE key_health_map_name='" . $row_key["key_param_id"] . "'
|
||
|
|
AND activity IN ($ids)
|
||
|
|
LIMIT 1");
|
||
|
|
|
||
|
|
while ($row = mysqli_fetch_assoc($parameters)) {
|
||
|
|
$inputType = $row['input_type']; // Input type like text, textarea, select
|
||
|
|
$columnName = $row['column_name']; // Field name
|
||
|
|
$label = $row_key['key_param_name']; // Label name
|
||
|
|
|
||
|
|
$counter++;
|
||
|
|
if ($counter % 2 == 1) {
|
||
|
|
echo '<div class="form-group">'; // Start a new form group for every two inputs
|
||
|
|
}
|
||
|
|
|
||
|
|
echo '<label class="col-sm-2 control-label no-padding-right" for="' . htmlspecialchars($columnName) . '">' . htmlspecialchars($label) . '</label>';
|
||
|
|
echo '<div class="col-sm-4">';
|
||
|
|
|
||
|
|
if ($inputType == 'text') {
|
||
|
|
echo '<input type="text" name="' . htmlspecialchars($columnName) . '" oninput="parameter_celculuter();" id="' . htmlspecialchars($columnName) . '" class="form-control" value="' . (isset($paramData[$columnName]) ? htmlspecialchars($paramData[$columnName], ENT_QUOTES) : '') . '">';
|
||
|
|
}
|
||
|
|
if ($inputType == 'date') {
|
||
|
|
echo '<input type="date" name="' . htmlspecialchars($columnName) . '" oninput="parameter_celculuter();" id="' . htmlspecialchars($columnName) . '" class="form-control" value="' . (isset($paramData[$columnName]) ? htmlspecialchars($paramData[$columnName], ENT_QUOTES) : '') . '">';
|
||
|
|
} elseif ($inputType == 'textarea') {
|
||
|
|
echo '<textarea name="' . htmlspecialchars($columnName) . '" oninput="parameter_celculuter();" id="' . htmlspecialchars($columnName) . '" class="form-control">' . (isset($paramData[$columnName]) ? htmlspecialchars($paramData[$columnName], ENT_QUOTES) : '') . '</textarea>';
|
||
|
|
} elseif ($inputType == 'select') {
|
||
|
|
$parameterValueIds = $row['parameter_value']; // Comma-separated IDs
|
||
|
|
$idsArray = explode(',', $parameterValueIds); // Convert to array
|
||
|
|
$idsList = implode(',', array_map('intval', $idsArray)); // Sanitize and prepare list of IDs
|
||
|
|
$paramValues = mysqli_query($conn, "SELECT parameter_value_id, parameter_value_name FROM checkup_parameter_value WHERE parameter_value_id IN ($idsList)");
|
||
|
|
|
||
|
|
echo '<select class="select2 form-control " name="' . htmlspecialchars($columnName) . '" oninput="parameter_celculuter();" id="' . htmlspecialchars($columnName) . '" >';
|
||
|
|
while ($option = mysqli_fetch_assoc($paramValues)) {
|
||
|
|
echo '<option value="' . htmlspecialchars($option['parameter_value_id']) . '" ' . (isset($paramData[$columnName]) && $paramData[$columnName] == $option['parameter_value_id'] ? 'selected' : '') . '>' . htmlspecialchars($option['parameter_value_name']) . '</option>';
|
||
|
|
}
|
||
|
|
echo '</select>';
|
||
|
|
} elseif ($inputType == 'number') {
|
||
|
|
echo '<input type="number" oninput="parameter_celculuter();" name="' . htmlspecialchars($columnName) . '" id="' . htmlspecialchars($columnName) . '" class="form-control" value="' . (isset($paramData[$columnName]) ? htmlspecialchars($paramData[$columnName], ENT_QUOTES) : '') . '">';
|
||
|
|
}
|
||
|
|
|
||
|
|
echo '</div>'; // Close col-sm-4
|
||
|
|
|
||
|
|
if ($counter % 2 == 0) {
|
||
|
|
echo '</div>'; // Close form-group for every two inputs
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Close any remaining open divs
|
||
|
|
if ($counter % 2 == 1) {
|
||
|
|
echo '</div>'; // Close the last form-group if it has only one input
|
||
|
|
}
|
||
|
|
}
|