diff --git a/back/models/vn-user.json b/back/models/vn-user.json
index 9131c9134..9e3f8df89 100644
--- a/back/models/vn-user.json
+++ b/back/models/vn-user.json
@@ -84,7 +84,7 @@
"worker": {
"type": "hasOne",
"model": "Worker",
- "foreignKey": "userFk"
+ "foreignKey": "id"
},
"userConfig": {
"type": "hasOne",
diff --git a/db/changes/234001/00-dropUserFk.sql b/db/changes/234001/00-dropUserFk.sql
index ad4db3110..d6ce328a8 100644
--- a/db/changes/234001/00-dropUserFk.sql
+++ b/db/changes/234001/00-dropUserFk.sql
@@ -1,5 +1,4 @@
-ALTER TABLE `vn`.`workerDocument` DROP FOREIGN KEY `workerDocument_ibfk_1`;
-
ALTER TABLE `vn`.`worker` DROP KEY `user_id_UNIQUE`;
ALTER TABLE `vn`.`worker` DROP COLUMN `userFk`;
+
diff --git a/db/changes/234001/01-deliveryAssistantACL.sql b/db/changes/234001/01-deliveryAssistantACL.sql
index 44459c432..504760d6f 100644
--- a/db/changes/234001/01-deliveryAssistantACL.sql
+++ b/db/changes/234001/01-deliveryAssistantACL.sql
@@ -1,5 +1,5 @@
-- Auto-generated SQL script. Actual values for binary/complex data types may differ - what you see is the default string representation of values.
-INSERT INTO `account`.`role` (name,description)
+INSERT INTO `account`.`role` (name, description)
VALUES ('deliveryAssistant','Jefe auxiliar repartos');
INSERT INTO `account`.`roleInherit` (role, inheritsFrom)
diff --git a/db/changes/234001/01-workerCreate.sql b/db/changes/234001/01-workerCreate.sql
new file mode 100644
index 000000000..166c65a26
--- /dev/null
+++ b/db/changes/234001/01-workerCreate.sql
@@ -0,0 +1,20 @@
+DELIMITER $$
+$$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerCreate`(
+ vFirstname VARCHAR(50),
+ vLastName VARCHAR(50),
+ vCode CHAR(3),
+ vBossFk INT,
+ vUserFk INT,
+ vFi VARCHAR(15) ,
+ vBirth DATE
+)
+BEGIN
+/**
+ * Create new worker
+ *
+ */
+ INSERT INTO worker(id, code, firstName, lastName, bossFk, fi, birth)
+ VALUES (vUserFk, vCode, vFirstname, vLastName, vBossFk, vFi, vBirth);
+END$$
+DELIMITER ;
diff --git a/db/dump/structure.sql b/db/dump/structure.sql
index eea10eeed..73f6e92cb 100644
--- a/db/dump/structure.sql
+++ b/db/dump/structure.sql
@@ -24255,7 +24255,6 @@ BEGIN
CONCAT('Cliente ', NEW.id),
CONCAT('Recibida la documentación: ', vText)
FROM worker w
- LEFT JOIN account.user u ON w.id = u.id AND u.active
LEFT JOIN account.user u ON w.id = u.id AND u.active
LEFT JOIN account.account ac ON ac.id = u.id
WHERE w.id = NEW.salesPersonFk;
@@ -45804,23 +45803,6 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `getWorkerCode`() RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
- READS SQL DATA
-BEGIN
- DECLARE vUserCode VARCHAR(3) CHARSET utf8 COLLATE utf8_unicode_ci;
-
- SELECT code INTO vUserCode
- FROM worker
- WHERE userFk = account.myUser_getId();
-
- RETURN vUserCode;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `hasAnyNegativeBase` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -48196,56 +48178,6 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `workerIsBoss`(vUserId INT) RETURNS int(11)
- DETERMINISTIC
-BEGIN
-/**
- * Comprueba por jerarquía si el trabajador actual es jefe
- * de un trabajador en concreto.
- *
- * @param vUserId Id del trabajador que se desea comprobar.
- * @return Revuelve verdadero si es jefe del empleado por escala jerárquica.
- */
- DECLARE vWorkerId INT;
- DECLARE vBossId INT;
-
- SELECT id INTO vWorkerId
- FROM vn.worker
- WHERE userFk = vUserId;
- IF vWorkerId IS NULL THEN
- CALL util.throw('USER_NOT_FOUND');
- END IF;
-
- DROP TEMPORARY TABLE IF EXISTS tCheckedWorker;
- CREATE TEMPORARY TABLE tCheckedWorker
- (PRIMARY KEY (workerFk))
- ENGINE = MEMORY
- SELECT id workerFk FROM worker LIMIT 0;
- LOOP
- SELECT bossFk INTO vBossId
- FROM vn.worker
- WHERE id = vWorkerId;
- IF (SELECT COUNT(*) FROM tCheckedWorker WHERE workerFk = vBossId) THEN
- CALL util.throw('INFINITE_LOOP');
- END IF;
- IF vBossId = vWorkerId THEN
- RETURN FALSE;
- ELSEIF vBossId = account.myUser_getId() THEN
- RETURN TRUE;
- ELSE
- INSERT INTO tCheckedWorker VALUES (vWorkerId);
- SET vWorkerId = vBossId;
- END IF;
- END LOOP;
- DROP TEMPORARY TABLE tCheckedWorker;
- RETURN FALSE;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `workerMachinery_isRegistered` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71229,9 +71161,8 @@ BEGIN
IF (vLanding IS NULL) THEN
SELECT e.email INTO vSalesPersonEmail
- FROM vn.client c
- JOIN vn.worker sp ON sp.id = c.salesPersonFk
- JOIN account.emailUser e ON e.userFk = sp.userFk
+ FROM client c
+ JOIN account.emailUser e ON e.userFk = c.salesPersonFk
WHERE c.id = vClientFk;
SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ',
@@ -73418,7 +73349,8 @@ BEGIN
at2.permissionRate,
at2.discountRate,
ct.hoursWeek hoursWeek,
- at2.isAllowedToWork
+ at2.isAllowedToWork,
+ u.userFk
FROM time t
LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo)
LEFT JOIN worker w ON w.id = b.workerFk
@@ -73946,7 +73878,7 @@ BEGIN
CREATE TEMPORARY TABLE tmp.`user`
SELECT u.id userFk
FROM account.user u
- JOIN vn.worker w ON w.id = u.id
+ JOIN vn.worker w ON w.userFk = u.id
WHERE w.id = vWorkerFk;
CALL vn.timeControl_calculate(vDatedFrom, vDatedTo);
@@ -76048,8 +75980,7 @@ BEGIN
LIMIT 10000000000000000000)sub
GROUP BY cont
HAVING cont2 MOD 2 = 1
- )sub2
- JOIN worker w ON w.userFk = sub2.userFk;
+ )sub2;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -82085,7 +82016,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `workerTimeJourneyNG`
--
diff --git a/modules/client/back/models/client-observation.json b/modules/client/back/models/client-observation.json
index b8852b186..95d00d374 100644
--- a/modules/client/back/models/client-observation.json
+++ b/modules/client/back/models/client-observation.json
@@ -41,7 +41,7 @@
"include": {
"relation": "worker",
"scope": {
- "fields": ["userFk"],
+ "fields": ["id"],
"include": {
"relation": "user",
"scope": {
diff --git a/modules/route/back/models/roadmap.json b/modules/route/back/models/roadmap.json
index 7ca8fe0f6..2f6bb8c02 100644
--- a/modules/route/back/models/roadmap.json
+++ b/modules/route/back/models/roadmap.json
@@ -47,7 +47,7 @@
"worker": {
"type": "belongsTo",
"model": "Worker",
- "foreignKey": "userFk"
+ "foreignKey": "id"
},
"supplier": {
"type": "belongsTo",
diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json
index 5f60318a5..aab569d7b 100644
--- a/modules/shelving/back/models/shelving.json
+++ b/modules/shelving/back/models/shelving.json
@@ -41,7 +41,7 @@
"worker": {
"type": "belongsTo",
"model": "Worker",
- "foreignKey": "userFk"
+ "foreignKey": "id"
}
}
}
diff --git a/modules/worker/back/methods/worker/filter.js b/modules/worker/back/methods/worker/filter.js
index 15a56949f..f9eae2db8 100644
--- a/modules/worker/back/methods/worker/filter.js
+++ b/modules/worker/back/methods/worker/filter.js
@@ -94,8 +94,6 @@ module.exports = Self => {
{'u.nickname': {like: `%${value}%`}}
]};
case 'id':
- case 'userFk':
- return {'w.id': value};
case 'firstName':
return {'w.firstName': {like: `%${value}%`}};
case 'lastName':
diff --git a/modules/worker/back/models/worker-time-control.json b/modules/worker/back/models/worker-time-control.json
index b045946e7..c40989d84 100644
--- a/modules/worker/back/models/worker-time-control.json
+++ b/modules/worker/back/models/worker-time-control.json
@@ -36,7 +36,7 @@
"worker": {
"type": "hasOne",
"model": "Worker",
- "foreignKey": "userFk"
+ "foreignKey": "id"
},
"warehouse": {
"type": "belongsTo",
diff --git a/modules/worker/front/search-panel/index.html b/modules/worker/front/search-panel/index.html
index 2adb56587..c93eef78b 100644
--- a/modules/worker/front/search-panel/index.html
+++ b/modules/worker/front/search-panel/index.html
@@ -18,7 +18,7 @@
+ ng-model="filter.id">
@@ -64,4 +64,4 @@
-
\ No newline at end of file
+