You are not logged in!!!"; } else { //********** BEGIN CONTENT **********// echo "

Punch History

"; echo "

Below is your company punch history. The below drop-down can be used to select pre-configured reports. Other reports are currently being written.

"; echo "
"; echo "
"; echo "
"; echo "
"; echo " "; echo " "; echo "
"; echo "
"; echo " "; echo "
"; echo "
"; if (isset($_POST['reporttype'])) { if ($_POST['reporttype'] == "Hours per week per user") { $query = "SELECT YEAR(punches.intime) AS g_year, WEEK(punches.intime) AS g_week, SUM(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600) 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;"; $stmt = $sql->prepare($query); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); //set up table header and open table echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; // $rows is an array containing all records... foreach ($rows as $row) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo ''; echo '
YearWeek#UsernameHours
" . $row['g_year'] . "" . $row['g_week'] . "" . $row['username'] . "" . $row['punchhours'] . "
'; } elseif ($_POST['reporttype'] == "Hours per month per user") { $query = "SELECT YEAR(punches.intime) AS g_year, MONTH(punches.intime) AS g_month, SUM(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600) 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;"; $stmt = $sql->prepare($query); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); //set up table header and open table echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; // $rows is an array containing all records... foreach ($rows as $row) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo ''; echo '
YearMonthUsernameHours
" . $row['g_year'] . "" . $row['g_month'] . "" . $row['username'] . "" . $row['punchhours'] . "
'; } else { echo "no query"; } } else { echo "no query"; } //********** END CONTENT **********// } require_once($yaptc_inc . "footer.inc.php"); ?>