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

572 lines
30 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<!-- <Link href="https://cdn.datatables.net/fixedcolumns/4.1.0/css/fixedColumns.dataTables.min.css" /> -->
<style>
.form-group .bootstrap-select>.dropdown-toggle {
padding: 9px 9px !important;
font-size: 12px !important;
border: 1px solid #c8c8c8 !important;
background: #fff !important;
}
.action_subject_addbtn {
background: #032DA4;
border-radius: 35px;
color: #fff;
padding: 5px 15px;
border: none;
font-size: 12px;
cursor: pointer;
text-decoration: none;
}
.custom_tble th:nth-child(1),
.custom_tble th:nth-child(2),
.custom_tble td:nth-child(1),
.custom_tble td:nth-child(2) {
background: #fff;
z-index: 9;
}
.table_div {
width: 100%;
}
th,
td {
white-space: nowrap;
}
.table_stu_name {
margin: auto;
}
.assign_Fee_startdate .form-control {
height: calc(2.25rem + 2px);
padding: 9px 3px;
}
.assign_fee_reset .subject_addbtn {
padding: 6px 10px;
}
/*START : added by Nandini*/
.dt-buttons {
display: block !important;
}
/*END OF : added by Nandini*/
.error {
color: red;
padding-top: 5px;
/* font-weight:500; */
}
</style>
<div class="wraper responsive-width">
<main class="long-tbl-main students_list_table" id="main">
<div class="from-group adding-class form-group_lng form_group_twobtn">
</div>
<!-- admin template section -->
<div class="admin_tempblock">
<div class="admin_tempsec">
<div class="admin_sec">
<?php
if (!empty($this->session->flashdata('success'))) { ?>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert">&times;</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">&times;</a>
<strong>Failed!</strong> <?php echo $this->session->flashdata('error'); ?>
</div>
<?php } ?>
<div class="subsec_sec">
<div class="subject_r">
<div class="subject_lsec">
<div class="col-md-6 pull-left" style="padding:0">
<button onclick="history.back()" type="button" class="btn subject_addbtn bg-dark">Back</button>
</div>
<?php
$theExportHeader = '';
if (isset($school_info) && !empty($school_info)) {
$courseTitle = '';
$monthTitle = '';
if (isset($selectedCourse) && !empty($selectedCourse)) {
// echo '<pre>';
$courseTitle = $selectedCourse['course_name'];
}
$theExportHeader = $courseTitle . ' - Class Schedule';
}
$selBatch = (isset($theBatchId) && !empty($theBatchId)) ? $theBatchId : $school_info['batch_id'];
$selCourseId = '';
$selSectionId = '';
$sercStdStr = '';
if (count($_POST) > 0) {
$selCourseId = $course;
$selSectionId = $section;
}
?>
<div class="subject_lhead"><?= 'Classroom Schedule'; ?></div>
<form method="post" action="<?php echo base_url(); ?>admin/classroom-schedule" id="form-filter">
<div class="filter_lbl">
<i class="fas fa-filter"></i>
Filter
</div>
<div class="row">
<div class="col-md-3">
<label class="has-float-label">
<select id="f_batch" name="f_batch" class="custom-select form-control">
<option value="">Select Batch</option>
<?php if (isset($batches) || !empty($batches)) {
foreach ($batches as $row) {
$b_selected = ($row['id'] == $selBatch) ? 'selected' : '';
?>
<option value="<?php echo $row['id'] ?>" <?= $b_selected; ?>>
<?php echo $row['b_name']; ?></option>
<?php }
} ?>
</select>
<span>Batch <b class="text-danger">*</b></span>
</label>
</div>
<div class="col-md-3">
<label class="has-float-label mb-0">
<select class="form-control custom-select" placeholder="Select Course" name="filter-course" id="filter-course">
<option value="">Select Course</option>
<?php
if (isset($courses) || !empty($courses)) {
foreach ($courses as $row) {
?>
<option value="<?php echo $row['id'] ?>" <?php if ($row['id'] == $selCourseId) { ?> selected <?php } ?>>
<?php echo $row['course_name']; ?>
</option>
<?php
}
}
?>
</select>
<span>Course <b class="text-danger">*</b></span>
</label>
<label id="filter-course-error" class="error py-0 my-0 px-1 small" for="filter-course"></label>
</div>
<div class="col-md-3">
<label class="has-float-label mb-0">
<select class="form-control custom-select" placeholder="Select Section" name="filter-section" id="filter-section">
<?php if ($section != '') {
$sectionName = $this->db->get_where('section', array('id' => $section))->row()->section_name;
?>
<option value="<?= $section; ?>" <?php echo set_select('filter-section', $section, TRUE); ?>><?php echo $sectionName; ?></option>
<?php } ?>
<option value=""> Select Section </option>
</select>
<span>Section <b class="text-danger">*</b></span>
</label>
<label id="filter-section-error" class="error py-0 my-0 px-1 small" for="filter-section"></label>
</div>
<div class="col-md-3">
<div class="form-group assign_fee_reset">
<input type="submit" name="filterSubmit" id="filter_reset" class="btn btn-success" value="Filter">
<a href="<?php echo base_url() ?>admin/classroom-schedule"><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>
</div>
</form>
<hr>
<?php if (isset($class_schedule) && !empty($selCourseId)) { ?>
<div class="table_div ">
<?php
// print_r($class_schedule);
?>
<form method="post" action="<?php echo base_url(); ?>admin/classroom-schedule" id="form-filter">
<input type="hidden" name="selectedBatchId" value="<?= $selBatch ?>" />
<input type="hidden" name="selectedCourseId" value="<?= $selCourseId ?>" />
<input type="hidden" name="selectedSectionId" value="<?= $section ?>" />
<div class="row align-items-center mb-3">
<div class="col-md-2">
<label class="has-float-label mb-0">
<input type="time" id="class_start_time" name="class_start_time" class=" form-control" value="" placeholder='Enter Class Starts Time' required>
<span>Start Time <b class="text-danger">*</b></span>
</label>
</div>
<div class="col-md-2">
<label class="has-float-label mb-0">
<input type="time" id="class_end_time" name="class_end_time" class=" form-control" value="" placeholder='Enter Class End Time' required>
<span>End Time <b class="text-danger">*</b></span>
</label>
</div>
<div class="col-md-3">
<label class="has-float-label mb-0">
<select id="subject" class="form-control selectpicker" name="subject" data-live-search="false" required>
<option value="">
Select Subject
</option>
<?php
foreach ($course_subjects as $cs_key => $course_subject) {
?>
<option value="<?= $course_subject['subject_id'] ?>">
<?= $course_subject['subject_name'] ?>
</option>
<?php
}
?>
<option value="0>">
<?= 'Interval' ?>
</option>
</select>
<span>Subject <b class="text-danger">*</b></span>
</label>
</div>
<div class="col-md-3">
<label class="has-float-label mb-0">
<select id="days" class="form-control selectpicker" name="days[]" multiple data-live-search="false" required>
<option value="">
Select Days
</option>
<?php
foreach ($week_days as $wd_key => $week_day) {
?>
<option value="<?= $week_day['id'] ?>">
<?= $week_day['title'] ?>
</option>
<?php
}
?>
</select>
<span>Day <b class="text-danger">*</b></span>
</label>
</div>
<div class="col-md-2">
<input type="submit" name="addClassSchedule" id="addClassSchedule" class="btn btn-outline-success w-100" value="Save">
</div>
</div>
</form>
<hr>
<table id="tbl" class="display" width="100%">
<thead>
<tr>
<th class="border-right border-top border-left sorting_desc" style="width: 4%">
<!-- <label class=" mb-0 pl-0 "> -->
Time
<!-- </label> -->
</th>
<?php
if (isset($week_days) && !empty($week_days)) {
foreach ($week_days as $w_key => $week_day) {
?>
<th class="text-center border-right border-top">
<?= $week_day['title'] ?>
</th>
<?php
}
}
?>
<th class="border-right border-top border-left sorting_desc noExport" style="width: 4%">
<!-- <label class=" mb-0 pl-0 "> -->
Action
<!-- </label> -->
</th>
</tr>
</thead>
<tbody>
<?php
// echo '<pre>';
if (isset($class_schedule) && !empty($class_schedule)) {
$sno = 1;
$class_schedules = isset($class_schedule['class_schedule']) ? $class_schedule['class_schedule'] : [];
// dd($class_schedules);
foreach ($class_schedules as $csKey => $schedule) {
$days_schedules = $schedule['days'];
?>
<tr>
<td class="border-right border-left">
<?php echo date('h:i A', strtotime($schedule['start_time'])) . ' - ' . date('h:i A', strtotime($schedule['end_time']));
// print_r($schedule['days']);
?>
</td>
<?php
foreach ($week_days as $w_key => $week_day) {
foreach ($days_schedules as $ds_key => $ds) {
if ($ds['id'] == $week_day['id']) {
?>
<td class="text-left border-right border-top">
<?= !empty($ds['subject']) ? $ds['subject']['subject_name'] : '-' ?>
</td>
<?php
}
}
}
?>
<td class="border-right border-left">
<?php
// dd($schedule);
$url_params = array(
'batch_id' => $schedule['batch_id'],
'course_id' => $schedule['course_id'],
'section_id' => $schedule['section_id'],
'start_time' => $schedule['start_time'],
'end_time' => $schedule['end_time']
);
?>
<a target="_blank" href="<?= base_url() . 'admin/classroom-schedule-update/' . urlencode(serialize($url_params)) ?>" class="btn btn-sm btn-outline-primary mr-1">
<i class="fa fa-edit"></i>
</a>
<button type="submit" id="deleteBtn" href="<?= base_url() . 'admin/classroom-schedule-update/' . urlencode(serialize($url_params)) ?>" class="btn btn-sm btn-outline-danger">
<i class="fa fa-trash"></i>
</button>
<form method="post" action="<?php echo base_url(); ?>admin/classroom-schedule" id="form-delete">
<input type="hidden" name="batch_id" value=<?= $schedule['batch_id'] ?>>
<input type="hidden" name="course_id" value=<?= $schedule['course_id'] ?>>
<input type="hidden" name="section_id" value=<?= $schedule['section_id'] ?>>
<input type="hidden" name="start_time" value=<?= $schedule['start_time'] ?>>
<input type="hidden" name="end_time" value=<?= $schedule['end_time'] ?>>
<input type="hidden" name="d_action" value='deleteSchedule'>
<!-- <input type="submit" -->
<!-- <button type="submit" name="deleteSchedule" class="btn btn-sm btn-outline-danger" value="Delete"> <i class="fas fa-trash"></i></button> -->
</form>
</td>
</tr>
<?php
}
// print_();($class_schedule);
}
?>
</tbody>
</table>
<!-- <hr />
<div class="row">
<div class="col-md-9"></div>
<div class="col-md-3"><button type="submit" class=" w-100 btn btn-sm mb-2" style="background-color:#032da1;color:#fff;" name="assigntostudents" value="assign"> Assign </button></div>
</div> -->
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- admin template section end -->
</main>
<!--End right-top side-->
</div>
<script defer src="<?php echo base_url(); ?>assets_admin/js/bootstrap-select.min.js"></script>
<!-- <script defer src="https://cdn.datatables.net/fixedcolumns/4.1.0/js/dataTables.fixedColumns.min.js"></script> -->
<script>
$("#deleteBtn").click(function() {
$("#form-delete").submit(); // Submit the form
});
$(document).ready(function() {
jQuery.validator.addMethod("inputregx", function(value, element) {
return this.optional(element) || /^[a-zA-Z0-9 -]{3,50}$/.test(value);
}, 'Please enter alpha and numeric characters only ');
$("#form-filter").validate({
ignore: "input[type='text']:hidden",
rules: {
"filter-course": {
required: true,
},
"filter-section": {
required: true,
},
"filter-fees_type[]": {
required: true
},
"filter-route-id": {
required: true
}
},
messages: {
"filter-course": {
required: "Please Select Course ",
},
"filter-section": {
required: "Please Select Section ",
}
},
submitHandler: function(form) {
form.submit();
}
});
});
</script>
<script>
/* Ensure that the demo table scrolls */
$(document).ready(function() {
var jsTheExportHeader = '<?php echo $theExportHeader; ?>';
var table = $('#tbl').DataTable({
scrollY: screen.height * 0.6,
scrollX: true,
scrollCollapse: true,
paging: false,
// order: [
// [1, 'acs']
// ],
fixedColumns: {
left: 1,
},
"dom": 'lBfrtip',
buttons: [{
extend: 'pdfHtml5',
// orientation: 'landscape',
exportOptions: {
columns: "thead th:not(.noExport)",
rows: function(indx, rowData, domElement) {
return $(domElement).css("display") != "none";
},
stripNewlines: false,
stripHtml: true
},
orientation: 'landscape',
pageSize: 'A4',
// customize: function(doc) {
// doc.content[1].table.widths = Array(doc.content[1].table.body[0].length + 1).join('*').split('');
// // doc.defaultStyle.alignment = 'center';
// doc.styles.tableHeader.alignment = 'center';
// }
// messageTop: 'The information in this table is copyright to Sirius Cybernetics Corp.'
},
{
extend: 'print',
exportOptions: {
columns: "thead th:not(.noExport)",
rows: function(indx, rowData, domElement) {
return $(domElement).css("display") != "none";
},
stripNewlines: false,
stripHtml: true
},
},
{
extend: 'excelHtml5',
header: true,
footer: true,
title: jsTheExportHeader,
exportOptions: {
columns: "thead th:not(.noExport)",
rows: function(indx, rowData, domElement) {
return $(domElement).css("display") != "none";
},
stripNewlines: false,
stripHtml: true,
},
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
$('row c[r^="C"]', sheet).attr('s', '2');
}
}
],
});
});
$('#filter-course').change(function() {
var course = $('#filter-course option:selected').val();
// alert(course);
var divData = '';
if (course != '' && course != 0) {
$.ajax({
url: "<?php echo base_url(); ?>Admin/get_section_by_course",
method: "POST",
data: {
course_id: course
},
dataType: "json",
success: function(response) {
// console.log(response);
// section options code and start from here
divData += "<option value='' > Select Section </option>";
if (response.sections != '') {
$.each(response.sections, function(i, sectiondata) {
divData += "<option value='" + sectiondata.section_id + "'>" + sectiondata.section_name + "</option>";
});
}
// $('#course_error_msg').text();
else {
divData += "<option value=''> -- No Section's Found --</option>";
}
$('#filter-section').empty().append(divData);
// section options code here End from here
}
});
} else {
divData = "<option value=''> -- Select Section -- </option>";
$('#filter-section').empty().append(divData);
}
});
</script>
<script>
jQuery(document).ready(function() {
jQuery(".custom_tble").clone(true).appendTo('.table_div_cover').addClass('clone');
});
</script>