Koha Solutions knowledge base: run log of a live check Article https://kohasolutions.com/knowledge-base/koha-slip-printer-setup Check scripts/kb/live/koha-slip-printer-setup.mjs (SHA-256 92a2afbab124d16deec1dbe76ac1d430c813b6b5a06e333370b067a5927e37c4) Ran 2026-11-08T07:03:38Z (UTC), 220 s Koha 26.05.02 (Koha::version 26.05.02.002, database version 26.0600002) Source https://git.koha-community.org/Koha-community/Koha/src/commit/d3fc229bc5eaea25dfe88f86149386408fe5d32d System Debian GNU/Linux 13 (trixie) Result PASS: all 51 claims held Each claim is something the article says. "seen" is what the check read back when it is not just a yes/no. Changes the check made to the test server were undone afterwards, as its header describes. == Claims == ok the article shows exactly the stylesheet this check tests (SLIP_CSS) ok the article shows exactly the IntranetSlipPrinterJS value this check tests (SLIP_JS) ok precondition: no KBVSLIP1 item and no /local-slips folder ok (set-up) KBVSLIP1 checked out to the fixture patron seen: issued ok SlipCSS and NoticeCSS are gone in 26.05; PrintSlipStylesheet, PrintSlipCSS and EmailNoticeStylesheet exist (renamed in 25.12, db_revs/251200046.pl) seen: EmailNoticeStylesheet,PrintSlipCSS,PrintSlipStylesheet ok the patron's Print menu offers "Print summary", "Print slip", "Print quick slip" seen: Print summary | Print slip | Print quick slip | Print checkin slip ok "Print quick slip" opens members/printslip.pl?…print=issueqslip in a new window seen: http://localhost:8081/cgi-bin/koha/members/printslip.pl?borrowernumber=3699&print=issueqslip ok …the quick slip lists today's checkout (KBVSLIP1) seen: Centerville Checked out to Reset Test (KBRESET1) 11/08/2026 07:03 Checked out today Kbverify slip test Barcode: KBVSLIP1 Date due: 11/13/2026 23:59 ok …and, with IntranetSlipPrinterJS empty, Koha calls window.print() once on load (the browser's print dialog) seen: 1 ok …and closes the window after printing (onafterprint → window.close()) ok the shipped ISSUEQSLIP has only an Email panel (message_transport_type email), and the quick slip above printed from it seen: email ok …a Print panel added to ISSUEQSLIP is ignored: the quick slip still prints the Email panel seen: Centerville Checked out to Reset Test (KBRESET1) 11/08/2026 07:03 Checked out today Kbverify slip test Barcode: KBVSLIP1 Date due: 11/13/2026 23:59 ok CircAutoPrintQuickSlip = "qslip": Enter on an empty barcode opens printslip.pl …print=issueqslip seen: http://localhost:8081/cgi-bin/koha/members/printslip.pl?borrowernumber=3699&print=issueqslip ok CircAutoPrintQuickSlip = "slip": Enter on an empty barcode opens printslip.pl …print=issueslip seen: http://localhost:8081/cgi-bin/koha/members/printslip.pl?borrowernumber=3699&print=issueslip ok CircAutoPrintQuickSlip = "clear": no window, the checkout screen is cleared (circulation.pl without the patron) seen: no window | http://localhost:8081/cgi-bin/koha/circ/circulation.pl ok CircAutoPrintQuickSlip = "ignore": nothing happens seen: no window | http://localhost:8081/cgi-bin/koha/circ/circulation.pl?borrowernumber=3699 ok System preferences wording: "When an empty barcode field is submitted in circulation" … "open a print quick slip window" seen: clear the screen, do nothing, open a print quick slip window, open a print slip window | When an empty barcode field is submitted in circulation | clear the screen | do nothing | open a print quick slip windo ok IntranetSlipPrinterJS = the article's value: the slip window prints once and stays open after printing seen: 1 prints, closed false ok IntranetSlipPrinterJS with code that never calls window.print(): Koha no longer prints at all seen: 0 ok PrintSlipCSS does NOT reach a printed slip in 26.05 (its text is not in the slip page) seen: false ok …nor does AllNoticeCSS or PrintNoticeCSS (they are added to queued print/email notices, not to slips) ok …though the notice editor shows PrintSlipCSS under "Print slip CSS", "CSS to be applied to print slips in addition to that already in \"All notice CSS\"." ok the notice's own CSS (Format tab) is on the slip, but every selector gets "#slip_issueqslip" in front: "p {" becomes "#slip_issueqslip p {" seen: #slip_issueqslip @page { size: 80mm 200mm; margin: 0; }#slip_issueqslip p { font-size: 11px; } ok …which turns "@page {" into "#slip_issueqslip @page {", so a page size there is ignored seen: #slip_issueqslip @page { size: 80mm 200mm; margin: 0; }#slip_issueqslip p { font-size: 11px; } ok …measured: printed to PDF, the page is still the default paper (612 pts = Letter), not 80 mm seen: Page size: 612 x 792 pts (letter) ok a slip with no slip CSS prints on the browser's default paper (Letter, 612 pts, in this Chromium; your printer's paper on a desk PC) seen: Page size: 612 x 792 pts (letter) ok the stylesheet file is served by the staff site: curl -sI /local-slips/slip-80mm.css → 200, text/css seen: HTTP/1.1 200 OK Content-Type: text/css ok System preferences: "Include the stylesheet at … on print slips." and the button "Save all Tools preferences" seen: PrintSlipStylesheet | Tools preferences | Notices and slips | View all Notices and slips preferences | Preference | | Value | PrintSlipStylesheet | Include the stylesheet at on print slips. (Th ok entering /local-slips/slip-80mm.css and clicking "Save all Tools preferences" stores it ok PrintSlipStylesheet = /local-slips/slip-80mm.css: the slip page links it () ok …measured: printed to PDF, the page is 80 mm wide by 200 mm (227 x 567 pts; 80 mm = 226.8 pts, Chromium rounds to whole pixels) seen: Page size: 227.04 x 567.12 pts ok …and the slip text is all on the 80 mm page (the barcode and title are in the PDF text) seen: Centerville Checked out to Reset Test (KBRESET1) 11/08/2026 07:04 Checked out today Kbverify slip test Barcode: KBVSLIP1 Date due: 11/13/2026 23:59 ok "size: 80mm auto" (the common web recipe) is ignored: the page falls back to the default paper (612 pts) seen: Page size: 612 x 792 pts (letter) ok …the same link is on the full checkout slip ("Print slip") seen: http://localhost:8081/cgi-bin/koha/members/printslip.pl?borrowernumber=3699&print=issueslip 24657 ok …and on the transfer slip (circ/transfer-slip.pl, the same circ/printslip.tt page) ok a fee receipt (members/printinvoice.pl, notice ACCOUNT_DEBIT) does NOT load PrintSlipStylesheet seen: true false ok …but its notice CSS is used as written (not prefixed): @page there prints the fee receipt 80 mm wide seen: Page size: 227.04 x 567.12 pts ok server: the box starts with Koha installed ok server: sudo mkdir -p /usr/share/koha/intranet/htdocs/local-slips prints nothing seen: exit=0 ok server: ls …/local-slips → "slip-80mm.css" seen: slip-80mm.css ok server: the file holds exactly the article's stylesheet seen: b89b63d5bec49d0f4f86c1dc55b8f42f1e56e53133e2f82c69aec55f73b43775 ok server: the staff site (port 8080) serves it: "HTTP/1.1 200 OK" / "Content-Type: text/css" seen: HTTP/1.1 200 OK Content-Type: text/css ok server: dpkg -S …/local-slips → "dpkg-query: no path found matching pattern …" (an upgrade leaves it); Koha's own print.css belongs to koha-common seen: dpkg-query: no path found matching pattern /usr/share/koha/intranet/htdocs/local-slips koha-common: /usr/share/koha/intranet/htdocs/intranet-tmpl/prog/css/print.css ok server: undo, sudo rm -r …/local-slips, prints nothing and the folder is gone seen: exit=0 ls: cannot access '/usr/share/koha/intranet/htdocs/local-slips': No such file or directory ok (box) systemctl is-active cups → active seen: active ok (box, set-up only: a stand-in queue, not shown) lpadmin adds a printer named Receipt80 seen: exit 0 lpadmin: Raw queues are deprecated and will stop working in a future version of CUPS. ok (box) lpstat -p lists the printer: "printer Receipt80 is idle. enabled since …" seen: printer Receipt80 is idle. enabled since Sun Nov 8 07:06:35 2026 ok (box) lpoptions -d Receipt80 makes it the default and prints its options (copies=1 device-uri=… printer-info=Receipt80 …) seen: copies=1 device-uri=socket://192.0.2.50:9100 finishings=3 job-cancel-after=10800 job-hold-until=no-hold job-priority=50 job-sheets=none,none marker-change-time=0 number-up=1 print-color-mode=monochrome printer-info=Receipt80 printer-is-accepting-jobs=true printer-is-shared=true printer-is-temporary=false printer-location printer-make-and-model='Local Raw Printer' printer-state=3 printer-state-change-time=1794121595 printer-state-reasons=none printer-type=4 printer-uri-supported=ipp://localhost/printers/Receipt80 ok (box) lpstat -d → "system default destination: Receipt80" seen: system default destination: Receipt80 ok (box) lpadmin -x Receipt80 removes it again seen: exit 0 no system default destination ok (box) Ubuntu 24.04 with CUPS seen: PRETTY_NAME="Ubuntu 24.04.5 LTS" cups 2.4.7-1.2ubuntu7.14 == The check that produced this log (scripts/kb/live/koha-slip-printer-setup.mjs) == /** * Live check for prisma/ks-kb/115-koha-slip-printer-setup.ts (plan209 row 1, written 2026-11-07). * * On live Koha 26.05.02: * 1. A record "Kbverify slip test" with item KBVSLIP1, checked out to the fixture patron. * 2. The patron's Print menu (Print slip / Print quick slip / Print checkin slip …) opens members/printslip.pl in a * new window, which calls window.print() on load and closes after printing (slip-print.inc). * 3. CircAutoPrintQuickSlip: an empty barcode on the checkout screen opens the quick slip (qslip), the full slip * (slip), clears the screen (clear) or does nothing (ignore). * 4. IntranetSlipPrinterJS replaces Koha's own window.print(): with the article's value the window prints and stays * open; with a value that never calls window.print(), nothing prints. * 5. Where slip CSS reaches a slip: PrintSlipStylesheet (a file, linked on every circ/printslip.tt slip) does; the * notice's own Format CSS does, but every selector is prefixed with #slip_, which breaks @page; PrintSlipCSS * and AllNoticeCSS do NOT reach a printed slip in 26.05 (shown only in the notice editor). Payment receipts * (printfeercpt / printinvoice) do not load PrintSlipStylesheet, and use the notice CSS unscoped. * 6. The same quick slip printed by Chromium to PDF with no slip CSS (the printer's default paper: Letter here) and * with the article's 80 mm stylesheet: pdfinfo page size 226.77 pts wide = 80 mm. KBV_SHOTS= keeps the PDFs * and screenshots. * In a throwaway kbv-systemd-ubuntu:24.04 box (systemd): CUPS installed and a stand-in queue Receipt80 added (set-up, * not shown: a real thermal printer is added with its maker's driver); then the article's Linux desk PC commands: * lpstat -p, lpoptions -d, lpstat -d (ran_on; a desk PC, so it stays a local box). On a real server (plan212, * 2026-11-08; was a throwaway kbv-koha-ubuntu:24.04 box on 2026-11-07): the local-slips folder and file as the sudo * user over SSH, the staff vhost serving it, dpkg -S, and the undo (serverPart). * Undone: slip prefs, the ISSUEQSLIP / ACCOUNT_DEBIT notice CSS, the /local-slips folder, the loan, the debit, the * record and item; the Ubuntu box and the server box are removed. */ import { spawnSync } from 'node:child_process' import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { createHash } from 'node:crypto' import { annotate } from '../annotate.mjs' import { createBox, ensureKohaImage, KOHA_IMAGE, removeBox, ssh } from './server-box/box.mjs' export const meta = { koha: '26.05.02', passed: '2026-11-07' } const BC = 'KBVSLIP1' const TITLE = 'Kbverify slip test' const WEBROOT = '/kohadevbox/koha/koha-tmpl' // live Koha's staff DocumentRoot; /usr/share/koha/intranet/htdocs on a package install const SHOTS = process.env.KBV_SHOTS const BOX = 'kbv-209-cups' const SYSTEMD_IMG = 'kbv-systemd-ubuntu:24.04' /** The slip stylesheet the article shows (the check tests this exact text). */ export const SLIP_CSS = `/* Slips on an 80 mm receipt roll */ @page { size: 80mm 200mm; margin: 0; } body { margin: 0; padding: 3mm 4mm; font-size: 12px; } #receipt table { width: 100%; } ` /** The article's IntranetSlipPrinterJS value: print, but keep the window open. */ export const SLIP_JS = `window.addEventListener('load', function () { window.print(); });` const ARTICLE = new URL('../../../prisma/ks-kb/115-koha-slip-printer-setup.ts', import.meta.url) export default async function run(ctx) { const I = ctx.INSTANCE const host = (cmd, args, opts = {}) => spawnSync(cmd, args, { encoding: 'utf8', timeout: 900000, ...opts }) const out = SHOTS ?? mkdtempSync(join(tmpdir(), 'kbv-slip-')) mkdirSync(out, { recursive: true }) const art = (() => { try { return readFileSync(ARTICLE, 'utf8') } catch { return '' } })() ctx.check('the article shows exactly the stylesheet this check tests (SLIP_CSS)', art.includes(JSON.stringify(SLIP_CSS).slice(1, -1)) || art.includes(SLIP_CSS)) ctx.check('the article shows exactly the IntranetSlipPrinterJS value this check tests (SLIP_JS)', art.includes(JSON.stringify(SLIP_JS).slice(1, -1)) || art.includes(SLIP_JS)) // ------------------------------------------------------------------ set-up const pid = ctx.patron() const perl = (code) => { ctx.sh(`cat > /tmp/kbv-slip.pl <<'PL'\n${code}\nPL\nchmod 644 /tmp/kbv-slip.pl`) return ctx.sh(`koha-shell ${I} -c "perl /tmp/kbv-slip.pl" 2>&1; rm -f /tmp/kbv-slip.pl`).out.trim().split('\n').pop() } const env = "use C4::Context; use Koha::Patrons; C4::Context->set_userenv(51, 'koha', '', 'Koha', 'Admin', 'CPL', 'CPL', 1);" ctx.check('precondition: no KBVSLIP1 item and no /local-slips folder', !ctx.sqlValue(`SELECT itemnumber FROM items WHERE barcode = '${BC}'`) && ctx.sh(`test -e ${WEBROOT}/local-slips`).code !== 0) const firstLine = Number(ctx.sqlValue('SELECT COALESCE(MAX(accountlines_id), 0) FROM accountlines')) const bn = Number(perl(`use C4::Biblio qw(AddBiblio); use MARC::Record; my $r = MARC::Record->new; $r->leader(' nam a22 7a 4500'); $r->append_fields(MARC::Field->new('245','1','0','a'=>'${TITLE}')); my ($bn) = AddBiblio($r, ''); Koha::Item->new({ biblionumber => $bn, homebranch => 'CPL', holdingbranch => 'CPL', barcode => '${BC}', itype => 'BK' })->store; print "$bn\\n";`)) ctx.restore('return the loan; delete the debit, the Kbverify record and item', () => { perl(`${env} use C4::Circulation qw(AddReturn); AddReturn('${BC}', 'CPL'); print "ok\\n";`) ctx.sql(`DELETE FROM account_offsets WHERE debit_id > ${firstLine} OR credit_id > ${firstLine}`) ctx.sql(`DELETE FROM accountlines WHERE accountlines_id > ${firstLine} AND borrowernumber = ${pid}`) perl(`use C4::Biblio qw(DelBiblio); my $b = Koha::Biblios->find(${bn}); $_->delete for $b ? $b->items->as_list : (); DelBiblio(${bn}); print "ok\\n";`) }) const issued = perl(`${env} use C4::Circulation qw(AddIssue); my $c = AddIssue(Koha::Patrons->find(${pid}), '${BC}'); print $c ? "issued\\n" : "no\\n";`) ctx.check('(set-up) KBVSLIP1 checked out to the fixture patron', issued === 'issued', issued) const itemnumber = ctx.sqlValue(`SELECT itemnumber FROM items WHERE barcode = '${BC}'`) for (const p of ['CircAutoPrintQuickSlip', 'IntranetSlipPrinterJS', 'PrintSlipStylesheet', 'PrintSlipCSS', 'AllNoticeCSS', 'PrintNoticeCSS']) ctx.setPref(p, ctx.sqlValue(`SELECT value FROM systempreferences WHERE variable = '${p}'`) ?? '') // snapshot → restored const prefs = ctx.sql("SELECT variable, value FROM systempreferences WHERE variable IN ('SlipCSS','NoticeCSS','PrintSlipStylesheet','PrintSlipCSS','EmailNoticeStylesheet')").map((r) => r[0]).sort() ctx.check('SlipCSS and NoticeCSS are gone in 26.05; PrintSlipStylesheet, PrintSlipCSS and EmailNoticeStylesheet exist (renamed in 25.12, db_revs/251200046.pl)', prefs.join(',') === 'EmailNoticeStylesheet,PrintSlipCSS,PrintSlipStylesheet', prefs.join(',')) // Each window gets window.print() replaced by a counter, so a headless run can see whether Koha asked to print. const staffCtxPage = async () => { const page = await ctx.newPage({ viewport: { width: 1280, height: 900 }, deviceScaleFactor: 1.5 }) await page.context().addInitScript(() => { window.__kbvPrints = 0 window.print = () => { window.__kbvPrints++ } }) await ctx.staffLogin(page) return page } const staff = await staffCtxPage() const circ = `${ctx.STAFF}/cgi-bin/koha/circ/circulation.pl?borrowernumber=${pid}` /** Run `act`, return the popup window it opened (or null) after it loaded. */ const popupOf = async (act, ms = 6000) => { const p = staff.context().waitForEvent('page', { timeout: ms }).catch(() => null) await act() const w = await p if (w) await w.waitForLoadState('load').catch(() => {}) if (w) await w.waitForTimeout(500) return w } const prints = (w) => (w && !w.isClosed() ? w.evaluate(() => window.__kbvPrints).catch(() => -1) : Promise.resolve(-1)) // ------------------------------------------------------------------ 2. the Print menu await staff.goto(circ) await staff.locator('button:has-text("Print")').first().click() const menu = (await staff.locator('.dropdown-menu.show a').allInnerTexts()).map((s) => s.trim()) ctx.check('the patron\'s Print menu offers "Print summary", "Print slip", "Print quick slip"', ['Print summary', 'Print slip', 'Print quick slip'].every((m) => menu.includes(m)), menu.join(' | ')) if (SHOTS) { await annotate(staff, ['box|.dropdown-menu.show a[data-code="issueqslip"]']) const b = await staff.locator('.dropdown-menu.show').boundingBox() await staff.screenshot({ path: join(SHOTS, 'print-menu.png'), clip: { x: Math.max(0, b.x - 30), y: Math.max(0, b.y - 60), width: 560, height: b.height + 90 } }) await staff.evaluate(() => document.querySelectorAll('[data-kb-annotations]').forEach((e) => e.remove())) } let closedAfterPrint = false const qs = await popupOf(() => staff.locator('.dropdown-menu.show a[data-code="issueqslip"]').click()) const qsUrl = qs?.url() ?? '' const qsText = qs ? await qs.evaluate(() => document.body.innerText).catch(() => '') : '' const qsPrints = await prints(qs) ctx.check('"Print quick slip" opens members/printslip.pl?…print=issueqslip in a new window', /members\/printslip\.pl\?borrowernumber=\d+.*print=issueqslip/.test(qsUrl), qsUrl) ctx.check('…the quick slip lists today\'s checkout (KBVSLIP1)', qsText.includes(BC) && qsText.includes(TITLE), qsText.slice(0, 300)) ctx.check('…and, with IntranetSlipPrinterJS empty, Koha calls window.print() once on load (the browser\'s print dialog)', qsPrints === 1, qsPrints) if (qs && !qs.isClosed()) { await qs.evaluate(() => window.onafterprint && window.onafterprint()).catch(() => {}) await staff.waitForTimeout(500) closedAfterPrint = qs.isClosed() } ctx.check('…and closes the window after printing (onafterprint → window.close())', closedAfterPrint, closedAfterPrint) const qsHtml = qs && !qs.isClosed() ? await qs.content() : '' // Which notice panel a checkout slip prints from: IssueSlip() asks for no transport, so GetPreparedLetter uses "email". const qRows = ctx.sql("SELECT message_transport_type FROM letter WHERE module = 'circulation' AND code = 'ISSUEQSLIP' AND branchcode = ''").map((r) => r[0]) ctx.check('the shipped ISSUEQSLIP has only an Email panel (message_transport_type email), and the quick slip above printed from it', qRows.join(',') === 'email' && qsText.includes(BC), qRows.join(',')) ctx.restore('delete the Kbverify Print panel of ISSUEQSLIP', () => ctx.sql("DELETE FROM letter WHERE module = 'circulation' AND code = 'ISSUEQSLIP' AND branchcode = '' AND message_transport_type = 'print' AND content LIKE '%KBVPRINTPANEL%'")) ctx.sql("INSERT INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('circulation', 'ISSUEQSLIP', '', 'Issue quick slip', 1, 'Issue quick slip', '

KBVPRINTPANEL

', 'print', 'default')") const wPanel = await popupOf(() => staff.evaluate((u) => { window.open(u, `kbv${Date.now()}`) }, `${ctx.STAFF}/cgi-bin/koha/members/printslip.pl?borrowernumber=${pid}&print=issueqslip`)) const panelText = wPanel ? await wPanel.evaluate(() => document.body.innerText).catch(() => '') : '' ctx.check('…a Print panel added to ISSUEQSLIP is ignored: the quick slip still prints the Email panel', !panelText.includes('KBVPRINTPANEL') && panelText.includes(BC), panelText.slice(0, 200)) if (wPanel && !wPanel.isClosed()) await wPanel.close() ctx.sql("DELETE FROM letter WHERE module = 'circulation' AND code = 'ISSUEQSLIP' AND branchcode = '' AND message_transport_type = 'print' AND content LIKE '%KBVPRINTPANEL%'") // ------------------------------------------------------------------ 3. CircAutoPrintQuickSlip const emptyBarcode = async () => { await staff.goto(circ) await staff.fill('#barcode', '') return popupOf(() => staff.locator('#barcode').press('Enter'), 5000) } for (const [val, code] of [['qslip', 'issueqslip'], ['slip', 'issueslip']]) { ctx.setPref('CircAutoPrintQuickSlip', val) const w = await emptyBarcode() ctx.check(`CircAutoPrintQuickSlip = "${val}": Enter on an empty barcode opens printslip.pl …print=${code}`, (w?.url() ?? '').includes(`print=${code}`), w?.url() ?? 'no window') if (w && !w.isClosed()) await w.close() } ctx.setPref('CircAutoPrintQuickSlip', 'clear') let w = await emptyBarcode() await staff.waitForTimeout(1000) ctx.check('CircAutoPrintQuickSlip = "clear": no window, the checkout screen is cleared (circulation.pl without the patron)', !w && /circ\/circulation\.pl$/.test(staff.url()), `${w ? w.url() : 'no window'} | ${staff.url()}`) ctx.setPref('CircAutoPrintQuickSlip', 'ignore') w = await emptyBarcode() ctx.check('CircAutoPrintQuickSlip = "ignore": nothing happens', !w && staff.url().includes(`borrowernumber=${pid}`), `${w ? w.url() : 'no window'} | ${staff.url()}`) ctx.setPref('CircAutoPrintQuickSlip', 'qslip') await staff.goto(`${ctx.STAFF}/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CircAutoPrintQuickSlip`) const prefText = await ctx.pageText(staff) const apOpts = (await staff.locator('select[name*="CircAutoPrintQuickSlip"] option').allInnerTexts()).map((o) => o.trim()) ctx.check('System preferences wording: "When an empty barcode field is submitted in circulation" … "open a print quick slip window"', prefText.includes('When an empty barcode field is submitted in circulation') && apOpts.includes('open a print quick slip window'), `${apOpts.join(', ')} | ${prefText.slice(prefText.indexOf('When an empty'), prefText.indexOf('When an empty') + 120)}`) if (SHOTS) { await annotate(staff, ['box|select[name*="CircAutoPrintQuickSlip"]']) const b = await staff.locator('select[name*="CircAutoPrintQuickSlip"]').boundingBox() await staff.screenshot({ path: join(SHOTS, 'pref-autoprint.png'), clip: { x: 215, y: Math.max(0, b.y - 120), width: 1060, height: 230 } }) await staff.evaluate(() => document.querySelectorAll('[data-kb-annotations]').forEach((e) => e.remove())) } // ------------------------------------------------------------------ 4. IntranetSlipPrinterJS const slipUrl = (code) => `${ctx.STAFF}/cgi-bin/koha/members/printslip.pl?borrowernumber=${pid}&print=${code}` const openSlip = async (code) => popupOf(() => staff.evaluate((u) => { window.open(u, `kbv${Date.now()}`) }, slipUrl(code))) ctx.setPref('IntranetSlipPrinterJS', SLIP_JS) w = await openSlip('issueqslip') const jsPrints = await prints(w) if (w && !w.isClosed()) await w.evaluate(() => window.onafterprint && window.onafterprint()).catch(() => {}) await staff.waitForTimeout(500) ctx.check('IntranetSlipPrinterJS = the article\'s value: the slip window prints once and stays open after printing', jsPrints === 1 && w && !w.isClosed(), `${jsPrints} prints, closed ${w?.isClosed()}`) if (w && !w.isClosed()) await w.close() ctx.setPref('IntranetSlipPrinterJS', 'window.kbvMarker = 1;') w = await openSlip('issueqslip') const noPrints = await prints(w) ctx.check('IntranetSlipPrinterJS with code that never calls window.print(): Koha no longer prints at all', noPrints === 0, noPrints) if (w && !w.isClosed()) await w.close() ctx.setPref('IntranetSlipPrinterJS', '') // ------------------------------------------------------------------ 5. where slip CSS goes const MARK = '#kbvmark' ctx.setPref('PrintSlipCSS', `${MARK}-printslipcss { color: red }`) ctx.setPref('AllNoticeCSS', `${MARK}-allnoticecss { color: red }`) ctx.setPref('PrintNoticeCSS', `${MARK}-printnoticecss { color: red }`) w = await openSlip('issueqslip') let html = w ? await w.content() : '' ctx.check('PrintSlipCSS does NOT reach a printed slip in 26.05 (its text is not in the slip page)', !html.includes('kbvmark-printslipcss'), html.includes('kbvmark-printslipcss')) ctx.check('…nor does AllNoticeCSS or PrintNoticeCSS (they are added to queued print/email notices, not to slips)', !html.includes('kbvmark-allnoticecss') && !html.includes('kbvmark-printnoticecss')) if (w && !w.isClosed()) await w.close() await staff.goto(`${ctx.STAFF}/cgi-bin/koha/tools/letter.pl?op=add_form&branchcode=&module=circulation&code=ISSUEQSLIP`) const letterHtml = await staff.content() ctx.check('…though the notice editor shows PrintSlipCSS under "Print slip CSS", "CSS to be applied to print slips in addition to that already in \\"All notice CSS\\"."', letterHtml.includes('kbvmark-printslipcss') && letterHtml.includes('CSS to be applied to print slips in addition to that already in "All notice CSS".') || letterHtml.includes('CSS to be applied to print slips in addition to that already in "All notice CSS".')) ctx.setPref('PrintSlipCSS', '') ctx.setPref('AllNoticeCSS', '') ctx.setPref('PrintNoticeCSS', '') // The notice's own Format CSS (letter.style), prefixed by printslip.tt. const oldStyle = ctx.sql("SELECT id, IFNULL(style, '') FROM letter WHERE module = 'circulation' AND code = 'ISSUEQSLIP' AND branchcode = ''") ctx.restore('put back the ISSUEQSLIP notice CSS', () => { for (const [id, s] of oldStyle) ctx.sql(`UPDATE letter SET style = ${s === '' ? 'NULL' : ctx.q(s)} WHERE id = ${id}`) }) ctx.sql(`UPDATE letter SET style = ${ctx.q('@page { size: 80mm 200mm; margin: 0; }\np { font-size: 11px; }')} WHERE module = 'circulation' AND code = 'ISSUEQSLIP' AND branchcode = ''`) w = await openSlip('issueqslip') html = w ? await w.content() : '' const styleTag = (html.match(/]*>([^<]*@page[^<]*)<\/style>/) ?? [])[1] ?? '' ctx.check('the notice\'s own CSS (Format tab) is on the slip, but every selector gets "#slip_issueqslip" in front: "p {" becomes "#slip_issueqslip p {"', /#slip_issueqslip\s+p \{/.test(styleTag), styleTag) ctx.check('…which turns "@page {" into "#slip_issueqslip @page {", so a page size there is ignored', styleTag.includes('#slip_issueqslip @page {'), styleTag) const pdfOf = async (page, name) => { const f = join(out, name) await page.evaluate(() => { window.onafterprint = null; window.close = () => {} }) // the slip closes itself after printing await page.emulateMedia({ media: 'print' }) await page.pdf({ path: f, preferCSSPageSize: true, printBackground: true }) return { f, info: host('pdfinfo', [f]).stdout ?? '' } } const pageSize = (info) => (info.match(/Page size:\s+([\d.]+) x ([\d.]+) pts/) ?? []).slice(1).map(Number) let pdf = w ? await pdfOf(w, 'slip-notice-css.pdf') : { info: '' } let [pw] = pageSize(pdf.info) ctx.check('…measured: printed to PDF, the page is still the default paper (612 pts = Letter), not 80 mm', pw === 612, pdf.info.match(/Page size:.*/)?.[0]) if (w && !w.isClosed()) await w.close() for (const [id, s] of oldStyle) ctx.sql(`UPDATE letter SET style = ${s === '' ? 'NULL' : ctx.q(s)} WHERE id = ${id}`) // No slip CSS: the browser's default paper. Then the article's stylesheet through PrintSlipStylesheet. w = await openSlip('issueqslip') pdf = w ? await pdfOf(w, 'slip-a4-default.pdf') : { info: '' } ;[pw] = pageSize(pdf.info) ctx.check('a slip with no slip CSS prints on the browser\'s default paper (Letter, 612 pts, in this Chromium; your printer\'s paper on a desk PC)', pw === 612, pdf.info.match(/Page size:.*/)?.[0]) if (w && !w.isClosed()) await w.close() ctx.restore('remove /local-slips', () => ctx.sh(`rm -rf ${WEBROOT}/local-slips`)) ctx.sh(`mkdir -p ${WEBROOT}/local-slips && cat > ${WEBROOT}/local-slips/slip-80mm.css <<'CSS'\n${SLIP_CSS}CSS\nchmod 755 ${WEBROOT}/local-slips; chmod 644 ${WEBROOT}/local-slips/slip-80mm.css`) const head = ctx.sh(`curl -sI '${ctx.STAFF}/local-slips/slip-80mm.css' | grep -iE '^HTTP|^Content-Type' | tr -d '\\r'`).out.trim() ctx.check('the stylesheet file is served by the staff site: curl -sI /local-slips/slip-80mm.css → 200, text/css', head.includes('200') && /text\/css/i.test(head), head) await staff.goto(`${ctx.STAFF}/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PrintSlipStylesheet`) const pssText = await ctx.pageText(staff) ctx.check('System preferences: "Include the stylesheet at … on print slips." and the button "Save all Tools preferences"', pssText.includes('Include the stylesheet at') && pssText.includes('on print slips.') && pssText.includes('Save all Tools preferences'), pssText.slice(pssText.indexOf('PrintSlipStylesheet'), pssText.indexOf('PrintSlipStylesheet') + 200)) await staff.locator('input[name*="PrintSlipStylesheet"]').first().fill('/local-slips/slip-80mm.css') await staff.locator('text=Save all Tools preferences').first().click() await staff.waitForTimeout(1500) ctx.check('entering /local-slips/slip-80mm.css and clicking "Save all Tools preferences" stores it', ctx.sqlValue("SELECT value FROM systempreferences WHERE variable = 'PrintSlipStylesheet'") === '/local-slips/slip-80mm.css') w = await openSlip('issueqslip') html = w ? await w.content() : '' ctx.check('PrintSlipStylesheet = /local-slips/slip-80mm.css: the slip page links it ()', html.includes('href="/local-slips/slip-80mm.css"')) pdf = w ? await pdfOf(w, 'slip-80mm.pdf') : { info: '' } const [pw80, ph80] = pageSize(pdf.info) ctx.check('…measured: printed to PDF, the page is 80 mm wide by 200 mm (227 x 567 pts; 80 mm = 226.8 pts, Chromium rounds to whole pixels)', Math.abs(pw80 - 226.77) < 0.5 && Math.abs(ph80 - 566.93) < 0.5, pdf.info.match(/Page size:.*/)?.[0]) const txt80 = host('pdftotext', ['-layout', pdf.f, '-']).stdout ?? '' ctx.check('…and the slip text is all on the 80 mm page (the barcode and title are in the PDF text)', txt80.includes(BC) && txt80.includes(TITLE), txt80.slice(0, 300)) if (w && !w.isClosed()) await w.close() // The recipe most web pages give, "size: 80mm auto", is not valid CSS for size: Chromium ignores the whole rule. ctx.sh(`sed -i 's/size: 80mm 200mm;/size: 80mm auto;/' ${WEBROOT}/local-slips/slip-80mm.css`) w = await openSlip('issueqslip') pdf = w ? await pdfOf(w, 'slip-80mm-auto.pdf') : { info: '' } ;[pw] = pageSize(pdf.info) ctx.check('"size: 80mm auto" (the common web recipe) is ignored: the page falls back to the default paper (612 pts)', pw === 612, pdf.info.match(/Page size:.*/)?.[0]) if (w && !w.isClosed()) await w.close() ctx.sh(`sed -i 's/size: 80mm auto;/size: 80mm 200mm;/' ${WEBROOT}/local-slips/slip-80mm.css`) w = await openSlip('issueslip') html = w ? await w.content() : '' ctx.check('…the same link is on the full checkout slip ("Print slip")', html.includes('href="/local-slips/slip-80mm.css"'), `${w?.url() ?? 'no window'} ${html.length}`) if (w && !w.isClosed()) await w.close() w = await popupOf(() => staff.evaluate((u) => { window.open(u, `kbv${Date.now()}`) }, `${ctx.STAFF}/cgi-bin/koha/circ/transfer-slip.pl?transferitem=${itemnumber}&branchcode=MPL&op=slip`)) html = w ? await w.content() : '' ctx.check('…and on the transfer slip (circ/transfer-slip.pl, the same circ/printslip.tt page)', html.includes('href="/local-slips/slip-80mm.css"') && html.includes('circ_printslip')) if (w && !w.isClosed()) await w.close() // Payment and fee receipts: a different page that does not load PrintSlipStylesheet. const debitId = perl(`${env} use Koha::Patrons; my $d = Koha::Patrons->find(${pid})->account->add_debit({ amount => 1.5, type => 'MANUAL', interface => 'intranet', description => 'Kbverify slip test fee', library_id => 'CPL' }); print $d->id, "\\n";`) w = await popupOf(() => staff.evaluate((u) => { window.open(u, `kbv${Date.now()}`) }, `${ctx.STAFF}/cgi-bin/koha/members/printinvoice.pl?accountlines_id=${debitId}&borrowernumber=${pid}`)) html = w ? await w.content() : '' ctx.check('a fee receipt (members/printinvoice.pl, notice ACCOUNT_DEBIT) does NOT load PrintSlipStylesheet', html.includes('printreceiptinvoice') && !html.includes('/local-slips/slip-80mm.css'), `${html.includes('printreceiptinvoice')} ${html.includes('/local-slips/')}`) if (w && !w.isClosed()) await w.close() const oldDebitStyle = ctx.sql("SELECT id, IFNULL(style, '') FROM letter WHERE code = 'ACCOUNT_DEBIT' AND branchcode = '' AND message_transport_type = 'print'") ctx.restore('put back the ACCOUNT_DEBIT notice CSS', () => { for (const [id, s] of oldDebitStyle) ctx.sql(`UPDATE letter SET style = ${s === '' ? 'NULL' : ctx.q(s)} WHERE id = ${id}`) }) ctx.sql(`UPDATE letter SET style = ${ctx.q('@page { size: 80mm 200mm; margin: 0; }')} WHERE code = 'ACCOUNT_DEBIT' AND branchcode = '' AND message_transport_type = 'print'`) w = await popupOf(() => staff.evaluate((u) => { window.open(u, `kbv${Date.now()}`) }, `${ctx.STAFF}/cgi-bin/koha/members/printinvoice.pl?accountlines_id=${debitId}&borrowernumber=${pid}`)) pdf = w ? await pdfOf(w, 'invoice-80mm.pdf') : { info: '' } ;[pw] = pageSize(pdf.info) ctx.check('…but its notice CSS is used as written (not prefixed): @page there prints the fee receipt 80 mm wide', Math.abs(pw - 226.77) < 0.5, pdf.info.match(/Page size:.*/)?.[0]) if (w && !w.isClosed()) await w.close() for (const [id, s] of oldDebitStyle) ctx.sql(`UPDATE letter SET style = ${s === '' ? 'NULL' : ctx.q(s)} WHERE id = ${id}`) // Side-by-side picture of the same quick slip at 80 mm and on a page printer. if (SHOTS) { host('pdftoppm', ['-png', '-r', '110', '-singlefile', join(out, 'slip-80mm.pdf'), join(out, 'p80')]) host('pdftoppm', ['-png', '-r', '110', '-singlefile', join(out, 'slip-a4-default.pdf'), join(out, 'pa4')]) } void qsHtml // ------------------------------------------------------------------ the server: where the file goes (plan212) await serverPart(ctx) // ------------------------------------------------------------------ Linux desk PC: CUPS (throwaway box) if (host('docker', ['image', 'inspect', SYSTEMD_IMG]).status !== 0) { ctx.check(`image ${SYSTEMD_IMG} present`, false) return } host('docker', ['rm', '-f', BOX]) ctx.restore('remove the Ubuntu box', () => host('docker', ['rm', '-f', BOX])) host('docker', ['run', '-d', '--privileged', '--cgroupns=host', '-v', '/sys/fs/cgroup:/sys/fs/cgroup:rw', '--name', BOX, SYSTEMD_IMG, '/lib/systemd/systemd']) const box = (cmd) => { const r = host('docker', ['exec', BOX, 'bash', '-c', cmd]) return `${r.stdout ?? ''}${r.stderr ?? ''}`.trim() } for (let i = 0; i < 30 && !/running|degraded/.test(box('systemctl is-system-running 2>/dev/null')); i++) await new Promise((r) => setTimeout(r, 1000)) box('apt-get update -qq >/dev/null 2>&1; DEBIAN_FRONTEND=noninteractive apt-get install -y -qq cups >/dev/null 2>&1; systemctl enable --now cups >/dev/null 2>&1') for (let i = 0; i < 30 && box('systemctl is-active cups') !== 'active'; i++) await new Promise((r) => setTimeout(r, 1000)) writeFileSync(join(out, 'cups.txt'), '') const steps = { active: box('systemctl is-active cups'), add: box('lpadmin -p Receipt80 -E -v socket://192.0.2.50:9100 -m raw; echo "exit $?"'), def: box('lpoptions -d Receipt80'), stat: box('lpstat -d'), list: box('lpstat -p'), remove: box('lpadmin -x Receipt80; echo "exit $?"; lpstat -d'), os: box('grep PRETTY_NAME /etc/os-release; dpkg-query -W cups'), } writeFileSync(join(out, 'cups.txt'), JSON.stringify(steps, null, 2)) ctx.check('(box) systemctl is-active cups → active', steps.active === 'active', steps.active) ctx.check('(box, set-up only: a stand-in queue, not shown) lpadmin adds a printer named Receipt80', steps.add.startsWith('exit 0'), steps.add) ctx.check('(box) lpstat -p lists the printer: "printer Receipt80 is idle. enabled since …"', /^printer Receipt80 is idle\. enabled since /.test(steps.list), steps.list) ctx.check('(box) lpoptions -d Receipt80 makes it the default and prints its options (copies=1 device-uri=… printer-info=Receipt80 …)', steps.def.startsWith('copies=1 device-uri=') && steps.def.includes('printer-info=Receipt80'), steps.def) ctx.check('(box) lpstat -d → "system default destination: Receipt80"', steps.stat === 'system default destination: Receipt80', steps.stat) ctx.check('(box) lpadmin -x Receipt80 removes it again', steps.remove.startsWith('exit 0'), steps.remove) ctx.check('(box) Ubuntu 24.04 with CUPS', steps.os.includes('Ubuntu 24.04'), steps.os) } /** * On a real server (plan212, 2026-11-08): a fresh Ubuntu 24.04 with Koha installed as our installation guide leaves * it, as the sudo user `librarian` over SSH. The article's step 3 commands, the file written with the article's own * text (SLIP_CSS), the staff site serving it through the reader's own Apache vhost (port 8080), dpkg -S, and the undo. * Replaces the throwaway kbv-koha-ubuntu package box used on 2026-11-07 (same claims; that proof stays in proofs.json). */ async function serverPart(ctx) { const err = ensureKohaImage() ?? createBox({ image: KOHA_IMAGE }) ctx.check('server: the box starts with Koha installed', err === null, err ?? '') if (err) return try { const L = (cmd) => ssh('librarian', cmd).replace(/\s+$/, '') await new Promise((r) => setTimeout(r, 10000)) const DIR = '/usr/share/koha/intranet/htdocs/local-slips' const mk = L(`sudo mkdir -p ${DIR}; echo "exit=$?"`) ctx.check('server: sudo mkdir -p /usr/share/koha/intranet/htdocs/local-slips prints nothing', mk === 'exit=0', mk) // the reader pastes into nano; the check writes the same text with tee L(`echo ${Buffer.from(SLIP_CSS).toString('base64')} | base64 -d | sudo tee ${DIR}/slip-80mm.css >/dev/null`) const ls = L(`ls ${DIR}`) ctx.check('server: ls …/local-slips → "slip-80mm.css"', ls === 'slip-80mm.css', ls) const same = L(`sha256sum ${DIR}/slip-80mm.css | cut -c1-64`) ctx.check('server: the file holds exactly the article\'s stylesheet', same === createHash('sha256').update(SLIP_CSS).digest('hex'), same) const head = L(`curl -sI -H 'Host: library-intra.example.org' http://127.0.0.1:8080/local-slips/slip-80mm.css | grep -iE "^HTTP|^Content-Type"`) ctx.check('server: the staff site (port 8080) serves it: "HTTP/1.1 200 OK" / "Content-Type: text/css"', head === 'HTTP/1.1 200 OK\nContent-Type: text/css', head) const own = L(`dpkg -S ${DIR}; dpkg -S /usr/share/koha/intranet/htdocs/intranet-tmpl/prog/css/print.css`) ctx.check('server: dpkg -S …/local-slips → "dpkg-query: no path found matching pattern …" (an upgrade leaves it); Koha\'s own print.css belongs to koha-common', own.includes(`dpkg-query: no path found matching pattern ${DIR}`) && own.includes('koha-common: /usr/share/koha/intranet/htdocs/intranet-tmpl/prog/css/print.css'), own) const rm = L(`sudo rm -r ${DIR}; echo "exit=$?"; ls ${DIR} 2>&1`) ctx.check('server: undo, sudo rm -r …/local-slips, prints nothing and the folder is gone', /^exit=0\nls: cannot access '\/usr\/share\/koha\/intranet\/htdocs\/local-slips': No such file or directory$/.test(rm), rm) } finally { removeBox() } }