22 lines
791 B
SQL
22 lines
791 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT)
|
|
BEGIN
|
|
/**
|
|
* Obtiene historial de la matrícula vPlate que el trabajador vWorkerFk escanea,
|
|
* si es jefe de producción muestra el historial completo.
|
|
*
|
|
* @param vPlate número de matrícula
|
|
* @param vWorkerFk id del trabajador
|
|
*
|
|
*/
|
|
DECLARE vWorkerName VARCHAR(255) DEFAULT account.user_getNameFromId(vWorkerFk);
|
|
|
|
SELECT mw.inTimed,account.user_getNameFromId(mw.workerFk) as workerName, mw.outTimed
|
|
FROM machineWorker mw
|
|
JOIN machine m ON m.plate = vPlate
|
|
WHERE mw.machineFk = m.id
|
|
AND mw.workerFk = IF(account.user_hasRole(vWorkerName, 'coolerAssist'), mw.workerFk, vWorkerFk)
|
|
ORDER BY mw.inTimed DESC;
|
|
END$$
|
|
DELIMITER ;
|