Guest User

Untitled

a guest
May 23rd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. function output_status_hours($summary_punches, $employee_hours, $color1, $color2, $tzo) {
  2. // Fill punch status hour summary array
  3. foreach ($summary_punches as $status) {
  4. $hours["$status"] = 0;
  5. }
  6. // Process each punch
  7. $current_timestamp = 0; // Tracks the current timestamp
  8. $current_date = 0; // Tracks the current date
  9. $previous_date = 0;
  10. $previous_status = ""; // Tracks the last handled status
  11. $current_hour = 0.0; // Current in hour
  12. $previous_hour = 0.0;
  13. $field = mysql_fetch_array($employee_hours);
  14. while ($field) { // If there's another field add the field
  15. $info_inout = "".$field['inout']."";
  16. $info_timestamp = "".$field['timestamp']."" + $tzo;
  17. $info_notes = "".$field['notes']."";
  18. $info_ipaddress = "".$field['ipaddress']."";
  19. $punchlist_in_or_out = "".$field['in_or_out']."";
  20. $punchlist_punchitems = "".$field['punchitems']."";
  21. $punchlist_color = "".$field['color']."";
  22.  
  23. $info_date = date('Y-m-d', $info_timestamp);
  24. $hours = date('G', $info_timestamp);
  25. $minutes = date('i', $info_timestamp) / 60; // Convert minutes to hours
  26. $seconds = date('s', $info_timestamp) / 3600; // Convert seconds to hours
  27. $current_hour = $hours + $minutes + $seconds;
  28.  
  29. print "<tr><td>Pre: $previous_status: ".$hours[$previous_status]."</td></tr>";
  30. if ($previous_date != $info_date) {
  31. if (empty($previous_status)) { // First day's entry
  32. print "<tr><td>$info_date's Hour $punchlist_punchitems: 24.0 - $current_hour = ".(24.0 - $current_hour)."</td></tr>";
  33. $hours[$punchlist_punchitems] = 24.0 - $current_hour;
  34. } else {
  35. print "<tr><td>$previous_date's Hour $previous_status: + $current_hour =".($current_hour)."</td></tr>";
  36. $hours[$previous_status] = $hours[$previous_status] + $current_hour;
  37. }
  38. } else {
  39. print "<tr><td>$previous_date's Hour $previous_status: $current_hour - $previous_hour=".($current_hour - $previous_hour)."</td></tr>";
  40. $hours[$previous_status] = $hours[$previous_status] + $current_hour - $previous_hour;
  41. }
  42. print "<tr><td>Post: $previous_status: ".$hours[$previous_status]."</td></tr>";
  43.  
  44. // Set-up for next field
  45. $previous_date = $info_date;
  46. $previous_status = $punchlist_punchitems;
  47. $field = mysql_fetch_array($employee_hours);
  48. }
  49. }
Add Comment
Please, Sign In to add comment