function getGitref() {
    nw = window.open("");
    nw.document.write("GITREF: __REVISION__");
    return 0;
}

function leadingZero(number) {
    var retval = number;
    if (number < 10) {
        retval = '0' + number;
    }
    return retval;
}

function now() {
    var today = new Date();

    return leadingZero(today.getDate())
        + '.' + leadingZero(today.getMonth() + 1)
        + '.' + leadingZero(today.getFullYear())
        + " " + leadingZero(today.getHours())
        + ":" + leadingZero(today.getMinutes())
        + ":" + leadingZero(today.getSeconds());
}

function getHeader() {
    return "<!DOCTYPE html><html><head></head><body>"
        + "DEICHMANSKE BIBLIOTEK<br>"
        + "Tlf: 23432900<br>"
        + "postmottak.deichman@oslo.kommune.no<br>"
        + "Kvittering på innlevert materiale<br>"
        + now() + "<br>"
        + "&nbsp;<br><hr>";
}

function getInner(contents) {
    var retval;
    if (contents.firstChild === null) {
        retval = "";
    } else if (contents.firstChild.nodeType !== Node.TEXT_NODE) {
        retval = contents.firstChild.innerText;
    } else {
        retval = contents.innerText.trim();
    }
    return retval;
}

function getRow(table) {
    var data = [];
    var headers = [];

    for (var r = 0, n = table.rows.length; r < n; r++) {
        var rowdata = [];

        for (var c = 0, m = table.rows[r].cells.length; c < m; c++) {
            var contents = table.rows[r].cells[c];
            rowdata[c] = getInner(contents);
        }

        if (r === 0) {
            headers = rowdata;
        } else {
            data[r] = rowdata;
        }
    }

    var string = getHeader();

    for (var i = 1, l = data.length; i < l; i++) {
        for (var k = 0, f = data[i].length; k < f; k++) {
            string += getRequiredFields(headers[k], data[i][k]);
        }
        string += "<hr>";
    }

    string += "&nbsp;<br>&nbsp;<br><body></html>";

    return string;
}

function getRequiredFields(header, data) {
    var ret = "";
    switch (header) {
        case "Tittel":
        case "Strekkode":
            ret = header + ":  " + data + "<br>";
            break;
        default:
            break;
    }
    return ret;
}

function getCheckIns() {
    var tables = ["checkedintable", "rfiditems"];
    var returnedItems = "";

    tables.forEach(function (table) {
        var currentTable = document.getElementById(table);
        if (currentTable !== null) {
            returnedItems += getRow(currentTable);
        }
    });

    printWindow = window.open("");
    printWindow.document.write(returnedItems);
    printWindow.print();
    printWindow.close();
}

if (window.location.href.toLowerCase().indexOf("gitref") > -1) {
    getGitref();
} else {
    getCheckIns();
}

@@ -1648,27 +1648,18 @@
 tring = 
-getHeader()
+%22%22
 ;%0A%0A    f
@@ -2522,39 +2522,128 @@
     
-printWindow = window.open(%22%22);%0A
+if (returnedItems !== %22%22) %7B%0A        printWindow = window.open(%22%22);%0A        printWindow.document.write(getHeader());%0A    
     
@@ -2685,24 +2685,28 @@
 Items);%0A    
+  
+  
 printWindow.
@@ -2710,24 +2710,28 @@
 ow.print();%0A
+    
     printWin
@@ -2743,16 +2743,22 @@
 lose();%0A
+    %7D%0A
 %7D%0A%0Aif (w

Fix repeating header and stop on empty error