JezK
Edit File: attendance.php
<?php session_start(); include("session_check.php"); include("menuheader.php"); include_once("school_admin_access_file.php"); if(!(in_array(1,$access) && in_array(1,$allow))) echo "<script>location.replace('dashboard.php');</script>"; $class_id =$_GET['classid']; $school_id =$_SESSION['child']['log_school_id']; //school_id $academic_id=$_SESSION['child']['choosen_academic_id']; // academic_year_id $user_id =$_SESSION['child']['auth_id']; $chosen_academic_id=$_SESSION['child']['choosen_academic_id']; //user_id $fun=new adminaccess(); ///////////////////////////////////// checking school existance in system $timeout=$fun->check_my_status($_SESSION['child']['log_school_id']); if($timeout==0) echo "<script>location.replace('logout.php');</script>"; ///////////////////////////////////// if(isset($_GET['classid']) && isset($_GET['sec_id']) && isset($_GET['date'])) { $details2=$fun->school_attendance($_GET['classid'],$_GET['sec_id'],$school_id,$academic_id,$_GET['date']); } $sections=$fun->get_sections($_GET['classid'],$academic_id); $chosen_date=$fun->get_current_academicyear_id($chosen_academic_id,$school_id); if($sections) { foreach($sections as $row) { if($_GET['sec_id']==$row['section_id']) { $secs .= "<option value='{$row['section_id']}' selected>{$row['section_name']}</option>"; } else { $secs .="<option value='{$row['section_id']}' >{$row['section_name']}</option>"; } } } $details=$fun->get_classes($school_id,$academic_id); if($details) { foreach($details as $row) { if($_GET['classid']==$row['class_id']) { $classes_list.= "<option value='{$row['class_id']}' selected>{$row['class_name']}</option>"; } else { $classes_list.= "<option value='{$row['class_id']}' >{$row['class_name']}</option>"; } } } ?> <style> 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; } select { width: 62px !important; background-color: #FFF; border: 1px solid #CCC; } .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; } .rad, .ckb{ cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; } .rad > input, .ckb > input{ /* HIDE ORG RADIO and CHECKBOX */ visibility: hidden; position: absolute; } /* RADIO and CHECKBOX STYLES */ .rad > i, .ckb > i{ /* DEFAULT STYLE */ display: inline-block; vertical-align: middle; width: 16px; height: 16px; border-radius: 50%; transition: 0.2s; box-shadow: inset 0 0 0 8px #fff; border: 1px solid gray; background: gray; } /* CHECKBOX OVERWRITE STYLES */ .ckb > i { width: 25px; border-radius: 3px; } .rad:hover > i{ /* HOVER STYLE */ box-shadow: inset 0 0 0 -1px #fff; background: gray; } .rad > input:checked + i{ /* (RADIO CHECKED) STYLE */ box-shadow: inset 0 0 0 -1px #fff; background: #BDF900; } .rad2, .ckb{ cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; } .rad2 > input, .ckb > input{ /* HIDE ORG RADIO and CHECKBOX */ visibility: hidden; position: absolute; } /* RADIO and CHECKBOX STYLES */ .rad2 > i, .ckb > i{ /* DEFAULT STYLE */ display: inline-block; vertical-align: middle; width: 16px; height: 16px; border-radius: 50%; transition: 0.2s; box-shadow: inset 0 0 0 8px #fff; border: 1px solid gray; background: gray; } /* CHECKBOX OVERWRITE STYLES */ .ckb > i { width: 25px; border-radius: 3px; } .rad2:hover > i{ /* HOVER STYLE */ box-shadow: inset 0 0 0 -1px #fff; background: gray; } .rad2 > input:checked + i{ /* (RADIO CHECKED) STYLE */ box-shadow: inset 0 0 0 -1px #fff; background:#FE001E; } .rad3, .ckb{ cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; } .rad3 > input, .ckb > input{ /* HIDE ORG RADIO and CHECKBOX */ visibility: hidden; position: absolute; } /* RADIO and CHECKBOX STYLES */ .rad3 > i, .ckb > i{ /* DEFAULT STYLE */ display: inline-block; vertical-align: middle; width: 16px; height: 16px; border-radius: 50%; transition: 0.2s; box-shadow: inset 0 0 0 8px #fff; border: 1px solid gray; background: gray; } /* CHECKBOX OVERWRITE STYLES */ .ckb > i { width: 25px; border-radius: 3px; } .rad3:hover > i{ /* HOVER STYLE */ box-shadow: inset 0 0 0 -1px #fff; background: gray; } .rad3 > input:checked + i{ /* (RADIO CHECKED) STYLE */ box-shadow: inset 0 0 0 -1px #fff; background:#FFB501; } </style> <body style="overflow-x: hidden;"> <div class="overflow"> <div class="row" style="margin-top: 30px; margin-left:1px;"> <div class="col-md-9 text-left" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:24px;"> <img src="images/attendence-black@2x.png" title ="Student Attendance"style="margin: -8px 0px 0px -13px;"></i>Student Attendance </div> <div class="col-md-2 text-center"> <button type="button" onClick="location.href='monthly_attendance.php'" class="btn btn-default" style="margin-right:20px;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;"> Month Wise Attendance </button> </div> </div> <form method="post" action="update.php"> <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; ">Class</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-control" id="classes" name="classes" style="height:29px; width:295px!important;font-size:12px;" tabindex="2" > <option value='0'>--Select Class--</option> <?php echo $classes_list;?> </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; ">Section</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-control" id="sections" name="sections" style="height:29px; width:295px!important;font-size:12px;" tabindex="2" > <option value='0' selected>--Select Section--</option> <?php echo $secs;?> </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 class="class"> <div class="form-group col-md-6" style="margin-bottom:1.0%; clear:both;"> <div class="col-md-4 col-md-offset-1 text-right"> <b style="color:#666666;">Date</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-7 "> <div id="datetimepicker" class="input-append date"> <input type="text" style="height:30px; width:268px;font-size:13px;" tabindex="5" id="datepicker" value="<?php if($_GET['date']!='') echo $_GET['date'];else echo date('d/m/Y');?>" id="datepicker" name="datepicker"> <span class="add-on" style="height:30px; "> <i class="icon-calendar"></i></span> </div> <!-- if there is an error--> <div class="col-md-10" id="err_attndate" style="color:#990000;margin-left:-15px;"></div> <!--- end error--> </div> </div> </div> <input type="hidden" id="start_dated" name="start_dates" value="<?php echo $chosen_date['start_date'];?>" > <input type="hidden" id="end_dated" name="end_dates" value="<?php echo $chosen_date['end_date'];?>" > <input type="hidden" id="now_dated" name="now_dates" value="<?php echo date('Y-m-d');?>"> <input type="hidden" id="stc" name="stc" value="<?php echo count($details2);?>"> <div class="col-md-12 text-right"> </div> <!------------------------------------------- <php if($_GET['date']=='') echo date('d/m/Y');else echo $_GET['date'];?> -------------------------------------------------------> <input type="hidden" name="rolls" id="rolls"> <input type="hidden" name="stdnts" id="stdnts"> <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" style="vertical-align:middle;">Sl.No</th> <th style="vertical-align:middle;">Student Roll Number</th> <th style="vertical-align:middle;">Student Name</th> <th style="vertical-align:middle;">Attendance Status</th> <th> <span style="margin-left:5px;">P</span><span style="margin-left:10px;">A</span><span style="margin-left:11px;">L</span><br> <img src="images/green_new.png" /> <img src="images/red_new.png" /> <img src="images/orange_new.png" /></th> </tr> </thead> <tbody id="myTable_tbody"> <?php $i=1; if($details2) { foreach($details2 as $record) { if($record['status']=='P') { $leave_details='Present'; $data_value = "P"; } else if($record['status']=='A') { $leave_details='<a href="#" data-target="#pwdModal1" data-toggle="modal" id="'.$record['student_id'].'" name="'.$record['student_name'].'" onclick="absent_details(this.id)" style="font-weight:bold;text-decoration:underline;">Absent</a>'; $data_value = "A"; } else if($record['status']=='L') { $leave_details = '<a href="#" data-target="#pwdModal" data-toggle="modal" id="'.$record['student_id'].'" name="'.$record['student_name'].'" onclick="leave_details(this.id)" style="font-weight:bold;text-decoration:underline;">Leave</a>'; $data_value = "L"; } else { $leave_details='-'; $data_value = "-"; } $names = "student".$record['student_id']; ?> <tr> <td class="col-sm-1" style=" font-size:14px;"><?php echo $i?></td> <td style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px;"> <?php echo $record[student_rollno]?></td> <td style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px;"><?php echo $record[student_name]?></td> <td style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px;"><?php echo $leave_details?></td> <td> <div class="atncls"> <label class="rad"> <input type="radio" name="<?php echo $names?>" id="<?php echo $names?>1" value="P" onclick="changeImage(<?php echo $record['student_id']?>,this.value,this);" <?php if($record['status']=='P') echo "checked=checked";?>> <i></i> </label> <label class="rad2"> <input type="radio" name="<?php echo $names?>" id="<?php echo $names?>3" value="A" onclick="changeImage(<?php echo $record['student_id']?>,this.value,this);" <?php if($record['status']=='A') echo "checked=checked";?>> <i></i> </label> <label class="rad3"> <input type="radio" name="<?php echo $names?>" id="<?php echo $names?>2" value="L" onclick="changeImage(<?php echo $record['student_id']?>,this.value,this);" <?php if($record['status']=='L') echo "checked=checked";?>> <i></i> </label> <br> </div> <input type="hidden" value="<?php echo '('.$record['student_name'].','.$record['student_rollno'].')';?>" id="atncls<?php echo $i?>"> </td> </tr> <?php $i++; } } else { //echo "no data available"; } ?> </tbody> </table> </div> </div> <!------------------------------------------------------------------------------------------------------> <div class="form-group"> <div class="col-md-12" align="center"> <input type="submit" class="btn btn-default custom-button-width .navbar-right btnclr" tabindex="16" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; " value="Submit" onclick="return checkallset();"> <!--<button type="button" onclick="location.href='Attendance_view_popup.php'" class="btn btn-default custom-button-width .navbar-right" tabindex="17" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; " >Cancel</button>----> </div> </div> </form> <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> /* $(document).ready(function() { $('.mheader').removeClass('selected'); $('#pic2').addClass('selected'); $('#myTable').DataTable({ stateSave: true, dom: 'T<"clear">lfrtip', "iDisplayLength":500, "lengthMenu": [500], "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'); });*/ $(document).ready(function() { var classname=$('#classes').find('option:selected').text(); var secname=$('#sections').find('option:selected').text(); var ndt=$('#datepicker').val(); $('#myTable').DataTable( { dom: 'B<"clear">lfrtip', "iDisplayLength": 500, "lengthMenu": [500], stateSave: true, buttons: [ { extend: 'print', title: '<center><h3><?php echo $_SESSION['child']['school_name']?></h3></center>', message: 'Student Attendance<br>Academic Year:<?php echo $_SESSION[child][choosen_year_name]?>   Class:'+classname+'   Section:'+secname+'   Date:'+ndt+'<br>', exportOptions: { columns: [ 0, 1, 2, 3 ] } }, { extend: 'pdfHtml5', title:'<?php echo $_SESSION['child']['school_name']?>', message: 'Student Attendance\nAcademic Year:<?php echo $_SESSION[child][choosen_year_name]?>\t Class:'+classname+'\tSection:'+secname+'\t Date:'+ndt+'\n', exportOptions: { columns: [ 0, 1, 2, 3 ] } }, { extend: 'excelHtml5', title:'<?php echo $_SESSION['child']['school_name']?>', exportOptions: { columns: [ 0, 1, 2, 3 ] } } ] } ); } ); </script> <!--<script type="text/javascript" src="http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.min.js"></script> <script type="text/javascript" src="http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.pt-BR.js"></script>--> <script type="text/javascript" src="js/bootstrap-datetimepicker.js" charset="UTF-8"></script> <script type="text/javascript" src="js/bootstrap-datetimepicker.fr.js" charset="UTF-8"></script> <script type="text/javascript"> $('#datetimepicker').datetimepicker({ format: 'dd/mm/yyyy', minView: 2, endDate: '+0d', pickTime: false }).on('changeDate', function() { $(this).datetimepicker('hide'); var nwdate=$("#now_dated").val(); var cudate=nwdate.split("-"); var done= $("#start_dated").val(); var dtwo = $("#end_dated").val(); var dayone = done.split('-'); var daytwo = dtwo.split('-'); var cmp= $("#datepicker").val(); var dcmp=cmp.split('/'); var mone=dayone[1]-1; var mtwos=daytwo[1]-1; var mcdate=dcmp[1]-1; var mcheck=cudate[1]-1; //alert(JSON.stringify(dcmp)); var dones = new Date(dayone[0],mone,dayone[2]); var dtwos = new Date(daytwo[0],mtwos,daytwo[2]); var cdate= new Date(dcmp[2],mcdate,dcmp[0]); var checkd= new Date(cudate[0],mcheck,cudate[2]); if(cdate>=dones && cdate<=dtwos) { if(cdate<=checkd) { getattendance(); } else { alert("You can not choose a Future date"); $("#datepicker").val(''); } } else { alert("Please choose the date within Chosen Academic Year"); $("#datepicker").val(''); var table='<tr>'; table+='<td colspan="5" align="center"><label style="margin: 0px 0px 0px 500px;">No Data Available</label></td>'; table+='</tr>'; $("#myTable_tbody").html(table); return false; } }); </script> <script> function datechecking() { var nwdate=$("#now_dated").val(); var cudate=nwdate.split("-"); var done= $("#start_dated").val(); var dtwo = $("#end_dated").val(); var dayone = done.split('-'); var daytwo = dtwo.split('-'); var cmp= $("#datepicker").val(); var dcmp=cmp.split('/'); var mone=dayone[1]-1; var mtwos=daytwo[1]-1; var mcdate=dcmp[1]-1; var mcheck=cudate[1]-1; //alert(JSON.stringify(dcmp)); var dones = new Date(dayone[0],mone,dayone[2]); var dtwos = new Date(daytwo[0],mtwos,daytwo[2]); var cdate= new Date(dcmp[2],mcdate,dcmp[0]); var checkd= new Date(cudate[0],mcheck,cudate[2]); if(cdate>=dones && cdate<=dtwos) { if(cdate<=checkd) { return true; } else { alert("You can not choose a Future date"); $("#datepicker").val(''); return false; } } else { alert("Please choose the date within Chosen Academic Year"); $("#datepicker").val(''); return false; } } $("#classes").change(function() { $('#err_class').text(''); if($(this).val() == 0) { $('#err_class').text("Please select Class"); $('#err_class').show(); return false; } else { //$('#datepicker').val(''); var x = $(this).val(); $.ajax({ url: "ajaxcalls_attn.php", type:"POST", data:"mode="+"choose_class"+"&data="+x, success: function(result) { //alert(result); //alert("success : "+result); var result2 = eval("("+result+")"); //alert(result2[0]); 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) { } }); } }); //script to get attendence of particular date $("#sections").change(function() { if(datechecking()) { getattendance(); } }); function leave_details(id) { var dt=$('#datepicker').val(); $.post('load_leave.php',{student_id:id,rdate:dt},function(data){ document.getElementById('pwdModal').innerHTML=data; }); } function absent_details(id) { var dt=$('#datepicker').val(); $.post('load_absent.php',{student_id:id,rdate:dt},function(data){ document.getElementById('pwdModal1').innerHTML=data; }); } function getattendance() { $('#err_class').text(''); $('#err_section').text(''); $('#err_attndate').text(''); if($("#classes").val() == 0) { $('#err_class').text("Please select Class"); $('#err_class').show(); return false; } else if($("#sections").val() ==0) { $('#err_section').text("Please select Section"); $('#err_section').show(); return false; } else if($("#datepicker").val() == "") { $('#err_attndate').text("Please select Date"); $('#err_attndate').show(); return false; } else { var cls=$("#classes").val(); var dt=$( "#datepicker" ).val(); var sec_id=$("#sections").val(); window.location.href="attendance.php?classid="+cls+"&date="+dt+"&sec_id="+sec_id; //$("#students").load("load_new.php",{classid:cls,date:dt,sec_id:sec_id},function(data){}); } } function changeImage(id,val,cid) { var yes=0; var confmstd=[]; var fmtion=id+'-'+val; var mainstr=document.getElementById('stdnts').value; if(cid.checked==true) { if(mainstr!='') { mainstr=mainstr.substring(0, mainstr.length - 1); var strobj=mainstr.split(','); for(i=0,j=0;i<strobj.length;i++) { confmstd[j]=strobj[i]; var spl=strobj[i].split('-'); if(id==spl[0]) { confmstd[j]=id+'-'+val; yes=1; } j++; } if(yes==0) { var fin=confmstd.join(','); document.getElementById('stdnts').value =fin+','+id+'-'+val+','; } else { var fin=confmstd.join(','); document.getElementById('stdnts').value =fin+','; } } else { document.getElementById('stdnts').value += id+'-'+val+','; } } } function checkallset() { var err=0; var stds=0; var present=[]; var leave=[]; var absent=[]; var i=0; var j=1; var p=0,l=0,a=0; $('#err_class').text(''); $('#err_section').text(''); $('#err_attndate').text(''); if($("#classes").val() == 0) { $('#err_class').text("Please select Class"); $('#err_class').show(); return false; } else if($("#sections").val() ==0) { $('#err_section').text("Please select Section"); $('#err_section').show(); return false; } else if($("#datepicker").val() == "") { $('#err_attndate').text("Please select Date"); $('#err_attndate').show(); return false; } x=$('#stc').val(); $('.atncls').each(function() { if($(this).find('input[type="radio"]:checked').length > 0) { cstatus=$(this).find('input[type="radio"]:checked').val(); k=$('#atncls'+j).val(); if(cstatus=='P') { present[p]=k; p++; } else if(cstatus=='L') { leave[l]=k; l++; } else if(cstatus=='A') { absent[a]=k; a++; } stds++; i++; j++; } else { err=1; } }); if(err==1) { alert('Attendance for all students have not been taken. Please ensure Attendance of every single student in the class is taken before submission'); return false; } else if(stds!=x) { alert('Attendance for all students have not been taken. Please ensure Attendance of every single student in the class is taken before submission'); return false; } else { if(a==0) a='\n No. of Students Absent: '+a+'\n'; else a='\n No. of Students Absent: '+a+'\n'+absent.toString()+'\n'; if(l==0) l='\n No. of Students on Leave: '+l; else l='\n No. of Students on Leave: '+l+'\n'+leave.toString(); yy=' No. of Students Present: '+p+'\n'+a+l; //alert(JSON.stringify(present)+'\n'+JSON.stringify(leave)+'\n'+JSON.stringify(absent)); 'Do you want to submit the Attendance ?' if(confirm(yy)) { return true; } else { return false; } } } </script> <!--modal dialog for leave details--> <div id="pwdModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" data-width="760"> <p> </p> </div> <!--modal dialog for absent details--> <div id="pwdModal1" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" data-width="760"> <p> </p> </div> </div> </body> </html>