Your IP : 18.118.184.36


Current Path : /home/lentoinv/churchmr.com/report/
Upload File :
Current File : /home/lentoinv/churchmr.com/report/generalattendance.php

<?php
session_start(); ob_start();
    error_reporting(0); 
  @ini_set('display_error', 0); 

  include("../cludes/connect.inc.php");
	
	$page = 67;

  if(isset($_POST['gidx'])){  $_SESSION['gidx'] = $_POST['gidx']; } 
$gidx = isset($_SESSION['gidx'])?$_SESSION['gidx']:'';

			  
if(isset($_POST['date'])){  $_SESSION['date'] = $_POST['date'];	} 
$date = isset($_SESSION['date'])?$_SESSION['date']:'';

if(array_key_exists('search', $_POST)){
$_SESSION['from'] = $_POST['from'];
$_SESSION['to'] = $_POST['to'];
  }
$from = isset($_SESSION['from'])?$_SESSION['from']:'';
$to = isset($_SESSION['to'])?$_SESSION['to']:'';

if(array_key_exists('searchx', $_POST)){
$_SESSION['fromx'] = $_POST['from'];
$_SESSION['tox'] = $_POST['to'];
  }
$fromx = isset($_SESSION['fromx'])?$_SESSION['fromx']:'';
$tox = isset($_SESSION['tox'])?$_SESSION['tox']:'';

     function attStatus($id,$ymd){
       global $db;
$qur=$db->query("SELECT * FROM attendance WHERE id='$id' AND ymd = '$ymd' ")or die(mysqli_error());
        $r=mysqli_num_rows($qur);   
    return $r;   
     }

function totalCount($from,$to,$day){
  global $db;
  $sql=$db->query("SELECT * FROM progs WHERE day = '$day' AND ymd >= '$from' AND ymd <= '$to' " )or die(mysqli_error());
  return mysqli_num_rows($sql); 
}

function totalPresent($id,$from,$to){
  global $db;
  $sql=$db->query("SELECT * FROM attendance WHERE day = 'Sat' AND id = '$id' AND ymd >= '$from' AND ymd <= '$to' " )or die(mysqli_error());
  return mysqli_num_rows($sql); 
}

$dd=date('d');
$mm=date('m');
$yy=date('y');

$ymd=date('ymd');
$ym=date('ym');




if(array_key_exists('postt', $_POST)){


$id=$_POST['present'];

$N = count($id);
for($i=0; $i < $N; $i++)
{
  $idx = $id[$i];
  $did = user($idx,'did');
if(attStatus($idx,$date)==0){
  $result = $db->query("INSERT INTO attendance (did,gid,ymd,id,day) VALUES ('$did','$gidx','$date','$idx','Sat')  ");
}

}
}

if(array_key_exists('unmark', $_POST)){


$id=$_POST['present'];

$N = count($id);
for($i=0; $i < $N; $i++)
{
  $idx = $id[$i];
  $did = user($idx,'did');

  $result = $db->query("DELETE FROM attendance WHERE id='$idx' AND ymd = '$date' ");

}
}



	 

?>


<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Attendance Reports</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- daterange picker -->
    <link rel="stylesheet" href="../plugins/daterangepicker/daterangepicker-bs3.css">
    <!-- iCheck for checkboxes and radio inputs -->
    <link rel="stylesheet" href="../plugins/iCheck/all.css">
    <!-- Bootstrap Color Picker -->
    <link rel="stylesheet" href="../plugins/colorpicker/bootstrap-colorpicker.min.css">
    <!-- Bootstrap time Picker -->
    <link rel="stylesheet" href="../plugins/timepicker/bootstrap-timepicker.min.css">
    <!-- Select2 -->
    <link rel="stylesheet" href="../plugins/select2/select2.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="../dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="../dist/css/skins/_all-skins.min.css">


  </head>
  <body class="hold-transition skin-blue sidebar-mini">
    <div class="wrapper">
<?php  require('header.php');  ?>

      <!-- Left side column. contains the logo and sidebar -->
<?php  require('sidebar.php');  ?>
      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
           Leaders/Workers Attendance Reports
            
          </h1>
         <ol class="breadcrumb">
            <li><i class="fa fa-dashboard"></i> Setup</li>
           <!-- <li class=""> <?php echo $ro['reg']; ?></li>-->
            <li class="active"><?php echo gName($gidx); ?></li>
            
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">  

          <div class="row">   
              
               <div class="col-md-4 col-sm-6 col-xs-12">
           <div class="box">
                <div class="box-header">
                  <h3  class="box-title">SELECT GROUP [<?php echo strtoupper(gName($gidx)) ?>]</h3>  
                     <h3  class="box-title"> </h3> 
                   </div>
              <div class="panel-body">
<form  method="post">
  <p>             
              <select name="gidx" class="form-control select2"  onchange="submit()">
                         
                        
                   <option value="">SELECT GROUP </option> 
                   <?php  
          $queryy=$db->query("SELECT * FROM zone WHERE rid = '$rid'  ORDER BY zone ASC " )or die(mysqli_error());  
           while($row=mysqli_fetch_array($queryy)){ ?>
                    
                           <option value="<?php echo $row['sn'] ;  ?>" <?php if($row['sn']==$gidx){ echo 'selected' ; } ?>><?php echo strtoupper($row['zone']) ;  ?></option>
                            <?php  }  ?>
                        </select>
                    </form>

       </p>
       
        
      


                </div><!-- /.tab-content -->
              </div><!-- /.box -->

              </div>
              
            
            
            
            
            
  
            
            
         
           
  
             <div class="col-md-4 col-sm-6 col-xs-12">
           <div class="box">
                <div class="box-header">
                  <h3  class="box-title">LEADERS MEETING ATTENDANCE </h3>  
              
              <form  method="post">
  
  <div class="col-md-4 no-padding">          
  From     
              <select name="from" class="form-control select2">
                         
                        
                   <option value="">SELECT DATE</option> 
                   <?php  
          $queryy=$db->query("SELECT * FROM progs WHERE day = 'Tue' AND yy = '$yy' AND ymd <= '$ymd' ORDER BY sn ASC " )or die(mysqli_error());  
           while($row=mysqli_fetch_array($queryy)){ ?>
                    
                           <option value="<?php echo $row['ymd'] ;  ?>" <?php if($row['ymd']==$fromx){ echo 'selected' ; } ?>><?php echo $row['date'] ;  ?></option>
                            <?php  }  ?>
                        </select>

                      </div>

                       <div class="col-md-4 no-padding">          
  To     
              <select name="to" class="form-control select2" >
                         
                        
                   <option value="">SELECT DATE</option> 
                   <?php  
          $queryy=$db->query("SELECT * FROM progs WHERE day = 'Tue' AND yy = '$yy' AND ymd <= '$ymd' ORDER BY sn ASC " )or die(mysqli_error());  
           while($row=mysqli_fetch_array($queryy)){ ?>
                    
                           <option value="<?php echo $row['ymd'] ;  ?>" <?php if($row['ymd']==$tox){ echo 'selected' ; } ?>><?php echo $row['date'] ;  ?></option>
                            <?php  }  ?>
                        </select>

                      </div>
                      <div class="col-md-4 no-padding"> <br>
                        <button type="submit" class="btn btn-primary form-control" name="searchx" >SEARCH</button>
                      </div>


                    </form>
                   </div>
                   <?php if(totalCount($fromx,$tox,'Tue')==1){ $datex=$fromx; ?> 
                    <div class="box-body">
                 
                     <?php $querr=$db->query("SELECT * FROM mdata WHERE gid = '$gidx' AND leader=1 " ); $gnumx = mysqli_num_rows($querr);  ?> 
                 
                  <table class="table table-bordered ">
                    <thead>
                         <tr>
                            <th>District</th>
                         <th>Total</th>
                          <th>Present</th>
                          <!---  <th>SECTION</th>  --->
<th>Remark</th>
                            
                          </tr>
                    </thead>
                    <tbody>
 <?php $i=1; $quer=$db->query("SELECT * FROM attendance WHERE gid = '$gidx' AND ymd='$fromx' " ); 
 $gnum = mysqli_num_rows($quer);

              $query=$db->query("select * FROM district WHERE gid = '$gidx' ORDER BY district ASC " )or die(mysqli_error());
              while($row=mysqli_fetch_array($query)){
              $did = $row['sn'];
              $sql=$db->query("SELECT * FROM mdata WHERE did = '$did' AND leader=1 " ); $dnum = mysqli_num_rows($sql);

              $e=$i++ ;
              ?>
                          <tr class="odd gradeX">
                         
                            <td><?php echo $row['district']; ?></td>
                            <td><?php echo $dnum; ?></td>
                            <td><?php $quer=$db->query("select * FROM attendance WHERE did = '$did' AND ymd='$fromx' " ); $num = mysqli_num_rows($quer);  echo $num; ?></td>
                           
                          <!---  <td></td>   --->
                            
                           
                            <td><?php echo number_format($num/$dnum*100,1); ?>%</td>
                          </tr>
                          <?php  } ?>
                          <tr><th>TOTAL</th><th><?php echo $gnumx; ?></th><th><?php echo $gnum; ?></th><th><?php echo number_format($gnum/$gnumx*100,1); ?>%</th></tr>
                     
                    </tbody>
                   
                  </table>
                </div><!-- /.box-body -->
              

       <?php } ?>
        <div class="panel-body">
       <?php if(isset($_SESSION['fromx'])){   ?>             

<h5><b><?php echo totalCount($fromx,$tox,'Tue') ?> WEEK(S): <?php echo ymdToDate($fromx).' - '.ymdToDate($tox) ?></b></h5>
        <form  method="post"> 
        <table width="100%" class="table">
 
 <tr><th>SN</th><th>NAME</th><th>YES</th><th>NO</th><th>REMARK</th></tr>
 <?php  $i=1; $per=0;
          $queryy=$db->query("SELECT * FROM mdata WHERE gid = '$gidx' AND leader=1 ORDER BY did ASC, surname ASC " )or die(mysqli_error());  
           while($row=mysqli_fetch_array($queryy)){ $e=$i++;  $id = $row['sn'];
$absent = totalCount($fromx,$tox,'Tue')-totalPresent($id,$fromx,$tox);
$remark = 100*totalPresent($id,$fromx,$tox)/totalCount($fromx,$tox,'Tue');
$per += $remark;
            $col = ($remark>=70)?'bgcolor="#C9FF99"':'';
            ?>
<tr <?php echo $col; ?>>
  <td><?php echo $e;  ?></td>
  <td><a href="tel:<?php echo $row['phone']; ?>"><?php echo userName($row['id']) ;  ?></a></td>
  <td><?php echo totalPresent($id,$fromx,$tox) ;  ?></td>
<td><?php echo $absent ;  ?></td>
<td><?php echo number_format($remark) ;  ?>%</td></tr>
<?php } ?>
<tr><th colspan="4">AVERAGE ATTENDANCE</th><th><?php echo number_format($per/$e,1); ?>%</th></tr>
</table>
<em>Leaders with remark of 70% or above  are highlighted</em>
         
                    


                     
                      
                  </form>   
      
<?php   } ?>



                </div><!-- /.tab-content -->
              </div><!-- /.box -->

          </div>


               <div class="col-md-4 col-sm-6 col-xs-12">
           <div class="box">
                <div class="box-header">
                  <h3  class="box-title">WORKERS TRAINING ATTENDANCE </h3>  
              
              <form  method="post">
  
  <div class="col-md-4 no-padding">          
  From     
              <select name="from" class="form-control select2">
                         
                        
                   <option value="">SELECT DATE</option> 
                   <?php  
          $queryy=$db->query("SELECT * FROM progs WHERE day = 'Sat' AND yy = '$yy' AND ymd <= '$ymd' ORDER BY sn ASC " )or die(mysqli_error());  
           while($row=mysqli_fetch_array($queryy)){ ?>
                    
                           <option value="<?php echo $row['ymd'] ;  ?>" <?php if($row['ymd']==$from){ echo 'selected' ; } ?>><?php echo $row['date'] ;  ?></option>
                            <?php  }  ?>
                        </select>

                      </div>

                       <div class="col-md-4 no-padding">          
  To     
              <select name="to" class="form-control select2" >
                         
                        
                   <option value="">SELECT DATE</option> 
                   <?php  
          $queryy=$db->query("SELECT * FROM progs WHERE day = 'Sat' AND yy = '$yy' AND ymd <= '$ymd' ORDER BY sn ASC " )or die(mysqli_error());  
           while($row=mysqli_fetch_array($queryy)){ ?>
                    
                           <option value="<?php echo $row['ymd'] ;  ?>" <?php if($row['ymd']==$to){ echo 'selected' ; } ?>><?php echo $row['date'] ;  ?></option>
                            <?php  }  ?>
                        </select>

                      </div>
                      <div class="col-md-4 no-padding"> <br>
                        <button type="submit" class="btn btn-primary form-control" name="search" >SEARCH</button>
                      </div>


                    </form>
                   </div>

                   <?php if(totalCount($from,$to,'Sat')==1){ $date=$from; ?> 

                   <div class="box-body">
                    
                 
                     <?php $querr=$db->query("SELECT * FROM mdata WHERE gid = '$gidx' AND worker=1 " ); $gnumx = mysqli_num_rows($querr);

                       ?> 
                 
                  <table class="table table-bordered ">
                    <thead>
                         <tr>
                            <th>District</th>
                         <th>Total</th>
                         <th>Present</th>
                          <!---  <th>SECTION</th>  --->
<th>Remark</th>
                            
                          </tr>
                    </thead>
                    <tbody>
 <?php $i=1; $quer=$db->query("select * FROM attendance WHERE gid = '$gidx' AND ymd='$date' " ); 
 $gnum = mysqli_num_rows($quer);



              $query=$db->query("select * FROM district WHERE gid = '$gidx' ORDER BY district ASC " )or die(mysqli_error());
              while($row=mysqli_fetch_array($query)){
              $did = $row['sn'];
$sql=$db->query("SELECT * FROM mdata WHERE did = '$did' AND worker=1 " ); $dnum = mysqli_num_rows($sql);

              $e=$i++ ;
              ?>
                          <tr class="odd gradeX">
                         
                            <td><?php echo $row['district']; ?></td>
                            <td><?php echo $dnum; ?></td>
                           <td><?php $quer=$db->query("select * FROM attendance WHERE did = '$did' AND ymd='$date' " ); $num = mysqli_num_rows($quer);  echo $num; ?></td>
                          <!---  <td></td>   --->
                            
                           
                            <td><?php echo number_format($num/$dnum*100,1); ?>%</td>
                          </tr>
                          <?php  } ?>
                          <tr><th>TOTAL</th><th><?php echo $gnumx; ?></th><th><?php echo $gnum; ?></th><th><?php echo number_format($gnum/$gnumx*100,1); ?>%</th></tr>
                     
                    </tbody>
                   
                  </table>
                </div><!-- /.box-body -->

              <?php } ?>
              <div class="panel-body">

       
        
       <?php if(isset($_SESSION['from'])){   ?>             

<h5><b><?php echo totalCount($from,$to,'Sat') ?> WEEK(S): <?php echo ymdToDate($from).' - '.ymdToDate($to) ?></b></h5>
        <form  method="post"> 
        <table width="100%" class="table">
 
<tr><th>SN</th><th>NAME</th><th>YES</th><th>NO</th><th>REMARK</th></tr>
 <?php  $i=1; $per=0;
          $queryy=$db->query("SELECT * FROM mdata WHERE gid = '$gidx' AND worker=1 ORDER BY did ASC, surname ASC " )or die(mysqli_error());  
           while($row=mysqli_fetch_array($queryy)){ $e=$i++;  $id = $row['sn'];
$absent = totalCount($from,$to,'Sat')-totalPresent($id,$from,$to);
$remark = 100*totalPresent($id,$from,$to)/totalCount($from,$to,'Sat');
            $col = ($remark>=70)?'bgcolor="#C9FF99"':'';
            $per += $remark;
            ?>
<tr <?php echo $col; ?>>
  <td><?php echo $e;  ?></td>
  <td><a href="tel:<?php echo $row['phone']; ?>"><?php echo userName($row['id']) ;  ?></a></td>
  <td><?php echo totalPresent($id,$from,$to) ;  ?></td>
<td><?php echo $absent ;  ?></td>
<td><?php echo number_format($remark) ;  ?>%</td></tr>
<?php } ?>
<tr><th colspan="4">AVERAGE ATTENDANCE</th><th><?php echo number_format($per/$e,1); ?>%</th></tr>
</table>
<em>Workers with remark of 70% or above  are highlighted</em>
         
                    


                     
                      
                  </form>   
      
<?php   } ?>



                </div><!-- /.tab-content -->
              </div><!-- /.box -->

              </div>



              
           
          </div><!-- /.row -->

          <!-- =========================================================== -->


          </div><!-- /.row -->

        </section> <!-- /.content -->
      </div><!-- /.content-wrapper -->

     <?php  require('footer.php');  ?>

      <!-- Control Sidebar -->
    <?php // require('settingbar.php');  ?>
      <!-- Add the sidebar's background. This div must be placed
           immediately after the control sidebar -->
      <div class="control-sidebar-bg"></div>
    </div><!-- ./wrapper -->

    <!-- jQuery 2.1.4 -->
   <script src="../plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <!-- Select2 -->
    <script src="../plugins/select2/select2.full.min.js"></script>
    <!-- InputMask -->
    <script src="../plugins/input-mask/jquery.inputmask.js"></script>
    <script src="../plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
    <script src="../plugins/input-mask/jquery.inputmask.extensions.js"></script>
    <!-- date-range-picker -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
    <script src="../plugins/daterangepicker/daterangepicker.js"></script>
    <!-- bootstrap color picker -->
    <script src="../plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
    <!-- bootstrap time picker -->
    <script src="../plugins/timepicker/bootstrap-timepicker.min.js"></script>
    <!-- SlimScroll 1.3.0 -->
    <script src="../plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- iCheck 1.0.1 -->
    <script src="../plugins/iCheck/icheck.min.js"></script>
    <!-- FastClick -->
    <script src="../plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="../dist/js/app.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="../dist/js/demo.js"></script>
    <script>
      $(function () {
        //Initialize Select2 Elements
        $(".select2").select2();

        //Datemask dd/mm/yyyy
        $("#datemask").inputmask("dd/mm/yyyy", {"placeholder": "dd/mm/yyyy"});
        //Datemask2 mm/dd/yyyy
        $("#datemask2").inputmask("mm/dd/yyyy", {"placeholder": "mm/dd/yyyy"});
        //Money Euro
        $("[data-mask]").inputmask();

        //Date range picker
        $('#reservation').daterangepicker();
        //Date range picker with time picker
        $('#reservationtime').daterangepicker({timePicker: true, timePickerIncrement: 30, format: 'MM/DD/YYYY h:mm A'});
        //Date range as a button
        $('#daterange-btn').daterangepicker(
            {
              ranges: {
                'Today': [moment(), moment()],
                'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                'Last 30 Days': [moment().subtract(29, 'days'), moment()],
                'This Month': [moment().startOf('month'), moment().endOf('month')],
                'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
              },
              startDate: moment().subtract(29, 'days'),
              endDate: moment()
            },
        function (start, end) {
          $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
        }
        );

        //iCheck for checkbox and radio inputs
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
          checkboxClass: 'icheckbox_minimal-blue',
          radioClass: 'iradio_minimal-blue'
        });
        //Red color scheme for iCheck
        $('input[type="checkbox"].minimal-red, input[type="radio"].minimal-red').iCheck({
          checkboxClass: 'icheckbox_minimal-red',
          radioClass: 'iradio_minimal-red'
        });
        //Flat red color scheme for iCheck
        $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
          checkboxClass: 'icheckbox_flat-green',
          radioClass: 'iradio_flat-green'
        });

        //Colorpicker
        $(".my-colorpicker1").colorpicker();
        //color picker with addon
        $(".my-colorpicker2").colorpicker();

        //Timepicker
        $(".timepicker").timepicker({
          showInputs: false
        });
      });
	  
	  
	  
    </script>
    
    

  </body>
</html>

?>