2015-02-24 10:37:52 -05:00
|
|
|
<?php
|
|
|
|
session_start();
|
|
|
|
require_once("config.inc.php");
|
2017-05-12 11:12:29 -04:00
|
|
|
require_once($yaptc_lang);
|
|
|
|
|
2015-02-24 10:37:52 -05:00
|
|
|
require_once($yaptc_inc . "functions.inc.php");
|
2015-02-26 12:44:21 -05:00
|
|
|
$yaptc_pagename = lang('PUNCH_EDITOR');
|
2016-02-04 14:18:34 -05:00
|
|
|
$yaptc_pageicon = '<i class="fa fa-clock-o"></i> ';
|
2015-02-24 10:37:52 -05:00
|
|
|
require_once($yaptc_inc . "header.inc.php");
|
|
|
|
if (getSessionStatus() == false):
|
|
|
|
killSession();
|
|
|
|
else: ?>
|
2015-02-26 12:44:21 -05:00
|
|
|
<!-- ********** BEGIN CONTENT ********** -->
|
2015-02-24 10:37:52 -05:00
|
|
|
|
2015-02-26 12:44:21 -05:00
|
|
|
<?php if($session_user["0"]["usertype"] !== "Administrator"): header("Location: index.php"); ?>
|
|
|
|
<h2 class="content-subhead"><?php echo lang('NOT_AUTHORIZED'); ?></h2>
|
|
|
|
<?php endif; ?>
|
2015-02-24 10:37:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-26 12:44:21 -05:00
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
if (!empty($_POST['punchuser'])) {
|
2015-02-24 10:37:52 -05:00
|
|
|
if (isset($_POST['notes'])) { if (!empty($_POST['notes'])) { $notes = $_POST['notes']; } else { $notes = NULL; } } else { $notes = NULL; }
|
|
|
|
if (isset($_POST['punchtime'])) {
|
|
|
|
// this needs work to check existing modified flag!!! i.e. if already set to 1, leave as 1!!!
|
2015-02-26 12:44:21 -05:00
|
|
|
if (!empty($_POST['punchtime'])) { $punchtime = $_POST['punchtime']; $modified = "1"; } else { $punchtime = $timenow; }
|
|
|
|
} else { $punchtime = $timenow; }
|
2015-02-24 10:37:52 -05:00
|
|
|
|
|
|
|
// Is the user currently punched in? If so, insert the punch out record, otherwise, insert a new punch in
|
|
|
|
if ($_POST['status']=="In") {
|
|
|
|
punchOut($yaptc_db, $_POST['punchid'], $notes, $punchtime, $modified);
|
|
|
|
} else {
|
|
|
|
punchIn($yaptc_db, $_POST['userid'], $notes, $punchtime, $modified);
|
|
|
|
}
|
|
|
|
|
|
|
|
header('Location: '.$_SERVER['PHP_SELF']);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-26 12:44:21 -05:00
|
|
|
?>
|
2015-02-24 10:37:52 -05:00
|
|
|
|
|
|
|
|
2015-02-24 11:37:40 -05:00
|
|
|
|
|
|
|
<?php
|
|
|
|
if (!empty($_POST['editpunch'])) {
|
2017-05-11 13:22:44 -04:00
|
|
|
editPunch($yaptc_db, $_POST['editpunch'], $_POST[$_POST['editpunch'] . "-intime"], $_POST[$_POST['editpunch'] . "-outtime"], $_POST[$_POST['editpunch'] . "-notes"]);
|
2015-02-24 11:37:40 -05:00
|
|
|
}
|
|
|
|
if (!empty($_POST['deletepunch'])) {
|
2017-05-11 13:22:44 -04:00
|
|
|
deletePunch($yaptc_db, $_POST['deletepunch']);
|
2015-02-24 11:37:40 -05:00
|
|
|
}
|
|
|
|
|
2015-02-26 12:44:21 -05:00
|
|
|
// Set up pagination
|
|
|
|
$page_num = 1;
|
|
|
|
if(!empty($_GET['pnum'])):
|
|
|
|
$page_num = filter_input(INPUT_GET, 'pnum', FILTER_VALIDATE_INT);
|
|
|
|
if(false === $page_num):
|
|
|
|
$page_num = 1;
|
|
|
|
endif;
|
|
|
|
endif;
|
2017-05-11 13:22:44 -04:00
|
|
|
$offset = ($page_num - 1) * $yaptc_rowsperpage;
|
|
|
|
$row_count = count(listPunches($yaptc_db, "%"));
|
2015-02-26 12:44:21 -05:00
|
|
|
$page_count = 0;
|
2017-05-11 13:22:44 -04:00
|
|
|
if (0 === $row_count): else: $page_count = (int)ceil($row_count / $yaptc_rowsperpage); if($page_num > $page_count): $page_num = 1; endif; endif;
|
2015-02-24 11:37:40 -05:00
|
|
|
?>
|
|
|
|
|
2017-05-12 00:38:26 -04:00
|
|
|
<div class="container">
|
|
|
|
<div class="page-header">
|
|
|
|
<h2><i class="glyphicon glyphicon-pencil"></i> <?php echo lang('EDIT_PUNCH_HEADER'); ?></h2>
|
|
|
|
</div>
|
|
|
|
<p class="lead"><?php echo lang('EDIT_PUNCH_DESC'); ?></p>
|
2015-02-24 11:37:40 -05:00
|
|
|
|
2015-02-26 12:44:21 -05:00
|
|
|
<form method="post" onsubmit="return confirm('<?php echo lang('SAVE_PUNCH_WARNING'); ?>')">
|
|
|
|
<table class="pure-table pure-table-striped">
|
|
|
|
<thead>
|
2017-05-12 00:38:26 -04:00
|
|
|
<tr><th colspan="6"><?php echo '<ul class="pagination pagination-sm">'; for ($i = 1; $i <= $page_count; $i++): echo '<li class="'; if ($i === $page_num): echo 'active'; else: echo ' '; endif; echo '"><a href="' . $_SERVER['PHP_SELF'] . '?pnum=' . $i . '">' . $i . '</a></li>'; endfor; echo '</ul>'; ?></th></tr>
|
2015-02-26 12:44:21 -05:00
|
|
|
<tr><th><?php echo lang('IN') . "/" . lang('OUT'); ?></th><th><?php echo lang('NAME'); ?></th><th><?php echo lang('HOURS'); ?></th><th><?php echo lang('FLAG'); ?></th><th><?php echo lang('NOTES'); ?></th><th><?php echo lang('ACTIONS'); ?></th></tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2017-05-11 13:22:44 -04:00
|
|
|
<?php foreach (listPunches($yaptc_db, "%", $yaptc_rowsperpage, $offset) as $row): ?>
|
2015-02-26 12:44:21 -05:00
|
|
|
<tr>
|
2016-02-04 14:18:34 -05:00
|
|
|
<td><input type="text" name="<?php echo $row['punchid']; ?>-intime" value="<?php echo $row['intime']; ?>" /><input type="text" name="<?php echo $row['punchid']; ?>-outtime" value="<?php echo $row['outtime']; ?>" /></td><td><?php echo $row['lastname'] . ", " . $row['firstname']; ?></td><td><?php echo $row['punchhours']; ?></td><td><?php echo $row['modified']; ?></td><td><input type="text" name="<?php echo $row['punchid']; ?>-notes" value="<?php echo $row['notes']; ?>" /></td><td><nobr><button type="submit" name="editpunch" value="<?php echo $row['punchid']; ?>" class="pure-button button-success"><i class="fa fa-floppy-o fa-lg"></i></button> <button type="submit" name="deletepunch" value="<?php echo $row['punchid']; ?>" class="pure-button button-error"><i class="fa fa-trash-o fa-lg"></i></button></nobr></td>
|
2015-02-26 12:44:21 -05:00
|
|
|
</tr>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</form>
|
2017-05-12 00:38:26 -04:00
|
|
|
</div>
|
2015-02-26 12:44:21 -05:00
|
|
|
<!-- ********** END CONTENT ********** -->
|
2015-02-24 10:37:52 -05:00
|
|
|
<?php endif; require_once($yaptc_inc . "footer.inc.php"); ?>
|