<?php
$tiga=$this->db->query("SELECT * from web_setting where id='1'");
foreach ($tiga->result() as $rt) {
$namsek=$rt->nama;
$logo=$rt->logo;
}
?>
<html lang="en">
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<head>
  <meta charset="utf-8">
  <title>Absensi <?php echo $namsek;?></title>
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <meta content="Metronic Shop UI description" name="description">
  <meta content="Metronic Shop UI keywords" name="keywords">
  <meta content="keenthemes" name="author">

  <meta property="og:site_name" content="Presensi Online">
  <meta property="og:title" content="Chung Chin">
  <meta property="og:description" content="Software, jaringan, Linux, Windows">
  <meta property="og:type" content="website">
  <meta property="og:image" content="-CUSTOMER VALUE-"><!-- link to image for socio -->
  <meta property="og:url" content="xwaja.my.id">

  <link rel="shortcut icon" href="favicon.ico">

   <!-- Global styles START -->
  <link href="assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet">
  <link href="assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <!-- Global styles END -->

  <!-- Page level plugin styles START -->
  <link href="assets/global/plugins/fancybox/source/jquery.fancybox.css" rel="stylesheet">
  <link href="assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css">
  <!-- Page level plugin styles END -->

  <!-- Theme styles START -->
  <link href="assets/global/css/components.css" rel="stylesheet">
  <link href="assets/global/css/plugins.css" rel="stylesheet">
  <link href="assets/frontend/layout/css/style.css" rel="stylesheet">
  <link href="assets/frontend/layout/css/style-responsive.css" rel="stylesheet">
  <link href="assets/frontend/layout/css/themes/red.css" rel="stylesheet" id="style-color">
  <link href="assets/frontend/layout/css/custom.css" rel="stylesheet">
  <script src="assets/js/fungsi.js" type="text/javascript"></script>
    <link rel="stylesheet" href="<?php echo base_url('assets/js/plugins/datatables/dataTables.bootstrap.css'); ?>">
	<script language="JavaScript" type="text/JavaScript">
	function MM_jumpMenu(targ,selObj,restore){ //v3.0
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}
	</script>
  <style type="text/css">
  th { text-center: center; }
  </style>
  <!-- Theme styles END -->
</head>
<!-- Head END -->

<!-- Body BEGIN -->
<body class="corporate">
    <!-- BEGIN HEADER -->
    <div class="header">
      <div class="container">
        <a class="site-logo" href="index"><img src="<?php echo base_url('assets/back/'.$logo.'');?>" height="38" alt="<?php echo $namsek;?>"><?php echo $namsek;?></a>

        <a href="javascript:void(0);" class="mobi-toggler"><i class="fa fa-bars"></i></a>

        <!-- BEGIN NAVIGATION -->
        <div class="header-navigation pull-right font-transform-inherit">
          <ul>
            <li>
              <a href="index.php">Home </a>

            </li>
            <li><a href="bulanan">Rekap Bulanan</a></li>
            <li class="active"><a href="rekapindividu">Rekap Individu</a></li>
            <li><a href="login">Login</a></li>

          </ul>
        </div>
        <!-- END NAVIGATION -->
      </div>
    </div>
    <!-- Header END -->

    <div class="main">
      <div class="container">
        <ul class="breadcrumb">
            <li><a href="index.php">Home</a></li>
            <li class="active">Rekap Absensi</li>
        </ul>
        <!-- BEGIN SIDEBAR & CONTENT -->
        <div class="row margin-bottom-20">
          <!-- BEGIN CONTENT -->
          <div class="col-md-12 col-sm-12">
            <div class="content-page">
			  <div class="row">
				<div class="col-md-12 ">
				<?php
				$jenis=$this->input->get('jenis');
				$mm=$this->input->get('mm');
				$yy=$this->input->get('yy');
				if (!$mm) $mm=date('m');
				if (!$yy) $yy=date('Y');
				$jmlhbulan=strlen($mm);
				if ($jmlhbulan ==1) {
					$mm='0'.$mm;
				}
				?>
				<center>
				<table><tr><td>BULAN</td><td>:</td><td>
					<select  name="mm" onChange="MM_jumpMenu('parent',this,0)">
						<?php if (!$mm=='') { ?>
							<option><?php echo bulan($mm);?></option>
						<?php } else {?>
						<?php }
							for ($i=1;$i<=12;$i++) {
										echo "<option value='?yy=$yy&mm=$i'>".bulan($i)."</option>";
						   } ?>

					</select>
					<select  name="yy" onChange="MM_jumpMenu('parent',this,0)">
						<?php if (!$yy=='') { ?>
							<option><?php echo $yy;?></option>
						<?php }
							for ($i=date("Y");$i>date('Y')-10;$i-=1){
										echo "<option value='?yy=$i&mm=$mm'>$i</option>";
						   } ?>

					</select>
					</td>
					<tr><td>TAMPILKAN</td><td> :</td><td>
						<select name="jenis" onChange="MM_jumpMenu('parent',this,0)">
						<?php if (!$jenis=='') {
								$jurusan1=$this->db->query("SELECT * FROM web_kelas WHERE kode='".$jenis."' ORDER BY urut ASC");
								foreach ($jurusan1->result() as $row1) {
								$nama1=$row1->nama;
								}
							?>

							<option><?php echo $nama1;?></option>
						<?php } else {?>
						<option selected>ALL</option>
						<?php }
						echo "<option value='?yy=$yy&mm=$mm&dd=$dd&jenis='>ALL</option>";
						$jurusan=$this->db->query("SELECT * FROM web_kelas ORDER BY urut ASC");
										foreach ($jurusan->result() as $row) {
										$kode=$row->kode;
										$nama=$row->nama;
										echo "<option value='?yy=$yy&mm=$mm&dd=$dd&jenis=$kode'>$nama</option>";
						?>
						<?php } ?>

						</select>
						</td></tr>
					</table>
					</center><br>
				  <!-- BEGIN SAMPLE FORM PORTLET-->
				  <div class="portlet box blue">
					<div class="portlet-title">
					  <div class="caption">
						<i class="fa fa-gift"></i> Daftar Rekap Absensi Individu
					  </div>

					</div>
					<div class="portlet-body">
						<div class="row">
							<div class="col-md-12 ">
							<?php
								if ($jenis =="ALL") {
									$carikelas="SELECT * FROM web_kelas ORDER BY urut ASC";
								}elseif($jenis ==""){
									$carikelas="SELECT * FROM web_kelas ORDER BY urut ASC";
								} else {
									$carikelas="SELECT * FROM web_kelas WHERE kode='".$jenis."' ORDER BY urut ASC";
								}
								
								$j_harik = $this->db->query("SELECT count(distinct tgl) as tes FROM web_absen WHERE date_format(tgl,'%m-%Y')='$mm-$yy' AND jenispegawai='1' GROUP BY tgl");
								$jml_harik=$j_harik->num_rows();
								/*foreach ($j_harik->result() as $jharik) {
								$jml_harik=$jharik->tes;
								}*/
								$j_hari = $this->db->query("SELECT count(distinct tgl) as tes FROM web_absen WHERE date_format(tgl,'%m-%Y')='$mm-$yy' AND jenispegawai='0' GROUP BY tgl");
								$jml_harin=$j_hari->num_rows();
								/*foreach ($j_hari->result() as $jhari) {
								$jml_harin=$jhari->tes;
								}*/
								$kelas = $this->db->query($carikelas);
								foreach ($kelas->result() as $rs) {
									$namakelas=$rs->nama;
									$kodekelas=$rs->kode;
									?>
									<h2><?php echo $namakelas;?></h2>
									<table class="table table-bordered table-striped">
									<tr>
									<th class="coba" rowspan="2" width=4%>NO.</th>
									 <th class="coba" rowspan="2" width=30%>NAMA</th>
									   <th class="coba" colspan="4">KEHADIRAN</th>
									   <th class="coba" colspan="5">KETIDAKHADIRAN</th>
									 </tr>
									 <tr>
									 <th class="coba" width=10%>TP</th>
									 <th class="coba" width=10%>TL</th>
									 <th class="coba" width=10%>TAP</th>		
									 <th class="coba" width=10%>HFULL</th>
									 <th class="coba" width=10%>S</th>
									 <th class="coba" width=10%>I</th>
									 <th class="coba" width=10%>WFH</th>
									 <th class="coba" width=10%>A</th>
									 <th class="coba" width=10%>TH</th>
									</tr>
									<?php
									$i=0;
									$siswa = $this->db->query("SELECT nm_pegawai,nip,absen,nomor_induk_baru,jenispegawai FROM web_siswa WHERE kd_jenis_ketenagaan='$kodekelas' ORDER BY nm_pegawai asc");
									foreach ($siswa->result() as $rssis) {
										$i++;
										$namasiswa=$rssis->nm_pegawai;
										$kodeabsen=$rssis->absen;
										//$skrg="$yy-$mm-$dd";
										$jenispegawai=$rssis->jenispegawai;
										if ($jenispegawai == 1) {
											$jml_hari=$jml_harik;
										} else {
											$jml_hari=$jml_harin;
										}
										$jam_tepat=array();
										$jam_terlambat=array();
										$jam_pulang=array();
										$sakit=0;
										$ijin=0;
										$tepat=0;
										$telat=0;
										$wfh=0;
										$tdkplg=0;
										$cek1=$this->db->query("SELECT jam,status,ket FROM web_absen WHERE nip='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy'");
										foreach ($cek1->result() as $rscek1) {
												if ($rscek1->status==1) {
												  if($rscek1->ket=="tepat waktu") {
													$tepat=$tepat+1;
												  } else {
													$telat=$telat+1;
												  }
												} elseif ($rscek1->status==2) {
													$tdkplg=$tdkplg+1; 
												} elseif ($rscek1->status==3) {
													$sakit=$sakit+1;
												} elseif ($rscek1->status==4) {
													$ijin=$ijin+1;
												} elseif ($rscek1->status==5) {
													$ijin=$ijin+1;
												} elseif ($rscek1->status==6) {
													$ijin=$ijin+1;
												} elseif ($rscek1->status==7) {
												  $wfh=$wfh+1;
												} 
											}
											  $ceksakit=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status='3'");
											  $sakit=$sakit+($ceksakit->num_rows());
											  $cekijin4=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status in ('4','5','6')");
															$ijin4=$cekijin4->num_rows();
											  $ijin=$ijin+$ijin4;
											  $cekijin7=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status='7'");
													$ijin7=$cekijin7->num_rows();
													$wfh=$wfh+$ijin7;
												  /*$cekijin4=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status='4'");
																$ijin4=$cekijin4->num_rows();
												  $cekijin5=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status='5'");
															$ijin5=$cekijin5->num_rows();
												  $cekijin6=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status='6'");
															$ijin6=$cekijin6->num_rows();
												  $cekijin7=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status='7'");
															$ijin7=$cekijin7->num_rows();
												  $ijin=$ijin+$ijin4+$ijin5+$ijin6+$ijin7;*/
										?>
										<tr>
										<tr>
										<td><?="$i."?></td>
										<td><a href="detail/?<?php echo "mm=$mm&yy=$yy&absen=$kodeabsen";?>"><?php echo balikin($namasiswa);?></a></td>
										<td class=coba> <?php echo $tepat;?></td>
										<td class=coba><?php echo $telat;?></td>
										<td class=coba><?php echo ($tepat+$telat)-$tdkplg;?></td>
										<td class=coba><b><?php echo ($tepat+$telat)-(($tepat+$telat)-$tdkplg);?></b></td>
										<td class=coba><?php echo $sakit;?></td>
										<td class=coba><?php echo $ijin;?></td>
										<td class=coba><?php echo $wfh;?></td>
										<td class=coba><b><?php echo $tidak=$jml_hari-$tepat-$telat-$sakit-$ijin-$wfh;?></b></td>
										<td class=coba><b><?php echo $tidak=$jml_hari-$tepat-$telat;?></b></td>
										</tr>
									<?php }?>
									</table>
									<?php
								}
							?>
							</div>
						</div>
					</div>
				  </div>
				  <!-- END SAMPLE FORM PORTLET-->
				</div>
			  </div>
          </div>
          <!-- END CONTENT -->
        </div>
        <!-- END SIDEBAR & CONTENT -->
      </div>
    </div>
    <!-- BEGIN FOOTER -->
    <div class="footer">
      <div class="container">
        <div class="row">
          <!-- BEGIN COPYRIGHT -->
          <div class="col-md-6 col-sm-6 padding-top-10">
             2019 © <?php echo $namsek;?>. ALL Rights Reserved. <a href="#">Privacy Policy</a> | <a href="#">Terms of Service</a>
          </div>
          <!-- END COPYRIGHT -->
          <!-- BEGIN PAYMENTS -->
          <div class="col-md-6 col-sm-6">
            <ul class="social-footer list-unstyled list-inline pull-right">
              <li><a href="#"><i class="fa fa-facebook"></i></a></li>
              <li><a href="#"><i class="fa fa-google-plus"></i></a></li>
              <li><a href="#"><i class="fa fa-dribbble"></i></a></li>
              <li><a href="#"><i class="fa fa-linkedin"></i></a></li>
              <li><a href="#"><i class="fa fa-twitter"></i></a></li>
              <li><a href="#"><i class="fa fa-skype"></i></a></li>
              <li><a href="#"><i class="fa fa-github"></i></a></li>
              <li><a href="#"><i class="fa fa-youtube"></i></a></li>
              <li><a href="#"><i class="fa fa-dropbox"></i></a></li>
            </ul>
          </div>
          <!-- END PAYMENTS -->
        </div>
      </div>
    </div>
    <!-- END FOOTER -->

    <!-- Load javascripts at bottom, this will reduce page load time -->
    <!-- BEGIN CORE PLUGINS (REQUIRED FOR ALL PAGES) -->
    <!--[if lt IE 9]>
    <script src="assets/global/plugins/respond.min.js"></script>
    <![endif]-->
    <script src="assets/global/plugins/jquery.min.js" type="text/javascript"></script>
    <script src="assets/global/plugins/jquery-migrate.min.js" type="text/javascript"></script>
    <script src="assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="assets/frontend/layout/scripts/back-to-top.js" type="text/javascript"></script>
	<script src="assets/frontend/layout/scripts/layout.js" type="text/javascript"></script>
	<script src="<?php echo base_url('assets/js/plugins/datatables/jquery.dataTables.min.js'); ?>"></script>
    <script src="<?php echo base_url('assets/js/plugins/datatables/dataTables.bootstrap.min.js'); ?>"></script>
	<script>
		  $(function () {
			$('#example1').DataTable();

		  });
		</script>
    <!-- END CORE PLUGINS -->

    <!-- BEGIN PAGE LEVEL JAVASCRIPTS (REQUIRED ONLY FOR CURRENT PAGE) -->
    <script src="assets/global/plugins/fancybox/source/jquery.fancybox.pack.js" type="text/javascript"></script><!-- pop up -->
    <script src="assets/global/plugins/uniform/jquery.uniform.min.js" type="text/javascript" ></script>
	 <script type="text/javascript">
        jQuery(document).ready(function() {
            Layout.init();
            Layout.initOWL();
            Layout.initTwitter();
            Layout.initFixHeaderWithPreHeader(); /* Switch On Header Fixing (only if you have pre-header) */
            Layout.initNavScrolling();
        });
    </script>

    <!-- END PAGE LEVEL JAVASCRIPTS -->
</body>
</html>
