<?php
session_name('CAKEPHP'); session_start();
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');
$CompanyId = $_SESSION['ACGCompanyId'];
	if($CompanyId) {
	    $sql_query = "SELECT * FROM config_hr where CompanyId=".$CompanyId;
		$sqlQuery =DB_query($sql_query,$db);
		$row = DB_fetch_array($sqlQuery);
                
                $sql_query1 = "SELECT * FROM config_hr where CompanyId=".$CompanyId." and global_flag='c'";
		$sqlQuery1 =DB_query($sql_query1,$db);
		$row1 = DB_fetch_array($sqlQuery1);
               
	}

 	if($_REQUEST['action']=='setItemnameAuto'){ 
 	
	 $item_name_auto = $_POST['flag']; 
	
		if($item_name_auto!='1'){
			$item_name_auto=0;
		}
	
		if($row['CompanyId']){
			
			$res = DB_query("update  config_hr set flag ='$item_name_auto' where global_flag ='a'",$db);
                        $s->pageLocation("index.php?route=Elementory/hrConfig".$rurl);
			
		}
		else{
			$sql ="insert into config_hr(CompanyId,flag,global_flag) values('$CompanyId','$item_name_auto','a')";	
			$res = DB_query($sql,$db);
			$s->pageLocation("index.php?route=Elementory/hrConfig".$rurl);
		}
	
  }
 if($_REQUEST['submit']!='')
 {
     $days=$_REQUEST['days'];
     if($row1['CompanyId']){
         $res = DB_query("update  config_hr set flag ='$days' where global_flag ='c'",$db);
         $s->pageLocation("index.php?route=Elementory/hrConfig".$rurl);
     }
 else {
       
       $sql ="insert into config_hr(CompanyId,flag,global_flag) values('$CompanyId','$days', 'c')";	
       $res = DB_query($sql,$db);
       $s->pageLocation("index.php?route=Elementory/hrConfig".$rurl);  
     }
     
 }
?>

<div align="left">
<form  action="" id="myForm" name="itemNameForm" method="post">
<input type="hidden" name="action" value="setItemnameAuto" />

 <strong>Attendance Time Format :   </strong>

<input type="radio" name="flag" value="1" <?php if($row['flag']=="1"){ ?> checked="checked" <?php }?> onclick="frmSubmit();">24 Hours
<input type="radio" name="flag" value="0" <?php if($row['flag']=="0"){ ?> checked="checked" <?php }?> onclick="frmSubmit();">12 Hours
<br/><br/><br/>
</form>
<form  action="" id="myForm2" name="itemNameForm2" method="post">
<strong>Compensation Days :   </strong>
<input type="text" name="days" value="<?php echo $row1['flag']; ?>" placeholder="Days">
<input type="submit" name="submit" value="Save">
</form></div>
<script>
function frmSubmit()
{
   
   document.getElementById("myForm").submit();
    
}
</script>
