diff --git a/db/changes/10503-november/00-aclProfileType.sql b/db/changes/10503-november/00-aclProfileType.sql
new file mode 100644
index 000000000..638b3d580
--- /dev/null
+++ b/db/changes/10503-november/00-aclProfileType.sql
@@ -0,0 +1,18 @@
+
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES
+ ('ProfileType', '*', '*', 'ALLOW', 'ROLE', 'employee');
+
+CREATE TABLE `vn`.`newWorkerConfig` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `street` VARCHAR(25) NULL,
+ `provinceFk` smallint(6) unsigned NULL,
+ `companyFk` smallint(5) unsigned NULL,
+ `profileTypeFk` INT(11) NULL,
+ `roleFk` int(10) unsigned NULL,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `newWorkerConfig_province_fk` FOREIGN KEY (`provinceFk`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `newWorkerConfig_company_fk` FOREIGN KEY (`companyFk`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `newWorkerConfig_profileType_fk` FOREIGN KEY (`profileTypeFk`) REFERENCES `vn`.`profileType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `newWorkerConfig_role_fk` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+);
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index 6624e99f4..a6fb9cbbb 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -2719,3 +2719,11 @@ UPDATE `account`.`user`
INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
VALUES
(0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', 'open', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
+
+INSERT INTO `vn`.`profileType` (`id`, `name`)
+ VALUES
+ (1, 'working');
+
+INSERT INTO `vn`.`newWorkerConfig` (`id`, `street`, `provinceFk`, `companyFk`, `profileTypeFk`, `roleFk`)
+ VALUES
+ (1, 'S/ ', 1, 442, 1, 1);
diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js
index 481011563..bdab1335a 100644
--- a/modules/worker/back/methods/worker/new.js
+++ b/modules/worker/back/methods/worker/new.js
@@ -8,7 +8,7 @@ module.exports = Self => {
accepts: [
{
arg: 'fi',
- type: 'number',
+ type: 'string',
description: `The fi of worker`,
required: true
},
@@ -30,12 +30,6 @@ module.exports = Self => {
description: `REPLACE!`,
required: true
},
- {
- arg: 'password',
- type: 'string',
- description: `REPLACE!`,
- required: true
- },
{
arg: 'email',
type: 'string',
@@ -43,49 +37,76 @@ module.exports = Self => {
required: true
},
{
- arg: 'role',
+ arg: 'roleFk',
type: 'number',
- description: `REPLACE!`
+ description: `REPLACE!`,
+ required: true
},
{
arg: 'street',
type: 'string',
- description: `REPLACE!`
+ description: `REPLACE!`,
+ required: true
},
{
- arg: 'string',
- type: 'number',
- description: `REPLACE!`
+ arg: 'city',
+ type: 'string',
+ description: `REPLACE!`,
+ required: true
},
{
arg: 'provinceFk',
type: 'number',
- description: `REPLACE!`
+ description: `REPLACE!`,
+ required: true
},
{
- arg: 'postalCode',
+ arg: 'iban',
+ type: 'string',
+ description: `REPLACE!`,
+ required: true
+ },
+ {
+ arg: 'bankEntityFk',
type: 'number',
- description: `REPLACE!`
+ description: `REPLACE!`,
+ required: true
+ },
+ {
+ arg: 'companyFk',
+ type: 'number',
+ description: `REPLACE!`,
+ required: true
+ },
+ {
+ arg: 'postcode',
+ type: 'string',
+ description: `REPLACE!`,
+ required: true
},
{
arg: 'phone',
- type: 'number',
- description: `REPLACE!`
+ type: 'string',
+ description: `REPLACE!`,
+ required: true
},
{
- arg: 'workerCode',
+ arg: 'code',
type: 'string',
- description: `REPLACE!`
+ description: `REPLACE!`,
+ required: true
},
{
arg: 'bossFk',
type: 'number',
- description: `REPLACE!`
+ description: `REPLACE!`,
+ required: true
},
{
arg: 'birth',
type: 'date',
- description: `REPLACE!`
+ description: `REPLACE!`,
+ required: true
}
],
returns: {
@@ -104,7 +125,7 @@ module.exports = Self => {
const args = ctx.args;
let tx;
-
+ console.log(args);
if (typeof options == 'object')
Object.assign(myOptions, options);
@@ -116,15 +137,16 @@ module.exports = Self => {
let client;
try {
client = await models.Client.findOne({
- where: {fi: fi},
+ where: {fi: args.fi},
}, myOptions);
if (!client) {
const nickname = args.firstName.concat(' ', args.lastNames);
+ const randomPassword = await models.Worker.rawSql('SELECT account.passwordGenerate();');
const user = await models.Account.create({
name: args.name,
nickname,
- password: md5(args.password),
+ password: md5(randomPassword),
email: args.email,
role: args.role
}, myOptions);
@@ -138,11 +160,11 @@ module.exports = Self => {
args.firstName,
args.lastNames,
args.fi,
- args.address,
+ args.street,
args.postalCode,
- args.town,
- args.province,
- args.company,
+ args.city,
+ args.provinceFk,
+ args.companyFk,
args.phone,
args.email,
user.id
@@ -151,8 +173,8 @@ module.exports = Self => {
const address = await models.Address.create({
clientFk: user.id,
- address: args.street,
- town: args.town,
+ street: args.street,
+ city: args.city,
provinceFk: args.provinceFk,
postalCode: args.postalCode,
mobile: args.phone,
@@ -160,17 +182,22 @@ module.exports = Self => {
isDefaultAddress: true
}, myOptions);
- client = await models.Sale.findById(user.id, null, myOptions);
- await client.updateAttribute('defaultAddressFk ', address.id);
- }
+ client = await models.Client.findById(user.id, null, myOptions);
+ console.log(address.id);
+ await client.updateAttributes({
+ iban: args.iban,
+ bankEntityFk: args.bankEntityFk,
+ defaultAddressFk: address.id
+ }, myOptions);
+ }
await models.Worker.rawSql('CALL vn.workerCreate(?, ?, ?, ?, ?, ?, ?)',
[
args.firstName,
args.lastNames,
- args.workerCode,
+ args.code,
args.bossFk,
- user.id,
+ client.id,
args.fi,
args.birth
]
@@ -184,6 +211,9 @@ module.exports = Self => {
// TODO: create this email, use client-welcome as template. And view CALL mail_insert in redmine for the body
// TODO: or use same funcionality back/methods/account/recover-password.js
+
+ // TODO: call worerWelcomeEmail, and this is who create the url for change password
+
const email = new Email('worker-welcome', {
recipient: args.email,
lang: ctx.req.getLocale()
diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json
index 3f3416504..de8aadd41 100644
--- a/modules/worker/back/model-config.json
+++ b/modules/worker/back/model-config.json
@@ -1,7 +1,7 @@
{
"AbsenceType": {
"dataSource": "vn"
- },
+ },
"Calendar": {
"dataSource": "vn"
},
@@ -16,13 +16,22 @@
},
"Department": {
"dataSource": "vn"
- },
+ },
+ "Device": {
+ "dataSource": "vn"
+ },
"EducationLevel": {
"dataSource": "vn"
},
"Journey": {
"dataSource": "vn"
},
+ "NewWorkerConfig":{
+ "dataSource": "vn"
+ },
+ "ProfileType":{
+ "dataSource": "vn"
+ },
"Time": {
"dataSource": "vn"
},
@@ -55,11 +64,8 @@
},
"WorkerDepartment": {
"dataSource": "vn"
- },
- "WorkerTimeControl": {
- "dataSource": "vn"
},
- "Device": {
+ "WorkerTimeControl": {
"dataSource": "vn"
},
"WorkerLog": {
diff --git a/modules/worker/back/models/new-worker-config.json b/modules/worker/back/models/new-worker-config.json
new file mode 100644
index 000000000..2102d236c
--- /dev/null
+++ b/modules/worker/back/models/new-worker-config.json
@@ -0,0 +1,39 @@
+{
+ "name": "NewWorkerConfig",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "newWorkerConfig"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "street": {
+ "type": "string"
+ },
+ "provinceFk": {
+ "type": "number"
+ },
+ "companyFk": {
+ "type": "number"
+ },
+ "profileTypeFk": {
+ "type": "number"
+ },
+ "roleFk": {
+ "type": "number"
+ }
+ },
+ "acls": [
+ {
+ "accessType": "READ",
+ "principalType": "ROLE",
+ "principalId": "$everyone",
+ "permission": "ALLOW"
+ }
+ ]
+}
diff --git a/modules/worker/back/models/profile-type.json b/modules/worker/back/models/profile-type.json
new file mode 100644
index 000000000..d1d750de8
--- /dev/null
+++ b/modules/worker/back/models/profile-type.json
@@ -0,0 +1,19 @@
+{
+ "name": "ProfileType",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "profileType"
+ }
+ },
+ "properties": {
+ "id": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+}
diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json
index 3d41707ce..e3a941dd3 100644
--- a/modules/worker/back/models/worker.json
+++ b/modules/worker/back/models/worker.json
@@ -52,6 +52,9 @@
},
"mobileExtension": {
"type" : "number"
+ },
+ "code": {
+ "type" : "string"
}
},
"relations": {
@@ -91,4 +94,4 @@
"foreignKey": "sectorFk"
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/worker/front/create/index.html b/modules/worker/front/create/index.html
new file mode 100644
index 000000000..58b4da060
--- /dev/null
+++ b/modules/worker/front/create/index.html
@@ -0,0 +1,208 @@
+
{{ $t('description.dearWorker') }},
+ +{{ $t('workerData', this.user.name, this.url) }}
+