JezK
Edit File: subject_management.php
<?php session_start(); include("session_check.php"); include "adm_operations.php"; $operations=new adm_operations(); include('school_timeout.php'); $result=0; /******************************get category based subjects********************/ if(isset($_GET['calcat'])) { $_SESSION['child']['calcat']=$_GET['calcat']; $result=$operations->getallsubjectsofclasscategory($_SESSION['child']['log_school_id'],$_SESSION['child']['calcat'],$_SESSION['child']['choosen_academic_id']); } else { unset($_SESSION['child']['calcat']); } ///////////////////////////////Page starts here/////////////////// include("header.php"); ?> <style> select { width: 62px !important; background-color: #FFF; border: 1px solid #CCC; } .red { color:#ff0000!important; font-size:12px; background: none; } .green { color:#0F9B0C!important; font-size:12px; background: none; } </style> <script> function postclassdata(value) { if(value==0) window.location.href="subject_management.php?calcat=1"; else window.location.href="subject_management.php?calcat="+value; } function removeSubjectfrom(sbid) { var x=$('#scategory').val(); if(confirm('Do you want to Delete the Subject ?')) { $.post('subj_ajax.php',{delsub:sbid},function(data){ if(data=='delete_ok') window.location.href='subject_management.php?calcat='+x; else if(data=='delete_not') { alert('You can not delete this subject as there is some data associated with it'); window.location.href='subject_management.php?calcat='+x; } }); } } function changeSubstatus(sbid,sts) { var x=$('#scategory').val(); if(sts==1) { if(confirm('Do you want to Deactivate the Subject ?')) { $.post('subj_ajax.php',{edtsub:sbid,stc:sts},function(data){ window.location.href='subject_management.php?calcat='+x; }); } } else { if(confirm('Do you want to Activate the Subject ?')) { $.post('subj_ajax.php',{edtsub:sbid,stc:sts},function(data){ window.location.href='subject_management.php?calcat='+x; }); } } } </script> <body style=" overflow-x: hidden;"> <div class="row" style="margin-top: 30px;margin-left:5px;"> <div class="col-md-9 text-left" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:24px; "> <i class=" glyphicon glyphicon-book" title ="Edit Subject" style="font-size: 20px;margin: 0px 0px 0px -15px;"></i> Subject Management </div> <div class="col-md-2 text-center"> <button type="button" onClick="location.href='add_subject.php'" class="btn btn-default" style="margin-right:20px;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;"> Add Subject </button> </div> </div> <form> <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 Category</b> <span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-control" id="scategory" style="height:29px; font-size:12px; width:300px!important;" tabindex="2" onchange="postclassdata(this.value)"> <option selected="selected" value='0'>--Select Category--</option> <option value='1' <?php if($_SESSION['child']['calcat']=='1') echo "selected";?>>Junior</option> <option value='2' <?php if($_SESSION['child']['calcat']=='2') echo "selected";?>>Primary</option> <option value='3' <?php if($_SESSION['child']['calcat']=='3') echo "selected";?>>Higher Secondary</option> <option value='4' <?php if($_SESSION['child']['calcat']=='4') echo "selected";?>>Senior Secondary</option> </select> </div> </div> </div> </form> <div class="row" style="margin-left:10px;margin-right:10px;"> <div class="col-md-12 centered" style="font-family: Arial, Helvetica, sans-serif;margin-top:30px;"> <table id="myTable" class="table table-condensed table-hover" style="margin-top:-10px;"> <thead> <tr class="info"> <th class="col-md-1 text-center">Sl.No</th> <th>Category Name</th> <th>Subject Name</th> <th>Status</th> <th>Actions</th> </tr> </thead> <tbody> <?php $i=1; if($result!='no subjects' || $result!=0) foreach($result as $row) { if($row['subject_status']=='1') { $act="Active"; $title="Deactivate"; $nstate='class="red glyphicon glyphicon-ban-circle"'; } else { $act="Deactivated"; $title="Activate"; $nstate='class="green glyphicon glyphicon-ok-circle"'; } echo ' <tr> <td class="col-sm-1 text-center" style=" font-size:14px;">'.$i.'</td> <td style=" font-size:14px;">'.$row[class_category_name].'</td> <td style=" font-size:14px;">'.$row[subject_name].'</td> <td style="font-size:14px;"> '.$act.'</td> <td class="center"> <a class=" buttonn" href="edit_subject.php?edtsub='.$row[subject_id].'" style="margin:4px;"> <i class="glyphicon glyphicon-pencil" title ="Edit" style="font-size: 14px; color:#01aee6;"></i> </a> <a class=" buttonn" onclick="changeSubstatus('.$row[subject_id].','.$row['subject_status'].');" style="margin:4px;"> <i '.$nstate.' title ="'.$title.'" style="font-size: 14px; color:#01aee6;"></i> </a> <a class=" buttonn" onclick="removeSubjectfrom('.$row[subject_id].');" style="margin:4px;"> <i class=" glyphicon glyphicon-remove" title="Delete" style="font-size: 14px; color:#01aee6;"></i> </a> </td> </tr>'; $i++; } ?> </tbody> </table> </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" class="init"> $(document).ready(function() { /*$('#myTable').DataTable( { "pageLength":100, stateSave: true, dom: 'T<"clear">lfrtip', "oLanguage": { "sSearch": "" }, tableTools: { "aButtons": [ { "sExtends": "xls", "mColumns": [0, 1, 2, 3] }, { "sExtends": "pdf", "sPdfOrientation": "landscape", "mColumns": [0, 1, 2, 3] }, { "sExtends": "print", "mColumns": [0, 1, 2, 3] } ] } }); $('div.dataTables_filter input').attr('placeholder', 'Search'); */ var scat=$('#scategory').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: 'Subject Management<br>Academic Year:<?php echo $_SESSION[child][choosen_year_name]?>   Category:'+scat+'<br>', exportOptions: { columns: [ 0, 1, 2, 3 ] } }, { extend: 'pdfHtml5', title:'<?php echo $_SESSION['child']['school_name']?>', message: 'Subject Management\nAcademic Year:<?php echo $_SESSION[child][choosen_year_name]?>\t Category:'+scat+'\n', exportOptions: { columns: [ 0, 1, 2, 3 ] } }, { extend: 'excelHtml5', title:'<?php echo $_SESSION['child']['school_name']?>', exportOptions: { columns: [ 0, 1, 2, 3 ] } } ] } ); } ); </script> <!--<div class="some" style=" position:fixed;left:0px;bottom:0px;height:30px;width:100%;color: #000000;margin-top:10px; line-height: 30px; height:40px; font-family:open sans;"> <div class="row"> <div class="col-md-12" style="text-align:center;"> © Designed | By : <a href=" # " style="color: #01aee6;">Krify Team</a> </div> </div> </div>--> <script> $(document).ready(function(){ $('#myTable').dataTable(); }); </script> </body> </html>