Updated Pure to 0.6, added pagination, don't think I broke anything...

This commit is contained in:
2015-02-26 12:44:21 -05:00
parent 73c7c17219
commit 05bf1f9682
55 changed files with 2459 additions and 3388 deletions

View File

@@ -12,6 +12,7 @@ function lang($phrase){
'NO_PUNCHES' => 'You have no recorded punches',
'NOT_AUTHORIZED' => 'Not Authorized!',
'OUT' => 'Out',
'PAGE' => 'Page',
'IN' => 'In',
'ADD_USER' => 'Add User',
'ADD_USER_DESC' => 'All fields are required! Username and email must be unique. Minimum password length is ',
@@ -24,7 +25,9 @@ function lang($phrase){
'ACCOUNT' => 'Account',
'META_DESC' => 'YAPTC Timecard system is a time recording application for small businesses.',
'USERS' => 'Manage Users',
'SAVE_PUNCH_WARNING' => 'Are you sure you want to save the edit to this user punch?',
'SAVE' => 'Save',
'DELETE' => 'Delete',
'NEW' => 'New',
'NAME' => 'Name',
'CONFIRM' => 'Confirm',
@@ -51,6 +54,8 @@ function lang($phrase){
'EMAIL' => 'E-Mail',
'USER_INFORMATION' => 'User Information',
'PUNCH_EDITOR' => 'Punch Edit',
'EDIT_PUNCH_HEADER' => 'User Punches',
'EDIT_PUNCH_DESC' => 'Edit or delete existing punches for users if needed. WARNING - there is NO UNDO for these actions!!!',
'PLEASE_LOG_IN' => 'Please log in to use the timecard system',
'REPORTS' => 'Reports',
'SINCE' => 'since',
@@ -73,6 +78,9 @@ $timenow = date('Y-m-d H:i:s');
// This Version
$yaptc_version = 'yaptc 0.8-beta';
// Timezone from config
date_default_timezone_set("$timezone");
// 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
@@ -162,10 +170,8 @@ function getPunchStatus($yaptc_db, $userid)
return array ($result['punchid'], $result['userid'], $result['intime'], $result['outtime'], $result['notes']);
}
// List punches sorted by intime. Pass uid or % for all. Pass limit to restrict row results. Default is set to tons of 9's because no wildcard exists for limit in mysql or pgsql
function listPunches($db, $uid, $limit = "999999999999999") {
// List punches sorted by intime. Pass uid or % for all. Pass limit to restrict row results. Default is set to tons of 9's because no wildcard exists for limit in mysql or pgsql. Limit can also include offset for pagination, i.e. "20,10" for a result of 10 records starting 20 records in
function listPunches($db, $uid, $limit = "999999999999999", $offset = "0") {
$stmt = $db->prepare('
SELECT
ROUND(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600,2) AS punchhours,
@@ -181,17 +187,18 @@ function listPunches($db, $uid, $limit = "999999999999999") {
INNER JOIN yaptc.users ON punches.userid = users.id
WHERE users.id LIKE :uid
ORDER BY punches.intime DESC
LIMIT :limit
LIMIT :limit OFFSET :offset
');
$stmt->execute(array(
':uid' => $uid,
':limit' => $limit,
':offset' => $offset
));
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
// Get user info from user id. Pass uid or % for all.
function getUserInfo($db, $uid) {
function getUserInfo($db, $uid, $limit = "999999999999999", $offset = "0") {
$stmt = $db->prepare('
SELECT
users.id AS userid,
@@ -206,10 +213,13 @@ function getUserInfo($db, $uid) {
FROM yaptc.users
INNER JOIN yaptc.usertypes ON users.usertype = usertypes.id
WHERE users.id LIKE :uid
ORDER BY users.lastname ASC;
ORDER BY users.lastname ASC
LIMIT :limit OFFSET :offset
');
$stmt->execute(array(
':uid' => $uid
':uid' => $uid,
':limit' => $limit,
':offset' => $offset
));
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}

View File

@@ -1,5 +1,5 @@
<?php
if (isset($_SESSION['user_id'])): $session_user = getUserInfo($db, $_SESSION['user_id']); endif;
if (isset($_SESSION['user_id'])): $session_user = getUserInfo($db, $_SESSION['user_id'], "1", "0"); endif;
$session_status = getSessionStatus();
?>
<!-- SIDE MENU -->
@@ -7,22 +7,22 @@ $session_status = getSessionStatus();
<div id="menu">
<div class="pure-menu pure-menu-open">
<a class="pure-menu-heading" href="index.php"><?php echo $yaptc_company; ?></a>
<ul>
<ul class="pure-menu-list">
<?php if ($session_status == false): ?>
<!-- MENU FOR ALL LOGGED OUT -->
<li class="<?php if ($yaptc_pagename==lang('LOGIN')): echo "pure-menu-selected"; endif; ?>"><a href="login.php"><?php echo lang('LOGIN'); ?></a></li>
<li class="pure-menu-item <?php if ($yaptc_pagename==lang('LOGIN')): echo "pure-menu-selected"; endif; ?>"><a href="login.php" class="pure-menu-link"><?php echo lang('LOGIN'); ?></a></li>
<?php elseif ($session_status == true): ?>
<!-- MENU FOR ALL LOGGED IN -->
<li class="<?php if ($yaptc_pagename==lang('HOME')): echo "pure-menu-selected"; endif; ?>"><a href="index.php"><?php echo lang('HOME'); ?></a></li>
<li class="<?php if ($yaptc_pagename==lang('ACCOUNT')): echo "pure-menu-selected"; endif; ?>"><a href="profile.php"><?php echo lang('ACCOUNT'); ?></a></li>
<li class="pure-menu-item <?php if ($yaptc_pagename==lang('HOME')): echo "pure-menu-selected"; endif; ?>"><a href="index.php" class="pure-menu-link"><?php echo lang('HOME'); ?></a></li>
<li class="pure-menu-item <?php if ($yaptc_pagename==lang('ACCOUNT')): echo "pure-menu-selected"; endif; ?>"><a href="profile.php" class="pure-menu-link"><?php echo lang('ACCOUNT'); ?></a></li>
<?php if ($session_user["0"]["usertype"] == "Administrator"): ?>
<!-- ADDITIONAL MENU IF LOGGED IN AS ADMIN -->
<li class="<?php if ($yaptc_pagename==lang('USERS')): echo "pure-menu-selected"; endif; ?>"><a href="users.php"><?php echo lang('USERS'); ?></a></li>
<li class="<?php if ($yaptc_pagename==lang('PUNCH_EDITOR')): echo "pure-menu-selected"; endif; ?>"><a href="manualpunch.php"><?php echo lang('PUNCH_EDITOR'); ?></a></li>
<li class="<?php if ($yaptc_pagename==lang('REPORTS')): echo "pure-menu-selected"; endif; ?>"><a href="reports.php"><?php echo lang('REPORTS'); ?></a></li>
<li class="pure-menu-item <?php if ($yaptc_pagename==lang('USERS')): echo "pure-menu-selected"; endif; ?>"><a href="users.php" class="pure-menu-link"><?php echo lang('USERS'); ?></a></li>
<li class="pure-menu-item <?php if ($yaptc_pagename==lang('PUNCH_EDITOR')): echo "pure-menu-selected"; endif; ?>"><a href="manualpunch.php" class="pure-menu-link"><?php echo lang('PUNCH_EDITOR'); ?></a></li>
<li class="pure-menu-item <?php if ($yaptc_pagename==lang('REPORTS')): echo "pure-menu-selected"; endif; ?>"><a href="reports.php" class="pure-menu-link"><?php echo lang('REPORTS'); ?></a></li>
<?php endif; ?>
<!-- MENU FOR ALL LOGGED IN - BOTTOM END -->
<li class="<?php if ($yaptc_pagename==lang('LOGOUT')): echo "pure-menu-selected"; endif; ?>"><a href="logout.php"><?php echo lang('LOGOUT'); ?></a></li>
<li class="pure-menu-item <?php if ($yaptc_pagename==lang('LOGOUT')): echo "pure-menu-selected"; endif; ?>"><a href="logout.php" class="pure-menu-link"><?php echo lang('LOGOUT'); ?></a></li>
<?php endif; ?>
</ul>
</div>