2015-02-11 23:52:11 -05:00
|
|
|
<?php
|
|
|
|
session_start();
|
|
|
|
require_once("config.inc.php");
|
2015-02-20 05:16:28 -05:00
|
|
|
require_once($yaptc_inc . "functions.inc.php");
|
2015-02-11 23:52:11 -05:00
|
|
|
$yaptc_pagename = "Home";
|
|
|
|
require_once($yaptc_inc . "header.inc.php");
|
|
|
|
require_once($yaptc_inc . "menu.inc.php");
|
2015-02-20 01:57:34 -05:00
|
|
|
if (getSessionStatus() == false):
|
2015-02-19 10:53:29 -05:00
|
|
|
killSession();
|
2015-02-20 05:16:28 -05:00
|
|
|
else: ?>
|
|
|
|
<!-- ********** BEGIN CONTENT ********** -->
|
2015-02-20 01:57:34 -05:00
|
|
|
|
2015-02-24 10:37:52 -05:00
|
|
|
<?php
|
|
|
|
$session_punch = listPunches($db, $session_user["0"]["userid"], 1);
|
2015-02-24 15:37:29 -05:00
|
|
|
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;
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-20 01:57:34 -05:00
|
|
|
|
2015-02-24 15:37:29 -05:00
|
|
|
<h2 class="content-subhead"><?php echo lang('QUICK_PUNCH'); ?></h2>
|
|
|
|
<p><?php echo $session_message; ?></p>
|
|
|
|
<p><?php echo lang('QUICK_PUNCH_PARAGRAPH'); ?></p>
|
2015-02-20 05:16:28 -05:00
|
|
|
<form class="pure-form pure-form-stacked" action="index.php" method="post">
|
2015-02-23 03:09:15 -05:00
|
|
|
<fieldset id="punch">
|
|
|
|
<input type="text" name="notes" placeholder="Enter notes if needed" maxlength="255" value="<?php if (isset($notes)): echo $notes; endif; ?>">
|
2015-02-24 15:37:29 -05:00
|
|
|
<?php if ($session_status == lang('IN')): ?>
|
2015-02-23 03:09:15 -05:00
|
|
|
<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>
|
2015-02-24 15:37:29 -05:00
|
|
|
<?php elseif ($session_status == lang('OUT')): ?>
|
2015-02-23 03:09:15 -05:00
|
|
|
<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>
|
2015-02-20 05:16:28 -05:00
|
|
|
<?php endif; ?>
|
|
|
|
</fieldset>
|
|
|
|
</form>
|
2015-02-20 01:57:34 -05:00
|
|
|
|
2015-02-20 05:16:28 -05:00
|
|
|
<?php
|
2015-02-24 10:47:00 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$punchtime = date('Y-m-d H:i:s');
|
2015-02-20 05:16:28 -05:00
|
|
|
if (!empty($_POST)):
|
2015-02-24 10:47:00 -05:00
|
|
|
if (!empty($_POST['notes'])): $notes = $_POST['notes']; else: $notes = NULL; endif;
|
2015-02-24 15:37:29 -05:00
|
|
|
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);
|
2015-02-20 05:16:28 -05:00
|
|
|
endif;
|
|
|
|
header('Location: ' . $_SERVER['PHP_SELF']);
|
2015-02-24 10:47:00 -05:00
|
|
|
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
2015-02-20 01:57:34 -05:00
|
|
|
|
2015-02-24 10:37:52 -05:00
|
|
|
|
|
|
|
|
2015-02-20 05:16:28 -05:00
|
|
|
<!-- ********** END CONTENT ********** -->
|
|
|
|
<?php endif; require_once($yaptc_inc . "footer.inc.php"); ?>
|