BBnepal-Accounts/application/views/admin/assign_due_fees.php
Sampanna Rimal 9cd05ef3cb commitall
2024-07-10 18:28:19 +05:45

610 lines
28 KiB
PHP

<style>
table.dataTable tfoot th {
font-weight: 600 !important;
}
.form-group .bootstrap-select>.dropdown-toggle {
padding: 9px 9px !important;
font-size: 12px !important;
border: 1px solid #c8c8c8 !important;
background: #fff !important;
}
.error {
color: red;
font-size: 12px;
}
input[type="number"] {
font-size: 14px;
border: 1px solid #858585;
border-radius: 4px;
color: #6b6b6b;
padding: 5px;
width: 160px;
}
table.dataTable tfoot th {
font-weight: 600 !important;
}
.form-group .bootstrap-select>.dropdown-toggle {
padding: 9px 9px !important;
font-size: 12px !important;
border: 1px solid #c8c8c8 !important;
background: #fff !important;
}
.course_grade_details_table input[type="text"] {
font-size: 14px;
border: 1px solid #858585;
border-radius: 4px;
color: #6b6b6b;
padding: 5px;
}
.course_grade_details_table input[type="number"] {
font-size: 14px;
border: 1px solid #858585;
border-radius: 4px;
color: #6b6b6b;
padding: 5px;
width: 90px;
}
.course_grade_details_table td,
.course_grade_details_table th {
border: 0;
padding: 15px 10px;
}
.course_grade_details_table {
border: 0;
}
.course_grade_details_table td {
text-align: left;
padding: 8px 10px;
}
.course_grade_details_table th {
font-weight: 300;
font-size: 15px;
color: black;
border-bottom: 2px solid #032da1;
}
.scrollable_table thead {
display: table;
width: 100%;
}
.scrollable_table tbody {
display: block;
overflow-y: scroll;
max-height: 400px;
}
.scrollable_table th,
.scrollable_table td {
width: 130px;
font-size: 12px;
}
.scrollable_table tr {
display: table;
width: 100%;
box-sizing: border-box;
}
.scrollable_table th:nth-child(1),
.scrollable_table td:nth-child(1) {
width: 42px;
}
span.margin-t {
margin-top: 5px;
display: block;
}
</style>
<div class="wraper responsive-width">
<main class="long-tbl-main" id="main">
<!-- admin template section -->
<div class="admin_tempblock">
<div class="admin_tempsec">
<div class="admin_sec">
<div class="from-group adding-class form-group_lng">
<!-- <a href="<?= base_url(); ?>admin/scholarship-types" class="">
<button type="button" class="btn subject_addbtn btn-sm">Scholarship Types</button>
</a>
<a href="<?= base_url(); ?>admin/scholarship" class="ml-4">
<button type="button" class="btn subject_addbtn btn-sm">Assign Scholarship</button>
</a> -->
</div>
<?php
if (!empty($this->session->flashdata('success_msg'))) { ?>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert">&times;</a>
<strong>Success!</strong> <?php echo $this->session->flashdata('success_msg'); ?>
</div>
<?php
}
if (!empty($this->session->flashdata('error_msg'))) {
?>
<div class="alert alert-danger">
<a href="#" class="close" data-dismiss="alert">&times;</a>
<strong>Failed!</strong> <?php echo $this->session->flashdata('error_msg'); ?>
</div>
<?php } ?>
<div class="subsec_sec" style="display:block">
<form id="searchFilters" action="<?= base_url(); ?>admin/assign-due-fees" method="POST" onkeydown=" return event.key != 'Enter'">
<div class="subject_lsec dashboard_graph report_sec_graph">
<div class="report_sec_cover">
<div class="report_sec_left">
<?php
// $f_f_types = array();
$currency_symbol = $school_info['currency_symbol'];
$search_batch = (isset($_POST['f_batch']) && !empty($_POST['f_batch'])) ? $_POST['f_batch'] : '';
$search_course_id = (isset($_POST['f_course']) && !empty($_POST['f_course'])) ? $_POST['f_course'] : '';
$search_section = (isset($_POST['f_section']) && !empty($_POST['f_section'])) ? $_POST['f_section'] : '';
// $search_fee_types = (isset($_POST['filter_fee_types']) && !empty($_POST['filter_fee_types'])) ? $_POST['filter_fee_types'] : '';
$theExportHeader = 'Scholarships';
// if (isset($school_info) && !empty($school_info)) {
// $theExportHeader = $school_info['school_name'] . '\n' . $school_info['address'] . '\n Scholarships';
// }
// if (count($_POST) > 0) {
// if (isset($_POST['filter_fee_types']) && !empty($_POST['filter_fee_types'])) {
// $f_f_types = $_POST['filter_fee_types'];
// }
// }
// print_r($_POST);
?>
</div>
<div class="subject_lhead">Opening Balance</div>
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-3">
<div class="subject-filter">
<label>Select Batch <span style="font-weight:bold;color:red;"> * </span></label>
<select id="f_batch" name="f_batch" class=" form-control">
<option value="">Select Batch</option>
<?php if (isset($batches) || !empty($batches)) {
foreach ($batches as $row) {
if ($search_batch != '')
$b_selected = ($row['id'] == $search_batch) ? 'selected' : '';
else
$b_selected = ($row['id'] == $school_info['batch_id']) ? 'selected' : '';
?>
<option value="<?php echo $row['id'] ?>" <?= $b_selected; ?>>
<?php echo $row['b_name']; ?></option>
<?php }
} ?>
</select>
<div class="text-danger cierr"><?php echo form_error('f_batch'); ?></div>
</div>
</div>
<div class="col-md-3">
<div class="subject-filter">
<label>Select Course <span style="font-weight:bold;color:red;"> * </span></label>
<select id="f_course" name="f_course" class=" form-control">
<option value="">Select Course</option>
<?php foreach ($course as $c_value) {
$course_selected = ($c_value['id'] == $search_course_id) ? 'selected' : '';
?>
<option value="<?= $c_value['id']; ?>" <?= $course_selected; ?>><?php echo $c_value['course_name']; ?> </option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-3">
<div class=" form-group subject-filter">
<label>Select Section</label>
<?php if ($search_course_id != '' && $search_course_id > 0) {
$sql = "SELECT s.id as section_id,s.section_name FROM course_sections cs JOIN section s ON s.id=cs.section_id WHERE cs.course_id='$search_course_id' ORDER BY s.id DESC";
$section_list = $this->Admin_model->get_query_result($sql);
?>
<select id="f_section" id="f_section" name="f_section[]" class=" form-control selectpicker" multiple>
<option value="" disabled>Select Section</option>
<?php
if (isset($section_list) && !empty($section_list)) {
foreach ($section_list as $se_val) { ?>
<option value="<?php echo $se_val['section_id'] ?>" <?php if (isset($search_section) && !empty($search_section)) {
echo (in_array($se_val['section_id'], $search_section)) ? 'selected' : '';
} ?>><?php echo $se_val['section_name'] ?></option>
<?php }
} ?>
</select>
<?php } else { ?>
<select id="f_section" id="f_section" name="f_section[]" class=" form-control selectpicker" multiple>
<option value="" disabled>Select Section</option>
</select>
<?php } ?>
</div>
</div>
<div class="col-md-3">
<div class="date-filter pt-4">
<input type="submit" name="filtersubmit" id="filter_reset1" class="btn btn-success " style="width:250px;height:40px;" value="Filter">
<a href="<?php echo base_url() ?>admin/total-due-report">
<div class="date-filter"> <button type="button" name="reset_filter" id="reset_filter" value="reset_filter" class="subject_addbtn subject_addbtn_nobg"><i class="fas fa-redo"></i>Reset</button>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- new divs added -->
<div class="tab-content">
<!-- new divs added -->
<div class="applicnts-list-wrap ">
<div class=" table_div">
<!-- changed ID -->
<table id="tbl1" class="display table-responsive">
<thead>
<tr>
<th>Student Id </th>
<th>Student Name</th>
<th>Roll No</th>
<th>Course</th>
<th>Section</th>
<th>Contact No</th>
<th>Amount (in Rs.)</th>
</tr>
</thead>
<tbody>
<?php
//dd($student_fees);
$sno = 1;
if (isset($student_fees) && !empty($student_fees)) {
foreach ($student_fees as $svalue) {
// echo '<pre>';
// print_r($svalue);
$amount = 0;
$cfId = 0;
if (isset($student_opening_balance) && count($student_opening_balance) != 0) {
foreach ($student_opening_balance as $sob) {
if ($sob['student_id'] == $svalue['student_id']) {
// print_r($sob);
$amount = $sob['amount'];
$cfId = $sob['course_fee_id'];
}
}
}
?>
<tr>
<td><?= $svalue['studentId']; ?></td>
<td><?= $svalue['student_name']; ?></td>
<td><?= $svalue['roll_no']; ?></td>
<td><?= $svalue['course_name']; ?></td>
<td><?= $svalue['section_name']; ?></td>
<td><?= $svalue['emergency_contact_number']; ?></td>
<td colspan="2">
<input type="hidden" class="form-control w-50 m-auto text-center" name="course_fee[<?= $svalue["student_id"]; ?>]" value="<?= $cfId != 0 ? $cfId : '' ?>">
<input type="hidden" class="form-control w-50 m-auto text-center" name="student_course[<?= $svalue["student_id"]; ?>]" value="<?= $svalue['course_id']; ?>">
<input type="hidden" class="form-control w-50 m-auto text-center" name="student_section[<?= $svalue["student_id"]; ?>]" value="<?= $svalue['section_id']; ?>">
<input type="hidden" class="form-control w-50 m-auto text-center" name="student_batch[<?= $svalue["student_id"]; ?>]" value="<?= $svalue['batch_id']; ?>">
<input type="number" min="0" placeholder="Amount" name='opening_balance[<?= $svalue["student_id"]; ?>]' value="<?= isset($amount) ? $amount : '' ?>">
</td>
</tr>
<?php
$sno++;
}
} ?>
</tbody>
</table>
<input type="submit" name="save" id="save_scholarship" class="btn subject_addbtn btn-sm " style="width:250px;height:40px;" value="Save">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- admin template section end -->
</main>
<!--End right-top side-->
</div>
<script defer src="<?php echo base_url(); ?>assets_admin/js/bootstrap-select.min.js"></script>
<script>
// function formOnEnter() {
// $(this).next('input').focus();
// }
$('input').on("keydown", function(e) {
/* ENTER PRESSED*/
console.log(e.keyCode);
if (e.keyCode == 13) {
/* FOCUS ELEMENT */
var inputs = $(this).parents("form").eq(0).find(":input[type='number']");
var idx = inputs.index(this);
if (idx == inputs.length - 1) {
inputs[0].select()
} else {
inputs[idx + 1].focus(); // handles submit buttons
inputs[idx + 1].select();
}
e.preventDefault();
return false;
} else {
return true;
// e.preventDefault();
}
});
$('#save_scholarship').click(function() {
$('#searchFilters').submit();
});
// Reusable helper functions
const calculateSale = (feePrice, discount) => {
feePrice = parseFloat(feePrice);
discount = parseFloat(discount);
return (feePrice * discount / 100).toFixed(2); // Final price
}
const calculateDiscount = (feePrice, finalPrice) => {
feePrice = parseFloat(feePrice);
finalPrice = parseFloat(finalPrice);
return (finalPrice * 100 / feePrice).toFixed(2); // Discount percentage
}
function perToAmount(discount, scholarshipAmountFieldName, feeAmount, selectId) {
console.log(discount + ' =============> ' + scholarshipAmountFieldName);
$('input[name="' + scholarshipAmountFieldName + '"]').val(calculateSale(feeAmount, discount));
$('#' + selectId).attr('required', 'required');
// console.log(calculateSale(feeAmount, discount));
}
function amountToPer(amount, scholarshipPercentageName, feeAmount) {
// console.log(discount + ' =============> ' + scholarshipAmountFieldName);
$('input[name="' + scholarshipPercentageName + '"]').val(calculateDiscount(feeAmount, amount));
$('#' + selectId).attr('required', true);
// console.log(calculateSale(feeAmount, discount));
}
// $('input[name^="scholarshipPercentage"]').change(function(event) {
// $('input').attr('name', $('input').attr('name'))
// console.log($('input').attr('name'));
// // console.log(event.target);
// // $('input[name^="scholarshipPercentage"]').val(1000);
// var index = $('input[name^="scholarshipPercentage"]').index(this);
// studentId = $('input[name^="studentId"]').val();
// var totalFeeAmount = $('input[name^="totalFee"]').val();
// $('input[name^="scholarshipPercentage"]').each(function(index, elem) {
// console.log('Index = ' + index + 'Eleam =======> ');
// $('input[name="scholarshipAmount[' + index + ']"]', index).val(1000);
// console.log($('input[name^="scholarshipPercentage"]').is(':focus'));
// // $(".val2", elem).val(parseInt($(".val1", elem).val()) * parseInt($("#value").val()));
// });
// alert('Index =======> ' + index + ' Student Id =======> ' + studentId + ' Total Fee Amount =======> ' + totalFeeAmount);
// });
// Init!
// $totalFee.trigger('input');
</script>
<script>
// checkFeeType();
// $("#filter_fee_types option[value='3']").prop('disabled', true);
// $("#filter_fee_types option[value='4']").prop('disabled', true);
// $("#filter_fee_types option[value='8']").prop('disabled', true);
// const intersection = TotalValues.filter(element => selectedValues.includes(element));
// const differValues = TotalValues.filter(element => !selectedValues.includes(element));
function checkFeeType() {
}
$('#filter_fee_types').change(function() {
$('#filter_fee_types').selectpicker('toggle');
$('#new-dropdown-section').addClass('d-none');
var TotalValues = [];
var selectedValues = [];
$('#filter_fee_types option').each(function() {
let item = $(this).val();
if (item != '') {
TotalValues.push(item);
}
});
$('#filter_fee_types option:selected').each(function() {
let selectItem = $(this).val();
if (selectItem != '')
selectedValues.push(selectItem);
});
const intersection = TotalValues.filter(element => selectedValues.includes(element));
const differValues = TotalValues.filter(element => !selectedValues.includes(element));
// console.log(intersection);
// console.log(differValues);
if (intersection.length > 0) {
var divData1 = '';
if (intersection.includes("3") || intersection.includes("4") || intersection.includes("8")) {
for (let i = 0; i < intersection.length; i++) {
if (intersection[i] == '4') {
$.ajax({
url: "<?php echo base_url(); ?>Admin/get_routes_by_batch_course",
method: "GET",
dataType: "json",
success: function(res) {
// console.log(res.routes);
// #new-dropdown-section
$('#new-dropdown-section').removeClass('d-none');
divData1 += "<label class='mb-0' style='font-size: 13px;margin-bottom: 4px !important;'> Routes <span class='text-danger'></span></label><select class='form-control' name='filter-route-id' id='filter-route-id' >";
divData1 += "<option value='' disabled> Select Routes </option>";
if (res.routes != '') {
$.each(res.routes, function(i, routedata) {
// console.log(routedata.id+"="+routedata.route_name);
divData1 += "<option value='" + routedata.id + "'>" + routedata.route_name + "</option>";
});
}
// $('#course_error_msg').text();
else {
divData1 += "<option value=''> -- No Route's Found --</option>";
}
divData1 += "</select>"
$('#new-dropdown-section').empty().append(divData1);
}
});
} else if (intersection[i] == '3') {
} else if (intersection[i] == '8') {
}
for (let j = 0; j < differValues.length; j++) {
$("#filter_fee_types option[value='" + differValues[j] + "']").prop('disabled', true);
}
$("#filter_fee_types option[value='" + intersection[i] + "']").prop('disabled', false);
}
} else {
$("#filter_fee_types option[value='3']").prop('disabled', true);
$("#filter_fee_types option[value='4']").prop('disabled', true);
$("#filter_fee_types option[value='8']").prop('disabled', true);
}
} else {
$("#filter_fee_types option").prop('disabled', false);
}
});
$(document).ready(function() {
$("#searchFilters").validate({
rules: {
f_batch: 'required',
f_course: 'required',
"filter_fee_types[]": {
required: true
},
},
submitHandler: function(form, e) {
e.preventDefault();
form.submit();
}
});
});
$('#f_course').change(function() {
var course = $('#f_course option:selected').val();
// alert(course);
var divData = '';
if (course != '' && course != 0) {
$.ajax({
url: "<?php echo base_url(); ?>Admin/get_section_by_course",
method: "POST",
data: {
course_id: course
},
dataType: "json",
success: function(response) {
// console.log(response);
// section options code and start from here
divData += "<option value='' disabled> Select Section </option>";
if (response.sections != '') {
$.each(response.sections, function(i, sectiondata) {
divData += "<option value='" + sectiondata.section_id + "'>" + sectiondata.section_name + "</option>";
});
}
// $('#course_error_msg').text();
else {
divData += "<option value=''> -- No Section's Found --</option>";
}
$('#f_section').empty().append(divData).selectpicker("refresh");
// section options code here End from here
}
});
} else {
divData = "<option value=''> -- Select Section -- </option>";
$('#f_section').empty().append(divData);
}
});
$(document).ready(function() {
$('.user-drpdown').click(function() {
$('.drpdown-items').toggle();
});
var currency_symbol = "<?php echo $currency_symbol; ?>";
var jsTheExportHeader = '<?php echo $theExportHeader; ?>';
//table js
$('#tbl1').DataTable({
"lengthMenu": [
[-1],
["All"]
],
"dom": 'lBfrtip',
"buttons": []
});
$('#f_section').selectpicker();
$('#f_feetype').selectpicker();
});
</script>
</body>
</html>