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

769 lines
38 KiB
PHP

<Link href="https://cdn.datatables.net/fixedcolumns/4.1.0/css/fixedColumns.dataTables.min.css" />
<style>
.form-group .bootstrap-select>.dropdown-toggle {
padding: 9px 9px !important;
font-size: 12px !important;
border: 1px solid #c8c8c8 !important;
background: #fff !important;
}
.action_subject_addbtn {
background: #032DA4;
border-radius: 35px;
color: #fff;
padding: 5px 15px;
border: none;
font-size: 12px;
cursor: pointer;
text-decoration: none;
}
.custom_tble th:nth-child(1),
.custom_tble th:nth-child(2),
.custom_tble td:nth-child(1),
.custom_tble td:nth-child(2) {
background: #fff;
z-index: 9;
}
.table_div {
width: 100%;
}
th,
td {
white-space: nowrap;
}
.table_stu_name {
width: 150px;
margin: auto;
}
.assign_Fee_startdate .form-control {
height: calc(2.25rem + 2px);
padding: 9px 3px;
}
.assign_fee_reset .subject_addbtn {
padding: 6px 10px;
}
/*START : added by Nandini*/
.dt-buttons {
display: none !important;
}
/*END OF : added by Nandini*/
.error {
color: red;
padding-top: 5px;
/* font-weight:500; */
}
@media screen and (min-width: 1200px) {}
@media screen and (max-width: 1200px) {
div.dataTables_wrapper {
width: 776px;
}
}
@media screen and (max-width: 1100px) {
div.dataTables_wrapper {
width: 700px;
}
}
@media screen and (max-width: 1024px) {
div.dataTables_wrapper {
width: 675px;
}
}
@media screen and (max-width: 800px) {
div.dataTables_wrapper {
width: 508px;
}
}
</style>
<div class="wraper responsive-width">
<main class="long-tbl-main students_list_table" id="main">
<div class="from-group adding-class form-group_lng form_group_twobtn">
</div>
<!-- admin template section -->
<div class="admin_tempblock">
<div class="admin_tempsec">
<div class="admin_sec">
<?php
if (!empty($this->session->flashdata('success'))) { ?>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert">&times;</a>
<strong>Success!</strong> <?php echo $this->session->flashdata('success'); ?>
</div>
<?php
}
if (!empty($this->session->flashdata('error'))) {
?>
<div class="alert alert-danger">
<a href="#" class="close" data-dismiss="alert">&times;</a>
<strong>Failed!</strong> <?php echo $this->session->flashdata('error'); ?>
</div>
<?php } ?>
<div class="subsec_sec">
<div class="subject_r">
<div class="subject_lsec">
<div class="col-md-6 pull-left" style="padding:0">
<a href="<?= base_url(); ?>admin/fee-course" class="pull-left"><button type="button" class="btn subject_addbtn bg-dark">Back</button></a>
</div>
<div class="subject_lhead"><?php echo $title; ?></div>
<?php
$selCourseId = '';
$selSectionId = '';
$sercStdStr = '';
if (count($_POST) > 0) {
$selCourseId = $_POST['filter-course'];
$selSectionId = $_POST['filter-section'];
}
?>
<form method="post" action="<?php echo base_url(); ?>admin/assign-all-fees" id="form-filter">
<div class="filter_lbl">
<i class="fas fa-filter"></i>
Filter
</div>
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label class="mb-0" style="font-size: 13px;">Course</label>
<select class="form-control" placeholder="Select Course" name="filter-course" id="filter-course">
<option value="">Select Course</option>
<?php
if (isset($courses) || !empty($courses)) {
foreach ($courses as $row) {
?>
<option value="<?php echo $row['id'] ?>" <?php if ($row['id'] == $selCourseId) { ?> selected <?php } ?>>
<?php echo $row['course_name']; ?>
</option>
<?php
}
}
?>
</select>
<div class="text-danger cierr"><?php echo form_error('filter-course'); ?></div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label class="mb-0" style="font-size: 13px;">Section</label>
<select class="form-control" placeholder="Select Section" name="filter-section" id="filter-section">
<?php if ($section != '') {
$sectionName = $this->db->get_where('section', array('id' => $section))->row()->section_name;
?>
<option value="<?= $section; ?>" <?php echo set_select('filter-section', $section, TRUE); ?>><?php echo $sectionName; ?></option>
<?php } ?>
<option value=""> -- Select Section -- </option>
</select>
<div class="text-danger cierr"><?php echo form_error('filter-section'); ?></div>
</div>
</div>
<div class="col-md-2">
<div class="form-group assign_fee_toall">
<label class="mb-0" style="font-size: 13px;">Fees Type</label>
<?php if (!empty($feestypes) && count($feestypes) > 0) { ?>
<select placeholder="Select Fees type" name="filter-fees_type[]" id="filter-fees_type" class="form-control selectpicker" multiple data-live-search="true">
<option value="" disabled> -- Select Fees type -- </option>
<?php
foreach ($fees_type as $ft_value) {
?>
<option value="<?= $ft_value['id'] ?>" <?php echo (in_array($ft_value['id'], $feestypes)) ? "selected" : ""; ?>><?= $ft_value['feetype_name'] ?></option>
<?php
} ?>
</select>
<label id="filter-fees_type-error" class="error" for="filter-fees_type"></label>
<?php
} else { ?>
<select placeholder="Select Fees type" name="filter-fees_type[]" id="filter-fees_type" class="form-control fees_type_list selectpicker" multiple>
<option value="" disabled> -- Select Fees type -- </option>
<?php
foreach ($fees_type as $ft_value) {
?>
<option value="<?= $ft_value['id'] ?>"><?= $ft_value['feetype_name'] ?></option>
<?php } ?>
</select>
<label id="filter-fees_type-error" class="error" for="filter-fees_type"></label>
<?php } ?>
<div class="text-danger cierr"><?php echo form_error('filter-fees_type'); ?></div>
</div>
</div>
<?php if (isset($filter_route_id) && $filter_route_id != '') { ?>
<div class="col-md-2 " id="new-dropdown-section">
<label class="mb-0" style="font-size: 13px;">Routes</label>
<select class='form-control' name='filter-route-id' id='filter-route-id'>
<?php if (isset($routes) && !empty($routes)) { ?>
<option value="" disabled> -- Select Route -- </option>
<?php
foreach ($routes as $rt_value) {
?>
<option value="<?= $rt_value['id'] ?>" <?php echo ($filter_route_id == $rt_value['id']) ? "selected" : ""; ?>><?= $rt_value['route_name'] ?></option>
<?php
} ?>
</select>
</div>
<?php }
} else { ?>
<div class="col-md-2 " id="new-dropdown-section">
</div>
<?php } ?>
<div class="col-md-2">
<div class="form-group assign_subject assign_Fee_startdate">
<label class="mb-0" style="font-size: 13px;margin-bottom: 4px !important;"> Start Date <span class="text-danger"></span></label>
<input type="text" name="date_from" id='date_from' class="form-control nepal-date" value="<?php echo $start_date; ?>" placeholder="Enter start date">
<p id="error_d_from" style="color:red;"></p>
</div>
</div>
<div class="col-md-3">
<div class="form-group assign_fee_reset" style="margin-top: 1.5rem;">
<input type="submit" name="filterSubmit" id="filter_reset" class="btn btn-success" value="Filter">
<a href="<?php echo base_url() ?>admin/assign-all-fees"><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>
</form>
<form method="post" action="<?php echo base_url(); ?>Admin/assigntostudents">
<div class="applicnts-list-wrap ">
<div class="table_div ">
<?php //dd($theStudents);
?>
<table id="tbl" class="display custom_tble" width="100%">
<thead>
<tr>
<th>
<label class="checkBox">
<input type="checkbox" id="chkParent" />
<span class="checkmark"><?php //echo $fee_value['course_fee_id'];
?></span>
</label>
</th>
<th>Student Details </th>
<?php $thCount = (!empty($fees_type_names)) ? count($fees_type_names) : 0;
// dd($fees_type_names);
foreach ($fees_type_names as $index => $fee_value) {
?>
<th>
<?php //echo $fee_value['feecourse_id']
?>
<div class="t_heading">
<?= $fee_value['fee_amount'] . '<br>' . $fee_value['fee_name'] //($fee_value['feecourse_id']);
?>
</div>
<input type="hidden" name="feestype[]" value="<?= $fee_value['course_fee_id']; ?>">
<label class="checkBox">
<input type="checkbox" name="grouped_<?= $fee_value['feecourse_id'] ?>" id="parentcheckall_<?= $fee_value['feecourse_id'] ?>" onclick="checkparent_all(this,<?= $fee_value['feecourse_id'] ?>)">
<span class="checkmark"></span>
</label>
</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
if (isset($theStudents['student_info']) && !empty($theStudents['student_info'])) {
$sno = 1;
foreach ($theStudents['student_info'] as $sindex => $student_value) {
// echo '<pre>';
// print_r($student_value);
?>
<tr>
<td width="5%">
<label class="checkBox">
<input type="checkbox" class="student-checkbox " id="student-checkbox_<?= $student_value['student_id']; ?>" name="students[]" onclick="studentParentCheck(this)" value="<?= $student_value['student_id']; ?>">
<span class="checkmark">
</span>
</label>
</td>
<td>
<div class="mx-2 text-left">
<?php echo $student_value['student_name']; ?> <br>
<small><?php echo $student_value['studentId']; ?></small> <br>
<?= isset($student_value['route_details']) && ($student_value['route_details']['one_way'] == 'yes') ? '<span class="text-muted" style="font-style: italic; font-size: 10px;font-weight: 500;">(One Way)</span>' : '' ?>
</div>
<input type="hidden" id="rowcounter_<?= $student_value['student_id']; ?>" class="student_list_chkbx" value="0">
</td>
<?php
foreach ($student_value['fees_data'] as $index => $fee_value) {
$check_status = ($fee_value['status'] == 1) ? "checked" : "";
$cfID = $fee_value["course_fee_id"];
$cfstudId = $student_value["student_id"];
$check_fees = $this->db->query('SELECT * FROM students_online_payments WHERE course_fee_id=' . $cfID . ' AND student_id=' . $cfstudId . ' AND paid_amount > 0')->result();
// $check_fees=$this->db->get_where('students_online_payments',array('course_fee_id'=>$fee_value['course_fee_id'],'student_id'=>$student_value['student_id']))->result();
if (count($check_fees) > 0) {
$className = "";
$checkbxinput = "";
$disable_attr = 'style="background-color: #28a745 !impotant;" disabled="disabled" data-toggle="tooltip" title="Fees Partialy paid" readonly="readonly"';
$partial_payment_checkbox = " style='background-color: green !important;'";
} else {
$checkbxinput = "stud_check_inputs feestype_childerns_" . $fee_value['course_fee_id'] . " childschkBx" . $student_value['student_id'];
$className = "fes_child_checkbox fees_type_" . $fee_value['course_fee_id'] . " student_checkid_" . $student_value['student_id'];
$disable_attr = '';
$partial_payment_checkbox = "";
}
?>
<td>
<?php //echo $fee_value['course_fee_id'];
?>
<label class="checkBox">
<input type="checkbox" id="checkBx_<?= $fee_value['course_fee_id']; ?>_<?= $student_value['student_id']; ?>" class=" <?= $className; ?>" name="fees_<?= $index; ?>_<?= $fee_value['course_fee_id']; ?>[]" onclick="fees_type_check(this,<?= $fee_value['course_fee_id']; ?>,<?php echo $student_value['student_id']; ?>)" <?= $check_status; ?> value="<?php echo ($fee_value['status'] == 1) ? "on" : "off"; ?>" <?= $disable_attr; ?>>
<span class="checkmark" <?php echo $partial_payment_checkbox; ?>><?php //echo $fee_value['course_fee_id'];
?></span>
</label>
<input type="hidden" id="chkBx_<?= $fee_value['course_fee_id']; ?>_<?= $student_value['student_id']; ?>" class="<?= $checkbxinput ?>" name="row[<?= $student_value['student_id']; ?>][<?= $fee_value['course_fee_id']; ?>]" value="<?php echo ($fee_value['status'] == 1) ? "on" : "off"; ?>">
<input type="hidden" id="cb_<?= $fee_value['course_fee_id']; ?>_<?= $student_value['student_id']; ?>" value="<?= $fee_value['status']; ?>">
<input type="hidden" name="one_way[<?= $student_value['student_id']; ?>][<?= $fee_value['course_fee_id']; ?>]" id="one_way_<?= $fee_value['course_fee_id']; ?>_<?= $student_value['student_id']; ?>" value="<?= isset($student_value['route_details']) ? $student_value['route_details']['one_way'] : 'no' ?>" />
</td>
<?php } ?>
</tr>
<?php $sno++;
}
}
?>
</tbody>
</table>
<hr />
<div class="row">
<div class="col-md-9"></div>
<div class="col-md-3"><button type="submit" class=" w-100 btn btn-sm mb-2" style="background-color:#032da1;color:#fff;" name="assigntostudents" value="assign"> Assign </button></div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</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 defer src="https://cdn.datatables.net/fixedcolumns/4.1.0/js/dataTables.fixedColumns.min.js"></script>
<script>
$(document).ready(function() {
jQuery.validator.addMethod("inputregx", function(value, element) {
return this.optional(element) || /^[a-zA-Z0-9 -]{3,50}$/.test(value);
}, 'Please enter alpha and numeric characters only ');
$("#form-filter").validate({
ignore: "input[type='text']:hidden",
rules: {
"filter-course": {
required: true,
},
"filter-fees_type[]": {
required: true
},
"filter-route-id": {
required: true
}
},
messages: {
"filter-course": {
required: "Please Select Course ",
}
},
submitHandler: function(form) {
form.submit();
}
});
});
</script>
<script>
function studentParentCheck(ele) {
// alert(+ele.value);
var isChecked = $('#' + ele.id).prop('checked');
if (isChecked == true) {
$('.childschkBx' + ele.value).val('on');
$('#rowcounter_' + ele.value).val(1);
$('.student_checkid_' + ele.value).each(function() {
$(this).prop('checked', true);
});
} else {
$('.childschkBx' + ele.value).val('off');
$('#rowcounter_' + ele.value).val(0);
$('.student_checkid_' + ele.value).each(function() {
$(this).prop('checked', false);
});
}
}
$(document).ready(function() {
<?php if (isset($filter_route_id) && $filter_route_id != '') { ?>
$('#new-dropdown-section').removeClass('d-none');
<?php } else { ?>
$('#new-dropdown-section').addClass('d-none');
<?php } ?>
$('#filter-fees_type').change(function() {
$('#filter-fees_type').selectpicker('toggle');
$('#new-dropdown-section').addClass('d-none');
var TotalValues = [];
var selectedValues = [];
$('#filter-fees_type option').each(function() {
let item = $(this).val();
if (item != '') {
TotalValues.push(item);
}
});
$('#filter-fees_type 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")) {
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') {
}
for (let j = 0; j < differValues.length; j++) {
$("#filter-fees_type option[value='" + differValues[j] + "']").prop('disabled', true);
}
$("#filter-fees_type option[value='" + intersection[i] + "']").prop('disabled', false);
}
} else {
$("#filter-fees_type option[value='3']").prop('disabled', true);
$("#filter-fees_type option[value='4']").prop('disabled', true);
}
} else {
$("#filter-fees_type option").prop('disabled', false);
}
// for(let i=0;i<TotalValues.length;i++){
// console.log(i, "i");
// console.log(TotalValues[i]);
// console.log(selectedValues[i]);
// if( selectedValues[i]==="3"){
// $("#filter-fees_type option[value='"+selectedValues[i]+"']").prop('disabled',false);
// }
// else {
// $("#filter-fees_type option[value='"+TotalValues[i]+"']").prop('disabled',true);
// }
// if(TotalValues[i] === '3'){
// $("#filter-fees_type option[value='"+TotalValues[i]+"']").prop('disabled',false);
// }
// else if(TotalValues[i] === '4'){
// $("#filter-fees_type option[value='"+TotalValues[i]+"']").prop('disabled',false);
// }
// else {
// $("#filter-fees_type option[value='"+TotalValues[i]+"']").prop('disabled',true);
// $("#filter-fees_type option[value='"+TotalValues[i]+"']").prop('selected',false);
// }
// }
});
$('#chkParent').click(function() {
var isChecked = $(this).prop("checked");
$('#tbl tr:has(td)').find('.student-checkbox').prop('checked', isChecked);
if (isChecked == true) {
$('.stud_check_inputs').val('on');
$('.student_list_chkbx').val(1);
$('.fes_child_checkbox').each(function() {
$(this).prop('checked', true);
});
} else {
$('.stud_check_inputs').val('off');
$('.student_list_chkbx').val(0);
$('.fes_child_checkbox').each(function() {
$(this).prop('checked', false);
});
}
});
$('#tbl tr:has(td)').find('.student-checkbox').click(function() {
var isChecked = $(this).prop("checked");
var isHeaderChecked = $("#chkParent").prop("checked");
if (isChecked == false && isHeaderChecked)
$("#chkParent").prop('checked', isChecked);
else {
$('#tbl tr:has(td)').find('.student-checkbox').each(function() {
if ($(this).prop("checked") == false)
isChecked = false;
});
$("#chkParent").prop('checked', isChecked);
}
});
});
$(document).ready(function() {
$('.user-drpdown').click(function() {
$('.drpdown-items').toggle();
});
//table js
});
/* Ensure that the demo table scrolls */
/* Ensure that the demo table scrolls */
$(document).ready(function() {
var table = $('#tbl').DataTable({
scrollY: "400px",
scrollX: true,
scrollCollapse: true,
paging: false,
fixedColumns: {
leftColumns: 2
}
});
});
$(document).ready(function() {
var selected = [];
$('.fees_type_list option:selected').each(function() {
selected[$(this).val()] = $(this).text();
});
// Get Section by Course - start from Here
// Developer :Shivakumar
$('#filter-course').change(function() {
var course = $('#filter-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=''> 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>";
}
$('#filter-section').empty().append(divData);
// section options code here End from here
}
});
} else {
divData = "<option value=''> -- Select Section -- </option>";
$('#filter-section').empty().append(divData);
}
});
// Get Section by Course - End from Here
});
function checkparent_all(ele, fee_id) {
var isChecked = $('#parentcheckall_' + fee_id).prop("checked");
if (isChecked == true) {
$('.feestype_childerns_' + fee_id).val('on');
$('.student_list_chkbx').val(1);
$('.fees_type_' + fee_id).prop('checked', isChecked);
$('.student-checkbox').each(function() {
$(this).prop('checked', true);
});
} else {
$('.feestype_childerns_' + fee_id).val('off');
$('.student_list_chkbx').val(0);
$('.student-checkbox').each(function() {
$(this).prop('checked', false);
});
$('.fees_type_' + fee_id).prop('checked', isChecked);
}
}
function fees_type_check_old(ele, fee_id, student_id) {
var isChecked = $('.fees_type_' + fee_id).prop("checked");
var isStudentChecked = $('#student-checkbox_' + student_id).prop("checked");
if (isStudentChecked == false)
$('#student-checkbox_' + student_id).prop('checked', true);
var isHeaderChecked = $('#parentcheckall_' + fee_id).prop("checked");
if (isChecked == false && isHeaderChecked) {
$('#parentcheckall_' + fee_id).prop('checked', isChecked);
} else {
$('.fees_type_' + fee_id).each(function() {
if ($(this).prop("checked") == false)
isChecked = false;
});
$('#parentcheckall_' + fee_id).prop('checked', isChecked);
}
}
function fees_type_check(ele, fee_id, student_id) {
var act_val = parseInt($('#cb_' + fee_id + '_' + student_id).val());
var isChecked = $('#' + ele.id).prop("checked");
// alert('#'+ele.id);
if (isChecked)
$('#chkBx_' + fee_id + '_' + student_id).val("on");
else
$('#chkBx_' + fee_id + '_' + student_id).val("off");
var read_val = (isChecked === true) ? 1 : 0;
var rowcounter = parseInt($('#rowcounter_' + student_id).val());
if (parseInt(read_val) != act_val) {
rowcounter = rowcounter + 1;
} else {
rowcounter = rowcounter - 1;
}
if (rowcounter === 0) {
$('#student-checkbox_' + student_id).prop('checked', false);
} else {
$('#student-checkbox_' + student_id).prop('checked', true);
}
$('#rowcounter_' + student_id).val(rowcounter);
}
//
function assignfees(ele, event) {
console.log(ele);
}
</script>
<script>
jQuery(document).ready(function() {
jQuery(".custom_tble").clone(true).appendTo('.table_div_cover').addClass('clone');
});
</script>
</body>
</html>