This commit is contained in:
Vicente Falco 2017-07-06 11:31:26 +02:00
commit a7af81383b
9 changed files with 270 additions and 154 deletions

View File

@ -26,7 +26,7 @@
on-change = "$ctrl.onChangeWareHouse(item)"
label="Store">
</vn-autocomplete>
<vn-icon-button vn-none pad-ten-top icon="refresh" ng-click="$ctrl.refreshTickets()"></vn-icon-button>
<vn-icon-button vn-none pad-ten-top margin-small-left icon="refresh" ng-click="$ctrl.refreshTickets()"></vn-icon-button>
</vn-one>
</vn-horizontal>
<vn-horizontal vn-one margin-large-bottom>

View File

@ -1,6 +1,7 @@
{
"Finder" : "Localizador",
"Error: No tickets selected!" : "Error: ¡No hay tickets seleccionados!",
"Error: Action not implemented!" : "Error: ¡Acción no implementada!",
"State" : "Estado",
"Alarm" : "Alarma",
"Agencies": "Agencias",

View File

@ -65,6 +65,18 @@ export default class ProductionActions {
}
);
}
_changeWorker(ids, workerFk, index) {
this.$http.put(`/production/api/Tickets/${workerFk}/changeWorker`, {tickets: ids}).then(
() => {
index.forEach(
i => {
this.tickets[i].workerFk = this.actionWorker.id;
this.tickets[i].worker = this.actionWorker.name;
}
);
}
);
}
doAction(actionName) {
let ids = [];
@ -93,8 +105,11 @@ export default class ProductionActions {
case 'changeTime':
this._changeTime(ids, this.actionHours.name, index);
break;
case 'changeWorker':
this._changeWorker(ids, this.actionWorker.id, index);
break;
default:
this.vnApp.showMessage(this.$translate.instant('Error: No jet implemented!'));
this.vnApp.showMessage(this.$translate.instant('Error: Action not implemented!'));
}
} else {
this.vnApp.showMessage(this.$translate.instant('Error: No tickets selected!'));

View File

@ -0,0 +1,27 @@
var express = require('express');
var router = new express.Router();
var mail = require('../mail.js');
var database = require('../database.js');
var template = require('../template.js');
// Escrito de cambios en méto de pago del cliente
router.post('/:userId/payment-update', function(request, response, next) {
database.pool.query('SELECT `e-mail` AS email, LOWER(p.Codigo) AS countryCode FROM Clientes AS c JOIN Paises AS p ON p.id = c.Id_Pais WHERE Id_Cliente = ?', [request.params.userId], function(error, qryRs) {
if (qryRs.length == 0)
return response.json({data: {message: 'Client not found'}});
template.getTemplate('payment-update', qryRs[0].countryCode, {userId: request.params.userId}, function(tplRs, error) {
if (error)
return response.json({data: {message: error}});
mail.send(qryRs[0].email, tplRs.subject, tplRs.body, tplRs.attachments, (mailrs, error) => {
if (error)
return response.json({data: {message: error}});
return response.json({data: {message: 'Mail sent'}});
});
});
});
});
module.exports = router;

View File

@ -0,0 +1,28 @@
var express = require('express');
var router = new express.Router();
var mail = require('../mail.js');
var database = require('../database.js');
var template = require('../template.js');
router.get('/:userId/notice', function(request, response) {
database.pool.query('SELECT `e-mail` AS email, LOWER(p.Codigo) AS countryCode FROM Clientes AS c JOIN Paises AS p ON p.id = c.Id_Pais WHERE Id_Cliente = ?', [request.params.userId], function(error, qryRs) {
if (qryRs.length == 0)
return response.json({data: {message: 'Client not found'}});
template.getTemplate('notice', qryRs[0].countryCode, {userId: request.params.userId}, function(tplRs, error) {
if (error)
return response.json({data: {message: error}});
mail.send(qryRs[0].email, tplRs.subject, tplRs.body, tplRs.attachments, (mailrs, error) => {
if (error)
return response.json({data: {message: error}});
return response.json({data: {message: 'Mail sent'}});
});
});
});
response.send(request.params.userid);
});
module.exports = router;

View File

@ -0,0 +1,35 @@
let database = require('../database.js');
module.exports = {
/**
* Devuelve el iban
* @param {String} addressNumber - Dirección de cuenta bancaria
* @param {Object} cb - Callback
*/
accountAddressIban: function(addressNumber, cb) {
database.pool.query('SELECT vn2008.cc_to_iban(?) AS iban', [addressNumber], function(error, result) {
cb(result[0].iban);
});
},
/**
* Obtiene el numero de cuenta completo incluyendo iban
* @param {String} addressNumber - Dirección de cuenta bancaria
* @return {String} Cuenta bancaria formateada
*/
accountAddress: function(addressNumber) {
var formattedAccountAddress = addressNumber.replace(/(.{4})/g, '$1-');
return formattedAccountAddress.substring(0, formattedAccountAddress.length - 1);
},
/**
* Devuelve el numero de cuenta mostrando únicamente los últimos 4 dígitos.
* @param {String} addressNumber - Dirección de cuenta bancaria
* @return {String} Cuenta bancaria formateada
*/
partialAccountAddress: function(addressNumber) {
let address = this.accountAddress(addressNumber);
return address.substring(0, 19).replace(/[0-9]/g, 'X') + address.substring(19, 24);
}
};

View File

@ -0,0 +1,10 @@
module.exports = {
/**
* Obtiene las variables de entorno
* @param {String} env - Nombre de la variable de entorno
* @return {String} Valor de la variable de entorno
*/
getEnv: function(env) {
return process.env[env];
}
};