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

222 lines
11 KiB
PHP

<div class="wraper responsive-width">
<main class="" id="main">
<div class="from-group adding-class form-group_lng" style="justify-content: end;">
<a href="<?= base_url(); ?>admin/add-edit-teacher/0"><button type="button" class="btn btn-success btn-sm">Add Teacher</button></a>
</div>
<?php
if (!empty($this->session->flashdata('success_msg'))) { ?>
<div class="alert alert-success" style="width:100%">
<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" style="width:100%">
<a href="#" class="close" data-dismiss="alert">&times;</a>
<strong>Failed!</strong> <?php echo $this->session->flashdata('error_msg'); ?>
</div>
<?php } ?>
<div id="fadeIn" class="mt-2 mb-1" style="width:100%">
</div>
<div class="admin_tempblock">
<div class="admin_tempsec">
<div class="admin_sec">
<div class="subsec_sec">
<div class="subject_r subject_r_lng">
<div class="subject_lsec teachers_list_table">
<div class="subject_lhead">Teacher List <p id="success" style="color:green;"></p>
</div>
<form method="post" id="downloadAll" action="<?php echo base_url(); ?>Admin/downloadAllteachers">
<!-- <div class="view_del-subjects"><a href="<?= base_url(); ?>admin/teacher_deleted">View Deleted Items</a></div> -->
<table id="tbl" class="display table-responsive">
<thead>
<tr>
<th><input type="checkbox" id="chkParent" /></th>
<th>S.No.</th>
<th>Profile</th>
<th>Teacher Id</th>
<th>Designation</th>
<th>Name</th>
<th>Email</th>
<th>Mobile</th>
<th>Address</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $i = 1;
foreach ($teacher as $teach) {
?>
<tr>
<td><input type="checkbox" name="teacher_id_list[]" value="<?= $teach['id'] ?>" /></td>
<td><?= $i; ?></td>
<td><img src="<?= $teach['profile_pic'] ?>" alt="Profile Picture" class="img-fluid img-thumbnail rounded-circle" width="100px;" height="80px;"></td>
<td class="text-capitalize text-left"><?= $teach['teacherId']; ?></td>
<td class="text-left">
<?php
$desig = '';
foreach ($hr_designation as $desKey => $designation) {
if ($designation['id'] == $teach['designation']) {
$desig = $designation['title'];
}
}
?>
<?= !empty($desig) ? $desig : '-' ?>
</td>
<td class="text-left"><?= $teach['teacher_name']; ?></td>
<td class="text-left">
<div class="email-width" title="<?= $teach['email']; ?>"><?= $teach['email']; ?></div>
</td>
<td><?= $teach['mobile']; ?></td>
<td class="text-left">
<div class="address-width"><?= $teach['address']; ?></div>
</td>
<td class="text-left">
<div class="sub_tabbtnsec">
<a href="<?php echo base_url(); ?>admin/view-teacher/<?php echo $teach['id']; ?>" data-toggle="tooltip" title="View">
<div class="sub_viewbtn"><i class="fas fa-eye"></i></div>
</a>
<a href="<?php echo base_url(); ?>admin/add-edit-teacher/<?php echo $teach['id']; ?>" data-toggle="tooltip" title="Edit">
<div class="sub_editbtn"><i class="fas fa-pencil-alt"></i></div>
</a>
<a data-toggle="modal" onclick="teachdel(<?php echo $teach['id']; ?>)" href="#deleteModal">
<div class="sub_delbtn">
<i class="fa fa-trash" aria-hidden="true"></i>
</div>
</a>
</div>
</td>
</tr>
<?php $i++;
} ?>
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
<div class="viewDoc delete-modal-wrap">
<div class="modal fade" id="deleteModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<div class="delete-modal">
<i class="far fa-times-circle"></i>
<input type="hidden" id="thid" />
<h4>Are you sure ?</h4>
<p> Are you sure you want to delete ? </p>
<div class="delete-modal-btn">
<button type="button" class="subject_addbtn subject_addbtn_red" onclick="deletedata($('#thid').val(), 'teacher');">Delete</button>
<button type="button" class="subject_addbtn subject_addbtn_cancel" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
//table js
$('#tbl').DataTable({
"lengthMenu": [
[25, 50, 100, 150, -1],
[25, 50, 100, 150, "All"]
],
dom: 'lBfrtip',
buttons: [{
extend: 'pdfHtml5',
exportOptions: {
columns: [1, 3, 4, 5]
}
},
{
extend: 'csvHtml5',
exportOptions: {
columns: [1, 3, 4, 5]
}
}
],
});
//table js end
});
</script>
<script type="text/javascript">
function teachdel(icn) {
//alert(icn);
$('#thid').val(icn);
}
function deletedata(id, table) {
$(".alert-dismissible").hide();
$.ajax({
type: 'POST',
url: "<?php echo base_url(); ?>Admin/delete_data",
data: {
id: id,
table: table
},
success: function(resposne) {
if (resposne == '1') {
window.location.href = "<?php echo base_url(); ?>Admin/teacher/1";
} else if (resposne == '0') {
$('#deleteModal').modal('hide');
$('#fadeIn').css('display', 'block');
$('#fadeIn').append('<div class="alert alert-danger alert-dismissible" role="alert" ><p>Teacher cannot be deleted as he/She is assign to Classroom</p><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>');
}
}
});
}
$(document).ready(function() {
$('#chkParent').click(function() {
var isChecked = $(this).prop("checked");
$('#tbl tr:has(td)').find('input[type="checkbox"]').prop('checked', isChecked);
});
$('#tbl 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 {
$('#tbl tr:has(td)').find('input[type="checkbox"]').each(function() {
if ($(this).prop("checked") == false)
isChecked = false;
});
console.log(isChecked);
$("#chkParent").prop('checked', isChecked);
}
});
});
$(document).on('click', '.download_idcards', function() {
var studentidlist = [];
$.each($("input[name='teacher_id_list[]']:checked"), function() {
var item = $(this).data('studentid');
studentidlist.push(item);
});
if (studentidlist.length === 0) {
alert("Please Select Teachers");
} else {
$('#downloadAll').submit();
}
});
</script>