mroe changes, moving to language file

This commit is contained in:
Josh North 2015-02-24 15:37:29 -05:00
parent dfd64ba4f9
commit 16b87fafe4
9 changed files with 62 additions and 73 deletions

View File

@ -1,9 +1,8 @@
</div>
<div class="header">
<h2>Server Time: <span id="date_time"></span><script type="text/javascript">window.onload = date_time('date_time');</script></h2>
<h2><?php echo lang('SERVER_TIME') . ": " . $timenow; ?></h2>
</div>
</div>
<script src="<?php echo $yaptc_libweb; ?>ui.js"></script>
</body>
</html>

View File

@ -1,9 +1,25 @@
<?php
// Languages
function lang($phrase){
static $lang = array(
'NO_PUNCHES' => 'You have no recorded punches',
'OUT' => 'Out',
'IN' => 'In',
'SINCE' => 'since',
'PUNCH_STATUS' => 'Punch Status',
'SERVER_TIME' => 'Server Time',
'QUICK_PUNCH_PARAGRAPH' => 'Click below to immediately punch your time. You may enter notes for your administrator to review.',
'YOU_HAVE_BEEN_PUNCHED' => 'You have been punched',
'QUICK_PUNCH' => 'Quick Punch'
);
return $lang[$phrase];
}
// Current Time
$timenow = date('Y-m-d H:i:s');
// Get user list for users management page
function listUsers($yaptc_db) {
$stmt = $yaptc_db->query("SELECT users.id as userid, users.username as username, users.email as email, users.created as created, users.firstname as firstname, users.lastname as lastname, users.usertype as usertypeid, usertypes.typename as usertype

View File

@ -9,7 +9,6 @@
<script type="text/javascript" src="<?php echo $yaptc_libweb; ?>date_time.js"></script>
<!--[if lte IE 8]>
<link rel="stylesheet" href="<?php echo $yaptc_incweb; ?>side-menu-old-ie.css">
<![endif]-->
@ -25,4 +24,5 @@
<!--<![endif]-->
</head>
<body onLoad="startclock();">
<body>

View File

@ -1 +0,0 @@
<?php echo date('F d, Y H:i:s') ?>

View File

@ -10,30 +10,43 @@ killSession();
else: ?>
<!-- ********** BEGIN CONTENT ********** -->
<h2 class="content-subhead">Current Status</h2>
<?php
$timenow = date('Y-m-d H:i');
$session_punch = listPunches($db, $session_user["0"]["userid"], 1);
if (!isset($session_punch['0']['intime'])): $status = "Out"; ?>
<p>You do not appear to have any punches on record.</p>
<?php else:
if (!empty($session_punch['0']['outtime'])): $status = "Out"; $statustime = $session_punch['0']['outtime'];
else: $status = "In"; $statustime = $session_punch['0']['intime']; $punchid = $session_punch['0']['punchid']; $notes = $session_punch['0']['notes'];
endif; ?>
<p>You have been Punched <?php echo $status; ?> since <?php echo date('g:i a \o\n M jS, Y', strtotime($statustime)); ?>.</p>
<?php endif; ?>
if (!isset($session_punch['0']['intime'])):
$session_status = lang('OUT');
$session_message = lang('PUNCH_STATUS') . ": " . lang('NO_PUNCHES');
else:
if (!empty($session_punch['0']['outtime'])):
$session_status = lang('OUT');
$statustime = $session_punch['0']['outtime'];
$session_message = lang('PUNCH_STATUS') . ": " . $session_status . " " . lang('SINCE') . " " . date('g:i a \o\n M jS, Y', strtotime($statustime));
else:
$session_status = lang('IN');
$statustime = $session_punch['0']['intime'];
$punchid = $session_punch['0']['punchid'];
$notes = $session_punch['0']['notes'];
$session_message = lang('PUNCH_STATUS') . ": " . $session_status . " " . lang('SINCE') . " " . date('g:i a \o\n M jS, Y', strtotime($statustime));
endif;
endif;
?>
<h2 class="content-subhead">Quick Punch</h2>
<p>Clicking the button below will immediately enter a new punch for you depending on your current status. Any notes you enter will be attached to the punch for your administrator to review.</p>
<h2 class="content-subhead"><?php echo lang('QUICK_PUNCH'); ?></h2>
<p><?php echo $session_message; ?></p>
<p><?php echo lang('QUICK_PUNCH_PARAGRAPH'); ?></p>
<form class="pure-form pure-form-stacked" action="index.php" method="post">
<fieldset id="punch">
<input type="text" name="notes" placeholder="Enter notes if needed" maxlength="255" value="<?php if (isset($notes)): echo $notes; endif; ?>">
<?php if ($status == "In"): ?>
<?php if ($session_status == lang('IN')): ?>
<button type="submit" class="pure-button button-success pure-button-disabled">Punch IN</button>
<button type="submit" class="pure-button button-error">Punch OUT</button>
<?php elseif ($status == "Out"): ?>
<?php elseif ($session_status == lang('OUT')): ?>
<button type="submit" class="pure-button button-success">Punch IN</button>
<button type="submit" class="pure-button button-error pure-button-disabled">Punch OUT</button>
<?php endif; ?>
@ -48,8 +61,8 @@ if (!isset($session_punch['0']['intime'])): $status = "Out"; ?>
$punchtime = date('Y-m-d H:i:s');
if (!empty($_POST)):
if (!empty($_POST['notes'])): $notes = $_POST['notes']; else: $notes = NULL; endif;
if ($status == "In"): punchOut($yaptc_db, $punchid, $notes, $punchtime, NULL);
elseif ($status == "Out"): punchIn($yaptc_db, $_SESSION['user_id'], $notes, $punchtime, NULL);
if ($session_status == lang('IN')): punchOut($yaptc_db, $punchid, $notes, $punchtime, NULL);
elseif ($session_status == lang('OUT')): punchIn($yaptc_db, $_SESSION['user_id'], $notes, $punchtime, NULL);
endif;
header('Location: ' . $_SERVER['PHP_SELF']);
endif;

11
lang/en.lang.php Normal file
View File

@ -0,0 +1,11 @@
<?php return array(
// Set up language strings here
'NO_PUNCHES' => 'You have no recorded punches'
'QUICK_PUNCH' => 'Quick Punch'
// EOF
); ?>

View File

@ -1,29 +0,0 @@
function date_time(id)
{
date = new Date;
year = date.getFullYear();
month = date.getMonth();
months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
d = date.getDate();
day = date.getDay();
days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
h = date.getHours();
if(h<10)
{
h = "0"+h;
}
m = date.getMinutes();
if(m<10)
{
m = "0"+m;
}
s = date.getSeconds();
if(s<10)
{
s = "0"+s;
}
result = ''+days[day]+' '+months[month]+' '+d+' '+year+' '+h+':'+m+':'+s;
document.getElementById(id).innerHTML = result;
setTimeout('date_time("'+id+'");','1000');
return true;
}

View File

@ -1 +0,0 @@
<?php echo date('F d, Y H:i:s') ?>

View File

@ -1,19 +0,0 @@
function doAjaxGet(dataSource) {
if(navigator.appName == "Microsoft Internet Explorer") {
objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
} else {
objHTTP = new XMLHttpRequest();
}
objHTTP.open("POST", dataSource, true);
objHTTP.onreadystatechange = function()
{
if (objHTTP.readyState == 4 && objHTTP.status == 200) {
document.getElementById('oClock').innerHTML = objHTTP.responseText;
}
}
objHTTP.send('null');
}
function startclock() {
doAjaxGet('time.inc.php');
setTimeout('startclock()',1000);
}