Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 4658-createWorker
This commit is contained in:
commit
5e831581a0
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE `vn`.`greuge` CHANGE `userFK` `userFk` int(10) unsigned DEFAULT NULL NULL;
|
|
@ -0,0 +1,88 @@
|
||||||
|
DROP PROCEDURE IF EXISTS `vn`.`timeBusiness_calculate`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Horas que debe trabajar un empleado según contrato y día.
|
||||||
|
* @param vDatedFrom workerTimeControl
|
||||||
|
* @param vDatedTo workerTimeControl
|
||||||
|
* @table tmp.user(userFk)
|
||||||
|
* @return tmp.timeBusinessCalculate
|
||||||
|
*/
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate;
|
||||||
|
CREATE TEMPORARY TABLE tmp.timeBusinessCalculate
|
||||||
|
(INDEX (departmentFk))
|
||||||
|
SELECT dated,
|
||||||
|
businessFk,
|
||||||
|
userFk,
|
||||||
|
departmentFk,
|
||||||
|
hourStart,
|
||||||
|
hourEnd,
|
||||||
|
timeTable,
|
||||||
|
timeWorkSeconds,
|
||||||
|
SEC_TO_TIME(timeWorkSeconds) timeWorkSexagesimal,
|
||||||
|
timeWorkSeconds / 3600 timeWorkDecimal,
|
||||||
|
timeWorkSeconds timeBusinessSeconds,
|
||||||
|
SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal,
|
||||||
|
timeWorkSeconds / 3600 timeBusinessDecimal,
|
||||||
|
name type,
|
||||||
|
permissionRate,
|
||||||
|
hoursWeek,
|
||||||
|
discountRate,
|
||||||
|
isAllowedToWork
|
||||||
|
FROM(SELECT t.dated,
|
||||||
|
b.id businessFk,
|
||||||
|
w.userFk,
|
||||||
|
b.departmentFk,
|
||||||
|
IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5) ORDER BY j.start ASC SEPARATOR ' - ')) hourStart ,
|
||||||
|
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, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)), 0)) timeWorkSeconds,
|
||||||
|
at2.name,
|
||||||
|
at2.permissionRate,
|
||||||
|
at2.discountRate,
|
||||||
|
cl.hours_week hoursWeek,
|
||||||
|
at2.isAllowedToWork
|
||||||
|
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
|
||||||
|
JOIN tmp.`user` u ON u.userFK = w.userFK
|
||||||
|
LEFT JOIN workCenter wc ON wc.id = b.workcenterFK
|
||||||
|
LEFT JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = b.calendarTypeFk
|
||||||
|
LEFT JOIN postgresql.journey j ON j.business_id = b.id AND j.day_id = WEEKDAY(t.dated) + 1
|
||||||
|
LEFT JOIN postgresql.calendar_employee ce ON ce.businessFk = b.id AND ce.date = t.dated
|
||||||
|
LEFT JOIN absenceType at2 ON at2.id = ce.calendar_state_id
|
||||||
|
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
|
||||||
|
GROUP BY w.userFk, t.dated
|
||||||
|
)sub;
|
||||||
|
|
||||||
|
UPDATE tmp.timeBusinessCalculate t
|
||||||
|
LEFT JOIN postgresql.journey j ON j.business_id = t.businessFk
|
||||||
|
SET t.timeWorkSeconds = t.hoursWeek / 5 * 3600,
|
||||||
|
t.timeWorkSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600),
|
||||||
|
t.timeWorkDecimal = t.hoursWeek / 5,
|
||||||
|
t.timeBusinessSeconds = t.hoursWeek / 5 * 3600,
|
||||||
|
t.timeBusinessSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600),
|
||||||
|
t.timeBusinessDecimal = t.hoursWeek / 5
|
||||||
|
WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND j.journey_id IS NULL ;
|
||||||
|
|
||||||
|
UPDATE tmp.timeBusinessCalculate t
|
||||||
|
SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate) ,
|
||||||
|
t.timeWorkSexagesimal = SEC_TO_TIME ((t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)) * 3600),
|
||||||
|
t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)
|
||||||
|
WHERE permissionRate <> 0;
|
||||||
|
|
||||||
|
UPDATE tmp.timeBusinessCalculate t
|
||||||
|
JOIN calendarHolidays ch ON ch.dated = t.dated
|
||||||
|
JOIN business b ON b.id = t.businessFk
|
||||||
|
AND b.workcenterFk = ch.workcenterFk
|
||||||
|
SET t.timeWorkSeconds = 0,
|
||||||
|
t.timeWorkSexagesimal = 0,
|
||||||
|
t.timeWorkDecimal = 0,
|
||||||
|
t.permissionrate = 1,
|
||||||
|
t.type = 'Festivo'
|
||||||
|
WHERE t.type IS NULL;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,7 +1,7 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
import selectors from '../../helpers/selectors.js';
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
fdescribe('Ticket expeditions and log path', () => {
|
describe('Ticket expeditions and log path', () => {
|
||||||
let browser;
|
let browser;
|
||||||
let page;
|
let page;
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,6 @@ describe('Ticket Edit basic data path', () => {
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketBasicData.nextStepButton);
|
await page.waitToClick(selectors.ticketBasicData.nextStepButton);
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketBasicData.withoutNegatives);
|
|
||||||
await page.waitToClick(selectors.ticketBasicData.finalizeButton);
|
await page.waitToClick(selectors.ticketBasicData.finalizeButton);
|
||||||
|
|
||||||
await page.waitForState('ticket.card.summary');
|
await page.waitForState('ticket.card.summary');
|
||||||
|
|
|
@ -23,12 +23,6 @@ module.exports = Self => {
|
||||||
|
|
||||||
Self.setPassword = async function(ctx, id, newPassword) {
|
Self.setPassword = async function(ctx, id, newPassword) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const userId = ctx.req.accessToken.userId;
|
|
||||||
|
|
||||||
const isSalesPerson = await models.Account.hasRole(userId, 'salesPerson');
|
|
||||||
|
|
||||||
if (!isSalesPerson)
|
|
||||||
throw new UserError(`Not enough privileges to edit a client`);
|
|
||||||
|
|
||||||
const isClient = await models.Client.findById(id, null);
|
const isClient = await models.Client.findById(id, null);
|
||||||
const isUserAccount = await models.UserAccount.findById(id, null);
|
const isUserAccount = await models.UserAccount.findById(id, null);
|
||||||
|
|
|
@ -6,21 +6,6 @@ describe('Client setPassword', () => {
|
||||||
req: {accessToken: {userId: salesPersonId}}
|
req: {accessToken: {userId: salesPersonId}}
|
||||||
};
|
};
|
||||||
|
|
||||||
it(`should throw an error if you don't have enough permissions`, async() => {
|
|
||||||
let error;
|
|
||||||
const employeeId = 1;
|
|
||||||
const ctx = {
|
|
||||||
req: {accessToken: {userId: employeeId}}
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
await models.Client.setPassword(ctx, 1, 't0pl3v3l.p455w0rd!');
|
|
||||||
} catch (e) {
|
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(error.message).toEqual(`Not enough privileges to edit a client`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error the setPassword target is not just a client but a worker', async() => {
|
it('should throw an error the setPassword target is not just a client but a worker', async() => {
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,21 @@
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
require('../methods/greuge/sumAmount')(Self);
|
require('../methods/greuge/sumAmount')(Self);
|
||||||
|
|
||||||
|
Self.observe('before save', function(ctx, next) {
|
||||||
|
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||||
|
|
||||||
|
let userFk = loopBackContext.active.accessToken.userId;
|
||||||
|
|
||||||
|
if (ctx.instance)
|
||||||
|
ctx.instance.userFk = userFk;
|
||||||
|
else
|
||||||
|
ctx.data.userFk = userFk;
|
||||||
|
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
Self.validatesLengthOf('description', {
|
Self.validatesLengthOf('description', {
|
||||||
max: 45,
|
max: 45,
|
||||||
message: 'Description should have maximum of 45 characters'
|
message: 'Description should have maximum of 45 characters'
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
"name": "Greuge",
|
"name": "Greuge",
|
||||||
"base": "Loggable",
|
"base": "Loggable",
|
||||||
"log": {
|
"log": {
|
||||||
"model": "ClientLog",
|
"model": "ClientLog",
|
||||||
"relation": "client",
|
"relation": "client",
|
||||||
"showField": "description"
|
"showField": "description"
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
|
@ -35,7 +35,6 @@
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"required": true
|
"required": true
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"client": {
|
"client": {
|
||||||
|
@ -52,6 +51,11 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "GreugeType",
|
"model": "GreugeType",
|
||||||
"foreignKey": "greugeTypeFk"
|
"foreignKey": "greugeTypeFk"
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Account",
|
||||||
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,6 +29,7 @@
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th field="shipped" default-order="DESC" expand>Date</vn-th>
|
<vn-th field="shipped" default-order="DESC" expand>Date</vn-th>
|
||||||
|
<vn-th field="userFk">Created by</vn-thfield></vn-th>
|
||||||
<vn-th field="description">Comment</vn-th>
|
<vn-th field="description">Comment</vn-th>
|
||||||
<vn-th field="greugeTypeFk">Type</vn-th>
|
<vn-th field="greugeTypeFk">Type</vn-th>
|
||||||
<vn-th field="amount" number>Amount</vn-th>
|
<vn-th field="amount" number>Amount</vn-th>
|
||||||
|
@ -37,6 +38,8 @@
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="greuge in greuges">
|
<vn-tr ng-repeat="greuge in greuges">
|
||||||
<vn-td shrink-datetime>{{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }}</vn-td>
|
<vn-td shrink-datetime>{{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }}</vn-td>
|
||||||
|
<vn-td><span ng-click="workerDescriptor.show($event, greuge.user.id)"
|
||||||
|
class="link">{{::greuge.user.name}}</span></vn-td>
|
||||||
<vn-td>
|
<vn-td>
|
||||||
<span title="{{::greuge.description}}">{{::greuge.description}}</span>
|
<span title="{{::greuge.description}}">{{::greuge.description}}</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
@ -57,3 +60,4 @@
|
||||||
vn-bind="+"
|
vn-bind="+"
|
||||||
fixed-bottom-right>
|
fixed-bottom-right>
|
||||||
</vn-float-button>
|
</vn-float-button>
|
||||||
|
<vn-worker-descriptor-popover vn-id="workerDescriptor"></vn-worker-descriptor-popover>
|
|
@ -8,6 +8,12 @@ class Controller extends Section {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
relation: 'greugeType',
|
relation: 'greugeType',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'name']
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'user',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['id', 'name']
|
fields: ['id', 'name']
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,3 +2,4 @@ Date: Fecha
|
||||||
Comment: Comentario
|
Comment: Comentario
|
||||||
Amount: Importe
|
Amount: Importe
|
||||||
Type: Tipo
|
Type: Tipo
|
||||||
|
Created by: Creado por
|
|
@ -49,6 +49,10 @@ module.exports = Self => {
|
||||||
const provisionalName = params.provisionalName;
|
const provisionalName = params.provisionalName;
|
||||||
delete params.provisionalName;
|
delete params.provisionalName;
|
||||||
|
|
||||||
|
const itemType = await models.ItemType.findById(params.typeFk, myOptions);
|
||||||
|
|
||||||
|
params.isLaid = itemType.isLaid;
|
||||||
|
|
||||||
const item = await models.Item.create(params, myOptions);
|
const item = await models.Item.create(params, myOptions);
|
||||||
|
|
||||||
const typeTags = await models.ItemTypeTag.find({
|
const typeTags = await models.ItemTypeTag.find({
|
||||||
|
|
|
@ -15,6 +15,11 @@ describe('item new()', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
let item = await models.Item.new(itemParams, options);
|
let item = await models.Item.new(itemParams, options);
|
||||||
|
|
||||||
|
let itemType = await models.ItemType.findById(item.typeFk, options);
|
||||||
|
|
||||||
|
item.isLaid = itemType.isLaid;
|
||||||
|
|
||||||
const temporalNameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}}, options);
|
const temporalNameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}}, options);
|
||||||
|
|
||||||
const temporalName = await models.ItemTag.findOne({
|
const temporalName = await models.ItemTag.findOne({
|
||||||
|
@ -26,9 +31,14 @@ describe('item new()', () => {
|
||||||
|
|
||||||
item = await models.Item.findById(item.id, null, options);
|
item = await models.Item.findById(item.id, null, options);
|
||||||
|
|
||||||
|
itemType = await models.ItemType.findById(item.typeFk, options);
|
||||||
|
|
||||||
|
item.isLaid = itemType.isLaid;
|
||||||
|
|
||||||
expect(item.intrastatFk).toEqual(5080000);
|
expect(item.intrastatFk).toEqual(5080000);
|
||||||
expect(item.originFk).toEqual(1);
|
expect(item.originFk).toEqual(1);
|
||||||
expect(item.typeFk).toEqual(2);
|
expect(item.typeFk).toEqual(2);
|
||||||
|
expect(item.isLaid).toBeFalse();
|
||||||
expect(item.name).toEqual('planta');
|
expect(item.name).toEqual('planta');
|
||||||
expect(temporalName.value).toEqual('planta');
|
expect(temporalName.value).toEqual('planta');
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
},
|
},
|
||||||
"isUnconventionalSize": {
|
"isUnconventionalSize": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"isLaid": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -143,6 +143,9 @@
|
||||||
},
|
},
|
||||||
"packingShelve": {
|
"packingShelve": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"isLaid": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -53,7 +53,7 @@ module.exports = Self => {
|
||||||
JOIN client c ON c.id = o.customer_id
|
JOIN client c ON c.id = o.customer_id
|
||||||
JOIN address a ON a.id = o.address_id
|
JOIN address a ON a.id = o.address_id
|
||||||
JOIN agencyMode am ON am.id = o.agency_id
|
JOIN agencyMode am ON am.id = o.agency_id
|
||||||
JOIN user u ON u.id = c.salesPersonFk
|
JOIN account.user u ON u.id = c.salesPersonFk
|
||||||
JOIN workerTeamCollegues wtc ON c.salesPersonFk = wtc.collegueFk`);
|
JOIN workerTeamCollegues wtc ON c.salesPersonFk = wtc.collegueFk`);
|
||||||
|
|
||||||
if (!filter.where) filter.where = {};
|
if (!filter.where) filter.where = {};
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('sendSms', {
|
||||||
|
description: 'Sends a SMS to each client of the routes, each client only recieves the SMS once',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'destination',
|
||||||
|
type: 'string',
|
||||||
|
description: 'A comma separated string of destinations',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'message',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/sendSms`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.sendSms = async(ctx, destination, message) => {
|
||||||
|
const targetClients = destination.split(',');
|
||||||
|
|
||||||
|
const allSms = [];
|
||||||
|
for (let client of targetClients) {
|
||||||
|
let sms = await Self.app.models.Sms.send(ctx, client, message);
|
||||||
|
allSms.push(sms);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allSms;
|
||||||
|
};
|
||||||
|
};
|
|
@ -12,6 +12,7 @@ module.exports = Self => {
|
||||||
require('../methods/route/updateWorkCenter')(Self);
|
require('../methods/route/updateWorkCenter')(Self);
|
||||||
require('../methods/route/driverRoutePdf')(Self);
|
require('../methods/route/driverRoutePdf')(Self);
|
||||||
require('../methods/route/driverRouteEmail')(Self);
|
require('../methods/route/driverRouteEmail')(Self);
|
||||||
|
require('../methods/route/sendSms')(Self);
|
||||||
|
|
||||||
Self.validate('kmStart', validateDistance, {
|
Self.validate('kmStart', validateDistance, {
|
||||||
message: 'Distance must be lesser than 1000'
|
message: 'Distance must be lesser than 1000'
|
||||||
|
|
|
@ -20,6 +20,13 @@
|
||||||
translate>
|
translate>
|
||||||
Update volume
|
Update volume
|
||||||
</vn-item>
|
</vn-item>
|
||||||
|
<vn-item
|
||||||
|
ng-click="$ctrl.deleteCurrentRoute()"
|
||||||
|
vn-acl="deliveryBoss"
|
||||||
|
vn-acl-action="remove"
|
||||||
|
translate>
|
||||||
|
Delete route
|
||||||
|
</vn-item>
|
||||||
</slot-menu>
|
</slot-menu>
|
||||||
<slot-body>
|
<slot-body>
|
||||||
<div class="attributes">
|
<div class="attributes">
|
||||||
|
|
|
@ -34,6 +34,14 @@ class Controller extends Descriptor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteCurrentRoute() {
|
||||||
|
this.$http.delete(`Routes/${this.id}`)
|
||||||
|
.then(() => {
|
||||||
|
this.vnApp.showSuccess(this.$t('Route deleted'));
|
||||||
|
this.$state.go('route.index');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
loadData() {
|
loadData() {
|
||||||
const filter = {
|
const filter = {
|
||||||
fields: [
|
fields: [
|
||||||
|
|
|
@ -23,4 +23,20 @@ describe('vnRouteDescriptorPopover', () => {
|
||||||
expect(controller.route).toEqual(response);
|
expect(controller.route).toEqual(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('deleteCurrentRoute()', () => {
|
||||||
|
it(`should perform a delete query to delete the current route`, () => {
|
||||||
|
const id = 1;
|
||||||
|
|
||||||
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
|
controller._id = id;
|
||||||
|
$httpBackend.expectDELETE(`Routes/${id}`).respond(200);
|
||||||
|
controller.deleteCurrentRoute();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.route).toBeUndefined();
|
||||||
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Route deleted');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,4 +4,6 @@ Send route report: Enviar informe de ruta
|
||||||
Show route report: Ver informe de ruta
|
Show route report: Ver informe de ruta
|
||||||
Update volume: Actualizar volumen
|
Update volume: Actualizar volumen
|
||||||
Volume updated: Volumen actualizado
|
Volume updated: Volumen actualizado
|
||||||
|
Delete route: Borrar ruta
|
||||||
|
Route deleted: Ruta borrada
|
||||||
Are you sure you want to update the volume?: Estas seguro que quieres actualizar el volumen?
|
Are you sure you want to update the volume?: Estas seguro que quieres actualizar el volumen?
|
|
@ -15,3 +15,4 @@ import './agency-term/index';
|
||||||
import './agency-term/createInvoiceIn';
|
import './agency-term/createInvoiceIn';
|
||||||
import './agency-term-search-panel';
|
import './agency-term-search-panel';
|
||||||
import './ticket-popup';
|
import './ticket-popup';
|
||||||
|
import './sms';
|
||||||
|
|
|
@ -9,3 +9,5 @@ Go to route: Ir a la ruta
|
||||||
You must select a valid time: Debe seleccionar una hora válida
|
You must select a valid time: Debe seleccionar una hora válida
|
||||||
You must select a valid date: Debe seleccionar una fecha válida
|
You must select a valid date: Debe seleccionar una fecha válida
|
||||||
Mark as served: Marcar como servidas
|
Mark as served: Marcar como servidas
|
||||||
|
Retrieving data from the routes: Recuperando datos de las rutas
|
||||||
|
Send SMS to all clients: Mandar sms a todos los clientes de las rutas
|
|
@ -0,0 +1,36 @@
|
||||||
|
<vn-dialog
|
||||||
|
vn-id="SMSDialog"
|
||||||
|
on-accept="$ctrl.onResponse()"
|
||||||
|
message="Send SMS to the selected tickets">
|
||||||
|
<tpl-body>
|
||||||
|
<section class="SMSDialog">
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textarea vn-one
|
||||||
|
vn-id="message"
|
||||||
|
label="Message"
|
||||||
|
ng-model="$ctrl.sms.message"
|
||||||
|
info="Special characters like accents counts as a multiple"
|
||||||
|
rows="5"
|
||||||
|
required="true"
|
||||||
|
rule>
|
||||||
|
</vn-textarea>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<span>
|
||||||
|
{{'Characters remaining' | translate}}:
|
||||||
|
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{
|
||||||
|
'colored': $ctrl.charactersRemaining() > 25,
|
||||||
|
'warning': $ctrl.charactersRemaining() <= 25,
|
||||||
|
'alert': $ctrl.charactersRemaining() < 0,
|
||||||
|
}">
|
||||||
|
{{$ctrl.charactersRemaining()}}
|
||||||
|
</vn-chip>
|
||||||
|
</span>
|
||||||
|
</vn-horizontal>
|
||||||
|
</section>
|
||||||
|
</tpl-body>
|
||||||
|
<tpl-buttons>
|
||||||
|
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||||
|
<button response="accept" translate>Send</button>
|
||||||
|
</tpl-buttons>
|
||||||
|
</vn-dialog>
|
|
@ -0,0 +1,47 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import Component from 'core/lib/component';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
|
class Controller extends Component {
|
||||||
|
open() {
|
||||||
|
this.$.SMSDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
charactersRemaining() {
|
||||||
|
const element = this.$.message;
|
||||||
|
const value = element.input.value;
|
||||||
|
|
||||||
|
const maxLength = 160;
|
||||||
|
const textAreaLength = new Blob([value]).size;
|
||||||
|
return maxLength - textAreaLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
onResponse() {
|
||||||
|
try {
|
||||||
|
if (!this.sms.destination)
|
||||||
|
throw new Error(`The destination can't be empty`);
|
||||||
|
if (!this.sms.message)
|
||||||
|
throw new Error(`The message can't be empty`);
|
||||||
|
if (this.charactersRemaining() < 0)
|
||||||
|
throw new Error(`The message it's too long`);
|
||||||
|
|
||||||
|
this.$http.post(`Routes/sendSms`, this.sms).then(res => {
|
||||||
|
this.vnApp.showMessage(this.$t('SMS sent!'));
|
||||||
|
|
||||||
|
if (res.data) this.emit('send', {response: res.data});
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
this.vnApp.showError(this.$t(e.message));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngModule.vnComponent('vnRouteSms', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
sms: '<',
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,71 @@
|
||||||
|
import './index';
|
||||||
|
|
||||||
|
describe('Route', () => {
|
||||||
|
describe('Component vnRouteSms', () => {
|
||||||
|
let controller;
|
||||||
|
let $httpBackend;
|
||||||
|
|
||||||
|
beforeEach(ngModule('route'));
|
||||||
|
|
||||||
|
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
||||||
|
$httpBackend = _$httpBackend_;
|
||||||
|
let $scope = $rootScope.$new();
|
||||||
|
const $element = angular.element('<vn-dialog></vn-dialog>');
|
||||||
|
controller = $componentController('vnRouteSms', {$element, $scope});
|
||||||
|
controller.$.message = {
|
||||||
|
input: {
|
||||||
|
value: 'My SMS'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('onResponse()', () => {
|
||||||
|
it('should perform a POST query and show a success snackbar', () => {
|
||||||
|
let params = {destinationFk: 1101, destination: 111111111, message: 'My SMS'};
|
||||||
|
controller.sms = {destinationFk: 1101, destination: 111111111, message: 'My SMS'};
|
||||||
|
|
||||||
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
$httpBackend.expect('POST', `Routes/sendSms`, params).respond(200, params);
|
||||||
|
|
||||||
|
controller.onResponse();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call onResponse without the destination and show an error snackbar', () => {
|
||||||
|
controller.sms = {destinationFk: 1101, message: 'My SMS'};
|
||||||
|
|
||||||
|
jest.spyOn(controller.vnApp, 'showError');
|
||||||
|
|
||||||
|
controller.onResponse();
|
||||||
|
|
||||||
|
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call onResponse without the message and show an error snackbar', () => {
|
||||||
|
controller.sms = {destinationFk: 1101, destination: 222222222};
|
||||||
|
|
||||||
|
jest.spyOn(controller.vnApp, 'showError');
|
||||||
|
|
||||||
|
controller.onResponse();
|
||||||
|
|
||||||
|
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('charactersRemaining()', () => {
|
||||||
|
it('should return the characters remaining in a element', () => {
|
||||||
|
controller.$.message = {
|
||||||
|
input: {
|
||||||
|
value: 'My message 0€'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = controller.charactersRemaining();
|
||||||
|
|
||||||
|
expect(result).toEqual(145);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,9 @@
|
||||||
|
Send SMS to the selected tickets: Enviar SMS a los tickets seleccionados
|
||||||
|
Routes to notify: Rutas a notificar
|
||||||
|
Message: Mensaje
|
||||||
|
SMS sent!: ¡SMS enviado!
|
||||||
|
Characters remaining: Carácteres restantes
|
||||||
|
The destination can't be empty: El destinatario no puede estar vacio
|
||||||
|
The message can't be empty: El mensaje no puede estar vacio
|
||||||
|
The message it's too long: El mensaje es demasiado largo
|
||||||
|
Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios
|
|
@ -0,0 +1,5 @@
|
||||||
|
@import "variables";
|
||||||
|
|
||||||
|
.SMSDialog {
|
||||||
|
min-width: 400px
|
||||||
|
}
|
|
@ -29,13 +29,21 @@
|
||||||
disabled="!$ctrl.isChecked"
|
disabled="!$ctrl.isChecked"
|
||||||
ng-click="$ctrl.deletePriority()"
|
ng-click="$ctrl.deletePriority()"
|
||||||
vn-tooltip="Delete priority"
|
vn-tooltip="Delete priority"
|
||||||
icon="filter_alt_off">
|
icon="filter_alt">
|
||||||
</vn-button>
|
</vn-button>
|
||||||
<vn-button
|
<vn-button
|
||||||
ng-click="$ctrl.setOrderedPriority($ctrl.tickets)"
|
ng-click="$ctrl.setOrderedPriority($ctrl.tickets)"
|
||||||
vn-tooltip="Renumber all tickets in the order you see on the screen"
|
vn-tooltip="Renumber all tickets in the order you see on the screen"
|
||||||
icon="format_list_numbered">
|
icon="format_list_numbered">
|
||||||
</vn-button>
|
</vn-button>
|
||||||
|
<vn-button
|
||||||
|
vn-acl="deliveryBoss"
|
||||||
|
vn-acl-action="remove"
|
||||||
|
disabled="!$ctrl.isChecked"
|
||||||
|
icon="sms"
|
||||||
|
vn-tooltip="Send SMS to all clients"
|
||||||
|
ng-click="$ctrl.sendSms()">
|
||||||
|
</vn-button>
|
||||||
</vn-tool-bar>
|
</vn-tool-bar>
|
||||||
<vn-table class="vn-pt-md" model="model" auto-load="false" vn-droppable="$ctrl.onDrop($event)">
|
<vn-table class="vn-pt-md" model="model" auto-load="false" vn-droppable="$ctrl.onDrop($event)">
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
|
@ -149,19 +157,29 @@
|
||||||
route="$ctrl.$params"
|
route="$ctrl.$params"
|
||||||
parent-reload="$ctrl.$.model.refresh()">
|
parent-reload="$ctrl.$.model.refresh()">
|
||||||
</vn-route-ticket-popup>
|
</vn-route-ticket-popup>
|
||||||
|
<div fixed-bottom-right>
|
||||||
<vn-float-button
|
<vn-vertical style="align-items: center;">
|
||||||
icon="add"
|
<a vn-bind="+">
|
||||||
ng-click="$ctrl.$.ticketPopup.show()"
|
<vn-button
|
||||||
vn-tooltip="Add ticket"
|
class="round md vn-mb-sm"
|
||||||
vn-acl="delivery"
|
ng-click="$ctrl.$.ticketPopup.show()"
|
||||||
vn-acl-action="remove"
|
icon="add"
|
||||||
vn-bind="+"
|
vn-tooltip="Add ticket"
|
||||||
fixed-bottom-right>
|
vn-acl="delivery"
|
||||||
</vn-float-button>
|
vn-acl-action="remove"
|
||||||
|
tooltip-position="left">
|
||||||
|
</vn-button>
|
||||||
|
</a>
|
||||||
|
</vn-vertical>
|
||||||
|
</div>
|
||||||
<vn-ticket-descriptor-popover
|
<vn-ticket-descriptor-popover
|
||||||
vn-id="ticket-descriptor">
|
vn-id="ticket-descriptor">
|
||||||
</vn-ticket-descriptor-popover>
|
</vn-ticket-descriptor-popover>
|
||||||
<vn-client-descriptor-popover
|
<vn-client-descriptor-popover
|
||||||
vn-id="client-descriptor">
|
vn-id="client-descriptor">
|
||||||
</vn-client-descriptor-popover>
|
</vn-client-descriptor-popover>
|
||||||
|
<!-- SMS Dialog -->
|
||||||
|
<vn-route-sms
|
||||||
|
vn-id="sms"
|
||||||
|
sms="$ctrl.newSMS">
|
||||||
|
</vn-route-sms>
|
|
@ -161,6 +161,37 @@ class Controller extends Section {
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async sendSms() {
|
||||||
|
try {
|
||||||
|
const clientsFk = [];
|
||||||
|
const clientsName = [];
|
||||||
|
const clients = [];
|
||||||
|
|
||||||
|
const selectedTickets = this.getSelectedItems(this.$.$ctrl.tickets);
|
||||||
|
|
||||||
|
for (let ticket of selectedTickets) {
|
||||||
|
clientsFk.push(ticket.clientFk);
|
||||||
|
let userContact = await this.$http.get(`Clients/${ticket.clientFk}`);
|
||||||
|
clientsName.push(userContact.data.name);
|
||||||
|
clients.push(userContact.data.phone);
|
||||||
|
}
|
||||||
|
|
||||||
|
const destinationFk = String(clientsFk);
|
||||||
|
const destination = String(clients);
|
||||||
|
|
||||||
|
this.newSMS = Object.assign({
|
||||||
|
destinationFk: destinationFk,
|
||||||
|
destination: destination
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$.sms.open();
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
this.vnApp.showError(this.$t(e.message));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnRouteTickets', {
|
ngModule.vnComponent('vnRouteTickets', {
|
||||||
|
|
|
@ -89,7 +89,7 @@ class Controller extends Section {
|
||||||
getUsesMana() {
|
getUsesMana() {
|
||||||
this.$http.get(`Sales/usesMana`)
|
this.$http.get(`Sales/usesMana`)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.useMana = res.data;
|
this.usesMana = res.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,6 @@ describe('workerTimeControl sendMail()', () => {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(function() {
|
|
||||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
|
||||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should fill time control of a worker without records in Journey and with rest', async() => {
|
it('should fill time control of a worker without records in Journey and with rest', async() => {
|
||||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||||
|
|
||||||
|
@ -124,9 +119,5 @@ describe('workerTimeControl sendMail()', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(function() {
|
|
||||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<div>{{$t('clientId')}}: <strong>{{client.id}}</strong></div>
|
<div>{{$t('clientId')}}: <strong>{{client.id}}</strong></div>
|
||||||
<div>{{$t('user')}}: <strong>{{client.userName}}</strong></div>
|
<div>{{$t('user')}}: <strong>{{client.userName}}</strong></div>
|
||||||
<div>{{$t('password')}}: <strong>********</strong>
|
<div>{{$t('password')}}: <strong>********</strong>
|
||||||
(<a href="https://verdnatura.es">{{$t('passwordResetText')}}</a>)
|
(<a href="https://shop.verdnatura.es">{{$t('passwordResetText')}}</a>)
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
subject: Bienvenido a Verdnatura
|
subject: Bienvenido a Verdnatura
|
||||||
title: "¡Te damos la bienvenida!"
|
title: "¡Te damos la bienvenida!"
|
||||||
dearClient: Estimado cliente
|
dearClient: Estimado cliente
|
||||||
clientData: 'Tus datos para poder comprar en la web de Verdnatura (<a href="https://verdnatura.es"
|
clientData: 'Tus datos para poder comprar en la web de Verdnatura (<a href="https://shop.verdnatura.es"
|
||||||
title="Visitar Verdnatura" target="_blank" style="color: #8dba25">https://verdnatura.es</a>)
|
title="Visitar Verdnatura" target="_blank" style="color: #8dba25">https://shop.verdnatura.es</a>)
|
||||||
o en nuestras aplicaciones para <a href="https://goo.gl/3hC2mG" title="App Store"
|
o en nuestras aplicaciones para <a href="https://goo.gl/3hC2mG" title="App Store"
|
||||||
target="_blank" style="color: #8dba25">iOS</a> y <a href="https://goo.gl/8obvLc"
|
target="_blank" style="color: #8dba25">iOS</a> y <a href="https://goo.gl/8obvLc"
|
||||||
title="Google Play" target="_blank" style="color: #8dba25">Android</a>, son'
|
title="Google Play" target="_blank" style="color: #8dba25">Android</a>, son'
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const vnPrintPath = path.resolve('print');
|
||||||
|
|
||||||
|
module.exports = new Stylesheet([
|
||||||
|
`${vnPrintPath}/common/css/spacing.css`,
|
||||||
|
`${vnPrintPath}/common/css/misc.css`,
|
||||||
|
`${vnPrintPath}/common/css/layout.css`,
|
||||||
|
`${vnPrintPath}/common/css/email.css`])
|
||||||
|
.mergeStyles();
|
|
@ -0,0 +1,6 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filename": "vehicle-event-expired.pdf",
|
||||||
|
"component": "vehicle-event-expired"
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1,3 @@
|
||||||
|
subject: Expiración Tarjetas Vehículos
|
||||||
|
title: Expiración Tarjetas Vehículos
|
||||||
|
description: A continuación se adjunta el informe de expiración de tarjetas vehículos
|
|
@ -0,0 +1,8 @@
|
||||||
|
<email-body v-bind="$props">
|
||||||
|
<div class="grid-row">
|
||||||
|
<div class="grid-block vn-pa-ml">
|
||||||
|
<h1>{{ $t('title') }}</h1>
|
||||||
|
<p v-html="$t('description')"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</email-body>
|
|
@ -0,0 +1,9 @@
|
||||||
|
const Component = require(`vn-print/core/component`);
|
||||||
|
const emailBody = new Component('email-body');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'vehicle-event-expired',
|
||||||
|
components: {
|
||||||
|
'email-body': emailBody.build()
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,9 +1,12 @@
|
||||||
const Stylesheet = require(`${appPath}/core/stylesheet`);
|
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const vnPrintPath = path.resolve('print');
|
||||||
|
|
||||||
module.exports = new Stylesheet([
|
module.exports = new Stylesheet([
|
||||||
`${appPath}/common/css/spacing.css`,
|
`${vnPrintPath}/common/css/spacing.css`,
|
||||||
`${appPath}/common/css/misc.css`,
|
`${vnPrintPath}/common/css/misc.css`,
|
||||||
`${appPath}/common/css/layout.css`,
|
`${vnPrintPath}/common/css/layout.css`,
|
||||||
`${appPath}/common/css/report.css`,
|
`${vnPrintPath}/common/css/report.css`,
|
||||||
`${__dirname}/style.css`])
|
`${__dirname}/style.css`])
|
||||||
.mergeStyles();
|
.mergeStyles();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const Component = require(`${appPath}/core/component`);
|
const Component = require(`vn-print/core/component`);
|
||||||
const reportBody = new Component('report-body');
|
const reportBody = new Component('report-body');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const Component = require(`${appPath}/core/component`);
|
const Component = require(`vn-print/core/component`);
|
||||||
const reportBody = new Component('report-body');
|
const reportBody = new Component('report-body');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
Loading…
Reference in New Issue