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 += headers[k] + ":  " + data[i][k] + "<br>";
        }
        string += "<hr>";
    }

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

    return string;
}

function getCheckIns() {
    var table = document.getElementById("checkedintable");
    if (table !== null) {
        printWindow = window.open("");
        printWindow.document.write(getRow(table));
        printWindow.print();
        printWindow.close();
    }
}

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

@@ -1767,24 +1767,26 @@
 %3C f; k++) %7B%0A
+//
             
@@ -1833,24 +1833,89 @@
 %5D + %22%3Cbr%3E%22;%0A
+            string += getRequiredFields(headers%5Bk%5D, data%5Bi%5D%5Bk%5D);%0A
         %7D%0A  
@@ -2035,144 +2035,407 @@
  get
-CheckIns() %7B%0A    var table = document.getElementById(%22checkedintable%22);%0A    if (table !== null) %7B%0A        printWindow = window.open(%22%22);
+RequiredFields(header, data) %7B%0A    var ret = %22%22;%0A    switch (header) %7B%0A        case %22Tittel%22:%0A        case %22Strekkode%22:%0A            ret = header + %22:  %22 + data + %22%3Cbr%3E%22;%0A            break;%0A        default:%0A            break;%0A    %7D%0A    return ret;%0A%7D%0A%0Afunction getCheckIns() %7B%0A    var tables = %5B%22checkedintable%22, %22rfiditems%22%5D;%0A%0A    printWindow = window.open(%22%22);%0A%0A    tables.forEach(function (table) %7B
 %0A   
@@ -2477,21 +2477,51 @@
 Row(
+document.getElementById(
 table))
-;
+);%0A
 %0A    
+%7D);%0A
     
@@ -2541,28 +2541,24 @@
 rint();%0A    
-   
- 
 printWindow.
@@ -2566,22 +2566,16 @@
 lose();%0A
-    %7D%0A
 %7D%0A%0Aif (w

Add support for materials returned with RFID