diff --git a/config.inc.php.example b/config.inc.php.example index b717be7..787ad5b 100755 --- a/config.inc.php.example +++ b/config.inc.php.example @@ -5,11 +5,12 @@ $yaptc_dirpath = '/usr/share/nginx/html/yaptc/'; // Absolute directory path to $yaptc_webpath = 'http://server-ip/yaptc/'; // Absolute URL to the root of this program $yaptc_appname = 'Timecard System'; // Program name to display in title bar $yaptc_company = 'Widgets, Inc.'; // Your company name -$yaptc_db = new PDO('mysql:host=localhost;dbname=YOUR_DATABASE;charset=utf8', 'YOUR_USER', 'YOUR_PASSWORD'); // Database connection string -$db = new PDO('mysql:host=localhost;dbname=YOUR_DATABASE;charset=utf8', 'YOUR_USER', 'YOUR_PASSWORD'); // Database connection string -$yaptc_allowadvancedpunch = 'yes'; // Should we allow users to make manual punch entries? set to yes or no +$db = new PDO('mysql:host=localhost;dbname=YOUR_DATABASE;charset=utf8', 'YOUR_USER', 'YOUR_PASSWORD'); // Database connection string +$yaptc_allowuseradvancedpunch = 'yes'; // Should we allow users to make manual punch entries? $yaptc_min_password = '8'; // Minimum password length -$yaptc_language = 'en'; // 2-character language code. Used to set HTML header and language template +$yaptc_language = 'en'; // 2-character language code for header and template. See http://www.w3schools.com/tags/ref_language_codes.asp +$timezone = 'America/New_York'; // Primary timezone of system - eventually to work across timezones... +$rowsperpage = '25'; // How many rows per page for tables? diff --git a/includes/functions.inc.php b/includes/functions.inc.php index 9a426e8..d1e15b3 100755 --- a/includes/functions.inc.php +++ b/includes/functions.inc.php @@ -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); } diff --git a/includes/menu.inc.php b/includes/menu.inc.php index 5005061..02d3927 100755 --- a/includes/menu.inc.php +++ b/includes/menu.inc.php @@ -1,5 +1,5 @@ @@ -7,22 +7,22 @@ $session_status = getSessionStatus();