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

513 lines
26 KiB
PHP

<style>
form label.error,
#secNameerr,
.error {
color: red;
}
.cierr {
font-size: 14px;
}
</style>
<div class="wraper responsive-width">
<main class="" id="main">
<!-- admin template section -->
<div class="main-wrap">
<div class="dashboard-cover">
<div class="admin_sec">
<div class="common-heading">
<h2>Promotions</h2>
</div>
<?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">&times;</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">&times;</span>
</button>
</div>
<?php } ?>
<div class="subsec_sec">
<div class="subject_r">
<div class="subject_lsec">
<!-- tab added -->
<form method="post" action="<?php base_url('admin/studentPromosionView') ?>" id="serach_student">
<?php
$courseId = (isset($courseId) && !empty($courseId)) ? $courseId : '';
//$batchId = (isset($batchId) && !empty($batchId)) ? $batchId : '';
$batchId = '';
if (isset($batchId) && $batchId != '')
$batchId = $batchId;
$sectionId = (isset($sectionId) && !empty($sectionId)) ? $sectionId : '';
?>
<div class="top-filter">
<div class="filter_lbl">
<i class="fas fa-filter"></i>
Filter
</div>
<div class="subject-filter">
<select id="batch" class="form-control" placeholder="Select Course" name="filter-batch">
<option value=""> Select Batch </option>
<?php
foreach ($batch as $key => $value) { ?>
<option value="<?php echo $value['id'] ?>" <?php echo ($batchId == $value['id']) ? 'selected' : '' ?>>
<?php echo $value['b_name']; ?>
</option>
<?php }
?>
</select>
<div class="text-danger cierr"><?php echo form_error('filter-batch'); ?></div>
</div>
<div class="subject-filter">
<select id="course" class="form-control" placeholder="Select Course" name="filter-course">
<option value=""> Select Course</option>
<?php
foreach ($course as $row) { ?>
<option value="<?php echo $row['id'] ?>" <?php echo ($courseId == $row['id']) ? 'selected' : '' ?>> <?php echo $row['course_name']; ?></option>
<?php }
?>
</select>
<div class="text-danger cierr"><?php echo form_error('filter-course'); ?></div>
</div>
<div class="subject-filter">
<select id="section" class="form-control" placeholder="Select Course" name="filter-section">
<option value=""> --- Select Section --- </option>
</select>
<div class="text-danger cierr"><?php echo form_error('filter-section'); ?></div>
</div>
<div class="filter-reset">
<input type="submit" name="filterSubmit" id="filter_reset" class="btn " value="Search" style="background: #032DA1 0% 0% no-repeat padding-box;color: #fff;">
<a href="<?php echo base_url(); ?>admin/studentPromosionView"><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>
</form>
<form method="post" id="downloadAll" action="<?php echo base_url(); ?>admin/promote-student">
<div class="subject_lhead">Promote Students To Different Batch</div>
<div class="top-filter">
<div class="filter_lbl">
<i class="fas fa-filter"></i>
Filter
</div>
<div class="subject-filter">
<select id="select_batch" class="form-control" placeholder="Select Course" name="select-batch">
<option value=""> Select Batch </option>
<?php
foreach ($batch as $key => $value) { ?>
<option value="<?php echo $value['id'] ?>">
<?php echo $value['b_name']; ?>
</option>
<?php }
?>
</select>
<label class="error batch-error d-none"></label>
</div>
<div class="subject-filter">
<select id="select_course" class="form-control" placeholder="Select Course" name="select-course">
<option value=""> Select Course</option>
<?php
foreach ($course as $row) { ?>
<option value="<?php echo $row['id'] ?>"> <?php echo $row['course_name']; ?></option>
<?php }
?>
</select>
<label class="error course-error d-none"></label>
</div>
<div class="subject-filter">
<select id="select_section" class="form-control" placeholder="Select Course" name="select-section">
<option value="0"> --- Select Section --- </option>
</select>
<label class="error section-error d-none"></label>
</div>
<div class="filter-reset">
<button class="btn btn-success" id="download_idcards">Promote</button>
</div>
</div>
<?php if (isset($promoted_students) && !empty($promoted_students)) { ?>
<script>
$(document).ready(function() {
$("#confirmModal").modal({
backdrop: 'static',
keyboard: false
});
});
</script>
<style type="text/css">
.reload .fa-undo:hover {
color: green !important;
}
</style>
<!-- Modal -->
<div class="modal fade " id="confirmModal" role="dialog">
<div class="modal-dialog modal-dialog-centered" style="max-width:70% !important">
<div class="modal-content bg-light">
<div class="modal-header" style="border-bottom: none;">
<h5 class="modal-title" id="exampleModalLongTitle">Promoted Student List</h5>
<!-- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button> -->
</div>
<div class="model-body">
<div class="container">
<div class="row justify-content-md-center">
<div class="col-md-12">
<table class="table" id="drop_list_student">
<thead>
<tr>
<th>SI No</th>
<th>Student ID</th>
<th>Student Name</th>
<th>Course Name</th>
<th>Section Name</th>
<th>Batch Name</th>
<th>Action</th>
</tr>
</thead>
<tbody class="list_drop">
<?php $i = 1;
foreach ($promoted_students as $key => $val) { ?>
<tr>
<td><?php echo $i++; ?> <input type="hidden" name="studentBatch_id" class="sb_id" value="<?php echo $val['sb_id']; ?>"></td>
<td><?php echo $val['student_id'] ?></td>
<td class="student_name"><?php echo $val['student_name'] ?></td>
<td><?php echo $val['course_name'] ?></td>
<td><?php echo $val['section_name'] ?></td>
<td><?php echo $val['batch_name'] ?></td>
<td>
<!-- <div class="reload" title="reload" onclick="get_batch_id(<?php echo $val['sb_id']; ?>)">
<i class="fa fa-undo" aria-hidden="true" style="color:red;font-size: 15px;font-weight: bold;"></i>
</div> -->
<div class="btnReload" title="reload">
<i class="fa fa-undo" aria-hidden="true" style="color:red;font-size: 15px;font-weight: bold;"></i>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="failed_define"></div>
<a href="<?php echo base_url(); ?>admin/studentPromosionView" class="btn btn-success float-right mb-3">
Final Submit
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
<?php if (isset($students) && !empty($students)) { ?>
<div class="applicnts-list-wrap ">
<div class="">
<table id="tbl1" class="display table-responsive">
<thead>
<tr>
<th>
<input type="checkbox" id="chkParent" />
</th>
<th>Student Id</th>
<th>Name of Student</th>
<th>course name</th>
<th>section name</th>
</tr>
</thead>
<tbody>
<?php foreach ($students as $key => $value) { ?>
<tr>
<td>
<input type='checkbox' name='student_id_list[]' value="<?php echo $value['id']; ?>" />
</td>
<td><?php echo $value['studentId'] ?></td>
<td><?php echo $value['name'] ?></td>
<td><?php echo $value['course_name'] ?></td>
<td><?php echo $value['section_name'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<?php } else { ?>
<div class="subject_lhead">No Data Found</div>
<?php } ?>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- admin template section end -->
</main>
<!--End right-top side-->
</div>
<script>
$(document).ready(function() {
$('.user-drpdown').click(function() {
$('.drpdown-items').toggle();
});
//table js
$('#tbl1').DataTable({
"lengthMenu": [
[-1],
["All"]
],
dom: 'lBfrtip',
buttons: [{
extend: 'pdfHtml5',
title: 'Student List',
exportOptions: {
columns: [1, 3, 4, 5, 6, 7]
}
},
{
extend: 'csvHtml5',
exportOptions: {
columns: [1, 3, 4, 5, 6, 7]
}
}
]
});
//table js end
//multiple select js start
// $('select').selectpicker();
//multiple select js end
});
var course_id = <?php echo ($courseId) ? $courseId : 0; ?>;
var sectionId = <?php echo ($sectionId) ? $sectionId : 0; ?>;
if (course_id != 0 && sectionId != 0) {
var id = $('#course').find(":selected").val();
$.ajax({
url: '<?php echo base_url() . 'admin/get_sections_from_classroom/' ?>' + id,
type: 'GET',
dataType: 'json',
success: function(result) {
let section = '';
section += '<option value=""> --- Select Section --- </option>';
$.each(result, function(key, value) {
if (sectionId == value['id']) {
section += '<option value="' + value['id'] + '" selected>' + value['section_name'] + '</option>';
} else {
section += '<option value="' + value['id'] + '" >' + value['section_name'] + '</option>';
}
});
$("#section").html(section);
}
});
}
$('#chkParent').click(function() {
var isChecked = $(this).prop("checked");
$('#tbl1 tr:has(td)').find('input[type="checkbox"]').prop('checked', isChecked);
});
$('#tbl1 tr:has(td)').find('input[type="checkbox"]').click(function() {
var isChecked = $(this).prop("checked");
var isHeaderChecked = $("#chkParent").prop("checked");
if (isChecked == false && isHeaderChecked)
$("#chkParent").prop('checked', isChecked);
else {
$('#tbl1 tr:has(td)').find('input[type="checkbox"]').each(function() {
if ($(this).prop("checked") == false)
isChecked = false;
});
console.log(isChecked);
$("#chkParent").prop('checked', isChecked);
}
});
$('#course').change(function() {
var id = $('#course').find(":selected").val();
$.ajax({
url: '<?php echo base_url() . 'admin/get_sections_from_course_id/' ?>' + id,
type: 'GET',
dataType: 'json',
success: function(result) {
let section = '';
section += '<option value=""> --- Select Section --- </option>';
$.each(result, function(key, value) {
section += '<option value="' + value['id'] + '">' + value['section_name'] + '</option>';
});
$("#section").html(section);
}
});
});
$('#select_course').change(function() {
var id = $('#select_course').find(":selected").val();
$.ajax({
url: '<?php echo base_url() . 'admin/get_sections_from_course_id/' ?>' + id,
type: 'GET',
dataType: 'json',
success: function(result) {
let section = '';
section += '<option value=""> --- Select Section --- </option>';
$.each(result, function(key, value) {
section += '<option value="' + value['id'] + '">' + value['section_name'] + '</option>';
});
$("#select_section").html(section);
}
});
});
$(document).on('click', '#download_idcards', function(e) {
var counter = 0;
var batch_id = $('#select_batch').find(":selected").val();
var course_id = $('#select_course').find(":selected").val();
var section_id = $('#select_section').find(":selected").val();
var from_batch_id = $('#batch').find(":selected").val();
if (batch_id == null || batch_id == undefined || batch_id == '') {
counter++;
$('.batch-error').removeClass('d-none');
$('.batch-error').css('display', 'block !important');
$('.batch-error').text('Please select the batch');
} else {
if (from_batch_id != '' && batch_id != '' && from_batch_id == batch_id) {
counter++;
$('.batch-error').removeClass('d-none');
$('.batch-error').css('display', 'block !important');
$('.batch-error').text('Students can not be promoted to the same batch.');
} else {
$('.batch-error').text('');
$('.batch-error').addClass('d-none')
}
}
if (course_id == null || course_id == undefined || course_id == '') {
counter++;
$('.course-error').removeClass('d-none');
$('.course-error').text('Please select the course');
$('.course-error').css('display', 'block !important');
} else {
$('.course-error').addClass('d-none');
$('.course-error').text('');
}
if (section_id == null || section_id == undefined || section_id == '') {
counter++;
$('.section-error').removeClass('d-none');
$('.section-error').css('display', 'block !important');
$('.section-error').text('Please select the section');
} else {
$('.section-error').addClass('d-none');
$('.section-error').text('');
}
if (counter == 0) {
var studentidlist = [];
$.each($("input[name='student_id_list[]']:checked"), function() {
var item = $(this).data('studentid');
studentidlist.push(item);
});
if (studentidlist.length === 0) {
alert("Please Select Students");
e.preventDefault(e);
} else {
$('#downloadAll').submit();
}
} else {
e.preventDefault(e);
}
});
$('#drop_list_student').on('click', '.btnReload', function() {
let currentTr = $(this).parent().parent();
var student_batch = $(this).parent().siblings().children('.sb_id');
// console.log($(student_batch).val());
var id = $(student_batch).val();
// $(currentTr).remove();
$.ajax({
url: '<?php echo base_url() ?>admin/deltePromotedStudentByBatch',
type: 'post',
data: {
id
},
success: function(result) {
console.log(result);
if (result == 'success') {
// location.reload();
$(currentTr).remove();
} else {
var failed_msg = '<div class="alert alert-danger alert-dismissible fade show" role="alert"><p>Cant Remove this table</p><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>';
$('.failed_define').html(failed_msg);
}
}
});
});
</script>
</body>
</html>