Javi validation
gitea/salix/timeControl_calculate This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-11-21 14:39:09 +01:00
parent a45ca84e7f
commit 33e9cf9816
1 changed files with 8 additions and 10 deletions

View File

@ -19,18 +19,17 @@ BEGIN
userFk,
dated
FROM (SELECT IF(@vUser = wtc.userFk, @vUser :=@vUser, @vUser := wtc.userFk ),
IF(@vIsOdd, @vIsOdd := FALSE, @vIsOdd := TRUE ),
IF(direction='in', @vIsOdd := TRUE, @vIsOdd := @vIsOdd ),
IF(@vIsOdd, @vLastTimed:=UNIX_TIMESTAMP(timed),@vLastTimed:=@vLastTimed),
IF(@vIsOdd, 0, UNIX_TIMESTAMP(timed)-@vLastTimed) timeWork,
IF(direction='in', @vDated := DATE(wtc.timed), @vDated :=@vDated) dated,
IF(wtc.direction='in', @vIsOdd := TRUE, @vIsOdd := !@vIsOdd),
IF(@vIsOdd, @vLastTimed:=UNIX_TIMESTAMP(wtc.timed), TRUE),
IF(@vIsOdd, 0, UNIX_TIMESTAMP(wtc.timed)-@vLastTimed) timeWork,
IF(wtc.direction='in', @vDated := DATE(wtc.timed), @vDated) dated,
wtc.userFk,
wtc.timed timed,
direction
wtc.direction
FROM workerTimeControl wtc
JOIN tmp.`user` w ON w.userFk = wtc.userFk
WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo
ORDER BY userFk, timed
WHERE wtc.timed BETWEEN curdate()-1 AND curdate()
ORDER BY wtc.userFk, wtc.timed
) sub
GROUP BY userFk, dated
ORDER BY userFk, dated
@ -39,4 +38,3 @@ BEGIN
END$$
DELIMITER ;