csrtechnew.ohctech.in/add_fee_collection.php

237 lines
11 KiB
PHP
Raw Permalink Normal View History

2025-04-14 13:28:09 +05:30
<script>
function validate() {
// Validate required fields
var batchName = $('#batch_name').val();
var feeScheduleId = $('#fee_schedule_id').val();
var beneficiaryId = $('#beneficiary_id').val();
var feeAmount = $('#fee_amount').val();
var collectionDate = $('#collection_date').val();
var paymentMode = $('#payment_mode').val();
// if (!feeScheduleId) {
// BootstrapDialog.alert('Please select Fee Schedule.');
// return false;
// }
if (!beneficiaryId) {
BootstrapDialog.alert('Please select Beneficiary Name.');
return false;
}
if (!feeAmount || isNaN(feeAmount) || parseFloat(feeAmount) <= 0) {
BootstrapDialog.alert('Please enter a valid Fee Amount.');
return false;
}
if (!collectionDate) {
BootstrapDialog.alert('Please select Collection Date.');
return false;
}
if (!paymentMode) {
BootstrapDialog.alert('Please select Payment Mode.');
return false;
}
// If all validations pass, call the save_section function
save_section();
}
</script>
<style>
#model-checkup-parameter {
overflow-y: auto;
}
</style>
<div class="modal fade" id="model-checkup-parameter" role="dialog" aria-hidden="true">
<form role="form" id="fee_form" name="fee_form" action="#" method="post">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add Fee Collection Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php
$ohc_type_id = $_SESSION['current_ohcttype'];
?>
<div class="modal-body">
<div class="row">
<!-- Batch Name -->
<div class="col-sm-6">
<div class="form-group">
<input type="hidden" name="fee_collection_id" id="fee_collection_id">
<input type="hidden" name="DFS_id" id="DFS_id" value="<?php echo "DFS" . $ohc_type_id ?>">
<label for="batch_name">Batch Name</label>
<select class="form-control select2" name="batch_name" id="batch_name" required onchange="fetch_beneficiary();">
<option value="" disabled selected>Please Select Batch Name</option>
<option value="<?php echo "DFS" . $ohc_type_id ?>">Not Enrolled Any Batch</option>
<!-- <?php
$voa = "VOA";
$option_query = "SELECT batch_id FROM training_batch_enrollment WHERE status = '" . $voa . "' AND ohc_type_id = '" . $ohc_type_id . "'";
$option_arry = mysqli_query($conn, $option_query);
// $result = @mysqli_fetch_array($option_arry);
while ($op = @mysqli_fetch_array($option_arry)) {
?>
<?php echo generateOptionWithWhereClause('training_batch_master', 'batch_name', 'batch_id', $row['batch_name'], '', 'batch_id', $op['batch_id']); ?>
<?php
}
?> -->
<?php echo generateOptionWithWhereClause('training_batch_master', 'batch_name', 'batch_id', $row['batch_name'], '', 'ohc_type_id', $ohc_type_id); ?>
</select>
</div>
</div>
<!-- Fee Schedule -->
<div class="col-sm-6">
<div class="form-group">
<label for="fee_schedule_id">Fee Schedule</label>
<select id="fee_schedule_id" name="fee_schedule_id" class="form-control select2 test" required onchange="getFeeScheduleInfo(this.value)">
<option value="" disabled selected>Please Select Feee Schedule</option>
</select>
</div>
</div>
<!-- Beneficiary Name -->
<div class="col-sm-6">
<div class="form-group">
<label for="beneficiary_id">Beneficiary Name<span style="color:red">*</span></label>
<select id="beneficiary_id" name="beneficiary_id" class="form-control select2" required>
<option value="" disabled selected>Please Select Beneficiary Name</option>
<?php
$query = "SELECT * FROM beneficiary_enquiry WHERE ohc_type_id = '$ohc_type_id'";
$result = mysqli_query($conn, $query);
if ($result) {
while ($row = mysqli_fetch_assoc($result)) {
$dob = getFieldFromTable('dob', 'patient_master', 'id', $row['patient_id']);
$dob = 'DOB -'.date_format(date_create($dob), "d-m-Y");
// Output the option HTML with correctly formatted PHP inside
echo "<option value='" . htmlspecialchars($row['patient_id'], ENT_QUOTES, 'UTF-8') . "'>" .
htmlspecialchars($row['beneficiary_name'], ENT_QUOTES, 'UTF-8') . " - " .
htmlspecialchars($dob, ENT_QUOTES, 'UTF-8') .
"</option>";
}
} else {
// Handle query execution error
echo "Error fetching data: " . mysqli_error($conn);
}
// echo generateOptionWithWhereClause('beneficiary_enquiry', 'beneficiary_name', 'id', '', '', 'ohc_type_id', $ohc_type_id) ; ?>
</select>
</div>
</div>
<!-- Fee Amount -->
<div class="col-sm-6">
<div class="form-group">
<label for="fee_amount">Fee Amount<span style="color:red">*</span></label>
<input type="number" step="0.01" class="form-control" name="fee_amount" id="fee_amount" placeholder="Enter Fee Amount" required />
</div>
</div>
<!-- Collection Date -->
<div class="col-sm-6">
<div class="form-group">
<label for="collection_date">Collection Date<span style="color:red">*</span></label>
<input type="date" class="form-control" name="collection_date" id="collection_date" required />
</div>
</div>
<!-- Payment Mode -->
<div class="col-sm-6">
<div class="form-group">
<label for="payment_mode">Payment Mode<span style="color:red">*</span></label>
<select id="payment_mode" name="payment_mode" class="form-control select2" required>
<!-- <option value="" disabled selected>Please Select Payment Mode</option> -->
<option value="Cash">Cash</option>
<option value="Online">Online</option>
</select>
</div>
</div>
<!-- Payment Remarks -->
<div class="col-sm-12">
<div class="form-group">
<label for="payment_remarks">Payment Remarks</label>
<input type="text" class="form-control" name="payment_remarks" id="payment_remarks" placeholder="Enter Remarks" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info btn-sm save_button" onclick="validate();">
<i class="ace-icon fa fa-floppy-o bigger-110"></i> Save
</button>
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">
<i class="ace-icon fa fa-times bigger-110"></i> Cancel
</button>
</div>
</div>
</div>
</form>
</div>
<script>
function fetch_fee_schedule() {
var batchid = $('#batch_name').val();
var fee_schedule = <?php
$fee_schedule = [];
2025-08-29 16:30:39 +05:30
if ($result = $conn->query("SELECT fee_schedule_id, schedule_name, batch FROM batch_fee_schedule")) {
while ($row = $result->fetch_assoc()) {
$fee_schedule[$row['batch']][] = [
'fee_schedule_id' => $row['fee_schedule_id'],
'schedule_name' => $row['schedule_name']
];
error_log("Chech_data : batch=" . $row['batch'] . " | schedule=" . $row['schedule_name']);
}
}
2025-04-14 13:28:09 +05:30
echo json_encode($fee_schedule);
?>
$('.test').empty().append('<option value="">Select Fee Schedule</option>');
// Populate the dropdown if there are beneficiaries for the selected batch_id
if (fee_schedule[batchid]) {
$.each(fee_schedule[batchid], function(index, ben) {
$('.test').append('<option value="' + ben.fee_schedule_id + '">' + ben.schedule_name + '</option>');
});
}
};
$('#batch_name').on('change', fetch_fee_schedule);
function getFeeScheduleInfo(scheduleId) {
$.ajax({
url: 'get_schedule_info.php',
type: "POST",
data: {
scheduleId: scheduleId
},
success: function(data) {
var data = $.parseJSON(data);
$("#collection_date").val(data.due_date);
$("#fee_amount").val(data.amount_due);
},
error: function(data) {
BootstrapDialog.alert(data.message);
return;
}
});
}
</script>