diff --git a/bindTicketShelving2.js b/bindTicketShelving2.js new file mode 100644 index 0000000..bee126e --- /dev/null +++ b/bindTicketShelving2.js @@ -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); \ No newline at end of file diff --git a/db/create.js b/db/create.js index 19dd64d..1c87e0b 100644 --- a/db/create.js +++ b/db/create.js @@ -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"); diff --git a/db/selectDB.js b/db/selectDB.js new file mode 100644 index 0000000..3b8f653 --- /dev/null +++ b/db/selectDB.js @@ -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; +