/home3/vehiclea/public_html/admin-appleiitfoundationschools-com/subjects.php
<?php
session_start();
$_SESSION['active'] = 'subject';
include('include/header.php');
// if(!empty($_POST['submit'])){
// subjectData_insert();
// }
if(!empty($_GET['delid'])){
delete_branch($_GET['delid']);
}
$select_academic=select_academic();
$select_class=select_class();
$select_SyllabusData = select_SyllabusData();
$select_SubjectData = select_SubjectData();
?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<main id="main" class="main">
<div class="pagetitle">
<h1>Apple IIT Schools</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.php">Home</a></li>
<li class="breadcrumb-item ">Subjects List</li>
</ol>
</nav>
</div>
<section class="section">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h5 class="card-title">Add Subjects</h5>
<?php
if(!empty($_POST['submit'])){
$number = count($_POST['subject_name']);
for($i=0; $i<$number; $i++)
{
$subject_name = strtoupper($_POST['subject_name'][$i]);
$Year = $_POST['Year'];
$class_name = $_POST['class_name'];
$syllabus = $_POST['syllabus'];
$create_date = $_POST['create_date'];
$query1 = executework("INSERT INTO subjects (class,subjects,syllabus,year,create_date) values('".$class_name."','".$subject_name."','".$syllabus."','".$Year."','".$create_date."')");
}
redirect('subjects.php?succ=1');
}
if(!empty($_GET['failed'])){
?>
<div align="center"><h4 style="color:red;">Already Subject Data Inserted </h4></div>
<?php
}
?>
<?php
if(!empty($_GET['del'])){
?>
<div align="center"><h4 style="color:red;">Subject Data Deleted Sucessfully </h4></div>
<?php
}
if(!empty($_GET['upd'])){
?>
<div align="center"><h4 style="color:green;">Subject Data Updated Successfully </h4></div>
<?php
}
?>
<?php
if(!empty($_GET['succ'])){
?>
<div align="center"><h4 style="color:green;">Subject Data Inserted Sucessfully </h4></div>
<?php
}
?>
<div id="delete_data" style="display: none;">
<h4 style="color:red; text-align: center; ">Data Delete Successfully</h4>
</div>
<form method="post" onsubmit="return subject_validation()">
<div class="row">
<div class="col-md-4 mt-4">
<label for="exampleInputEmail1" class="form-label">Academic Year</label>
<select name="Year" id="AcaYear" class="form-control">
<option value="">Please Select Year</option>
<?php
$select_academic = select_academic();
while($academic = mysqli_fetch_array($select_academic)){
?>
<option value="<?= $academic['yearOf']?>"><?= $academic['yearOf']?></option>
<?php
}
?>
</select>
</div>
<div class="col-md-4 mt-4">
<label for="exampleInputEmail1" class="form-label">Class</label>
<select name="class_name" id="class_name" class="form-control">
<option value="">Please Select Class</option>
<?php
while($class = mysqli_fetch_array($select_class)){
?>
<option value="<?= $class['name']?>"><?= $class['name']?></option>
<?php
}
?>
</select>
</div>
<!-- <div class="col-md-3 mt-4">
<label for="exampleInputEmail1" class="form-label">Section</label>
<select name="section" id="section" class="form-control" onChange="select_section()">
<option value="">Please Select Section</option>
<?php
//$select_section = select_section1();
// while($section= mysqli_fetch_array($select_section))
// {
?>
<option value="<?= $section['section']?>"><?= $section['section']?></option>
<?php
// }
?>
</select>
</div> -->
<div class="col-md-4 mt-4">
<label for="exampleInputEmail1" class="form-label">Syllabus Type</label>
<select name="syllabus" id="syllabus" class="form-control">
<option value="">Please Select Syllabus</option>
<?php
while($syllabus = mysqli_fetch_array($select_SyllabusData)){
?>
<option value="<?= $syllabus['name']?>"><?= $syllabus['name']?></option>
<?php
}
?>
</select>
</div>
<div class="col-md-4 mt-4">
<label for="exampleInputEmail1" class="form-label">Subject Name</label>
<input type="text" class="form-control" id="subject_name" name="subject_name[]" placeholder="Enter subject name">
</div>
<input type="hidden" name="create_date[]" value="<?= date('Y-m-d H:i:s')?>">
<div class="col-md-4 mt-4">
<button class="btn btn-success" type="button" name="addnew" style="background-color: #69F0AE; color: #000000;" onclick="add_row();" id="addRowbutton"><i class="fa fa-plus-circle"></i></button>
</div>
</div>
<div id="row_list"></div>
<div class="mt-4">
<input type="submit" class="btn" value="Add" name="submit" style="background-color: #69F0AE; color: #000000;">
</div>
</form>
<h5 class="card-title">Reports</h5>
<div class="row">
<table class="table">
<thead style="background-color:#7E57C2; color: #ffff;">
<tr>
<th>S.No</th>
<th>Academic Year</th>
<th>Class</th>
<!-- <th>Section</th> -->
<th>Syllabus</th>
<?php
if($_SESSION['user']=='admin'){
?>
<th>Action</th>
<?php
}
?>
</tr>
</thead>
<!-- <div class="col-md-4 mt-4">
<label for="exampleInputEmail1" class="form-label">Syllabus Type</label>
<select name="syllabusdata" id="syllabusdata" class="form-control" onChange="select_syllabus(this.value)">
<option value="">Please Select Class</option>
<?php
$select_SyllabusData = select_SyllabusData();
while($syllabus = mysqli_fetch_array($select_SyllabusData)){
?>
<option value="<?= $syllabus['name']?>"><?= $syllabus['name']?></option>
<?php
}
?>
</select>
</div> -->
<!-- <div class="col-md-4 mt-4">
<label for="exampleInputEmail1" class="form-label">Class List</label>
<select name="class_list" id="class_list" class="form-control">
<option value="">Please Select Class</option>
</select>
</div> -->
<tbody>
<?php
$class_list = executework("SELECT DISTINCT class,syllabus,year FROM subjects");
$i=1;
while( $classname = mysqli_fetch_array($class_list) )
{
?>
<tr>
<td><?= $i;?></td>
<td id="year_id_<?= $i?>"><?= $classname['year']?></td>
<td id="class_id_<?= $i?>"><?= $classname['class']?></td>
<!-- <td><?= $classname['section']?></td> -->
<td id="syllabus_id_<?= $i?>"><?= $classname['syllabus']?></td>
<?php
if($_SESSION['user']=='admin'){
?>
<td>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false" style="background-color:#69F0AE;">
Action
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
<li><a class="dropdown-item text-center" href="subject_edit.php?edit=<?= $classname['id']?>">EDIT</a></li>
<li><a class="dropdown-item text-center" href="javascript:void();" oonclick="confirmDelete(<?php echo $classname['id']?>)">DELETE</a></li>
<li><a class="dropdown-item text-center" data-bs-toggle="modal" data-bs-target="#exampleModal" href="javascript:void(0)" onclick="class_show(<?= $i?>)">VIEW</a></li>
</ul>
</div>
</td>
<?php
}
?>
</tr>
<?php
$i++;
}
?>
</tbody>
</table>
</div>
<!-- <div class="mt-4">
<button type="button" class="btn btn-warning" onClick="search_data()">Search</button>
</div> -->
<div id="result" class="mt-4">
</div>
</div>
</div>
</div>
</div>
</section>
</main><!-- End #main -->
<!---- Modal---->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div id="modal_view"></div>
</div>
</div>
</div>
<!---- Modal ---->
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script>
function subject_validation()
{
var year = $('#AcaYear').val();
var class_name = $('#class_name').val();
var syllabus = $('#syllabus').val();
var subject_name = $('#subject_name').val();
if(year == '')
{
swal('Please Select Year');
return false;
}
else if(class_name == '')
{
swal('Please Select Class');
return false;
}
else if(syllabus == '')
{
swal('Please Select Syllabus Type');
return false;
}
else if(subject_name == '')
{
swal('Please Enter SubjectName');
return false;
}
else{
return true;
}
}
</script>
<script>
function confirmDelete(subjectid)
{
if (subjectid != '') {
var x = confirm('Are you sure to Delete?');
if(x){
$.ajax({
url : "delete.php",
data : {subjectid : subjectid},
type : 'POST',
success : function(response) {
if(response ==1){
$('#delete_data').show();
window.location.href = "subjects.php";
}
}
});
}
}
}
</script>
<script>
function select_syllabus(class_list){
if(class_list !=''){
$.ajax({
url : "section.php",
data : {class_list : class_list},
type : 'POST',
success : function(response) {
$('#class_list').html(response);
}
});
}
}
</script>
<script>
// function select_section(val){
// if(val !=''){
// $.ajax({
// url : "section.php",
// data : {val : val},
// type : 'POST',
// success : function(response) {
// $('#section').html(response);
// }
// });
// }
// }
</script>
<script>
function search_data(){
var syllabusdata = $('#syllabusdata').val();
var class_listdata = $('#class_list').val();
if(syllabusdata != '' && class_listdata != ''){
$.ajax({
url : "section.php",
data : {class_listdata : class_listdata,syllabusdata:syllabusdata},
type : 'POST',
success : function(response) {
$('#result').html(response);
}
});
}
else{
alert("please Select");
}
}
</script>
<script>
$(document).ready(function() {
var i=0;
$("#addRowbutton").on("click", function() {
i++;
$('#row_list').append('<div id="row'+i+'"><div class="row"><div class="col-md-3 mt-4"><input type="text" name="subject_name[]" id="subject_name'+i+'" class="form-control" placeholder="Enter Subject"></div><div class="col-md-3 mt-4"><button type="button" name="remove" id="'+i+'" style="background-color: red; color: #000000;" class="btn btn-danger btn_remove">X</button></div></div></div>');
});
$(document).on('click', '.btn_remove', function(){
var button_id = $(this).attr("id");
$('#row'+button_id+'').remove();
});
});
</script>
<script>
function class_show(id)
{
var class_name = $('#class_id_'+id).html();
var Year = $('#year_id_'+id).html();
var syllabus = $('#syllabus_id_'+id).html();
if(class_name !='' && Year !='')
{
$.ajax({
url : "subjects_list.php",
data : {class_name : class_name,Year : Year,type:1,syllabus : syllabus},
type : 'POST',
success : function(response) {
$('#modal_view').html(response);
}
});
}
}
</script>
<?php include('include/footer.php'); ?>
@LwBee Strong Bypass
Upload File
Create New File