+9
-1
@@ -151,7 +151,15 @@ router.get('/', verifyToken, requireApprovalStep('man_power:entry', 'view'), asy
|
||||
docs.forEach(d => { d.tabCounts = byDoc[d.docEntry] || {}; d.totalRows = Object.values(d.tabCounts).reduce((a, b) => a + b, 0); });
|
||||
} catch (e) { console.warn('[MANPOWER] tab counts failed (non-fatal):', e.message); }
|
||||
}
|
||||
res.json({ success: true, data: docs });
|
||||
// Genuine total (same filter, no paging) — drives "Page X of Y" on the
|
||||
// client instead of an open-ended "Page X".
|
||||
let total = null;
|
||||
try {
|
||||
const c = await sap().sapRequest('GET', `Production_Data/$count${filter ? '?' + filter.slice(1) : ''}`, null, co);
|
||||
const n = Number(c);
|
||||
if (!isNaN(n)) total = n;
|
||||
} catch (e) { console.warn('[MANPOWER] $count failed — pager will show no total:', e.message); }
|
||||
res.json({ success: true, data: docs, total });
|
||||
} catch (err) { res.status(500).json({ success: false, message: err.message }); }
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user