JezK
Edit File: student_management.php
<?php session_start(); include('header.php'); include_once("student_access.php"); $student=new student_access(); ///////////////////////////////////// $timeout=$student->check_my_status($_SESSION['child']['log_school_id']); if($timeout==0) echo "<script>location.replace('logout.php');</script>"; ///////////////////////////////////// $sch_id = $_SESSION['child']['log_school_id']; $acadamic_id = $_SESSION['child']['current_academic_id']; $choosen_acc_id = $_SESSION['child']['choosen_academic_id']; if($_SESSION['student_edit']['stu_id']) { $student_id = $_SESSION['student_edit']['stu_id']; } else if($_SESSION['student_add']['stu_id']) { $student_id = $_SESSION['student_add']['stu_id']; } else { $student_id =''; } $details=$student->get_classes_byschool_total($sch_id,$choosen_acc_id); if($_SESSION['child']['stu_class_id']) { $section_byclass =$student->get_sections_data_byclass($_SESSION['child']['stu_class_id']); } ?> <style> .table-condensed>thead>tr>th, .table-condensed>tbody>tr>th, .table-condensed>tfoot>tr>th, .table-condensed>thead>tr>td, .table-condensed>tbody>tr>td, .table-condensed>tfoot>tr>td { padding: 3px; } label { display: inline-block; max-width: 100%; margin-bottom: 5px; font-weight: 700; font-size: 12px !important; font-style:normal!important; font-family:Arial, Helvetica, sans-serif!important; } .stu_details{ font-size:14px; font-family:Arial, Helvetica, sans-serif; font-style:normal; font-size:13px; } select { width: 62px !important; background-color: #FFF; border: 1px solid #CCC; } </style> <!--<body class="imgg" >--> <body style=" overflow-x: hidden;"> <div class="row" style="margin-top: 30px;margin-left:5px;"> <div class="col-md-7 text-left" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:24px;"> <i class=" glyphicon glyphicon-certificate" title ="Student management" style="font-size: 20px;margin: 0px 0px 0px -15px;"> </i> Student Management </div> <div class="col-md-5 text-right"> <button type="button" onClick="location.href='add_student.php'" class="btn btn-default" style="margin-right:20px;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;"> Add Student </button> <button type="button" onClick="location.href='excel_templates/student_upload_excel.xls'" class="btn btn-default" style="margin-right:20px;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;"> Download Excel </button> <button type="button" onClick="location.href='upload_students.php'" class="btn btn-default" style="margin-right:20px;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;"> Upload Excel </button> </div> </div> <form class="form-horizontal"> <div class="box-body" style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; "> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-right"> <b style="color:#666666; ">Choose Class</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-control" id="classes" style="height:29px; font-size:12px;width:300px!important;" tabindex="1" > <option selected="selected" value=' ' >--Select Class--</option> <?php foreach($details as $key=>$row) { if($row['class_id'] == $_SESSION['child']['stu_class_id']) { $selected = "selected=selected"; } else { $selected = ""; } echo "<option value='{$row['class_id']}'{$selected}>{$row['class_name']}</option>"; }?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_class" style="color:#990000;margin-left:-15px;"></div> <!--- end error--> </div> </div> </div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-right"> <b style="color:#666666; ">Choose Section</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-control" id="sections" style="height:29px; font-size:12px;width:300px!important;" tabindex="2" > <option selected="selected" value='0'>--Select Section--</option> <?php if(count($section_byclass)>0) foreach($section_byclass as $key=>$row) { if($row['section_id'] == $_SESSION['child']['section_id']) { $selected = "selected=selected"; } else { $selected = ""; } echo "<option value='{$row['section_id']}'{$selected}>{$row['section_name']}</option>"; }?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_section" style="color:#990000;margin-left:-15px;"></div> <!--- end error--> </div> </div> </div> </div> </form> <div class="row" style="margin-left:10px;margin-right:10px;"> <div id="students" class="col-md-12 centered" style="font-family: Arial, Helvetica, sans-serif;margin-top:30px;"> </div> </div> <script src="//code.jquery.com/jquery-1.12.0.min.js"></script> <script src="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.1.2/js/dataTables.buttons.min.js"></script> <script src="//cdn.datatables.net/buttons/1.1.2/js/buttons.print.min.js"></script> <script src="//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script> <script src="//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script> <script src="//cdn.datatables.net/buttons/1.1.2/js/buttons.html5.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script> <script type="text/javascript" language="javascript"> $(document).ready(function() { var class_id=$("#classes").val(); var sec_id=$("#sections").val(); // $("#students").load("students_data.php",{classid:class_id,sec_id:sec_id},function(data){ $.post("students_data.php",{classid:class_id,sec_id:sec_id},function(data) { document.getElementById("students").innerHTML=data; var clname=$("#classes").find('option:selected').text(); var scnam=$("#sections").find('option:selected').text(); $('#myTable').DataTable( { dom: 'B<"clear">lfrtip', "iDisplayLength": 100, stateSave: true, buttons: [ { extend: 'print', title: '<center><h3><?php echo $_SESSION['child']['school_name']?></h3></center>', message: 'Student Management<br>Academic Year:<?php echo $_SESSION[child][choosen_year_name]?>   Class:'+clname+'   Section:'+scnam+'<br>', exportOptions: { columns: [ 0, 1, 2, 3, 4, 5, 6 ] } }, { extend: 'pdfHtml5', title:'<?php echo $_SESSION['child']['school_name']?>', message: 'Student Management\nAcademic Year:<?php echo $_SESSION[child][choosen_year_name]?>\t Class:'+clname+'\tSection:'+scnam+'\n', exportOptions: { columns: [ 0, 1, 2, 3, 4, 5, 6 ] } }, { extend: 'excelHtml5', title:'<?php echo $_SESSION['child']['school_name']?>', exportOptions: { columns: [ 0, 1, 2, 3, 4, 5, 6 ] } } ] }); //$('div.dataTables_filter input').attr('placeholder', 'Search'); }); $("#classes").change(function() { $('#err_class').text(""); if($(this).val() == 0) { var section_option = '<option value="0">--Select Section--</option>'; $("#sections").html(section_option); $('#err_class').text('Please select Class'); $('#err_class').show(); return false; } else { var x = $(this).val(); $.ajax({ url: "ajaxcalls.php", type:"POST", data:"mode="+"choose_class"+"&data="+x, success: function(result) { var result2 = eval("("+result+")"); var section_option = '<option value="0">--Select Section--</option>'; for(var i = 0;i < result2.length;i++){ section_option += '<option value="'+result2[i].section_id+'">'+result2[i].section_name+'</option>'; } $("#sections").html(section_option); }, error : function(e) { } }); } }); $("#sections").change(function() { $('#err_section').text(""); if($("#classes").val() == 0) { $('#err_class').text('Please Choose the Class'); return false; } else { if($("#sections").val() == 0) { $('#err_section').text("Please select Section"); $('#err_section').show(); return false; } else { var class_id=$("#classes").val(); var sec_id=$("#sections").val(); //$("#students").load("students_data.php",{classid:class_id,sec_id:sec_id},function(data){ $.post("students_data.php",{classid:class_id,sec_id:sec_id},function(data){ document.getElementById("students").innerHTML=data; var clname=$("#classes").find('option:selected').text(); var scnam=$("#sections").find('option:selected').text(); $('#myTable').DataTable( { dom: 'B<"clear">lfrtip', "iDisplayLength": 100, stateSave: true, buttons: [ { extend: 'print', title: '<center><h3><?php echo $_SESSION['child']['school_name']?></h3></center>', message: 'Student Management<br>Academic Year:<?php echo $_SESSION[child][choosen_year_name]?>   Class:'+clname+'   Section:'+scnam+'<br>', exportOptions: { columns: [ 0, 1, 2, 3, 4, 5, 6 ] } }, { extend: 'pdfHtml5', title:'<?php echo $_SESSION['child']['school_name']?>', message: 'Student Management\nAcademic Year:<?php echo $_SESSION[child][choosen_year_name]?>\t Class:'+clname+'\tSection:'+scnam+'\n', exportOptions: { columns: [ 0, 1, 2, 3, 4, 5, 6 ] } }, { extend: 'excelHtml5', title:'<?php echo $_SESSION['child']['school_name']?>', exportOptions: { columns: [ 0, 1, 2, 3, 4, 5, 6 ] } } ] }); //$('div.dataTables_filter input').attr('placeholder', 'Search'); }); } } }); $('#myTable').DataTable({ "pageLength":100, stateSave: true, dom: 'T<"clear">lfrtip', "oLanguage": { "sSearch": "" }, tableTools: { "aButtons": [ { "sExtends": "xls", "mColumns": [0,1,2,3,4,5,6] }, { "sExtends": "pdf", "sPdfOrientation": "landscape", "mColumns": [0,1,2,3,4,5,6] }, { "sExtends": "print", "mColumns": [0,1,2,3,4,5,6] } ] } }); $('div.dataTables_filter input').attr('placeholder', 'Search'); }); $('#add_btn').click(function(event) { $.ajax({ url: "ajaxconditions.php", type:"POST", data:"action="+"add_student", success: function(result) { if(result == "sucess") { window.location = 'add_student.php'; } else if(result == "exeedcount") { alert("You already consumed all student licenses. Please purchase additional licenses in order to add students into the system"); return false; } } }); }); </script> <script> $(document).ready(function(){ $('#myTable').dataTable(); if($('#classes').val() == 0) { var section_option = '<option value="0">--Select Section--</option>'; $("#sections").html(section_option); } }); </script> </body> </html>