202 lines
8.4 KiB
PHP
202 lines
8.4 KiB
PHP
<?php include('techsyn_header.php'); ?>
|
|
<div class="main-container ace-save-state" id="main-container">
|
|
<script type="text/javascript">
|
|
try {
|
|
ace.settings.loadState('main-container')
|
|
} catch (e) {}
|
|
</script>
|
|
<?php include('techsyn_sidebar.php'); ?>
|
|
|
|
<?php
|
|
$bene_detail_id = $_POST['bene_detail_id'];
|
|
error_log('jiji'.$bene_detail_id);
|
|
|
|
|
|
// Check if bene_detail_id is set
|
|
if ($bene_detail_id) {
|
|
// Fetch Beneficiary Details
|
|
$sql_pri = "SELECT * FROM beneficiary_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_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'];
|
|
}
|
|
}
|
|
|
|
|
|
// Fetch Beneficiary Data
|
|
$beneficiaries = mysqli_query($conn, "SELECT id, patient_name FROM patient_master");
|
|
|
|
// Fetch Program Data
|
|
$programs = mysqli_query($conn, "SELECT csr_id, program_name FROM csr_program");
|
|
|
|
// Fetch Dynamic Fields from checkup_parameter table
|
|
$parameters = mysqli_query($conn, "SELECT * FROM checkup_parameter where activity != '' ORDER BY checkup_form_section_id");
|
|
?>
|
|
|
|
<!--breadcrumb-->
|
|
<div class="main-content">
|
|
<div class="main-content-inner">
|
|
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
|
|
<ul class="breadcrumb">
|
|
<li>
|
|
<i class="ace-icon fa fa-home home-icon"></i>
|
|
<a href="#">Home</a>
|
|
</li>
|
|
|
|
<li class="active">Beneficiary Additional Details</li>
|
|
</ul>
|
|
</div>
|
|
<!-- End of breadcrumb -->
|
|
|
|
<div class="page-content">
|
|
<div class="box box-primary" style="padding: 10px; margin: 2px 0px 50px 5px; width: 99.5%;">
|
|
|
|
|
|
<form id="beneficiaryForm" name="beneficiaryForm" enctype="multipart/form-data" action="#" method="post">
|
|
<!-- Beneficiary Select -->
|
|
<div class="form-group">
|
|
<label for="beneficiary">Beneficiary</label>
|
|
<input type="hidden" name="bene_detail_id" id="bene_detail_id" value="<?= $bene_detail_id ?>">
|
|
<select name="beneficiary" id="beneficiary" class="form-control select2">
|
|
<?php while ($row = mysqli_fetch_assoc($beneficiaries)): ?>
|
|
<option value="<?= $row['id'] ?>" <?= (isset($beneData) && $beneData['beneficiary'] == $row['id']) ? 'selected' : '' ?>>
|
|
<?= $row['patient_name'] ?>
|
|
</option>
|
|
<?php endwhile; ?>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Program Select -->
|
|
<div class="row">
|
|
<div class="col-sm-6">
|
|
|
|
<div class="form-group">
|
|
<label for="program">Program</label>
|
|
<select name="program" id="program" class="form-control select2">
|
|
<?php while ($row = mysqli_fetch_assoc($programs)): ?>
|
|
<option value="<?= $row['csr_id'] ?>" <?= (isset($beneData) && $beneData['program'] == $row['csr_id']) ? 'selected' : '' ?>>
|
|
<?= $row['program_name'] ?>
|
|
</option>
|
|
<?php endwhile; ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<div class="form-group">
|
|
<label for="program">activity</label>
|
|
<select name="activity" id="activity" class="form-control select2">
|
|
<?php echo generateOptionWithWhereClause('program_master', 'program_name', 'program_id', $activity_name, '', 'program_status', '"Active"') ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Dynamic Fields -->
|
|
<div class="row">
|
|
<?php
|
|
$counter = 0;
|
|
while ($row = mysqli_fetch_assoc($parameters)):
|
|
$inputType = $row['input_type']; // Input type like text, textarea, select
|
|
$columnName = $row['column_name']; // Field name
|
|
$placeHolder = $row['place_holder_name']; // Placeholder text
|
|
$label = $row['parameter_name']; // Label name
|
|
?>
|
|
|
|
<div class="col-sm-6">
|
|
<div class="form-group">
|
|
<label for="<?= $columnName ?>"><?= $label ?></label>
|
|
|
|
<?php if ($inputType == 'text'): ?>
|
|
<input type="text" name="<?= $columnName ?>" id="<?= $columnName ?>" class="form-control" placeholder="<?= $placeHolder ?>" value="<?= isset($paramData[$columnName]) ? htmlspecialchars($paramData[$columnName], ENT_QUOTES) : '' ?>">
|
|
|
|
<?php elseif ($inputType == 'textarea'): ?>
|
|
<textarea name="<?= $columnName ?>" id="<?= $columnName ?>" class="form-control" placeholder="<?= $placeHolder ?>"><?= isset($paramData[$columnName]) ? htmlspecialchars($paramData[$columnName], ENT_QUOTES) : '' ?></textarea>
|
|
|
|
<?php elseif ($inputType == 'select'): ?>
|
|
<?php
|
|
// Fetch comma-separated IDs from the checkup_parameter table
|
|
$parameterValueIds = $row['parameter_value']; // Comma-separated IDs
|
|
$idsArray = explode(',', $parameterValueIds); // Convert to array
|
|
|
|
// Prepare the SQL query to fetch parameter values based on the IDs
|
|
$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)");
|
|
?>
|
|
<select name="<?= $columnName ?>" id="<?= $columnName ?>" class="form-control select2">
|
|
<?php while ($option = mysqli_fetch_assoc($paramValues)): ?>
|
|
<option value="<?= $option['parameter_value_id'] ?>" <?= (isset($paramData[$columnName]) && $paramData[$columnName] == $option['parameter_value_id']) ? 'selected' : '' ?>>
|
|
<?= $option['parameter_value_name'] ?>
|
|
</option>
|
|
<?php endwhile; ?>
|
|
</select>
|
|
|
|
<?php elseif ($inputType == 'number'): ?>
|
|
<input type="number" name="<?= $columnName ?>" id="<?= $columnName ?>" class="form-control" placeholder="<?= $placeHolder ?>" value="<?= isset($paramData[$columnName]) ? htmlspecialchars($paramData[$columnName], ENT_QUOTES) : '' ?>">
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
// Close the row after two fields (col-sm-6 + col-sm-6 = 12)
|
|
$counter++;
|
|
if ($counter % 2 == 0) {
|
|
echo '</div><div class="row">';
|
|
}
|
|
?>
|
|
<?php endwhile; ?>
|
|
</div>
|
|
|
|
<div class="text-center">
|
|
<button class="btn btn-primary" type="button" id="save_button" >
|
|
<i class="ace-icon fa fa-save"></i> Save
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
|
|
|
|
<?php if (isset($_REQUEST['flex_procurement_id'])) { ?>
|
|
<?php include('upload_bill.php'); ?>
|
|
<?php include('image_popup_procurement.php'); ?>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
// function save_bene() {
|
|
// $.ajax({
|
|
// type: 'POST',
|
|
// url: 'save_bene_param.php',
|
|
// data: $("#beneficiaryForm").serialize(),
|
|
// dataType: 'json',
|
|
// success: function(response) {
|
|
// if (response.success) {
|
|
// BootstrapDialog.alert('Beneficiary Details Saved Successfully.', function() {
|
|
// // Redirect to another page
|
|
// window.location.href = 'beneficiary_add_details.php'; // Replace with your desired URL
|
|
// });
|
|
// } else {
|
|
// BootstrapDialog.alert('Error in Saving Beneficiary Details: ' + response.error);
|
|
// }
|
|
// },
|
|
// error: function(xhr, status, error) {
|
|
// BootstrapDialog.alert('Error in Saving Beneficiary Details');
|
|
// }
|
|
// });
|
|
// }
|
|
</script>
|
|
|
|
|
|
|
|
<?php include('techsyn_footer.php'); ?>
|