This commit is contained in:
llopis15 2021-03-12 16:26:02 +01:00
parent 89e3a1b465
commit edc9ae4915
3 changed files with 45 additions and 1 deletions

21
bindTicketShelving2.js Normal file
View File

@ -0,0 +1,21 @@
const insert = require('./insertTicket');
const filter = require('./filter');
const select = require('./db/selectDB')
var barcode = "A0A3B820690F";
var shelving = "ABC";///introducida por el usuario
var collectionFk = '254';
function ticketCollection(collectionFk){//parametro collectionFk
let consultaSql = select.select(collectionFk)
if(filter.filterShelving(shelving)){
insert.insertTicket(consultaSql, shelving)
}
else{
console.log("¡MATRICULA INCORRECTA!")
}
}
ticketCollection(collectionFk, shelving);

View File

@ -3,7 +3,7 @@ const con = require('./connect.js')
con.con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
var sql = "CREATE TABLE customers (code VARCHAR(100) PRIMARY KEY, shelvingFk VARCHAR(10) FOREIGN KEY REFERENCES shelving(code), level INT(11))";
var sql = "CREATE TABLE smartTag2 (code VARCHAR(100) PRIMARY KEY, shelvingFk VARCHAR(10) FOREIGN KEY REFERENCES vn.shelving(code), level INT(11))";
con.con.query(sql, function (err, result) {
if (err) throw err;
console.log("Table created");

23
db/selectDB.js Normal file
View File

@ -0,0 +1,23 @@
const con = require('./connect')
//ticket
//cliente
//agencia
function select(collectionFk){
con.con.connect(function(err) {
let consSql = `SELECT t.id, t.clientFk, am.name
FROM ticketCollection tc
JOIN ticket t ON t.id = tc.ticketFk
JOIN agencyMode am ON am.id = t.agencyModeFk
WHERE tc.collectionFk = ${collectionFk}`;
if (err) throw err;
con.con.query(consSql, function (err, result, fields) {
if (err) throw err;
console.log(result);
});
});
}
exports.select = select;