<?php
	ob_start();
	session_start();
	function firstSunday($DATE)
    {
	// $DATE='2014-04-01';
         $date = date('Y-m',strtotime($DATE));
         $day = trim(strtotime("%e",$DATE));

        for($day; $day <= '7'; $day++){
             $dd = strftime("%A",strtotime($date.'-'.$day));
            if($dd == 'Sunday'){
                return $day;
            }
        }
    }
?>
<!DOCTYPE html>
<html>
    <head>
 <?php include("header-js.php");?>	
		
<!-----hrm-------------->		
<!-- Responsive -->
<link rel="stylesheet" href="css/responsive.css" />
<link rel="stylesheet" href="css/jquery-ui.css" />
<!-- /Responsive -->
<link rel="stylesheet" href="css/style.css" />

<!-- FORM -->
<link rel="stylesheet" href="css/form-slide.css" type="text/css" media="screen"/>

<link rel="stylesheet" type="text/css" href="dist/bootstrap-clockpicker.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/github.min.css">
<style type="text/css">
.navbar h3 {
	color: #f5f5f5;
	margin-top: 14px;
}
.hljs-pre {
	background: #f8f8f8;
	padding: 3px;
}
.footer {
	border-top: 1px solid #eee;
	margin-top: 40px;
	padding: 40px 0;
}
.input-group {
	width: 110px;
	margin-bottom: 10px;
}
.pull-center {
	margin-left: auto;
	margin-right: auto;
}
@media (min-width: 768px) {
  .container {
    max-width: 730px;
  }
}
@media (max-width: 767px) {
  .pull-center {
    float: right;
  }
}
</style>


<link rel="stylesheet" type="text/css" href="css/jquery.jui_pagination.css"/>
<!-- if touch event support is needed (mobile devices) -->
<script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script>
 
<script type="text/javascript" src="js/jquery.jui_pagination.min.js"></script>
<script type="text/javascript" src="js/en.js"></script>


<script type="text/javascript" src="js/jquery.ba-hashchange.min.js"></script>

<!-----hrm-------------->
        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
    </head>
	

<script type="text/javascript">

	function showEmp(str)
	{
	
	var xmlhttp;    
	if (str=="")
	  {
	  document.getElementById("txtHintClient").innerHTML="";
	  return;
	  }
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		   document.getElementById("txtHintClient").innerHTML=xmlhttp.responseText;
		}
	  }
	xmlhttp.open("GET","emp_ajax.php?str="+str,true);
	xmlhttp.send();
	}

	function get_time(){
	
	literboxqty = $("#data-id option:selected").attr("data-id");
		var val = document.getElementById("recdate").value;
		var e = document.getElementById("empid");
		
		var strUser = e.options[e.selectedIndex].value;
		$.get("timer_ajax.php?dts="+val+"&empid="+strUser,function(data){
		$('.clockpicker input').val(data);
		});
	get_timeout();
	}

	function get_timeout(){
	
		var val = document.getElementById("recdate").value;
		var e = document.getElementById("empid");
		var strUser = e.options[e.selectedIndex].value;
		$.get("timer_ajax_out.php?dts="+val+"&empid="+strUser,function(data){
			$('.clockpickerout input').val(data);
		});
	
	}
	//function get_time(val){
		
		
		//alert(strUser);
	//}
	
	function getval()
	{
	locationHashChangedss();
	
	}
</script>

    <body class="skin-blue">
	 <?php 
	include("header.php");
?>

                    <!-- Small boxes (Stat box) -->
                    

                    <!-- Main row -->
                    <div class="row">
                    
					<div id="wrapper">



<div class="content">

<div id="form-content">
<div class="report-tab">
<div class="employee-title">
<div class="report-left" style="width:300px;"><h2><translate>Attendence Regularization</translate><span></span></h2></div>



<div class="clear-float"></div>
</div><!-- /employee-title -->

<div class="report-cell-02">
	<!--<label><input type="button" value="Timesheet" data-page="Timesheet_show"  class="btn-tab-01 Timesheet_show" /></label>
	<label><input type="button" value="Muster Roll" data-page="Muster_Roll_show"  class="btn-tab-01 Muster_Roll_show" /></label>-->
    
<!--<ul class="payroll-menu">
<li data-page="Timesheet_show" class="Timesheet_show">Timesheet</li>
</ul>-->
<?php
if($_SESSION['usertype'] != 'Subadmin')
{	
?>
<!--<ul class="payroll-menu">
<li data-page="Muster_Roll_show" class="Muster_Roll_show" >Muster Roll</li>
</ul>
<ul class="payroll-menu">
<li data-page="Attendance_show" class="Attendance_show" >Attendance</li>
</ul>-->

<?php } ?>

<?php 
$sub_rights=mysql_query("select * from menu as m,menu_sub as s where  m.menu_name='Leave Apply & Tracking' and m.menu_id=s.menu_id ");
$menu_cnt=mysql_num_rows($sub_rights);
?>

<?php
$emp_id=$_SESSION['admin_id'];
$qry=$db->fetchQuery("select * from employee where imd_supervisor_id=$emp_id");
?>

<?php if($userid==1){?>   <!--if start for admin/user -->


<ul class="payroll-menu" style="margin-bottom:0px !important; ">
<li data-page="addNewpersonalLeaveRequest" class="addNewpersonalLeaveRequest"><translate>Apply Leave</translate></li>
</ul>

<?php
if($_SESSION['usertype']!='Superadmin')
{
?>
<ul class="payroll-menu" style="margin-bottom:0px !important; ">
<li data-page="personalleave" class="personalleave" ><translate>Applied Leaves</translate></li>
</ul>
<?php
}
if(!empty($qry) || $_SESSION['usertype']=='Superadmin')
{
?>
<ul class="payroll-menu" style="margin-bottom:0px !important; ">
<li data-page="leaveRequests" class="leaveRequests"><translate>Approve Leaves</translate></li>
</ul>
<?php } ?>


<ul class="payroll-menu" style="margin-bottom:0px !important; ">
<!--<li data-page="AttendenceRegularization" class="AttendenceRegularization" ><translate>Attendence Regularization</translate></li>-->
<li data-page="timesheet_edit" class="AttendenceRegularization" ><translate>Attendance Regularization</translate></li>
</ul>

<?php
if(!empty($qry) || $_SESSION['usertype']=='Superadmin')
{
?>
<ul class="payroll-menu" style="margin-bottom:0px !important;">
<li data-page="timesheet_approval" class="timesheet_approval" ><translate>Approve Attendance</translate></li>
</ul>

<?php
}
?>

<?php
if($_SESSION['usertype']!='Superadmin')
{
?>
<ul class="payroll-menu" style="margin-bottom:0px !important; ">
<li data-page="timesheet_view" class="timesheet_view" ><translate>Attendance Status</translate></li>
</ul>
<?php
}
?>


<?php } else {?>   <!--if end and else start for admin/user -->


     
	 <?php  while($rows=mysql_fetch_array($sub_rights)){
	 
	 
	 ?>
	 
<?php if($rows['s_menu_name']=='addNewpersonalLeaveRequest')
      {$class='addNewpersonalLeaveRequest';$val='Apply Leave';}
      if($rows['s_menu_name']=='Applied Leaves')
      {$class='personalleave';$val='Applied Leaves';}
      if($rows['s_menu_name']=='leaveRequests')
      {$class='leaveRequests';$val='Approve Leaves';}
      if($rows['s_menu_name']=='timesheet_edit')
      {$class='timesheet_edit';$val='Attendance Regularization';}
      if($rows['s_menu_name']=='timesheet_approval')
      {$class='timesheet_approval'; $val='Approve Attendance'; }
      if($rows['s_menu_name']=='Attendance Status')
      {$class='timesheet_view';$val='Attendance Status';}
   
	  
	  $view_rights=mysql_fetch_array(mysql_query("select * from tbl_user_rights where user_id='$userid' and s_submenu_id='$rows[s_id]'"));
    ?>

<?php if($view_rights['view_right']==1){?>

<ul class="payroll-menu" style="margin-bottom:0px !important;">
<li data-page="<?php echo $rows['s_menu_link'];?>" class="<?php echo $class;?>" ><translate><?php echo $val;?></translate></li>
</ul>
<?php }} 


} ?>


<div class="clear-float"></div>
</div>
<div class="report-cell-03" style="display:none;">

<form class="pdtSearchForm">
<label><input type="text" placeholder="From date" name="from_date" id="prdaddate" style="width:100px;"/></label>
<label><input type="text" placeholder="To date" name="to_date" id="toaddate" style="width:100px;" /></label>



<label>
    <select name="immapproval" id="immapproval" style="width:100px;">
    <option value=""> Approval</option>
	<option value="0">Approved</option>
	<option value="1">Pending</option>
    </select>
</label>

<!--<label>
    <select name="finalapproval" id="finalapproval" style="width:100px;">
    <option value="">Final</option>
	<option value="1">Approved</option>
	<option value="0">Pending</option>
    </select>
</label>-->	


</form>




<label><input type="button" value="Search" id="searchtimeview" class="searchtimeviewsearch" style="width:70px;" /></label>
<label>
<input type="button" value="Search" id="searchtimeapproval" class="searchtimeapproval" style="width:70px;" />
</label>
<div class="clear-float"></div>
</div>
<div id="tablelist"></div>
<div class="pagination-holder clearfix"align="center" >
			<div id="light-pagination" style="width:500px"  class="pagination light-theme simple-pagination"></div>
</div>
            <div id="form-wrapper" class="edit_time" style="display: none;"> 
                <div id="steps">
			
			
				
                     <form action="" method="post"  id="frm1" name="frm1" >
					 
					 <?php 

$sub_rights_regular=mysql_fetch_array(mysql_query("select * from menu as m,menu_sub as s where  m.menu_name='Leave Apply & Tracking' and m.menu_id=s.menu_id  and s.s_menu_link='timesheet_edit'"));

 $main_rights_regular=mysql_fetch_array(mysql_query("select * from tbl_user_rights where s_submenu_id='$sub_rights_regular[s_id]' and user_id='$userid' and m_menu_id='$sub_rights_regular[menu_id]'"));
//timesheet_edit
?>
<!-- Recruitment ////////////////////////////////////////////////////////////////////// -->		
				
                        <fieldset class="step">
                            <legend style="border:none;"><translate>TimeSheet Adjustable Form</translate></legend>
							<!--<p class="heading01">Reference</p>-->
                            <p>
                                <label for="Date"><translate>Date</translate></label>
                               <input type="text" name="recdate" id="recdate"  AUTOCOMPLETE=OFF onChange="get_time()" />
                            </p>
							
							<?php 
							 if($_SESSION['usertype'] =='Superadmin') 
							   {?>
							<p>
                               <label for="Source"><translate>Branch</translate></label>
								
                               <?php 				 
							   $sqlbranch = $db->fetchQuery("select * from branches order by branch_name asc");  ?>
                               <select name="branchid" id="branchid" onChange="showEmp(this.value)" >  
                               <option value="">-Select Branch Name-</option>
                               <?php 	foreach($sqlbranch as $brchlist){ ?>                            
                               <option value="<?=$brchlist['branch_id']?>"><?=$brchlist['branch_name']?></option>
                               <?php } ?>
                               </select>
							   </p><?php } ?>
							
							<?php 
							 if($_SESSION['usertype'] =='Superadmin') 
							   {?>
							    <p id="txtHintClient">
                               <label for="Source"><translate>Employee Name</translate></label>
								
                               <?php
							   $sqlemp = $db->fetchQuery("select * from employee where status = 1 order by e_fname asc");  ?>
                               <select name="empid" id="empid" onChange="get_time()" >  
                               <option value="">-Select Employee Name-</option>
                               <?php 	foreach($sqlemp as $list){ ?>                            
                               <option value="<?=$list['e_id']?>"><?=$list['e_fname']?></option>
                               <?php } ?>
                               </select>
							   						   
                            </p>
							   <?php  }
							   else if($_SESSION['branchadmin']=='Y')
							   { ?>
							   
							   <p >
                               <label for="Source"><translate>Employee Name</translate></label>
								
                               <?php
							   $branchid = $_SESSION['branch_id'];
							   $sqlemp = $db->fetchQuery("select * from employee where where branchid=$branchid order by e_fname asc");  ?>
                               <select name="empid" id="empid" onChange="get_time()" >  
                               <option value="">-Select Employee Name-</option>
                               <?php 	foreach($sqlemp as $list){ ?>                            
                               <option value="<?=$list['e_id']?>"><?=$list['e_fname']?></option>
                               <?php } ?>
                               </select>
							   						   
                            </p>
							<?php } ?>
                           
							
							
                            
     <div class="clear-float"></div>
      <div class="picker-cell">      
      <div class="picker-cell-left" for="Source"  style="text-align:left!important;"><translate>Time In</translate></div> 
        <div class="form-group" style="float:left;">
		<div class="input-group clockpicker" data-placement="top" data-align="left" data-donetext="Done" id="">
		<input type="text" name="timepicker_in" class="form-control" value="">
		<span class="input-group-addon">
		<span class="glyphicon glyphicon-time"></span>
        </span>		
        </div>
        </div>                       
     <div class="clear-float"></div>
      </div><!-- /picker-cell -->
	  
      
      <div class="picker-cell">      
      <div class="picker-cell-left" for="Source" style="text-align:left!important;"><translate>Time Out</translate></div> 
        <div class="form-group" style="float:left;">
		<div class="input-group clockpickerout" data-placement="top" data-align="left" data-donetext="Done" id="" style="cursor:pointer;">
		<input type="text" name="timepicker_out" class="form-control" value="">
		<span class="input-group-addon">
		<span class="glyphicon glyphicon-time"></span>
        </span>		
        </div>
        </div>                       
     <div class="clear-float"></div>
      </div>
                 
	<?php
		if($_SESSION['usertype']=='Subadmin') 
		{  ?>     
         <p>
           <label for="Date"><translate>Reason</translate></label>
           <input type="text" name="reason" id="reason"  AUTOCOMPLETE=OFF  />
         </p>                   
        <?php } ?>
                          
                     
                            <?php  if($userid!=1){ if($main_rights_regular['add_right']==1){?>
							<p class="submit">
                                 <button id="registerButton2" type="button" onClick="fun_TimesheetPage()" >Finish</button>
								</p>
								<?php } } else{?>
								<p class="submit">
                                 <button id="registerButton2" type="button" onClick="fun_TimesheetPage()" >Finish</button>
								</p>
								<?php }?>
								
                        </fieldset>
						
                    </form>
                </div>
                
            </div>
    </div>
</div>
<div class="clear-float"></div>
</div><!-- /content -->
<div id="busy">Loading...</div>
<div class="footer">
<strong>© add-HRM</strong><br />
<span>Developed by <a href="http://www.aadhocc.com" target="_blank">Aadhocc</a></span></div><!-- /footer -->

</div>
					
					
                    </div><!-- /.row (main row) -->

                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->

        <!-- add new calendar event modal -->
<input type="hidden"  name="adjust-timesheet" class="adjust-timesheet">
		
		<!--------------scripts for employee list-------------->

<script type="text/javascript" src="js/moment.min.js"></script>

<script type="text/javascript" src="dist/bootstrap-clockpicker.min.js"></script>
<script type="text/javascript">
$('.clockpickerout').clockpicker()
	.find('input').change(function(){
		console.log(this.value);
	});

$('.clockpicker').clockpicker()
	.find('input').change(function(){
		console.log(this.value);
	});
var input = $('#single-input').clockpicker({
	placement: 'bottom',
	align: 'left',
	autoclose: true,
	'default': 'now'
});

// Manually toggle to the minutes view
$('#check-minutes').click(function(e){
	// Have to stop propagation here
	e.stopPropagation();
	input.clockpicker('show')
			.clockpicker('toggleView', 'minutes');
});
if (/mobile/i.test(navigator.userAgent)) {
	$('input').prop('readOnly', true);
}

</script>
<script type="text/javascript" src="assets/js/highlight.min.js"></script>
<script type="text/javascript">
hljs.configure({tabReplace: '    '});
hljs.initHighlightingOnLoad();
</script>

<script src="js/dateFormat.js"></script>
<script type="text/javascript" src="js/sliding.form.js"></script>
<!--<script type="text/javascript" src="js/insert.js"></script>-->

<script type="text/javascript" src="js/individualtimelist.js"></script>
       <?php 
	include("footer-js.php");
?>
<script type="text/javascript" >
$('#recdate').on('click',function(){ 
		 $(this).datepicker({dateFormat:"dd-mm-yy"}).focus();	
	});
$('#prdaddate').on('click',function(){ 
		 $(this).datepicker({dateFormat:"dd-mm-yy"}).focus();	
	});	
$('#toaddate').on('click',function(){ 
		 $(this).datepicker({dateFormat:"dd-mm-yy"}).focus();	
	});		
</script>

	<!--------------scripts for employee list-------------->
    </body>
</html>