#3530 Eliminar uso de person
gitea/salix/pipeline/head This commit is unstable Details

This commit is contained in:
Carlos Andrés 2022-07-29 17:03:31 +02:00
parent 67feac7c6c
commit 6f825ee3bc
1 changed files with 425 additions and 486 deletions

View File

@ -4860,9 +4860,8 @@ BEGIN
-- Ventas totales del ultimo año -- Ventas totales del ultimo año
UPDATE indicators UPDATE indicators
SET lastYearSales = SET lastYearSales =
( (SELECT SUM(importe + recargo)
SELECT SUM(importe + recargo) FROM ventas v
FROM bs.ventas v
JOIN vn2008.empresa e ON e.id = v.empresa_id JOIN vn2008.empresa e ON e.id = v.empresa_id
JOIN vn2008.empresa_grupo eg ON eg.empresa_grupo_id = e.empresa_grupo JOIN vn2008.empresa_grupo eg ON eg.empresa_grupo_id = e.empresa_grupo
WHERE fecha BETWEEN oneYearBefore AND vDated WHERE fecha BETWEEN oneYearBefore AND vDated
@ -4873,8 +4872,7 @@ BEGIN
-- Greuge total acumulado -- Greuge total acumulado
UPDATE indicators UPDATE indicators
SET totalGreuge = SET totalGreuge =
( (SELECT SUM(amount)
SELECT SUM(amount)
FROM vn.greuge FROM vn.greuge
WHERE shipped <= vDated WHERE shipped <= vDated
) )
@ -4883,34 +4881,32 @@ BEGIN
-- Tasa de morosidad con respecto a las ventas del último mes -- Tasa de morosidad con respecto a las ventas del último mes
UPDATE indicators UPDATE indicators
SET latePaymentRate = SET latePaymentRate =
(SELECT SUM(amount) FROM bi.defaulters WHERE date = vDated and amount > 0) (SELECT SUM(amount)
FROM bi.defaulters
WHERE date = vDated AND amount > 0)
/ /
( SELECT SUM(importe + recargo) FROM bs.ventas WHERE fecha BETWEEN oneMonthBefore AND vDated) (SELECT SUM(importe + recargo)
FROM ventas
WHERE fecha BETWEEN oneMonthBefore AND vDated)
WHERE updated = vDated; WHERE updated = vDated;
-- Número de trabajadores activos -- Número de trabajadores activos
UPDATE indicators UPDATE indicators
SET countEmployee = SET countEmployee =
( SELECT CAST(SUM(hours_week) / 40 AS DECIMAL (10 , 2 )) (SELECT CAST(SUM(cl.hours_week) / 40 AS DECIMAL (10, 2))
FROM FROM postgresql.business b
postgresql.business AS b JOIN postgresql.business_labour bl ON bl.business_id = b.business_id
JOIN postgresql.profile p ON p.profile_id = b.provider_id JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id
JOIN postgresql.person pe ON pe.person_id = p.person_id WHERE vDated BETWEEN b.date_start AND IFNULL(b.date_end, vDated)
LEFT JOIN AND b.companyCodeFk = 'VNL'
postgresql.business_labour AS bl ON bl.business_id = b.business_id
LEFT JOIN
postgresql.calendar_labour_type AS cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id
WHERE
(vDated BETWEEN b.date_start AND b.date_end OR (b.date_end IS NULL AND b.date_start <= vDated))
AND pe.name = 'VERDNATURA LEVANTE SL'
) )
WHERE updated = vDated; WHERE updated = vDated;
-- Maná medio acumulado por comercial -- Maná medio acumulado por comercial
UPDATE indicators UPDATE indicators
SET averageMana = SET averageMana =
(SELECT avg(used) (SELECT AVG(amount)
FROM bs.mana_spellers FROM vn.workerMana
) )
WHERE updated = vDated; WHERE updated = vDated;
@ -4928,14 +4924,12 @@ BEGIN
SET lastMonthLostClients = SET lastMonthLostClients =
(SELECT COUNT(lm.clientFk) (SELECT COUNT(lm.clientFk)
FROM FROM
( (SELECT DISTINCT t.clientFk
SELECT DISTINCT t.clientFk
FROM vn.ticket t FROM vn.ticket t
WHERE t.shipped BETWEEN oneMonthBefore AND vDated WHERE t.shipped BETWEEN oneMonthBefore AND vDated
) cm ) cm
RIGHT JOIN RIGHT JOIN
( (SELECT DISTINCT t.clientFk
SELECT DISTINCT t.clientFk
FROM vn.ticket t FROM vn.ticket t
WHERE t.shipped >= twoMonthsBefore WHERE t.shipped >= twoMonthsBefore
AND t.shipped < oneMonthBefore AND t.shipped < oneMonthBefore
@ -4949,14 +4943,12 @@ BEGIN
SET lastMonthNewClients = SET lastMonthNewClients =
(SELECT COUNT(cm.clientFk) (SELECT COUNT(cm.clientFk)
FROM FROM
( (SELECT DISTINCT t.clientFk
SELECT DISTINCT t.clientFk
FROM vn.ticket t FROM vn.ticket t
WHERE t.shipped BETWEEN oneMonthBefore AND vDated WHERE t.shipped BETWEEN oneMonthBefore AND vDated
) cm ) cm
LEFT JOIN LEFT JOIN
( (SELECT DISTINCT t.clientFk
SELECT DISTINCT t.clientFk
FROM vn.ticket t FROM vn.ticket t
WHERE t.shipped >= twoMonthsBefore WHERE t.shipped >= twoMonthsBefore
AND t.shipped < oneMonthBefore AND t.shipped < oneMonthBefore
@ -4974,45 +4966,31 @@ BEGIN
) )
WHERE updated = vDated; WHERE updated = vDated;
/* -- Cálculo de las ventas agrupado por semanas
-- Indicadores de producción SELECT week INTO vWeek
UPDATE indicators i
JOIN productionIndicators pi ON pi.dated = i.updated
SET i.productionHours = pi.productionHours,
i.dailyWorkersCost = pi.dailyWorkersCost,
i.volumeM3 = pi.volumeM3,
i.salesValue = pi.salesValue,
i.valueM3 = pi.valueM3,
i.hoursM3 = pi.hoursM3,
i.workerCostM3 = pi.workerCostM3,
i.salesWorkersCostRate = pi.salesWorkersCostRate
WHERE updated BETWEEN oneMonthBefore AND vDated;
*/
-- CAP Para el calculo de las ventas agrupado por semanas
SELECT week
FROM vn.time FROM vn.time
WHERE dated=vDated INTO vWeek; WHERE dated = vDated;
TRUNCATE `bs`.`salesByWeek`; TRUNCATE salesByWeek;
INSERT INTO `bs`.`salesByWeek` (week,year,sales) INSERT INTO salesByWeek (week, year, sales)
SELECT `t`.`week` AS `week`,`t`.`year` AS `year`, SUM(`v`.`importe` + `v`.`recargo`) AS `sales` SELECT t.week, t.year, SUM(v.importe + v.recargo) sales
FROM `bs`.`ventas` `v` FROM ventas v
LEFT JOIN `vn`.`time` `t` ON `t`.`dated` = fecha LEFT JOIN vn.time t ON t.dated = fecha
GROUP BY `t`.`week` , `t`.`year` GROUP BY t.week, t.year
ORDER BY `t`.`week` , `t`.`year`; ORDER BY t.week, t.year;
-- CAP Indicador Ventas semana actual -- Indicador Ventas semana actual
UPDATE indicators i UPDATE indicators i
JOIN `bs`.`salesByWeek` s ON s.week= vWeek AND s.year = YEAR(vDated) JOIN salesByWeek s ON s.week= vWeek
AND s.year = YEAR(vDated)
SET i.thisWeekSales = s.sales SET i.thisWeekSales = s.sales
WHERE updated = vDated; WHERE updated = vDated;
-- CAP indicador ventas semana actual en el año pasado -- Indicador ventas semana actual en el año pasado
UPDATE indicators i UPDATE indicators i
JOIN `bs`.`salesByWeek` s ON s.week= vWeek AND s.year = YEAR(vDated)-1 JOIN salesByWeek s ON s.week = vWeek
AND s.year = YEAR(vDated)-1
SET i.lastYearWeekSales = s.sales SET i.lastYearWeekSales = s.sales
WHERE updated = vDated; WHERE updated = vDated;
@ -6900,7 +6878,6 @@ BEGIN
/** /**
* Carga los datos de la plantilla de trabajadores, altas y bajas en la tabla workerLabourDataByMonth para facilitar el cálculo del gráfico en grafana. * Carga los datos de la plantilla de trabajadores, altas y bajas en la tabla workerLabourDataByMonth para facilitar el cálculo del gráfico en grafana.
* Se carga el día 21 de cada mes, elimina los registros del último año y los vuelve a calcular * Se carga el día 21 de cada mes, elimina los registros del último año y los vuelve a calcular
*
*/ */
DECLARE vFristDay DATE; DECLARE vFristDay DATE;
DECLARE vLastDay DATE; DECLARE vLastDay DATE;
@ -6941,9 +6918,8 @@ BEGIN
INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
SELECT 'hiring', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent) SELECT 'hiring', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent)
FROM vn.workerLabour w FROM vn.workerLabour w
JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk JOIN vn.workCenter wc ON wc.id = w.workCenterFk
JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
JOIN postgresql.person p ON p.id_trabajador = w.workerFk
LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato
LEFT JOIN (SELECT w.workerFk LEFT JOIN (SELECT w.workerFk
FROM vn.workerLabour w FROM vn.workerLabour w
@ -6951,25 +6927,24 @@ BEGIN
AND wl.workerFk = w.workerFk AND wl.workerFk = w.workerFk
WHERE w.started BETWEEN vFristDay AND vLastDay AND wl.ended WHERE w.started BETWEEN vFristDay AND vLastDay AND wl.ended
)sub ON sub.workerFk = w.workerFk )sub ON sub.workerFk = w.workerFk
WHERE wc.center_id IS NOT NULL WHERE wc.payrollCenterFk IS NOT NULL
AND w.started BETWEEN vFristDay AND vLastDay AND w.started BETWEEN vFristDay AND vLastDay
AND sub.workerFk IS NULL AND sub.workerFk IS NULL
AND NOT p.isFreelance; AND NOT w.isFreelance;
-- Bajas periodo -- Bajas periodo
INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
SELECT 'layoffs', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent) SELECT 'layoffs', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent)
FROM vn.workerLabour w FROM vn.workerLabour w
JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk JOIN vn.workCenter wc ON wc.id = w.workCenterFk
JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
JOIN postgresql.person p ON p.id_trabajador = w.workerFk
LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato
LEFT JOIN (SELECT started, workerFk FROM vn.workerLabour) wl ON wl.started >= w.ended LEFT JOIN (SELECT started, workerFk FROM vn.workerLabour) wl ON wl.started >= w.ended
AND wl.workerFk = w.workerFk AND wl.workerFk = w.workerFk
WHERE wc.center_id IS NOT NULL WHERE wc.payrollCenterFk IS NOT NULL
AND w.ended BETWEEN vFristDay AND vLastDay AND w.ended BETWEEN vFristDay AND vLastDay
AND wl.started IS NULL AND wl.started IS NULL
AND NOT p.isFreelance; AND NOT w.isFreelance;
-- Anterior al periodo -- Anterior al periodo
SET vLastDay = LAST_DAY(DATE_SUB(vFristDay, INTERVAL 1 DAY)); SET vLastDay = LAST_DAY(DATE_SUB(vFristDay, INTERVAL 1 DAY));
@ -6977,26 +6952,24 @@ BEGIN
INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
SELECT 'staff', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent) SELECT 'staff', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent)
FROM vn.workerLabour w FROM vn.workerLabour w
JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk JOIN vn.workCenter wc ON wc.id = w.workCenterFk
JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
JOIN postgresql.person p ON p.id_trabajador = w.workerFk
LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato
WHERE wc.center_id IS NOT NULL WHERE wc.payrollCenterFk IS NOT NULL
AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay) AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay)
AND NOT p.isFreelance; AND NOT w.isFreelance;
-- Discapacidad -- Discapacidad
INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent)
SELECT 'disabled', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent) SELECT 'disabled', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent)
FROM vn.workerLabour w FROM vn.workerLabour w
JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk JOIN vn.workCenter wc ON wc.id = w.workCenterFk
JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk
JOIN postgresql.person p ON p.id_trabajador = w.workerFk
LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato
WHERE wc.center_id IS NOT NULL WHERE wc.payrollCenterFk IS NOT NULL
AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay) AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay)
AND p.isDisable AND w.isDisable
AND NOT p.isFreelance; AND NOT w.isFreelance;
END LOOP; END LOOP;
CLOSE vCursor; CLOSE vCursor;
@ -21042,21 +21015,20 @@ BEGIN
IF(co.country IN ('España', 'España exento'), 1,IF(co.isUeeMember = 1, 2, 4)), IF(co.country IN ('España', 'España exento'), 1,IF(co.isUeeMember = 1, 2, 4)),
IFNULL(s.taxTypeSageFk, 0), IFNULL(s.taxTypeSageFk, 0),
n.Nacion, n.Nacion,
IFNULL(con.Telefono, ''), IFNULL(sc.phone, ''),
IFNULL(con.Movil, ''), IFNULL(sc.mobile, ''),
IFNULL(s.transactionTypeSageFk, 0), IFNULL(s.transactionTypeSageFk, 0),
IFNULL(s.withholdingSageFk, '0'), IFNULL(s.withholdingSageFk, '0'),
IFNULL(SUBSTR(con.email, 1, (COALESCE(NULLIF(LOCATE(',', con.email), 0), 99) - 1)), ''), IFNULL(SUBSTR(sc.email, 1, (COALESCE(NULLIF(LOCATE(',', sc.email), 0), 99) - 1)), ''),
IFNULL(iban, '') IFNULL(iban, '')
FROM vn.supplier s FROM vn.supplier s
JOIN providerLastThreeMonths pl ON pl.supplierFk = s.id JOIN supplierLastThreeMonths pl ON pl.supplierFk = s.id
LEFT JOIN vn.country co ON co.id = s.countryFk LEFT JOIN vn.country co ON co.id = s.countryFk
LEFT JOIN Naciones n ON n.countryFk = co.id LEFT JOIN Naciones n ON n.countryFk = co.id
LEFT JOIN vn.province p ON p.id = s.provinceFk LEFT JOIN vn.province p ON p.id = s.provinceFk
LEFT JOIN Provincias pr ON pr.provinceFk = p.id LEFT JOIN Provincias pr ON pr.provinceFk = p.id
LEFT JOIN vn2008.Relaciones r ON r.Id_Proveedor = s.id LEFT JOIN vn.supplierContact sc ON sc.supplierFk = s.id
LEFT JOIN vn.supplierAccount sa ON sa.supplierFk = s.id LEFT JOIN vn.supplierAccount sa ON sa.supplierFk = s.id
LEFT JOIN vn2008.Contactos con ON con.Id_Contacto = r.Id_Contacto
JOIN vn.company c ON c.id = pl.companyFk JOIN vn.company c ON c.id = pl.companyFk
WHERE c.id = vCompanyFk AND WHERE c.id = vCompanyFk AND
s.isActive AND s.isActive AND
@ -85349,7 +85321,6 @@ DELIMITER ;
DELIMITER ;; DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME) CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME)
BEGIN BEGIN
/** /**
* Horas que debe trabajar un empleado según contrato y día. * Horas que debe trabajar un empleado según contrato y día.
* @param vDatedFrom workerTimeControl * @param vDatedFrom workerTimeControl
@ -85357,7 +85328,6 @@ BEGIN
* @table tmp.user(userFk) * @table tmp.user(userFk)
* @return tmp.timeBusinessCalculate * @return tmp.timeBusinessCalculate
*/ */
DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate;
CREATE TEMPORARY TABLE tmp.timeBusinessCalculate CREATE TEMPORARY TABLE tmp.timeBusinessCalculate
@ -85374,7 +85344,7 @@ BEGIN
timeWorkSeconds timeBusinessSeconds, timeWorkSeconds timeBusinessSeconds,
SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal, SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal,
timeWorkSeconds / 3600 timeBusinessDecimal, timeWorkSeconds / 3600 timeBusinessDecimal,
type, name type,
permissionRate, permissionRate,
hoursWeek, hoursWeek,
discountRate, discountRate,
@ -85387,25 +85357,24 @@ BEGIN
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) hourEnd, IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) hourEnd,
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5), " - ", LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) timeTable, IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5), " - ", LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) timeTable,
IF(j.start = NULL, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds, IF(j.start = NULL, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds,
cs.type, at2.name,
cs.permissionRate, at2.permissionRate,
cs.discountRate, at2.discountRate,
cl.hours_week hoursWeek, cl.hours_week hoursWeek,
cs.isAllowedToWork at2.isAllowedToWork
FROM vn.time t FROM time t
LEFT JOIN postgresql.business b ON t.dated BETWEEN b.date_start AND ifnull(b.date_end, vDatedTo ) LEFT JOIN postgresql.business b ON t.dated BETWEEN b.date_start AND IFNULL(b.date_end, vDatedTo )
LEFT JOIN postgresql.profile AS pr ON b.client_id = pr.profile_id LEFT JOIN postgresql.profile pr ON b.client_id = pr.profile_id
LEFT JOIN postgresql.person AS p ON pr.person_id = p.person_id LEFT JOIN worker w ON w.id = pr.workerFk
LEFT JOIN vn.worker AS w ON p.id_trabajador = w.id
JOIN tmp.`user` u ON u.userFK = w.userFK JOIN tmp.`user` u ON u.userFK = w.userFK
JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id JOIN postgresql.business_labour bl ON b.business_id = bl.business_id
LEFT JOIN postgresql.business_labour_payroll AS bp ON bl.business_id = bp.business_id LEFT JOIN postgresql.business_labour_payroll bp ON bl.business_id = bp.business_id
LEFT JOIN postgresql.professional_category AS pc ON bl.professional_category_id = pc.professional_category_id LEFT JOIN postgresql.professional_category pc ON bl.professional_category_id = pc.professional_category_id
LEFT JOIN postgresql.workcenter AS wc ON bl.workcenter_id = wc.workcenter_id LEFT JOIN workCenter wc ON bl.workcenter_id = wc.id
LEFT JOIN postgresql.calendar_labour_type AS cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id LEFT JOIN postgresql.calendar_labour_type cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id
LEFT JOIN postgresql.journey AS j ON j.business_id = b.business_id and j.day_id=WEEKDAY(t.dated)+1 LEFT JOIN postgresql.journey j ON j.business_id = b.business_id AND j.day_id=WEEKDAY(t.dated)+1
LEFT JOIN postgresql.calendar_employee ce ON ce.business_id=b.business_id and ce.date = t.dated LEFT JOIN postgresql.calendar_employee ce ON ce.business_id=b.business_id AND ce.date = t.dated
LEFT JOIN postgresql.calendar_state cs ON cs.calendar_state_id = ce.calendar_state_id LEFT JOIN absenceType at2 ON at2.id = ce.calendar_state_id
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
GROUP BY w.userFk,dated GROUP BY w.userFk,dated
)sub; )sub;
@ -85427,7 +85396,7 @@ BEGIN
WHERE permissionRate <> 0; WHERE permissionRate <> 0;
UPDATE tmp.timeBusinessCalculate t UPDATE tmp.timeBusinessCalculate t
JOIN vn.calendarHolidays ch ON ch.dated = t.dated JOIN calendarHolidays ch ON ch.dated = t.dated
JOIN postgresql.business_labour bl ON bl.business_id = t.businessFk AND bl.workcenter_id = ch.workcenterFk JOIN postgresql.business_labour bl ON bl.business_id = t.businessFk AND bl.workcenter_id = ch.workcenterFk
SET t.timeWorkSeconds = 0, SET t.timeWorkSeconds = 0,
t.timeWorkSexagesimal = 0, t.timeWorkSexagesimal = 0,
@ -85503,17 +85472,16 @@ BEGIN
SELECT DISTINCT w.userFk SELECT DISTINCT w.userFk
FROM postgresql.business AS b FROM postgresql.business AS b
LEFT JOIN postgresql.profile AS pr ON pr.profile_id = b.client_id LEFT JOIN postgresql.profile AS pr ON pr.profile_id = b.client_id
LEFT JOIN postgresql.person AS p ON p.person_id = pr.person_id
LEFT JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id LEFT JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id
LEFT JOIN vn.worker AS w ON p.id_trabajador = w.id LEFT JOIN worker AS w ON w.id = pr.workerFk
LEFT JOIN vn.department AS d ON bl.department_id = d.id LEFT JOIN department AS d ON bl.department_id = d.id
WHERE ((b.date_start BETWEEN vDatedFrom AND vDatedTo OR b.date_end BETWEEN vDatedFrom AND vDatedTo) OR WHERE (b.date_start BETWEEN vDatedFrom AND vDatedTo
(b.date_end IS NULL AND b.date_start <= vDatedTo) OR OR IFNULL(b.date_end, vDatedTo) BETWEEN vDatedFrom AND vDatedTo
(b.date_start <= vDatedFrom AND b.date_end >= vDatedTo) OR (b.date_start <= vDatedFrom AND b.date_end >= vDatedTo)
) AND bl.department_id = vDepartmentFk ) AND bl.department_id = vDepartmentFk
ORDER BY b.date_end DESC; ORDER BY b.date_end DESC;
CALL vn.timeBusiness_calculate(vDatedFrom, vDatedTo); CALL timeBusiness_calculate(vDatedFrom, vDatedTo);
DROP TEMPORARY TABLE tmp.`user`; DROP TEMPORARY TABLE tmp.`user`;
@ -85949,17 +85917,16 @@ BEGIN
SELECT DISTINCT w.userFk SELECT DISTINCT w.userFk
FROM postgresql.business AS b FROM postgresql.business AS b
LEFT JOIN postgresql.profile AS pr ON pr.profile_id = b.client_id LEFT JOIN postgresql.profile AS pr ON pr.profile_id = b.client_id
LEFT JOIN postgresql.person AS p ON p.person_id = pr.person_id
LEFT JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id LEFT JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id
LEFT JOIN vn.worker AS w ON p.id_trabajador = w.id LEFT JOIN worker AS w ON w.id = pr.workerFk
LEFT JOIN vn.department AS d ON bl.department_id = d.id LEFT JOIN department AS d ON bl.department_id = d.id
WHERE ((b.date_start BETWEEN vDatedFrom AND vDatedTo OR b.date_end BETWEEN vDatedFrom AND vDatedTo) OR WHERE (b.date_start BETWEEN vDatedFrom AND vDatedTo
(b.date_end IS NULL AND b.date_start <= vDatedTo) OR OR IFNULL(b.date_end, vDatedTo) BETWEEN vDatedFrom AND vDatedTo
(b.date_start <= vDatedFrom AND b.date_end >= vDatedTo) OR (b.date_start <= vDatedFrom AND b.date_end >= vDatedTo)
) AND bl.department_id = vDepartmentFk ) AND bl.department_id = vDepartmentFk
ORDER BY b.date_end DESC; ORDER BY b.date_end DESC;
CALL vn.timeControl_calculate(vDatedFrom, vDatedTo); CALL timeControl_calculate(vDatedFrom, vDatedTo);
DROP TEMPORARY TABLE tmp.`user`; DROP TEMPORARY TABLE tmp.`user`;
@ -87359,18 +87326,7 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `workerCalendar_calculateYear` */; /*!50003 DROP PROCEDURE IF EXISTS `BEGIN
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalendar_calculateYear`(vYear INT, vWorkerFk INT)
BEGIN
/** /**
* Calcula los días y horas de vacaciones en función de un trabajador y año * Calcula los días y horas de vacaciones en función de un trabajador y año
@ -87379,7 +87335,6 @@ BEGIN
* @param vWorkerFk * @param vWorkerFk
* @return tmp.workerCalendarCalculateYear (days, hours, daysEnjoyed, hoursEnjoyed) * @return tmp.workerCalendarCalculateYear (days, hours, daysEnjoyed, hoursEnjoyed)
*/ */
DECLARE vDone BOOL; DECLARE vDone BOOL;
DECLARE vBusinessFk INT; DECLARE vBusinessFk INT;
@ -87387,9 +87342,8 @@ BEGIN
SELECT b.business_id SELECT b.business_id
FROM postgresql.business b FROM postgresql.business b
LEFT JOIN postgresql.profile AS pr ON pr.profile_id = b.client_id LEFT JOIN postgresql.profile AS pr ON pr.profile_id = b.client_id
LEFT JOIN postgresql.person AS p ON p.person_id = pr.person_id
WHERE vYear BETWEEN YEAR(b.date_start) AND IFNULL(YEAR(b.date_end), vYear ) WHERE vYear BETWEEN YEAR(b.date_start) AND IFNULL(YEAR(b.date_end), vYear )
AND p.id_trabajador = vWorkerFk; AND pr.workerFk = vWorkerFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE; SET vDone = TRUE;
@ -87446,18 +87400,20 @@ DELIMITER ;
DELIMITER ;; DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCreate`( CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCreate`(
vFirstname VARCHAR(50), vFirstname VARCHAR(50),
vSurnames VARCHAR(50), vLastName VARCHAR(50),
vWorkerCode CHAR(3), vCode CHAR(3),
vBossFk INT, vBossFk INT,
vUserFk INT vUserFk INT,
vFi VARCHAR(15) ,
vBirth DATE
) )
BEGIN BEGIN
/** /**
* Create new worker * Create new worker
* *
*/ */
INSERT INTO worker(id, code, firstName, lastName, userFk, bossFk) INSERT INTO worker(id, code, firstName, lastName, userFk, bossFk, fi, birth)
VALUES (vUserFk, vWorkerCode, vFirstname, vSurnames, vUserFk, vBossFk); VALUES (vUserFk, vCode, vFirstname, vLastName, vUserFk, vBossFk, vFi, vBirth);
END ;; END ;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -87559,30 +87515,24 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.workerDepartmentByDate; DROP TEMPORARY TABLE IF EXISTS tmp.workerDepartmentByDate;
CREATE TEMPORARY TABLE tmp.workerDepartmentByDate CREATE TEMPORARY TABLE tmp.workerDepartmentByDate
ENGINE = MEMORY ENGINE = MEMORY
SELECT SELECT w.userFk,
w.userFk, w.lastName name,
p.name, w.firstName firstname,
p.firstname, d.name department,
d.name AS department, d.id departmentFk,
d.id as departmentFk,
b.date_start, b.date_start,
d.isProduction, d.isProduction,
CAST(12 * blp.importepactado / clt.hours_week / 52 AS DECIMAL(10,2)) as costeHora , CAST(12 * blp.importepactado / clt.hours_week / 52 AS DECIMAL(10,2)) costeHora,
p.nif w.fi nif
FROM postgresql.profile pr
FROM postgresql.person p
JOIN postgresql.profile pr ON p.person_id = pr.person_id
JOIN postgresql.business b ON b.client_id = pr.profile_id JOIN postgresql.business b ON b.client_id = pr.profile_id
JOIN postgresql.business_labour bl ON bl.business_id = b.business_id JOIN postgresql.business_labour bl ON bl.business_id = b.business_id
JOIN postgresql.calendar_labour_type clt ON clt.calendar_labour_type_id = bl.calendar_labour_type_id JOIN postgresql.calendar_labour_type clt ON clt.calendar_labour_type_id = bl.calendar_labour_type_id
JOIN postgresql.business_labour_payroll blp ON blp.business_id = b.business_id JOIN postgresql.business_labour_payroll blp ON blp.business_id = b.business_id
JOIN vn.department d ON d.id = bl.department_id JOIN department d ON d.id = bl.department_id
JOIN vn.worker w ON w.id = p.id_trabajador JOIN worker w ON w.id = pr.workerFk
WHERE b.date_start <= vDate AND IFNULL(b.date_end,'3000-01-01') > vDate WHERE b.date_start <= vDate
; AND (b.date_end > vDate OR b.date_end IS NULL);
-- SELECT * FROM tmp.workerDepartmentByDate;
END ;; END ;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -87646,19 +87596,18 @@ BEGIN
DECLARE rs CURSOR FOR DECLARE rs CURSOR FOR
SELECT a.id SELECT a.id
FROM ((SELECT * FROM (select date_end,date_start,business_id, client_id FROM (SELECT client_id, business_id
FROM (SELECT business_id, client_id
FROM postgresql.business FROM postgresql.business
ORDER BY client_id, date_end IS NULL DESC , date_end DESC) ORDER BY client_id, date_end IS NULL DESC , date_end DESC
c GROUP BY client_id) c LIMIT 10000000000000000000)sub
INNER JOIN postgresql.business b ON c.client_id = b.client_id AND c.business_id = b.business_id GROUP BY client_id)sub2
INNER JOIN postgresql.profile pr ON b.client_id = pr.profile_id JOIN postgresql.business b ON sub2.client_id = b.client_id AND sub2.business_id = b.business_id
INNER JOIN postgresql.person p ON pr.person_id = p.person_id JOIN postgresql.profile pr ON b.client_id = pr.profile_id
JOIN account.account a ON pr.workerFk = a.id
INNER JOIN vn.worker w ON p.id_trabajador = w.id) WHERE b.date_end IS NOT NULL
INNER JOIN account.account a ON w.userFk = a.id AND b.date_end < CURDATE()
WHERE ((b.date_end) IS NOT NULL AND b.date_end > TIMESTAMPADD(DAY, -70, CURDATE());
AND (b.date_end) < CURDATE()
AND (b.date_end) > TIMESTAMPADD(DAY, -70,CURDATE()) );
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
@ -89089,16 +89038,14 @@ proc: BEGIN
END IF; END IF;
-- VERIFICAR VACACIONES -- VERIFICAR VACACIONES
SELECT cs.type INTO vCalendarStateType SELECT at2.name INTO vCalendarStateType
FROM postgresql.calendar_employee ce FROM postgresql.calendar_employee ce
JOIN postgresql.business b USING(business_id) JOIN postgresql.business b USING(business_id)
JOIN postgresql.profile pr ON pr.profile_id = b.client_id JOIN postgresql.profile pr ON pr.profile_id = b.client_id
JOIN postgresql.person p ON p.person_id = pr.person_id JOIN absenceType at2 ON at2.id = ce.calendar_state_id
JOIN postgresql.calendar_state cs USING(calendar_state_id)
JOIN worker w ON w.id = p.id_trabajador
WHERE ce.date = CURDATE() WHERE ce.date = CURDATE()
AND cs.isAllowedToWork = FALSE AND at2.isAllowedToWork = FALSE
AND w.userFk = vUserFk AND pr.workerFk = vUserFk
LIMIT 1; LIMIT 1;
IF(LENGTH(vCalendarStateType)) THEN IF(LENGTH(vCalendarStateType)) THEN
@ -89115,9 +89062,7 @@ proc: BEGIN
IF (SELECT COUNT(*) IF (SELECT COUNT(*)
FROM postgresql.business b FROM postgresql.business b
JOIN postgresql.profile pr ON pr.profile_id = b.client_id JOIN postgresql.profile pr ON pr.profile_id = b.client_id
JOIN postgresql.person p ON p.person_id = pr.person_id WHERE pr.workerFk = vUserFk
JOIN worker w ON w.id = p.id_trabajador
WHERE w.userFk = vUserFk
AND b.date_start <= vDated AND b.date_start <= vDated
AND IFNULL(b.date_end,vDated) >= vDated AND IFNULL(b.date_end,vDated) >= vDated
) = 0 THEN ) = 0 THEN
@ -90345,6 +90290,7 @@ BEGIN
DECLARE vPermissionRate DECIMAL(5,2); DECLARE vPermissionRate DECIMAL(5,2);
DECLARE vIsTeleworking BOOL; DECLARE vIsTeleworking BOOL;
DECLARE vIsTeleworkingOld BOOL; DECLARE vIsTeleworkingOld BOOL;
DECLARE vError BOOL DEFAULT FALSE;
DECLARE vCursor CURSOR FOR DECLARE vCursor CURSOR FOR
SELECT CONCAT(u.name, '@verdnatura.es'), u.id, tb.dated, tb.timeWorkDecimal, LEFT(tb.timeWorkSexagesimal,5) timeWorkSexagesimal, SELECT CONCAT(u.name, '@verdnatura.es'), u.id, tb.dated, tb.timeWorkDecimal, LEFT(tb.timeWorkSexagesimal,5) timeWorkSexagesimal,
@ -90353,8 +90299,9 @@ BEGIN
JOIN user u ON u.id = tb.userFk JOIN user u ON u.id = tb.userFk
JOIN department d ON d.id = tb.departmentFk JOIN department d ON d.id = tb.departmentFk
JOIN postgresql.business b ON b.business_id = tb.businessFk JOIN postgresql.business b ON b.business_id = tb.businessFk
JOIN company c ON c.id = b.provider_id
LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated
LEFT JOIN worker w ON w.id = u.id
LEFT JOIN `user` u2 ON u2.id = w.bossFk
JOIN (SELECT tb.userFk, JOIN (SELECT tb.userFk,
SUM(IF(tb.type IS NULL, SUM(IF(tb.type IS NULL,
IF(tc.timeWorkDecimal > 0, FALSE, IF(tb.timeWorkDecimal > 0, TRUE, FALSE)), IF(tc.timeWorkDecimal > 0, FALSE, IF(tb.timeWorkDecimal > 0, TRUE, FALSE)),
@ -90366,17 +90313,28 @@ BEGIN
)sub ON sub.userFk = u.id )sub ON sub.userFk = u.id
WHERE d.hasToRefill AND WHERE d.hasToRefill AND
IFNULL(vWorkerFk,u.id) = u.id AND IFNULL(vWorkerFk,u.id) = u.id AND
c.code = 'VNL' b.companyCodeFk = 'VNL'
ORDER BY u.id, tb.dated; ORDER BY u.id, tb.dated;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
SET vError = TRUE;
INSERT INTO tmp.error(workerFk)
SELECT vWorkerFk;
END;
DROP TABLE IF EXISTS tmp.timeControlCalculate; DROP TABLE IF EXISTS tmp.timeControlCalculate;
DROP TABLE IF EXISTS tmp.timeBusinessCalculate; DROP TABLE IF EXISTS tmp.timeBusinessCalculate;
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate;
DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate;
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate1; DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate1;
DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate1; DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate1;
DROP TEMPORARY TABLE IF EXISTS tmp.error;
CREATE TEMPORARY TABLE tmp.error (workerFk INT);
SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vStarted, vEnded SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vStarted, vEnded
FROM time FROM time
@ -90419,6 +90377,9 @@ proc: LOOP
LEAVE proc; LEAVE proc;
END IF; END IF;
START TRANSACTION;
SET vError = FALSE;
IF vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL AND IFNULL(vPermissionRate, TRUE) THEN IF vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL AND IFNULL(vPermissionRate, TRUE) THEN
IF vTimeTable IS NULL THEN IF vTimeTable IS NULL THEN
INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail)
@ -90516,9 +90477,10 @@ proc: LOOP
FETCH vCursor INTO vReceiver, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking; FETCH vCursor INTO vReceiver, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking;
IF vWorkerFk <> vWorkerFkOld OR vDone THEN IF vWorkerFk <> vWorkerFkOld OR vDone THEN
SELECT CONCAT( IFNULL(nif, ''), ' - ', firstName, ' ', name ) INTO vWorkerInfo SELECT CONCAT_WS(' ', fi, firstName, surnames) INTO vWorkerInfo
FROM postgresql.person FROM person
WHERE id_trabajador = vWorkerFkOld; WHERE workerFk = vWorkerFkOld;
SET vHeader = CONCAT("<br><br><br> SET vHeader = CONCAT("<br><br><br>
<div align=\"center\"> <div align=\"center\">
<h2>", vWorkerInfo , "</h2> <h2>", vWorkerInfo , "</h2>
@ -90548,7 +90510,7 @@ proc: LOOP
</table> </table>
</div>"); </div>");
IF vIsTeleworkingOld THEN IF vIsTeleworkingOld AND NOT vError THEN
CALL mail_insert( CALL mail_insert(
vReceiverOld, vReceiverOld,
'timecontrol@verdnatura.es', 'timecontrol@verdnatura.es',
@ -90558,6 +90520,8 @@ proc: LOOP
INSERT IGNORE INTO workerTimeControlMail (workerFk, year, week) INSERT IGNORE INTO workerTimeControlMail (workerFk, year, week)
VALUES(vWorkerFkOld, vYear, vWeek); VALUES(vWorkerFkOld, vYear, vWeek);
ELSE
ROLLBACK;
END IF; END IF;
SET vBody = ''; SET vBody = '';
@ -90566,13 +90530,24 @@ proc: LOOP
SET vIsTeleworkingOld = vIsTeleworking; SET vIsTeleworkingOld = vIsTeleworking;
SET vReceiverOld = vReceiver; SET vReceiverOld = vReceiver;
END IF; END IF;
COMMIT;
END LOOP; END LOOP;
CLOSE vCursor; CLOSE vCursor;
INSERT INTO mail (receiver, replyTo, subject, body)
SELECT CONCAT(u.name, '@verdnatura.es'),
CONCAT('Error registro de horas semana ', vWeek, ' año ', vYear) ,
CONCAT('No se ha podido enviar el registro de horas al empleado/s: ', GROUP_CONCAT(DISTINCT CONCAT('<br>', w.id, ' ', w.firstName, ' ', w.lastName)))
FROM tmp.error e
JOIN worker w ON w.id = e.workerFk
JOIN user u ON u.id = w.bossFk
GROUP BY w.bossFk;
DROP TABLE tmp.timeControlCalculate; DROP TABLE tmp.timeControlCalculate;
DROP TABLE tmp.timeBusinessCalculate; DROP TABLE tmp.timeBusinessCalculate;
DROP TABLE tmp.timeControlCalculate1; DROP TABLE tmp.timeControlCalculate1;
DROP TABLE tmp.timeBusinessCalculate1; DROP TABLE tmp.timeBusinessCalculate1;
DROP TABLE tmp.error;
END ;; END ;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -90785,14 +90760,12 @@ DELIMITER ;
DELIMITER ;; DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerWeekControl`(vUserFk INT, vDated DATE, vTabletFk VARCHAR(100)) CREATE DEFINER=`root`@`localhost` PROCEDURE `workerWeekControl`(vUserFk INT, vDated DATE, vTabletFk VARCHAR(100))
BEGIN BEGIN
/*
/* Devuelve la cantidad de descansos de 12h y de 36 horas que ha disfrutado el trabajador * Devuelve la cantidad de descansos de 12h y de 36 horas que ha disfrutado el trabajador
* en la semana inmediatamente anterior a la fecha que pasa como parámetro. * en la semana inmediatamente anterior a la fecha que pasa como parámetro.
*
* UPDATED PAK 2019/09/02 * UPDATED PAK 2019/09/02
* PENDING REVIEW * PENDING REVIEW
*/ */
DECLARE vDescansos12h INT; DECLARE vDescansos12h INT;
DECLARE vDescansos36h INT; DECLARE vDescansos36h INT;
DECLARE vJornadas INT; DECLARE vJornadas INT;
@ -90804,9 +90777,8 @@ DECLARE vCantWork VARCHAR(50) DEFAULT '';
DECLARE vDepartmentFk INT; DECLARE vDepartmentFk INT;
DECLARE isEnabled BOOLEAN DEFAULT TRUE; DECLARE isEnabled BOOLEAN DEFAULT TRUE;
SELECT COUNT(*) INTO vHasSignedToday SELECT COUNT(*) INTO vHasSignedToday
FROM vn.workerTimeControl WHERE timed >= vDated AND userFk = vUserFk; FROM workerTimeControl WHERE timed >= vDated AND userFk = vUserFk;
SET @day := 0; SET @day := 0;
SET @lastTimed := NOW(); SET @lastTimed := NOW();
@ -90855,25 +90827,21 @@ FROM (
) sub; ) sub;
-- Vacaciones -- Vacaciones
SELECT cs.type INTO vCantWork SELECT at2.name INTO vCantWork
FROM postgresql.calendar_employee ce FROM postgresql.calendar_employee ce
JOIN postgresql.business b USING(business_id) JOIN postgresql.business b USING(business_id)
JOIN postgresql.profile pr ON pr.profile_id = b.client_id JOIN postgresql.profile pr ON pr.profile_id = b.client_id
JOIN postgresql.person p ON p.person_id = pr.person_id JOIN absenceType at2 ON at2.id = ce.calendar_state_id
JOIN postgresql.calendar_state cs USING(calendar_state_id)
JOIN vn.worker w ON w.id = p.id_trabajador
WHERE ce.date = CURDATE() WHERE ce.date = CURDATE()
AND cs.isAllowedToWork = FALSE AND at2.isAllowedToWork = FALSE
AND w.userFk = vUserFk AND pr.workerFk = vUserFk
LIMIT 1; LIMIT 1;
-- Contrato en vigor -- Contrato en vigor
SELECT IF(COUNT(*),vCantWork,'Sin contrato') INTO vCantWork SELECT IF(COUNT(*),vCantWork,'Sin contrato') INTO vCantWork
FROM postgresql.business b FROM postgresql.business b
JOIN postgresql.profile pr ON pr.profile_id = b.client_id JOIN postgresql.profile pr ON pr.profile_id = b.client_id
JOIN postgresql.person p ON p.person_id = pr.person_id WHERE pr.workerFk = vUserFk
JOIN vn.worker w ON w.id = p.id_trabajador
WHERE w.userFk = vUserFk
AND b.date_start <= vDated AND b.date_start <= vDated
AND IFNULL(b.date_end,vDated) >= vDated; AND IFNULL(b.date_end,vDated) >= vDated;
@ -90881,76 +90849,47 @@ SELECT IF(COUNT(*),vCantWork,'Sin contrato') INTO vCantWork
IF vTabletFk <> '0' THEN IF vTabletFk <> '0' THEN
-- 1 Obtener el departamento del usuario -- 1 Obtener el departamento del usuario
SELECT wtcu.departmentFk INTO vDepartmentFk SELECT wtcu.departmentFk INTO vDepartmentFk
FROM vn.workerTimeControlUserInfo wtcu FROM workerTimeControlUserInfo wtcu
WHERE wtcu.userFk = vUserFk; WHERE wtcu.userFk = vUserFk;
-- 2 Comprobar si la tablet pertenece al departamento -- 2 Comprobar si la tablet pertenece al departamento
SELECT COUNT(td.tabletFk) INTO isEnabled SELECT COUNT(td.tabletFk) INTO isEnabled
FROM vn.tabletDepartment td FROM tabletDepartment td
WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk; WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk;
END IF; END IF;
IF vJornadas IS NOT NULL THEN IF vJornadas IS NOT NULL THEN
SELECT 'Jornadas' as Item, vJornadas as Cantidad, 'Correcto' AS Análisis SELECT 'Jornadas' as Item, vJornadas as Cantidad, 'Correcto' AS Análisis
UNION ALL UNION ALL
SELECT 'Descansos 12 h' as Item, vDescansos12h as Cantidad, IF(vDescansos12h >= vJornadas, 'Correcto','Error: 1 por jornada') as Análisis SELECT 'Descansos 12 h' as Item, vDescansos12h as Cantidad, IF(vDescansos12h >= vJornadas, 'Correcto','Error: 1 por jornada') as Análisis
UNION ALL UNION ALL
SELECT 'Descansos 36 h' as Item, vDescansos36h as Cantidad, IF(vDescansos36h / 2 >= FLOOR(vJornadas/10), 'Correcto','Error: mínimo 2 cada 14 dias') as Análisis SELECT 'Descansos 36 h' as Item, vDescansos36h as Cantidad, IF(vDescansos36h / 2 >= FLOOR(vJornadas/10), 'Correcto','Error: mínimo 2 cada 14 dias') as Análisis
UNION ALL UNION ALL
SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, IF(vImpares = 0, 'Correcto','Error') as Análisis SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, IF(vImpares = 0, 'Correcto','Error') as Análisis
UNION ALL UNION ALL
SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item, SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item,
'' as Cantidad, '' as Cantidad,
IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis
UNION ALL UNION ALL
SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis;
SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis
;
ELSE ELSE
SELECT 'Jornadas' as Item, vJornadas as Cantidad, 'Correcto' AS Análisis SELECT 'Jornadas' as Item, vJornadas as Cantidad, 'Correcto' AS Análisis
UNION ALL UNION ALL
SELECT 'Descansos 12 h' as Item, vDescansos12h as Cantidad, 'Correcto' as Análisis SELECT 'Descansos 12 h' as Item, vDescansos12h as Cantidad, 'Correcto' as Análisis
UNION ALL UNION ALL
SELECT 'Descansos 36 h' as Item, vDescansos36h as Cantidad, 'Correcto' as Análisis SELECT 'Descansos 36 h' as Item, vDescansos36h as Cantidad, 'Correcto' as Análisis
UNION ALL UNION ALL
SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, 'Correcto' as Análisis SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, 'Correcto' as Análisis
UNION ALL UNION ALL
SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item, SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item,
'' as Cantidad, IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis '' as Cantidad, IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis
UNION ALL UNION ALL
SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis;
SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis
;
END IF; END IF;
END ;; END ;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -94308,7 +94247,7 @@ USE `bs`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `bajasLaborales` AS select `p`.`firstname` AS `firstname`,`p`.`name` AS `name`,`b`.`business_id` AS `business_id`,max(`ce`.`date`) AS `lastDate`,max(ifnull(`b`.`date_end`,curdate())) AS `endContract`,`cs`.`type` AS `type`,cast(count(0) as decimal(10,0)) AS `dias`,`w`.`userFk` AS `userFk` from (((((`postgresql`.`calendar_employee` `ce` join `postgresql`.`business` `b` on((`b`.`business_id` = `ce`.`business_id`))) join `postgresql`.`profile` `pr` on((`pr`.`profile_id` = `b`.`client_id`))) join `postgresql`.`person` `p` on((`p`.`person_id` = `pr`.`person_id`))) join `postgresql`.`calendar_state` `cs` on((`cs`.`calendar_state_id` = `ce`.`calendar_state_id`))) join `vn`.`worker` `w` on((`w`.`id` = `p`.`id_trabajador`))) where ((`ce`.`date` >= (curdate() + interval -(1) year)) and (`cs`.`type` not in ('Vacaciones','Vacaciones 1/2 día','Compensar','Festivo'))) group by `p`.`firstname`,`p`.`name`,`cs`.`type` having (`endContract` >= curdate()) */; /*!50001 VIEW `bajasLaborales` AS SELECT `w`.`firstName` AS `firstname`, `w`.`lastName` AS `name`, `b`.`business_id` AS `business_id`, MAX(`ce`.`date`) AS `lastDate`, MAX(IFNULL(`b`.`date_end`, CURDATE())) AS `endContract`, `at`.`name` AS `type`, CAST(COUNT(0) AS DECIMAL (10 , 0 )) AS `dias`, `w`.`id` AS `userFk` FROM ((((`postgresql`.`calendar_employee` `ce` JOIN `postgresql`.`business` `b` ON ((`b`.`business_id` = `ce`.`business_id`))) JOIN `postgresql`.`profile` `pr` ON ((`pr`.`profile_id` = `b`.`client_id`))) JOIN `vn`.`worker` `w` ON ((`w`.`id` = `pr`.`workerFk`))) JOIN `vn`.`absenceType` `at` ON ((`at`.`id` = `ce`.`calendar_state_id`))) WHERE ((`ce`.`date` >= (CURDATE() + INTERVAL -(1) YEAR)) AND (`at`.`name` NOT IN ('Vacaciones' , 'Vacaciones 1/2 día', 'Compensar', 'Festivo'))) GROUP BY w.firstName , w.lastName , at.name HAVING (endContract >= CURDATE()) */;
/*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 SET collation_connection = @saved_col_connection */;
@ -95237,11 +95176,11 @@ USE `sage`;
/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 SET collation_connection = @saved_col_connection */;
-- --
-- Final view structure for view `providerLastThreeMonths` -- Final view structure for view `supplierLastThreeMonths`
-- --
/*!50001 DROP TABLE IF EXISTS `providerLastThreeMonths`*/; /*!50001 DROP TABLE IF EXISTS `supplierLastThreeMonths `*/;
/*!50001 DROP VIEW IF EXISTS `providerLastThreeMonths`*/; /*!50001 DROP VIEW IF EXISTS `supplierLastThreeMonths`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET @saved_col_connection = @@collation_connection */;
@ -95250,7 +95189,7 @@ USE `sage`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `providerLastThreeMonths` AS select `vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`companyFk` AS `companyFk` from `vn`.`invoiceIn` where (`vn`.`invoiceIn`.`issued` > (curdate() - interval 3 month)) union select `vn`.`payment`.`supplierFk` AS `supplierFk`,`vn`.`payment`.`companyFk` AS `companyFk` from `vn`.`payment` where (`vn`.`payment`.`received` > (curdate() + interval -(3) month)) */; /*!50001 VIEW `supplierLastThreeMonths` AS SELECT `vn`.`invoiceIn`.`supplierFk` AS `supplierFk`, `vn`.`invoiceIn`.`companyFk` AS `companyFk` FROM `vn`.`invoiceIn` WHERE (`vn`.`invoiceIn`.`issued` > (CURDATE() - INTERVAL 3 MONTH)) UNION SELECT `vn`.`payment`.`supplierFk` AS `supplierFk`, `vn`.`payment`.`companyFk` AS `companyFk` FROM `vn`.`payment` WHERE (`vn`.`payment`.`received` > (CURDATE() + INTERVAL -(3) MONTH)) */;
/*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 SET collation_connection = @saved_col_connection */;
@ -97136,7 +97075,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `personMedia` AS select `p`.`id_trabajador` AS `workerFk`,`m`.`value` AS `mediaValue` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `po` on((`po`.`person_id` = `p`.`person_id`))) join `postgresql`.`profile_media` `pom` on((`pom`.`profile_id` = `po`.`profile_id`))) join `postgresql`.`media` `m` on((`m`.`media_id` = `pom`.`media_id`))) join `postgresql`.`media_type` `mt` on((`mt`.`media_type_id` = `m`.`media_type_id`))) where (`mt`.`name` = 'movil personal') */; /*!50001 VIEW `personMedia` AS SELECT `po`.`workerFk` AS `workerFk`, `m`.`value` AS `mediaValue` FROM (((`postgresql`.`profile` `po` JOIN `postgresql`.`profile_media` `pom` ON ((`pom`.`profile_id` = `po`.`profile_id`))) JOIN `postgresql`.`media` `m` ON ((`m`.`media_id` = `pom`.`media_id`))) JOIN `postgresql`.`media_type` `mt` ON ((`mt`.`media_type_id` = `m`.`media_type_id`))) WHERE (`mt`.`name` = 'movil personal') */;
/*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 SET collation_connection = @saved_col_connection */;
@ -97459,7 +97398,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `salesPersonSince` AS select `p`.`id_trabajador` AS `workerFk`,min(`b`.`date_start`) AS `started` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_id`))) left join `postgresql`.`business` `b` on((`pr`.`profile_id` = `b`.`client_id`))) left join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) join `postgresql`.`professional_category` `pc` on((`pc`.`professional_category_id` = `bl`.`professional_category_id`))) where (`pc`.`category_name` = 'Aux ventas') group by `p`.`id_trabajador` */; /*!50001 VIEW `salesPersonSince` AS SELECT `pr`.`workerFk` AS `workerFk`, MIN(`b`.`date_start`) AS `started` FROM (((`postgresql`.`profile` `pr` LEFT JOIN `postgresql`.`business` `b` ON ((`pr`.`profile_id` = `b`.`client_id`))) LEFT JOIN `postgresql`.`business_labour` `bl` ON ((`b`.`business_id` = `bl`.`business_id`))) JOIN `postgresql`.`professional_category` `pc` ON ((`pc`.`professional_category_id` = `bl`.`professional_category_id`))) WHERE (`pc`.`category_name` = 'Aux ventas') GROUP BY `pr`.`workerFk` */;
/*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 SET collation_connection = @saved_col_connection */;
@ -97877,7 +97816,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `workerBusinessDated` AS select `t`.`dated` AS `dated`,`b`.`business_id` AS `business_id`,`w`.`id` AS `workerFk` from ((((`vn`.`time` `t` left join `postgresql`.`business` `b` on((`t`.`dated` between `b`.`date_start` and ifnull(`b`.`date_end`,curdate())))) left join `postgresql`.`profile` `pr` on((`b`.`client_id` = `pr`.`profile_id`))) left join `postgresql`.`person` `p` on((`pr`.`person_id` = `p`.`person_id`))) left join `vn`.`worker` `w` on((`p`.`id_trabajador` = `w`.`id`))) where (`t`.`dated` > (curdate() + interval -(2) year)) */; /*!50001 VIEW `workerBusinessDated` AS SELECT `t`.`dated` AS `dated`, `b`.`business_id` AS `business_id`, `pr`.`workerFk` AS `workerFk` FROM ((`vn`.`time` `t` LEFT JOIN `postgresql`.`business` `b` ON ((`t`.`dated` BETWEEN `b`.`date_start` AND IFNULL(`b`.`date_end`, CURDATE())))) LEFT JOIN `postgresql`.`profile` `pr` ON ((`b`.`client_id` = `pr`.`profile_id`))) WHERE (`t`.`dated` > (CURDATE() + INTERVAL -(2) YEAR)) */;
/*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 SET collation_connection = @saved_col_connection */;
@ -97896,7 +97835,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `workerCalendar` AS select `ce`.`business_id` AS `businessFk`,`p`.`id_trabajador` AS `workerFk`,`ce`.`calendar_state_id` AS `absenceTypeFk`,`ce`.`date` AS `dated` from (((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_id`))) join `postgresql`.`business` `b` on((`b`.`client_id` = `pr`.`profile_id`))) join `postgresql`.`calendar_employee` `ce` on((`ce`.`business_id` = `b`.`business_id`))) */; /*!50001 VIEW `workerCalendar` AS SELECT `ce`.`business_id` AS `businessFk`, `pr`.`workerFk` AS `workerFk`, `ce`.`calendar_state_id` AS `absenceTypeFk`, `ce`.`date` AS `dated` FROM ((`postgresql`.`profile` `pr` JOIN `postgresql`.`business` `b` ON ((`b`.`client_id` = `pr`.`profile_id`))) JOIN `postgresql`.`calendar_employee` `ce` ON ((`ce`.`business_id` = `b`.`business_id`))) */;
/*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 SET collation_connection = @saved_col_connection */;
@ -97915,7 +97854,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `workerDepartment` AS select `p`.`id_trabajador` AS `workerFk`,`d`.`id` AS `departmentFk` from (((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_id`))) left join (`postgresql`.`business` `b` left join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) on((`pr`.`profile_id` = `b`.`client_id`))) join `vn`.`department` `d` on((`d`.`id` = `bl`.`department_id`))) where ((isnull(`b`.`date_end`) and (`b`.`date_start` <= curdate())) or ((`b`.`date_end` >= curdate()) and (`b`.`date_start` <= curdate()))) */; /*!50001 VIEW `workerDepartment` AS SELECT `pr`.`workerFk` AS `workerFk`, `bl`.`department_id` AS `departmentFk` FROM (`postgresql`.`profile` `pr` LEFT JOIN (`postgresql`.`business` `b` LEFT JOIN `postgresql`.`business_labour` `bl` ON ((`b`.`business_id` = `bl`.`business_id`))) ON ((`pr`.`profile_id` = `b`.`client_id`))) WHERE ((ISNULL(`b`.`date_end`) AND (`b`.`date_start` <= CURDATE())) OR ((`b`.`date_end` >= CURDATE()) AND (`b`.`date_start` <= CURDATE()))) */;
/*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 SET collation_connection = @saved_col_connection */;
@ -97953,7 +97892,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `workerLabour` AS select `b`.`business_id` AS `businessFk`,`p`.`id_trabajador` AS `workerFk`,`bl`.`workcenter_id` AS `workCenterFk`,`b`.`date_start` AS `started`,`b`.`date_end` AS `ended`,`d`.`id` AS `departmentFk`,`b`.`payedHolidays` AS `payedHolidays` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_id`))) join `postgresql`.`business` `b` on((`b`.`client_id` = `pr`.`profile_id`))) join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) join `vn`.`department` `d` on((`d`.`id` = `bl`.`department_id`))) order by `b`.`date_start` desc */; /*!50001 VIEW `workerLabour` AS SELECT `b`.`business_id` AS `businessFk`, `pr`.`workerFk` AS `workerFk`, `bl`.`workcenter_id` AS `workCenterFk`, `b`.`date_start` AS `started`, `b`.`date_end` AS `ended`, `d`.`id` AS `departmentFk`, `b`.`payedHolidays` AS `payedHolidays` FROM (((`postgresql`.`profile` `pr` JOIN `postgresql`.`business` `b` ON ((`b`.`client_id` = `pr`.`profile_id`))) JOIN `postgresql`.`business_labour` `bl` ON ((`b`.`business_id` = `bl`.`business_id`))) JOIN `vn`.`department` `d` ON ((`d`.`id` = `bl`.`department_id`))) ORDER BY `b`.`date_start` DESC */;
/*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 SET collation_connection = @saved_col_connection */;
@ -97991,7 +97930,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `workerMedia` AS select `p`.`id_trabajador` AS `workerFk`,`m`.`value` AS `mediaValue` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `po` on((`po`.`person_id` = `p`.`person_id`))) join `postgresql`.`profile_media` `pom` on((`pom`.`profile_id` = `po`.`profile_id`))) join `postgresql`.`media` `m` on((`m`.`media_id` = `pom`.`media_id`))) join `postgresql`.`media_type` `mt` on((`mt`.`media_type_id` = `m`.`media_type_id`))) where (`mt`.`name` = 'movil empresa') */; /*!50001 VIEW `workerMedia` AS SELECT `po`.`workerFk` AS `workerFk`, `m`.`value` AS `mediaValue` FROM (((`postgresql`.`profile` `po` JOIN `postgresql`.`profile_media` `pom` ON ((`pom`.`profile_id` = `po`.`profile_id`))) JOIN `postgresql`.`media` `m` ON ((`m`.`media_id` = `pom`.`media_id`))) JOIN `postgresql`.`media_type` `mt` ON ((`mt`.`media_type_id` = `m`.`media_type_id`))) WHERE (`mt`.`name` = 'movil empresa') */;
/*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */; /*!50001 SET collation_connection = @saved_col_connection */;