0
직원들이 시계를 넣을 수있는 시간 제한 시스템을 편집 중이며 지난 7 일 동안의 총 시간을 표시하려고합니다.하지만 코드는 조금 뒤죽박죽입니다. 어떻게 접근하는지 알아내는 데 어려움이 있습니다. 누가 나 좀 도와주고 싶어?지난 7 일 동안의 총 시간 표시
<?php
// check if we have a report to generate
if ($_GET['action'] == "generate") {
// get name
$sql = "select name from employees where id = " . $_GET['employee_id'] . " limit 1";
$result = mysql_query($sql) or die($sql);
$row = mysql_fetch_assoc($result);
extract($row);
// maybe need to edit this to get a better idea of time
$sql = "select unix_timestamp(time_in) as time_i, unix_timestamp(time_out) as time_o, timediff(time_out, time_in) as time_diff from time where employee_id = " .
$_GET['employee_id'] . " and time_out is not null and time_in between '" . $_GET['date_from'] . "' and '" . $_GET['date_to'] . " 23:59:59' and " .
"date_format(time_out, '%c%d%Y') = date_format(time_in, '%c%d%Y') order by time_i asc";
$result = mysql_query($sql) or die($sql);
echo "<h1>TimeClock Report for $name</h1>\n";
echo "<table cellpadding=\"4\" cellspacing=\"6\">\n";
echo "<tr><th align=\"center\"><u>Date</u></th><th align=\"center\"><u>Clock In Time</u></th><th align=\"center\"><u>Clock Out Time</u></th><th align=\"center\"><u>Total Time</u></th></tr>\n";
$current_time = time();
$new_time = $current_time;
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td align=\"center\">" . date("M jS", $row['time_i']) . "</td>";
echo "<td align=\"center\">" . date("g:i:s A", $row['time_i']) . "</td>";
echo "<td align=\"center\">" . date("g:i:s A", $row['time_o']) . "</td>";
echo "<td align=\"center\">" . $row['time_diff'] . "</td>";
echo "</tr>\n";
$hrs = substr($row['time_diff'], 0, 2);
$min = substr($row['time_diff'], 3, 2);
$sec = substr($row['time_diff'], 6, 2);
$new_time += $sec;
$new_time += ($min * 60);
$new_time += ($hrs * 60 * 60);
}
echo "</table>\n";
$date_diff = $new_time - $current_time;
$fullDays = floor($date_diff/(60*60*24));
$fullHours = floor(($date_diff-($fullDays*60*60*24))/(60*60));
$fullMinutes = floor(($date_diff-($fullDays*60*60*24)-($fullHours*60*60))/60);
$fullHours = $fullHours + ($fullDays * 24);
echo "<strong><u>Total:</u></strong> $fullHours hours $fullMinutes mins\n";
}
?>