PHP로 작성해야하는 직원 지불에 대한 시간 차이 시간당 요금이 필요한 보고서가 있습니다. 예를 들어MySQL 쿼리를 사용하는 PHP의 시간 계산
:이 내가 어떤 제안 ... PHP에서 어떻게해야 할 수있는 쉬운 방법이 아닌 경우
Employee Clock-In Clock-Out Total-Hours Rate Salary
Mike 2015-01-01 22:57:09 2015-01-02 11:48:14 12:51:05 10 128.51
Mike 2015-01-03 11:48:51 2015-01-06 22:19:27 82:30:36 10 825.10
Mike 2015-01-06 21:19:40 2015-01-06 22:00:00 00:40:20 10 6.72
내 쿼리가
SELECT tt.id,ts.fname,tt.punch_in,tt.punch_out,
SEC_TO_TIME(TIMESTAMPDIFF(SECOND,tt.punch_in,tt.punch_out)) as working_hours_new,ter.hourlyrate,
((SUBSTRING(SEC_TO_TIME(TIMESTAMPDIFF(SECOND,tt.punch_in,tt.punch_out)),1,2) + SUBSTRING(SEC_TO_TIME(TIMESTAMPDIFF(SECOND,tt.punch_in,tt.punch_out)),4,2)/60 + SUBSTRING(SEC_TO_TIME(TIMESTAMPDIFF(SECOND,tt.punch_in,tt.punch_out)),7,2)/3600) * ter.hourlyrate) as pay
from tbl_times as tt left join tbl_server as ts on ts.serverid = tt.user_id left join tbl_employee_rates as ter on ter.userid=tt.user_id
where ts.locationid = ? and ts.active = 1 and ter.stauts = 1 and date(punch_in) >= ? and date(punch_out) <= ?
이하?