<?PHP

session_start();

include 'connect.php';

if(isset($_SESSION['adminemail']))

{

$user=$_SESSION['adminemail'];



$gtp=mysqli_query($conn,"select * from admin where username='$user'");

$gtp1=mysqli_fetch_assoc($gtp);



include 'top.php';

?>





<div id="page-wrapper" >
          <div id="page-inner">

<div class="main-content">

				<div class="main-content-inner">

					<div class="breadcrumbs ace-save-state" id="breadcrumbs">

						<ul class="breadcrumb">

							<li>

								<i class="ace-icon fa fa-home home-icon"></i>

								<a href="#">Home</a>

							</li>

							<li class="active">Overtime Attendance</li>

						</ul><!-- /.breadcrumb -->

					</div>



					<div class="page-content">

			



						<div class="page-header">

                        

<?php



$aca=mysqli_query($conn,"select * from financial where user='$user' order by ID desc");

$aca1=mysqli_fetch_assoc($aca);



$financial=$aca1['financial'];



?>                        

                        

							<table style="width:100%;">

                        

                        <tr><td style="width:50%;">

                        

							<h1>

								Overtime Attendance

							</h1>

                            

                            </td>

                            

                            <td style="width:50%; text-align:right; padding-right:15px; font-size:15px;">

                            

                            <i class="fa fa-calendar"></i>&nbsp; <?php echo $financial; ?>

                            

                            </td></tr></table>

                            

						</div><!-- /.page-header -->

<br />



						<div class="row">

							<div class="col-xs-12">

                            

								<!-- PAGE CONTENT BEGINS -->

                                

<script type="text/javascript" src="bootstrap/jquery.js"></script>      

                <link rel="stylesheet" href="css/colorbox.css" />

		<script src="lib/jquery.colorbox.js"></script>

		<script>

			$(document).ready(function(){

				//Examples of how to assign the Colorbox event to elements

				$(".group1").colorbox({rel:'group1', width:"50%", height:"75%"});

				});

		</script>



<script>

	

jQuery(function($){

		   

	// simple jQuery validation script

	$('#register').submit(function(){

		

		var valid = true;

		var errormsg = 'This field is required!';

		var errorcn = 'error';

		

		$('.' + errorcn, this).remove();			

		

		$('#required', this).each(function(){

			var parent = $(this).parent();

			if( $(this).val() == '' ){

				var msg = $(this).attr('title');

				msg = (msg != '') ? msg : errormsg;

				$('<span style="font-size:11px;color:#ff0000;" class="'+ errorcn +'">'+ msg +'</span>')

					.appendTo(parent)

					.fadeIn('fast')

					.click(function(){ $(this).remove(); });

				valid = false;

			};

		});

		

		return valid;

	});

	

});	



</script>



<script type="text/javascript">

				          $(document).ready( function() {

				        	  // Select all

				              $("A[href='#select_all']").click( function() {

				                  $("#" + $(this).attr('rel') + " INPUT[type='checkbox']").attr('checked', true);

				                  return false;

				              });



				              // Select none

				              $("A[href='#select_none']").click( function() {

				                  $("#" + $(this).attr('rel') + " INPUT[type='checkbox']").attr('checked', false);

				                  return false;

				              });



				              // Invert selection

				              $("A[href='#invert_selection']").click( function() {

				                  $("#" + $(this).attr('rel') + " INPUT[type='checkbox']").each( function() {

				                      $(this).attr('checked', !$(this).attr('checked'));

				                  });

				                  return false;

				              });

					           

						   });

			    </script>



        

<?php



if($_GET['id'])

{

	

	$id=$_GET['id'];

	

	$sel=mysqli_query($conn,"select * from ot_attendance where entryno='$id'");

	$sel1=mysqli_fetch_assoc($sel);

	

	echo"<center><table>

	<tr><td>Entry No.</td><td>: ".$sel1['entryno']."</td><td style='width:350px;'></td><td>Date</td><td>: ".date('d-m-Y',strtotime($sel1['date']))."</td></tr>

	</table><br />";

	

	echo"<table class='table table-bordered table-condensed' style='width:75%; margin:auto;'>

	

	<thead><tr><th>Emp ID</th><th>Name</th><th>Department</th><th>Time In</th><th>Time Out</th></tr></thead>";

	

	$gsel=mysqli_query($conn,"select * from ot_attendance where entryno='$id' order by empid asc");

	while($gsel1=mysqli_fetch_assoc($gsel))

	{

		

		$emp=mysqli_query($conn,"select * from employee where empid='$gsel1[empid]'");

		$emp1=mysqli_fetch_assoc($emp);

		

		$dept=mysqli_query($conn,"select * from department where ID='$emp1[department]'");

		$dept1=mysqli_fetch_assoc($dept);

		

		echo"<tr><td>".$emp1['empid']."</td><td>".$emp1['name']."</td><td>".$dept1['department']."</td>

		<td>".date('g:i A', strtotime($gsel1['timein']))."</td>

		<td>".date('g:i A', strtotime($gsel1['timeout']))."</td></tr>";

		

	}

	

	echo"</table><br /><br />";

	

	

	echo"<center><a href='viewotattendance.php'>Back</a></center>";

	

}

else

{



if (isset($_GET['s'])) 

	

	{

	 $status=$_GET['s'];

	 

	 	if($status=='1')

		 {

           echo'<div class="alert alert-success alert-dismissable">

                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

                <span style="text-align:left;">Attendance Time in Added Successfully.</span>

                </div>';

		}

		 

		elseif($status=='2')

		{

           echo'<div class="alert alert-success alert-dismissable">

                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

                Time Out Added Successfully.

                </div>';

		}

		

		elseif($status=='3')

		{

           echo'<div class="alert alert-success alert-dismissable">

                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

                Time Out Added Successfully.

                </div>';

		}

		

		elseif($status=='4')

		{

           echo'<div class="alert alert-success alert-dismissable">

                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

                Values Edited Successfully.

                </div>';

		}

		

	}





echo"<br />

<a href='otattendance.php' style='margin-left:14%;'>Add New</a>

<center><table style='width:75%; margin:auto;'><tr><td>

<table id='dynamic-table' class='table table-striped table-bordered table-condensed'>

<thead><tr><th width='10%'>Date</th><th width='15%'>Entry No</th>

<th style='width:12%;'>No.of Present</th><th width='15%'>Actions</th></tr></thead><tbody>";



$g=mysqli_query($conn,"select * from ot_attendance group by entryno");

$csk=mysqli_num_rows($g);



if($csk>0)

{



while($g1=mysqli_fetch_assoc($g))

{        



	$pre=mysqli_query($conn,"select * from ot_attendance where entryno='$g1[entryno]'");

	$pre1=mysqli_num_rows($pre);



echo"<tr><td>".date('d-m-Y',strtotime($g1['date']))."</td><td>".$g1['entryno']."</td>



<td>".$pre1."</td>



<td><a href='viewotattendance.php?id=".$g1['entryno']."'><i class='fa fa-search-plus'></i></a> &nbsp; 

<a href='editotattendance1.php?id=".$g1['entryno']."'><i class='fa fa-pencil'></i></a> &nbsp; 

<a href='del.php?id=".$g1['entryno']."&desc=otattendance' title='Delete'><i class='fa fa-trash-o'></i></a></td></tr>";

}



}



else

{

echo"<tr><td colspan='4' height='35' style='text-align:center; padding:25px 0 10px 0;'>No Records Found</td></tr>";

}



echo"</tbody></table></td></tr></table><br />";



}



?>



 </div>

 </div>

 

 <link rel="stylesheet" href="bootstrap/dataTables.tableTools.css">

    

    <link rel="stylesheet" href="css/datepicker.css">



<script src="bootstrap/jquery-1.7.2.min.js"></script>

        <script src="bootstrap/bootstrap-datepicker.js"></script>



    <script>

         

    

	$('.datepicker').datepicker();

	

</script>



								<!-- PAGE CONTENT ENDS -->

							</div><!-- /.col -->

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

					



</div><!-- /.page-content -->

				</div>

			</div><!-- /.main-content -->
			</div><!-- /.main-content -->
			</div><!-- /.main-content -->





<?php



include 'bottom.php';



}

else

{



 header("location:login.php");

}



?>