928 lines
31 KiB
PHP
928 lines
31 KiB
PHP
|
<link rel="stylesheet" href="<?php echo base_url(); ?>assets_admin/css/bootstrap-select.css">
|
||
|
<style>
|
||
|
.multiple-fields-fees .form-div {
|
||
|
width: auto;
|
||
|
margin-right: 12px;
|
||
|
}
|
||
|
label.error,label#Nameerr,#dublicateErr {
|
||
|
color: red;
|
||
|
}
|
||
|
/*input {
|
||
|
height: calc(2.25rem + 2px);;
|
||
|
}*/
|
||
|
.form-control[readonly] {
|
||
|
background-color: rgb(255 255 255 / 0%);
|
||
|
opacity: 1;
|
||
|
}
|
||
|
.form-control[disabled] {
|
||
|
background-color: #e9ecef;
|
||
|
opacity: 1;
|
||
|
}
|
||
|
.dropdown.bootstrap-select {
|
||
|
width: 240px !important;
|
||
|
display: block !important;
|
||
|
}
|
||
|
</style>
|
||
|
<script src="<?php echo base_url(); ?>assets_admin/js/moment.min.js"></script>
|
||
|
<main class="wraper responsive-width" id="main" >
|
||
|
<div class="main-wrap" >
|
||
|
<div class="dashboard-cover">
|
||
|
<?php if($this->session->flashdata('success')) { ?>
|
||
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||
|
<p><?php echo $this->session->flashdata('success') ?></p>
|
||
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||
|
<span aria-hidden="true">×</span>
|
||
|
</button>
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
<?php if($this->session->flashdata('failed')) { ?>
|
||
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||
|
<p><?php echo $this->session->flashdata('failed') ?></p>
|
||
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||
|
<span aria-hidden="true">×</span>
|
||
|
</button>
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
<div class="common-heading">
|
||
|
<!-- <div class="calendar-type mb-3">
|
||
|
<p class="mb-2">Note : Click below button to change type of calendar</p>
|
||
|
<input type="checkbox" id="cal_language" name="cal_language" checked data-toggle="toggle" data-on="Bikram Sambat" data-off="Gregorian" data-onstyle="primary" data-offstyle="success">
|
||
|
</div> -->
|
||
|
<h2>Fee </h2>
|
||
|
</div>
|
||
|
<form action="<?= base_url() ?>admin/ae-fee-course/<?= $fees_id ?>" id="fee_form" method="post">
|
||
|
<?php if($fees_id == 0) { ?>
|
||
|
<div class="feeForm-wrap">
|
||
|
<div class="form-group">
|
||
|
<label for="">Batch<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="batch_id" class="form-control" id="batch_id">
|
||
|
<option selected disabled value=''>Select one batch</option>
|
||
|
<?php foreach ($batches as $key => $value) {
|
||
|
echo '<option value="'.$value['id'].'">'.$value['b_name'].' : '.batchdateFormatTo($value['b_from'], $value['b_end']).'</option>';
|
||
|
} ?>
|
||
|
</select>
|
||
|
<div class="empty_batch_err" style="display:none;color:red"></div>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label for="">Course<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="course_id[]" multiple class="form-control selectpicker" id="course_id" onchange="CourseChange(this)">
|
||
|
<option disabled value=''>Select Courses</option>
|
||
|
<?php foreach ($courses as $key => $value) {
|
||
|
echo '<option value="'.$value['id'].'">'.$value['course_name'].'</option>';
|
||
|
} ?>
|
||
|
</select>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label for="">Fees Type<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="feetype" onchange="check_hostel_type(this)" class="form-control" id="feetype">
|
||
|
<option selected disabled value=''>Select fee type</option>
|
||
|
<?php foreach ($feeTypes as $key => $value) {
|
||
|
echo '<option value="'.$value['id'].'">'.$value['feetype_name'].'</option>';
|
||
|
} ?>
|
||
|
</select>
|
||
|
<label id="Nameerr" style="display : none"></label>
|
||
|
</div>
|
||
|
<div class="form-group" id="group-checkbox-id">
|
||
|
<label>Group Fees</label>
|
||
|
<label class="checkBox">
|
||
|
<input type="checkbox" id="checkBx" name="grouped" onchange="valueChanged()">
|
||
|
<span class="checkmark"></span>
|
||
|
</label>
|
||
|
<div class="form-group-h">
|
||
|
<div class="form-group">
|
||
|
<label for="">Due date<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<input type="text" name="common_bs_due_date" class="form-control cm-datepicker common_date_picker" id="cm-datepicker" placeholder="Select Date"/>
|
||
|
<input type="date" onchange="applyEnglishDate(this, event)" name="common_ad_due_date" placeholder="Select Date" class="form-control eng-date english-datepicker common_date_picker" style="display: none;">
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div id="newdropdowns"></div>
|
||
|
<div class="multiple-fields-fees">
|
||
|
<div class="form-group form-group-div">
|
||
|
<div class="form-div">
|
||
|
<label for="">Fees Name<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<div class="fees-name-container">
|
||
|
<input type="text" name="feename[0]" id="" class="form-control feeNameClass" placeholder="Enter fees name">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-div">
|
||
|
<label for="">Amount<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<input type="text" name="feeamount[0]" id="" class="form-control feeAmountClass" placeholder="Enter fees amount">
|
||
|
</div>
|
||
|
<div class="form-div">
|
||
|
<label for="">Due date<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<input type="text" name="bsdate[0]" class="form-control cm-datepicker nepali-datepicker" id="nepali-datepicker" placeholder="Select Date"/>
|
||
|
<input type="date" name="englishdate[0]" class="form-control english-datepicker" style="display: none;" placeholder="Select Date">
|
||
|
</div>
|
||
|
<div class="form-div add-remove-btns">
|
||
|
<button style="display:none" class="add-delete-btn" onclick="addExtraFields(this, event)" name="Add new Course" id="addBtn1">+</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div id="dublicateErr" class="mb-2" style="display:none"></div>
|
||
|
<hr>
|
||
|
<!-- Nstallments section -->
|
||
|
|
||
|
<!-- <div class="installment-section mt-3 mb-3">
|
||
|
<div class="form-check">
|
||
|
<input type="checkbox" class="form-check-input" id="installment">
|
||
|
<label class="form-check-label" for="installment">Create Installments</label>
|
||
|
</div>
|
||
|
|
||
|
<div class="main_installments_container mt-3" style="display:none">
|
||
|
<select class="form-control" name="payment_type">
|
||
|
<option value="" selected>Choose one payment type</option>
|
||
|
<?php
|
||
|
foreach ($payment_types as $key => $value) { ?>
|
||
|
<option value="<?= $value['id'] ?>"><?= $value['payment_type_name'] ?></option>
|
||
|
<?php }
|
||
|
?>
|
||
|
</select>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
$('#installment').on('change',function() {
|
||
|
let sum = 0;
|
||
|
$('#dublicateErr').hide();
|
||
|
$('.feeAmountClass').each(function(i,ele) {
|
||
|
sum += Number(ele.value);
|
||
|
})
|
||
|
|
||
|
if(sum > 0) {
|
||
|
|
||
|
if($('#installment').is(":checked")) {
|
||
|
$('.main_installments_container').show();
|
||
|
}
|
||
|
|
||
|
} else {
|
||
|
$('.main_installments_container').hide();
|
||
|
$('#dublicateErr').text('Please enter atleast one amount');
|
||
|
$('#dublicateErr').show();
|
||
|
$(this).prop('checked', false)
|
||
|
}
|
||
|
|
||
|
})
|
||
|
</script> -->
|
||
|
|
||
|
<!-- Nstallments section -->
|
||
|
|
||
|
|
||
|
|
||
|
<input type="submit" class="subject_addbtn" value="Save">
|
||
|
<a href="<?php echo base_url() ?>admin/fee-course"><button type="button" class=" ml-2 subject_addbtn bg-dark">Back</button></a>
|
||
|
</div>
|
||
|
<?php } else { // UPDATE FORM STARTS HERE ?>
|
||
|
|
||
|
<div class="feeForm-wrap">
|
||
|
<div class="form-group">
|
||
|
<label for="">Batch<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="batch_id" class="form-control" id="batch_id">
|
||
|
<?php foreach ($batches as $key => $value) {
|
||
|
if(in_array($course_fees[0]['batch'],$value)) {
|
||
|
echo '<option selected value="'.$value['id'].'">'.$value['b_name'].' : '.batchdateFormatTo($value['b_from'], $value['b_end']).'</option>';
|
||
|
} else {
|
||
|
echo '<option value="'.$value['id'].'">'.$value['b_name'].' : '.batchdateFormatTo($value['b_from'], $value['b_end']).'</option>';
|
||
|
}
|
||
|
} ?>
|
||
|
</select>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label for="">Course<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="course_id" class="form-control" id="course_id" >
|
||
|
<?php foreach ($courses as $key => $value) {
|
||
|
if(in_array($course_fees[0]['course'],$value)) {
|
||
|
echo '<option selected value="'.$value['id'].'">'.$value['course_name'].'</option>';
|
||
|
} else {
|
||
|
echo '<option value="'.$value['id'].'">'.$value['course_name'].'</option>';
|
||
|
}
|
||
|
} ?>
|
||
|
</select>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<?php
|
||
|
$disabled_var = $course_fees[0]['fee_id'] == 8 ? 'enabled' : '';
|
||
|
?>
|
||
|
<label for="">Fees Type<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="feetype" <?= $disabled_var ?> onchange="check_hostel_type(this)" class="form-control" id="feetype" >
|
||
|
<?php foreach ($feeTypes as $key => $value) {
|
||
|
if(in_array($course_fees[0]['feetype'],$value)) {
|
||
|
echo '<option selected value="'.$value['id'].'">'.$value['feetype_name'].'</option>';
|
||
|
} else {
|
||
|
echo '<option value="'.$value['id'].'">'.$value['feetype_name'].'</option>';
|
||
|
}
|
||
|
} ?>
|
||
|
</select>
|
||
|
<label id="Nameerr" style="display : none"></label>
|
||
|
</div>
|
||
|
<?php
|
||
|
$div_style = $course_fees[0]['fee_id'] == 8 ? 'none' : 'block';
|
||
|
?>
|
||
|
<div class="form-group" id="group-checkbox-id" style="display:<?= $div_style ?>">
|
||
|
<label>Group Fees</label>
|
||
|
<label class="checkBox">
|
||
|
|
||
|
<?php if($course_fees[0]['grouped'] == 'yes') {
|
||
|
echo '<input type="checkbox" checked name="grouped" id="checkBx" onchange="valueChanged()">';
|
||
|
} else {
|
||
|
echo '<input type="checkbox" name="grouped" id="checkBx" onchange="valueChanged()">';
|
||
|
} ?>
|
||
|
<span class="checkmark"></span>
|
||
|
</label>
|
||
|
<div class="form-group-h">
|
||
|
<div class="form-group">
|
||
|
<label for="">Due date<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<?php if($course_fees[0]['grouped'] == 'yes') { ?>
|
||
|
<input type="text" value="<?= $course_fees[0]['due_date'] ?>" name="common_bs_due_date" class="form-control cm-datepicker common_date_picker" id="cm-datepicker" placeholder="Select Date"/>
|
||
|
<?php } else { ?>
|
||
|
<input type="text" name="common_bs_due_date" class="form-control cm-datepicker common_date_picker" id="cm-datepicker" placeholder="Select Date"/>
|
||
|
<?php } ?>
|
||
|
<input type="date" name="common_ad_due_date" placeholder="Select Date" class="form-control english-datepicker eng-date common_date_picker" style="display: none;">
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<?php
|
||
|
// dd($course_fees);
|
||
|
$route_div_style = $course_fees[0]['fee_id'] == 4 ? '' : 'd-none';
|
||
|
?>
|
||
|
<div class="form-group <?=$route_div_style; ?>" >
|
||
|
<?php //dd($course_fees); ?>
|
||
|
<label for="">Route Name<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="new_route_id" class="form-control" id="new_route_id" >
|
||
|
<?php
|
||
|
|
||
|
foreach ($edit_route_list as $rt_key => $rt_value) {
|
||
|
if($course_fees[0]['route_id']==$rt_value['id']) {
|
||
|
echo '<option selected value="'.$rt_value['id'].'">'.$rt_value['route_name'].'</option>';
|
||
|
} else {
|
||
|
echo '<option value="'.$rt_value['id'].'">'.$rt_value['route_name'].'</option>';
|
||
|
}
|
||
|
} ?>
|
||
|
</select>
|
||
|
</div>
|
||
|
<div class="multiple-fields-fees">
|
||
|
<?php $selectedPlan = '' ?> <!-- // Used only for Hostel -->
|
||
|
<?php
|
||
|
|
||
|
// dd($course_fees);
|
||
|
foreach ($course_fees as $key => $value) {
|
||
|
$feenames = (array)json_decode($value['fees_name']);
|
||
|
$nameLength = count($feenames);
|
||
|
|
||
|
// dd($feenames);
|
||
|
foreach ($feenames as $index => $ele) {
|
||
|
$selectedPlan = $ele->name; // Ignore if fee type is not hostel
|
||
|
|
||
|
|
||
|
?>
|
||
|
|
||
|
|
||
|
<div class="form-group form-group-div ">
|
||
|
<div class="form-div">
|
||
|
<?php //echo $index."<br>".$ele->name; ?>
|
||
|
<label for="">Fees Name - <?php //echo $index ?><span class="text-danger font-weight-bold">*</span></label>
|
||
|
<div class="fees-name-container">
|
||
|
<input type="text" value="<?= $ele->name ?>" name="feename[<?= $index ?>]" id="" class="form-control feeNameClass checkfeename" placeholder="Enter fees name">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-div">
|
||
|
<label for="">Amount<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<input type="text" value="<?= $ele->amount ?>" name="feeamount[<?= $index ?>]" id="" class="form-control feeAmountClass" placeholder="Enter fees amount">
|
||
|
</div>
|
||
|
<?php if($value['grouped'] == 'no') { ?>
|
||
|
<div class="form-div">
|
||
|
<label for="">Due date<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<input type="text" value="<?= $value['due_date'] ?>" name="bsdate[0]" class="form-control cm-datepicker nepali-datepicker" id="nepali-datepicker" placeholder="Select Date"/>
|
||
|
<input type="date" name="englishdate[<?= $index ?>]" class="form-control english-datepicker" style="display: none;" placeholder="Select Date">
|
||
|
</div>
|
||
|
<?php } else { ?>
|
||
|
<div class="form-div">
|
||
|
<label for="">Due date<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<input type="text" disabled value="<?= $value['due_date'] ?>" name="bsdate[0]" class="form-control cm-datepicker nepali-datepicker" id="nepali-datepicker" placeholder="Select Date"/>
|
||
|
<input type="date" disabled name="englishdate[<?= $index ?>]" class="form-control english-datepicker" style="display: none;" placeholder="Select Date">
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
<?php if($nameLength == 1) { ?>
|
||
|
<div class="form-div add-remove-btns">
|
||
|
<button style="display:none" class="add-delete-btn" onclick="addExtraFields(this, event)" name="Add new Course" id="addBtn1">+</button>
|
||
|
</div>
|
||
|
<?php } else if($index == ($nameLength - 1)){ ?>
|
||
|
<div class="form-div add-remove-btns">
|
||
|
<button style="display:none" class="add-delete-btn" onclick="addExtraFields(this, event)" name="Add new Course" id="addBtn1">+</button>
|
||
|
</div>
|
||
|
<div class="form-div add-remove-btns remove-btn">
|
||
|
<button class="add-delete-btn" onclick="removeExtraField(this, event)" name="Add new Course" id="addBtn1">-</button>
|
||
|
</div>
|
||
|
<?php } else if($index > 0) { ?>
|
||
|
<div class="form-div add-remove-btns remove-btn">
|
||
|
<button class="add-delete-btn" onclick="removeExtraField(this, event)" name="Add new Course" id="addBtn1">-</button>
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
</div>
|
||
|
<?php }
|
||
|
} ?>
|
||
|
</div>
|
||
|
<div id="dublicateErr" class="mb-2" style="display:none"></div>
|
||
|
<input type="submit" class="subject_addbtn" value="Update">
|
||
|
<a href="<?php echo base_url() ?>admin/fee-course"><button type="button" class=" ml-2 subject_addbtn bg-dark">Back</button></a>
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
|
||
|
</form>
|
||
|
</div>
|
||
|
</div>
|
||
|
</main>
|
||
|
<script defer src="<?php echo base_url(); ?>assets_admin/js/bootstrap-select.min.js"></script>
|
||
|
|
||
|
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
|
||
|
function CourseChange(element){
|
||
|
// alert(element.id);
|
||
|
$('#feetype').val('');
|
||
|
$('#newdropdowns').empty();
|
||
|
}
|
||
|
|
||
|
function CheckRouteFee(inputelement){
|
||
|
let batchid=$('#batch_id option:selected').val();
|
||
|
// alert(BatchId);
|
||
|
// let CourseId=$('#cousrse_id option:selected').val();
|
||
|
let feeTypeId=$('#feetype option:selected').val();
|
||
|
var selectedValues=[];
|
||
|
let checkfeename=$('.checkfeename').val();
|
||
|
|
||
|
$('#course_id option:selected').each(function() {
|
||
|
let selectedItem=$(this).val();
|
||
|
// alert('course_ids'+selectedItem);
|
||
|
if(selectedItem !=''){
|
||
|
selectedValues.push(selectedItem);
|
||
|
}
|
||
|
|
||
|
});
|
||
|
let routeId=$('#'+inputelement.id).val();
|
||
|
|
||
|
if(batchid === '')
|
||
|
alert("Please Select Batch");
|
||
|
else if(feeTypeId === '')
|
||
|
alert("Please Select Fees Type");
|
||
|
else if(selectedValues.length === 0)
|
||
|
alert("Please Select course");
|
||
|
else if(routeId === '')
|
||
|
alert("Please Select Route");
|
||
|
|
||
|
if(batchid !=='' && feeTypeId !=='' && (selectedValues.length > 0) && routeId!==''){
|
||
|
var errdiv='';
|
||
|
$.ajax({
|
||
|
url : '<?php echo base_url() ?>' + 'admin/check_route_fees',
|
||
|
type : 'POST',
|
||
|
data:{
|
||
|
batch_id:batchid,
|
||
|
feetype_id:feeTypeId,
|
||
|
course_ids:selectedValues,
|
||
|
route_id:routeId
|
||
|
},
|
||
|
dataType: "json",
|
||
|
success: function(response){
|
||
|
if(response != 0)
|
||
|
{
|
||
|
errdiv +='<p ><strong class="text-danger" style="font-size:16px;">NOTE : </strong> <span style="font-size:14px;" class="text-success">The existing fee names can not be created again.</span></p>';
|
||
|
// for(let i=0;i<response.length;i++){
|
||
|
// errdiv +='<p class="text-danger" style="font-size:12px;"> <strong>'+ response[i].fee_values +'</strong> Fees already created for Batch and Course <strong>'+response[i].course_name+'</strong></p>';
|
||
|
|
||
|
// }
|
||
|
$('#errorDiv').empty().append(errdiv);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
else {
|
||
|
console.log(selectedValues.length);
|
||
|
}
|
||
|
|
||
|
|
||
|
// alert("batch "+BatchId);
|
||
|
|
||
|
// alert("feestype "+feeTypeId);
|
||
|
// alert(inputelement.id);
|
||
|
}
|
||
|
|
||
|
|
||
|
$('#batch_id').on('change', function() {
|
||
|
$('.empty_batch_err').hide();
|
||
|
$('#Nameerr').hide();
|
||
|
})
|
||
|
|
||
|
const check_hostel_type = function(ele) {
|
||
|
$('#newdropdowns').empty();
|
||
|
$('#Nameerr').hide();
|
||
|
$('#group-checkbox-id').show();
|
||
|
let feenameContainer = $('.fees-name-container');
|
||
|
let notFirstChild = $('.multiple-fields-fees .form-group.form-group-div:not(:first-child)');
|
||
|
if(ele.value == 3) {
|
||
|
|
||
|
$('#group-checkbox-id').hide();
|
||
|
$('.main_installments_container').hide();
|
||
|
if(notFirstChild.length > 0) {
|
||
|
notFirstChild.remove();
|
||
|
$('.multiple-fields-fees .form-control').each(function(index,ele) {
|
||
|
ele.value = '';
|
||
|
})
|
||
|
}
|
||
|
|
||
|
$('#group-checkbox-id').hide();
|
||
|
$.ajax({
|
||
|
url : '<?php echo base_url() ?>' + 'admin/ajax_get_hostel_plans',
|
||
|
type : 'POST',
|
||
|
async : false,
|
||
|
success: function(data){
|
||
|
|
||
|
feenameContainer.empty();
|
||
|
feenameContainer.append(data);
|
||
|
}
|
||
|
});
|
||
|
} else if(ele.value == 4) {
|
||
|
$(".add-delete-btn").show();
|
||
|
$('#group-checkbox-id').hide();
|
||
|
$('.empty_batch_err').hide();
|
||
|
$('#Nameerr').hide();
|
||
|
$('.main_installments_container').hide();
|
||
|
|
||
|
if(notFirstChild.length > 0) {
|
||
|
notFirstChild.remove();
|
||
|
$('.multiple-fields-fees .form-control').each(function(index,ele) {
|
||
|
ele.value = '';
|
||
|
})
|
||
|
}
|
||
|
$('#group-checkbox-id').hide();
|
||
|
let batch_id = $('#batch_id').val();
|
||
|
if(batch_id) {
|
||
|
$.ajax({
|
||
|
url : '<?php echo base_url() ?>' + 'admin/ajax_get_transport_routes_new',
|
||
|
type : 'POST',
|
||
|
data : {
|
||
|
batch_id
|
||
|
},
|
||
|
async : false,
|
||
|
success: function(data){
|
||
|
// console.log(data);
|
||
|
|
||
|
|
||
|
if(!data) {
|
||
|
$('#Nameerr').show();
|
||
|
$('#Nameerr').text('There are no routes for selected batch to create Transport fees');
|
||
|
$(ele).val('');
|
||
|
} else {
|
||
|
$('#newdropdowns').empty();
|
||
|
$('#newdropdowns').append(data);
|
||
|
feenameContainer.empty();
|
||
|
feenameContainer.append('<input type="text" name="feename[0]" id="" class="form-control feeNameClass" placeholder="Enter fees name">');
|
||
|
}
|
||
|
|
||
|
}
|
||
|
});
|
||
|
} else {
|
||
|
$('.empty_batch_err').show();
|
||
|
$('.empty_batch_err').text('Please select a batch');
|
||
|
$(ele).val('');
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// afras code start here
|
||
|
|
||
|
// if(batch_id) {
|
||
|
// $.ajax({
|
||
|
// url : '<?php //echo base_url() ?>' + 'admin/ajax_get_transport_routes',
|
||
|
// type : 'POST',
|
||
|
// data : {
|
||
|
// batch_id
|
||
|
// },
|
||
|
// async : false,
|
||
|
// success: function(data){
|
||
|
// console.log(data);
|
||
|
// if(!data) {
|
||
|
// $('#Nameerr').show();
|
||
|
// $('#Nameerr').text('There are no routes for selected batch to create Transport fees');
|
||
|
// $(ele).val('');
|
||
|
// } else {
|
||
|
// feenameContainer.empty();
|
||
|
// feenameContainer.append(data);
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
// });
|
||
|
// } else {
|
||
|
// $('.empty_batch_err').show();
|
||
|
// $('.empty_batch_err').text('Please select a batch');
|
||
|
// $(ele).val('');
|
||
|
// }
|
||
|
// Afras code end here
|
||
|
|
||
|
} else if (ele.value == 8) {
|
||
|
$("#group-checkbox-id").hide();
|
||
|
$(".add-delete-btn").show();
|
||
|
} else {
|
||
|
$('.main_installments_container').show();
|
||
|
$('#group-checkbox-id').show();
|
||
|
feenameContainer.empty();
|
||
|
feenameContainer.append('<input type="text" name="feename[0]" id="" class="form-control feeNameClass" placeholder="Enter fees name">');
|
||
|
$('.multiple-fields-fees .form-control').each(function(index,ele) {
|
||
|
ele.value = '';
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const set_plan_id = function(ele) {
|
||
|
let id = $(ele).find(':selected').data('id');
|
||
|
$('#hostel_plan_id').val(id);
|
||
|
}
|
||
|
|
||
|
const set_transport_route_id = function(ele) {
|
||
|
let id = $(ele).find(':selected').data('id');
|
||
|
$('#route_id').val(id);
|
||
|
}
|
||
|
|
||
|
|
||
|
$(document).ready(function(){
|
||
|
|
||
|
if($('#checkBx').is(":checked")) {
|
||
|
$(".form-group-h").show();
|
||
|
$(".add-delete-btn").show();
|
||
|
} else {
|
||
|
$(".form-group-h").hide();
|
||
|
$(".add-delete-btn").hide();
|
||
|
}
|
||
|
|
||
|
$('.english-datepicker').attr('min', moment().format('YYYY-MM-DD'))
|
||
|
|
||
|
var mainInput = $(".cm-datepicker");
|
||
|
let NDate = NepaliFunctions.GetCurrentBsDate();
|
||
|
let todayDate = `${NDate.year}-${NDate.month}-${NDate.day}`;
|
||
|
|
||
|
mainInput.nepaliDatePicker({
|
||
|
disableBefore: todayDate,
|
||
|
language : 'english',
|
||
|
onChange: function(data) {
|
||
|
$('.nepali-datepicker').val(data.bs);
|
||
|
},
|
||
|
});
|
||
|
|
||
|
// *************************************************************************
|
||
|
|
||
|
<?php if($fees_id > 0) { ?>
|
||
|
if($('#feetype').val() == 3) {
|
||
|
$('#group-checkbox-id').hide();
|
||
|
$.ajax({
|
||
|
url : '<?php echo base_url() ?>' + 'admin/ajax_get_hostel_plans',
|
||
|
type : 'POST',
|
||
|
data : {
|
||
|
selected_plan : '<?= $selectedPlan ?>'
|
||
|
},
|
||
|
async : false,
|
||
|
success: function(data){
|
||
|
let feenameContainer = $('.fees-name-container');
|
||
|
feenameContainer.empty();
|
||
|
feenameContainer.append(data);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
if($('#feetype').val() == 4) {
|
||
|
$('#newdropdowns').empty();
|
||
|
$('#group-checkbox-id').hide();
|
||
|
let batch_id = $('#batch_id').val();
|
||
|
$.ajax({
|
||
|
url : '<?php echo base_url() ?>' + 'admin/ajax_get_transport_routes_new',
|
||
|
type : 'POST',
|
||
|
data : {
|
||
|
selected_plan : '<?= $selectedPlan ?>',
|
||
|
batch_id
|
||
|
},
|
||
|
async : false,
|
||
|
success: function(data){
|
||
|
|
||
|
$('#newdropdowns').append(data);
|
||
|
// let feenameContainer = $('.fees-name-container');
|
||
|
// feenameContainer.empty();
|
||
|
// feenameContainer.append();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
<?php } ?>
|
||
|
|
||
|
|
||
|
|
||
|
});
|
||
|
</script>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
const applyEnglishDate = (ele) => {
|
||
|
|
||
|
$('.english-datepicker').val(ele.value);
|
||
|
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
let clonedItems = [];
|
||
|
|
||
|
$('.nepali-datepicker').attr('readonly', 'readonly');
|
||
|
|
||
|
|
||
|
|
||
|
function valueChanged()
|
||
|
{
|
||
|
let notFirstChild = $('.multiple-fields-fees .form-group.form-group-div:not(:first-child)');
|
||
|
if($('#checkBx').is(":checked")){
|
||
|
$(".form-group-h").show();
|
||
|
$(".add-delete-btn").show();
|
||
|
|
||
|
|
||
|
if(notFirstChild.length > 0) {
|
||
|
$('.multiple-fields-fees').append(notFirstChild);
|
||
|
}
|
||
|
|
||
|
$('.english-datepicker').attr("disabled", true);
|
||
|
$('.nepali-datepicker').attr("disabled", true);
|
||
|
|
||
|
$('.eng-date').prop('disabled', false);
|
||
|
|
||
|
}else{
|
||
|
|
||
|
$('.english-datepicker').removeAttr('disabled');
|
||
|
$('.nepali-datepicker').removeAttr('disabled');
|
||
|
|
||
|
$('.english-datepicker').removeAttr('readonly');
|
||
|
$('.nepali-datepicker').removeAttr('readonly');
|
||
|
|
||
|
$(".form-group-h").hide();
|
||
|
$(".add-delete-btn").hide();
|
||
|
if(notFirstChild.length > 0) {
|
||
|
notFirstChild.remove();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
if($('#checkBx').is(":checked")) {
|
||
|
|
||
|
let updatedMultipleFields = $('.multiple-fields-fees .form-group.form-group-div');
|
||
|
|
||
|
$('.add-remove-btns').remove();
|
||
|
|
||
|
for (var i = updatedMultipleFields.length - 1; i >= 0; i--) {
|
||
|
|
||
|
if(i == 0 && (updatedMultipleFields.length == 1)) {
|
||
|
$(updatedMultipleFields[i]).append('<div class="form-div add-remove-btns"><button class="add-delete-btn" onclick="addExtraFields(this, event)" name="Add new Course" id="addBtn1">+</button></div>');
|
||
|
} else if(i == updatedMultipleFields.length - 1) {
|
||
|
|
||
|
$(updatedMultipleFields[i]).append('<div class="form-div add-remove-btns"><button class="add-delete-btn" onclick="addExtraFields(this, event)" name="Add new Course" id="addBtn1">+</button></div><div class="form-div add-remove-btns remove-btn"><button class="add-delete-btn" onclick="removeExtraField(this, event)" name="Add new Course" id="addBtn1">-</button></div>');
|
||
|
|
||
|
} else if (i == 0 ) {
|
||
|
$(updatedMultipleFields[i]).append('');
|
||
|
} else {
|
||
|
$(updatedMultipleFields[i]).append('<div class="form-div add-remove-btns remove-btn"><button class="add-delete-btn" onclick="removeExtraField(this, event)" name="Add new Course" id="addBtn1">-</button></div>');
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
// Add extra field
|
||
|
let count = 1;
|
||
|
let idCount = $('.multiple-fields-fees .form-group.form-group-div').length - 1;
|
||
|
function addExtraFields(ele,e){
|
||
|
e.preventDefault();
|
||
|
|
||
|
count = count + parseInt($(ele).parent().prev().find('input').attr('id'));
|
||
|
|
||
|
let extra = $(ele).parent().parent().clone();
|
||
|
|
||
|
$(extra).children('.remove-btn').remove();
|
||
|
$(extra).find('.feeAmountClass').val(null);
|
||
|
$(extra).find('.feeNameClass').val(null);
|
||
|
|
||
|
let newDatePicker = $(extra).find('.nepali-datepicker');
|
||
|
|
||
|
newDatePicker.attr('id', count);
|
||
|
|
||
|
extra.append('<div class="form-div add-remove-btns remove-btn"><button class="add-delete-btn" onclick="removeExtraField(this, event)" name="Add new Course" id="addBtn1">-</button></div>');
|
||
|
|
||
|
$('.multiple-fields-fees').append(extra);
|
||
|
|
||
|
let multipleFieldslength = $('.multiple-fields-fees .form-group.form-group-div').length;
|
||
|
let allinputs = $(extra).find('input');
|
||
|
let nameVal = '';
|
||
|
|
||
|
for(let i=0; i<allinputs.length; i++) {
|
||
|
if(multipleFieldslength == 2) {
|
||
|
idCount = 0;
|
||
|
nameVal = allinputs[i].name.replace('[0]', '['+(idCount + 1)+']')
|
||
|
} else {
|
||
|
nameVal = allinputs[i].name.replace('['+idCount+']', '['+(idCount + 1)+']')
|
||
|
}
|
||
|
allinputs[i].setAttribute('name', nameVal);
|
||
|
|
||
|
}
|
||
|
|
||
|
idCount++;
|
||
|
ele.remove();
|
||
|
|
||
|
}
|
||
|
|
||
|
function removeExtraField(ele, e) {
|
||
|
e.preventDefault();
|
||
|
|
||
|
let CurrentParent = $(ele).parent().parent();
|
||
|
let removedIndex = 0;
|
||
|
let multipleFields = $('.multiple-fields-fees .form-group.form-group-div');
|
||
|
|
||
|
for (var i = multipleFields.length - 1; i >= 0; i--) {
|
||
|
if(multipleFields[i] == CurrentParent[0]) {
|
||
|
removedIndex = i;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$(ele).parent().parent().remove();
|
||
|
|
||
|
let updatedMultipleFields = $('.multiple-fields-fees .form-group.form-group-div');
|
||
|
|
||
|
$('.add-remove-btns').remove();
|
||
|
|
||
|
for (var i = updatedMultipleFields.length - 1; i >= 0; i--) {
|
||
|
|
||
|
if(i == 0 && (updatedMultipleFields.length == 1)) {
|
||
|
$(updatedMultipleFields[i]).append('<div class="form-div add-remove-btns"><button class="add-delete-btn" onclick="addExtraFields(this, event)" name="Add new Course" id="addBtn1">+</button></div>');
|
||
|
} else if(i == updatedMultipleFields.length - 1) {
|
||
|
|
||
|
$(updatedMultipleFields[i]).append('<div class="form-div add-remove-btns"><button class="add-delete-btn" onclick="addExtraFields(this, event)" name="Add new Course" id="addBtn1">+</button></div><div class="form-div add-remove-btns remove-btn"><button class="add-delete-btn" onclick="removeExtraField(this, event)" name="Add new Course" id="addBtn1">-</button></div>');
|
||
|
|
||
|
} else if (i == 0 ) {
|
||
|
$(updatedMultipleFields[i]).append('');
|
||
|
} else {
|
||
|
$(updatedMultipleFields[i]).append('<div class="form-div add-remove-btns remove-btn"><button class="add-delete-btn" onclick="removeExtraField(this, event)" name="Add new Course" id="addBtn1">-</button></div>');
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<script>
|
||
|
|
||
|
|
||
|
$("#fee_form").validate({
|
||
|
ignore: ":hidden",
|
||
|
rules: {
|
||
|
batch_id: "required",
|
||
|
course_id : "required",
|
||
|
common_bs_due_date : "required",
|
||
|
common_ad_due_date : "required",
|
||
|
common_fee_name : "required",
|
||
|
feetype : "required",
|
||
|
<?php for($i = 0; $i < 20 ; $i++){
|
||
|
echo "'feename[$i]' : {
|
||
|
required : true,
|
||
|
},";
|
||
|
} ?>
|
||
|
<?php for($i = 0; $i < 20 ; $i++){
|
||
|
echo "'feeamount[$i]' : {
|
||
|
required : true,
|
||
|
digits : true
|
||
|
},";
|
||
|
} ?>
|
||
|
<?php for($i = 0; $i < 20 ; $i++){?>
|
||
|
'bsdate[<?php echo $i ?>]' : "required",
|
||
|
'englishdate[<?php echo $i ?>]' : "required",
|
||
|
<?php } ?>
|
||
|
|
||
|
},
|
||
|
messages: {
|
||
|
course_id : "Please select a course id",
|
||
|
batch_id : "Please select a batch id",
|
||
|
common_ad_due_date : "Please select a date",
|
||
|
common_bs_due_date : "Please select a date",
|
||
|
common_fee_name : "Please provide a common fee name",
|
||
|
feetype : "Please select a fee type",
|
||
|
<?php for($i = 0; $i < 20 ; $i++){
|
||
|
echo "'feename[$i]' : {
|
||
|
required : 'Please provide a fee name',
|
||
|
},";
|
||
|
} ?>
|
||
|
<?php for($i = 0; $i < 20 ; $i++){
|
||
|
echo "'feeamount[$i]' : {
|
||
|
required : 'Please provide a fee amount',
|
||
|
},";
|
||
|
} ?>
|
||
|
<?php for($i = 0; $i < 20 ; $i++){?>
|
||
|
'bsdate[<?php echo $i ?>]' : "Please select a date",
|
||
|
'englishdate[<?php echo $i ?>]' : "Please select a date",
|
||
|
<?php } ?>
|
||
|
|
||
|
},
|
||
|
submitHandler: function(form,e) {
|
||
|
e.preventDefault();
|
||
|
fee_type_id = $('#feetype').val()
|
||
|
let flag = false;
|
||
|
$('#Nameerr').hide();
|
||
|
$('#dublicateErr').hide();
|
||
|
|
||
|
if(fee_type_id != 1 && fee_type_id != 2 ) { // Non-Unique Validation
|
||
|
|
||
|
let feeVal = [];
|
||
|
$('.feeNameClass').each(function(index,ele) {
|
||
|
let val = ele.value.toLowerCase();
|
||
|
feeVal.push(val);
|
||
|
})
|
||
|
|
||
|
let inputDataArr = {
|
||
|
id : <?= $fees_id ?>,
|
||
|
batch_id : $('#batch_id').val(),
|
||
|
course_id : $('#course_id').val(),
|
||
|
fee_type : $('#feetype').val(),
|
||
|
fee_names : feeVal
|
||
|
}
|
||
|
|
||
|
let inputValue = JSON.stringify(inputDataArr);
|
||
|
|
||
|
$.ajax({
|
||
|
url : '<?php echo base_url() ?>' + 'admin/ajax_check_fee_names',
|
||
|
data : {
|
||
|
info : inputValue,
|
||
|
},
|
||
|
type : 'POST',
|
||
|
async : false,
|
||
|
success: function(data){
|
||
|
console.log(data);
|
||
|
if(data){
|
||
|
flag = true
|
||
|
} else {
|
||
|
$('#dublicateErr').show();
|
||
|
$('#dublicateErr').text('provided fee names have been used with the same batch,course and feetype id. Please change atleast 1 name');
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
} else { // Unique Validation
|
||
|
|
||
|
let inputDataArr = {
|
||
|
id : <?= $fees_id ?>,
|
||
|
batch_id : $('#batch_id').val(),
|
||
|
course_id : $('#course_id').val(),
|
||
|
fee_type : $('#feetype').val(),
|
||
|
}
|
||
|
console.log(inputDataArr);
|
||
|
let inputValue = JSON.stringify(inputDataArr);
|
||
|
|
||
|
$.ajax({
|
||
|
url : '<?php echo base_url() ?>' + 'admin/ajax_validate_fee_type',
|
||
|
data : {
|
||
|
info : inputValue,
|
||
|
},
|
||
|
type : 'POST',
|
||
|
async : false,
|
||
|
success: function(data){
|
||
|
console.log(data);
|
||
|
if(data == 'success'){
|
||
|
flag = true
|
||
|
} else {
|
||
|
$('#dublicateErr').show();
|
||
|
$('#dublicateErr').text('Application Fee and Course Fee cannot be created twice for the same batch,course,feetype combination');
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
if(flag) {
|
||
|
form.submit();
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
</script>
|
||
|
<script>
|
||
|
$('#cal_language').change(function() {
|
||
|
|
||
|
$('.english-datepicker').hide();
|
||
|
$('.nepali-datepicker').hide();
|
||
|
$('.cm-datepicker').hide();
|
||
|
|
||
|
|
||
|
if($(this).prop('checked')) {
|
||
|
$('.nepali-datepicker').show();
|
||
|
$('.cm-datepicker').show();
|
||
|
} else {
|
||
|
$('.english-datepicker').show();
|
||
|
}
|
||
|
})
|
||
|
</script>
|
||
|
|
||
|
|