BBnepal-Accounts/application/views/admin/assign_registration_number.php

226 lines
9.7 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<style>
.displaydata {
width: 100% !important;
}
.subject_addbtn {
background: #032da1;
border-radius: 3px;
color: #fff;
padding: 3px 38px;
border: none;
font-size: 16px;
cursor: pointer;
}
</style>
<div class="wraper responsive-width">
<main class="long-tbl-main" id="main">
<div class="displaydata pt-5 form-group_lng" style="display:flex">
<div class="col-md-6 pull-left" style="padding:0">
<a href="<?= base_url(); ?>admin/assign-students/<?php echo $classroomid ?>" class="pull-left"><button type="button" class="btn subject_addbtn bg-dark">Back</button></a>
</div>
</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">
<div class="subject_lhead"><?php echo $title; ?> <p id="success" style="color:green;"></p>
</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="view_del-subjects"><a href="<?= base_url(); ?>admin/classroom_deleted">View Deleted Items</a></div>-->
<table id="tbl" class="display table-responsive">
<thead>
<tr>
<th>S.No.</th>
<th>Student Id</th>
<th>Photo</th>
<th>Name</th>
<th>Batch</th>
<th>Registration No.</th>
</tr>
</thead>
<tbody>
<?php
$sno = 1;
// echo "<pre>";
// print_r($student_list);
// die();
foreach ($student_list as $student) {
if (empty($student['photo'])) {
$profile_path = base_url() . "common_assets/user.png";
} else if (file_exists('assets_student/application/' . $student['photo'])) {
$profile_path = base_url() . "assets_student/application/" . $student['photo'];
} else {
if ($student['gender'] == 'Male' || $student['gender'] == 'male')
$profile_path = base_url() . "common_assets/male_image.jpg";
else
$profile_path = base_url() . "common_assets/female_image.jpg";
}
?>
<tr>
<td><?= $sno; ?></td>
<td class="text-left"><?= $student['studentId']; ?></td>
<td> <img src="<?= $profile_path; ?>" class="student_img_list" /></td>
<td class="text-left"><?= $student['name']; ?></td>
<td>
<?php
$batch = $this->db->get_where('batch', array('id' => $student['student_batch']))->row_array();
echo $batch['b_name'];
?>
</td>
<td>
<input type="text" class="form-control w-100 m-auto text-center rolls" onchange="check_data(this)" name="registration_no[]" value="<?= $student['registration_no']; ?>" max="3">
<input type="hidden" class="form-control w-100 m-auto text-center" name="student_batchid[]" value="<?= $student['stud_batch_id']; ?>">
</td>
</tr>
<?php $sno++;
}
?>
</tbody>
<tfoot>
<tr>
<th colspan="5"></th>
<th>
<div class="float-right w-100">
<button class="btn btn-md btn-info w-100 update_roll">Update Registration No</button>
</div>
</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
<form method="post" id="update_rollNumber" action="<?php echo base_url('admin/registration-number/' . $encrepted_clas); ?>">
<input type="hidden" name="registration_numbers" class="registration_numbers">
<input type="hidden" name="batch_ids" class="batch_id">
</form>
</div>
</div>
</main>
</div>
<script>
// $('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='text']");
// 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();
// }
// });
$(document).ready(function() {
//table js
$('#tbl').DataTable({
"lengthMenu": [
[-1],
["All"]
],
paging: false,
info: false
});
//table js end
});
function check_data(data) {
var $regexname = /^([0-9]{1,3})$/;
// if (!data.value.match($regexname)) {
// data.value = data.defaultValue;
// alert("Please Enter only Positive number or Length should be 3");
// return false;
// }
// if (data.value == 0) {
// data.value = data.defaultValue;
// alert("Zero should not be Enter");
// return false;
// }
}
$('.update_roll').on('click', function() {
let arr = [];
let batch = [];
var registration_no = $("input[name='registration_no[]']")
.each(function() {
arr.push($(this).val());
});
$("input[name='student_batchid[]']")
.each(function() {
batch.push($(this).val());
});
arr = arr.filter(function(e) {
return e
});
const toFindDuplicates = arr => arr.filter((item, index) => arr.indexOf(item) !== index);
let duplicateElementa = toFindDuplicates(arr);
if (duplicateElementa.length > 0) {
alert(' You have dublicate elements ' + duplicateElementa.toString());
return;
} else {
// console.log(arr);
$('.registration_numbers').val(arr);
$('.batch_id').val(batch);
$('#update_rollNumber').submit();
}
});
</script>
<script type="text/javascript">
$(document).ready(function() {
// show the alert
setTimeout(function() {
$(".alert").alert('close');
<?php unset($_SESSION['success_msg']); ?>
<?php unset($_SESSION['error_msg']); ?>
}, 15000);
});
</script>