diff --git a/config.inc.php.example b/config.inc.php.example index bbd6cce..b717be7 100755 --- a/config.inc.php.example +++ b/config.inc.php.example @@ -7,10 +7,9 @@ $yaptc_appname = 'Timecard System'; // Program name to display in $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_adminmsg = ''; // Message will display on all pages! $yaptc_allowadvancedpunch = 'yes'; // Should we allow users to make manual punch entries? set to yes or no $yaptc_min_password = '8'; // Minimum password length -$yaptc_language = 'en'; // Language +$yaptc_language = 'en'; // 2-character language code. Used to set HTML header and language template diff --git a/includes/footer.inc.php b/includes/footer.inc.php index 2f6f4a7..0199f85 100755 --- a/includes/footer.inc.php +++ b/includes/footer.inc.php @@ -1,8 +1,9 @@ - -
-

-
- - - + +
+

+
+ + + + diff --git a/includes/functions.inc.php b/includes/functions.inc.php index 859973b..9a426e8 100755 --- a/includes/functions.inc.php +++ b/includes/functions.inc.php @@ -3,15 +3,65 @@ // Languages function lang($phrase){ static $lang = array( + 'ACCOUNT_INFO_HEADER' => 'Account Information', + 'ACCOUNT_INFO_DESC' => 'You may make changes to your user profile below. To change your password, enter a new password twice below and press save. Minimum password length is ', + 'USER_LIST_HEADER' => 'User List', + 'USER_LIST_DESC' => 'Delete or Punch users from the actions column. Eventually, password resets will also be enabled.', + 'PUNCH_HISTORY_HEADER' => 'Punch History', + 'PUNCH_HISTORY_DESC' => 'The following is your entire punch history, most recent first.', 'NO_PUNCHES' => 'You have no recorded punches', + 'NOT_AUTHORIZED' => 'Not Authorized!', 'OUT' => 'Out', 'IN' => 'In', + 'ADD_USER' => 'Add User', + 'ADD_USER_DESC' => 'All fields are required! Username and email must be unique. Minimum password length is ', + 'HOURS' => 'Hours', + 'FLAG' => 'Flag', + 'NOTES' => 'Notes', + 'HOME' => 'Home', + 'LOGIN' => 'Login', + 'LOGOUT' => 'Logout', + 'ACCOUNT' => 'Account', + 'META_DESC' => 'YAPTC Timecard system is a time recording application for small businesses.', + 'USERS' => 'Manage Users', + 'SAVE' => 'Save', + 'NEW' => 'New', + 'NAME' => 'Name', + 'CONFIRM' => 'Confirm', + 'PUNCH' => 'Punch', + 'NOTES_PLACEHOLDER' => 'Enter notes if needed', + 'USERNAME' => 'Username', + 'DELETE_WARNING' => '********* WARNING! ********** Are you SURE you want to DELETE this user AND ALL ASSOCIATED PUNCHES!?!? There is NO UNDO!', + 'ACTIONS' => 'Actions', + 'CREATED' => 'Created', + 'MIN_PASSWORD_LENGTH' => 'Minimum password length is ', + 'USERTYPE' => 'User Type', + 'ILLEGAL_CHARACTERS' => 'Username contains illegal characters', + 'PASSWORD_NOTMATCH' => 'Passwords do not match', + 'EMAIL_NOTVALID' => 'Email address not valid', + 'USERNAME_NOTEMPTY' => 'Username cannot be empty', + 'PASSWORD_NOTEMPTY' => 'Password cannot be empty', + 'USERNAME_USED' => 'Username already in use', + 'EMAIL_USED' => 'Email already in use', + 'PASSWORD_NOTCONFIRMED' => 'Password must be confirmed', + 'PASSWORD' => 'Password', + 'USER' => 'User', + 'FIRSTNAME' => 'First Name', + 'LASTNAME' => 'Last Name', + 'EMAIL' => 'E-Mail', + 'USER_INFORMATION' => 'User Information', + 'PUNCH_EDITOR' => 'Punch Edit', + 'PLEASE_LOG_IN' => 'Please log in to use the timecard system', + 'REPORTS' => 'Reports', '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.', + 'ADVANCED_PUNCH_PARAGRAPH' => 'Click the punch button to immediately punch your time. You may also make changes to the defaults. Note that changing the punch time will result in a flag on the punch for your administrator to review.', 'YOU_HAVE_BEEN_PUNCHED' => 'You have been punched', - 'QUICK_PUNCH' => 'Quick Punch' + 'QUICK_PUNCH' => 'Quick Punch', + 'SOFTWARE_VERSION' => 'Software Version', + 'ADVANCED_PUNCH' => 'Advanced Punch' ); return $lang[$phrase]; } @@ -20,6 +70,9 @@ function lang($phrase){ // Current Time $timenow = date('Y-m-d H:i:s'); +// This Version +$yaptc_version = 'yaptc 0.8-beta'; + // 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 diff --git a/includes/header.inc.php b/includes/header.inc.php index 546b68e..bda4649 100755 --- a/includes/header.inc.php +++ b/includes/header.inc.php @@ -1,28 +1,27 @@ - - - - - -<?php echo $yaptc_company . ">" . $yaptc_appname . ">" . $yaptc_pagename; ?> - - - - - - - - - - - - - - - - - + + + + + + <?php echo $yaptc_company . " > " . $yaptc_appname . " > " . $yaptc_pagename; ?> + + + + + + + + + + + +
diff --git a/includes/menu.inc.php b/includes/menu.inc.php index 83e8dd0..5005061 100755 --- a/includes/menu.inc.php +++ b/includes/menu.inc.php @@ -1,62 +1,35 @@ -
- - - - - - - - -
- -
-

-

-

" . $adminmessage . "

"; endif; ?> -
- -
+ + + +
+
+

+

+
+
diff --git a/includes/side-menu.css b/includes/side-menu.css index f52671b..2449f1d 100755 --- a/includes/side-menu.css +++ b/includes/side-menu.css @@ -38,19 +38,19 @@ body { line-height:1em; } .header { - margin:.25em 0 0 0; + margin:.25em 0 1em 0; color:#333; - padding:.0; + padding:0; border-bottom:2px solid #eee; } .header h1 { - margin:0; + margin:.25em 0 0 0; font-size:2em; font-weight:300; padding:0; } .header h2 { - margin:0; + margin:.25em 0 0 0; font-size:1em; font-weight:300; padding:0; @@ -63,7 +63,7 @@ body { font-size:1.5em; } .content p { - margin:.25em 0 1em 0; + margin:.25em 0 0 0; font-weight:300; color: #888; font-size:1em; diff --git a/index.php b/index.php index 0aea51c..5fcaa71 100755 --- a/index.php +++ b/index.php @@ -2,15 +2,15 @@ session_start(); require_once("config.inc.php"); require_once($yaptc_inc . "functions.inc.php"); -$yaptc_pagename = "Home"; +$yaptc_pagename = lang('HOME'); require_once($yaptc_inc . "header.inc.php"); require_once($yaptc_inc . "menu.inc.php"); if (getSessionStatus() == false): killSession(); else: ?> - - + - - - - - - - -

-

-

-
-
- - - - - - - - -
-
- - +

+

+

+
+
+ + +
+
+ +

+

+

+
+
+ + + +
+
-?> - - - - + + diff --git a/login.php b/login.php index d356f3e..7b8e8eb 100755 --- a/login.php +++ b/login.php @@ -2,18 +2,18 @@ session_start(); require_once("config.inc.php"); require_once($yaptc_inc . "functions.inc.php"); -$yaptc_pagename = "Login"; +$yaptc_pagename = lang('LOGIN'); require_once($yaptc_inc . "header.inc.php"); require_once($yaptc_inc . "menu.inc.php"); if (getSessionStatus() == true): -header ("Refresh:3; url=index.php", true, 303); -echo "

You are already logged in...

"; +header('Location: index.php'); else: ?> - - + prepare($query); @@ -30,20 +30,18 @@ if (!empty($_POST)): $_SESSION['lastname'] = $user->lastname; session_write_close(); header("Location: index.php"); - else: - header("Refresh:3; url=login.php", true, 303); - echo "

Login failed, please try again...

"; endif; endif; ?> -

User Login

-
-
- - -
- -
- +

+
+
+ + +
+ +
+ + diff --git a/logout.php b/logout.php index 8b1cb75..57ee83c 100755 --- a/logout.php +++ b/logout.php @@ -2,16 +2,13 @@ session_start(); require_once("config.inc.php"); require_once($yaptc_inc . "functions.inc.php"); -$yaptc_pagename = "Logout"; +$yaptc_pagename = lang('LOGOUT'); require_once($yaptc_inc . "header.inc.php"); require_once($yaptc_inc . "menu.inc.php"); if (getSessionStatus() == false): killSession(); else: ?> - - + -

Logging out...

- - + diff --git a/profile.php b/profile.php index 84ce2dc..689180e 100755 --- a/profile.php +++ b/profile.php @@ -2,18 +2,17 @@ session_start(); require_once("config.inc.php"); require_once($yaptc_inc . "functions.inc.php"); -$yaptc_pagename = "Profile"; +$yaptc_pagename = lang('ACCOUNT'); require_once($yaptc_inc . "header.inc.php"); require_once($yaptc_inc . "menu.inc.php"); if (getSessionStatus() == false): killSession(); else: ?> - - + HashPassword($_POST['password']); -setUserInfo($db, $session_user["0"]["userid"], $_POST['firstname'], $_POST['lastname'], $_POST['email'], $_POST['usertypeid'], $password); +setUserInfo($db, $session_user["0"]["userid"], $_POST['firstname'], $_POST['lastname'], $_POST['email'], $session_user["0"]["usertypeid"], $password); header('Location: ' . $_SERVER['PHP_SELF']); endif; endif; ?> +

+

+
+
+
+
+ + " readonly /> + + " readonly /> + + " readonly /> +
+
+ + " /> + + " /> + + " /> +
+
+ + + + +
+
+ +
+
+
+
+

+

+ + + + + + + + + + + +
-

Profile Information

-

You may make changes to your user profile below if you wish. Updates will take effect immediately on pressing "Save".

-

To change your password, enter a new password twice below and press save. Password minimum length is

-
-
-
-
- -" readonly> - -" readonly> - -" readonly> -" readonly> -
-
- -"> - -"> - -"> -
-
- - - - -
-
- -
-
-
-
- - - - - + diff --git a/punchlog.php b/punchlog.php deleted file mode 100755 index 072a9b1..0000000 --- a/punchlog.php +++ /dev/null @@ -1,117 +0,0 @@ - - - - -prepare("SELECT punches.id as punchid, users.id as user, punches.intime as intime, punches.outtime as outtime, punches.notes as notes FROM punches INNER JOIN users ON punches.userid = users.id WHERE users.id = $userid ORDER BY punches.id DESC LIMIT 1"); -$result->execute(); -$last = $result->fetchObject(); - -// Let's build the page - this is the header with current status IF allowed -if ($yaptc_allowadvancedpunch == 'yes'): - -echo "

Advanced Punch

"; -if(!isset($last->user)) { - echo "

You do not appear to have any punches on record.

"; - $status = "Out"; - } else { - if (!empty($last->outtime)) { $status = "Out"; $statustime = $last->outtime; } else { $status = "In"; $statustime = $last->intime; $punchid = $last->punchid; $notes = $last->notes; } -echo "

You have been Punched $status since " . date('g:i a \o\n M jS, Y', strtotime($statustime)) . ".

"; -} - -echo "

Use this form to enter a specific time on your punch. NOTE: changing the time from the current time will cause a flag on your log for the administrator to review, so we suggest you enter a reason why in the notes field (i.e. forgot punch, working from home, system down, etc).

"; -echo "
"; -echo "
"; -echo ""; -echo ""; -echo ""; -if (isset($notes)) { -echo ""; -} else { -echo ""; -} -echo "
"; -if ($status=="In") { -echo ""; -echo ""; - } else { -echo ""; -echo ""; -} -echo "
"; - - - - -// If the posted variables are not empty, we must be trying to insert a new punch. Use the form values to insert new record -if (!empty($_POST)) { - -// Is the notes field set? If so, use, otherwise set to null -if (isset($_POST['notes'])) { if (!empty($_POST['notes'])) { $p_notes = $_POST['notes']; } else { $p_notes = NULL; } } else { $p_notes = NULL; } - -// Is the punch time field set? If so, use, otherwise set to now -if (isset($_POST['punchtime'])) { - if (!empty($_POST['punchtime'])) { $p_punchtime = $_POST['punchtime'] . ':00'; $p_modified = "1"; } else { $p_punchtime = $timenow; $p_modified = "0"; } -} else { $p_punchtime = $timenow; $p_modified = "0"; } - -// Is the user currently punched in? If so, insert the punch out record, otherwise, insert a new punch in -if ($status=="In") { - $query = "UPDATE punches SET outtime = :p_punchtime, notes = :p_notes, modified = :p_modified WHERE id = :p_punchid"; - $stmt = $yaptc_db->prepare($query); - $stmt->execute(array( - ':p_punchid' => $punchid, - ':p_notes' => $p_notes, - ':p_punchtime' => $p_punchtime, - ':p_modified' => $p_modified, - )); - } else { - $query = "INSERT INTO punches (userid, notes, intime, modified) VALUES (:p_userid, :p_notes, :p_punchtime, :p_modified)"; - $stmt = $yaptc_db->prepare($query); - $stmt->execute(array( - ':p_userid' => $_SESSION['user_id'], - ':p_notes' => $p_notes, - ':p_punchtime' => $p_punchtime, - ':p_modified' => $p_modified, - )); - } - -// And then send user back to this page to see the updates -header('Location: '.$_SERVER['PHP_SELF']); -} - -// Close out the form... -echo "
"; -echo "
"; -endif; - - - - -echo "

Punch History

"; -echo "

Below is your full punch history, sorted newest to oldest.

"; -?> - - - - - - -
InOutNameHoursFlaggedNotes
- - - - - - diff --git a/users.php b/users.php index 6dab714..077bfd9 100755 --- a/users.php +++ b/users.php @@ -2,50 +2,32 @@ session_start(); require_once("config.inc.php"); require_once($yaptc_inc . "functions.inc.php"); -$yaptc_pagename = "Users"; +$yaptc_pagename = lang('USERS'); require_once($yaptc_inc . "header.inc.php"); require_once($yaptc_inc . "menu.inc.php"); if (getSessionStatus() == false): killSession(); else: ?> - + + + +

+ + +

+

- -

Add User

-

All fields are required! Password must be at least characters. Username and email must be unique.

$_POST['username'], ':email' => $email )); - $existing = $stmt->fetchObject(); + if ($existing): + if ($existing->username == $_POST['username']): $errors['username'] = lang('USERNAME_USED'); endif; + if ($existing->email == $email): $errors['email'] = lang('PASSWORD_USED'); endif; + endif; +endif; - if ($existing) - { - if ($existing->username == $_POST['username']) - { - $errors['username'] = "That username is already in use."; - } - if ($existing->email == $email) - { - $errors['email'] = "That email address is already in use."; - } - } -} - -if (!empty($_POST['newuser']) && empty($errors)) -{ +if (!empty($_POST['newuser']) && empty($errors)): $hasher = new PasswordHash(8, FALSE); $password = $hasher->HashPassword($_POST['password']); + + + $query = "INSERT INTO users (firstname, lastname, username, password, email, created, usertype) VALUES (:firstname, :lastname, :username, :password, :email, NOW(), :usertype)"; $stmt = $yaptc_db->prepare($query); @@ -85,17 +60,8 @@ if (!empty($_POST['newuser']) && empty($errors)) ':email' => $_POST['email'], ':usertype' => $_POST['usertype'], )); - - if ($success) - { - $message = "Account created."; - } - else - { - echo "Account could not be created. Please try again later."; - } -} - + if ($success): $message = "Account created."; else: echo "Account could not be created. Please try again later."; endif; + endif; ?> @@ -132,8 +98,8 @@ if (!empty($_POST['newuser']) && empty($errors))
- + @@ -165,42 +131,20 @@ echo "user deleted!"; ?> -

User List

-

Current users. To edit, select the edit button in the right column.

- - - - - - - - - - - - - - -" . $row['firstname'] . ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -?> - - - - -
First NameLast NameUsernameEmailCreatedUser TypeActions
" . $row['lastname'] . "" . $row['username'] . "" . $row['email'] . "" . $row['created'] . "" . $row['usertype'] . "
- -
+

+

+ + + + + + + + + + + +
- -

NOT AUTHORIZED!

- - - +