diff --git a/routes/acl.js b/routes/acl.js index f650813..13c3844 100644 --- a/routes/acl.js +++ b/routes/acl.js @@ -196,7 +196,7 @@ router.get('/bulk-add', async (req, res) => { // Render form to bulk add ACL ent router.post('/bulk-add', async (req, res) => { // Process bulk add of ACL entries - const data = req.body; + const data = req.body.credentials; if (!Array.isArray(data)) { return res.status(400).json({ error: 'Invalid data format' }); } diff --git a/views/acl-bulk-add.ejs b/views/acl-bulk-add.ejs index 4355f2d..3b0bc72 100644 --- a/views/acl-bulk-add.ejs +++ b/views/acl-bulk-add.ejs @@ -145,26 +145,20 @@ rows.forEach(tr => { const selected = tr.querySelector('input[type="checkbox"]'); if (selected && selected.checked) { - const cardNumber = tr.children[1].textContent; - const controller = tr.children[2].textContent; - const door = tr.children[3].textContent; - const timestamp = tr.children[4].textContent; - const name = tr.querySelector('input[name="name"]').value; - const startDate = tr.querySelectorAll('input[type="date"]')[0].value; - const endDate = tr.querySelectorAll('input[type="date"]')[1].value; - const allowedDoors = []; + const CardNumber = tr.children[1].textContent; + const Name = tr.querySelector('input[name="name"]').value; + const StartDate = tr.querySelectorAll('input[type="date"]')[0].value; + const EndDate = tr.querySelectorAll('input[type="date"]')[1].value; + const Doors = []; tr.children[8].querySelectorAll('input[type="checkbox"]').forEach(cb => { - if (cb.checked) allowedDoors.push(cb.name); + if (cb.checked) Doors.push(cb.name); }); credentials.push({ - cardNumber, - controller, - door, - timestamp, - name, - startDate, - endDate, - allowedDoors + CardNumber, + Name, + StartDate, + EndDate, + Doors }); } });