MMCT TEAM
Server IP : 2a02:4780:3:1378:0:3736:a38e:10  /  Your IP : 18.221.201.67
Web Server : LiteSpeed
System : Linux sg-nme-web1278.main-hosting.eu 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User : u926327694 ( 926327694)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u926327694/domains/smsoft.in/public_html/smart/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u926327694/domains/smsoft.in/public_html/smart/daily_report.php
<?php
if(isset($_GET['code']) && isset($_GET['session_year']))
{
    $code=$_GET['code'];
    $session_year = $_GET['session_year'];
    include'config.php';
    $sel_school=mysqli_query($con,"select * from schools where school_code='$code'");
    $main_username="";
    $main_password="";
    $main_dbname="";
    $endingDate = '';
    while($row_school=mysqli_fetch_array($sel_school))
    {
        $main_username=$row_school['db_user'];
        $main_password=$row_school['db_pwd'];
        $main_dbname=$row_school['db'];
        $endingDate = $row_school['expiry_date'];
    }
    
    $oneWeekBeforeEndDate = strtotime($endingDate . ' -1 week');
    $oneWeekBeforeEndDate1 = strtotime($endingDate);
    $todayTime = strtotime("now");
    if ($todayTime >= $oneWeekBeforeEndDate && $todayTime <= $oneWeekBeforeEndDate1) {
        echo '<script>alert("Your license is expire in 7 days. Please make a payment to renew and continue using it.");</script>';
    }
    
    if ($todayTime > $oneWeekBeforeEndDate1) {
        echo '<script>alert("Your license is expired. Please make a payment to renew and continue using it.");</script>';
        exit;
    }
    
    $con_school=mysqli_connect("localhost",$main_username,$main_password,$main_dbname);
    if (!$con_school)
    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error(); exit;
    }
    
    $session_id = 0;
    $sel_session = mysqli_query($con_school,"select * from sessions where session='$session_year'");
    while($row_session = mysqli_fetch_array($sel_session)) {
        $session_id = $row_session['id'];
    }
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Attendance Report</title>
    <link href="https://smsoft.in/demo/student_management_system/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://smsoft.in/demo/student_management_system/vendor/metisMenu/metisMenu.min.css" rel="stylesheet">
    <link href="https://smsoft.in/demo/student_management_system/vendor/datatables-plugins/dataTables.bootstrap.css" rel="stylesheet">
    <link href="https://smsoft.in/demo/student_management_system/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">
    <link href="https://smsoft.in/demo/student_management_system/dist/css/sb-admin-2.css" rel="stylesheet">
    <link href="https://smsoft.in/demo/student_management_system/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <style>
        .big-checkbox {
            transform: scale(1.2);
            cursor:pointer;
        }
.others {
    color:green
}
.others1 {
    color:red
}
#wrapper {
    width: calc(100% - 10px);
    padding: 5px;
}
</style>
</head>
<body>
    <div id="wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <b>Attendance Report Filter</b>
                        </div>
                        <div class="panel-body">
                            <div class="row">
							<form role="form" action="" method="post">
								<div class="col-lg-2">
                                        <div class="form-group">
                                            <label>Date</label>
											<?php
											date_default_timezone_set('Asia/Kolkata');
								$timestamp = time();
								$date_time = date("Y-m-d", $timestamp);
								$res1=mysqli_query($con_school,"select class,id from classes where `class`!=''");
								$res13=mysqli_query($con_school,"select section,id from sections where `section`!=''");
							 ?>
                                            <input type="date" name="att_date" class="form-control" value="<?php  echo $date_time; ?>" required />
                                        </div>
                                      
                                </div>
                                <div class="col-lg-2">
                                        <div class="form-group">
                                            <label style="width:100%;">Staff Attendance</label>
                                            <input type="checkbox" name="is_staff_att" class="is_staff_att big-checkbox" value="1" />
                                            
                                            </select>
                                        </div>
                                </div>
                                <div class="col-lg-2 staff_att_on">
                                        <div class="form-group">
                                            <label>Class</label>
                                            <select class="form-control" name='att_class' required >
                                                <option value="0">All</option>
                                                <?php
                                                while($res_class=mysqli_fetch_array($res1))
                                                {
                                                ?>
                                                <option  value="<?php  echo $res_class['id']; ?>" ><?php echo $res_class['class']; ?></option>
                                                <?php
                                                }
                                                ?>
                                            </select>
                                        </div>
                                </div>
								<div class="col-lg-2 staff_att_on">
                                        <div class="form-group">
                                            <label>Division</label>
                                            <select class="form-control" name='att_division' required>
                                                <option value="0">All</option>
                                                <?php
                                                while($res_section=mysqli_fetch_array($res13))
                                                {
                                                ?>
                                                <option value="<?php echo $res_section['id']; ?>"  ><?php echo $res_section['section']; ?></option>
                                                <?php
                                                }
                                                ?>
                                            </select>
                                        </div>
                                </div>
                                <div class="col-lg-3">
                                    <div class="form-group">
                                        <label style="width:100%;">&nbsp;</label>
								        <button type="submit" name="btnSearch" class="btn btn-default">Present</button>
								        <button type="submit" name="btnAbsentReport" class="btn btn-default">Absent</button>
								        <button type="submit" name="btnPanchRecord" class="btn btn-default">Panch Records</button>
								    </div>
								</div>
							</form>
                            </div>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            
			<?php  
			if(isset($_POST['btnSearch']))
			{
			    $att_date=$_POST['att_date'];
				$att_class=$_POST['att_class'];
				$att_division=$_POST['att_division'];
				$is_staff_att=isset($_POST['is_staff_att']) ? $_POST['is_staff_att'] : 0;
			?>
				 
				
					<div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-lg-6">
                                    <b>Present Attendance Report (<?php echo Date('d-m-Y',strtotime($att_date))." / ".Date('l',strtotime($att_date)); ?>)</b>
                                </div>
                                <?php
                                    $total_studs = 0;
                                    $present_studs = 0;
                                    $absent_studs = 0;
                                    if($is_staff_att == "0") {
                                        $pstuds_res=mysqli_query($con_school,"SELECT att.id FROM bio_attendance as att inner join students as st on att.RFID = st.weight inner join student_session as ss on ss.student_id = st.id and ss.session_id=$session_id and (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0) where att.date = '$att_date' AND (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0) AND att.status='PRESENT' AND att.is_staff=0");
                                        $present_studs = mysqli_num_rows($pstuds_res);
                                        
                                        $tstuds_res=mysqli_query($con_school,"SELECT st.id FROM students as st inner join student_session as ss on ss.student_id = st.id and ss.session_id=$session_id and (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0) where (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0)");
                                        $total_studs = mysqli_num_rows($tstuds_res);
                                        $absent_studs = $total_studs - $present_studs;
                                    }
                                    else {
                                        $pstuds_res=mysqli_query($con_school,"SELECT att.id FROM bio_attendance as att inner join staff as st on att.RFID = st.employee_id where att.date = '$att_date' AND att.status='PRESENT' AND att.is_staff=1");
                                        $present_studs = mysqli_num_rows($pstuds_res);
                                        
                                        $tstuds_res=mysqli_query($con_school,"SELECT st.id FROM staff as st");
                                        $total_studs = mysqli_num_rows($tstuds_res);
                                        $absent_studs = $total_studs - $present_studs;
                                    }
                                ?>
                                <div class="col-lg-6">
                                    <b>Total : <?php echo $total_studs; ?> | </b>
                                    <b>Present : <?php echo $present_studs; ?> | </b>
                                    <b>Absent : <?php echo $absent_studs; ?></b>
                                </div>
                            </div>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="table-responsive">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="example">
                                <thead>
                                    <tr>
                                        <?php if($is_staff_att == "0") { ?>
                                        <th>Roll No. / RFID</th>
                                        <th>Name</th>
                                        <th>Class</th>
                                        <th>Division</th>
                                        <?php } else { ?>
                                        <th>RFID</th>
                                        <th>Name</th>
                                        <?php } ?>
                                        <th>Date / Day</th>
                                        <th>In Time</th>
                                        <th>Out Time</th>
                                        <th>Status</th>
                                    </tr>
                                </thead> 
                                <tbody>
								  <?php
								  $sel_st = '';
								  if($is_staff_att == "0") {
    								  $sel_st = "SELECT *, att.status as att_status FROM bio_attendance as att inner join students as st on att.RFID = st.weight inner join student_session as ss on ss.student_id = st.id and ss.session_id=$session_id and (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0) inner join classes as cl on cl.id = ss.class_id inner join sections as divi on divi.id = ss.section_id where att.date = '$att_date' AND (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0)  AND att.is_staff=0";
								  }
								  else {
								      $sel_st = "SELECT *, att.status as att_status FROM bio_attendance as att inner join staff as st on att.RFID = st.employee_id where att.date = '$att_date' AND att.is_staff=1";
								  }
								   if(!$class_res=mysqli_query($con_school,$sel_st))
    								{
    									echo("Error description: " . mysqli_error($con_school));
    								}
									while ($d=mysqli_fetch_array($class_res))
									{  
								        $timeFormatted_IN_TIME = "00:00:00";
								        if($d['in_time'] != "00:00:00") {
    								        $time_IN_TIME = DateTime::createFromFormat("H:i:s", $d['in_time']);
    								        $timeFormatted_IN_TIME = $time_IN_TIME->format("h:i:s A");
								        }
								        
								        $timeFormatted_OUT_TIME = "00:00:00";
								        if($d['out_time'] != "00:00:00") {
    								        $time_OUT_TIME = DateTime::createFromFormat("H:i:s", $d['out_time']);
    								        $timeFormatted_OUT_TIME = $time_OUT_TIME->format("h:i:s A");
								        }
								?>	<tr>
								        <?php if($is_staff_att == "0") { ?>
								        <td><?php echo $d['roll_no']. " / ". $d['RFID']; ?></td>
								        <td><?php echo $d['firstname']." ".$d['middlename']." ".$d['lastname']; ?></td>
								        <td><?php echo $d['class']; ?></td>
								        <td><?php echo $d['section']; ?></td>
								        <?php } else { ?>
								        <td><?php echo $d['RFID']; ?></td>
								        <td><?php echo $d['name']; ?></td>
								        <?php } ?>
								        <td>
								            <?php 
								                echo Date('d-m-Y',strtotime($d['date']))." / ".Date('l',strtotime($d['date'])); 
								            ?>
								        </td>
								        <td><?php echo $timeFormatted_IN_TIME; ?></td>
								        <td><?php echo $timeFormatted_OUT_TIME; ?></td>
								        <td><?php echo $d['att_status']; ?></td>
								    </tr>
								  <?php
								 	}
								  ?>
						  </tbody>
                            </table>
                            </div>
                            <!-- /.table-responsive -->
                            <center>
								     
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
				
				<?PHP
			}
			?>
			
			<?php  
			if(isset($_POST['btnAbsentReport']))
			{
			    $att_date=$_POST['att_date'];
				$att_class=$_POST['att_class'];
				$att_division=$_POST['att_division'];
				$is_staff_att=isset($_POST['is_staff_att']) ? $_POST['is_staff_att'] : 0;
			?>
				 
				
					<div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-lg-6">
                                    <b>Absent Attendance Report (<?php echo Date('d-m-Y',strtotime($att_date))." / ".Date('l',strtotime($att_date)); ?>)</b>
                                </div>
                                <?php
                                    $total_studs = 0;
                                    $present_studs = 0;
                                    $absent_studs = 0;
                                    if($is_staff_att == "0") {
                                        $pstuds_res=mysqli_query($con_school,"SELECT att.id FROM bio_attendance as att inner join students as st on att.RFID = st.weight inner join student_session as ss on ss.student_id = st.id and ss.session_id=$session_id and (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0) where att.date = '$att_date' AND (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0) AND att.status='PRESENT' AND att.is_staff=0");
                                        $present_studs = mysqli_num_rows($pstuds_res);
                                        
                                        $tstuds_res=mysqli_query($con_school,"SELECT st.id FROM students as st inner join student_session as ss on ss.student_id = st.id and ss.session_id=$session_id and (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0) where (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0)");
                                        $total_studs = mysqli_num_rows($tstuds_res);
                                        $absent_studs = $total_studs - $present_studs;
                                    }
                                    else {
                                        $pstuds_res=mysqli_query($con_school,"SELECT att.id FROM bio_attendance as att inner join staff as st on att.RFID = st.employee_id where att.date = '$att_date' AND att.status='PRESENT' AND att.is_staff=1");
                                        $present_studs = mysqli_num_rows($pstuds_res);
                                        
                                        $tstuds_res=mysqli_query($con_school,"SELECT st.id FROM staff as st");
                                        $total_studs = mysqli_num_rows($tstuds_res);
                                        $absent_studs = $total_studs - $present_studs;
                                    }
                                ?>
                                <div class="col-lg-6">
                                    <b>Total : <?php echo $total_studs; ?> | </b>
                                    <b>Present : <?php echo $present_studs; ?> | </b>
                                    <b>Absent : <?php echo $absent_studs; ?></b>
                                </div>
                            </div>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="table-responsive">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="example">
                                <thead>
                                    <tr>
                                        <?php if($is_staff_att == "0") { ?>
                                        <th>Roll No. / RFID</th>
                                        <th>Name</th>
                                        <th>Class</th>
                                        <th>Division</th>
                                        <?php } else { ?>
                                        <th>RFID</th>
                                        <th>Name</th>
                                        <?php } ?>
                                        <th>Date / Day</th>
                                        <th>Status</th>
                                    </tr>
                                </thead> 
                                <tbody>
								  <?php
								  $sel_st = '';
								  if($is_staff_att == "0") {
    								  $sel_st = "SELECT * FROM students as st inner join student_session as ss on ss.student_id = st.id and ss.session_id=$session_id and (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0) inner join classes as cl on cl.id = ss.class_id inner join sections as divi on divi.id = ss.section_id where (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0) and st.weight not in(SELECT att.RFID FROM bio_attendance as att inner join students as st on att.RFID = st.weight inner join student_session as ss on ss.student_id = st.id and ss.session_id=$session_id and (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0) where att.date = '$att_date' AND (ss.class_id = $att_class OR $att_class = 0) and (ss.section_id = $att_division OR $att_division = 0) AND att.status='PRESENT' AND att.is_staff=0)";
								  }
								  else {
								      $sel_st = "SELECT * FROM staff as st where employee_id not in (SELECT RFID FROM bio_attendance as att inner join staff as st on att.RFID = st.employee_id where att.date = '$att_date' AND att.is_staff=1)";
								  }
								   if(!$class_res=mysqli_query($con_school,$sel_st))
    								{
    									echo("Error description: " . mysqli_error($con_school));
    								}
									while ($d=mysqli_fetch_array($class_res))
									{  
								?>	<tr>
								        <?php if($is_staff_att == "0") { ?>
								        <td><?php echo $d['roll_no']. " / ". $d['weight']; ?></td>
								        <td><?php echo $d['firstname']." ".$d['middlename']." ".$d['lastname']; ?></td>
								        <td><?php echo $d['class']; ?></td>
								        <td><?php echo $d['section']; ?></td>
								        <?php } else { ?>
								        <td><?php echo $d['employee_id']; ?></td>
								        <td><?php echo $d['name']; ?></td>
								        <?php } ?>
								        <td>
								            <?php 
								                echo Date('d-m-Y',strtotime($att_date))." / ".Date('l',strtotime($att_date)); 
								            ?>
								        </td>
								        <td>Absent</td>
								    </tr>
								  <?php
								 	}
								  ?>
						  </tbody>
                            </table>
                            </div>
                            <!-- /.table-responsive -->
                            <center>
								     
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
				
				<?PHP
			}
			?>
			
			<?php  
			if(isset($_POST['btnPanchRecord']))
			{
			    $att_date=$_POST['att_date'];
			    $is_staff_att=isset($_POST['is_staff_att']) ? $_POST['is_staff_att'] : 0;
			?>
				 
				
					<div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <b>Punching Report</b>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="table-responsive">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="example">
                                <thead>
                                    <tr>
                                        <?php if($is_staff_att == "0") { ?>
                                        <th>Roll No. / RFID</th>
                                        <?php } else { ?>
                                        <th>RFID</th>
                                        <?php } ?>
                                        <th>Name</th>
                                        <th>Date / Day</th>
                                        <th>Panch Time</th>
                                    </tr>
                                </thead> 
                                <tbody>
								  <?php
								  $sel_query_punch = "SELECT * FROM `bio_attendance_log` as att inner join students as st on att.RFID = st.weight  where `date_of_transaction` = '$att_date'";
								  if($is_staff_att == "1") {
								      $sel_query_punch = "SELECT * FROM `bio_attendance_log` as att inner join staff as st on att.RFID = st.employee_id  where `date_of_transaction` = '$att_date'";
								  }
								   if(!$class_res=mysqli_query($con_school,$sel_query_punch))
    								{
    									echo("Error description: " . mysqli_error($con_school));
    								}
									while ($d=mysqli_fetch_array($class_res))
									{  
									    $timeFormatted_IN_TIME = "00:00:00";
								        if($d['time_in'] != "00:00:00") {
    								        $time_IN_TIME = DateTime::createFromFormat("H:i:s", $d['time_in']);
    								        $timeFormatted_IN_TIME = $time_IN_TIME->format("h:i:s A");
								        }
								?>	<tr>
								        <?php if($is_staff_att == "0") { ?>
								        <td><?php echo $d['roll_no']. " / ". $d['RFID']; ?></td>
								        <td><?php echo $d['firstname']." ".$d['middlename']." ".$d['lastname']; ?></td>
								        <?php } else { ?>
								        <td><?php echo $d['RFID']; ?></td>
								        <td><?php echo $d['name']; ?></td>
								        <?php } ?>
								        <td>
								            <?php 
								                echo Date('d-m-Y',strtotime($d['date_of_transaction']))." / ".Date('l',strtotime($d['date_of_transaction'])); 
								            ?>
								        </td>
								        <td><?php echo $timeFormatted_IN_TIME; ?></td>
								    </tr>
								  <?php
								 	}
								  ?>
						  </tbody>
                            </table>
                            </div>
                            <!-- /.table-responsive -->
                            <center>
								     
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
				
				<?PHP
			}
			?>
		
			
            <!-- /.row -->
        
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->


	
	
	
	
    <!-- jQuery -->
    <script src="https://smsoft.in/demo/student_management_system/vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="https://smsoft.in/demo/student_management_system/vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="https://smsoft.in/demo/student_management_system/vendor/metisMenu/metisMenu.min.js"></script>

    <!-- DataTables JavaScript -->
    
    <!-- Custom Theme JavaScript -->
    <script src="https://smsoft.in/demo/student_management_system/dist/js/sb-admin-2.js"></script>

 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/jquery.dataTables.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/dataTables.bootstrap.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/dataTables.buttons.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/buttons.bootstrap.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/jszip.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/pdfmake.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/vfs_fonts.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/buttons.html5.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/buttons.print.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/buttons.colVis.min.js"></script>
<script>
$(document).ready(function() {
    var table = $('#example').DataTable( {
        lengthChange: false,
        buttons: [ 'copy', 'excel', 'pdf', 'colvis' ]
    } );
 
    table.buttons().container()
        .appendTo( '#example_wrapper .col-sm-6:eq(0)' );
        
        $(".is_staff_att").change(function() {
           if($(this).prop("checked")) {
               $(".staff_att_on").hide();
           } 
           else {
               $(".staff_att_on").show();
           }
        });
} );
</script>
</body>

</html>
<?php
}
else
{
    echo"Pass school code and session year in url";
}
?>

MMCT - 2023