diff --git a/config.inc.php.example b/config.inc.php.example index ecd3c63..038d0f6 100755 --- a/config.inc.php.example +++ b/config.inc.php.example @@ -8,7 +8,7 @@ $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 $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 diff --git a/includes/functions.inc.php b/includes/functions.inc.php index 1b41ba3..7b6f2b1 100755 --- a/includes/functions.inc.php +++ b/includes/functions.inc.php @@ -9,27 +9,7 @@ ORDER BY users.lastname ASC;"); return $stmt->fetchAll(PDO::FETCH_ASSOC); } -// Update user profile -function updateUserProfile($yaptc_db, $userid, $firstname, $lastname, $email) -{ -$stmt = $yaptc_db->prepare("UPDATE users SET firstname = :firstname, lastname = :lastname, email = :email WHERE id = :userid;"); -$stmt->execute(array( - ':userid' => $userid, - ':firstname' => $firstname, - ':lastname' => $lastname, - ':email' => $email, - )); -} -// Update user profile -function updateUserPassword($yaptc_db, $userid, $password) -{ -$stmt = $yaptc_db->prepare("UPDATE users SET password = :password WHERE id = :userid;"); -$stmt->execute(array( - ':userid' => $userid, - ':password' => $password, - )); -} // Get login status - returns true or false @@ -51,37 +31,29 @@ function killSession() header("Location: login.php"); } -// Get user access level. Call with $sql passed or it will not work correctly -function getSessionAccess($yaptc_db) -{ - if (isset($_SESSION['user_id'])) { - $query3 = "SELECT users.id as userid, usertypes.typename AS usertype FROM yaptc.users INNER JOIN yaptc.usertypes ON users.usertype = usertypes.id WHERE users.id = :id"; - $stmt3 = $yaptc_db->prepare($query3); - $stmt3->execute(array( - ':id' => $_SESSION['user_id'] - )); - $user3 = $stmt3->fetchObject(); - return $user3->usertype; - } -} + // Punch Out -function punchOut($yaptc_db, $punchid, $notes) +function punchOut($yaptc_db, $punchid, $notes, $outtime, $modified=NULL) { -$stmt = $yaptc_db->prepare("UPDATE punches SET punches.outtime = NOW(), punches.notes = :notes WHERE punches.id = :punchid;"); +$stmt = $yaptc_db->prepare("UPDATE punches SET punches.outtime = :outtime, punches.notes = :notes, punches.modified = :modified WHERE punches.id = :punchid;"); $stmt->execute(array( ':punchid' => $punchid, + ':modified' => $modified, + ':outtime' => $outtime, ':notes' => $notes )); } // Punch In -function punchIn($yaptc_db, $userid, $notes) +function punchIn($yaptc_db, $userid, $notes, $punchtime, $modified=NULL) { -$stmt = $yaptc_db->prepare("INSERT INTO punches (punches.userid, punches.notes, punches.intime) VALUES (:userid, :notes, NOW());"); +$stmt = $yaptc_db->prepare("INSERT INTO punches (punches.userid, punches.notes, punches.intime, punches.modified) VALUES (:userid, :notes, :punchtime, :modified);"); $stmt->execute(array( ':userid' => $userid, - ':notes' => $notes + ':notes' => $notes, + ':punchtime' => $punchtime, + ':modified' => $modified )); } @@ -96,16 +68,140 @@ 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") { + $stmt = $db->prepare(' + SELECT + ROUND(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600,2) AS punchhours, + punches.id as punchid, + punches.intime as intime, + punches.outtime as outtime, + users.id AS userid, + users.firstname as firstname, + users.lastname as lastname, + REPLACE (punches.modified, "1", "YES") as modified, + punches.notes as notes + FROM yaptc.punches + INNER JOIN yaptc.users ON punches.userid = users.id + WHERE users.id LIKE :uid + ORDER BY punches.intime DESC + LIMIT :limit + '); + $stmt->execute(array( + ':uid' => $uid, + ':limit' => $limit, + )); + return $stmt->fetchAll(PDO::FETCH_ASSOC); +} + +// Get user info from user id. Pass uid or % for all. +function getUserInfo($db, $uid) { + $stmt = $db->prepare(' + SELECT + users.id AS userid, + users.username AS username, + users.firstname AS firstname, + users.lastname AS lastname, + users.email AS email, + usertypes.typename AS usertype, + usertypes.id AS usertypeid, + users.created AS created, + users.password AS password + FROM yaptc.users + INNER JOIN yaptc.usertypes ON users.usertype = usertypes.id + WHERE users.id LIKE :uid + ORDER BY users.lastname ASC; + '); + $stmt->execute(array( + ':uid' => $uid + )); + return $stmt->fetchAll(PDO::FETCH_ASSOC); +} + + +// Update user profile +function updateUserPassword($yaptc_db, $userid, $password) +{ +$stmt = $yaptc_db->prepare("UPDATE users SET password = :password WHERE id = :userid;"); +$stmt->execute(array( + ':userid' => $userid, + ':password' => $password, + )); +} + + + +// Set user info from user id +function setUserInfo($db, $uid, $firstname, $lastname, $email, $usertypeid, $password) { + $stmt = $db->prepare(' + UPDATE + yaptc.users + SET + firstname = :firstname, + lastname = :lastname, + email = :email, + usertype = :usertypeid, + password = :password + WHERE id = :uid + '); + $stmt->execute(array( + ':uid' => $uid, + ':firstname' => $firstname, + ':lastname' => $lastname, + ':email' => $email, + ':usertypeid' => $usertypeid, + ':password' => $password, + )); + +} + // Report - Weekly Hours by Week then User -function reportWeeklyByUser($yaptc_db) { - $stmt = $yaptc_db->query("SELECT YEAR(punches.intime) AS g_year, WEEK(punches.intime) AS g_week, ROUND(SUM(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600),2) AS punchhours, punches.id as punchid, users.id as user, users.username as username, users.firstname as firstname, users.lastname as lastname, punches.intime as intime, punches.outtime as outtime, punches.notes as notes, punches.modified as modified FROM punches INNER JOIN users ON punches.userid = users.id GROUP BY g_year, g_week, users.username;"); - return $stmt->fetchAll(PDO::FETCH_ASSOC); +function reportWeeklyByUser($yaptc_db) +{ + $statement = $yaptc_db->prepare(' + SELECT + YEAR(punches.intime) AS g_year, + WEEK(punches.intime) AS g_week, + ROUND(SUM(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600),2) AS punchhours, + punches.intime as intime, + punches.outtime as outtime, + users.firstname as firstname, + users.lastname as lastname, + REPLACE (punches.modified, "1", "YES") as modified, + punches.notes as notes + FROM yaptc.punches + INNER JOIN yaptc.users ON punches.userid = users.id + GROUP BY g_year, g_week, users.username + '); + $statement->execute(); + return $statement->fetchAll(PDO::FETCH_ASSOC); } // Report - Monthly Hours by Month then User -function reportMonthlyByUser($yaptc_db) { - $stmt = $yaptc_db->query("SELECT YEAR(punches.intime) AS g_year, MONTHNAME(punches.intime) AS g_month, ROUND(SUM(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600),2) AS punchhours, punches.id as punchid, users.id as user, users.username as username, users.firstname as firstname, users.lastname as lastname, punches.intime as intime, punches.outtime as outtime, punches.notes as notes, punches.modified as modified FROM punches INNER JOIN users ON punches.userid = users.id GROUP BY g_year, g_month, users.username;"); - return $stmt->fetchAll(PDO::FETCH_ASSOC); +function reportMonthlyByUser($yaptc_db) +{ + $statement = $yaptc_db->prepare(' + SELECT + YEAR(punches.intime) AS g_year, + MONTHNAME(punches.intime) AS g_month, + ROUND(SUM(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600),2) AS punchhours, + punches.intime as intime, + punches.outtime as outtime, + users.firstname as firstname, + users.lastname as lastname, + REPLACE (punches.modified, "1", "YES") as modified, + punches.notes as notes + FROM yaptc.punches + INNER JOIN yaptc.users ON punches.userid = users.id + GROUP BY g_year, g_month, users.username; + '); + $statement->execute(); + return $statement->fetchAll(PDO::FETCH_ASSOC); } + + +// EOF ?> diff --git a/includes/menu.inc.php b/includes/menu.inc.php index 0090857..83e8dd0 100755 --- a/includes/menu.inc.php +++ b/includes/menu.inc.php @@ -12,38 +12,39 @@ ';} else {echo '>';} echo 'Home'; - } -// Profile -if ($userLogged == true) { - echo '
You do not appear to have any punches on record.
You have been Punched since .
@@ -37,6 +39,7 @@ else: ?> + + diff --git a/lib/pure/HISTORY.md b/lib/pure/HISTORY.md deleted file mode 100755 index 445de01..0000000 --- a/lib/pure/HISTORY.md +++ /dev/null @@ -1,413 +0,0 @@ -Pure Change History -=================== - -0.5.0 (2014-05-27) ------------------- - -### Base - -* Added the `.pure-img` class name for make images scale with the viewport in - fluid layouts. - -### Grids - -* __[!]__ Removed `.pure-g-r` from core, in favor of a mobile-first responsive - grid system. ([#24][], [#267][]) - - To use the mobile-first grid system, you need to pull in `pure.css`, along - with `grids-responsive.css`. We also have `grids-responsive-old-ie.css` that - you can serve to IE < 9 users so that they can view a desktop-version of your - website: - - ```html - - - - - - - ``` - - Find out more about the new grid system at