442 lines
20 KiB
PHP
442 lines
20 KiB
PHP
|
<link rel="stylesheet" href="<?php echo base_url(); ?>assets_admin/css/bootstrap-select.css">
|
||
|
<style>
|
||
|
.error {
|
||
|
color: red;
|
||
|
padding-top: 2px;
|
||
|
}
|
||
|
|
||
|
.form-group.form-group-iconselect {
|
||
|
position: relative;
|
||
|
margin: 0px 0px 25px 0px;
|
||
|
}
|
||
|
|
||
|
label#subject_icon-error {
|
||
|
position: absolute;
|
||
|
bottom: -25px;
|
||
|
}
|
||
|
</style>
|
||
|
<div class="wraper responsive-width">
|
||
|
<main class="" id="main">
|
||
|
|
||
|
<div class="admin_tempblock">
|
||
|
<div class="admin_tempsec">
|
||
|
<div class="admin_sec">
|
||
|
<div class="from-group adding-class form-group_lng"><!-- Button trigger modal -->
|
||
|
<button type="button" class="btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#exampleModal">
|
||
|
Assign Teacher
|
||
|
</button>
|
||
|
<a href="<?= base_url(); ?>admin/assign-class-teacher/<?= $id ?>" class="ml-2">
|
||
|
<button type="button" class="btn btn-sm btn-outline-primary">Assign Class Teacher</button>
|
||
|
</a>
|
||
|
</div>
|
||
|
<!-- Modal -->
|
||
|
|
||
|
<?php
|
||
|
if (!empty($this->session->flashdata('success'))) { ?>
|
||
|
<div class="alert alert-success">
|
||
|
<a href="#" class="close" data-dismiss="alert">×</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">×</a>
|
||
|
<strong>Failed!</strong> <?php echo $this->session->flashdata('error'); ?>
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
<div class="subsec_sec">
|
||
|
<div class="subject_l subject_l_full_width">
|
||
|
<div class="subject_lsec">
|
||
|
ufdhsXAJKZLM
|
||
|
<div class="subject_lhead"><?php echo $title; ?></div>
|
||
|
|
||
|
|
||
|
<?php
|
||
|
$classroom_name = (isset($classroom['classroom_name'])) ? $classroom['classroom_name'] : '';
|
||
|
$course_id = (isset($classroom['course_id'])) ? $classroom['course_id'] : '';
|
||
|
$section_id = (isset($classroom['section_id'])) ? $classroom['section_id'] : '';
|
||
|
$is_active = (isset($classroom['is_active'])) ? $classroom['is_active'] : '';
|
||
|
$action_url = base_url() . 'admin/ae-classroom/' . $id;
|
||
|
|
||
|
// echo '<pre>';
|
||
|
// print_r($subjects_teacher);
|
||
|
|
||
|
?>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<form id="classroomfrom" method="post" action="<?= $action_url; ?>">
|
||
|
|
||
|
<div class="form-group assign_subject">
|
||
|
<label>Course <span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="course_id" id="course_id" class="selectpicker" data-live-search="true">
|
||
|
<option value="" data-course_name="">-- Select Option --</option>
|
||
|
<?php foreach ($courselist as $c_value) {
|
||
|
|
||
|
$selected = ($course_id == $c_value['id']) ? "selected" : "";
|
||
|
?>
|
||
|
<option value="<?= $c_value['id']; ?>" <?= $selected; ?> data-course_name="<?= $c_value['course_name']; ?>"><?= $c_value['course_name']; ?></option>
|
||
|
<?php
|
||
|
} ?>
|
||
|
</select>
|
||
|
<label id="course_id-error" class="error" for="course_id"></label>
|
||
|
</div>
|
||
|
|
||
|
<div class="form-group assign_subject">
|
||
|
<label>Section <span class="text-danger font-weight-bold">*</span></label>
|
||
|
<?php if ($id == 0) {
|
||
|
?>
|
||
|
<select name="section_id" id="section_id" class="selectpicker" data-live-search="true">
|
||
|
<option value="" data-section_name="">-- Select Option --</option>
|
||
|
|
||
|
</select>
|
||
|
<?php
|
||
|
} else {
|
||
|
?>
|
||
|
<select name="section_id" id="section_id" class="selectpicker" data-live-search="true">
|
||
|
<option value="" data-section_name="">-- Select Option --</option>
|
||
|
<?php foreach ($sectionlist as $s_value) {
|
||
|
$selected = ($section_id == $s_value['sectionId']) ? "selected" : "";
|
||
|
?>
|
||
|
<option value="<?= $s_value['sectionId']; ?>" <?= $selected; ?> data-section_name="<?= $s_value['section_name']; ?>"><?= $s_value['section_name']; ?></option>
|
||
|
<?php
|
||
|
} ?>
|
||
|
</select>
|
||
|
<?php } ?>
|
||
|
<label id="section_id-error" class="error" for="section_id"></label>
|
||
|
</div>
|
||
|
|
||
|
<div class="subject_lformarea">
|
||
|
<div class="form-group">
|
||
|
<label for="">Classroom Name <span class="text-danger font-weight-bold">*</span></label>
|
||
|
<input type="text" name="classroom_name" id="classroom_name" class="form-control" value="<?= $classroom_name; ?>" placeholder="Enter classroom name" readonly>
|
||
|
<label id="classroomerror" class="error" style="display : none"></label>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<?php
|
||
|
if ($id == 0) {
|
||
|
?>
|
||
|
<div class="form-group" id="subject_section">
|
||
|
|
||
|
</div>
|
||
|
<?php
|
||
|
}
|
||
|
?>
|
||
|
|
||
|
<div class="form-group">
|
||
|
<label for="">Status <span class="text-danger font-weight-bold">*</span></label>
|
||
|
<?php
|
||
|
|
||
|
$active_list = array('yes', 'no');
|
||
|
?>
|
||
|
<select name="is_active" id="is_active" class="form-control">
|
||
|
<option value="">-- Select Option --</option>
|
||
|
<?php foreach ($active_list as $avlue) {
|
||
|
$selected = ($is_active == $avlue) ? "selected" : "";
|
||
|
?>
|
||
|
<option <?= $avlue ?> <?= $selected ?>><?= $avlue ?></option>
|
||
|
<?php } ?>
|
||
|
</select>
|
||
|
<label id="is_active-error" class="error" for="is_active"></label>
|
||
|
</div>
|
||
|
|
||
|
<!-- updated start -->
|
||
|
|
||
|
|
||
|
<?php if ($id > 0) { ?>
|
||
|
<label for="" class="subject-label"> Subject and Teacher</label>
|
||
|
<?php
|
||
|
foreach ($course_subjects as $cs_value) {
|
||
|
$SubjectName = $this->db->get_where('subject', array('id' => $cs_value['course_subject_ids']))->row()->subject_name;
|
||
|
$SubjectTeachers_list = $this->Admin_model->get_general_result_details('teacher_subjects', 'ASC', array('subject_id' => $cs_value['course_subject_ids']));
|
||
|
|
||
|
?>
|
||
|
<div class="subject-flex">
|
||
|
<div class="form-group ">
|
||
|
|
||
|
<input type="hidden" name="subject_id[]" class="form-control" value="<?php echo $cs_value['course_subject_ids'] ?>">
|
||
|
<input type="text" class="form-control" value="<?php echo (!empty($SubjectName)) ? $SubjectName : "No Subject Found"; ?>" readonly>
|
||
|
</div>
|
||
|
<div class="form-group subject-select">
|
||
|
<select name="teacher_id[]" id="" class="form-control subjects">
|
||
|
<?php
|
||
|
echo '<option value="" data-course_name="">-- Select Option --</option>';
|
||
|
foreach ($SubjectTeachers_list as $stl_value) {
|
||
|
$TeacherSelected = ($stl_value['teacher_id'] == $cs_value['teacher_id']) ? "selected" : "";
|
||
|
?>
|
||
|
<option value="<?php echo $stl_value['teacher_id']; ?>" <?= $TeacherSelected; ?>>
|
||
|
<?php
|
||
|
// echo $value['teacher_id'];
|
||
|
echo $TeacherName = $this->db->get_where('teacher', array('id' => $stl_value['teacher_id']))->row()->teacher_name;
|
||
|
?>
|
||
|
</option>
|
||
|
<?php
|
||
|
}
|
||
|
?>
|
||
|
</select>
|
||
|
</div>
|
||
|
<!-- <div class="p-2">
|
||
|
<?php
|
||
|
$classTeacherChecked = '';
|
||
|
|
||
|
if ($cs_value['is_class_teacher'] == 'yes') {
|
||
|
$classTeacherChecked = 'Class Teacher';
|
||
|
|
||
|
echo 'Class Teacher';
|
||
|
}
|
||
|
// print_r($cs_value);
|
||
|
?>
|
||
|
<label></label>
|
||
|
|
||
|
</div> -->
|
||
|
</div>
|
||
|
<?php
|
||
|
}
|
||
|
} ?>
|
||
|
<!-- <input type="text" id="classSubject" name="classSubject" class="col-md-12" /> -->
|
||
|
|
||
|
<!-- updated end -->
|
||
|
|
||
|
|
||
|
<button type="submit" class="subject_addbtn"><?php echo $btnvalue = ($id > 0) ? 'Update' : 'Add'; ?></button>
|
||
|
<a href="<?= base_url(); ?>admin/classroom"><button type="button" class=" ml-2 subject_addbtn bg-dark">Back</button></a>
|
||
|
|
||
|
</form>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</main>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<!-- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js"></script> -->
|
||
|
<script defer src="<?php echo base_url(); ?>assets_admin/js/bootstrap-select.min.js"></script>
|
||
|
<script>
|
||
|
$('.isClassTeacher').on('change', function(i, v) {
|
||
|
console.log(i.which);
|
||
|
$('.isClassTeacher').not(this).prop('checked', false);
|
||
|
$('#classSubject').val('v')
|
||
|
});
|
||
|
</script>
|
||
|
<script>
|
||
|
$('#assign_subject_id').on('change', function() {
|
||
|
|
||
|
|
||
|
var id = $('#assign_subject_id').find(":selected").val();
|
||
|
alert(id);
|
||
|
$.ajax({
|
||
|
url: '<?php echo base_url() . 'admin/get_subject_teachers/' ?>' + id,
|
||
|
type: 'GET',
|
||
|
dataType: 'json',
|
||
|
success: function(result) {
|
||
|
let section = '';
|
||
|
console.log(result);
|
||
|
section += '<option value=""> - Select Section - </option>';
|
||
|
$.each(result, function(key, value) {
|
||
|
section += '<option value="' + value['teacher_id'] + '">' + value['teacher_name'] + '</option>';
|
||
|
|
||
|
});
|
||
|
$("#section_select").
|
||
|
data(section);
|
||
|
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
$(document).ready(function() {
|
||
|
|
||
|
var CName = $('#course_id :selected').data('course_name')
|
||
|
var CourseName = (CName != '') ? CName : '';
|
||
|
var SName = $('#section_id :selected').data('section_name');
|
||
|
var SectionName = (SName != '') ? SName : '';
|
||
|
$('#course_id').change(function() {
|
||
|
var courseID = $(this).val();
|
||
|
CourseName = $('#course_id :selected').data('course_name');
|
||
|
if (CourseName != '') {
|
||
|
var FullName = CourseName + ' - ' + SectionName;
|
||
|
$('#classroom_name').attr('value', FullName);
|
||
|
}
|
||
|
|
||
|
get_subjects(courseID);
|
||
|
|
||
|
var div_data = '<option value="" data-section_name="" > -- Please Select -- </option>';
|
||
|
$.ajax({
|
||
|
type: 'post',
|
||
|
url: '<?php echo base_url(); ?>Admin/getSectionsforClassroomByCourse',
|
||
|
data: {
|
||
|
course_id: courseID
|
||
|
},
|
||
|
dataType: 'json',
|
||
|
success: function(response) {
|
||
|
$.each(response, function(i, obj) {
|
||
|
div_data += "<option value=" + obj.id + " data-section_name='" + obj.section_name + "'>" + obj.section_name + "</option>";
|
||
|
});
|
||
|
// console.log(div_data);
|
||
|
|
||
|
$('#section_id').empty().append(div_data).selectpicker("refresh");
|
||
|
}
|
||
|
});
|
||
|
|
||
|
});
|
||
|
|
||
|
|
||
|
function get_subjects(courseID) {
|
||
|
$('#subject_section').html('');
|
||
|
$.ajax({
|
||
|
type: 'post',
|
||
|
url: '<?php echo base_url(); ?>Admin/getSubjectsByCourse',
|
||
|
data: {
|
||
|
course_id: courseID
|
||
|
},
|
||
|
dataType: 'json',
|
||
|
success: function(response) {
|
||
|
var subarr = response.subjects;
|
||
|
var tr = '';
|
||
|
$.each(subarr, function(i, value1) {
|
||
|
tr += '<label for="">Subject and Teacher</label><input type="hidden" class="form-control" name="classroom_subjects[]" id="crsubject" value="' + value1.id + '">';
|
||
|
tr += '<input type="text" class="form-control" value="' + value1.subject_name + '">';
|
||
|
tr += gettechers(value1.id);
|
||
|
});
|
||
|
|
||
|
$('#subject_section').append(tr);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
function gettechers(id) {
|
||
|
tr = '';
|
||
|
$.ajax({
|
||
|
url: "<?= base_url() ?>admin/getTeacherbysubjects",
|
||
|
data: {
|
||
|
subject_id: id
|
||
|
},
|
||
|
type: 'POST',
|
||
|
async: false,
|
||
|
success: function(data) {
|
||
|
|
||
|
data = JSON.parse(data);
|
||
|
// console.log(data);
|
||
|
|
||
|
tr += '<select name="classroom_teacher[]" class="form-control subjects"> <option value=""> - Please Select Teacher - </option>'
|
||
|
if (data['teachers'].length > 0) {
|
||
|
$.each(data['teachers'], function(i, value2) {
|
||
|
|
||
|
tr += '<option value="' + value2['teach_id'] + '">' + value2['teacher_name'] + '</option>';
|
||
|
|
||
|
});
|
||
|
} else {
|
||
|
tr += '<option value=" "> No Teacher Found</option>';
|
||
|
}
|
||
|
tr += '</select> <p id="crteacher_error" style="color:red;"></p>';
|
||
|
|
||
|
|
||
|
}
|
||
|
});
|
||
|
|
||
|
return tr;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
$('#section_id').change(function() {
|
||
|
if (CourseName != '') {
|
||
|
SectionName = $('#section_id :selected').data('section_name');
|
||
|
var FullName = CourseName + ' - ' + SectionName;
|
||
|
$('#classroom_name').attr('value', FullName);
|
||
|
} else {
|
||
|
$('#section_id').val('');
|
||
|
$('#course_id-error').text("Please Select Course Name");
|
||
|
}
|
||
|
});
|
||
|
|
||
|
|
||
|
//multiple select js start
|
||
|
$('select').selectpicker();
|
||
|
//multiple select js end
|
||
|
|
||
|
jQuery.validator.addMethod("inputregx", function(value, element) {
|
||
|
return this.optional(element) || /^[a-zA-Z0-9- ]{2,50}$/.test(value);
|
||
|
}, 'Please enter alpha and numeric characters only ');
|
||
|
|
||
|
$("#classroomfrom").validate({
|
||
|
|
||
|
// ignore: "input[type='text']:hidden",
|
||
|
rules: {
|
||
|
classroom_name: {
|
||
|
required: true,
|
||
|
rangelength: [2, 50],
|
||
|
inputregx: true
|
||
|
},
|
||
|
course_id: {
|
||
|
required: true
|
||
|
},
|
||
|
section_id: {
|
||
|
required: true
|
||
|
},
|
||
|
is_active: {
|
||
|
required: true
|
||
|
},
|
||
|
},
|
||
|
messages: {
|
||
|
classroom_name: {
|
||
|
required: "Please enter subject name "
|
||
|
},
|
||
|
course_id: {
|
||
|
required: "Please select course"
|
||
|
},
|
||
|
section_id: {
|
||
|
required: "Please select section"
|
||
|
},
|
||
|
is_active: {
|
||
|
required: "Please select status"
|
||
|
},
|
||
|
},
|
||
|
|
||
|
submitHandler: function(form) {
|
||
|
|
||
|
var EditId = "<?= $id ?>";
|
||
|
// if (EditId == 0) {
|
||
|
var inputValue = $("input[name='classroom_name']", form).val();
|
||
|
let flag = false;
|
||
|
$.ajax({
|
||
|
url: "<?= base_url() ?>admin/checknamewithId",
|
||
|
data: {
|
||
|
id: EditId,
|
||
|
value: inputValue,
|
||
|
tablename: "classroom",
|
||
|
column: "classroom_name"
|
||
|
},
|
||
|
type: 'POST',
|
||
|
async: false,
|
||
|
success: function(data) {
|
||
|
// console.log(data);
|
||
|
if (data == 'success')
|
||
|
flag = true;
|
||
|
|
||
|
}
|
||
|
});
|
||
|
|
||
|
if (flag) {
|
||
|
form.submit();
|
||
|
} else {
|
||
|
$('#classroomerror').show();
|
||
|
$('#classroomerror').text('This Classroom name already exists.');
|
||
|
}
|
||
|
// } else {
|
||
|
// form.submit();
|
||
|
// }
|
||
|
}
|
||
|
});
|
||
|
|
||
|
|
||
|
});
|
||
|
</script>
|