Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function output_status_hours($summary_punches, $employee_hours, $color1, $color2, $tzo) {
- // Fill punch status hour summary array
- foreach ($summary_punches as $status) {
- $hours["$status"] = 0;
- }
- // Process each punch
- $current_timestamp = 0; // Tracks the current timestamp
- $current_date = 0; // Tracks the current date
- $previous_date = 0;
- $previous_status = ""; // Tracks the last handled status
- $current_hour = 0.0; // Current in hour
- $previous_hour = 0.0;
- $field = mysql_fetch_array($employee_hours);
- while ($field) { // If there's another field add the field
- $info_inout = "".$field['inout']."";
- $info_timestamp = "".$field['timestamp']."" + $tzo;
- $info_notes = "".$field['notes']."";
- $info_ipaddress = "".$field['ipaddress']."";
- $punchlist_in_or_out = "".$field['in_or_out']."";
- $punchlist_punchitems = "".$field['punchitems']."";
- $punchlist_color = "".$field['color']."";
- $info_date = date('Y-m-d', $info_timestamp);
- $hours = date('G', $info_timestamp);
- $minutes = date('i', $info_timestamp) / 60; // Convert minutes to hours
- $seconds = date('s', $info_timestamp) / 3600; // Convert seconds to hours
- $current_hour = $hours + $minutes + $seconds;
- print "<tr><td>Pre: $previous_status: ".$hours[$previous_status]."</td></tr>";
- if ($previous_date != $info_date) {
- if (empty($previous_status)) { // First day's entry
- print "<tr><td>$info_date's Hour $punchlist_punchitems: 24.0 - $current_hour = ".(24.0 - $current_hour)."</td></tr>";
- $hours[$punchlist_punchitems] = 24.0 - $current_hour;
- } else {
- print "<tr><td>$previous_date's Hour $previous_status: + $current_hour =".($current_hour)."</td></tr>";
- $hours[$previous_status] = $hours[$previous_status] + $current_hour;
- }
- } else {
- print "<tr><td>$previous_date's Hour $previous_status: $current_hour - $previous_hour=".($current_hour - $previous_hour)."</td></tr>";
- $hours[$previous_status] = $hours[$previous_status] + $current_hour - $previous_hour;
- }
- print "<tr><td>Post: $previous_status: ".$hours[$previous_status]."</td></tr>";
- // Set-up for next field
- $previous_date = $info_date;
- $previous_status = $punchlist_punchitems;
- $field = mysql_fetch_array($employee_hours);
- }
- }
Add Comment
Please, Sign In to add comment