ATTENDANCE REPORT

For:

OHC Name: format('Y-m-d H:i:s'); $sql_attendance = "SELECT ar.out_time as out_time FROM `attendance_detail` ar RIGHT JOIN `attendance_master` a ON a.attendance_id = ar.attendance_id where ar.staff_id = '$id' AND ar.staff_deploy_ohc = '" . $ohc_idd . "' and ar.out_time>'$indate_formatted' and day(ar.out_time)='$i' and month(ar.out_time) = '" . $month . "' and year(a.attendance_date)='" . $year . "' "; error_log("QUERY OUTTIME greater::" . $sql_attendance); $query_attendance = mysqli_query($GLOBALS['conn'], $sql_attendance); $row_att = mysqli_fetch_array($query_attendance); error_log("OUTTIME Greater::" . $row_att['out_time']); $outTime = $row_att['out_time']; if ($outTime == "") { $outTime = ""; } else { $date = date_create($outTime); $time = date_format($date, "d-m-Y h:i:sa"); // $time = date_format( $date , "h:i:sa"); $outTime = $time; } return $outTime; } function getOt($i, $id, $ohc_idd, $year) { $sql_attendance = "SELECT ar.ot as ot FROM `attendance_detail` ar RIGHT JOIN `attendance_master` a ON a.attendance_id = ar.attendance_id where ar.staff_id = '$id' AND ar.staff_deploy_ohc = '" . $ohc_idd . "' and day(ar.in_time)='$i' and month(a.attendance_date) = '" . $_POST['attend_month'] . "' and year(a.attendance_date)='" . $year . "' "; error_log("QUERY ot::" . $sql_attendance); $query_attendance = mysqli_query($GLOBALS['conn'], $sql_attendance); $row_att = mysqli_fetch_array($query_attendance); error_log("ot::" . $row_att['ot']); $ot = $row_att['ot']; return strtoupper($ot); } function getRemarks($i, $id, $ohc_idd, $year) { $sql_attendance = "SELECT ar.remark as remarks FROM `attendance_detail` ar RIGHT JOIN `attendance_master` a ON a.attendance_id = ar.attendance_id where ar.staff_id = '$id' AND ar.staff_deploy_ohc = '" . $ohc_idd . "' and day(ar.in_time)='$i' and month(a.attendance_date) = '" . $_POST['attend_month'] . "' and year(a.attendance_date)='" . $year . "'"; error_log("REMARKS" . $sql_attendance); $query_attendance = mysqli_query($GLOBALS['conn'], $sql_attendance); $row_att = mysqli_fetch_array($query_attendance); return $row_att['remarks']; } function getRelay($id) { $sql_attendance = "SELECT a.relay_set_work FROM `attendance_detail` ar RIGHT JOIN `attendance_master` a ON a.attendance_id = ar.attendance_id where ar.staff_id = '$id' "; error_log("REMARKS" . $sql_attendance); $query_attendance = mysqli_query($GLOBALS['conn'], $sql_attendance); $row_att = mysqli_fetch_array($query_attendance); if ($row_att['relay_set_work'] == 'G') { return 'GENERAL'; } else { return $row_att['relay_set_work']; } } function getNoOfDays($id, $ohc_idd, $year) { $sql_days = "SELECT in_time , out_time from attendance_detail a left join attendance_master b on a.attendance_id = b.attendance_id where a.staff_id='$id' AND a.staff_deploy_ohc = '" . $ohc_idd . "' and month(b.attendance_date) = '" . $_POST['attend_month'] . "' and a.wo!='W' and year(b.attendance_date)='" . $year . "'"; error_log("NO. OF DAYS::" . $sql_days); $result_days = mysqli_query($GLOBALS['conn'], $sql_days); $numDay = 0; while ($row_days = mysqli_fetch_assoc($result_days)) { if ($row_days['in_time'] == "00:00:00" && $row_days['out_time'] == "00:00:00") { if (empty($row_days['out_time']) && empty($row_days['in_time'])) { } } else { $numDay++; } } return $numDay; } function getWo($id, $ohc_idd, $year) { $sql_days = "SELECT count(*) as total from attendance_detail a left join attendance_master b on a.attendance_id = b.attendance_id where a.staff_id='$id' AND a.staff_deploy_ohc = '" . $ohc_idd . "' and month(b.attendance_date) = '" . $_POST['attend_month'] . "' and a.wo='W' and year(a.attendance_date)='" . $year . "'"; error_log("NO. OF DAYS::" . $sql_days); $result_days = mysqli_query($GLOBALS['conn'], $sql_days); $woDay = 0; if ($row_days = mysqli_fetch_assoc($result_days)) { $woDay = $row_days['total']; } return $woDay; } function getNoOfHours($intime, $outtime) { $diff = strtotime($outtime) - strtotime($intime); if ($diff < 0) return 0; // $hours = floor($diff / 3600); $minutes = floor($diff / 60); // error_log("DIFFERENCE::" . $hours . " --- " . $minutes); return $minutes; } function convertMinutesToHoursAndMinutes($minutes) { $hours = floor($minutes / 60); $remainingMinutes = $minutes % 60; $result = $hours . " hour" . ($hours == 1 ? "" : "s"); if ($remainingMinutes > 0) { $result .= " and " . $remainingMinutes . " minute" . ($remainingMinutes == 1 ? "" : "s"); } return $result; } error_log('tt'.cal_days_in_month(CAL_GREGORIAN, $_POST['attend_month'], $year)); ?> getTimestamp() > $datetimeObjOut->getTimestamp()) { $out_time = getOutTimeGreater($i, $row_attend['staff_id'], $ohc_id, $_POST['attend_month'], $year, $in_time); if ($out_time == "") { $out_time = getOutTime($i + 1, $row_attend['staff_id'], $ohc_id, $_POST['attend_month'], $year); } } } $total += getNoOfHours($in_time, $out_time); $total_hours[$count] = $total; error_log("out time " . $out_time); ?>
Sr. Name No. of Days Worked No. of Hours Worked W/O Absent
In Out Worked Hrs O/T Remark
h.' Hrs '.$interval->i.' min '; } ?>