<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<?php

include ("../navigation/header.php");
$page_name = "AD-presets";
include ("../navigation/access.php");

$table_name = $_SESSION['db_prefix']."_presets";
$preset_query = "SELECT  preset_value  FROM $table_name WHERE preset_name = 'Exchange rate' ";
$preset_result = mySQL_query($preset_query);
$exchange_rate = mysql_result($preset_result, 0, "preset_value");

$table_name = $_SESSION['db_prefix']."_presets";
$preset_query = "SELECT  preset_value  FROM $table_name WHERE preset_name = 'Press points' ";
$preset_result = mySQL_query($preset_query);
$press_points = mysql_result($preset_result, 0, "preset_value");

$table_name = $_SESSION['db_prefix']."_presets";
$preset_query = "SELECT  preset_value  FROM $table_name WHERE preset_name = 'Plate area' ";
$preset_result = mySQL_query($preset_query);
$plate_area = mysql_result($preset_result, 0, "preset_value");

$table_name = $_SESSION['db_prefix']."_presets";
$preset_query = "SELECT  preset_value  FROM $table_name WHERE preset_name = 'follow_up' ";
$preset_result = mySQL_query($preset_query);
$follow_up = mysql_result($preset_result, 0, "preset_value");


$table_name = $_SESSION['db_prefix']."_presets";
$preset_query = "SELECT  preset_value  FROM $table_name WHERE preset_name = 'VAT' ";
$preset_result = mySQL_query($preset_query);
$vat_rate = mysql_result($preset_result, 0, "preset_value");

$table_name = $_SESSION['db_prefix']."_presets";
$time_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'clockin1'  ";
$time_result = mySQL_query($time_query);
$time_num = mysql_num_rows($time_result);
if ($time_num!=0) {
$hours1 = mysql_result($time_result, 0, "preset_value");
}
else {
	$hours1 = 0;
}


$clockin_hours1 =  floor($hours1/60); 
$clockin_mins1 =   $hours1 % 60; 
if ($clockin_hours1<10) { $clockin_hours1 = 0 . $clockin_hours1; }
if ($clockin_mins1<10) { $clockin_mins1 = 0 . $clockin_mins1; }

$table_name = $_SESSION['db_prefix']."_presets";

$time_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'clockout1'  ";
$time_result = mySQL_query($time_query);
$hours1 = mysql_result($time_result, 0, "preset_value");

$grace_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'grace1'  ";
$grace_result = mySQL_query($grace_query);
$grace1 = mysql_result($grace_result, 0, "preset_value");


$clockout_hours1 =  floor($hours1/60); 
$clockout_mins1 =   $hours1 % 60; 
if ($clockout_hours1<10) { $clockout_hours1 = 0 . $clockout_hours1; }
if ($clockout_mins1<10) { $clockout_mins1 = 0 . $clockout_mins1; }


$time_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'clockin2'  ";
$time_result = mySQL_query($time_query);
$hours2 = mysql_result($time_result, 0, "preset_value");

$grace_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'grace2'  ";
$grace_result = mySQL_query($grace_query);
$grace2 = mysql_result($grace_result, 0, "preset_value");


$clockin_hours2 =  floor($hours2/60); 
$clockin_mins2 =   $hours2 % 60; 
if ($clockin_hours2<10) { $clockin_hours2 = 0 . $clockin_hours2; }
if ($clockin_mins2<10) { $clockin_mins2 = 0 . $clockin_mins2; }


$time_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'clockout2'  ";
$time_result = mySQL_query($time_query);
$hours2 = mysql_result($time_result, 0, "preset_value");


$clockout_hours2 =  floor($hours2/60); 
$clockout_mins2 =   $hours2 % 60; 
if ($clockout_hours2<10) { $clockout_hours2 = 0 . $clockout_hours2; }
if ($clockout_mins2<10) { $clockout_mins2 = 0 . $clockout_mins2; }

$time_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'lunch'  ";
$time_result = mySQL_query($time_query);
$lunch = mysql_result($time_result, 0, "preset_value");
?>

<!--jscript-->
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/confirm_exit.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/numbers_only_decimal.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>


</head>

<body>
<?php 
if ($permission_num==1) {
	include ("../navigation/admin_sidebar.php");
?>

<div class="main_frame">
<div class="page_head_frame">
    <table width="809" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="385"><label class="label_page_head">Presets</label></td>
        <td align="right">&nbsp;</td>
      </tr>
    </table>
  </div>
  <div class="page_middle_frame">
  <form action="presets_save.php" method="get">
  <div class="page_inside_frame">
  <label class="label_std">Edit values and click Save.</label>
  <br />
<br />

  <table width="402" align="left"  id="table_display">
     <tr>
      <td width="237" align="left">Exchange rate:</td>
      <td width="153"><input type="text" name="exchange_text" id="exchange_text"  value="<?php echo $exchange_rate ?>" onKeyPress="return isNumberKey(event)" onkeyup=" this.value = this.value.replace (/(\.....).*/, '$1')" class="text50" onfocus = "this.select();" style="text-align:right"/></td>
    </tr>
    <tr>
      <td width="237" align="left">VAT rate:</td>
      <td width="153"><input name="vat_text" type="text" id="vat_text" value="<?php echo $vat_rate ?>" onkeypress="return numbersonly(this, event)" class="text50" onfocus = "this.select();" style="text-align:right"/></td>
    </tr>
    <tr>
      <td align="left">Press points:</td>
      <td><input name="press_points_text" type="text" id="press_points_text" value="<?php echo $press_points ?>" onKeyPress="return isNumberKey(event)" onkeyup=" this.value = this.value.replace (/(\.....).*/, '$1')" class="text50" onfocus = "this.select();" style="text-align:right"/></td>
    </tr>
    <tr>
      <td align="left">Plate area:</td>
      <td><input name="plate_area_text" type="text" id="plate_area_text" value="<?php echo $plate_area ?>" onKeyPress="return isNumberKey(event)" onkeyup=" this.value = this.value.replace (/(\.....).*/, '$1')" class="text50" onfocus = "this.select();" style="text-align:right"/></td>
    </tr>
    <tr>
      <td align="left">Follow-up period in days:</td>
      <td><input name="follow_up_text" type="text" id="follow_up_text" value="<?php echo $follow_up ?>" onkeypress="return numbersonly(this, event)" class="text50" onfocus = "this.select();" style="text-align:right"/></td>
    </tr>
   </table>
 </div><br /><br /><br />

<div class="page_inside_frame">
  Working times: <br />
    Time zone 1 clock-in: 
  <input name="clockin_hour_text" type="text" class="text20" onkeypress="return numbersonly(this, event)" maxlength="1" max="9" style="text-align:right" value="<?php echo $clockin_hours1 ?>" onfocus = "this.select();"/>
    :
  <input name="clockin_min_text" type="text" class="text20" onkeypress="return numbersonly(this, event)" maxlength="2" style="text-align:right" max="59" value="<?php echo $clockin_mins1 ?>" onfocus = "this.select();"/>
  &nbsp; clock_out:
  <input name="clockout_hour_text" type="text" class="text20" onkeypress="return numbersonly(this, event)" maxlength="2" max="20" style="text-align:right" value="<?php echo $clockout_hours1 ?>"/>
    :
  <input name="clockout_min_text" type="text" class="text20" onkeypress="return numbersonly(this, event)" maxlength="2" max="59" style="text-align:right" value="<?php echo $clockout_mins1 ?>" onfocus = "this.select();"/>
&nbsp;&nbsp;&nbsp;&nbsp;grace time: 
<input type="text" name="grace_min_text" id="grace_min_text" class="text20" onkeypress="return numbersonly(this, event)" maxlength="2" style="text-align:right" value="<?php echo $grace1 ?>"> minutes
<br />
<br />
  
  Time zone 2 clock-in:
    <input name="clockin_hour_2_text" type="text" class="text20" onkeypress="return numbersonly(this, event)" maxlength="1" max="9" style="text-align:right" value="<?php echo $clockin_hours2 ?>" onfocus = "this.select();"/>
:
<input name="clockin_min_2_text" type="text" class="text20" onkeypress="return numbersonly(this, event)" maxlength="2" style="text-align:right" max="59" value="<?php echo $clockin_mins2 ?>" onfocus = "this.select();"/>
&nbsp; clock_out:
<input name="clockout_hour_2_text" type="text" class="text20" onkeypress="return numbersonly(this, event)" maxlength="2" max="20" style="text-align:right" value="<?php echo $clockout_hours2 ?>" onfocus = "this.select();"/>
:
<input name="clockout_min_2_text" type="text" class="text20" onkeypress="return numbersonly(this, event)" maxlength="2" max="59" style="text-align:right" value="<?php echo $clockout_mins2 ?>" onfocus = "this.select();"/>
&nbsp;&nbsp;&nbsp;&nbsp;grace time: 
<input type="text" name="grace_min2_text" id="grace_min2_text" class="text20"  onkeypress="return numbersonly(this, event)" maxlength="2" style="text-align:right" value="<?php echo $grace2 ?>"> minutes  
<br />
<br />
Tea time / Lunch time combined:&nbsp;&nbsp; 
<input type="text" name="lunch_text" id="lunch_text" class="text20"  onkeypress="return numbersonly(this, event)" onfocus = "this.select();" maxlength="2" style="text-align:right" value="<?php echo $lunch ?>" />
minutes<br />
</div>


 <div class="spacer_frame" style="height:410px;"></div>    
 <div class="page_inside_frame">
      <table width="645" border="0">
        <tr>
          <td width="20"></td>
          <td width="615" align="right">
            <input name="button2" type="button" class="imagebutton" id="button2" onclick="cancel_confirmation(3, '../admin_module/user_list.php');" value="Close"/>
            <input name="save_button"  id="save_button" type="submit" class="imagebutton" value="Save" onclick="needToConfirm = false; " />
            <input name="save_close_button"  id="save_close_button" type="submit" class="imagebutton" value="Save &amp; Close" onclick="needToConfirm = false; " /></td>
        </tr>
      </table>
    </div>  
 </form>
</div> 
</div> 

<?php include ('../navigation/side_bar.php'); ?>
</body>

<?php } else {
$_SESSION['denied_return'] = "admin_module/user_list.php";	
include ("../navigation/admin_sidebar.php");
include ('../navigation/side_bar.php');
?>
	<body onload="needToConfirm = false; accessdenied(); return false">
	</body>
<?php }
?>


</html>